add comments + better checktexturename if statement

This commit is contained in:
ashifolfi 2022-11-20 16:06:47 -05:00
parent e48f7d1538
commit 1b14dff0e9

View file

@ -1662,21 +1662,30 @@ INT32 R_CheckTextureNumForName(const char *name)
return -1; return -1;
} }
// i was fully expecting this to take like an hour to figure out not 2 mintues and 5 lines of c - ashi //
// R_CheckTextureNameForNum
//
// because sidedefs use numbers and sometimes you want names
// returns no texture marker if no texture was found
//
const char *R_CheckTextureNameForNum(INT32 num) const char *R_CheckTextureNameForNum(INT32 num)
{ {
if (textures[num] && textures[num]->name) if (num > 0 && num < numtextures)
{
return textures[num]->name; return textures[num]->name;
}
return "-"; return "-";
} }
//
// R_TextureNameForNum
//
// calls R_CheckTextureNameForNum and returns REDWALL if result is a no texture marker
//
const char *R_TextureNameForNum(INT32 num) const char *R_TextureNameForNum(INT32 num)
{ {
const char *result = R_CheckTextureNameForNum(num); const char *result = R_CheckTextureNameForNum(num);
if (strcmp(result, "-")) if (strcmp(result, "-") == 0)
return "REDWALL"; return "REDWALL";
return result; return result;