mirror of https://github.com/OpenMW/openmw.git
added savedgame-specifc record structs for objects state
parent
e453468eff
commit
8c5f313546
@ -0,0 +1,26 @@
|
||||
|
||||
#include "cellid.hpp"
|
||||
|
||||
#include "esmreader.hpp"
|
||||
#include "esmwriter.hpp"
|
||||
|
||||
void ESM::CellId::load (ESMReader &esm)
|
||||
{
|
||||
mWorldspace = esm.getHNString ("SPAC");
|
||||
|
||||
if (esm.isNextSub ("CIDX"))
|
||||
{
|
||||
esm.getHT (mIndex, 8);
|
||||
mPaged = true;
|
||||
}
|
||||
else
|
||||
mPaged = false;
|
||||
}
|
||||
|
||||
void ESM::CellId::save (ESMWriter &esm) const
|
||||
{
|
||||
esm.writeHNString ("SPAC", mWorldspace);
|
||||
|
||||
if (mPaged)
|
||||
esm.writeHNT ("CIDX", mIndex, 8);
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
#ifndef OPENMW_ESM_CELLID_H
|
||||
#define OPENMW_ESM_CELLID_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class ESMReader;
|
||||
class ESMWriter;
|
||||
|
||||
struct CellId
|
||||
{
|
||||
struct CellIndex
|
||||
{
|
||||
int mX;
|
||||
int mY;
|
||||
};
|
||||
|
||||
std::string mWorldspace;
|
||||
CellIndex mIndex;
|
||||
bool mPaged;
|
||||
|
||||
void load (ESMReader &esm);
|
||||
void save (ESMWriter &esm) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,47 @@
|
||||
|
||||
#include "objectstate.hpp"
|
||||
|
||||
#include "esmreader.hpp"
|
||||
#include "esmwriter.hpp"
|
||||
|
||||
void ESM::ObjectState::load (ESMReader &esm)
|
||||
{
|
||||
mRef.load (esm, true);
|
||||
|
||||
mHasLocals = 0;
|
||||
esm.getHNOT (mHasLocals, "HLOC");
|
||||
|
||||
if (mHasLocals)
|
||||
mLocals.load (esm);
|
||||
|
||||
mEnabled = 1;
|
||||
esm.getHNOT (mEnabled, "ENAB");
|
||||
|
||||
mCount = 1;
|
||||
esm.getHNOT (mCount, "COUN");
|
||||
|
||||
esm.getHNT (mPosition, "POS_", 24);
|
||||
|
||||
esm.getHNT (mLocalRotation, "LROT", 12);
|
||||
}
|
||||
|
||||
void ESM::ObjectState::save (ESMWriter &esm) const
|
||||
{
|
||||
mRef.save (esm);
|
||||
|
||||
if (mHasLocals)
|
||||
{
|
||||
esm.writeHNT ("HLOC", mHasLocals);
|
||||
mLocals.save (esm);
|
||||
}
|
||||
|
||||
if (!mEnabled)
|
||||
esm.writeHNT ("ENAB", mEnabled);
|
||||
|
||||
if (mCount!=1)
|
||||
esm.writeHNT ("COUN", mCount);
|
||||
|
||||
esm.writeHNT ("POS_", mPosition, 24);
|
||||
|
||||
esm.writeHNT ("LROT", mLocalRotation, 12);
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
#ifndef OPENMW_ESM_OBJECTSTATE_H
|
||||
#define OPENMW_ESM_OBJECTSTATE_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "cellref.hpp"
|
||||
#include "locals.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class ESMReader;
|
||||
class ESMWriter;
|
||||
|
||||
// format 0, saved games only
|
||||
|
||||
///< \brief Save state for objects, that do not use custom data
|
||||
struct ObjectState
|
||||
{
|
||||
std::string mId;
|
||||
|
||||
CellRef mRef;
|
||||
|
||||
unsigned char mHasLocals;
|
||||
Locals mLocals;
|
||||
unsigned char mEnabled;
|
||||
int mCount;
|
||||
ESM::Position mPosition;
|
||||
float mLocalRotation[3];
|
||||
|
||||
void load (ESMReader &esm);
|
||||
void save (ESMWriter &esm) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,44 @@
|
||||
|
||||
#include "player.hpp"
|
||||
|
||||
#include "esmreader.hpp"
|
||||
#include "esmwriter.hpp"
|
||||
|
||||
void ESM::Player::load (ESMReader &esm)
|
||||
{
|
||||
mObject.load (esm);
|
||||
|
||||
mCellId.load (esm);
|
||||
|
||||
esm.getHNT (mLastKnownExteriorPosition, "LKEP", 12);
|
||||
|
||||
if (esm.isNextSub ("MARK"))
|
||||
{
|
||||
mHasMark = true;
|
||||
esm.getHT (mMarkedPosition, 24);
|
||||
mMarkedCell.load (esm);
|
||||
}
|
||||
else
|
||||
mHasMark = false;
|
||||
|
||||
mAutoMove = 0;
|
||||
esm.getHNOT (mAutoMove, "AMOV");
|
||||
}
|
||||
|
||||
void ESM::Player::save (ESMWriter &esm) const
|
||||
{
|
||||
mObject.save (esm);
|
||||
|
||||
mCellId.save (esm);
|
||||
|
||||
esm.writeHNT ("LKEP", mLastKnownExteriorPosition, 12);
|
||||
|
||||
if (mHasMark)
|
||||
{
|
||||
esm.writeHNT ("MARK", mMarkedPosition, 24);
|
||||
mMarkedCell.save (esm);
|
||||
}
|
||||
|
||||
if (mAutoMove)
|
||||
esm.writeHNT ("AMOV", mAutoMove);
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
#ifndef OPENMW_ESM_PLAYER_H
|
||||
#define OPENMW_ESM_PLAYER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "objectstate.hpp"
|
||||
#include "cellid.hpp"
|
||||
#include "defs.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class ESMReader;
|
||||
class ESMWriter;
|
||||
|
||||
// format 0, saved games only
|
||||
|
||||
struct Player
|
||||
{
|
||||
ObjectState mObject;
|
||||
CellId mCellId;
|
||||
float mLastKnownExteriorPosition[3];
|
||||
unsigned char mHasMark;
|
||||
ESM::Position mMarkedPosition;
|
||||
CellId mMarkedCell;
|
||||
unsigned char mAutoMove;
|
||||
|
||||
void load (ESMReader &esm);
|
||||
void save (ESMWriter &esm) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue