From 3dc9eab74354066df3e17759fffd7cd7886cca79 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 7 Dec 2018 02:43:27 +0100 Subject: [PATCH] Renamed the operator() and [] methods in FTextureManager which take a name The operators cannot be easily searched for so this makes it hard to do any evaluations on the use of this method. --- src/d_main.cpp | 11 ++++++----- src/g_statusbar/shared_sbar.cpp | 2 +- src/hu_scores.cpp | 2 +- src/p_sectors.cpp | 4 ++-- src/posix/cocoa/i_video.mm | 2 +- src/textures/textures.h | 19 ++++++++++--------- src/v_draw.cpp | 16 ++++++++-------- src/wi_stuff.cpp | 10 +++++----- 8 files changed, 34 insertions(+), 32 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 601a5558c..39f7bd8e0 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -184,18 +184,19 @@ CVAR (Int, snd_drawoutput, 0, 0); CUSTOM_CVAR (String, vid_cursor, "None", CVAR_ARCHIVE | CVAR_NOINITCALL) { bool res = false; + if (!stricmp(self, "None" ) && gameinfo.CursorPic.IsNotEmpty()) { - res = I_SetCursor(TexMan[gameinfo.CursorPic]); + res = I_SetCursor(TexMan.GetTextureByName(gameinfo.CursorPic)); } else { - res = I_SetCursor(TexMan[self]); + res = I_SetCursor(TexMan.GetTextureByName(self)); } if (!res) { - I_SetCursor(TexMan["cursor"]); + I_SetCursor(TexMan.GetTextureByName("cursor")); } } @@ -834,7 +835,7 @@ void D_Display () int x; FString pstring = "By "; - tex = TexMan(gameinfo.PauseSign); + tex = TexMan.GetTextureByName(gameinfo.PauseSign, true); x = (SCREENWIDTH - tex->GetDisplayWidth() * CleanXfac)/2 + tex->GetDisplayLeftOffset() * CleanXfac; screen->DrawTexture (tex, x, 4, DTA_CleanNoMove, true, TAG_DONE); @@ -1241,7 +1242,7 @@ void D_DoAdvanceDemo (void) case 3: if (gameinfo.advisoryTime) { - Advisory = TexMan["ADVISOR"]; + Advisory = TexMan.GetTextureByName("ADVISOR"); demosequence = 1; pagetic = (int)(gameinfo.advisoryTime * TICRATE); break; diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index ea2db01fe..06dd1e57a 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -817,7 +817,7 @@ void DBaseStatusBar::RefreshBackground () const if (setblocks >= 10) { - FTexture *p = TexMan[gameinfo.Border.b]; + FTexture *p = TexMan.GetTextureByName(gameinfo.Border.b); if (p != NULL) { screen->FlatFill(0, y, x, y + p->GetDisplayHeight(), p, true); diff --git a/src/hu_scores.cpp b/src/hu_scores.cpp index 1fc3b9a35..435acc8f0 100644 --- a/src/hu_scores.cpp +++ b/src/hu_scores.cpp @@ -445,7 +445,7 @@ static void HU_DrawPlayer (player_t *player, bool highlight, int col1, int col2, if (teamplay && Teams[player->userinfo.GetTeam()].GetLogo().IsNotEmpty ()) { - FTexture *pic = TexMan[Teams[player->userinfo.GetTeam()].GetLogo().GetChars ()]; + FTexture *pic = TexMan.GetTextureByName(Teams[player->userinfo.GetTeam()].GetLogo().GetChars ()); screen->DrawTexture (pic, col1 - (pic->GetDisplayWidth() + 2) * CleanXfac, y, DTA_CleanNoMove, true, TAG_DONE); } diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index 23881740b..fd323e65f 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -501,7 +501,7 @@ double FindShortestTextureAround (sector_t *sec) CheckShortestTex (check->sidedef[1]->GetTexture(side_t::bottom), minsize); } } - return minsize < FLT_MAX ? minsize : TexMan[0]->GetDisplayHeight(); + return minsize < FLT_MAX ? minsize : TexMan.ByIndex(0)->GetDisplayHeight(); } // @@ -526,7 +526,7 @@ double FindShortestUpperAround (sector_t *sec) CheckShortestTex (check->sidedef[1]->GetTexture(side_t::top), minsize); } } - return minsize < FLT_MAX ? minsize : TexMan[0]->GetDisplayHeight(); + return minsize < FLT_MAX ? minsize : TexMan.ByIndex(0)->GetDisplayHeight(); } // diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index 9243cd5be..d10c590b2 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -647,7 +647,7 @@ CUSTOM_CVAR(Bool, vid_hidpi, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINI // --------------------------------------------------------------------------- -bool I_SetCursor(FTexture* cursorpic) +bool I_SetCursor(FTexture *cursorpic) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSCursor* cursor = nil; diff --git a/src/textures/textures.h b/src/textures/textures.h index 2bc6cab1a..e75ce0a8a 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -565,12 +565,16 @@ public: if ((unsigned)texnum.GetIndex() >= Textures.Size()) return NULL; return Textures[texnum.GetIndex()].Texture; } - FTexture *operator[] (const char *texname) + + FTexture *GetTextureByName(const char *name, bool animate = false) { - FTextureID texnum = GetTextureID (texname, ETextureType::MiscPatch); - if (!texnum.Exists()) return NULL; - return Textures[texnum.GetIndex()].Texture; + FTextureID texnum = GetTextureID (name, ETextureType::MiscPatch); + if (!texnum.Exists()) return nullptr; + if (!animate) return Textures[texnum.GetIndex()].Texture; + else return Textures[Translation[texnum.GetIndex()]].Texture; + } + FTexture *ByIndex(int i) { if (unsigned(i) >= Textures.Size()) return NULL; @@ -589,18 +593,15 @@ public: } return Textures[picnum].Texture; } + /* FTexture *operator() (const char *texname) { FTextureID texnum = GetTextureID (texname, ETextureType::MiscPatch); if (texnum.texnum == -1) return NULL; return Textures[Translation[texnum.texnum]].Texture; } + */ - FTexture *ByIndexTranslated(int i) - { - if (unsigned(i) >= Textures.Size()) return NULL; - return Textures[Translation[i]].Texture; - } //public: FTextureID PalCheck(FTextureID tex); diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 36c9c921e..00c6307ef 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -1304,22 +1304,22 @@ void DFrameBuffer::DrawFrame (int left, int top, int width, int height) int bottom = top + height; // Draw top and bottom sides. - p = TexMan[border->t]; + p = TexMan.GetTextureByName(border->t); FlatFill(left, top - p->GetDisplayHeight(), right, top, p, true); - p = TexMan[border->b]; + p = TexMan.GetTextureByName(border->b); FlatFill(left, bottom, right, bottom + p->GetDisplayHeight(), p, true); // Draw left and right sides. - p = TexMan[border->l]; + p = TexMan.GetTextureByName(border->l); FlatFill(left - p->GetDisplayWidth(), top, left, bottom, p, true); - p = TexMan[border->r]; + p = TexMan.GetTextureByName(border->r); FlatFill(right, top, right + p->GetDisplayWidth(), bottom, p, true); // Draw beveled corners. - DrawTexture (TexMan[border->tl], left-offset, top-offset, TAG_DONE); - DrawTexture (TexMan[border->tr], left+width, top-offset, TAG_DONE); - DrawTexture (TexMan[border->bl], left-offset, top+height, TAG_DONE); - DrawTexture (TexMan[border->br], left+width, top+height, TAG_DONE); + DrawTexture (TexMan.GetTextureByName(border->tl), left-offset, top-offset, TAG_DONE); + DrawTexture (TexMan.GetTextureByName(border->tr), left+width, top-offset, TAG_DONE); + DrawTexture (TexMan.GetTextureByName(border->bl), left-offset, top+height, TAG_DONE); + DrawTexture (TexMan.GetTextureByName(border->br), left+width, top+height, TAG_DONE); } DEFINE_ACTION_FUNCTION(_Screen, DrawFrame) diff --git a/src/wi_stuff.cpp b/src/wi_stuff.cpp index 01340ce19..17f6a913a 100644 --- a/src/wi_stuff.cpp +++ b/src/wi_stuff.cpp @@ -383,13 +383,13 @@ bool DInterBackground::LoadBackground(bool isenterpic) case 1: // Splat sc.MustGetString(); - splat = TexMan[sc.String]; + splat = TexMan.GetTextureByName(sc.String); break; case 2: // Pointers while (sc.GetString() && !sc.Crossed) { - yah.Push(TexMan[sc.String]); + yah.Push(TexMan.GetTextureByName(sc.String)); } if (sc.Crossed) sc.UnGet(); @@ -481,14 +481,14 @@ bool DInterBackground::LoadBackground(bool isenterpic) if (!sc.CheckString("{")) { sc.MustGetString(); - an.frames.Push(TexMan[sc.String]); + an.frames.Push(TexMan.GetTextureByName(sc.String)); } else { while (!sc.CheckString("}")) { sc.MustGetString(); - an.frames.Push(TexMan[sc.String]); + an.frames.Push(TexMan.GetTextureByName(sc.String)); } } an.ctr = -1; @@ -503,7 +503,7 @@ bool DInterBackground::LoadBackground(bool isenterpic) an.loc.y = sc.Number; sc.MustGetString(); an.frames.Reserve(1); // allocate exactly one element - an.frames[0] = TexMan[sc.String]; + an.frames[0] = TexMan.GetTextureByName(sc.String); anims.Push(an); break;