Revert changes done in r0074e32c2f and r4d86e4199a - fixes buildissues ( if()+reinterpret_cast is faster than dynamic_casts btw )
--HG-- branch : trunk
This commit is contained in:
@@ -257,16 +257,6 @@ Item::Item()
|
||||
m_paidExtendedCost = 0;
|
||||
}
|
||||
|
||||
inline Bag* Item::ToBag()
|
||||
{
|
||||
return dynamic_cast<Bag*>(this);
|
||||
}
|
||||
|
||||
inline const Bag* Item::ToBag() const
|
||||
{
|
||||
return dynamic_cast<const Bag*>(this);
|
||||
}
|
||||
|
||||
bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner)
|
||||
{
|
||||
Object::_Create(guidlow, 0, HIGHGUID_ITEM);
|
||||
|
||||
@@ -347,9 +347,6 @@ class Item : public Object
|
||||
|
||||
void BuildUpdate(UpdateDataMapType&);
|
||||
|
||||
Bag* ToBag();
|
||||
const Bag* ToBag() const;
|
||||
|
||||
private:
|
||||
std::string m_text;
|
||||
uint8 m_slot;
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
@@ -16740,36 +16740,6 @@ uint32 Unit::GetRemainingDotDamage(uint64 caster, uint32 spellId, uint8 effectIn
|
||||
return amount;
|
||||
}
|
||||
|
||||
inline Pet* Unit::ToPet()
|
||||
{
|
||||
return dynamic_cast<Pet*>(this);
|
||||
}
|
||||
|
||||
inline const Pet* Unit::ToPet() const
|
||||
{
|
||||
return dynamic_cast<const Pet*>(this);
|
||||
}
|
||||
|
||||
inline Totem* Unit::ToTotem()
|
||||
{
|
||||
return dynamic_cast<Totem*>(this);
|
||||
}
|
||||
|
||||
inline const Totem* Unit::ToTotem() const
|
||||
{
|
||||
return dynamic_cast<const Totem*>(this);
|
||||
}
|
||||
|
||||
inline TempSummon* Unit::ToTempSummon()
|
||||
{
|
||||
return dynamic_cast<TempSummon*>(this);
|
||||
}
|
||||
|
||||
inline const TempSummon* Unit::ToTempSummon() const
|
||||
{
|
||||
return dynamic_cast<const TempSummon*>(this);
|
||||
}
|
||||
|
||||
void CharmInfo::SetIsCommandAttack(bool val)
|
||||
{
|
||||
m_isCommandAttack = val;
|
||||
|
||||
@@ -1980,12 +1980,10 @@ class Unit : public WorldObject
|
||||
virtual bool isBeingLoaded() const { return false;}
|
||||
bool IsDuringRemoveFromWorld() const {return m_duringRemoveFromWorld;}
|
||||
|
||||
Pet* ToPet();
|
||||
const Pet* ToPet() const;
|
||||
Totem* ToTotem();
|
||||
const Totem* ToTotem() const;
|
||||
TempSummon* ToTempSummon();
|
||||
const TempSummon* ToTempSummon() const;
|
||||
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; }
|
||||
|
||||
protected:
|
||||
explicit Unit ();
|
||||
|
||||
@@ -2787,7 +2787,7 @@ void Map::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source, O
|
||||
// prepare static data
|
||||
uint64 sourceGUID = source ? source->GetGUID() : (uint64)0; //some script commands doesn't have source
|
||||
uint64 targetGUID = target ? target->GetGUID() : (uint64)0;
|
||||
uint64 ownerGUID = (source->GetTypeId() == TYPEID_ITEM) ? source->ToItem()->GetOwnerGUID() : (uint64)0;
|
||||
uint64 ownerGUID = (source->GetTypeId() == TYPEID_ITEM) ? ((Item*)source)->GetOwnerGUID() : (uint64)0;
|
||||
|
||||
///- Schedule script execution for all scripts in the script map
|
||||
ScriptMap const *s2 = &(s->second);
|
||||
@@ -2822,7 +2822,7 @@ void Map::ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* sou
|
||||
// prepare static data
|
||||
uint64 sourceGUID = source ? source->GetGUID() : (uint64)0;
|
||||
uint64 targetGUID = target ? target->GetGUID() : (uint64)0;
|
||||
uint64 ownerGUID = (source->GetTypeId() == TYPEID_ITEM) ? source->ToItem()->GetOwnerGUID() : (uint64)0;
|
||||
uint64 ownerGUID = (source->GetTypeId() == TYPEID_ITEM) ? ((Item*)source)->GetOwnerGUID() : (uint64)0;
|
||||
|
||||
ScriptAction sa;
|
||||
sa.sourceGUID = sourceGUID;
|
||||
|
||||
@@ -193,13 +193,13 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
|
||||
case TYPEID_ITEM:
|
||||
case TYPEID_CONTAINER:
|
||||
{
|
||||
sScriptMgr.ItemQuestAccept(_player, pObject->ToItem(), qInfo);
|
||||
sScriptMgr.ItemQuestAccept(_player, ((Item*)pObject), qInfo);
|
||||
|
||||
// destroy not required for quest finish quest starting item
|
||||
bool destroyItem = true;
|
||||
for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
|
||||
{
|
||||
if (qInfo->ReqItemId[i] == pObject->ToItem()->GetEntry() && pObject->ToItem()->GetProto()->MaxCount > 0)
|
||||
if ((qInfo->ReqItemId[i] == ((Item*)pObject)->GetEntry()) && (((Item*)pObject)->GetProto()->MaxCount > 0))
|
||||
{
|
||||
destroyItem = false;
|
||||
break;
|
||||
@@ -207,7 +207,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket & recv_data)
|
||||
}
|
||||
|
||||
if (destroyItem)
|
||||
_player->DestroyItem(pObject->ToItem()->GetBagSlot(), pObject->ToItem()->GetSlot(),true);
|
||||
_player->DestroyItem(((Item*)pObject)->GetBagSlot(), ((Item*)pObject)->GetSlot(),true);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user