Skip to content

Commit

Permalink
a bunch of fixes to heat/pressure digitation
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jacob1 committed Mar 8, 2018
1 parent 5eb0d1b commit 5a61e6a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 43 deletions.
12 changes: 7 additions & 5 deletions src/simulation/Simulation.cpp
Expand Up @@ -3833,11 +3833,13 @@ void Simulation::UpdateParticles(int start, int end)
if (!r)
continue;
rt = TYP(r);
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))
&&(rt!=PT_FILT||(t!=PT_BRAY&&t!=PT_PHOT&&t!=PT_BIZR&&t!=PT_BIZRG))
&&(t!=PT_ELEC||rt!=PT_DEUT)
&&(t!=PT_DEUT||rt!=PT_ELEC))
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))
&& (rt!=PT_FILT||(t!=PT_BRAY&&t!=PT_PHOT&&t!=PT_BIZR&&t!=PT_BIZRG))
&& (t!=PT_ELEC||rt!=PT_DEUT)
&& (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);
#ifdef REALISTIC
Expand Down
14 changes: 9 additions & 5 deletions src/simulation/elements/HSWC.cpp
Expand Up @@ -56,25 +56,29 @@ int Element_HSWC::update(UPDATE_FUNC_ARGS)
}
else
{
bool deserializeTemp = parts[i].tmp == 1;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (parts[i].tmp == 1 && !r)
r = sim->photons[y + ry][x + rx];
if (!r)
continue;
if (TYP(r)==PT_HSWC)
if (TYP(r) == PT_HSWC)
{
if (parts[ID(r)].life<10&&parts[ID(r)].life>0)
parts[i].life = 9;
else if (parts[ID(r)].life==0)
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;
}
}
}
}
Expand Down
16 changes: 7 additions & 9 deletions src/simulation/elements/PSNS.cpp
Expand Up @@ -48,21 +48,19 @@ Element_PSNS::Element_PSNS()
int Element_PSNS::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt;
float photonWl = 0.0f;
bool setFilt = false;
if (sim->pv[y/CELL][x/CELL] > parts[i].temp-273.15f)
{
parts[i].life = 0;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
for (rx = -2; rx <= 2; rx++)
for (ry = -2; ry <= 2; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
rt = TYP(r);
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)
{
parts[ID(r)].life = 4;
Expand All @@ -75,13 +73,13 @@ int Element_PSNS::update(UPDATE_FUNC_ARGS)
if (parts[i].tmp == 1)
{
parts[i].life = 0;
setFilt = true;
photonWl = sim->pv[y / CELL][x / CELL];
bool setFilt = true;
float photonWl = sim->pv[y / CELL][x / CELL];
if (setFilt)
{
int nx, ny;
for (rx = -1; rx < 2; rx++)
for (ry = -1; ry < 2; ry++)
for (rx = -1; rx <= 1; rx++)
for (ry = -1; ry <= 1; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
r = pmap[y + ry][x + rx];
Expand Down
52 changes: 28 additions & 24 deletions src/simulation/elements/PUMP.cpp
Expand Up @@ -49,49 +49,53 @@ Element_PUMP::Element_PUMP()
int Element_PUMP::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
if (parts[i].life!=10)
if (parts[i].life != 10)
{
if (parts[i].life>0)
parts[i].life--;
}
else
{
if (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;
if (parts[i].temp <= -256.0+273.15)
parts[i].temp = -256.0+273.15;

for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (parts[i].tmp != 1 && (!(rx && ry)))
for (rx = -1; rx <= 1; rx++)
for (ry = -1; ry <= 1; 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++)
for (ry=-2; ry<3; ry++)
else
{
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))
{
r = pmap[y+ry][x+rx];
if (!r)
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;
else if (parts[ID(r)].life==0)
else if (parts[ID(r)].life == 0)
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;
Expand Down

0 comments on commit 5a61e6a

Please sign in to comment.