mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
Merge remote-tracking branch 'scrawl/persistence'
This commit is contained in:
commit
2c8a511179
13 changed files with 45 additions and 7 deletions
|
@ -235,6 +235,12 @@ namespace MWClass
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool Creature::isPersistent(const MWWorld::Ptr &actor) const
|
||||
{
|
||||
MWWorld::LiveCellRef<ESM::Creature>* ref = actor.get<ESM::Creature>();
|
||||
return ref->mBase->mPersistent;
|
||||
}
|
||||
|
||||
MWWorld::Ptr
|
||||
Creature::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const
|
||||
{
|
||||
|
|
|
@ -64,6 +64,8 @@ namespace MWClass
|
|||
|
||||
virtual int getServices (const MWWorld::Ptr& actor) const;
|
||||
|
||||
virtual bool isPersistent (const MWWorld::Ptr& ptr) const;
|
||||
|
||||
static void registerSelf();
|
||||
|
||||
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||
|
|
|
@ -235,6 +235,12 @@ namespace MWClass
|
|||
MWBase::Environment::get().getMechanicsManager()->add(ptr);
|
||||
}
|
||||
|
||||
bool Npc::isPersistent(const MWWorld::Ptr &actor) const
|
||||
{
|
||||
MWWorld::LiveCellRef<ESM::NPC>* ref = actor.get<ESM::NPC>();
|
||||
return ref->mBase->mPersistent;
|
||||
}
|
||||
|
||||
std::string Npc::getModel(const MWWorld::Ptr &ptr) const
|
||||
{
|
||||
MWWorld::LiveCellRef<ESM::NPC> *ref =
|
||||
|
|
|
@ -130,6 +130,8 @@ namespace MWClass
|
|||
|
||||
virtual int getServices (const MWWorld::Ptr& actor) const;
|
||||
|
||||
virtual bool isPersistent (const MWWorld::Ptr& ptr) const;
|
||||
|
||||
static void registerSelf();
|
||||
|
||||
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
|
||||
|
|
|
@ -201,7 +201,7 @@ namespace MWGui
|
|||
{
|
||||
mPtr = container;
|
||||
|
||||
if (container.getTypeName() == typeid(ESM::NPC).name() && !loot)
|
||||
if (!loot)
|
||||
{
|
||||
// we are stealing stuff
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
|
@ -258,9 +258,9 @@ namespace MWGui
|
|||
onTakeAllButtonClicked(mTakeButton);
|
||||
|
||||
/// \todo if corpse is non-disposable: messagebox #{sDisposeCorpseFail}
|
||||
//if ()
|
||||
// MWBase::Environment::get().getWindowManager()->messageBox("#{sDisposeCorpseFail}");
|
||||
//else
|
||||
if (MWWorld::Class::get(mPtr).isPersistent(mPtr))
|
||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sDisposeCorpseFail}");
|
||||
else
|
||||
MWBase::Environment::get().getWorld()->deleteObject(mPtr);
|
||||
|
||||
mPtr = MWWorld::Ptr();
|
||||
|
|
|
@ -220,6 +220,11 @@ namespace MWWorld
|
|||
return get (ptr.getTypeName());
|
||||
}
|
||||
|
||||
bool Class::isPersistent(const Ptr &ptr) const
|
||||
{
|
||||
throw std::runtime_error ("class does not support persistence");
|
||||
}
|
||||
|
||||
void Class::registerClass (const std::string& key, boost::shared_ptr<Class> instance)
|
||||
{
|
||||
sClasses.insert (std::make_pair (key, instance));
|
||||
|
|
|
@ -253,6 +253,8 @@ namespace MWWorld
|
|||
|
||||
virtual float getWeight (const MWWorld::Ptr& ptr) const;
|
||||
|
||||
virtual bool isPersistent (const MWWorld::Ptr& ptr) const;
|
||||
|
||||
virtual Ptr
|
||||
copyToCell(const Ptr &ptr, CellStore &cell) const;
|
||||
|
||||
|
|
|
@ -15,8 +15,9 @@ ESM_Context ESMReader::getContext()
|
|||
return mCtx;
|
||||
}
|
||||
|
||||
ESMReader::ESMReader():
|
||||
mBuffer(50*1024)
|
||||
ESMReader::ESMReader()
|
||||
: mBuffer(50*1024)
|
||||
, mRecordFlags(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -216,7 +216,7 @@ public:
|
|||
follows the header, ie beyond the entire record. You should use
|
||||
leftRec to orient yourself inside the record itself.
|
||||
*/
|
||||
void getRecHeader() { uint32_t u; getRecHeader(u); }
|
||||
void getRecHeader() { getRecHeader(mRecordFlags); }
|
||||
void getRecHeader(uint32_t &flags);
|
||||
|
||||
bool hasMoreRecs() const { return mCtx.leftFile > 0; }
|
||||
|
@ -249,11 +249,16 @@ public:
|
|||
/// Sets font encoder for ESM strings
|
||||
void setEncoder(ToUTF8::Utf8Encoder* encoder);
|
||||
|
||||
/// Get record flags of last record
|
||||
unsigned int getRecordFlags() { return mRecordFlags; }
|
||||
|
||||
private:
|
||||
Ogre::DataStreamPtr mEsm;
|
||||
|
||||
ESM_Context mCtx;
|
||||
|
||||
unsigned int mRecordFlags;
|
||||
|
||||
// Special file signifier (see SpecialFile enum above)
|
||||
|
||||
// Buffer for ESM strings
|
||||
|
|
|
@ -7,6 +7,8 @@ namespace ESM {
|
|||
|
||||
void Creature::load(ESMReader &esm)
|
||||
{
|
||||
mPersistent = esm.getRecordFlags() & 0x0400;
|
||||
|
||||
mModel = esm.getHNString("MODL");
|
||||
mOriginal = esm.getHNOString("CNAM");
|
||||
mName = esm.getHNOString("FNAM");
|
||||
|
|
|
@ -69,6 +69,9 @@ struct Creature
|
|||
NPDTstruct mData;
|
||||
|
||||
int mFlags;
|
||||
|
||||
bool mPersistent;
|
||||
|
||||
float mScale;
|
||||
|
||||
std::string mId, mModel, mName, mScript;
|
||||
|
|
|
@ -10,6 +10,8 @@ void NPC::load(ESMReader &esm)
|
|||
{
|
||||
mNpdt52.mGold = -10;
|
||||
|
||||
mPersistent = esm.getRecordFlags() & 0x0400;
|
||||
|
||||
mModel = esm.getHNOString("MODL");
|
||||
mName = esm.getHNOString("FNAM");
|
||||
|
||||
|
|
|
@ -100,6 +100,8 @@ struct NPC
|
|||
|
||||
int mFlags;
|
||||
|
||||
bool mPersistent;
|
||||
|
||||
InventoryList mInventory;
|
||||
SpellList mSpells;
|
||||
|
||||
|
|
Loading…
Reference in a new issue