From 34160a4354117b28285cefb56023ce235fa57697 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 31 Dec 2022 19:34:46 +0100 Subject: [PATCH] - ported the scuba mask drawers to texture IDs. These were also the last places in Duke using tileWidth and tileHeight. --- source/core/gamehud.cpp | 10 +++++++--- source/core/gamehud.h | 1 + source/core/textures/buildtiles.h | 8 -------- source/games/duke/src/hudweapon_d.cpp | 9 ++++++--- source/games/duke/src/hudweapon_r.cpp | 15 ++++++++++----- source/games/duke/src/namelist_r.h | 6 +++++- 6 files changed, 29 insertions(+), 20 deletions(-) diff --git a/source/core/gamehud.cpp b/source/core/gamehud.cpp index 54068e76d..92eb60bd1 100644 --- a/source/core/gamehud.cpp +++ b/source/core/gamehud.cpp @@ -54,13 +54,12 @@ F2DDrawer twodpsp; -void hud_drawsprite(double sx, double sy, double sz, double a, int picnum, int dashade, int dapalnum, int dastat, double alpha) +void hud_drawsprite(double sx, double sy, double sz, double a, FTextureID texid, int dashade, int dapalnum, int dastat, double alpha) { - sz *= 1. / 65536.; alpha *= (dastat & RS_TRANS1)? glblend[0].def[!!(dastat & RS_TRANS2)].alpha : 1.; int palid = TRANSLATION(Translation_Remap + curbasepal, dapalnum); - auto tex = tileGetTexture(picnum, true); + auto tex = TexMan.GetGameTexture(texid, true); DrawTexture(&twodpsp, tex, sx, sy, DTA_ScaleX, sz, DTA_ScaleY, sz, @@ -81,6 +80,11 @@ void hud_drawsprite(double sx, double sy, double sz, double a, int picnum, int d TAG_DONE); } +void hud_drawsprite(double sx, double sy, double sz, double a, int picnum, int dashade, int dapalnum, int dastat, double alpha) +{ + hud_drawsprite(sx, sy, sz / 65536., a, tileGetTextureID(picnum), dashade, dapalnum, dastat, alpha); +} + //========================================================================== // diff --git a/source/core/gamehud.h b/source/core/gamehud.h index e06b0b216..db17a68e5 100644 --- a/source/core/gamehud.h +++ b/source/core/gamehud.h @@ -6,6 +6,7 @@ extern F2DDrawer twodpsp; void DrawRateStuff(); void hud_drawsprite(double sx, double sy, double sz, double a, int picnum, int dashade, int dapalnum, int dastat, double alpha = 1); +void hud_drawsprite(double sx, double sy, double sz, double a, FTextureID texid, int dashade, int dapalnum, int dastat, double alpha = 1); // orientation bits for hud_drawsprite. enum { diff --git a/source/core/textures/buildtiles.h b/source/core/textures/buildtiles.h index 4c3fa32d1..3229a2263 100644 --- a/source/core/textures/buildtiles.h +++ b/source/core/textures/buildtiles.h @@ -24,14 +24,6 @@ inline void spritetypebase::setspritetexture(FTextureID tex) picnum = legacyTileNum(tex); } -//[[deprecated]] -inline int tileForName(const char* name) -{ - auto texid = TexMan.CheckForTexture(name, ETextureType::Any, FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_ReturnAll); - if (!texid.isValid()) return -1; - return legacyTileNum(texid); -} - //[[deprecated]] inline int tileWidth(int num) { diff --git a/source/games/duke/src/hudweapon_d.cpp b/source/games/duke/src/hudweapon_d.cpp index b49b45f86..f1e410575 100644 --- a/source/games/duke/src/hudweapon_d.cpp +++ b/source/games/duke/src/hudweapon_d.cpp @@ -144,9 +144,12 @@ void displaymasks_d(int snum, int p, double interpfrac) { if (ps[snum].scuba_on) { - int y = 200 - tileHeight(DTILE_SCUBAMASK); - hud_drawsprite(44, y, 65536, 0, DTILE_SCUBAMASK, 0, p, 2 + 16); - hud_drawsprite((320 - 43), y, 65536, 0, DTILE_SCUBAMASK, 0, p, 2 + 4 + 16); + auto scuba0 = TexMan.CheckForTexture("SCUBAMASK", ETextureType::Any); + auto tex0 = TexMan.GetGameTexture(scuba0); + + double y = 200 - tex0->GetDisplayHeight(); + hud_drawsprite(44, y, 1., 0, scuba0, 0, p, 2 + 16); + hud_drawsprite((320 - 43), y, 1, 0, scuba0, 0, p, 2 + 4 + 16); } } diff --git a/source/games/duke/src/hudweapon_r.cpp b/source/games/duke/src/hudweapon_r.cpp index 00c284aec..6bcd49dac 100644 --- a/source/games/duke/src/hudweapon_r.cpp +++ b/source/games/duke/src/hudweapon_r.cpp @@ -69,15 +69,20 @@ void displaymasks_r(int snum, int p, double interpfrac) { if (ps[snum].scuba_on) { + auto scuba0 = TexMan.CheckForTexture("SCUBAMASK0", ETextureType::Any); + auto scuba3 = TexMan.CheckForTexture("SCUBAMASK3", ETextureType::Any); + auto scuba4 = TexMan.CheckForTexture("SCUBAMASK4", ETextureType::Any); + auto tex0 = TexMan.GetGameTexture(scuba0); + auto tex4 = TexMan.GetGameTexture(scuba4); //int pin = 0; // to get the proper clock value with regards to interpolation we have add a interpfrac based offset to the value. double interpclock = PlayClock + TICSPERFRAME * interpfrac; int pin = RS_STRETCH; - hud_drawsprite((320 - (tileWidth(RTILE_SCUBAMASK) >> 1) - 15), (200 - (tileHeight(RTILE_SCUBAMASK) >> 1) + BobVal(interpclock) * 16), 49152, 0, RTILE_SCUBAMASK, 0, p, 2 + 16 + pin); - hud_drawsprite((320 - tileWidth(RTILE_SCUBAMASK + 4)), (200 - tileHeight(RTILE_SCUBAMASK + 4)), 65536, 0, RTILE_SCUBAMASK + 4, 0, p, 2 + 16 + pin); - hud_drawsprite(tileWidth(RTILE_SCUBAMASK + 4), (200 - tileHeight(RTILE_SCUBAMASK + 4)), 65536, 0, RTILE_SCUBAMASK + 4, 0, p, 2 + 4 + 16 + pin); - hud_drawsprite(35, (-1), 65536, 0, RTILE_SCUBAMASK + 3, 0, p, 2 + 16 + pin); - hud_drawsprite(285, 200, 65536, -180, RTILE_SCUBAMASK + 3, 0, p, 2 + 16 + pin); + hud_drawsprite((320 - (tex0->GetDisplayWidth() * 0.5) - 15), (200 - (tex0->GetDisplayHeight() * 0.5) + BobVal(interpclock) * 16), 0.75, 0, scuba0, 0, p, 2 + 16 + pin); + hud_drawsprite((320 - tex4->GetDisplayWidth()), (200 - tex4->GetDisplayHeight()), 1., 0, scuba4, 0, p, 2 + 16 + pin); + hud_drawsprite(tex4->GetDisplayWidth(), (200 - tex4->GetDisplayHeight()), 1., 0, scuba4, 0, p, 2 + 4 + 16 + pin); + hud_drawsprite(35, (-1), 1., 0, scuba3, 0, p, 2 + 16 + pin); + hud_drawsprite(285, 200, 1., -180, scuba3, 0, p, 2 + 16 + pin); } } diff --git a/source/games/duke/src/namelist_r.h b/source/games/duke/src/namelist_r.h index 686e570e4..033ce36c9 100644 --- a/source/games/duke/src/namelist_r.h +++ b/source/games/duke/src/namelist_r.h @@ -1000,7 +1000,11 @@ x(KNEE, 3340) x(SHOTGUN, 3350) x(HANDTHROW, 3360) x(SHOTGUNSHELLS, 3372) -x(SCUBAMASK, 3374) +x(SCUBAMASK0, 3374) +x(SCUBAMASK1, 3375) +x(SCUBAMASK2, 3376) +x(SCUBAMASK3, 3377) +x(SCUBAMASK4, 3378) x(CHAINGUN, 3380) x(SHRINKER, 3384) x(CIRCLESTUCK, 3388)