1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-20 05:23:53 +00:00
openmw/components/esm3/savedgame.cpp
florent.teppe afed7e60ef Upgraded Filesave version for RefIDs
Fix logic issue
2022-12-27 23:05:31 +01:00

56 lines
1.7 KiB
C++

#include "savedgame.hpp"
#include "esmreader.hpp"
#include "esmwriter.hpp"
namespace ESM
{
int SavedGame::sCurrentFormat = 22;
void SavedGame::load(ESMReader& esm)
{
mPlayerName = esm.getHNString("PLNA");
esm.getHNOT(mPlayerLevel, "PLLE");
mPlayerClassId = ESM::RefId::stringRefId(esm.getHNOString("PLCL"));
mPlayerClassName = esm.getHNOString("PLCN");
mPlayerCell = ESM::RefId::stringRefId(esm.getHNString("PLCE"));
esm.getHNTSized<16>(mInGameTime, "TSTM");
esm.getHNT(mTimePlayed, "TIME");
mDescription = esm.getHNString("DESC");
while (esm.isNextSub("DEPE"))
mContentFiles.push_back(esm.getHString());
esm.getSubNameIs("SCRN");
esm.getSubHeader();
mScreenshot.resize(esm.getSubSize());
esm.getExact(mScreenshot.data(), mScreenshot.size());
}
void SavedGame::save(ESMWriter& esm) const
{
esm.writeHNString("PLNA", mPlayerName);
esm.writeHNT("PLLE", mPlayerLevel);
if (!mPlayerClassId.empty())
esm.writeHNString("PLCL", mPlayerClassId.getRefIdString());
else
esm.writeHNString("PLCN", mPlayerClassName);
esm.writeHNString("PLCE", mPlayerCell.getRefIdString());
esm.writeHNT("TSTM", mInGameTime, 16);
esm.writeHNT("TIME", mTimePlayed);
esm.writeHNString("DESC", mDescription);
for (std::vector<std::string>::const_iterator iter(mContentFiles.begin()); iter != mContentFiles.end(); ++iter)
esm.writeHNString("DEPE", *iter);
esm.startSubRecord("SCRN");
esm.write(mScreenshot.data(), mScreenshot.size());
esm.endRecord("SCRN");
}
}