1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 21:53:51 +00:00

Use dynamic_cast to get the LiveCellRef

This commit is contained in:
Chris Robinson 2013-08-14 20:26:50 -07:00
parent 48c07fbd98
commit 86f2cd5848
2 changed files with 4 additions and 2 deletions

View file

@ -28,6 +28,8 @@ namespace MWWorld
LiveCellRefBase(std::string type, const ESM::CellRef &cref=ESM::CellRef())
: mTypeName(type), mRef(cref), mData(mRef)
{ }
/* Need this for the class to be recognized as polymorphic */
virtual ~LiveCellRefBase() { }
};
/// A reference to one object (of any type) in a cell.

View file

@ -46,8 +46,8 @@ namespace MWWorld
template<typename T>
MWWorld::LiveCellRef<T> *get() const
{
if(mRef && mRef->mTypeName == typeid(T).name())
return static_cast<MWWorld::LiveCellRef<T>*>(mRef);
MWWorld::LiveCellRef<T> *ref = dynamic_cast<MWWorld::LiveCellRef<T>*>(mRef);
if(ref) return ref;
std::stringstream str;
str<< "Bad LiveCellRef cast to "<<typeid(T).name()<<" from ";