- took the translation slot definition out of the container and use a dynamic array to store the data.

This commit is contained in:
Christoph Oelckers 2020-04-11 12:44:59 +02:00
parent cf757ba834
commit 66a837f983
3 changed files with 25 additions and 25 deletions

View file

@ -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(); Clear();
// Make sure that index 0 is always the identity translation. // 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.MakeIdentity();
remap.Inactive = true; remap.Inactive = true;
AddRemap(&remap); AddRemap(&remap);
TranslationTables.Resize(numslots);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -82,7 +83,7 @@ void PaletteContainer::Clear()
{ {
remapArena.FreeAllBlocks(); remapArena.FreeAllBlocks();
uniqueRemaps.Reset(); 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 type = GetTranslationType(translation);
unsigned int index = GetTranslationIndex(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; return NULL;
} }

View file

@ -7,6 +7,25 @@
class FSerializer; 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 enum EStandardTranslations
{ {
STD_Ice = 7, STD_Ice = 7,

View file

@ -72,33 +72,13 @@ inline int GetTranslationIndex(uint32_t trans)
return (trans & TRANSLATION_MASK); 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 class PaletteContainer
{ {
FMemArena remapArena; FMemArena remapArena;
TArray<FRemapTable*> uniqueRemaps; TArray<FRemapTable*> uniqueRemaps;
TAutoGrowArray<FRemapTablePtr, FRemapTable*> TranslationTables[NUM_TRANSLATION_TABLES]; TArray<TAutoGrowArray<FRemapTablePtr, FRemapTable*>> TranslationTables;
public: public:
void Init(); // This cannot be a constructor!!! void Init(int numslots); // This cannot be a constructor!!!
void Clear(); void Clear();
FRemapTable* AddRemap(FRemapTable* remap); FRemapTable* AddRemap(FRemapTable* remap);
void UpdateTranslation(int trans, FRemapTable* remap); void UpdateTranslation(int trans, FRemapTable* remap);