aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Object
diff options
context:
space:
mode:
authorclick <none@none>2010-08-06 03:00:39 +0200
committerclick <none@none>2010-08-06 03:00:39 +0200
commit0caaa3e478701e655ce0429a826abd48c023d1fd (patch)
tree9b605667a3ffa1fd37a6383669083ccd3ba0a875 /src/server/game/Entities/Object
parent71ef21de21be2e4fc426c8ebb3be3556e517bee0 (diff)
Revert changes done in r0074e32c2f and r4d86e4199a - fixes buildissues ( if()+reinterpret_cast is faster than dynamic_casts btw )
--HG-- branch : trunk
Diffstat (limited to 'src/server/game/Entities/Object')
-rw-r--r--src/server/game/Entities/Object/Object.cpp42
-rw-r--r--src/server/game/Entities/Object/Object.h14
2 files changed, 5 insertions, 51 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index b2344f21873..203b6a3e1b6 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -101,7 +101,7 @@ Object::~Object()
{
sLog.outCrash("Object::~Object - guid="UI64FMTD", typeid=%d, entry=%u deleted but still in world!!", GetGUID(), GetTypeId(), GetEntry());
if (isType(TYPEMASK_ITEM))
- sLog.outCrash("Item slot %u", this->ToItem()->GetSlot());
+ sLog.outCrash("Item slot %u", ((Item*)this)->GetSlot());
ASSERT(false);
RemoveFromWorld();
}
@@ -1135,46 +1135,6 @@ bool Object::PrintIndexError(uint32 index, bool set) const
return false;
}
-inline Unit* Object::ToUnit()
-{
- return dynamic_cast<Unit*>(this);
-}
-
-inline const Unit* Object::ToUnit() const
-{
- return dynamic_cast<const Unit*>(this);
-}
-
-inline Player* Object::ToPlayer()
-{
- return dynamic_cast<Player*>(this);
-}
-
-inline const Player* Object::ToPlayer() const
-{
- return dynamic_cast<const Player*>(this);
-}
-
-inline Creature* Object::ToCreature()
-{
- return dynamic_cast<Creature*>(this);
-}
-
-inline const Creature* Object::ToCreature() const
-{
- return dynamic_cast<const Creature*>(this);
-}
-
-inline Item* Object::ToItem()
-{
- return dynamic_cast<Item*>(this);
-}
-
-inline const Item* Object::ToItem() const
-{
- return dynamic_cast<const Item*>(this);
-}
-
bool Position::HasInLine(const Unit * const target, float distance, float width) const
{
if (!HasInArc(M_PI, target) || !target->IsWithinDist3d(m_positionX, m_positionY, m_positionZ, distance))
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index af0c7fb76c5..af501823d4a 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -116,8 +116,6 @@ class CreatureAI;
class ZoneScript;
class Unit;
class Transport;
-class Item;
-
typedef UNORDERED_MAP<Player*, UpdateData> UpdateDataMapType;
@@ -321,14 +319,10 @@ class Object
// FG: some hacky helpers
void ForceValuesUpdateAtIndex(uint32);
- Unit* ToUnit();
- const Unit* ToUnit() const;
- Player* ToPlayer();
- const Player* ToPlayer() const;
- Creature* ToCreature();
- const Creature* ToCreature() const;
- Item* ToItem();
- const Item* ToItem() const;
+ Player* ToPlayer(){ if (GetTypeId() == TYPEID_PLAYER) return reinterpret_cast<Player*>(this); else return NULL; }
+ const Player* ToPlayer() const { if (GetTypeId() == TYPEID_PLAYER) return (const Player*)((Player*)this); else return NULL; }
+ Creature* ToCreature(){ if (GetTypeId() == TYPEID_UNIT) return reinterpret_cast<Creature*>(this); else return NULL; }
+ const Creature* ToCreature() const {if (GetTypeId() == TYPEID_UNIT) return (const Creature*)((Creature*)this); else return NULL; }
protected: