Skip to content

Commit

Permalink
Fix "missing custom elements" warnings when loading saves with RSST/R…
Browse files Browse the repository at this point in the history
…SSS; mark SNOW as carrying ctype as well
  • Loading branch information
jacob1 committed Apr 20, 2024
1 parent 6de252e commit de345a8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/client/GameSave.cpp
Expand Up @@ -51,9 +51,17 @@ GameSave::GameSave(const std::vector<char> &data, bool newWantAuthors)
void GameSave::MapPalette()
{
int partMap[PT_NUM];
bool ignoreMissingErrors[PT_NUM];
for(int i = 0; i < PT_NUM; i++)
{
partMap[i] = i;
ignoreMissingErrors[i] = false;
}
if (version <= Version(98, 2))
{
ignoreMissingErrors[PT_SNOW] = true;
ignoreMissingErrors[PT_RSST] = true;
ignoreMissingErrors[PT_RSSS] = true;
}

auto &sd = SimulationData::CRef();
Expand Down Expand Up @@ -90,12 +98,14 @@ void GameSave::MapPalette()
}
}
}
auto paletteLookup = [this, &partMap](int type) {
auto paletteLookup = [this, &partMap](int type, bool ignoreMissingErrors) {
if (type > 0 && type < PT_NUM)
{
auto carriedType = partMap[type];
if (!carriedType) // type is not 0 so this shouldn't be 0 either
{
if (ignoreMissingErrors)
return type;
missingElements.ids.insert(type);
}
type = carriedType;
Expand All @@ -113,15 +123,15 @@ void GameSave::MapPalette()
{
continue;
}
tempPart.type = paletteLookup(tempPart.type);
tempPart.type = paletteLookup(tempPart.type, false);
for (auto index : possiblyCarriesType)
{
if (elements[tempPart.type].CarriesTypeIn & (1U << index))
{
auto *prop = reinterpret_cast<int *>(reinterpret_cast<char *>(&tempPart) + properties[index].Offset);
auto carriedType = *prop & int(pmapmask);
auto extra = *prop >> pmapbits;
carriedType = paletteLookup(carriedType);
carriedType = paletteLookup(carriedType, ignoreMissingErrors[tempPart.type]);
*prop = PMAP(extra, carriedType);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/simulation/elements/SNOW.cpp
Expand Up @@ -35,6 +35,7 @@ void Element::Element_SNOW()
Description = "Light particles. Created when ICE breaks under pressure.";

Properties = TYPE_PART|PROP_NEUTPASS;
CarriesTypeIn = 1U << FIELD_CTYPE;

LowPressure = IPL;
LowPressureTransition = NT;
Expand Down

0 comments on commit de345a8

Please sign in to comment.