Clean up P_InitMapData and fix maps not working of loaded before header

This commit is contained in:
NepDisk 2025-10-20 15:42:34 -04:00
parent a5f89b769d
commit 7723e414e4
4 changed files with 24 additions and 20 deletions

View file

@ -1852,6 +1852,10 @@ void D_SRB2Main(void)
I_Error("Bad '%s' level warp.\n"
#if defined (_WIN32)
"Are you using MSDOS 8.3 filenames in Zone Builder?\n"
"\n"
"To check: edit the BlanKart game configuration in Ultimate Lowee Builder.\n"
"Go to the Testing tab and make sure \"Use short paths and file names\" is turned off.\n"
"(The option is hidden by default. Check \"Customize parameters\" to show it.)\n"
#endif
, word);
}

View file

@ -9269,7 +9269,7 @@ INT16 wadnamemap = 0; // gamemap based
UINT8 P_InitMapData(boolean existingmapheaders)
{
UINT8 ret = 0;
INT32 i;
INT32 i, j;
lumpnum_t maplump;
virtres_t *virtmap;
virtlump_t *minimap, *thumbnailPic;
@ -9279,27 +9279,13 @@ UINT8 P_InitMapData(boolean existingmapheaders)
for (i = 0; i < nummapheaders; ++i)
{
name = mapheaderinfo[i]->lumpname;
maplump = W_CheckNumForMap(name);
// Doesn't exist?
if (maplump == INT16_MAX)
{
#ifndef DEVELOP
if (!existingmapheaders)
{
I_Error("P_InitMapData: Base map %s has a header but no level\n", name);
}
#endif
continue;
}
maplump = W_CheckNumForMap(name, (mapheaderinfo[i]->lumpnum == LUMPERROR));
// Always check for cup cache reassociations.
// (The core assumption is that cups < headers.)
if (maplump != LUMPERROR || mapheaderinfo[i]->lumpnum != LUMPERROR)
{
cupheader_t *cup = kartcupheaders;
INT32 j;
mapheaderinfo[i]->cup = NULL;
while (cup)
{
@ -9327,6 +9313,18 @@ UINT8 P_InitMapData(boolean existingmapheaders)
}
}
// Doesn't exist in this set of files?
if (maplump == LUMPERROR)
{
#ifndef DEVELOP
if (!existingmapheaders)
{
I_Error("P_InitMapData: Base map %s has a header but no level\n", name);
}
#endif
continue;
}
// No change?
if (mapheaderinfo[i]->lumpnum == maplump)
continue;
@ -9350,6 +9348,7 @@ UINT8 P_InitMapData(boolean existingmapheaders)
}
mapheaderinfo[i]->lumpnum = maplump;
if (maplump == wadnamelump)
wadnamemap = i+1;

View file

@ -1452,11 +1452,12 @@ lumpnum_t W_CheckNumForLongName(const char *name)
// Look for valid map data through all added files in descendant order.
// Get a map marker for WADs, and a standalone WAD file lump inside PK3s.
lumpnum_t W_CheckNumForMap(const char *name)
lumpnum_t W_CheckNumForMap(const char *name, boolean checktofirst)
{
lumpnum_t check = INT16_MAX;
UINT32 uhash, hash = quickncasehash(name, LUMPNUMCACHENAME);
INT32 i;
UINT16 firstfile = (checktofirst || (partadd_earliestfile == UINT16_MAX)) ? 0 : partadd_earliestfile;
// Check the lumpnumcache first. Loop backwards so that we check
// most recent entries first
@ -1472,7 +1473,7 @@ lumpnum_t W_CheckNumForMap(const char *name)
uhash = quickncasehash(name, 8); // Not a mistake, legacy system for short lumpnames
for (i = numwadfiles - 1; i >= 0; i--)
for (i = numwadfiles - 1; i >= firstfile; i--)
{
check = W_CheckNumForMapPwad(name, uhash, (UINT16)i, 0);

View file

@ -171,7 +171,7 @@ 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_CheckNumForMap(const char *name, boolean checktofirst);
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