Fix "missing custom elements" warnings when loading saves with RSST/RSSS; mark SNOW as carrying ctype as well

This commit is contained in:
jacob1 2024-04-19 23:31:09 -04:00
parent 6de252eb34
commit de345a85a1
No known key found for this signature in database
GPG Key ID: 4E58A32D510E1995
2 changed files with 14 additions and 3 deletions

View File

@ -51,9 +51,17 @@ GameSave::GameSave(const std::vector<char> &data, bool newWantAuthors)
void GameSave::MapPalette() void GameSave::MapPalette()
{ {
int partMap[PT_NUM]; int partMap[PT_NUM];
bool ignoreMissingErrors[PT_NUM];
for(int i = 0; i < PT_NUM; i++) for(int i = 0; i < PT_NUM; i++)
{ {
partMap[i] = 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(); auto &sd = SimulationData::CRef();
@ -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) if (type > 0 && type < PT_NUM)
{ {
auto carriedType = partMap[type]; auto carriedType = partMap[type];
if (!carriedType) // type is not 0 so this shouldn't be 0 either if (!carriedType) // type is not 0 so this shouldn't be 0 either
{ {
if (ignoreMissingErrors)
return type;
missingElements.ids.insert(type); missingElements.ids.insert(type);
} }
type = carriedType; type = carriedType;
@ -113,7 +123,7 @@ void GameSave::MapPalette()
{ {
continue; continue;
} }
tempPart.type = paletteLookup(tempPart.type); tempPart.type = paletteLookup(tempPart.type, false);
for (auto index : possiblyCarriesType) for (auto index : possiblyCarriesType)
{ {
if (elements[tempPart.type].CarriesTypeIn & (1U << index)) if (elements[tempPart.type].CarriesTypeIn & (1U << index))
@ -121,7 +131,7 @@ void GameSave::MapPalette()
auto *prop = reinterpret_cast<int *>(reinterpret_cast<char *>(&tempPart) + properties[index].Offset); auto *prop = reinterpret_cast<int *>(reinterpret_cast<char *>(&tempPart) + properties[index].Offset);
auto carriedType = *prop & int(pmapmask); auto carriedType = *prop & int(pmapmask);
auto extra = *prop >> pmapbits; auto extra = *prop >> pmapbits;
carriedType = paletteLookup(carriedType); carriedType = paletteLookup(carriedType, ignoreMissingErrors[tempPart.type]);
*prop = PMAP(extra, carriedType); *prop = PMAP(extra, carriedType);
} }
} }

View File

@ -35,6 +35,7 @@ void Element::Element_SNOW()
Description = "Light particles. Created when ICE breaks under pressure."; Description = "Light particles. Created when ICE breaks under pressure.";
Properties = TYPE_PART|PROP_NEUTPASS; Properties = TYPE_PART|PROP_NEUTPASS;
CarriesTypeIn = 1U << FIELD_CTYPE;
LowPressure = IPL; LowPressure = IPL;
LowPressureTransition = NT; LowPressureTransition = NT;