From f8873debc6a6647a21a017030bc7d90b37ef9dd2 Mon Sep 17 00:00:00 2001 From: Saveliy Skresanov Date: Thu, 4 Apr 2024 22:10:58 +0700 Subject: [PATCH] Fix RSST/RSSS not respecting the CarriesCtypeIn field. Reset GEL's tmp field when it turns into RSST. --- src/simulation/elements/GLOW.cpp | 4 ++++ src/simulation/elements/NEUT.cpp | 4 +++- src/simulation/elements/PHOT.cpp | 5 ++++- src/simulation/elements/RSST.cpp | 8 ++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/simulation/elements/GLOW.cpp b/src/simulation/elements/GLOW.cpp index ef8bb6a1c..c621e142d 100644 --- a/src/simulation/elements/GLOW.cpp +++ b/src/simulation/elements/GLOW.cpp @@ -59,17 +59,21 @@ static int update(UPDATE_FUNC_ARGS) auto r = pmap[y+ry][x+rx]; if (!r) continue; + if (TYP(r)==PT_WATR && sim->rng.chance(1, 400)) { sim->kill_part(i); sim->part_change_type(ID(r),x+rx,y+ry,PT_DEUT); parts[ID(r)].life = 10; + return 1; } else if (TYP(r) == PT_GEL) //GLOW + GEL = RSST { sim->kill_part(i); sim->part_change_type(ID(r),x+rx,y+ry,PT_RSST); + parts[ID(r)].tmp = 0; + return 1; } } diff --git a/src/simulation/elements/NEUT.cpp b/src/simulation/elements/NEUT.cpp index f7d2fd351..319feac69 100644 --- a/src/simulation/elements/NEUT.cpp +++ b/src/simulation/elements/NEUT.cpp @@ -54,6 +54,8 @@ void Element::Element_NEUT() static int update(UPDATE_FUNC_ARGS) { + auto &sd = SimulationData::CRef(); + auto &elements = sd.elements; unsigned int pressureFactor = 3 + (int)sim->pv[y/CELL][x/CELL]; for (int rx = -1; rx <= 1; rx++) { @@ -178,7 +180,7 @@ static int update(UPDATE_FUNC_ARGS) sim->create_part(ID(r), x, y, ct_under); //If there's a correct tmp set, use it for ctype - if(tmp_under > 0 && ct_under < PT_NUM) + if((tmp_under > 0) && (tmp_under < PT_NUM) && (elements[ct_under].CarriesTypeIn & (1U << FIELD_CTYPE))) parts[ID(r)].ctype = tmp_under; } else diff --git a/src/simulation/elements/PHOT.cpp b/src/simulation/elements/PHOT.cpp index ef3a33934..17cabaab1 100644 --- a/src/simulation/elements/PHOT.cpp +++ b/src/simulation/elements/PHOT.cpp @@ -57,6 +57,9 @@ void Element::Element_PHOT() static int update(UPDATE_FUNC_ARGS) { + auto &sd = SimulationData::CRef(); + auto &elements = sd.elements; + if (!(parts[i].ctype&0x3FFFFFFF)) { sim->kill_part(i); return 1; @@ -121,7 +124,7 @@ static int update(UPDATE_FUNC_ARGS) sim->create_part(ID(r), x, y, ct_under); //If there's a correct tmp set, use it for ctype - if(tmp_under > 0 && ct_under < PT_NUM) + if((tmp_under > 0) && (tmp_under < PT_NUM) && (elements[ct_under].CarriesTypeIn & (1U << FIELD_CTYPE))) parts[ID(r)].ctype = tmp_under; } else diff --git a/src/simulation/elements/RSST.cpp b/src/simulation/elements/RSST.cpp index 2f0c5eb90..747b52ced 100644 --- a/src/simulation/elements/RSST.cpp +++ b/src/simulation/elements/RSST.cpp @@ -33,6 +33,7 @@ void Element::Element_RSST() Description = "Resist. Solidifies on contact with photons, is destroyed by electrons and spark."; Properties = TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_NEUTPASS; + CarriesTypeIn = (1U << FIELD_CTYPE) | (1U << FIELD_TMP); LowPressure = IPL; LowPressureTransition = NT; @@ -80,6 +81,13 @@ int update(UPDATE_FUNC_ARGS) if(parts[ID(r)].ctype != PT_RSST) parts[i].ctype = parts[ID(r)].ctype; } + + // Set RSST tmp from nearby breakable clone + if((TYP(r) == PT_BCLN) || (TYP(r) == PT_PBCN)) + { + if(parts[ID(r)].ctype != PT_RSST) + parts[i].tmp = parts[ID(r)].ctype; + } } }