--- a/src/saveload.cpp Fri Apr 25 02:15:34 2008 +0000
+++ b/src/saveload.cpp Mon May 26 20:45:25 2008 +0000
@@ -30,11 +30,16 @@
#include "core/endian_func.hpp"
#include "vehicle_base.h"
#include "autoreplace_base.h"
+#include "statusbar_gui.h"
#include <list>
#include "table/strings.h"
extern const uint16 SAVEGAME_VERSION = NEWGRF_AIRPORTS_SAVEGAME;
+
+SavegameType _savegame_type; ///< type of savegame we are loading
+
+uint32 _ttdp_version; ///< version of TTDP savegame (if applicable)
uint16 _sl_version; ///< the major savegame version identifier
byte _sl_minor_version; ///< the minor savegame version, DO NOT USE!
@@ -527,7 +532,7 @@
static inline size_t SlCalcNetStringLen(const char *ptr, size_t length)
{
if (ptr == NULL) return 0;
- return minu(strlen(ptr), length - 1);
+ return min(strlen(ptr), length - 1);
}
/** Calculate the gross length of the string that it
@@ -907,7 +912,7 @@
static void SlLoadChunk(const ChunkHandler *ch)
{
byte m = SlReadByte();
- size_t len;
+ uint32 len;
uint32 endoffs;
_sl.block_mode = m;
@@ -1114,7 +1119,7 @@
static void WriteNoComp(uint size)
{
- fwrite(_sl.buf, 1, size, _sl.fh);
+ if (fwrite(_sl.buf, 1, size, _sl.fh) != size) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_WRITEABLE);
}
static bool InitNoComp()
@@ -1200,9 +1205,9 @@
_z.avail_out = 4096;
do {
- /* read more bytes from the file?*/
+ /* read more bytes from the file? */
if (_z.avail_in == 0) {
- _z.avail_in = fread(_z.next_in = _sl.buf + 4096, 1, 4096, _sl.fh);
+ _z.avail_in = (uint)fread(_z.next_in = _sl.buf + 4096, 1, 4096, _sl.fh);
}
/* inflate the data */
@@ -1489,7 +1494,7 @@
_fast_forward = 0;
if (_cursor.sprite == SPR_CURSOR_MOUSE) SetMouseCursor(SPR_CURSOR_ZZZ, PAL_NONE);
- SendWindowMessage(WC_STATUS_BAR, 0, true, 0, 0);
+ InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SAVELOAD_START);
_ts.saveinprogress = true;
}
@@ -1500,7 +1505,7 @@
_fast_forward = _ts.ff_state;
if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE);
- SendWindowMessage(WC_STATUS_BAR, 0, false, 0, 0);
+ InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SAVELOAD_FINISH);
_ts.saveinprogress = false;
}
@@ -1580,7 +1585,7 @@
if (_sl.excpt_uninit != NULL) _sl.excpt_uninit();
ShowInfo(GetSaveLoadErrorString());
- fprintf(stderr, GetSaveLoadErrorString());
+ DEBUG(sl, 0, GetSaveLoadErrorString());
if (threaded) {
SetAsyncSaveFinish(SaveFileError);
@@ -1632,6 +1637,7 @@
InitializeGame(IG_DATE_RESET, 256, 256); // set a mapsize of 256x256 for TTDPatch games or it might get confused
if (!LoadOldSaveGame(filename)) return SL_REINIT;
_sl_version = 0;
+ _sl_minor_version = 0;
if (!AfterLoadGame()) return SL_REINIT;
return SL_OK;
}
@@ -1747,6 +1753,8 @@
fmt->uninit_read();
fclose(_sl.fh);
+ _savegame_type = SGT_OTTD;
+
/* After loading fix up savegame for any internal changes that
* might've occured since then. If it fails, load back the old game */
if (!AfterLoadGame()) return SL_REINIT;