saveload.c
changeset 2828 996de8e891c7
parent 2808 35e0e9c6c227
child 2848 cb4b1cc0bf65
equal deleted inserted replaced
2827:61e2ac8b0801 2828:996de8e891c7
  1230 	}
  1230 	}
  1231 	return def;
  1231 	return def;
  1232 }
  1232 }
  1233 
  1233 
  1234 // actual loader/saver function
  1234 // actual loader/saver function
  1235 void InitializeGame(uint size_x, uint size_y);
  1235 void InitializeGame(int mode, uint size_x, uint size_y);
  1236 extern bool AfterLoadGame(void);
  1236 extern bool AfterLoadGame(void);
  1237 extern void BeforeSaveGame(void);
  1237 extern void BeforeSaveGame(void);
  1238 extern bool LoadOldSaveGame(const char *file);
  1238 extern bool LoadOldSaveGame(const char *file);
  1239 
  1239 
  1240 /** Small helper function to close the to be loaded savegame an signal error */
  1240 /** Small helper function to close the to be loaded savegame an signal error */
  1361 	}
  1361 	}
  1362 	WaitTillSaved();
  1362 	WaitTillSaved();
  1363 
  1363 
  1364 	/* Load a TTDLX or TTDPatch game */
  1364 	/* Load a TTDLX or TTDPatch game */
  1365 	if (mode == SL_OLD_LOAD) {
  1365 	if (mode == SL_OLD_LOAD) {
  1366 		InitializeGame(256, 256); // set a mapsize of 256x256 for TTDPatch games or it might get confused
  1366 		InitializeGame(IG_DATE_RESET, 256, 256); // set a mapsize of 256x256 for TTDPatch games or it might get confused
  1367 		if (!LoadOldSaveGame(filename)) return SL_REINIT;
  1367 		if (!LoadOldSaveGame(filename)) return SL_REINIT;
  1368 		_sl_version = 0;
  1368 		_sl_version = 0;
  1369 		AfterLoadGame();
  1369 		AfterLoadGame();
  1370 		return SL_OK;
  1370 		return SL_OK;
  1371 	}
  1371 	}
  1485 		}
  1485 		}
  1486 
  1486 
  1487 		/* Old maps were hardcoded to 256x256 and thus did not contain
  1487 		/* Old maps were hardcoded to 256x256 and thus did not contain
  1488 		 * any mapsize information. Pre-initialize to 256x256 to not to
  1488 		 * any mapsize information. Pre-initialize to 256x256 to not to
  1489 		 * confuse old games */
  1489 		 * confuse old games */
  1490 		InitializeGame(256, 256);
  1490 		InitializeGame(IG_DATE_RESET, 256, 256);
  1491 
  1491 
  1492 		SlLoadChunks();
  1492 		SlLoadChunks();
  1493 		fmt->uninit_read();
  1493 		fmt->uninit_read();
  1494 		fclose(_sl.fh);
  1494 		fclose(_sl.fh);
  1495 
  1495