Expose some of the statefile structure to load and save.
This commit is contained in:
+7
-42
@@ -23,7 +23,7 @@
|
||||
#include "globdata.h"
|
||||
#include "intel.h"
|
||||
#include "state.h"
|
||||
#include "grpinfo.h"
|
||||
#include "grpintrn.h"
|
||||
|
||||
#include "libs/mathlib.h"
|
||||
#include "libs/log.h"
|
||||
@@ -35,42 +35,7 @@
|
||||
static BYTE LastEncGroup;
|
||||
// Last encountered group, saved into state files
|
||||
|
||||
//#define DEBUG_GROUPS
|
||||
|
||||
// A group header describes battle groups present in a star system. There is
|
||||
// at most 1 group header per system.
|
||||
// 'Random' group info file (RANDGRPINFO_FILE) always contains only one
|
||||
// group header record, which describes the last-visited star system,
|
||||
// (which may be the current system). Thus the randomly generated groups
|
||||
// are valid for 7 days (set in PutGroupInfo) after the player leaves
|
||||
// the system, or until the player enters another star system.
|
||||
typedef struct
|
||||
{
|
||||
BYTE NumGroups;
|
||||
BYTE day_index, month_index;
|
||||
COUNT star_index, year_index;
|
||||
// day_index, month_index, year_index specify when
|
||||
// random groups expire (if you were to leave the system
|
||||
// by going to HSpace and stay there till such time)
|
||||
// star_index is the index of a star this group header
|
||||
// applies to; ~0 means uninited
|
||||
DWORD GroupOffset[NUM_SAVED_BATTLE_GROUPS + 1];
|
||||
// Absolute offsets of group definitions in a state file
|
||||
// Group 0 is a list of groups present in solarsys
|
||||
// (RANDGRPINFO_FILE only)
|
||||
// Groups 1..max are definitions of actual battle groups
|
||||
// containing ship makeup and status
|
||||
|
||||
// Each group has the following format:
|
||||
// 1 byte, RaceType (LastEncGroup in Group 0)
|
||||
// 1 byte, NumShips (NumGroups in Group 0)
|
||||
// Ships follow:
|
||||
// 1 byte, RaceType
|
||||
// 16 bytes, part of SHIP_FRAGMENT struct
|
||||
|
||||
} GROUP_HEADER;
|
||||
|
||||
static void
|
||||
void
|
||||
ReadGroupHeader (GAME_STATE_FILE *fp, GROUP_HEADER *pGH)
|
||||
{
|
||||
sread_8 (fp, &pGH->NumGroups);
|
||||
@@ -82,7 +47,7 @@ ReadGroupHeader (GAME_STATE_FILE *fp, GROUP_HEADER *pGH)
|
||||
sread_a32 (fp, pGH->GroupOffset, NUM_SAVED_BATTLE_GROUPS + 1);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
WriteGroupHeader (GAME_STATE_FILE *fp, const GROUP_HEADER *pGH)
|
||||
{
|
||||
swrite_8 (fp, pGH->NumGroups);
|
||||
@@ -94,7 +59,7 @@ WriteGroupHeader (GAME_STATE_FILE *fp, const GROUP_HEADER *pGH)
|
||||
swrite_a32 (fp, pGH->GroupOffset, NUM_SAVED_BATTLE_GROUPS + 1);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
ReadShipFragment (GAME_STATE_FILE *fp, SHIP_FRAGMENT *FragPtr)
|
||||
{
|
||||
BYTE tmpb;
|
||||
@@ -116,7 +81,7 @@ ReadShipFragment (GAME_STATE_FILE *fp, SHIP_FRAGMENT *FragPtr)
|
||||
sread_16 (fp, NULL); /* unused; was loc.y */
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
WriteShipFragment (GAME_STATE_FILE *fp, const SHIP_FRAGMENT *FragPtr)
|
||||
{
|
||||
swrite_16 (fp, 0); /* unused: was which_side */
|
||||
@@ -134,7 +99,7 @@ WriteShipFragment (GAME_STATE_FILE *fp, const SHIP_FRAGMENT *FragPtr)
|
||||
swrite_16 (fp, 0); /* unused; was loc.y */
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
ReadIpGroup (GAME_STATE_FILE *fp, IP_GROUP *GroupPtr)
|
||||
{
|
||||
BYTE tmpb;
|
||||
@@ -157,7 +122,7 @@ ReadIpGroup (GAME_STATE_FILE *fp, IP_GROUP *GroupPtr)
|
||||
sread_16s(fp, &GroupPtr->loc.y);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
WriteIpGroup (GAME_STATE_FILE *fp, const IP_GROUP *GroupPtr)
|
||||
{
|
||||
swrite_16 (fp, 0); /* unused; was which_side */
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#ifndef _GRPINTRN_H
|
||||
#define _GRPINTRN_H
|
||||
|
||||
// For IPGROUP
|
||||
#include "grpinfo.h"
|
||||
|
||||
// For SHIP_FRAGMENT
|
||||
#include "races.h"
|
||||
|
||||
// For GAME_STATE_FILE
|
||||
#include "state.h"
|
||||
|
||||
//#define DEBUG_GROUPS
|
||||
|
||||
// A group header describes battle groups present in a star system. There is
|
||||
// at most 1 group header per system.
|
||||
// 'Random' group info file (RANDGRPINFO_FILE) always contains only one
|
||||
// group header record, which describes the last-visited star system,
|
||||
// (which may be the current system). Thus the randomly generated groups
|
||||
// are valid for 7 days (set in PutGroupInfo) after the player leaves
|
||||
// the system, or until the player enters another star system.
|
||||
typedef struct
|
||||
{
|
||||
BYTE NumGroups;
|
||||
BYTE day_index, month_index;
|
||||
COUNT star_index, year_index;
|
||||
// day_index, month_index, year_index specify when
|
||||
// random groups expire (if you were to leave the system
|
||||
// by going to HSpace and stay there till such time)
|
||||
// star_index is the index of a star this group header
|
||||
// applies to; ~0 means uninited
|
||||
DWORD GroupOffset[NUM_SAVED_BATTLE_GROUPS + 1];
|
||||
// Absolute offsets of group definitions in a state file
|
||||
// Group 0 is a list of groups present in solarsys
|
||||
// (RANDGRPINFO_FILE only)
|
||||
// Groups 1..max are definitions of actual battle groups
|
||||
// containing ship makeup and status
|
||||
|
||||
// Each group has the following format:
|
||||
// 1 byte, RaceType (LastEncGroup in Group 0)
|
||||
// 1 byte, NumShips (NumGroups in Group 0)
|
||||
// Ships follow:
|
||||
// 1 byte, RaceType
|
||||
// 16 bytes, part of SHIP_FRAGMENT struct
|
||||
// (part of IP_GROUP struct in Group 0)
|
||||
|
||||
} GROUP_HEADER;
|
||||
|
||||
void ReadGroupHeader (GAME_STATE_FILE *fp, GROUP_HEADER *pGH);
|
||||
void WriteGroupHeader (GAME_STATE_FILE *fp, const GROUP_HEADER *pGH);
|
||||
void ReadShipFragment (GAME_STATE_FILE *fp, SHIP_FRAGMENT *FragPtr);
|
||||
void WriteShipFragment (GAME_STATE_FILE *fp, const SHIP_FRAGMENT *FragPtr);
|
||||
void ReadIpGroup (GAME_STATE_FILE *fp, IP_GROUP *GroupPtr);
|
||||
void WriteIpGroup (GAME_STATE_FILE *fp, const IP_GROUP *GroupPtr);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user