From a4742c7da7738326916699371f9c70061bfccb2b Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 16 Dec 2021 18:34:51 -0800 Subject: [PATCH 01/13] P_AddWadFile: only load textures in current file --- src/p_setup.c | 2 +- src/r_textures.c | 229 +++++++++++++++++++++++++++-------------------- src/r_textures.h | 1 + 3 files changed, 133 insertions(+), 99 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index fab5429b8..e36c20a0a 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4452,7 +4452,7 @@ boolean P_AddWadFile(const char *wadfilename) // Reload it all anyway, just in case they // added some textures but didn't insert a // TEXTURES/etc. list. - R_LoadTextures(); // numtexture changes + R_LoadTexturesPwad(wadnum); // numtexture changes // Reload ANIMDEFS P_InitPicAnims(); diff --git a/src/r_textures.c b/src/r_textures.c index 4ec110556..76e78f00e 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -926,27 +926,53 @@ Rloadtextures (INT32 i, INT32 w) return i; } -// -// R_LoadTextures -// Initializes the texture list with the textures from the world map. -// -void R_LoadTextures(void) +static INT32 +count_range +( const char * marker_start, + const char * marker_end, + const char * folder, + UINT16 wadnum) { - INT32 i, w; UINT16 j; - UINT16 texstart, texend, texturesLumpPos; + UINT16 texstart, texend; + INT32 count = 0; - // Free previous memory before numtextures change. - if (numtextures) + // Count flats + if (wadfiles[wadnum]->type == RET_PK3) { - for (i = 0; i < numtextures; i++) - { - Z_Free(textures[i]); - Z_Free(texturecache[i]); - } - Z_Free(texturetranslation); - Z_Free(textures); + texstart = W_CheckNumForFolderStartPK3(folder, wadnum, 0); + texend = W_CheckNumForFolderEndPK3(folder, wadnum, texstart); } + else + { + texstart = W_CheckNumForMarkerStartPwad(marker_start, wadnum, 0); + texend = W_CheckNumForNamePwad(marker_end, wadnum, texstart); + } + + if (texstart != INT16_MAX && texend != INT16_MAX) + { + // PK3s have subfolders, so we can't just make a simple sum + if (wadfiles[wadnum]->type == RET_PK3) + { + for (j = texstart; j < texend; j++) + { + if (!W_IsLumpFolder(wadnum, j)) // Check if lump is a folder; if not, then count it + count++; + } + } + else // Add all the textures between markers + { + count += (texend - texstart); + } + } + + return count; +} + +static INT32 R_CountTextures(UINT16 wadnum) +{ + UINT16 texturesLumpPos; + INT32 count = 0; // Load patches and textures. @@ -955,106 +981,76 @@ void R_LoadTextures(void) // the markers. // This system will allocate memory for all duplicate/patched textures even if it never uses them, // but the alternative is to spend a ton of time checking and re-checking all previous entries just to skip any potentially patched textures. - for (w = 0, numtextures = 0; w < numwadfiles; w++) - { + #ifdef WALLFLATS - // Count flats - if (wadfiles[w]->type == RET_PK3) - { - texstart = W_CheckNumForFolderStartPK3("flats/", (UINT16)w, 0); - texend = W_CheckNumForFolderEndPK3("flats/", (UINT16)w, texstart); - } - else - { - texstart = W_CheckNumForMarkerStartPwad("F_START", (UINT16)w, 0); - texend = W_CheckNumForNamePwad("F_END", (UINT16)w, texstart); - } + count += count_range("F_START", "F_END", "flats/", wadnum); +#endif - if (!( texstart == INT16_MAX || texend == INT16_MAX )) - { - // PK3s have subfolders, so we can't just make a simple sum - if (wadfiles[w]->type == RET_PK3) - { - for (j = texstart; j < texend; j++) - { - if (!W_IsLumpFolder((UINT16)w, j)) // Check if lump is a folder; if not, then count it - numtextures++; - } - } - else // Add all the textures between F_START and F_END - { - numtextures += (UINT32)(texend - texstart); - } - } -#endif/*WALLFLATS*/ + // Count the textures from TEXTURES lumps + texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", wadnum, 0); - // Count the textures from TEXTURES lumps - texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0); - while (texturesLumpPos != INT16_MAX) - { - numtextures += R_CountTexturesInTEXTURESLump((UINT16)w, (UINT16)texturesLumpPos); - texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, texturesLumpPos + 1); - } - - // Count single-patch textures - if (wadfiles[w]->type == RET_PK3) - { - texstart = W_CheckNumForFolderStartPK3("textures/", (UINT16)w, 0); - texend = W_CheckNumForFolderEndPK3("textures/", (UINT16)w, texstart); - } - else - { - texstart = W_CheckNumForMarkerStartPwad(TX_START, (UINT16)w, 0); - texend = W_CheckNumForNamePwad(TX_END, (UINT16)w, 0); - } - - if (texstart == INT16_MAX || texend == INT16_MAX) - continue; - - // PK3s have subfolders, so we can't just make a simple sum - if (wadfiles[w]->type == RET_PK3) - { - for (j = texstart; j < texend; j++) - { - if (!W_IsLumpFolder((UINT16)w, j)) // Check if lump is a folder; if not, then count it - numtextures++; - } - } - else // Add all the textures between TX_START and TX_END - { - numtextures += (UINT32)(texend - texstart); - } + while (texturesLumpPos != INT16_MAX) + { + count += R_CountTexturesInTEXTURESLump(wadnum, texturesLumpPos); + texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", wadnum, texturesLumpPos + 1); } - // If no textures found by this point, bomb out - if (!numtextures) - I_Error("No textures detected in any WADs!\n"); + // Count single-patch textures + count += count_range(TX_START, TX_END, "textures/", wadnum); + + return count; +} + +static void +recallocuser +( void * user, + size_t old, + size_t new) +{ + char *p = Z_Realloc(*(void**)user, + new, PU_STATIC, user); + + if (new > old) + memset(&p[old], 0, (new - old)); +} + +static void R_AllocateTextures(INT32 add) +{ + const INT32 newtextures = (numtextures + add); + const size_t newsize = newtextures * sizeof (void*); + const size_t oldsize = numtextures * sizeof (void*); + + INT32 i; // Allocate memory and initialize to 0 for all the textures we are initialising. - // There are actually 5 buffers allocated in one for convenience. - textures = Z_Calloc((numtextures * sizeof(void *)) * 5, PU_STATIC, NULL); + recallocuser(&textures, oldsize, newsize); // Allocate texture column offset table. - texturecolumnofs = (void *)((UINT8 *)textures + (numtextures * sizeof(void *))); + recallocuser(&texturecolumnofs, oldsize, newsize); // Allocate texture referencing cache. - texturecache = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 2)); + recallocuser(&texturecache, oldsize, newsize); // Allocate texture width table. - texturewidth = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 3)); + recallocuser(&texturewidth, oldsize, newsize); // Allocate texture height table. - textureheight = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 4)); + recallocuser(&textureheight, oldsize, newsize); // Create translation table for global animation. - texturetranslation = Z_Malloc((numtextures + 1) * sizeof(*texturetranslation), PU_STATIC, NULL); + Z_Realloc(texturetranslation, (newtextures + 1) * sizeof(*texturetranslation), PU_STATIC, &texturetranslation); - for (i = 0; i < numtextures; i++) + for (i = numtextures; i < newtextures; ++i) texturetranslation[i] = i; +} - for (i = 0, w = 0; w < numwadfiles; w++) - { +static INT32 R_DefineTextures(INT32 i, UINT16 w) +{ #ifdef WALLFLATS - i = Rloadflats(i, w); + i = Rloadflats(i, w); #endif - i = Rloadtextures(i, w); - } + return Rloadtextures(i, w); +} + +static void R_FinishLoadingTextures(INT32 add) +{ + numtextures += add; #ifdef HWRENDER if (rendermode == render_opengl) @@ -1062,6 +1058,43 @@ void R_LoadTextures(void) #endif } +// +// R_LoadTextures +// Initializes the texture list with the textures from the world map. +// +void R_LoadTextures(void) +{ + INT32 i, w; + INT32 newtextures = 0; + + for (w = 0; w < numwadfiles; w++) + { + newtextures += R_CountTextures((UINT16)w); + } + + // If no textures found by this point, bomb out + if (!newtextures) + I_Error("No textures detected in any WADs!\n"); + + R_AllocateTextures(newtextures); + + for (i = 0, w = 0; w < numwadfiles; w++) + { + i = R_DefineTextures(i, w); + } + + R_FinishLoadingTextures(newtextures); +} + +void R_LoadTexturesPwad(UINT16 wadnum) +{ + INT32 newtextures = R_CountTextures(wadnum); + + R_AllocateTextures(newtextures); + R_DefineTextures(numtextures, wadnum); + R_FinishLoadingTextures(newtextures); +} + static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) { char *texturesToken; diff --git a/src/r_textures.h b/src/r_textures.h index 6e0cc168a..bd737c231 100644 --- a/src/r_textures.h +++ b/src/r_textures.h @@ -76,6 +76,7 @@ extern UINT8 **texturecache; // graphics data for each generated full-size textu // Load TEXTURES definitions, create lookup tables void R_LoadTextures(void); +void R_LoadTexturesPwad(UINT16 wadnum); void R_FlushTextureCache(void); // Texture generation From 4578e6f8f12248de5afff859658f5237d702c7b9 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 16 Dec 2021 22:10:36 -0800 Subject: [PATCH 02/13] Hash name lookup for textures and lumps --- src/doomdef.h | 16 ++++++++++++++++ src/r_textures.c | 12 ++++++++++-- src/r_textures.h | 1 + src/w_wad.c | 19 ++++++++++++++++--- src/w_wad.h | 1 + 5 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index ff6d2c1e5..ee17fb689 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -550,6 +550,22 @@ extern boolean capslock; // i_system.c, replace getchar() once the keyboard has been appropriated INT32 I_GetKey(void); +/* http://www.cse.yorku.ca/~oz/hash.html */ +static inline +UINT32 quickncasehash (const char *p, size_t n) +{ + size_t i = 0; + UINT32 x = 5381; + + while (i < n && p[i]) + { + x = (x * 33) ^ tolower(p[i]); + i++; + } + + return x; +} + #ifndef min // Double-Check with WATTCP-32's cdefs.h #define min(x, y) (((x) < (y)) ? (x) : (y)) #endif diff --git a/src/r_textures.c b/src/r_textures.c index 76e78f00e..23574e8bb 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -59,6 +59,7 @@ INT32 *texturetranslation; // Painfully simple texture id cacheing to make maps load faster. :3 static struct { char name[9]; + UINT32 hash; INT32 id; } *tidcache = NULL; static INT32 tidcachelen = 0; @@ -788,6 +789,7 @@ Rloadflats (INT32 i, INT32 w) // Set texture properties. M_Memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name)); + texture->hash = quickncasehash(texture->name, 8); #ifndef NO_PNG_LUMPS if (Picture_IsLumpPNG(header, lumplength)) @@ -886,6 +888,7 @@ Rloadtextures (INT32 i, INT32 w) // Set texture properties. M_Memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name)); + texture->hash = quickncasehash(texture->name, 8); #ifndef NO_PNG_LUMPS if (Picture_IsLumpPNG((UINT8 *)&patchlump, lumplength)) @@ -1401,6 +1404,7 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture) // Allocate memory for a zero-patch texture. Obviously, we'll be adding patches momentarily. resultTexture = (texture_t *)Z_Calloc(sizeof(texture_t),PU_STATIC,NULL); M_Memcpy(resultTexture->name, newTextureName, 8); + resultTexture->hash = quickncasehash(newTextureName, 8); resultTexture->width = newTextureWidth; resultTexture->height = newTextureHeight; resultTexture->type = TEXTURETYPE_COMPOSITE; @@ -1626,25 +1630,29 @@ void R_ClearTextureNumCache(boolean btell) INT32 R_CheckTextureNumForName(const char *name) { INT32 i; + UINT32 hash; // "NoTexture" marker. if (name[0] == '-') return 0; + hash = quickncasehash(name, 8); + for (i = 0; i < tidcachelen; i++) - if (!strncasecmp(tidcache[i].name, name, 8)) + if (tidcache[i].hash == hash && !strncasecmp(tidcache[i].name, name, 8)) return tidcache[i].id; // Need to parse the list backwards, so textures loaded more recently are used in lieu of ones loaded earlier //for (i = 0; i < numtextures; i++) <- old for (i = (numtextures - 1); i >= 0; i--) // <- new - if (!strncasecmp(textures[i]->name, name, 8)) + if (textures[i]->hash == hash && !strncasecmp(textures[i]->name, name, 8)) { tidcachelen++; Z_Realloc(tidcache, tidcachelen * sizeof(*tidcache), PU_STATIC, &tidcache); strncpy(tidcache[tidcachelen-1].name, name, 8); tidcache[tidcachelen-1].name[8] = '\0'; CONS_Debug(DBG_SETUP, "texture #%s: %s\n", sizeu1(tidcachelen), tidcache[tidcachelen-1].name); + tidcache[tidcachelen-1].hash = hash; tidcache[tidcachelen-1].id = i; return i; } diff --git a/src/r_textures.h b/src/r_textures.h index bd737c231..90eadcf5c 100644 --- a/src/r_textures.h +++ b/src/r_textures.h @@ -54,6 +54,7 @@ typedef struct { // Keep name for switch changing, etc. char name[8]; + UINT32 hash; UINT8 type; // TEXTURETYPE_ INT16 width, height; boolean holes; diff --git a/src/w_wad.c b/src/w_wad.c index 60339c426..4e1d00780 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -354,6 +354,7 @@ static lumpinfo_t* ResGetLumpsStandalone (FILE* handle, UINT16* numlumps, const lumpinfo->size = ftell(handle); fseek(handle, 0, SEEK_SET); strcpy(lumpinfo->name, lumpname); + lumpinfo->hash = quickncasehash(lumpname, 8); // Allocate the lump's long name. lumpinfo->longname = Z_Malloc(9 * sizeof(char), PU_STATIC, NULL); @@ -451,6 +452,7 @@ static lumpinfo_t* ResGetLumpsWad (FILE* handle, UINT16* nlmp, const char* filen lump_p->compression = CM_NOCOMPRESSION; memset(lump_p->name, 0x00, 9); strncpy(lump_p->name, fileinfo->name, 8); + lump_p->hash = quickncasehash(lump_p->name, 8); // Allocate the lump's long name. lump_p->longname = Z_Malloc(9 * sizeof(char), PU_STATIC, NULL); @@ -625,6 +627,7 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) memset(lump_p->name, '\0', 9); // Making sure they're initialized to 0. Is it necessary? strncpy(lump_p->name, trimname, min(8, dotpos - trimname)); + lump_p->hash = quickncasehash(lump_p->name, 8); lump_p->longname = Z_Calloc(dotpos - trimname + 1, PU_STATIC, NULL); strlcpy(lump_p->longname, trimname, dotpos - trimname + 1); @@ -974,12 +977,14 @@ UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump) { UINT16 i; static char uname[8 + 1]; + UINT32 hash; if (!TestValidLump(wad,0)) return INT16_MAX; strlcpy(uname, name, sizeof uname); strupr(uname); + hash = quickncasehash(uname, 8); // // scan forward @@ -990,7 +995,7 @@ UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump) { lumpinfo_t *lump_p = wadfiles[wad]->lumpinfo + startlump; for (i = startlump; i < wadfiles[wad]->numlumps; i++, lump_p++) - if (!strncmp(lump_p->name, uname, sizeof(uname) - 1)) + if (lump_p->hash == hash && !strncmp(lump_p->name, uname, sizeof(uname) - 1)) return i; } @@ -1193,15 +1198,20 @@ lumpnum_t W_CheckNumForLongName(const char *name) // TODO: Make it search through cache first, maybe...? lumpnum_t W_CheckNumForMap(const char *name) { + UINT32 hash = quickncasehash(name, 8); UINT16 lumpNum, end; UINT32 i; + lumpinfo_t *p; for (i = numwadfiles - 1; i < numwadfiles; i--) { if (wadfiles[i]->type == RET_WAD) { for (lumpNum = 0; lumpNum < wadfiles[i]->numlumps; lumpNum++) - if (!strncmp(name, (wadfiles[i]->lumpinfo + lumpNum)->name, 8)) + { + p = wadfiles[i]->lumpinfo + lumpNum; + if (p->hash == hash && !strncmp(name, p->name, 8)) return (i<<16) + lumpNum; + } } else if (wadfiles[i]->type == RET_PK3) { @@ -1212,8 +1222,11 @@ lumpnum_t W_CheckNumForMap(const char *name) continue; // Now look for the specified map. for (; lumpNum < end; lumpNum++) - if (!strnicmp(name, (wadfiles[i]->lumpinfo + lumpNum)->name, 8)) + { + p = wadfiles[i]->lumpinfo + lumpNum; + if (p->hash == hash && !strnicmp(name, p->name, 8)) return (i<<16) + lumpNum; + } } } return LUMPERROR; diff --git a/src/w_wad.h b/src/w_wad.h index b6bf94be8..55e3e0072 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -67,6 +67,7 @@ typedef struct unsigned long position; // filelump_t filepos unsigned long disksize; // filelump_t size char name[9]; // filelump_t name[] e.g. "LongEntr" + UINT32 hash; char *longname; // e.g. "LongEntryName" char *fullname; // e.g. "Folder/Subfolder/LongEntryName.extension" size_t size; // real (uncompressed) size From ffa2af7e0745050f65d558df7b48c4340bb6c6e9 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 16 Dec 2021 22:25:08 -0800 Subject: [PATCH 03/13] Disable flat animdefs The speed up is significant. --- src/p_spec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/p_spec.c b/src/p_spec.c index caf4704d2..d60d9cc06 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -212,6 +212,12 @@ void P_InitPicAnims(void) lastanim->picnum = R_TextureNumForName(animdefs[i].endname); lastanim->basepic = R_TextureNumForName(animdefs[i].startname); } + else + { + CONS_Alert(CONS_WARNING, "ANIMDEFS flats are disabled; flat support in general will be removed soon! (%s, %s)\n", animdefs[i].startname, animdefs[i].endname); + continue; + } +#if 0 else { if ((W_CheckNumForName(animdefs[i].startname)) == LUMPERROR) @@ -220,6 +226,7 @@ void P_InitPicAnims(void) lastanim->picnum = R_GetFlatNumForName(animdefs[i].endname); lastanim->basepic = R_GetFlatNumForName(animdefs[i].startname); } +#endif lastanim->istexture = animdefs[i].istexture; lastanim->numpics = lastanim->picnum - lastanim->basepic + 1; From 8012d006845119e37e4342b4fcb300310671ab05 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 17 Dec 2021 01:06:38 -0800 Subject: [PATCH 04/13] Add HU_UpdatePatch, recaches patch only if it exists in pwad --- src/hu_stuff.c | 38 +++++++++++++++++++++++++++++++++----- src/hu_stuff.h | 3 ++- src/p_setup.c | 6 ++++++ src/p_setup.h | 2 ++ 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 7afc7d531..e9b3d4c41 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -302,19 +302,47 @@ void HU_Init(void) HU_LoadGraphics(); } -patch_t *HU_CachePatch(const char *format, ...) +patch_t *HU_UpdatePatch(patch_t **user, const char *format, ...) { va_list ap; char buffer[9]; + lumpnum_t lump; + patch_t *patch; + va_start (ap, format); - vsprintf(buffer, format, ap); + vsnprintf(buffer, sizeof buffer, format, ap); va_end (ap); - if (W_CheckNumForName(buffer) == LUMPERROR) - return NULL; + if (user && p_adding_file != INT16_MAX) + { + lump = W_CheckNumForNamePwad(buffer, p_adding_file, 0); + + /* no update in this wad */ + if (lump == INT16_MAX) + return *user; + + lump |= (p_adding_file << 16); + } else - return (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + { + lump = W_CheckNumForName(buffer); + + if (lump == LUMPERROR) + return NULL; + } + + patch = W_CachePatchNum(lump, PU_HUDGFX); + + if (user) + { + if (*user) + Patch_Free(*user); + + *user = patch; + } + + return patch; } static inline void HU_Stop(void) diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 4d686516e..a8d8bee22 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -123,7 +123,8 @@ void HU_Init(void); void HU_LoadGraphics(void); // Load a HUDGFX patch or NULL. -patch_t *HU_CachePatch(const char *format, ...); +patch_t *HU_UpdatePatch(patch_t **user, const char *format, ...); +#define HU_CachePatch(...) HU_UpdatePatch(NULL, __VA_ARGS__) // reset heads up when consoleplayer respawns. void HU_Start(void); diff --git a/src/p_setup.c b/src/p_setup.c index e36c20a0a..62cb26d81 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4319,6 +4319,8 @@ static lumpinfo_t* FindFolder(const char *folName, UINT16 *start, UINT16 *end, l return lumpinfo; } +UINT16 p_adding_file = INT16_MAX; + // // Add a wadfile to the active wad files, // replace sounds, musics, patches, textures, sprites and maps @@ -4356,6 +4358,8 @@ boolean P_AddWadFile(const char *wadfilename) else wadnum = (UINT16)(numwadfiles-1); + p_adding_file = wadnum; + switch(wadfiles[wadnum]->type) { case RET_PK3: @@ -4538,5 +4542,7 @@ boolean P_AddWadFile(const char *wadfilename) refreshdirmenu &= ~REFRESHDIR_GAMEDATA; // Under usual circumstances we'd wait for REFRESHDIR_GAMEDATA to disappear the next frame, but it's a bit too dangerous for that... + p_adding_file = INT16_MAX; + return true; } diff --git a/src/p_setup.h b/src/p_setup.h index 0a7587ec0..cbb697b0e 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -93,6 +93,8 @@ INT32 P_CheckLevelFlat(const char *flatname); extern size_t nummapthings; extern mapthing_t *mapthings; +extern UINT16 p_adding_file; + void P_SetupLevelSky(const char *skytexname, boolean global); #ifdef SCANTHINGS void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum); From 8de36a9ab07304860230c6b31cea3942a654f046 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 17 Dec 2021 01:40:58 -0800 Subject: [PATCH 05/13] Load titlecard font with font system --- src/hu_stuff.c | 36 +++++++++++------------------------- src/hu_stuff.h | 8 +++----- src/v_video.c | 10 +++++----- 3 files changed, 19 insertions(+), 35 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index e9b3d4c41..2a0bfa90c 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -73,8 +73,6 @@ patch_t *pinggfx[5]; // small ping graphic patch_t *mping[5]; // smaller ping graphic -patch_t *tc_font[2][LT_FONTSIZE]; // Special font stuff for titlecard - patch_t *framecounter; patch_t *frameslash; // framerate stuff. Used in screen.c @@ -180,8 +178,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum); void HU_LoadGraphics(void) { - char buffer[9]; - INT32 i, j; + INT32 i; if (dedicated) return; @@ -194,27 +191,6 @@ void HU_LoadGraphics(void) emblemicon = HU_CachePatch("EMBLICON"); songcreditbg = HU_CachePatch("K_SONGCR"); - // Cache titlecard font - j = LT_FONTSTART; - for (i = 0; i < LT_FONTSIZE; i++, j++) - { - // cache the titlecard font - - // Bottom layer - sprintf(buffer, "GTOL%.3d", j); - if (W_CheckNumForName(buffer) == LUMPERROR) - tc_font[0][i] = NULL; - else - tc_font[0][i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); - - // Top layer - sprintf(buffer, "GTFN%.3d", j); - if (W_CheckNumForName(buffer) == LUMPERROR) - tc_font[1][i] = NULL; - else - tc_font[1][i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); - } - // cache ping gfx: for (i = 0; i < 5; i++) { @@ -279,6 +255,16 @@ void HU_Init(void) PR ("CRFNT"); REG; + DIG (3); + + ADIM (LT); + + PR ("GTOL"); + REG; + + PR ("GTFN"); + REG; + DIG (1); DIM (0, 10); diff --git a/src/hu_stuff.h b/src/hu_stuff.h index a8d8bee22..392ae27a2 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -39,11 +39,6 @@ #define LT_FONTEND 'z' // the last font characters #define LT_FONTSIZE (LT_FONTEND - LT_FONTSTART + 1) -// Under regular circumstances, we'd use the built in font stuff, however this font is a bit messy because of how we're gonna draw shit. -// tc_font[0][n] is used for the "bottom" layer -// tc_font[1][n] is used for the "top" layer -extern patch_t *tc_font[2][LT_FONTSIZE]; - #define CRED_FONTSTART '!' // the first font character #define CRED_FONTEND 'Z' // the last font character #define CRED_FONTSIZE (CRED_FONTEND - CRED_FONTSTART + 1) @@ -59,6 +54,9 @@ enum X (LT), X (CRED), + X (GTOL), + X (GTFN), + X (TALLNUM), X (NIGHTSNUM), X (PINGNUM), diff --git a/src/v_video.c b/src/v_video.c index 5bd7ba733..6367006d7 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1701,13 +1701,13 @@ INT32 V_TitleCardStringWidth(const char *str) c -= LT_FONTSTART; // check if character exists, if not, it's a space. - if (c < 0 || c >= LT_FONTSIZE || !tc_font[0][(INT32)c]) + if (c < 0 || c >= LT_FONTSIZE || !fontv[GTOL_FONT].font[(INT32)c]) { xoffs += 10; continue; } - pp = tc_font[1][(INT32)c]; + pp = fontv[GTFN_FONT].font[(INT32)c]; xoffs += pp->width-5; } @@ -1768,14 +1768,14 @@ void V_DrawTitleCardString(INT32 x, INT32 y, const char *str, INT32 flags, boole c -= LT_FONTSTART; // check if character exists, if not, it's a space. - if (c < 0 || c >= LT_FONTSIZE || !tc_font[1][(INT32)c]) + if (c < 0 || c >= LT_FONTSIZE || !fontv[GTFN_FONT].font[(INT32)c]) { xoffs += 10; continue; } - ol = tc_font[0][(INT32)c]; - pp = tc_font[1][(INT32)c]; + ol = fontv[GTOL_FONT].font[(INT32)c]; + pp = fontv[GTFN_FONT].font[(INT32)c]; if (timer) { From 1c0ddc7bca2cfc80f15a9b2c67d2462926208c7f Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 17 Dec 2021 02:38:17 -0800 Subject: [PATCH 06/13] P_AddWadFile: only reload graphics when replaced --- src/font.c | 4 +- src/hu_stuff.c | 14 +- src/k_hud.c | 350 ++++++++++++++++++++++++------------------------- src/p_setup.c | 2 +- src/st_stuff.c | 156 +++++++++++----------- 5 files changed, 263 insertions(+), 263 deletions(-) diff --git a/src/font.c b/src/font.c index aeaabd018..353f21a83 100644 --- a/src/font.c +++ b/src/font.c @@ -27,7 +27,7 @@ FontCache (font_t *fnt) c = fnt->start; for (i = 0; i < fnt->size; ++i, ++c) { - fnt->font[i] = HU_CachePatch( + HU_UpdatePatch(&fnt->font[i], "%s%.*d", fnt->prefix, fnt->digits, @@ -57,7 +57,7 @@ Font_DumbRegister (const font_t *sfnt) memcpy(fnt, sfnt, sizeof (font_t)); - if (!( fnt->font = ZZ_Alloc(sfnt->size * sizeof (patch_t *)) )) + if (!( fnt->font = ZZ_Calloc(sfnt->size * sizeof (patch_t *)) )) return -1; return fontc++; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 2a0bfa90c..130c1d437 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -186,21 +186,21 @@ void HU_LoadGraphics(void) Font_Load(); // minus for negative tallnums - tallminus = HU_CachePatch("STTMINUS"); + HU_UpdatePatch(&tallminus, "STTMINUS"); - emblemicon = HU_CachePatch("EMBLICON"); - songcreditbg = HU_CachePatch("K_SONGCR"); + HU_UpdatePatch(&emblemicon, "EMBLICON"); + HU_UpdatePatch(&songcreditbg, "K_SONGCR"); // cache ping gfx: for (i = 0; i < 5; i++) { - pinggfx[i] = HU_CachePatch("PINGGFX%d", i+1); - mping[i] = HU_CachePatch("MPING%d", i+1); + HU_UpdatePatch(&pinggfx[i], "PINGGFX%d", i+1); + HU_UpdatePatch(&mping[i], "MPING%d", i+1); } // fps stuff - framecounter = HU_CachePatch("FRAMER"); - frameslash = HU_CachePatch("FRAMESL");; + HU_UpdatePatch(&framecounter, "FRAMER"); + HU_UpdatePatch(&frameslash, "FRAMESL"); } // Initialise Heads up diff --git a/src/k_hud.c b/src/k_hud.c index 7f54abd49..986ea645a 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -170,23 +170,23 @@ void K_LoadKartHUDGraphics(void) char buffer[9]; // Null Stuff - kp_nodraw = W_CachePatchName("K_TRNULL", PU_HUDGFX); + HU_UpdatePatch(&kp_nodraw, "K_TRNULL"); // Stickers - kp_timesticker = W_CachePatchName("K_STTIME", PU_HUDGFX); - kp_timestickerwide = W_CachePatchName("K_STTIMW", PU_HUDGFX); - kp_lapsticker = W_CachePatchName("K_STLAPS", PU_HUDGFX); - kp_lapstickerwide = W_CachePatchName("K_STLAPW", PU_HUDGFX); - kp_lapstickernarrow = W_CachePatchName("K_STLAPN", PU_HUDGFX); - kp_splitlapflag = W_CachePatchName("K_SPTLAP", PU_HUDGFX); - kp_bumpersticker = W_CachePatchName("K_STBALN", PU_HUDGFX); - kp_bumperstickerwide = W_CachePatchName("K_STBALW", PU_HUDGFX); - kp_capsulesticker = W_CachePatchName("K_STCAPN", PU_HUDGFX); - kp_capsulestickerwide = W_CachePatchName("K_STCAPW", PU_HUDGFX); - kp_karmasticker = W_CachePatchName("K_STKARM", PU_HUDGFX); - kp_spheresticker = W_CachePatchName("K_STBSMT", PU_HUDGFX); - kp_splitkarmabomb = W_CachePatchName("K_SPTKRM", PU_HUDGFX); - kp_timeoutsticker = W_CachePatchName("K_STTOUT", PU_HUDGFX); + HU_UpdatePatch(&kp_timesticker, "K_STTIME"); + HU_UpdatePatch(&kp_timestickerwide, "K_STTIMW"); + HU_UpdatePatch(&kp_lapsticker, "K_STLAPS"); + HU_UpdatePatch(&kp_lapstickerwide, "K_STLAPW"); + HU_UpdatePatch(&kp_lapstickernarrow, "K_STLAPN"); + HU_UpdatePatch(&kp_splitlapflag, "K_SPTLAP"); + HU_UpdatePatch(&kp_bumpersticker, "K_STBALN"); + HU_UpdatePatch(&kp_bumperstickerwide, "K_STBALW"); + HU_UpdatePatch(&kp_capsulesticker, "K_STCAPN"); + HU_UpdatePatch(&kp_capsulestickerwide, "K_STCAPW"); + HU_UpdatePatch(&kp_karmasticker, "K_STKARM"); + HU_UpdatePatch(&kp_spheresticker, "K_STBSMT"); + HU_UpdatePatch(&kp_splitkarmabomb, "K_SPTKRM"); + HU_UpdatePatch(&kp_timeoutsticker, "K_STTOUT"); // Pre-start countdown bulbs sprintf(buffer, "K_BULBxx"); @@ -194,7 +194,7 @@ void K_LoadKartHUDGraphics(void) { buffer[6] = '0'+((i+1)/10); buffer[7] = '0'+((i+1)%10); - kp_prestartbulb[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_prestartbulb[i], "%s", buffer); } sprintf(buffer, "K_SBLBxx"); @@ -202,68 +202,68 @@ void K_LoadKartHUDGraphics(void) { buffer[6] = '0'+((i+1)/10); buffer[7] = '0'+((i+1)%10); - kp_prestartbulb_split[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_prestartbulb_split[i], "%s", buffer); } // Pre-start position letters - kp_prestartletters[0] = W_CachePatchName("K_PL_P", PU_HUDGFX); - kp_prestartletters[1] = W_CachePatchName("K_PL_O", PU_HUDGFX); - kp_prestartletters[2] = W_CachePatchName("K_PL_S", PU_HUDGFX); - kp_prestartletters[3] = W_CachePatchName("K_PL_I", PU_HUDGFX); - kp_prestartletters[4] = W_CachePatchName("K_PL_T", PU_HUDGFX); - kp_prestartletters[5] = W_CachePatchName("K_PL_N", PU_HUDGFX); - kp_prestartletters[6] = W_CachePatchName("K_PL_EX", PU_HUDGFX); + HU_UpdatePatch(&kp_prestartletters[0], "K_PL_P"); + HU_UpdatePatch(&kp_prestartletters[1], "K_PL_O"); + HU_UpdatePatch(&kp_prestartletters[2], "K_PL_S"); + HU_UpdatePatch(&kp_prestartletters[3], "K_PL_I"); + HU_UpdatePatch(&kp_prestartletters[4], "K_PL_T"); + HU_UpdatePatch(&kp_prestartletters[5], "K_PL_N"); + HU_UpdatePatch(&kp_prestartletters[6], "K_PL_EX"); - kp_prestartletters_split[0] = W_CachePatchName("K_SPL_P", PU_HUDGFX); - kp_prestartletters_split[1] = W_CachePatchName("K_SPL_O", PU_HUDGFX); - kp_prestartletters_split[2] = W_CachePatchName("K_SPL_S", PU_HUDGFX); - kp_prestartletters_split[3] = W_CachePatchName("K_SPL_I", PU_HUDGFX); - kp_prestartletters_split[4] = W_CachePatchName("K_SPL_T", PU_HUDGFX); - kp_prestartletters_split[5] = W_CachePatchName("K_SPL_N", PU_HUDGFX); - kp_prestartletters_split[6] = W_CachePatchName("K_SPL_EX", PU_HUDGFX); + HU_UpdatePatch(&kp_prestartletters_split[0], "K_SPL_P"); + HU_UpdatePatch(&kp_prestartletters_split[1], "K_SPL_O"); + HU_UpdatePatch(&kp_prestartletters_split[2], "K_SPL_S"); + HU_UpdatePatch(&kp_prestartletters_split[3], "K_SPL_I"); + HU_UpdatePatch(&kp_prestartletters_split[4], "K_SPL_T"); + HU_UpdatePatch(&kp_prestartletters_split[5], "K_SPL_N"); + HU_UpdatePatch(&kp_prestartletters_split[6], "K_SPL_EX"); // Starting countdown - kp_startcountdown[0] = W_CachePatchName("K_CNT3A", PU_HUDGFX); - kp_startcountdown[1] = W_CachePatchName("K_CNT2A", PU_HUDGFX); - kp_startcountdown[2] = W_CachePatchName("K_CNT1A", PU_HUDGFX); - kp_startcountdown[3] = W_CachePatchName("K_CNTGOA", PU_HUDGFX); - kp_startcountdown[4] = W_CachePatchName("K_DUEL1", PU_HUDGFX); - kp_startcountdown[5] = W_CachePatchName("K_CNT3B", PU_HUDGFX); - kp_startcountdown[6] = W_CachePatchName("K_CNT2B", PU_HUDGFX); - kp_startcountdown[7] = W_CachePatchName("K_CNT1B", PU_HUDGFX); - kp_startcountdown[8] = W_CachePatchName("K_CNTGOB", PU_HUDGFX); - kp_startcountdown[9] = W_CachePatchName("K_DUEL2", PU_HUDGFX); + HU_UpdatePatch(&kp_startcountdown[0], "K_CNT3A"); + HU_UpdatePatch(&kp_startcountdown[1], "K_CNT2A"); + HU_UpdatePatch(&kp_startcountdown[2], "K_CNT1A"); + HU_UpdatePatch(&kp_startcountdown[3], "K_CNTGOA"); + HU_UpdatePatch(&kp_startcountdown[4], "K_DUEL1"); + HU_UpdatePatch(&kp_startcountdown[5], "K_CNT3B"); + HU_UpdatePatch(&kp_startcountdown[6], "K_CNT2B"); + HU_UpdatePatch(&kp_startcountdown[7], "K_CNT1B"); + HU_UpdatePatch(&kp_startcountdown[8], "K_CNTGOB"); + HU_UpdatePatch(&kp_startcountdown[9], "K_DUEL2"); // Splitscreen - kp_startcountdown[10] = W_CachePatchName("K_SMC3A", PU_HUDGFX); - kp_startcountdown[11] = W_CachePatchName("K_SMC2A", PU_HUDGFX); - kp_startcountdown[12] = W_CachePatchName("K_SMC1A", PU_HUDGFX); - kp_startcountdown[13] = W_CachePatchName("K_SMCGOA", PU_HUDGFX); - kp_startcountdown[14] = W_CachePatchName("K_SDUEL1", PU_HUDGFX); - kp_startcountdown[15] = W_CachePatchName("K_SMC3B", PU_HUDGFX); - kp_startcountdown[16] = W_CachePatchName("K_SMC2B", PU_HUDGFX); - kp_startcountdown[17] = W_CachePatchName("K_SMC1B", PU_HUDGFX); - kp_startcountdown[18] = W_CachePatchName("K_SMCGOB", PU_HUDGFX); - kp_startcountdown[19] = W_CachePatchName("K_SDUEL2", PU_HUDGFX); + HU_UpdatePatch(&kp_startcountdown[10], "K_SMC3A"); + HU_UpdatePatch(&kp_startcountdown[11], "K_SMC2A"); + HU_UpdatePatch(&kp_startcountdown[12], "K_SMC1A"); + HU_UpdatePatch(&kp_startcountdown[13], "K_SMCGOA"); + HU_UpdatePatch(&kp_startcountdown[14], "K_SDUEL1"); + HU_UpdatePatch(&kp_startcountdown[15], "K_SMC3B"); + HU_UpdatePatch(&kp_startcountdown[16], "K_SMC2B"); + HU_UpdatePatch(&kp_startcountdown[17], "K_SMC1B"); + HU_UpdatePatch(&kp_startcountdown[18], "K_SMCGOB"); + HU_UpdatePatch(&kp_startcountdown[19], "K_SDUEL2"); // Fault - kp_racefault[0] = W_CachePatchName("K_FAULTA", PU_HUDGFX); - kp_racefault[1] = W_CachePatchName("K_FAULTB", PU_HUDGFX); + HU_UpdatePatch(&kp_racefault[0], "K_FAULTA"); + HU_UpdatePatch(&kp_racefault[1], "K_FAULTB"); // Splitscreen - kp_racefault[2] = W_CachePatchName("K_SMFLTA", PU_HUDGFX); - kp_racefault[3] = W_CachePatchName("K_SMFLTB", PU_HUDGFX); + HU_UpdatePatch(&kp_racefault[2], "K_SMFLTA"); + HU_UpdatePatch(&kp_racefault[3], "K_SMFLTB"); // 2P splitscreen - kp_racefault[4] = W_CachePatchName("K_2PFLTA", PU_HUDGFX); - kp_racefault[5] = W_CachePatchName("K_2PFLTB", PU_HUDGFX); + HU_UpdatePatch(&kp_racefault[4], "K_2PFLTA"); + HU_UpdatePatch(&kp_racefault[5], "K_2PFLTB"); // Finish - kp_racefinish[0] = W_CachePatchName("K_FINA", PU_HUDGFX); - kp_racefinish[1] = W_CachePatchName("K_FINB", PU_HUDGFX); + HU_UpdatePatch(&kp_racefinish[0], "K_FINA"); + HU_UpdatePatch(&kp_racefinish[1], "K_FINB"); // Splitscreen - kp_racefinish[2] = W_CachePatchName("K_SMFINA", PU_HUDGFX); - kp_racefinish[3] = W_CachePatchName("K_SMFINB", PU_HUDGFX); + HU_UpdatePatch(&kp_racefinish[2], "K_SMFINA"); + HU_UpdatePatch(&kp_racefinish[3], "K_SMFINB"); // 2P splitscreen - kp_racefinish[4] = W_CachePatchName("K_2PFINA", PU_HUDGFX); - kp_racefinish[5] = W_CachePatchName("K_2PFINB", PU_HUDGFX); + HU_UpdatePatch(&kp_racefinish[4], "K_2PFINA"); + HU_UpdatePatch(&kp_racefinish[5], "K_2PFINB"); // Position numbers sprintf(buffer, "K_POSNxx"); @@ -274,7 +274,7 @@ void K_LoadKartHUDGraphics(void) { //sprintf(buffer, "K_POSN%d%d", i, j); buffer[7] = '0'+j; - kp_positionnum[i][j] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_positionnum[i][j], "%s", buffer); } } @@ -282,7 +282,7 @@ void K_LoadKartHUDGraphics(void) for (i = 0; i < NUMWINFRAMES; i++) { buffer[7] = '0'+i; - kp_winnernum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_winnernum[i], "%s", buffer); } sprintf(buffer, "OPPRNKxx"); @@ -290,128 +290,128 @@ void K_LoadKartHUDGraphics(void) { buffer[6] = '0'+(i/10); buffer[7] = '0'+(i%10); - kp_facenum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_facenum[i], "%s", buffer); } sprintf(buffer, "K_CHILIx"); for (i = 0; i < 8; i++) { buffer[7] = '0'+(i+1); - kp_facehighlight[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_facehighlight[i], "%s", buffer); } - kp_spbminimap = W_CachePatchName("SPBMMAP", PU_HUDGFX); + HU_UpdatePatch(&kp_spbminimap, "SPBMMAP"); // Rings & Lives - kp_ringsticker[0] = W_CachePatchName("RNGBACKA", PU_HUDGFX); - kp_ringsticker[1] = W_CachePatchName("RNGBACKB", PU_HUDGFX); + HU_UpdatePatch(&kp_ringsticker[0], "RNGBACKA"); + HU_UpdatePatch(&kp_ringsticker[1], "RNGBACKB"); sprintf(buffer, "K_RINGx"); for (i = 0; i < 6; i++) { buffer[6] = '0'+(i+1); - kp_ring[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_ring[i], "%s", buffer); } - kp_ringdebtminus = W_CachePatchName("RDEBTMIN", PU_HUDGFX); + HU_UpdatePatch(&kp_ringdebtminus, "RDEBTMIN"); sprintf(buffer, "SPBRNGxx"); for (i = 0; i < 16; i++) { buffer[6] = '0'+((i+1) / 10); buffer[7] = '0'+((i+1) % 10); - kp_ringspblock[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_ringspblock[i], "%s", buffer); } - kp_ringstickersplit[0] = W_CachePatchName("SMRNGBGA", PU_HUDGFX); - kp_ringstickersplit[1] = W_CachePatchName("SMRNGBGB", PU_HUDGFX); + HU_UpdatePatch(&kp_ringstickersplit[0], "SMRNGBGA"); + HU_UpdatePatch(&kp_ringstickersplit[1], "SMRNGBGB"); sprintf(buffer, "K_SRINGx"); for (i = 0; i < 6; i++) { buffer[7] = '0'+(i+1); - kp_smallring[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_smallring[i], "%s", buffer); } - kp_ringdebtminussmall = W_CachePatchName("SRDEBTMN", PU_HUDGFX); + HU_UpdatePatch(&kp_ringdebtminussmall, "SRDEBTMN"); sprintf(buffer, "SPBRGSxx"); for (i = 0; i < 16; i++) { buffer[6] = '0'+((i+1) / 10); buffer[7] = '0'+((i+1) % 10); - kp_ringspblocksmall[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_ringspblocksmall[i], "%s", buffer); } // Speedometer - kp_speedometersticker = W_CachePatchName("K_SPDMBG", PU_HUDGFX); + HU_UpdatePatch(&kp_speedometersticker, "K_SPDMBG"); sprintf(buffer, "K_SPDMLx"); for (i = 0; i < 4; i++) { buffer[7] = '0'+(i+1); - kp_speedometerlabel[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_speedometerlabel[i], "%s", buffer); } // Extra ranking icons - kp_rankbumper = W_CachePatchName("K_BLNICO", PU_HUDGFX); - kp_tinybumper[0] = W_CachePatchName("K_BLNA", PU_HUDGFX); - kp_tinybumper[1] = W_CachePatchName("K_BLNB", PU_HUDGFX); - kp_ranknobumpers = W_CachePatchName("K_NOBLNS", PU_HUDGFX); - kp_rankcapsule = W_CachePatchName("K_CAPICO", PU_HUDGFX); - kp_rankemerald = W_CachePatchName("K_EMERC", PU_HUDGFX); - kp_rankemeraldflash = W_CachePatchName("K_EMERW", PU_HUDGFX); - kp_rankemeraldback = W_CachePatchName("K_EMERBK", PU_HUDGFX); + HU_UpdatePatch(&kp_rankbumper, "K_BLNICO"); + HU_UpdatePatch(&kp_tinybumper[0], "K_BLNA"); + HU_UpdatePatch(&kp_tinybumper[1], "K_BLNB"); + HU_UpdatePatch(&kp_ranknobumpers, "K_NOBLNS"); + HU_UpdatePatch(&kp_rankcapsule, "K_CAPICO"); + HU_UpdatePatch(&kp_rankemerald, "K_EMERC"); + HU_UpdatePatch(&kp_rankemeraldflash, "K_EMERW"); + HU_UpdatePatch(&kp_rankemeraldback, "K_EMERBK"); // Battle graphics - kp_battlewin = W_CachePatchName("K_BWIN", PU_HUDGFX); - kp_battlecool = W_CachePatchName("K_BCOOL", PU_HUDGFX); - kp_battlelose = W_CachePatchName("K_BLOSE", PU_HUDGFX); - kp_battlewait = W_CachePatchName("K_BWAIT", PU_HUDGFX); - kp_battleinfo = W_CachePatchName("K_BINFO", PU_HUDGFX); - kp_wanted = W_CachePatchName("K_WANTED", PU_HUDGFX); - kp_wantedsplit = W_CachePatchName("4PWANTED", PU_HUDGFX); - kp_wantedreticle = W_CachePatchName("MMAPWANT", PU_HUDGFX); + HU_UpdatePatch(&kp_battlewin, "K_BWIN"); + HU_UpdatePatch(&kp_battlecool, "K_BCOOL"); + HU_UpdatePatch(&kp_battlelose, "K_BLOSE"); + HU_UpdatePatch(&kp_battlewait, "K_BWAIT"); + HU_UpdatePatch(&kp_battleinfo, "K_BINFO"); + HU_UpdatePatch(&kp_wanted, "K_WANTED"); + HU_UpdatePatch(&kp_wantedsplit, "4PWANTED"); + HU_UpdatePatch(&kp_wantedreticle, "MMAPWANT"); // Kart Item Windows - kp_itembg[0] = W_CachePatchName("K_ITBG", PU_HUDGFX); - kp_itembg[1] = W_CachePatchName("K_ITBGD", PU_HUDGFX); - kp_itemtimer[0] = W_CachePatchName("K_ITIMER", PU_HUDGFX); - kp_itemmulsticker[0] = W_CachePatchName("K_ITMUL", PU_HUDGFX); - kp_itemx = W_CachePatchName("K_ITX", PU_HUDGFX); + HU_UpdatePatch(&kp_itembg[0], "K_ITBG"); + HU_UpdatePatch(&kp_itembg[1], "K_ITBGD"); + HU_UpdatePatch(&kp_itemtimer[0], "K_ITIMER"); + HU_UpdatePatch(&kp_itemmulsticker[0], "K_ITMUL"); + HU_UpdatePatch(&kp_itemx, "K_ITX"); - kp_superring[0] = W_CachePatchName("K_ITRING", PU_HUDGFX); - kp_sneaker[0] = W_CachePatchName("K_ITSHOE", PU_HUDGFX); - kp_rocketsneaker[0] = W_CachePatchName("K_ITRSHE", PU_HUDGFX); + HU_UpdatePatch(&kp_superring[0], "K_ITRING"); + HU_UpdatePatch(&kp_sneaker[0], "K_ITSHOE"); + HU_UpdatePatch(&kp_rocketsneaker[0], "K_ITRSHE"); sprintf(buffer, "K_ITINVx"); for (i = 0; i < 7; i++) { buffer[7] = '1'+i; - kp_invincibility[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_invincibility[i], "%s", buffer); } - kp_banana[0] = W_CachePatchName("K_ITBANA", PU_HUDGFX); - kp_eggman[0] = W_CachePatchName("K_ITEGGM", PU_HUDGFX); + HU_UpdatePatch(&kp_banana[0], "K_ITBANA"); + HU_UpdatePatch(&kp_eggman[0], "K_ITEGGM"); sprintf(buffer, "K_ITORBx"); for (i = 0; i < 4; i++) { buffer[7] = '1'+i; - kp_orbinaut[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_orbinaut[i], "%s", buffer); } - kp_jawz[0] = W_CachePatchName("K_ITJAWZ", PU_HUDGFX); - kp_mine[0] = W_CachePatchName("K_ITMINE", PU_HUDGFX); - kp_landmine[0] = W_CachePatchName("K_ITLNDM", PU_HUDGFX); - kp_ballhog[0] = W_CachePatchName("K_ITBHOG", PU_HUDGFX); - kp_selfpropelledbomb[0] = W_CachePatchName("K_ITSPB", PU_HUDGFX); - kp_grow[0] = W_CachePatchName("K_ITGROW", PU_HUDGFX); - kp_shrink[0] = W_CachePatchName("K_ITSHRK", PU_HUDGFX); - kp_thundershield[0] = W_CachePatchName("K_ITTHNS", PU_HUDGFX); - kp_bubbleshield[0] = W_CachePatchName("K_ITBUBS", PU_HUDGFX); - kp_flameshield[0] = W_CachePatchName("K_ITFLMS", PU_HUDGFX); - kp_hyudoro[0] = W_CachePatchName("K_ITHYUD", PU_HUDGFX); - kp_pogospring[0] = W_CachePatchName("K_ITPOGO", PU_HUDGFX); - kp_kitchensink[0] = W_CachePatchName("K_ITSINK", PU_HUDGFX); - kp_sadface[0] = W_CachePatchName("K_ITSAD", PU_HUDGFX); + HU_UpdatePatch(&kp_jawz[0], "K_ITJAWZ"); + HU_UpdatePatch(&kp_mine[0], "K_ITMINE"); + HU_UpdatePatch(&kp_landmine[0], "K_ITLNDM"); + HU_UpdatePatch(&kp_ballhog[0], "K_ITBHOG"); + HU_UpdatePatch(&kp_selfpropelledbomb[0], "K_ITSPB"); + HU_UpdatePatch(&kp_grow[0], "K_ITGROW"); + HU_UpdatePatch(&kp_shrink[0], "K_ITSHRK"); + HU_UpdatePatch(&kp_thundershield[0], "K_ITTHNS"); + HU_UpdatePatch(&kp_bubbleshield[0], "K_ITBUBS"); + HU_UpdatePatch(&kp_flameshield[0], "K_ITFLMS"); + HU_UpdatePatch(&kp_hyudoro[0], "K_ITHYUD"); + HU_UpdatePatch(&kp_pogospring[0], "K_ITPOGO"); + HU_UpdatePatch(&kp_kitchensink[0], "K_ITSINK"); + HU_UpdatePatch(&kp_sadface[0], "K_ITSAD"); sprintf(buffer, "FSMFGxxx"); for (i = 0; i < 104; i++) @@ -419,7 +419,7 @@ void K_LoadKartHUDGraphics(void) buffer[5] = '0'+((i+1)/100); buffer[6] = '0'+(((i+1)/10)%10); buffer[7] = '0'+((i+1)%10); - kp_flameshieldmeter[i][0] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_flameshieldmeter[i][0], "%s", buffer); } sprintf(buffer, "FSMBG0xx"); @@ -427,41 +427,41 @@ void K_LoadKartHUDGraphics(void) { buffer[6] = '0'+((i+1)/10); buffer[7] = '0'+((i+1)%10); - kp_flameshieldmeter_bg[i][0] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_flameshieldmeter_bg[i][0], "%s", buffer); } // Splitscreen - kp_itembg[2] = W_CachePatchName("K_ISBG", PU_HUDGFX); - kp_itembg[3] = W_CachePatchName("K_ISBGD", PU_HUDGFX); - kp_itemtimer[1] = W_CachePatchName("K_ISIMER", PU_HUDGFX); - kp_itemmulsticker[1] = W_CachePatchName("K_ISMUL", PU_HUDGFX); + HU_UpdatePatch(&kp_itembg[2], "K_ISBG"); + HU_UpdatePatch(&kp_itembg[3], "K_ISBGD"); + HU_UpdatePatch(&kp_itemtimer[1], "K_ISIMER"); + HU_UpdatePatch(&kp_itemmulsticker[1], "K_ISMUL"); - kp_superring[1] = W_CachePatchName("K_ISRING", PU_HUDGFX); - kp_sneaker[1] = W_CachePatchName("K_ISSHOE", PU_HUDGFX); - kp_rocketsneaker[1] = W_CachePatchName("K_ISRSHE", PU_HUDGFX); + HU_UpdatePatch(&kp_superring[1], "K_ISRING"); + HU_UpdatePatch(&kp_sneaker[1], "K_ISSHOE"); + HU_UpdatePatch(&kp_rocketsneaker[1], "K_ISRSHE"); sprintf(buffer, "K_ISINVx"); for (i = 0; i < 6; i++) { buffer[7] = '1'+i; - kp_invincibility[i+7] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_invincibility[i+7], "%s", buffer); } - kp_banana[1] = W_CachePatchName("K_ISBANA", PU_HUDGFX); - kp_eggman[1] = W_CachePatchName("K_ISEGGM", PU_HUDGFX); - kp_orbinaut[4] = W_CachePatchName("K_ISORBN", PU_HUDGFX); - kp_jawz[1] = W_CachePatchName("K_ISJAWZ", PU_HUDGFX); - kp_mine[1] = W_CachePatchName("K_ISMINE", PU_HUDGFX); - kp_landmine[1] = W_CachePatchName("K_ISLNDM", PU_HUDGFX); - kp_ballhog[1] = W_CachePatchName("K_ISBHOG", PU_HUDGFX); - kp_selfpropelledbomb[1] = W_CachePatchName("K_ISSPB", PU_HUDGFX); - kp_grow[1] = W_CachePatchName("K_ISGROW", PU_HUDGFX); - kp_shrink[1] = W_CachePatchName("K_ISSHRK", PU_HUDGFX); - kp_thundershield[1] = W_CachePatchName("K_ISTHNS", PU_HUDGFX); - kp_bubbleshield[1] = W_CachePatchName("K_ISBUBS", PU_HUDGFX); - kp_flameshield[1] = W_CachePatchName("K_ISFLMS", PU_HUDGFX); - kp_hyudoro[1] = W_CachePatchName("K_ISHYUD", PU_HUDGFX); - kp_pogospring[1] = W_CachePatchName("K_ISPOGO", PU_HUDGFX); - kp_kitchensink[1] = W_CachePatchName("K_ISSINK", PU_HUDGFX); - kp_sadface[1] = W_CachePatchName("K_ISSAD", PU_HUDGFX); + HU_UpdatePatch(&kp_banana[1], "K_ISBANA"); + HU_UpdatePatch(&kp_eggman[1], "K_ISEGGM"); + HU_UpdatePatch(&kp_orbinaut[4], "K_ISORBN"); + HU_UpdatePatch(&kp_jawz[1], "K_ISJAWZ"); + HU_UpdatePatch(&kp_mine[1], "K_ISMINE"); + HU_UpdatePatch(&kp_landmine[1], "K_ISLNDM"); + HU_UpdatePatch(&kp_ballhog[1], "K_ISBHOG"); + HU_UpdatePatch(&kp_selfpropelledbomb[1], "K_ISSPB"); + HU_UpdatePatch(&kp_grow[1], "K_ISGROW"); + HU_UpdatePatch(&kp_shrink[1], "K_ISSHRK"); + HU_UpdatePatch(&kp_thundershield[1], "K_ISTHNS"); + HU_UpdatePatch(&kp_bubbleshield[1], "K_ISBUBS"); + HU_UpdatePatch(&kp_flameshield[1], "K_ISFLMS"); + HU_UpdatePatch(&kp_hyudoro[1], "K_ISHYUD"); + HU_UpdatePatch(&kp_pogospring[1], "K_ISPOGO"); + HU_UpdatePatch(&kp_kitchensink[1], "K_ISSINK"); + HU_UpdatePatch(&kp_sadface[1], "K_ISSAD"); sprintf(buffer, "FSMFSxxx"); for (i = 0; i < 104; i++) @@ -469,7 +469,7 @@ void K_LoadKartHUDGraphics(void) buffer[5] = '0'+((i+1)/100); buffer[6] = '0'+(((i+1)/10)%10); buffer[7] = '0'+((i+1)%10); - kp_flameshieldmeter[i][1] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_flameshieldmeter[i][1], "%s", buffer); } sprintf(buffer, "FSMBS0xx"); @@ -477,7 +477,7 @@ void K_LoadKartHUDGraphics(void) { buffer[6] = '0'+((i+1)/10); buffer[7] = '0'+((i+1)%10); - kp_flameshieldmeter_bg[i][1] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_flameshieldmeter_bg[i][1], "%s", buffer); } // CHECK indicators @@ -485,7 +485,7 @@ void K_LoadKartHUDGraphics(void) for (i = 0; i < 6; i++) { buffer[7] = '1'+i; - kp_check[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_check[i], "%s", buffer); } // Rival indicators @@ -493,7 +493,7 @@ void K_LoadKartHUDGraphics(void) for (i = 0; i < 2; i++) { buffer[7] = '1'+i; - kp_rival[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_rival[i], "%s", buffer); } // Rival indicators @@ -504,33 +504,33 @@ void K_LoadKartHUDGraphics(void) for (j = 0; j < 2; j++) { buffer[7] = '1'+j; - kp_localtag[i][j] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_localtag[i][j], "%s", buffer); } } // Typing indicator - kp_talk = W_CachePatchName("K_TALK", PU_HUDGFX); - kp_typdot = W_CachePatchName("K_TYPDOT", PU_HUDGFX); + HU_UpdatePatch(&kp_talk, "K_TALK"); + HU_UpdatePatch(&kp_typdot, "K_TYPDOT"); // Eggman warning numbers sprintf(buffer, "K_EGGNx"); for (i = 0; i < 4; i++) { buffer[6] = '0'+i; - kp_eggnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_eggnum[i], "%s", buffer); } // First person mode - kp_fpview[0] = W_CachePatchName("VIEWA0", PU_HUDGFX); - kp_fpview[1] = W_CachePatchName("VIEWB0D0", PU_HUDGFX); - kp_fpview[2] = W_CachePatchName("VIEWC0E0", PU_HUDGFX); + HU_UpdatePatch(&kp_fpview[0], "VIEWA0"); + HU_UpdatePatch(&kp_fpview[1], "VIEWB0D0"); + HU_UpdatePatch(&kp_fpview[2], "VIEWC0E0"); // Input UI Wheel sprintf(buffer, "K_WHEELx"); for (i = 0; i < 5; i++) { buffer[7] = '0'+i; - kp_inputwheel[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_inputwheel[i], "%s", buffer); } // HERE COMES A NEW CHALLENGER @@ -539,7 +539,7 @@ void K_LoadKartHUDGraphics(void) { buffer[6] = '0'+((i+1)/10); buffer[7] = '0'+((i+1)%10); - kp_challenger[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_challenger[i], "%s", buffer); } // Lap start animation @@ -547,7 +547,7 @@ void K_LoadKartHUDGraphics(void) for (i = 0; i < 7; i++) { buffer[6] = '0'+(i+1); - kp_lapanim_lap[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_lapanim_lap[i], "%s", buffer); } sprintf(buffer, "K_LAPFxx"); @@ -555,7 +555,7 @@ void K_LoadKartHUDGraphics(void) { buffer[6] = '0'+((i+1)/10); buffer[7] = '0'+((i+1)%10); - kp_lapanim_final[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_lapanim_final[i], "%s", buffer); } sprintf(buffer, "K_LAPNxx"); @@ -565,7 +565,7 @@ void K_LoadKartHUDGraphics(void) for (j = 0; j < 3; j++) { buffer[7] = '0'+(j+1); - kp_lapanim_number[i][j] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_lapanim_number[i][j], "%s", buffer); } } @@ -573,39 +573,39 @@ void K_LoadKartHUDGraphics(void) for (i = 0; i < 2; i++) { buffer[7] = '0'+(i+1); - kp_lapanim_emblem[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_lapanim_emblem[i], "%s", buffer); } sprintf(buffer, "K_LAPH0x"); for (i = 0; i < 3; i++) { buffer[7] = '0'+(i+1); - kp_lapanim_hand[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_lapanim_hand[i], "%s", buffer); } - kp_yougotem = (patch_t *) W_CachePatchName("YOUGOTEM", PU_HUDGFX); - kp_itemminimap = (patch_t *) W_CachePatchName("MMAPITEM", PU_HUDGFX); + HU_UpdatePatch(&kp_yougotem, "YOUGOTEM"); + HU_UpdatePatch(&kp_itemminimap, "MMAPITEM"); sprintf(buffer, "ALAGLESx"); for (i = 0; i < 10; ++i) { buffer[7] = '0'+i; - kp_alagles[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_alagles[i], "%s", buffer); } sprintf(buffer, "BLAGLESx"); for (i = 0; i < 6; ++i) { buffer[7] = '0'+i; - kp_blagles[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + HU_UpdatePatch(&kp_blagles[i], "%s", buffer); } - kp_cpu = (patch_t *) W_CachePatchName("K_CPU", PU_HUDGFX); + HU_UpdatePatch(&kp_cpu, "K_CPU"); - kp_nametagstem = (patch_t *) W_CachePatchName("K_NAMEST", PU_HUDGFX); + HU_UpdatePatch(&kp_nametagstem, "K_NAMEST"); - kp_trickcool[0] = W_CachePatchName("K_COOL1", PU_HUDGFX); - kp_trickcool[1] = W_CachePatchName("K_COOL2", PU_HUDGFX); + HU_UpdatePatch(&kp_trickcool[0], "K_COOL1"); + HU_UpdatePatch(&kp_trickcool[1], "K_COOL2"); } // For the item toggle menu diff --git a/src/p_setup.c b/src/p_setup.c index 62cb26d81..e0c00fe3e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4462,7 +4462,7 @@ boolean P_AddWadFile(const char *wadfilename) P_InitPicAnims(); // Flush and reload HUD graphics - ST_UnloadGraphics(); + //ST_UnloadGraphics(); HU_LoadGraphics(); ST_LoadGraphics(); diff --git a/src/st_stuff.c b/src/st_stuff.c index 3e0788f4d..d2f774f95 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -261,114 +261,114 @@ void ST_LoadGraphics(void) // cache the status bar overlay icons (fullscreen mode) // Prefix "STT" is whitelisted (doesn't trigger ISGAMEMODIFIED), btw - sborings = W_CachePatchName("STTRINGS", PU_HUDGFX); - sboredrings = W_CachePatchName("STTRRING", PU_HUDGFX); - sboscore = W_CachePatchName("STTSCORE", PU_HUDGFX); - sbotime = W_CachePatchName("STTTIME", PU_HUDGFX); // Time logo - sboredtime = W_CachePatchName("STTRTIME", PU_HUDGFX); - sbocolon = W_CachePatchName("STTCOLON", PU_HUDGFX); // Colon for time - sboperiod = W_CachePatchName("STTPERIO", PU_HUDGFX); // Period for time centiseconds + HU_UpdatePatch(&sborings, "STTRINGS"); + HU_UpdatePatch(&sboredrings, "STTRRING"); + HU_UpdatePatch(&sboscore, "STTSCORE"); + HU_UpdatePatch(&sbotime, "STTTIME"); // Time logo + HU_UpdatePatch(&sboredtime, "STTRTIME"); + HU_UpdatePatch(&sbocolon, "STTCOLON"); // Colon for time + HU_UpdatePatch(&sboperiod, "STTPERIO"); // Period for time centiseconds - slidgame = W_CachePatchName("SLIDGAME", PU_HUDGFX); - slidtime = W_CachePatchName("SLIDTIME", PU_HUDGFX); - slidover = W_CachePatchName("SLIDOVER", PU_HUDGFX); + HU_UpdatePatch(&slidgame, "SLIDGAME"); + HU_UpdatePatch(&slidtime, "SLIDTIME"); + HU_UpdatePatch(&slidover, "SLIDOVER"); - stlivex = W_CachePatchName("STLIVEX", PU_HUDGFX); - livesback = W_CachePatchName("STLIVEBK", PU_HUDGFX); - nrec_timer = W_CachePatchName("NGRTIMER", PU_HUDGFX); // Timer for NiGHTS - getall = W_CachePatchName("GETALL", PU_HUDGFX); // Special Stage HUD - timeup = W_CachePatchName("TIMEUP", PU_HUDGFX); // Special Stage HUD - race1 = W_CachePatchName("RACE1", PU_HUDGFX); - race2 = W_CachePatchName("RACE2", PU_HUDGFX); - race3 = W_CachePatchName("RACE3", PU_HUDGFX); - racego = W_CachePatchName("RACEGO", PU_HUDGFX); - nightslink = W_CachePatchName("NGHTLINK", PU_HUDGFX); + HU_UpdatePatch(&stlivex, "STLIVEX"); + HU_UpdatePatch(&livesback, "STLIVEBK"); + HU_UpdatePatch(&nrec_timer, "NGRTIMER"); // Timer for NiGHTS + HU_UpdatePatch(&getall, "GETALL"); // Special Stage HUD + HU_UpdatePatch(&timeup, "TIMEUP"); // Special Stage HUD + HU_UpdatePatch(&race1, "RACE1"); + HU_UpdatePatch(&race2, "RACE2"); + HU_UpdatePatch(&race3, "RACE3"); + HU_UpdatePatch(&racego, "RACEGO"); + HU_UpdatePatch(&nightslink, "NGHTLINK"); for (i = 0; i < 6; ++i) { - hunthoming[i] = W_CachePatchName(va("HOMING%d", i+1), PU_HUDGFX); - itemhoming[i] = W_CachePatchName(va("HOMITM%d", i+1), PU_HUDGFX); + HU_UpdatePatch(&hunthoming[i], "HOMING%d", i+1); + HU_UpdatePatch(&itemhoming[i], "HOMITM%d", i+1); } - curweapon = W_CachePatchName("CURWEAP", PU_HUDGFX); - normring = W_CachePatchName("RINGIND", PU_HUDGFX); - bouncering = W_CachePatchName("BNCEIND", PU_HUDGFX); - infinityring = W_CachePatchName("INFNIND", PU_HUDGFX); - autoring = W_CachePatchName("AUTOIND", PU_HUDGFX); - explosionring = W_CachePatchName("BOMBIND", PU_HUDGFX); - scatterring = W_CachePatchName("SCATIND", PU_HUDGFX); - grenadering = W_CachePatchName("GRENIND", PU_HUDGFX); - railring = W_CachePatchName("RAILIND", PU_HUDGFX); - jumpshield = W_CachePatchName("TVWWICON", PU_HUDGFX); - forceshield = W_CachePatchName("TVFOICON", PU_HUDGFX); - ringshield = W_CachePatchName("TVATICON", PU_HUDGFX); - watershield = W_CachePatchName("TVELICON", PU_HUDGFX); - bombshield = W_CachePatchName("TVARICON", PU_HUDGFX); - pityshield = W_CachePatchName("TVPIICON", PU_HUDGFX); - pinkshield = W_CachePatchName("TVPPICON", PU_HUDGFX); - flameshield = W_CachePatchName("TVFLICON", PU_HUDGFX); - bubbleshield = W_CachePatchName("TVBBICON", PU_HUDGFX); - thundershield = W_CachePatchName("TVZPICON", PU_HUDGFX); - invincibility = W_CachePatchName("TVIVICON", PU_HUDGFX); - sneakers = W_CachePatchName("TVSSICON", PU_HUDGFX); - gravboots = W_CachePatchName("TVGVICON", PU_HUDGFX); + HU_UpdatePatch(&curweapon, "CURWEAP"); + HU_UpdatePatch(&normring, "RINGIND"); + HU_UpdatePatch(&bouncering, "BNCEIND"); + HU_UpdatePatch(&infinityring, "INFNIND"); + HU_UpdatePatch(&autoring, "AUTOIND"); + HU_UpdatePatch(&explosionring, "BOMBIND"); + HU_UpdatePatch(&scatterring, "SCATIND"); + HU_UpdatePatch(&grenadering, "GRENIND"); + HU_UpdatePatch(&railring, "RAILIND"); + HU_UpdatePatch(&jumpshield, "TVWWICON"); + HU_UpdatePatch(&forceshield, "TVFOICON"); + HU_UpdatePatch(&ringshield, "TVATICON"); + HU_UpdatePatch(&watershield, "TVELICON"); + HU_UpdatePatch(&bombshield, "TVARICON"); + HU_UpdatePatch(&pityshield, "TVPIICON"); + HU_UpdatePatch(&pinkshield, "TVPPICON"); + HU_UpdatePatch(&flameshield, "TVFLICON"); + HU_UpdatePatch(&bubbleshield, "TVBBICON"); + HU_UpdatePatch(&thundershield, "TVZPICON"); + HU_UpdatePatch(&invincibility, "TVIVICON"); + HU_UpdatePatch(&sneakers, "TVSSICON"); + HU_UpdatePatch(&gravboots, "TVGVICON"); - tagico = W_CachePatchName("TAGICO", PU_HUDGFX); - rflagico = W_CachePatchName("RFLAGICO", PU_HUDGFX); - bflagico = W_CachePatchName("BFLAGICO", PU_HUDGFX); - rmatcico = W_CachePatchName("RMATCICO", PU_HUDGFX); - bmatcico = W_CachePatchName("BMATCICO", PU_HUDGFX); - gotrflag = W_CachePatchName("GOTRFLAG", PU_HUDGFX); - gotbflag = W_CachePatchName("GOTBFLAG", PU_HUDGFX); - fnshico = W_CachePatchName("FNSHICO", PU_HUDGFX); - nonicon = W_CachePatchName("NONICON", PU_HUDGFX); - nonicon2 = W_CachePatchName("NONICON2", PU_HUDGFX); + HU_UpdatePatch(&tagico, "TAGICO"); + HU_UpdatePatch(&rflagico, "RFLAGICO"); + HU_UpdatePatch(&bflagico, "BFLAGICO"); + HU_UpdatePatch(&rmatcico, "RMATCICO"); + HU_UpdatePatch(&bmatcico, "BMATCICO"); + HU_UpdatePatch(&gotrflag, "GOTRFLAG"); + HU_UpdatePatch(&gotbflag, "GOTBFLAG"); + HU_UpdatePatch(&fnshico, "FNSHICO"); + HU_UpdatePatch(&nonicon, "NONICON"); + HU_UpdatePatch(&nonicon2, "NONICON2"); // NiGHTS HUD things - bluestat = W_CachePatchName("BLUESTAT", PU_HUDGFX); - byelstat = W_CachePatchName("BYELSTAT", PU_HUDGFX); - orngstat = W_CachePatchName("ORNGSTAT", PU_HUDGFX); - redstat = W_CachePatchName("REDSTAT", PU_HUDGFX); - yelstat = W_CachePatchName("YELSTAT", PU_HUDGFX); - nbracket = W_CachePatchName("NBRACKET", PU_HUDGFX); - nring = W_CachePatchName("NRNG1", PU_HUDGFX); + HU_UpdatePatch(&bluestat, "BLUESTAT"); + HU_UpdatePatch(&byelstat, "BYELSTAT"); + HU_UpdatePatch(&orngstat, "ORNGSTAT"); + HU_UpdatePatch(&redstat, "REDSTAT"); + HU_UpdatePatch(&yelstat, "YELSTAT"); + HU_UpdatePatch(&nbracket, "NBRACKET"); + HU_UpdatePatch(&nring, "NRNG1"); for (i = 0; i < 12; ++i) { - nhud[i] = W_CachePatchName(va("NHUD%d", i+1), PU_HUDGFX); - nbon[i] = W_CachePatchName(va("NBON%d", i+1), PU_HUDGFX); + HU_UpdatePatch(&nhud[i], "NHUD%d", i+1); + HU_UpdatePatch(&nbon[i], "NBON%d", i+1); } - nsshud = W_CachePatchName("NSSHUD", PU_HUDGFX); - nssbon = W_CachePatchName("NSSBON", PU_HUDGFX); - minicaps = W_CachePatchName("MINICAPS", PU_HUDGFX); + HU_UpdatePatch(&nsshud, "NSSHUD"); + HU_UpdatePatch(&nssbon, "NSSBON"); + HU_UpdatePatch(&minicaps, "MINICAPS"); for (i = 0; i < 8; ++i) { - narrow[i] = W_CachePatchName(va("NARROW%d", i+1), PU_HUDGFX); - nredar[i] = W_CachePatchName(va("NREDAR%d", i+1), PU_HUDGFX); + HU_UpdatePatch(&narrow[i], "NARROW%d", i+1); + HU_UpdatePatch(&nredar[i], "NREDAR%d", i+1); } // non-animated version - narrow[8] = W_CachePatchName("NARROW9", PU_HUDGFX); + HU_UpdatePatch(&narrow[8], "NARROW9"); - drillbar = W_CachePatchName("DRILLBAR", PU_HUDGFX); + HU_UpdatePatch(&drillbar, "DRILLBAR"); for (i = 0; i < 3; ++i) - drillfill[i] = W_CachePatchName(va("DRILLFI%d", i+1), PU_HUDGFX); - capsulebar = W_CachePatchName("CAPSBAR", PU_HUDGFX); - capsulefill = W_CachePatchName("CAPSFILL", PU_HUDGFX); - minus5sec = W_CachePatchName("MINUS5", PU_HUDGFX); + HU_UpdatePatch(&drillfill[i], "DRILLFI%d", i+1); + HU_UpdatePatch(&capsulebar, "CAPSBAR"); + HU_UpdatePatch(&capsulefill, "CAPSFILL"); + HU_UpdatePatch(&minus5sec, "MINUS5"); for (i = 0; i < 7; ++i) - ngradeletters[i] = W_CachePatchName(va("GRADE%d", i), PU_HUDGFX); + HU_UpdatePatch(&ngradeletters[i], "GRADE%d", i); K_LoadKartHUDGraphics(); // Midnight Channel: - hud_tv1 = W_CachePatchName("HUD_TV1", PU_HUDGFX); - hud_tv2 = W_CachePatchName("HUD_TV2", PU_HUDGFX); + HU_UpdatePatch(&hud_tv1, "HUD_TV1"); + HU_UpdatePatch(&hud_tv2, "HUD_TV2"); #ifdef HAVE_DISCORDRPC // Discord Rich Presence - envelope = W_CachePatchName("K_REQUES", PU_HUDGFX); + HU_UpdatePatch(&envelope, "K_REQUES"); #endif } From 0cf65047ec02fffd86947226ddee02d441acbdbc Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 17 Dec 2021 03:09:00 -0800 Subject: [PATCH 07/13] Do not load MUSICDEF twice --- src/p_setup.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index e0c00fe3e..1aabc2227 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4478,11 +4478,6 @@ boolean P_AddWadFile(const char *wadfilename) // S_LoadMusicDefs(wadnum); - // - // edit music defs - // - S_LoadMusicDefs(wadnum); - // // search for maps // From 2179da40bf0878e003f4030cdb92c8661db47771 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 18 Dec 2021 18:23:24 -0500 Subject: [PATCH 08/13] Update brightmap reading - Does it per-wad - Saves hashes for certain bits - Adds R_UpdateTextureBrightmap to respect the zone memory --- src/d_netcmd.c | 2 +- src/k_brightmap.c | 88 +++++++++++++++++++++++------------------------ src/k_brightmap.h | 11 ++++++ src/p_setup.c | 2 +- src/r_textures.h | 2 ++ 5 files changed, 59 insertions(+), 46 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c221aee90..31004c0b1 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2571,7 +2571,7 @@ static void Command_Map_f(void) mustmodifygame = !(netgame || multiplayer) && !majormods; - if (mustmodifygame) + if (mustmodifygame && !option_force) { /* May want to be more descriptive? */ CONS_Printf(M_GetText("Sorry, level change disabled in single player.\n")); diff --git a/src/k_brightmap.c b/src/k_brightmap.c index f481938f2..c62d645e6 100644 --- a/src/k_brightmap.c +++ b/src/k_brightmap.c @@ -37,7 +37,7 @@ static size_t maxBrightmapStorage = 0; static brightmapStorage_t *K_NewBrightmap(void) { 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 ]; } @@ -63,6 +63,7 @@ static brightmapStorage_t *K_GetBrightmapStorageByIndex(size_t checkIndex) --------------------------------------------------*/ static brightmapStorage_t *K_GetBrightmapStorageByTextureName(const char *checkName) { + UINT32 checkHash = quickncasehash(checkName, 8); size_t i; if (maxBrightmapStorage == 0) @@ -74,7 +75,7 @@ static brightmapStorage_t *K_GetBrightmapStorageByTextureName(const char *checkN { brightmapStorage_t *bms = &brightmapStorage[i]; - if (stricmp(checkName, bms->textureName) == 0) + if (checkHash == bms->textureHash) { // Name matches. return bms; @@ -119,6 +120,7 @@ static boolean K_BRIGHTLumpParser(UINT8 *data, size_t size) { bms = K_NewBrightmap(); strncpy(bms->textureName, tkn, 9); + bms->textureHash = quickncasehash(bms->textureName, 8); } Z_Free(tkn); @@ -128,6 +130,7 @@ static boolean K_BRIGHTLumpParser(UINT8 *data, size_t size) if (tkn && pos < size) { strncpy(bms->brightmapName, tkn, 9); + bms->brightmapHash = quickncasehash(bms->brightmapName, 8); } 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. --------------------------------------------------*/ -void K_InitBrightmaps(void) +void K_InitBrightmapsPwad(INT32 wadNum) { - INT32 wadNum; + UINT16 lumpNum; size_t i; 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 - lumpNum = W_CheckNumForNamePwad("BRIGHT", wadNum, 0); - - while (lumpNum != INT16_MAX) + if (data != NULL) { - UINT8 *data; - data = (UINT8 *)W_CacheLumpNumPwad(wadNum, lumpNum, PU_STATIC); + lumpinfo_t *lump_p = &wadfiles[wadNum]->lumpinfo[lumpNum]; + size_t size = W_LumpLengthPwad(wadNum, lumpNum); - // If that didn't exist, we have nothing to do here. - if (data == NULL) - { - 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 + char *name = malloc(nameLength + 1); - size_t nameLength = strlen(wadfiles[wadNum]->filename) + 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name - char *name = malloc(nameLength + 1); + sprintf(name, "%s|%s", wadfiles[wadNum]->filename, lump_p->fullname); + name[nameLength] = '\0'; - sprintf(name, "%s|%s", wadfiles[wadNum]->filename, lump_p->fullname); - name[nameLength] = '\0'; + size = W_LumpLengthPwad(wadNum, lumpNum); - 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); - K_BRIGHTLumpParser(data, size); - - free(name); - } - - lumpNum = W_CheckNumForNamePwad("BRIGHT", (UINT16)wadNum, lumpNum + 1); + free(name); + Z_Free(data); } + + lumpNum = W_CheckNumForNamePwad("BRIGHT", (UINT16)wadNum, lumpNum + 1); } if (maxBrightmapStorage == 0) @@ -237,14 +228,7 @@ void K_InitBrightmaps(void) if (texNum != -1) { bmNum = R_CheckTextureNumForName(bms->brightmapName); - if (bmNum == -1) - { - texturebrightmaps[texNum] = 0; - } - else - { - texturebrightmaps[texNum] = bmNum; - } + R_UpdateTextureBrightmap(texNum, (bmNum == -1 ? 0 : bmNum)); } } @@ -253,4 +237,20 @@ void K_InitBrightmaps(void) // Clear brightmapStorage now that we're done with it. Z_Free(brightmapStorage); 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); + } } diff --git a/src/k_brightmap.h b/src/k_brightmap.h index 8d33ae5cb..72bc7e9df 100644 --- a/src/k_brightmap.h +++ b/src/k_brightmap.h @@ -24,9 +24,20 @@ typedef struct brightmapStorage_s // before putting them into texturebrightmaps. char textureName[9]; // The texture's name. + UINT32 textureHash; // The texture name's hash. + char brightmapName[9]; // The brightmap's name. + UINT32 brightmapHash; // The brightmap name's hash. } 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); diff --git a/src/p_setup.c b/src/p_setup.c index 08826cf64..fcbe9ed07 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4463,7 +4463,7 @@ boolean P_AddWadFile(const char *wadfilename) P_InitPicAnims(); // Reload BRIGHT - K_InitBrightmaps(); + K_InitBrightmapsPwad(wadnum); // Flush and reload HUD graphics //ST_UnloadGraphics(); diff --git a/src/r_textures.h b/src/r_textures.h index 284fce987..fd67427f2 100644 --- a/src/r_textures.h +++ b/src/r_textures.h @@ -96,6 +96,8 @@ void *R_GetFlat(lumpnum_t flatnum); boolean R_CheckPowersOfTwo(void); void R_CheckFlatLength(size_t size); +void R_UpdateTextureBrightmap(INT32 tx, INT32 bm); + // Returns the texture number for the texture name. INT32 R_TextureNumForName(const char *name); INT32 R_CheckTextureNumForName(const char *name); From cd7e1258636a161258f945a244b8aee48663f204 Mon Sep 17 00:00:00 2001 From: toaster Date: Sat, 12 Mar 2022 18:00:52 +0000 Subject: [PATCH 09/13] Update texturecache user when reallocating # Conflicts: # src/r_textures.c --- src/r_textures.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/r_textures.c b/src/r_textures.c index b48ca9efd..d04935b3e 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -1056,10 +1056,20 @@ static void R_AllocateTextures(INT32 add) // Create brightmap texture table. Z_Realloc(texturebrightmaps, (newtextures + 1) * sizeof(*texturebrightmaps), PU_STATIC, &texturebrightmaps); - for (i = numtextures; i < newtextures; ++i) + for (i = 0; i < numtextures; ++i) + { + // R_FlushTextureCache relies on the user for + // Z_Free, texturecache has been reallocated so the + // user is now garbage memory. + Z_SetUser(texturecache[i], + (void**)&texturecache[i]); + } + + while (i < newtextures) { texturetranslation[i] = i; texturebrightmaps[i] = 0; + i++; } } From 884064049e8a3e9bd8a4329809ccb2a6b2ab78be Mon Sep 17 00:00:00 2001 From: toaster Date: Sat, 14 May 2022 14:56:02 +0100 Subject: [PATCH 10/13] * Allocate the "MISSING" patch only once, statically, at first boot via `missingpat`, and prevent it from being freed. * Rework HU_UpdatePatch to HU_UpdateOrBlankPatch with a "required" boolean. * If desired graphic is not present in resources: * If required is true, return `missingpat`. * If false, return NULL as before (font compatibility). * Add an alias with the previous function signature, so you don't need to add a million `true`s everywhere. * Remove a ton of irrelevant graphics the game attempts to cache only because of code inherited from vanilla SRB2. * Remove the unused hudinfo system, also inherited from vanilla SRB2. --- src/deh_lua.c | 10 --- src/deh_soc.c | 79 ----------------- src/deh_soc.h | 1 - src/dehacked.c | 12 --- src/font.c | 3 +- src/hu_stuff.c | 45 +++++----- src/hu_stuff.h | 15 +--- src/k_hud.c | 4 +- src/lua_baselib.c | 1 - src/lua_hudlib.c | 102 +-------------------- src/lua_libs.h | 1 - src/r_defs.h | 2 + src/r_patch.c | 11 ++- src/st_stuff.c | 219 +--------------------------------------------- src/st_stuff.h | 47 ---------- src/v_video.c | 4 +- src/w_wad.c | 4 +- 17 files changed, 43 insertions(+), 517 deletions(-) diff --git a/src/deh_lua.c b/src/deh_lua.c index 543998584..6e892d5e2 100644 --- a/src/deh_lua.c +++ b/src/deh_lua.c @@ -436,16 +436,6 @@ static inline int lib_getenum(lua_State *L) } return luaL_error(L, "karthud '%s' could not be found.\n", word); } - else if (fastncmp("HUD_",word,4)) { - p = word+4; - for (i = 0; i < NUMHUDITEMS; i++) - if (fastcmp(p, HUDITEMS_LIST[i])) { - lua_pushinteger(L, i); - return 1; - } - if (mathlib) return luaL_error(L, "huditem '%s' could not be found.\n", word); - return 0; - } else if (fastncmp("SKINCOLOR_",word,10)) { p = word+10; for (i = 0; i < NUMCOLORFREESLOTS; i++) { diff --git a/src/deh_soc.c b/src/deh_soc.c index e2dec10d7..aa55ca638 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -2407,66 +2407,6 @@ void readmenu(MYFILE *f, INT32 num) Z_Free(s); } -void readhuditem(MYFILE *f, INT32 num) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word = s; - char *word2; - char *tmp; - INT32 i; - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - // First remove trailing newline, if there is one - tmp = strchr(s, '\n'); - if (tmp) - *tmp = '\0'; - - tmp = strchr(s, '#'); - if (tmp) - *tmp = '\0'; - if (s == tmp) - continue; // Skip comment lines, but don't break. - - // Get the part before the " = " - tmp = strchr(s, '='); - if (tmp) - *(tmp-1) = '\0'; - else - break; - strupr(word); - - // Now get the part after - word2 = tmp += 2; - strupr(word2); - - i = atoi(word2); // used for numerical settings - - if (fastcmp(word, "X")) - { - hudinfo[num].x = i; - } - else if (fastcmp(word, "Y")) - { - hudinfo[num].y = i; - } - else if (fastcmp(word, "F")) - { - hudinfo[num].f = i; - } - else - deh_warning("Level header %d: unknown word '%s'", num, word); - } - } while (!myfeof(f)); // finish when the line is empty - - Z_Free(s); -} - void readframe(MYFILE *f, INT32 num) { char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); @@ -4204,20 +4144,6 @@ sfxenum_t get_sfx(const char *word) return sfx_None; } -hudnum_t get_huditem(const char *word) -{ // Returns the value of HUD_ enumerations - hudnum_t i; - if (*word >= '0' && *word <= '9') - return atoi(word); - if (fastncmp("HUD_",word,4)) - word += 4; // take off the HUD_ - for (i = 0; i < NUMHUDITEMS; i++) - if (fastcmp(word, HUDITEMS_LIST[i])) - return i; - deh_warning("Couldn't find huditem named 'HUD_%s'",word); - return HUD_LIVES; -} - menutype_t get_menutype(const char *word) { // Returns the value of MN_ enumerations menutype_t i; @@ -4461,11 +4387,6 @@ static fixed_t find_const(const char **rword) free(word); return 0; } - else if (fastncmp("HUD_",word,4)) { - r = get_huditem(word); - free(word); - return r; - } else if (fastncmp("GRADE_",word,6)) { char *p = word+6; diff --git a/src/deh_soc.h b/src/deh_soc.h index 0025eb1c4..e2319ab14 100644 --- a/src/deh_soc.h +++ b/src/deh_soc.h @@ -52,7 +52,6 @@ statenum_t get_state(const char *word); spritenum_t get_sprite(const char *word); playersprite_t get_sprite2(const char *word); sfxenum_t get_sfx(const char *word); -hudnum_t get_huditem(const char *word); menutype_t get_menutype(const char *word); //INT16 get_gametype(const char *word); //powertype_t get_power(const char *word); diff --git a/src/dehacked.c b/src/dehacked.c index f86047fed..5f0743a7e 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -495,18 +495,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile) ignorelines(f); } } - else if (fastcmp(word, "HUDITEM")) - { - if (i == 0 && word2[0] != '0') // If word2 isn't a number - i = get_huditem(word2); // find a huditem by name - if (i >= 0 && i < NUMHUDITEMS) - readhuditem(f, i); - else - { - deh_warning("HUD item number %d out of range (0 - %d)", i, NUMHUDITEMS-1); - ignorelines(f); - } - } else if (fastcmp(word, "MENU")) { if (i == 0 && word2[0] != '0') // If word2 isn't a number diff --git a/src/font.c b/src/font.c index 353f21a83..39f879ea0 100644 --- a/src/font.c +++ b/src/font.c @@ -27,7 +27,8 @@ FontCache (font_t *fnt) c = fnt->start; for (i = 0; i < fnt->size; ++i, ++c) { - HU_UpdatePatch(&fnt->font[i], + HU_UpdateOrBlankPatch(&fnt->font[i], + false, "%s%.*d", fnt->prefix, fnt->digits, diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 3287c3461..77deff138 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -87,24 +87,12 @@ static boolean headsupactive = false; boolean hu_showscores; // draw rankings static char hu_tick; -patch_t *rflagico; -patch_t *bflagico; -patch_t *rmatcico; -patch_t *bmatcico; -patch_t *tagico; -patch_t *tallminus; -patch_t *tallinfin; - -//------------------------------------------- -// coop hud -//------------------------------------------- - -static patch_t *emblemicon; - //------------------------------------------- // misc vars //------------------------------------------- +patch_t *missingpat; + // song credits static patch_t *songcreditbg; @@ -189,10 +177,6 @@ void HU_LoadGraphics(void) Font_Load(); - // minus for negative tallnums - HU_UpdatePatch(&tallminus, "STTMINUS"); - - HU_UpdatePatch(&emblemicon, "EMBLICON"); HU_UpdatePatch(&songcreditbg, "K_SONGCR"); // cache ping gfx: @@ -222,6 +206,16 @@ void HU_Init(void) RegisterNetXCmd(XD_SAY, Got_Saycmd); #endif + // only allocate if not present, to save us a lot of headache + if (missingpat == NULL) + { + lumpnum_t missingnum = W_GetNumForName("MISSING"); + if (missingnum == LUMPERROR) + I_Error("HU_LoadGraphics: \"MISSING\" patch not present in resource files."); + + missingpat = W_CachePatchNum(W_GetNumForName("MISSING"), PU_STATIC); + } + // set shift translation table shiftxform = english_shiftxform; @@ -292,7 +286,7 @@ void HU_Init(void) HU_LoadGraphics(); } -patch_t *HU_UpdatePatch(patch_t **user, const char *format, ...) +patch_t *HU_UpdateOrBlankPatch(patch_t **user, boolean required, const char *format, ...) { va_list ap; char buffer[9]; @@ -319,7 +313,12 @@ patch_t *HU_UpdatePatch(patch_t **user, const char *format, ...) lump = W_CheckNumForName(buffer); if (lump == LUMPERROR) - return NULL; + { + if (required == true) + *user = missingpat; + + return *user; + } } patch = W_CachePatchNum(lump, PU_HUDGFX); @@ -2151,10 +2150,10 @@ void HU_Drawer(void) if (modeattacking && pausedelay > 0 && !pausebreakkey) { INT32 strength = ((pausedelay - 1 - NEWTICRATE/2)*10)/(NEWTICRATE/3); - INT32 y = hudinfo[HUD_LIVES].y - 13; + INT32 x = BASEVIDWIDTH/2, y = BASEVIDHEIGHT/2; // obviously incorrect values while we scrap hudinfo - V_DrawThinString(hudinfo[HUD_LIVES].x-2, y, - hudinfo[HUD_LIVES].f|((leveltime & 4) ? V_SKYMAP : V_BLUEMAP), + V_DrawThinString(x, y, + ((leveltime & 4) ? V_SKYMAP : V_BLUEMAP), "HOLD TO RETRY..."); if (strength > 9) diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 392ae27a2..d81dba2a6 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -104,14 +104,6 @@ extern patch_t *pinggfx[5]; extern patch_t *framecounter; extern patch_t *frameslash; -extern patch_t *rflagico; -extern patch_t *bflagico; -extern patch_t *rmatcico; -extern patch_t *bmatcico; -extern patch_t *tagico; -extern patch_t *tallminus; -extern patch_t *tallinfin; - // set true whenever the tab rankings are being shown for any reason extern boolean hu_showscores; @@ -120,9 +112,10 @@ void HU_Init(void); void HU_LoadGraphics(void); -// Load a HUDGFX patch or NULL. -patch_t *HU_UpdatePatch(patch_t **user, const char *format, ...); -#define HU_CachePatch(...) HU_UpdatePatch(NULL, __VA_ARGS__) +// Load a HUDGFX patch or NULL/missingpat (dependent on required boolean). +patch_t *HU_UpdateOrBlankPatch(patch_t **user, boolean required, const char *format, ...); +//#define HU_CachePatch(...) HU_UpdateOrBlankPatch(NULL, false, __VA_ARGS__) -- not sure how to default the missingpat here plus not currently used +#define HU_UpdatePatch(user, ...) HU_UpdateOrBlankPatch(user, true, __VA_ARGS__) // reset heads up when consoleplayer respawns. void HU_Start(void); diff --git a/src/k_hud.c b/src/k_hud.c index 8a688d1dc..b7bf9c38d 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -623,14 +623,14 @@ void K_LoadKartHUDGraphics(void) for (i = 0; i < 8; i++) { buffer[7] = '0'+((i+1)%10); - HU_UpdatePatch(&kp_bossbar[i], buffer); + HU_UpdatePatch(&kp_bossbar[i], "%s", buffer); } sprintf(buffer, "K_BOSR0x"); for (i = 0; i < 4; i++) { buffer[7] = '0'+((i+1)%10); - HU_UpdatePatch(&kp_bossret[i], buffer); + HU_UpdatePatch(&kp_bossret[i], "%s", buffer); } } diff --git a/src/lua_baselib.c b/src/lua_baselib.c index decf683f4..85ff45a4c 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -214,7 +214,6 @@ static const struct { {META_BBOX, "bbox"}, - {META_HUDINFO, "hudinfo_t"}, {META_PATCH, "patch_t"}, {META_COLORMAP, "colormap"}, {META_CAMERA, "camera_t"}, diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 75a84ed18..b5e3d1acc 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -14,7 +14,7 @@ #include "fastcmp.h" #include "r_defs.h" #include "r_local.h" -#include "st_stuff.h" // hudinfo[] +#include "st_stuff.h" #include "g_game.h" #include "i_video.h" // rendermode #include "p_local.h" // camera_t @@ -63,18 +63,6 @@ static const char *const hud_disable_options[] = { "intermissionmessages", NULL}; -enum hudinfo { - hudinfo_x = 0, - hudinfo_y, - hudinfo_f -}; - -static const char *const hudinfo_opt[] = { - "x", - "y", - "f", - NULL}; - enum patch { patch_valid = 0, patch_width, @@ -182,73 +170,6 @@ static const char *const camera_opt[] = { "pnum", NULL}; -static int lib_getHudInfo(lua_State *L) -{ - UINT32 i; - lua_remove(L, 1); - - i = luaL_checkinteger(L, 1); - if (i >= NUMHUDITEMS) - return luaL_error(L, "hudinfo[] index %d out of range (0 - %d)", i, NUMHUDITEMS-1); - LUA_PushUserdata(L, &hudinfo[i], META_HUDINFO); - return 1; -} - -static int lib_hudinfolen(lua_State *L) -{ - lua_pushinteger(L, NUMHUDITEMS); - return 1; -} - -static int hudinfo_get(lua_State *L) -{ - hudinfo_t *info = *((hudinfo_t **)luaL_checkudata(L, 1, META_HUDINFO)); - enum hudinfo field = luaL_checkoption(L, 2, hudinfo_opt[0], hudinfo_opt); - I_Assert(info != NULL); // huditems are always valid - - switch(field) - { - case hudinfo_x: - lua_pushinteger(L, info->x); - break; - case hudinfo_y: - lua_pushinteger(L, info->y); - break; - case hudinfo_f: - lua_pushinteger(L, info->f); - break; - } - return 1; -} - -static int hudinfo_set(lua_State *L) -{ - hudinfo_t *info = *((hudinfo_t **)luaL_checkudata(L, 1, META_HUDINFO)); - enum hudinfo field = luaL_checkoption(L, 2, hudinfo_opt[0], hudinfo_opt); - I_Assert(info != NULL); - - switch(field) - { - case hudinfo_x: - info->x = (INT32)luaL_checkinteger(L, 3); - break; - case hudinfo_y: - info->y = (INT32)luaL_checkinteger(L, 3); - break; - case hudinfo_f: - info->f = (INT32)luaL_checkinteger(L, 3); - break; - } - return 0; -} - -static int hudinfo_num(lua_State *L) -{ - hudinfo_t *info = *((hudinfo_t **)luaL_checkudata(L, 1, META_HUDINFO)); - lua_pushinteger(L, info-hudinfo); - return 1; -} - static int colormap_get(lua_State *L) { const UINT8 *colormap = *((UINT8 **)luaL_checkudata(L, 1, META_COLORMAP)); @@ -1307,27 +1228,6 @@ int LUA_HudLib(lua_State *L) lua_rawseti(L, -2, 6); // HUD[6] = title card rendering functions array lua_setfield(L, LUA_REGISTRYINDEX, "HUD"); - luaL_newmetatable(L, META_HUDINFO); - lua_pushcfunction(L, hudinfo_get); - lua_setfield(L, -2, "__index"); - - lua_pushcfunction(L, hudinfo_set); - lua_setfield(L, -2, "__newindex"); - - lua_pushcfunction(L, hudinfo_num); - lua_setfield(L, -2, "__len"); - lua_pop(L,1); - - lua_newuserdata(L, 0); - lua_createtable(L, 0, 2); - lua_pushcfunction(L, lib_getHudInfo); - lua_setfield(L, -2, "__index"); - - lua_pushcfunction(L, lib_hudinfolen); - lua_setfield(L, -2, "__len"); - lua_setmetatable(L, -2); - lua_setglobal(L, "hudinfo"); - luaL_newmetatable(L, META_COLORMAP); lua_pushcfunction(L, colormap_get); lua_setfield(L, -2, "__index"); diff --git a/src/lua_libs.h b/src/lua_libs.h index c02964467..a6580622b 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -81,7 +81,6 @@ extern lua_State *gL; #define META_BBOX "BOUNDING_BOX" -#define META_HUDINFO "HUDINFO_T*" #define META_PATCH "PATCH_T*" #define META_COLORMAP "COLORMAP" #define META_CAMERA "CAMERA_T*" diff --git a/src/r_defs.h b/src/r_defs.h index a466c856c..93353a775 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -691,6 +691,8 @@ typedef struct #endif } patch_t; +extern patch_t *missingpat; + #if defined(_MSC_VER) #pragma pack(1) #endif diff --git a/src/r_patch.c b/src/r_patch.c index 1a08d1892..544c15ae8 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -76,8 +76,7 @@ static void Patch_FreeData(patch_t *patch) for (i = 0; i < 4; i++) { - if (patch->flats[i]) - Z_Free(patch->flats[i]); + Z_Free(patch->flats[i]); } #ifdef ROTSPRITE @@ -96,14 +95,14 @@ static void Patch_FreeData(patch_t *patch) } #endif - if (patch->columnofs) - Z_Free(patch->columnofs); - if (patch->columns) - Z_Free(patch->columns); + Z_Free(patch->columnofs); + Z_Free(patch->columns); } void Patch_Free(patch_t *patch) { + if (patch == missingpat) + return; Patch_FreeData(patch); Z_Free(patch); } diff --git a/src/st_stuff.c b/src/st_stuff.c index 5efcdc6f5..2c2bcec12 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -63,77 +63,6 @@ patch_t *faceprefix[MAXSKINS][NUMFACES]; // status bar overlay // ------------------------------------------ -// icons for overlay -patch_t *sboscore; // Score logo -patch_t *sbotime; // Time logo -patch_t *sbocolon; // Colon for time -patch_t *sboperiod; // Period for time centiseconds -patch_t *livesback; // Lives icon background -patch_t *stlivex; -static patch_t *nrec_timer; // Timer for NiGHTS records -static patch_t *sborings; -static patch_t *slidgame; -static patch_t *slidtime; -static patch_t *slidover; -static patch_t *sboredrings; -static patch_t *sboredtime; -static patch_t *getall; // Special Stage HUD -static patch_t *timeup; // Special Stage HUD -static patch_t *hunthoming[6]; -static patch_t *itemhoming[6]; -static patch_t *race1; -static patch_t *race2; -static patch_t *race3; -static patch_t *racego; -static patch_t *nightslink; -static patch_t *curweapon; -static patch_t *normring; -static patch_t *bouncering; -static patch_t *infinityring; -static patch_t *autoring; -static patch_t *explosionring; -static patch_t *scatterring; -static patch_t *grenadering; -static patch_t *railring; -static patch_t *jumpshield; -static patch_t *forceshield; -static patch_t *ringshield; -static patch_t *watershield; -static patch_t *bombshield; -static patch_t *pityshield; -static patch_t *pinkshield; -static patch_t *flameshield; -static patch_t *bubbleshield; -static patch_t *thundershield; -static patch_t *invincibility; -static patch_t *sneakers; -static patch_t *gravboots; -static patch_t *nonicon; -static patch_t *nonicon2; -static patch_t *bluestat; -static patch_t *byelstat; -static patch_t *orngstat; -static patch_t *redstat; -static patch_t *yelstat; -static patch_t *nbracket; -static patch_t *nring; -static patch_t *nhud[12]; -static patch_t *nsshud; -static patch_t *nbon[12]; -static patch_t *nssbon; -static patch_t *narrow[9]; -static patch_t *nredar[8]; // Red arrow -static patch_t *drillbar; -static patch_t *drillfill[3]; -static patch_t *capsulebar; -static patch_t *capsulefill; -patch_t *ngradeletters[7]; -static patch_t *minus5sec; -static patch_t *minicaps; -static patch_t *gotrflag; -static patch_t *gotbflag; -static patch_t *fnshico; - // Midnight Channel: static patch_t *hud_tv1; static patch_t *hud_tv2; @@ -143,38 +72,6 @@ static patch_t *hud_tv2; static patch_t *envelope; #endif -// SRB2kart - -hudinfo_t hudinfo[NUMHUDITEMS] = -{ - { 16, 176, V_SNAPTOLEFT|V_SNAPTOBOTTOM}, // HUD_LIVES - - { 16, 42, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_RINGS - { 96, 42, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_RINGSNUM - { 120, 42, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_RINGSNUMTICS - - { 16, 10, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_SCORE - { 120, 10, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_SCORENUM - - { 16, 26, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_TIME - { 72, 26, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_MINUTES - { 72, 26, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_TIMECOLON - { 96, 26, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_SECONDS - { 96, 26, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_TIMETICCOLON - { 120, 26, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_TICS - - { 0, 56, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_SS_TOTALRINGS - - { 110, 93, 0}, // HUD_GETRINGS - { 160, 93, 0}, // HUD_GETRINGSNUM - { 124, 160, 0}, // HUD_TIMELEFT - { 168, 176, 0}, // HUD_TIMELEFTNUM - { 130, 93, 0}, // HUD_TIMEUP - { 152, 168, 0}, // HUD_HUNTPICS - - { 288, 176, V_SNAPTORIGHT|V_SNAPTOBOTTOM}, // HUD_POWERUPS -}; - // // STATUS BAR CODE // @@ -249,8 +146,6 @@ void ST_UnloadGraphics(void) void ST_LoadGraphics(void) { - int i; - // SRB2 border patch // st_borderpatchnum = W_GetNumForName("GFZFLR01"); // scr_borderpatch = W_CacheLumpNum(st_borderpatchnum, PU_HUDGFX); @@ -260,107 +155,6 @@ void ST_LoadGraphics(void) // but load them in R_AddSkins, that gets called // first anyway // cache the status bar overlay icons (fullscreen mode) - - // Prefix "STT" is whitelisted (doesn't trigger ISGAMEMODIFIED), btw - HU_UpdatePatch(&sborings, "STTRINGS"); - HU_UpdatePatch(&sboredrings, "STTRRING"); - HU_UpdatePatch(&sboscore, "STTSCORE"); - HU_UpdatePatch(&sbotime, "STTTIME"); // Time logo - HU_UpdatePatch(&sboredtime, "STTRTIME"); - HU_UpdatePatch(&sbocolon, "STTCOLON"); // Colon for time - HU_UpdatePatch(&sboperiod, "STTPERIO"); // Period for time centiseconds - - HU_UpdatePatch(&slidgame, "SLIDGAME"); - HU_UpdatePatch(&slidtime, "SLIDTIME"); - HU_UpdatePatch(&slidover, "SLIDOVER"); - - HU_UpdatePatch(&stlivex, "STLIVEX"); - HU_UpdatePatch(&livesback, "STLIVEBK"); - HU_UpdatePatch(&nrec_timer, "NGRTIMER"); // Timer for NiGHTS - HU_UpdatePatch(&getall, "GETALL"); // Special Stage HUD - HU_UpdatePatch(&timeup, "TIMEUP"); // Special Stage HUD - HU_UpdatePatch(&race1, "RACE1"); - HU_UpdatePatch(&race2, "RACE2"); - HU_UpdatePatch(&race3, "RACE3"); - HU_UpdatePatch(&racego, "RACEGO"); - HU_UpdatePatch(&nightslink, "NGHTLINK"); - - for (i = 0; i < 6; ++i) - { - HU_UpdatePatch(&hunthoming[i], "HOMING%d", i+1); - HU_UpdatePatch(&itemhoming[i], "HOMITM%d", i+1); - } - - HU_UpdatePatch(&curweapon, "CURWEAP"); - HU_UpdatePatch(&normring, "RINGIND"); - HU_UpdatePatch(&bouncering, "BNCEIND"); - HU_UpdatePatch(&infinityring, "INFNIND"); - HU_UpdatePatch(&autoring, "AUTOIND"); - HU_UpdatePatch(&explosionring, "BOMBIND"); - HU_UpdatePatch(&scatterring, "SCATIND"); - HU_UpdatePatch(&grenadering, "GRENIND"); - HU_UpdatePatch(&railring, "RAILIND"); - HU_UpdatePatch(&jumpshield, "TVWWICON"); - HU_UpdatePatch(&forceshield, "TVFOICON"); - HU_UpdatePatch(&ringshield, "TVATICON"); - HU_UpdatePatch(&watershield, "TVELICON"); - HU_UpdatePatch(&bombshield, "TVARICON"); - HU_UpdatePatch(&pityshield, "TVPIICON"); - HU_UpdatePatch(&pinkshield, "TVPPICON"); - HU_UpdatePatch(&flameshield, "TVFLICON"); - HU_UpdatePatch(&bubbleshield, "TVBBICON"); - HU_UpdatePatch(&thundershield, "TVZPICON"); - HU_UpdatePatch(&invincibility, "TVIVICON"); - HU_UpdatePatch(&sneakers, "TVSSICON"); - HU_UpdatePatch(&gravboots, "TVGVICON"); - - HU_UpdatePatch(&tagico, "TAGICO"); - HU_UpdatePatch(&rflagico, "RFLAGICO"); - HU_UpdatePatch(&bflagico, "BFLAGICO"); - HU_UpdatePatch(&rmatcico, "RMATCICO"); - HU_UpdatePatch(&bmatcico, "BMATCICO"); - HU_UpdatePatch(&gotrflag, "GOTRFLAG"); - HU_UpdatePatch(&gotbflag, "GOTBFLAG"); - HU_UpdatePatch(&fnshico, "FNSHICO"); - HU_UpdatePatch(&nonicon, "NONICON"); - HU_UpdatePatch(&nonicon2, "NONICON2"); - - // NiGHTS HUD things - HU_UpdatePatch(&bluestat, "BLUESTAT"); - HU_UpdatePatch(&byelstat, "BYELSTAT"); - HU_UpdatePatch(&orngstat, "ORNGSTAT"); - HU_UpdatePatch(&redstat, "REDSTAT"); - HU_UpdatePatch(&yelstat, "YELSTAT"); - HU_UpdatePatch(&nbracket, "NBRACKET"); - HU_UpdatePatch(&nring, "NRNG1"); - for (i = 0; i < 12; ++i) - { - HU_UpdatePatch(&nhud[i], "NHUD%d", i+1); - HU_UpdatePatch(&nbon[i], "NBON%d", i+1); - } - HU_UpdatePatch(&nsshud, "NSSHUD"); - HU_UpdatePatch(&nssbon, "NSSBON"); - HU_UpdatePatch(&minicaps, "MINICAPS"); - - for (i = 0; i < 8; ++i) - { - HU_UpdatePatch(&narrow[i], "NARROW%d", i+1); - HU_UpdatePatch(&nredar[i], "NREDAR%d", i+1); - } - - // non-animated version - HU_UpdatePatch(&narrow[8], "NARROW9"); - - HU_UpdatePatch(&drillbar, "DRILLBAR"); - for (i = 0; i < 3; ++i) - HU_UpdatePatch(&drillfill[i], "DRILLFI%d", i+1); - HU_UpdatePatch(&capsulebar, "CAPSBAR"); - HU_UpdatePatch(&capsulefill, "CAPSFILL"); - HU_UpdatePatch(&minus5sec, "MINUS5"); - - for (i = 0; i < 7; ++i) - HU_UpdatePatch(&ngradeletters[i], "GRADE%d", i); - K_LoadKartHUDGraphics(); // Midnight Channel: @@ -547,17 +341,6 @@ static INT32 SCR(INT32 r) // ========================================================================= // INTERNAL DRAWING // ========================================================================= -#define ST_DrawTopLeftOverlayPatch(x,y,p) V_DrawScaledPatch(SCX(hudinfo[h+!!r_splitscreen].x), SCY(hudinfo[h+!!r_splitscreen].y), V_SNAPTOTOP|V_SNAPTOLEFT|V_HUDTRANS, p) -#define ST_DrawOverlayNum(x,y,n) V_DrawTallNum(x, y, V_NOSCALESTART|V_HUDTRANS, n) -#define ST_DrawPaddedOverlayNum(x,y,n,d) V_DrawPaddedTallNum(x, y, V_NOSCALESTART|V_HUDTRANS, n, d) -#define ST_DrawOverlayPatch(x,y,p) V_DrawScaledPatch(x, y, V_NOSCALESTART|V_HUDTRANS, p) -#define ST_DrawMappedOverlayPatch(x,y,p,c) V_DrawMappedScaledPatch(x, y, V_NOSCALESTART|V_HUDTRANS, p, c) -#define ST_DrawNumFromHud(h,n) V_DrawTallNum(SCX(hudinfo[h].x), SCY(hudinfo[h].y), V_NOSCALESTART|V_HUDTRANS, n) -#define ST_DrawPadNumFromHud(h,n,q) V_DrawPaddedTallNum(SCX(hudinfo[h].x), SCY(hudinfo[h].y), V_NOSCALESTART|V_HUDTRANS, n, q) -#define ST_DrawPatchFromHud(h,p) V_DrawScaledPatch(SCX(hudinfo[h].x), SCY(hudinfo[h].y), V_NOSCALESTART|V_HUDTRANS, p) -#define ST_DrawNumFromHudWS(h,n) V_DrawTallNum(SCX(hudinfo[h+!!r_splitscreen].x), SCY(hudinfo[h+!!r_splitscreen].y), V_NOSCALESTART|V_HUDTRANS, n) -#define ST_DrawPadNumFromHudWS(h,n,q) V_DrawPaddedTallNum(SCX(hudinfo[h+!!r_splitscreen].x), SCY(hudinfo[h+!!r_splitscreen].y), V_NOSCALESTART|V_HUDTRANS, n, q) -#define ST_DrawPatchFromHudWS(h,p) V_DrawScaledPatch(SCX(hudinfo[h+!!r_splitscreen].x), SCY(hudinfo[h+!!r_splitscreen].y), V_NOSCALESTART|V_HUDTRANS, p) // Devmode information static void ST_drawDebugInfo(void) @@ -807,7 +590,7 @@ void ST_runTitleCard(void) char c = toupper(bossinfo.enemyname[bossinfo.titleshow]); bossinfo.titleshow++; c -= LT_FONTSTART; - if (c < 0 || c >= LT_FONTSIZE || !tc_font[1][(INT32)c] || !bossinfo.titlesound) + if (c < 0 || c >= LT_FONTSIZE || !fontv[GTFN_FONT].font[(INT32)c] || !bossinfo.titlesound) { ; } diff --git a/src/st_stuff.h b/src/st_stuff.h index a17f72c1f..e24343551 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -81,54 +81,7 @@ extern UINT32 st_translucency; extern lumpnum_t st_borderpatchnum; // patches, also used in intermission -extern patch_t *sboscore; -extern patch_t *sbotime; -extern patch_t *sbocolon; -extern patch_t *sboperiod; extern patch_t *faceprefix[MAXSKINS][NUMFACES]; -extern patch_t *livesback; -extern patch_t *stlivex; -extern patch_t *ngradeletters[7]; - -/** HUD location information (don't move this comment) - */ -typedef struct -{ - INT32 x, y, f; -} hudinfo_t; - -typedef enum -{ - HUD_LIVES, - - HUD_RINGS, - HUD_RINGSNUM, - HUD_RINGSNUMTICS, - - HUD_SCORE, - HUD_SCORENUM, - - HUD_TIME, - HUD_MINUTES, - HUD_TIMECOLON, - HUD_SECONDS, - HUD_TIMETICCOLON, - HUD_TICS, - - HUD_SS_TOTALRINGS, - - HUD_GETRINGS, - HUD_GETRINGSNUM, - HUD_TIMELEFT, - HUD_TIMELEFTNUM, - HUD_TIMEUP, - HUD_HUNTPICS, - HUD_POWERUPS, - - NUMHUDITEMS -} hudnum_t; - -extern hudinfo_t hudinfo[NUMHUDITEMS]; extern UINT16 objectsdrawn; diff --git a/src/v_video.c b/src/v_video.c index 2f806fb03..7e01f3393 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2310,8 +2310,8 @@ void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num) } while (num); // draw a minus sign if necessary - if (neg) - V_DrawScaledPatch(x - w, y, flags, tallminus); // Tails + //if (neg) + //V_DrawScaledPatch(x - w, y, flags, tallminus); // Tails } // Draws a number with a set number of digits. diff --git a/src/w_wad.c b/src/w_wad.c index e1cb6b1aa..879c75063 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1796,7 +1796,7 @@ void *W_CachePatchName(const char *name, INT32 tag) num = W_CheckNumForName(name); if (num == LUMPERROR) - return W_CachePatchNum(W_GetNumForName("MISSING"), tag); + return missingpat; return W_CachePatchNum(num, tag); } @@ -1807,7 +1807,7 @@ void *W_CachePatchLongName(const char *name, INT32 tag) num = W_CheckNumForLongName(name); if (num == LUMPERROR) - return W_CachePatchNum(W_GetNumForLongName("MISSING"), tag); + return missingpat; return W_CachePatchNum(num, tag); } From 8593074d19353439acd729cf02a5ed2400e7f457 Mon Sep 17 00:00:00 2001 From: toaster Date: Sat, 14 May 2022 15:43:50 +0100 Subject: [PATCH 11/13] ANIMDEFS now only reports the "flats are disabled" warning for ANIMDEFs in the most recently loaded file. Notably, this means there are no warnings produced if an added file contains no errors, reducing even MORE of the friction the addons menu has been experiencing in devbuilds lately. --- src/p_spec.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 3fe162bb6..cc1a0f8a9 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -164,6 +164,9 @@ void P_ParseAnimationDefintion(SINT8 istexture); * \sa P_FindAnimatedFlat, P_SetupLevelFlatAnims * \author Steven McGranahan (original), Shadow Hog (had to rewrite it to handle multiple WADs), JTE (had to rewrite it to handle multiple WADs _correctly_) */ + +static boolean animdeftempflats = false; // only until ANIMDEFS flats are removed + void P_InitPicAnims(void) { // Init animation @@ -183,6 +186,7 @@ void P_InitPicAnims(void) while (animdefsLumpNum != INT16_MAX) { + animdeftempflats = ((p_adding_file == INT16_MAX) || p_adding_file == w); P_ParseANIMDEFSLump(w, animdefsLumpNum); animdefsLumpNum = W_CheckNumForNamePwad("ANIMDEFS", (UINT16)w, animdefsLumpNum + 1); } @@ -204,7 +208,7 @@ void P_InitPicAnims(void) lastanim = anims; for (i = 0; animdefs[i].istexture != -1; i++) { - if (animdefs[i].istexture) + if (animdefs[i].istexture == 1) { if (R_CheckTextureNumForName(animdefs[i].startname) == -1) continue; @@ -214,11 +218,13 @@ void P_InitPicAnims(void) } else { - CONS_Alert(CONS_WARNING, "ANIMDEFS flats are disabled; flat support in general will be removed soon! (%s, %s)\n", animdefs[i].startname, animdefs[i].endname); + if (animdefs[i].istexture == 2) + { + CONS_Alert(CONS_WARNING, "ANIMDEFS flats are disabled; flat support in general will be removed soon! (%s, %s)\n", animdefs[i].startname, animdefs[i].endname); + } continue; } #if 0 - else { if ((W_CheckNumForName(animdefs[i].startname)) == LUMPERROR) continue; @@ -374,7 +380,10 @@ void P_ParseAnimationDefintion(SINT8 istexture) Z_Free(animdefsToken); // set texture type - animdefs[i].istexture = istexture; + if (istexture) + animdefs[i].istexture = 1; + else + animdefs[i].istexture = (animdeftempflats ? 2 : 0); // "RANGE" animdefsToken = M_GetToken(NULL); From 80c14cd6ac569ca9a8c49cf6e6d0adce13698d64 Mon Sep 17 00:00:00 2001 From: toaster Date: Sat, 14 May 2022 19:18:57 +0100 Subject: [PATCH 12/13] use missingnum instead of re-calling W_GetNumForName --- src/hu_stuff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 77deff138..c859df55f 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -213,7 +213,7 @@ void HU_Init(void) if (missingnum == LUMPERROR) I_Error("HU_LoadGraphics: \"MISSING\" patch not present in resource files."); - missingpat = W_CachePatchNum(W_GetNumForName("MISSING"), PU_STATIC); + missingpat = W_CachePatchNum(missingnum, PU_STATIC); } // set shift translation table From a044ea76f7154ed9748b1a17ae90d6b0daa262f1 Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 16 May 2022 21:47:20 +0100 Subject: [PATCH 13/13] I made skin loading 2/15ths faster on my machine by inverting this jump conditional --- src/r_things.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index 9441804b1..3108a82fc 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -261,7 +261,9 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 for (l = startlump; l < endlump; l++) { - if (memcmp(lumpinfo[l].name,sprname,4)==0) + if (memcmp(lumpinfo[l].name,sprname,4)) + continue; + { INT32 width, height; INT16 topoffset, leftoffset;