mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 13:19:40 +00:00
store additional state of lights in saved game files
This commit is contained in:
parent
ec7cb90ca4
commit
900532a6ca
6 changed files with 73 additions and 3 deletions
|
@ -2,6 +2,7 @@
|
||||||
#include "light.hpp"
|
#include "light.hpp"
|
||||||
|
|
||||||
#include <components/esm/loadligh.hpp>
|
#include <components/esm/loadligh.hpp>
|
||||||
|
#include <components/esm/lightstate.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
@ -269,4 +270,24 @@ namespace MWClass
|
||||||
}
|
}
|
||||||
return std::make_pair(1,"");
|
return std::make_pair(1,"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Light::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
const ESM::LightState& state2 = dynamic_cast<const ESM::LightState&> (state);
|
||||||
|
|
||||||
|
ensureCustomData (ptr);
|
||||||
|
|
||||||
|
dynamic_cast<CustomData&> (*ptr.getRefData().getCustomData()).mTime = state2.mTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Light::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
ESM::LightState& state2 = dynamic_cast<ESM::LightState&> (state);
|
||||||
|
|
||||||
|
ensureCustomData (ptr);
|
||||||
|
|
||||||
|
state2.mTime = dynamic_cast<CustomData&> (*ptr.getRefData().getCustomData()).mTime;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,14 @@ namespace MWClass
|
||||||
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
|
||||||
|
|
||||||
std::pair<int, std::string> canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const;
|
std::pair<int, std::string> canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) 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.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <components/esm/cellid.hpp>
|
#include <components/esm/cellid.hpp>
|
||||||
#include <components/esm/esmwriter.hpp>
|
#include <components/esm/esmwriter.hpp>
|
||||||
#include <components/esm/objectstate.hpp>
|
#include <components/esm/objectstate.hpp>
|
||||||
|
#include <components/esm/lightstate.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
@ -331,7 +332,7 @@ namespace MWWorld
|
||||||
writeReferenceCollection<ESM::ObjectState> (writer, mIngreds);
|
writeReferenceCollection<ESM::ObjectState> (writer, mIngreds);
|
||||||
writeReferenceCollection<ESM::ObjectState> (writer, mCreatureLists);
|
writeReferenceCollection<ESM::ObjectState> (writer, mCreatureLists);
|
||||||
writeReferenceCollection<ESM::ObjectState> (writer, mItemLists);
|
writeReferenceCollection<ESM::ObjectState> (writer, mItemLists);
|
||||||
writeReferenceCollection<ESM::ObjectState> (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::ObjectState> (writer, mNpcs);
|
||||||
|
@ -413,7 +414,7 @@ namespace MWWorld
|
||||||
|
|
||||||
case ESM::REC_LIGH:
|
case ESM::REC_LIGH:
|
||||||
|
|
||||||
readReferenceCollection<ESM::ObjectState> (reader, mLights, contentFileMap);
|
readReferenceCollection<ESM::LightState> (reader, mLights, contentFileMap);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ESM::REC_LOCK:
|
case ESM::REC_LOCK:
|
||||||
|
|
|
@ -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
|
savedgame journalentry queststate locals globalscript player objectstate cellid cellstate globalmap lightstate
|
||||||
)
|
)
|
||||||
|
|
||||||
add_component_dir (misc
|
add_component_dir (misc
|
||||||
|
|
21
components/esm/lightstate.cpp
Normal file
21
components/esm/lightstate.cpp
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
#include "lightstate.hpp"
|
||||||
|
|
||||||
|
#include "esmreader.hpp"
|
||||||
|
#include "esmwriter.hpp"
|
||||||
|
|
||||||
|
void ESM::LightState::load (ESMReader &esm)
|
||||||
|
{
|
||||||
|
ObjectState::load (esm);
|
||||||
|
|
||||||
|
mTime = 0;
|
||||||
|
esm.getHNOT (mTime, "LTIM");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ESM::LightState::save (ESMWriter &esm, bool inInventory) const
|
||||||
|
{
|
||||||
|
ObjectState::save (esm, inInventory);
|
||||||
|
|
||||||
|
if (mTime)
|
||||||
|
esm.writeHNT ("LTIM", mTime);
|
||||||
|
}
|
19
components/esm/lightstate.hpp
Normal file
19
components/esm/lightstate.hpp
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef OPENMW_ESM_LIGHTSTATE_H
|
||||||
|
#define OPENMW_ESM_LIGHTSTATE_H
|
||||||
|
|
||||||
|
#include "objectstate.hpp"
|
||||||
|
|
||||||
|
namespace ESM
|
||||||
|
{
|
||||||
|
// format 0, saved games only
|
||||||
|
|
||||||
|
struct LightState : public ObjectState
|
||||||
|
{
|
||||||
|
float mTime;
|
||||||
|
|
||||||
|
virtual void load (ESMReader &esm);
|
||||||
|
virtual void save (ESMWriter &esm, bool inInventory = false) const;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue