TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
event_commandscript Class Reference

Public Member Functions

 event_commandscript ()
 
std::vector< ChatCommandGetCommands () const override
 
- Public Member Functions inherited from ScriptObject
const std::string & GetName () const
 

Static Public Member Functions

static bool HandleEventActiveListCommand (ChatHandler *handler, char const *)
 
static bool HandleEventInfoCommand (ChatHandler *handler, char const *args)
 
static bool HandleEventStartCommand (ChatHandler *handler, char const *args)
 
static bool HandleEventStopCommand (ChatHandler *handler, char const *args)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()
 

Constructor & Destructor Documentation

event_commandscript::event_commandscript ( )
inline
34 : CommandScript("event_commandscript") { }
CommandScript(const char *name)
Definition: ScriptMgr.cpp:1616

Member Function Documentation

std::vector<ChatCommand> event_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

37  {
38  static std::vector<ChatCommand> eventCommandTable =
39  {
44  };
45  static std::vector<ChatCommand> commandTable =
46  {
47  { "event", rbac::RBAC_PERM_COMMAND_EVENT, false, NULL, "", eventCommandTable },
48  };
49  return commandTable;
50  }
arena_t NULL
Definition: jemalloc_internal.h:624
static bool HandleEventStartCommand(ChatHandler *handler, char const *args)
Definition: cs_event.cpp:130
static bool HandleEventInfoCommand(ChatHandler *handler, char const *args)
Definition: cs_event.cpp:81
Definition: RBAC.h:274
static bool HandleEventStopCommand(ChatHandler *handler, char const *args)
Definition: cs_event.cpp:171
static bool HandleEventActiveListCommand(ChatHandler *handler, char const *)
Definition: cs_event.cpp:52

+ Here is the call graph for this function:

static bool event_commandscript::HandleEventActiveListCommand ( ChatHandler handler,
char const  
)
inlinestatic
53  {
54  uint32 counter = 0;
55 
56  GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
57  GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
58 
59  char const* active = handler->GetTrinityString(LANG_ACTIVE);
60 
61  for (GameEventMgr::ActiveEvents::const_iterator itr = activeEvents.begin(); itr != activeEvents.end(); ++itr)
62  {
63  uint32 eventId = *itr;
64  GameEventData const& eventData = events[eventId];
65 
66  if (handler->GetSession())
67  handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, eventId, eventId, eventData.description.c_str(), active);
68  else
69  handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, eventId, eventData.description.c_str(), active);
70 
71  ++counter;
72  }
73 
74  if (counter == 0)
76  handler->SetSentErrorMessage(true);
77 
78  return true;
79  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: Language.h:610
uint32_t uint32
Definition: Define.h:150
Definition: Language.h:611
Definition: Language.h:906
#define sGameEventMgr
Definition: GameEventMgr.h:184
std::set< uint16 > ActiveEvents
Definition: GameEventMgr.h:106
Definition: Language.h:68
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:67
std::vector< GameEventData > GameEventDataMap
Definition: GameEventMgr.h:107
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: GameEventMgr.h:56
std::string description
Definition: GameEventMgr.h:69

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool event_commandscript::HandleEventInfoCommand ( ChatHandler handler,
char const args 
)
inlinestatic
82  {
83  if (!*args)
84  return false;
85 
86  // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
87  char* id = handler->extractKeyFromLink((char*)args, "Hgameevent");
88  if (!id)
89  return false;
90 
91  uint32 eventId = atoi(id);
92 
93  GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
94 
95  if (eventId >= events.size())
96  {
98  handler->SetSentErrorMessage(true);
99  return false;
100  }
101 
102  GameEventData const& eventData = events[eventId];
103  if (!eventData.isValid())
104  {
106  handler->SetSentErrorMessage(true);
107  return false;
108  }
109 
110  GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
111  bool active = activeEvents.find(eventId) != activeEvents.end();
112  char const* activeStr = active ? handler->GetTrinityString(LANG_ACTIVE) : "";
113 
114  std::string startTimeStr = TimeToTimestampStr(eventData.start);
115  std::string endTimeStr = TimeToTimestampStr(eventData.end);
116 
117  uint32 delay = sGameEventMgr->NextCheck(eventId);
118  time_t nextTime = time(NULL) + delay;
119  std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(time(NULL) + delay) : "-";
120 
121  std::string occurenceStr = secsToTimeString(eventData.occurence * MINUTE);
122  std::string lengthStr = secsToTimeString(eventData.length * MINUTE);
123 
124  handler->PSendSysMessage(LANG_EVENT_INFO, eventId, eventData.description.c_str(), activeStr,
125  startTimeStr.c_str(), endTimeStr.c_str(), occurenceStr.c_str(), lengthStr.c_str(),
126  nextStr.c_str());
127  return true;
128  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
std::string secsToTimeString(uint64 timeInSecs, bool shortText, bool hoursOnly)
Definition: Util.cpp:109
Definition: Language.h:612
arena_t NULL
Definition: jemalloc_internal.h:624
time_t end
Definition: GameEventMgr.h:61
uint32 length
Definition: GameEventMgr.h:64
Definition: Common.h:97
Definition: Language.h:613
uint32_t uint32
Definition: Define.h:150
std::string TimeToTimestampStr(time_t t)
Definition: Util.cpp:195
uint32 occurence
Definition: GameEventMgr.h:63
#define sGameEventMgr
Definition: GameEventMgr.h:184
std::set< uint16 > ActiveEvents
Definition: GameEventMgr.h:106
Definition: Language.h:68
virtual char const * GetTrinityString(uint32 entry) const
Definition: Chat.cpp:67
std::vector< GameEventData > GameEventDataMap
Definition: GameEventMgr.h:107
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: GameEventMgr.h:56
char * extractKeyFromLink(char *text, char const *linkType, char **something1=NULL)
Definition: Chat.cpp:641
std::string description
Definition: GameEventMgr.h:69
bool isValid() const
Definition: GameEventMgr.h:72
time_t start
Definition: GameEventMgr.h:60

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool event_commandscript::HandleEventStartCommand ( ChatHandler handler,
char const args 
)
inlinestatic
131  {
132  if (!*args)
133  return false;
134 
135  // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
136  char* id = handler->extractKeyFromLink((char*)args, "Hgameevent");
137  if (!id)
138  return false;
139 
140  int32 eventId = atoi(id);
141 
142  GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
143 
144  if (eventId < 1 || uint32(eventId) >= events.size())
145  {
147  handler->SetSentErrorMessage(true);
148  return false;
149  }
150 
151  GameEventData const& eventData = events[eventId];
152  if (!eventData.isValid())
153  {
155  handler->SetSentErrorMessage(true);
156  return false;
157  }
158 
159  GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
160  if (activeEvents.find(eventId) != activeEvents.end())
161  {
162  handler->PSendSysMessage(LANG_EVENT_ALREADY_ACTIVE, eventId);
163  handler->SetSentErrorMessage(true);
164  return false;
165  }
166 
167  sGameEventMgr->StartEvent(eventId, true);
168  return true;
169  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: Language.h:612
int32_t int32
Definition: Define.h:146
Definition: Language.h:614
#define sGameEventMgr
Definition: GameEventMgr.h:184
std::set< uint16 > ActiveEvents
Definition: GameEventMgr.h:106
std::vector< GameEventData > GameEventDataMap
Definition: GameEventMgr.h:107
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
uint32_t uint32
Definition: g3dmath.h:168
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: GameEventMgr.h:56
char * extractKeyFromLink(char *text, char const *linkType, char **something1=NULL)
Definition: Chat.cpp:641
bool isValid() const
Definition: GameEventMgr.h:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool event_commandscript::HandleEventStopCommand ( ChatHandler handler,
char const args 
)
inlinestatic
172  {
173  if (!*args)
174  return false;
175 
176  // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
177  char* id = handler->extractKeyFromLink((char*)args, "Hgameevent");
178  if (!id)
179  return false;
180 
181  int32 eventId = atoi(id);
182 
183  GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
184 
185  if (eventId < 1 || uint32(eventId) >= events.size())
186  {
188  handler->SetSentErrorMessage(true);
189  return false;
190  }
191 
192  GameEventData const& eventData = events[eventId];
193  if (!eventData.isValid())
194  {
196  handler->SetSentErrorMessage(true);
197  return false;
198  }
199 
200  GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
201 
202  if (activeEvents.find(eventId) == activeEvents.end())
203  {
204  handler->PSendSysMessage(LANG_EVENT_NOT_ACTIVE, eventId);
205  handler->SetSentErrorMessage(true);
206  return false;
207  }
208 
209  sGameEventMgr->StopEvent(eventId, true);
210  return true;
211  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Definition: Language.h:612
Definition: Language.h:615
int32_t int32
Definition: Define.h:146
#define sGameEventMgr
Definition: GameEventMgr.h:184
std::set< uint16 > ActiveEvents
Definition: GameEventMgr.h:106
std::vector< GameEventData > GameEventDataMap
Definition: GameEventMgr.h:107
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
uint32_t uint32
Definition: g3dmath.h:168
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
Definition: GameEventMgr.h:56
char * extractKeyFromLink(char *text, char const *linkType, char **something1=NULL)
Definition: Chat.cpp:641
bool isValid() const
Definition: GameEventMgr.h:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


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