mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-21 23:45:20 +02:00
Fix "missing custom elements" warnings when loading saves with RSST/RSSS; mark SNOW as carrying ctype as well
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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;
|
||||||
|
Reference in New Issue
Block a user