Merge pull request 'File loading refactor' (#68) from wadstrbuf into blankart-dev

Reviewed-on: https://codeberg.org/NepDisk/blankart/pulls/68
This commit is contained in:
NepDisk 2025-06-28 23:57:54 +02:00
commit f72475b557
46 changed files with 1027 additions and 1572 deletions

View file

@ -279,7 +279,7 @@ static int luaB_dofile (lua_State *L) {
snprintf(fullfilename, sizeof(fullfilename), "Lua/%s", filename);
lumpnum = W_CheckNumForFullNamePK3(fullfilename, numwadfiles - 1, 0);
if (lumpnum == INT16_MAX)
if (lumpnum == LUMPERROR)
luaL_error(L, "can't find script " LUA_QS, fullfilename);
LUA_LoadLump(numwadfiles - 1, lumpnum, false);

View file

@ -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_GetNumForLongName(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);

View file

@ -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<patch_t*>(W_CachePatchName("SRB2BACK", PU_CACHE));
patch_t *pat = static_cast<patch_t*>(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<patch_t*>(W_CachePatchName("M_PAUSE", PU_PATCH));
patch = static_cast<patch_t*>(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
@ -1559,7 +1559,7 @@ void D_SRB2Main(void)
}
D_CleanFile(startuppwads);
partadd_earliestfile = UINT16_MAX;
partadd_earliestfile = MAX_WADFILES;
CON_SetLoadingProgress(LOADED_PWAD);

View file

@ -1353,7 +1353,8 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum)
if (fastcmp(word+4, "NAME"))
{
strncpy(cutscenes[num]->scene[scenenum].picname[picid], word2, 8);
strncpy(cutscenes[num]->scene[scenenum].picname[picid], word2, SHORTNAMELEN);
cutscenes[num]->scene[scenenum].picname[picid][SHORTNAMELEN] = '\0';
}
else if (fastcmp(word+4, "HIRES"))
{
@ -1595,7 +1596,8 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum)
for (picid = 0; picid < MAX_PROMPT_PICS; picid++)
{
strncpy(textprompts[num]->page[pagenum].picname[picid], textprompts[num]->page[metapagenum].picname[picid], 8);
strncpy(textprompts[num]->page[pagenum].picname[picid], textprompts[num]->page[metapagenum].picname[picid], SHORTNAMELEN);
textprompts[num]->page[pagenum].picname[picid][SHORTNAMELEN] = '\0';
textprompts[num]->page[pagenum].pichires[picid] = textprompts[num]->page[metapagenum].pichires[picid];
textprompts[num]->page[pagenum].picduration[picid] = textprompts[num]->page[metapagenum].picduration[picid];
textprompts[num]->page[pagenum].xcoord[picid] = textprompts[num]->page[metapagenum].xcoord[picid];
@ -1615,7 +1617,8 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum)
if (fastcmp(word+4, "NAME"))
{
strncpy(textprompts[num]->page[pagenum].picname[picid], word2, 8);
strncpy(textprompts[num]->page[pagenum].picname[picid], word2, SHORTNAMELEN);
textprompts[num]->page[pagenum].picname[picid][SHORTNAMELEN] = '\0';
}
else if (fastcmp(word+4, "HIRES"))
{
@ -1677,7 +1680,10 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum)
*textprompts[num]->page[pagenum].name = '\0';
}
else if (fastcmp(word, "ICON"))
strncpy(textprompts[num]->page[pagenum].iconname, word2, 8);
{
strncpy(textprompts[num]->page[pagenum].iconname, word2, SHORTNAMELEN);
textprompts[num]->page[pagenum].iconname[SHORTNAMELEN] = '\0';
}
else if (fastcmp(word, "ICONALIGN"))
textprompts[num]->page[pagenum].rightside = (i || word2[0] == 'R');
else if (fastcmp(word, "ICONFLIP"))
@ -1745,7 +1751,8 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum)
UINT8 metapagenum = usi - 1;
strncpy(textprompts[num]->page[pagenum].name, textprompts[num]->page[metapagenum].name, 32);
strncpy(textprompts[num]->page[pagenum].iconname, textprompts[num]->page[metapagenum].iconname, 8);
strncpy(textprompts[num]->page[pagenum].iconname, textprompts[num]->page[metapagenum].iconname, SHORTNAMELEN);
textprompts[num]->page[pagenum].iconname[SHORTNAMELEN] = '\0';
textprompts[num]->page[pagenum].rightside = textprompts[num]->page[metapagenum].rightside;
textprompts[num]->page[pagenum].iconflip = textprompts[num]->page[metapagenum].iconflip;
textprompts[num]->page[pagenum].lines = textprompts[num]->page[metapagenum].lines;
@ -2138,7 +2145,7 @@ void readmenu(MYFILE *f, INT32 num)
if (fastcmp(word, "BACKGROUNDNAME"))
{
strncpy(menudefs[num].bgname, word2, 8);
strlcpy(menudefs[num].bgname, word2, sizeof(menudefs[num].bgname));
titlechanged = true;
}
else if (fastcmp(word, "HIDEBACKGROUND"))
@ -2179,7 +2186,7 @@ void readmenu(MYFILE *f, INT32 num)
}
else if (fastcmp(word, "TITLEPICSNAME"))
{
strncpy(menudefs[num].ttname, word2, 9);
strlcpy(menudefs[num].ttname, word2, sizeof(menudefs[num].ttname));
titlechanged = true;
}
else if (fastcmp(word, "TITLEPICSX"))
@ -3139,13 +3146,11 @@ void readmaincfg(MYFILE *f)
else
{
lumpnum_t lumpnum;
char newname[9];
char newname[SHORTNAMELEN+1];
strncpy(newname, word2, 8);
strlcpy(newname, word2, sizeof(newname));
newname[8] = '\0';
lumpnum = W_CheckNumForName(newname);
lumpnum = W_CheckNumForLongName(newname);
if (lumpnum == LUMPERROR || W_LumpLength(lumpnum) == 0)
CONS_Debug(DBG_SETUP, "SOC Error: script lump %s not found/not valid.\n", newname);
@ -3296,7 +3301,7 @@ void readmaincfg(MYFILE *f)
}
else if (fastcmp(word, "TITLEPICSNAME"))
{
strncpy(ttname, word2, 9);
strlcpy(ttname, word2, sizeof(ttname));
titlechanged = true;
}
else if (fastcmp(word, "TITLEPICSX"))

View file

@ -204,10 +204,12 @@ extern UINT16 skincolor_redteam, skincolor_blueteam, skincolor_redring, skincolo
extern boolean exitfadestarted;
#define SHORTNAMELEN 8
struct scene_t
{
UINT8 numpics;
char picname[8][8];
char picname[8][SHORTNAMELEN+1];
UINT8 pichires[8];
char *text;
UINT16 xcoord[8];
@ -251,7 +253,7 @@ struct textpage_t
UINT8 picmode; // sequence mode after displaying last pic, 0 = persist, 1 = loop, 2 = destroy
UINT8 pictoloop; // if picmode == loop, which pic to loop to?
UINT8 pictostart; // initial pic number to show
char picname[MAX_PROMPT_PICS][8];
char picname[MAX_PROMPT_PICS][SHORTNAMELEN+1];
UINT8 pichires[MAX_PROMPT_PICS];
UINT16 xcoord[MAX_PROMPT_PICS]; // gfx
UINT16 ycoord[MAX_PROMPT_PICS]; // gfx
@ -263,7 +265,7 @@ struct textpage_t
char tag[33]; // page tag
char name[34]; // narrator name, extra char for color
char iconname[8]; // narrator icon lump
char iconname[SHORTNAMELEN+1]; // narrator icon lump
boolean rightside; // narrator side, false = left, true = right
boolean iconflip; // narrator flip icon horizontally
UINT8 hidehud; // hide hud, 0 = show all, 1 = hide depending on prompt position (top/bottom), 2 = hide all

View file

@ -341,7 +341,7 @@ union FColorRGBA
typedef union FColorRGBA RGBA_t;
typedef UINT32 lumpnum_t; // 16 : 16 unsigned long (wad num: lump num)
#define LUMPERROR UINT32_MAX
#define LUMPERROR UINT16_MAX // unified LUMPERROR
typedef UINT32 tic_t;
#define INFTICS UINT32_MAX

View file

@ -64,7 +64,7 @@ static INT32 menuanimtimer; // Title screen: background animation timing
mobj_t *titlemapcameraref = NULL;
// menu presentation state
char curbgname[9];
char curbgname[SHORTNAMELEN+1];
SINT8 curfadevalue;
INT32 curbgcolor;
INT32 curbgxspeed;
@ -94,7 +94,7 @@ boolean curhidepics;
ttmode_enum curttmode;
UINT8 curttscale;
// ttmode user vars
char curttname[9];
char curttname[SHORTNAMELEN+1];
INT16 curttx;
INT16 curtty;
INT16 curttloop;
@ -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)<<FRACBITS;
@ -335,14 +335,14 @@ static void F_IntroDrawScene(void)
// DRAW A FULL PIC INSTEAD OF FLAT!
if (intro_scenenum == 0)
{
background = W_CachePatchName("KARTKREW", PU_CACHE);
background = W_CachePatchLongName("KARTKREW", PU_CACHE);
highres = true;
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 0);
}
if (intro_scenenum == 1)
{
background = W_CachePatchName("BLANKART", PU_CACHE);
background = W_CachePatchLongName("BLANKART", PU_CACHE);
highres = false;
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
}
@ -753,10 +753,10 @@ void F_CreditDrawer(void)
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
// Draw background
V_DrawSciencePatch(0, 0 - FixedMul(32<<FRACBITS, FixedDiv(credbgtimer%TICRATE, TICRATE)), V_SNAPTOTOP, W_CachePatchName("CREDTILE", PU_CACHE), FRACUNIT);
V_DrawSciencePatch(0, 0 - FixedMul(32<<FRACBITS, FixedDiv(credbgtimer%TICRATE, TICRATE)), V_SNAPTOTOP, W_CachePatchLongName("CREDTILE", PU_CACHE), FRACUNIT);
V_DrawSciencePatch(0, 0 - FixedMul(40<<FRACBITS, FixedDiv(credbgtimer%(TICRATE/2), (TICRATE/2))), V_SNAPTOTOP, W_CachePatchName("CREDZIGZ", PU_CACHE), FRACUNIT);
V_DrawSciencePatch(320<<FRACBITS, 0 - FixedMul(40<<FRACBITS, FixedDiv(credbgtimer%(TICRATE/2), (TICRATE/2))), V_SNAPTOTOP|V_FLIP, W_CachePatchName("CREDZIGZ", PU_CACHE), FRACUNIT);
V_DrawSciencePatch(0, 0 - FixedMul(40<<FRACBITS, FixedDiv(credbgtimer%(TICRATE/2), (TICRATE/2))), V_SNAPTOTOP, W_CachePatchLongName("CREDZIGZ", PU_CACHE), FRACUNIT);
V_DrawSciencePatch(320<<FRACBITS, 0 - FixedMul(40<<FRACBITS, FixedDiv(credbgtimer%(TICRATE/2), (TICRATE/2))), V_SNAPTOTOP|V_FLIP, W_CachePatchLongName("CREDZIGZ", PU_CACHE), FRACUNIT);
// Draw pictures
for (i = 0; credits_pics[i].patch; i++)
@ -770,7 +770,7 @@ void F_CreditDrawer(void)
sc = FRACUNIT; // quick hack so I don't have to add another field to credits_pics
}
V_DrawFixedPatch(credits_pics[i].x<<FRACBITS, (credits_pics[i].y<<FRACBITS) - 4*(animtimer<<FRACBITS)/5, sc, 0, W_CachePatchName(credits_pics[i].patch, PU_CACHE), colormap);
V_DrawFixedPatch(credits_pics[i].x<<FRACBITS, (credits_pics[i].y<<FRACBITS) - 4*(animtimer<<FRACBITS)/5, sc, 0, W_CachePatchLongName(credits_pics[i].patch, PU_CACHE), colormap);
}
// Dim the background
@ -999,7 +999,7 @@ void F_BlanCreditDrawer(void)
fixed_t yscroll = FixedMul(32<<FRACBITS, FixedDiv(credbgtimer%TICRATE, TICRATE));
V_DrawFill(-100,-100,vid.width, vid.height,81);
V_DrawSciencePatch(0, 0 - yscroll, V_SNAPTOTOP, W_CachePatchName("CREDTILE", PU_CACHE), FRACUNIT);
V_DrawSciencePatch(0, 0 - yscroll, V_SNAPTOTOP, W_CachePatchLongName("CREDTILE", PU_CACHE), FRACUNIT);
V_DrawFillConsoleMap(-100,-100,vid.width, vid.height,0);
// Draw credits text on top
@ -1135,7 +1135,7 @@ void F_InitMenuPresValues(boolean title)
}
// Set defaults for presentation values
strncpy(curbgname, "TITLESKY", 9);
strcpy(curbgname, "TITLESKY");
curfadevalue = 16;
curbgcolor = -1;
curbgxspeed = titlescrollxspeed;
@ -1145,7 +1145,7 @@ void F_InitMenuPresValues(boolean title)
curhidepics = hidetitlepics;
curttmode = ttmode;
curttscale = ttscale;
strncpy(curttname, ttname, 9);
strcpy(curttname, ttname);
curttx = ttx;
curtty = tty;
curttloop = ttloop;
@ -1182,7 +1182,7 @@ void F_SkyScroll(INT32 scrollxspeed, INT32 scrollyspeed, const char *patchname)
return;
}
pat = W_CachePatchName(patchname, PU_PATCH_LOWPRIORITY);
pat = W_CachePatchLongName(patchname, PU_PATCH_LOWPRIORITY);
if (scrollxspeed == 0 && scrollyspeed == 0)
{
@ -1222,56 +1222,54 @@ void F_SkyScroll(INT32 scrollxspeed, INT32 scrollyspeed, const char *patchname)
}
}
#define LOADTTGFX(arr, name, maxf) \
lumpnum = W_CheckNumForName(name); \
if (lumpnum != LUMPERROR) \
{ \
arr[0] = W_CachePatchName(name, PU_PATCH_LOWPRIORITY); \
arr[min(1, maxf-1)] = 0; \
} \
else if (strlen(name) <= 6) \
{ \
fixed_t cnt = strlen(name); \
strncpy(lumpname, name, 7); \
for (i = 0; i < maxf-1; i++) \
{ \
sprintf(&lumpname[cnt], "%.2hu", (UINT16)(i+1)); \
lumpname[8] = 0; \
lumpnum = W_CheckNumForName(lumpname); \
if (lumpnum != LUMPERROR) \
arr[i] = W_CachePatchName(lumpname, PU_PATCH_LOWPRIORITY); \
else \
break; \
} \
arr[min(i, maxf-1)] = 0; \
} \
else \
arr[0] = 0;
static void LoadTTGFX(patch_t **arr, const char *name, UINT16 maxf)
{
UINT16 i;
lumpnum_t lumpnum;
char lumpname[SHORTNAMELEN+1];
lumpnum = W_CheckNumForLongName(name);
if (lumpnum != LUMPERROR)
{
arr[0] = W_CachePatchNum(lumpnum, PU_PATCH_LOWPRIORITY);
arr[min(1, maxf-1)] = NULL;
}
else if (strlen(name) <= 6)
{
fixed_t cnt = strlen(name);
strncpy(lumpname, name, 7);
for (i = 0; i < maxf-1; i++)
{
sprintf(&lumpname[cnt], "%.2hu", (UINT16)(i+1));
lumpnum = W_CheckNumForLongName(lumpname);
if (lumpnum != LUMPERROR)
arr[i] = W_CachePatchNum(lumpnum, PU_PATCH_LOWPRIORITY);
else
break;
}
arr[min(i, maxf-1)] = NULL;
}
else
arr[0] = NULL;
}
static void F_CacheTitleScreen(void)
{
UINT16 i;
switch(curttmode)
{
case TTMODE_NONE:
break;
case TTMODE_KART:
ttbanner = W_CachePatchName("TTKBANNR", PU_PATCH_LOWPRIORITY);
ttkart = W_CachePatchName("TTKART", PU_PATCH_LOWPRIORITY);
ttcheckers = W_CachePatchName("TTCHECK", PU_PATCH_LOWPRIORITY);
ttkflash = W_CachePatchName("TTKFLASH", PU_PATCH_LOWPRIORITY);
ttbanner = W_CachePatchLongName("TTKBANNR", PU_PATCH_LOWPRIORITY);
ttkart = W_CachePatchLongName("TTKART", PU_PATCH_LOWPRIORITY);
ttcheckers = W_CachePatchLongName("TTCHECK", PU_PATCH_LOWPRIORITY);
ttkflash = W_CachePatchLongName("TTKFLASH", PU_PATCH_LOWPRIORITY);
break;
case TTMODE_USER:
{
lumpnum_t lumpnum;
char lumpname[9];
LOADTTGFX(ttuser, curttname, TTMAX_USER)
LoadTTGFX(ttuser, curttname, TTMAX_USER);
break;
}
}
}
@ -1584,7 +1582,7 @@ void F_TitleScreenTicker(boolean run)
{
lumpnum_t l = LUMPERROR;
numstaff = 0;
while (numstaff < 99 && (l = W_CheckNumForName(va("TDEMO%03u", numstaff))) != LUMPERROR)
while (numstaff < 99 && (l = W_CheckNumForLongName(va("TDEMO%03u", numstaff))) != LUMPERROR)
numstaff++;
if (numstaff)
@ -1620,7 +1618,7 @@ void F_TitleScreenTicker(boolean run)
if (vLump == NULL)
{
if (((W_CheckNumForName(va("%sS%02u", mapheaderinfo[mapnum]->lumpname, numstaff)))) != LUMPERROR)
if (((W_CheckNumForLongName(va("%sS%02u", mapheaderinfo[mapnum]->lumpname, numstaff)))) != LUMPERROR)
sprintf(dname, "%sS%02u", mapheaderinfo[mapnum]->lumpname, numstaff);
else
{
@ -1844,10 +1842,10 @@ void F_CutsceneDrawer(void)
{
if (cutscenes[cutnum]->scene[scenenum].pichires[picnum])
V_DrawSmallScaledPatch(picxpos, picypos, 0,
W_CachePatchName(cutscenes[cutnum]->scene[scenenum].picname[picnum], PU_PATCH_LOWPRIORITY));
W_CachePatchLongName(cutscenes[cutnum]->scene[scenenum].picname[picnum], PU_PATCH_LOWPRIORITY));
else
V_DrawScaledPatch(picxpos,picypos, 0,
W_CachePatchName(cutscenes[cutnum]->scene[scenenum].picname[picnum], PU_PATCH_LOWPRIORITY));
W_CachePatchLongName(cutscenes[cutnum]->scene[scenenum].picname[picnum], PU_PATCH_LOWPRIORITY));
}
if (dofadenow && rendermode != render_none)
@ -1930,7 +1928,7 @@ static void F_GetPageTextGeometry(UINT8 *pagelines, boolean *rightside, INT32 *b
// reuse:
// cutnum -> promptnum
// scenenum -> pagenum
lumpnum_t iconlump = W_CheckNumForName(textprompts[cutnum]->page[scenenum].iconname);
lumpnum_t iconlump = W_CheckNumForLongName(textprompts[cutnum]->page[scenenum].iconname);
*pagelines = textprompts[cutnum]->page[scenenum].lines ? textprompts[cutnum]->page[scenenum].lines : 4;
*rightside = (iconlump != LUMPERROR && textprompts[cutnum]->page[scenenum].rightside);
@ -2305,7 +2303,7 @@ void F_TextPromptDrawer(void)
if (!promptactive)
return;
iconlump = W_CheckNumForName(textprompts[cutnum]->page[scenenum].iconname);
iconlump = W_CheckNumForLongName(textprompts[cutnum]->page[scenenum].iconname);
F_GetPageTextGeometry(&pagelines, &rightside, &boxh, &texth, &texty, &namey, &chevrony, &textx, &textr);
// Draw gfx first
@ -2313,10 +2311,10 @@ void F_TextPromptDrawer(void)
{
if (textprompts[cutnum]->page[scenenum].pichires[picnum])
V_DrawSmallScaledPatch(picxpos, picypos, 0,
W_CachePatchName(textprompts[cutnum]->page[scenenum].picname[picnum], PU_PATCH_LOWPRIORITY));
W_CachePatchLongName(textprompts[cutnum]->page[scenenum].picname[picnum], PU_PATCH_LOWPRIORITY));
else
V_DrawScaledPatch(picxpos,picypos, 0,
W_CachePatchName(textprompts[cutnum]->page[scenenum].picname[picnum], PU_PATCH_LOWPRIORITY));
W_CachePatchLongName(textprompts[cutnum]->page[scenenum].picname[picnum], PU_PATCH_LOWPRIORITY));
}
// Draw background
@ -2326,7 +2324,7 @@ void F_TextPromptDrawer(void)
if (iconlump != LUMPERROR)
{
INT32 iconx, icony, scale, scaledsize;
patch = W_CachePatchName(textprompts[cutnum]->page[scenenum].iconname, PU_PATCH_LOWPRIORITY);
patch = W_CachePatchLongName(textprompts[cutnum]->page[scenenum].iconname, PU_PATCH_LOWPRIORITY);
// scale and center
if (patch->width > patch->height)

View file

@ -93,10 +93,12 @@ typedef enum
#define TTMAX_ALACROIX 30 // max frames for SONIC typeface, plus one for NULL terminating entry
#define TTMAX_USER 100
#define SHORTNAMELEN 8
extern ttmode_enum ttmode;
extern UINT8 ttscale;
// ttmode user vars
extern char ttname[9];
extern char ttname[SHORTNAMELEN+1];
extern INT16 ttx;
extern INT16 tty;
extern INT16 ttloop;
@ -114,7 +116,7 @@ typedef enum
// Current menu parameters
extern mobj_t *titlemapcameraref;
extern char curbgname[9];
extern char curbgname[SHORTNAMELEN+1];
extern SINT8 curfadevalue;
extern INT32 curbgcolor;
extern INT32 curbgxspeed;
@ -126,7 +128,7 @@ extern boolean curhidepics;
extern ttmode_enum curttmode;
extern UINT8 curttscale;
// ttmode user vars
extern char curttname[9];
extern char curttname[SHORTNAMELEN+1];
extern INT16 curttx;
extern INT16 curtty;
extern INT16 curttloop;

View file

@ -102,7 +102,7 @@ static fixed_t paldiv;
* \return fademask_t for lump
*/
static fademask_t *F_GetFadeMask(UINT8 masknum, UINT8 scrnnum) {
static char lumpname[9] = "FADEmmss";
static char lumpname[SHORTNAMELEN+1] = "FADEmmss";
static fademask_t fm = {NULL,0,0,0,0,0};
lumpnum_t lumpnum;
UINT8 *lump, *mask;
@ -112,16 +112,9 @@ static fademask_t *F_GetFadeMask(UINT8 masknum, UINT8 scrnnum) {
if (masknum > 99 || scrnnum > 99)
goto freemask;
// SRB2Kart: This suddenly triggers ERRORMODE now
//sprintf(&lumpname[4], "%.2hu%.2hu", (UINT16)masknum, (UINT16)scrnnum);
sprintf(&lumpname[4], "%.2hu%.2hu", (UINT16)masknum, (UINT16)scrnnum);
lumpname[4] = '0'+(masknum/10);
lumpname[5] = '0'+(masknum%10);
lumpname[6] = '0'+(scrnnum/10);
lumpname[7] = '0'+(scrnnum%10);
lumpnum = W_CheckNumForName(lumpname);
lumpnum = W_CheckNumForLongName(lumpname);
if (lumpnum == LUMPERROR)
goto freemask;
@ -429,7 +422,7 @@ tic_t F_GetWipeLength(UINT8 wipetype)
(void)wipetype;
return 0;
#else
static char lumpname[10] = "FADEmmss";
static char lumpname[SHORTNAMELEN+1] = "FADEmmss";
lumpnum_t lumpnum;
UINT8 wipeframe;
@ -440,7 +433,7 @@ tic_t F_GetWipeLength(UINT8 wipetype)
{
sprintf(&lumpname[4], "%.2hu%.2hu", (UINT16)wipetype, (UINT16)wipeframe);
lumpnum = W_CheckNumForName(lumpname);
lumpnum = W_CheckNumForLongName(lumpname);
if (lumpnum == LUMPERROR)
return --wipeframe;
}
@ -456,7 +449,7 @@ boolean F_WipeExists(UINT8 wipetype)
(void)wipetype;
return false;
#else
static char lumpname[10] = "FADEmm00";
static char lumpname[SHORTNAMELEN+1] = "FADEmm00";
lumpnum_t lumpnum;
if (wipetype > 99)
@ -464,7 +457,7 @@ boolean F_WipeExists(UINT8 wipetype)
sprintf(&lumpname[4], "%.2hu00", (UINT16)wipetype);
lumpnum = W_CheckNumForName(lumpname);
lumpnum = W_CheckNumForLongName(lumpname);
return !(lumpnum == LUMPERROR);
#endif
}

View file

@ -2868,11 +2868,12 @@ void G_DeferedPlayDemo(const char *name)
#define SKIPERRORS
void G_DoPlayDemo(char *defdemoname)
void G_DoPlayDemo(const char *defdemoname)
{
UINT8 i, p;
lumpnum_t l;
char skin[17],color[MAXCOLORNAME+1],follower[17],mapname[MAXMAPLUMPNAME],*n,*pdemoname;
char skin[17],color[MAXCOLORNAME+1],follower[17],mapname[MAXMAPLUMPNAME],*pdemoname;
const char *n;
UINT8 version,subversion;
UINT32 randseed;
char msg[1024];
@ -2927,7 +2928,7 @@ void G_DoPlayDemo(char *defdemoname)
if (n == defdemoname)
{
// Raw lump.
if ((l = W_CheckNumForName(defdemoname)) == LUMPERROR)
if ((l = W_CheckNumForLongName(defdemoname)) == LUMPERROR)
{
snprintf(msg, 1024, M_GetText("Failed to read lump '%s'.\n"), defdemoname);
CONS_Alert(CONS_ERROR, "%s", msg);
@ -3381,11 +3382,12 @@ void G_DoPlayDemo(char *defdemoname)
demo.deferstart = true;
}
void G_AddGhost(char *defdemoname)
void G_AddGhost(const char *defdemoname)
{
INT32 i;
lumpnum_t l;
char name[17],skin[17],color[MAXCOLORNAME+1],*n,*pdemoname;
char name[17],skin[17],color[MAXCOLORNAME+1],*pdemoname;
const char *n;
UINT64 demohash;
demoghost *gh;
UINT8 flags;
@ -3420,7 +3422,7 @@ void G_AddGhost(char *defdemoname)
p = buffer;
}
// load demo resource from WAD
else if ((l = W_CheckNumForName(defdemoname)) == LUMPERROR)
else if ((l = W_CheckNumForLongName(defdemoname)) == LUMPERROR)
{
CONS_Alert(CONS_ERROR, M_GetText("Failed to read lump '%s'.\n"), defdemoname);
Z_Free(pdemoname);
@ -3799,7 +3801,7 @@ void G_DoPlayMetal(void)
// it's an internal demo
// TODO: Use map header to determine lump name
if ((l = W_CheckNumForName(va("%sMS",G_BuildMapName(gamemap)))) == LUMPERROR)
if ((l = W_CheckNumForLongName(va("%sMS",G_BuildMapName(gamemap)))) == LUMPERROR)
{
CONS_Alert(CONS_WARNING, M_GetText("No bot recording for this map.\n"));
return;

View file

@ -179,9 +179,9 @@ extern demoghost *ghosts;
#define DFILE_ERROR_EXTRAFILES 0x05 // Extra files outside of the replay's file list are loaded.
void G_DeferedPlayDemo(const char *demo);
void G_DoPlayDemo(char *defdemoname);
void G_DoPlayDemo(const char *defdemoname);
void G_TimeDemo(const char *name);
void G_AddGhost(char *defdemoname);
void G_AddGhost(const char *defdemoname);
void G_UpdateStaffGhostName(lumpnum_t l);
void G_FreeGhosts(void);
void G_DoneLevelLoad(void);

View file

@ -1210,7 +1210,7 @@ void HWR_InitLight(void)
lspr[i].dynamic_sqrradius = lspr[i].dynamic_radius*lspr[i].dynamic_radius;
lightmappatch.mipmap->downloaded = false;
coronalumpnum = W_CheckNumForName("CORONA");
coronalumpnum = W_CheckNumForLongName("CORONA");
}
// -----------------+

View file

@ -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;
@ -6494,7 +6494,7 @@ static lumpnum_t wipelumpnum;
// puts wipe lumpname in wipename[9]
static boolean HWR_WipeCheck(UINT8 wipenum, UINT8 scrnnum)
{
static char lumpname[9] = "FADEmmss";
static char lumpname[SHORTNAMELEN+1] = "FADEmmss";
size_t lsize;
// not a valid wipe number
@ -6506,7 +6506,7 @@ static boolean HWR_WipeCheck(UINT8 wipenum, UINT8 scrnnum)
lumpname[5] = '0'+(wipenum%10);
lumpname[6] = '0'+(scrnnum/10);
lumpname[7] = '0'+(scrnnum%10);
wipelumpnum = W_CheckNumForName(lumpname);
wipelumpnum = W_CheckNumForLongName(lumpname);
// again, shouldn't be here really
if (wipelumpnum == LUMPERROR)
@ -6552,19 +6552,6 @@ void HWR_DrawScreenFinalTexture(int width, int height)
HWD.pfnDrawScreenFinalTexture(width, height);
}
static inline UINT16 HWR_FindShaderDefs(UINT16 wadnum)
{
UINT16 i;
lumpinfo_t *lump_p;
lump_p = wadfiles[wadnum]->lumpinfo;
for (i = 0; i < wadfiles[wadnum]->numlumps; i++, lump_p++)
if (memcmp(lump_p->name, "SHADERS", 7) == 0)
return i;
return INT16_MAX;
}
boolean HWR_CompileShaders(void)
{
return HWD.pfnCompileShaders();
@ -6603,8 +6590,8 @@ void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3)
int shadertype = 0;
int i;
lump = HWR_FindShaderDefs(wadnum);
if (lump == INT16_MAX)
lump = W_CheckNumForLongNamePwad("SHADERS", wadnum, 0);
if (lump == LUMPERROR)
return;
shaderdef = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE);
@ -6671,23 +6658,19 @@ skip_lump:
if (PK3)
{
shader_lumpname = Z_Malloc(strlen(value) + 12, PU_STATIC, NULL);
strcpy(shader_lumpname, "Shaders/sh_");
strcat(shader_lumpname, value);
shader_lumpname = xva("Shaders/sh_%s", value);
shader_lumpnum = W_CheckNumForFullNamePK3(shader_lumpname, wadnum, 0);
}
else
{
shader_lumpname = Z_Malloc(strlen(value) + 4, PU_STATIC, NULL);
strcpy(shader_lumpname, "SH_");
strcat(shader_lumpname, value);
shader_lumpnum = W_CheckNumForNamePwad(shader_lumpname, wadnum, 0);
shader_lumpname = xva("SH_%.5s", value);
shader_lumpnum = W_CheckNumForLongNamePwad(shader_lumpname, wadnum, 0);
}
if (shader_lumpnum == INT16_MAX)
if (shader_lumpnum == LUMPERROR)
{
CONS_Alert(CONS_ERROR, "HWR_LoadCustomShadersFromFile: Missing shader source %s (file %s, line %d)\n", shader_lumpname, wadfiles[wadnum]->filename, linenum);
Z_Free(shader_lumpname);
free(shader_lumpname);
continue;
}
@ -6698,7 +6681,7 @@ skip_lump:
HWD.pfnLoadCustomShader(shaderxlat[i].id, shader_source, shader_size, (shadertype == 2));
Z_Free(shader_source);
Z_Free(shader_lumpname);
free(shader_lumpname);
}
}

View file

@ -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.");
@ -310,23 +310,23 @@ void HU_Init(void)
patch_t *HU_UpdateOrBlankPatch(patch_t **user, boolean required, const char *format, ...)
{
va_list ap;
char buffer[9];
char buffer[SHORTNAMELEN+1];
lumpnum_t lump = INT16_MAX;
lumpnum_t lump = LUMPERROR;
patch_t *patch;
va_start (ap, format);
vsnprintf(buffer, sizeof buffer, format, ap);
va_end (ap);
if (user && partadd_earliestfile != UINT16_MAX)
if (user && partadd_earliestfile != MAX_WADFILES)
{
UINT16 fileref = numwadfiles;
lump = INT16_MAX;
lump = LUMPERROR;
while ((lump == INT16_MAX) && ((--fileref) >= partadd_earliestfile))
while ((lump == LUMPERROR) && ((--fileref) >= partadd_earliestfile))
{
lump = W_CheckNumForNamePwad(buffer, fileref, 0);
lump = W_CheckNumForLongNamePwad(buffer, fileref, 0);
}
/* no update in this wad */
@ -339,7 +339,7 @@ patch_t *HU_UpdateOrBlankPatch(patch_t **user, boolean required, const char *for
}
else
{
lump = W_CheckNumForName(buffer);
lump = W_CheckNumForLongName(buffer);
if (lump == LUMPERROR)
{

View file

@ -158,7 +158,7 @@ void P_ResetData(INT32 flags)
if (!init)
{
lumpnum = W_CheckNumForLongNamePwadNoUpper("states", MAINWAD_MAIN, 0);
lumpnum = W_CheckNumForLongNamePwad("STATES", MAINWAD_MAIN, 0);
DEH_LoadDehackedLumpPwad(MAINWAD_MAIN, lumpnum, true);
}
}
@ -183,7 +183,7 @@ void P_ResetData(INT32 flags)
if (!init)
{
lumpnum = W_CheckNumForLongNamePwadNoUpper("mobjs", MAINWAD_MAIN, 0);
lumpnum = W_CheckNumForLongNamePwad("MOBJS", MAINWAD_MAIN, 0);
DEH_LoadDehackedLumpPwad(MAINWAD_MAIN, lumpnum, true);
}
}
@ -211,7 +211,7 @@ void P_ResetData(INT32 flags)
if (!init)
{
lumpnum = W_CheckNumForLongNamePwadNoUpper("skincolors", MAINWAD_MAIN, 0);
lumpnum = W_CheckNumForLongNamePwad("SKINCOLORS", MAINWAD_MAIN, 0);
DEH_LoadDehackedLumpPwad(MAINWAD_MAIN, lumpnum, true);
}
}

View file

@ -166,11 +166,11 @@ static boolean K_BRIGHTLumpParser(char *data, size_t size)
}
/*--------------------------------------------------
void K_InitBrightmapsPwad(INT32 wadNum)
void K_InitBrightmapsPwad(UINT16 wadNum)
See header file for description.
--------------------------------------------------*/
void K_InitBrightmapsPwad(INT32 wadNum)
void K_InitBrightmapsPwad(UINT16 wadNum)
{
UINT16 lumpNum;
size_t i;
@ -178,27 +178,18 @@ void K_InitBrightmapsPwad(INT32 wadNum)
I_Assert(brightmapStorage == NULL);
// Find BRIGHT lump in the WAD
lumpNum = W_CheckNumForNamePwad("BRIGHT", wadNum, 0);
while (lumpNum != INT16_MAX)
for (lumpNum = 0; (lumpNum = W_CheckNumForLongNamePwad("BRIGHT", wadNum, lumpNum)) != LUMPERROR; lumpNum++)
{
UINT8 *data = (UINT8 *)W_CacheLumpNumPwad(wadNum, lumpNum, PU_CACHE);
UINT8 *data = (UINT8 *)W_CacheLumpNumPwad(wadNum, lumpNum, PU_STATIC);
if (data != NULL)
{
lumpinfo_t *lump_p = &wadfiles[wadNum]->lumpinfo[lumpNum];
size_t size = W_LumpLengthPwad(wadNum, lumpNum);
char *datacopy;
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';
size = W_LumpLengthPwad(wadNum, lumpNum);
CONS_Printf(M_GetText("Loading BRIGHT from %s\n"), name);
CONS_Printf(M_GetText("Loading BRIGHT from %s|%s\n"), wadfiles[wadNum]->filename, W_CheckFullNameForNumPwad(wadNum, lumpNum));
datacopy = (char *)Z_Malloc((size+1)*sizeof(char),PU_STATIC,NULL);
memmove(datacopy,data,size);
@ -209,11 +200,7 @@ void K_InitBrightmapsPwad(INT32 wadNum)
K_BRIGHTLumpParser(datacopy, size);
Z_Free(datacopy);
free(name);
}
lumpNum = W_CheckNumForNamePwad("BRIGHT", (UINT16)wadNum, lumpNum + 1);
}
if (maxBrightmapStorage == 0)
@ -256,7 +243,7 @@ void K_InitBrightmapsPwad(INT32 wadNum)
--------------------------------------------------*/
void K_InitBrightmaps(void)
{
INT32 wadNum;
UINT16 wadNum;
for (wadNum = 0; wadNum < numwadfiles; wadNum++)
{

View file

@ -35,12 +35,12 @@ struct brightmapStorage_t
};
/*--------------------------------------------------
void K_InitBrightmapsPwad(INT32 wadNum);
void K_InitBrightmapsPwad(UINT16 wadNum);
Finds all BRIGHT lumps for one WAD/PK3 and processes them.
--------------------------------------------------*/
void K_InitBrightmapsPwad(INT32 wadNum);
void K_InitBrightmapsPwad(UINT16 wadNum);
/*--------------------------------------------------
void K_InitBrightmaps(void);

View file

@ -386,7 +386,7 @@ void K_LoadKartHUDGraphics(void)
for (size_t m = 0; m < sizeof(patchNames) / sizeof(patchNames[0]); ++m)
{
kp_kartzspeedo[m] = W_CachePatchName(patchNames[m], PU_HUDGFX);
kp_kartzspeedo[m] = W_CachePatchLongName(patchNames[m], PU_HUDGFX);
}
}
@ -1541,7 +1541,7 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI
if (emblem->collected)
{
emblempic[curemb] = W_CachePatchName(M_GetEmblemPatch(emblem, false), PU_CACHE);
emblempic[curemb] = W_CachePatchLongName(M_GetEmblemPatch(emblem, false), PU_CACHE);
emblemcol[curemb] = R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE);
if (++curemb == 3)
break;
@ -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;
@ -2608,7 +2608,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())
@ -4932,8 +4932,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
{

View file

@ -2261,22 +2261,14 @@ static boolean K_TERRAINLumpParser(char *data, size_t size)
boolean K_InitTerrainPwad(UINT16 wadNum)
{
UINT16 lumpNum;
lumpinfo_t *lump_p = wadfiles[wadNum]->lumpinfo;
boolean terrainLoaded = false;
// Iterate through all lumps and compare the name individually.
// In PK3 files, you can potentially have multiple TERRAIN differentiated by
// their file extension.
for (lumpNum = 0; lumpNum < wadfiles[wadNum]->numlumps; lumpNum++, lump_p++)
for (lumpNum = 0; (lumpNum = W_CheckNumForLongNamePwad("TERRAIN", wadNum, lumpNum)) != LUMPERROR; lumpNum++)
{
UINT8 *data;
if (memcmp(lump_p->name, "TERRAIN", 8) != 0)
{
continue;
}
data = (UINT8 *)W_CacheLumpNumPwad(wadNum, lumpNum, PU_STATIC);
UINT8 *data = (UINT8 *)W_CacheLumpNumPwad(wadNum, lumpNum, PU_STATIC);
// If that didn't exist, we have nothing to do here.
if (data == NULL)
@ -2288,17 +2280,10 @@ boolean K_InitTerrainPwad(UINT16 wadNum)
size_t size = W_LumpLengthPwad(wadNum, lumpNum);
char *datacopy;
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';
size = W_LumpLengthPwad(wadNum, lumpNum);
CONS_Printf(M_GetText("Loading TERRAIN from %s\n"), name);
CONS_Printf(M_GetText("Loading TERRAIN from %s|%s\n"), wadfiles[wadNum]->filename, W_CheckFullNameForNumPwad(wadNum, lumpNum));
terrainLoaded = true;
datacopy = (char *)Z_Malloc((size+1)*sizeof(char),PU_STATIC,NULL);
memmove(datacopy,data,size);
@ -2309,8 +2294,6 @@ boolean K_InitTerrainPwad(UINT16 wadNum)
K_TERRAINLumpParser(datacopy, size);
Z_Free(datacopy);
free(name);
}
}

View file

@ -710,7 +710,6 @@ void LUA_LoadLump(UINT16 wad, UINT16 lump, boolean noresults)
{
MYFILE f;
char *name;
size_t len;
if (M_CheckParm("-nolua"))
{
@ -723,21 +722,10 @@ void LUA_LoadLump(UINT16 wad, UINT16 lump, boolean noresults)
W_ReadLumpPwad(wad, lump, f.data);
f.curpos = f.data;
len = strlen(wadfiles[wad]->filename); // length of file name
if (wadfiles[wad]->type == RET_LUA)
{
name = malloc(len+1);
strcpy(name, wadfiles[wad]->filename);
}
name = xva("%s", wadfiles[wad]->filename);
else // If it's not a .lua file, copy the lump name in too.
{
lumpinfo_t *lump_p = &wadfiles[wad]->lumpinfo[lump];
len += 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name
name = malloc(len+1);
sprintf(name, "%s|%s", wadfiles[wad]->filename, lump_p->fullname);
name[len] = '\0';
}
name = xva("%s|%s", wadfiles[wad]->filename, W_CheckFullNameForNumPwad(wad, lump));
lua_compatmode = wadfiles[wad]->compatmode;

View file

@ -378,7 +378,7 @@ consvar_t cv_dummymenuplayer = CVAR_INIT ("dummymenuplayer", "P1", CV_HIDEN|CV_C
consvar_t cv_dummyteam = CVAR_INIT ("dummyteam", "Spectator", CV_HIDEN, dummyteam_cons_t, NULL);
consvar_t cv_dummyspectate = CVAR_INIT ("dummyspectate", "Spectator", CV_HIDEN, dummyspectate_cons_t, NULL);
consvar_t cv_dummyscramble = CVAR_INIT ("dummyscramble", "Random", CV_HIDEN, dummyscramble_cons_t, NULL);
consvar_t cv_dummystaff = CVAR_INIT ("dummystaff", "0", CV_HIDEN|CV_CALL, dummystaff_cons_t, Dummystaff_OnChange);
consvar_t cv_dummystaff = CVAR_INIT ("dummystaff", "0", CV_HIDEN|CV_CALL|CV_NOINIT, dummystaff_cons_t, Dummystaff_OnChange);
consvar_t cv_dummyattackingrings = CVAR_INIT ("dummyattackingrings", "Off", CV_HIDEN|CV_CALL|CV_NOINIT, CV_OnOff, Nextmap_OnChange);
consvar_t cv_dummyattackingstacking = CVAR_INIT ("dummyattackingstacking", "Off", CV_HIDEN|CV_CALL|CV_NOINIT, CV_OnOff, Nextmap_OnChange);
@ -826,7 +826,7 @@ void M_SetMenuCurBackground(void)
}
else if (menudefs[menutype].bgname[0])
{
strncpy(curbgname, menudefs[menutype].bgname, 8);
strcpy(curbgname, menudefs[menutype].bgname);
curbgxspeed = menudefs[menutype].titlescrollxspeed != INT32_MAX ? menudefs[menutype].titlescrollxspeed : titlescrollxspeed;
curbgyspeed = menudefs[menutype].titlescrollyspeed != INT32_MAX ? menudefs[menutype].titlescrollyspeed : titlescrollyspeed;
return;
@ -836,7 +836,7 @@ void M_SetMenuCurBackground(void)
curbghide = true;
else
{
strncpy(curbgname, "TITLESKY", 9);
strcpy(curbgname, "TITLESKY");
curbgxspeed = titlescrollxspeed;
curbgyspeed = titlescrollyspeed;
}
@ -905,7 +905,7 @@ void M_SetMenuCurTitlePics(void)
curhidepics = menudefs[menutype].hidetitlepics;
curttmode = menudefs[menutype].ttmode;
curttscale = (menudefs[menutype].ttscale != UINT8_MAX ? menudefs[menutype].ttscale : ttscale);
strncpy(curttname, menudefs[menutype].ttname, sizeof(curttname)-1);
strcpy(curttname, menudefs[menutype].ttname);
curttx = (menudefs[menutype].ttx != INT16_MAX ? menudefs[menutype].ttx : ttx);
curtty = (menudefs[menutype].tty != INT16_MAX ? menudefs[menutype].tty : tty);
curttloop = (menudefs[menutype].ttloop != INT16_MAX ? menudefs[menutype].ttloop : ttloop);
@ -927,7 +927,7 @@ void M_SetMenuCurTitlePics(void)
curhidepics = hidetitlepics;
curttmode = ttmode;
curttscale = ttscale;
strncpy(curttname, ttname, 9);
strcpy(curttname, ttname);
curttx = ttx;
curtty = tty;
curttloop = ttloop;
@ -2226,10 +2226,10 @@ static void M_DrawMapEmblems(INT32 mapnum, INT32 x, INT32 y)
lasttype = curtype;
if (emblem->collected)
V_DrawSmallMappedPatch(x, y, 0, W_CachePatchName(M_GetEmblemPatch(emblem, false), PU_CACHE),
V_DrawSmallMappedPatch(x, y, 0, W_CachePatchLongName(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;
@ -2240,7 +2240,7 @@ static void M_DrawMenuTitle(void)
{
if (currentMenu->headerpic)
{
patch_t *p = W_CachePatchName(currentMenu->headerpic, PU_CACHE);
patch_t *p = W_CachePatchLongName(currentMenu->headerpic, PU_CACHE);
if (p->height > 24) // title is larger than normal
{
@ -2273,7 +2273,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)
@ -2318,14 +2318,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);
@ -2435,7 +2435,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);
@ -2513,7 +2513,7 @@ static INT32 M_DrawMenuItem(menuitem_t *item, INT16 x, INT16 y, INT32 vflags, bo
if (!item->patch)
return 0;
p = W_CachePatchName(item->patch, PU_CACHE);
p = W_CachePatchLongName(item->patch, PU_CACHE);
break;
}
}
@ -2692,7 +2692,7 @@ void MD_DrawGenericMenu(void)
// DRAW THE SKULL CURSOR
if (M_ItemSelectable(&currentMenu->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)
@ -3195,23 +3195,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;
}
@ -3906,7 +3906,7 @@ static void DrawReplayHutReplayInfo(void)
{
static angle_t rubyfloattime = 0;
const fixed_t rubyheight = FINESINE(rubyfloattime>>ANGLETOFINESHIFT);
V_DrawFixedPatch((x+(w>>2))<<FRACBITS, ((y+(h>>2))<<FRACBITS) - (rubyheight<<1), FRACUNIT, V_SNAPTOTOP, W_CachePatchName("RUBYICON", PU_CACHE), NULL);
V_DrawFixedPatch((x+(w>>2))<<FRACBITS, ((y+(h>>2))<<FRACBITS) - (rubyheight<<1), FRACUNIT, V_SNAPTOTOP, W_CachePatchLongName("RUBYICON", PU_CACHE), NULL);
rubyfloattime += FixedMul(ANGLE_MAX/NEWTICRATE, renderdeltatics);
}
}
@ -3967,7 +3967,7 @@ static void DrawReplayHutReplayInfo(void)
}
else
{
patch = W_CachePatchName("M_NOWANT", PU_CACHE);
patch = W_CachePatchLongName("M_NOWANT", PU_CACHE);
colormap = R_GetTranslationColormap(
TC_RAINBOW,
demolist[dir_on[menudepthleft]].standings[0].color,
@ -4029,7 +4029,7 @@ void MD_DrawReplayHut(void)
if (demolist[i].type == MD_SUBDIR)
{
localx += 8;
V_DrawScaledPatch(x - 4, localy, V_SNAPTOTOP|V_SNAPTOLEFT, W_CachePatchName(dirmenu[i][DIR_TYPE] == EXT_UP ? "M_RBACK" : "M_RFLDR", PU_CACHE));
V_DrawScaledPatch(x - 4, localy, V_SNAPTOTOP|V_SNAPTOLEFT, W_CachePatchLongName(dirmenu[i][DIR_TYPE] == EXT_UP ? "M_RBACK" : "M_RFLDR", PU_CACHE));
}
if (i == (INT16)dir_on[menudepthleft])
@ -4075,7 +4075,7 @@ void MD_DrawReplayHut(void)
// Draw the cursor
V_DrawScaledPatch(currentMenu->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);
@ -4126,7 +4126,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,
@ -4306,17 +4306,17 @@ void MD_DrawPlaybackMenu(void)
if (i != itemOn)
inactivemap = R_GetTranslationColormap(players[ply].skin, players[ply].skincolor, GTC_MENUCACHE);
}
else if (currentMenu->menuitems[i].patch && W_CheckNumForName(currentMenu->menuitems[i].patch) != LUMPERROR)
icon = W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE);
else if (currentMenu->menuitems[i].patch && W_CheckNumForLongName(currentMenu->menuitems[i].patch) != LUMPERROR)
icon = W_CachePatchLongName(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 if (currentMenu->menuitems[i].patch && W_CheckNumForLongName(currentMenu->menuitems[i].patch) != LUMPERROR)
icon = W_CachePatchLongName(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));
@ -5255,7 +5255,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),
@ -5326,10 +5326,10 @@ static void M_DrawStatsMaps(void)
exemblem = &extraemblems[i];
if (exemblem->collected)
V_DrawSmallMappedPatch(295, y, 0, W_CachePatchName(M_GetExtraEmblemPatch(exemblem, false), PU_CACHE),
V_DrawSmallMappedPatch(295, y, 0, W_CachePatchLongName(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));
}
@ -5718,7 +5718,7 @@ INT32 MR_ChooseTimeAttack(INT32 choice)
INT32 MR_ReplayStaff(INT32 choice)
{
(void)choice;
lumpnum_t l = W_CheckNumForName(va("%sS%02u",G_BuildMapName(cv_nextmap.value),cv_dummystaff.value));
lumpnum_t l = W_CheckNumForLongName(va("%sS%02u",G_BuildMapName(cv_nextmap.value),cv_dummystaff.value));
if (l == LUMPERROR)
return false;
@ -6479,7 +6479,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)<<FRACBITS, ((y+i/2)<<FRACBITS) - (rubyheight<<1), FRACUNIT, 0, W_CachePatchName("RUBYICON", PU_CACHE), NULL);
V_DrawFixedPatch((x+w/2)<<FRACBITS, ((y+i/2)<<FRACBITS) - (rubyheight<<1), FRACUNIT, 0, W_CachePatchLongName("RUBYICON", PU_CACHE), NULL);
rubyfloattime += FixedMul(ANGLE_MAX/NEWTICRATE, renderdeltatics);
}
}
@ -6615,7 +6615,7 @@ void MD_DrawMPMainMenu(void)
cursorframe += renderdeltatics / 4;
for (; cursorframe > 7 * FRACUNIT; cursorframe -= 7 * FRACUNIT) {}
V_DrawFixedPatch(x<<FRACBITS, y<<FRACBITS, FRACUNIT, 0, W_CachePatchName(va("K_BHILI%d", (cursorframe >> FRACBITS) + 1), PU_CACHE), NULL);
V_DrawFixedPatch(x<<FRACBITS, y<<FRACBITS, FRACUNIT, 0, W_CachePatchLongName(va("K_BHILI%d", (cursorframe >> FRACBITS) + 1), PU_CACHE), NULL);
}
x += incrwidth;
@ -6685,7 +6685,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;
@ -6715,13 +6715,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))<<FRACBITS, ((my+76) + ((weight-1)*8))<<FRACBITS, FRACUNIT, 0, statdot, flashcol);
else
V_DrawFixedPatch(((BASEVIDWIDTH - mx - 80) + ((speed-1)*8))<<FRACBITS, ((my+76) + ((weight-1)*8))<<FRACBITS, FRACUNIT, 0, statdot, NULL);
statdot = W_CachePatchName("K_SDOT2", PU_CACHE); // coloured center
statdot = W_CachePatchLongName("K_SDOT2", PU_CACHE); // coloured center
V_DrawFixedPatch(((BASEVIDWIDTH - mx - 80) + ((speed-1)*8))<<FRACBITS, ((my+76) + ((weight-1)*8))<<FRACBITS, FRACUNIT, 0, statdot, R_GetTranslationColormap(0, cv_dummycolor.value, GTC_MENUCACHE));
// 2.2 color bar backported with permission
@ -6786,7 +6786,7 @@ void MD_DrawSetupMultiPlayerMenu(void)
cursorframe += renderdeltatics / 4;
for (; cursorframe > 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;
@ -7669,7 +7669,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
@ -7812,14 +7812,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;
}
@ -7849,18 +7849,18 @@ 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, translucent, W_CachePatchName(K_GetItemPatch(currentMenu->menuitems[thisitem].argument, true), PU_CACHE));
V_DrawScaledPatch(x, y, 0, W_CachePatchLongName("K_ISMUL", PU_CACHE));
V_DrawScaledPatch(x, y, translucent, W_CachePatchLongName(K_GetItemPatch(currentMenu->menuitems[thisitem].argument, true), PU_CACHE));
V_DrawString(x+24, y+31, V_ALLOWLOWERCASE|translucent, va("x%d", drawnum));
}
else
V_DrawScaledPatch(x, y, translucent, W_CachePatchName(K_GetItemPatch(currentMenu->menuitems[thisitem].argument, true), PU_CACHE));
V_DrawScaledPatch(x, y, translucent, W_CachePatchLongName(K_GetItemPatch(currentMenu->menuitems[thisitem].argument, true), PU_CACHE));
y += spacing;
}
@ -7873,7 +7873,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;
@ -7881,15 +7881,15 @@ void MD_DrawMonitorToggles(void)
trans = ((10-TICRATE)+shitsfree-1)<<V_ALPHASHIFT;
else if (shitsfree < 5)
trans = (10-shitsfree)<<V_ALPHASHIFT;
V_DrawScaledPatch(onx-1, ony-2, trans, W_CachePatchName("K_ITFREE", PU_CACHE));
V_DrawScaledPatch(onx-1, ony-2, trans, W_CachePatchLongName("K_ITFREE", PU_CACHE));
}
}
else
#endif
if (currentMenu->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
{
@ -7907,19 +7907,19 @@ 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, 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-1, ony-2, 0, W_CachePatchLongName("K_ITMUL", PU_CACHE));
V_DrawScaledPatch(onx-1, ony-2, translucent, W_CachePatchLongName(K_GetItemPatch(currentMenu->menuitems[itemOn].argument, false), 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
V_DrawScaledPatch(onx-1, ony-2, translucent, W_CachePatchName(K_GetItemPatch(currentMenu->menuitems[itemOn].argument, false), PU_CACHE));
V_DrawScaledPatch(onx-1, ony-2, translucent, W_CachePatchLongName(K_GetItemPatch(currentMenu->menuitems[itemOn].argument, false), PU_CACHE));
}
}
@ -8406,7 +8406,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);
@ -8481,12 +8481,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;
}
@ -8513,12 +8513,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;
@ -8533,7 +8533,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)
{

View file

@ -190,6 +190,8 @@ struct menuitem_t
INT16 x, y; // coordinates, see menuitemflags
};
#define SHORTNAMELEN 8
struct menu_t
{
dehinfo_t info;
@ -208,7 +210,7 @@ struct menu_t
// MENUPRES STUFF BELOW
char bgname[8]; // name for background gfx lump; lays over titlemap if this is set
char bgname[SHORTNAMELEN+1]; // name for background gfx lump; lays over titlemap if this is set
SINT8 fadestrength; // darken background when displaying this menu, strength 0-31 or -1 for undefined
INT32 bgcolor; // fill color, overrides bg name. -1 means follow bg name rules.
INT32 titlescrollxspeed; // background gfx scroll per menu; inherits global setting
@ -218,7 +220,7 @@ struct menu_t
SINT8 hidetitlepics; // hide title gfx per menu; -1 means undefined, inherits global setting
ttmode_enum ttmode; // title wing animation mode; default TTMODE_KART
UINT8 ttscale; // scale of title wing gfx (FRACUNIT / ttscale); -1 means undefined, inherits global setting
char ttname[9]; // lump name of title wing gfx. If name length is <= 6, engine will attempt to load numbered frames (TTNAMExx)
char ttname[SHORTNAMELEN+1]; // lump name of title wing gfx. If name length is <= 6, engine will attempt to load numbered frames (TTNAMExx)
INT16 ttx; // X position of title wing
INT16 tty; // Y position of title wing
INT16 ttloop; // # frame to loop; -1 means dont loop

View file

@ -198,7 +198,7 @@ static SINT8 partadd_stage = -1;
static boolean partadd_replacescurrentmap = false;
static boolean partadd_terrainloaded = false;
static boolean partadd_important = false;
UINT16 partadd_earliestfile = UINT16_MAX;
UINT16 partadd_earliestfile = MAX_WADFILES;
// Maintain *ZOOM TUBE* waypoints
// Renamed because SRB2Kart owns real waypoints.
@ -8106,13 +8106,11 @@ static void P_RunLevelScript(const char *scriptname)
if (!(mapheaderinfo[gamemap-1]->levelflags & LF_SCRIPTISFILE))
{
lumpnum_t lumpnum;
char newname[9];
char newname[SHORTNAMELEN+1];
strncpy(newname, scriptname, 8);
strlcpy(newname, scriptname, sizeof(newname));
newname[8] = '\0';
lumpnum = W_CheckNumForName(newname);
lumpnum = W_CheckNumForLongName(newname);
if (lumpnum == LUMPERROR || W_LumpLength(lumpnum) == 0)
{
@ -9019,7 +9017,7 @@ boolean P_RunSOC(const char *socfilename)
if (strstr(socfilename, ".soc") != NULL)
return P_AddWadFile(socfilename, WC_AUTO);
lump = W_CheckNumForName(socfilename);
lump = W_CheckNumForLongName(socfilename);
if (lump == LUMPERROR)
return false;
@ -9031,22 +9029,34 @@ boolean P_RunSOC(const char *socfilename)
// Auxiliary function for PK3 loading - looks for sound replacements.
// NOTE: it does not really add any new sound entry or anything.
void P_LoadSoundsRange(UINT16 wadnum, UINT16 first, UINT16 num)
static void P_LoadSoundsRange(UINT16 wadnum, size_t *sreplaces)
{
size_t j;
lumpinfo_t *lumpinfo = wadfiles[wadnum]->lumpinfo + first;
for (; num > 0; num--, lumpinfo++)
sfxenum_t j;
UINT16 i, end;
if (!W_CheckNumForMarkers((const char *[]){"Sounds/"}, 1, wadnum, &i, &end))
return;
for (; i < end; i++)
{
// Let's check whether it's replacing an existing sound or it's a brand new one.
const char *name = W_CheckNameForNumPwad(wadnum, i);
if (name[0] != 'D' || name[1] != 'S')
continue;
for (j = 1; j < NUMSFX; j++)
{
if (S_sfx[j].name && !strnicmp(S_sfx[j].name, lumpinfo->name + 2, 6))
if (S_sfx[j].name && !strnicmp(S_sfx[j].name, name + 2, 6))
{
// the sound will be reloaded when needed,
// since sfx->data will be NULL
CONS_Debug(DBG_SETUP, "Sound %.8s replaced\n", lumpinfo->name);
CONS_Debug(DBG_SETUP, "Sound %.8s replaced\n", name);
I_FreeSfx(&S_sfx[j]);
// Re-cache it
//if (S_PrecacheSound())
//S_sfx[j].data = I_GetSfx(&S_sfx[j]);
*sreplaces += 1;
break; // there shouldn't be two sounds with the same name, so stop looking
}
}
@ -9055,44 +9065,26 @@ void P_LoadSoundsRange(UINT16 wadnum, UINT16 first, UINT16 num)
// Auxiliary function for PK3 loading - looks for music and music replacements.
// NOTE: does nothing but print debug messages. The code is handled somewhere else.
void P_LoadMusicsRange(UINT16 wadnum, UINT16 first, UINT16 num)
static void P_LoadMusicsRange(UINT16 wadnum, size_t *digmreplaces, size_t *mreplaces)
{
lumpinfo_t *lumpinfo = wadfiles[wadnum]->lumpinfo + first;
char *name;
for (; num > 0; num--, lumpinfo++)
UINT16 i, end;
if (!W_CheckNumForMarkers((const char *[]){"Music/"}, 1, wadnum, &i, &end))
return;
for (; i < end; i++)
{
name = lumpinfo->name;
const char *name = W_CheckNameForNumPwad(wadnum, i);
if (name[0] == 'O' && name[1] == '_')
{
CONS_Debug(DBG_SETUP, "Music %.8s replaced\n", name);
*digmreplaces += 1;
}
else if (name[0] == 'D' && name[1] == '_')
{
CONS_Debug(DBG_SETUP, "Music %.8s replaced\n", name);
CONS_Debug(DBG_SETUP, "Music %.8s ignored\n", name);
*mreplaces += 1;
}
}
return;
}
// Auxiliary function - input a folder name and gives us the resource markers positions.
static lumpinfo_t* FindFolder(const char *folName, UINT16 *start, UINT16 *end, lumpinfo_t *lumpinfo, UINT16 *pnumlumps, size_t *pi)
{
UINT16 numlumps = *pnumlumps;
size_t i = *pi;
if (!stricmp(lumpinfo->fullname, folName))
{
lumpinfo++;
*start = ++i;
for (; i < numlumps; i++, lumpinfo++)
if (strnicmp(lumpinfo->fullname, folName, strlen(folName)))
break;
lumpinfo--;
*end = i-- - *start;
*pi = i;
*pnumlumps = numlumps;
return lumpinfo;
}
return lumpinfo;
}
lumpnum_t wadnamelump = LUMPERROR;
@ -9115,7 +9107,7 @@ UINT8 P_InitMapData(boolean existingmapheaders)
maplump = W_CheckNumForMap(name);
// Doesn't exist?
if (maplump == INT16_MAX)
if (maplump == LUMPERROR)
{
#ifndef DEVELOP
if (!existingmapheaders)
@ -9210,7 +9202,7 @@ UINT8 P_InitMapData(boolean existingmapheaders)
// okay... try finding them the old-fashioned way
else
{
oldPic = W_CachePatchName(va("%sP", name), PU_STATIC);
oldPic = W_CachePatchLongName(va("%sP", name), PU_STATIC);
if (oldPic != missingpat)
mapheaderinfo[i]->thumbnailPic = oldPic;
}
@ -9221,7 +9213,7 @@ UINT8 P_InitMapData(boolean existingmapheaders)
}
else
{
oldPic = W_CachePatchName(va("%sR", name), PU_STATIC);
oldPic = W_CachePatchLongName(va("%sR", name), PU_STATIC);
if (oldPic != missingpat)
mapheaderinfo[i]->minimapPic = oldPic;
}
@ -9241,98 +9233,40 @@ boolean P_AddWadFile(const char *wadfilename, wadcompat_t compat)
{
UINT16 wadnum;
if ((wadnum = P_PartialAddWadFile(wadfilename, compat)) == UINT16_MAX)
if ((wadnum = P_PartialAddWadFile(wadfilename, compat)) == MAX_WADFILES)
return false;
P_MultiSetupWadFiles(true);
return true;
}
static size_t sreplaces = 0, mreplaces = 0, digmreplaces = 0;
//
// search for sound replacements
//
static boolean P_CheckSoundReplacements(char *name, size_t i)
{
if (name[0] == 'D')
{
if (name[1] == 'S')
{
for (i = 1; i < NUMSFX; i++)
{
if (S_sfx[i].name && !strnicmp(S_sfx[i].name, name + 2, 6))
{
// the sound will be reloaded when needed,
// since sfx->data will be NULL
CONS_Debug(DBG_SETUP, "Sound %.8s replaced\n", name);
I_FreeSfx(&S_sfx[i]);
// Re-cache it
//if (S_PrecacheSound())
//S_sfx[j].data = I_GetSfx(&S_sfx[j]);
sreplaces++;
return true;
}
}
}
else if (name[1] == '_')
{
CONS_Debug(DBG_SETUP, "Music %.8s ignored\n", name);
mreplaces++;
return true;
}
}
else if (name[0] == 'O' && name[1] == '_')
{
CONS_Debug(DBG_SETUP, "Music %.8s replaced\n", name);
digmreplaces++;
return true;
}
return false;
}
//
// check for non Lua votescreen replacements
//
static boolean P_CheckVoteReplacements(char *name)
static boolean P_CheckVoteReplacements(UINT16 wad)
{
// widescreen patch Race
if (!VoteScreen.replaced.widerace && !memcmp(name, "INTERSCW", 8))
UINT16 i;
for (i = 0; i < wadfiles[wad]->numlumps; i++)
{
VoteScreen.replaced.widerace = true;
return false;
const char *name = W_CheckNameForNumPwad(wad, i);
// widescreen patch Race
if (!VoteScreen.replaced.widerace && !strncmp(name, "INTERSCW", 8))
VoteScreen.replaced.widerace = true;
if (!VoteScreen.replaced.race && !strncmp(name, "INTERSCR", 8))
VoteScreen.replaced.race = true;
// widescreen patch Battle
if (!VoteScreen.replaced.widebattle && !strncmp(name, "BATTLSCW", 8))
VoteScreen.replaced.widebattle = true;
if (!VoteScreen.replaced.battle && !strncmp(name, "BATTLSCR", 8))
VoteScreen.replaced.battle = true;
}
if (!VoteScreen.replaced.race && !memcmp(name, "INTERSCR", 8))
{
VoteScreen.replaced.race = true;
return false;
}
// widescreen patch Battle
if (!VoteScreen.replaced.widebattle && !memcmp(name, "BATTLSCW", 8))
{
VoteScreen.replaced.widebattle = true;
return false;
}
if (!VoteScreen.replaced.battle && !memcmp(name, "BATTLSCR", 8))
{
VoteScreen.replaced.battle = true;
return false;
}
if (VoteScreen.replaced.widerace && VoteScreen.replaced.race
&& VoteScreen.replaced.widebattle && VoteScreen.replaced.battle)
{
return true;
}
return false;
return VoteScreen.replaced.widerace && VoteScreen.replaced.race
&& VoteScreen.replaced.widebattle && VoteScreen.replaced.battle;
}
//
@ -9341,32 +9275,15 @@ static boolean P_CheckVoteReplacements(char *name)
//
UINT16 P_PartialAddWadFile(const char *wadfilename, wadcompat_t compat)
{
size_t i;
size_t sreplaces = 0, mreplaces = 0, digmreplaces = 0;
UINT16 numlumps, wadnum;
char *name;
static boolean allvotereplaced = false;
lumpinfo_t *lumpinfo;
sreplaces = mreplaces = digmreplaces = 0;
// Vars to help us with the position start and amount of each resource type.
// Useful for PK3s since they use folders.
// WADs use markers for some resources, but others such as sounds are checked lump-by-lump anyway.
// UINT16 luaPos, luaNum = 0;
// UINT16 socPos, socNum = 0;
UINT16 sfxPos = 0, sfxNum = 0;
UINT16 musPos = 0, musNum = 0;
// UINT16 sprPos, sprNum = 0;
UINT16 texPos = 0, texNum = 0;
// UINT16 patPos, patNum = 0;
// UINT16 flaPos, flaNum = 0;
// UINT16 mapPos, mapNum = 0;
// Init file.
if ((numlumps = W_InitFile(wadfilename, false, false, compat)) == INT16_MAX)
if ((numlumps = W_InitFile(wadfilename, false, false, compat)) == LUMPERROR)
{
refreshdirmenu |= REFRESHDIR_NOTLOADED;
return UINT16_MAX;
return MAX_WADFILES;
}
wadnum = (UINT16)(numwadfiles-1);
@ -9381,56 +9298,12 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, wadcompat_t compat)
}
partadd_stage = 0;
P_LoadSoundsRange(wadnum, &sreplaces);
P_LoadMusicsRange(wadnum, &digmreplaces, &mreplaces);
switch(wadfiles[wadnum]->type)
{
case RET_PK3:
// Look for the lumps that act as resource delimitation markers.
lumpinfo = wadfiles[wadnum]->lumpinfo;
for (i = 0; i < numlumps; i++, lumpinfo++)
{
// lumpinfo = FindFolder("Lua/", &luaPos, &luaNum, lumpinfo, &numlumps, &i);
// lumpinfo = FindFolder("SOC/", &socPos, &socNum, lumpinfo, &numlumps, &i);
lumpinfo = FindFolder("Sounds/", &sfxPos, &sfxNum, lumpinfo, &numlumps, &i);
lumpinfo = FindFolder("Music/", &musPos, &musNum, lumpinfo, &numlumps, &i);
// lumpinfo = FindFolder("Sprites/", &sprPos, &sprNum, lumpinfo, &numlumps, &i);
lumpinfo = FindFolder("Textures/", &texPos, &texNum, lumpinfo, &numlumps, &i);
// lumpinfo = FindFolder("Patches/", &patPos, &patNum, lumpinfo, &numlumps, &i);
// lumpinfo = FindFolder("Flats/", &flaPos, &flaNum, lumpinfo, &numlumps, &i);
// lumpinfo = FindFolder("Maps/", &mapPos, &mapNum, lumpinfo, &numlumps, &i);
}
if (!allvotereplaced && P_CheckVoteReplacements(wadnum))
allvotereplaced = true;
// Update the detected resources.
// Note: ALWAYS load Lua scripts first, SOCs right after, and the remaining resources afterwards.
// if (luaNum) // Lua scripts.
// P_LoadLuaScrRange(wadnum, luaPos, luaNum);
// if (socNum) // SOCs.
// P_LoadDehackRange(wadnum, socPos, socNum);
if (sfxNum) // Sounds. TODO: Function currently only updates already existing sounds, the rest is handled somewhere else.
P_LoadSoundsRange(wadnum, sfxPos, sfxNum);
if (musNum) // Music. TODO: Useless function right now.
P_LoadMusicsRange(wadnum, musPos, musNum);
// if (sprNum) // Sprites.
// R_LoadSpritsRange(wadnum, sprPos, sprNum);
// if (texNum) // Textures. TODO: R_LoadTextures() does the folder positioning once again. New function maybe?
// R_LoadTextures();
// if (mapNum) // Maps. TODO: Actually implement the map WAD loading code, lulz.
// P_LoadWadMapRange(wadnum, mapPos, mapNum);
break;
default:
lumpinfo = wadfiles[wadnum]->lumpinfo;
for (i = 0; i < numlumps; i++, lumpinfo++)
{
name = lumpinfo->name;
if (P_CheckSoundReplacements(name, i));
continue;
if (!allvotereplaced && P_CheckVoteReplacements(name))
allvotereplaced = true;
}
break;
}
if (!devparm && sreplaces)
CONS_Printf(M_GetText("%s sounds replaced\n"), sizeu1(sreplaces));
if (!devparm && mreplaces)
@ -9477,7 +9350,7 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, wadcompat_t compat)
//
// extra sprite/skin data
//
R_LoadSpriteInfoLumps(wadnum, numlumps);
R_LoadSpriteInfoLumps(wadnum);
refreshdirmenu &= ~REFRESHDIR_GAMEDATA; // Under usual circumstances we'd wait for REFRESHDIR_ flags to disappear the next frame, but this one's a bit too dangerous for that...
partadd_stage = 0;
@ -9572,7 +9445,7 @@ boolean P_MultiSetupWadFiles(boolean fullsetup)
partadd_important = false;
partadd_replacescurrentmap = false;
partadd_terrainloaded = false;
partadd_earliestfile = UINT16_MAX;
partadd_earliestfile = MAX_WADFILES;
return true;
}

View file

@ -115,8 +115,6 @@ SINT8 P_PartialAddGetStage(void);
extern UINT16 partadd_earliestfile;
boolean P_RunSOC(const char *socfilename);
void P_LoadSoundsRange(UINT16 wadnum, UINT16 first, UINT16 num);
void P_LoadMusicsRange(UINT16 wadnum, UINT16 first, UINT16 num);
//void P_WriteThings(void);
void P_UpdateSegLightOffset(seg_t *li);
boolean P_ApplyLightOffset(UINT8 baselightnum, const sector_t *sector);

View file

@ -152,13 +152,10 @@ void P_InitPicAnims(void)
UINT16 animdefsLumpNum;
// Find ANIMDEFS lump in the WAD
animdefsLumpNum = W_CheckNumForNamePwad("ANIMDEFS", w, 0);
while (animdefsLumpNum != INT16_MAX)
for (animdefsLumpNum = 0; (animdefsLumpNum = W_CheckNumForLongNamePwad("ANIMDEFS", w, animdefsLumpNum)) != LUMPERROR; animdefsLumpNum++)
{
animdeftempflats = ((partadd_earliestfile == UINT16_MAX) || partadd_earliestfile == w);
animdeftempflats = ((partadd_earliestfile == MAX_WADFILES) || partadd_earliestfile == w);
P_ParseANIMDEFSLump(w, animdefsLumpNum);
animdefsLumpNum = W_CheckNumForNamePwad("ANIMDEFS", (UINT16)w, animdefsLumpNum + 1);
}
}
@ -2978,7 +2975,7 @@ boolean P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, cha
case 415: // Run a script
if (cv_runscripts.value)
{
lumpnum_t lumpnum = W_CheckNumForName(stringargs[0]);
lumpnum_t lumpnum = W_CheckNumForLongName(stringargs[0]);
if (lumpnum == LUMPERROR || W_LumpLength(lumpnum) == 0)
CONS_Debug(DBG_SETUP, "Line type 415 Executor: script lump %s not found/not valid.\n", stringargs[0]);

View file

@ -221,10 +221,10 @@ static inline lumpnum_t R_CheckNumForNameList(const char *name, lumplist_t *list
size_t i;
UINT16 lump;
for (i = listsize - 1; i < INT16_MAX; i--)
for (i = listsize - 1; i != SIZE_MAX; i--)
{
lump = W_CheckNumForNamePwad(name, list[i].wadfile, list[i].firstlump);
if (lump == INT16_MAX || lump > (list[i].firstlump + list[i].numlumps))
if (lump == LUMPERROR || lump > (list[i].firstlump + list[i].numlumps))
continue;
else
return (list[i].wadfile<<16)+lump;
@ -240,13 +240,13 @@ static void R_InitExtraColormaps(void)
for (cfile = clump = 0; cfile < numwadfiles; cfile++, clump = 0)
{
startnum = W_CheckNumForNamePwad("C_START", cfile, clump);
if (startnum == INT16_MAX)
startnum = W_CheckNumForLongNamePwad("C_START", cfile, clump);
if (startnum == LUMPERROR)
continue;
endnum = W_CheckNumForNamePwad("C_END", cfile, clump);
endnum = W_CheckNumForLongNamePwad("C_END", cfile, clump);
if (endnum == INT16_MAX)
if (endnum == LUMPERROR)
I_Error("R_InitExtraColormaps: C_START without C_END\n");
// This shouldn't be possible when you use the Pwad function, silly
@ -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++)
{

View file

@ -237,15 +237,15 @@ void R_InitTranslucencyTables(void)
// optimised code (in other words, transtables pointer low word is 0)
transtables = static_cast<UINT8 *>(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<UINT8 *>(Z_Malloc(256, PU_STATIC, NULL));
invremap = static_cast<UINT8 *>(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

View file

@ -1852,17 +1852,18 @@ void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum)
//
// Load and read every SPRTINFO lump from the specified file.
//
void R_LoadSpriteInfoLumps(UINT16 wadnum, UINT16 numlumps)
void R_LoadSpriteInfoLumps(UINT16 wadnum)
{
lumpinfo_t *lumpinfo = wadfiles[wadnum]->lumpinfo;
UINT16 i;
char *name;
#define NUMPREFIXES 2
static lumpprefixes_t sprtinfoprfx[NUMPREFIXES] = {
{ "SPRTINFO", 8 },
{ "SPR_", 4 },
};
for (i = 0; i < numlumps; i++, lumpinfo++)
UINT16 i;
for (i = 0; (i = W_CheckNumForNameMultiPrefixPwad(sprtinfoprfx, NUMPREFIXES, wadnum, i)) != LUMPERROR; i++)
{
name = lumpinfo->name;
// Load SPRTINFO and SPR_ lumps as SpriteInfo
if (!memcmp(name, "SPRTINFO", 8) || !memcmp(name, "SPR_", 4))
R_ParseSPRTINFOLump(wadnum, i);
R_ParseSPRTINFOLump(wadnum, i);
}
#undef NUMPREFIXES
}

View file

@ -129,7 +129,7 @@ boolean Picture_PNGDimensions(UINT8 *png, INT32 *width, INT32 *height, INT16 *to
// SpriteInfo
extern spriteinfo_t spriteinfo[NUMSPRITES];
void R_LoadSpriteInfoLumps(UINT16 wadnum, UINT16 numlumps);
void R_LoadSpriteInfoLumps(UINT16 wadnum);
void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum);
#ifdef __cplusplus

View file

@ -105,14 +105,14 @@ static void Sk_SetDefaultValue(skin_t *skin)
snprintf(skin->name,
sizeof skin->name, "skin %u", (UINT32)(skin-skins));
skin->name[sizeof skin->name - 1] = '\0';
skin->wadnum = INT16_MAX;
skin->wadnum = MAX_WADFILES;
skin->flags = 0;
strcpy(skin->realname, "Someone");
strncpy(skin->facerank, "MISSING", 9);
strncpy(skin->facewant, "MISSING", 9);
strncpy(skin->facemmap, "MISSING", 9);
strcpy(skin->facerank, "MISSING");
strcpy(skin->facewant, "MISSING");
strcpy(skin->facemmap, "MISSING");
skin->starttranscolor = 96;
skin->prefcolor = SKINCOLOR_GREEN;
skin->supercolor = SKINCOLOR_SUPER1;
@ -159,7 +159,7 @@ void R_InitSkins(void)
R_AddSkins((UINT16)i);
if (!wadfiles[i]->compatmode)
R_PatchSkins((UINT16)i);
R_LoadSpriteInfoLumps(i, wadfiles[i]->numlumps);
R_LoadSpriteInfoLumps(i);
}
ST_ReloadSkinFaceGraphics();
}
@ -347,27 +347,6 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum)
// Add skins from a pwad, each skin preceded by 'S_SKIN' marker
//
// Does the same is in w_wad, but check only for
// the first 6 characters (this is so we can have S_SKIN1, S_SKIN2..
// for wad editors that don't like multiple resources of the same name)
//
static UINT16 W_CheckForSkinMarkerInPwad(UINT16 wadid, UINT16 startlump)
{
UINT16 i;
const char *S_SKIN = "S_SKIN";
lumpinfo_t *lump_p;
// scan forward, start at <startlump>
if (startlump < wadfiles[wadid]->numlumps)
{
lump_p = wadfiles[wadid]->lumpinfo + startlump;
for (i = startlump; i < wadfiles[wadid]->numlumps; i++, lump_p++)
if (memcmp(lump_p->name,S_SKIN,6)==0)
return i;
}
return INT16_MAX; // not found
}
// turn _ into spaces and . into katana dot
#define SYMBOLCONVERT(name) for (value = name; *value; value++)\
{\
@ -378,27 +357,6 @@ static UINT16 W_CheckForSkinMarkerInPwad(UINT16 wadid, UINT16 startlump)
// Patch skins from a pwad, each skin preceded by 'P_SKIN' marker
//
// Does the same is in w_wad, but check only for
// the first 6 characters (this is so we can have P_SKIN1, P_SKIN2..
// for wad editors that don't like multiple resources of the same name)
//
static UINT16 W_CheckForPatchSkinMarkerInPwad(UINT16 wadid, UINT16 startlump)
{
UINT16 i;
const char *P_SKIN = "P_SKIN";
lumpinfo_t *lump_p;
// scan forward, start at <startlump>
if (startlump < wadfiles[wadid]->numlumps)
{
lump_p = wadfiles[wadid]->lumpinfo + startlump;
for (i = startlump; i < wadfiles[wadid]->numlumps; i++, lump_p++)
if (memcmp(lump_p->name,P_SKIN,6)==0)
return i;
}
return INT16_MAX; // not found
}
#define NUMKARTFRAMES 19
#define S(f, s) { f - 'A', SPR2_##s },
static UINT8 KART_TO_SPR2[][2] = {
@ -437,16 +395,16 @@ static void R_LoadSkinSprites(UINT16 wadnum, UINT16 *lump, UINT16 *lastlump, ski
UINT8 sprite2;
*lump += 1; // start after S_SKIN
*lastlump = W_CheckNumForNamePwad("S_END",wadnum,*lump); // stop at S_END
*lastlump = W_CheckNumForLongNamePwad("S_END", wadnum, *lump); // stop at S_END
// old wadding practices die hard -- stop at S_SKIN (or P_SKIN) or S_START if they come before S_END.
newlastlump = W_FindNextEmptyInPwad(wadnum,*lump);
if (newlastlump < *lastlump) *lastlump = newlastlump;
newlastlump = W_CheckForSkinMarkerInPwad(wadnum,*lump);
newlastlump = W_CheckNumForNamePrefixPwad("S_SKIN", 6, wadnum, *lump);
if (newlastlump < *lastlump) *lastlump = newlastlump;
newlastlump = W_CheckForPatchSkinMarkerInPwad(wadnum,*lump);
newlastlump = W_CheckNumForNamePrefixPwad("P_SKIN", 6, wadnum, *lump);
if (newlastlump < *lastlump) *lastlump = newlastlump;
newlastlump = W_CheckNumForNamePwad("S_START",wadnum,*lump);
newlastlump = W_CheckNumForLongNamePwad("S_START", wadnum, *lump);
if (newlastlump < *lastlump) *lastlump = newlastlump;
/*// ...and let's handle super, too
@ -628,7 +586,7 @@ static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value)
GETFLAG(OLDDEATH)
#undef GETFLAG
#define GETPATCH(field) else if (compat && !stricmp(stoken, #field)) strncpy(skin->field, value, 8);
#define GETPATCH(field) else if (compat && !stricmp(stoken, #field)) strlcpy(skin->field, value, sizeof(skin->field));
GETPATCH(facerank)
GETPATCH(facewant)
GETPATCH(facemmap)
@ -690,7 +648,7 @@ void R_AddSkins(UINT16 wadnum)
// search for all skin markers in pwad
//
while ((lump = W_CheckForSkinMarkerInPwad(wadnum, lastlump)) != INT16_MAX)
while (lastlump != LUMPERROR && (lump = W_CheckNumForNamePrefixPwad("S_SKIN", 6, wadnum, lastlump)) != LUMPERROR)
{
// advance by default
lastlump = lump + 1;
@ -862,7 +820,7 @@ void R_PatchSkins(UINT16 wadnum)
// search for all skin patch markers in pwad
//
while ((lump = W_CheckForPatchSkinMarkerInPwad(wadnum, lastlump)) != INT16_MAX)
while (lastlump != LUMPERROR && (lump = W_CheckNumForNamePrefixPwad("P_SKIN", 6, wadnum, lastlump)) != LUMPERROR)
{
INT32 skinnum = 0;

View file

@ -42,7 +42,7 @@ struct skin_t
skinflags_t flags;
char realname[SKINNAMESIZE+1]; // Display name for level completion.
char facerank[9], facewant[9], facemmap[9]; // Arbitrarily named patch lumps
char facerank[SHORTNAMELEN+1], facewant[SHORTNAMELEN+1], facemmap[SHORTNAMELEN+1]; // Arbitrarily named patch lumps
// SRB2kart
UINT8 kartspeed;

View file

@ -287,7 +287,7 @@ static boolean R_CheckTextureLumpLength(texture_t *texture, size_t patch)
texture->name,
sizeu1(offsetof(softwarepatch_t, columnofs)),
sizeu2(lumplength),
wadfiles[wadnum]->lumpinfo[lumpnum].fullname
W_CheckFullNameForNumPwad(wadnum, lumpnum)
);
return false;
@ -1117,6 +1117,11 @@ void R_FlushTextureCache(void)
int R_CountTexturesInTEXTURESLump(UINT16 wadNum, UINT16 lumpNum);
void R_ParseTEXTURESLump(UINT16 wadNum, UINT16 lumpNum, INT32 *index);
static const char *flatmarkers[] = {
"Flats/",
"F_START", "F_END",
};
static INT32
Rloadflats (INT32 i, INT32 w)
{
@ -1126,82 +1131,73 @@ Rloadflats (INT32 i, INT32 w)
texpatch_t *patch;
UINT8 header[PNG_HEADER_SIZE];
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);
}
if (!W_CheckNumForMarkers(flatmarkers, sizeof(flatmarkers)/sizeof(*flatmarkers), (UINT16)w, &texstart, &texend))
return i;
if (!( texstart == INT16_MAX || texend == INT16_MAX ))
// Work through each lump between the markers in the WAD.
for (j = 0; j < (texend - texstart); j++)
{
// Work through each lump between the markers in the WAD.
for (j = 0; j < (texend - texstart); j++)
UINT16 wadnum = (UINT16)w;
lumpnum_t lumpnum = texstart + j;
if (wadfiles[w]->type == RET_PK3)
{
UINT16 wadnum = (UINT16)w;
lumpnum_t lumpnum = texstart + j;
if (W_IsLumpFolder(wadnum, lumpnum)) // Check if lump is a folder
continue; // If it is then SKIP IT
}
if (wadfiles[w]->type == RET_PK3)
{
if (W_IsLumpFolder(wadnum, lumpnum)) // Check if lump is a folder
continue; // If it is then SKIP IT
}
size_t lumplength = W_LumpLengthPwad(wadnum, lumpnum);
size_t flatsize = R_FlatDimensionsFromLumpSize(lumplength);
size_t lumplength = W_LumpLengthPwad(wadnum, lumpnum);
size_t flatsize = R_FlatDimensionsFromLumpSize(lumplength);
//CONS_Printf("\n\"%s\" is a flat, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),flatsize,flatsize);
texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL);
//CONS_Printf("\n\"%s\" is a flat, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),flatsize,flatsize);
texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL);
// Set texture properties.
M_Memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name));
texture->hash = quickncasehash(texture->name, 8);
// Set texture properties.
M_Memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name));
texture->hash = quickncasehash(texture->name, 8);
#ifndef NO_PNG_LUMPS
W_ReadLumpHeaderPwad(wadnum, lumpnum, header, sizeof header, 0);
W_ReadLumpHeaderPwad(wadnum, lumpnum, header, sizeof header, 0);
if (Picture_IsLumpPNG(header, lumplength))
{
UINT8 *flatlump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE);
INT32 width, height;
Picture_PNGDimensions((UINT8 *)flatlump, &width, &height, NULL, NULL, lumplength);
texture->width = (INT16)width;
texture->height = (INT16)height;
Z_Free(flatlump);
}
else
#endif
texture->width = texture->height = flatsize;
texture->type = TEXTURETYPE_FLAT;
texture->patchcount = 1;
texture->holes = false;
texture->flip = 0;
texture->terrainID = K_GetTerrainIDForTextureName(texture->name);
// Allocate information for the texture's patches.
patch = &texture->patches[0];
patch->originx = patch->originy = 0;
patch->wad = (UINT16)w;
patch->lump = texstart + j;
patch->flip = 0;
texturewidth[i] = texture->width;
textureheight[i] = texture->height << FRACBITS;
i++;
if (Picture_IsLumpPNG(header, lumplength))
{
UINT8 *flatlump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE);
INT32 width, height;
Picture_PNGDimensions((UINT8 *)flatlump, &width, &height, NULL, NULL, lumplength);
texture->width = (INT16)width;
texture->height = (INT16)height;
Z_Free(flatlump);
}
else
#endif
texture->width = texture->height = flatsize;
texture->type = TEXTURETYPE_FLAT;
texture->patchcount = 1;
texture->holes = false;
texture->flip = 0;
texture->terrainID = K_GetTerrainIDForTextureName(texture->name);
// Allocate information for the texture's patches.
patch = &texture->patches[0];
patch->originx = patch->originy = 0;
patch->wad = (UINT16)w;
patch->lump = texstart + j;
patch->flip = 0;
texturewidth[i] = texture->width;
textureheight[i] = texture->height << FRACBITS;
i++;
}
return i;
}
#define TX_START "TX_START"
#define TX_END "TX_END"
static const char *texturemarkers[] = {
"Textures/",
"TX_START", "TX_END",
};
static INT32
Rloadtextures (INT32 i, INT32 w)
@ -1213,134 +1209,108 @@ Rloadtextures (INT32 i, INT32 w)
softwarepatch_t patchlump;
// Get the lump numbers for the markers in the WAD, if they exist.
if (!W_CheckNumForMarkers(texturemarkers, sizeof(texturemarkers)/sizeof(*texturemarkers), (UINT16)w, &texstart, &texend))
return i;
if (wadfiles[w]->type == RET_PK3)
{
texstart = W_CheckNumForFolderStartPK3("textures/", (UINT16)w, 0);
texend = W_CheckNumForFolderEndPK3("textures/", (UINT16)w, texstart);
texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0);
while (texturesLumpPos != INT16_MAX)
{
for (texturesLumpPos = 0; (texturesLumpPos = W_CheckNumForLongNamePwad("TEXTURES", (UINT16)w, texturesLumpPos)) != LUMPERROR; texturesLumpPos++)
R_ParseTEXTURESLump(w, texturesLumpPos, &i);
texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, texturesLumpPos + 1);
}
}
else
{
texstart = W_CheckNumForMarkerStartPwad(TX_START, (UINT16)w, 0);
texend = W_CheckNumForNamePwad(TX_END, (UINT16)w, 0);
texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0);
if (texturesLumpPos != INT16_MAX)
texturesLumpPos = W_CheckNumForLongNamePwad("TEXTURES", (UINT16)w, 0);
if (texturesLumpPos != LUMPERROR)
R_ParseTEXTURESLump(w, texturesLumpPos, &i);
}
if (!( texstart == INT16_MAX || texend == INT16_MAX ))
// Work through each lump between the markers in the WAD.
for (j = 0; j < (texend - texstart); j++)
{
// Work through each lump between the markers in the WAD.
for (j = 0; j < (texend - texstart); j++)
UINT16 wadnum = (UINT16)w;
lumpnum_t lumpnum = texstart + j;
#ifndef NO_PNG_LUMPS
size_t lumplength;
#endif
if (wadfiles[w]->type == RET_PK3)
{
UINT16 wadnum = (UINT16)w;
lumpnum_t lumpnum = texstart + j;
#ifndef NO_PNG_LUMPS
size_t lumplength;
#endif
if (wadfiles[w]->type == RET_PK3)
{
if (W_IsLumpFolder(wadnum, lumpnum)) // Check if lump is a folder
continue; // If it is then SKIP IT
}
W_ReadLumpHeaderPwad(wadnum, lumpnum, &patchlump, PNG_HEADER_SIZE, 0);
#ifndef NO_PNG_LUMPS
lumplength = W_LumpLengthPwad(wadnum, lumpnum);
#endif
//CONS_Printf("\n\"%s\" is a single patch, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),patchlump->width, patchlump->height);
texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL);
// 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))
{
UINT8 *png = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE);
INT32 width, height;
Picture_PNGDimensions(png, &width, &height, NULL, NULL, lumplength);
texture->width = (INT16)width;
texture->height = (INT16)height;
Z_Free(png);
}
else
#endif
{
texture->width = SHORT(patchlump.width);
texture->height = SHORT(patchlump.height);
}
texture->type = TEXTURETYPE_SINGLEPATCH;
texture->patchcount = 1;
texture->holes = false;
texture->flip = 0;
texture->terrainID = K_GetTerrainIDForTextureName(texture->name);
// Allocate information for the texture's patches.
patch = &texture->patches[0];
patch->originx = patch->originy = 0;
patch->wad = (UINT16)w;
patch->lump = texstart + j;
patch->flip = 0;
texturewidth[i] = texture->width;
textureheight[i] = texture->height << FRACBITS;
i++;
if (W_IsLumpFolder(wadnum, lumpnum)) // Check if lump is a folder
continue; // If it is then SKIP IT
}
W_ReadLumpHeaderPwad(wadnum, lumpnum, &patchlump, PNG_HEADER_SIZE, 0);
#ifndef NO_PNG_LUMPS
lumplength = W_LumpLengthPwad(wadnum, lumpnum);
#endif
//CONS_Printf("\n\"%s\" is a single patch, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),patchlump->width, patchlump->height);
texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL);
// 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))
{
UINT8 *png = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE);
INT32 width, height;
Picture_PNGDimensions(png, &width, &height, NULL, NULL, lumplength);
texture->width = (INT16)width;
texture->height = (INT16)height;
Z_Free(png);
}
else
#endif
{
texture->width = SHORT(patchlump.width);
texture->height = SHORT(patchlump.height);
}
texture->type = TEXTURETYPE_SINGLEPATCH;
texture->patchcount = 1;
texture->holes = false;
texture->flip = 0;
texture->terrainID = K_GetTerrainIDForTextureName(texture->name);
// Allocate information for the texture's patches.
patch = &texture->patches[0];
patch->originx = patch->originy = 0;
patch->wad = (UINT16)w;
patch->lump = texstart + j;
patch->flip = 0;
texturewidth[i] = texture->width;
textureheight[i] = texture->height << FRACBITS;
i++;
}
return i;
}
static INT32
count_range
( const char * marker_start,
const char * marker_end,
const char * folder,
UINT16 wadnum)
static INT32 count_range(const char *markers[], size_t nummarkers, UINT16 wadnum)
{
UINT16 j;
UINT16 texstart, texend;
INT32 count = 0;
// Count flats
if (!W_CheckNumForMarkers(markers, nummarkers, wadnum, &texstart, &texend))
return count;
// PK3s have subfolders, so we can't just make a simple sum
if (wadfiles[wadnum]->type == RET_PK3)
{
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++)
{
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);
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;
}
@ -1358,19 +1328,14 @@ static INT32 R_CountTextures(UINT16 wadnum)
// 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.
count += count_range("F_START", "F_END", "flats/", wadnum);
count += count_range(flatmarkers, sizeof(flatmarkers)/sizeof(*flatmarkers), wadnum);
// Count the textures from TEXTURES lumps
texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", wadnum, 0);
while (texturesLumpPos != INT16_MAX)
{
for (texturesLumpPos = 0; (texturesLumpPos = W_CheckNumForLongNamePwad("TEXTURES", wadnum, texturesLumpPos)) != LUMPERROR; texturesLumpPos++)
count += R_CountTexturesInTEXTURESLump(wadnum, texturesLumpPos);
texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", wadnum, texturesLumpPos + 1);
}
// Count single-patch textures
count += count_range(TX_START, TX_END, "textures/", wadnum);
count += count_range(texturemarkers, sizeof(texturemarkers)/sizeof(*texturemarkers), wadnum);
return count;
}
@ -1498,7 +1463,7 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch)
char *texturesToken;
size_t texturesTokenLength;
char *endPos;
char *patchName = NULL;
char patchName[SHORTNAMELEN+1];
INT16 patchXPos;
INT16 patchYPos;
UINT8 flip = 0;
@ -1514,19 +1479,13 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch)
I_Error("Error parsing TEXTURES lump: Unexpected end of file where patch name should be");
}
texturesTokenLength = strlen(texturesToken);
if (texturesTokenLength>8)
if (texturesTokenLength >= sizeof(patchName))
{
I_Error("Error parsing TEXTURES lump: Patch name \"%s\" exceeds 8 characters",texturesToken);
I_Error("Error parsing TEXTURES lump: Patch name \"%s\" exceeds %zu characters", texturesToken, sizeof(patchName) - 1);
}
else
{
if (patchName != NULL)
{
Z_Free(patchName);
}
patchName = (char *)Z_Malloc((texturesTokenLength+1)*sizeof(char),PU_STATIC,NULL);
M_Memcpy(patchName,texturesToken,texturesTokenLength*sizeof(char));
patchName[texturesTokenLength] = '\0';
strcpy(patchName, texturesToken);
}
// Comma 1
@ -1665,7 +1624,7 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch)
if (actuallyLoadPatch == true)
{
// Check lump exists
patchLumpNum = W_GetNumForName(patchName);
patchLumpNum = W_GetNumForLongName(patchName);
// If so, allocate memory for texpatch_t and fill 'er up
resultPatch = (texpatch_t *)Z_Malloc(sizeof(texpatch_t),PU_STATIC,NULL);
resultPatch->originx = patchXPos;
@ -1675,14 +1634,11 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch)
resultPatch->flip = flip;
resultPatch->alpha = alpha;
resultPatch->style = style;
// Clean up a little after ourselves
Z_Free(patchName);
// Then return it
return resultPatch;
}
else
{
Z_Free(patchName);
return NULL;
}
}

View file

@ -271,7 +271,7 @@ void R_AddKartFaces(skin_t *skin)
spritedef_t *sd = &skin->sprites[SPR2_XTRA];
for (size_t f = 0; f < NUMFACES; f++)
{
lumpnum_t lumpnum = W_CheckNumForName(reinterpret_cast<char *>(skin) + KART_FACES[f]); // how do you do, fellow C++ers?
lumpnum_t lumpnum = W_CheckNumForLongName(reinterpret_cast<char *>(skin) + KART_FACES[f]); // how do you do, fellow C++ers?
if (lumpnum == LUMPERROR)
I_Error("R_AddKartFaces: missing patch %s for skin %s", reinterpret_cast<char *>(skin) + KART_FACES[f], skin->name);
R_InstallSpriteLump(WADFILENUM(lumpnum), LUMPNUM(lumpnum), numspritelumps, f, 0, 0);
@ -301,7 +301,6 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
UINT16 l;
UINT8 frame;
UINT8 rotation;
lumpinfo_t *lumpinfo;
softwarepatch_t patch;
UINT16 numadded = 0;
boolean compat = wadfiles[wadnum]->compatmode;
@ -323,24 +322,21 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
// scan the lumps,
// filling in the frames for whatever is found
lumpinfo = wadfiles[wadnum]->lumpinfo;
if (endlump > wadfiles[wadnum]->numlumps)
endlump = wadfiles[wadnum]->numlumps;
for (l = startlump; l < endlump; l++)
for (l = startlump; (l = W_CheckNumForNamePrefixPwad(sprname, 4, wadnum, l)) != LUMPERROR && l < endlump; l++)
{
if (memcmp(lumpinfo[l].name,sprname,4))
continue;
{
const char *longname = W_CheckNameForNumPwad(wadnum, l);
INT32 width, height;
INT16 topoffset, leftoffset;
#ifndef NO_PNG_LUMPS
boolean isPNG = false;
#endif
frame = R_Char2Frame(lumpinfo[l].name[4], compat);
rotation = R_Char2Rotation(lumpinfo[l].name[5]);
frame = R_Char2Frame(longname[4], compat);
rotation = R_Char2Rotation(longname[5]);
if (frame >= 64 || rotation == 255) // Give an actual NAME error -_-...
{
@ -391,10 +387,10 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
R_InstallSpriteLump(wadnum, l, numspritelumps, frame, rotation, 0);
if (lumpinfo[l].name[6])
if (longname[6])
{
frame = R_Char2Frame(lumpinfo[l].name[6], compat);
rotation = R_Char2Rotation(lumpinfo[l].name[7]);
frame = R_Char2Frame(longname[6], compat);
rotation = R_Char2Rotation(longname[7]);
if (frame >= 64 || rotation == 255) // Give an actual NAME error -_-...
{
@ -493,6 +489,12 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
return true;
}
static const char *spritemarkers[] = {
"Sprites/",
"S_START", "S_END",
"SS_START", "SS_END", // deutex compatib.
};
//
// Search for sprites replacements in a wad whose names are in namelist
//
@ -502,42 +504,12 @@ void R_AddSpriteDefs(UINT16 wadnum)
UINT16 start, end;
char wadname[MAX_WADPATH];
// Find the sprites section in this resource file.
switch (wadfiles[wadnum]->type)
{
case RET_WAD:
start = W_CheckNumForMarkerStartPwad("S_START", wadnum, 0);
if (start == INT16_MAX)
start = W_CheckNumForMarkerStartPwad("SS_START", wadnum, 0); //deutex compatib.
end = W_CheckNumForNamePwad("S_END",wadnum,start);
if (end == INT16_MAX)
end = W_CheckNumForNamePwad("SS_END",wadnum,start); //deutex compatib.
break;
case RET_PK3:
start = W_CheckNumForFolderStartPK3("Sprites/", wadnum, 0);
end = W_CheckNumForFolderEndPK3("Sprites/", wadnum, start);
break;
default:
return;
}
if (start == INT16_MAX)
{
// ignore skin wads (we don't want skin sprites interfering with vanilla sprites)
if (W_CheckNumForNamePwad("S_SKIN", wadnum, 0) != UINT16_MAX)
return;
start = 0; //let say S_START is lump 0
}
if (end == INT16_MAX || start >= end)
if (!W_CheckNumForMarkers(spritemarkers, sizeof(spritemarkers)/sizeof(*spritemarkers), wadnum, &start, &end))
{
CONS_Debug(DBG_SETUP, "no sprites in pwad %d\n", wadnum);
return;
}
//
// scan through lumps, for each sprite, find all the sprite frames
//
@ -1472,7 +1444,7 @@ static void R_ProjectDropShadow(
if (shadowpatch == NULL)
{
shadowpatch = static_cast<patch_t*>(W_CachePatchName("DSHADOW", PU_SPRITE));
shadowpatch = static_cast<patch_t*>(W_CachePatchLongName("DSHADOW", PU_SPRITE));
}
patch = shadowpatch;

View file

@ -313,22 +313,17 @@ static void SetChannelsNum(void)
//
lumpnum_t S_GetSfxLumpNum(sfxinfo_t *sfx)
{
char namebuf[9];
lumpnum_t sfxlump;
sprintf(namebuf, "ds%s", sfx->name);
sfxlump = W_CheckNumForName(namebuf);
sfxlump = W_CheckNumForLongName(va("DS%s", sfx->name));
if (sfxlump != LUMPERROR)
return sfxlump;
strlcpy(namebuf, sfx->name, sizeof namebuf);
sfxlump = W_CheckNumForName(namebuf);
sfxlump = W_CheckNumForLongName(sfx->name);
if (sfxlump != LUMPERROR)
return sfxlump;
return W_GetNumForName("dsthok");
return W_GetNumForLongName("DSTHOK");
}
//
@ -1387,12 +1382,11 @@ MusicDefError
int line
){
const wadfile_t * wad = wadfiles[WADFILENUM (lumpnum)];
const lumpinfo_t * lump = &wad->lumpinfo[LUMPNUM (lumpnum)];
CONS_Alert(level,
va("%%s|%%s: %s (line %%d)\n", description),
wad->filename,
lump->fullname,
W_CheckFullNameForNum(lumpnum),
field,
line
);
@ -1645,14 +1639,10 @@ void S_LoadMusicDefs(UINT16 wad)
{
const lumpnum_t wadnum = wad << 16;
UINT16 lump = 0;
UINT16 lump;
while (( lump = W_CheckNumForNamePwad("MUSICDEF", wad, lump) ) != INT16_MAX)
{
for (lump = 0; (lump = W_CheckNumForLongNamePwad("MUSICDEF", wad, lump)) != LUMPERROR; lump++)
S_LoadMusicDefLump(wadnum | lump);
lump++;
}
}
//
@ -1852,9 +1842,16 @@ boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping)
return (boolean)mname[0];
}
static lumpnum_t S_GetMusicLumpNum(const char *mname)
{
char *n = va("O_%s", mname);
strupr(n); // yep, you can do that
return W_CheckNumForNamePrefix(n, 8);
}
boolean S_MusicExists(const char *mname)
{
return W_CheckNumForName(va("O_%s", mname)) != LUMPERROR;
return S_GetMusicLumpNum(mname) != LUMPERROR;
}
/// ------------------------
@ -2188,14 +2185,6 @@ boolean S_RecallMusic(UINT16 status, boolean fromfirst)
/// Music Playback
/// ------------------------
static lumpnum_t S_GetMusicLumpNum(const char *mname)
{
if (S_MusicExists(mname))
return W_GetNumForName(va("o_%s", mname));
else
return LUMPERROR;
}
static boolean S_LoadMusic(const char *mname)
{
lumpnum_t mlumpnum;

View file

@ -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 */

View file

@ -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();

View file

@ -1537,7 +1537,7 @@ static void I_CleanupGME(void *userdata)
static boolean I_StartGMESong(const char *musicname, boolean looping)
{
char filename[9];
char filename[SHORTNAMELEN+1];
void *data;
lumpnum_t lumpnum;
size_t lumplength;
@ -1552,7 +1552,7 @@ static boolean I_StartGMESong(const char *musicname, boolean looping)
snprintf(filename, sizeof filename, "o_%s", musicname);
lumpnum = W_CheckNumForName(filename);
lumpnum = W_CheckNumForLongName(filename);
if (lumpnum == LUMPERROR)
{

View file

@ -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;

View file

@ -47,3 +47,27 @@ UINT32 strbuf_append(strbuf_t **strbuf, const char *str)
strcpy(buf->buf - sizeof(UINT32) + oldsize, str);
return oldsize;
}
// appends a fixed-size array of bytes to the buffer, and inserts a null terminator
// useful if you know the length of a string in advance, or want to truncate it to a certain length
// returns an offset to the newly appended bytes
UINT32 strbuf_append_m(strbuf_t **strbuf, const void *src, UINT32 len)
{
strbuf_t *buf = *strbuf;
size_t addbytes = len + 1;
UINT32 oldsize = buf->size;
buf->size += addbytes;
if ((oldsize % STRBUF_BLOCKSIZE) + addbytes >= STRBUF_BLOCKSIZE) {
UINT32 newsize = buf->size + STRBUF_BLOCKSIZE - (buf->size % STRBUF_BLOCKSIZE);
if (newsize <= oldsize)
I_Error("String buffer size wrapped around!?");
buf = *strbuf = Z_Realloc(buf, newsize, PU_STATIC, NULL);
if (!buf)
I_Error("Failed to allocate string buffer");
}
memcpy(buf->buf - sizeof(UINT32) + oldsize, src, len);
buf->buf[-sizeof(UINT32) + oldsize + len] = '\0';
return oldsize;
}

View file

@ -22,6 +22,7 @@ struct strbuf_t
strbuf_t *strbuf_alloc(void);
UINT32 strbuf_append(strbuf_t **strbuf, const char *str);
UINT32 strbuf_append_m(strbuf_t **strbuf, const void *src, UINT32 len);
// returns the string at the given offset
FUNCINLINE static ATTRINLINE char *strbuf_get(strbuf_t *strbuf, UINT32 ofs)

View file

@ -407,9 +407,8 @@ TYPEDEF (colorlookup_t);
TYPEDEF (cliprect_t);
// w_wad.h
TYPEDEF (filelump_t);
TYPEDEF (wadinfo_t);
TYPEDEF (lumpinfo_t);
TYPEDEF (lumpprefixes_t);
TYPEDEF (virtlump_t);
TYPEDEF (virtres_t);
TYPEDEF (wadfile_t);

View file

@ -313,7 +313,7 @@ UINT32 V_GammaCorrect(UINT32 input, double power)
// keep a copy of the palette so that we can get the RGB value for a color index at any time.
static void LoadPalette(const char *lumpname)
{
lumpnum_t lumpnum = W_GetNumForName(lumpname);
lumpnum_t lumpnum = W_GetNumForLongName(lumpname);
size_t i, palsize = W_LumpLength(lumpnum)/3;
UINT8 *pal;
@ -408,22 +408,15 @@ void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue)
*blue = (UINT8)(working[0][2]);
}
const char *R_GetPalname(UINT16 num)
{
static char palname[9];
char newpal[9] = "PLAYPAL";
if (num > 0 && num <= 10000)
snprintf(newpal, 8, "PAL%04u", num-1);
strncpy(palname, newpal, 8);
return palname;
}
const char *GetPalette(void)
{
if (gamestate == GS_LEVEL)
return R_GetPalname((encoremode ? mapheaderinfo[gamemap-1]->encorepal : mapheaderinfo[gamemap-1]->palette));
UINT16 num = encoremode ? mapheaderinfo[gamemap-1]->encorepal : mapheaderinfo[gamemap-1]->palette;
if (gamestate == GS_LEVEL && num > 0 && num <= 10000)
{
static char palname[SHORTNAMELEN+1];
sprintf(palname, "PAL%04u", num-1);
return palname;
}
return "PLAYPAL";
}
@ -994,7 +987,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));
}
//
@ -1712,7 +1705,7 @@ void V_DrawCustomFadeScreen(const char *lump, UINT8 strength)
lighttable_t *clm = NULL;
if (lump != NULL)
lumpnum = W_GetNumForName(lump);
lumpnum = W_GetNumForLongName(lump);
else
return;

View file

@ -68,7 +68,6 @@ void V_SetPalette(INT32 palettenum);
void V_SetPaletteLump(const char *pal);
const char *R_GetPalname(UINT16 num);
const char *GetPalette(void);
extern RGBA_t *pLocalPalette;

File diff suppressed because it is too large Load diff

View file

@ -22,58 +22,6 @@
extern "C" {
#endif
// a raw entry of the wad directory
// NOTE: This sits here and not in w_wad.c because p_setup.c makes use of it to load map WADs inside PK3s.
#if defined(_MSC_VER)
#pragma pack(1)
#endif
struct filelump_t
{
UINT32 filepos; // file offset of the resource
UINT32 size; // size of the resource
char name[8]; // name of the resource
} ATTRPACK;
#if defined(_MSC_VER)
#pragma pack()
#endif
// ==============================================================
// WAD FILE STRUCTURE DEFINITIONS
// ==============================================================
// header of a wad file
struct wadinfo_t
{
char identification[4]; // should be "IWAD" or "PWAD"
UINT32 numlumps; // how many resources
UINT32 infotableofs; // the 'directory' of resources
};
// Available compression methods for lumps.
typedef enum
{
CM_NOCOMPRESSION,
#ifdef HAVE_ZLIB
CM_DEFLATE,
#endif
CM_LZF,
CM_UNSUPPORTED
} compmethod;
// a memory entry of the wad directory
struct lumpinfo_t
{
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
compmethod compression; // lump compression method
};
// =========================================================================
// 'VIRTUAL' RESOURCES
// =========================================================================
@ -120,6 +68,7 @@ struct wadfile_t
{
char *filename;
restype_t type;
UINT32 *lumphashes; // hashes for every lump's longname in ALL CAPS
lumpinfo_t *lumpinfo;
lumpcache_t *lumpcache;
lumpcache_t *patchcache;
@ -139,6 +88,12 @@ typedef enum wadcompat
WC_OFF,
} wadcompat_t;
struct lumpprefixes_t
{
const char *prefix;
size_t len;
};
#define WADFILENUM(lumpnum) (UINT16)((lumpnum)>>16) // wad flumpnum>>16) // wad file number in upper word
#define LUMPNUM(lumpnum) (UINT16)((lumpnum)&0xFFFF) // lump number for this pwad
@ -151,7 +106,7 @@ void W_Shutdown(void);
// Opens a WAD file. Returns the FILE * handle for the file, or NULL if not found or could not be opened
FILE *W_OpenWadFile(const char **filename, boolean useerrors);
// Load and add a wadfile to the active wad files, returns numbers of lumps, INT16_MAX on error
// Load and add a wadfile to the active wad files, returns numbers of lumps, LUMPERROR on error
UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup, wadcompat_t compat);
boolean W_MakeFileHash(const char *filename, boolean openwad, UINT64 *ret);
@ -163,27 +118,23 @@ INT32 W_InitMultipleFiles(char **filenames, boolean addons);
const char *W_CheckNameForNumPwad(UINT16 wad, UINT16 lump);
const char *W_CheckNameForNum(lumpnum_t lumpnum);
const char *W_CheckFullNameForNumPwad(UINT16 wad, UINT16 lump);
const char *W_CheckFullNameForNum(lumpnum_t lumpnum);
UINT16 W_FindNextEmptyInPwad(UINT16 wad, UINT16 startlump); // checks only in one pwad
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
UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump);
UINT16 W_CheckNumForLongNamePwadNoUpper(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);
/* Find the first lump after F_START for instance. */
UINT16 W_CheckNumForMarkerStartPwad(const char *name, UINT16 wad, UINT16 startlump);
boolean W_CheckNumForMarkers(const char *markers[], size_t nummarkers, UINT16 wad, UINT16 *ostart, UINT16 *oend);
UINT16 W_CheckNumForFullNamePK3(const char *name, UINT16 wad, UINT16 startlump);
UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlump);
UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump);
lumpnum_t W_CheckNumForMap(const char *name);
lumpnum_t W_CheckNumForName(const char *name);
lumpnum_t W_CheckNumForLongName(const char *name);
lumpnum_t W_GetNumForName(const char *name); // like W_CheckNumForName but I_Error on LUMPERROR
lumpnum_t W_CheckNumForNamePrefix(const char *name, size_t namelen);
lumpnum_t W_GetNumForLongName(const char *name);
lumpnum_t W_CheckNumForNameInBlock(const char *name, const char *blockstart, const char *blockend);
lumpnum_t W_CheckNumForNameInFolder(const char *lump, const char *folder);
UINT8 W_LumpExists(const char *name); // Lua uses this.
@ -211,8 +162,6 @@ 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);
void *W_CachePatchLongName(const char *name, INT32 tag);
// Returns either a Software patch, or an OpenGL patch.

View file

@ -447,7 +447,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?
@ -590,13 +590,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]);
@ -1104,8 +1104,8 @@ static void Y_VoteScreenCheck(void)
// non lua vote background handling
boolean prefbattletype = ((votelevels[0][1] & ~0x80) == GT_BATTLE);
VoteScreen.widebgpatch = W_CachePatchName((prefbattletype ? "BATTLSCW" : "INTERSCW"), PU_PATCH);
VoteScreen.bgpatch = W_CachePatchName((prefbattletype ? "BATTLSCR" : "INTERSCR"), PU_PATCH);
VoteScreen.widebgpatch = W_CachePatchLongName((prefbattletype ? "BATTLSCW" : "INTERSCW"), PU_PATCH);
VoteScreen.bgpatch = W_CachePatchLongName((prefbattletype ? "BATTLSCR" : "INTERSCR"), PU_PATCH);
}
//
@ -1153,7 +1153,7 @@ static void Y_DrawLuaVoteScreenPatch(boolean widePatch)
// Draw non animated patch
if (!tempfoundAnimLuaVoteFrames)
{
votebg = W_CachePatchName(va("%s1", tempPrefix), PU_PATCH);
votebg = W_CachePatchLongName(va("%s1", tempPrefix), PU_PATCH);
Y_VoteBackgroundDrawer(votebg);
return;
}
@ -1166,7 +1166,7 @@ static void Y_DrawLuaVoteScreenPatch(boolean widePatch)
nextframe = (VoteScreen.currentAnimFrame + 1);
votebg = W_CachePatchName(va("%s%d", tempPrefix, nextframe), PU_PATCH);
votebg = W_CachePatchLongName(va("%s%d", tempPrefix, nextframe), PU_PATCH);
Y_VoteBackgroundDrawer(votebg);
@ -1532,7 +1532,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));
}
}
@ -1864,13 +1864,13 @@ static void Y_InitVoteDrawing(void)
// setup the background patches
Y_VoteScreenCheck();
VoteScreen.cursor[0] = W_CachePatchName("M_CURSOR", PU_PATCH);
VoteScreen.cursor[1] = W_CachePatchName("P1CURSOR", PU_PATCH);
VoteScreen.cursor[2] = W_CachePatchName("P2CURSOR", PU_PATCH);
VoteScreen.cursor[3] = W_CachePatchName("P3CURSOR", PU_PATCH);
VoteScreen.cursor[4] = W_CachePatchName("P4CURSOR", PU_PATCH);
VoteScreen.cursor[0] = W_CachePatchLongName("M_CURSOR", PU_PATCH);
VoteScreen.cursor[1] = W_CachePatchLongName("P1CURSOR", PU_PATCH);
VoteScreen.cursor[2] = W_CachePatchLongName("P2CURSOR", PU_PATCH);
VoteScreen.cursor[3] = W_CachePatchLongName("P3CURSOR", PU_PATCH);
VoteScreen.cursor[4] = W_CachePatchLongName("P4CURSOR", PU_PATCH);
VoteScreen.rubyicon = W_CachePatchName("RUBYICON", PU_PATCH);
VoteScreen.rubyicon = W_CachePatchLongName("RUBYICON", PU_PATCH);
}
void Y_StartVote(void)