diff --git a/src/r_data/r_translate.cpp b/src/r_data/r_translate.cpp index eb413c272..8296a3fcc 100644 --- a/src/r_data/r_translate.cpp +++ b/src/r_data/r_translate.cpp @@ -62,7 +62,7 @@ PaletteContainer palMgr; // //---------------------------------------------------------------------------- -void PaletteContainer::Init() // This cannot be a constructor!!! +void PaletteContainer::Init(int numslots) // This cannot be a constructor!!! { Clear(); // Make sure that index 0 is always the identity translation. @@ -70,6 +70,7 @@ void PaletteContainer::Init() // This cannot be a constructor!!! remap.MakeIdentity(); remap.Inactive = true; AddRemap(&remap); + TranslationTables.Resize(numslots); } //---------------------------------------------------------------------------- @@ -82,7 +83,7 @@ void PaletteContainer::Clear() { remapArena.FreeAllBlocks(); uniqueRemaps.Reset(); - for (auto& slot : TranslationTables) slot.Reset(); + TranslationTables.Reset(); } //---------------------------------------------------------------------------- @@ -160,7 +161,7 @@ FRemapTable *PaletteContainer::TranslationToTable(int translation) unsigned int type = GetTranslationType(translation); unsigned int index = GetTranslationIndex(translation); - if (type <= 0 || type >= NUM_TRANSLATION_TABLES || index >= NumTranslations(type)) + if (type <= 0 || type >= TranslationTables.Size() || index >= NumTranslations(type)) { return NULL; } diff --git a/src/r_data/r_translate.h b/src/r_data/r_translate.h index 58c839ecc..0b8cb0cbe 100644 --- a/src/r_data/r_translate.h +++ b/src/r_data/r_translate.h @@ -7,6 +7,25 @@ class FSerializer; +enum +{ + TRANSLATION_Invalid, + TRANSLATION_Players, + TRANSLATION_PlayersExtra, + TRANSLATION_Standard, + TRANSLATION_LevelScripted, + TRANSLATION_Decals, + TRANSLATION_PlayerCorpses, + TRANSLATION_Decorate, + TRANSLATION_Blood, + TRANSLATION_RainPillar, + TRANSLATION_Custom, + TRANSLATION_Font, + + NUM_TRANSLATION_TABLES +}; + + enum EStandardTranslations { STD_Ice = 7, diff --git a/src/utility/palutil.h b/src/utility/palutil.h index 13cd8b711..0bcbfeed2 100644 --- a/src/utility/palutil.h +++ b/src/utility/palutil.h @@ -72,33 +72,13 @@ inline int GetTranslationIndex(uint32_t trans) return (trans & TRANSLATION_MASK); } -// Fixme: This should avoid hard game content dependencies! -enum -{ - TRANSLATION_Invalid, - TRANSLATION_Players, - TRANSLATION_PlayersExtra, - TRANSLATION_Standard, - TRANSLATION_LevelScripted, - TRANSLATION_Decals, - TRANSLATION_PlayerCorpses, - TRANSLATION_Decorate, - TRANSLATION_Blood, - TRANSLATION_RainPillar, - TRANSLATION_Custom, - TRANSLATION_Font, - - NUM_TRANSLATION_TABLES -}; - - class PaletteContainer { FMemArena remapArena; TArray uniqueRemaps; - TAutoGrowArray TranslationTables[NUM_TRANSLATION_TABLES]; + TArray> TranslationTables; public: - void Init(); // This cannot be a constructor!!! + void Init(int numslots); // This cannot be a constructor!!! void Clear(); FRemapTable* AddRemap(FRemapTable* remap); void UpdateTranslation(int trans, FRemapTable* remap);