diff --git a/src/game/header/local.h b/src/game/header/local.h index 19afbcfe..026f622f 100644 --- a/src/game/header/local.h +++ b/src/game/header/local.h @@ -573,6 +573,7 @@ typedef struct int ofs; fieldtype_t type; int flags; + short save_ver; // currently only used by clientfields[] } field_t; extern field_t fields[]; diff --git a/src/game/savegame/savegame.c b/src/game/savegame/savegame.c index 76035b4e..df995df9 100644 --- a/src/game/savegame/savegame.c +++ b/src/game/savegame/savegame.c @@ -71,7 +71,7 @@ * load older savegames. This should be bumped if the files * in tables/ are changed, otherwise strange things may happen. */ -#define SAVEGAMEVER "YQ2-2" +#define SAVEGAMEVER "YQ2-3" #ifndef BUILD_DATE #define BUILD_DATE __DATE__ @@ -733,7 +733,7 @@ WriteClient(FILE *f, gclient_t *client) * Read the client struct from a file */ void -ReadClient(FILE *f, gclient_t *client) +ReadClient(FILE *f, gclient_t *client, short save_ver) { field_t *field; @@ -741,7 +741,14 @@ ReadClient(FILE *f, gclient_t *client) for (field = clientfields; field->name; field++) { - ReadField(f, field, (byte *)client); + if(field->save_ver <= save_ver) + { + ReadField(f, field, (byte *)client); + } + } + if(save_ver < 3) + { + InitClientResp(client); } } @@ -822,6 +829,8 @@ ReadGame(const char *filename) char str_os[32]; char str_arch[32]; + short save_ver = 0; + gi.FreeTags(TAG_GAME); f = Q_fopen(filename, "rb"); @@ -839,6 +848,26 @@ ReadGame(const char *filename) if (!strcmp(str_ver, SAVEGAMEVER)) { + save_ver = 3; + if (strcmp(str_game, GAMEVERSION)) + { + fclose(f); + gi.error("Savegame from another game.so.\n"); + } + else if (strcmp(str_os, YQ2OSTYPE)) + { + fclose(f); + gi.error("Savegame from another os.\n"); + } + else if (strcmp(str_arch, YQ2ARCH)) + { + fclose(f); + gi.error("Savegame from another architecture.\n"); + } + } + else if (!strcmp(str_ver, "YQ2-2")) + { + save_ver = 2; if (strcmp(str_game, GAMEVERSION)) { fclose(f); @@ -857,6 +886,7 @@ ReadGame(const char *filename) } else if (!strcmp(str_ver, "YQ2-1")) { + save_ver = 1; if (strcmp(str_game, GAMEVERSION)) { fclose(f); @@ -901,7 +931,7 @@ ReadGame(const char *filename) for (i = 0; i < game.maxclients; i++) { - ReadClient(f, &game.clients[i]); + ReadClient(f, &game.clients[i], save_ver); } fclose(f); diff --git a/src/game/savegame/tables/clientfields.h b/src/game/savegame/tables/clientfields.h index 72d51e3c..4a9c8b3d 100644 --- a/src/game/savegame/tables/clientfields.h +++ b/src/game/savegame/tables/clientfields.h @@ -28,4 +28,6 @@ {"pers.weapon", CLOFS(pers.weapon), F_ITEM}, {"pers.lastweapon", CLOFS(pers.lastweapon), F_ITEM}, {"newweapon", CLOFS(newweapon), F_ITEM}, -{NULL, 0, F_INT} +{"resp.coop_respawn.weapon", CLOFS(resp.coop_respawn.weapon), F_ITEM, 0, 3}, +{"resp.coop_respawn.lastweapon", CLOFS(resp.coop_respawn.lastweapon), F_ITEM, 0, 3}, +{NULL, 0, F_INT, 0} diff --git a/src/game/savegame/tables/gamefunc_decs.h b/src/game/savegame/tables/gamefunc_decs.h index a30232f7..9e3fca6f 100644 --- a/src/game/savegame/tables/gamefunc_decs.h +++ b/src/game/savegame/tables/gamefunc_decs.h @@ -33,7 +33,7 @@ extern void WriteLevelLocals ( FILE * f ) ; extern void WriteEdict ( FILE * f , edict_t * ent ) ; extern void ReadGame ( const char * filename ) ; extern void WriteGame ( const char * filename , qboolean autosave ) ; -extern void ReadClient ( FILE * f , gclient_t * client ) ; +extern void ReadClient ( FILE * f , gclient_t * client, short save_ver ) ; extern void WriteClient ( FILE * f , gclient_t * client ) ; extern void ReadField ( FILE * f , field_t * field , byte * base ) ; extern void WriteField2 ( FILE * f , field_t * field , byte * base ) ;