[10107] Pool/event info in .npc info and .gobject target commands

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
schmoozerd 2010-06-26 18:46:21 +04:00 committed by VladimirMangos
parent a504b4d200
commit 4e1c8a2ad6
12 changed files with 152 additions and 47 deletions

View file

@ -33,6 +33,8 @@
#include "CellImpl.h"
#include "AccountMgr.h"
#include "SpellMgr.h"
#include "PoolManager.h"
#include "GameEventMgr.h"
// Supported shift-links (client generated and server side)
// |color|Hachievement:achievement_id:player_guid:0:0:0:0:0:0:0:0|h[name]|h|r
@ -2523,3 +2525,42 @@ int CliHandler::GetSessionDbLocaleIndex() const
{
return sObjectMgr.GetDBCLocaleIndex();
}
// Check/ Output if a NPC or GO (by guid) is part of a pool or game event
template <typename T>
void ChatHandler::ShowNpcOrGoSpawnInformation(uint32 guid)
{
if (uint16 pool_id = sPoolMgr.IsPartOfAPool<T>(guid))
{
uint16 top_pool_id = sPoolMgr.IsPartOfTopPool<Pool>(pool_id);
if (!top_pool_id || top_pool_id == pool_id)
PSendSysMessage(LANG_NPC_GO_INFO_POOL, pool_id);
else
PSendSysMessage(LANG_NPC_GO_INFO_TOP_POOL, pool_id, top_pool_id);
if (int16 event_id = sGameEventMgr.GetGameEventId<Pool>(top_pool_id))
{
GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
GameEventData const& eventData = events[std::abs(event_id)];
if (event_id > 0)
PSendSysMessage(LANG_NPC_GO_INFO_POOL_GAME_EVENT_S, top_pool_id, std::abs(event_id), eventData.description.c_str());
else
PSendSysMessage(LANG_NPC_GO_INFO_POOL_GAME_EVENT_D, top_pool_id, std::abs(event_id), eventData.description.c_str());
}
}
else if (int16 event_id = sGameEventMgr.GetGameEventId<T>(guid))
{
GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
GameEventData const& eventData = events[std::abs(event_id)];
if (event_id > 0)
PSendSysMessage(LANG_NPC_GO_INFO_GAME_EVENT_S, std::abs(event_id), eventData.description.c_str());
else
PSendSysMessage(LANG_NPC_GO_INFO_GAME_EVENT_D, std::abs(event_id), eventData.description.c_str());
}
}
// Instantiate template for helper function
template void ChatHandler::ShowNpcOrGoSpawnInformation<Creature>(uint32 guid);
template void ChatHandler::ShowNpcOrGoSpawnInformation<GameObject>(uint32 guid);

View file

@ -560,7 +560,8 @@ class ChatHandler
void HandleLearnSkillRecipesHelper(Player* player,uint32 skill_id);
void ShowSpellListHelper(Player* target, SpellEntry const* spellInfo, LocaleConstant loc);
bool HandleGoHelper(Player* _player, uint32 mapid, float x, float y, float const* zPtr = NULL, float const* ortPtr = NULL);
template<typename T>
void ShowNpcOrGoSpawnInformation(uint32 guid);
/**
* Stores informations about a deleted character

View file

@ -839,6 +839,39 @@ void GameEventMgr::UpdateWorldStates(uint16 event_id, bool Activate)
}
}
// Get the Game Event ID for Creature by guid
template <>
int16 GameEventMgr::GetGameEventId<Creature>(uint32 guid_or_poolid)
{
for (uint16 i = 0; i < mGameEventCreatureGuids.size(); i++) // 0 <= i <= 2*(S := mGameEvent.size()) - 2
for (GuidList::const_iterator itr = mGameEventCreatureGuids[i].begin(); itr != mGameEventCreatureGuids[i].end(); itr++)
if (*itr == guid_or_poolid)
return i + 1 - mGameEvent.size(); // -S *1 + 1 <= . <= 1*S - 1
return 0;
}
// Get the Game Event ID for GameObject by guid
template <>
int16 GameEventMgr::GetGameEventId<GameObject>(uint32 guid_or_poolid)
{
for (uint16 i = 0; i < mGameEventGameobjectGuids.size(); i++)
for (GuidList::const_iterator itr = mGameEventGameobjectGuids[i].begin(); itr != mGameEventGameobjectGuids[i].end(); itr++)
if (*itr == guid_or_poolid)
return i + 1 - mGameEvent.size(); // -S *1 + 1 <= . <= 1*S - 1
return 0;
}
// Get the Game Event ID for Pool by pool ID
template <>
int16 GameEventMgr::GetGameEventId<Pool>(uint32 guid_or_poolid)
{
for (uint16 i = 0; i < mGameEventSpawnPoolIds.size(); i++)
for (IdList::const_iterator itr = mGameEventSpawnPoolIds[i].begin(); itr != mGameEventSpawnPoolIds[i].end(); itr++)
if (*itr == guid_or_poolid)
return i;
return 0;
}
GameEventMgr::GameEventMgr()
{
m_IsGameEventsInit = false;

View file

@ -67,6 +67,8 @@ class GameEventMgr
uint32 Initialize();
void StartEvent(uint16 event_id, bool overwrite = false);
void StopEvent(uint16 event_id, bool overwrite = false);
template<typename T>
int16 GetGameEventId(uint32 guid_or_poolid);
private:
void AddActiveEvent(uint16 event_id) { m_ActiveEvents.insert(event_id); }
void RemoveActiveEvent(uint16 event_id) { m_ActiveEvents.erase(event_id); }

View file

@ -840,7 +840,13 @@ enum MangosStrings
LANG_CHARACTERS_LIST_LINE_CONSOLE = 1140,
LANG_CHARACTERS_LIST_LINE_CHAT = 1141,
LANG_ACCOUNT_LIST_LINE_CHAT = 1142,
// Room for more level 3 1143-1199 not used
LANG_NPC_GO_INFO_GAME_EVENT_S = 1143,
LANG_NPC_GO_INFO_GAME_EVENT_D = 1144,
LANG_NPC_GO_INFO_POOL = 1145,
LANG_NPC_GO_INFO_TOP_POOL = 1146,
LANG_NPC_GO_INFO_POOL_GAME_EVENT_S = 1147,
LANG_NPC_GO_INFO_POOL_GAME_EVENT_D = 1148,
// Room for more level 3 1149-1199 not used
// Debug commands
LANG_CINEMATIC_NOT_EXIST = 1200,

View file

@ -526,7 +526,7 @@ bool ChatHandler::HandleGameObjectTargetCommand(const char* args)
PSendSysMessage(LANG_GAMEOBJECT_DETAIL, lowguid, goI->name, lowguid, id, x, y, z, mapid, o);
if(target)
if (target)
{
time_t curRespawnDelay = target->GetRespawnTimeEx()-time(NULL);
if(curRespawnDelay < 0)
@ -536,6 +536,8 @@ bool ChatHandler::HandleGameObjectTargetCommand(const char* args)
std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true);
PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str());
ShowNpcOrGoSpawnInformation<GameObject>(target->GetDBTableGUIDLow());
}
return true;
}
@ -858,7 +860,7 @@ bool ChatHandler::HandleGameObjectNearCommand(const char* args)
GameObjectInfo const * gInfo = ObjectMgr::GetGameObjectInfo(entry);
if(!gInfo)
if (!gInfo)
continue;
PSendSysMessage(LANG_GO_MIXED_LIST_CHAT, guid, entry, guid, gInfo->name, x, y, z, mapid);

View file

@ -3809,6 +3809,7 @@ bool ChatHandler::HandleNpcInfoCommand(const char* /*args*/)
SendSysMessage(LANG_NPCINFO_TRAINER);
}
ShowNpcOrGoSpawnInformation<Creature>(target->GetDBTableGUIDLow());
return true;
}