mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Update brightmap reading
- Does it per-wad - Saves hashes for certain bits - Adds R_UpdateTextureBrightmap to respect the zone memory
This commit is contained in:
parent
e4aa53a92e
commit
2179da40bf
5 changed files with 59 additions and 46 deletions
|
|
@ -2571,7 +2571,7 @@ static void Command_Map_f(void)
|
||||||
|
|
||||||
mustmodifygame = !(netgame || multiplayer) && !majormods;
|
mustmodifygame = !(netgame || multiplayer) && !majormods;
|
||||||
|
|
||||||
if (mustmodifygame)
|
if (mustmodifygame && !option_force)
|
||||||
{
|
{
|
||||||
/* May want to be more descriptive? */
|
/* May want to be more descriptive? */
|
||||||
CONS_Printf(M_GetText("Sorry, level change disabled in single player.\n"));
|
CONS_Printf(M_GetText("Sorry, level change disabled in single player.\n"));
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ static size_t maxBrightmapStorage = 0;
|
||||||
static brightmapStorage_t *K_NewBrightmap(void)
|
static brightmapStorage_t *K_NewBrightmap(void)
|
||||||
{
|
{
|
||||||
maxBrightmapStorage++;
|
maxBrightmapStorage++;
|
||||||
brightmapStorage = (brightmapStorage_t *)Z_Realloc(brightmapStorage, sizeof(brightmapStorage_t) * (maxBrightmapStorage + 1), PU_STATIC, NULL);
|
brightmapStorage = (brightmapStorage_t *)Z_Realloc(brightmapStorage, sizeof(brightmapStorage_t) * (maxBrightmapStorage + 1), PU_STATIC, &brightmapStorage);
|
||||||
return &brightmapStorage[ maxBrightmapStorage - 1 ];
|
return &brightmapStorage[ maxBrightmapStorage - 1 ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,6 +63,7 @@ static brightmapStorage_t *K_GetBrightmapStorageByIndex(size_t checkIndex)
|
||||||
--------------------------------------------------*/
|
--------------------------------------------------*/
|
||||||
static brightmapStorage_t *K_GetBrightmapStorageByTextureName(const char *checkName)
|
static brightmapStorage_t *K_GetBrightmapStorageByTextureName(const char *checkName)
|
||||||
{
|
{
|
||||||
|
UINT32 checkHash = quickncasehash(checkName, 8);
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (maxBrightmapStorage == 0)
|
if (maxBrightmapStorage == 0)
|
||||||
|
|
@ -74,7 +75,7 @@ static brightmapStorage_t *K_GetBrightmapStorageByTextureName(const char *checkN
|
||||||
{
|
{
|
||||||
brightmapStorage_t *bms = &brightmapStorage[i];
|
brightmapStorage_t *bms = &brightmapStorage[i];
|
||||||
|
|
||||||
if (stricmp(checkName, bms->textureName) == 0)
|
if (checkHash == bms->textureHash)
|
||||||
{
|
{
|
||||||
// Name matches.
|
// Name matches.
|
||||||
return bms;
|
return bms;
|
||||||
|
|
@ -119,6 +120,7 @@ static boolean K_BRIGHTLumpParser(UINT8 *data, size_t size)
|
||||||
{
|
{
|
||||||
bms = K_NewBrightmap();
|
bms = K_NewBrightmap();
|
||||||
strncpy(bms->textureName, tkn, 9);
|
strncpy(bms->textureName, tkn, 9);
|
||||||
|
bms->textureHash = quickncasehash(bms->textureName, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
Z_Free(tkn);
|
Z_Free(tkn);
|
||||||
|
|
@ -128,6 +130,7 @@ static boolean K_BRIGHTLumpParser(UINT8 *data, size_t size)
|
||||||
if (tkn && pos < size)
|
if (tkn && pos < size)
|
||||||
{
|
{
|
||||||
strncpy(bms->brightmapName, tkn, 9);
|
strncpy(bms->brightmapName, tkn, 9);
|
||||||
|
bms->brightmapHash = quickncasehash(bms->brightmapName, 8);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -163,57 +166,45 @@ static boolean K_BRIGHTLumpParser(UINT8 *data, size_t size)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------
|
/*--------------------------------------------------
|
||||||
void K_InitBrightmaps(void)
|
void K_InitBrightmapsPwad(INT32 wadNum)
|
||||||
|
|
||||||
See header file for description.
|
See header file for description.
|
||||||
--------------------------------------------------*/
|
--------------------------------------------------*/
|
||||||
void K_InitBrightmaps(void)
|
void K_InitBrightmapsPwad(INT32 wadNum)
|
||||||
{
|
{
|
||||||
INT32 wadNum;
|
UINT16 lumpNum;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
I_Assert(brightmapStorage == NULL);
|
I_Assert(brightmapStorage == NULL);
|
||||||
maxBrightmapStorage = 0;
|
|
||||||
|
|
||||||
for (wadNum = 0; wadNum < numwadfiles; wadNum++)
|
// Find BRIGHT lump in the WAD
|
||||||
|
lumpNum = W_CheckNumForNamePwad("BRIGHT", wadNum, 0);
|
||||||
|
|
||||||
|
while (lumpNum != INT16_MAX)
|
||||||
{
|
{
|
||||||
UINT16 lumpNum;
|
UINT8 *data = (UINT8 *)W_CacheLumpNumPwad(wadNum, lumpNum, PU_CACHE);
|
||||||
|
|
||||||
// Find BRIGHT lump in the WAD
|
if (data != NULL)
|
||||||
lumpNum = W_CheckNumForNamePwad("BRIGHT", wadNum, 0);
|
|
||||||
|
|
||||||
while (lumpNum != INT16_MAX)
|
|
||||||
{
|
{
|
||||||
UINT8 *data;
|
lumpinfo_t *lump_p = &wadfiles[wadNum]->lumpinfo[lumpNum];
|
||||||
data = (UINT8 *)W_CacheLumpNumPwad(wadNum, lumpNum, PU_STATIC);
|
size_t size = W_LumpLengthPwad(wadNum, lumpNum);
|
||||||
|
|
||||||
// If that didn't exist, we have nothing to do here.
|
size_t nameLength = strlen(wadfiles[wadNum]->filename) + 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name
|
||||||
if (data == NULL)
|
char *name = malloc(nameLength + 1);
|
||||||
{
|
|
||||||
lumpNum = W_CheckNumForNamePwad("BRIGHT", (UINT16)wadNum, lumpNum + 1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lumpinfo_t *lump_p = &wadfiles[wadNum]->lumpinfo[lumpNum];
|
|
||||||
size_t size = W_LumpLengthPwad(wadNum, lumpNum);
|
|
||||||
|
|
||||||
size_t nameLength = strlen(wadfiles[wadNum]->filename) + 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name
|
sprintf(name, "%s|%s", wadfiles[wadNum]->filename, lump_p->fullname);
|
||||||
char *name = malloc(nameLength + 1);
|
name[nameLength] = '\0';
|
||||||
|
|
||||||
sprintf(name, "%s|%s", wadfiles[wadNum]->filename, lump_p->fullname);
|
size = W_LumpLengthPwad(wadNum, lumpNum);
|
||||||
name[nameLength] = '\0';
|
|
||||||
|
|
||||||
size = W_LumpLengthPwad(wadNum, lumpNum);
|
CONS_Printf(M_GetText("Loading BRIGHT from %s\n"), name);
|
||||||
|
K_BRIGHTLumpParser(data, size);
|
||||||
|
|
||||||
CONS_Printf(M_GetText("Loading BRIGHT from %s\n"), name);
|
free(name);
|
||||||
K_BRIGHTLumpParser(data, size);
|
Z_Free(data);
|
||||||
|
|
||||||
free(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
lumpNum = W_CheckNumForNamePwad("BRIGHT", (UINT16)wadNum, lumpNum + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lumpNum = W_CheckNumForNamePwad("BRIGHT", (UINT16)wadNum, lumpNum + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxBrightmapStorage == 0)
|
if (maxBrightmapStorage == 0)
|
||||||
|
|
@ -237,14 +228,7 @@ void K_InitBrightmaps(void)
|
||||||
if (texNum != -1)
|
if (texNum != -1)
|
||||||
{
|
{
|
||||||
bmNum = R_CheckTextureNumForName(bms->brightmapName);
|
bmNum = R_CheckTextureNumForName(bms->brightmapName);
|
||||||
if (bmNum == -1)
|
R_UpdateTextureBrightmap(texNum, (bmNum == -1 ? 0 : bmNum));
|
||||||
{
|
|
||||||
texturebrightmaps[texNum] = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
texturebrightmaps[texNum] = bmNum;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -253,4 +237,20 @@ void K_InitBrightmaps(void)
|
||||||
// Clear brightmapStorage now that we're done with it.
|
// Clear brightmapStorage now that we're done with it.
|
||||||
Z_Free(brightmapStorage);
|
Z_Free(brightmapStorage);
|
||||||
brightmapStorage = NULL;
|
brightmapStorage = NULL;
|
||||||
|
maxBrightmapStorage = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*--------------------------------------------------
|
||||||
|
void K_InitBrightmaps(void)
|
||||||
|
|
||||||
|
See header file for description.
|
||||||
|
--------------------------------------------------*/
|
||||||
|
void K_InitBrightmaps(void)
|
||||||
|
{
|
||||||
|
INT32 wadNum;
|
||||||
|
|
||||||
|
for (wadNum = 0; wadNum < numwadfiles; wadNum++)
|
||||||
|
{
|
||||||
|
K_InitBrightmapsPwad(wadNum);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,20 @@ typedef struct brightmapStorage_s
|
||||||
// before putting them into texturebrightmaps.
|
// before putting them into texturebrightmaps.
|
||||||
|
|
||||||
char textureName[9]; // The texture's name.
|
char textureName[9]; // The texture's name.
|
||||||
|
UINT32 textureHash; // The texture name's hash.
|
||||||
|
|
||||||
char brightmapName[9]; // The brightmap's name.
|
char brightmapName[9]; // The brightmap's name.
|
||||||
|
UINT32 brightmapHash; // The brightmap name's hash.
|
||||||
} brightmapStorage_t;
|
} brightmapStorage_t;
|
||||||
|
|
||||||
|
/*--------------------------------------------------
|
||||||
|
void K_InitBrightmapsPwad(INT32 wadNum);
|
||||||
|
|
||||||
|
Finds all BRIGHT lumps for one WAD/PK3 and processes them.
|
||||||
|
--------------------------------------------------*/
|
||||||
|
|
||||||
|
void K_InitBrightmapsPwad(INT32 wadNum);
|
||||||
|
|
||||||
/*--------------------------------------------------
|
/*--------------------------------------------------
|
||||||
void K_InitBrightmaps(void);
|
void K_InitBrightmaps(void);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4463,7 +4463,7 @@ boolean P_AddWadFile(const char *wadfilename)
|
||||||
P_InitPicAnims();
|
P_InitPicAnims();
|
||||||
|
|
||||||
// Reload BRIGHT
|
// Reload BRIGHT
|
||||||
K_InitBrightmaps();
|
K_InitBrightmapsPwad(wadnum);
|
||||||
|
|
||||||
// Flush and reload HUD graphics
|
// Flush and reload HUD graphics
|
||||||
//ST_UnloadGraphics();
|
//ST_UnloadGraphics();
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,8 @@ void *R_GetFlat(lumpnum_t flatnum);
|
||||||
boolean R_CheckPowersOfTwo(void);
|
boolean R_CheckPowersOfTwo(void);
|
||||||
void R_CheckFlatLength(size_t size);
|
void R_CheckFlatLength(size_t size);
|
||||||
|
|
||||||
|
void R_UpdateTextureBrightmap(INT32 tx, INT32 bm);
|
||||||
|
|
||||||
// Returns the texture number for the texture name.
|
// Returns the texture number for the texture name.
|
||||||
INT32 R_TextureNumForName(const char *name);
|
INT32 R_TextureNumForName(const char *name);
|
||||||
INT32 R_CheckTextureNumForName(const char *name);
|
INT32 R_CheckTextureNumForName(const char *name);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue