AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
event_commandscript Class Reference
Inheritance diagram for event_commandscript:
CommandScript ScriptObject

Public Member Functions

 event_commandscript ()
 
ChatCommandTable GetCommands () const override
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
uint16 GetTotalAvailableHooks ()
 

Static Public Member Functions

static bool HandleEventActiveListCommand (ChatHandler *handler)
 
static bool HandleEventInfoCommand (ChatHandler *handler, EventEntry const eventId)
 
static bool HandleEventStartCommand (ChatHandler *handler, EventEntry const eventId)
 
static bool HandleEventStopCommand (ChatHandler *handler, EventEntry const eventId)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ event_commandscript()

event_commandscript::event_commandscript ( )
inline
33: CommandScript("event_commandscript") { }
Definition CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable event_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

36 {
37 static ChatCommandTable eventCommandTable =
38 {
43 };
44 static ChatCommandTable commandTable =
45 {
46 { "event", eventCommandTable }
47 };
48 return commandTable;
49 }
static bool HandleEventStopCommand(ChatHandler *handler, EventEntry const eventId)
Definition cs_event.cpp:145
static bool HandleEventInfoCommand(ChatHandler *handler, EventEntry const eventId)
Definition cs_event.cpp:78
static bool HandleEventActiveListCommand(ChatHandler *handler)
Definition cs_event.cpp:51
static bool HandleEventStartCommand(ChatHandler *handler, EventEntry const eventId)
Definition cs_event.cpp:116
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46
@ RBAC_PERM_COMMAND_EVENT_START
Definition RBAC.h:217
@ RBAC_PERM_COMMAND_EVENT_STOP
Definition RBAC.h:218
@ RBAC_PERM_COMMAND_EVENT_ACTIVELIST
Definition RBAC.h:216
@ RBAC_PERM_COMMAND_EVENT_INFO
Definition RBAC.h:215

References HandleEventActiveListCommand(), HandleEventInfoCommand(), HandleEventStartCommand(), HandleEventStopCommand(), rbac::RBAC_PERM_COMMAND_EVENT_ACTIVELIST, rbac::RBAC_PERM_COMMAND_EVENT_INFO, rbac::RBAC_PERM_COMMAND_EVENT_START, and rbac::RBAC_PERM_COMMAND_EVENT_STOP.

◆ HandleEventActiveListCommand()

static bool event_commandscript::HandleEventActiveListCommand ( ChatHandler handler)
inlinestatic
52 {
53 uint32 counter = 0;
54
56 GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
57
58 std::string active = handler->GetAcoreString(LANG_ACTIVE);
59
60 for (uint16 eventId : activeEvents)
61 {
62 GameEventData const& eventData = events[eventId];
63
64 if (handler->GetSession())
65 handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, eventId, eventId, eventData.Description, active);
66 else
67 handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, eventId, eventData.Description, active);
68
69 ++counter;
70 }
71
72 if (counter == 0)
74
75 return true;
76 }
std::uint32_t uint32
Definition Define.h:107
std::uint16_t uint16
Definition Define.h:108
#define sGameEventMgr
Definition GameEventMgr.h:201
@ LANG_EVENT_ENTRY_LIST_CONSOLE
Definition Language.h:904
@ LANG_EVENT_ENTRY_LIST_CHAT
Definition Language.h:652
@ LANG_ACTIVE
Definition Language.h:67
@ LANG_NOEVENTFOUND
Definition Language.h:653
events
Definition boss_sartura.cpp:43
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:219
WorldSession * GetSession()
Definition Chat.h:242
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:168
virtual std::string GetAcoreString(uint32 entry) const
Definition Chat.cpp:42
std::vector< GameEventData > GameEventDataMap
Definition GameEventMgr.h:107
std::set< uint16 > ActiveEvents
Definition GameEventMgr.h:106
Definition GameEventMgr.h:57
std::string Description
Definition GameEventMgr.h:70

References GameEventData::Description, ChatHandler::GetAcoreString(), ChatHandler::GetSession(), LANG_ACTIVE, LANG_EVENT_ENTRY_LIST_CHAT, LANG_EVENT_ENTRY_LIST_CONSOLE, LANG_NOEVENTFOUND, ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), and sGameEventMgr.

Referenced by GetCommands().

◆ HandleEventInfoCommand()

static bool event_commandscript::HandleEventInfoCommand ( ChatHandler handler,
EventEntry const  eventId 
)
inlinestatic
79 {
81
82 if (std::size_t(eventId) >= events.size())
83 {
85 return false;
86 }
87
88 GameEventData const& eventData = events[eventId];
89 if (!eventData.isValid())
90 {
92 return false;
93 }
94
95 GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
96 bool active = activeEvents.find(eventId) != activeEvents.end();
97 std::string activeStr = active ? handler->GetAcoreString(LANG_ACTIVE) : "";
98
99 std::string startTimeStr = Acore::Time::TimeToTimestampStr(Seconds(eventData.Start));
100 std::string endTimeStr = Acore::Time::TimeToTimestampStr(Seconds(eventData.End));
101
102 uint32 delay = sGameEventMgr->NextCheck(eventId);
103 time_t nextTime = GameTime::GetGameTime().count() + delay;
104 std::string nextStr = nextTime >= eventData.Start && nextTime < eventData.End ? Acore::Time::TimeToTimestampStr(Seconds(nextTime)) : "-";
105
106 std::string occurenceStr = secsToTimeString(eventData.Occurence * MINUTE, true);
107 std::string lengthStr = secsToTimeString(eventData.Length * MINUTE, true);
108
109 handler->PSendSysMessage(LANG_EVENT_INFO, uint16(eventId), eventData.Description, activeStr,
110 startTimeStr, endTimeStr, occurenceStr, lengthStr,
111 nextStr);
112
113 return true;
114 }
constexpr auto MINUTE
Definition Common.h:47
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:30
@ LANG_EVENT_INFO
Definition Language.h:655
@ LANG_EVENT_NOT_EXIST
Definition Language.h:654
std::string secsToTimeString(uint64 timeInSecs, bool shortText)
Definition Util.cpp:73
void SendErrorMessage(uint32 entry)
Definition Chat.cpp:224
AC_COMMON_API std::string TimeToTimestampStr(Seconds time=0s, std::string_view fmt={})
Definition Timer.cpp:272
Seconds GetGameTime()
Definition GameTime.cpp:38
time_t Start
Definition GameEventMgr.h:60
time_t End
Definition GameEventMgr.h:61
uint32 Length
Definition GameEventMgr.h:64
bool isValid() const
Definition GameEventMgr.h:73
uint32 Occurence
Definition GameEventMgr.h:63

References GameEventData::Description, GameEventData::End, ChatHandler::GetAcoreString(), GameTime::GetGameTime(), GameEventData::isValid(), LANG_ACTIVE, LANG_EVENT_INFO, LANG_EVENT_NOT_EXIST, GameEventData::Length, MINUTE, GameEventData::Occurence, ChatHandler::PSendSysMessage(), secsToTimeString(), ChatHandler::SendErrorMessage(), sGameEventMgr, GameEventData::Start, and Acore::Time::TimeToTimestampStr().

Referenced by GetCommands().

◆ HandleEventStartCommand()

static bool event_commandscript::HandleEventStartCommand ( ChatHandler handler,
EventEntry const  eventId 
)
inlinestatic
117 {
119
120 if (*eventId < 1 || *eventId >= events.size())
121 {
123 return false;
124 }
125
126 GameEventData const& eventData = events[eventId];
127 if (!eventData.isValid())
128 {
130 return false;
131 }
132
133 GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
134 if (activeEvents.find(eventId) != activeEvents.end())
135 {
136 handler->SendErrorMessage(LANG_EVENT_ALREADY_ACTIVE, uint16(eventId), eventData.Description);
137 return false;
138 }
139
140 handler->PSendSysMessage(LANG_EVENT_STARTED, uint16(eventId), eventData.Description);
141 sGameEventMgr->StartEvent(eventId, true);
142 return true;
143 }
@ LANG_EVENT_STARTED
Definition Language.h:672
@ LANG_EVENT_ALREADY_ACTIVE
Definition Language.h:656

References GameEventData::Description, GameEventData::isValid(), LANG_EVENT_ALREADY_ACTIVE, LANG_EVENT_NOT_EXIST, LANG_EVENT_STARTED, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), and sGameEventMgr.

Referenced by GetCommands().

◆ HandleEventStopCommand()

static bool event_commandscript::HandleEventStopCommand ( ChatHandler handler,
EventEntry const  eventId 
)
inlinestatic
146 {
148
149 if (*eventId < 1 || *eventId >= events.size())
150 {
152 return false;
153 }
154
155 GameEventData const& eventData = events[eventId];
156 if (!eventData.isValid())
157 {
159 return false;
160 }
161
162 GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
163
164 if (activeEvents.find(eventId) == activeEvents.end())
165 {
166 handler->SendErrorMessage(LANG_EVENT_NOT_ACTIVE, uint16(eventId), eventData.Description);
167 return false;
168 }
169
170 handler->PSendSysMessage(LANG_EVENT_STOPPED, uint16(eventId), eventData.Description);
171 sGameEventMgr->StopEvent(eventId, true);
172 return true;
173 }
@ LANG_EVENT_NOT_ACTIVE
Definition Language.h:657
@ LANG_EVENT_STOPPED
Definition Language.h:673

References GameEventData::Description, GameEventData::isValid(), LANG_EVENT_NOT_ACTIVE, LANG_EVENT_NOT_EXIST, LANG_EVENT_STOPPED, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), and sGameEventMgr.

Referenced by GetCommands().


The documentation for this class was generated from the following file: