Skip to content

Commit

Permalink
Fix issue causing overlay custom palette being reset on load
Browse files Browse the repository at this point in the history
  • Loading branch information
Starkku committed Mar 29, 2024
1 parent cec9374 commit 5e1960f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Ext/OverlayType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ void OverlayTypeExt::ExtData::Serialize(T& Stm)
{
Stm
.Process(this->PaletteFile)
.Process(this->Palette)
;
}

Expand All @@ -35,6 +34,11 @@ void OverlayTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)

this->PaletteFile.Read(pArtINI, pArtSection, "Palette");

BuildPalette();
}

void OverlayTypeExt::ExtData::BuildPalette()
{
if (GeneralUtils::IsValidString(this->PaletteFile))
{
char pFilename[0x20];
Expand All @@ -48,6 +52,7 @@ void OverlayTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm)
{
Extension<OverlayTypeClass>::LoadFromStream(Stm);
this->Serialize(Stm);
this->BuildPalette();
}

void OverlayTypeExt::ExtData::SaveToStream(PhobosStreamWriter& Stm)
Expand Down
3 changes: 2 additions & 1 deletion src/Ext/OverlayType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class OverlayTypeExt
{
public:
PhobosFixedString<32u> PaletteFile;
DynamicVectorClass<ColorScheme*>* Palette;
DynamicVectorClass<ColorScheme*>* Palette; // Intentionally not serialized - rebuilt from the palette file on load.

ExtData(OverlayTypeClass* OwnerObject) : Extension<OverlayTypeClass>(OwnerObject)
, PaletteFile {}
Expand All @@ -37,6 +37,7 @@ class OverlayTypeExt
private:
template <typename T>
void Serialize(T& Stm);
void BuildPalette();
};

class ExtContainer final : public Container<OverlayTypeExt>
Expand Down

0 comments on commit 5e1960f

Please sign in to comment.