also fix SOAP changing .ctype of particles it thinks it's attached to
This commit is contained in:
parent
ecf1f0e391
commit
20a7d0528b
@ -2578,24 +2578,6 @@ int Simulation::get_normal_interp(int pt, float x0, float y0, float dx, float dy
|
||||
return get_normal(pt, x, y, dx, dy, nx, ny);
|
||||
}
|
||||
|
||||
//For soap only
|
||||
void Simulation::detach(int i)
|
||||
{
|
||||
if ((parts[i].ctype&2) == 2)
|
||||
{
|
||||
if ((parts[parts[i].tmp].ctype&4) == 4)
|
||||
parts[parts[i].tmp].ctype ^= 4;
|
||||
}
|
||||
|
||||
if ((parts[i].ctype&4) == 4)
|
||||
{
|
||||
if ((parts[parts[i].tmp2].ctype&2) == 2)
|
||||
parts[parts[i].tmp2].ctype ^= 2;
|
||||
}
|
||||
|
||||
parts[i].ctype = 0;
|
||||
}
|
||||
|
||||
void Simulation::kill_part(int i)//kills particle number i
|
||||
{
|
||||
int x = (int)(parts[i].x+0.5f);
|
||||
@ -2627,7 +2609,7 @@ void Simulation::kill_part(int i)//kills particle number i
|
||||
}
|
||||
else if (parts[i].type == PT_SOAP)
|
||||
{
|
||||
detach(i);
|
||||
Element_SOAP::detach(this, i);
|
||||
}
|
||||
|
||||
parts[i].type = PT_NONE;
|
||||
@ -2657,7 +2639,7 @@ void Simulation::part_change_type(int i, int x, int y, int t)//changes the type
|
||||
fighcount--;
|
||||
}
|
||||
else if (parts[i].type == PT_SOAP)
|
||||
detach(i);
|
||||
Element_SOAP::detach(this, i);
|
||||
|
||||
parts[i].type = t;
|
||||
if (elements[t].Properties & TYPE_ENERGY)
|
||||
@ -2827,7 +2809,7 @@ int Simulation::create_part(int p, int x, int y, int tv)
|
||||
}
|
||||
else if (parts[p].type == PT_SOAP)
|
||||
{
|
||||
detach(p);
|
||||
Element_SOAP::detach(this, p);
|
||||
}
|
||||
i = p;
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS)
|
||||
else if ((parts[i].tmp&0xFF) == 0 && (sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)))
|
||||
{
|
||||
if ((r&0xFF)==PT_SOAP)
|
||||
sim->detach(r>>8);
|
||||
Element_SOAP::detach(sim, r>>8);
|
||||
transfer_part_to_pipe(parts+(r>>8), parts+i);
|
||||
sim->kill_part(r>>8);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ int Element_PRTI::update(UPDATE_FUNC_ARGS)
|
||||
continue;// Handling these is a bit more complicated, and is done in STKM_interact()
|
||||
|
||||
if ((r&0xFF) == PT_SOAP)
|
||||
sim->detach(r>>8);
|
||||
Element_SOAP::detach(sim, r>>8);
|
||||
|
||||
for ( nnx=0; nnx<80; nnx++)
|
||||
if (!sim->portalp[parts[i].tmp][count][nnx].type)
|
||||
|
@ -47,6 +47,24 @@ Element_SOAP::Element_SOAP()
|
||||
|
||||
}
|
||||
|
||||
//#TPT-Directive ElementHeader Element_SOAP static void detach(Simulation * sim, int i)
|
||||
void Element_SOAP::detach(Simulation * sim, int i)
|
||||
{
|
||||
if ((sim->parts[i].ctype&2) == 2 && sim->parts[sim->parts[i].tmp].type == PT_SOAP)
|
||||
{
|
||||
if ((sim->parts[sim->parts[i].tmp].ctype&4) == 4)
|
||||
sim->parts[sim->parts[i].tmp].ctype ^= 4;
|
||||
}
|
||||
|
||||
if ((sim->parts[i].ctype&4) == 4 && sim->parts[sim->parts[i].tmp2].type == PT_SOAP)
|
||||
{
|
||||
if ((sim->parts[sim->parts[i].tmp2].ctype&2) == 2)
|
||||
sim->parts[sim->parts[i].tmp2].ctype ^= 2;
|
||||
}
|
||||
|
||||
sim->parts[i].ctype = 0;
|
||||
}
|
||||
|
||||
//#TPT-Directive ElementHeader Element_SOAP static void attach(Particle * parts, int i1, int i2)
|
||||
void Element_SOAP::attach(Particle * parts, int i1, int i2)
|
||||
{
|
||||
@ -93,24 +111,24 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
int target = i;
|
||||
//break entire bubble in a loop
|
||||
while((parts[target].ctype&6) != 6 && (parts[target].ctype&6))
|
||||
while((parts[target].ctype&6) != 6 && (parts[target].ctype&6) && parts[target].type == PT_SOAP)
|
||||
{
|
||||
if (parts[target].ctype&2)
|
||||
{
|
||||
target = parts[target].tmp;
|
||||
sim->detach(target);
|
||||
detach(sim, target);
|
||||
}
|
||||
if (parts[target].ctype&4)
|
||||
{
|
||||
target = parts[target].tmp2;
|
||||
sim->detach(target);
|
||||
detach(sim, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((parts[i].ctype&6) != 6)
|
||||
parts[i].ctype = 0;
|
||||
if ((parts[i].ctype&6) == 6 && (parts[parts[i].tmp].ctype&6) == 6 && parts[parts[i].tmp].tmp == i)
|
||||
sim->detach(i);
|
||||
detach(sim, i);
|
||||
}
|
||||
parts[i].vy = (parts[i].vy-0.1f)*0.5f;
|
||||
parts[i].vx *= 0.5f;
|
||||
@ -144,7 +162,7 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS)
|
||||
|| (r && sim->elements[r&0xFF].State != ST_GAS
|
||||
&& (r&0xFF) != PT_SOAP && (r&0xFF) != PT_GLAS))
|
||||
{
|
||||
sim->detach(i);
|
||||
detach(sim, i);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,8 @@ int Element_STOR::update(UPDATE_FUNC_ARGS)
|
||||
continue;
|
||||
if (!parts[i].tmp && !parts[i].life && (r&0xFF)!=PT_STOR && !(sim->elements[(r&0xFF)].Properties&TYPE_SOLID) && (!parts[i].ctype || (r&0xFF)==parts[i].ctype))
|
||||
{
|
||||
if ((r&0xFF) == PT_SOAP) sim->detach(r>>8);
|
||||
if ((r&0xFF) == PT_SOAP)
|
||||
Element_SOAP::detach(sim, r>>8);
|
||||
parts[i].tmp = parts[r>>8].type;
|
||||
parts[i].temp = parts[r>>8].temp;
|
||||
parts[i].tmp2 = parts[r>>8].life;
|
||||
|
Loading…
Reference in New Issue
Block a user