mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-20 11:41:33 +00:00
added creature/NPC state to saved games (only container/inventory for now)
This commit is contained in:
parent
d2ec3ffdc8
commit
5b04c10e1d
12 changed files with 148 additions and 12 deletions
|
@ -2,6 +2,7 @@
|
||||||
#include "creature.hpp"
|
#include "creature.hpp"
|
||||||
|
|
||||||
#include <components/esm/loadcrea.hpp>
|
#include <components/esm/loadcrea.hpp>
|
||||||
|
#include <components/esm/creaturestate.hpp>
|
||||||
|
|
||||||
#include "../mwmechanics/creaturestats.hpp"
|
#include "../mwmechanics/creaturestats.hpp"
|
||||||
#include "../mwmechanics/magiceffects.hpp"
|
#include "../mwmechanics/magiceffects.hpp"
|
||||||
|
@ -613,6 +614,28 @@ namespace MWClass
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Creature::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
const ESM::CreatureState& state2 = dynamic_cast<const ESM::CreatureState&> (state);
|
||||||
|
|
||||||
|
ensureCustomData (ptr);
|
||||||
|
|
||||||
|
dynamic_cast<CustomData&> (*ptr.getRefData().getCustomData()).mContainerStore.
|
||||||
|
readState (state2.mInventory);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Creature::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
ESM::CreatureState& state2 = dynamic_cast<ESM::CreatureState&> (state);
|
||||||
|
|
||||||
|
ensureCustomData (ptr);
|
||||||
|
|
||||||
|
dynamic_cast<CustomData&> (*ptr.getRefData().getCustomData()).mContainerStore.
|
||||||
|
writeState (state2.mInventory);
|
||||||
|
}
|
||||||
|
|
||||||
const ESM::GameSetting* Creature::fMinWalkSpeedCreature;
|
const ESM::GameSetting* Creature::fMinWalkSpeedCreature;
|
||||||
const ESM::GameSetting* Creature::fMaxWalkSpeedCreature;
|
const ESM::GameSetting* Creature::fMaxWalkSpeedCreature;
|
||||||
const ESM::GameSetting *Creature::fEncumberedMoveEffect;
|
const ESM::GameSetting *Creature::fEncumberedMoveEffect;
|
||||||
|
|
|
@ -118,6 +118,14 @@ namespace MWClass
|
||||||
|
|
||||||
/// Get a blood texture suitable for \a ptr (see Blood Texture 0-2 in Morrowind.ini)
|
/// Get a blood texture suitable for \a ptr (see Blood Texture 0-2 in Morrowind.ini)
|
||||||
virtual int getBloodTexture (const MWWorld::Ptr& ptr) const;
|
virtual int getBloodTexture (const MWWorld::Ptr& ptr) const;
|
||||||
|
|
||||||
|
virtual void readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state)
|
||||||
|
const;
|
||||||
|
///< Read additional state from \a state into \a ptr.
|
||||||
|
|
||||||
|
virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
|
||||||
|
const;
|
||||||
|
///< Write additional state from \a ptr into \a state.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include <components/esm/loadmgef.hpp>
|
#include <components/esm/loadmgef.hpp>
|
||||||
#include <components/esm/loadnpc.hpp>
|
#include <components/esm/loadnpc.hpp>
|
||||||
|
#include <components/esm/npcstate.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
@ -1233,6 +1234,28 @@ namespace MWClass
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Npc::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
const ESM::NpcState& state2 = dynamic_cast<const ESM::NpcState&> (state);
|
||||||
|
|
||||||
|
ensureCustomData (ptr);
|
||||||
|
|
||||||
|
dynamic_cast<CustomData&> (*ptr.getRefData().getCustomData()).mInventoryStore.
|
||||||
|
readState (state2.mInventory);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Npc::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
ESM::NpcState& state2 = dynamic_cast<ESM::NpcState&> (state);
|
||||||
|
|
||||||
|
ensureCustomData (ptr);
|
||||||
|
|
||||||
|
dynamic_cast<CustomData&> (*ptr.getRefData().getCustomData()).mInventoryStore.
|
||||||
|
writeState (state2.mInventory);
|
||||||
|
}
|
||||||
|
|
||||||
const ESM::GameSetting *Npc::fMinWalkSpeed;
|
const ESM::GameSetting *Npc::fMinWalkSpeed;
|
||||||
const ESM::GameSetting *Npc::fMaxWalkSpeed;
|
const ESM::GameSetting *Npc::fMaxWalkSpeed;
|
||||||
const ESM::GameSetting *Npc::fEncumberedMoveEffect;
|
const ESM::GameSetting *Npc::fEncumberedMoveEffect;
|
||||||
|
|
|
@ -152,6 +152,14 @@ namespace MWClass
|
||||||
virtual bool isNpc() const {
|
virtual bool isNpc() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state)
|
||||||
|
const;
|
||||||
|
///< Read additional state from \a state into \a ptr.
|
||||||
|
|
||||||
|
virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
|
||||||
|
const;
|
||||||
|
///< Write additional state from \a ptr into \a state.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include <components/esm/objectstate.hpp>
|
#include <components/esm/objectstate.hpp>
|
||||||
#include <components/esm/lightstate.hpp>
|
#include <components/esm/lightstate.hpp>
|
||||||
#include <components/esm/containerstate.hpp>
|
#include <components/esm/containerstate.hpp>
|
||||||
|
#include <components/esm/npcstate.hpp>
|
||||||
|
#include <components/esm/creaturestate.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
@ -328,7 +330,7 @@ namespace MWWorld
|
||||||
writeReferenceCollection<ESM::ObjectState> (writer, mBooks);
|
writeReferenceCollection<ESM::ObjectState> (writer, mBooks);
|
||||||
writeReferenceCollection<ESM::ObjectState> (writer, mClothes);
|
writeReferenceCollection<ESM::ObjectState> (writer, mClothes);
|
||||||
writeReferenceCollection<ESM::ContainerState> (writer, mContainers);
|
writeReferenceCollection<ESM::ContainerState> (writer, mContainers);
|
||||||
writeReferenceCollection<ESM::ObjectState> (writer, mCreatures);
|
writeReferenceCollection<ESM::CreatureState> (writer, mCreatures);
|
||||||
writeReferenceCollection<ESM::ObjectState> (writer, mDoors);
|
writeReferenceCollection<ESM::ObjectState> (writer, mDoors);
|
||||||
writeReferenceCollection<ESM::ObjectState> (writer, mIngreds);
|
writeReferenceCollection<ESM::ObjectState> (writer, mIngreds);
|
||||||
writeReferenceCollection<ESM::ObjectState> (writer, mCreatureLists);
|
writeReferenceCollection<ESM::ObjectState> (writer, mCreatureLists);
|
||||||
|
@ -336,7 +338,7 @@ namespace MWWorld
|
||||||
writeReferenceCollection<ESM::LightState> (writer, mLights);
|
writeReferenceCollection<ESM::LightState> (writer, mLights);
|
||||||
writeReferenceCollection<ESM::ObjectState> (writer, mLockpicks);
|
writeReferenceCollection<ESM::ObjectState> (writer, mLockpicks);
|
||||||
writeReferenceCollection<ESM::ObjectState> (writer, mMiscItems);
|
writeReferenceCollection<ESM::ObjectState> (writer, mMiscItems);
|
||||||
writeReferenceCollection<ESM::ObjectState> (writer, mNpcs);
|
writeReferenceCollection<ESM::NpcState> (writer, mNpcs);
|
||||||
writeReferenceCollection<ESM::ObjectState> (writer, mProbes);
|
writeReferenceCollection<ESM::ObjectState> (writer, mProbes);
|
||||||
writeReferenceCollection<ESM::ObjectState> (writer, mRepairs);
|
writeReferenceCollection<ESM::ObjectState> (writer, mRepairs);
|
||||||
writeReferenceCollection<ESM::ObjectState> (writer, mStatics);
|
writeReferenceCollection<ESM::ObjectState> (writer, mStatics);
|
||||||
|
@ -390,7 +392,7 @@ namespace MWWorld
|
||||||
|
|
||||||
case ESM::REC_CREA:
|
case ESM::REC_CREA:
|
||||||
|
|
||||||
readReferenceCollection<ESM::ObjectState> (reader, mCreatures, contentFileMap);
|
readReferenceCollection<ESM::CreatureState> (reader, mCreatures, contentFileMap);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ESM::REC_DOOR:
|
case ESM::REC_DOOR:
|
||||||
|
@ -430,7 +432,7 @@ namespace MWWorld
|
||||||
|
|
||||||
case ESM::REC_NPC_:
|
case ESM::REC_NPC_:
|
||||||
|
|
||||||
readReferenceCollection<ESM::ObjectState> (reader, mNpcs, contentFileMap);
|
readReferenceCollection<ESM::NpcState> (reader, mNpcs, contentFileMap);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ESM::REC_PROB:
|
case ESM::REC_PROB:
|
||||||
|
|
|
@ -130,7 +130,7 @@ namespace MWWorld
|
||||||
void fill (const ESM::InventoryList& items, const std::string& owner, const std::string& faction, const MWWorld::ESMStore& store);
|
void fill (const ESM::InventoryList& items, const std::string& owner, const std::string& faction, const MWWorld::ESMStore& store);
|
||||||
///< Insert items into *this.
|
///< Insert items into *this.
|
||||||
|
|
||||||
void clear();
|
virtual void clear();
|
||||||
///< Empty container.
|
///< Empty container.
|
||||||
|
|
||||||
float getWeight() const;
|
float getWeight() const;
|
||||||
|
|
|
@ -40,7 +40,7 @@ add_component_dir (esm
|
||||||
loadinfo loadingr loadland loadlevlist loadligh loadlock loadprob loadrepa loadltex loadmgef loadmisc loadnpcc
|
loadinfo loadingr loadland loadlevlist loadligh loadlock loadprob loadrepa loadltex loadmgef loadmisc loadnpcc
|
||||||
loadnpc loadpgrd loadrace loadregn loadscpt loadskil loadsndg loadsoun loadspel loadsscr loadstat
|
loadnpc loadpgrd loadrace loadregn loadscpt loadskil loadsndg loadsoun loadspel loadsscr loadstat
|
||||||
loadweap records aipackage effectlist spelllist variant variantimp loadtes3 cellref filter
|
loadweap records aipackage effectlist spelllist variant variantimp loadtes3 cellref filter
|
||||||
savedgame journalentry queststate locals globalscript player objectstate cellid cellstate globalmap lightstate inventorystate containerstate
|
savedgame journalentry queststate locals globalscript player objectstate cellid cellstate globalmap lightstate inventorystate containerstate npcstate creaturestate
|
||||||
)
|
)
|
||||||
|
|
||||||
add_component_dir (misc
|
add_component_dir (misc
|
||||||
|
|
16
components/esm/creaturestate.cpp
Normal file
16
components/esm/creaturestate.cpp
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
#include "creaturestate.hpp"
|
||||||
|
|
||||||
|
void ESM::CreatureState::load (ESMReader &esm)
|
||||||
|
{
|
||||||
|
ObjectState::load (esm);
|
||||||
|
|
||||||
|
mInventory.load (esm);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ESM::CreatureState::save (ESMWriter &esm, bool inInventory) const
|
||||||
|
{
|
||||||
|
ObjectState::save (esm, inInventory);
|
||||||
|
|
||||||
|
mInventory.save (esm);
|
||||||
|
}
|
20
components/esm/creaturestate.hpp
Normal file
20
components/esm/creaturestate.hpp
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#ifndef OPENMW_ESM_CREATURESTATE_H
|
||||||
|
#define OPENMW_ESM_CREATURESTATE_H
|
||||||
|
|
||||||
|
#include "objectstate.hpp"
|
||||||
|
#include "inventorystate.hpp"
|
||||||
|
|
||||||
|
namespace ESM
|
||||||
|
{
|
||||||
|
// format 0, saved games only
|
||||||
|
|
||||||
|
struct CreatureState : public ObjectState
|
||||||
|
{
|
||||||
|
InventoryState mInventory;
|
||||||
|
|
||||||
|
virtual void load (ESMReader &esm);
|
||||||
|
virtual void save (ESMWriter &esm, bool inInventory = false) const;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
16
components/esm/npcstate.cpp
Normal file
16
components/esm/npcstate.cpp
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
#include "npcstate.hpp"
|
||||||
|
|
||||||
|
void ESM::NpcState::load (ESMReader &esm)
|
||||||
|
{
|
||||||
|
ObjectState::load (esm);
|
||||||
|
|
||||||
|
mInventory.load (esm);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ESM::NpcState::save (ESMWriter &esm, bool inInventory) const
|
||||||
|
{
|
||||||
|
ObjectState::save (esm, inInventory);
|
||||||
|
|
||||||
|
mInventory.save (esm);
|
||||||
|
}
|
20
components/esm/npcstate.hpp
Normal file
20
components/esm/npcstate.hpp
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#ifndef OPENMW_ESM_NPCSTATE_H
|
||||||
|
#define OPENMW_ESM_NPCSTATE_H
|
||||||
|
|
||||||
|
#include "objectstate.hpp"
|
||||||
|
#include "inventorystate.hpp"
|
||||||
|
|
||||||
|
namespace ESM
|
||||||
|
{
|
||||||
|
// format 0, saved games only
|
||||||
|
|
||||||
|
struct NpcState : public ObjectState
|
||||||
|
{
|
||||||
|
InventoryState mInventory;
|
||||||
|
|
||||||
|
virtual void load (ESMReader &esm);
|
||||||
|
virtual void save (ESMWriter &esm, bool inInventory = false) const;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "objectstate.hpp"
|
#include "npcstate.hpp"
|
||||||
#include "cellid.hpp"
|
#include "cellid.hpp"
|
||||||
#include "defs.hpp"
|
#include "defs.hpp"
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ namespace ESM
|
||||||
|
|
||||||
struct Player
|
struct Player
|
||||||
{
|
{
|
||||||
ObjectState mObject;
|
NpcState mObject;
|
||||||
CellId mCellId;
|
CellId mCellId;
|
||||||
float mLastKnownExteriorPosition[3];
|
float mLastKnownExteriorPosition[3];
|
||||||
unsigned char mHasMark;
|
unsigned char mHasMark;
|
||||||
|
|
Loading…
Reference in a new issue