Skip to content

Commit

Permalink
Renamed the operator() and [] methods in FTextureManager which take a…
Browse files Browse the repository at this point in the history
… name

The operators cannot be easily searched for so this makes it hard to do any evaluations on the use of this method.
  • Loading branch information
coelckers committed Dec 7, 2018
1 parent 9fedecb commit 3dc9eab
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 32 deletions.
11 changes: 6 additions & 5 deletions src/d_main.cpp
Expand Up @@ -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"));
}
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/g_statusbar/shared_sbar.cpp
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/hu_scores.cpp
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/p_sectors.cpp
Expand Up @@ -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();
}

//
Expand All @@ -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();
}

//
Expand Down
2 changes: 1 addition & 1 deletion src/posix/cocoa/i_video.mm
Expand Up @@ -647,7 +647,7 @@ void I_SetFPSLimit(int limit)
// ---------------------------------------------------------------------------


bool I_SetCursor(FTexture* cursorpic)
bool I_SetCursor(FTexture *cursorpic)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSCursor* cursor = nil;
Expand Down
19 changes: 10 additions & 9 deletions src/textures/textures.h
Expand Up @@ -565,12 +565,16 @@ class FTextureManager
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;
Expand All @@ -589,18 +593,15 @@ class FTextureManager
}
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);
Expand Down
16 changes: 8 additions & 8 deletions src/v_draw.cpp
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions src/wi_stuff.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand Down

0 comments on commit 3dc9eab

Please sign in to comment.