diff --git a/cgdoom/cgdoom.c b/cgdoom/cgdoom.c index 33922bd..926c552 100644 --- a/cgdoom/cgdoom.c +++ b/cgdoom/cgdoom.c @@ -385,6 +385,7 @@ int CGD_EnableDemos = 0; int CGD_SingleEpisodeUltimate = 0; int CGD_2MBLineMemory = 0; int CGD_Frameskip = 1; +const char *CGD_WADFileName = NULL; /* Performance counters */ struct CGD_Perf CGD_Perf; @@ -694,6 +695,12 @@ int main(void) if(CGD_2MBLineMemory) CGD_2MBLineMemory = FindZeroedMemory((void *)0xac200000); + /* Remember WAD file name for saves and loads */ + static char wad_name[32] = { 0 }; + for (int i = 0; wads[choice].name[i] != '.'; i++) + wad_name[i] = wads[choice].name[i]; + CGD_WADFileName = wad_name; + /* Setup access to WAD file */ #ifdef CG_EMULATOR gWADmethod = CGDOOM_WAD_BFILE; diff --git a/cgdoom/cgdoom.h b/cgdoom/cgdoom.h index 4f3f345..3755501 100644 --- a/cgdoom/cgdoom.h +++ b/cgdoom/cgdoom.h @@ -32,6 +32,8 @@ extern int CGD_EnableDemos; extern int CGD_SingleEpisodeUltimate; /* Skip this amount of frames after every rendered frame (default 1) */ extern int CGD_Frameskip; +/* WAD file name (without .wad), used to avoid save file conflicts */ +extern const char *CGD_WADFileName; // Global variables interfacing with Doom itself. diff --git a/cgdoom/g_game.c b/cgdoom/g_game.c index 33c04ad..90d65a0 100644 --- a/cgdoom/g_game.c +++ b/cgdoom/g_game.c @@ -1007,7 +1007,7 @@ void G_DoSaveGame (void) int length; int i; - sprintf(name, SAVEGAMENAME "%d.dsg", savegameslot); + sprintf(name, "%s_%d.dsg", CGD_WADFileName, savegameslot); description = savedescription; save_p = savebuffer = screens[0]; diff --git a/cgdoom/m_menu.c b/cgdoom/m_menu.c index 84eb442..3b6c374 100644 --- a/cgdoom/m_menu.c +++ b/cgdoom/m_menu.c @@ -467,7 +467,7 @@ void M_ReadSaveStrings(void) for (i = 0;i < load_end;i++) { - sprintf(name, SAVEGAMENAME "%d.dsg", i); + sprintf(name, "%s_%d.dsg", CGD_WADFileName, i); memcpy(fc_path, u"\\\\fls0\\", 14); for (j = 0; name[j]; j++) fc_path[j+7] = name[j]; @@ -538,7 +538,7 @@ void M_DrawSaveLoadBorder(int x,int y,int height,int count) void M_LoadSelect(int choice) { char name[64]; - sprintf(name, SAVEGAMENAME "%d.dsg", choice); + sprintf(name, "%s_%d.dsg", CGD_WADFileName, choice); G_LoadGame (name); M_ClearMenus (); }