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

Public Member Functions

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

Static Public Member Functions

static bool HandleAddDisables (ChatHandler *handler, char const *args, uint8 disableType)
 
static bool HandleAddDisableSpellCommand (ChatHandler *handler, char const *args)
 
static bool HandleAddDisableQuestCommand (ChatHandler *handler, char const *args)
 
static bool HandleAddDisableMapCommand (ChatHandler *handler, char const *args)
 
static bool HandleAddDisableBattlegroundCommand (ChatHandler *handler, char const *args)
 
static bool HandleAddDisableAchievementCriteriaCommand (ChatHandler *handler, char const *args)
 
static bool HandleAddDisableOutdoorPvPCommand (ChatHandler *handler, char const *args)
 
static bool HandleAddDisableVmapCommand (ChatHandler *handler, char const *args)
 
static bool HandleAddDisableMMapCommand (ChatHandler *handler, char const *args)
 
static bool HandleRemoveDisables (ChatHandler *handler, char const *args, uint8 disableType)
 
static bool HandleRemoveDisableSpellCommand (ChatHandler *handler, char const *args)
 
static bool HandleRemoveDisableQuestCommand (ChatHandler *handler, char const *args)
 
static bool HandleRemoveDisableMapCommand (ChatHandler *handler, char const *args)
 
static bool HandleRemoveDisableBattlegroundCommand (ChatHandler *handler, char const *args)
 
static bool HandleRemoveDisableAchievementCriteriaCommand (ChatHandler *handler, char const *args)
 
static bool HandleRemoveDisableOutdoorPvPCommand (ChatHandler *handler, char const *args)
 
static bool HandleRemoveDisableVmapCommand (ChatHandler *handler, char const *args)
 
static bool HandleRemoveDisableMMapCommand (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

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

Member Function Documentation

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

Implements CommandScript.

41  {
42  static std::vector<ChatCommand> removeDisableCommandTable =
43  {
52  };
53  static std::vector<ChatCommand> addDisableCommandTable =
54  {
63  };
64  static std::vector<ChatCommand> disableCommandTable =
65  {
66  { "add", rbac::RBAC_PERM_COMMAND_DISABLE_ADD, true, NULL, "", addDisableCommandTable },
67  { "remove", rbac::RBAC_PERM_COMMAND_DISABLE_REMOVE, true, NULL, "", removeDisableCommandTable },
68  };
69  static std::vector<ChatCommand> commandTable =
70  {
71  { "disable", rbac::RBAC_PERM_COMMAND_DISABLE, false, NULL, "", disableCommandTable },
72  };
73  return commandTable;
74  }
static bool HandleAddDisableQuestCommand(ChatHandler *handler, char const *args)
Definition: cs_disable.cpp:219
static bool HandleRemoveDisableOutdoorPvPCommand(ChatHandler *handler, char const *args)
Definition: cs_disable.cpp:375
static bool HandleAddDisableMapCommand(ChatHandler *handler, char const *args)
Definition: cs_disable.cpp:227
static bool HandleAddDisableMMapCommand(ChatHandler *handler, char const *args)
Definition: cs_disable.cpp:268
arena_t NULL
Definition: jemalloc_internal.h:624
static bool HandleRemoveDisableVmapCommand(ChatHandler *handler, char const *args)
Definition: cs_disable.cpp:383
static bool HandleRemoveDisableAchievementCriteriaCommand(ChatHandler *handler, char const *args)
Definition: cs_disable.cpp:367
static bool HandleRemoveDisableMapCommand(ChatHandler *handler, char const *args)
Definition: cs_disable.cpp:351
Definition: RBAC.h:255
static bool HandleRemoveDisableQuestCommand(ChatHandler *handler, char const *args)
Definition: cs_disable.cpp:343
static bool HandleAddDisableVmapCommand(ChatHandler *handler, char const *args)
Definition: cs_disable.cpp:260
static bool HandleAddDisableBattlegroundCommand(ChatHandler *handler, char const *args)
Definition: cs_disable.cpp:235
static bool HandleAddDisableAchievementCriteriaCommand(ChatHandler *handler, char const *args)
Definition: cs_disable.cpp:243
static bool HandleAddDisableSpellCommand(ChatHandler *handler, char const *args)
Definition: cs_disable.cpp:211
static bool HandleAddDisableOutdoorPvPCommand(ChatHandler *handler, char const *args)
Definition: cs_disable.cpp:251
static bool HandleRemoveDisableMMapCommand(ChatHandler *handler, char const *args)
Definition: cs_disable.cpp:391
static bool HandleRemoveDisableBattlegroundCommand(ChatHandler *handler, char const *args)
Definition: cs_disable.cpp:359
static bool HandleRemoveDisableSpellCommand(ChatHandler *handler, char const *args)
Definition: cs_disable.cpp:335

+ Here is the call graph for this function:

static bool disable_commandscript::HandleAddDisableAchievementCriteriaCommand ( ChatHandler handler,
char const args 
)
inlinestatic
244  {
245  if (!*args)
246  return false;
247 
249  }
static bool HandleAddDisables(ChatHandler *handler, char const *args, uint8 disableType)
Definition: cs_disable.cpp:76
Definition: DisableMgr.h:33

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool disable_commandscript::HandleAddDisableBattlegroundCommand ( ChatHandler handler,
char const args 
)
inlinestatic
236  {
237  if (!*args)
238  return false;
239 
240  return HandleAddDisables(handler, args, DISABLE_TYPE_BATTLEGROUND);
241  }
static bool HandleAddDisables(ChatHandler *handler, char const *args, uint8 disableType)
Definition: cs_disable.cpp:76
Definition: DisableMgr.h:32

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool disable_commandscript::HandleAddDisableMapCommand ( ChatHandler handler,
char const args 
)
inlinestatic
228  {
229  if (!*args)
230  return false;
231 
232  return HandleAddDisables(handler, args, DISABLE_TYPE_MAP);
233  }
static bool HandleAddDisables(ChatHandler *handler, char const *args, uint8 disableType)
Definition: cs_disable.cpp:76
Definition: DisableMgr.h:31

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool disable_commandscript::HandleAddDisableMMapCommand ( ChatHandler handler,
char const args 
)
inlinestatic
269  {
270  if (!*args)
271  return false;
272 
273  return HandleAddDisables(handler, args, DISABLE_TYPE_MMAP);
274  }
static bool HandleAddDisables(ChatHandler *handler, char const *args, uint8 disableType)
Definition: cs_disable.cpp:76
Definition: DisableMgr.h:36

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool disable_commandscript::HandleAddDisableOutdoorPvPCommand ( ChatHandler handler,
char const args 
)
inlinestatic
252  {
253  if (!*args)
254  return false;
255 
257  return true;
258  }
static bool HandleAddDisables(ChatHandler *handler, char const *args, uint8 disableType)
Definition: cs_disable.cpp:76
Definition: DisableMgr.h:34

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool disable_commandscript::HandleAddDisableQuestCommand ( ChatHandler handler,
char const args 
)
inlinestatic
220  {
221  if (!*args)
222  return false;
223 
224  return HandleAddDisables(handler, args, DISABLE_TYPE_QUEST);
225  }
static bool HandleAddDisables(ChatHandler *handler, char const *args, uint8 disableType)
Definition: cs_disable.cpp:76
Definition: DisableMgr.h:30

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool disable_commandscript::HandleAddDisables ( ChatHandler handler,
char const args,
uint8  disableType 
)
inlinestatic
77  {
78  char* entryStr = strtok((char*)args, " ");
79  if (!entryStr || !atoi(entryStr))
80  return false;
81 
82  char* flagsStr = strtok(NULL, " ");
83  uint8 flags = flagsStr ? uint8(atoi(flagsStr)) : 0;
84 
85  char* commentStr = strtok(NULL, "");
86  if (!commentStr)
87  return false;
88 
89  std::string disableComment = commentStr;
90  uint32 entry = uint32(atoi(entryStr));
91 
92  std::string disableTypeStr = "";
93 
94  switch (disableType)
95  {
96  case DISABLE_TYPE_SPELL:
97  {
98  if (!sSpellMgr->GetSpellInfo(entry))
99  {
101  handler->SetSentErrorMessage(true);
102  return false;
103  }
104  disableTypeStr = "spell";
105  break;
106  }
107  case DISABLE_TYPE_QUEST:
108  {
109  if (!sObjectMgr->GetQuestTemplate(entry))
110  {
112  handler->SetSentErrorMessage(true);
113  return false;
114  }
115  disableTypeStr = "quest";
116  break;
117  }
118  case DISABLE_TYPE_MAP:
119  {
120  if (!sMapStore.LookupEntry(entry))
121  {
123  handler->SetSentErrorMessage(true);
124  return false;
125  }
126  disableTypeStr = "map";
127  break;
128  }
130  {
131  if (!sBattlemasterListStore.LookupEntry(entry))
132  {
134  handler->SetSentErrorMessage(true);
135  return false;
136  }
137  disableTypeStr = "battleground";
138  break;
139  }
141  {
142  if (!sAchievementMgr->GetAchievementCriteria(entry))
143  {
145  handler->SetSentErrorMessage(true);
146  return false;
147  }
148  disableTypeStr = "achievement criteria";
149  break;
150  }
152  {
153  if (entry > MAX_OUTDOORPVP_TYPES)
154  {
156  handler->SetSentErrorMessage(true);
157  return false;
158  }
159  disableTypeStr = "outdoorpvp";
160  break;
161  }
162  case DISABLE_TYPE_VMAP:
163  {
164  if (!sMapStore.LookupEntry(entry))
165  {
167  handler->SetSentErrorMessage(true);
168  return false;
169  }
170  disableTypeStr = "vmap";
171  break;
172  }
173  case DISABLE_TYPE_MMAP:
174  {
175  if (!sMapStore.LookupEntry(entry))
176  {
178  handler->SetSentErrorMessage(true);
179  return false;
180  }
181  disableTypeStr = "mmap";
182  break;
183  }
184  default:
185  break;
186  }
187 
188  PreparedStatement* stmt = NULL;
190  stmt->setUInt32(0, entry);
191  stmt->setUInt8(1, disableType);
192  PreparedQueryResult result = WorldDatabase.Query(stmt);
193  if (result)
194  {
195  handler->PSendSysMessage("This %s (Id: %u) is already disabled.", disableTypeStr.c_str(), entry);
196  handler->SetSentErrorMessage(true);
197  return false;
198  }
199 
201  stmt->setUInt32(0, entry);
202  stmt->setUInt8(1, disableType);
203  stmt->setUInt16(2, flags);
204  stmt->setString(3, disableComment);
205  WorldDatabase.Execute(stmt);
206 
207  handler->PSendSysMessage("Add Disabled %s (Id: %u) for reason %s", disableTypeStr.c_str(), entry, disableComment.c_str());
208  return true;
209  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
Definition: WorldDatabase.h:97
DBCStorage< BattlemasterListEntry > sBattlemasterListStore(BattlemasterListfmt)
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
Definition: WorldDatabase.h:96
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
arena_t NULL
Definition: jemalloc_internal.h:624
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Definition: Language.h:1098
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PreparedStatement.h:74
Definition: Language.h:1078
Definition: Language.h:447
Definition: DisableMgr.h:36
#define MAX_OUTDOORPVP_TYPES
Definition: OutdoorPvP.h:37
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: DisableMgr.h:32
uint32_t uint32
Definition: Define.h:150
Definition: DisableMgr.h:35
Definition: DisableMgr.h:29
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
Definition: DisableMgr.h:30
uint8_t uint8
Definition: g3dmath.h:164
Definition: DisableMgr.h:33
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Definition: Language.h:474
DBCStorage< MapEntry > sMapStore(Mapfmt)
Definition: DisableMgr.h:31
uint8_t uint8
Definition: Define.h:152
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: DisableMgr.h:34
uint32_t uint32
Definition: g3dmath.h:168
uint8 flags
Definition: DisableMgr.cpp:44
Definition: Language.h:1100
#define sAchievementMgr
Definition: AchievementMgr.h:501

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool disable_commandscript::HandleAddDisableSpellCommand ( ChatHandler handler,
char const args 
)
inlinestatic
212  {
213  if (!*args)
214  return false;
215 
216  return HandleAddDisables(handler, args, DISABLE_TYPE_SPELL);
217  }
static bool HandleAddDisables(ChatHandler *handler, char const *args, uint8 disableType)
Definition: cs_disable.cpp:76
Definition: DisableMgr.h:29

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool disable_commandscript::HandleAddDisableVmapCommand ( ChatHandler handler,
char const args 
)
inlinestatic
261  {
262  if (!*args)
263  return false;
264 
265  return HandleAddDisables(handler, args, DISABLE_TYPE_VMAP);
266  }
static bool HandleAddDisables(ChatHandler *handler, char const *args, uint8 disableType)
Definition: cs_disable.cpp:76
Definition: DisableMgr.h:35

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool disable_commandscript::HandleRemoveDisableAchievementCriteriaCommand ( ChatHandler handler,
char const args 
)
inlinestatic
368  {
369  if (!*args)
370  return false;
371 
373  }
static bool HandleRemoveDisables(ChatHandler *handler, char const *args, uint8 disableType)
Definition: cs_disable.cpp:276
Definition: DisableMgr.h:33

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool disable_commandscript::HandleRemoveDisableBattlegroundCommand ( ChatHandler handler,
char const args 
)
inlinestatic
360  {
361  if (!*args)
362  return false;
363 
364  return HandleRemoveDisables(handler, args, DISABLE_TYPE_BATTLEGROUND);
365  }
Definition: DisableMgr.h:32
static bool HandleRemoveDisables(ChatHandler *handler, char const *args, uint8 disableType)
Definition: cs_disable.cpp:276

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool disable_commandscript::HandleRemoveDisableMapCommand ( ChatHandler handler,
char const args 
)
inlinestatic
352  {
353  if (!*args)
354  return false;
355 
356  return HandleRemoveDisables(handler, args, DISABLE_TYPE_MAP);
357  }
static bool HandleRemoveDisables(ChatHandler *handler, char const *args, uint8 disableType)
Definition: cs_disable.cpp:276
Definition: DisableMgr.h:31

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool disable_commandscript::HandleRemoveDisableMMapCommand ( ChatHandler handler,
char const args 
)
inlinestatic
392  {
393  if (!*args)
394  return false;
395 
396  return HandleRemoveDisables(handler, args, DISABLE_TYPE_MMAP);
397  }
Definition: DisableMgr.h:36
static bool HandleRemoveDisables(ChatHandler *handler, char const *args, uint8 disableType)
Definition: cs_disable.cpp:276

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool disable_commandscript::HandleRemoveDisableOutdoorPvPCommand ( ChatHandler handler,
char const args 
)
inlinestatic
376  {
377  if (!*args)
378  return false;
379 
380  return HandleRemoveDisables(handler, args, DISABLE_TYPE_OUTDOORPVP);
381  }
static bool HandleRemoveDisables(ChatHandler *handler, char const *args, uint8 disableType)
Definition: cs_disable.cpp:276
Definition: DisableMgr.h:34

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool disable_commandscript::HandleRemoveDisableQuestCommand ( ChatHandler handler,
char const args 
)
inlinestatic
344  {
345  if (!*args)
346  return false;
347 
348  return HandleRemoveDisables(handler, args, DISABLE_TYPE_QUEST);
349  }
Definition: DisableMgr.h:30
static bool HandleRemoveDisables(ChatHandler *handler, char const *args, uint8 disableType)
Definition: cs_disable.cpp:276

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool disable_commandscript::HandleRemoveDisables ( ChatHandler handler,
char const args,
uint8  disableType 
)
inlinestatic
277  {
278  char* entryStr = strtok((char*)args, " ");
279  if (!entryStr || !atoi(entryStr))
280  return false;
281 
282  uint32 entry = uint32(atoi(entryStr));
283 
284  std::string disableTypeStr = "";
285 
286  switch (disableType)
287  {
288  case DISABLE_TYPE_SPELL:
289  disableTypeStr = "spell";
290  break;
291  case DISABLE_TYPE_QUEST:
292  disableTypeStr = "quest";
293  break;
294  case DISABLE_TYPE_MAP:
295  disableTypeStr = "map";
296  break;
298  disableTypeStr = "battleground";
299  break;
301  disableTypeStr = "achievement criteria";
302  break;
304  disableTypeStr = "outdoorpvp";
305  break;
306  case DISABLE_TYPE_VMAP:
307  disableTypeStr = "vmap";
308  break;
309  case DISABLE_TYPE_MMAP:
310  disableTypeStr = "mmap";
311  break;
312  }
313 
314  PreparedStatement* stmt = NULL;
316  stmt->setUInt32(0, entry);
317  stmt->setUInt8(1, disableType);
318  PreparedQueryResult result = WorldDatabase.Query(stmt);
319  if (!result)
320  {
321  handler->PSendSysMessage("This %s (Id: %u) is not disabled.", disableTypeStr.c_str(), entry);
322  handler->SetSentErrorMessage(true);
323  return false;
324  }
325 
327  stmt->setUInt32(0, entry);
328  stmt->setUInt8(1, disableType);
329  WorldDatabase.Execute(stmt);
330 
331  handler->PSendSysMessage("Remove Disabled %s (Id: %u)", disableTypeStr.c_str(), entry);
332  return true;
333  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
Definition: WorldDatabase.h:96
arena_t NULL
Definition: jemalloc_internal.h:624
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Definition: PreparedStatement.h:74
Definition: DisableMgr.h:36
Definition: WorldDatabase.h:98
Definition: DisableMgr.h:32
uint32_t uint32
Definition: Define.h:150
Definition: DisableMgr.h:35
Definition: DisableMgr.h:29
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
Definition: DisableMgr.h:30
Definition: DisableMgr.h:33
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Definition: DisableMgr.h:31
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: DisableMgr.h:34
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool disable_commandscript::HandleRemoveDisableSpellCommand ( ChatHandler handler,
char const args 
)
inlinestatic
336  {
337  if (!*args)
338  return false;
339 
340  return HandleRemoveDisables(handler, args, DISABLE_TYPE_SPELL);
341  }
Definition: DisableMgr.h:29
static bool HandleRemoveDisables(ChatHandler *handler, char const *args, uint8 disableType)
Definition: cs_disable.cpp:276

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool disable_commandscript::HandleRemoveDisableVmapCommand ( ChatHandler handler,
char const args 
)
inlinestatic
384  {
385  if (!*args)
386  return false;
387 
388  return HandleRemoveDisables(handler, args, DISABLE_TYPE_VMAP);
389  }
Definition: DisableMgr.h:35
static bool HandleRemoveDisables(ChatHandler *handler, char const *args, uint8 disableType)
Definition: cs_disable.cpp:276

+ 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: