Add .life serialization support to lsns (#652)
This commit is contained in:
parent
eba51a1ea5
commit
b2adbb54db
@ -69,8 +69,13 @@ int Element_LSNS::update(UPDATE_FUNC_ARGS)
|
|||||||
sim->part_change_type(ID(r), x + rx, y + ry, PT_SPRK);
|
sim->part_change_type(ID(r), x + rx, y + ry, PT_SPRK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bool setFilt = false;
|
||||||
|
bool Setnewlife = false;
|
||||||
|
int partlife = 0;
|
||||||
|
int Newlife = 0;
|
||||||
for (rx = -rd; rx < rd + 1; rx++)
|
for (rx = -rd; rx < rd + 1; rx++)
|
||||||
for (ry = -rd; ry < rd + 1; ry++)
|
for (ry = -rd; ry < rd + 1; ry++)
|
||||||
if (x + rx >= 0 && y + ry >= 0 && x + rx < XRES && y + ry < YRES && (rx || ry))
|
if (x + rx >= 0 && y + ry >= 0 && x + rx < XRES && y + ry < YRES && (rx || ry))
|
||||||
@ -80,9 +85,68 @@ int Element_LSNS::update(UPDATE_FUNC_ARGS)
|
|||||||
r = sim->photons[y + ry][x + rx];
|
r = sim->photons[y + ry][x + rx];
|
||||||
if (!r)
|
if (!r)
|
||||||
continue;
|
continue;
|
||||||
|
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)
|
if (parts[ID(r)].life > parts[i].temp - 273.15)
|
||||||
|
{
|
||||||
parts[i].life = 1;
|
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;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user