We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexSuggestions & BugsSoftware Bugs › Bug 110:ArrayIndexOutOfBoundsException. Fixed?Not!
Page Index Toggle Pages: 1
Bug 110:ArrayIndexOutOfBoundsException. Fixed?Not! (Read 1274 times)
Bug 110:ArrayIndexOutOfBoundsException. Fixed?Not!
Feb 21st, 2007, 11:56am
 
Try to autoformat this code under Processing 124 Mac OS X Macbook Intel Core Duo 1, with 1gb ram. you'd get a arrayindexoutofbounds exception. but if you comment it out, it formats fine. I went to the bug database. Apparently it is reported has fixed, but it doesn't appear so.
Code:


class SFunit
{
int tx,ty,hp,ap,sp,te,exists,ut,side,ai,player,tp;
int lastfired=0;
int lparticle=0;
int cweapon=0;
int pcharn=0;
int firing=0;
float vx,vy,accelerating,deg,x,y;
String name,description,utype;
SFunit(float a,float b, int c, int d, int e, int f, int g, int h,int i, String A, String B, String C)
{
x=a;
y=b;
hp=c;
ap=d;
sp=e;
exists=f;
side=g;
ai=h;
player=i;
name=A;
description=B;
utype=C;
deg=0;
te=-1;//t unit
tp=-1;//t planet
//match ut.
for (int gg=0; gg<20;gg++)
{
if (utype.equals(unittype[gg].name))
{
ut=gg;
break;
}
}
}
void update(int sx,int sy)
{

if (this.deg>=360)
{
this.deg=this.deg%360;
}
if (this.deg<0)
{
this.deg=360+this.deg;
}

this.vx=this.vx+accelerating*sin(PI*deg/180)*unittype[ut].acc;
this.vy=this.vy+accelerating*cos(PI*deg/180)*unittype[ut].acc;
this.x+=this.vx;
this.y+=this.vy;

if (this.firing==1)
{
for (int gg=0; gg<52; gg++)
{
//get the currently selected weapon and match its char to the one defined in the ship's type.
if (unittype[this.ut].wstring.charAt(this.cweapon)==weapon[gg].weaponchar)
{
if ((millis()>this.lastfired+weapon[gg].delaybetweenstring || this.pcharn!=0))
{//check delays
if ((millis()>this.lparticle+weapon[gg].delaybetweenparticle && this.pcharn!=0) || (millis()>this.lastfired+weapon[gg].delaybetweenstring) )
{
if (millis()>this.lastfired+weapon[gg].delaybetweenstring) this.lastfired=millis();
this.pcharn=this.pcharn+1;
if (this.pcharn>4)
{
this.pcharn=0; //nth bullet in series
}
this.lparticle=millis();
for (int kk=0;kk<52;kk++)
{
//find the particle type defined in the weapon string, which is the current 'bullet' to be shot in the weapon string.
// a weapon string is a series of bullets of any type.
if (particletype[kk].Pchar==weapon[gg].particlestring.charAt(this.pcharn))
{
for (int ii=0;ii<1000;ii++)
{
//find an empty particle space
if (particle[ii].exists==0 && particletype[kk].Pchar!='_')
{
//place particle
particle[ii]=new SFparticle(0,millis(),0,1,1,this.x,this.y,this.vx+sin(PI*this.deg/180)*particletype[particle[ii].pt].initv,this.vy+cos(PI*this.deg/180)*particletype[particle[ii].pt].initv,0,deg,"bullet",str(random(0,1000000)));
break;
}
}
break;
}
}
}
}
break;
}
}
}
}

void ai()
{
}

}

Re: Bug 110:ArrayIndexOutOfBoundsException. Fixed?
Reply #1 - Feb 21st, 2007, 12:03pm
 
I have realised it happens only if I have 11 or more braces...
Re: Bug 110:ArrayIndexOutOfBoundsException. Fixed?
Reply #2 - Apr 20th, 2007, 2:30pm
 
despite your enthusiasm, that's a different bug. please file it in the bugs database if you'd like to see it fixed.
Page Index Toggle Pages: 1