mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-09-01 04:01:56 +02:00
a bunch of fixes to heat/pressure digitation
add limits so that you don't get impossible temp or pressures only undigitize from FILT 1 pixel away ensure everything only works through FILT, not sometimes PHOT or BRAY HSWC with .tmp of 1 no longer conducts heat to FILT
This commit is contained in:
@@ -3833,11 +3833,13 @@ void Simulation::UpdateParticles(int start, int end)
|
|||||||
if (!r)
|
if (!r)
|
||||||
continue;
|
continue;
|
||||||
rt = TYP(r);
|
rt = TYP(r);
|
||||||
if (rt&&elements[rt].HeatConduct&&(rt!=PT_HSWC||parts[ID(r)].life==10)
|
if (rt && elements[rt].HeatConduct && (rt!=PT_HSWC||parts[ID(r)].life==10)
|
||||||
&&(t!=PT_FILT||(rt!=PT_BRAY&&rt!=PT_BIZR&&rt!=PT_BIZRG))
|
&& (t!=PT_FILT||(rt!=PT_BRAY&&rt!=PT_BIZR&&rt!=PT_BIZRG))
|
||||||
&&(rt!=PT_FILT||(t!=PT_BRAY&&t!=PT_PHOT&&t!=PT_BIZR&&t!=PT_BIZRG))
|
&& (rt!=PT_FILT||(t!=PT_BRAY&&t!=PT_PHOT&&t!=PT_BIZR&&t!=PT_BIZRG))
|
||||||
&&(t!=PT_ELEC||rt!=PT_DEUT)
|
&& (t!=PT_ELEC||rt!=PT_DEUT)
|
||||||
&&(t!=PT_DEUT||rt!=PT_ELEC))
|
&& (t!=PT_DEUT||rt!=PT_ELEC)
|
||||||
|
&& (t!=PT_HSWC || rt!=PT_FILT || parts[i].tmp != 1)
|
||||||
|
&& (t!=PT_FILT || rt!=PT_HSWC || parts[ID(r)].tmp != 1))
|
||||||
{
|
{
|
||||||
surround_hconduct[j] = ID(r);
|
surround_hconduct[j] = ID(r);
|
||||||
#ifdef REALISTIC
|
#ifdef REALISTIC
|
||||||
|
@@ -56,25 +56,29 @@ int Element_HSWC::update(UPDATE_FUNC_ARGS)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
bool deserializeTemp = parts[i].tmp == 1;
|
||||||
for (rx=-2; rx<3; rx++)
|
for (rx=-2; rx<3; rx++)
|
||||||
for (ry=-2; ry<3; ry++)
|
for (ry=-2; ry<3; ry++)
|
||||||
if (BOUNDS_CHECK && (rx || ry))
|
if (BOUNDS_CHECK && (rx || ry))
|
||||||
{
|
{
|
||||||
r = pmap[y+ry][x+rx];
|
r = pmap[y+ry][x+rx];
|
||||||
if (parts[i].tmp == 1 && !r)
|
|
||||||
r = sim->photons[y + ry][x + rx];
|
|
||||||
if (!r)
|
if (!r)
|
||||||
continue;
|
continue;
|
||||||
if (TYP(r)==PT_HSWC)
|
if (TYP(r) == PT_HSWC)
|
||||||
{
|
{
|
||||||
if (parts[ID(r)].life<10&&parts[ID(r)].life>0)
|
if (parts[ID(r)].life<10&&parts[ID(r)].life>0)
|
||||||
parts[i].life = 9;
|
parts[i].life = 9;
|
||||||
else if (parts[ID(r)].life==0)
|
else if (parts[ID(r)].life==0)
|
||||||
parts[ID(r)].life = 10;
|
parts[ID(r)].life = 10;
|
||||||
}
|
}
|
||||||
if (parts[i].tmp == 1 && (TYP(r) == PT_FILT || TYP(r) == PT_PHOT || TYP(r) == PT_BRAY))
|
if (deserializeTemp && TYP(r) == PT_FILT)
|
||||||
{
|
{
|
||||||
parts[i].temp = parts[ID(r)].ctype - 0x10000000;
|
if (rx >= -1 && rx <= 1 && ry >= -1 && ry <= 1)
|
||||||
|
{
|
||||||
|
int newTemp = parts[ID(r)].ctype - 0x10000000;
|
||||||
|
if (newTemp >= MIN_TEMP && newTemp <= MAX_TEMP)
|
||||||
|
parts[i].temp = parts[ID(r)].ctype - 0x10000000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -48,21 +48,19 @@ Element_PSNS::Element_PSNS()
|
|||||||
int Element_PSNS::update(UPDATE_FUNC_ARGS)
|
int Element_PSNS::update(UPDATE_FUNC_ARGS)
|
||||||
{
|
{
|
||||||
int r, rx, ry, rt;
|
int r, rx, ry, rt;
|
||||||
float photonWl = 0.0f;
|
|
||||||
bool setFilt = false;
|
|
||||||
if (sim->pv[y/CELL][x/CELL] > parts[i].temp-273.15f)
|
if (sim->pv[y/CELL][x/CELL] > parts[i].temp-273.15f)
|
||||||
{
|
{
|
||||||
parts[i].life = 0;
|
parts[i].life = 0;
|
||||||
for (rx=-2; rx<3; rx++)
|
for (rx = -2; rx <= 2; rx++)
|
||||||
for (ry=-2; ry<3; ry++)
|
for (ry = -2; ry <= 2; ry++)
|
||||||
if (BOUNDS_CHECK && (rx || ry))
|
if (BOUNDS_CHECK && (rx || ry))
|
||||||
{
|
{
|
||||||
r = pmap[y+ry][x+rx];
|
r = pmap[y+ry][x+rx];
|
||||||
if (!r)
|
if (!r)
|
||||||
continue;
|
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)
|
||||||
{
|
{
|
||||||
|
rt = TYP(r);
|
||||||
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)].life = 4;
|
||||||
@@ -75,13 +73,13 @@ int Element_PSNS::update(UPDATE_FUNC_ARGS)
|
|||||||
if (parts[i].tmp == 1)
|
if (parts[i].tmp == 1)
|
||||||
{
|
{
|
||||||
parts[i].life = 0;
|
parts[i].life = 0;
|
||||||
setFilt = true;
|
bool setFilt = true;
|
||||||
photonWl = sim->pv[y / CELL][x / CELL];
|
float photonWl = sim->pv[y / CELL][x / CELL];
|
||||||
if (setFilt)
|
if (setFilt)
|
||||||
{
|
{
|
||||||
int nx, ny;
|
int nx, ny;
|
||||||
for (rx = -1; rx < 2; rx++)
|
for (rx = -1; rx <= 1; rx++)
|
||||||
for (ry = -1; ry < 2; ry++)
|
for (ry = -1; ry <= 1; ry++)
|
||||||
if (BOUNDS_CHECK && (rx || ry))
|
if (BOUNDS_CHECK && (rx || ry))
|
||||||
{
|
{
|
||||||
r = pmap[y + ry][x + rx];
|
r = pmap[y + ry][x + rx];
|
||||||
|
@@ -49,49 +49,53 @@ Element_PUMP::Element_PUMP()
|
|||||||
int Element_PUMP::update(UPDATE_FUNC_ARGS)
|
int Element_PUMP::update(UPDATE_FUNC_ARGS)
|
||||||
{
|
{
|
||||||
int r, rx, ry;
|
int r, rx, ry;
|
||||||
if (parts[i].life!=10)
|
if (parts[i].life != 10)
|
||||||
{
|
{
|
||||||
if (parts[i].life>0)
|
if (parts[i].life>0)
|
||||||
parts[i].life--;
|
parts[i].life--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (parts[i].temp>=256.0+273.15)
|
if (parts[i].temp >= 256.0+273.15)
|
||||||
parts[i].temp=256.0+273.15;
|
parts[i].temp = 256.0+273.15;
|
||||||
if (parts[i].temp<= -256.0+273.15)
|
if (parts[i].temp <= -256.0+273.15)
|
||||||
parts[i].temp = -256.0+273.15;
|
parts[i].temp = -256.0+273.15;
|
||||||
|
|
||||||
for (rx=-1; rx<2; rx++)
|
for (rx = -1; rx <= 1; rx++)
|
||||||
for (ry=-1; ry<2; ry++)
|
for (ry = -1; ry <= 1; ry++)
|
||||||
if (parts[i].tmp != 1 && (!(rx && ry)))
|
{
|
||||||
|
if (parts[i].tmp != 1)
|
||||||
{
|
{
|
||||||
sim->pv[(y/CELL)+ry][(x/CELL)+rx] += 0.1f*((parts[i].temp-273.15)-sim->pv[(y/CELL)+ry][(x/CELL)+rx]);
|
if (!(rx && ry))
|
||||||
|
sim->pv[(y/CELL)+ry][(x/CELL)+rx] += 0.1f*((parts[i].temp-273.15)-sim->pv[(y/CELL)+ry][(x/CELL)+rx]);
|
||||||
}
|
}
|
||||||
for (rx=-2; rx<3; rx++)
|
else
|
||||||
for (ry=-2; ry<3; ry++)
|
{
|
||||||
|
int r = pmap[y+ry][x+rx];
|
||||||
|
if (TYP(r) == PT_FILT)
|
||||||
|
{
|
||||||
|
int newPressure = parts[ID(r)].ctype - 0x10000000;
|
||||||
|
if (newPressure >= 0 && newPressure <= 512)
|
||||||
|
{
|
||||||
|
sim->pv[(y + ry) / CELL][(x + rx) / CELL] = newPressure - 256;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (rx = -2; rx <= 2; rx++)
|
||||||
|
for (ry = -2; ry <= 2; ry++)
|
||||||
if (BOUNDS_CHECK && (rx || ry))
|
if (BOUNDS_CHECK && (rx || ry))
|
||||||
{
|
{
|
||||||
r = pmap[y+ry][x+rx];
|
r = pmap[y+ry][x+rx];
|
||||||
if (!r)
|
if (!r)
|
||||||
continue;
|
continue;
|
||||||
if (TYP(r)==PT_PUMP)
|
if (TYP(r) == PT_PUMP)
|
||||||
{
|
{
|
||||||
if (parts[ID(r)].life<10&&parts[ID(r)].life>0)
|
if (parts[ID(r)].life < 10 && parts[ID(r)].life > 0)
|
||||||
parts[i].life = 9;
|
parts[i].life = 9;
|
||||||
else if (parts[ID(r)].life==0)
|
else if (parts[ID(r)].life == 0)
|
||||||
parts[ID(r)].life = 10;
|
parts[ID(r)].life = 10;
|
||||||
}
|
}
|
||||||
if (parts[i].tmp == 1 && (TYP(r) == PT_FILT || TYP(r) == PT_PHOT || TYP(r) == PT_BRAY))
|
|
||||||
{
|
|
||||||
if (parts[ID(r)].ctype >= 0x10000000 && parts[ID(r)].ctype <= 0x10000000 + 512)
|
|
||||||
{
|
|
||||||
sim->pv[(y / CELL) + ry][(x / CELL) + rx] = (parts[ID(r)].ctype - 0x10000000) - 256;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sim->pv[(y / CELL) + ry][(x / CELL) + rx] = 0.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user