Utilize the mHasCustomData flag in writeAdditionalState

openmw-38
scrawl 9 years ago
parent 19d87c78f2
commit eb51e2838f

@ -299,6 +299,8 @@ namespace MWClass
void Container::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) const void Container::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) const
{ {
if (!state.mHasCustomState)
return;
const ESM::ContainerState& state2 = dynamic_cast<const ESM::ContainerState&> (state); const ESM::ContainerState& state2 = dynamic_cast<const ESM::ContainerState&> (state);
if (!ptr.getRefData().getCustomData()) if (!ptr.getRefData().getCustomData())
@ -316,7 +318,11 @@ namespace MWClass
{ {
ESM::ContainerState& state2 = dynamic_cast<ESM::ContainerState&> (state); ESM::ContainerState& state2 = dynamic_cast<ESM::ContainerState&> (state);
ensureCustomData (ptr); if (!ptr.getRefData().getCustomData())
{
state.mHasCustomState = false;
return;
}
dynamic_cast<ContainerCustomData&> (*ptr.getRefData().getCustomData()).mContainerStore. dynamic_cast<ContainerCustomData&> (*ptr.getRefData().getCustomData()).mContainerStore.
writeState (state2.mInventory); writeState (state2.mInventory);

@ -735,8 +735,6 @@ namespace MWClass
return; return;
} }
ensureCustomData (ptr);
CreatureCustomData& customData = ptr.getRefData().getCustomData()->asCreatureCustomData(); CreatureCustomData& customData = ptr.getRefData().getCustomData()->asCreatureCustomData();
customData.mContainerStore->writeState (state2.mInventory); customData.mContainerStore->writeState (state2.mInventory);

@ -104,6 +104,9 @@ namespace MWClass
void CreatureLevList::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) void CreatureLevList::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state)
const const
{ {
if (!state.mHasCustomState)
return;
const ESM::CreatureLevListState& state2 = dynamic_cast<const ESM::CreatureLevListState&> (state); const ESM::CreatureLevListState& state2 = dynamic_cast<const ESM::CreatureLevListState&> (state);
ensureCustomData(ptr); ensureCustomData(ptr);
@ -117,7 +120,12 @@ namespace MWClass
{ {
ESM::CreatureLevListState& state2 = dynamic_cast<ESM::CreatureLevListState&> (state); ESM::CreatureLevListState& state2 = dynamic_cast<ESM::CreatureLevListState&> (state);
ensureCustomData(ptr); if (!ptr.getRefData().getCustomData())
{
state.mHasCustomState = false;
return;
}
CreatureLevListCustomData& customData = ptr.getRefData().getCustomData()->asCreatureLevListCustomData(); CreatureLevListCustomData& customData = ptr.getRefData().getCustomData()->asCreatureLevListCustomData();
state2.mSpawnActorId = customData.mSpawnActorId; state2.mSpawnActorId = customData.mSpawnActorId;
state2.mSpawn = customData.mSpawn; state2.mSpawn = customData.mSpawn;

@ -343,6 +343,8 @@ namespace MWClass
void Door::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) const void Door::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) const
{ {
if (!state.mHasCustomState)
return;
ensureCustomData(ptr); ensureCustomData(ptr);
DoorCustomData& customData = ptr.getRefData().getCustomData()->asDoorCustomData(); DoorCustomData& customData = ptr.getRefData().getCustomData()->asDoorCustomData();
@ -352,7 +354,11 @@ namespace MWClass
void Door::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) const void Door::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state) const
{ {
ensureCustomData(ptr); if (!ptr.getRefData().getCustomData())
{
state.mHasCustomState = false;
return;
}
const DoorCustomData& customData = ptr.getRefData().getCustomData()->asDoorCustomData(); const DoorCustomData& customData = ptr.getRefData().getCustomData()->asDoorCustomData();
ESM::DoorState& state2 = dynamic_cast<ESM::DoorState&>(state); ESM::DoorState& state2 = dynamic_cast<ESM::DoorState&>(state);

@ -1187,8 +1187,6 @@ namespace MWClass
return; return;
} }
ensureCustomData (ptr);
NpcCustomData& customData = ptr.getRefData().getCustomData()->asNpcCustomData(); NpcCustomData& customData = ptr.getRefData().getCustomData()->asNpcCustomData();
customData.mInventoryStore.writeState (state2.mInventory); customData.mInventoryStore.writeState (state2.mInventory);

Loading…
Cancel
Save