Add .life serialization support to lsns (#652)
This commit is contained in:
parent
eba51a1ea5
commit
b2adbb54db
@ -52,37 +52,101 @@ int Element_LSNS::update(UPDATE_FUNC_ARGS)
|
||||
if (parts[i].life)
|
||||
{
|
||||
parts[i].life = 0;
|
||||
for (rx=-2; rx<3; rx++)
|
||||
for (ry=-2; ry<3; ry++)
|
||||
for (rx = -2; rx < 3; rx++)
|
||||
for (ry = -2; ry < 3; ry++)
|
||||
if (BOUNDS_CHECK && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
r = pmap[y + ry][x + rx];
|
||||
if (!r)
|
||||
continue;
|
||||
rt = TYP(r);
|
||||
if (sim->parts_avg(i,ID(r),PT_INSL) != PT_INSL)
|
||||
if (sim->parts_avg(i, ID(r), PT_INSL) != PT_INSL)
|
||||
{
|
||||
if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[ID(r)].life==0)
|
||||
if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt == PT_WATR || rt == PT_SLTW || rt == PT_NTCT || rt == PT_PTCT || rt == PT_INWR) && parts[ID(r)].life == 0)
|
||||
{
|
||||
parts[ID(r)].life = 4;
|
||||
parts[ID(r)].ctype = rt;
|
||||
sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK);
|
||||
sim->part_change_type(ID(r), x + rx, y + ry, PT_SPRK);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
for (rx=-rd; rx<rd+1; rx++)
|
||||
for (ry=-rd; ry<rd+1; ry++)
|
||||
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES && (rx || ry))
|
||||
bool setFilt = false;
|
||||
bool Setnewlife = false;
|
||||
int partlife = 0;
|
||||
int Newlife = 0;
|
||||
for (rx = -rd; rx < rd + 1; rx++)
|
||||
for (ry = -rd; ry < rd + 1; ry++)
|
||||
if (x + rx >= 0 && y + ry >= 0 && x + rx < XRES && y + ry < YRES && (rx || ry))
|
||||
{
|
||||
r = pmap[y+ry][x+rx];
|
||||
if(!r)
|
||||
r = sim->photons[y+ry][x+rx];
|
||||
if(!r)
|
||||
r = pmap[y + ry][x + rx];
|
||||
if (!r)
|
||||
r = sim->photons[y + ry][x + rx];
|
||||
if (!r)
|
||||
continue;
|
||||
if (parts[ID(r)].life > parts[i].temp-273.15)
|
||||
if (parts[i].tmp == 1 && TYP(r) != PT_LSNS && TYP(r) != PT_FILT && parts[ID(r)].life >= 0)
|
||||
{
|
||||
setFilt = true;
|
||||
partlife = parts[ID(r)].life;
|
||||
}
|
||||
if (parts[i].tmp == 3 && TYP(r) == PT_FILT)
|
||||
{
|
||||
Setnewlife = true;
|
||||
Newlife = parts[ID(r)].ctype;
|
||||
}
|
||||
if ((parts[i].tmp != 1) && (parts[i].tmp != 2) && (parts[i].tmp != 3))
|
||||
{
|
||||
if (parts[ID(r)].life > parts[i].temp - 273.15)
|
||||
{
|
||||
parts[i].life = 1;
|
||||
}
|
||||
}
|
||||
//Invert mode.
|
||||
if (parts[i].tmp == 2)
|
||||
{
|
||||
if (parts[ID(r)].life > parts[i].temp - 273.15)
|
||||
parts[i].life = 0;
|
||||
else
|
||||
parts[i].life = 1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
int nx, ny;
|
||||
for (int rx = -1; rx <= 1; rx++)
|
||||
for (int ry = -1; ry <= 1; ry++)
|
||||
if (BOUNDS_CHECK && (rx || ry))
|
||||
{
|
||||
int r = pmap[y + ry][x + rx];
|
||||
if (!r)
|
||||
continue;
|
||||
nx = x + rx;
|
||||
ny = y + ry;
|
||||
//.life serialization.
|
||||
if (setFilt)
|
||||
{
|
||||
while (TYP(r) == PT_FILT)
|
||||
{
|
||||
parts[ID(r)].ctype = 0x10000000 + partlife;
|
||||
nx += rx;
|
||||
ny += ry;
|
||||
if (nx < 0 || ny < 0 || nx >= XRES || ny >= YRES)
|
||||
break;
|
||||
r = pmap[ny][nx];
|
||||
}
|
||||
}
|
||||
//.life deserialization.
|
||||
if (Setnewlife)
|
||||
{
|
||||
if (TYP(r) != PT_FILT)
|
||||
{
|
||||
parts[ID(r)].life = Newlife - 0x10000000;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user