Scripts/Commands: Add tele and event commands to commandscripts system and streamlining the command selection process to ensure the correct command is run when using abbreviations
Patch by Paradox (some cleanups was needed) --HG-- branch : trunk
This commit is contained in:
@@ -2113,166 +2113,6 @@ bool ChatHandler::HandleLookupEventCommand(const char* args)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleEventActiveListCommand(const char* /*args*/)
|
||||
{
|
||||
uint32 counter = 0;
|
||||
|
||||
GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
|
||||
GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList();
|
||||
|
||||
char const* active = GetTrinityString(LANG_ACTIVE);
|
||||
|
||||
for (GameEventMgr::ActiveEvents::const_iterator itr = activeEvents.begin(); itr != activeEvents.end(); ++itr)
|
||||
{
|
||||
uint32 event_id = *itr;
|
||||
GameEventData const& eventData = events[event_id];
|
||||
|
||||
if (m_session)
|
||||
PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT,event_id,event_id,eventData.description.c_str(),active);
|
||||
else
|
||||
PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE,event_id,eventData.description.c_str(),active);
|
||||
|
||||
++counter;
|
||||
}
|
||||
|
||||
if (counter == 0)
|
||||
SendSysMessage(LANG_NOEVENTFOUND);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleEventInfoCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
// id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
|
||||
char* cId = extractKeyFromLink((char*)args,"Hgameevent");
|
||||
if (!cId)
|
||||
return false;
|
||||
|
||||
uint32 event_id = atoi(cId);
|
||||
|
||||
GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
|
||||
|
||||
if (event_id >=events.size())
|
||||
{
|
||||
SendSysMessage(LANG_EVENT_NOT_EXIST);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
GameEventData const& eventData = events[event_id];
|
||||
if (!eventData.isValid())
|
||||
{
|
||||
SendSysMessage(LANG_EVENT_NOT_EXIST);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList();
|
||||
bool active = activeEvents.find(event_id) != activeEvents.end();
|
||||
char const* activeStr = active ? GetTrinityString(LANG_ACTIVE) : "";
|
||||
|
||||
std::string startTimeStr = TimeToTimestampStr(eventData.start);
|
||||
std::string endTimeStr = TimeToTimestampStr(eventData.end);
|
||||
|
||||
uint32 delay = sGameEventMgr.NextCheck(event_id);
|
||||
time_t nextTime = time(NULL)+delay;
|
||||
std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(time(NULL)+delay) : "-";
|
||||
|
||||
std::string occurenceStr = secsToTimeString(eventData.occurence * MINUTE);
|
||||
std::string lengthStr = secsToTimeString(eventData.length * MINUTE);
|
||||
|
||||
PSendSysMessage(LANG_EVENT_INFO,event_id,eventData.description.c_str(),activeStr,
|
||||
startTimeStr.c_str(),endTimeStr.c_str(),occurenceStr.c_str(),lengthStr.c_str(),
|
||||
nextStr.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleEventStartCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
// id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
|
||||
char* cId = extractKeyFromLink((char*)args,"Hgameevent");
|
||||
if (!cId)
|
||||
return false;
|
||||
|
||||
int32 event_id = atoi(cId);
|
||||
|
||||
GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
|
||||
|
||||
if (event_id < 1 || uint32(event_id) >= events.size())
|
||||
{
|
||||
SendSysMessage(LANG_EVENT_NOT_EXIST);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
GameEventData const& eventData = events[event_id];
|
||||
if (!eventData.isValid())
|
||||
{
|
||||
SendSysMessage(LANG_EVENT_NOT_EXIST);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList();
|
||||
if (activeEvents.find(event_id) != activeEvents.end())
|
||||
{
|
||||
PSendSysMessage(LANG_EVENT_ALREADY_ACTIVE,event_id);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
sGameEventMgr.StartEvent(event_id,true);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleEventStopCommand(const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
// id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
|
||||
char* cId = extractKeyFromLink((char*)args,"Hgameevent");
|
||||
if (!cId)
|
||||
return false;
|
||||
|
||||
int32 event_id = atoi(cId);
|
||||
|
||||
GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
|
||||
|
||||
if (event_id < 1 || uint32(event_id) >= events.size())
|
||||
{
|
||||
SendSysMessage(LANG_EVENT_NOT_EXIST);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
GameEventData const& eventData = events[event_id];
|
||||
if (!eventData.isValid())
|
||||
{
|
||||
SendSysMessage(LANG_EVENT_NOT_EXIST);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList();
|
||||
|
||||
if (activeEvents.find(event_id) == activeEvents.end())
|
||||
{
|
||||
PSendSysMessage(LANG_EVENT_NOT_ACTIVE,event_id);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
sGameEventMgr.StopEvent(event_id,true);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleCombatStopCommand(const char* args)
|
||||
{
|
||||
Player* target;
|
||||
|
||||
Reference in New Issue
Block a user