Permalink
Browse files

Savegames are now stored by type. Campaign saves are located in saveg…

…ames/campaign/ Skirmish saves are located in savegames/skirmish/
  • Loading branch information...
1 parent 2d5f858 commit d8789661fbffe2f648a06a0689de3a9350bbe8b0 @vexed vexed committed Apr 2, 2012
Showing with 92 additions and 43 deletions.
  1. +9 −3 src/frontend.cpp
  2. +2 −1 src/frontend.h
  3. +25 −9 src/ingameop.cpp
  4. +4 −2 src/ingameop.h
  5. +44 −25 src/loadsave.cpp
  6. +6 −3 src/loadsave.h
  7. +2 −0 src/main.cpp
View
@@ -244,7 +244,8 @@ static void startSinglePlayerMenu(void)
addTextButton(FRONTEND_NEWGAME, FRONTEND_POS2X,FRONTEND_POS2Y,_("New Campaign") , WBUT_TXTCENTRE);
addTextButton(FRONTEND_SKIRMISH, FRONTEND_POS3X,FRONTEND_POS3Y, _("Start Skirmish Game"), WBUT_TXTCENTRE);
addTextButton(FRONTEND_CHALLENGES, FRONTEND_POS4X, FRONTEND_POS4Y, _("Challenges"), WBUT_TXTCENTRE);
- addTextButton(FRONTEND_LOADGAME, FRONTEND_POS5X,FRONTEND_POS5Y, _("Load Game"), WBUT_TXTCENTRE);
+ addTextButton(FRONTEND_LOADGAME_MISSION, FRONTEND_POS5X,FRONTEND_POS5Y, _("Load Campaign Game"), WBUT_TXTCENTRE);
+ addTextButton(FRONTEND_LOADGAME_SKIRMISH, FRONTEND_POS6X,FRONTEND_POS6Y, _("Load Skirmish Game"), WBUT_TXTCENTRE);
addSideText (FRONTEND_SIDETEXT ,FRONTEND_SIDEX,FRONTEND_SIDEY,_("SINGLE PLAYER"));
addMultiBut(psWScreen, FRONTEND_BOTFORM, FRONTEND_QUIT, 10, 10, 30, 29, P_("menu", "Return"), IMAGE_RETURN, IMAGE_RETURN_HI, IMAGE_RETURN_HI);
@@ -317,9 +318,14 @@ bool runSinglePlayerMenu(void)
frontEndNewGame();
break;
- case FRONTEND_LOADGAME:
+ case FRONTEND_LOADGAME_MISSION:
SPinit();
- addLoadSave(LOAD_FRONTEND, _("Load Saved Game")); // change mode when loadsave returns
+ addLoadSave(LOAD_FRONTEND_MISSION, _("Load Campaign Saved Game")); // change mode when loadsave returns
+ break;
+
+ case FRONTEND_LOADGAME_SKIRMISH:
+ SPinit();
+ addLoadSave(LOAD_FRONTEND_SKIRMISH, _("Load Skirmish Saved Game")); // change mode when loadsave returns
break;
case FRONTEND_SKIRMISH:
View
@@ -172,7 +172,8 @@ enum
FRONTEND_QUIT,
FRONTEND_FASTPLAY, //tutorial menu option
FRONTEND_NEWGAME = 20200, // single player (menu)
- FRONTEND_LOADGAME,
+ FRONTEND_LOADGAME_MISSION,
+ FRONTEND_LOADGAME_SKIRMISH,
FRONTEND_SKIRMISH,
FRONTEND_CHALLENGES,
FRONTEND_HOST = 20300, //multiplayer menu options
View
@@ -269,10 +269,20 @@ static bool _intAddInGameOptions(void)
if ((!bMultiPlayer || (NetPlay.bComms == 0)) && !bInTutorial)
{
- // add 'load'
- addIGTextButton(INTINGAMEOP_LOAD, INTINGAMEOP_1_X, INTINGAMEOP_3_Y, INTINGAMEOP_OP_W, _("Load Game"), OPALIGN);
- // add 'save'
- addIGTextButton(INTINGAMEOP_SAVE, INTINGAMEOP_1_X, INTINGAMEOP_4_Y, INTINGAMEOP_OP_W, _("Save Game"), OPALIGN);
+ if (!bMultiPlayer)
+ {
+ // add 'load'
+ addIGTextButton(INTINGAMEOP_LOAD_MISSION, INTINGAMEOP_1_X, INTINGAMEOP_3_Y, INTINGAMEOP_OP_W, _("Load Game"), OPALIGN);
+ // add 'save'
+ addIGTextButton(INTINGAMEOP_SAVE_MISSION, INTINGAMEOP_1_X, INTINGAMEOP_4_Y, INTINGAMEOP_OP_W, _("Save Game"), OPALIGN);
+ }
+ else
+ {
+ // add 'load'
+ addIGTextButton(INTINGAMEOP_LOAD_SKIRMISH, INTINGAMEOP_1_X, INTINGAMEOP_3_Y, INTINGAMEOP_OP_W, _("Load Game"), OPALIGN);
+ // add 'save'
+ addIGTextButton(INTINGAMEOP_SAVE_SKIRMISH, INTINGAMEOP_1_X, INTINGAMEOP_4_Y, INTINGAMEOP_OP_W, _("Save Game"), OPALIGN);
+ }
}
intMode = INT_INGAMEOP; // change interface mode.
@@ -489,15 +499,21 @@ void intProcessInGameOptions(UDWORD id)
// addConsoleMessage(_("GAME SAVED!"), LEFT_JUSTIFY, SYSTEM_MESSAGE);
// }
// break;
- case INTINGAMEOP_LOAD:
+ case INTINGAMEOP_LOAD_MISSION:
intCloseInGameOptions(true, false);
- addLoadSave(LOAD_INGAME, _("Load Saved Game")); // change mode when loadsave returns
+ addLoadSave(LOAD_INGAME_MISSION, _("Load Campaign Saved Game")); // change mode when loadsave returns
break;
- case INTINGAMEOP_SAVE:
+ case INTINGAMEOP_LOAD_SKIRMISH:
intCloseInGameOptions(true, false);
- addLoadSave(SAVE_INGAME, _("Save Game"));
+ addLoadSave(LOAD_INGAME_SKIRMISH, _("Load Skirmish Saved Game")); // change mode when loadsave returns
break;
-
+ case INTINGAMEOP_SAVE_MISSION:
+ intCloseInGameOptions(true, false);
+ addLoadSave(SAVE_INGAME_MISSION, _("Save Campaign Game"));
+ break;
+ case INTINGAMEOP_SAVE_SKIRMISH:
+ intCloseInGameOptions(true, false);
+ addLoadSave(SAVE_INGAME_SKIRMISH, _("Save Skirmish Game"));
// GAME OPTIONS KEYS
case INTINGAMEOP_FXVOL:
case INTINGAMEOP_3DFXVOL:
View
@@ -83,8 +83,10 @@ enum
INTINGAMEOP_QUIT = INTINGAMEOP + 1,
INTINGAMEOP_QUIT_CONFIRM, ///< The all important quit button
INTINGAMEOP_RESUME,
- INTINGAMEOP_LOAD,
- INTINGAMEOP_SAVE,
+ INTINGAMEOP_LOAD_MISSION,
+ INTINGAMEOP_LOAD_SKIRMISH,
+ INTINGAMEOP_SAVE_MISSION,
+ INTINGAMEOP_SAVE_SKIRMISH,
INTINGAMEOP_OPTIONS,
INTINGAMEOP_FXVOL,
INTINGAMEOP_FXVOL_S,
View
@@ -117,39 +117,51 @@ bool saveInMissionRes(void)
// return whether the save screen was displayed in the middle of a mission
bool saveMidMission(void)
{
- return bLoadSaveMode == SAVE_INGAME;
+ return bLoadSaveMode == SAVE_INGAME_MISSION;
}
// ////////////////////////////////////////////////////////////////////////////
bool addLoadSave(LOADSAVE_MODE savemode, const char *title)
{
- bool bLoad;
-
+ bool bLoad = true;
+ char NewSaveGamePath[PATH_MAX] = {'\0'};
bLoadSaveMode = savemode;
UDWORD slotCount;
-// removed hardcoded values! change with the defines above! -Q
static char sSlotCaps[totalslots][totalslotspace];
static char sSlotTips[totalslots][totalslotspace];
char **i, **files;
switch(savemode)
{
- case LOAD_FRONTEND:
- case LOAD_MISSIONEND:
- case LOAD_INGAME:
- bLoad = true;
- break;
- case SAVE_MISSIONEND:
- case SAVE_INGAME:
- default:
- bLoad = false;
- break;
+ case LOAD_FRONTEND_MISSION:
+ case LOAD_INGAME_MISSION:
+ case LOAD_MISSIONEND:
+ ssprintf(NewSaveGamePath, "%s%s/", SaveGamePath, "campaign");
+ break;
+ case LOAD_FRONTEND_SKIRMISH:
+ case LOAD_INGAME_SKIRMISH:
+ ssprintf(NewSaveGamePath, "%s%s/", SaveGamePath, "skirmish");
+ break;
+ case SAVE_MISSIONEND:
+ case SAVE_INGAME_MISSION:
+ ssprintf(NewSaveGamePath, "%s%s/", SaveGamePath, "campaign");
+ bLoad = false;
+ break;
+ case SAVE_INGAME_SKIRMISH:
+ ssprintf(NewSaveGamePath, "%s%s/", SaveGamePath, "skirmish");
+ bLoad = false;
+ break;
+ default:
+ ASSERT("Invalid load/save mode!", "Invalid load/save mode!");
+ ssprintf(NewSaveGamePath, "%s%s/", SaveGamePath, "campaign");
+ break;
}
mode = bLoad;
debug(LOG_SAVE, "called (%d, %s)", bLoad, title);
- if ((bLoadSaveMode == LOAD_INGAME) || (bLoadSaveMode == SAVE_INGAME))
+ if ((bLoadSaveMode == LOAD_INGAME_MISSION) || (bLoadSaveMode == SAVE_INGAME_MISSION)
+ || (bLoadSaveMode == LOAD_INGAME_SKIRMISH) || (bLoadSaveMode == SAVE_INGAME_SKIRMISH))
{
if (!bMultiPlayer || (NetPlay.bComms ==0))
{
@@ -181,8 +193,6 @@ bool addLoadSave(LOADSAVE_MODE savemode, const char *title)
intRemoveReticule();
}
- (void) PHYSFS_mkdir(SaveGamePath); // just in case
-
psRequestScreen = widgCreateScreen(); // init the screen
widgSetTipFont(psRequestScreen,font_regular);
@@ -277,10 +287,10 @@ bool addLoadSave(LOADSAVE_MODE savemode, const char *title)
// fill slots.
slotCount = 0;
- debug(LOG_SAVE, "Searching \"%s\" for savegames", SaveGamePath);
+ debug(LOG_SAVE, "Searching \"%s\" for savegames", NewSaveGamePath);
// add savegame filenames minus extensions to buttons
- files = PHYSFS_enumerateFiles(SaveGamePath);
+ files = PHYSFS_enumerateFiles(NewSaveGamePath);
for (i = files; *i != NULL; ++i)
{
W_BUTTON *button;
@@ -300,7 +310,7 @@ bool addLoadSave(LOADSAVE_MODE savemode, const char *title)
debug(LOG_SAVE, "We found [%s]", *i);
/* Figure save-time */
- snprintf(savefile, sizeof(savefile), "%s/%s", SaveGamePath, *i);
+ snprintf(savefile, sizeof(savefile), "%s/%s", NewSaveGamePath, *i);
savetime = PHYSFS_getLastModTime(savefile);
timeinfo = localtime(&savetime);
strftime(sSlotTips[slotCount], sizeof(sSlotTips[slotCount]), "%x %X", timeinfo);
@@ -330,7 +340,8 @@ bool closeLoadSave(void)
widgDelete(psRequestScreen,LOADSAVE_FORM);
bLoadSaveUp = false;
- if ((bLoadSaveMode == LOAD_INGAME) || (bLoadSaveMode == SAVE_INGAME))
+ if ((bLoadSaveMode == LOAD_INGAME_MISSION) || (bLoadSaveMode == SAVE_INGAME_MISSION)
+ || (bLoadSaveMode == LOAD_INGAME_SKIRMISH) || (bLoadSaveMode == SAVE_INGAME_SKIRMISH))
{
if (!bMultiPlayer || (NetPlay.bComms == 0))
@@ -410,6 +421,7 @@ bool runLoadSave(bool bResetMissionWidgets)
static char sDelete[PATH_MAX];
UDWORD i, campaign;
W_CONTEXT context;
+ char NewSaveGamePath[PATH_MAX] = {'\0'};
id = widgRunScreen(psRequestScreen);
@@ -420,7 +432,14 @@ bool runLoadSave(bool bResetMissionWidgets)
{
goto cleanup;
}
-
+ if (bMultiPlayer)
+ {
+ ssprintf(NewSaveGamePath, "%s%s/", SaveGamePath, "skirmish");
+ }
+ else
+ {
+ ssprintf(NewSaveGamePath, "%s%s/", SaveGamePath, "campaign");
+ }
// clicked a load entry
if( id >= LOADENTRY_START && id <= LOADENTRY_END )
{
@@ -429,7 +448,7 @@ bool runLoadSave(bool bResetMissionWidgets)
{
if( ((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText )
{
- sprintf(sRequestResult, "%s%s%s", SaveGamePath, ((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText, sExt);
+ sprintf(sRequestResult, "%s%s%s", NewSaveGamePath, ((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText, sExt);
}
else
{
@@ -457,7 +476,7 @@ bool runLoadSave(bool bResetMissionWidgets)
if (((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText != NULL)
{
- snprintf(sDelete, sizeof(sDelete), "%s%s%s", SaveGamePath,
+ snprintf(sDelete, sizeof(sDelete), "%s%s%s", NewSaveGamePath,
((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText, sExt);
}
else
@@ -524,7 +543,7 @@ bool runLoadSave(bool bResetMissionWidgets)
{
sstrcpy(sTemp, widgGetString(psRequestScreen, id));
removeWildcards(sTemp);
- snprintf(sRequestResult, sizeof(sRequestResult), "%s%s%s", SaveGamePath, sTemp, sExt);
+ snprintf(sRequestResult, sizeof(sRequestResult), "%s%s%s", NewSaveGamePath, sTemp, sExt);
if (strlen(sDelete) != 0)
{
deleteSaveGame(sDelete); //only delete game if a new game fills the slot
View
@@ -29,11 +29,14 @@
enum LOADSAVE_MODE
{
-LOAD_FRONTEND,
+LOAD_FRONTEND_MISSION,
LOAD_MISSIONEND,
+LOAD_INGAME_MISSION,
+LOAD_FRONTEND_SKIRMISH,
+LOAD_INGAME_SKIRMISH,
SAVE_MISSIONEND,
-LOAD_INGAME,
-SAVE_INGAME
+SAVE_INGAME_MISSION,
+SAVE_INGAME_SKIRMISH
};
/***************************************************************************/
View
@@ -1118,6 +1118,8 @@ int realmain(int argc, char *argv[])
/*** Initialize directory structure ***/
make_dir(ScreenDumpPath, "screenshots", NULL);
make_dir(SaveGamePath, "savegames", NULL);
+ PHYSFS_mkdir("savegames/campaign");
+ PHYSFS_mkdir("savegames/skirmish");
make_dir(MultiCustomMapsPath, "maps", NULL); // MUST have this to prevent crashes when getting map
PHYSFS_mkdir("music");
PHYSFS_mkdir("logs"); // a place to hold our netplay, mingw crash reports & WZ logs

0 comments on commit d878966

Please sign in to comment.