mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 13:15:32 +00:00
Improve const-correctness in writeAdditionalState
This commit is contained in:
parent
b48445dea7
commit
ed3486e816
19 changed files with 33 additions and 32 deletions
|
@ -313,7 +313,7 @@ namespace MWClass
|
|||
readState (state2.mInventory);
|
||||
}
|
||||
|
||||
void Container::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) const
|
||||
void Container::writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) const
|
||||
{
|
||||
ESM::ContainerState& state2 = dynamic_cast<ESM::ContainerState&> (state);
|
||||
|
||||
|
@ -323,7 +323,7 @@ namespace MWClass
|
|||
return;
|
||||
}
|
||||
|
||||
dynamic_cast<ContainerCustomData&> (*ptr.getRefData().getCustomData()).mContainerStore.
|
||||
dynamic_cast<const ContainerCustomData&> (*ptr.getRefData().getCustomData()).mContainerStore.
|
||||
writeState (state2.mInventory);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace MWClass
|
|||
const;
|
||||
///< Read additional state from \a state into \a ptr.
|
||||
|
||||
virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
|
||||
virtual void writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state)
|
||||
const;
|
||||
///< Write additional state from \a ptr into \a state.
|
||||
|
||||
|
|
|
@ -724,7 +724,7 @@ namespace MWClass
|
|||
customData.mCreatureStats.readState (state2.mCreatureStats);
|
||||
}
|
||||
|
||||
void Creature::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
|
||||
void Creature::writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state)
|
||||
const
|
||||
{
|
||||
ESM::CreatureState& state2 = dynamic_cast<ESM::CreatureState&> (state);
|
||||
|
@ -735,7 +735,7 @@ namespace MWClass
|
|||
return;
|
||||
}
|
||||
|
||||
CreatureCustomData& customData = ptr.getRefData().getCustomData()->asCreatureCustomData();
|
||||
const CreatureCustomData& customData = dynamic_cast<const CreatureCustomData&>(*ptr.getRefData().getCustomData());
|
||||
|
||||
customData.mContainerStore->writeState (state2.mInventory);
|
||||
customData.mCreatureStats.writeState (state2.mCreatureStats);
|
||||
|
|
|
@ -117,12 +117,10 @@ namespace MWClass
|
|||
/// 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 void readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state)
|
||||
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;
|
||||
virtual void writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) const;
|
||||
///< Write additional state from \a ptr into \a state.
|
||||
|
||||
virtual int getBaseGold(const MWWorld::Ptr& ptr) const;
|
||||
|
|
|
@ -115,7 +115,7 @@ namespace MWClass
|
|||
customData.mSpawn = state2.mSpawn;
|
||||
}
|
||||
|
||||
void CreatureLevList::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
|
||||
void CreatureLevList::writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state)
|
||||
const
|
||||
{
|
||||
ESM::CreatureLevListState& state2 = dynamic_cast<ESM::CreatureLevListState&> (state);
|
||||
|
@ -126,7 +126,7 @@ namespace MWClass
|
|||
return;
|
||||
}
|
||||
|
||||
CreatureLevListCustomData& customData = ptr.getRefData().getCustomData()->asCreatureLevListCustomData();
|
||||
const CreatureLevListCustomData& customData = dynamic_cast<const CreatureLevListCustomData&>(*ptr.getRefData().getCustomData());
|
||||
state2.mSpawnActorId = customData.mSpawnActorId;
|
||||
state2.mSpawn = customData.mSpawn;
|
||||
}
|
||||
|
|
|
@ -23,12 +23,10 @@ namespace MWClass
|
|||
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state)
|
||||
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;
|
||||
virtual void writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) const;
|
||||
///< Write additional state from \a ptr into \a state.
|
||||
|
||||
virtual void respawn (const MWWorld::Ptr& ptr) const;
|
||||
|
|
|
@ -351,14 +351,14 @@ namespace MWClass
|
|||
customData.mDoorState = state2.mDoorState;
|
||||
}
|
||||
|
||||
void Door::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) const
|
||||
void Door::writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) const
|
||||
{
|
||||
if (!ptr.getRefData().getCustomData())
|
||||
{
|
||||
state.mHasCustomState = false;
|
||||
return;
|
||||
}
|
||||
const DoorCustomData& customData = ptr.getRefData().getCustomData()->asDoorCustomData();
|
||||
const DoorCustomData& customData = dynamic_cast<const DoorCustomData&>(*ptr.getRefData().getCustomData());
|
||||
|
||||
ESM::DoorState& state2 = dynamic_cast<ESM::DoorState&>(state);
|
||||
state2.mDoorState = customData.mDoorState;
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace MWClass
|
|||
const;
|
||||
///< Read additional state from \a state into \a ptr.
|
||||
|
||||
virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
|
||||
virtual void writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state)
|
||||
const;
|
||||
///< Write additional state from \a ptr into \a state.
|
||||
};
|
||||
|
|
|
@ -1175,7 +1175,7 @@ namespace MWClass
|
|||
static_cast<MWMechanics::CreatureStats&> (customData.mNpcStats).readState (state2.mCreatureStats);
|
||||
}
|
||||
|
||||
void Npc::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
|
||||
void Npc::writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state)
|
||||
const
|
||||
{
|
||||
ESM::NpcState& state2 = dynamic_cast<ESM::NpcState&> (state);
|
||||
|
@ -1186,7 +1186,7 @@ namespace MWClass
|
|||
return;
|
||||
}
|
||||
|
||||
NpcCustomData& customData = ptr.getRefData().getCustomData()->asNpcCustomData();
|
||||
const NpcCustomData& customData = dynamic_cast<const NpcCustomData&>(*ptr.getRefData().getCustomData());
|
||||
|
||||
customData.mInventoryStore.writeState (state2.mInventory);
|
||||
customData.mNpcStats.writeState (state2.mNpcStats);
|
||||
|
|
|
@ -145,7 +145,7 @@ namespace MWClass
|
|||
const;
|
||||
///< Read additional state from \a state into \a ptr.
|
||||
|
||||
virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
|
||||
virtual void writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state)
|
||||
const;
|
||||
///< Write additional state from \a ptr into \a state.
|
||||
|
||||
|
|
|
@ -397,7 +397,7 @@ namespace MWWorld
|
|||
|
||||
void Class::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) const {}
|
||||
|
||||
void Class::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) const {}
|
||||
void Class::writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state) const {}
|
||||
|
||||
int Class::getBaseGold(const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
|
|
|
@ -313,7 +313,7 @@ namespace MWWorld
|
|||
const;
|
||||
///< Read additional state from \a state into \a ptr.
|
||||
|
||||
virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
|
||||
virtual void writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state)
|
||||
const;
|
||||
///< Write additional state from \a ptr into \a state.
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ void MWWorld::ContainerStore::storeState (const LiveCellRef<T>& ref, ESM::Object
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
void MWWorld::ContainerStore::storeStates (CellRefList<T>& collection,
|
||||
void MWWorld::ContainerStore::storeStates (const CellRefList<T>& collection,
|
||||
ESM::InventoryState& inventory, int& index, bool equipable) const
|
||||
{
|
||||
for (typename CellRefList<T>::List::const_iterator iter (collection.mList.begin());
|
||||
|
@ -707,7 +707,7 @@ MWWorld::Ptr MWWorld::ContainerStore::search (const std::string& id)
|
|||
return Ptr();
|
||||
}
|
||||
|
||||
void MWWorld::ContainerStore::writeState (ESM::InventoryState& state)
|
||||
void MWWorld::ContainerStore::writeState (ESM::InventoryState& state) const
|
||||
{
|
||||
state.mItems.clear();
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace MWWorld
|
|||
void storeState (const LiveCellRef<T>& ref, ESM::ObjectState& state) const;
|
||||
|
||||
template<typename T>
|
||||
void storeStates (CellRefList<T>& collection,
|
||||
void storeStates (const CellRefList<T>& collection,
|
||||
ESM::InventoryState& inventory, int& index,
|
||||
bool equipable = false) const;
|
||||
|
||||
|
@ -169,8 +169,7 @@ namespace MWWorld
|
|||
|
||||
Ptr search (const std::string& id);
|
||||
|
||||
/// \todo make this method const once const-correct ContainerStoreIterators are available
|
||||
virtual void writeState (ESM::InventoryState& state);
|
||||
virtual void writeState (ESM::InventoryState& state) const;
|
||||
|
||||
virtual void readState (const ESM::InventoryState& state);
|
||||
|
||||
|
|
|
@ -752,7 +752,7 @@ bool MWWorld::InventoryStore::isEquipped(const MWWorld::Ptr &item)
|
|||
return false;
|
||||
}
|
||||
|
||||
void MWWorld::InventoryStore::writeState(ESM::InventoryState &state)
|
||||
void MWWorld::InventoryStore::writeState(ESM::InventoryState &state) const
|
||||
{
|
||||
MWWorld::ContainerStore::writeState(state);
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ namespace MWWorld
|
|||
virtual void clear();
|
||||
///< Empty container.
|
||||
|
||||
virtual void writeState (ESM::InventoryState& state);
|
||||
virtual void writeState (ESM::InventoryState& state) const;
|
||||
|
||||
virtual void readState (const ESM::InventoryState& state);
|
||||
};
|
||||
|
|
|
@ -54,8 +54,7 @@ void MWWorld::LiveCellRefBase::saveImp (ESM::ObjectState& state) const
|
|||
{
|
||||
mRef.writeState(state);
|
||||
|
||||
/// \todo get rid of this cast once const-correct Ptr are available
|
||||
Ptr ptr (const_cast<LiveCellRefBase *> (this));
|
||||
ConstPtr ptr (this);
|
||||
|
||||
mData.write (state, mClass->getScript (ptr));
|
||||
|
||||
|
|
|
@ -205,6 +205,11 @@ namespace MWWorld
|
|||
return mCustomData;
|
||||
}
|
||||
|
||||
const CustomData *RefData::getCustomData() const
|
||||
{
|
||||
return mCustomData;
|
||||
}
|
||||
|
||||
bool RefData::hasChanged() const
|
||||
{
|
||||
return mChanged;
|
||||
|
|
|
@ -116,6 +116,8 @@ namespace MWWorld
|
|||
CustomData *getCustomData();
|
||||
///< May return a 0-pointer. The ownership of the return data object is not transferred.
|
||||
|
||||
const CustomData *getCustomData() const;
|
||||
|
||||
bool hasChanged() const;
|
||||
///< Has this RefData changed since it was originally loaded?
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue