*Add function GetPlayer and GetCreature for scripts. Please try to not use GetUnit in the future.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-04-11 13:42:34 -05:00
parent 80e1a5faac
commit 9378a9cf21
56 changed files with 196 additions and 169 deletions
+1 -1
View File
@@ -124,7 +124,7 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
{
while (!m_assistants.empty())
{
Creature* assistant = (Creature*)Unit::GetUnit(m_owner, *m_assistants.begin());
Creature* assistant = Unit::GetCreature(m_owner, *m_assistants.begin());
m_assistants.pop_front();
if (assistant && assistant->CanAssistTo(&m_owner, victim))
+10
View File
@@ -10436,6 +10436,16 @@ Unit* Unit::GetUnit(WorldObject& object, uint64 guid)
return ObjectAccessor::GetUnit(object,guid);
}
Player* Unit::GetPlayer(uint64 guid)
{
return ObjectAccessor::FindPlayer(guid);
}
Creature* Unit::GetCreature(WorldObject& object, uint64 guid)
{
return ObjectAccessor::GetCreature(object, guid);
}
bool Unit::isVisibleForInState( Player const* u, bool inVisibleList ) const
{
return isVisibleForOrDetect(u, false, inVisibleList, false);
+17
View File
@@ -1363,6 +1363,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void addFollower(FollowerReference* pRef) { m_FollowingRefManager.insertFirst(pRef); }
void removeFollower(FollowerReference* /*pRef*/ ) { /* nothing to do yet */ }
static Unit* GetUnit(WorldObject& object, uint64 guid);
static Player* GetPlayer(uint64 guid);
static Creature* GetCreature(WorldObject& object, uint64 guid);
MotionMaster* GetMotionMaster() { return &i_motionMaster; }
@@ -1509,5 +1511,20 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
uint32 m_reducedThreatPercent;
uint64 m_misdirectionTargetGUID;
};
namespace Trinity
{
template<class T>
void RandomResizeList(std::list<T> &_list, uint32 _size)
{
while(_list.size() > _size)
{
typename std::list<T>::iterator itr = _list.begin();
advance(itr, urand(0, _list.size() - 1));
_list.erase(itr);
}
}
}
#endif