Use the const version of CustomData::as*

openmw-38
scrawl 9 years ago
parent 16e3699739
commit 0d4729dcd5

@ -734,7 +734,7 @@ namespace MWClass
return;
}
const CreatureCustomData& customData = dynamic_cast<const CreatureCustomData&>(*ptr.getRefData().getCustomData());
const CreatureCustomData& customData = ptr.getRefData().getCustomData()->asCreatureCustomData();
customData.mContainerStore->writeState (state2.mInventory);
customData.mCreatureStats.writeState (state2.mCreatureStats);

@ -22,6 +22,10 @@ namespace MWClass
{
return *this;
}
virtual const CreatureLevListCustomData& asCreatureLevListCustomData() const
{
return *this;
}
};
MWWorld::CustomData *CreatureLevListCustomData::clone() const
@ -121,7 +125,7 @@ namespace MWClass
return;
}
const CreatureLevListCustomData& customData = dynamic_cast<const CreatureLevListCustomData&>(*ptr.getRefData().getCustomData());
const CreatureLevListCustomData& customData = ptr.getRefData().getCustomData()->asCreatureLevListCustomData();
state2.mSpawnActorId = customData.mSpawnActorId;
state2.mSpawn = customData.mSpawn;
}

@ -351,7 +351,7 @@ namespace MWClass
state.mHasCustomState = false;
return;
}
const DoorCustomData& customData = dynamic_cast<const DoorCustomData&>(*ptr.getRefData().getCustomData());
const DoorCustomData& customData = ptr.getRefData().getCustomData()->asDoorCustomData();
ESM::DoorState& state2 = dynamic_cast<ESM::DoorState&>(state);
state2.mDoorState = customData.mDoorState;

@ -1184,7 +1184,7 @@ namespace MWClass
return;
}
const NpcCustomData& customData = dynamic_cast<const NpcCustomData&>(*ptr.getRefData().getCustomData());
const NpcCustomData& customData = ptr.getRefData().getCustomData()->asNpcCustomData();
customData.mInventoryStore.writeState (state2.mInventory);
customData.mNpcStats.writeState (state2.mNpcStats);

@ -63,5 +63,12 @@ MWClass::CreatureLevListCustomData &CustomData::asCreatureLevListCustomData()
throw std::logic_error(error.str());
}
const MWClass::CreatureLevListCustomData &CustomData::asCreatureLevListCustomData() const
{
std::stringstream error;
error << "bad cast " << typeid(this).name() << " to CreatureLevListCustomData";
throw std::logic_error(error.str());
}
}

@ -35,6 +35,7 @@ namespace MWWorld
virtual const MWClass::DoorCustomData& asDoorCustomData() const;
virtual MWClass::CreatureLevListCustomData& asCreatureLevListCustomData();
virtual const MWClass::CreatureLevListCustomData& asCreatureLevListCustomData() const;
};
}

Loading…
Cancel
Save