From 2ff383a248f16a557d5dd31df8035da2ca29e5f2 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Wed, 25 Jun 2025 22:13:32 +0200 Subject: [PATCH] Replace shortname functions with stubs, and some trivial caller replacements --- src/console.c | 9 ++-- src/d_main.cpp | 8 +-- src/f_finale.c | 26 ++++----- src/hardware/hw_light.c | 2 +- src/hardware/hw_main.c | 4 +- src/hu_stuff.c | 2 +- src/k_hud.c | 8 +-- src/m_menu.c | 116 ++++++++++++++++++++-------------------- src/r_data.c | 9 ++-- src/r_draw.cpp | 38 ++++++------- src/sdl/endtxt.c | 2 +- src/sdl/i_system.cpp | 2 +- src/st_stuff.c | 2 +- src/v_video.c | 2 +- src/w_wad.c | 71 ------------------------ src/w_wad.h | 19 +++++-- src/y_inter.c | 24 ++++----- 17 files changed, 142 insertions(+), 202 deletions(-) diff --git a/src/console.c b/src/console.c index ced99246e..855386b5c 100644 --- a/src/console.c +++ b/src/console.c @@ -299,7 +299,8 @@ void CON_SetupBackColormapEx(INT32 color, boolean prompt) { UINT16 i, palsum; UINT8 j, palindex; - UINT8 *pal = W_CacheLumpName(GetPalette(), PU_CACHE); + lumpnum_t lump = W_GetNumForName(GetPalette()); + UINT8 *pal = W_CacheLumpNum(lump, PU_CACHE); INT32 shift = 6; if (color == INT32_MAX) @@ -1758,12 +1759,12 @@ static void CON_DrawBackpic(void) // Get the lumpnum for CONSBACK, STARTUP (Only during game startup) or fallback into MISSING. if (con_startup) - piclump = W_CheckNumForName("STARTUP"); + piclump = W_CheckNumForLongName("STARTUP"); else - piclump = W_CheckNumForName("KARTKREW"); + piclump = W_CheckNumForLongName("KARTKREW"); if (piclump == LUMPERROR) - piclump = W_GetNumForName("MISSING"); + piclump = W_GetNumForLongName("MISSING"); // Cache the patch. con_backpic = W_CachePatchNum(piclump, PU_PATCH); diff --git a/src/d_main.cpp b/src/d_main.cpp index 467378456..ea834c848 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -295,7 +295,7 @@ static void D_RenderLevel(void) if (r_splitscreen == 2) // Draw over the fourth screen so you don't have to stare at a HOM :V { // V_DrawPatchFill, but for the fourth screen only - patch_t *pat = static_cast(W_CachePatchName("SRB2BACK", PU_CACHE)); + patch_t *pat = static_cast(W_CachePatchLongName("SRB2BACK", PU_CACHE)); INT32 dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); INT32 x, y, pw = SHORT(pat->width) * dupz, ph = SHORT(pat->height) * dupz; @@ -632,7 +632,7 @@ static bool D_Display(void) py = 4; else py = viewwindowy + 4; - patch = static_cast(W_CachePatchName("M_PAUSE", PU_PATCH)); + patch = static_cast(W_CachePatchLongName("M_PAUSE", PU_PATCH)); V_DrawScaledPatch(viewwindowx + (BASEVIDWIDTH - patch->width)/2, py, 0, patch); } @@ -786,9 +786,9 @@ void D_SRB2Loop(void) /* Smells like a hack... Don't fade Sonic's ass into the title screen. */ if (gamestate != GS_TITLESCREEN) { - static lumpnum_t gstartuplumpnum = W_CheckNumForName("STARTUP"); + static lumpnum_t gstartuplumpnum = W_CheckNumForLongName("STARTUP"); if (gstartuplumpnum == LUMPERROR) - gstartuplumpnum = W_GetNumForName("MISSING"); + gstartuplumpnum = W_GetNumForLongName("MISSING"); V_DrawScaledPatch(0, 0, 0, W_CachePatchNum(gstartuplumpnum, PU_PATCH)); } #endif diff --git a/src/f_finale.c b/src/f_finale.c index 77ca2fb0c..26de402ad 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -232,8 +232,8 @@ static void F_TitleBGScroll(INT32 scrollspeed) patch_t *pat, *pat2; INT32 anim2 = 0; - pat = W_CachePatchName("TITLEBG1", PU_CACHE); - pat2 = W_CachePatchName("TITLEBG2", PU_CACHE); + pat = W_CachePatchLongName("TITLEBG1", PU_CACHE); + pat2 = W_CachePatchLongName("TITLEBG2", PU_CACHE); w = (vid.width / vid.dupx)<downloaded = false; - coronalumpnum = W_CheckNumForName("CORONA"); + coronalumpnum = W_CheckNumForLongName("CORONA"); } // -----------------+ diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 2b9c19d6c..dbc08f032 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3181,7 +3181,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) if (!shadowpatch || !shadowpatch->hardware) { CONS_Debug(DBG_RENDER, "remaking shadowsprite\n"); - shadowpatch = (patch_t *)W_CachePatchName("DSHADOW", PU_SPRITE); + shadowpatch = (patch_t *)W_CachePatchLongName("DSHADOW", PU_SPRITE); } gpatch = shadowpatch; @@ -5986,7 +5986,7 @@ void HWR_RenderPlayerView(void) if (r_splitscreen == 2 && player == &players[displayplayers[2]]) // No black void please. { // V_DrawPatchFill, but for the fourth screen only - patch_t *gpatch = W_CachePatchName("SRB2BACK", PU_CACHE); + patch_t *gpatch = W_CachePatchLongName("SRB2BACK", PU_CACHE); INT32 dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); INT32 x, y, pw = SHORT(gpatch->width) * dupz, ph = SHORT(gpatch->height) * dupz; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index fc71e8450..b33ce0ae0 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -228,7 +228,7 @@ void HU_Init(void) // only allocate if not present, to save us a lot of headache if (missingpat == NULL) { - lumpnum_t missingnum = W_GetNumForName("MISSING"); + lumpnum_t missingnum = W_GetNumForLongName("MISSING"); if (missingnum == LUMPERROR) I_Error("HU_LoadGraphics: \"MISSING\" patch not present in resource files."); diff --git a/src/k_hud.c b/src/k_hud.c index 13e51fde8..2c348309d 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -1577,7 +1577,7 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI V_DrawRightAlignedString(workx, worky, splitflags|V_6WIDTHSPACE, targettext); workx -= 67; - V_DrawSmallScaledPatch(workx + 4, worky, splitflags, W_CachePatchName("NEEDIT", PU_CACHE)); + V_DrawSmallScaledPatch(workx + 4, worky, splitflags, W_CachePatchLongName("NEEDIT", PU_CACHE)); break; @@ -2605,7 +2605,7 @@ static void K_drawKartBumpersOrKarma(void) { if (itembreaker) { - patch_t *item = W_CachePatchName("RNDMA0", PU_PATCH); + patch_t *item = W_CachePatchLongName("RNDMA0", PU_PATCH); UINT8 *itemcolormap = R_GetTranslationColormap(TC_BLINK, SKINCOLOR_BLACK, GTC_CACHE); if (!K_UseColorHud()) @@ -4929,8 +4929,8 @@ void K_drawKartHUD(void) snapflags = 0; } - V_DrawTinyScaledPatch(x-54, y, snapflags|V_SLIDEIN, W_CachePatchName("TTKBANNR", PU_CACHE)); - V_DrawTinyScaledPatch(x-54, y+25, snapflags|V_SLIDEIN, W_CachePatchName("TTKART", PU_CACHE)); + V_DrawTinyScaledPatch(x-54, y, snapflags|V_SLIDEIN, W_CachePatchLongName("TTKBANNR", PU_CACHE)); + V_DrawTinyScaledPatch(x-54, y+25, snapflags|V_SLIDEIN, W_CachePatchLongName("TTKART", PU_CACHE)); } else { diff --git a/src/m_menu.c b/src/m_menu.c index abefb937a..6f43bf1ad 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2208,7 +2208,7 @@ static void M_DrawMapEmblems(INT32 mapnum, INT32 x, INT32 y) V_DrawSmallMappedPatch(x, y, 0, W_CachePatchName(M_GetEmblemPatch(emblem, false), PU_CACHE), R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_MENUCACHE)); else - V_DrawSmallScaledPatch(x, y, 0, W_CachePatchName("NEEDIT", PU_CACHE)); + V_DrawSmallScaledPatch(x, y, 0, W_CachePatchLongName("NEEDIT", PU_CACHE)); emblem = M_GetLevelEmblems(-1); x -= 8; @@ -2252,7 +2252,7 @@ static void M_DrawMenuTitle(void) static void M_DrawSliderCursor(INT16 x, INT16 y, INT32 vflags, consvar_t *cv, INT32 value) { fixed_t range = FixedDiv(value - cv->PossibleValue[0].value, cv->PossibleValue[1].value - cv->PossibleValue[0].value); - V_DrawFixedPatch((x - 4)*FRACUNIT + (SLIDER_RANGE+4)*range, y*FRACUNIT, FRACUNIT, vflags, W_CachePatchName("M_SLIDEC", PU_CACHE), NULL); + V_DrawFixedPatch((x - 4)*FRACUNIT + (SLIDER_RANGE+4)*range, y*FRACUNIT, FRACUNIT, vflags, W_CachePatchLongName("M_SLIDEC", PU_CACHE), NULL); } static void M_DrawRightString(menuitem_t *item, INT16 x, INT16 y, INT32 vflags, boolean selected) @@ -2297,14 +2297,14 @@ static void M_DrawRightString(menuitem_t *item, INT16 x, INT16 y, INT32 vflags, if (atoi(cv->defaultvalue) != cv->value) M_DrawSliderCursor(x, y, vflags, cv, atoi(cv->defaultvalue)); - p = W_CachePatchName("M_SLIDEL", PU_CACHE); + p = W_CachePatchLongName("M_SLIDEL", PU_CACHE); V_DrawScaledPatch(x - 8, y, vflags, p); - p = W_CachePatchName("M_SLIDEM", PU_CACHE); + p = W_CachePatchLongName("M_SLIDEM", PU_CACHE); for (i = 0; i < SLIDER_RANGE; i += 8) V_DrawScaledPatch (x + i, y, vflags, p); - p = W_CachePatchName("M_SLIDER", PU_CACHE); + p = W_CachePatchLongName("M_SLIDER", PU_CACHE); V_DrawScaledPatch(x + i, y, vflags, p); M_DrawSliderCursor(x, y, vflags, cv, cv->value); @@ -2414,7 +2414,7 @@ static void M_DrawRightString(menuitem_t *item, INT16 x, INT16 y, INT32 vflags, vflags &= ~(V_FLIP|V_PARAMMASK); const tic_t freq = TICRATE/2; if ((leveltime % freq) >= freq/2) - V_DrawScaledPatch(204, y - 1, vflags, W_CachePatchName("K_REQUE2", PU_CACHE)); + V_DrawScaledPatch(204, y - 1, vflags, W_CachePatchLongName("K_REQUE2", PU_CACHE)); } else if (item->patch) V_DrawRightAlignedString(BASEVIDWIDTH - x, y, (selected || (item->status & ITH_MASK) == ITH_HIGHLIGHT ? highlightflags : 0)|vflags, item->patch); @@ -2671,7 +2671,7 @@ void MD_DrawGenericMenu(void) // DRAW THE SKULL CURSOR if (M_ItemSelectable(¤tMenu->menuitems[itemOn])) - V_DrawScaledPatch(cursorx, cursory, 0, W_CachePatchName("M_CURSOR", PU_CACHE)); + V_DrawScaledPatch(cursorx, cursory, 0, W_CachePatchLongName("M_CURSOR", PU_CACHE)); x = currentMenu->x - 20 + currentMenu->cursoroffset; if (cliptop) @@ -3174,23 +3174,23 @@ INT32 MR_Addons(INT32 choice) W_UnlockCachedPatch(addonsp[i]); } - addonsp[EXT_FOLDER] = W_CachePatchName("M_FFLDR", PU_STATIC); - addonsp[EXT_UP] = W_CachePatchName("M_FBACK", PU_STATIC); - addonsp[EXT_NORESULTS] = W_CachePatchName("M_FNOPE", PU_STATIC); - addonsp[EXT_TXT] = W_CachePatchName("M_FTXT", PU_STATIC); - addonsp[EXT_CFG] = W_CachePatchName("M_FCFG", PU_STATIC); - addonsp[EXT_WAD] = W_CachePatchName("M_FWAD", PU_STATIC); + addonsp[EXT_FOLDER] = W_CachePatchLongName("M_FFLDR", PU_STATIC); + addonsp[EXT_UP] = W_CachePatchLongName("M_FBACK", PU_STATIC); + addonsp[EXT_NORESULTS] = W_CachePatchLongName("M_FNOPE", PU_STATIC); + addonsp[EXT_TXT] = W_CachePatchLongName("M_FTXT", PU_STATIC); + addonsp[EXT_CFG] = W_CachePatchLongName("M_FCFG", PU_STATIC); + addonsp[EXT_WAD] = W_CachePatchLongName("M_FWAD", PU_STATIC); #ifdef USE_KART - addonsp[EXT_KART] = W_CachePatchName("M_FKART", PU_STATIC); + addonsp[EXT_KART] = W_CachePatchLongName("M_FKART", PU_STATIC); #endif - addonsp[EXT_PK3] = W_CachePatchName("M_FPK3", PU_STATIC); - addonsp[EXT_SOC] = W_CachePatchName("M_FSOC", PU_STATIC); - addonsp[EXT_LUA] = W_CachePatchName("M_FLUA", PU_STATIC); - addonsp[NUM_EXT] = W_CachePatchName("M_FUNKN", PU_STATIC); - addonsp[NUM_EXT+1] = W_CachePatchName("M_FSEL", PU_STATIC); - addonsp[NUM_EXT+2] = W_CachePatchName("M_FLOAD", PU_STATIC); - addonsp[NUM_EXT+3] = W_CachePatchName("M_FSRCH", PU_STATIC); - addonsp[NUM_EXT+4] = W_CachePatchName("M_FSAVE", PU_STATIC); + addonsp[EXT_PK3] = W_CachePatchLongName("M_FPK3", PU_STATIC); + addonsp[EXT_SOC] = W_CachePatchLongName("M_FSOC", PU_STATIC); + addonsp[EXT_LUA] = W_CachePatchLongName("M_FLUA", PU_STATIC); + addonsp[NUM_EXT] = W_CachePatchLongName("M_FUNKN", PU_STATIC); + addonsp[NUM_EXT+1] = W_CachePatchLongName("M_FSEL", PU_STATIC); + addonsp[NUM_EXT+2] = W_CachePatchLongName("M_FLOAD", PU_STATIC); + addonsp[NUM_EXT+3] = W_CachePatchLongName("M_FSRCH", PU_STATIC); + addonsp[NUM_EXT+4] = W_CachePatchLongName("M_FSAVE", PU_STATIC); return true; } @@ -3885,7 +3885,7 @@ static void DrawReplayHutReplayInfo(void) { static angle_t rubyfloattime = 0; const fixed_t rubyheight = FINESINE(rubyfloattime>>ANGLETOFINESHIFT); - V_DrawFixedPatch((x+(w>>2))<>2))<>2))<>2))<x - 24, cursory, V_SNAPTOTOP|V_SNAPTOLEFT, - W_CachePatchName("M_CURSOR", PU_CACHE)); + W_CachePatchLongName("M_CURSOR", PU_CACHE)); // Now draw some replay info! V_DrawFill(10, 10, 300, 60, V_SNAPTOTOP|159); @@ -4105,7 +4105,7 @@ void MD_DrawReplayStartMenu(void) } else { - patch = W_CachePatchName("M_NORANK", PU_CACHE); + patch = W_CachePatchLongName("M_NORANK", PU_CACHE); colormap = R_GetTranslationColormap( TC_RAINBOW, demolist[dir_on[menudepthleft]].standings[i].color, @@ -4288,14 +4288,14 @@ void MD_DrawPlaybackMenu(void) else if (currentMenu->menuitems[i].patch && W_CheckNumForName(currentMenu->menuitems[i].patch) != LUMPERROR) icon = W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE); else - icon = W_CachePatchName("PLAYRANK", PU_CACHE); // temp + icon = W_CachePatchLongName("PLAYRANK", PU_CACHE); // temp } else if (currentMenu->menuitems[i].status & IT_HIDDEN) continue; else if (currentMenu->menuitems[i].patch && W_CheckNumForName(currentMenu->menuitems[i].patch) != LUMPERROR) icon = W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE); else - icon = W_CachePatchName("PLAYRANK", PU_CACHE); // temp + icon = W_CachePatchLongName("PLAYRANK", PU_CACHE); // temp if ((i == M_GetMenuIndex(MN_PLAYBACK, "FASTFORWARD") && cv_playbackspeed.value > 1) || (i == M_GetMenuIndex(MN_PLAYBACK, "REWIND") && demo.rewinding)) V_DrawMappedPatch(currentMenu->x + currentMenu->menuitems[i].x, currentMenu->y, transmap|V_SNAPTOTOP, icon, R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_JAWZ, GTC_MENUCACHE)); @@ -5234,7 +5234,7 @@ static void M_DrawStatsMaps(void) V_DrawRightAlignedString(BASEVIDWIDTH-16, 50, MENUCAPS|recommendedflags, "(complete)"); V_DrawString(32, 50, 0, va("x %d/%d", M_CountEmblems(), numemblems+numextraemblems)); - V_DrawSmallScaledPatch(20, 50, 0, W_CachePatchName("GOTITA", PU_STATIC)); + V_DrawSmallScaledPatch(20, 50, 0, W_CachePatchLongName("GOTITA", PU_STATIC)); if (location) V_DrawCharacter(10, y-(skullAnimCounter/5), @@ -5308,7 +5308,7 @@ static void M_DrawStatsMaps(void) V_DrawSmallMappedPatch(295, y, 0, W_CachePatchName(M_GetExtraEmblemPatch(exemblem, false), PU_CACHE), R_GetTranslationColormap(TC_DEFAULT, M_GetExtraEmblemColor(exemblem), GTC_MENUCACHE)); else - V_DrawSmallScaledPatch(295, y, 0, W_CachePatchName("NEEDIT", PU_CACHE)); + V_DrawSmallScaledPatch(295, y, 0, W_CachePatchLongName("NEEDIT", PU_CACHE)); V_DrawString(20, y, 0, va("%s", exemblem->description)); } @@ -6427,7 +6427,7 @@ static void M_DrawLevelSelectOnly(INT16 y, boolean selected, boolean leftfade, b { static angle_t rubyfloattime = 0; const fixed_t rubyheight = FINESINE(rubyfloattime>>ANGLETOFINESHIFT); - V_DrawFixedPatch((x+w/2)< 7 * FRACUNIT; cursorframe -= 7 * FRACUNIT) {} - V_DrawFixedPatch(x<> FRACBITS) + 1), PU_CACHE), NULL); + V_DrawFixedPatch(x<> FRACBITS) + 1), PU_CACHE), NULL); } x += incrwidth; @@ -6633,7 +6633,7 @@ void MD_DrawSetupMultiPlayerMenu(void) INT32 mx, my, st, flags = 0; spritedef_t *sprdef; spriteframe_t *sprframe; - patch_t *statdot = W_CachePatchName("K_SDOT0", PU_CACHE); + patch_t *statdot = W_CachePatchLongName("K_SDOT0", PU_CACHE); patch_t *patch; UINT8 frame; UINT8 speed; @@ -6663,13 +6663,13 @@ void MD_DrawSetupMultiPlayerMenu(void) speed = skins[cv_chooseskin.value].kartspeed; weight = skins[cv_chooseskin.value].kartweight; - statdot = W_CachePatchName("K_SDOT1", PU_CACHE); + statdot = W_CachePatchLongName("K_SDOT1", PU_CACHE); if (skullAnimCounter < 4) // SRB2Kart: we draw this dot later so that it's not covered if there's multiple skins with the same stats V_DrawFixedPatch(((BASEVIDWIDTH - mx - 80) + ((speed-1)*8))< 7 * FRACUNIT; cursorframe -= 7 * FRACUNIT) {} - cursor = W_CachePatchName(va("K_BHILI%d", (cursorframe >> FRACBITS) + 1), PU_CACHE); + cursor = W_CachePatchLongName(va("K_BHILI%d", (cursorframe >> FRACBITS) + 1), PU_CACHE); if (col < 0) col += numskins; @@ -7617,7 +7617,7 @@ void MD_DrawVideoMode(void) j = menudefs[MN_OP_VIDEOMODE].y + 14 + ((vidm_selected % vidm_column_size)*8); V_DrawScaledPatch(i - 8, j, 0, - W_CachePatchName("M_CURSOR", PU_CACHE)); + W_CachePatchLongName("M_CURSOR", PU_CACHE)); } // special menuitem key handler for video mode list @@ -7760,14 +7760,14 @@ void MD_DrawMonitorToggles(void) #ifdef ITEMTOGGLEBOTTOMRIGHT if (currentMenu->menuitems[thisitem].argument == 255) { - V_DrawScaledPatch(x, y, V_TRANSLUCENT, W_CachePatchName("K_ISBG", PU_CACHE)); + V_DrawScaledPatch(x, y, V_TRANSLUCENT, W_CachePatchLongName("K_ISBG", PU_CACHE)); continue; } #endif if (currentMenu->menuitems[thisitem].argument == 0) { - V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISBG", PU_CACHE)); - V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISTOGL", PU_CACHE)); + V_DrawScaledPatch(x, y, 0, W_CachePatchLongName("K_ISBG", PU_CACHE)); + V_DrawScaledPatch(x, y, 0, W_CachePatchLongName("K_ISTOGL", PU_CACHE)); continue; } @@ -7797,13 +7797,13 @@ void MD_DrawMonitorToggles(void) } if (cv->value) - V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISBG", PU_CACHE)); + V_DrawScaledPatch(x, y, 0, W_CachePatchLongName("K_ISBG", PU_CACHE)); else - V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISBGD", PU_CACHE)); + V_DrawScaledPatch(x, y, 0, W_CachePatchLongName("K_ISBGD", PU_CACHE)); if (drawnum != 0) { - V_DrawScaledPatch(x, y, 0, W_CachePatchName("K_ISMUL", PU_CACHE)); + V_DrawScaledPatch(x, y, 0, W_CachePatchLongName("K_ISMUL", PU_CACHE)); V_DrawScaledPatch(x, y, translucent, W_CachePatchName(K_GetItemPatch(currentMenu->menuitems[thisitem].argument, true), PU_CACHE)); V_DrawString(x+24, y+31, V_ALLOWLOWERCASE|translucent, va("x%d", drawnum)); } @@ -7821,7 +7821,7 @@ void MD_DrawMonitorToggles(void) #ifdef ITEMTOGGLEBOTTOMRIGHT if (currentMenu->menuitems[itemOn].argument == 255) { - V_DrawScaledPatch(onx-1, ony-2, V_TRANSLUCENT, W_CachePatchName("K_ITBG", PU_CACHE)); + V_DrawScaledPatch(onx-1, ony-2, V_TRANSLUCENT, W_CachePatchLongName("K_ITBG", PU_CACHE)); if (shitsfree) { INT32 trans = V_TRANSLUCENT; @@ -7829,15 +7829,15 @@ void MD_DrawMonitorToggles(void) trans = ((10-TICRATE)+shitsfree-1)<menuitems[itemOn].argument == 0) { - V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchName("K_ITBG", PU_CACHE)); - V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchName("K_ITTOGL", PU_CACHE)); + V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchLongName("K_ITBG", PU_CACHE)); + V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchLongName("K_ITTOGL", PU_CACHE)); } else { @@ -7855,15 +7855,15 @@ void MD_DrawMonitorToggles(void) } if (cv->value) - V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchName("K_ITBG", PU_CACHE)); + V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchLongName("K_ITBG", PU_CACHE)); else - V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchName("K_ITBGD", PU_CACHE)); + V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchLongName("K_ITBGD", PU_CACHE)); if (drawnum != 0) { - V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchName("K_ITMUL", PU_CACHE)); + V_DrawScaledPatch(onx-1, ony-2, 0, W_CachePatchLongName("K_ITMUL", PU_CACHE)); V_DrawScaledPatch(onx-1, ony-2, translucent, W_CachePatchName(K_GetItemPatch(currentMenu->menuitems[itemOn].argument, false), PU_CACHE)); - V_DrawScaledPatch(onx+27, ony+39, translucent, W_CachePatchName("K_ITX", PU_CACHE)); + V_DrawScaledPatch(onx+27, ony+39, translucent, W_CachePatchLongName("K_ITX", PU_CACHE)); V_DrawKartString(onx+37, ony+34, translucent, va("%d", drawnum)); } else @@ -8353,7 +8353,7 @@ void M_QuitResponse(INT32 ch) while (ptime > I_GetTime()) { V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); - V_DrawSmallScaledPatch(0, 0, 0, W_CachePatchName("GAMEQUIT", PU_CACHE)); // Demo 3 Quit Screen Tails 06-16-2001 + V_DrawSmallScaledPatch(0, 0, 0, W_CachePatchLongName("GAMEQUIT", PU_CACHE)); // Demo 3 Quit Screen Tails 06-16-2001 I_FinishUpdate(); // Update the screen with the image Tails 06-19-2001 I_Sleep(cv_sleep.value); I_UpdateTime(cv_timescale.value); @@ -8428,12 +8428,12 @@ static void M_DrawSticker(INT32 x, INT32 y, INT32 width, INT32 flags, boolean is if (isSmall == true) { - stickerEnd = W_CachePatchName("K_STIKE2", PU_CACHE); + stickerEnd = W_CachePatchLongName("K_STIKE2", PU_CACHE); height = 6; } else { - stickerEnd = W_CachePatchName("K_STIKEN", PU_CACHE); + stickerEnd = W_CachePatchLongName("K_STIKEN", PU_CACHE); height = 11; } @@ -8460,12 +8460,12 @@ void MD_DrawDiscordRequests(void) if (confirmAccept == true) { colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_GREEN, GTC_MENUCACHE); - hand = W_CachePatchName("K_LAPH02", PU_CACHE); + hand = W_CachePatchLongName("K_LAPH02", PU_CACHE); } else { colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_RED, GTC_MENUCACHE); - hand = W_CachePatchName("K_LAPH03", PU_CACHE); + hand = W_CachePatchLongName("K_LAPH03", PU_CACHE); } slide = confirmLength - confirmDelay; @@ -8480,7 +8480,7 @@ void MD_DrawDiscordRequests(void) colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_GREY, GTC_MENUCACHE); } - V_DrawFixedPatch(56*FRACUNIT, 150*FRACUNIT, FRACUNIT, 0, W_CachePatchName("K_LAPE01", PU_CACHE), colormap); + V_DrawFixedPatch(56*FRACUNIT, 150*FRACUNIT, FRACUNIT, 0, W_CachePatchLongName("K_LAPE01", PU_CACHE), colormap); if (hand != NULL) { diff --git a/src/r_data.c b/src/r_data.c index c9bf53611..fc834a034 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -275,7 +275,7 @@ void R_InitColormaps(void) lumpnum_t lump; // Load in the light tables - lump = W_GetNumForName("COLORMAP"); + lump = W_GetNumForLongName("COLORMAP"); len = W_LumpLength(lump); if (len < COLORMAP_SIZE*2) // accomodate encore mode later len = COLORMAP_SIZE*2; @@ -295,13 +295,13 @@ void R_ReInitColormaps(UINT16 num, void *newencoremap, size_t encoremapsize, boo { char colormap[9] = "COLORMAP"; lumpnum_t lump; - const lumpnum_t basecolormaplump = W_GetNumForName(colormap); + const lumpnum_t basecolormaplump = W_GetNumForLongName(colormap); boolean remap = false; if (num > 0 && num <= 10000) snprintf(colormap, 8, "CLM%04u", num-1); // Load in the light tables, now 64k aligned for smokie... - lump = W_GetNumForName(colormap); + lump = W_GetNumForLongName(colormap); if (lump == LUMPERROR) lump = basecolormaplump; else @@ -1204,7 +1204,8 @@ static void R_Init8to16(void) UINT8 *palette; int i; - palette = W_CacheLumpName("PLAYPAL",PU_CACHE); + lumpnum_t lump = W_GetNumForLongName("PLAYPAL"); + palette = W_CacheLumpNum(lump, PU_CACHE); for (i = 0; i < 256; i++) { diff --git a/src/r_draw.cpp b/src/r_draw.cpp index a95384c57..841df4b6d 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -237,15 +237,15 @@ void R_InitTranslucencyTables(void) // optimised code (in other words, transtables pointer low word is 0) transtables = static_cast(Z_MallocAlign(NUMTRANSTABLES*0x10000, PU_STATIC, NULL, 16)); - W_ReadLump(W_GetNumForName("TRANS10"), transtables); - W_ReadLump(W_GetNumForName("TRANS20"), transtables+0x10000); - W_ReadLump(W_GetNumForName("TRANS30"), transtables+0x20000); - W_ReadLump(W_GetNumForName("TRANS40"), transtables+0x30000); - W_ReadLump(W_GetNumForName("TRANS50"), transtables+0x40000); - W_ReadLump(W_GetNumForName("TRANS60"), transtables+0x50000); - W_ReadLump(W_GetNumForName("TRANS70"), transtables+0x60000); - W_ReadLump(W_GetNumForName("TRANS80"), transtables+0x70000); - W_ReadLump(W_GetNumForName("TRANS90"), transtables+0x80000); + W_ReadLump(W_GetNumForLongName("TRANS10"), transtables); + W_ReadLump(W_GetNumForLongName("TRANS20"), transtables+0x10000); + W_ReadLump(W_GetNumForLongName("TRANS30"), transtables+0x20000); + W_ReadLump(W_GetNumForLongName("TRANS40"), transtables+0x30000); + W_ReadLump(W_GetNumForLongName("TRANS50"), transtables+0x40000); + W_ReadLump(W_GetNumForLongName("TRANS60"), transtables+0x50000); + W_ReadLump(W_GetNumForLongName("TRANS70"), transtables+0x60000); + W_ReadLump(W_GetNumForLongName("TRANS80"), transtables+0x70000); + W_ReadLump(W_GetNumForLongName("TRANS90"), transtables+0x80000); R_AllocateBlendTables(); R_GenerateBlendTables(); @@ -345,8 +345,8 @@ void R_InitPaletteRemap(void) { palremap = static_cast(Z_Malloc(256, PU_STATIC, NULL)); invremap = static_cast(Z_Malloc(256, PU_STATIC, NULL)); - W_ReadLump(W_GetNumForName("PALREMAP"), palremap); - W_ReadLump(W_GetNumForName("INVREMAP"), invremap); + W_ReadLump(W_GetNumForLongName("PALREMAP"), palremap); + W_ReadLump(W_GetNumForLongName("INVREMAP"), invremap); } UINT8 R_GetPaletteRemap(UINT8 color) @@ -512,14 +512,14 @@ lumpnum_t viewborderlump[8]; void R_InitViewBorder(void) { - viewborderlump[BRDR_T] = W_GetNumForName("brdr_t"); - viewborderlump[BRDR_B] = W_GetNumForName("brdr_b"); - viewborderlump[BRDR_L] = W_GetNumForName("brdr_l"); - viewborderlump[BRDR_R] = W_GetNumForName("brdr_r"); - viewborderlump[BRDR_TL] = W_GetNumForName("brdr_tl"); - viewborderlump[BRDR_BL] = W_GetNumForName("brdr_bl"); - viewborderlump[BRDR_TR] = W_GetNumForName("brdr_tr"); - viewborderlump[BRDR_BR] = W_GetNumForName("brdr_br"); + viewborderlump[BRDR_T] = W_GetNumForLongName("brdr_t"); + viewborderlump[BRDR_B] = W_GetNumForLongName("brdr_b"); + viewborderlump[BRDR_L] = W_GetNumForLongName("brdr_l"); + viewborderlump[BRDR_R] = W_GetNumForLongName("brdr_r"); + viewborderlump[BRDR_TL] = W_GetNumForLongName("brdr_tl"); + viewborderlump[BRDR_BL] = W_GetNumForLongName("brdr_bl"); + viewborderlump[BRDR_TR] = W_GetNumForLongName("brdr_tr"); + viewborderlump[BRDR_BR] = W_GetNumForLongName("brdr_br"); } #if 0 diff --git a/src/sdl/endtxt.c b/src/sdl/endtxt.c index 1e72ca9a8..cb7adc847 100644 --- a/src/sdl/endtxt.c +++ b/src/sdl/endtxt.c @@ -45,7 +45,7 @@ void ShowEndTxt(void) #endif UINT16 *ptext; void *data; - lumpnum_t endoomnum = W_GetNumForName("ENDOOM"); + lumpnum_t endoomnum = W_GetNumForLongName("ENDOOM"); //char *col; /* if the xterm has more then 80 columns we need to add nl's */ diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 995edc626..bf0e8fba0 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1919,7 +1919,7 @@ void I_Quit(void) I_ShutdownSystem(); SDL_Quit(); /* if option -noendtxt is set, don't print the text */ - if (!M_CheckParm("-noendtxt") && W_CheckNumForName("ENDOOM") != LUMPERROR) + if (!M_CheckParm("-noendtxt") && W_CheckNumForLongName("ENDOOM") != LUMPERROR) { printf("\r"); ShowEndTxt(); diff --git a/src/st_stuff.c b/src/st_stuff.c index 2e404b3e8..04ad728dc 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -200,7 +200,7 @@ void ST_LoadFaceGraphics(INT32 skinnum) } if (i < FACE_MAX) { - patch_t *missing = W_CachePatchName("MISSING", PU_HUDGFX); + patch_t *missing = W_CachePatchLongName("MISSING", PU_HUDGFX); while (i < FACE_MAX) { faceprefix[skinnum][i] = missing; diff --git a/src/v_video.c b/src/v_video.c index e4d39cd40..36a4df30a 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -994,7 +994,7 @@ void V_DrawContinueIcon(INT32 x, INT32 y, INT32 flags, INT32 skinnum, UINT16 ski { (void)skinnum; (void)skincolor; - V_DrawScaledPatch(x - 10, y - 14, flags, W_CachePatchName("CONTINS", PU_PATCH)); + V_DrawScaledPatch(x - 10, y - 14, flags, W_CachePatchLongName("CONTINS", PU_PATCH)); } // diff --git a/src/w_wad.c b/src/w_wad.c index f6a353321..fd6c603ad 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1210,25 +1210,6 @@ UINT16 W_CheckNumForMapPwad(const char *name, UINT32 hash, UINT16 wad, UINT16 st return LUMPERROR; } -// -// Same as the original, but checks in one pwad only. -// wadid is a wad number -// (Used for sprites loading) -// -// 'startlump' is the lump number to start the search -// -// NOTE: only exists for compatibility with code requiring the 8-char truncation. -// use W_CheckNumForLongNamePwad in new code! -// if the old code passes a string literal, you can switch without issues -// -UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump) -{ - char shortname[8+1]; - strncpy(shortname, name, 8); - shortname[8] = '\0'; - return W_CheckNumForLongNamePwad(shortname, wad, startlump); -} - // // Like W_CheckNumForNamePwad, but can find entries with long names // @@ -1355,22 +1336,6 @@ UINT16 W_CheckNumForFullNamePK3(const char *name, UINT16 wad, UINT16 startlump) return LUMPERROR; } -// -// W_CheckNumForName -// Returns LUMPERROR if name not found. -// -// NOTE: only exists for compatibility with code requiring the 8-char truncation. -// use W_CheckNumForLongName in new code! -// if the old code passes a string literal, you can switch without issues -// -lumpnum_t W_CheckNumForName(const char *name) -{ - char shortname[8+1]; - strncpy(shortname, name, 8); - shortname[8] = '\0'; - return W_CheckNumForLongName(shortname); -} - // // Like W_CheckNumForName, but can find entries with long names // @@ -1482,23 +1447,6 @@ lumpnum_t W_CheckNumForMap(const char *name) } } -// -// W_GetNumForName -// -// Calls W_CheckNumForName, but bombs out if not found. -// -lumpnum_t W_GetNumForName(const char *name) -{ - lumpnum_t i; - - i = W_CheckNumForName(name); - - if (i == LUMPERROR) - I_Error("W_GetNumForName: %s not found!\n", name); - - return i; -} - // // Like W_GetNumForName, but can find entries with long names // @@ -1958,14 +1906,6 @@ boolean W_IsPatchCached(lumpnum_t lumpnum, void *ptr) return W_IsPatchCachedPWAD(WADFILENUM(lumpnum),LUMPNUM(lumpnum), ptr); } -// ========================================================================== -// W_CacheLumpName -// ========================================================================== -void *W_CacheLumpName(const char *name, INT32 tag) -{ - return W_CacheLumpNum(W_GetNumForName(name), tag); -} - // ========================================================================== // CACHING OF GRAPHIC PATCH RESOURCES // ========================================================================== @@ -2075,17 +2015,6 @@ void W_UnlockCachedPatch(void *patch) Z_Unlock(patch); } -void *W_CachePatchName(const char *name, INT32 tag) -{ - lumpnum_t num; - - num = W_CheckNumForName(name); - - if (num == LUMPERROR) - return missingpat; - return W_CachePatchNum(num, tag); -} - void *W_CachePatchLongName(const char *name, INT32 tag) { lumpnum_t num; diff --git a/src/w_wad.h b/src/w_wad.h index f2b6b9993..2f26147cf 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -133,8 +133,18 @@ const char *W_CheckFullNameForNum(lumpnum_t lumpnum); UINT16 W_FindNextEmptyInPwad(UINT16 wad, UINT16 startlump); // checks only in one pwad +// helper for old functions that use 8-char names +// careful, you might be dealing with a non-terminated string! +static inline const char *W_ShortName(const char *name) +{ + static char shortname[8+1]; + strncpy(shortname, name, 8); + shortname[8] = '\0'; + return shortname; +} + UINT16 W_CheckNumForMapPwad(const char *name, UINT32 hash, UINT16 wad, UINT16 startlump); -UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump); // checks only in one pwad +#define W_CheckNumForNamePwad(name, wad, start) W_CheckNumForLongNamePwad(W_ShortName(name), wad, start) UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump); UINT16 W_CheckNumForNamePrefixPwad(const char *name, size_t namelen, UINT16 wad, UINT16 startlump); UINT16 W_CheckNumForNameMultiPrefixPwad(const lumpprefixes_t *prefixes, size_t numprefixes, UINT16 wad, UINT16 startlump); @@ -144,9 +154,9 @@ UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlum UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump); lumpnum_t W_CheckNumForMap(const char *name); -lumpnum_t W_CheckNumForName(const char *name); +#define W_CheckNumForName(name) W_CheckNumForLongName(W_ShortName(name)) lumpnum_t W_CheckNumForLongName(const char *name); -lumpnum_t W_GetNumForName(const char *name); // like W_CheckNumForName but I_Error on LUMPERROR +#define W_GetNumForName(name) W_GetNumForLongName(W_ShortName(name)) lumpnum_t W_GetNumForLongName(const char *name); lumpnum_t W_CheckNumForNameInFolder(const char *lump, const char *folder); UINT8 W_LumpExists(const char *name); // Lua uses this. @@ -175,8 +185,7 @@ boolean W_IsPatchCached(lumpnum_t lump, void *ptr); boolean W_NeedPaletteRemapPwad(UINT16 wad, UINT16 lump, boolean ignorecache); boolean W_NeedPaletteRemap(lumpnum_t lump, boolean ignorecache); -void *W_CacheLumpName(const char *name, INT32 tag); -void *W_CachePatchName(const char *name, INT32 tag); +#define W_CachePatchName(name, tag) W_CachePatchLongName(W_ShortName(name), tag) void *W_CachePatchLongName(const char *name, INT32 tag); // Returns either a Software patch, or an OpenGL patch. diff --git a/src/y_inter.c b/src/y_inter.c index eb5fef9b0..e36f94a58 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -511,7 +511,7 @@ void Y_IntermissionDrawer(void) { // no y_buffer if (y_buffer == NULL) - V_DrawPatchFill(W_CachePatchName("SRB2BACK", PU_CACHE)); + V_DrawPatchFill(W_CachePatchLongName("SRB2BACK", PU_CACHE)); else { // Maybe the resolution changed? @@ -654,13 +654,13 @@ void Y_IntermissionDrawer(void) if (data.num[i] == whiteplayer) { UINT8 cursorframe = (intertic / 4) % 8; - V_DrawScaledPatch(x+16, y-4, 0, W_CachePatchName(va("K_CHILI%d", cursorframe+1), PU_CACHE)); + V_DrawScaledPatch(x+16, y-4, 0, W_CachePatchLongName(va("K_CHILI%d", cursorframe+1), PU_CACHE)); } if ((players[data.num[i]].pflags & PF_NOCONTEST) && players[data.num[i]].bot) { // RETIRED!! - V_DrawScaledPatch(x+12, y-7, 0, W_CachePatchName("K_NOBLNS", PU_CACHE)); + V_DrawScaledPatch(x+12, y-7, 0, W_CachePatchLongName("K_NOBLNS", PU_CACHE)); } STRBUFCPY(strtime, data.name[i]); @@ -1509,7 +1509,7 @@ void Y_VoteDrawer(void) if (!splitscreen && i == consoleplayer) { UINT8 cursorframe = (votetic / 4) % 8; - V_DrawScaledPatch(x+24, y+9, V_SNAPTOLEFT, W_CachePatchName(va("K_CHILI%d", cursorframe+1), PU_CACHE)); + V_DrawScaledPatch(x+24, y+9, V_SNAPTOLEFT, W_CachePatchLongName(va("K_CHILI%d", cursorframe+1), PU_CACHE)); } } @@ -1851,14 +1851,14 @@ void Y_StartVote(void) Y_AnimatedVoteScreenCheck(); - widebgpatch = W_CachePatchName((battlemode ? "BATTLSCW" : "INTERSCW"), PU_STATIC); - bgpatch = W_CachePatchName((battlemode ? "BATTLSCR" : "INTERSCR"), PU_STATIC); - cursor = W_CachePatchName("M_CURSOR", PU_STATIC); - cursor1 = W_CachePatchName("P1CURSOR", PU_STATIC); - cursor2 = W_CachePatchName("P2CURSOR", PU_STATIC); - cursor3 = W_CachePatchName("P3CURSOR", PU_STATIC); - cursor4 = W_CachePatchName("P4CURSOR", PU_STATIC); - rubyicon = W_CachePatchName("RUBYICON", PU_STATIC); + widebgpatch = W_CachePatchLongName((battlemode ? "BATTLSCW" : "INTERSCW"), PU_STATIC); + bgpatch = W_CachePatchLongName((battlemode ? "BATTLSCR" : "INTERSCR"), PU_STATIC); + cursor = W_CachePatchLongName("M_CURSOR", PU_STATIC); + cursor1 = W_CachePatchLongName("P1CURSOR", PU_STATIC); + cursor2 = W_CachePatchLongName("P2CURSOR", PU_STATIC); + cursor3 = W_CachePatchLongName("P3CURSOR", PU_STATIC); + cursor4 = W_CachePatchLongName("P4CURSOR", PU_STATIC); + rubyicon = W_CachePatchLongName("RUBYICON", PU_STATIC); timer = cv_votetime.value*TICRATE; pickedvote = -1;