2 * Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef MANGOSSERVER_CHAT_H
20 #define MANGOSSERVER_CHAT_H
22 #include "SharedDefines.h"
35 uint32 SecurityLevel
; // function pointer required correct align (use uint32)
36 bool (ChatHandler::*Handler
)(const char* args
);
38 ChatCommand
* ChildCommands
;
44 explicit ChatHandler(WorldSession
* session
) : m_session(session
) {}
45 explicit ChatHandler(Player
* player
) : m_session(player
->GetSession()) {}
48 static void FillMessageData( WorldPacket
*data
, WorldSession
* session
, uint8 type
, uint32 language
, const char *channelName
, uint64 target_guid
, const char *message
, Unit
*speaker
);
50 void FillMessageData( WorldPacket
*data
, uint8 type
, uint32 language
, uint64 target_guid
, const char* message
)
52 FillMessageData( data
, m_session
, type
, language
, NULL
, target_guid
, message
, NULL
);
55 void FillSystemMessageData( WorldPacket
*data
, const char* message
)
57 FillMessageData( data
, CHAT_MSG_SYSTEM
, LANG_UNIVERSAL
, 0, message
);
60 static char* LineFromMessage(char*& pos
) { char* start
= strtok(pos
,"\n"); pos
= NULL
; return start
; }
62 const char *GetMangosString(int32 entry
);
64 void SendSysMessage( const char *str
);
65 void SendSysMessage( int32 entry
);
66 void PSendSysMessage( const char *format
, ...) ATTR_PRINTF(2,3);
67 void PSendSysMessage( int32 entry
, ... );
69 int ParseCommands(const char* text
);
72 bool hasStringAbbr(const char* name
, const char* part
);
73 void SendGlobalSysMessage(const char *str
);
75 bool ExecuteCommandInTable(ChatCommand
*table
, const char* text
, std::string fullcommand
);
76 bool ShowHelpForCommand(ChatCommand
*table
, const char* cmd
);
77 bool ShowHelpForSubCommands(ChatCommand
*table
, char const* cmd
, char const* subcmd
);
79 ChatCommand
* getCommandTable();
81 bool HandleHelpCommand(const char* args
);
82 bool HandleCommandsCommand(const char* args
);
83 bool HandleAcctCommand(const char* args
);
84 bool HandleStartCommand(const char* args
);
85 bool HandleInfoCommand(const char* args
);
86 bool HandleDismountCommand(const char* args
);
87 bool HandleSaveCommand(const char* args
);
88 bool HandleGMListCommand(const char* args
);
90 bool HandleNamegoCommand(const char* args
);
91 bool HandleGonameCommand(const char* args
);
92 bool HandleGroupgoCommand(const char* args
);
93 bool HandleRecallCommand(const char* args
);
94 bool HandleAnnounceCommand(const char* args
);
95 bool HandleNotifyCommand(const char* args
);
96 bool HandleGMmodeCommand(const char* args
);
97 bool HandleGMChatCommand(const char* args
);
98 bool HandleVisibleCommand(const char* args
);
99 bool HandleGPSCommand(const char* args
);
100 bool HandleTaxiCheatCommand(const char* args
);
101 bool HandleWhispersCommand(const char* args
);
102 bool HandleSayCommand(const char* args
);
103 bool HandleNpcWhisperCommand(const char* args
);
104 bool HandleYellCommand(const char* args
);
105 bool HandlePlayEmoteCommand(const char* args
);
106 bool HandleSendMailCommand(const char* args
);
107 bool HandleNameTeleCommand(const char* args
);
108 bool HandleGroupTeleCommand(const char* args
);
109 bool HandleDrunkCommand(const char* args
);
111 bool HandleEventActiveListCommand(const char* args
);
112 bool HandleEventStartCommand(const char* args
);
113 bool HandleEventStopCommand(const char* args
);
114 bool HandleEventInfoCommand(const char* args
);
116 bool HandleModifyKnownTitlesCommand(const char* args
);
117 bool HandleModifyHPCommand(const char* args
);
118 bool HandleModifyManaCommand(const char* args
);
119 bool HandleModifyRageCommand(const char* args
);
120 bool HandleModifyEnergyCommand(const char* args
);
121 bool HandleModifyMoneyCommand(const char* args
);
122 bool HandleModifyASpeedCommand(const char* args
);
123 bool HandleModifySpeedCommand(const char* args
);
124 bool HandleModifyBWalkCommand(const char* args
);
125 bool HandleModifyFlyCommand(const char* args
);
126 bool HandleModifySwimCommand(const char* args
);
127 bool HandleModifyScaleCommand(const char* args
);
128 bool HandleModifyMountCommand(const char* args
);
129 bool HandleModifyBitCommand(const char* args
);
130 bool HandleModifyFactionCommand(const char* args
);
131 bool HandleModifySpellCommand(const char* args
);
132 bool HandleModifyTalentCommand (const char* args
);
133 bool HandleModifyHonorCommand (const char* args
);
134 bool HandleModifyRepCommand(const char* args
);
135 bool HandleModifyArenaCommand(const char* args
);
137 bool HandleReloadCommand(const char* args
);
138 bool HandleReloadAllCommand(const char* args
);
139 bool HandleReloadAllAreaCommand(const char* args
);
140 bool HandleReloadAllItemCommand(const char* args
);
141 bool HandleReloadAllLootCommand(const char* args
);
142 bool HandleReloadAllNpcCommand(const char* args
);
143 bool HandleReloadAllQuestCommand(const char* args
);
144 bool HandleReloadAllScriptsCommand(const char* args
);
145 bool HandleReloadAllSpellCommand(const char* args
);
146 bool HandleReloadAllLocalesCommand(const char* args
);
148 bool HandleReloadConfigCommand(const char* args
);
150 bool HandleReloadAreaTriggerTavernCommand(const char* args
);
151 bool HandleReloadAreaTriggerTeleportCommand(const char* args
);
152 bool HandleReloadEventScriptsCommand(const char* args
);
153 bool HandleReloadCommandCommand(const char* args
);
154 bool HandleReloadCreatureQuestRelationsCommand(const char* args
);
155 bool HandleReloadCreatureQuestInvRelationsCommand(const char* args
);
156 bool HandleReloadGameGraveyardZoneCommand(const char* args
);
157 bool HandleReloadGameObjectScriptsCommand(const char* args
);
158 bool HandleReloadGameTeleCommand(const char* args
);
159 bool HandleReloadGOQuestRelationsCommand(const char* args
);
160 bool HandleReloadGOQuestInvRelationsCommand(const char* args
);
161 bool HandleReloadLootTemplatesCreatureCommand(const char* args
);
162 bool HandleReloadLootTemplatesDisenchantCommand(const char* args
);
163 bool HandleReloadLootTemplatesFishingCommand(const char* args
);
164 bool HandleReloadLootTemplatesGameobjectCommand(const char* args
);
165 bool HandleReloadLootTemplatesItemCommand(const char* args
);
166 bool HandleReloadLootTemplatesPickpocketingCommand(const char* args
);
167 bool HandleReloadLootTemplatesProspectingCommand(const char* args
);
168 bool HandleReloadLootTemplatesReferenceCommand(const char* args
);
169 bool HandleReloadLootTemplatesQuestMailCommand(const char* args
);
170 bool HandleReloadLootTemplatesSkinningCommand(const char* args
);
171 bool HandleReloadMangosStringCommand(const char* args
);
172 bool HandleReloadNpcGossipCommand(const char* args
);
173 bool HandleReloadNpcTrainerCommand(const char* args
);
174 bool HandleReloadNpcVendorCommand(const char* args
);
175 bool HandleReloadQuestAreaTriggersCommand(const char* args
);
176 bool HandleReloadQuestEndScriptsCommand(const char* args
);
177 bool HandleReloadQuestStartScriptsCommand(const char* args
);
178 bool HandleReloadQuestTemplateCommand(const char* args
);
179 bool HandleReloadReservedNameCommand(const char*);
180 bool HandleReloadSkillDiscoveryTemplateCommand(const char* args
);
181 bool HandleReloadSkillExtraItemTemplateCommand(const char* args
);
182 bool HandleReloadSkillFishingBaseLevelCommand(const char* args
);
183 bool HandleReloadSpellAffectCommand(const char* args
);
184 bool HandleReloadSpellChainCommand(const char* args
);
185 bool HandleReloadSpellElixirCommand(const char* args
);
186 bool HandleReloadSpellLearnSpellCommand(const char* args
);
187 bool HandleReloadSpellProcEventCommand(const char* args
);
188 bool HandleReloadSpellScriptTargetCommand(const char* args
);
189 bool HandleReloadSpellScriptsCommand(const char* args
);
190 bool HandleReloadSpellTargetPositionCommand(const char* args
);
191 bool HandleReloadSpellThreatsCommand(const char* args
);
192 bool HandleReloadSpellPetAurasCommand(const char* args
);
193 bool HandleReloadPageTextsCommand(const char* args
);
194 bool HandleReloadItemEnchantementsCommand(const char* args
);
195 bool HandleReloadLocalesCreatureCommand(const char* args
);
196 bool HandleReloadLocalesGameobjectCommand(const char* args
);
197 bool HandleReloadLocalesItemCommand(const char* args
);
198 bool HandleReloadLocalesNpcTextCommand(const char* args
);
199 bool HandleReloadLocalesPageTextCommand(const char* args
);
200 bool HandleReloadLocalesQuestCommand(const char* args
);
202 bool HandleInstanceListBindsCommand(const char* args
);
203 bool HandleInstanceUnbindCommand(const char* args
);
204 bool HandleInstanceStatsCommand(const char* args
);
205 bool HandleInstanceSaveDataCommand(const char * args
);
207 bool HandleAddHonorCommand(const char* args
);
208 bool HandleHonorAddKillCommand(const char* args
);
209 bool HandleUpdateHonorFieldsCommand(const char* args
);
211 bool HandleLoadScriptsCommand(const char* args
);
212 bool HandleSendQuestPartyMsgCommand(const char* args
);
213 bool HandleSendQuestInvalidMsgCommand(const char* args
);
215 bool HandleDebugInArcCommand(const char* args
);
216 bool HandleDebugSpellFailCommand(const char* args
);
218 bool HandleGUIDCommand(const char* args
);
219 bool HandleNameCommand(const char* args
);
220 bool HandleSubNameCommand(const char* args
);
221 bool HandleItemMoveCommand(const char* args
);
222 bool HandleDelCreatureCommand(const char* args
);
223 bool HandleDeMorphCommand(const char* args
);
224 bool HandleAddVendorItemCommand(const char* args
);
225 bool HandleDelVendorItemCommand(const char* args
);
226 bool HandleAddMoveCommand(const char* args
);
227 bool HandleSetMoveTypeCommand(const char* args
);
228 bool HandleChangeLevelCommand(const char* args
);
229 bool HandleSetPoiCommand(const char* args
);
230 bool HandleEquipErrorCommand(const char* args
);
231 bool HandleNPCFlagCommand(const char* args
);
232 bool HandleSetModelCommand(const char* args
);
233 bool HandleFactionIdCommand(const char* args
);
234 bool HandleAddSpwCommand(const char* args
);
235 bool HandleSpawnDistCommand(const char* args
);
236 bool HandleSpawnTimeCommand(const char* args
);
237 bool HandleGoCreatureCommand(const char* args
);
238 bool HandleGoObjectCommand(const char* args
);
239 bool HandleGoTriggerCommand(const char* args
);
240 bool HandleGoGraveyardCommand(const char* args
);
241 bool HandleTargetObjectCommand(const char* args
);
242 bool HandleDelObjectCommand(const char* args
);
243 bool HandleMoveCreatureCommand(const char* args
);
244 bool HandleMoveObjectCommand(const char* args
);
245 bool HandleTurnObjectCommand(const char* args
);
246 bool HandlePInfoCommand(const char* args
);
247 bool HandlePLimitCommand(const char* args
);
248 bool HandleMuteCommand(const char* args
);
249 bool HandleUnmuteCommand(const char* args
);
250 bool HandleMovegensCommand(const char* args
);
252 bool HandleBanCommand(const char* args
);
253 bool HandleUnBanCommand(const char* args
);
254 bool HandleBanInfoCommand(const char* args
);
255 bool HandleBanListCommand(const char* args
);
256 bool HandleIdleRestartCommand(const char* args
);
257 bool HandleIdleShutDownCommand(const char* args
);
258 bool HandleShutDownCommand(const char* args
);
259 bool HandleRestartCommand(const char* args
);
260 bool HandleSecurityCommand(const char* args
);
261 bool HandleGoXYCommand(const char* args
);
262 bool HandleGoXYZCommand(const char* args
);
263 bool HandleGoZoneXYCommand(const char* args
);
264 bool HandleGoGridCommand(const char* args
);
265 bool HandleAddWeaponCommand(const char* args
);
266 bool HandleAllowMovementCommand(const char* args
);
267 bool HandleGoCommand(const char* args
);
269 bool HandleLearnCommand(const char* args
);
270 bool HandleLearnAllCommand(const char* args
);
271 bool HandleLearnAllGMCommand(const char* args
);
272 bool HandleLearnAllCraftsCommand(const char* args
);
273 bool HandleLearnAllRecipesCommand(const char* args
);
274 bool HandleLearnAllDefaultCommand(const char* args
);
275 bool HandleLearnAllLangCommand(const char* args
);
276 bool HandleLearnAllMyClassCommand(const char* args
);
277 bool HandleLearnAllMySpellsCommand(const char* args
);
278 bool HandleLearnAllMyTalentsCommand(const char* args
);
280 bool HandleLookupAreaCommand(const char* args
);
281 bool HandleLookupCreatureCommand(const char* args
);
282 bool HandleLookupEventCommand(const char* args
);
283 bool HandleLookupFactionCommand(const char * args
);
284 bool HandleLookupItemCommand(const char * args
);
285 bool HandleLookupItemSetCommand(const char * args
);
286 bool HandleLookupObjectCommand(const char* args
);
287 bool HandleLookupPlayerIpCommand(const char* args
);
288 bool HandleLookupPlayerAccountCommand(const char* args
);
289 bool HandleLookupPlayerEmailCommand(const char* args
);
290 bool HandleLookupQuestCommand(const char* args
);
291 bool HandleLookupSkillCommand(const char* args
);
292 bool HandleLookupSpellCommand(const char* args
);
293 bool HandleLookupTeleCommand(const char * args
);
295 bool HandleCooldownCommand(const char* args
);
296 bool HandleUnLearnCommand(const char* args
);
297 bool HandleGetDistanceCommand(const char* args
);
298 bool HandleGameObjectCommand(const char* args
);
299 bool HandleAnimCommand(const char* args
);
300 bool HandlePlaySoundCommand(const char* args
);
301 bool HandleStandStateCommand(const char* args
);
302 bool HandleDieCommand(const char* args
);
303 bool HandleDamageCommand(const char *args
);
304 bool HandleReviveCommand(const char* args
);
305 bool HandleMorphCommand(const char* args
);
306 bool HandleAuraCommand(const char* args
);
307 bool HandleUnAuraCommand(const char* args
);
308 bool HandleLinkGraveCommand(const char* args
);
309 bool HandleNearGraveCommand(const char* args
);
310 bool HandleSpawnTransportCommand(const char* args
);
311 bool HandleExploreCheatCommand(const char* args
);
312 bool HandleTextEmoteCommand(const char* args
);
313 bool HandleNpcInfoCommand(const char* args
);
314 bool HandleHoverCommand(const char* args
);
315 bool HandleLevelUpCommand(const char* args
);
316 bool HandleShowAreaCommand(const char* args
);
317 bool HandleHideAreaCommand(const char* args
);
318 bool HandleAddItemCommand(const char* args
);
319 bool HandleAddItemSetCommand(const char* args
);
321 bool HandleGuildCreateCommand(const char* args
);
322 bool HandleGuildInviteCommand(const char* args
);
323 bool HandleGuildUninviteCommand(const char* args
);
324 bool HandleGuildRankCommand(const char* args
);
325 bool HandleGuildDeleteCommand(const char* args
);
326 bool HandleUpdate(const char* args
);
327 bool HandleBankCommand(const char* args
);
328 bool HandleChangeWeather(const char* args
);
329 bool HandleKickPlayerCommand(const char * args
);
330 bool HandleTeleCommand(const char * args
);
331 bool HandleAddTeleCommand(const char * args
);
332 bool HandleDelTeleCommand(const char * args
);
333 bool HandleListAurasCommand(const char * args
);
335 bool HandleResetHonorCommand(const char * args
);
336 bool HandleResetLevelCommand(const char * args
);
337 bool HandleResetSpellsCommand(const char * args
);
339 bool HandleResetStatsCommand(const char * args
);
340 bool HandleResetTalentsCommand(const char * args
);
342 bool HandleResetAllCommand(const char * args
);
343 bool HandleTicketCommand(const char* args
);
344 bool HandleDelTicketCommand(const char* args
);
345 bool HandleMaxSkillCommand(const char* args
);
346 bool HandleSetSkillCommand(const char* args
);
347 bool HandleListCreatureCommand(const char* args
);
348 bool HandleListItemCommand(const char* args
);
349 bool HandleListObjectCommand(const char* args
);
350 bool HandleNearObjectCommand(const char* args
);
351 bool HandlePasswordCommand(const char* args
);
352 bool HandleLockAccountCommand(const char* args
);
353 bool HandleRespawnCommand(const char* args
);
354 bool HandleWpAddCommand(const char* args
);
355 bool HandleWpModifyCommand(const char* args
);
356 bool HandleWpShowCommand(const char* args
);
357 bool HandleWpExportCommand(const char* args
);
358 bool HandleWpImportCommand(const char* args
);
359 bool HandleFlyModeCommand(const char* args
);
360 bool HandleSendOpcodeCommand(const char* args
);
361 bool HandleSellErrorCommand(const char* args
);
362 bool HandleBuyErrorCommand(const char* args
);
363 bool HandleUpdateWorldStateCommand(const char* args
);
364 bool HandlePlaySound2Command(const char* args
);
365 bool HandleSendChannelNotifyCommand(const char* args
);
366 bool HandleSendChatMsgCommand(const char* args
);
367 bool HandleRenameCommand(const char * args
);
368 bool HandleLoadPDumpCommand(const char *args
);
369 bool HandleWritePDumpCommand(const char *args
);
370 bool HandleChangeEntryCommand(const char *args
);
371 bool HandleCastCommand(const char *args
);
372 bool HandleCastBackCommand(const char *args
);
373 bool HandleCastDistCommand(const char *args
);
374 bool HandleCastSelfCommand(const char *args
);
375 bool HandleCastTargetCommand(const char *args
);
376 bool HandleComeToMeCommand(const char *args
);
377 bool HandleCombatStopCommand(const char *args
);
379 //! Development Commands
380 bool HandleSetValue(const char* args
);
381 bool HandleGetValue(const char* args
);
382 bool HandleSet32Bit(const char* args
);
383 bool HandleMod32Value(const char* args
);
384 bool HandleAddQuest(const char * args
);
385 bool HandleRemoveQuest(const char * args
);
386 bool HandleCompleteQuest(const char * args
);
387 bool HandleSaveAllCommand(const char* args
);
388 bool HandleGetItemState(const char * args
);
389 bool HandleGetLootRecipient(const char * args
);
391 Player
* getSelectedPlayer();
392 Creature
* getSelectedCreature();
393 Unit
* getSelectedUnit();
394 char* extractKeyFromLink(char* text
, char const* linkType
, char** something1
= NULL
);
395 char* extractKeyFromLink(char* text
, char const* const* linkTypes
, int* found_idx
, char** something1
= NULL
);
396 uint32
extractSpellIdFromLink(char* text
);
397 GameTele
const* extractGameTeleFromLink(char* text
);
399 GameObject
* GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid
,uint32 entry
);
401 WorldSession
* m_session
;
403 // Utility methods for commands
404 void ShowTicket(uint64 guid
, char const* text
, char const* time
);
405 uint32
GetTicketIDByNum(uint32 num
);
406 bool LookupPlayerSearchCommand(QueryResult
* result
, int32 limit
);
408 void SetSentErrorMessage(bool val
){ sentErrorMessage
= val
;};
410 // common global flag
411 static bool load_command_table
;
412 bool sentErrorMessage
;
416 char const *fmtstring( char const *format
, ... );