From c19fd602d51bb2ddf87869717835f14f61594af6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 9 Nov 2023 19:22:32 +0100 Subject: [PATCH] migrate to FTranslationID support So far this only adapts to the changes in the backend without making further use of this type. --- source/common/engine/i_interface.h | 1 + source/common/engine/palettecontainer.cpp | 19 ++--- source/common/engine/palettecontainer.h | 70 +++++++++++++++---- source/common/fonts/font.cpp | 2 +- source/common/fonts/hexfont.cpp | 4 +- source/common/fonts/singlelumpfont.cpp | 2 +- source/common/fonts/specialfont.cpp | 2 +- source/common/scripting/backend/codegen.cpp | 2 +- source/common/scripting/backend/codegen.h | 8 +++ .../common/scripting/interface/vmnatives.cpp | 6 +- source/common/statusbar/base_sbar.cpp | 13 ++-- source/common/statusbar/base_sbar.h | 4 +- source/core/automap.cpp | 4 +- source/core/gamecontrol.cpp | 2 +- source/core/gamehud.cpp | 2 +- source/core/precache.cpp | 2 +- source/core/rendering/scene/hw_flats.cpp | 2 +- source/core/rendering/scene/hw_sky.cpp | 2 +- source/core/rendering/scene/hw_sprites.cpp | 4 +- source/core/rendering/scene/hw_walls.cpp | 2 +- source/core/textures/hightile.cpp | 2 +- source/core/textures/texinfo.h | 1 + source/games/duke/src/d_menu.cpp | 4 +- 23 files changed, 107 insertions(+), 53 deletions(-) diff --git a/source/common/engine/i_interface.h b/source/common/engine/i_interface.h index bdc05198e..6679184de 100644 --- a/source/common/engine/i_interface.h +++ b/source/common/engine/i_interface.h @@ -10,6 +10,7 @@ class FGameTexture; class FTextureID; enum EUpscaleFlags : int; class FConfigFile; +struct FTranslationID; struct SystemCallbacks { diff --git a/source/common/engine/palettecontainer.cpp b/source/common/engine/palettecontainer.cpp index 40c73e4a4..2e85bd688 100644 --- a/source/common/engine/palettecontainer.cpp +++ b/source/common/engine/palettecontainer.cpp @@ -220,7 +220,7 @@ FRemapTable* PaletteContainer::AddRemap(FRemapTable* remap) // //---------------------------------------------------------------------------- -void PaletteContainer::UpdateTranslation(int trans, FRemapTable* remap) +void PaletteContainer::UpdateTranslation(FTranslationID trans, FRemapTable* remap) { auto newremap = AddRemap(remap); TranslationTables[GetTranslationType(trans)].SetVal(GetTranslationIndex(trans), newremap); @@ -232,7 +232,7 @@ void PaletteContainer::UpdateTranslation(int trans, FRemapTable* remap) // //---------------------------------------------------------------------------- -int PaletteContainer::AddTranslation(int slot, FRemapTable* remap, int count) +FTranslationID PaletteContainer::AddTranslation(int slot, FRemapTable* remap, int count) { uint32_t id = 0; for (int i = 0; i < count; i++) @@ -249,9 +249,9 @@ int PaletteContainer::AddTranslation(int slot, FRemapTable* remap, int count) // //---------------------------------------------------------------------------- -void PaletteContainer::CopyTranslation(int dest, int src) +void PaletteContainer::CopyTranslation(FTranslationID dest, FTranslationID src) { - TranslationTables[GetTranslationType(dest)].SetVal(GetTranslationIndex(dest), TranslationToTable(src)); + TranslationTables[GetTranslationType(dest)].SetVal(GetTranslationIndex(dest), TranslationToTable(src.index())); } //---------------------------------------------------------------------------- @@ -260,8 +260,9 @@ void PaletteContainer::CopyTranslation(int dest, int src) // //---------------------------------------------------------------------------- -FRemapTable *PaletteContainer::TranslationToTable(int translation) +FRemapTable *PaletteContainer::TranslationToTable(int translation) const { + if (IsLuminosityTranslation(translation)) return nullptr; unsigned int type = GetTranslationType(translation); unsigned int index = GetTranslationIndex(translation); @@ -278,14 +279,14 @@ FRemapTable *PaletteContainer::TranslationToTable(int translation) // //---------------------------------------------------------------------------- -int PaletteContainer::StoreTranslation(int slot, FRemapTable *remap) +FTranslationID PaletteContainer::StoreTranslation(int slot, FRemapTable *remap) { unsigned int i; auto size = NumTranslations(slot); for (i = 0; i < size; i++) { - if (*remap == *TranslationToTable(TRANSLATION(slot, i))) + if (*remap == *TranslationToTable(TRANSLATION(slot, i).index())) { // A duplicate of this translation already exists return TRANSLATION(slot, i); @@ -821,8 +822,8 @@ bool FRemapTable::AddColors(int start, int count, const uint8_t*colors, int tran } // placeholder -int R_FindCustomTranslation(FName name) +FTranslationID R_FindCustomTranslation(FName name) { - return -1; + return NO_TRANSLATION; } diff --git a/source/common/engine/palettecontainer.h b/source/common/engine/palettecontainer.h index 96413fe1f..b7869e276 100644 --- a/source/common/engine/palettecontainer.h +++ b/source/common/engine/palettecontainer.h @@ -43,6 +43,8 @@ private: }; + +// outside facing translation ID struct FTranslationID { public: @@ -67,21 +69,22 @@ public: { return ID == other.ID; } - bool operator ==(int other) const = delete; - bool operator !=(int other) const = delete; constexpr int index() const { return ID; } constexpr bool isvalid() const { - return ID > 0; + return ID >= 0; } private: int ID; }; +constexpr FTranslationID NO_TRANSLATION = FTranslationID::fromInt(0); +constexpr FTranslationID INVALID_TRANSLATION = FTranslationID::fromInt(-1); + // A class that initializes unusued pointers to NULL. This is used so that when // the TAutoGrowArray below is expanded, the new elements will be NULLed. class FRemapTablePtr @@ -107,28 +110,45 @@ enum TRANSLATIONTYPE_MASK = (255 << TRANSLATION_SHIFT) }; -inline constexpr uint32_t TRANSLATION(uint8_t a, uint32_t b) +inline constexpr FTranslationID TRANSLATION(uint8_t a, uint32_t b) { - return (a << TRANSLATION_SHIFT) | b; + return FTranslationID::fromInt((a << TRANSLATION_SHIFT) | b); } -inline constexpr uint32_t LuminosityTranslation(int range, uint8_t min, uint8_t max) +inline constexpr int MakeLuminosityTranslation(int range, uint8_t min, uint8_t max) { // ensure that the value remains positive. return ( (1 << 30) | ((range&0x3fff) << 16) | (min << 8) | max ); } +inline constexpr bool IsLuminosityTranslation(FTranslationID trans) +{ + return trans.index() > 0 && (trans.index() & (1 << 30)); +} + inline constexpr bool IsLuminosityTranslation(int trans) { return trans > 0 && (trans & (1 << 30)); } -inline constexpr int GetTranslationType(uint32_t trans) +inline constexpr int GetTranslationType(FTranslationID trans) +{ + assert(!IsLuminosityTranslation(trans)); + return (trans.index() & TRANSLATIONTYPE_MASK) >> TRANSLATION_SHIFT; +} + +inline constexpr int GetTranslationIndex(FTranslationID trans) +{ + assert(!IsLuminosityTranslation(trans)); + return (trans.index() & TRANSLATION_MASK); +} + +inline constexpr int GetTranslationType(int trans) { assert(!IsLuminosityTranslation(trans)); return (trans & TRANSLATIONTYPE_MASK) >> TRANSLATION_SHIFT; } -inline constexpr int GetTranslationIndex(uint32_t trans) +inline constexpr int GetTranslationIndex(int trans) { assert(!IsLuminosityTranslation(trans)); return (trans & TRANSLATION_MASK); @@ -162,11 +182,11 @@ public: void Clear(); int DetermineTranslucency(FileReader& file); FRemapTable* AddRemap(FRemapTable* remap); - void UpdateTranslation(int trans, FRemapTable* remap); - int AddTranslation(int slot, FRemapTable* remap, int count = 1); - void CopyTranslation(int dest, int src); - int StoreTranslation(int slot, FRemapTable* remap); - FRemapTable* TranslationToTable(int translation); + void UpdateTranslation(FTranslationID trans, FRemapTable* remap); + FTranslationID AddTranslation(int slot, FRemapTable* remap, int count = 1); + void CopyTranslation(FTranslationID dest, FTranslationID src); + FTranslationID StoreTranslation(int slot, FRemapTable* remap); + FRemapTable* TranslationToTable(int translation) const; void GenerateGlobalBrightmapFromColormap(const uint8_t* cmapdata, int numlevels); void PushIdentityTable(int slot) @@ -174,7 +194,7 @@ public: AddTranslation(slot, nullptr); } - FRemapTable* GetTranslation(int slot, int index) + FRemapTable* GetTranslation(int slot, int index) const { if (TranslationTables.Size() <= (unsigned)slot) return nullptr; return TranslationTables[slot].GetVal(index); @@ -192,6 +212,28 @@ public: return TranslationTables[slot].Size(); } + +}; + +struct LuminosityTranslationDesc +{ + int colorrange; + int lum_min; + int lum_max; + + static LuminosityTranslationDesc fromInt(int translation) + { + LuminosityTranslationDesc t; + t.colorrange = (translation >> 16) & 0x3fff; + t.lum_min = (translation >> 8) & 0xff; + t.lum_max = translation & 0xff; + return t; + } + + static LuminosityTranslationDesc fromID(FTranslationID translation) + { + return fromInt(translation.index()); + } }; extern PaletteContainer GPalette; diff --git a/source/common/fonts/font.cpp b/source/common/fonts/font.cpp index c12d254b1..c622eab3b 100644 --- a/source/common/fonts/font.cpp +++ b/source/common/fonts/font.cpp @@ -1060,7 +1060,7 @@ void FFont::LoadTranslations() for (int i = 0; i < NumTextColors; i++) { if (i == CR_UNTRANSLATED) Translations[i] = 0; - else Translations[i] = LuminosityTranslation(i*2 + TranslationType, minlum, maxlum); + else Translations[i] = MakeLuminosityTranslation(i*2 + TranslationType, minlum, maxlum); } } diff --git a/source/common/fonts/hexfont.cpp b/source/common/fonts/hexfont.cpp index 3ec2816e6..d72c50e8a 100644 --- a/source/common/fonts/hexfont.cpp +++ b/source/common/fonts/hexfont.cpp @@ -324,7 +324,7 @@ public: for (int i = 0; i < NumTextColors; i++) { if (i == CR_UNTRANSLATED) Translations[i] = 0; - else Translations[i] = LuminosityTranslation(i * 2 + 1, minlum, maxlum); + else Translations[i] = MakeLuminosityTranslation(i * 2 + 1, minlum, maxlum); } } @@ -388,7 +388,7 @@ public: for (int i = 0; i < NumTextColors; i++) { if (i == CR_UNTRANSLATED) Translations[i] = 0; - else Translations[i] = LuminosityTranslation(i * 2, minlum, maxlum); + else Translations[i] = MakeLuminosityTranslation(i * 2, minlum, maxlum); } } }; diff --git a/source/common/fonts/singlelumpfont.cpp b/source/common/fonts/singlelumpfont.cpp index b40a86bff..ca40519da 100644 --- a/source/common/fonts/singlelumpfont.cpp +++ b/source/common/fonts/singlelumpfont.cpp @@ -195,7 +195,7 @@ void FSingleLumpFont::LoadTranslations() for (int i = 0; i < NumTextColors; i++) { if (i == CR_UNTRANSLATED) Translations[i] = 0; - else Translations[i] = LuminosityTranslation(i * 2 + (FontType == FONT1 ? 1 : 0), minlum, maxlum); + else Translations[i] = MakeLuminosityTranslation(i * 2 + (FontType == FONT1 ? 1 : 0), minlum, maxlum); } } diff --git a/source/common/fonts/specialfont.cpp b/source/common/fonts/specialfont.cpp index 9c35f2a8a..6547778c0 100644 --- a/source/common/fonts/specialfont.cpp +++ b/source/common/fonts/specialfont.cpp @@ -196,7 +196,7 @@ void FSpecialFont::LoadTranslations() remap.Remap[i] = i; } } - trans = GPalette.StoreTranslation(TRANSLATION_Internal, &remap); + trans = GPalette.StoreTranslation(TRANSLATION_Internal, &remap).index(); } } diff --git a/source/common/scripting/backend/codegen.cpp b/source/common/scripting/backend/codegen.cpp index 7f3a410ca..da487fad8 100644 --- a/source/common/scripting/backend/codegen.cpp +++ b/source/common/scripting/backend/codegen.cpp @@ -49,7 +49,7 @@ extern FRandom pr_exrandom; FMemArena FxAlloc(65536); CompileEnvironment compileEnvironment; -int R_FindCustomTranslation(FName name); +FTranslationID R_FindCustomTranslation(FName name); struct FLOP { diff --git a/source/common/scripting/backend/codegen.h b/source/common/scripting/backend/codegen.h index e1ad37856..3f73a09c5 100644 --- a/source/common/scripting/backend/codegen.h +++ b/source/common/scripting/backend/codegen.h @@ -48,6 +48,7 @@ #include "types.h" #include "vmintern.h" #include "c_cvars.h" +#include "palettecontainer.h" struct FState; // needed for FxConstant. Maybe move the state constructor to a subclass later? @@ -508,6 +509,13 @@ public: isresolved = true; } + FxConstant(FTranslationID state, const FScriptPosition& pos) : FxExpression(EFX_Constant, pos) + { + value.Int = state.index(); + ValueType = value.Type = TypeTranslationID; + isresolved = true; + } + FxConstant(VMFunction* state, const FScriptPosition& pos) : FxExpression(EFX_Constant, pos) { value.pointer = state; diff --git a/source/common/scripting/interface/vmnatives.cpp b/source/common/scripting/interface/vmnatives.cpp index 6242d556b..317ae6bfd 100644 --- a/source/common/scripting/interface/vmnatives.cpp +++ b/source/common/scripting/interface/vmnatives.cpp @@ -1372,16 +1372,16 @@ DEFINE_ACTION_FUNCTION_NATIVE(DObject, FindFunction, FindFunctionPointer) ACTION_RETURN_POINTER(FindFunctionPointer(cls, fn.GetIndex())); } -int R_FindCustomTranslation(FName name); +FTranslationID R_FindCustomTranslation(FName name); static int ZFindTranslation(int intname) { - return R_FindCustomTranslation(ENamedName(intname)); + return R_FindCustomTranslation(ENamedName(intname)).index(); } static int MakeTransID(int g, int s) { - return TRANSLATION(g, s); + return TRANSLATION(g, s).index(); } DEFINE_ACTION_FUNCTION_NATIVE(_Translation, GetID, ZFindTranslation) diff --git a/source/common/statusbar/base_sbar.cpp b/source/common/statusbar/base_sbar.cpp index d7908233c..51950e8b2 100644 --- a/source/common/statusbar/base_sbar.cpp +++ b/source/common/statusbar/base_sbar.cpp @@ -601,7 +601,7 @@ void DStatusBarCore::DrawGraphic(FGameTexture* tex, double x, double y, int flag DTA_ClipBottom, twod->GetHeight(), DTA_ClipRight, clipwidth < 0? twod->GetWidth() : int(x + boxwidth * clipwidth), DTA_Color, color, - DTA_TranslationIndex, translation? translation : (flags & DI_TRANSLATABLE) ? GetTranslation() : 0, + DTA_TranslationIndex, translation? translation : (flags & DI_TRANSLATABLE) ? GetTranslation().index() : 0, DTA_ColorOverlay, (flags & DI_DIM) ? MAKEARGB(170, 0, 0, 0) : 0, DTA_Alpha, Alpha, DTA_AlphaChannel, !!(flags & DI_ALPHAMAPPED), @@ -686,7 +686,7 @@ void DStatusBarCore::DrawRotated(FGameTexture* tex, double x, double y, int flag DTA_Color, color, DTA_CenterOffsetRel, !!(flags & DI_ITEM_RELCENTER), DTA_Rotate, angle, - DTA_TranslationIndex, translation ? translation : (flags & DI_TRANSLATABLE) ? GetTranslation() : 0, + DTA_TranslationIndex, translation ? translation : (flags & DI_TRANSLATABLE) ? GetTranslation().index() : 0, DTA_ColorOverlay, (flags & DI_DIM) ? MAKEARGB(170, 0, 0, 0) : 0, DTA_Alpha, Alpha, DTA_AlphaChannel, !!(flags & DI_ALPHAMAPPED), @@ -704,7 +704,7 @@ void DStatusBarCore::DrawRotated(FGameTexture* tex, double x, double y, int flag // //============================================================================ -void DStatusBarCore::DrawString(FFont* font, const FString& cstring, double x, double y, int flags, double Alpha, int translation, int spacing, EMonospacing monospacing, int shadowX, int shadowY, double scaleX, double scaleY, int pt, int style) +void DStatusBarCore::DrawString(FFont* font, const FString& cstring, double x, double y, int flags, double Alpha, int translation, int spacing, EMonospacing monospacing, int shadowX, int shadowY, double scaleX, double scaleY, FTranslationID pt, int style) { bool monospaced = monospacing != EMonospacing::Off; double dx = 0; @@ -823,11 +823,11 @@ void DStatusBarCore::DrawString(FFont* font, const FString& cstring, double x, d DTA_FillColor, 0, TAG_DONE); } - DrawChar(twod, font, pt == 0? fontcolor : CR_NATIVEPAL, rx, ry, ch, + DrawChar(twod, font, pt == NO_TRANSLATION? fontcolor : CR_NATIVEPAL, rx, ry, ch, DTA_DestWidthF, rw, DTA_DestHeightF, rh, DTA_Alpha, Alpha, - DTA_TranslationIndex, pt, + DTA_TranslationIndex, pt.index(), DTA_LegacyRenderStyle, ERenderStyle(style), TAG_DONE); @@ -840,10 +840,11 @@ void DStatusBarCore::DrawString(FFont* font, const FString& cstring, double x, d } } -void SBar_DrawString(DStatusBarCore* self, DHUDFont* font, const FString& string, double x, double y, int flags, int trans, double alpha, int wrapwidth, int linespacing, double scaleX, double scaleY, int pt, int style) +void SBar_DrawString(DStatusBarCore* self, DHUDFont* font, const FString& string, double x, double y, int flags, int trans, double alpha, int wrapwidth, int linespacing, double scaleX, double scaleY, int pt_, int style) { if (font == nullptr || font->mFont == nullptr) ThrowAbortException(X_READ_NIL, nullptr); if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function"); + auto pt = FTranslationID::fromInt(pt_); // resolve auto-alignment before making any adjustments to the position values. if (!(flags & DI_SCREEN_MANUAL_ALIGN)) diff --git a/source/common/statusbar/base_sbar.h b/source/common/statusbar/base_sbar.h index f095ab80d..444e5257a 100644 --- a/source/common/statusbar/base_sbar.h +++ b/source/common/statusbar/base_sbar.h @@ -179,7 +179,7 @@ public: void BeginHUD(int resW, int resH, double Alpha, bool forceScaled = false); void SetSize(int reltop = 32, int hres = 320, int vres = 200, int hhres = -1, int hvres = -1); virtual DVector2 GetHUDScale() const; - virtual uint32_t GetTranslation() const { return 0; } + virtual FTranslationID GetTranslation() const { return NO_TRANSLATION; } void SetDrawSize(int reltop, int hres, int vres); virtual void SetScale(); void ValidateResolution(int& hres, int& vres) const; @@ -188,7 +188,7 @@ public: void DrawGraphic(FTextureID texture, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY, ERenderStyle style = STYLE_Translucent, PalEntry color = 0xffffffff, int translation = 0, double clipwidth = -1.0); void DrawRotated(FTextureID texture, double x, double y, int flags, double angle, double Alpha, double scaleX, double scaleY, PalEntry color = 0xffffffff, int translation = 0, ERenderStyle style = STYLE_Translucent); void DrawRotated(FGameTexture* tex, double x, double y, int flags, double angle, double Alpha, double scaleX, double scaleY, PalEntry color = 0xffffffff, int translation = 0, ERenderStyle style = STYLE_Translucent); - void DrawString(FFont* font, const FString& cstring, double x, double y, int flags, double Alpha, int translation, int spacing, EMonospacing monospacing, int shadowX, int shadowY, double scaleX, double scaleY, int pt, int style); + void DrawString(FFont* font, const FString& cstring, double x, double y, int flags, double Alpha, int translation, int spacing, EMonospacing monospacing, int shadowX, int shadowY, double scaleX, double scaleY, FTranslationID pt, int style); void TransformRect(double& x, double& y, double& w, double& h, int flags = 0); void Fill(PalEntry color, double x, double y, double w, double h, int flags = 0); void SetClipRect(double x, double y, double w, double h, int flags = 0); diff --git a/source/core/automap.cpp b/source/core/automap.cpp index 8c899d8da..1cef14907 100644 --- a/source/core/automap.cpp +++ b/source/core/automap.cpp @@ -527,7 +527,7 @@ static void renderDrawMapView(const DVector2& cpos, const DVector2& cangvect, co auto flortex = sect->floortexture; if (!flortex.isValid()) continue; - int translation = TRANSLATION(Translation_Remap + curbasepal, sector[i].floorpal); + int translation = TRANSLATION(Translation_Remap + curbasepal, sector[i].floorpal).index(); PalEntry light = shadeToLight(sector[i].floorshade); for (auto section : sectionsPerSector[i]) @@ -580,7 +580,7 @@ static void renderDrawMapView(const DVector2& cpos, const DVector2& cangvect, co color.a = uint8_t(alpha * 255); } - int translation = TRANSLATION(Translation_Remap + curbasepal, actor->spr.pal); + int translation = TRANSLATION(Translation_Remap + curbasepal, actor->spr.pal).index(); const static unsigned indices[] = { 0, 1, 2, 0, 2, 3 }; twod->AddPoly(TexMan.GetGameTexture(actor->spr.spritetexture(), true), vertices.Data(), vertices.Size(), indices, 6, translation, color, rs, &viewport3d); } diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 3ee7a0676..e7472ee03 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -1540,7 +1540,7 @@ DEFINE_ACTION_FUNCTION(_Raze, PickTexture) PARAM_PROLOGUE; PARAM_INT(texid); TexturePick pick; - if (PickTexture(TexMan.GetGameTexture(FSetTextureID(texid)), TRANSLATION(Translation_Remap, 0), pick)) + if (PickTexture(TexMan.GetGameTexture(FSetTextureID(texid)), TRANSLATION(Translation_Remap, 0).index(), pick)) { ACTION_RETURN_INT(pick.texture->GetID().GetIndex()); } diff --git a/source/core/gamehud.cpp b/source/core/gamehud.cpp index a46f2384d..732d1c316 100644 --- a/source/core/gamehud.cpp +++ b/source/core/gamehud.cpp @@ -57,7 +57,7 @@ F2DDrawer twodpsp; void hud_drawsprite(double sx, double sy, double sz, double a, FTextureID texid, int dashade, int dapalnum, int dastat, double alpha) { alpha *= (dastat & RS_TRANS1)? glblend[0].def[!!(dastat & RS_TRANS2)].alpha : 1.; - int palid = TRANSLATION(Translation_Remap + curbasepal, dapalnum); + int palid = TRANSLATION(Translation_Remap + curbasepal, dapalnum).index(); auto tex = TexMan.GetGameTexture(texid, true); diff --git a/source/core/precache.cpp b/source/core/precache.cpp index 76a67c2cf..89581d657 100644 --- a/source/core/precache.cpp +++ b/source/core/precache.cpp @@ -63,7 +63,7 @@ static void doprecache(FTextureID texid, int palette) { if ((palette < (MAXPALOOKUPS - RESERVEDPALS)) && (!lookups.checkTable(palette))) return; - int palid = TRANSLATION(Translation_Remap + curbasepal, palette); + int palid = TRANSLATION(Translation_Remap + curbasepal, palette).index(); auto tex = TexMan.GetGameTexture(texid); PrecacheTex(tex, palid); diff --git a/source/core/rendering/scene/hw_flats.cpp b/source/core/rendering/scene/hw_flats.cpp index c91756057..d018786a1 100644 --- a/source/core/rendering/scene/hw_flats.cpp +++ b/source/core/rendering/scene/hw_flats.cpp @@ -254,7 +254,7 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent) } - state.SetMaterial(texture, UF_Texture, 0, Sprite == nullptr? CLAMP_NONE : CLAMP_XY, TRANSLATION(Translation_Remap + curbasepal, palette), -1); + state.SetMaterial(texture, UF_Texture, 0, Sprite == nullptr? CLAMP_NONE : CLAMP_XY, TRANSLATION(Translation_Remap + curbasepal, palette).index(), -1); state.SetLightIndex(dynlightindex); state.Draw(DT_Triangles, vertindex, vertcount); diff --git a/source/core/rendering/scene/hw_sky.cpp b/source/core/rendering/scene/hw_sky.cpp index beeb9ccf3..aec22cb53 100644 --- a/source/core/rendering/scene/hw_sky.cpp +++ b/source/core/rendering/scene/hw_sky.cpp @@ -56,7 +56,7 @@ void initSkyInfo(HWDrawInfo *di, HWSkyInfo* sky, sectortype* sector, int plane) SkyDefinition skydef; if (!skytex) { - int remap = TRANSLATION(Translation_Remap + curbasepal, palette); + int remap = TRANSLATION(Translation_Remap + curbasepal, palette).index(); skydef = getSky(texid); int tw = (int)tex->GetDisplayWidth(); diff --git a/source/core/rendering/scene/hw_sprites.cpp b/source/core/rendering/scene/hw_sprites.cpp index 369168d17..3e47683bd 100644 --- a/source/core/rendering/scene/hw_sprites.cpp +++ b/source/core/rendering/scene/hw_sprites.cpp @@ -115,7 +115,7 @@ void HWSprite::DrawSprite(HWDrawInfo* di, FRenderState& state, bool translucent) if (modelframe == 0) { - state.SetMaterial(texture, UF_Texture, 0, CLAMP_XY, TRANSLATION(Translation_Remap + curbasepal, palette), -1); + state.SetMaterial(texture, UF_Texture, 0, CLAMP_XY, TRANSLATION(Translation_Remap + curbasepal, palette).index(), -1); state.SetNormal(0, 0, 0); @@ -157,7 +157,7 @@ void HWSprite::DrawSprite(HWDrawInfo* di, FRenderState& state, bool translucent) mr.BeginDrawModel(RenderStyle, nullptr, rotmat, mirrored); TArray a; mr.SetupFrame(model, 0, 0, 0, a, 0); - model->RenderFrame(&mr, TexMan.GetGameTexture(model->GetPaletteTexture()), 0, 0, 0.f, TRANSLATION(Translation_Remap + curbasepal, palette), nullptr, a, 0); + model->RenderFrame(&mr, TexMan.GetGameTexture(model->GetPaletteTexture()), 0, 0, 0.f, TRANSLATION(Translation_Remap + curbasepal, palette).index(), nullptr, a, 0); mr.EndDrawModel(RenderStyle, nullptr); state.SetDepthFunc(DF_Less); state.SetVertexBuffer(screen->mVertexData); diff --git a/source/core/rendering/scene/hw_walls.cpp b/source/core/rendering/scene/hw_walls.cpp index 8fccda3fa..b00df04a7 100644 --- a/source/core/rendering/scene/hw_walls.cpp +++ b/source/core/rendering/scene/hw_walls.cpp @@ -189,7 +189,7 @@ void HWWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags) { SetLightAndFog(di, state, fade, palette, shade, visibility, alpha); - state.SetMaterial(texture, UF_Texture, 0, (flags & (HWF_CLAMPX | HWF_CLAMPY)), TRANSLATION(Translation_Remap + curbasepal, palette), -1); + state.SetMaterial(texture, UF_Texture, 0, (flags & (HWF_CLAMPX | HWF_CLAMPY)), TRANSLATION(Translation_Remap + curbasepal, palette).index(), -1); if (Sprite == nullptr) { diff --git a/source/core/textures/hightile.cpp b/source/core/textures/hightile.cpp index 7fd051486..e271d4c23 100644 --- a/source/core/textures/hightile.cpp +++ b/source/core/textures/hightile.cpp @@ -373,7 +373,7 @@ bool PickTexture(FGameTexture* tex, int paletteid, TexturePick& pick, bool wanti applytint = true; if (!(h.tintFlags & TINTF_APPLYOVERPALSWAP)) useremap = 0; } - pick.translation = IsLuminosityTranslation(paletteid)? paletteid : paletteid == 0? 0 : TRANSLATION(usepalette + Translation_Remap, useremap); + pick.translation = IsLuminosityTranslation(paletteid)? paletteid : paletteid == 0? 0 : TRANSLATION(usepalette + Translation_Remap, useremap).index(); } else pick.translation |= 0x80000000; } diff --git a/source/core/textures/texinfo.h b/source/core/textures/texinfo.h index 39fb467fc..2fec52ec4 100644 --- a/source/core/textures/texinfo.h +++ b/source/core/textures/texinfo.h @@ -4,6 +4,7 @@ #include "gamefuncs.h" #include "tiletexture.h" #include "s_soundinternal.h" +#include "palettecontainer.h" class FGameTexture; // extended texture info for which there is no room in the texture manager. diff --git a/source/games/duke/src/d_menu.cpp b/source/games/duke/src/d_menu.cpp index 737f70c62..0be75176f 100644 --- a/source/games/duke/src/d_menu.cpp +++ b/source/games/duke/src/d_menu.cpp @@ -125,7 +125,7 @@ FSavegameInfo GameInterface::GetSaveSig() void GameInterface::DrawPlayerSprite(const DVector2& origin, bool onteam) { int mclock = I_GetBuildTime(); - int color = TRANSLATION(Translation_Remap, playercolor2lookup(playercolor)); + auto color = TRANSLATION(Translation_Remap, playercolor2lookup(playercolor)); auto basetex = TexMan.CheckForTexture("PLAYERWALK", ETextureType::Any); if (!basetex.isValid()) return; // these are normal in-game animations. Duke has 4 frames, RR has 8, each with 5 rotations that must have consecutive IDs. @@ -136,7 +136,7 @@ void GameInterface::DrawPlayerSprite(const DVector2& origin, bool onteam) double scale = isRR() ? 0.375 : 0.75; double scaley = isRR() ? 0.3 : 0.75; - DrawTexture(twod, tex, x, y, DTA_FullscreenScale, FSMode_Fit320x200, DTA_TranslationIndex, color, DTA_ScaleX, scale, DTA_ScaleY, scaley, TAG_DONE); + DrawTexture(twod, tex, x, y, DTA_FullscreenScale, FSMode_Fit320x200, DTA_TranslationIndex, color.index(), DTA_ScaleX, scale, DTA_ScaleY, scaley, TAG_DONE); } END_DUKE_NS