[10106] More modes for .go commands

* Now '.go' command can be used with creature_entry/gameobject_entry shift links (output of .lookup creature/object commands)
* Now '.go object' command sipport id-mode and name part mode similar .go creature case: .go object id #gameobject_id or .go object $namepart.
* HandleGoHelper use in more commands also.
This commit is contained in:
VladimirMangos 2010-06-26 14:57:36 +04:00
parent e203a235ba
commit a504b4d200
13 changed files with 439 additions and 235 deletions

View file

@ -35,6 +35,7 @@
#include "Transports.h"
#include "ProgressBar.h"
#include "Language.h"
#include "PoolManager.h"
#include "GameEventMgr.h"
#include "Spell.h"
#include "Chat.h"
@ -8624,3 +8625,103 @@ Quest const* GetQuestTemplateStore(uint32 entry)
{
return sObjectMgr.GetQuestTemplate(entry);
}
bool FindCreatureData::operator()( CreatureDataPair const& dataPair )
{
// skip wrong entry ids
if (i_id && dataPair.second.id != i_id)
return false;
if (!i_anyData)
i_anyData = &dataPair;
// without player we can't find more stricted cases, so use fouded
if (!i_player)
return true;
// skip diff. map cases
if (dataPair.second.mapid != i_player->GetMapId())
return false;
float new_dist = i_player->GetDistance2d(dataPair.second.posX, dataPair.second.posY);
if (!i_mapData || new_dist < i_mapDist)
{
i_mapData = &dataPair;
i_mapDist = new_dist;
}
// skip not spawned (in any state),
uint16 pool_id = sPoolMgr.IsPartOfAPool<Creature>(dataPair.first);
if (pool_id && !sPoolMgr.IsSpawnedObject<Creature>(dataPair.first))
return false;
if (!i_spawnedData || new_dist < i_spawnedDist)
{
i_spawnedData = &dataPair;
i_spawnedDist = new_dist;
}
return false;
}
CreatureDataPair const* FindCreatureData::GetResult() const
{
if (i_spawnedData)
return i_spawnedData;
if (i_mapData)
return i_mapData;
return i_anyData;
}
bool FindGOData::operator()( GameObjectDataPair const& dataPair )
{
// skip wrong entry ids
if (i_id && dataPair.second.id != i_id)
return false;
if (!i_anyData)
i_anyData = &dataPair;
// without player we can't find more stricted cases, so use fouded
if (!i_player)
return true;
// skip diff. map cases
if (dataPair.second.mapid != i_player->GetMapId())
return false;
float new_dist = i_player->GetDistance2d(dataPair.second.posX, dataPair.second.posY);
if (!i_mapData || new_dist < i_mapDist)
{
i_mapData = &dataPair;
i_mapDist = new_dist;
}
// skip not spawned (in any state)
uint16 pool_id = sPoolMgr.IsPartOfAPool<GameObject>(dataPair.first);
if (pool_id && !sPoolMgr.IsSpawnedObject<GameObject>(dataPair.first))
return false;
if (!i_spawnedData || new_dist < i_spawnedDist)
{
i_spawnedData = &dataPair;
i_spawnedDist = new_dist;
}
return false;
}
GameObjectDataPair const* FindGOData::GetResult() const
{
if (i_mapData)
return i_mapData;
if (i_spawnedData)
return i_spawnedData;
return i_anyData;
}