From 0a7344e432e7d30451df3b6473a84b64b6d1d600 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 11 Apr 2020 12:41:09 +0200 Subject: [PATCH] - abstract the external translation interface. The translation table array now only gets accessed from within r_translate.cpp. --- src/g_game.cpp | 6 +- .../textures/formats/buildtexture.cpp | 4 +- src/gamedata/textures/formats/imgztexture.cpp | 2 +- .../textures/formats/patchtexture.cpp | 2 +- .../textures/formats/shadertexture.cpp | 2 +- src/gamedata/textures/imagehelpers.h | 2 +- src/p_setup.cpp | 13 +- src/playsim/p_acs.cpp | 11 +- src/r_data/r_translate.cpp | 222 ++++++++++-------- src/r_data/r_translate.h | 7 +- src/rendering/v_framebuffer.cpp | 9 +- 11 files changed, 158 insertions(+), 122 deletions(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index 863c01bd5..5fcb3df56 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1614,9 +1614,9 @@ void FLevelLocals::QueueBody (AActor *body) GetTranslationType(body->Translation) == TRANSLATION_PlayersExtra) { // This needs to be able to handle multiple levels, in case a level with dead players is used as a secondary one later. - *translationtables[TRANSLATION_PlayerCorpses][modslot] = *TranslationToTable(body->Translation); - body->Translation = TRANSLATION(TRANSLATION_PlayerCorpses,modslot); - translationtables[TRANSLATION_PlayerCorpses][modslot]->UpdateNative(); + CopyTranslation(TRANSLATION(TRANSLATION_PlayerCorpses, modslot), body->Translation); + body->Translation = TRANSLATION(TRANSLATION_PlayerCorpses, modslot); + } const int skinidx = body->player->userinfo.GetSkin(); diff --git a/src/gamedata/textures/formats/buildtexture.cpp b/src/gamedata/textures/formats/buildtexture.cpp index 1b5be6543..3a9eae259 100644 --- a/src/gamedata/textures/formats/buildtexture.cpp +++ b/src/gamedata/textures/formats/buildtexture.cpp @@ -84,7 +84,7 @@ FBuildTexture::FBuildTexture(const FString &pathprefix, int tilenum, const uint8 TArray FBuildTexture::CreatePalettedPixels(int conversion) { TArray Pixels(Width * Height, true); - FRemapTable *Remap = translationtables[TRANSLATION_Standard][Translation]; + FRemapTable *Remap = GetTranslation(TRANSLATION_Standard, Translation); for (int i = 0; i < Width*Height; i++) { auto c = RawPixels[i]; @@ -95,7 +95,7 @@ TArray FBuildTexture::CreatePalettedPixels(int conversion) int FBuildTexture::CopyPixels(FBitmap *bmp, int conversion) { - PalEntry *Remap = translationtables[TRANSLATION_Standard][Translation]->Palette; + PalEntry *Remap = GetTranslation(TRANSLATION_Standard, Translation)->Palette; bmp->CopyPixelData(0, 0, RawPixels, Width, Height, Height, 1, 0, Remap); return -1; diff --git a/src/gamedata/textures/formats/imgztexture.cpp b/src/gamedata/textures/formats/imgztexture.cpp index 2f466c5e2..913690f56 100644 --- a/src/gamedata/textures/formats/imgztexture.cpp +++ b/src/gamedata/textures/formats/imgztexture.cpp @@ -203,6 +203,6 @@ TArray FIMGZTexture::CreatePalettedPixels(int conversion) int FIMGZTexture::CopyPixels(FBitmap *bmp, int conversion) { if (!isalpha) return FImageSource::CopyPixels(bmp, conversion); - else return CopyTranslatedPixels(bmp, translationtables[TRANSLATION_Standard][STD_Grayscale]->Palette); + else return CopyTranslatedPixels(bmp, GetTranslation(TRANSLATION_Standard, STD_Grayscale)->Palette); } diff --git a/src/gamedata/textures/formats/patchtexture.cpp b/src/gamedata/textures/formats/patchtexture.cpp index 705da984a..7ce3a5d88 100644 --- a/src/gamedata/textures/formats/patchtexture.cpp +++ b/src/gamedata/textures/formats/patchtexture.cpp @@ -263,7 +263,7 @@ TArray FPatchTexture::CreatePalettedPixels(int conversion) int FPatchTexture::CopyPixels(FBitmap *bmp, int conversion) { if (!isalpha) return FImageSource::CopyPixels(bmp, conversion); - else return CopyTranslatedPixels(bmp, translationtables[TRANSLATION_Standard][STD_Grayscale]->Palette); + else return CopyTranslatedPixels(bmp, GetTranslation(TRANSLATION_Standard, STD_Grayscale)->Palette); } //========================================================================== diff --git a/src/gamedata/textures/formats/shadertexture.cpp b/src/gamedata/textures/formats/shadertexture.cpp index 8f817d9bc..3814e4628 100644 --- a/src/gamedata/textures/formats/shadertexture.cpp +++ b/src/gamedata/textures/formats/shadertexture.cpp @@ -122,7 +122,7 @@ public: int CopyPixels(FBitmap *bmp, int conversion) override { - bmp->CopyPixelData(0, 0, Pixels, Width, Height, Height, 1, 0, translationtables[TRANSLATION_Standard][8]->Palette); + bmp->CopyPixelData(0, 0, Pixels, Width, Height, Height, 1, 0, GetTranslation(TRANSLATION_Standard, STD_Gray)->Palette); return 0; } diff --git a/src/gamedata/textures/imagehelpers.h b/src/gamedata/textures/imagehelpers.h index 12f730db6..f9475e6eb 100644 --- a/src/gamedata/textures/imagehelpers.h +++ b/src/gamedata/textures/imagehelpers.h @@ -55,7 +55,7 @@ namespace ImageHelpers { if (wantluminance) { - return translationtables[TRANSLATION_Standard][srcisgrayscale ? STD_Gray : STD_Grayscale]->Remap; + return GetTranslation(TRANSLATION_Standard, srcisgrayscale ? STD_Gray : STD_Grayscale)->Remap; } else { diff --git a/src/p_setup.cpp b/src/p_setup.cpp index b7d5540ca..8685b4ec1 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -406,17 +406,8 @@ void P_SetupLevel(FLevelLocals *Level, int position, bool newGame) { Level->Players[i]->mo = nullptr; } - // [RH] Clear any scripted translation colors the previous level may have set. - for (i = 0; i < int(translationtables[TRANSLATION_LevelScripted].Size()); ++i) - { - FRemapTable *table = translationtables[TRANSLATION_LevelScripted][i]; - if (table != nullptr) - { - delete table; - translationtables[TRANSLATION_LevelScripted][i] = nullptr; - } - } - translationtables[TRANSLATION_LevelScripted].Clear(); + ClearScriptedTranslations(); + // Initial height of PointOfView will be set by player think. auto p = Level->GetConsolePlayer(); diff --git a/src/playsim/p_acs.cpp b/src/playsim/p_acs.cpp index dd958c6b4..6e435c56d 100644 --- a/src/playsim/p_acs.cpp +++ b/src/playsim/p_acs.cpp @@ -6771,6 +6771,7 @@ int DLevelScript::RunScript() ScriptFunction *activeFunction = NULL; FRemapTable *translation = 0; int resultValue = 1; + int transi = -1; if (InModuleScriptNumber >= 0) { @@ -9500,13 +9501,9 @@ scriptwait: sp--; if (i >= 1 && i <= MAX_ACS_TRANSLATIONS) { - translation = translationtables[TRANSLATION_LevelScripted].GetVal(i - 1); - if (translation == NULL) - { - translation = new FRemapTable; - translationtables[TRANSLATION_LevelScripted].SetVal(i - 1, translation); - } + translation = new FRemapTable; translation->MakeIdentity(); + transi = i + 1; } } break; @@ -9593,7 +9590,7 @@ scriptwait: case PCD_ENDTRANSLATION: if (translation != NULL) { - translation->UpdateNative(); + UpdateTranslation(TRANSLATION(TRANSLATION_LevelScripted, transi), translation); translation = NULL; } break; diff --git a/src/r_data/r_translate.cpp b/src/r_data/r_translate.cpp index 890b1c0bd..13dc24957 100644 --- a/src/r_data/r_translate.cpp +++ b/src/r_data/r_translate.cpp @@ -53,7 +53,69 @@ #include "gi.h" -TAutoGrowArray translationtables[NUM_TRANSLATION_TABLES]; +static TAutoGrowArray TranslationTables[NUM_TRANSLATION_TABLES]; + +void UpdateTranslation(int trans, FRemapTable* remap) +{ + TranslationTables[GetTranslationType(trans)].SetVal(GetTranslationIndex(trans), remap); + remap->UpdateNative(); +} + +int AddTranslation(int slot, FRemapTable* remap) +{ + auto i = TranslationTables[slot].Push(remap); + return TRANSLATION(slot, i); +} + +FRemapTable* GetTranslation(int slot, int index) +{ + return TranslationTables[slot].GetVal(index); +} + +void CopyTranslation(int dest, int src) +{ + *TranslationTables[GetTranslationType(dest)][GetTranslationType(src)] = *TranslationToTable(src); + TranslationTables[GetTranslationType(dest)][GetTranslationType(src)]->UpdateNative(); +} + +void ClearScriptedTranslations() +{ + // [RH] Clear any scripted translation colors the previous level may have set. + for (unsigned i = 0; i < TranslationTables[TRANSLATION_LevelScripted].Size(); ++i) + { + FRemapTable* table = TranslationTables[TRANSLATION_LevelScripted][i]; + if (table != nullptr) + { + delete table; + TranslationTables[TRANSLATION_LevelScripted][i] = nullptr; + } + } + TranslationTables[TRANSLATION_LevelScripted].Clear(); +} + +//---------------------------------------------------------------------------- +// +// +// +//---------------------------------------------------------------------------- + +FRemapTable *TranslationToTable(int translation) +{ + unsigned int type = GetTranslationType(translation); + unsigned int index = GetTranslationIndex(translation); + TAutoGrowArray *slots; + + if (type <= 0 || type >= NUM_TRANSLATION_TABLES) + { + return NULL; + } + slots = &TranslationTables[type]; + if (index >= slots->Size()) + { + return NULL; + } + return slots->operator[](index); +} const uint8_t IcePalette[16][3] = @@ -191,9 +253,9 @@ void FRemapTable::StaticSerializeTranslations(FSerializer &arc) int w; if (arc.isWriting()) { - for (unsigned int i = 0; i < translationtables[TRANSLATION_LevelScripted].Size(); ++i) + for (unsigned int i = 0; i < TranslationTables[TRANSLATION_LevelScripted].Size(); ++i) { - trans = translationtables[TRANSLATION_LevelScripted][i]; + trans = TranslationTables[TRANSLATION_LevelScripted][i]; if (trans != NULL && !trans->IsIdentity()) { if (arc.BeginObject(nullptr)) @@ -210,11 +272,11 @@ void FRemapTable::StaticSerializeTranslations(FSerializer &arc) while (arc.BeginObject(nullptr)) { arc("index", w); - trans = translationtables[TRANSLATION_LevelScripted].GetVal(w); + trans = TranslationTables[TRANSLATION_LevelScripted].GetVal(w); if (trans == NULL) { trans = new FRemapTable; - translationtables[TRANSLATION_LevelScripted].SetVal(w, trans); + TranslationTables[TRANSLATION_LevelScripted].SetVal(w, trans); } trans->Serialize(arc); arc.EndObject(); @@ -708,21 +770,21 @@ int FRemapTable::StoreTranslation(int slot) { unsigned int i; - for (i = 0; i < translationtables[slot].Size(); i++) + for (i = 0; i < TranslationTables[slot].Size(); i++) { - if (*this == *translationtables[slot][i]) + if (*this == *TranslationTables[slot][i]) { // A duplicate of this translation already exists return TRANSLATION(slot, i); } } - if (translationtables[slot].Size() >= MAX_DECORATE_TRANSLATIONS) + if (TranslationTables[slot].Size() >= MAX_DECORATE_TRANSLATIONS) { I_Error("Too many DECORATE translations"); } FRemapTable *newtrans = new FRemapTable; *newtrans = *this; - i = translationtables[slot].Push(newtrans); + i = TranslationTables[slot].Push(newtrans); return TRANSLATION(slot, i); } @@ -742,7 +804,7 @@ int CreateBloodTranslation(PalEntry color) if (BloodTranslationColors.Size() == 0) { // Don't use the first slot. - translationtables[TRANSLATION_Blood].Push(NULL); + TranslationTables[TRANSLATION_Blood].Push(NULL); BloodTranslationColors.Push(0); } @@ -772,7 +834,7 @@ int CreateBloodTranslation(PalEntry color) trans->Palette[i] = pe; trans->Remap[i] = entry; } - translationtables[TRANSLATION_Blood].Push(trans); + TranslationTables[TRANSLATION_Blood].Push(trans); return BloodTranslationColors.Push(color); } @@ -782,35 +844,11 @@ int CreateBloodTranslation(PalEntry color) // //---------------------------------------------------------------------------- -FRemapTable *TranslationToTable(int translation) -{ - unsigned int type = GetTranslationType(translation); - unsigned int index = GetTranslationIndex(translation); - TAutoGrowArray *slots; - - if (type <= 0 || type >= NUM_TRANSLATION_TABLES) - { - return NULL; - } - slots = &translationtables[type]; - if (index >= slots->Size()) - { - return NULL; - } - return slots->operator[](index); -} - -//---------------------------------------------------------------------------- -// -// -// -//---------------------------------------------------------------------------- - static void PushIdentityTable(int slot) { FRemapTable *table = new FRemapTable; table->MakeIdentity(); - translationtables[slot].Push(table); + TranslationTables[slot].Push(table); } //---------------------------------------------------------------------------- @@ -857,84 +895,84 @@ void R_InitTranslationTables () { for (i = 0x70; i < 0x80; i++) { // map green ramp to gray, brown, red - translationtables[TRANSLATION_Standard][0]->Remap[i] = 0x60 + (i&0xf); - translationtables[TRANSLATION_Standard][1]->Remap[i] = 0x40 + (i&0xf); - translationtables[TRANSLATION_Standard][2]->Remap[i] = 0x20 + (i&0xf); + TranslationTables[TRANSLATION_Standard][0]->Remap[i] = 0x60 + (i&0xf); + TranslationTables[TRANSLATION_Standard][1]->Remap[i] = 0x40 + (i&0xf); + TranslationTables[TRANSLATION_Standard][2]->Remap[i] = 0x20 + (i&0xf); - translationtables[TRANSLATION_Standard][0]->Palette[i] = GPalette.BaseColors[0x60 + (i&0xf)] | MAKEARGB(255,0,0,0); - translationtables[TRANSLATION_Standard][1]->Palette[i] = GPalette.BaseColors[0x40 + (i&0xf)] | MAKEARGB(255,0,0,0); - translationtables[TRANSLATION_Standard][2]->Palette[i] = GPalette.BaseColors[0x20 + (i&0xf)] | MAKEARGB(255,0,0,0); + TranslationTables[TRANSLATION_Standard][0]->Palette[i] = GPalette.BaseColors[0x60 + (i&0xf)] | MAKEARGB(255,0,0,0); + TranslationTables[TRANSLATION_Standard][1]->Palette[i] = GPalette.BaseColors[0x40 + (i&0xf)] | MAKEARGB(255,0,0,0); + TranslationTables[TRANSLATION_Standard][2]->Palette[i] = GPalette.BaseColors[0x20 + (i&0xf)] | MAKEARGB(255,0,0,0); } } else if (gameinfo.gametype == GAME_Heretic) { for (i = 225; i <= 240; i++) { - translationtables[TRANSLATION_Standard][0]->Remap[i] = 114+(i-225); // yellow - translationtables[TRANSLATION_Standard][1]->Remap[i] = 145+(i-225); // red - translationtables[TRANSLATION_Standard][2]->Remap[i] = 190+(i-225); // blue + TranslationTables[TRANSLATION_Standard][0]->Remap[i] = 114+(i-225); // yellow + TranslationTables[TRANSLATION_Standard][1]->Remap[i] = 145+(i-225); // red + TranslationTables[TRANSLATION_Standard][2]->Remap[i] = 190+(i-225); // blue - translationtables[TRANSLATION_Standard][0]->Palette[i] = GPalette.BaseColors[114+(i-225)] | MAKEARGB(255,0,0,0); - translationtables[TRANSLATION_Standard][1]->Palette[i] = GPalette.BaseColors[145+(i-225)] | MAKEARGB(255,0,0,0); - translationtables[TRANSLATION_Standard][2]->Palette[i] = GPalette.BaseColors[190+(i-225)] | MAKEARGB(255,0,0,0); + TranslationTables[TRANSLATION_Standard][0]->Palette[i] = GPalette.BaseColors[114+(i-225)] | MAKEARGB(255,0,0,0); + TranslationTables[TRANSLATION_Standard][1]->Palette[i] = GPalette.BaseColors[145+(i-225)] | MAKEARGB(255,0,0,0); + TranslationTables[TRANSLATION_Standard][2]->Palette[i] = GPalette.BaseColors[190+(i-225)] | MAKEARGB(255,0,0,0); } } else if (gameinfo.gametype == GAME_Strife) { for (i = 0x20; i <= 0x3F; ++i) { - translationtables[TRANSLATION_Standard][0]->Remap[i] = i - 0x20; - translationtables[TRANSLATION_Standard][1]->Remap[i] = i - 0x20; - translationtables[TRANSLATION_Standard][2]->Remap[i] = 0xD0 + (i&0xf); - translationtables[TRANSLATION_Standard][3]->Remap[i] = 0xD0 + (i&0xf); - translationtables[TRANSLATION_Standard][4]->Remap[i] = i - 0x20; - translationtables[TRANSLATION_Standard][5]->Remap[i] = i - 0x20; - translationtables[TRANSLATION_Standard][6]->Remap[i] = i - 0x20; + TranslationTables[TRANSLATION_Standard][0]->Remap[i] = i - 0x20; + TranslationTables[TRANSLATION_Standard][1]->Remap[i] = i - 0x20; + TranslationTables[TRANSLATION_Standard][2]->Remap[i] = 0xD0 + (i&0xf); + TranslationTables[TRANSLATION_Standard][3]->Remap[i] = 0xD0 + (i&0xf); + TranslationTables[TRANSLATION_Standard][4]->Remap[i] = i - 0x20; + TranslationTables[TRANSLATION_Standard][5]->Remap[i] = i - 0x20; + TranslationTables[TRANSLATION_Standard][6]->Remap[i] = i - 0x20; } for (i = 0x50; i <= 0x5F; ++i) { // Merchant hair - translationtables[TRANSLATION_Standard][4]->Remap[i] = 0x80 + (i&0xf); - translationtables[TRANSLATION_Standard][5]->Remap[i] = 0x10 + (i&0xf); - translationtables[TRANSLATION_Standard][6]->Remap[i] = 0x40 + (i&0xf); + TranslationTables[TRANSLATION_Standard][4]->Remap[i] = 0x80 + (i&0xf); + TranslationTables[TRANSLATION_Standard][5]->Remap[i] = 0x10 + (i&0xf); + TranslationTables[TRANSLATION_Standard][6]->Remap[i] = 0x40 + (i&0xf); } for (i = 0x80; i <= 0x8F; ++i) { - translationtables[TRANSLATION_Standard][0]->Remap[i] = 0x40 + (i&0xf); // red - translationtables[TRANSLATION_Standard][1]->Remap[i] = 0xB0 + (i&0xf); // rust - translationtables[TRANSLATION_Standard][2]->Remap[i] = 0x10 + (i&0xf); // gray - translationtables[TRANSLATION_Standard][3]->Remap[i] = 0x30 + (i&0xf); // dark green - translationtables[TRANSLATION_Standard][4]->Remap[i] = 0x50 + (i&0xf); // gold - translationtables[TRANSLATION_Standard][5]->Remap[i] = 0x60 + (i&0xf); // bright green - translationtables[TRANSLATION_Standard][6]->Remap[i] = 0x90 + (i&0xf); // blue + TranslationTables[TRANSLATION_Standard][0]->Remap[i] = 0x40 + (i&0xf); // red + TranslationTables[TRANSLATION_Standard][1]->Remap[i] = 0xB0 + (i&0xf); // rust + TranslationTables[TRANSLATION_Standard][2]->Remap[i] = 0x10 + (i&0xf); // gray + TranslationTables[TRANSLATION_Standard][3]->Remap[i] = 0x30 + (i&0xf); // dark green + TranslationTables[TRANSLATION_Standard][4]->Remap[i] = 0x50 + (i&0xf); // gold + TranslationTables[TRANSLATION_Standard][5]->Remap[i] = 0x60 + (i&0xf); // bright green + TranslationTables[TRANSLATION_Standard][6]->Remap[i] = 0x90 + (i&0xf); // blue } for (i = 0xC0; i <= 0xCF; ++i) { - translationtables[TRANSLATION_Standard][4]->Remap[i] = 0xA0 + (i&0xf); - translationtables[TRANSLATION_Standard][5]->Remap[i] = 0x20 + (i&0xf); - translationtables[TRANSLATION_Standard][6]->Remap[i] = (i&0xf); + TranslationTables[TRANSLATION_Standard][4]->Remap[i] = 0xA0 + (i&0xf); + TranslationTables[TRANSLATION_Standard][5]->Remap[i] = 0x20 + (i&0xf); + TranslationTables[TRANSLATION_Standard][6]->Remap[i] = (i&0xf); } - translationtables[TRANSLATION_Standard][6]->Remap[0xC0] = 1; + TranslationTables[TRANSLATION_Standard][6]->Remap[0xC0] = 1; for (i = 0xD0; i <= 0xDF; ++i) { - translationtables[TRANSLATION_Standard][4]->Remap[i] = 0xB0 + (i&0xf); - translationtables[TRANSLATION_Standard][5]->Remap[i] = 0x30 + (i&0xf); - translationtables[TRANSLATION_Standard][6]->Remap[i] = 0x10 + (i&0xf); + TranslationTables[TRANSLATION_Standard][4]->Remap[i] = 0xB0 + (i&0xf); + TranslationTables[TRANSLATION_Standard][5]->Remap[i] = 0x30 + (i&0xf); + TranslationTables[TRANSLATION_Standard][6]->Remap[i] = 0x10 + (i&0xf); } for (i = 0xF1; i <= 0xF6; ++i) { - translationtables[TRANSLATION_Standard][0]->Remap[i] = 0xDF + (i&0xf); + TranslationTables[TRANSLATION_Standard][0]->Remap[i] = 0xDF + (i&0xf); } for (i = 0xF7; i <= 0xFB; ++i) { - translationtables[TRANSLATION_Standard][0]->Remap[i] = i - 6; + TranslationTables[TRANSLATION_Standard][0]->Remap[i] = i - 6; } for (i = 0; i < 7; ++i) { for (int j = 0x20; j <= 0xFB; ++j) { - translationtables[TRANSLATION_Standard][i]->Palette[j] = - GPalette.BaseColors[translationtables[TRANSLATION_Standard][i]->Remap[j]] | MAKEARGB(255,0,0,0); + TranslationTables[TRANSLATION_Standard][i]->Palette[j] = + GPalette.BaseColors[TranslationTables[TRANSLATION_Standard][i]->Remap[j]] | MAKEARGB(255,0,0,0); } } } @@ -948,7 +986,7 @@ void R_InitTranslationTables () { IcePaletteRemap[i] = ColorMatcher.Pick (IcePalette[i][0], IcePalette[i][1], IcePalette[i][2]); } - FRemapTable *remap = translationtables[TRANSLATION_Standard][STD_Ice]; + FRemapTable *remap = TranslationTables[TRANSLATION_Standard][STD_Ice]; remap->Remap[0] = 0; remap->Palette[0] = 0; for (i = 1; i < 256; ++i) @@ -963,7 +1001,7 @@ void R_InitTranslationTables () // The alphatexture translation. This is just a standard index as gray mapping. PushIdentityTable(TRANSLATION_Standard); - remap = translationtables[TRANSLATION_Standard][STD_Gray]; + remap = TranslationTables[TRANSLATION_Standard][STD_Gray]; remap->Remap[0] = 0; remap->Palette[0] = 0; for (i = 1; i < 256; i++) @@ -974,7 +1012,7 @@ void R_InitTranslationTables () // Palette to grayscale ramp. For internal use only, because the remap does not map to the palette. PushIdentityTable(TRANSLATION_Standard); - remap = translationtables[TRANSLATION_Standard][STD_Grayscale]; + remap = TranslationTables[TRANSLATION_Standard][STD_Grayscale]; remap->Remap[0] = 0; remap->Palette[0] = 0; for (i = 1; i < 256; i++) @@ -1000,15 +1038,15 @@ void R_DeinitTranslationTables() { for (int i = 0; i < NUM_TRANSLATION_TABLES; ++i) { - for (unsigned int j = 0; j < translationtables[i].Size(); ++j) + for (unsigned int j = 0; j < TranslationTables[i].Size(); ++j) { - if (translationtables[i][j] != NULL) + if (TranslationTables[i][j] != NULL) { - delete translationtables[i][j]; - translationtables[i][j] = NULL; + delete TranslationTables[i][j]; + TranslationTables[i][j] = NULL; } } - translationtables[i].Clear(); + TranslationTables[i].Clear(); } BloodTranslationColors.Clear(); } @@ -1290,9 +1328,9 @@ void R_BuildPlayerTranslation (int player) R_CreatePlayerTranslation (h, s, v, colorset, &Skins[players[player].userinfo.GetSkin()], - translationtables[TRANSLATION_Players][player], - translationtables[TRANSLATION_PlayersExtra][player], - translationtables[TRANSLATION_RainPillar][player] + TranslationTables[TRANSLATION_Players][player], + TranslationTables[TRANSLATION_PlayersExtra][player], + TranslationTables[TRANSLATION_RainPillar][player] ); } @@ -1325,7 +1363,7 @@ DEFINE_ACTION_FUNCTION(_Translation, SetPlayerTranslation) PARAM_UINT(pnum); PARAM_POINTER(cls, FPlayerClass); - if (pnum >= MAXPLAYERS || tgroup >= NUM_TRANSLATION_TABLES || tnum >= translationtables[tgroup].Size()) + if (pnum >= MAXPLAYERS || tgroup >= NUM_TRANSLATION_TABLES || tnum >= TranslationTables[tgroup].Size()) { ACTION_RETURN_BOOL(false); } @@ -1338,7 +1376,7 @@ DEFINE_ACTION_FUNCTION(_Translation, SetPlayerTranslation) { PlayerSkin = R_FindSkin(Skins[PlayerSkin].Name, int(cls - &PlayerClasses[0])); R_GetPlayerTranslation(PlayerColor, GetColorSet(cls->Type, PlayerColorset), - &Skins[PlayerSkin], translationtables[tgroup][tnum]); + &Skins[PlayerSkin], TranslationTables[tgroup][tnum]); } ACTION_RETURN_BOOL(true); } @@ -1402,7 +1440,7 @@ DEFINE_ACTION_FUNCTION(_Translation, GetID) void R_ParseTrnslate() { customTranslationMap.Clear(); - translationtables[TRANSLATION_Custom].Clear(); + TranslationTables[TRANSLATION_Custom].Clear(); int lump; int lastlump = 0; @@ -1425,7 +1463,7 @@ void R_ParseTrnslate() { sc.ScriptError("Translation must be in the range [0,%d]", max); } - base = translationtables[TRANSLATION_Standard][sc.Number]; + base = TranslationTables[TRANSLATION_Standard][sc.Number]; } else if (sc.TokenType == TK_Identifier) { @@ -1434,7 +1472,7 @@ void R_ParseTrnslate() { sc.ScriptError("Base translation '%s' not found in '%s'", sc.String, newtrans.GetChars()); } - base = translationtables[GetTranslationType(tnum)][GetTranslationIndex(tnum)]; + base = TranslationTables[GetTranslationType(tnum)][GetTranslationIndex(tnum)]; } else { diff --git a/src/r_data/r_translate.h b/src/r_data/r_translate.h index d71c64d44..07338178e 100644 --- a/src/r_data/r_translate.h +++ b/src/r_data/r_translate.h @@ -108,7 +108,6 @@ private: FRemapTable *Ptr; }; -extern TAutoGrowArray translationtables[NUM_TRANSLATION_TABLES]; #define TRANSLATION_SHIFT 16 #define TRANSLATION_MASK ((1< 1) ? translationtables[TRANSLATION_Standard][t - 2]->Remap[k] : k; - PalEntry pe = GPalette.BaseColors[palindex]; + PalEntry pe; + if (t > 1) + { + auto palette = GetTranslation(TRANSLATION_Standard, t - 2)->Palette; + pe = palette[k]; + } + else GPalette.BaseColors[k]; k++; screen->Dim(pe, 1.f, j*blocksize, i*blocksize, blocksize, blocksize); }