From 169d708547f80bced6ce9afcd30afc7eb77fdd35 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 23 Nov 2020 08:55:02 +0100 Subject: [PATCH] - removed all remaining uses of tilesiz. --- source/build/src/engine.cpp | 2 +- source/core/textures/buildtiles.cpp | 1 - source/core/textures/buildtiles.h | 12 ------------ source/exhumed/src/exhumed.cpp | 16 ++++++++-------- source/exhumed/src/lighting.cpp | 4 ++-- source/exhumed/src/player.cpp | 2 +- source/exhumed/src/ramses.cpp | 2 +- source/exhumed/src/sequence.cpp | 4 ++-- source/games/duke/src/actors_r.cpp | 4 ++-- source/games/duke/src/game.cpp | 4 ++-- source/games/duke/src/hudweapon_r.cpp | 6 +++--- source/games/duke/src/sbar_d.cpp | 2 +- source/games/duke/src/sbar_r.cpp | 2 +- source/sw/src/jsector.cpp | 2 +- source/sw/src/panel.cpp | 2 +- source/sw/src/sbar.cpp | 8 ++++---- source/sw/src/weapon.cpp | 2 +- 17 files changed, 31 insertions(+), 44 deletions(-) diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index c57f3fddc..9c2062fd6 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -1775,7 +1775,7 @@ void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang) auto const spr = (uspritetype * )&sprite[tsprite[s].owner]; if ((spr->cstat&48) == 32) { - const int32_t xspan = tilesiz[spr->picnum].x; + const int32_t xspan = tileWidth(spr->picnum); int32_t npoints = 0; vec2_t v1 = { spr->x, spr->y }, v2, v3, v4; diff --git a/source/core/textures/buildtiles.cpp b/source/core/textures/buildtiles.cpp index ef1193075..653dd717c 100644 --- a/source/core/textures/buildtiles.cpp +++ b/source/core/textures/buildtiles.cpp @@ -928,7 +928,6 @@ void processSetAnim(const char* cmd, FScriptPosition& pos, SetAnim& imp) TileFiles.setAnim(imp.tile1, imp.type, imp.speed, count); } -TileSiz tilesiz; PicAnm picanm; #if 0 // this only gets in if unavoidable. It'd be preferable if the script side can solely operate on texture names. diff --git a/source/core/textures/buildtiles.h b/source/core/textures/buildtiles.h index 0e9941ae6..c875f7084 100644 --- a/source/core/textures/buildtiles.h +++ b/source/core/textures/buildtiles.h @@ -395,17 +395,6 @@ inline const uint8_t* tileRawData(int num) } // Some hacks to allow accessing the no longer existing arrays as if they still were arrays to avoid changing hundreds of lines of code. -struct TileSiz -{ - const vec2_16_t operator[](size_t index) - { - assert(index < MAXTILES); - vec2_16_t v = { (int16_t)TileFiles.tiledata[index].texture->GetDisplayWidth(), (int16_t)TileFiles.tiledata[index].texture->GetDisplayHeight() }; - return v; - } -}; -extern TileSiz tilesiz; - struct PicAnm { picanm_t& operator[](size_t index) @@ -416,7 +405,6 @@ struct PicAnm }; extern PicAnm picanm; -// Helpers to read the refactored tilesiz array. inline int tileWidth(int num) { assert(num < MAXTILES); diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index e8010126b..f905fd4e9 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -242,7 +242,7 @@ void DrawClock() int v2 = nVal & 0xF; int yPos = 32 - tileHeight(v2 + kClockSymbol1) / 2; - CopyTileToBitmap(v2 + kClockSymbol1, kTile3603, ebp - tilesiz[v2 + kClockSymbol1].x / 2, yPos); + CopyTileToBitmap(v2 + kClockSymbol1, kTile3603, ebp - tileWidth(v2 + kClockSymbol1) / 2, yPos); ebp -= 15; @@ -583,7 +583,7 @@ void CopyTileToBitmap(short nSrcTile, short nDestTile, int xPos, int yPos) const uint8_t *pSrc = tilePtr(nSrcTile); - for (int x = 0; x < tilesiz[nSrcTile].x; x++) + for (int x = 0; x < tileWidth(nSrcTile); x++) { pDest += destYSize; @@ -667,11 +667,11 @@ void SaveTextureState() fw->Write(&loaded, 1); if (Worktile) fw->Write(Worktile, WorktileSize); auto pixels = TileFiles.tileMakeWritable(kTile3603); - fw->Write(pixels, tilesiz[kTile3603].x * tilesiz[kTile3603].y); + fw->Write(pixels, tileWidth(kTile3603) * tileHeight(kTile3603)); pixels = TileFiles.tileMakeWritable(kEnergy1); - fw->Write(pixels, tilesiz[kEnergy1].x * tilesiz[kEnergy1].y); + fw->Write(pixels, tileWidth(kEnergy1) * tileHeight(kEnergy1)); pixels = TileFiles.tileMakeWritable(kEnergy2); - fw->Write(pixels, tilesiz[kEnergy2].x * tilesiz[kEnergy2].y); + fw->Write(pixels, tileWidth(kEnergy2) * tileHeight(kEnergy2)); } @@ -689,11 +689,11 @@ void LoadTextureState() fr.Read(Worktile, WorktileSize); } auto pixels = TileFiles.tileMakeWritable(kTile3603); - fr.Read(pixels, tilesiz[kTile3603].x * tilesiz[kTile3603].y); + fr.Read(pixels, tileWidth(kTile3603) * tileHeight(kTile3603)); pixels = TileFiles.tileMakeWritable(kEnergy1); - fr.Read(pixels, tilesiz[kEnergy1].x * tilesiz[kEnergy1].y); + fr.Read(pixels, tileWidth(kEnergy1) * tileHeight(kEnergy1)); pixels = TileFiles.tileMakeWritable(kEnergy2); - fr.Read(pixels, tilesiz[kEnergy2].x * tilesiz[kEnergy2].y); + fr.Read(pixels, tileWidth(kEnergy2) * tileHeight(kEnergy2)); TileFiles.InvalidateTile(kTileRamsesWorkTile); TileFiles.InvalidateTile(kTile3603); TileFiles.InvalidateTile(kEnergy1); diff --git a/source/exhumed/src/lighting.cpp b/source/exhumed/src/lighting.cpp index 8360270ea..281fd86c8 100644 --- a/source/exhumed/src/lighting.cpp +++ b/source/exhumed/src/lighting.cpp @@ -630,7 +630,7 @@ void AddFlow(int nSprite, int nSpeed, int b) short nPic = sector[var_18].floorpicnum; short nAngle = sprite[nSprite].ang; - sFlowInfo[nFlow].field_14 = (tilesiz[nPic].x << 14) - 1; + sFlowInfo[nFlow].field_14 = (tileWidth(nPic) << 14) - 1; sFlowInfo[nFlow].field_18 = (tileHeight(nPic) << 14) - 1; sFlowInfo[nFlow].field_C = -bcos(nAngle) * nSpeed; sFlowInfo[nFlow].field_10 = bsin(nAngle) * nSpeed; @@ -649,7 +649,7 @@ void AddFlow(int nSprite, int nSpeed, int b) var_18 = nSprite; short nPic = wall[var_18].picnum; - sFlowInfo[nFlow].field_14 = (tilesiz[nPic].x * wall[var_18].xrepeat) << 8; + sFlowInfo[nFlow].field_14 = (tileWidth(nPic) * wall[var_18].xrepeat) << 8; sFlowInfo[nFlow].field_18 = (tileHeight(nPic) * wall[var_18].yrepeat) << 8; sFlowInfo[nFlow].field_C = -bcos(nAngle) * nSpeed; sFlowInfo[nFlow].field_10 = bsin(nAngle) * nSpeed; diff --git a/source/exhumed/src/player.cpp b/source/exhumed/src/player.cpp index b79e00405..99375abcc 100644 --- a/source/exhumed/src/player.cpp +++ b/source/exhumed/src/player.cpp @@ -243,7 +243,7 @@ void InitPlayerInventory(short nPlayer) auto pixels = tilePtr(kTile3571 + nPlayer); - nPlayerColor[nPlayer] = pixels[tilesiz[nPlayer + kTile3571].x * tileHeight(nPlayer + kTile3571) / 2]; + nPlayerColor[nPlayer] = pixels[tileWidth(nPlayer + kTile3571) * tileHeight(nPlayer + kTile3571) / 2]; } // done diff --git a/source/exhumed/src/ramses.cpp b/source/exhumed/src/ramses.cpp index d285799ed..7a4c03300 100644 --- a/source/exhumed/src/ramses.cpp +++ b/source/exhumed/src/ramses.cpp @@ -276,7 +276,7 @@ void DoSpiritHead() { int srctile = nMouthTile + 598; auto src = tilePtr(srctile); - int sizx = tilesiz[srctile].x; + int sizx = tileWidth(srctile); int sizy = tileHeight(srctile); int workptr = 212 * (97 - sizx / 2) + 159 - sizy; int srcptr = 0; diff --git a/source/exhumed/src/sequence.cpp b/source/exhumed/src/sequence.cpp index b279f69fa..86227eb86 100644 --- a/source/exhumed/src/sequence.cpp +++ b/source/exhumed/src/sequence.cpp @@ -333,7 +333,7 @@ void seq_LoadSequences() #endif nShadowPic = seq_GetFirstSeqPicnum(kSeqShadow); - nShadowWidth = tilesiz[nShadowPic].x; + nShadowWidth = tileWidth(nShadowPic); nFlameHeight = tileHeight(seq_GetFirstSeqPicnum(kSeqFirePoof)); @@ -618,7 +618,7 @@ int seq_PlotSequence(short nSprite, short edx, short nFrame, short ecx) { pTSprite->picnum = nShadowPic; - int edx = ((tilesiz[nPict].x << 5) / nShadowWidth) - ((nFloorZ - pTSprite->z) >> 10); + int edx = ((tileWidth(nPict) << 5) / nShadowWidth) - ((nFloorZ - pTSprite->z) >> 10); if (edx < 1) { edx = 1; } diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 018c89455..3d10fffb1 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1283,7 +1283,7 @@ static bool weaponhitwall(DDukeActor *proj, int wal, const vec3_t& oldpos) j->s.yrepeat = 8; j->s.cstat = 16; j->s.ang = (j->s.ang + 512) & 2047; - j->s.clipdist = mulscale7(s->xrepeat, tilesiz[s->picnum].x); + j->s.clipdist = mulscale7(s->xrepeat, tileWidth(s->picnum)); } deletesprite(proj); return true; @@ -2080,7 +2080,7 @@ static void rrra_specialstats() { s->xrepeat <<= 1; s->yrepeat <<= 1; - s->clipdist = mulscale7(s->xrepeat, tilesiz[s->picnum].x); + s->clipdist = mulscale7(s->xrepeat, tileWidth(s->picnum)); } else if (enemysizecheat == 2) { diff --git a/source/games/duke/src/game.cpp b/source/games/duke/src/game.cpp index fd103596d..142f33e86 100644 --- a/source/games/duke/src/game.cpp +++ b/source/games/duke/src/game.cpp @@ -210,11 +210,11 @@ static void setupbackdrop() { for (int i = 0; i < MAXUSERTILES; i++) { - if (tilesiz[i].x == 512) + if (tileWidth(i) == 512) { defineSky(i, 32768, 1, pskyoff); } - else if (tilesiz[i].x == 1024) + else if (tileWidth(i) == 1024) { defineSky(i, 32768, 0, pskyoff); } diff --git a/source/games/duke/src/hudweapon_r.cpp b/source/games/duke/src/hudweapon_r.cpp index 228b23cfa..4e1ab6a90 100644 --- a/source/games/duke/src/hudweapon_r.cpp +++ b/source/games/duke/src/hudweapon_r.cpp @@ -80,9 +80,9 @@ void displaymasks_r(int snum, double smoothratio) // to get the proper clock value with regards to interpolation we have add a smoothratio based offset to the value. double interpclock = ud.levelclock + (TICSPERFRAME/65536.) * smoothratio; int pin = RS_STRETCH; - hud_drawsprite((320 - (tilesiz[SCUBAMASK].x >> 1) - 15), (200 - (tileHeight(SCUBAMASK) >> 1) + bsinf(interpclock, -10)), 49152, 0, SCUBAMASK, 0, p, 2 + 16 + pin); - hud_drawsprite((320 - tilesiz[SCUBAMASK + 4].x), (200 - tileHeight(SCUBAMASK + 4)), 65536, 0, SCUBAMASK + 4, 0, p, 2 + 16 + pin); - hud_drawsprite(tilesiz[SCUBAMASK + 4].x, (200 - tileHeight(SCUBAMASK + 4)), 65536, 0, SCUBAMASK + 4, 0, p, 2 + 4 + 16 + pin); + hud_drawsprite((320 - (tileWidth(SCUBAMASK) >> 1) - 15), (200 - (tileHeight(SCUBAMASK) >> 1) + bsinf(interpclock, -10)), 49152, 0, SCUBAMASK, 0, p, 2 + 16 + pin); + hud_drawsprite((320 - tileWidth(SCUBAMASK + 4)), (200 - tileHeight(SCUBAMASK + 4)), 65536, 0, SCUBAMASK + 4, 0, p, 2 + 16 + pin); + hud_drawsprite(tileWidth(SCUBAMASK + 4), (200 - tileHeight(SCUBAMASK + 4)), 65536, 0, SCUBAMASK + 4, 0, p, 2 + 4 + 16 + pin); hud_drawsprite(35, (-1), 65536, 0, SCUBAMASK + 3, 0, p, 2 + 16 + pin); hud_drawsprite(285, 200, 65536, 1024, SCUBAMASK + 3, 0, p, 2 + 16 + pin); } diff --git a/source/games/duke/src/sbar_d.cpp b/source/games/duke/src/sbar_d.cpp index c47347866..dd90477d7 100644 --- a/source/games/duke/src/sbar_d.cpp +++ b/source/games/duke/src/sbar_d.cpp @@ -388,7 +388,7 @@ public: auto p = &ps[snum]; int h = tileHeight(BOTTOMSTATUSBAR); int top = 200 - h; - int left = (320 - tilesiz[BOTTOMSTATUSBAR].x) / 2; + int left = (320 - tileWidth(BOTTOMSTATUSBAR)) / 2; BeginStatusBar(320, 200, h); DrawInventory(p, 160, 154, 0); if (hud_size == Hud_StbarOverlay) Set43ClipRect(); diff --git a/source/games/duke/src/sbar_r.cpp b/source/games/duke/src/sbar_r.cpp index 14280b2b6..92aaaf061 100644 --- a/source/games/duke/src/sbar_r.cpp +++ b/source/games/duke/src/sbar_r.cpp @@ -348,7 +348,7 @@ public: double h = tileHeight(BOTTOMSTATUSBAR) * scale; double wh = 0; if (hud_size < Hud_Stbar) wh = tileHeight(WEAPONBAR) * scale; - double left = (320 - tilesiz[BOTTOMSTATUSBAR].x * scale) / 2; + double left = (320 - tileWidth(BOTTOMSTATUSBAR) * scale) / 2; double top = 200 - h; BeginStatusBar(320, 200, wh + h); diff --git a/source/sw/src/jsector.cpp b/source/sw/src/jsector.cpp index 81533527b..8fa082401 100644 --- a/source/sw/src/jsector.cpp +++ b/source/sw/src/jsector.cpp @@ -462,7 +462,7 @@ void JS_InitMirrors(void) void drawroomstotile(int daposx, int daposy, int daposz, fixed_t daq16ang, fixed_t daq16horiz, short dacursectnum, short tilenume) { - TileFiles.MakeCanvas(tilenume, tilesiz[tilenume].x, tileHeight(tilenume)); + TileFiles.MakeCanvas(tilenume, tileWidth(tilenume), tileHeight(tilenume)); auto canvas = renderSetTarget(tilenume); if (!canvas) return; diff --git a/source/sw/src/panel.cpp b/source/sw/src/panel.cpp index 7cc4c783f..7344dec66 100644 --- a/source/sw/src/panel.cpp +++ b/source/sw/src/panel.cpp @@ -4024,7 +4024,7 @@ SpawnOnFire(PLAYERp pp) { fire = pSpawnSprite(pp, &ps_OnFire[RANDOM_P2(8<<8)>>8], PRI_FRONT, x, ON_FIRE_Y_BOT); SET(fire->flags, PANF_WEAPON_SPRITE); - x += tilesiz[fire->picndx].x; + x += tileWidth(fire->picndx); } } diff --git a/source/sw/src/sbar.cpp b/source/sw/src/sbar.cpp index 9dbb243ce..4562019c9 100644 --- a/source/sw/src/sbar.cpp +++ b/source/sw/src/sbar.cpp @@ -217,7 +217,7 @@ private: font_pic = font_base[color] + (ch - '0'); DrawGraphic(tileGetTexture(font_pic), x, ys, DI_ITEM_LEFT_TOP, 1, -1, -1, 1, 1, shadeToLight(shade)); - x += tilesiz[font_pic].x + 1; + x += tileWidth(font_pic) + 1; } } @@ -449,7 +449,7 @@ private: }; - xsize = tilesiz[PANEL_KEY_RED].x + 1; + xsize = tileWidth(PANEL_KEY_RED) + 1; ysize = tileHeight(PANEL_KEY_RED) + 2; i = 0; @@ -607,7 +607,7 @@ private: auto NORM_CANG = [](int ang) { return (((ang)+32) & 31); }; int start_ang, ang; - int x_size = tilesiz[COMPASS_NORTH].x; + int x_size = tileWidth(COMPASS_NORTH); int x; int i; @@ -669,7 +669,7 @@ private: BeginStatusBar(320, 200, tileHeight(STATUS_BAR)); if (hud_size == Hud_StbarOverlay) Set43ClipRect(); - int left = (320 - tilesiz[STATUS_BAR].x) / 2; + int left = (320 - tileWidth(STATUS_BAR)) / 2; DrawGraphic(tileGetTexture(STATUS_BAR), left, 200, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, 1, 1); twod->ClearClipRect(); DisplayPanelNumber(PANEL_HEALTH_BOX_X + PANEL_HEALTH_XOFF, PANEL_BOX_Y + PANEL_HEALTH_YOFF, u->Health); diff --git a/source/sw/src/weapon.cpp b/source/sw/src/weapon.cpp index 25a858219..86866df6a 100644 --- a/source/sw/src/weapon.cpp +++ b/source/sw/src/weapon.cpp @@ -16108,7 +16108,7 @@ WallSpriteInsideSprite(SPRITEp wsp, SPRITEp sp) // y delta day = -bcos(wsp->ang) * wsp->xrepeat; - xsiz = tilesiz[wsp->picnum].x; + xsiz = tileWidth(wsp->picnum); mid_dist = DIV2(xsiz) + xoff; // starting from the center find the first point