Add compatmode flag

This commit is contained in:
GenericHeroGuy 2025-01-24 17:17:47 +01:00
parent be64786d57
commit d67c9862ae
3 changed files with 43 additions and 0 deletions

View file

@ -4634,6 +4634,8 @@ static void Command_ListWADS_f(void)
CONS_Printf("\x82 * %.2d\x80: %s\n", i, tempname);
else if (!wadfiles[i]->important)
CONS_Printf("\x86 %.2d: %s\n", i, tempname);
else if (wadfiles[i]->compatmode)
CONS_Printf("\x8a %.2d: %s\n", i, tempname);
else
CONS_Printf(" %.2d: %s\n", i, tempname);
}

View file

@ -291,6 +291,33 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum, boolean mainfile)
#endif
}
static inline boolean CheckCompatFilename(char *filename)
{
// check for a K prefix
char *basename = strrchr(filename, *PATHSEP);
return toupper(basename ? basename[1] : filename[0]) == 'K';
}
// try to figure out if a PK3 file needs compatmode enabled (palette remap)
static inline boolean CheckCompatZip(UINT16 wadnum)
{
if (CheckCompatFilename(wadfiles[wadnum]->filename))
return true;
// assume RR/2.2 for PK3s so basegame assets work
return false;
}
// ditto, but for WADs
static inline boolean CheckCompatWad(UINT16 wadnum)
{
if (CheckCompatFilename(wadfiles[wadnum]->filename))
return true;
// assume Kart/2.1 for WADs so basegame assets work
return true;
}
/** Compute MD5 message digest for bytes read from STREAM of this filname.
*
* The resulting message digest number will be written into the 16 bytes
@ -872,6 +899,19 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup)
break;
}
// check if compatmode is needed
switch (wadfile->type)
{
case RET_WAD:
wadfile->compatmode = CheckCompatWad(numwadfiles - 1);
break;
case RET_PK3:
wadfile->compatmode = CheckCompatZip(numwadfiles - 1);
break;
default:
break;
}
if (refreshdirmenu & REFRESHDIR_GAMEDATA)
G_LoadGameData();
DEH_UpdateMaxFreeslots();

View file

@ -128,6 +128,7 @@ struct wadfile_t
UINT8 md5sum[16];
boolean important; // also network - !W_VerifyNMUSlumps
boolean compatmode; // TODO: network this too!
};
#define WADFILENUM(lumpnum) (UINT16)((lumpnum)>>16) // wad flumpnum>>16) // wad file number in upper word