(svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.

- Fix: also fix an unnoticed error in SlSaveLoadConv() due to wrong types.
pull/155/head
Darkvater 19 years ago
parent edf7a3be82
commit f4f5cb93f8

@ -103,7 +103,7 @@ void InitializeDepot(void)
}
static const byte _depot_desc[] = {
static const SaveLoad _depot_desc[] = {
SLE_CONDVAR(Depot, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
SLE_CONDVAR(Depot, xy, SLE_UINT32, 6, 255),
SLE_VAR(Depot,town_index, SLE_UINT16),

@ -1065,7 +1065,7 @@ no_add:;
InvalidateWindow(WC_SUBSIDIES_LIST, 0);
}
static const byte _subsidies_desc[] = {
static const SaveLoad _subsidies_desc[] = {
SLE_VAR(Subsidy,cargo_type, SLE_UINT8),
SLE_VAR(Subsidy,age, SLE_UINT8),
SLE_CONDVAR(Subsidy,from, SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
@ -1650,7 +1650,7 @@ static void SaveLoad_CAPR(void)
SlArray(&_cargo_payment_rates_frac, NUM_CARGO, SLE_UINT16);
}
static const byte _economy_desc[] = {
static const SaveLoad _economy_desc[] = {
SLE_VAR(Economy,max_loan, SLE_INT32),
SLE_VAR(Economy,max_loan_unround, SLE_INT32),
SLE_VAR(Economy,fluct, SLE_FILE_I16 | SLE_VAR_I32),
@ -1663,7 +1663,7 @@ static const byte _economy_desc[] = {
// Economy variables
static void SaveLoad_ECMY(void)
{
SlObject(&_economy, &_economy_desc);
SlObject(&_economy, _economy_desc);
}
const ChunkHandler _economy_chunk_handlers[] = {

@ -927,7 +927,7 @@ int GetPlayerMaxRailtype(int p)
}
static const byte _engine_desc[] = {
static const SaveLoad _engine_desc[] = {
SLE_VAR(Engine,intro_date, SLE_UINT16),
SLE_VAR(Engine,age, SLE_UINT16),
SLE_VAR(Engine,reliability, SLE_UINT16),

@ -1945,7 +1945,7 @@ const TileTypeProcs _tile_type_industry_procs = {
GetSlopeTileh_Industry, /* get_slope_tileh_proc */
};
static const byte _industry_desc[] = {
static const SaveLoad _industry_desc[] = {
SLE_CONDVAR(Industry, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
SLE_CONDVAR(Industry, xy, SLE_UINT32, 6, 255),
SLE_VAR(Industry,width, SLE_UINT8),

@ -766,7 +766,7 @@ static void Load_NAME(void)
}
}
static const byte _game_opt_desc[] = {
static const SaveLoad _game_opt_desc[] = {
// added a new difficulty option (town attitude) in version 4
SLE_CONDARR(GameOptions,diff, SLE_FILE_I16 | SLE_VAR_I32, 17, 0, 3),
SLE_CONDARR(GameOptions,diff, SLE_FILE_I16 | SLE_VAR_I32, 18, 4, 255),

@ -7,7 +7,6 @@
#include "gfx.h"
#include "window.h"
#include "gui.h"
#include "saveload.h"
#include "economy.h"
#include "network.h"

@ -4,7 +4,6 @@
#include "strings.h"
#include "table/sprites.h"
#include "network.h"
#include "saveload.h"
#include "hal.h" // for file list

@ -1088,7 +1088,7 @@ void InitializeOrders(void)
_backup_orders_tile = 0;
}
static const byte _order_desc[] = {
static const SaveLoad _order_desc[] = {
SLE_VAR(Order,type, SLE_UINT8),
SLE_VAR(Order,flags, SLE_UINT8),
SLE_VAR(Order,station, SLE_UINT16),

@ -951,7 +951,7 @@ void LoadFromHighScore(void)
}
// Save/load of players
static const byte _player_desc[] = {
static const SaveLoad _player_desc[] = {
SLE_VAR(Player,name_2, SLE_UINT32),
SLE_VAR(Player,name_1, SLE_STRINGID),
@ -1000,7 +1000,7 @@ static const byte _player_desc[] = {
SLE_END()
};
static const byte _player_economy_desc[] = {
static const SaveLoad _player_economy_desc[] = {
// these were changed to 64-bit in savegame format 2
SLE_CONDVAR(PlayerEconomyEntry,income, SLE_INT32, 0, 1),
SLE_CONDVAR(PlayerEconomyEntry,expenses, SLE_INT32, 0, 1),
@ -1015,7 +1015,7 @@ static const byte _player_economy_desc[] = {
SLE_END()
};
static const byte _player_ai_desc[] = {
static const SaveLoad _player_ai_desc[] = {
SLE_VAR(PlayerAI,state, SLE_UINT8),
SLE_VAR(PlayerAI,tick, SLE_UINT8),
SLE_CONDVAR(PlayerAI,state_counter, SLE_FILE_U16 | SLE_VAR_U32, 0, 12),
@ -1059,7 +1059,7 @@ static const byte _player_ai_desc[] = {
SLE_END()
};
static const byte _player_ai_build_rec_desc[] = {
static const SaveLoad _player_ai_build_rec_desc[] = {
SLE_CONDVAR(AiBuildRec,spec_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
SLE_CONDVAR(AiBuildRec,spec_tile, SLE_UINT32, 6, 255),
SLE_CONDVAR(AiBuildRec,use_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),

File diff suppressed because it is too large Load Diff

@ -13,7 +13,6 @@ typedef struct SaveLoadGlobVarList {
byte to_version;
} SaveLoadGlobVarList;
typedef struct {
uint32 id;
ChunkSaveLoadProc *save_proc;
@ -28,62 +27,63 @@ typedef struct {
typedef void WriterProc(uint len);
typedef uint ReaderProc(void);
typedef uint ReferenceToIntProc(void *v, uint t);
typedef void *IntToReferenceProc(uint r, uint t);
typedef enum SLRefType {
REF_ORDER = 0,
REF_VEHICLE = 1,
REF_STATION = 2,
REF_TOWN = 3,
REF_VEHICLE_OLD = 4,
REF_ROADSTOPS = 5
} SLRefType;
typedef uint ReferenceToIntProc(const void *obj, SLRefType rt);
typedef void *IntToReferenceProc(uint index, SLRefType rt);
typedef struct {
bool save;
byte need_length;
byte block_mode;
bool error;
byte version;
uint16 full_version;
typedef struct SaveLoad SaveLoad;
int obj_len;
int array_index, last_array_index;
/** The saveload struct, containing reader-writer functions, bufffer, version, etc. */
typedef struct {
bool save; /// are we doing a save or a load atm. True when saving
byte need_length; /// ???
byte block_mode; /// ???
bool error; /// did an error occur or not
byte version; /// the major savegame version identifier
uint16 full_version; /// the full version of the savegame
uint32 offs_base;
int obj_len; /// the length of the current object we are busy with
int array_index, last_array_index; /// in the case of an array, the current and last positions
WriterProc *write_bytes;
ReaderProc *read_bytes;
uint32 offs_base; /// the offset in number of bytes since we started writing data (eg uncompressed savegame size)
ReferenceToIntProc *ref_to_int_proc;
IntToReferenceProc *int_to_ref_proc;
WriterProc *write_bytes; /// savegame writer function
ReaderProc *read_bytes; /// savegame loader function
const ChunkHandler * const * chs;
const byte * const *includes;
ReferenceToIntProc *ref_to_int_proc; /// function to convert pointers to numbers when saving a game
IntToReferenceProc *int_to_ref_proc; /// function to convert numbers to pointers when loading a game
byte *bufp, *bufe;
const ChunkHandler* const *chs; /// the chunk of data that is being processed atm (vehicles, signs, etc.)
const SaveLoad* const *includes; /// the internal layouf of the given chunk
int tmp;
/** When saving/loading savegames, they are always saved to a temporary memory-place
* to be flushed to file (save) or to final place (load) when full. */
byte *bufp, *bufe; /// bufp(ointer) gives the current position in the buffer bufe(nd) gives the end of the buffer
// these 3 may be used by compressor/decompressors.
byte *buf; // pointer and size to read/write, initialized by init
uint bufsize;
FILE *fh;
byte *buf; /// pointer to temporary memory to read/write, initialized by SaveLoadFormat->initread/write
uint bufsize; /// the size of the temporary memory *buf
FILE *fh; /// the file from which is read or written to
void (*excpt_uninit)(void);
const char *excpt_msg;
jmp_buf excpt; // used to jump to "exception handler"
void (*excpt_uninit)(void); /// the function to execute on any encountered error
const char *excpt_msg; /// the error message
jmp_buf excpt; /// @todo used to jump to "exception handler"; really ugly
} SaverLoader;
extern SaverLoader _sl;
enum {
REF_ORDER = 0,
REF_VEHICLE = 1,
REF_STATION = 2,
REF_TOWN = 3,
REF_VEHICLE_OLD = 4,
REF_ROADSTOPS = 5
};
enum {
INC_VEHICLE_COMMON = 0,
};
enum {
CH_RIFF = 0,
CH_ARRAY = 1,
@ -99,9 +99,9 @@ enum {
CH_NUM_PRI_LEVELS = 4,
};
enum {
SLE_FILE_I8 = 0,
SLE_FILE_U8 = 1,
typedef enum VarTypes {
SLE_FILE_I8 = 0,
SLE_FILE_U8 = 1,
SLE_FILE_I16 = 2,
SLE_FILE_U16 = 3,
SLE_FILE_I32 = 4,
@ -113,63 +113,88 @@ enum {
// SLE_FILE_IVAR = 8,
// SLE_FILE_UVAR = 9,
SLE_VAR_I8 = 0 << 4,
SLE_VAR_U8 = 1 << 4,
SLE_VAR_I16 = 2 << 4,
SLE_VAR_U16 = 3 << 4,
SLE_VAR_I32 = 4 << 4,
SLE_VAR_U32 = 5 << 4,
SLE_VAR_I64 = 6 << 4,
SLE_VAR_U64 = 7 << 4,
SLE_VAR_I8 = 0 << 4,
SLE_VAR_U8 = 1 << 4,
SLE_VAR_I16 = 2 << 4,
SLE_VAR_U16 = 3 << 4,
SLE_VAR_I32 = 4 << 4,
SLE_VAR_U32 = 5 << 4,
SLE_VAR_I64 = 6 << 4,
SLE_VAR_U64 = 7 << 4,
SLE_VAR_NULL = 8 << 4, // useful to write zeros in savegame.
SLE_VAR_INT = SLE_VAR_I32,
SLE_VAR_INT = SLE_VAR_I32,
SLE_VAR_UINT = SLE_VAR_U32,
SLE_INT8 = SLE_FILE_I8 | SLE_VAR_I8,
SLE_UINT8 = SLE_FILE_U8 | SLE_VAR_U8,
SLE_INT16 = SLE_FILE_I16 | SLE_VAR_I16,
SLE_INT8 = SLE_FILE_I8 | SLE_VAR_I8,
SLE_UINT8 = SLE_FILE_U8 | SLE_VAR_U8,
SLE_INT16 = SLE_FILE_I16 | SLE_VAR_I16,
SLE_UINT16 = SLE_FILE_U16 | SLE_VAR_U16,
SLE_INT32 = SLE_FILE_I32 | SLE_VAR_I32,
SLE_INT32 = SLE_FILE_I32 | SLE_VAR_I32,
SLE_UINT32 = SLE_FILE_U32 | SLE_VAR_U32,
SLE_INT64 = SLE_FILE_I64 | SLE_VAR_I64,
SLE_INT64 = SLE_FILE_I64 | SLE_VAR_I64,
SLE_UINT64 = SLE_FILE_U64 | SLE_VAR_U64,
SLE_STRINGID = SLE_FILE_STRINGID | SLE_VAR_U16,
} VarType;
enum SaveLoadTypes {
SL_VAR = 0,
SL_REF = 1,
SL_ARR = 2,
SL_CONDVAR = 0 | (1 << 2), // 4
SL_CONDREF = 1 | (1 << 2), // 5
SL_CONDARR = 2 | (1 << 2), // 6
// non-normal save-load types
SL_WRITEBYTE = 8,
SL_INCLUDE = 9,
SL_END = 15
};
#define SLE_VAR(t,i,c) 0 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c
#define SLE_REF(t,i,c) 0x10 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c
#define SLE_ARR(t,i,c,l) 0x20 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c, l
#define SLE_CONDVAR(t,i,c,from,to) 0x40 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c, from, to
#define SLE_CONDREF(t,i,c,from,to) 0x50 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c, from, to
#define SLE_CONDARR(t,i,c,l,from,to) 0x60 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c, from,to, l
#define SLE_WRITEBYTE(t,i,b,c) 0x80 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, b, c
#define SLE_INCLUDE(t,i,c) 0x90 | (offsetof(t,i) & 0xF), offsetof(t,i) >> 4, c
#define SLE_VARX(t,c) 0x00 | ((t) & 0xF), (t) >> 4, c
#define SLE_REFX(t,c) 0x10 | ((t) & 0xF), (t) >> 4, c
#define SLE_CONDVARX(t,c,from,to) 0x40 | ((t) & 0xF), (t) >> 4, c, from, to
#define SLE_CONDREFX(t,c,from,to) 0x50 | ((t) & 0xF), (t) >> 4, c, from, to
#define SLE_WRITEBYTEX(t,b) 0x80 | ((t) & 0xF), (t) >> 4, b
#define SLE_INCLUDEX(t,c) 0x90 | ((t) & 0xF), (t) >> 4, c
#define SLE_END() 0xF0
/** SaveLoad type struct. Do NOT use this directly but use the SLE_ macros defined just below! */
struct SaveLoad {
byte cmd; /// the action to take with the saved/loaded type, All types need different action
VarType type; /// type of the variable to be saved, int
uint16 offset; /// offset of this variable in the struct (max offset is 65536)
uint16 length; /// (conditional) length of the variable (eg. arrays) (max array size is 65536 elements)
uint16 version_from; /// save/load the variable starting from this savegame version
uint16 version_to; /// save/load the variable until this savegame version
};
/* Simple variables, references (pointers) and arrays */
#define SLE_VAR(base, variable, type) {SL_VAR, type, offsetof(base, variable), 0, 0, 0}
#define SLE_REF(base, variable, type) {SL_REF, type, offsetof(base, variable), 0, 0, 0}
#define SLE_ARR(base, variable, type, length) {SL_ARR, type, offsetof(base, variable), length, 0, 0}
/* Conditional variables, references (pointers) and arrays that are only valid for certain savegame versions */
#define SLE_CONDVAR(base, variable, type, from, to) {SL_CONDVAR, type, offsetof(base, variable), 0, from, to}
#define SLE_CONDREF(base, variable, type, from, to) {SL_CONDREF, type, offsetof(base, variable), 0, from, to}
#define SLE_CONDARR(base, variable, type, length, from, to) {SL_CONDARR, type, offsetof(base, variable), length, from, to}
/* Translate values ingame to different values in the savegame and vv */
#define SLE_WRITEBYTE(base, variable, game_value, file_value) {SL_WRITEBYTE, 0, offsetof(base, variable), 0, game_value, file_value}
/* Load common code and put it into each struct (currently only for vehicles */
#define SLE_INCLUDE(base, variable, include_index) {SL_INCLUDE, 0, offsetof(base, variable), 0, include_index, 0}
/* The same as the ones at the top, only the offset is given directly; used for unions */
#define SLE_VARX(offset, type) {SL_VAR, type, offset, 0, 0, 0}
#define SLE_REFX(offset, type) {SL_REF, type, offset, 0, 0, 0}
#define SLE_CONDVARX(offset, type, from, to) {SL_CONDVAR, type, offset, 0, from, to}
#define SLE_CONDREFX(offset, type, from, to) {SL_CONDREF, type, offset, 0, from, to}
#define SLE_WRITEBYTEX(offset, something) {SL_WRITEBYTE, 0, offset, 0, something, 0}
#define SLE_INCLUDEX(offset, type) {SL_INCLUDE, type, offset, 0, 0, 0}
/* End marker */
#define SLE_END() {SL_END, 0, 0, 0, 0, 0}
void SlSetArrayIndex(uint index);
int SlIterateArray(void);
void SlArray(void *array, uint length, uint conv);
void SlObject(void *object, const void *desc);
void SlObject(void *object, const SaveLoad *desc);
void SlAutolength(AutolengthProc *proc, void *arg);
uint SlGetFieldLength(void);
int SlReadByte(void);
void SlSetLength(uint length);
void SlWriteByte(byte v);
void SlSetLength(size_t length);
void SlWriteByte(byte b);
void SlGlobList(const SaveLoadGlobVarList *desc);
//int GetSavegameType(char *file);
#endif /* SAVELOAD_H */

@ -439,7 +439,7 @@ static uint32 ConvertSdlKeyIntoMy(SDL_keysym *sym)
return (key << 16) + sym->unicode;
}
void DoExitSave(void);
extern void DoExitSave(void);
static int PollEvent(void)
{

@ -216,7 +216,7 @@ void InitializeSigns(void)
AddBlockToPool(&_sign_pool);
}
static const byte _sign_desc[] = {
static const SaveLoad _sign_desc[] = {
SLE_VAR(SignStruct,str, SLE_UINT16),
SLE_CONDVAR(SignStruct,x, SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
SLE_CONDVAR(SignStruct,y, SLE_FILE_I16 | SLE_VAR_I32, 0, 4),

@ -2966,7 +2966,7 @@ const TileTypeProcs _tile_type_station_procs = {
GetSlopeTileh_Station, /* get_slope_tileh_proc */
};
static const byte _roadstop_desc[] = {
static const SaveLoad _roadstop_desc[] = {
SLE_VAR(RoadStop,xy, SLE_UINT32),
SLE_VAR(RoadStop,used, SLE_UINT8),
SLE_VAR(RoadStop,status, SLE_UINT8),
@ -2983,7 +2983,7 @@ static const byte _roadstop_desc[] = {
SLE_END()
};
static const byte _station_desc[] = {
static const SaveLoad _station_desc[] = {
SLE_CONDVAR(Station, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
SLE_CONDVAR(Station, xy, SLE_UINT32, 6, 255),
SLE_CONDVAR(Station, bus_tile_obsolete, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
@ -3036,7 +3036,7 @@ static const byte _station_desc[] = {
SLE_END()
};
static const byte _goods_desc[] = {
static const SaveLoad _goods_desc[] = {
SLE_VAR(GoodsEntry,waiting_acceptance,SLE_UINT16),
SLE_VAR(GoodsEntry,days_since_pickup, SLE_UINT8),
SLE_VAR(GoodsEntry,rating, SLE_UINT8),

@ -72,7 +72,7 @@
//#include <alloca.h>
//#include <malloc.h>
# define __int64 long long
# define NOT_REACHED()
# define NOT_REACHED() assert(0)
# define GCC_PACK __attribute__((packed))
# if (__GNUC__ == 2)
@ -85,7 +85,7 @@
# define NORETURN
# define FORCEINLINE inline
# define CDECL
# define NOT_REACHED()
# define NOT_REACHED() assert(0)
# define GCC_PACK
# undef TTD_ALIGNMENT_4
# undef TTD_ALIGNMENT_2
@ -104,7 +104,11 @@
# define FORCEINLINE __forceinline
# define inline _inline
# define CDECL _cdecl
# define NOT_REACHED() _assume(0)
# if defined(_DEBUG)
# define NOT_REACHED() assert(0)
# else
# define NOT_REACHED() _assume(0)
# endif
int CDECL snprintf(char *str, size_t size, const char *format, ...);
int CDECL vsnprintf(char *str, size_t size, const char *format, va_list ap);
# undef TTD_ALIGNMENT_4

@ -368,10 +368,9 @@ void InitializeAnimatedTiles(void)
static void SaveLoad_ANIT(void)
{
if (_sl.version < 6)
SlArray(_animated_tile_list, lengthof(_animated_tile_list),
SLE_FILE_U16 | SLE_VAR_U32);
else
if (_sl.version < 6) {
SlArray(_animated_tile_list, lengthof(_animated_tile_list), SLE_FILE_U16 | SLE_VAR_U32);
} else
SlArray(_animated_tile_list, lengthof(_animated_tile_list), SLE_UINT32);
}

@ -1973,7 +1973,7 @@ const TileTypeProcs _tile_type_town_procs = {
// Save and load of towns.
static const byte _town_desc[] = {
static const SaveLoad _town_desc[] = {
SLE_CONDVAR(Town, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
SLE_CONDVAR(Town, xy, SLE_UINT32, 6, 255),

@ -27,7 +27,6 @@
#include "fileio.h"
#include "hal.h"
#include "airport.h"
#include "saveload.h"
#include "ai.h"
#include "console.h"
#include "screenshot.h"

@ -1815,7 +1815,7 @@ restart:
// Save and load of vehicles
const byte _common_veh_desc[] = {
const SaveLoad _common_veh_desc[] = {
SLE_VAR(Vehicle,subtype, SLE_UINT8),
SLE_REF(Vehicle,next, REF_VEHICLE_OLD),
@ -1912,7 +1912,7 @@ const byte _common_veh_desc[] = {
};
static const byte _train_desc[] = {
static const SaveLoad _train_desc[] = {
SLE_WRITEBYTE(Vehicle,type,VEH_Train, 0), // Train type. VEH_Train in mem, 0 in file.
SLE_INCLUDEX(0, INC_VEHICLE_COMMON),
SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleRail,crash_anim_pos), SLE_UINT16),
@ -1929,7 +1929,7 @@ static const byte _train_desc[] = {
SLE_END()
};
static const byte _roadveh_desc[] = {
static const SaveLoad _roadveh_desc[] = {
SLE_WRITEBYTE(Vehicle,type,VEH_Road, 1), // Road type. VEH_Road in mem, 1 in file.
SLE_INCLUDEX(0, INC_VEHICLE_COMMON),
SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleRoad,state), SLE_UINT8),
@ -1949,7 +1949,7 @@ static const byte _roadveh_desc[] = {
SLE_END()
};
static const byte _ship_desc[] = {
static const SaveLoad _ship_desc[] = {
SLE_WRITEBYTE(Vehicle,type,VEH_Ship, 2), // Ship type. VEH_Ship in mem, 2 in file.
SLE_INCLUDEX(0, INC_VEHICLE_COMMON),
SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleShip,state), SLE_UINT8),
@ -1960,7 +1960,7 @@ static const byte _ship_desc[] = {
SLE_END()
};
static const byte _aircraft_desc[] = {
static const SaveLoad _aircraft_desc[] = {
SLE_WRITEBYTE(Vehicle,type,VEH_Aircraft, 3), // Aircraft type. VEH_Aircraft in mem, 3 in file.
SLE_INCLUDEX(0, INC_VEHICLE_COMMON),
SLE_VARX(offsetof(Vehicle,u)+offsetof(VehicleAir,crashed_counter), SLE_UINT16),
@ -1979,7 +1979,7 @@ static const byte _aircraft_desc[] = {
SLE_END()
};
static const byte _special_desc[] = {
static const SaveLoad _special_desc[] = {
SLE_WRITEBYTE(Vehicle,type,VEH_Special, 4),
SLE_VAR(Vehicle,subtype, SLE_UINT8),
@ -2011,7 +2011,7 @@ static const byte _special_desc[] = {
SLE_END()
};
static const byte _disaster_desc[] = {
static const SaveLoad _disaster_desc[] = {
SLE_WRITEBYTE(Vehicle,type,VEH_Disaster, 5),
SLE_REF(Vehicle,next, REF_VEHICLE_OLD),

@ -429,7 +429,7 @@ void InitializeWaypoints(void)
AddBlockToPool(&_waypoint_pool);
}
static const byte _waypoint_desc[] = {
static const SaveLoad _waypoint_desc[] = {
SLE_CONDVAR(Waypoint, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
SLE_CONDVAR(Waypoint, xy, SLE_UINT32, 6, 255),
SLE_CONDVAR(Waypoint, town_index, SLE_UINT16, 12, 255),

@ -181,7 +181,7 @@ static void ClientSizeChanged(int w, int h)
}
}
void DoExitSave(void);
extern void DoExitSave(void);
static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
@ -1194,8 +1194,11 @@ static const char _save_succeeded[] =
"Be aware that critical parts of the internal game state may have become "
"corrupted. The saved game is not guaranteed to work.";
bool EmergencySave();
static bool EmergencySave(void)
{
SaveOrLoad("crash.sav", SL_SAVE);
return true;
}
typedef struct {
HINTERNET (WINAPI *InternetOpenA)(LPCSTR,DWORD, LPCSTR, LPCSTR, DWORD);

Loading…
Cancel
Save