Skip to content

Commit

Permalink
Fix RSST/RSSS not respecting the CarriesCtypeIn field. Reset GEL's tm…
Browse files Browse the repository at this point in the history
…p field when it turns into RSST.
  • Loading branch information
savask committed Apr 4, 2024
1 parent 51f714d commit f8873de
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/simulation/elements/GLOW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/simulation/elements/NEUT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/simulation/elements/PHOT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/simulation/elements/RSST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit f8873de

Please sign in to comment.