diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index aa0a723989..ff467cec4b 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -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 diff --git a/src/simulation/elements/HSWC.cpp b/src/simulation/elements/HSWC.cpp index a8cd7a3139..e17c179043 100644 --- a/src/simulation/elements/HSWC.cpp +++ b/src/simulation/elements/HSWC.cpp @@ -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; + } } } } diff --git a/src/simulation/elements/PSNS.cpp b/src/simulation/elements/PSNS.cpp index 70189d6042..ee11e53a7e 100644 --- a/src/simulation/elements/PSNS.cpp +++ b/src/simulation/elements/PSNS.cpp @@ -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; @@ -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]; diff --git a/src/simulation/elements/PUMP.cpp b/src/simulation/elements/PUMP.cpp index aafdc9739f..72736927b9 100644 --- a/src/simulation/elements/PUMP.cpp +++ b/src/simulation/elements/PUMP.cpp @@ -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;