From 27087d0ea83134865f09733a626973191f5c1750 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Wed, 25 Sep 2013 20:32:15 -0700 Subject: [PATCH] Refactor savegame information Coalesce it out of three header files into one (save.h). This also includes references to NextActivity, which may be the wrong place to do it. Time will tell. --- sc2/src/uqm/comm.c | 2 +- sc2/src/uqm/gameopt.c | 1 - sc2/src/uqm/load.c | 4 +--- sc2/src/uqm/load.h | 39 ---------------------------------- sc2/src/uqm/planets/devices.c | 2 +- sc2/src/uqm/planets/scan.c | 2 +- sc2/src/uqm/planets/solarsys.c | 2 +- sc2/src/uqm/restart.c | 2 +- sc2/src/uqm/save.h | 31 +++++++++++++++++++++++++-- sc2/src/uqm/sis.h | 23 -------------------- sc2/src/uqm/starbase.c | 2 +- sc2/src/uqm/starcon.c | 2 +- 12 files changed, 37 insertions(+), 75 deletions(-) delete mode 100644 sc2/src/uqm/load.h diff --git a/sc2/src/uqm/comm.c b/sc2/src/uqm/comm.c index 55c07df11..6336de8a9 100644 --- a/sc2/src/uqm/comm.c +++ b/sc2/src/uqm/comm.c @@ -31,8 +31,8 @@ #include "endian_uqm.h" #include "gamestr.h" #include "options.h" -#include "load.h" #include "oscill.h" +#include "save.h" #include "settings.h" #include "setup.h" #include "sounds.h" diff --git a/sc2/src/uqm/gameopt.c b/sc2/src/uqm/gameopt.c index 296d9d3b9..18bc0ab8b 100644 --- a/sc2/src/uqm/gameopt.c +++ b/sc2/src/uqm/gameopt.c @@ -26,7 +26,6 @@ #include "sis.h" #include "units.h" #include "gamestr.h" -#include "load.h" #include "options.h" #include "save.h" #include "settings.h" diff --git a/sc2/src/uqm/load.c b/sc2/src/uqm/load.c index c7a58c6d0..e115273b6 100644 --- a/sc2/src/uqm/load.c +++ b/sc2/src/uqm/load.c @@ -18,16 +18,14 @@ #include -#include "load.h" - #include "build.h" #include "libs/declib.h" #include "encount.h" #include "starmap.h" #include "libs/file.h" #include "globdata.h" -#include "load.h" #include "options.h" +#include "save.h" #include "setup.h" #include "state.h" #include "grpinfo.h" diff --git a/sc2/src/uqm/load.h b/sc2/src/uqm/load.h deleted file mode 100644 index 175e38c80..000000000 --- a/sc2/src/uqm/load.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _LOAD_H -#define _LOAD_H - -#include "sis.h" - // for SUMMARY_DESC -#include "libs/compiler.h" -#include "globdata.h" - -#if defined(__cplusplus) -extern "C" { -#endif - -extern ACTIVITY NextActivity; - -extern BOOLEAN LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc); - - -#if defined(__cplusplus) -} -#endif - -#endif /* _LOAD_H */ - diff --git a/sc2/src/uqm/planets/devices.c b/sc2/src/uqm/planets/devices.c index 99b0ac379..e781d5b1c 100644 --- a/sc2/src/uqm/planets/devices.c +++ b/sc2/src/uqm/planets/devices.c @@ -23,9 +23,9 @@ #include "../encount.h" #include "../gamestr.h" #include "../controls.h" +#include "../save.h" #include "../settings.h" #include "../shipcont.h" -#include "../load.h" #include "../setup.h" #include "../state.h" #include "../sis.h" diff --git a/sc2/src/uqm/planets/scan.c b/sc2/src/uqm/planets/scan.c index ed063337b..3d5d9fd7b 100644 --- a/sc2/src/uqm/planets/scan.c +++ b/sc2/src/uqm/planets/scan.c @@ -30,13 +30,13 @@ #include "../nameref.h" #include "../resinst.h" #include "../settings.h" -#include "../load.h" #include "../util.h" #include "../process.h" #include "../setup.h" #include "../sounds.h" #include "../state.h" #include "../sis.h" +#include "../save.h" #include "options.h" #include "libs/graphics/gfx_common.h" #include "libs/graphics/drawable.h" diff --git a/sc2/src/uqm/planets/solarsys.c b/sc2/src/uqm/planets/solarsys.c index 677b9dfdb..11bd4c0bf 100644 --- a/sc2/src/uqm/planets/solarsys.c +++ b/sc2/src/uqm/planets/solarsys.c @@ -37,11 +37,11 @@ #include "../ipdisp.h" #include "../grpinfo.h" #include "../process.h" -#include "../load.h" #include "../setup.h" #include "../sounds.h" #include "../state.h" #include "../uqmdebug.h" +#include "../save.h" #include "options.h" #include "libs/graphics/gfx_common.h" #include "libs/mathlib.h" diff --git a/sc2/src/uqm/restart.c b/sc2/src/uqm/restart.c index b877a2edb..f52e753b4 100644 --- a/sc2/src/uqm/restart.c +++ b/sc2/src/uqm/restart.c @@ -30,8 +30,8 @@ #include "supermelee/melee.h" #include "resinst.h" #include "nameref.h" +#include "save.h" #include "settings.h" -#include "load.h" #include "setup.h" #include "sounds.h" #include "setupmenu.h" diff --git a/sc2/src/uqm/save.h b/sc2/src/uqm/save.h index 7a3c3c2ac..6f37f01ff 100644 --- a/sc2/src/uqm/save.h +++ b/sc2/src/uqm/save.h @@ -17,14 +17,41 @@ #ifndef _SAVE_H #define _SAVE_H -#include "sis.h" - // for SUMMARY_DESC +#include "sis.h" // SUMMARY_DESC includes SIS_STATE in it +#include "globdata.h" #include "libs/compiler.h" #if defined(__cplusplus) extern "C" { #endif +// XXX: Theoretically, a player can have 17 devices on board without +// cheating. We only provide +// room for 16 below, which is not really a problem since this +// is only used for displaying savegame summaries. There is also +// room for only 16 devices on screen. +#define MAX_EXCLUSIVE_DEVICES 16 +#define SAVE_MAGIC 0x01534d55 +#define SAVE_NAME_SIZE 24 + +typedef struct +{ + SIS_STATE SS; + BYTE Activity; + BYTE Flags; + BYTE day_index, month_index; + COUNT year_index; + BYTE MCreditLo, MCreditHi; + BYTE NumShips, NumDevices; + BYTE ShipList[MAX_BUILT_SHIPS]; + BYTE DeviceList[MAX_EXCLUSIVE_DEVICES]; + UNICODE SaveName[SAVE_NAME_SIZE]; +} SUMMARY_DESC; + +extern ACTIVITY NextActivity; + +extern BOOLEAN LoadGame (COUNT which_game, SUMMARY_DESC *summary_desc); + extern void SaveProblem (void); extern BOOLEAN SaveGame (COUNT which_game, SUMMARY_DESC *summary_desc, const char *name); diff --git a/sc2/src/uqm/sis.h b/sc2/src/uqm/sis.h index 723081887..ee07a81db 100644 --- a/sc2/src/uqm/sis.h +++ b/sc2/src/uqm/sis.h @@ -154,29 +154,6 @@ typedef struct UNICODE PlanetName[SIS_NAME_SIZE]; } SIS_STATE; -// XXX: Theoretically, a player can have 17 devices on board without -// cheating. We only provide -// room for 16 below, which is not really a problem since this -// is only used for displaying savegame summaries. There is also -// room for only 16 devices on screen. -#define MAX_EXCLUSIVE_DEVICES 16 -#define SAVE_MAGIC 0x01534d55 -#define SAVE_NAME_SIZE 24 - -typedef struct -{ - SIS_STATE SS; - BYTE Activity; - BYTE Flags; - BYTE day_index, month_index; - COUNT year_index; - BYTE MCreditLo, MCreditHi; - BYTE NumShips, NumDevices; - BYTE ShipList[MAX_BUILT_SHIPS]; - BYTE DeviceList[MAX_EXCLUSIVE_DEVICES]; - UNICODE SaveName[SAVE_NAME_SIZE]; -} SUMMARY_DESC; - #define OVERRIDE_LANDER_FLAGS (1 << 7) #define AFTER_BOMB_INSTALLED (1 << 7) diff --git a/sc2/src/uqm/starbase.c b/sc2/src/uqm/starbase.c index be12f06c7..f1192085c 100644 --- a/sc2/src/uqm/starbase.c +++ b/sc2/src/uqm/starbase.c @@ -22,7 +22,7 @@ #include "starmap.h" #include "comm.h" #include "gamestr.h" -#include "load.h" +#include "save.h" #include "starbase.h" #include "sis.h" #include "resinst.h" diff --git a/sc2/src/uqm/starcon.c b/sc2/src/uqm/starcon.c index cf9d6724f..5903e6860 100644 --- a/sc2/src/uqm/starcon.c +++ b/sc2/src/uqm/starcon.c @@ -24,10 +24,10 @@ #include "gameev.h" #include "types.h" #include "globdata.h" -#include "load.h" #include "resinst.h" #include "restart.h" #include "starbase.h" +#include "save.h" #include "setup.h" #include "master.h" #include "controls.h"