TPT: Put ifs into switch in create_part
This commit is contained in:
parent
5ec6223065
commit
ef777b92dc
@ -2546,7 +2546,10 @@ int Simulation::create_part(int p, int x, int y, int tv)//the function for creat
|
||||
parts[i].tmp = 0;
|
||||
parts[i].tmp2 = 0;
|
||||
}
|
||||
if (t==PT_LIGH && p==-2)
|
||||
switch (t)
|
||||
{
|
||||
case PT_LIGH:
|
||||
if (p==-2)
|
||||
{
|
||||
switch (gravityMode)
|
||||
{
|
||||
@ -2558,106 +2561,172 @@ int Simulation::create_part(int p, int x, int y, int tv)//the function for creat
|
||||
parts[i].tmp = rand()%360;
|
||||
break;
|
||||
case 2:
|
||||
parts[i].tmp = atan2(x-XCNTR, y-YCNTR)*(180.0f/M_PI)+90;
|
||||
break;
|
||||
parts[i].tmp = atan2(float( x-XCNTR), float(y-YCNTR))*(180.0f/M_PI)+90;
|
||||
}
|
||||
parts[i].tmp2 = 4;
|
||||
}
|
||||
if (t==PT_SOAP)
|
||||
{
|
||||
break;
|
||||
case PT_SOAP:
|
||||
parts[i].tmp = -1;
|
||||
parts[i].tmp2 = -1;
|
||||
}
|
||||
//now set various properties that we want at spawn.
|
||||
if (t==PT_ACID || t==PT_CAUS)
|
||||
{
|
||||
break;
|
||||
case PT_ACID: case PT_CAUS:
|
||||
parts[i].life = 75;
|
||||
}
|
||||
break;
|
||||
/*Testing
|
||||
if(t==PT_WOOD){
|
||||
case PT_WOOD:
|
||||
parts[i].life = 150;
|
||||
}
|
||||
break;
|
||||
End Testing*/
|
||||
if (t==PT_WARP) {
|
||||
case PT_WARP:
|
||||
parts[i].life = rand()%95+70;
|
||||
}
|
||||
if (t==PT_FUSE) {
|
||||
break;
|
||||
case PT_FUSE:
|
||||
parts[i].life = 50;
|
||||
parts[i].tmp = 50;
|
||||
}
|
||||
/*if (elements[t].Properties&PROP_LIFE) {
|
||||
int r;
|
||||
for (r = 0; r<NGOL; r++)
|
||||
if (t==goltype[r])
|
||||
parts[i].tmp = grule[r+1][9] - 1;
|
||||
}*/
|
||||
if (t==PT_LIFE && v<NGOLALT)
|
||||
break;
|
||||
case PT_LIFE:
|
||||
if (v<NGOLALT)
|
||||
{
|
||||
parts[i].tmp = grule[v+1][9] - 1;
|
||||
parts[i].ctype = v;
|
||||
}
|
||||
if (t==PT_TRON)
|
||||
{
|
||||
int randhue = rand()%360;
|
||||
int randomdir = rand()%4;
|
||||
parts[i].tmp = 1|(randomdir<<5)|(randhue<<7);//set as a head and a direction
|
||||
parts[i].tmp2 = 4;//tail
|
||||
parts[i].life = 5;
|
||||
}
|
||||
if (t==PT_DEUT)
|
||||
break;
|
||||
case PT_DEUT:
|
||||
parts[i].life = 10;
|
||||
if (t==PT_MERC)
|
||||
break;
|
||||
case PT_MERC:
|
||||
parts[i].tmp = 10;
|
||||
if (t==PT_BRAY)
|
||||
break;
|
||||
case PT_BRAY:
|
||||
parts[i].life = 30;
|
||||
if (t==PT_PUMP || t==PT_GPMP)
|
||||
parts[i].life= 10;
|
||||
if (t==PT_SING)
|
||||
break;
|
||||
case PT_GPMP: case PT_PUMP:
|
||||
parts[i].life = 10;
|
||||
break;
|
||||
case PT_SING:
|
||||
parts[i].life = rand()%50+60;
|
||||
if (t==PT_QRTZ)
|
||||
break;
|
||||
case PT_QRTZ:
|
||||
parts[i].tmp = (rand()%11);
|
||||
if (t==PT_PQRT)
|
||||
break;
|
||||
case PT_PQRT:
|
||||
parts[i].tmp = (rand()%11);
|
||||
if (t==PT_CLST)
|
||||
break;
|
||||
case PT_CLST:
|
||||
parts[i].tmp = (rand()%7);
|
||||
if (t==PT_FSEP)
|
||||
break;
|
||||
case PT_FSEP:
|
||||
parts[i].life = 50;
|
||||
if (t==PT_COAL) {
|
||||
break;
|
||||
case PT_COAL:
|
||||
parts[i].life = 110;
|
||||
parts[i].tmp = 50;
|
||||
}
|
||||
if (t==PT_IGNT) {
|
||||
break;
|
||||
case PT_IGNT:
|
||||
parts[i].life = 3;
|
||||
}
|
||||
if (t==PT_FRZW)
|
||||
break;
|
||||
case PT_FRZW:
|
||||
parts[i].life = 100;
|
||||
if (t==PT_PIPE)
|
||||
break;
|
||||
case PT_PIPE:
|
||||
parts[i].life = 60;
|
||||
if (t==PT_BCOL)
|
||||
break;
|
||||
case PT_BCOL:
|
||||
parts[i].life = 110;
|
||||
if (t==PT_FIRE)
|
||||
break;
|
||||
case PT_FIRE:
|
||||
parts[i].life = rand()%50+120;
|
||||
if (t==PT_PLSM)
|
||||
break;
|
||||
case PT_PLSM:
|
||||
parts[i].life = rand()%150+50;
|
||||
if (t==PT_HFLM)
|
||||
break;
|
||||
case PT_HFLM:
|
||||
parts[i].life = rand()%150+50;
|
||||
if (t==PT_LAVA)
|
||||
break;
|
||||
case PT_LAVA:
|
||||
parts[i].life = rand()%120+240;
|
||||
if (t==PT_NBLE)
|
||||
break;
|
||||
case PT_NBLE:
|
||||
parts[i].life = 0;
|
||||
if (t==PT_ICEI)
|
||||
break;
|
||||
case PT_ICEI:
|
||||
parts[i].ctype = PT_WATR;
|
||||
if (t==PT_NEUT)
|
||||
{
|
||||
float r = (rand()%128+128)/127.0f;
|
||||
float a = (rand()%360)*3.14159f/180.0f;
|
||||
parts[i].life = rand()%480+480;
|
||||
parts[i].vx = r*cosf(a);
|
||||
parts[i].vy = r*sinf(a);
|
||||
}
|
||||
if (t==PT_MORT)
|
||||
{
|
||||
break;
|
||||
case PT_MORT:
|
||||
parts[i].vx = 2;
|
||||
break;
|
||||
case PT_STKM:
|
||||
if (player.spwn==0)
|
||||
{
|
||||
parts[i].x = (float)x;
|
||||
parts[i].y = (float)y;
|
||||
parts[i].type = PT_STKM;
|
||||
parts[i].vx = 0;
|
||||
parts[i].vy = 0;
|
||||
parts[i].life = 100;
|
||||
parts[i].ctype = 0;
|
||||
parts[i].temp = elements[t].Temperature;
|
||||
Element_STKM::STKM_init_legs(this, &player, i);
|
||||
player.spwn = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
create_part(-1,x,y,PT_SPAWN);
|
||||
elementCount[PT_SPAWN] = 1;
|
||||
break;
|
||||
case PT_STKM2:
|
||||
if (player2.spwn==0)
|
||||
{
|
||||
parts[i].x = (float)x;
|
||||
parts[i].y = (float)y;
|
||||
parts[i].type = PT_STKM2;
|
||||
parts[i].vx = 0;
|
||||
parts[i].vy = 0;
|
||||
parts[i].life = 100;
|
||||
parts[i].ctype = 0;
|
||||
parts[i].temp = elements[t].Temperature;
|
||||
Element_STKM::STKM_init_legs(this, &player2, i);
|
||||
player2.spwn = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
create_part(-1,x,y,PT_SPAWN2);
|
||||
elementCount[PT_SPAWN2] = 1;
|
||||
break;
|
||||
case PT_FIGH:
|
||||
break;
|
||||
case PT_BIZR: case PT_BIZRG: case PT_BIZRS:
|
||||
parts[i].ctype = 0x47FFFF;
|
||||
break;
|
||||
default:
|
||||
if (t==PT_FIGH)
|
||||
{
|
||||
unsigned char fcount = 0;
|
||||
while (fcount < 100 && fcount < (fighcount+1) && fighters[fcount].spwn==1) fcount++;
|
||||
if (fcount < 100 && fighters[fcount].spwn==0)
|
||||
{
|
||||
parts[i].x = (float)x;
|
||||
parts[i].y = (float)y;
|
||||
parts[i].type = PT_FIGH;
|
||||
parts[i].vx = 0;
|
||||
parts[i].vy = 0;
|
||||
parts[i].life = 100;
|
||||
parts[i].ctype = 0;
|
||||
parts[i].tmp = fcount;
|
||||
parts[i].temp = elements[t].Temperature;
|
||||
Element_STKM::STKM_init_legs(this, &fighters[fcount], i);
|
||||
fighters[fcount].spwn = 1;
|
||||
fighters[fcount].elem = PT_DUST;
|
||||
fighcount++;
|
||||
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
if (t==PT_PHOT)
|
||||
{
|
||||
@ -2674,74 +2743,24 @@ int Simulation::create_part(int p, int x, int y, int tv)//the function for creat
|
||||
parts[i].vx = 2.0f*cosf(a);
|
||||
parts[i].vy = 2.0f*sinf(a);
|
||||
}
|
||||
if (t==PT_STKM)
|
||||
if (t==PT_NEUT)
|
||||
{
|
||||
if (player.spwn==0)
|
||||
float r = (rand()%128+128)/127.0f;
|
||||
float a = (rand()%360)*3.14159f/180.0f;
|
||||
parts[i].life = rand()%480+480;
|
||||
parts[i].vx = r*cosf(a);
|
||||
parts[i].vy = r*sinf(a);
|
||||
}
|
||||
if (t==PT_TRON)
|
||||
{
|
||||
parts[i].x = (float)x;
|
||||
parts[i].y = (float)y;
|
||||
parts[i].type = PT_STKM;
|
||||
parts[i].vx = 0;
|
||||
parts[i].vy = 0;
|
||||
parts[i].life = 100;
|
||||
parts[i].ctype = 0;
|
||||
parts[i].temp = elements[t].Temperature;
|
||||
//STKM_init_legs(this, &player, i);
|
||||
player.spwn = 1;
|
||||
int randhue = rand()%360;
|
||||
int randomdir = rand()%4;
|
||||
parts[i].tmp = 1|(randomdir<<5)|(randhue<<7);//set as a head and a direction
|
||||
parts[i].tmp2 = 4;//tail
|
||||
parts[i].life = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
create_part(-1,x,y,PT_SPAWN);
|
||||
}
|
||||
if (t==PT_STKM2)
|
||||
{
|
||||
if (player2.spwn==0)
|
||||
{
|
||||
parts[i].x = (float)x;
|
||||
parts[i].y = (float)y;
|
||||
parts[i].type = PT_STKM2;
|
||||
parts[i].vx = 0;
|
||||
parts[i].vy = 0;
|
||||
parts[i].life = 100;
|
||||
parts[i].ctype = 0;
|
||||
parts[i].temp = elements[t].Temperature;
|
||||
//STKM_init_legs(this, &player2, i);
|
||||
player2.spwn = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
create_part(-1,x,y,PT_SPAWN2);
|
||||
}
|
||||
if (t==PT_FIGH)
|
||||
{
|
||||
unsigned char fcount = 0;
|
||||
while (fcount < 100 && fcount < (fighcount+1) && fighters[fcount].spwn==1) fcount++;
|
||||
if (fcount < 100 && fighters[fcount].spwn==0)
|
||||
{
|
||||
parts[i].x = (float)x;
|
||||
parts[i].y = (float)y;
|
||||
parts[i].type = PT_FIGH;
|
||||
parts[i].vx = 0;
|
||||
parts[i].vy = 0;
|
||||
parts[i].life = 100;
|
||||
parts[i].ctype = 0;
|
||||
parts[i].tmp = fcount;
|
||||
parts[i].temp = elements[t].Temperature;
|
||||
//STKM_init_legs(this, &fighters[fcount], i);
|
||||
fighters[fcount].spwn = 1;
|
||||
fighters[fcount].elem = PT_DUST;
|
||||
fighcount++;
|
||||
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
if (t==PT_BIZR||t==PT_BIZRG||t==PT_BIZRS)
|
||||
parts[i].ctype = 0x47FFFF;
|
||||
//and finally set the pmap/photon maps to the newly created particle
|
||||
if (elements[t].Properties & TYPE_ENERGY)
|
||||
photons[y][x] = t|(i<<8);
|
||||
|
@ -46,8 +46,8 @@ Element_SOAP::Element_SOAP()
|
||||
Graphics = NULL;
|
||||
}
|
||||
|
||||
//#TPT-Directive ElementHeader Element_SOAP static int attach(Particle * parts, int i1, int i2)
|
||||
void attach(Particle * parts, int i1, int i2)
|
||||
//#TPT-Directive ElementHeader Element_SOAP static void attach(Particle * parts, int i1, int i2)
|
||||
void Element_SOAP::attach(Particle * parts, int i1, int i2)
|
||||
{
|
||||
if (!(parts[i2].ctype&4))
|
||||
{
|
||||
|
Reference in New Issue
Block a user