diff --git a/src/server/scripts/Commands/cs_event.cpp b/src/server/scripts/Commands/cs_event.cpp
index 9ae157781..f04449567 100644
--- a/src/server/scripts/Commands/cs_event.cpp
+++ b/src/server/scripts/Commands/cs_event.cpp
@@ -15,25 +15,23 @@
* with this program. If not, see .
*/
-/* ScriptData
-Name: event_commandscript
-%Complete: 100
-Comment: All event related commands
-Category: commandscripts
-EndScriptData */
+ /* ScriptData
+ Name: event_commandscript
+ %Complete: 100
+ Comment: All event related commands
+ Category: commandscripts
+ EndScriptData */
+#include "ScriptMgr.h"
#include "Chat.h"
#include "GameEventMgr.h"
#include "Language.h"
#include "Player.h"
-#include "ScriptMgr.h"
-
-#if AC_COMPILER == AC_COMPILER_GNU
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
using namespace Acore::ChatCommands;
+using EventEntry = Variant, uint16>;
+
class event_commandscript : public CommandScript
{
public:
@@ -43,19 +41,19 @@ public:
{
static ChatCommandTable eventCommandTable =
{
- { "activelist", SEC_GAMEMASTER, true, &HandleEventActiveListCommand, "" },
- { "start", SEC_GAMEMASTER, true, &HandleEventStartCommand, "" },
- { "stop", SEC_GAMEMASTER, true, &HandleEventStopCommand, "" },
- { "", SEC_GAMEMASTER, true, &HandleEventInfoCommand, "" }
+ { "activelist", HandleEventActiveListCommand, SEC_GAMEMASTER, Console::Yes },
+ { "start", HandleEventStartCommand, SEC_GAMEMASTER, Console::Yes },
+ { "stop", HandleEventStopCommand, SEC_GAMEMASTER, Console::Yes },
+ { "info", HandleEventInfoCommand, SEC_GAMEMASTER, Console::Yes }
};
static ChatCommandTable commandTable =
{
- { "event", SEC_GAMEMASTER, false, nullptr, "", eventCommandTable }
+ { "event", eventCommandTable }
};
return commandTable;
}
- static bool HandleEventActiveListCommand(ChatHandler* handler, char const* /*args*/)
+ static bool HandleEventActiveListCommand(ChatHandler* handler)
{
uint32 counter = 0;
@@ -64,41 +62,37 @@ public:
char const* active = handler->GetAcoreString(LANG_ACTIVE);
- for (GameEventMgr::ActiveEvents::const_iterator itr = activeEvents.begin(); itr != activeEvents.end(); ++itr)
+ for (uint16 eventId : activeEvents)
{
- uint32 eventId = *itr;
GameEventData const& eventData = events[eventId];
if (handler->GetSession())
+ {
handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, eventId, eventId, eventData.description.c_str(), active);
+ }
else
+ {
handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, eventId, eventData.description.c_str(), active);
+ }
++counter;
}
if (counter == 0)
+ {
handler->SendSysMessage(LANG_NOEVENTFOUND);
+ }
+
handler->SetSentErrorMessage(true);
return true;
}
- static bool HandleEventInfoCommand(ChatHandler* handler, char const* args)
+ static bool HandleEventInfoCommand(ChatHandler* handler, EventEntry const eventId)
{
- if (!*args)
- return false;
-
- // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
- char* id = handler->extractKeyFromLink((char*)args, "Hgameevent");
- if (!id)
- return false;
-
- uint32 eventId = atoi(id);
-
GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
- if (eventId >= events.size())
+ if (std::size_t(eventId) >= events.size())
{
handler->SendSysMessage(LANG_EVENT_NOT_EXIST);
handler->SetSentErrorMessage(true);
@@ -127,27 +121,18 @@ public:
std::string occurenceStr = secsToTimeString(eventData.occurence * MINUTE, true);
std::string lengthStr = secsToTimeString(eventData.length * MINUTE, true);
- handler->PSendSysMessage(LANG_EVENT_INFO, eventId, eventData.description.c_str(), activeStr,
- startTimeStr.c_str(), endTimeStr.c_str(), occurenceStr.c_str(), lengthStr.c_str(),
- nextStr.c_str());
+ handler->PSendSysMessage(LANG_EVENT_INFO, uint16(eventId), eventData.description.c_str(), activeStr,
+ startTimeStr.c_str(), endTimeStr.c_str(), occurenceStr.c_str(), lengthStr.c_str(),
+ nextStr.c_str());
+
return true;
}
- static bool HandleEventStartCommand(ChatHandler* handler, char const* args)
+ static bool HandleEventStartCommand(ChatHandler* handler, EventEntry const eventId)
{
- if (!*args)
- return false;
-
- // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
- char* id = handler->extractKeyFromLink((char*)args, "Hgameevent");
- if (!id)
- return false;
-
- int32 eventId = atoi(id);
-
GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
- if (eventId < 1 || uint32(eventId) >= events.size())
+ if (*eventId < 1 || *eventId >= events.size())
{
handler->SendSysMessage(LANG_EVENT_NOT_EXIST);
handler->SetSentErrorMessage(true);
@@ -165,7 +150,7 @@ public:
GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
if (activeEvents.find(eventId) != activeEvents.end())
{
- handler->PSendSysMessage(LANG_EVENT_ALREADY_ACTIVE, eventId);
+ handler->PSendSysMessage(LANG_EVENT_ALREADY_ACTIVE, uint16(eventId));
handler->SetSentErrorMessage(true);
return false;
}
@@ -174,21 +159,11 @@ public:
return true;
}
- static bool HandleEventStopCommand(ChatHandler* handler, char const* args)
+ static bool HandleEventStopCommand(ChatHandler* handler, EventEntry const eventId)
{
- if (!*args)
- return false;
-
- // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
- char* id = handler->extractKeyFromLink((char*)args, "Hgameevent");
- if (!id)
- return false;
-
- int32 eventId = atoi(id);
-
GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
- if (eventId < 1 || uint32(eventId) >= events.size())
+ if (*eventId < 1 || *eventId >= events.size())
{
handler->SendSysMessage(LANG_EVENT_NOT_EXIST);
handler->SetSentErrorMessage(true);
@@ -207,7 +182,7 @@ public:
if (activeEvents.find(eventId) == activeEvents.end())
{
- handler->PSendSysMessage(LANG_EVENT_NOT_ACTIVE, eventId);
+ handler->PSendSysMessage(LANG_EVENT_NOT_ACTIVE, uint16(eventId));
handler->SetSentErrorMessage(true);
return false;
}