added secondary saved game header record

actorid
Marc Zinnschlag 11 years ago
parent 1c7a4d4b3a
commit dc75627d53

@ -40,6 +40,7 @@ add_component_dir (esm
loadinfo loadingr loadland loadlevlist loadligh loadlock loadprob loadrepa loadltex loadmgef loadmisc loadnpcc
loadnpc loadpgrd loadrace loadregn loadscpt loadskil loadsndg loadsoun loadspel loadsscr loadstat
loadweap records aipackage effectlist spelllist variant variantimp loadtes3 cellref filter
savedgame
)
add_component_dir (misc

@ -83,6 +83,9 @@ enum RecNameInts
REC_STAT = 0x54415453,
REC_WEAP = 0x50414557,
// format 0 - saved games
REC_SAVE = 0x45564153,
// format 1
REC_FILT = 0x544C4946
};

@ -0,0 +1,36 @@
#include "savedgame.hpp"
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
unsigned int ESM::SavedGame::sRecordId = ESM::REC_SAVE;
void ESM::SavedGame::load (ESMReader &esm)
{
mPlayerName = esm.getHNString("PNAM");
esm.getHNOT (mPlayerLevel, "PLEV");
mPlayerClass = esm.getHNString("PCLA");
mPlayerCell = esm.getHNString("PCEL");
esm.getHNT (mInGameTime, "TSTM", 16);
esm.getHNT (mTimePlayed, "TIME");
while (esm.isNextSub ("DEPE"))
mContentFiles.push_back (esm.getHString());
}
void ESM::SavedGame::save (ESMWriter &esm) const
{
esm.writeHNCString (mPlayerName, "PNAM");
esm.writeHNT ("PLEV", mPlayerLevel);
esm.writeHNCString (mPlayerClass, "PCLA");
esm.writeHNCString (mPlayerCell, "PCEL");
esm.writeHNT ("TSTM", mInGameTime, 16);
esm.writeHNT ("TIME", mTimePlayed);
for (std::vector<std::string>::const_iterator iter (mContentFiles.begin());
iter!=mContentFiles.end(); ++iter)
esm.writeHNCString (*iter, "DEPE");
}

@ -0,0 +1,41 @@
#ifndef OPENMW_ESM_SAVEDGAME_H
#define OPENMW_ESM_SAVEDGAME_H
#include <vector>
#include <string>
namespace ESM
{
class ESMReader;
class ESMWriter;
// format 0, saved games only
struct SavedGame
{
static unsigned int sRecordId;
struct TimeStamp
{
float mGameHour;
int mDay;
int mMonth;
int mYear;
};
std::vector<std::string> mContentFiles;
std::string mPlayerName;
int mPlayerLevel;
std::string mPlayerClass;
std::string mPlayerCell;
TimeStamp mInGameTime;
float mTimePlayed;
/// \todo add field for screenshot
void load (ESMReader &esm);
void save (ESMWriter &esm) const;
};
}
#endif
Loading…
Cancel
Save