Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…ames/campaign/ Skirmish saves are located in savegames/skirmish/
  • Loading branch information...
commit d8789661fbffe2f648a06a0689de3a9350bbe8b0 1 parent 2d5f858
vexed authored April 02, 2012
12  src/frontend.cpp
@@ -244,7 +244,8 @@ static void startSinglePlayerMenu(void)
244 244
 	addTextButton(FRONTEND_NEWGAME,  FRONTEND_POS2X,FRONTEND_POS2Y,_("New Campaign") , WBUT_TXTCENTRE);
245 245
 	addTextButton(FRONTEND_SKIRMISH, FRONTEND_POS3X,FRONTEND_POS3Y, _("Start Skirmish Game"), WBUT_TXTCENTRE);
246 246
 	addTextButton(FRONTEND_CHALLENGES, FRONTEND_POS4X, FRONTEND_POS4Y, _("Challenges"), WBUT_TXTCENTRE);
247  
-	addTextButton(FRONTEND_LOADGAME, FRONTEND_POS5X,FRONTEND_POS5Y, _("Load Game"), WBUT_TXTCENTRE);
  247
+	addTextButton(FRONTEND_LOADGAME_MISSION, FRONTEND_POS5X,FRONTEND_POS5Y, _("Load Campaign Game"), WBUT_TXTCENTRE);
  248
+	addTextButton(FRONTEND_LOADGAME_SKIRMISH, FRONTEND_POS6X,FRONTEND_POS6Y, _("Load Skirmish Game"), WBUT_TXTCENTRE);
248 249
 
249 250
 	addSideText	 (FRONTEND_SIDETEXT ,FRONTEND_SIDEX,FRONTEND_SIDEY,_("SINGLE PLAYER"));
250 251
 	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)
317 318
 				frontEndNewGame();
318 319
 				break;
319 320
 
320  
-			case FRONTEND_LOADGAME:
  321
+			case FRONTEND_LOADGAME_MISSION:
321 322
 				SPinit();
322  
-				addLoadSave(LOAD_FRONTEND, _("Load Saved Game"));	// change mode when loadsave returns
  323
+				addLoadSave(LOAD_FRONTEND_MISSION, _("Load Campaign Saved Game"));	// change mode when loadsave returns
  324
+				break;
  325
+
  326
+			case FRONTEND_LOADGAME_SKIRMISH:
  327
+				SPinit();
  328
+				addLoadSave(LOAD_FRONTEND_SKIRMISH, _("Load Skirmish Saved Game"));	// change mode when loadsave returns
323 329
 				break;
324 330
 
325 331
 			case FRONTEND_SKIRMISH:
3  src/frontend.h
@@ -172,7 +172,8 @@ enum
172 172
 	FRONTEND_QUIT,
173 173
 	FRONTEND_FASTPLAY,					//tutorial menu option
174 174
 	FRONTEND_NEWGAME		= 20200,	// single player (menu)
175  
-	FRONTEND_LOADGAME,
  175
+	FRONTEND_LOADGAME_MISSION,
  176
+	FRONTEND_LOADGAME_SKIRMISH,
176 177
 	FRONTEND_SKIRMISH,
177 178
 	FRONTEND_CHALLENGES,
178 179
 	FRONTEND_HOST			= 20300,	//multiplayer menu options
34  src/ingameop.cpp
@@ -269,10 +269,20 @@ static bool _intAddInGameOptions(void)
269 269
 
270 270
 	if ((!bMultiPlayer || (NetPlay.bComms == 0)) && !bInTutorial)
271 271
 	{
272  
-		// add 'load'
273  
-		addIGTextButton(INTINGAMEOP_LOAD, INTINGAMEOP_1_X, INTINGAMEOP_3_Y, INTINGAMEOP_OP_W, _("Load Game"), OPALIGN);
274  
-		// add 'save'
275  
-		addIGTextButton(INTINGAMEOP_SAVE, INTINGAMEOP_1_X, INTINGAMEOP_4_Y, INTINGAMEOP_OP_W, _("Save Game"), OPALIGN);
  272
+		if (!bMultiPlayer)
  273
+		{
  274
+			// add 'load'
  275
+			addIGTextButton(INTINGAMEOP_LOAD_MISSION, INTINGAMEOP_1_X, INTINGAMEOP_3_Y, INTINGAMEOP_OP_W, _("Load Game"), OPALIGN);
  276
+			// add 'save'
  277
+			addIGTextButton(INTINGAMEOP_SAVE_MISSION, INTINGAMEOP_1_X, INTINGAMEOP_4_Y, INTINGAMEOP_OP_W, _("Save Game"), OPALIGN);
  278
+		}
  279
+		else
  280
+		{
  281
+			// add 'load'
  282
+			addIGTextButton(INTINGAMEOP_LOAD_SKIRMISH, INTINGAMEOP_1_X, INTINGAMEOP_3_Y, INTINGAMEOP_OP_W, _("Load Game"), OPALIGN);
  283
+			// add 'save'
  284
+			addIGTextButton(INTINGAMEOP_SAVE_SKIRMISH, INTINGAMEOP_1_X, INTINGAMEOP_4_Y, INTINGAMEOP_OP_W, _("Save Game"), OPALIGN);
  285
+		}
276 286
 	}
277 287
 
278 288
 	intMode		= INT_INGAMEOP;			// change interface mode.
@@ -489,15 +499,21 @@ void intProcessInGameOptions(UDWORD id)
489 499
 //			addConsoleMessage(_("GAME SAVED!"), LEFT_JUSTIFY, SYSTEM_MESSAGE);
490 500
 //		}
491 501
 //		break;
492  
-	case INTINGAMEOP_LOAD:
  502
+	case INTINGAMEOP_LOAD_MISSION:
493 503
 		intCloseInGameOptions(true, false);
494  
-		addLoadSave(LOAD_INGAME, _("Load Saved Game"));	// change mode when loadsave returns
  504
+		addLoadSave(LOAD_INGAME_MISSION, _("Load Campaign Saved Game"));	// change mode when loadsave returns
495 505
 		break;
496  
-	case INTINGAMEOP_SAVE:
  506
+	case INTINGAMEOP_LOAD_SKIRMISH:
497 507
 		intCloseInGameOptions(true, false);
498  
-		addLoadSave(SAVE_INGAME, _("Save Game"));
  508
+		addLoadSave(LOAD_INGAME_SKIRMISH, _("Load Skirmish Saved Game"));	// change mode when loadsave returns
499 509
 		break;
500  
-
  510
+	case INTINGAMEOP_SAVE_MISSION:
  511
+		intCloseInGameOptions(true, false);
  512
+		addLoadSave(SAVE_INGAME_MISSION, _("Save Campaign Game"));
  513
+		break;
  514
+	case INTINGAMEOP_SAVE_SKIRMISH:
  515
+		intCloseInGameOptions(true, false);
  516
+		addLoadSave(SAVE_INGAME_SKIRMISH, _("Save Skirmish Game"));
501 517
 	// GAME OPTIONS KEYS
502 518
 	case INTINGAMEOP_FXVOL:
503 519
 	case INTINGAMEOP_3DFXVOL:
6  src/ingameop.h
@@ -83,8 +83,10 @@ enum
83 83
 	INTINGAMEOP_QUIT = INTINGAMEOP + 1,
84 84
 	INTINGAMEOP_QUIT_CONFIRM,               ///< The all important quit button
85 85
 	INTINGAMEOP_RESUME,
86  
-	INTINGAMEOP_LOAD,
87  
-	INTINGAMEOP_SAVE,
  86
+	INTINGAMEOP_LOAD_MISSION,
  87
+	INTINGAMEOP_LOAD_SKIRMISH,
  88
+	INTINGAMEOP_SAVE_MISSION,
  89
+	INTINGAMEOP_SAVE_SKIRMISH,
88 90
 	INTINGAMEOP_OPTIONS,
89 91
 	INTINGAMEOP_FXVOL,
90 92
 	INTINGAMEOP_FXVOL_S,
69  src/loadsave.cpp
@@ -117,39 +117,51 @@ bool saveInMissionRes(void)
117 117
 // return whether the save screen was displayed in the middle of a mission
118 118
 bool saveMidMission(void)
119 119
 {
120  
-	return bLoadSaveMode == SAVE_INGAME;
  120
+	return bLoadSaveMode == SAVE_INGAME_MISSION;
121 121
 }
122 122
 
123 123
 // ////////////////////////////////////////////////////////////////////////////
124 124
 bool addLoadSave(LOADSAVE_MODE savemode, const char *title)
125 125
 {
126  
-	bool bLoad;
127  
-
  126
+	bool bLoad = true;
  127
+	char NewSaveGamePath[PATH_MAX] = {'\0'};
128 128
 	bLoadSaveMode = savemode;
129 129
 	UDWORD			slotCount;
130  
-// removed hardcoded values!  change with the defines above! -Q
131 130
 	static char	sSlotCaps[totalslots][totalslotspace];
132 131
 	static char	sSlotTips[totalslots][totalslotspace];
133 132
 	char **i, **files;
134 133
 
135 134
 	switch(savemode)
136 135
 	{
137  
-	case LOAD_FRONTEND:
138  
-	case LOAD_MISSIONEND:
139  
-	case LOAD_INGAME:
140  
-		bLoad = true;
141  
-		break;
142  
-	case SAVE_MISSIONEND:
143  
-	case SAVE_INGAME:
144  
-	default:
145  
-		bLoad = false;
146  
-		break;
  136
+		case LOAD_FRONTEND_MISSION:
  137
+		case LOAD_INGAME_MISSION:
  138
+		case LOAD_MISSIONEND:
  139
+			ssprintf(NewSaveGamePath, "%s%s/", SaveGamePath, "campaign");
  140
+			break;
  141
+		case LOAD_FRONTEND_SKIRMISH:
  142
+		case LOAD_INGAME_SKIRMISH:
  143
+			ssprintf(NewSaveGamePath, "%s%s/", SaveGamePath, "skirmish");
  144
+			break;
  145
+		case SAVE_MISSIONEND:
  146
+		case SAVE_INGAME_MISSION:
  147
+			ssprintf(NewSaveGamePath, "%s%s/", SaveGamePath, "campaign");
  148
+			bLoad = false;
  149
+			break;
  150
+		case SAVE_INGAME_SKIRMISH:
  151
+			ssprintf(NewSaveGamePath, "%s%s/", SaveGamePath, "skirmish");
  152
+			bLoad = false;
  153
+			break;
  154
+		default:
  155
+			ASSERT("Invalid load/save mode!", "Invalid load/save mode!");
  156
+			ssprintf(NewSaveGamePath, "%s%s/", SaveGamePath, "campaign");
  157
+			break;
147 158
 	}
148 159
 
149 160
 	mode = bLoad;
150 161
 	debug(LOG_SAVE, "called (%d, %s)", bLoad, title);
151 162
 
152  
-	if ((bLoadSaveMode == LOAD_INGAME) || (bLoadSaveMode == SAVE_INGAME))
  163
+	if ((bLoadSaveMode == LOAD_INGAME_MISSION) || (bLoadSaveMode == SAVE_INGAME_MISSION)
  164
+		|| (bLoadSaveMode == LOAD_INGAME_SKIRMISH) || (bLoadSaveMode == SAVE_INGAME_SKIRMISH))
153 165
 	{
154 166
 		if (!bMultiPlayer || (NetPlay.bComms ==0))
155 167
 		{
@@ -181,8 +193,6 @@ bool addLoadSave(LOADSAVE_MODE savemode, const char *title)
181 193
 		intRemoveReticule();
182 194
 	}
183 195
 
184  
-	(void) PHYSFS_mkdir(SaveGamePath); // just in case
185  
-
186 196
 	psRequestScreen = widgCreateScreen(); // init the screen
187 197
 	widgSetTipFont(psRequestScreen,font_regular);
188 198
 
@@ -277,10 +287,10 @@ bool addLoadSave(LOADSAVE_MODE savemode, const char *title)
277 287
 	// fill slots.
278 288
 	slotCount = 0;
279 289
 
280  
-	debug(LOG_SAVE, "Searching \"%s\" for savegames", SaveGamePath);
  290
+	debug(LOG_SAVE, "Searching \"%s\" for savegames", NewSaveGamePath);
281 291
 
282 292
 	// add savegame filenames minus extensions to buttons
283  
-	files = PHYSFS_enumerateFiles(SaveGamePath);
  293
+	files = PHYSFS_enumerateFiles(NewSaveGamePath);
284 294
 	for (i = files; *i != NULL; ++i)
285 295
 	{
286 296
 		W_BUTTON *button;
@@ -300,7 +310,7 @@ bool addLoadSave(LOADSAVE_MODE savemode, const char *title)
300 310
 		debug(LOG_SAVE, "We found [%s]", *i);
301 311
 
302 312
 		/* Figure save-time */
303  
-		snprintf(savefile, sizeof(savefile), "%s/%s", SaveGamePath, *i);
  313
+		snprintf(savefile, sizeof(savefile), "%s/%s", NewSaveGamePath, *i);
304 314
 		savetime = PHYSFS_getLastModTime(savefile);
305 315
 		timeinfo = localtime(&savetime);
306 316
 		strftime(sSlotTips[slotCount], sizeof(sSlotTips[slotCount]), "%x %X", timeinfo);
@@ -330,7 +340,8 @@ bool closeLoadSave(void)
330 340
 	widgDelete(psRequestScreen,LOADSAVE_FORM);
331 341
 	bLoadSaveUp = false;
332 342
 
333  
-	if ((bLoadSaveMode == LOAD_INGAME) || (bLoadSaveMode == SAVE_INGAME))
  343
+	if ((bLoadSaveMode == LOAD_INGAME_MISSION) || (bLoadSaveMode == SAVE_INGAME_MISSION)
  344
+		|| (bLoadSaveMode == LOAD_INGAME_SKIRMISH) || (bLoadSaveMode == SAVE_INGAME_SKIRMISH))
334 345
 	{
335 346
 
336 347
 		if (!bMultiPlayer || (NetPlay.bComms == 0))
@@ -410,6 +421,7 @@ bool runLoadSave(bool bResetMissionWidgets)
410 421
 	static char     sDelete[PATH_MAX];
411 422
 	UDWORD		i, campaign;
412 423
 	W_CONTEXT		context;
  424
+	char NewSaveGamePath[PATH_MAX] = {'\0'};
413 425
 
414 426
 	id = widgRunScreen(psRequestScreen);
415 427
 
@@ -420,7 +432,14 @@ bool runLoadSave(bool bResetMissionWidgets)
420 432
 	{
421 433
 		goto cleanup;
422 434
 	}
423  
-
  435
+	if (bMultiPlayer)
  436
+	{
  437
+		ssprintf(NewSaveGamePath, "%s%s/", SaveGamePath, "skirmish");
  438
+	}
  439
+	else
  440
+	{
  441
+		ssprintf(NewSaveGamePath, "%s%s/", SaveGamePath, "campaign");
  442
+	}
424 443
 	// clicked a load entry
425 444
 	if( id >= LOADENTRY_START  &&  id <= LOADENTRY_END )
426 445
 	{
@@ -429,7 +448,7 @@ bool runLoadSave(bool bResetMissionWidgets)
429 448
 		{
430 449
 			if( ((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText )
431 450
 			{
432  
-				sprintf(sRequestResult, "%s%s%s", SaveGamePath, ((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText, sExt);
  451
+				sprintf(sRequestResult, "%s%s%s", NewSaveGamePath, ((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText, sExt);
433 452
 			}
434 453
 			else
435 454
 			{
@@ -457,7 +476,7 @@ bool runLoadSave(bool bResetMissionWidgets)
457 476
 
458 477
 				if (((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText != NULL)
459 478
 				{
460  
-					snprintf(sDelete, sizeof(sDelete), "%s%s%s", SaveGamePath,
  479
+					snprintf(sDelete, sizeof(sDelete), "%s%s%s", NewSaveGamePath,
461 480
 					         ((W_BUTTON *)widgGetFromID(psRequestScreen,id))->pText, sExt);
462 481
 				}
463 482
 				else
@@ -524,7 +543,7 @@ bool runLoadSave(bool bResetMissionWidgets)
524 543
 		{
525 544
 			sstrcpy(sTemp, widgGetString(psRequestScreen, id));
526 545
 			removeWildcards(sTemp);
527  
-			snprintf(sRequestResult, sizeof(sRequestResult), "%s%s%s", SaveGamePath, sTemp, sExt);
  546
+			snprintf(sRequestResult, sizeof(sRequestResult), "%s%s%s", NewSaveGamePath, sTemp, sExt);
528 547
 			if (strlen(sDelete) != 0)
529 548
 			{
530 549
 				deleteSaveGame(sDelete);	//only delete game if a new game fills the slot
9  src/loadsave.h
@@ -29,11 +29,14 @@
29 29
 
30 30
 enum LOADSAVE_MODE
31 31
 {
32  
-LOAD_FRONTEND,
  32
+LOAD_FRONTEND_MISSION,
33 33
 LOAD_MISSIONEND,
  34
+LOAD_INGAME_MISSION,
  35
+LOAD_FRONTEND_SKIRMISH,
  36
+LOAD_INGAME_SKIRMISH,
34 37
 SAVE_MISSIONEND,
35  
-LOAD_INGAME,
36  
-SAVE_INGAME
  38
+SAVE_INGAME_MISSION,
  39
+SAVE_INGAME_SKIRMISH
37 40
 };
38 41
 
39 42
 /***************************************************************************/
2  src/main.cpp
@@ -1118,6 +1118,8 @@ int realmain(int argc, char *argv[])
1118 1118
 	/*** Initialize directory structure ***/
1119 1119
 	make_dir(ScreenDumpPath, "screenshots", NULL);
1120 1120
 	make_dir(SaveGamePath, "savegames", NULL);
  1121
+	PHYSFS_mkdir("savegames/campaign");
  1122
+	PHYSFS_mkdir("savegames/skirmish");
1121 1123
 	make_dir(MultiCustomMapsPath, "maps", NULL); // MUST have this to prevent crashes when getting map
1122 1124
 	PHYSFS_mkdir("music");
1123 1125
 	PHYSFS_mkdir("logs");		// a place to hold our netplay, mingw crash reports & WZ logs

0 notes on commit d878966

Please sign in to comment.
Something went wrong with that request. Please try again.