Make typecasting methods *really* safe and get rid of redundant typeId/Typemask checks, thanks Zor and Machiavelli for help

--HG--
branch : trunk
This commit is contained in:
Shauren
2010-08-05 17:01:25 +02:00
parent 30194bdd61
commit c94046b065
6 changed files with 98 additions and 8 deletions
+6 -4
View File
@@ -1980,10 +1980,12 @@ class Unit : public WorldObject
virtual bool isBeingLoaded() const { return false;}
bool IsDuringRemoveFromWorld() const {return m_duringRemoveFromWorld;}
Pet* ToPet(){ if (isPet()) return reinterpret_cast<Pet*>(this); else return NULL; }
Totem* ToTotem(){ if (isTotem()) return reinterpret_cast<Totem*>(this); else return NULL; }
TempSummon* ToTempSummon() { if (isSummon()) return reinterpret_cast<TempSummon*>(this); else return NULL; }
const TempSummon* ToTempSummon() const { if (isSummon()) return reinterpret_cast<const TempSummon*>(this); else return NULL; }
Pet* ToPet();
const Pet* ToPet() const;
Totem* ToTotem();
const Totem* ToTotem() const;
TempSummon* ToTempSummon();
const TempSummon* ToTempSummon() const;
protected:
explicit Unit ();