Revert "Store terrain ID instead of terrain pointer, add new helpers and accomodate for this"

This reverts commit 9baae4cecb.
This commit is contained in:
NepDisk 2024-08-21 22:49:45 -04:00
parent 711df9fb03
commit cb3b95c0e1
4 changed files with 1 additions and 78 deletions

View file

@ -332,16 +332,6 @@ terrain_t *K_GetDefaultTerrain(void)
return K_GetTerrainByIndex(defaultTerrain);
}
/*--------------------------------------------------
size_t K_GetDefaultTerrainID(void)
See header file for description.
--------------------------------------------------*/
size_t K_GetDefaultTerrainID(void)
{
return defaultTerrain;
}
/*--------------------------------------------------
terrain_t *K_GetTerrainForTextureName(const char *checkName)
@ -370,34 +360,6 @@ terrain_t *K_GetTerrainForTextureName(const char *checkName)
return K_GetDefaultTerrain();
}
/*--------------------------------------------------
size_t K_GetTerrainIDForTextureName(const char *checkName)
See header file for description.
--------------------------------------------------*/
size_t K_GetTerrainIDForTextureName(const char *checkName)
{
UINT32 checkHash = quickncasehash(checkName, 8);
size_t i;
if (numTerrainFloorDefs > 0)
{
for (i = 0; i < numTerrainFloorDefs; i++)
{
t_floor_t *f = &terrainFloorDefs[i];
if (checkHash == f->textureHash && !strncasecmp(checkName, f->textureName, 8))
{
return f->terrainID;
}
}
}
// This texture doesn't have a terrain directly applied to it,
// so we fallback to the default terrain.
return K_GetDefaultTerrainID();
}
/*--------------------------------------------------
terrain_t *K_GetTerrainForTextureNum(INT32 textureNum)
@ -408,7 +370,7 @@ terrain_t *K_GetTerrainForTextureNum(INT32 textureNum)
if (textureNum >= 0 && textureNum < numtextures)
{
texture_t *tex = textures[textureNum];
return K_GetTerrainByIndex(tex->terrainID);
return K_GetTerrainForTextureName(tex->name);
}
// This texture doesn't have a terrain directly applied to it,
@ -1866,12 +1828,6 @@ static boolean K_TERRAINLumpParser(UINT8 *data, size_t size)
{
f->terrainID = K_GetTerrainHeapIndex(t);
CONS_Printf("Texture '%s' set to Terrain '%s'\n", f->textureName, tkn);
INT32 tex = R_CheckTextureNumForName(f->textureName);
if (tex != -1)
{
textures[tex]->terrainID = f->terrainID;
}
}
}
else

View file

@ -388,19 +388,6 @@ terrain_t *K_GetTerrainByName(const char *checkName);
terrain_t *K_GetDefaultTerrain(void);
/*--------------------------------------------------
size_t K_GetDefaultTerrainID(void)
Returns the default terrain definition's ID, used
in cases where terrain is not set for a texture.
Input Arguments:-
None
Return:-
The default terrain definition's ID, NULL if it didn't exist.
--------------------------------------------------*/
size_t K_GetDefaultTerrainID(void);
/*--------------------------------------------------
terrain_t *K_GetTerrainForTextureName(const char *checkName);
@ -420,22 +407,6 @@ size_t K_GetDefaultTerrainID(void);
terrain_t *K_GetTerrainForTextureName(const char *checkName);
/*--------------------------------------------------
size_t K_GetTerrainIDForTextureName(const char *checkName)
Returns the ID of the terrain definition applied
to the texture name inputted.
Input Arguments:-
checkName - The texture's name.
Return:-
The texture's terrain definition's ID if it exists,
otherwise the default terrain's ID if it exists,
otherwise NULL.
--------------------------------------------------*/
size_t K_GetTerrainIDForTextureName(const char *checkName);
/*--------------------------------------------------
terrain_t *K_GetTerrainForTextureNum(INT32 textureNum);

View file

@ -853,7 +853,6 @@ Rloadflats (INT32 i, INT32 w)
texture->patchcount = 1;
texture->holes = false;
texture->flip = 0;
texture->terrainID = K_GetTerrainIDForTextureName(texture->name);
// Allocate information for the texture's patches.
patch = &texture->patches[0];
@ -956,7 +955,6 @@ Rloadtextures (INT32 i, INT32 w)
texture->patchcount = 1;
texture->holes = false;
texture->flip = 0;
texture->terrainID = K_GetTerrainIDForTextureName(texture->name);
// Allocate information for the texture's patches.
patch = &texture->patches[0];
@ -1477,7 +1475,6 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
resultTexture->width = newTextureWidth;
resultTexture->height = newTextureHeight;
resultTexture->type = TEXTURETYPE_COMPOSITE;
resultTexture->terrainID = K_GetTerrainIDForTextureName(newTextureName);
}
Z_Free(texturesToken);
texturesToken = M_GetToken(NULL);

View file

@ -62,7 +62,6 @@ typedef struct
boolean holes;
UINT8 flip; // 1 = flipx, 2 = flipy, 3 = both
void *flat; // The texture, as a flat.
size_t terrainID;
// All the patches[patchcount] are drawn back to front into the cached texture.
INT16 patchcount;