diff --git a/src/r_data/r_translate.cpp b/src/r_data/r_translate.cpp index a6007ce38..890b1c0bd 100644 --- a/src/r_data/r_translate.cpp +++ b/src/r_data/r_translate.cpp @@ -135,27 +135,6 @@ bool FUniquePalette::Update() /****************************************************/ /****************************************************/ -FRemapTable::FRemapTable(int count) -{ - assert(count <= 256); - Inactive = false; - Alloc(count); - - // Note that the tables are left uninitialized. It is assumed that - // the caller will do that next, if only by calling MakeIdentity(). -} - -//---------------------------------------------------------------------------- -// -// -// -//---------------------------------------------------------------------------- - -FRemapTable::~FRemapTable() -{ - Free(); -} - //---------------------------------------------------------------------------- // // @@ -179,78 +158,6 @@ int FRemapTable::GetUniqueIndex() // //---------------------------------------------------------------------------- -void FRemapTable::Alloc(int count) -{ - Remap = (uint8_t *)M_Malloc(count*sizeof(*Remap) + count*sizeof(*Palette)); - assert (Remap != NULL); - Palette = (PalEntry *)(Remap + count*(sizeof(*Remap))); - Native = NULL; - NumEntries = count; -} - -//---------------------------------------------------------------------------- -// -// -// -//---------------------------------------------------------------------------- - -void FRemapTable::Free() -{ - KillNative(); - if (Remap != NULL) - { - M_Free(Remap); - Remap = NULL; - Palette = NULL; - NumEntries = 0; - } -} - -//---------------------------------------------------------------------------- -// -// -// -//---------------------------------------------------------------------------- - -FRemapTable::FRemapTable(const FRemapTable &o) -{ - Remap = NULL; - Native = NULL; - NumEntries = 0; - operator= (o); -} - -//---------------------------------------------------------------------------- -// -// -// -//---------------------------------------------------------------------------- - -FRemapTable &FRemapTable::operator=(const FRemapTable &o) -{ - if (&o == this) - { - return *this; - } - if (o.NumEntries != NumEntries) - { - Free(); - } - if (Remap == NULL) - { - Alloc(o.NumEntries); - } - Inactive = o.Inactive; - memcpy(Remap, o.Remap, NumEntries*sizeof(*Remap) + NumEntries*sizeof(*Palette)); - return *this; -} - -//---------------------------------------------------------------------------- -// -// -// -//---------------------------------------------------------------------------- - bool FRemapTable::operator==(const FRemapTable &o) { // Two translations are identical when they have the same amount of colors @@ -271,14 +178,6 @@ void FRemapTable::Serialize(FSerializer &arc) int n = NumEntries; arc("numentries", NumEntries); - if (arc.isReading()) - { - if (n != NumEntries) - { - Free(); - Alloc(NumEntries); - } - } arc.Array("remap", Remap, NumEntries); arc.Array("palette", Palette, NumEntries); } diff --git a/src/r_data/r_translate.h b/src/r_data/r_translate.h index 7f57e680d..f050f788e 100644 --- a/src/r_data/r_translate.h +++ b/src/r_data/r_translate.h @@ -61,11 +61,9 @@ public: struct FRemapTable { - FRemapTable(int count=256); - FRemapTable(const FRemapTable &o); - ~FRemapTable(); + FRemapTable(int count = 256) { NumEntries = count; } + FRemapTable(const FRemapTable& o) = default; - FRemapTable &operator= (const FRemapTable &o); bool operator==(const FRemapTable &o); void MakeIdentity(); void KillNative(); @@ -83,15 +81,14 @@ struct FRemapTable int StoreTranslation(int slot); int GetUniqueIndex(); - uint8_t *Remap; // For the software renderer - PalEntry *Palette; // The ideal palette this maps to + uint8_t Remap[256]; // For the software renderer + PalEntry Palette[256]; // The ideal palette this maps to FUniquePalette *Native; // The index into the list of unique palettes (this is to avoid frequent texture recreation with changing ACS translations) + //int crc32; int NumEntries; // # of elements in this table (usually 256) - bool Inactive; // This table is inactive and should be treated as if it was passed as NULL + bool Inactive = false; // This table is inactive and should be treated as if it was passed as NULL private: - void Free(); - void Alloc(int count); }; // A class that initializes unusued pointers to NULL. This is used so that when