mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-22 19:38:06 -04:00
avoid demo lump name collisions (#712)
* check if the demo file name gets truncated to a lump name that is already present * only apply to demos loaded from the command line * no need to copy string, lumpinfo[] isn't going to change anymore at this point * lumps called DEMO* are considered safe * correct order * Update w_wad.c * comments * reverse search order
This commit is contained in:
parent
73ea00854b
commit
8d4ccf9a52
@ -3675,6 +3675,9 @@ void D_CheckNetPlaybackSkip(void);
|
||||
|
||||
void G_DeferedPlayDemo(char* name)
|
||||
{
|
||||
// [FG] avoid demo lump name collisions
|
||||
W_DemoLumpNameCollision(&name);
|
||||
|
||||
defdemoname = name;
|
||||
gameaction = ga_playdemo;
|
||||
|
||||
|
41
src/w_wad.c
41
src/w_wad.c
@ -555,6 +555,47 @@ boolean W_IsIWADLump (const int lump)
|
||||
lumpinfo[lump].wad_file == wadfiles[0];
|
||||
}
|
||||
|
||||
// [FG] avoid demo lump name collisions
|
||||
void W_DemoLumpNameCollision(char **name)
|
||||
{
|
||||
const char *const safename = "DEMO1";
|
||||
char basename[9];
|
||||
int i, lump;
|
||||
|
||||
ExtractFileBase(*name, basename);
|
||||
|
||||
// [FG] lumps called DEMO* are considered safe
|
||||
if (!strncasecmp(basename, safename, 4))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lump = W_CheckNumForName(basename);
|
||||
|
||||
if (lump >= 0)
|
||||
{
|
||||
for (i = lump - 1; i >= 0; i--)
|
||||
{
|
||||
if (!strncasecmp(lumpinfo[i].name, basename, 8))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= 0)
|
||||
{
|
||||
fprintf(stderr, "Demo lump name collision detected with lump \'%.8s\' from %s.\n",
|
||||
lumpinfo[i].name, W_WadNameForLump(i));
|
||||
|
||||
// [FG] the DEMO1 lump is almost certainly always a demo lump
|
||||
M_StringCopy(lumpinfo[lump].name, safename, 8);
|
||||
*name = lumpinfo[lump].name;
|
||||
|
||||
W_InitLumpHash();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void W_CloseFileDescriptors(void)
|
||||
{
|
||||
int i;
|
||||
|
@ -121,6 +121,7 @@ extern void WritePredefinedLumpWad(const char *filename); // jff 5/6/98
|
||||
// [FG] name of the WAD file that contains the lump
|
||||
const char *W_WadNameForLump (const int lump);
|
||||
boolean W_IsIWADLump (const int lump);
|
||||
void W_DemoLumpNameCollision(char **name);
|
||||
|
||||
void W_CloseFileDescriptors(void);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user