1 | /* |
---|
2 | * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> |
---|
3 | * |
---|
4 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
5 | * |
---|
6 | * This program is free software; you can redistribute it and/or modify |
---|
7 | * it under the terms of the GNU General Public License as published by |
---|
8 | * the Free Software Foundation; either version 2 of the License, or |
---|
9 | * (at your option) any later version. |
---|
10 | * |
---|
11 | * This program is distributed in the hope that it will be useful, |
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | * GNU General Public License for more details. |
---|
15 | * |
---|
16 | * You should have received a copy of the GNU General Public License |
---|
17 | * along with this program; if not, write to the Free Software |
---|
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
19 | */ |
---|
20 | |
---|
21 | #include "Common.h" |
---|
22 | #include "Database/DatabaseEnv.h" |
---|
23 | #include "WorldPacket.h" |
---|
24 | #include "WorldSession.h" |
---|
25 | #include "World.h" |
---|
26 | #include "ObjectMgr.h" |
---|
27 | #include "AccountMgr.h" |
---|
28 | #include "PlayerDump.h" |
---|
29 | #include "SpellMgr.h" |
---|
30 | #include "Player.h" |
---|
31 | #include "Opcodes.h" |
---|
32 | #include "GameObject.h" |
---|
33 | #include "Chat.h" |
---|
34 | #include "Log.h" |
---|
35 | #include "Guild.h" |
---|
36 | #include "ObjectAccessor.h" |
---|
37 | #include "MapManager.h" |
---|
38 | #include "SpellAuras.h" |
---|
39 | #include "ScriptCalls.h" |
---|
40 | #include "Language.h" |
---|
41 | #include "GridNotifiersImpl.h" |
---|
42 | #include "CellImpl.h" |
---|
43 | #include "Weather.h" |
---|
44 | #include "PointMovementGenerator.h" |
---|
45 | #include "TargetedMovementGenerator.h" |
---|
46 | #include "SkillDiscovery.h" |
---|
47 | #include "SkillExtraItems.h" |
---|
48 | #include "SystemConfig.h" |
---|
49 | #include "Config/ConfigEnv.h" |
---|
50 | #include "Util.h" |
---|
51 | #include "ItemEnchantmentMgr.h" |
---|
52 | #include "BattleGroundMgr.h" |
---|
53 | #include "InstanceSaveMgr.h" |
---|
54 | #include "InstanceData.h" |
---|
55 | #include "AccountMgr.h" |
---|
56 | |
---|
57 | //reload commands |
---|
58 | bool ChatHandler::HandleReloadCommand(const char* arg) |
---|
59 | { |
---|
60 | // this is error catcher for wrong table name in .reload commands |
---|
61 | PSendSysMessage("Db table with name starting from '%s' not found and can't be reloaded.",arg); |
---|
62 | SetSentErrorMessage(true); |
---|
63 | return false; |
---|
64 | } |
---|
65 | |
---|
66 | bool ChatHandler::HandleReloadAllCommand(const char*) |
---|
67 | { |
---|
68 | HandleReloadAreaTriggerTeleportCommand(""); |
---|
69 | HandleReloadSkillFishingBaseLevelCommand(""); |
---|
70 | |
---|
71 | HandleReloadAllAreaCommand(""); |
---|
72 | HandleReloadAllLootCommand(""); |
---|
73 | HandleReloadAllNpcCommand(""); |
---|
74 | HandleReloadAllQuestCommand(""); |
---|
75 | HandleReloadAllSpellCommand(""); |
---|
76 | HandleReloadAllItemCommand(""); |
---|
77 | HandleReloadAllLocalesCommand(""); |
---|
78 | |
---|
79 | HandleReloadCommandCommand(""); |
---|
80 | HandleReloadReservedNameCommand(""); |
---|
81 | HandleReloadTrinityStringCommand(""); |
---|
82 | HandleReloadGameTeleCommand(""); |
---|
83 | return true; |
---|
84 | } |
---|
85 | |
---|
86 | bool ChatHandler::HandleReloadAllAreaCommand(const char*) |
---|
87 | { |
---|
88 | //HandleReloadQuestAreaTriggersCommand(""); -- reloaded in HandleReloadAllQuestCommand |
---|
89 | HandleReloadAreaTriggerTeleportCommand(""); |
---|
90 | HandleReloadAreaTriggerTavernCommand(""); |
---|
91 | HandleReloadGameGraveyardZoneCommand(""); |
---|
92 | return true; |
---|
93 | } |
---|
94 | |
---|
95 | bool ChatHandler::HandleReloadAllLootCommand(const char*) |
---|
96 | { |
---|
97 | sLog.outString( "Re-Loading Loot Tables..." ); |
---|
98 | LoadLootTables(); |
---|
99 | SendGlobalSysMessage("DB tables `*_loot_template` reloaded."); |
---|
100 | return true; |
---|
101 | } |
---|
102 | |
---|
103 | bool ChatHandler::HandleReloadAllNpcCommand(const char* /*args*/) |
---|
104 | { |
---|
105 | HandleReloadNpcGossipCommand("a"); |
---|
106 | HandleReloadNpcOptionCommand("a"); |
---|
107 | HandleReloadNpcTrainerCommand("a"); |
---|
108 | HandleReloadNpcVendorCommand("a"); |
---|
109 | return true; |
---|
110 | } |
---|
111 | |
---|
112 | bool ChatHandler::HandleReloadAllQuestCommand(const char* /*args*/) |
---|
113 | { |
---|
114 | HandleReloadQuestAreaTriggersCommand("a"); |
---|
115 | HandleReloadQuestTemplateCommand("a"); |
---|
116 | |
---|
117 | sLog.outString( "Re-Loading Quests Relations..." ); |
---|
118 | objmgr.LoadQuestRelations(); |
---|
119 | SendGlobalSysMessage("DB tables `*_questrelation` and `*_involvedrelation` reloaded."); |
---|
120 | return true; |
---|
121 | } |
---|
122 | |
---|
123 | bool ChatHandler::HandleReloadAllScriptsCommand(const char*) |
---|
124 | { |
---|
125 | if(sWorld.IsScriptScheduled()) |
---|
126 | { |
---|
127 | PSendSysMessage("DB scripts used currently, please attempt reload later."); |
---|
128 | SetSentErrorMessage(true); |
---|
129 | return false; |
---|
130 | } |
---|
131 | |
---|
132 | sLog.outString( "Re-Loading Scripts..." ); |
---|
133 | HandleReloadGameObjectScriptsCommand("a"); |
---|
134 | HandleReloadEventScriptsCommand("a"); |
---|
135 | HandleReloadQuestEndScriptsCommand("a"); |
---|
136 | HandleReloadQuestStartScriptsCommand("a"); |
---|
137 | HandleReloadSpellScriptsCommand("a"); |
---|
138 | SendGlobalSysMessage("DB tables `*_scripts` reloaded."); |
---|
139 | return true; |
---|
140 | } |
---|
141 | |
---|
142 | bool ChatHandler::HandleReloadAllSpellCommand(const char*) |
---|
143 | { |
---|
144 | HandleReloadSkillDiscoveryTemplateCommand("a"); |
---|
145 | HandleReloadSkillExtraItemTemplateCommand("a"); |
---|
146 | HandleReloadSpellAffectCommand("a"); |
---|
147 | HandleReloadSpellChainCommand("a"); |
---|
148 | HandleReloadSpellElixirCommand("a"); |
---|
149 | HandleReloadSpellLearnSpellCommand("a"); |
---|
150 | HandleReloadSpellProcEventCommand("a"); |
---|
151 | HandleReloadSpellScriptTargetCommand("a"); |
---|
152 | HandleReloadSpellTargetPositionCommand("a"); |
---|
153 | HandleReloadSpellThreatsCommand("a"); |
---|
154 | HandleReloadSpellPetAurasCommand("a"); |
---|
155 | HandleReloadSpellDisabledCommand("a"); |
---|
156 | return true; |
---|
157 | } |
---|
158 | |
---|
159 | bool ChatHandler::HandleReloadAllItemCommand(const char*) |
---|
160 | { |
---|
161 | HandleReloadPageTextsCommand("a"); |
---|
162 | HandleReloadItemEnchantementsCommand("a"); |
---|
163 | return true; |
---|
164 | } |
---|
165 | |
---|
166 | bool ChatHandler::HandleReloadAllLocalesCommand(const char* args) |
---|
167 | { |
---|
168 | HandleReloadLocalesCreatureCommand("a"); |
---|
169 | HandleReloadLocalesGameobjectCommand("a"); |
---|
170 | HandleReloadLocalesItemCommand("a"); |
---|
171 | HandleReloadLocalesNpcTextCommand("a"); |
---|
172 | HandleReloadLocalesPageTextCommand("a"); |
---|
173 | HandleReloadLocalesQuestCommand("a"); |
---|
174 | return true; |
---|
175 | } |
---|
176 | |
---|
177 | bool ChatHandler::HandleReloadConfigCommand(const char* arg) |
---|
178 | { |
---|
179 | sLog.outString( "Re-Loading config settings..." ); |
---|
180 | sWorld.LoadConfigSettings(true); |
---|
181 | SendGlobalSysMessage("World config settings reloaded."); |
---|
182 | return true; |
---|
183 | } |
---|
184 | |
---|
185 | bool ChatHandler::HandleReloadAreaTriggerTavernCommand(const char*) |
---|
186 | { |
---|
187 | sLog.outString( "Re-Loading Tavern Area Triggers..." ); |
---|
188 | objmgr.LoadTavernAreaTriggers(); |
---|
189 | SendGlobalSysMessage("DB table `areatrigger_tavern` reloaded."); |
---|
190 | return true; |
---|
191 | } |
---|
192 | |
---|
193 | bool ChatHandler::HandleReloadAreaTriggerTeleportCommand(const char*) |
---|
194 | { |
---|
195 | sLog.outString( "Re-Loading AreaTrigger teleport definitions..." ); |
---|
196 | objmgr.LoadAreaTriggerTeleports(); |
---|
197 | SendGlobalSysMessage("DB table `areatrigger_teleport` reloaded."); |
---|
198 | return true; |
---|
199 | } |
---|
200 | |
---|
201 | bool ChatHandler::HandleReloadCommandCommand(const char*) |
---|
202 | { |
---|
203 | load_command_table = true; |
---|
204 | SendGlobalSysMessage("DB table `command` will be reloaded at next chat command use."); |
---|
205 | return true; |
---|
206 | } |
---|
207 | |
---|
208 | bool ChatHandler::HandleReloadCreatureQuestRelationsCommand(const char*) |
---|
209 | { |
---|
210 | sLog.outString( "Loading Quests Relations... (`creature_questrelation`)" ); |
---|
211 | objmgr.LoadCreatureQuestRelations(); |
---|
212 | SendGlobalSysMessage("DB table `creature_questrelation` (creature quest givers) reloaded."); |
---|
213 | return true; |
---|
214 | } |
---|
215 | |
---|
216 | bool ChatHandler::HandleReloadCreatureQuestInvRelationsCommand(const char*) |
---|
217 | { |
---|
218 | sLog.outString( "Loading Quests Relations... (`creature_involvedrelation`)" ); |
---|
219 | objmgr.LoadCreatureInvolvedRelations(); |
---|
220 | SendGlobalSysMessage("DB table `creature_involvedrelation` (creature quest takers) reloaded."); |
---|
221 | return true; |
---|
222 | } |
---|
223 | |
---|
224 | bool ChatHandler::HandleReloadGOQuestRelationsCommand(const char*) |
---|
225 | { |
---|
226 | sLog.outString( "Loading Quests Relations... (`gameobject_questrelation`)" ); |
---|
227 | objmgr.LoadGameobjectQuestRelations(); |
---|
228 | SendGlobalSysMessage("DB table `gameobject_questrelation` (gameobject quest givers) reloaded."); |
---|
229 | return true; |
---|
230 | } |
---|
231 | |
---|
232 | bool ChatHandler::HandleReloadGOQuestInvRelationsCommand(const char*) |
---|
233 | { |
---|
234 | sLog.outString( "Loading Quests Relations... (`gameobject_involvedrelation`)" ); |
---|
235 | objmgr.LoadGameobjectInvolvedRelations(); |
---|
236 | SendGlobalSysMessage("DB table `gameobject_involvedrelation` (gameobject quest takers) reloaded."); |
---|
237 | return true; |
---|
238 | } |
---|
239 | |
---|
240 | bool ChatHandler::HandleReloadQuestAreaTriggersCommand(const char*) |
---|
241 | { |
---|
242 | sLog.outString( "Re-Loading Quest Area Triggers..." ); |
---|
243 | objmgr.LoadQuestAreaTriggers(); |
---|
244 | SendGlobalSysMessage("DB table `areatrigger_involvedrelation` (quest area triggers) reloaded."); |
---|
245 | return true; |
---|
246 | } |
---|
247 | |
---|
248 | bool ChatHandler::HandleReloadQuestTemplateCommand(const char*) |
---|
249 | { |
---|
250 | sLog.outString( "Re-Loading Quest Templates..." ); |
---|
251 | objmgr.LoadQuests(); |
---|
252 | SendGlobalSysMessage("DB table `quest_template` (quest definitions) reloaded."); |
---|
253 | return true; |
---|
254 | } |
---|
255 | |
---|
256 | bool ChatHandler::HandleReloadLootTemplatesCreatureCommand(const char*) |
---|
257 | { |
---|
258 | sLog.outString( "Re-Loading Loot Tables... (`creature_loot_template`)" ); |
---|
259 | LoadLootTemplates_Creature(); |
---|
260 | LootTemplates_Creature.CheckLootRefs(); |
---|
261 | SendGlobalSysMessage("DB table `creature_loot_template` reloaded."); |
---|
262 | return true; |
---|
263 | } |
---|
264 | |
---|
265 | bool ChatHandler::HandleReloadLootTemplatesDisenchantCommand(const char*) |
---|
266 | { |
---|
267 | sLog.outString( "Re-Loading Loot Tables... (`disenchant_loot_template`)" ); |
---|
268 | LoadLootTemplates_Disenchant(); |
---|
269 | LootTemplates_Disenchant.CheckLootRefs(); |
---|
270 | SendGlobalSysMessage("DB table `disenchant_loot_template` reloaded."); |
---|
271 | return true; |
---|
272 | } |
---|
273 | |
---|
274 | bool ChatHandler::HandleReloadLootTemplatesFishingCommand(const char*) |
---|
275 | { |
---|
276 | sLog.outString( "Re-Loading Loot Tables... (`fishing_loot_template`)" ); |
---|
277 | LoadLootTemplates_Fishing(); |
---|
278 | LootTemplates_Fishing.CheckLootRefs(); |
---|
279 | SendGlobalSysMessage("DB table `fishing_loot_template` reloaded."); |
---|
280 | return true; |
---|
281 | } |
---|
282 | |
---|
283 | bool ChatHandler::HandleReloadLootTemplatesGameobjectCommand(const char*) |
---|
284 | { |
---|
285 | sLog.outString( "Re-Loading Loot Tables... (`gameobject_loot_template`)" ); |
---|
286 | LoadLootTemplates_Gameobject(); |
---|
287 | LootTemplates_Gameobject.CheckLootRefs(); |
---|
288 | SendGlobalSysMessage("DB table `gameobject_loot_template` reloaded."); |
---|
289 | return true; |
---|
290 | } |
---|
291 | |
---|
292 | bool ChatHandler::HandleReloadLootTemplatesItemCommand(const char*) |
---|
293 | { |
---|
294 | sLog.outString( "Re-Loading Loot Tables... (`item_loot_template`)" ); |
---|
295 | LoadLootTemplates_Item(); |
---|
296 | LootTemplates_Item.CheckLootRefs(); |
---|
297 | SendGlobalSysMessage("DB table `item_loot_template` reloaded."); |
---|
298 | return true; |
---|
299 | } |
---|
300 | |
---|
301 | bool ChatHandler::HandleReloadLootTemplatesPickpocketingCommand(const char*) |
---|
302 | { |
---|
303 | sLog.outString( "Re-Loading Loot Tables... (`pickpocketing_loot_template`)" ); |
---|
304 | LoadLootTemplates_Pickpocketing(); |
---|
305 | LootTemplates_Pickpocketing.CheckLootRefs(); |
---|
306 | SendGlobalSysMessage("DB table `pickpocketing_loot_template` reloaded."); |
---|
307 | return true; |
---|
308 | } |
---|
309 | |
---|
310 | bool ChatHandler::HandleReloadLootTemplatesProspectingCommand(const char*) |
---|
311 | { |
---|
312 | sLog.outString( "Re-Loading Loot Tables... (`prospecting_loot_template`)" ); |
---|
313 | LoadLootTemplates_Prospecting(); |
---|
314 | LootTemplates_Prospecting.CheckLootRefs(); |
---|
315 | SendGlobalSysMessage("DB table `prospecting_loot_template` reloaded."); |
---|
316 | return true; |
---|
317 | } |
---|
318 | |
---|
319 | bool ChatHandler::HandleReloadLootTemplatesQuestMailCommand(const char*) |
---|
320 | { |
---|
321 | sLog.outString( "Re-Loading Loot Tables... (`quest_mail_loot_template`)" ); |
---|
322 | LoadLootTemplates_QuestMail(); |
---|
323 | LootTemplates_QuestMail.CheckLootRefs(); |
---|
324 | SendGlobalSysMessage("DB table `quest_mail_loot_template` reloaded."); |
---|
325 | return true; |
---|
326 | } |
---|
327 | |
---|
328 | bool ChatHandler::HandleReloadLootTemplatesReferenceCommand(const char*) |
---|
329 | { |
---|
330 | sLog.outString( "Re-Loading Loot Tables... (`reference_loot_template`)" ); |
---|
331 | LoadLootTemplates_Reference(); |
---|
332 | SendGlobalSysMessage("DB table `reference_loot_template` reloaded."); |
---|
333 | return true; |
---|
334 | } |
---|
335 | |
---|
336 | bool ChatHandler::HandleReloadLootTemplatesSkinningCommand(const char*) |
---|
337 | { |
---|
338 | sLog.outString( "Re-Loading Loot Tables... (`skinning_loot_template`)" ); |
---|
339 | LoadLootTemplates_Skinning(); |
---|
340 | LootTemplates_Skinning.CheckLootRefs(); |
---|
341 | SendGlobalSysMessage("DB table `skinning_loot_template` reloaded."); |
---|
342 | return true; |
---|
343 | } |
---|
344 | |
---|
345 | bool ChatHandler::HandleReloadTrinityStringCommand(const char*) |
---|
346 | { |
---|
347 | sLog.outString( "Re-Loading trinity_string Table!" ); |
---|
348 | objmgr.LoadTrinityStrings(); |
---|
349 | SendGlobalSysMessage("DB table `trinity_string` reloaded."); |
---|
350 | return true; |
---|
351 | } |
---|
352 | |
---|
353 | bool ChatHandler::HandleReloadNpcOptionCommand(const char*) |
---|
354 | { |
---|
355 | sLog.outString( "Re-Loading `npc_option` Table!" ); |
---|
356 | objmgr.LoadNpcOptions(); |
---|
357 | SendGlobalSysMessage("DB table `npc_option` reloaded."); |
---|
358 | return true; |
---|
359 | } |
---|
360 | |
---|
361 | bool ChatHandler::HandleReloadNpcGossipCommand(const char*) |
---|
362 | { |
---|
363 | sLog.outString( "Re-Loading `npc_gossip` Table!" ); |
---|
364 | objmgr.LoadNpcTextId(); |
---|
365 | SendGlobalSysMessage("DB table `npc_gossip` reloaded."); |
---|
366 | return true; |
---|
367 | } |
---|
368 | |
---|
369 | bool ChatHandler::HandleReloadNpcTrainerCommand(const char*) |
---|
370 | { |
---|
371 | sLog.outString( "Re-Loading `npc_trainer` Table!" ); |
---|
372 | objmgr.LoadTrainerSpell(); |
---|
373 | SendGlobalSysMessage("DB table `npc_trainer` reloaded."); |
---|
374 | return true; |
---|
375 | } |
---|
376 | |
---|
377 | bool ChatHandler::HandleReloadNpcVendorCommand(const char*) |
---|
378 | { |
---|
379 | sLog.outString( "Re-Loading `npc_vendor` Table!" ); |
---|
380 | objmgr.LoadVendors(); |
---|
381 | SendGlobalSysMessage("DB table `npc_vendor` reloaded."); |
---|
382 | return true; |
---|
383 | } |
---|
384 | |
---|
385 | bool ChatHandler::HandleReloadReservedNameCommand(const char*) |
---|
386 | { |
---|
387 | sLog.outString( "Loading ReservedNames... (`reserved_name`)" ); |
---|
388 | objmgr.LoadReservedPlayersNames(); |
---|
389 | SendGlobalSysMessage("DB table `reserved_name` (player reserved names) reloaded."); |
---|
390 | return true; |
---|
391 | } |
---|
392 | |
---|
393 | bool ChatHandler::HandleReloadSkillDiscoveryTemplateCommand(const char* /*args*/) |
---|
394 | { |
---|
395 | sLog.outString( "Re-Loading Skill Discovery Table..." ); |
---|
396 | LoadSkillDiscoveryTable(); |
---|
397 | SendGlobalSysMessage("DB table `skill_discovery_template` (recipes discovered at crafting) reloaded."); |
---|
398 | return true; |
---|
399 | } |
---|
400 | |
---|
401 | bool ChatHandler::HandleReloadSkillExtraItemTemplateCommand(const char* /*args*/) |
---|
402 | { |
---|
403 | sLog.outString( "Re-Loading Skill Extra Item Table..." ); |
---|
404 | LoadSkillExtraItemTable(); |
---|
405 | SendGlobalSysMessage("DB table `skill_extra_item_template` (extra item creation when crafting) reloaded."); |
---|
406 | return true; |
---|
407 | } |
---|
408 | |
---|
409 | bool ChatHandler::HandleReloadSkillFishingBaseLevelCommand(const char* /*args*/) |
---|
410 | { |
---|
411 | sLog.outString( "Re-Loading Skill Fishing base level requirements..." ); |
---|
412 | objmgr.LoadFishingBaseSkillLevel(); |
---|
413 | SendGlobalSysMessage("DB table `skill_fishing_base_level` (fishing base level for zone/subzone) reloaded."); |
---|
414 | return true; |
---|
415 | } |
---|
416 | |
---|
417 | bool ChatHandler::HandleReloadSpellAffectCommand(const char*) |
---|
418 | { |
---|
419 | sLog.outString( "Re-Loading SpellAffect definitions..." ); |
---|
420 | spellmgr.LoadSpellAffects(); |
---|
421 | SendGlobalSysMessage("DB table `spell_affect` (spell mods apply requirements) reloaded."); |
---|
422 | return true; |
---|
423 | } |
---|
424 | |
---|
425 | bool ChatHandler::HandleReloadSpellChainCommand(const char*) |
---|
426 | { |
---|
427 | sLog.outString( "Re-Loading Spell Chain Data... " ); |
---|
428 | spellmgr.LoadSpellChains(); |
---|
429 | SendGlobalSysMessage("DB table `spell_chain` (spell ranks) reloaded."); |
---|
430 | return true; |
---|
431 | } |
---|
432 | |
---|
433 | bool ChatHandler::HandleReloadSpellElixirCommand(const char*) |
---|
434 | { |
---|
435 | sLog.outString( "Re-Loading Spell Elixir types..." ); |
---|
436 | spellmgr.LoadSpellElixirs(); |
---|
437 | SendGlobalSysMessage("DB table `spell_elixir` (spell exlixir types) reloaded."); |
---|
438 | return true; |
---|
439 | } |
---|
440 | |
---|
441 | bool ChatHandler::HandleReloadSpellLearnSpellCommand(const char*) |
---|
442 | { |
---|
443 | sLog.outString( "Re-Loading Spell Learn Spells..." ); |
---|
444 | spellmgr.LoadSpellLearnSpells(); |
---|
445 | SendGlobalSysMessage("DB table `spell_learn_spell` reloaded."); |
---|
446 | return true; |
---|
447 | } |
---|
448 | |
---|
449 | bool ChatHandler::HandleReloadSpellProcEventCommand(const char*) |
---|
450 | { |
---|
451 | sLog.outString( "Re-Loading Spell Proc Event conditions..." ); |
---|
452 | spellmgr.LoadSpellProcEvents(); |
---|
453 | SendGlobalSysMessage("DB table `spell_proc_event` (spell proc trigger requirements) reloaded."); |
---|
454 | return true; |
---|
455 | } |
---|
456 | |
---|
457 | bool ChatHandler::HandleReloadSpellScriptTargetCommand(const char*) |
---|
458 | { |
---|
459 | sLog.outString( "Re-Loading SpellsScriptTarget..." ); |
---|
460 | spellmgr.LoadSpellScriptTarget(); |
---|
461 | SendGlobalSysMessage("DB table `spell_script_target` (spell targets selection in case specific creature/GO requirements) reloaded."); |
---|
462 | return true; |
---|
463 | } |
---|
464 | |
---|
465 | bool ChatHandler::HandleReloadSpellTargetPositionCommand(const char*) |
---|
466 | { |
---|
467 | sLog.outString( "Re-Loading Spell target coordinates..." ); |
---|
468 | spellmgr.LoadSpellTargetPositions(); |
---|
469 | SendGlobalSysMessage("DB table `spell_target_position` (destination coordinates for spell targets) reloaded."); |
---|
470 | return true; |
---|
471 | } |
---|
472 | |
---|
473 | bool ChatHandler::HandleReloadSpellThreatsCommand(const char*) |
---|
474 | { |
---|
475 | sLog.outString( "Re-Loading Aggro Spells Definitions..."); |
---|
476 | spellmgr.LoadSpellThreats(); |
---|
477 | SendGlobalSysMessage("DB table `spell_threat` (spell aggro definitions) reloaded."); |
---|
478 | return true; |
---|
479 | } |
---|
480 | |
---|
481 | bool ChatHandler::HandleReloadSpellPetAurasCommand(const char*) |
---|
482 | { |
---|
483 | sLog.outString( "Re-Loading Spell pet auras..."); |
---|
484 | spellmgr.LoadSpellPetAuras(); |
---|
485 | SendGlobalSysMessage("DB table `spell_pet_auras` reloaded."); |
---|
486 | return true; |
---|
487 | } |
---|
488 | |
---|
489 | bool ChatHandler::HandleReloadPageTextsCommand(const char*) |
---|
490 | { |
---|
491 | sLog.outString( "Re-Loading Page Texts..." ); |
---|
492 | objmgr.LoadPageTexts(); |
---|
493 | SendGlobalSysMessage("DB table `page_texts` reloaded."); |
---|
494 | return true; |
---|
495 | } |
---|
496 | |
---|
497 | bool ChatHandler::HandleReloadItemEnchantementsCommand(const char*) |
---|
498 | { |
---|
499 | sLog.outString( "Re-Loading Item Random Enchantments Table..." ); |
---|
500 | LoadRandomEnchantmentsTable(); |
---|
501 | SendGlobalSysMessage("DB table `item_enchantment_template` reloaded."); |
---|
502 | return true; |
---|
503 | } |
---|
504 | |
---|
505 | bool ChatHandler::HandleReloadGameObjectScriptsCommand(const char* arg) |
---|
506 | { |
---|
507 | if(sWorld.IsScriptScheduled()) |
---|
508 | { |
---|
509 | SendSysMessage("DB scripts used currently, please attempt reload later."); |
---|
510 | SetSentErrorMessage(true); |
---|
511 | return false; |
---|
512 | } |
---|
513 | |
---|
514 | if(*arg!='a') |
---|
515 | sLog.outString( "Re-Loading Scripts from `gameobject_scripts`..."); |
---|
516 | |
---|
517 | objmgr.LoadGameObjectScripts(); |
---|
518 | |
---|
519 | if(*arg!='a') |
---|
520 | SendGlobalSysMessage("DB table `gameobject_scripts` reloaded."); |
---|
521 | |
---|
522 | return true; |
---|
523 | } |
---|
524 | |
---|
525 | bool ChatHandler::HandleReloadEventScriptsCommand(const char* arg) |
---|
526 | { |
---|
527 | if(sWorld.IsScriptScheduled()) |
---|
528 | { |
---|
529 | SendSysMessage("DB scripts used currently, please attempt reload later."); |
---|
530 | SetSentErrorMessage(true); |
---|
531 | return false; |
---|
532 | } |
---|
533 | |
---|
534 | if(*arg!='a') |
---|
535 | sLog.outString( "Re-Loading Scripts from `event_scripts`..."); |
---|
536 | |
---|
537 | objmgr.LoadEventScripts(); |
---|
538 | |
---|
539 | if(*arg!='a') |
---|
540 | SendGlobalSysMessage("DB table `event_scripts` reloaded."); |
---|
541 | |
---|
542 | return true; |
---|
543 | } |
---|
544 | |
---|
545 | bool ChatHandler::HandleReloadQuestEndScriptsCommand(const char* arg) |
---|
546 | { |
---|
547 | if(sWorld.IsScriptScheduled()) |
---|
548 | { |
---|
549 | SendSysMessage("DB scripts used currently, please attempt reload later."); |
---|
550 | SetSentErrorMessage(true); |
---|
551 | return false; |
---|
552 | } |
---|
553 | |
---|
554 | if(*arg!='a') |
---|
555 | sLog.outString( "Re-Loading Scripts from `quest_end_scripts`..."); |
---|
556 | |
---|
557 | objmgr.LoadQuestEndScripts(); |
---|
558 | |
---|
559 | if(*arg!='a') |
---|
560 | SendGlobalSysMessage("DB table `quest_end_scripts` reloaded."); |
---|
561 | |
---|
562 | return true; |
---|
563 | } |
---|
564 | |
---|
565 | bool ChatHandler::HandleReloadQuestStartScriptsCommand(const char* arg) |
---|
566 | { |
---|
567 | if(sWorld.IsScriptScheduled()) |
---|
568 | { |
---|
569 | SendSysMessage("DB scripts used currently, please attempt reload later."); |
---|
570 | SetSentErrorMessage(true); |
---|
571 | return false; |
---|
572 | } |
---|
573 | |
---|
574 | if(*arg!='a') |
---|
575 | sLog.outString( "Re-Loading Scripts from `quest_start_scripts`..."); |
---|
576 | |
---|
577 | objmgr.LoadQuestStartScripts(); |
---|
578 | |
---|
579 | if(*arg!='a') |
---|
580 | SendGlobalSysMessage("DB table `quest_start_scripts` reloaded."); |
---|
581 | |
---|
582 | return true; |
---|
583 | } |
---|
584 | |
---|
585 | bool ChatHandler::HandleReloadSpellScriptsCommand(const char* arg) |
---|
586 | { |
---|
587 | if(sWorld.IsScriptScheduled()) |
---|
588 | { |
---|
589 | SendSysMessage("DB scripts used currently, please attempt reload later."); |
---|
590 | SetSentErrorMessage(true); |
---|
591 | return false; |
---|
592 | } |
---|
593 | |
---|
594 | if(*arg!='a') |
---|
595 | sLog.outString( "Re-Loading Scripts from `spell_scripts`..."); |
---|
596 | |
---|
597 | objmgr.LoadSpellScripts(); |
---|
598 | |
---|
599 | if(*arg!='a') |
---|
600 | SendGlobalSysMessage("DB table `spell_scripts` reloaded."); |
---|
601 | |
---|
602 | return true; |
---|
603 | } |
---|
604 | |
---|
605 | bool ChatHandler::HandleReloadGameGraveyardZoneCommand(const char* /*arg*/) |
---|
606 | { |
---|
607 | sLog.outString( "Re-Loading Graveyard-zone links..."); |
---|
608 | |
---|
609 | objmgr.LoadGraveyardZones(); |
---|
610 | |
---|
611 | SendGlobalSysMessage("DB table `game_graveyard_zone` reloaded."); |
---|
612 | |
---|
613 | return true; |
---|
614 | } |
---|
615 | |
---|
616 | bool ChatHandler::HandleReloadGameTeleCommand(const char* /*arg*/) |
---|
617 | { |
---|
618 | sLog.outString( "Re-Loading Game Tele coordinates..."); |
---|
619 | |
---|
620 | objmgr.LoadGameTele(); |
---|
621 | |
---|
622 | SendGlobalSysMessage("DB table `game_tele` reloaded."); |
---|
623 | |
---|
624 | return true; |
---|
625 | } |
---|
626 | |
---|
627 | bool ChatHandler::HandleReloadSpellDisabledCommand(const char* /*arg*/) |
---|
628 | { |
---|
629 | sLog.outString( "Re-Loading spell disabled table..."); |
---|
630 | |
---|
631 | objmgr.LoadSpellDisabledEntrys(); |
---|
632 | |
---|
633 | SendGlobalSysMessage("DB table `spell_disabled` reloaded."); |
---|
634 | |
---|
635 | return true; |
---|
636 | } |
---|
637 | |
---|
638 | bool ChatHandler::HandleReloadLocalesCreatureCommand(const char* /*arg*/) |
---|
639 | { |
---|
640 | sLog.outString( "Re-Loading Locales Creature ..."); |
---|
641 | objmgr.LoadCreatureLocales(); |
---|
642 | SendGlobalSysMessage("DB table `locales_creature` reloaded."); |
---|
643 | return true; |
---|
644 | } |
---|
645 | |
---|
646 | bool ChatHandler::HandleReloadLocalesGameobjectCommand(const char* /*arg*/) |
---|
647 | { |
---|
648 | sLog.outString( "Re-Loading Locales Gameobject ... "); |
---|
649 | objmgr.LoadGameObjectLocales(); |
---|
650 | SendGlobalSysMessage("DB table `locales_gameobject` reloaded."); |
---|
651 | return true; |
---|
652 | } |
---|
653 | |
---|
654 | bool ChatHandler::HandleReloadLocalesItemCommand(const char* /*arg*/) |
---|
655 | { |
---|
656 | sLog.outString( "Re-Loading Locales Item ... "); |
---|
657 | objmgr.LoadItemLocales(); |
---|
658 | SendGlobalSysMessage("DB table `locales_item` reloaded."); |
---|
659 | return true; |
---|
660 | } |
---|
661 | |
---|
662 | bool ChatHandler::HandleReloadLocalesNpcTextCommand(const char* /*arg*/) |
---|
663 | { |
---|
664 | sLog.outString( "Re-Loading Locales NPC Text ... "); |
---|
665 | objmgr.LoadNpcTextLocales(); |
---|
666 | SendGlobalSysMessage("DB table `locales_npc_text` reloaded."); |
---|
667 | return true; |
---|
668 | } |
---|
669 | |
---|
670 | bool ChatHandler::HandleReloadLocalesPageTextCommand(const char* /*arg*/) |
---|
671 | { |
---|
672 | sLog.outString( "Re-Loading Locales Page Text ... "); |
---|
673 | objmgr.LoadPageTextLocales(); |
---|
674 | SendGlobalSysMessage("DB table `locales_page_text` reloaded."); |
---|
675 | return true; |
---|
676 | } |
---|
677 | |
---|
678 | bool ChatHandler::HandleReloadLocalesQuestCommand(const char* /*arg*/) |
---|
679 | { |
---|
680 | sLog.outString( "Re-Loading Locales Quest ... "); |
---|
681 | objmgr.LoadQuestLocales(); |
---|
682 | SendGlobalSysMessage("DB table `locales_quest` reloaded."); |
---|
683 | return true; |
---|
684 | } |
---|
685 | |
---|
686 | bool ChatHandler::HandleLoadScriptsCommand(const char* args) |
---|
687 | { |
---|
688 | if(!LoadScriptingModule(args)) return true; |
---|
689 | |
---|
690 | sWorld.SendWorldText(LANG_SCRIPTS_RELOADED); |
---|
691 | return true; |
---|
692 | } |
---|
693 | |
---|
694 | bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args) |
---|
695 | { |
---|
696 | char* arg1 = strtok((char*)args, " "); |
---|
697 | if( !arg1 ) |
---|
698 | return false; |
---|
699 | |
---|
700 | char* arg2 = strtok(NULL, " "); |
---|
701 | |
---|
702 | std::string targetAccountName; |
---|
703 | uint32 targetAccountId = 0; |
---|
704 | uint32 targetSecurity = 0; |
---|
705 | |
---|
706 | /// only target player different from self allowed (if targetPlayer!=NULL then not console) |
---|
707 | Player* targetPlayer = getSelectedPlayer(); |
---|
708 | if(targetPlayer && m_session->GetPlayer()!=targetPlayer) |
---|
709 | { |
---|
710 | /// wrong command syntax or unexpected targeting |
---|
711 | if(arg2) |
---|
712 | return false; |
---|
713 | |
---|
714 | targetAccountId = targetPlayer->GetSession()->GetAccountId(); |
---|
715 | targetSecurity = targetPlayer->GetSession()->GetSecurity(); |
---|
716 | if(!accmgr.GetName(targetAccountId,targetAccountName)) |
---|
717 | { |
---|
718 | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,targetAccountName.c_str()); |
---|
719 | SetSentErrorMessage(true); |
---|
720 | return false; |
---|
721 | } |
---|
722 | } |
---|
723 | else |
---|
724 | { |
---|
725 | targetAccountName = arg1; |
---|
726 | if(!AccountMgr::normilizeString(targetAccountName)) |
---|
727 | { |
---|
728 | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,targetAccountName.c_str()); |
---|
729 | SetSentErrorMessage(true); |
---|
730 | return false; |
---|
731 | } |
---|
732 | |
---|
733 | targetAccountId = accmgr.GetId(targetAccountName); |
---|
734 | targetSecurity = accmgr.GetSecurity(targetAccountId); |
---|
735 | } |
---|
736 | |
---|
737 | int32 gm = (int32)atoi(arg2); |
---|
738 | if ( gm < SEC_PLAYER || gm > SEC_ADMINISTRATOR ) |
---|
739 | { |
---|
740 | SendSysMessage(LANG_BAD_VALUE); |
---|
741 | SetSentErrorMessage(true); |
---|
742 | return false; |
---|
743 | } |
---|
744 | |
---|
745 | /// m_session==NULL only for console |
---|
746 | uint32 plSecurity = m_session ? m_session->GetSecurity() : SEC_CONSOLE; |
---|
747 | |
---|
748 | /// can set security level only for target with less security and to less security that we have |
---|
749 | /// This is also reject self apply in fact |
---|
750 | if(targetSecurity >= plSecurity || uint32(gm) >= plSecurity ) |
---|
751 | { |
---|
752 | SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); |
---|
753 | SetSentErrorMessage(true); |
---|
754 | return false; |
---|
755 | } |
---|
756 | |
---|
757 | if(targetPlayer) |
---|
758 | { |
---|
759 | ChatHandler(targetPlayer).PSendSysMessage(LANG_YOURS_SECURITY_CHANGED,GetName(), gm); |
---|
760 | targetPlayer->GetSession()->SetSecurity(gm); |
---|
761 | } |
---|
762 | |
---|
763 | PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm); |
---|
764 | loginDatabase.PExecute("UPDATE account SET gmlevel = '%i' WHERE id = '%u'", gm, targetAccountId); |
---|
765 | |
---|
766 | return true; |
---|
767 | } |
---|
768 | |
---|
769 | /// Set password for account |
---|
770 | bool ChatHandler::HandleAccountSetPasswordCommand(const char* args) |
---|
771 | { |
---|
772 | if(!*args) |
---|
773 | return false; |
---|
774 | |
---|
775 | ///- Get the command line arguments |
---|
776 | char *szAccount = strtok ((char*)args," "); |
---|
777 | char *szPassword1 = strtok (NULL," "); |
---|
778 | char *szPassword2 = strtok (NULL," "); |
---|
779 | |
---|
780 | if (!szAccount||!szPassword1 || !szPassword2) |
---|
781 | return false; |
---|
782 | |
---|
783 | std::string account_name = szAccount; |
---|
784 | if(!AccountMgr::normilizeString(account_name)) |
---|
785 | { |
---|
786 | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
---|
787 | SetSentErrorMessage(true); |
---|
788 | return false; |
---|
789 | } |
---|
790 | |
---|
791 | uint32 targetAccountId = accmgr.GetId(account_name); |
---|
792 | if (!targetAccountId) |
---|
793 | { |
---|
794 | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
---|
795 | SetSentErrorMessage(true); |
---|
796 | return false; |
---|
797 | } |
---|
798 | |
---|
799 | uint32 targetSecurity = accmgr.GetSecurity(targetAccountId); |
---|
800 | |
---|
801 | /// m_session==NULL only for console |
---|
802 | uint32 plSecurity = m_session ? m_session->GetSecurity() : SEC_CONSOLE; |
---|
803 | |
---|
804 | /// can set password only for target with less security |
---|
805 | /// This is also reject self apply in fact |
---|
806 | if (targetSecurity >= plSecurity) |
---|
807 | { |
---|
808 | SendSysMessage (LANG_YOURS_SECURITY_IS_LOW); |
---|
809 | SetSentErrorMessage (true); |
---|
810 | return false; |
---|
811 | } |
---|
812 | |
---|
813 | if (strcmp(szPassword1,szPassword2)) |
---|
814 | { |
---|
815 | SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH); |
---|
816 | SetSentErrorMessage (true); |
---|
817 | return false; |
---|
818 | } |
---|
819 | |
---|
820 | AccountOpResult result = accmgr.ChangePassword(targetAccountId, szPassword1); |
---|
821 | |
---|
822 | switch(result) |
---|
823 | { |
---|
824 | case AOR_OK: |
---|
825 | SendSysMessage(LANG_COMMAND_PASSWORD); |
---|
826 | break; |
---|
827 | case AOR_NAME_NOT_EXIST: |
---|
828 | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
---|
829 | SetSentErrorMessage(true); |
---|
830 | return false; |
---|
831 | case AOR_PASS_TOO_LONG: |
---|
832 | SendSysMessage(LANG_PASSWORD_TOO_LONG); |
---|
833 | SetSentErrorMessage(true); |
---|
834 | return false; |
---|
835 | default: |
---|
836 | SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD); |
---|
837 | SetSentErrorMessage(true); |
---|
838 | return false; |
---|
839 | } |
---|
840 | |
---|
841 | return true; |
---|
842 | } |
---|
843 | |
---|
844 | bool ChatHandler::HandleAllowMovementCommand(const char* /*args*/) |
---|
845 | { |
---|
846 | if(sWorld.getAllowMovement()) |
---|
847 | { |
---|
848 | sWorld.SetAllowMovement(false); |
---|
849 | SendSysMessage(LANG_CREATURE_MOVE_DISABLED); |
---|
850 | } |
---|
851 | else |
---|
852 | { |
---|
853 | sWorld.SetAllowMovement(true); |
---|
854 | SendSysMessage(LANG_CREATURE_MOVE_ENABLED); |
---|
855 | } |
---|
856 | return true; |
---|
857 | } |
---|
858 | |
---|
859 | bool ChatHandler::HandleMaxSkillCommand(const char* /*args*/) |
---|
860 | { |
---|
861 | Player* SelectedPlayer = getSelectedPlayer(); |
---|
862 | if(!SelectedPlayer) |
---|
863 | { |
---|
864 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
865 | SetSentErrorMessage(true); |
---|
866 | return false; |
---|
867 | } |
---|
868 | |
---|
869 | // each skills that have max skill value dependent from level seted to current level max skill value |
---|
870 | SelectedPlayer->UpdateSkillsToMaxSkillsForLevel(); |
---|
871 | return true; |
---|
872 | } |
---|
873 | |
---|
874 | bool ChatHandler::HandleSetSkillCommand(const char* args) |
---|
875 | { |
---|
876 | // number or [name] Shift-click form |color|Hskill:skill_id|h[name]|h|r |
---|
877 | char* skill_p = extractKeyFromLink((char*)args,"Hskill"); |
---|
878 | if(!skill_p) |
---|
879 | return false; |
---|
880 | |
---|
881 | char *level_p = strtok (NULL, " "); |
---|
882 | |
---|
883 | if( !level_p) |
---|
884 | return false; |
---|
885 | |
---|
886 | char *max_p = strtok (NULL, " "); |
---|
887 | |
---|
888 | int32 skill = atoi(skill_p); |
---|
889 | |
---|
890 | if (skill <= 0) |
---|
891 | { |
---|
892 | PSendSysMessage(LANG_INVALID_SKILL_ID, skill); |
---|
893 | SetSentErrorMessage(true); |
---|
894 | return false; |
---|
895 | } |
---|
896 | |
---|
897 | int32 level = atol (level_p); |
---|
898 | |
---|
899 | Player * target = getSelectedPlayer(); |
---|
900 | if(!target) |
---|
901 | { |
---|
902 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
903 | SetSentErrorMessage(true); |
---|
904 | return false; |
---|
905 | } |
---|
906 | |
---|
907 | SkillLineEntry const* sl = sSkillLineStore.LookupEntry(skill); |
---|
908 | if(!sl) |
---|
909 | { |
---|
910 | PSendSysMessage(LANG_INVALID_SKILL_ID, skill); |
---|
911 | SetSentErrorMessage(true); |
---|
912 | return false; |
---|
913 | } |
---|
914 | |
---|
915 | if(!target->GetSkillValue(skill)) |
---|
916 | { |
---|
917 | PSendSysMessage(LANG_SET_SKILL_ERROR, target->GetName(), skill, sl->name[0]); |
---|
918 | SetSentErrorMessage(true); |
---|
919 | return false; |
---|
920 | } |
---|
921 | |
---|
922 | int32 max = max_p ? atol (max_p) : target->GetPureMaxSkillValue(skill); |
---|
923 | |
---|
924 | if( level <= 0 || level > max || max <= 0 ) |
---|
925 | return false; |
---|
926 | |
---|
927 | target->SetSkill(skill, level, max); |
---|
928 | PSendSysMessage(LANG_SET_SKILL, skill, sl->name[0], target->GetName(), level, max); |
---|
929 | |
---|
930 | return true; |
---|
931 | } |
---|
932 | |
---|
933 | bool ChatHandler::HandleUnLearnCommand(const char* args) |
---|
934 | { |
---|
935 | if (!*args) |
---|
936 | return false; |
---|
937 | |
---|
938 | |
---|
939 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r |
---|
940 | uint32 min_id = extractSpellIdFromLink((char*)args); |
---|
941 | if(!min_id) |
---|
942 | return false; |
---|
943 | |
---|
944 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r |
---|
945 | char* tail = strtok(NULL,""); |
---|
946 | |
---|
947 | uint32 max_id = extractSpellIdFromLink(tail); |
---|
948 | |
---|
949 | if (!max_id) |
---|
950 | { |
---|
951 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r |
---|
952 | max_id = min_id+1; |
---|
953 | } |
---|
954 | else |
---|
955 | { |
---|
956 | if (max_id < min_id) |
---|
957 | std::swap(min_id,max_id); |
---|
958 | |
---|
959 | max_id=max_id+1; |
---|
960 | } |
---|
961 | |
---|
962 | Player* target = getSelectedPlayer(); |
---|
963 | if(!target) |
---|
964 | { |
---|
965 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
966 | SetSentErrorMessage(true); |
---|
967 | return false; |
---|
968 | } |
---|
969 | |
---|
970 | for(uint32 spell=min_id;spell<max_id;spell++) |
---|
971 | { |
---|
972 | if (target->HasSpell(spell)) |
---|
973 | target->removeSpell(spell); |
---|
974 | else |
---|
975 | SendSysMessage(LANG_FORGET_SPELL); |
---|
976 | } |
---|
977 | |
---|
978 | return true; |
---|
979 | } |
---|
980 | |
---|
981 | bool ChatHandler::HandleCooldownCommand(const char* args) |
---|
982 | { |
---|
983 | Player* target = getSelectedPlayer(); |
---|
984 | if(!target) |
---|
985 | { |
---|
986 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
987 | SetSentErrorMessage(true); |
---|
988 | return false; |
---|
989 | } |
---|
990 | |
---|
991 | if (!*args) |
---|
992 | { |
---|
993 | target->RemoveAllSpellCooldown(); |
---|
994 | PSendSysMessage(LANG_REMOVEALL_COOLDOWN, target->GetName()); |
---|
995 | } |
---|
996 | else |
---|
997 | { |
---|
998 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form |
---|
999 | uint32 spell_id = extractSpellIdFromLink((char*)args); |
---|
1000 | if(!spell_id) |
---|
1001 | return false; |
---|
1002 | |
---|
1003 | if(!sSpellStore.LookupEntry(spell_id)) |
---|
1004 | { |
---|
1005 | PSendSysMessage(LANG_UNKNOWN_SPELL, target==m_session->GetPlayer() ? GetTrinityString(LANG_YOU) : target->GetName()); |
---|
1006 | SetSentErrorMessage(true); |
---|
1007 | return false; |
---|
1008 | } |
---|
1009 | |
---|
1010 | WorldPacket data( SMSG_CLEAR_COOLDOWN, (4+8) ); |
---|
1011 | data << uint32(spell_id); |
---|
1012 | data << uint64(target->GetGUID()); |
---|
1013 | target->GetSession()->SendPacket(&data); |
---|
1014 | target->RemoveSpellCooldown(spell_id); |
---|
1015 | PSendSysMessage(LANG_REMOVE_COOLDOWN, spell_id, target==m_session->GetPlayer() ? GetTrinityString(LANG_YOU) : target->GetName()); |
---|
1016 | } |
---|
1017 | return true; |
---|
1018 | } |
---|
1019 | |
---|
1020 | bool ChatHandler::HandleLearnAllCommand(const char* /*args*/) |
---|
1021 | { |
---|
1022 | static const char *allSpellList[] = |
---|
1023 | { |
---|
1024 | "3365", |
---|
1025 | "6233", |
---|
1026 | "6247", |
---|
1027 | "6246", |
---|
1028 | "6477", |
---|
1029 | "6478", |
---|
1030 | "22810", |
---|
1031 | "8386", |
---|
1032 | "21651", |
---|
1033 | "21652", |
---|
1034 | "522", |
---|
1035 | "7266", |
---|
1036 | "8597", |
---|
1037 | "2479", |
---|
1038 | "22027", |
---|
1039 | "6603", |
---|
1040 | "5019", |
---|
1041 | "133", |
---|
1042 | "168", |
---|
1043 | "227", |
---|
1044 | "5009", |
---|
1045 | "9078", |
---|
1046 | "668", |
---|
1047 | "203", |
---|
1048 | "20599", |
---|
1049 | "20600", |
---|
1050 | "81", |
---|
1051 | "20597", |
---|
1052 | "20598", |
---|
1053 | "20864", |
---|
1054 | "1459", |
---|
1055 | "5504", |
---|
1056 | "587", |
---|
1057 | "5143", |
---|
1058 | "118", |
---|
1059 | "5505", |
---|
1060 | "597", |
---|
1061 | "604", |
---|
1062 | "1449", |
---|
1063 | "1460", |
---|
1064 | "2855", |
---|
1065 | "1008", |
---|
1066 | "475", |
---|
1067 | "5506", |
---|
1068 | "1463", |
---|
1069 | "12824", |
---|
1070 | "8437", |
---|
1071 | "990", |
---|
1072 | "5145", |
---|
1073 | "8450", |
---|
1074 | "1461", |
---|
1075 | "759", |
---|
1076 | "8494", |
---|
1077 | "8455", |
---|
1078 | "8438", |
---|
1079 | "6127", |
---|
1080 | "8416", |
---|
1081 | "6129", |
---|
1082 | "8451", |
---|
1083 | "8495", |
---|
1084 | "8439", |
---|
1085 | "3552", |
---|
1086 | "8417", |
---|
1087 | "10138", |
---|
1088 | "12825", |
---|
1089 | "10169", |
---|
1090 | "10156", |
---|
1091 | "10144", |
---|
1092 | "10191", |
---|
1093 | "10201", |
---|
1094 | "10211", |
---|
1095 | "10053", |
---|
1096 | "10173", |
---|
1097 | "10139", |
---|
1098 | "10145", |
---|
1099 | "10192", |
---|
1100 | "10170", |
---|
1101 | "10202", |
---|
1102 | "10054", |
---|
1103 | "10174", |
---|
1104 | "10193", |
---|
1105 | "12826", |
---|
1106 | "2136", |
---|
1107 | "143", |
---|
1108 | "145", |
---|
1109 | "2137", |
---|
1110 | "2120", |
---|
1111 | "3140", |
---|
1112 | "543", |
---|
1113 | "2138", |
---|
1114 | "2948", |
---|
1115 | "8400", |
---|
1116 | "2121", |
---|
1117 | "8444", |
---|
1118 | "8412", |
---|
1119 | "8457", |
---|
1120 | "8401", |
---|
1121 | "8422", |
---|
1122 | "8445", |
---|
1123 | "8402", |
---|
1124 | "8413", |
---|
1125 | "8458", |
---|
1126 | "8423", |
---|
1127 | "8446", |
---|
1128 | "10148", |
---|
1129 | "10197", |
---|
1130 | "10205", |
---|
1131 | "10149", |
---|
1132 | "10215", |
---|
1133 | "10223", |
---|
1134 | "10206", |
---|
1135 | "10199", |
---|
1136 | "10150", |
---|
1137 | "10216", |
---|
1138 | "10207", |
---|
1139 | "10225", |
---|
1140 | "10151", |
---|
1141 | "116", |
---|
1142 | "205", |
---|
1143 | "7300", |
---|
1144 | "122", |
---|
1145 | "837", |
---|
1146 | "10", |
---|
1147 | "7301", |
---|
1148 | "7322", |
---|
1149 | "6143", |
---|
1150 | "120", |
---|
1151 | "865", |
---|
1152 | "8406", |
---|
1153 | "6141", |
---|
1154 | "7302", |
---|
1155 | "8461", |
---|
1156 | "8407", |
---|
1157 | "8492", |
---|
1158 | "8427", |
---|
1159 | "8408", |
---|
1160 | "6131", |
---|
1161 | "7320", |
---|
1162 | "10159", |
---|
1163 | "8462", |
---|
1164 | "10185", |
---|
1165 | "10179", |
---|
1166 | "10160", |
---|
1167 | "10180", |
---|
1168 | "10219", |
---|
1169 | "10186", |
---|
1170 | "10177", |
---|
1171 | "10230", |
---|
1172 | "10181", |
---|
1173 | "10161", |
---|
1174 | "10187", |
---|
1175 | "10220", |
---|
1176 | "2018", |
---|
1177 | "2663", |
---|
1178 | "12260", |
---|
1179 | "2660", |
---|
1180 | "3115", |
---|
1181 | "3326", |
---|
1182 | "2665", |
---|
1183 | "3116", |
---|
1184 | "2738", |
---|
1185 | "3293", |
---|
1186 | "2661", |
---|
1187 | "3319", |
---|
1188 | "2662", |
---|
1189 | "9983", |
---|
1190 | "8880", |
---|
1191 | "2737", |
---|
1192 | "2739", |
---|
1193 | "7408", |
---|
1194 | "3320", |
---|
1195 | "2666", |
---|
1196 | "3323", |
---|
1197 | "3324", |
---|
1198 | "3294", |
---|
1199 | "22723", |
---|
1200 | "23219", |
---|
1201 | "23220", |
---|
1202 | "23221", |
---|
1203 | "23228", |
---|
1204 | "23338", |
---|
1205 | "10788", |
---|
1206 | "10790", |
---|
1207 | "5611", |
---|
1208 | "5016", |
---|
1209 | "5609", |
---|
1210 | "2060", |
---|
1211 | "10963", |
---|
1212 | "10964", |
---|
1213 | "10965", |
---|
1214 | "22593", |
---|
1215 | "22594", |
---|
1216 | "596", |
---|
1217 | "996", |
---|
1218 | "499", |
---|
1219 | "768", |
---|
1220 | "17002", |
---|
1221 | "1448", |
---|
1222 | "1082", |
---|
1223 | "16979", |
---|
1224 | "1079", |
---|
1225 | "5215", |
---|
1226 | "20484", |
---|
1227 | "5221", |
---|
1228 | "15590", |
---|
1229 | "17007", |
---|
1230 | "6795", |
---|
1231 | "6807", |
---|
1232 | "5487", |
---|
1233 | "1446", |
---|
1234 | "1066", |
---|
1235 | "5421", |
---|
1236 | "3139", |
---|
1237 | "779", |
---|
1238 | "6811", |
---|
1239 | "6808", |
---|
1240 | "1445", |
---|
1241 | "5216", |
---|
1242 | "1737", |
---|
1243 | "5222", |
---|
1244 | "5217", |
---|
1245 | "1432", |
---|
1246 | "6812", |
---|
1247 | "9492", |
---|
1248 | "5210", |
---|
1249 | "3030", |
---|
1250 | "1441", |
---|
1251 | "783", |
---|
1252 | "6801", |
---|
1253 | "20739", |
---|
1254 | "8944", |
---|
1255 | "9491", |
---|
1256 | "22569", |
---|
1257 | "5226", |
---|
1258 | "6786", |
---|
1259 | "1433", |
---|
1260 | "8973", |
---|
1261 | "1828", |
---|
1262 | "9495", |
---|
1263 | "9006", |
---|
1264 | "6794", |
---|
1265 | "8993", |
---|
1266 | "5203", |
---|
1267 | "16914", |
---|
1268 | "6784", |
---|
1269 | "9635", |
---|
1270 | "22830", |
---|
1271 | "20722", |
---|
1272 | "9748", |
---|
1273 | "6790", |
---|
1274 | "9753", |
---|
1275 | "9493", |
---|
1276 | "9752", |
---|
1277 | "9831", |
---|
1278 | "9825", |
---|
1279 | "9822", |
---|
1280 | "5204", |
---|
1281 | "5401", |
---|
1282 | "22831", |
---|
1283 | "6793", |
---|
1284 | "9845", |
---|
1285 | "17401", |
---|
1286 | "9882", |
---|
1287 | "9868", |
---|
1288 | "20749", |
---|
1289 | "9893", |
---|
1290 | "9899", |
---|
1291 | "9895", |
---|
1292 | "9832", |
---|
1293 | "9902", |
---|
1294 | "9909", |
---|
1295 | "22832", |
---|
1296 | "9828", |
---|
1297 | "9851", |
---|
1298 | "9883", |
---|
1299 | "9869", |
---|
1300 | "17406", |
---|
1301 | "17402", |
---|
1302 | "9914", |
---|
1303 | "20750", |
---|
1304 | "9897", |
---|
1305 | "9848", |
---|
1306 | "3127", |
---|
1307 | "107", |
---|
1308 | "204", |
---|
1309 | "9116", |
---|
1310 | "2457", |
---|
1311 | "78", |
---|
1312 | "18848", |
---|
1313 | "331", |
---|
1314 | "403", |
---|
1315 | "2098", |
---|
1316 | "1752", |
---|
1317 | "11278", |
---|
1318 | "11288", |
---|
1319 | "11284", |
---|
1320 | "6461", |
---|
1321 | "2344", |
---|
1322 | "2345", |
---|
1323 | "6463", |
---|
1324 | "2346", |
---|
1325 | "2352", |
---|
1326 | "775", |
---|
1327 | "1434", |
---|
1328 | "1612", |
---|
1329 | "71", |
---|
1330 | "2468", |
---|
1331 | "2458", |
---|
1332 | "2467", |
---|
1333 | "7164", |
---|
1334 | "7178", |
---|
1335 | "7367", |
---|
1336 | "7376", |
---|
1337 | "7381", |
---|
1338 | "21156", |
---|
1339 | "5209", |
---|
1340 | "3029", |
---|
1341 | "5201", |
---|
1342 | "9849", |
---|
1343 | "9850", |
---|
1344 | "20719", |
---|
1345 | "22568", |
---|
1346 | "22827", |
---|
1347 | "22828", |
---|
1348 | "22829", |
---|
1349 | "6809", |
---|
1350 | "8972", |
---|
1351 | "9005", |
---|
1352 | "9823", |
---|
1353 | "9827", |
---|
1354 | "6783", |
---|
1355 | "9913", |
---|
1356 | "6785", |
---|
1357 | "6787", |
---|
1358 | "9866", |
---|
1359 | "9867", |
---|
1360 | "9894", |
---|
1361 | "9896", |
---|
1362 | "6800", |
---|
1363 | "8992", |
---|
1364 | "9829", |
---|
1365 | "9830", |
---|
1366 | "780", |
---|
1367 | "769", |
---|
1368 | "6749", |
---|
1369 | "6750", |
---|
1370 | "9755", |
---|
1371 | "9754", |
---|
1372 | "9908", |
---|
1373 | "20745", |
---|
1374 | "20742", |
---|
1375 | "20747", |
---|
1376 | "20748", |
---|
1377 | "9746", |
---|
1378 | "9745", |
---|
1379 | "9880", |
---|
1380 | "9881", |
---|
1381 | "5391", |
---|
1382 | "842", |
---|
1383 | "3025", |
---|
1384 | "3031", |
---|
1385 | "3287", |
---|
1386 | "3329", |
---|
1387 | "1945", |
---|
1388 | "3559", |
---|
1389 | "4933", |
---|
1390 | "4934", |
---|
1391 | "4935", |
---|
1392 | "4936", |
---|
1393 | "5142", |
---|
1394 | "5390", |
---|
1395 | "5392", |
---|
1396 | "5404", |
---|
1397 | "5420", |
---|
1398 | "6405", |
---|
1399 | "7293", |
---|
1400 | "7965", |
---|
1401 | "8041", |
---|
1402 | "8153", |
---|
1403 | "9033", |
---|
1404 | "9034", |
---|
1405 | //"9036", problems with ghost state |
---|
1406 | "16421", |
---|
1407 | "21653", |
---|
1408 | "22660", |
---|
1409 | "5225", |
---|
1410 | "9846", |
---|
1411 | "2426", |
---|
1412 | "5916", |
---|
1413 | "6634", |
---|
1414 | //"6718", phasing stealth, annoing for learn all case. |
---|
1415 | "6719", |
---|
1416 | "8822", |
---|
1417 | "9591", |
---|
1418 | "9590", |
---|
1419 | "10032", |
---|
1420 | "17746", |
---|
1421 | "17747", |
---|
1422 | "8203", |
---|
1423 | "11392", |
---|
1424 | "12495", |
---|
1425 | "16380", |
---|
1426 | "23452", |
---|
1427 | "4079", |
---|
1428 | "4996", |
---|
1429 | "4997", |
---|
1430 | "4998", |
---|
1431 | "4999", |
---|
1432 | "5000", |
---|
1433 | "6348", |
---|
1434 | "6349", |
---|
1435 | "6481", |
---|
1436 | "6482", |
---|
1437 | "6483", |
---|
1438 | "6484", |
---|
1439 | "11362", |
---|
1440 | "11410", |
---|
1441 | "11409", |
---|
1442 | "12510", |
---|
1443 | "12509", |
---|
1444 | "12885", |
---|
1445 | "13142", |
---|
1446 | "21463", |
---|
1447 | "23460", |
---|
1448 | "11421", |
---|
1449 | "11416", |
---|
1450 | "11418", |
---|
1451 | "1851", |
---|
1452 | "10059", |
---|
1453 | "11423", |
---|
1454 | "11417", |
---|
1455 | "11422", |
---|
1456 | "11419", |
---|
1457 | "11424", |
---|
1458 | "11420", |
---|
1459 | "27", |
---|
1460 | "31", |
---|
1461 | "33", |
---|
1462 | "34", |
---|
1463 | "35", |
---|
1464 | "15125", |
---|
1465 | "21127", |
---|
1466 | "22950", |
---|
1467 | "1180", |
---|
1468 | "201", |
---|
1469 | "12593", |
---|
1470 | "12842", |
---|
1471 | "16770", |
---|
1472 | "6057", |
---|
1473 | "12051", |
---|
1474 | "18468", |
---|
1475 | "12606", |
---|
1476 | "12605", |
---|
1477 | "18466", |
---|
1478 | "12502", |
---|
1479 | "12043", |
---|
1480 | "15060", |
---|
1481 | "12042", |
---|
1482 | "12341", |
---|
1483 | "12848", |
---|
1484 | "12344", |
---|
1485 | "12353", |
---|
1486 | "18460", |
---|
1487 | "11366", |
---|
1488 | "12350", |
---|
1489 | "12352", |
---|
1490 | "13043", |
---|
1491 | "11368", |
---|
1492 | "11113", |
---|
1493 | "12400", |
---|
1494 | "11129", |
---|
1495 | "16766", |
---|
1496 | "12573", |
---|
1497 | "15053", |
---|
1498 | "12580", |
---|
1499 | "12475", |
---|
1500 | "12472", |
---|
1501 | "12953", |
---|
1502 | "12488", |
---|
1503 | "11189", |
---|
1504 | "12985", |
---|
1505 | "12519", |
---|
1506 | "16758", |
---|
1507 | "11958", |
---|
1508 | "12490", |
---|
1509 | "11426", |
---|
1510 | "3565", |
---|
1511 | "3562", |
---|
1512 | "18960", |
---|
1513 | "3567", |
---|
1514 | "3561", |
---|
1515 | "3566", |
---|
1516 | "3563", |
---|
1517 | "1953", |
---|
1518 | "2139", |
---|
1519 | "12505", |
---|
1520 | "13018", |
---|
1521 | "12522", |
---|
1522 | "12523", |
---|
1523 | "5146", |
---|
1524 | "5144", |
---|
1525 | "5148", |
---|
1526 | "8419", |
---|
1527 | "8418", |
---|
1528 | "10213", |
---|
1529 | "10212", |
---|
1530 | "10157", |
---|
1531 | "12524", |
---|
1532 | "13019", |
---|
1533 | "12525", |
---|
1534 | "13020", |
---|
1535 | "12526", |
---|
1536 | "13021", |
---|
1537 | "18809", |
---|
1538 | "13031", |
---|
1539 | "13032", |
---|
1540 | "13033", |
---|
1541 | "4036", |
---|
1542 | "3920", |
---|
1543 | "3919", |
---|
1544 | "3918", |
---|
1545 | "7430", |
---|
1546 | "3922", |
---|
1547 | "3923", |
---|
1548 | "7411", |
---|
1549 | "7418", |
---|
1550 | "7421", |
---|
1551 | "13262", |
---|
1552 | "7412", |
---|
1553 | "7415", |
---|
1554 | "7413", |
---|
1555 | "7416", |
---|
1556 | "13920", |
---|
1557 | "13921", |
---|
1558 | "7745", |
---|
1559 | "7779", |
---|
1560 | "7428", |
---|
1561 | "7457", |
---|
1562 | "7857", |
---|
1563 | "7748", |
---|
1564 | "7426", |
---|
1565 | "13421", |
---|
1566 | "7454", |
---|
1567 | "13378", |
---|
1568 | "7788", |
---|
1569 | "14807", |
---|
1570 | "14293", |
---|
1571 | "7795", |
---|
1572 | "6296", |
---|
1573 | "20608", |
---|
1574 | "755", |
---|
1575 | "444", |
---|
1576 | "427", |
---|
1577 | "428", |
---|
1578 | "442", |
---|
1579 | "447", |
---|
1580 | "3578", |
---|
1581 | "3581", |
---|
1582 | "19027", |
---|
1583 | "3580", |
---|
1584 | "665", |
---|
1585 | "3579", |
---|
1586 | "3577", |
---|
1587 | "6755", |
---|
1588 | "3576", |
---|
1589 | "2575", |
---|
1590 | "2577", |
---|
1591 | "2578", |
---|
1592 | "2579", |
---|
1593 | "2580", |
---|
1594 | "2656", |
---|
1595 | "2657", |
---|
1596 | "2576", |
---|
1597 | "3564", |
---|
1598 | "10248", |
---|
1599 | "8388", |
---|
1600 | "2659", |
---|
1601 | "14891", |
---|
1602 | "3308", |
---|
1603 | "3307", |
---|
1604 | "10097", |
---|
1605 | "2658", |
---|
1606 | "3569", |
---|
1607 | "16153", |
---|
1608 | "3304", |
---|
1609 | "10098", |
---|
1610 | "4037", |
---|
1611 | "3929", |
---|
1612 | "3931", |
---|
1613 | "3926", |
---|
1614 | "3924", |
---|
1615 | "3930", |
---|
1616 | "3977", |
---|
1617 | "3925", |
---|
1618 | "136", |
---|
1619 | "228", |
---|
1620 | "5487", |
---|
1621 | "43", |
---|
1622 | "202", |
---|
1623 | "0" |
---|
1624 | }; |
---|
1625 | |
---|
1626 | int loop = 0; |
---|
1627 | while(strcmp(allSpellList[loop], "0")) |
---|
1628 | { |
---|
1629 | uint32 spell = atol((char*)allSpellList[loop++]); |
---|
1630 | |
---|
1631 | if (m_session->GetPlayer()->HasSpell(spell)) |
---|
1632 | continue; |
---|
1633 | |
---|
1634 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); |
---|
1635 | if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) |
---|
1636 | { |
---|
1637 | PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); |
---|
1638 | continue; |
---|
1639 | } |
---|
1640 | |
---|
1641 | m_session->GetPlayer()->learnSpell(spell); |
---|
1642 | } |
---|
1643 | |
---|
1644 | SendSysMessage(LANG_COMMAND_LEARN_MANY_SPELLS); |
---|
1645 | |
---|
1646 | return true; |
---|
1647 | } |
---|
1648 | |
---|
1649 | bool ChatHandler::HandleLearnAllGMCommand(const char* /*args*/) |
---|
1650 | { |
---|
1651 | static const char *gmSpellList[] = |
---|
1652 | { |
---|
1653 | "24347", // Become A Fish, No Breath Bar |
---|
1654 | "35132", // Visual Boom |
---|
1655 | "38488", // Attack 4000-8000 AOE |
---|
1656 | "38795", // Attack 2000 AOE + Slow Down 90% |
---|
1657 | "15712", // Attack 200 |
---|
1658 | "1852", // GM Spell Silence |
---|
1659 | "31899", // Kill |
---|
1660 | "31924", // Kill |
---|
1661 | "29878", // Kill My Self |
---|
1662 | "26644", // More Kill |
---|
1663 | |
---|
1664 | "28550", //Invisible 24 |
---|
1665 | "23452", //Invisible + Target |
---|
1666 | "0" |
---|
1667 | }; |
---|
1668 | |
---|
1669 | uint16 gmSpellIter = 0; |
---|
1670 | while( strcmp(gmSpellList[gmSpellIter], "0") ) |
---|
1671 | { |
---|
1672 | uint32 spell = atol((char*)gmSpellList[gmSpellIter++]); |
---|
1673 | |
---|
1674 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); |
---|
1675 | if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) |
---|
1676 | { |
---|
1677 | PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); |
---|
1678 | continue; |
---|
1679 | } |
---|
1680 | |
---|
1681 | m_session->GetPlayer()->learnSpell(spell); |
---|
1682 | } |
---|
1683 | |
---|
1684 | SendSysMessage(LANG_LEARNING_GM_SKILLS); |
---|
1685 | return true; |
---|
1686 | } |
---|
1687 | |
---|
1688 | bool ChatHandler::HandleLearnAllMyClassCommand(const char* /*args*/) |
---|
1689 | { |
---|
1690 | HandleLearnAllMySpellsCommand(""); |
---|
1691 | HandleLearnAllMyTalentsCommand(""); |
---|
1692 | return true; |
---|
1693 | } |
---|
1694 | |
---|
1695 | bool ChatHandler::HandleLearnAllMySpellsCommand(const char* /*args*/) |
---|
1696 | { |
---|
1697 | ChrClassesEntry const* clsEntry = sChrClassesStore.LookupEntry(m_session->GetPlayer()->getClass()); |
---|
1698 | if(!clsEntry) |
---|
1699 | return true; |
---|
1700 | uint32 family = clsEntry->spellfamily; |
---|
1701 | |
---|
1702 | for (uint32 i = 0; i < sSpellStore.GetNumRows(); i++) |
---|
1703 | { |
---|
1704 | SpellEntry const *spellInfo = sSpellStore.LookupEntry(i); |
---|
1705 | if(!spellInfo) |
---|
1706 | continue; |
---|
1707 | |
---|
1708 | // skip wrong class/race skills |
---|
1709 | if(!m_session->GetPlayer()->IsSpellFitByClassAndRace(spellInfo->Id)) |
---|
1710 | continue; |
---|
1711 | |
---|
1712 | // skip other spell families |
---|
1713 | if( spellInfo->SpellFamilyName != family) |
---|
1714 | continue; |
---|
1715 | |
---|
1716 | //TODO: skip triggered spells |
---|
1717 | |
---|
1718 | // skip spells with first rank learned as talent (and all talents then also) |
---|
1719 | uint32 first_rank = spellmgr.GetFirstSpellInChain(spellInfo->Id); |
---|
1720 | if(GetTalentSpellCost(first_rank) > 0 ) |
---|
1721 | continue; |
---|
1722 | |
---|
1723 | // skip broken spells |
---|
1724 | if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) |
---|
1725 | continue; |
---|
1726 | |
---|
1727 | m_session->GetPlayer()->learnSpell(i); |
---|
1728 | } |
---|
1729 | |
---|
1730 | SendSysMessage(LANG_COMMAND_LEARN_CLASS_SPELLS); |
---|
1731 | return true; |
---|
1732 | } |
---|
1733 | |
---|
1734 | static void learnAllHighRanks(Player* player, uint32 spellid) |
---|
1735 | { |
---|
1736 | SpellChainMapNext const& nextMap = spellmgr.GetSpellChainNext(); |
---|
1737 | for(SpellChainMapNext::const_iterator itr = nextMap.lower_bound(spellid); itr != nextMap.upper_bound(spellid); ++itr) |
---|
1738 | { |
---|
1739 | player->learnSpell(itr->second); |
---|
1740 | learnAllHighRanks(player,itr->second); |
---|
1741 | } |
---|
1742 | } |
---|
1743 | |
---|
1744 | bool ChatHandler::HandleLearnAllMyTalentsCommand(const char* /*args*/) |
---|
1745 | { |
---|
1746 | Player* player = m_session->GetPlayer(); |
---|
1747 | uint32 classMask = player->getClassMask(); |
---|
1748 | |
---|
1749 | for (uint32 i = 0; i < sTalentStore.GetNumRows(); i++) |
---|
1750 | { |
---|
1751 | TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); |
---|
1752 | if(!talentInfo) |
---|
1753 | continue; |
---|
1754 | |
---|
1755 | TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); |
---|
1756 | if(!talentTabInfo) |
---|
1757 | continue; |
---|
1758 | |
---|
1759 | if( (classMask & talentTabInfo->ClassMask) == 0 ) |
---|
1760 | continue; |
---|
1761 | |
---|
1762 | // search highest talent rank |
---|
1763 | uint32 spellid = 0; |
---|
1764 | int rank = 4; |
---|
1765 | for(; rank >= 0; --rank) |
---|
1766 | { |
---|
1767 | if(talentInfo->RankID[rank]!=0) |
---|
1768 | { |
---|
1769 | spellid = talentInfo->RankID[rank]; |
---|
1770 | break; |
---|
1771 | } |
---|
1772 | } |
---|
1773 | |
---|
1774 | if(!spellid) // ??? none spells in telent |
---|
1775 | continue; |
---|
1776 | |
---|
1777 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid); |
---|
1778 | if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) |
---|
1779 | continue; |
---|
1780 | |
---|
1781 | // learn highest rank of talent |
---|
1782 | player->learnSpell(spellid); |
---|
1783 | |
---|
1784 | // and learn all non-talent spell ranks (recursive by tree) |
---|
1785 | learnAllHighRanks(player,spellid); |
---|
1786 | } |
---|
1787 | |
---|
1788 | SendSysMessage(LANG_COMMAND_LEARN_CLASS_TALENTS); |
---|
1789 | return true; |
---|
1790 | } |
---|
1791 | |
---|
1792 | bool ChatHandler::HandleLearnAllLangCommand(const char* /*args*/) |
---|
1793 | { |
---|
1794 | // skipping UNIVERSAL language (0) |
---|
1795 | for(int i = 1; i < LANGUAGES_COUNT; ++i) |
---|
1796 | m_session->GetPlayer()->learnSpell(lang_description[i].spell_id); |
---|
1797 | |
---|
1798 | SendSysMessage(LANG_COMMAND_LEARN_ALL_LANG); |
---|
1799 | return true; |
---|
1800 | } |
---|
1801 | |
---|
1802 | bool ChatHandler::HandleLearnAllDefaultCommand(const char* args) |
---|
1803 | { |
---|
1804 | char* pName = strtok((char*)args, ""); |
---|
1805 | Player *player = NULL; |
---|
1806 | if (pName) |
---|
1807 | { |
---|
1808 | std::string name = pName; |
---|
1809 | |
---|
1810 | if(!normalizePlayerName(name)) |
---|
1811 | { |
---|
1812 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
1813 | SetSentErrorMessage(true); |
---|
1814 | return false; |
---|
1815 | } |
---|
1816 | |
---|
1817 | player = objmgr.GetPlayer(name.c_str()); |
---|
1818 | } |
---|
1819 | else |
---|
1820 | player = getSelectedPlayer(); |
---|
1821 | |
---|
1822 | if(!player) |
---|
1823 | { |
---|
1824 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
1825 | SetSentErrorMessage(true); |
---|
1826 | return false; |
---|
1827 | } |
---|
1828 | |
---|
1829 | player->learnDefaultSpells(); |
---|
1830 | player->learnQuestRewardedSpells(); |
---|
1831 | |
---|
1832 | PSendSysMessage(LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST,player->GetName()); |
---|
1833 | return true; |
---|
1834 | } |
---|
1835 | |
---|
1836 | bool ChatHandler::HandleLearnCommand(const char* args) |
---|
1837 | { |
---|
1838 | Player* targetPlayer = getSelectedPlayer(); |
---|
1839 | |
---|
1840 | if(!targetPlayer) |
---|
1841 | { |
---|
1842 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
1843 | SetSentErrorMessage(true); |
---|
1844 | return false; |
---|
1845 | } |
---|
1846 | |
---|
1847 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form |
---|
1848 | uint32 spell = extractSpellIdFromLink((char*)args); |
---|
1849 | if(!spell || !sSpellStore.LookupEntry(spell)) |
---|
1850 | return false; |
---|
1851 | |
---|
1852 | if (targetPlayer->HasSpell(spell)) |
---|
1853 | { |
---|
1854 | if(targetPlayer == m_session->GetPlayer()) |
---|
1855 | SendSysMessage(LANG_YOU_KNOWN_SPELL); |
---|
1856 | else |
---|
1857 | PSendSysMessage(LANG_TARGET_KNOWN_SPELL,targetPlayer->GetName()); |
---|
1858 | SetSentErrorMessage(true); |
---|
1859 | return false; |
---|
1860 | } |
---|
1861 | |
---|
1862 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); |
---|
1863 | if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) |
---|
1864 | { |
---|
1865 | PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); |
---|
1866 | SetSentErrorMessage(true); |
---|
1867 | return false; |
---|
1868 | } |
---|
1869 | |
---|
1870 | targetPlayer->learnSpell(spell); |
---|
1871 | |
---|
1872 | return true; |
---|
1873 | } |
---|
1874 | |
---|
1875 | bool ChatHandler::HandleAddItemCommand(const char* args) |
---|
1876 | { |
---|
1877 | if (!*args) |
---|
1878 | return false; |
---|
1879 | |
---|
1880 | uint32 itemId = 0; |
---|
1881 | |
---|
1882 | if(args[0]=='[') // [name] manual form |
---|
1883 | { |
---|
1884 | char* citemName = citemName = strtok((char*)args, "]"); |
---|
1885 | |
---|
1886 | if(citemName && citemName[0]) |
---|
1887 | { |
---|
1888 | std::string itemName = citemName+1; |
---|
1889 | WorldDatabase.escape_string(itemName); |
---|
1890 | QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE name = '%s'", itemName.c_str()); |
---|
1891 | if (!result) |
---|
1892 | { |
---|
1893 | PSendSysMessage(LANG_COMMAND_COULDNOTFIND, citemName+1); |
---|
1894 | SetSentErrorMessage(true); |
---|
1895 | return false; |
---|
1896 | } |
---|
1897 | itemId = result->Fetch()->GetUInt16(); |
---|
1898 | delete result; |
---|
1899 | } |
---|
1900 | else |
---|
1901 | return false; |
---|
1902 | } |
---|
1903 | else // item_id or [name] Shift-click form |color|Hitem:item_id:0:0:0|h[name]|h|r |
---|
1904 | { |
---|
1905 | char* cId = extractKeyFromLink((char*)args,"Hitem"); |
---|
1906 | if(!cId) |
---|
1907 | return false; |
---|
1908 | itemId = atol(cId); |
---|
1909 | } |
---|
1910 | |
---|
1911 | char* ccount = strtok(NULL, " "); |
---|
1912 | |
---|
1913 | int32 count = 1; |
---|
1914 | |
---|
1915 | if (ccount) |
---|
1916 | count = strtol(ccount, NULL, 10); |
---|
1917 | |
---|
1918 | if (count == 0) |
---|
1919 | count = 1; |
---|
1920 | |
---|
1921 | Player* pl = m_session->GetPlayer(); |
---|
1922 | Player* plTarget = getSelectedPlayer(); |
---|
1923 | if(!plTarget) |
---|
1924 | plTarget = pl; |
---|
1925 | |
---|
1926 | sLog.outDetail(GetTrinityString(LANG_ADDITEM), itemId, count); |
---|
1927 | |
---|
1928 | ItemPrototype const *pProto = objmgr.GetItemPrototype(itemId); |
---|
1929 | if(!pProto) |
---|
1930 | { |
---|
1931 | PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId); |
---|
1932 | SetSentErrorMessage(true); |
---|
1933 | return false; |
---|
1934 | } |
---|
1935 | |
---|
1936 | //Subtract |
---|
1937 | if (count < 0) |
---|
1938 | { |
---|
1939 | plTarget->DestroyItemCount(itemId, -count, true, false); |
---|
1940 | PSendSysMessage(LANG_REMOVEITEM, itemId, -count, plTarget->GetName()); |
---|
1941 | return true; |
---|
1942 | } |
---|
1943 | |
---|
1944 | //Adding items |
---|
1945 | uint32 noSpaceForCount = 0; |
---|
1946 | |
---|
1947 | // check space and find places |
---|
1948 | ItemPosCountVec dest; |
---|
1949 | uint8 msg = plTarget->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount ); |
---|
1950 | if( msg != EQUIP_ERR_OK ) // convert to possible store amount |
---|
1951 | count -= noSpaceForCount; |
---|
1952 | |
---|
1953 | if( count == 0 || dest.empty()) // can't add any |
---|
1954 | { |
---|
1955 | PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount ); |
---|
1956 | SetSentErrorMessage(true); |
---|
1957 | return false; |
---|
1958 | } |
---|
1959 | |
---|
1960 | Item* item = plTarget->StoreNewItem( dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); |
---|
1961 | |
---|
1962 | // remove binding (let GM give it to another player later) |
---|
1963 | if(pl==plTarget) |
---|
1964 | for(ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) |
---|
1965 | if(Item* item1 = pl->GetItemByPos(itr->pos)) |
---|
1966 | item1->SetBinding( false ); |
---|
1967 | |
---|
1968 | if(count > 0 && item) |
---|
1969 | { |
---|
1970 | pl->SendNewItem(item,count,false,true); |
---|
1971 | if(pl!=plTarget) |
---|
1972 | plTarget->SendNewItem(item,count,true,false); |
---|
1973 | } |
---|
1974 | |
---|
1975 | if(noSpaceForCount > 0) |
---|
1976 | PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); |
---|
1977 | |
---|
1978 | return true; |
---|
1979 | } |
---|
1980 | |
---|
1981 | bool ChatHandler::HandleAddItemSetCommand(const char* args) |
---|
1982 | { |
---|
1983 | if (!*args) |
---|
1984 | return false; |
---|
1985 | |
---|
1986 | char* cId = extractKeyFromLink((char*)args,"Hitemset"); // number or [name] Shift-click form |color|Hitemset:itemset_id|h[name]|h|r |
---|
1987 | if (!cId) |
---|
1988 | return false; |
---|
1989 | |
---|
1990 | uint32 itemsetId = atol(cId); |
---|
1991 | |
---|
1992 | // prevent generation all items with itemset field value '0' |
---|
1993 | if (itemsetId == 0) |
---|
1994 | { |
---|
1995 | PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND,itemsetId); |
---|
1996 | SetSentErrorMessage(true); |
---|
1997 | return false; |
---|
1998 | } |
---|
1999 | |
---|
2000 | Player* pl = m_session->GetPlayer(); |
---|
2001 | Player* plTarget = getSelectedPlayer(); |
---|
2002 | if(!plTarget) |
---|
2003 | plTarget = pl; |
---|
2004 | |
---|
2005 | sLog.outDetail(GetTrinityString(LANG_ADDITEMSET), itemsetId); |
---|
2006 | |
---|
2007 | QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE itemset = %u",itemsetId); |
---|
2008 | |
---|
2009 | if(!result) |
---|
2010 | { |
---|
2011 | PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND,itemsetId); |
---|
2012 | |
---|
2013 | SetSentErrorMessage(true); |
---|
2014 | return false; |
---|
2015 | } |
---|
2016 | |
---|
2017 | do |
---|
2018 | { |
---|
2019 | Field *fields = result->Fetch(); |
---|
2020 | uint32 itemId = fields[0].GetUInt32(); |
---|
2021 | |
---|
2022 | ItemPosCountVec dest; |
---|
2023 | uint8 msg = plTarget->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, itemId, 1 ); |
---|
2024 | if( msg == EQUIP_ERR_OK ) |
---|
2025 | { |
---|
2026 | Item* item = plTarget->StoreNewItem( dest, itemId, true); |
---|
2027 | |
---|
2028 | // remove binding (let GM give it to another player later) |
---|
2029 | if(pl==plTarget) |
---|
2030 | item->SetBinding( false ); |
---|
2031 | |
---|
2032 | pl->SendNewItem(item,1,false,true); |
---|
2033 | if(pl!=plTarget) |
---|
2034 | plTarget->SendNewItem(item,1,true,false); |
---|
2035 | } |
---|
2036 | else |
---|
2037 | { |
---|
2038 | pl->SendEquipError( msg, NULL, NULL ); |
---|
2039 | PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, 1); |
---|
2040 | } |
---|
2041 | |
---|
2042 | }while( result->NextRow() ); |
---|
2043 | |
---|
2044 | delete result; |
---|
2045 | |
---|
2046 | return true; |
---|
2047 | } |
---|
2048 | |
---|
2049 | bool ChatHandler::HandleListItemCommand(const char* args) |
---|
2050 | { |
---|
2051 | if(!*args) |
---|
2052 | return false; |
---|
2053 | |
---|
2054 | char* cId = extractKeyFromLink((char*)args,"Hitem"); |
---|
2055 | if(!cId) |
---|
2056 | return false; |
---|
2057 | |
---|
2058 | uint32 item_id = atol(cId); |
---|
2059 | if(!item_id) |
---|
2060 | { |
---|
2061 | PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id); |
---|
2062 | SetSentErrorMessage(true); |
---|
2063 | return false; |
---|
2064 | } |
---|
2065 | |
---|
2066 | ItemPrototype const* itemProto = objmgr.GetItemPrototype(item_id); |
---|
2067 | if(!itemProto) |
---|
2068 | { |
---|
2069 | PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, item_id); |
---|
2070 | SetSentErrorMessage(true); |
---|
2071 | return false; |
---|
2072 | } |
---|
2073 | |
---|
2074 | char* c_count = strtok(NULL, " "); |
---|
2075 | int count = c_count ? atol(c_count) : 10; |
---|
2076 | |
---|
2077 | if(count < 0) |
---|
2078 | return false; |
---|
2079 | |
---|
2080 | QueryResult *result; |
---|
2081 | |
---|
2082 | // inventory case |
---|
2083 | uint32 inv_count = 0; |
---|
2084 | result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM character_inventory WHERE item_template='%u'",item_id); |
---|
2085 | if(result) |
---|
2086 | { |
---|
2087 | inv_count = (*result)[0].GetUInt32(); |
---|
2088 | delete result; |
---|
2089 | } |
---|
2090 | |
---|
2091 | result=CharacterDatabase.PQuery( |
---|
2092 | // 0 1 2 3 4 5 |
---|
2093 | "SELECT ci.item, cibag.slot AS bag, ci.slot, ci.guid, characters.account,characters.name " |
---|
2094 | "FROM character_inventory AS ci LEFT JOIN character_inventory AS cibag ON (cibag.item=ci.bag),characters " |
---|
2095 | "WHERE ci.item_template='%u' AND ci.guid = characters.guid LIMIT %u ", |
---|
2096 | item_id,uint32(count)); |
---|
2097 | |
---|
2098 | if(result) |
---|
2099 | { |
---|
2100 | do |
---|
2101 | { |
---|
2102 | Field *fields = result->Fetch(); |
---|
2103 | uint32 item_guid = fields[0].GetUInt32(); |
---|
2104 | uint32 item_bag = fields[1].GetUInt32(); |
---|
2105 | uint32 item_slot = fields[2].GetUInt32(); |
---|
2106 | uint32 owner_guid = fields[3].GetUInt32(); |
---|
2107 | uint32 owner_acc = fields[4].GetUInt32(); |
---|
2108 | std::string owner_name = fields[5].GetCppString(); |
---|
2109 | |
---|
2110 | char const* item_pos = 0; |
---|
2111 | if(Player::IsEquipmentPos(item_bag,item_slot)) |
---|
2112 | item_pos = "[equipped]"; |
---|
2113 | else if(Player::IsInventoryPos(item_bag,item_slot)) |
---|
2114 | item_pos = "[in inventory]"; |
---|
2115 | else if(Player::IsBankPos(item_bag,item_slot)) |
---|
2116 | item_pos = "[in bank]"; |
---|
2117 | else |
---|
2118 | item_pos = ""; |
---|
2119 | |
---|
2120 | PSendSysMessage(LANG_ITEMLIST_SLOT, |
---|
2121 | item_guid,owner_name.c_str(),owner_guid,owner_acc,item_pos); |
---|
2122 | } while (result->NextRow()); |
---|
2123 | |
---|
2124 | int64 res_count = result->GetRowCount(); |
---|
2125 | |
---|
2126 | delete result; |
---|
2127 | |
---|
2128 | if(count > res_count) |
---|
2129 | count-=res_count; |
---|
2130 | else if(count) |
---|
2131 | count = 0; |
---|
2132 | } |
---|
2133 | |
---|
2134 | // mail case |
---|
2135 | uint32 mail_count = 0; |
---|
2136 | result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM mail_items WHERE item_template='%u'", item_id); |
---|
2137 | if(result) |
---|
2138 | { |
---|
2139 | mail_count = (*result)[0].GetUInt32(); |
---|
2140 | delete result; |
---|
2141 | } |
---|
2142 | |
---|
2143 | if(count > 0) |
---|
2144 | { |
---|
2145 | result=CharacterDatabase.PQuery( |
---|
2146 | // 0 1 2 3 4 5 6 |
---|
2147 | "SELECT mail_items.item_guid, mail.sender, mail.receiver, char_s.account, char_s.name, char_r.account, char_r.name " |
---|
2148 | "FROM mail,mail_items,characters as char_s,characters as char_r " |
---|
2149 | "WHERE mail_items.item_template='%u' AND char_s.guid = mail.sender AND char_r.guid = mail.receiver AND mail.id=mail_items.mail_id LIMIT %u", |
---|
2150 | item_id,uint32(count)); |
---|
2151 | } |
---|
2152 | else |
---|
2153 | result = NULL; |
---|
2154 | |
---|
2155 | if(result) |
---|
2156 | { |
---|
2157 | do |
---|
2158 | { |
---|
2159 | Field *fields = result->Fetch(); |
---|
2160 | uint32 item_guid = fields[0].GetUInt32(); |
---|
2161 | uint32 item_s = fields[1].GetUInt32(); |
---|
2162 | uint32 item_r = fields[2].GetUInt32(); |
---|
2163 | uint32 item_s_acc = fields[3].GetUInt32(); |
---|
2164 | std::string item_s_name = fields[4].GetCppString(); |
---|
2165 | uint32 item_r_acc = fields[5].GetUInt32(); |
---|
2166 | std::string item_r_name = fields[6].GetCppString(); |
---|
2167 | |
---|
2168 | char const* item_pos = "[in mail]"; |
---|
2169 | |
---|
2170 | PSendSysMessage(LANG_ITEMLIST_MAIL, |
---|
2171 | item_guid,item_s_name.c_str(),item_s,item_s_acc,item_r_name.c_str(),item_r,item_r_acc,item_pos); |
---|
2172 | } while (result->NextRow()); |
---|
2173 | |
---|
2174 | int64 res_count = result->GetRowCount(); |
---|
2175 | |
---|
2176 | delete result; |
---|
2177 | |
---|
2178 | if(count > res_count) |
---|
2179 | count-=res_count; |
---|
2180 | else if(count) |
---|
2181 | count = 0; |
---|
2182 | } |
---|
2183 | |
---|
2184 | // auction case |
---|
2185 | uint32 auc_count = 0; |
---|
2186 | result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM auctionhouse WHERE item_template='%u'",item_id); |
---|
2187 | if(result) |
---|
2188 | { |
---|
2189 | auc_count = (*result)[0].GetUInt32(); |
---|
2190 | delete result; |
---|
2191 | } |
---|
2192 | |
---|
2193 | if(count > 0) |
---|
2194 | { |
---|
2195 | result=CharacterDatabase.PQuery( |
---|
2196 | // 0 1 2 3 |
---|
2197 | "SELECT auctionhouse.itemguid, auctionhouse.itemowner, characters.account, characters.name " |
---|
2198 | "FROM auctionhouse,characters WHERE auctionhouse.item_template='%u' AND characters.guid = auctionhouse.itemowner LIMIT %u", |
---|
2199 | item_id,uint32(count)); |
---|
2200 | } |
---|
2201 | else |
---|
2202 | result = NULL; |
---|
2203 | |
---|
2204 | if(result) |
---|
2205 | { |
---|
2206 | do |
---|
2207 | { |
---|
2208 | Field *fields = result->Fetch(); |
---|
2209 | uint32 item_guid = fields[0].GetUInt32(); |
---|
2210 | uint32 owner = fields[1].GetUInt32(); |
---|
2211 | uint32 owner_acc = fields[2].GetUInt32(); |
---|
2212 | std::string owner_name = fields[3].GetCppString(); |
---|
2213 | |
---|
2214 | char const* item_pos = "[in auction]"; |
---|
2215 | |
---|
2216 | PSendSysMessage(LANG_ITEMLIST_AUCTION, item_guid, owner_name.c_str(), owner, owner_acc,item_pos); |
---|
2217 | } while (result->NextRow()); |
---|
2218 | |
---|
2219 | delete result; |
---|
2220 | } |
---|
2221 | |
---|
2222 | // guild bank case |
---|
2223 | uint32 guild_count = 0; |
---|
2224 | result=CharacterDatabase.PQuery("SELECT COUNT(item_entry) FROM guild_bank_item WHERE item_entry='%u'",item_id); |
---|
2225 | if(result) |
---|
2226 | { |
---|
2227 | guild_count = (*result)[0].GetUInt32(); |
---|
2228 | delete result; |
---|
2229 | } |
---|
2230 | |
---|
2231 | result=CharacterDatabase.PQuery( |
---|
2232 | // 0 1 2 |
---|
2233 | "SELECT gi.item_guid, gi.guildid, guild.name " |
---|
2234 | "FROM guild_bank_item AS gi, guild WHERE gi.item_entry='%u' AND gi.guildid = guild.guildid LIMIT %u ", |
---|
2235 | item_id,uint32(count)); |
---|
2236 | |
---|
2237 | if(result) |
---|
2238 | { |
---|
2239 | do |
---|
2240 | { |
---|
2241 | Field *fields = result->Fetch(); |
---|
2242 | uint32 item_guid = fields[0].GetUInt32(); |
---|
2243 | uint32 guild_guid = fields[1].GetUInt32(); |
---|
2244 | std::string guild_name = fields[2].GetCppString(); |
---|
2245 | |
---|
2246 | char const* item_pos = "[in guild bank]"; |
---|
2247 | |
---|
2248 | PSendSysMessage(LANG_ITEMLIST_GUILD,item_guid,guild_name.c_str(),guild_guid,item_pos); |
---|
2249 | } while (result->NextRow()); |
---|
2250 | |
---|
2251 | int64 res_count = result->GetRowCount(); |
---|
2252 | |
---|
2253 | delete result; |
---|
2254 | |
---|
2255 | if(count > res_count) |
---|
2256 | count-=res_count; |
---|
2257 | else if(count) |
---|
2258 | count = 0; |
---|
2259 | } |
---|
2260 | |
---|
2261 | if(inv_count+mail_count+auc_count+guild_count == 0) |
---|
2262 | { |
---|
2263 | SendSysMessage(LANG_COMMAND_NOITEMFOUND); |
---|
2264 | SetSentErrorMessage(true); |
---|
2265 | return false; |
---|
2266 | } |
---|
2267 | |
---|
2268 | PSendSysMessage(LANG_COMMAND_LISTITEMMESSAGE,item_id,inv_count+mail_count+auc_count+guild_count,inv_count,mail_count,auc_count,guild_count); |
---|
2269 | |
---|
2270 | return true; |
---|
2271 | } |
---|
2272 | |
---|
2273 | bool ChatHandler::HandleListObjectCommand(const char* args) |
---|
2274 | { |
---|
2275 | if(!*args) |
---|
2276 | return false; |
---|
2277 | |
---|
2278 | // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r |
---|
2279 | char* cId = extractKeyFromLink((char*)args,"Hgameobject_entry"); |
---|
2280 | if(!cId) |
---|
2281 | return false; |
---|
2282 | |
---|
2283 | uint32 go_id = atol(cId); |
---|
2284 | if(!go_id) |
---|
2285 | { |
---|
2286 | PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID, go_id); |
---|
2287 | SetSentErrorMessage(true); |
---|
2288 | return false; |
---|
2289 | } |
---|
2290 | |
---|
2291 | GameObjectInfo const * gInfo = objmgr.GetGameObjectInfo(go_id); |
---|
2292 | if(!gInfo) |
---|
2293 | { |
---|
2294 | PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID, go_id); |
---|
2295 | SetSentErrorMessage(true); |
---|
2296 | return false; |
---|
2297 | } |
---|
2298 | |
---|
2299 | char* c_count = strtok(NULL, " "); |
---|
2300 | int count = c_count ? atol(c_count) : 10; |
---|
2301 | |
---|
2302 | if(count < 0) |
---|
2303 | return false; |
---|
2304 | |
---|
2305 | QueryResult *result; |
---|
2306 | |
---|
2307 | uint32 obj_count = 0; |
---|
2308 | result=WorldDatabase.PQuery("SELECT COUNT(guid) FROM gameobject WHERE id='%u'",go_id); |
---|
2309 | if(result) |
---|
2310 | { |
---|
2311 | obj_count = (*result)[0].GetUInt32(); |
---|
2312 | delete result; |
---|
2313 | } |
---|
2314 | |
---|
2315 | if(m_session) |
---|
2316 | { |
---|
2317 | Player* pl = m_session->GetPlayer(); |
---|
2318 | result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE id = '%u' ORDER BY order_ ASC LIMIT %u", |
---|
2319 | pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),go_id,uint32(count)); |
---|
2320 | } |
---|
2321 | else |
---|
2322 | result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM gameobject WHERE id = '%u' LIMIT %u", |
---|
2323 | go_id,uint32(count)); |
---|
2324 | |
---|
2325 | if (result) |
---|
2326 | { |
---|
2327 | do |
---|
2328 | { |
---|
2329 | Field *fields = result->Fetch(); |
---|
2330 | uint32 guid = fields[0].GetUInt32(); |
---|
2331 | float x = fields[1].GetFloat(); |
---|
2332 | float y = fields[2].GetFloat(); |
---|
2333 | float z = fields[3].GetFloat(); |
---|
2334 | int mapid = fields[4].GetUInt16(); |
---|
2335 | |
---|
2336 | if (m_session) |
---|
2337 | PSendSysMessage(LANG_GO_LIST_CHAT, guid, guid, gInfo->name, x, y, z, mapid); |
---|
2338 | else |
---|
2339 | PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, gInfo->name, x, y, z, mapid); |
---|
2340 | } while (result->NextRow()); |
---|
2341 | |
---|
2342 | delete result; |
---|
2343 | } |
---|
2344 | |
---|
2345 | PSendSysMessage(LANG_COMMAND_LISTOBJMESSAGE,go_id,obj_count); |
---|
2346 | return true; |
---|
2347 | } |
---|
2348 | |
---|
2349 | bool ChatHandler::HandleNearObjectCommand(const char* args) |
---|
2350 | { |
---|
2351 | float distance = (!*args) ? 10 : atol(args); |
---|
2352 | uint32 count = 0; |
---|
2353 | |
---|
2354 | Player* pl = m_session->GetPlayer(); |
---|
2355 | QueryResult *result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, map, " |
---|
2356 | "(POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ " |
---|
2357 | "FROM gameobject WHERE map='%u' AND (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) <= '%f' ORDER BY order_", |
---|
2358 | pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), |
---|
2359 | pl->GetMapId(),pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),distance*distance); |
---|
2360 | |
---|
2361 | if (result) |
---|
2362 | { |
---|
2363 | do |
---|
2364 | { |
---|
2365 | Field *fields = result->Fetch(); |
---|
2366 | uint32 guid = fields[0].GetUInt32(); |
---|
2367 | uint32 entry = fields[1].GetUInt32(); |
---|
2368 | float x = fields[2].GetFloat(); |
---|
2369 | float y = fields[3].GetFloat(); |
---|
2370 | float z = fields[4].GetFloat(); |
---|
2371 | int mapid = fields[5].GetUInt16(); |
---|
2372 | |
---|
2373 | GameObjectInfo const * gInfo = objmgr.GetGameObjectInfo(entry); |
---|
2374 | |
---|
2375 | if(!gInfo) |
---|
2376 | continue; |
---|
2377 | |
---|
2378 | PSendSysMessage(LANG_GO_LIST_CHAT, guid, guid, gInfo->name, x, y, z, mapid); |
---|
2379 | |
---|
2380 | ++count; |
---|
2381 | } while (result->NextRow()); |
---|
2382 | |
---|
2383 | delete result; |
---|
2384 | } |
---|
2385 | |
---|
2386 | PSendSysMessage(LANG_COMMAND_NEAROBJMESSAGE,distance,count); |
---|
2387 | return true; |
---|
2388 | } |
---|
2389 | |
---|
2390 | bool ChatHandler::HandleObjectStateCommand(const char* args) |
---|
2391 | { |
---|
2392 | // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r |
---|
2393 | char* cId = extractKeyFromLink((char*)args, "Hgameobject"); |
---|
2394 | if(!cId) |
---|
2395 | return false; |
---|
2396 | |
---|
2397 | uint32 lowguid = atoi(cId); |
---|
2398 | if(!lowguid) |
---|
2399 | return false; |
---|
2400 | |
---|
2401 | GameObject* gobj = NULL; |
---|
2402 | |
---|
2403 | if(GameObjectData const* goData = objmgr.GetGOData(lowguid)) |
---|
2404 | gobj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, goData->id); |
---|
2405 | |
---|
2406 | if(!gobj) |
---|
2407 | { |
---|
2408 | PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); |
---|
2409 | SetSentErrorMessage(true); |
---|
2410 | return false; |
---|
2411 | } |
---|
2412 | |
---|
2413 | char* cstate = strtok(NULL, " "); |
---|
2414 | if(!cstate) |
---|
2415 | return false; |
---|
2416 | |
---|
2417 | int32 state = atoi(cstate); |
---|
2418 | if(state < 0) |
---|
2419 | gobj->SendObjectDeSpawnAnim(gobj->GetGUID()); |
---|
2420 | else |
---|
2421 | gobj->SetGoState(state); |
---|
2422 | |
---|
2423 | return true; |
---|
2424 | |
---|
2425 | return true; |
---|
2426 | } |
---|
2427 | |
---|
2428 | bool ChatHandler::HandleListCreatureCommand(const char* args) |
---|
2429 | { |
---|
2430 | if(!*args) |
---|
2431 | return false; |
---|
2432 | |
---|
2433 | // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r |
---|
2434 | char* cId = extractKeyFromLink((char*)args,"Hcreature_entry"); |
---|
2435 | if(!cId) |
---|
2436 | return false; |
---|
2437 | |
---|
2438 | uint32 cr_id = atol(cId); |
---|
2439 | if(!cr_id) |
---|
2440 | { |
---|
2441 | PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID, cr_id); |
---|
2442 | SetSentErrorMessage(true); |
---|
2443 | return false; |
---|
2444 | } |
---|
2445 | |
---|
2446 | CreatureInfo const* cInfo = objmgr.GetCreatureTemplate(cr_id); |
---|
2447 | if(!cInfo) |
---|
2448 | { |
---|
2449 | PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID, cr_id); |
---|
2450 | SetSentErrorMessage(true); |
---|
2451 | return false; |
---|
2452 | } |
---|
2453 | |
---|
2454 | char* c_count = strtok(NULL, " "); |
---|
2455 | int count = c_count ? atol(c_count) : 10; |
---|
2456 | |
---|
2457 | if(count < 0) |
---|
2458 | return false; |
---|
2459 | |
---|
2460 | QueryResult *result; |
---|
2461 | |
---|
2462 | uint32 cr_count = 0; |
---|
2463 | result=WorldDatabase.PQuery("SELECT COUNT(guid) FROM creature WHERE id='%u'",cr_id); |
---|
2464 | if(result) |
---|
2465 | { |
---|
2466 | cr_count = (*result)[0].GetUInt32(); |
---|
2467 | delete result; |
---|
2468 | } |
---|
2469 | |
---|
2470 | if(m_session) |
---|
2471 | { |
---|
2472 | Player* pl = m_session->GetPlayer(); |
---|
2473 | result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM creature WHERE id = '%u' ORDER BY order_ ASC LIMIT %u", |
---|
2474 | pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), cr_id,uint32(count)); |
---|
2475 | } |
---|
2476 | else |
---|
2477 | result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id = '%u' LIMIT %u", |
---|
2478 | cr_id,uint32(count)); |
---|
2479 | |
---|
2480 | if (result) |
---|
2481 | { |
---|
2482 | do |
---|
2483 | { |
---|
2484 | Field *fields = result->Fetch(); |
---|
2485 | uint32 guid = fields[0].GetUInt32(); |
---|
2486 | float x = fields[1].GetFloat(); |
---|
2487 | float y = fields[2].GetFloat(); |
---|
2488 | float z = fields[3].GetFloat(); |
---|
2489 | int mapid = fields[4].GetUInt16(); |
---|
2490 | |
---|
2491 | if (m_session) |
---|
2492 | PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, cInfo->Name, x, y, z, mapid); |
---|
2493 | else |
---|
2494 | PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, cInfo->Name, x, y, z, mapid); |
---|
2495 | } while (result->NextRow()); |
---|
2496 | |
---|
2497 | delete result; |
---|
2498 | } |
---|
2499 | |
---|
2500 | PSendSysMessage(LANG_COMMAND_LISTCREATUREMESSAGE,cr_id,cr_count); |
---|
2501 | return true; |
---|
2502 | } |
---|
2503 | |
---|
2504 | bool ChatHandler::HandleLookupItemCommand(const char* args) |
---|
2505 | { |
---|
2506 | if(!*args) |
---|
2507 | return false; |
---|
2508 | |
---|
2509 | std::string namepart = args; |
---|
2510 | std::wstring wnamepart; |
---|
2511 | |
---|
2512 | // converting string that we try to find to lower case |
---|
2513 | if(!Utf8toWStr(namepart,wnamepart)) |
---|
2514 | return false; |
---|
2515 | |
---|
2516 | wstrToLower(wnamepart); |
---|
2517 | |
---|
2518 | uint32 counter = 0; |
---|
2519 | |
---|
2520 | // Search in `item_template` |
---|
2521 | for (uint32 id = 0; id < sItemStorage.MaxEntry; id++) |
---|
2522 | { |
---|
2523 | ItemPrototype const *pProto = sItemStorage.LookupEntry<ItemPrototype >(id); |
---|
2524 | if(!pProto) |
---|
2525 | continue; |
---|
2526 | |
---|
2527 | int loc_idx = m_session ? m_session->GetSessionDbLocaleIndex() : objmgr.GetDBCLocaleIndex(); |
---|
2528 | if ( loc_idx >= 0 ) |
---|
2529 | { |
---|
2530 | ItemLocale const *il = objmgr.GetItemLocale(pProto->ItemId); |
---|
2531 | if (il) |
---|
2532 | { |
---|
2533 | if (il->Name.size() > loc_idx && !il->Name[loc_idx].empty()) |
---|
2534 | { |
---|
2535 | std::string name = il->Name[loc_idx]; |
---|
2536 | |
---|
2537 | if (Utf8FitTo(name, wnamepart)) |
---|
2538 | { |
---|
2539 | if (m_session) |
---|
2540 | PSendSysMessage(LANG_ITEM_LIST_CHAT, id, id, name.c_str()); |
---|
2541 | else |
---|
2542 | PSendSysMessage(LANG_ITEM_LIST_CONSOLE, id, name.c_str()); |
---|
2543 | ++counter; |
---|
2544 | continue; |
---|
2545 | } |
---|
2546 | } |
---|
2547 | } |
---|
2548 | } |
---|
2549 | |
---|
2550 | std::string name = pProto->Name1; |
---|
2551 | if(name.empty()) |
---|
2552 | continue; |
---|
2553 | |
---|
2554 | if (Utf8FitTo(name, wnamepart)) |
---|
2555 | { |
---|
2556 | if (m_session) |
---|
2557 | PSendSysMessage(LANG_ITEM_LIST_CHAT, id, id, name.c_str()); |
---|
2558 | else |
---|
2559 | PSendSysMessage(LANG_ITEM_LIST_CONSOLE, id, name.c_str()); |
---|
2560 | ++counter; |
---|
2561 | } |
---|
2562 | } |
---|
2563 | |
---|
2564 | if (counter==0) |
---|
2565 | SendSysMessage(LANG_COMMAND_NOITEMFOUND); |
---|
2566 | |
---|
2567 | return true; |
---|
2568 | } |
---|
2569 | |
---|
2570 | bool ChatHandler::HandleLookupItemSetCommand(const char* args) |
---|
2571 | { |
---|
2572 | if(!*args) |
---|
2573 | return false; |
---|
2574 | |
---|
2575 | std::string namepart = args; |
---|
2576 | std::wstring wnamepart; |
---|
2577 | |
---|
2578 | if(!Utf8toWStr(namepart,wnamepart)) |
---|
2579 | return false; |
---|
2580 | |
---|
2581 | // converting string that we try to find to lower case |
---|
2582 | wstrToLower( wnamepart ); |
---|
2583 | |
---|
2584 | uint32 counter = 0; // Counter for figure out that we found smth. |
---|
2585 | |
---|
2586 | // Search in ItemSet.dbc |
---|
2587 | for (uint32 id = 0; id < sItemSetStore.GetNumRows(); id++) |
---|
2588 | { |
---|
2589 | ItemSetEntry const *set = sItemSetStore.LookupEntry(id); |
---|
2590 | if(set) |
---|
2591 | { |
---|
2592 | int loc = m_session ? m_session->GetSessionDbcLocale() : sWorld.GetDefaultDbcLocale(); |
---|
2593 | std::string name = set->name[loc]; |
---|
2594 | if(name.empty()) |
---|
2595 | continue; |
---|
2596 | |
---|
2597 | if (!Utf8FitTo(name, wnamepart)) |
---|
2598 | { |
---|
2599 | loc = 0; |
---|
2600 | for(; loc < MAX_LOCALE; ++loc) |
---|
2601 | { |
---|
2602 | if(m_session && loc==m_session->GetSessionDbcLocale()) |
---|
2603 | continue; |
---|
2604 | |
---|
2605 | name = set->name[loc]; |
---|
2606 | if(name.empty()) |
---|
2607 | continue; |
---|
2608 | |
---|
2609 | if (Utf8FitTo(name, wnamepart)) |
---|
2610 | break; |
---|
2611 | } |
---|
2612 | } |
---|
2613 | |
---|
2614 | if(loc < MAX_LOCALE) |
---|
2615 | { |
---|
2616 | // send item set in "id - [namedlink locale]" format |
---|
2617 | if (m_session) |
---|
2618 | PSendSysMessage(LANG_ITEMSET_LIST_CHAT,id,id,name.c_str(),localeNames[loc]); |
---|
2619 | else |
---|
2620 | PSendSysMessage(LANG_ITEMSET_LIST_CONSOLE,id,name.c_str(),localeNames[loc]); |
---|
2621 | ++counter; |
---|
2622 | } |
---|
2623 | } |
---|
2624 | } |
---|
2625 | if (counter == 0) // if counter == 0 then we found nth |
---|
2626 | SendSysMessage(LANG_COMMAND_NOITEMSETFOUND); |
---|
2627 | return true; |
---|
2628 | } |
---|
2629 | |
---|
2630 | bool ChatHandler::HandleLookupSkillCommand(const char* args) |
---|
2631 | { |
---|
2632 | if (!*args) |
---|
2633 | return false; |
---|
2634 | |
---|
2635 | // can be NULL in console call |
---|
2636 | Player* target = getSelectedPlayer(); |
---|
2637 | |
---|
2638 | std::string namepart = args; |
---|
2639 | std::wstring wnamepart; |
---|
2640 | |
---|
2641 | if(!Utf8toWStr(namepart,wnamepart)) |
---|
2642 | return false; |
---|
2643 | |
---|
2644 | // converting string that we try to find to lower case |
---|
2645 | wstrToLower( wnamepart ); |
---|
2646 | |
---|
2647 | uint32 counter = 0; // Counter for figure out that we found smth. |
---|
2648 | |
---|
2649 | // Search in SkillLine.dbc |
---|
2650 | for (uint32 id = 0; id < sSkillLineStore.GetNumRows(); id++) |
---|
2651 | { |
---|
2652 | SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(id); |
---|
2653 | if(skillInfo) |
---|
2654 | { |
---|
2655 | int loc = m_session ? m_session->GetSessionDbcLocale() : sWorld.GetDefaultDbcLocale(); |
---|
2656 | std::string name = skillInfo->name[loc]; |
---|
2657 | if(name.empty()) |
---|
2658 | continue; |
---|
2659 | |
---|
2660 | if (!Utf8FitTo(name, wnamepart)) |
---|
2661 | { |
---|
2662 | loc = 0; |
---|
2663 | for(; loc < MAX_LOCALE; ++loc) |
---|
2664 | { |
---|
2665 | if(m_session && loc==m_session->GetSessionDbcLocale()) |
---|
2666 | continue; |
---|
2667 | |
---|
2668 | name = skillInfo->name[loc]; |
---|
2669 | if(name.empty()) |
---|
2670 | continue; |
---|
2671 | |
---|
2672 | if (Utf8FitTo(name, wnamepart)) |
---|
2673 | break; |
---|
2674 | } |
---|
2675 | } |
---|
2676 | |
---|
2677 | if(loc < MAX_LOCALE) |
---|
2678 | { |
---|
2679 | char const* knownStr = ""; |
---|
2680 | if(target && target->HasSkill(id)) |
---|
2681 | knownStr = GetTrinityString(LANG_KNOWN); |
---|
2682 | |
---|
2683 | // send skill in "id - [namedlink locale]" format |
---|
2684 | if (m_session) |
---|
2685 | PSendSysMessage(LANG_SKILL_LIST_CHAT,id,id,name.c_str(),localeNames[loc],knownStr); |
---|
2686 | else |
---|
2687 | PSendSysMessage(LANG_SKILL_LIST_CONSOLE,id,name.c_str(),localeNames[loc],knownStr); |
---|
2688 | |
---|
2689 | ++counter; |
---|
2690 | } |
---|
2691 | } |
---|
2692 | } |
---|
2693 | if (counter == 0) // if counter == 0 then we found nth |
---|
2694 | SendSysMessage(LANG_COMMAND_NOSKILLFOUND); |
---|
2695 | return true; |
---|
2696 | } |
---|
2697 | |
---|
2698 | bool ChatHandler::HandleLookupSpellCommand(const char* args) |
---|
2699 | { |
---|
2700 | if (!*args) |
---|
2701 | return false; |
---|
2702 | |
---|
2703 | // can be NULL at console call |
---|
2704 | Player* target = getSelectedPlayer(); |
---|
2705 | |
---|
2706 | std::string namepart = args; |
---|
2707 | std::wstring wnamepart; |
---|
2708 | |
---|
2709 | if(!Utf8toWStr(namepart,wnamepart)) |
---|
2710 | return false; |
---|
2711 | |
---|
2712 | // converting string that we try to find to lower case |
---|
2713 | wstrToLower( wnamepart ); |
---|
2714 | |
---|
2715 | uint32 counter = 0; // Counter for figure out that we found smth. |
---|
2716 | |
---|
2717 | // Search in Spell.dbc |
---|
2718 | for (uint32 id = 0; id < sSpellStore.GetNumRows(); id++) |
---|
2719 | { |
---|
2720 | SpellEntry const *spellInfo = sSpellStore.LookupEntry(id); |
---|
2721 | if(spellInfo) |
---|
2722 | { |
---|
2723 | int loc = m_session ? m_session->GetSessionDbcLocale() : sWorld.GetDefaultDbcLocale(); |
---|
2724 | std::string name = spellInfo->SpellName[loc]; |
---|
2725 | if(name.empty()) |
---|
2726 | continue; |
---|
2727 | |
---|
2728 | if (!Utf8FitTo(name, wnamepart)) |
---|
2729 | { |
---|
2730 | loc = 0; |
---|
2731 | for(; loc < MAX_LOCALE; ++loc) |
---|
2732 | { |
---|
2733 | if(m_session && loc==m_session->GetSessionDbcLocale()) |
---|
2734 | continue; |
---|
2735 | |
---|
2736 | name = spellInfo->SpellName[loc]; |
---|
2737 | if(name.empty()) |
---|
2738 | continue; |
---|
2739 | |
---|
2740 | if (Utf8FitTo(name, wnamepart)) |
---|
2741 | break; |
---|
2742 | } |
---|
2743 | } |
---|
2744 | |
---|
2745 | if(loc < MAX_LOCALE) |
---|
2746 | { |
---|
2747 | bool known = target && target->HasSpell(id); |
---|
2748 | bool learn = (spellInfo->Effect[0] == SPELL_EFFECT_LEARN_SPELL); |
---|
2749 | |
---|
2750 | uint32 telentCost = GetTalentSpellCost(id); |
---|
2751 | |
---|
2752 | bool talent = (telentCost > 0); |
---|
2753 | bool passive = IsPassiveSpell(id); |
---|
2754 | bool active = target && (target->HasAura(id,0) || target->HasAura(id,1) || target->HasAura(id,2)); |
---|
2755 | |
---|
2756 | // unit32 used to prevent interpreting uint8 as char at output |
---|
2757 | // find rank of learned spell for learning spell, or talent rank |
---|
2758 | uint32 rank = telentCost ? telentCost : spellmgr.GetSpellRank(learn ? spellInfo->EffectTriggerSpell[0] : id); |
---|
2759 | |
---|
2760 | // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format |
---|
2761 | std::ostringstream ss; |
---|
2762 | if (m_session) |
---|
2763 | ss << id << " - |cffffffff|Hspell:" << id << "|h[" << name; |
---|
2764 | else |
---|
2765 | ss << id << " - " << name; |
---|
2766 | |
---|
2767 | // include rank in link name |
---|
2768 | if(rank) |
---|
2769 | ss << GetTrinityString(LANG_SPELL_RANK) << rank; |
---|
2770 | |
---|
2771 | if (m_session) |
---|
2772 | ss << " " << localeNames[loc] << "]|h|r"; |
---|
2773 | else |
---|
2774 | ss << " " << localeNames[loc]; |
---|
2775 | |
---|
2776 | if(talent) |
---|
2777 | ss << GetTrinityString(LANG_TALENT); |
---|
2778 | if(passive) |
---|
2779 | ss << GetTrinityString(LANG_PASSIVE); |
---|
2780 | if(learn) |
---|
2781 | ss << GetTrinityString(LANG_LEARN); |
---|
2782 | if(known) |
---|
2783 | ss << GetTrinityString(LANG_KNOWN); |
---|
2784 | if(active) |
---|
2785 | ss << GetTrinityString(LANG_ACTIVE); |
---|
2786 | |
---|
2787 | SendSysMessage(ss.str().c_str()); |
---|
2788 | |
---|
2789 | ++counter; |
---|
2790 | } |
---|
2791 | } |
---|
2792 | } |
---|
2793 | if (counter == 0) // if counter == 0 then we found nth |
---|
2794 | SendSysMessage(LANG_COMMAND_NOSPELLFOUND); |
---|
2795 | return true; |
---|
2796 | } |
---|
2797 | |
---|
2798 | bool ChatHandler::HandleLookupQuestCommand(const char* args) |
---|
2799 | { |
---|
2800 | if (!*args) |
---|
2801 | return false; |
---|
2802 | |
---|
2803 | // can be NULL at console call |
---|
2804 | Player* target = getSelectedPlayer(); |
---|
2805 | |
---|
2806 | std::string namepart = args; |
---|
2807 | std::wstring wnamepart; |
---|
2808 | |
---|
2809 | // converting string that we try to find to lower case |
---|
2810 | if(!Utf8toWStr(namepart,wnamepart)) |
---|
2811 | return false; |
---|
2812 | |
---|
2813 | wstrToLower(wnamepart); |
---|
2814 | |
---|
2815 | uint32 counter = 0 ; |
---|
2816 | |
---|
2817 | ObjectMgr::QuestMap const& qTemplates = objmgr.GetQuestTemplates(); |
---|
2818 | for (ObjectMgr::QuestMap::const_iterator iter = qTemplates.begin(); iter != qTemplates.end(); ++iter) |
---|
2819 | { |
---|
2820 | Quest * qinfo = iter->second; |
---|
2821 | |
---|
2822 | int loc_idx = m_session ? m_session->GetSessionDbLocaleIndex() : objmgr.GetDBCLocaleIndex(); |
---|
2823 | if ( loc_idx >= 0 ) |
---|
2824 | { |
---|
2825 | QuestLocale const *il = objmgr.GetQuestLocale(qinfo->GetQuestId()); |
---|
2826 | if (il) |
---|
2827 | { |
---|
2828 | if (il->Title.size() > loc_idx && !il->Title[loc_idx].empty()) |
---|
2829 | { |
---|
2830 | std::string title = il->Title[loc_idx]; |
---|
2831 | |
---|
2832 | if (Utf8FitTo(title, wnamepart)) |
---|
2833 | { |
---|
2834 | char const* statusStr = ""; |
---|
2835 | |
---|
2836 | if(target) |
---|
2837 | { |
---|
2838 | QuestStatus status = target->GetQuestStatus(qinfo->GetQuestId()); |
---|
2839 | |
---|
2840 | if(status == QUEST_STATUS_COMPLETE) |
---|
2841 | { |
---|
2842 | if(target->GetQuestRewardStatus(qinfo->GetQuestId())) |
---|
2843 | statusStr = GetTrinityString(LANG_COMMAND_QUEST_REWARDED); |
---|
2844 | else |
---|
2845 | statusStr = GetTrinityString(LANG_COMMAND_QUEST_COMPLETE); |
---|
2846 | } |
---|
2847 | else if(status == QUEST_STATUS_INCOMPLETE) |
---|
2848 | statusStr = GetTrinityString(LANG_COMMAND_QUEST_ACTIVE); |
---|
2849 | } |
---|
2850 | |
---|
2851 | if (m_session) |
---|
2852 | PSendSysMessage(LANG_QUEST_LIST_CHAT,qinfo->GetQuestId(),qinfo->GetQuestId(),title.c_str(),statusStr); |
---|
2853 | else |
---|
2854 | PSendSysMessage(LANG_QUEST_LIST_CONSOLE,qinfo->GetQuestId(),title.c_str(),statusStr); |
---|
2855 | |
---|
2856 | ++counter; |
---|
2857 | continue; |
---|
2858 | } |
---|
2859 | } |
---|
2860 | } |
---|
2861 | } |
---|
2862 | |
---|
2863 | std::string title = qinfo->GetTitle(); |
---|
2864 | if(title.empty()) |
---|
2865 | continue; |
---|
2866 | |
---|
2867 | if (Utf8FitTo(title, wnamepart)) |
---|
2868 | { |
---|
2869 | char const* statusStr = ""; |
---|
2870 | |
---|
2871 | if(target) |
---|
2872 | { |
---|
2873 | QuestStatus status = target->GetQuestStatus(qinfo->GetQuestId()); |
---|
2874 | |
---|
2875 | if(status == QUEST_STATUS_COMPLETE) |
---|
2876 | { |
---|
2877 | if(target->GetQuestRewardStatus(qinfo->GetQuestId())) |
---|
2878 | statusStr = GetTrinityString(LANG_COMMAND_QUEST_REWARDED); |
---|
2879 | else |
---|
2880 | statusStr = GetTrinityString(LANG_COMMAND_QUEST_COMPLETE); |
---|
2881 | } |
---|
2882 | else if(status == QUEST_STATUS_INCOMPLETE) |
---|
2883 | statusStr = GetTrinityString(LANG_COMMAND_QUEST_ACTIVE); |
---|
2884 | } |
---|
2885 | |
---|
2886 | if (m_session) |
---|
2887 | PSendSysMessage(LANG_QUEST_LIST_CHAT,qinfo->GetQuestId(),qinfo->GetQuestId(),title.c_str(),statusStr); |
---|
2888 | else |
---|
2889 | PSendSysMessage(LANG_QUEST_LIST_CONSOLE,qinfo->GetQuestId(),title.c_str(),statusStr); |
---|
2890 | |
---|
2891 | ++counter; |
---|
2892 | } |
---|
2893 | } |
---|
2894 | |
---|
2895 | if (counter==0) |
---|
2896 | SendSysMessage(LANG_COMMAND_NOQUESTFOUND); |
---|
2897 | |
---|
2898 | return true; |
---|
2899 | } |
---|
2900 | |
---|
2901 | bool ChatHandler::HandleLookupCreatureCommand(const char* args) |
---|
2902 | { |
---|
2903 | if (!*args) |
---|
2904 | return false; |
---|
2905 | |
---|
2906 | std::string namepart = args; |
---|
2907 | std::wstring wnamepart; |
---|
2908 | |
---|
2909 | // converting string that we try to find to lower case |
---|
2910 | if (!Utf8toWStr (namepart,wnamepart)) |
---|
2911 | return false; |
---|
2912 | |
---|
2913 | wstrToLower (wnamepart); |
---|
2914 | |
---|
2915 | uint32 counter = 0; |
---|
2916 | |
---|
2917 | for (uint32 id = 0; id< sCreatureStorage.MaxEntry; ++id) |
---|
2918 | { |
---|
2919 | CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo> (id); |
---|
2920 | if(!cInfo) |
---|
2921 | continue; |
---|
2922 | |
---|
2923 | int loc_idx = m_session ? m_session->GetSessionDbLocaleIndex() : objmgr.GetDBCLocaleIndex(); |
---|
2924 | if (loc_idx >= 0) |
---|
2925 | { |
---|
2926 | CreatureLocale const *cl = objmgr.GetCreatureLocale (id); |
---|
2927 | if (cl) |
---|
2928 | { |
---|
2929 | if (cl->Name.size() > loc_idx && !cl->Name[loc_idx].empty ()) |
---|
2930 | { |
---|
2931 | std::string name = cl->Name[loc_idx]; |
---|
2932 | |
---|
2933 | if (Utf8FitTo (name, wnamepart)) |
---|
2934 | { |
---|
2935 | if (m_session) |
---|
2936 | PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name.c_str ()); |
---|
2937 | else |
---|
2938 | PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str ()); |
---|
2939 | |
---|
2940 | ++counter; |
---|
2941 | continue; |
---|
2942 | } |
---|
2943 | } |
---|
2944 | } |
---|
2945 | } |
---|
2946 | |
---|
2947 | std::string name = cInfo->Name; |
---|
2948 | if (name.empty ()) |
---|
2949 | continue; |
---|
2950 | |
---|
2951 | if (Utf8FitTo(name, wnamepart)) |
---|
2952 | { |
---|
2953 | if (m_session) |
---|
2954 | PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name.c_str ()); |
---|
2955 | else |
---|
2956 | PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str ()); |
---|
2957 | ++counter; |
---|
2958 | } |
---|
2959 | } |
---|
2960 | |
---|
2961 | if (counter==0) |
---|
2962 | SendSysMessage (LANG_COMMAND_NOCREATUREFOUND); |
---|
2963 | |
---|
2964 | return true; |
---|
2965 | } |
---|
2966 | |
---|
2967 | bool ChatHandler::HandleLookupObjectCommand(const char* args) |
---|
2968 | { |
---|
2969 | if(!*args) |
---|
2970 | return false; |
---|
2971 | |
---|
2972 | std::string namepart = args; |
---|
2973 | std::wstring wnamepart; |
---|
2974 | |
---|
2975 | // converting string that we try to find to lower case |
---|
2976 | if(!Utf8toWStr(namepart,wnamepart)) |
---|
2977 | return false; |
---|
2978 | |
---|
2979 | wstrToLower(wnamepart); |
---|
2980 | |
---|
2981 | uint32 counter = 0; |
---|
2982 | |
---|
2983 | for (uint32 id = 0; id< sGOStorage.MaxEntry; id++ ) |
---|
2984 | { |
---|
2985 | GameObjectInfo const* gInfo = sGOStorage.LookupEntry<GameObjectInfo>(id); |
---|
2986 | if(!gInfo) |
---|
2987 | continue; |
---|
2988 | |
---|
2989 | int loc_idx = m_session ? m_session->GetSessionDbLocaleIndex() : objmgr.GetDBCLocaleIndex(); |
---|
2990 | if ( loc_idx >= 0 ) |
---|
2991 | { |
---|
2992 | GameObjectLocale const *gl = objmgr.GetGameObjectLocale(id); |
---|
2993 | if (gl) |
---|
2994 | { |
---|
2995 | if (gl->Name.size() > loc_idx && !gl->Name[loc_idx].empty()) |
---|
2996 | { |
---|
2997 | std::string name = gl->Name[loc_idx]; |
---|
2998 | |
---|
2999 | if (Utf8FitTo(name, wnamepart)) |
---|
3000 | { |
---|
3001 | if (m_session) |
---|
3002 | PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, id, id, name.c_str()); |
---|
3003 | else |
---|
3004 | PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, id, name.c_str()); |
---|
3005 | ++counter; |
---|
3006 | continue; |
---|
3007 | } |
---|
3008 | } |
---|
3009 | } |
---|
3010 | } |
---|
3011 | |
---|
3012 | std::string name = gInfo->name; |
---|
3013 | if(name.empty()) |
---|
3014 | continue; |
---|
3015 | |
---|
3016 | if(Utf8FitTo(name, wnamepart)) |
---|
3017 | { |
---|
3018 | if (m_session) |
---|
3019 | PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, id, id, name.c_str()); |
---|
3020 | else |
---|
3021 | PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, id, name.c_str()); |
---|
3022 | ++counter; |
---|
3023 | } |
---|
3024 | } |
---|
3025 | |
---|
3026 | if(counter==0) |
---|
3027 | SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND); |
---|
3028 | |
---|
3029 | return true; |
---|
3030 | } |
---|
3031 | |
---|
3032 | /** \brief GM command level 3 - Create a guild. |
---|
3033 | * |
---|
3034 | * This command allows a GM (level 3) to create a guild. |
---|
3035 | * |
---|
3036 | * The "args" parameter contains the name of the guild leader |
---|
3037 | * and then the name of the guild. |
---|
3038 | * |
---|
3039 | */ |
---|
3040 | bool ChatHandler::HandleGuildCreateCommand(const char* args) |
---|
3041 | { |
---|
3042 | |
---|
3043 | if (!*args) |
---|
3044 | return false; |
---|
3045 | |
---|
3046 | char *lname = strtok ((char*)args, " "); |
---|
3047 | char *gname = strtok (NULL, ""); |
---|
3048 | |
---|
3049 | if (!lname) |
---|
3050 | return false; |
---|
3051 | |
---|
3052 | if (!gname) |
---|
3053 | { |
---|
3054 | SendSysMessage (LANG_INSERT_GUILD_NAME); |
---|
3055 | SetSentErrorMessage (true); |
---|
3056 | return false; |
---|
3057 | } |
---|
3058 | |
---|
3059 | std::string guildname = gname; |
---|
3060 | |
---|
3061 | Player* player = ObjectAccessor::Instance ().FindPlayerByName (lname); |
---|
3062 | if (!player) |
---|
3063 | { |
---|
3064 | SendSysMessage (LANG_PLAYER_NOT_FOUND); |
---|
3065 | SetSentErrorMessage (true); |
---|
3066 | return false; |
---|
3067 | } |
---|
3068 | |
---|
3069 | if (player->GetGuildId()) |
---|
3070 | { |
---|
3071 | SendSysMessage (LANG_PLAYER_IN_GUILD); |
---|
3072 | return true; |
---|
3073 | } |
---|
3074 | |
---|
3075 | Guild *guild = new Guild; |
---|
3076 | if (!guild->create (player->GetGUID (),guildname)) |
---|
3077 | { |
---|
3078 | delete guild; |
---|
3079 | SendSysMessage (LANG_GUILD_NOT_CREATED); |
---|
3080 | SetSentErrorMessage (true); |
---|
3081 | return false; |
---|
3082 | } |
---|
3083 | |
---|
3084 | objmgr.AddGuild (guild); |
---|
3085 | return true; |
---|
3086 | } |
---|
3087 | |
---|
3088 | bool ChatHandler::HandleGuildInviteCommand(const char *args) |
---|
3089 | { |
---|
3090 | if (!*args) |
---|
3091 | return false; |
---|
3092 | |
---|
3093 | char* par1 = strtok ((char*)args, " "); |
---|
3094 | char* par2 = strtok (NULL, ""); |
---|
3095 | if(!par1 || !par2) |
---|
3096 | return false; |
---|
3097 | |
---|
3098 | std::string glName = par2; |
---|
3099 | Guild* targetGuild = objmgr.GetGuildByName (glName); |
---|
3100 | if (!targetGuild) |
---|
3101 | return false; |
---|
3102 | |
---|
3103 | std::string plName = par1; |
---|
3104 | if (!normalizePlayerName (plName)) |
---|
3105 | { |
---|
3106 | SendSysMessage (LANG_PLAYER_NOT_FOUND); |
---|
3107 | SetSentErrorMessage (true); |
---|
3108 | return false; |
---|
3109 | } |
---|
3110 | |
---|
3111 | uint64 plGuid = 0; |
---|
3112 | if (Player* targetPlayer = ObjectAccessor::Instance ().FindPlayerByName (plName.c_str ())) |
---|
3113 | plGuid = targetPlayer->GetGUID (); |
---|
3114 | else |
---|
3115 | plGuid = objmgr.GetPlayerGUIDByName (plName.c_str ()); |
---|
3116 | |
---|
3117 | if (!plGuid) |
---|
3118 | false; |
---|
3119 | |
---|
3120 | // players's guild membership checked in AddMember before add |
---|
3121 | if (!targetGuild->AddMember (plGuid,targetGuild->GetLowestRank ())) |
---|
3122 | return false; |
---|
3123 | |
---|
3124 | return true; |
---|
3125 | } |
---|
3126 | |
---|
3127 | bool ChatHandler::HandleGuildUninviteCommand(const char *args) |
---|
3128 | { |
---|
3129 | if (!*args) |
---|
3130 | return false; |
---|
3131 | |
---|
3132 | char* par1 = strtok ((char*)args, " "); |
---|
3133 | if(!par1) |
---|
3134 | return false; |
---|
3135 | |
---|
3136 | std::string plName = par1; |
---|
3137 | if (!normalizePlayerName (plName)) |
---|
3138 | { |
---|
3139 | SendSysMessage (LANG_PLAYER_NOT_FOUND); |
---|
3140 | SetSentErrorMessage (true); |
---|
3141 | return false; |
---|
3142 | } |
---|
3143 | |
---|
3144 | uint64 plGuid = 0; |
---|
3145 | uint32 glId = 0; |
---|
3146 | if (Player* targetPlayer = ObjectAccessor::Instance ().FindPlayerByName (plName.c_str ())) |
---|
3147 | { |
---|
3148 | plGuid = targetPlayer->GetGUID (); |
---|
3149 | glId = targetPlayer->GetGuildId (); |
---|
3150 | } |
---|
3151 | else |
---|
3152 | { |
---|
3153 | plGuid = objmgr.GetPlayerGUIDByName (plName.c_str ()); |
---|
3154 | glId = Player::GetGuildIdFromDB (plGuid); |
---|
3155 | } |
---|
3156 | |
---|
3157 | if (!plGuid || !glId) |
---|
3158 | return false; |
---|
3159 | |
---|
3160 | Guild* targetGuild = objmgr.GetGuildById (glId); |
---|
3161 | if (!targetGuild) |
---|
3162 | return false; |
---|
3163 | |
---|
3164 | targetGuild->DelMember (plGuid); |
---|
3165 | |
---|
3166 | return true; |
---|
3167 | } |
---|
3168 | |
---|
3169 | bool ChatHandler::HandleGuildRankCommand(const char *args) |
---|
3170 | { |
---|
3171 | if (!*args) |
---|
3172 | return false; |
---|
3173 | |
---|
3174 | char* par1 = strtok ((char*)args, " "); |
---|
3175 | char* par2 = strtok (NULL, " "); |
---|
3176 | if (!par1 || !par2) |
---|
3177 | return false; |
---|
3178 | |
---|
3179 | std::string plName = par1; |
---|
3180 | if (!normalizePlayerName (plName)) |
---|
3181 | { |
---|
3182 | SendSysMessage (LANG_PLAYER_NOT_FOUND); |
---|
3183 | SetSentErrorMessage (true); |
---|
3184 | return false; |
---|
3185 | } |
---|
3186 | |
---|
3187 | uint64 plGuid = 0; |
---|
3188 | uint32 glId = 0; |
---|
3189 | if (Player* targetPlayer = ObjectAccessor::Instance ().FindPlayerByName (plName.c_str ())) |
---|
3190 | { |
---|
3191 | plGuid = targetPlayer->GetGUID (); |
---|
3192 | glId = targetPlayer->GetGuildId (); |
---|
3193 | } |
---|
3194 | else |
---|
3195 | { |
---|
3196 | plGuid = objmgr.GetPlayerGUIDByName (plName.c_str ()); |
---|
3197 | glId = Player::GetGuildIdFromDB (plGuid); |
---|
3198 | } |
---|
3199 | |
---|
3200 | if (!plGuid || !glId) |
---|
3201 | return false; |
---|
3202 | |
---|
3203 | Guild* targetGuild = objmgr.GetGuildById (glId); |
---|
3204 | if (!targetGuild) |
---|
3205 | return false; |
---|
3206 | |
---|
3207 | uint32 newrank = uint32 (atoi (par2)); |
---|
3208 | if (newrank > targetGuild->GetLowestRank ()) |
---|
3209 | return false; |
---|
3210 | |
---|
3211 | targetGuild->ChangeRank (plGuid,newrank); |
---|
3212 | |
---|
3213 | return true; |
---|
3214 | } |
---|
3215 | |
---|
3216 | bool ChatHandler::HandleGuildDeleteCommand(const char* args) |
---|
3217 | { |
---|
3218 | if (!*args) |
---|
3219 | return false; |
---|
3220 | |
---|
3221 | char* par1 = strtok ((char*)args, " "); |
---|
3222 | if (!par1) |
---|
3223 | return false; |
---|
3224 | |
---|
3225 | std::string gld = par1; |
---|
3226 | |
---|
3227 | Guild* targetGuild = objmgr.GetGuildByName (gld); |
---|
3228 | if (!targetGuild) |
---|
3229 | return false; |
---|
3230 | |
---|
3231 | targetGuild->Disband (); |
---|
3232 | |
---|
3233 | return true; |
---|
3234 | } |
---|
3235 | |
---|
3236 | bool ChatHandler::HandleGetDistanceCommand(const char* /*args*/) |
---|
3237 | { |
---|
3238 | Unit* pUnit = getSelectedUnit(); |
---|
3239 | |
---|
3240 | if(!pUnit) |
---|
3241 | { |
---|
3242 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
3243 | SetSentErrorMessage(true); |
---|
3244 | return false; |
---|
3245 | } |
---|
3246 | |
---|
3247 | PSendSysMessage(LANG_DISTANCE, m_session->GetPlayer()->GetDistance(pUnit),m_session->GetPlayer()->GetDistance2d(pUnit)); |
---|
3248 | |
---|
3249 | return true; |
---|
3250 | } |
---|
3251 | |
---|
3252 | // FIX-ME!!! |
---|
3253 | |
---|
3254 | bool ChatHandler::HandleAddWeaponCommand(const char* /*args*/) |
---|
3255 | { |
---|
3256 | /*if (!*args) |
---|
3257 | return false; |
---|
3258 | |
---|
3259 | uint64 guid = m_session->GetPlayer()->GetSelection(); |
---|
3260 | if (guid == 0) |
---|
3261 | { |
---|
3262 | SendSysMessage(LANG_NO_SELECTION); |
---|
3263 | return true; |
---|
3264 | } |
---|
3265 | |
---|
3266 | Creature *pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid); |
---|
3267 | |
---|
3268 | if(!pCreature) |
---|
3269 | { |
---|
3270 | SendSysMessage(LANG_SELECT_CREATURE); |
---|
3271 | return true; |
---|
3272 | } |
---|
3273 | |
---|
3274 | char* pSlotID = strtok((char*)args, " "); |
---|
3275 | if (!pSlotID) |
---|
3276 | return false; |
---|
3277 | |
---|
3278 | char* pItemID = strtok(NULL, " "); |
---|
3279 | if (!pItemID) |
---|
3280 | return false; |
---|
3281 | |
---|
3282 | uint32 ItemID = atoi(pItemID); |
---|
3283 | uint32 SlotID = atoi(pSlotID); |
---|
3284 | |
---|
3285 | ItemPrototype* tmpItem = objmgr.GetItemPrototype(ItemID); |
---|
3286 | |
---|
3287 | bool added = false; |
---|
3288 | if(tmpItem) |
---|
3289 | { |
---|
3290 | switch(SlotID) |
---|
3291 | { |
---|
3292 | case 1: |
---|
3293 | pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, ItemID); |
---|
3294 | added = true; |
---|
3295 | break; |
---|
3296 | case 2: |
---|
3297 | pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_01, ItemID); |
---|
3298 | added = true; |
---|
3299 | break; |
---|
3300 | case 3: |
---|
3301 | pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_02, ItemID); |
---|
3302 | added = true; |
---|
3303 | break; |
---|
3304 | default: |
---|
3305 | PSendSysMessage(LANG_ITEM_SLOT_NOT_EXIST,SlotID); |
---|
3306 | added = false; |
---|
3307 | break; |
---|
3308 | } |
---|
3309 | if(added) |
---|
3310 | { |
---|
3311 | PSendSysMessage(LANG_ITEM_ADDED_TO_SLOT,ItemID,tmpItem->Name1,SlotID); |
---|
3312 | } |
---|
3313 | } |
---|
3314 | else |
---|
3315 | { |
---|
3316 | PSendSysMessage(LANG_ITEM_NOT_FOUND,ItemID); |
---|
3317 | return true; |
---|
3318 | } |
---|
3319 | */ |
---|
3320 | return true; |
---|
3321 | } |
---|
3322 | |
---|
3323 | bool ChatHandler::HandleDieCommand(const char* /*args*/) |
---|
3324 | { |
---|
3325 | Unit* target = getSelectedUnit(); |
---|
3326 | |
---|
3327 | if(!target || !m_session->GetPlayer()->GetSelection()) |
---|
3328 | { |
---|
3329 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
3330 | SetSentErrorMessage(true); |
---|
3331 | return false; |
---|
3332 | } |
---|
3333 | |
---|
3334 | if( target->isAlive() ) |
---|
3335 | { |
---|
3336 | m_session->GetPlayer()->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); |
---|
3337 | } |
---|
3338 | |
---|
3339 | return true; |
---|
3340 | } |
---|
3341 | |
---|
3342 | bool ChatHandler::HandleDamageCommand(const char * args) |
---|
3343 | { |
---|
3344 | if (!*args) |
---|
3345 | return false; |
---|
3346 | |
---|
3347 | Unit* target = getSelectedUnit(); |
---|
3348 | |
---|
3349 | if(!target || !m_session->GetPlayer()->GetSelection()) |
---|
3350 | { |
---|
3351 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
3352 | SetSentErrorMessage(true); |
---|
3353 | return false; |
---|
3354 | } |
---|
3355 | |
---|
3356 | if( !target->isAlive() ) |
---|
3357 | return true; |
---|
3358 | |
---|
3359 | char* damageStr = strtok((char*)args, " "); |
---|
3360 | if(!damageStr) |
---|
3361 | return false; |
---|
3362 | |
---|
3363 | int32 damage = atoi((char*)damageStr); |
---|
3364 | if(damage <=0) |
---|
3365 | return true; |
---|
3366 | |
---|
3367 | char* schoolStr = strtok((char*)NULL, " "); |
---|
3368 | |
---|
3369 | // flat melee damage without resistence/etc reduction |
---|
3370 | if(!schoolStr) |
---|
3371 | { |
---|
3372 | m_session->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); |
---|
3373 | m_session->GetPlayer()->SendAttackStateUpdate (HITINFO_NORMALSWING2, target, 1, SPELL_SCHOOL_MASK_NORMAL, damage, 0, 0, VICTIMSTATE_NORMAL, 0); |
---|
3374 | return true; |
---|
3375 | } |
---|
3376 | |
---|
3377 | uint32 school = schoolStr ? atoi((char*)schoolStr) : SPELL_SCHOOL_NORMAL; |
---|
3378 | if(school >= MAX_SPELL_SCHOOL) |
---|
3379 | return false; |
---|
3380 | |
---|
3381 | SpellSchoolMask schoolmask = SpellSchoolMask(1 << school); |
---|
3382 | |
---|
3383 | if ( schoolmask & SPELL_SCHOOL_MASK_NORMAL ) |
---|
3384 | damage = m_session->GetPlayer()->CalcArmorReducedDamage(target, damage); |
---|
3385 | |
---|
3386 | char* spellStr = strtok((char*)NULL, " "); |
---|
3387 | |
---|
3388 | // melee damage by specific school |
---|
3389 | if(!spellStr) |
---|
3390 | { |
---|
3391 | uint32 absorb = 0; |
---|
3392 | uint32 resist = 0; |
---|
3393 | |
---|
3394 | m_session->GetPlayer()->CalcAbsorbResist(target,schoolmask, SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); |
---|
3395 | |
---|
3396 | if (damage <= absorb + resist) |
---|
3397 | return true; |
---|
3398 | |
---|
3399 | damage -= absorb + resist; |
---|
3400 | |
---|
3401 | m_session->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, schoolmask, NULL, false); |
---|
3402 | m_session->GetPlayer()->SendAttackStateUpdate (HITINFO_NORMALSWING2, target, 1, schoolmask, damage, absorb, resist, VICTIMSTATE_NORMAL, 0); |
---|
3403 | return true; |
---|
3404 | } |
---|
3405 | |
---|
3406 | // non-melee damage |
---|
3407 | |
---|
3408 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form |
---|
3409 | uint32 spellid = extractSpellIdFromLink((char*)args); |
---|
3410 | if(!spellid || !sSpellStore.LookupEntry(spellid)) |
---|
3411 | return false; |
---|
3412 | |
---|
3413 | m_session->GetPlayer()->SpellNonMeleeDamageLog(target, spellid, damage, false); |
---|
3414 | return true; |
---|
3415 | } |
---|
3416 | |
---|
3417 | bool ChatHandler::HandleModifyArenaCommand(const char * args) |
---|
3418 | { |
---|
3419 | if (!*args) |
---|
3420 | return false; |
---|
3421 | |
---|
3422 | Player *target = getSelectedPlayer(); |
---|
3423 | if(!target) |
---|
3424 | { |
---|
3425 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
3426 | SetSentErrorMessage(true); |
---|
3427 | return false; |
---|
3428 | } |
---|
3429 | |
---|
3430 | int32 amount = (uint32)atoi(args); |
---|
3431 | |
---|
3432 | target->ModifyArenaPoints(amount); |
---|
3433 | |
---|
3434 | PSendSysMessage(LANG_COMMAND_MODIFY_ARENA, target->GetName(), target->GetArenaPoints()); |
---|
3435 | |
---|
3436 | return true; |
---|
3437 | } |
---|
3438 | |
---|
3439 | bool ChatHandler::HandleReviveCommand(const char* args) |
---|
3440 | { |
---|
3441 | Player* SelectedPlayer = NULL; |
---|
3442 | |
---|
3443 | if (*args) |
---|
3444 | { |
---|
3445 | std::string name = args; |
---|
3446 | if(!normalizePlayerName(name)) |
---|
3447 | { |
---|
3448 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
3449 | SetSentErrorMessage(true); |
---|
3450 | return false; |
---|
3451 | } |
---|
3452 | |
---|
3453 | SelectedPlayer = objmgr.GetPlayer(name.c_str()); |
---|
3454 | } |
---|
3455 | else |
---|
3456 | SelectedPlayer = getSelectedPlayer(); |
---|
3457 | |
---|
3458 | if(!SelectedPlayer) |
---|
3459 | { |
---|
3460 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
3461 | SetSentErrorMessage(true); |
---|
3462 | return false; |
---|
3463 | } |
---|
3464 | |
---|
3465 | SelectedPlayer->ResurrectPlayer(0.5f); |
---|
3466 | SelectedPlayer->SpawnCorpseBones(); |
---|
3467 | SelectedPlayer->SaveToDB(); |
---|
3468 | return true; |
---|
3469 | } |
---|
3470 | |
---|
3471 | bool ChatHandler::HandleAuraCommand(const char* args) |
---|
3472 | { |
---|
3473 | char* px = strtok((char*)args, " "); |
---|
3474 | if (!px) |
---|
3475 | return false; |
---|
3476 | |
---|
3477 | Unit *target = getSelectedUnit(); |
---|
3478 | if(!target) |
---|
3479 | { |
---|
3480 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
3481 | SetSentErrorMessage(true); |
---|
3482 | return false; |
---|
3483 | } |
---|
3484 | |
---|
3485 | uint32 spellID = (uint32)atoi(px); |
---|
3486 | SpellEntry const *spellInfo = sSpellStore.LookupEntry( spellID ); |
---|
3487 | if(spellInfo) |
---|
3488 | { |
---|
3489 | for(uint32 i = 0;i<3;i++) |
---|
3490 | { |
---|
3491 | uint8 eff = spellInfo->Effect[i]; |
---|
3492 | if (eff>=TOTAL_SPELL_EFFECTS) |
---|
3493 | continue; |
---|
3494 | if( IsAreaAuraEffect(eff) || |
---|
3495 | eff == SPELL_EFFECT_APPLY_AURA || |
---|
3496 | eff == SPELL_EFFECT_PERSISTENT_AREA_AURA ) |
---|
3497 | { |
---|
3498 | Aura *Aur = CreateAura(spellInfo, i, NULL, target); |
---|
3499 | target->AddAura(Aur); |
---|
3500 | } |
---|
3501 | } |
---|
3502 | } |
---|
3503 | |
---|
3504 | return true; |
---|
3505 | } |
---|
3506 | |
---|
3507 | bool ChatHandler::HandleUnAuraCommand(const char* args) |
---|
3508 | { |
---|
3509 | char* px = strtok((char*)args, " "); |
---|
3510 | if (!px) |
---|
3511 | return false; |
---|
3512 | |
---|
3513 | Unit *target = getSelectedUnit(); |
---|
3514 | if(!target) |
---|
3515 | { |
---|
3516 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
3517 | SetSentErrorMessage(true); |
---|
3518 | return false; |
---|
3519 | } |
---|
3520 | |
---|
3521 | std::string argstr = args; |
---|
3522 | if (argstr == "all") |
---|
3523 | { |
---|
3524 | target->RemoveAllAuras(); |
---|
3525 | return true; |
---|
3526 | } |
---|
3527 | |
---|
3528 | uint32 spellID = (uint32)atoi(px); |
---|
3529 | target->RemoveAurasDueToSpell(spellID); |
---|
3530 | |
---|
3531 | return true; |
---|
3532 | } |
---|
3533 | |
---|
3534 | bool ChatHandler::HandleLinkGraveCommand(const char* args) |
---|
3535 | { |
---|
3536 | if(!*args) |
---|
3537 | return false; |
---|
3538 | |
---|
3539 | char* px = strtok((char*)args, " "); |
---|
3540 | if (!px) |
---|
3541 | return false; |
---|
3542 | |
---|
3543 | uint32 g_id = (uint32)atoi(px); |
---|
3544 | |
---|
3545 | uint32 g_team; |
---|
3546 | |
---|
3547 | char* px2 = strtok(NULL, " "); |
---|
3548 | |
---|
3549 | if (!px2) |
---|
3550 | g_team = 0; |
---|
3551 | else if (strncmp(px2,"horde",6)==0) |
---|
3552 | g_team = HORDE; |
---|
3553 | else if (strncmp(px2,"alliance",9)==0) |
---|
3554 | g_team = ALLIANCE; |
---|
3555 | else |
---|
3556 | return false; |
---|
3557 | |
---|
3558 | WorldSafeLocsEntry const* graveyard = sWorldSafeLocsStore.LookupEntry(g_id); |
---|
3559 | |
---|
3560 | if(!graveyard ) |
---|
3561 | { |
---|
3562 | PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST, g_id); |
---|
3563 | SetSentErrorMessage(true); |
---|
3564 | return false; |
---|
3565 | } |
---|
3566 | |
---|
3567 | Player* player = m_session->GetPlayer(); |
---|
3568 | |
---|
3569 | uint32 zoneId = player->GetZoneId(); |
---|
3570 | |
---|
3571 | AreaTableEntry const *areaEntry = GetAreaEntryByAreaID(zoneId); |
---|
3572 | if(!areaEntry || areaEntry->zone !=0 ) |
---|
3573 | { |
---|
3574 | PSendSysMessage(LANG_COMMAND_GRAVEYARDWRONGZONE, g_id,zoneId); |
---|
3575 | SetSentErrorMessage(true); |
---|
3576 | return false; |
---|
3577 | } |
---|
3578 | |
---|
3579 | if(graveyard->map_id != areaEntry->mapid && g_team != 0) |
---|
3580 | { |
---|
3581 | SendSysMessage(LANG_COMMAND_GRAVEYARDWRONGTEAM); |
---|
3582 | SetSentErrorMessage(true); |
---|
3583 | return false; |
---|
3584 | } |
---|
3585 | |
---|
3586 | if(objmgr.AddGraveYardLink(g_id,player->GetZoneId(),g_team)) |
---|
3587 | PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED, g_id,zoneId); |
---|
3588 | else |
---|
3589 | PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED, g_id,zoneId); |
---|
3590 | |
---|
3591 | return true; |
---|
3592 | } |
---|
3593 | |
---|
3594 | bool ChatHandler::HandleNearGraveCommand(const char* args) |
---|
3595 | { |
---|
3596 | uint32 g_team; |
---|
3597 | |
---|
3598 | size_t argslen = strlen(args); |
---|
3599 | |
---|
3600 | if(!*args) |
---|
3601 | g_team = 0; |
---|
3602 | else if (strncmp((char*)args,"horde",argslen)==0) |
---|
3603 | g_team = HORDE; |
---|
3604 | else if (strncmp((char*)args,"alliance",argslen)==0) |
---|
3605 | g_team = ALLIANCE; |
---|
3606 | else |
---|
3607 | return false; |
---|
3608 | |
---|
3609 | Player* player = m_session->GetPlayer(); |
---|
3610 | |
---|
3611 | WorldSafeLocsEntry const* graveyard = objmgr.GetClosestGraveYard( |
---|
3612 | player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(),player->GetMapId(),g_team); |
---|
3613 | |
---|
3614 | if(graveyard) |
---|
3615 | { |
---|
3616 | uint32 g_id = graveyard->ID; |
---|
3617 | |
---|
3618 | GraveYardData const* data = objmgr.FindGraveYardData(g_id,player->GetZoneId()); |
---|
3619 | if (!data) |
---|
3620 | { |
---|
3621 | PSendSysMessage(LANG_COMMAND_GRAVEYARDERROR,g_id); |
---|
3622 | SetSentErrorMessage(true); |
---|
3623 | return false; |
---|
3624 | } |
---|
3625 | |
---|
3626 | g_team = data->team; |
---|
3627 | |
---|
3628 | std::string team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_NOTEAM); |
---|
3629 | |
---|
3630 | if(g_team == 0) |
---|
3631 | team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_ANY); |
---|
3632 | else if(g_team == HORDE) |
---|
3633 | team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_HORDE); |
---|
3634 | else if(g_team == ALLIANCE) |
---|
3635 | team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_ALLIANCE); |
---|
3636 | |
---|
3637 | PSendSysMessage(LANG_COMMAND_GRAVEYARDNEAREST, g_id,team_name.c_str(),player->GetZoneId()); |
---|
3638 | } |
---|
3639 | else |
---|
3640 | { |
---|
3641 | std::string team_name; |
---|
3642 | |
---|
3643 | if(g_team == 0) |
---|
3644 | team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_ANY); |
---|
3645 | else if(g_team == HORDE) |
---|
3646 | team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_HORDE); |
---|
3647 | else if(g_team == ALLIANCE) |
---|
3648 | team_name = GetTrinityString(LANG_COMMAND_GRAVEYARD_ALLIANCE); |
---|
3649 | |
---|
3650 | if(g_team == ~uint32(0)) |
---|
3651 | PSendSysMessage(LANG_COMMAND_ZONENOGRAVEYARDS, player->GetZoneId()); |
---|
3652 | else |
---|
3653 | PSendSysMessage(LANG_COMMAND_ZONENOGRAFACTION, player->GetZoneId(),team_name.c_str()); |
---|
3654 | } |
---|
3655 | |
---|
3656 | return true; |
---|
3657 | } |
---|
3658 | |
---|
3659 | //play npc emote |
---|
3660 | bool ChatHandler::HandlePlayEmoteCommand(const char* args) |
---|
3661 | { |
---|
3662 | uint32 emote = atoi((char*)args); |
---|
3663 | |
---|
3664 | Creature* target = getSelectedCreature(); |
---|
3665 | if(!target) |
---|
3666 | { |
---|
3667 | SendSysMessage(LANG_SELECT_CREATURE); |
---|
3668 | SetSentErrorMessage(true); |
---|
3669 | return false; |
---|
3670 | } |
---|
3671 | |
---|
3672 | target->SetUInt32Value(UNIT_NPC_EMOTESTATE,emote); |
---|
3673 | |
---|
3674 | return true; |
---|
3675 | } |
---|
3676 | |
---|
3677 | bool ChatHandler::HandleNpcInfoCommand(const char* /*args*/) |
---|
3678 | { |
---|
3679 | Creature* target = getSelectedCreature(); |
---|
3680 | |
---|
3681 | if(!target) |
---|
3682 | { |
---|
3683 | SendSysMessage(LANG_SELECT_CREATURE); |
---|
3684 | SetSentErrorMessage(true); |
---|
3685 | return false; |
---|
3686 | } |
---|
3687 | |
---|
3688 | uint32 faction = target->getFaction(); |
---|
3689 | uint32 npcflags = target->GetUInt32Value(UNIT_NPC_FLAGS); |
---|
3690 | uint32 displayid = target->GetDisplayId(); |
---|
3691 | uint32 nativeid = target->GetNativeDisplayId(); |
---|
3692 | uint32 Entry = target->GetEntry(); |
---|
3693 | CreatureInfo const* cInfo = target->GetCreatureInfo(); |
---|
3694 | |
---|
3695 | int32 curRespawnDelay = target->GetRespawnTimeEx()-time(NULL); |
---|
3696 | if(curRespawnDelay < 0) |
---|
3697 | curRespawnDelay = 0; |
---|
3698 | std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay,true); |
---|
3699 | std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true); |
---|
3700 | |
---|
3701 | PSendSysMessage(LANG_NPCINFO_CHAR, target->GetDBTableGUIDLow(), faction, npcflags, Entry, displayid, nativeid); |
---|
3702 | PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel()); |
---|
3703 | PSendSysMessage(LANG_NPCINFO_HEALTH,target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth()); |
---|
3704 | PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUInt32Value(UNIT_FIELD_FLAGS), target->GetUInt32Value(UNIT_DYNAMIC_FLAGS), target->getFaction()); |
---|
3705 | PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str()); |
---|
3706 | PSendSysMessage(LANG_NPCINFO_LOOT, cInfo->lootid,cInfo->pickpocketLootId,cInfo->SkinLootId); |
---|
3707 | PSendSysMessage(LANG_NPCINFO_DUNGEON_ID, target->GetInstanceId()); |
---|
3708 | PSendSysMessage(LANG_NPCINFO_POSITION,float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ())); |
---|
3709 | |
---|
3710 | if ((npcflags & UNIT_NPC_FLAG_VENDOR) ) |
---|
3711 | { |
---|
3712 | SendSysMessage(LANG_NPCINFO_VENDOR); |
---|
3713 | } |
---|
3714 | if ((npcflags & UNIT_NPC_FLAG_TRAINER) ) |
---|
3715 | { |
---|
3716 | SendSysMessage(LANG_NPCINFO_TRAINER); |
---|
3717 | } |
---|
3718 | |
---|
3719 | return true; |
---|
3720 | } |
---|
3721 | |
---|
3722 | bool ChatHandler::HandleExploreCheatCommand(const char* args) |
---|
3723 | { |
---|
3724 | if (!*args) |
---|
3725 | return false; |
---|
3726 | |
---|
3727 | int flag = atoi((char*)args); |
---|
3728 | |
---|
3729 | Player *chr = getSelectedPlayer(); |
---|
3730 | if (chr == NULL) |
---|
3731 | { |
---|
3732 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
3733 | SetSentErrorMessage(true); |
---|
3734 | return false; |
---|
3735 | } |
---|
3736 | |
---|
3737 | if (flag != 0) |
---|
3738 | { |
---|
3739 | PSendSysMessage(LANG_YOU_SET_EXPLORE_ALL, chr->GetName()); |
---|
3740 | if (needReportToTarget(chr)) |
---|
3741 | ChatHandler(chr).PSendSysMessage(LANG_YOURS_EXPLORE_SET_ALL,GetName()); |
---|
3742 | } |
---|
3743 | else |
---|
3744 | { |
---|
3745 | PSendSysMessage(LANG_YOU_SET_EXPLORE_NOTHING, chr->GetName()); |
---|
3746 | if (needReportToTarget(chr)) |
---|
3747 | ChatHandler(chr).PSendSysMessage(LANG_YOURS_EXPLORE_SET_NOTHING,GetName()); |
---|
3748 | } |
---|
3749 | |
---|
3750 | for (uint8 i=0; i<128; i++) |
---|
3751 | { |
---|
3752 | if (flag != 0) |
---|
3753 | { |
---|
3754 | m_session->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1+i,0xFFFFFFFF); |
---|
3755 | } |
---|
3756 | else |
---|
3757 | { |
---|
3758 | m_session->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1+i,0); |
---|
3759 | } |
---|
3760 | } |
---|
3761 | |
---|
3762 | return true; |
---|
3763 | } |
---|
3764 | |
---|
3765 | bool ChatHandler::HandleHoverCommand(const char* args) |
---|
3766 | { |
---|
3767 | char* px = strtok((char*)args, " "); |
---|
3768 | uint32 flag; |
---|
3769 | if (!px) |
---|
3770 | flag = 1; |
---|
3771 | else |
---|
3772 | flag = atoi(px); |
---|
3773 | |
---|
3774 | m_session->GetPlayer()->SetHover(flag); |
---|
3775 | |
---|
3776 | if (flag) |
---|
3777 | SendSysMessage(LANG_HOVER_ENABLED); |
---|
3778 | else |
---|
3779 | SendSysMessage(LANG_HOVER_DISABLED); |
---|
3780 | |
---|
3781 | return true; |
---|
3782 | } |
---|
3783 | |
---|
3784 | bool ChatHandler::HandleWaterwalkCommand(const char* args) |
---|
3785 | { |
---|
3786 | if(!args) |
---|
3787 | return false; |
---|
3788 | |
---|
3789 | Player *player = getSelectedPlayer(); |
---|
3790 | if(!player) |
---|
3791 | { |
---|
3792 | PSendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
3793 | SetSentErrorMessage(true); |
---|
3794 | return false; |
---|
3795 | } |
---|
3796 | |
---|
3797 | if (strncmp(args, "on", 3) == 0) |
---|
3798 | player->SetMovement(MOVE_WATER_WALK); // ON |
---|
3799 | else if (strncmp(args, "off", 4) == 0) |
---|
3800 | player->SetMovement(MOVE_LAND_WALK); // OFF |
---|
3801 | else |
---|
3802 | { |
---|
3803 | SendSysMessage(LANG_USE_BOL); |
---|
3804 | return false; |
---|
3805 | } |
---|
3806 | |
---|
3807 | PSendSysMessage(LANG_YOU_SET_WATERWALK, args, player->GetName()); |
---|
3808 | if(needReportToTarget(player)) |
---|
3809 | ChatHandler(player).PSendSysMessage(LANG_YOUR_WATERWALK_SET, args, GetName()); |
---|
3810 | return true; |
---|
3811 | |
---|
3812 | } |
---|
3813 | |
---|
3814 | bool ChatHandler::HandleLevelUpCommand(const char* args) |
---|
3815 | { |
---|
3816 | char* px = strtok((char*)args, " "); |
---|
3817 | char* py = strtok((char*)NULL, " "); |
---|
3818 | |
---|
3819 | // command format parsing |
---|
3820 | char* pname = (char*)NULL; |
---|
3821 | int addlevel = 1; |
---|
3822 | |
---|
3823 | if(px && py) // .levelup name level |
---|
3824 | { |
---|
3825 | addlevel = atoi(py); |
---|
3826 | pname = px; |
---|
3827 | } |
---|
3828 | else if(px && !py) // .levelup name OR .levelup level |
---|
3829 | { |
---|
3830 | if(isalpha(px[0])) // .levelup name |
---|
3831 | pname = px; |
---|
3832 | else // .levelup level |
---|
3833 | addlevel = atoi(px); |
---|
3834 | } |
---|
3835 | // else .levelup - nothing do for prepering |
---|
3836 | |
---|
3837 | // player |
---|
3838 | Player *chr = NULL; |
---|
3839 | uint64 chr_guid = 0; |
---|
3840 | |
---|
3841 | std::string name; |
---|
3842 | |
---|
3843 | if(pname) // player by name |
---|
3844 | { |
---|
3845 | name = pname; |
---|
3846 | if(!normalizePlayerName(name)) |
---|
3847 | { |
---|
3848 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
3849 | SetSentErrorMessage(true); |
---|
3850 | return false; |
---|
3851 | } |
---|
3852 | |
---|
3853 | chr = objmgr.GetPlayer(name.c_str()); |
---|
3854 | if(!chr) // not in game |
---|
3855 | { |
---|
3856 | chr_guid = objmgr.GetPlayerGUIDByName(name); |
---|
3857 | if (chr_guid == 0) |
---|
3858 | { |
---|
3859 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
3860 | SetSentErrorMessage(true); |
---|
3861 | return false; |
---|
3862 | } |
---|
3863 | } |
---|
3864 | } |
---|
3865 | else // player by selection |
---|
3866 | { |
---|
3867 | chr = getSelectedPlayer(); |
---|
3868 | |
---|
3869 | if (chr == NULL) |
---|
3870 | { |
---|
3871 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
3872 | SetSentErrorMessage(true); |
---|
3873 | return false; |
---|
3874 | } |
---|
3875 | |
---|
3876 | name = chr->GetName(); |
---|
3877 | } |
---|
3878 | |
---|
3879 | assert(chr || chr_guid); |
---|
3880 | |
---|
3881 | int32 oldlevel = chr ? chr->getLevel() : Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL,chr_guid); |
---|
3882 | int32 newlevel = oldlevel + addlevel; |
---|
3883 | if(newlevel < 1) |
---|
3884 | newlevel = 1; |
---|
3885 | if(newlevel > 255) // hardcoded maximum level |
---|
3886 | newlevel = 255; |
---|
3887 | |
---|
3888 | if(chr) |
---|
3889 | { |
---|
3890 | chr->GiveLevel(newlevel); |
---|
3891 | chr->InitTalentForLevel(); |
---|
3892 | chr->SetUInt32Value(PLAYER_XP,0); |
---|
3893 | |
---|
3894 | if(oldlevel == newlevel) |
---|
3895 | ChatHandler(chr).SendSysMessage(LANG_YOURS_LEVEL_PROGRESS_RESET); |
---|
3896 | else |
---|
3897 | if(oldlevel < newlevel) |
---|
3898 | ChatHandler(chr).PSendSysMessage(LANG_YOURS_LEVEL_UP,newlevel-oldlevel); |
---|
3899 | else |
---|
3900 | if(oldlevel > newlevel) |
---|
3901 | ChatHandler(chr).PSendSysMessage(LANG_YOURS_LEVEL_DOWN,newlevel-oldlevel); |
---|
3902 | } |
---|
3903 | else |
---|
3904 | { |
---|
3905 | // update levle and XP at level, all other will be updated at loading |
---|
3906 | Tokens values; |
---|
3907 | Player::LoadValuesArrayFromDB(values,chr_guid); |
---|
3908 | Player::SetUInt32ValueInArray(values,UNIT_FIELD_LEVEL,newlevel); |
---|
3909 | Player::SetUInt32ValueInArray(values,PLAYER_XP,0); |
---|
3910 | Player::SaveValuesArrayInDB(values,chr_guid); |
---|
3911 | } |
---|
3912 | |
---|
3913 | if(m_session->GetPlayer() != chr) // including chr==NULL |
---|
3914 | PSendSysMessage(LANG_YOU_CHANGE_LVL,name.c_str(),newlevel); |
---|
3915 | return true; |
---|
3916 | } |
---|
3917 | |
---|
3918 | bool ChatHandler::HandleShowAreaCommand(const char* args) |
---|
3919 | { |
---|
3920 | if (!*args) |
---|
3921 | return false; |
---|
3922 | |
---|
3923 | int area = atoi((char*)args); |
---|
3924 | |
---|
3925 | Player *chr = getSelectedPlayer(); |
---|
3926 | if (chr == NULL) |
---|
3927 | { |
---|
3928 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
3929 | SetSentErrorMessage(true); |
---|
3930 | return false; |
---|
3931 | } |
---|
3932 | |
---|
3933 | int offset = area / 32; |
---|
3934 | uint32 val = (uint32)(1 << (area % 32)); |
---|
3935 | |
---|
3936 | if(offset >= 128) |
---|
3937 | { |
---|
3938 | SendSysMessage(LANG_BAD_VALUE); |
---|
3939 | SetSentErrorMessage(true); |
---|
3940 | return false; |
---|
3941 | } |
---|
3942 | |
---|
3943 | uint32 currFields = chr->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset); |
---|
3944 | chr->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, (uint32)(currFields | val)); |
---|
3945 | |
---|
3946 | SendSysMessage(LANG_EXPLORE_AREA); |
---|
3947 | return true; |
---|
3948 | } |
---|
3949 | |
---|
3950 | bool ChatHandler::HandleHideAreaCommand(const char* args) |
---|
3951 | { |
---|
3952 | if (!*args) |
---|
3953 | return false; |
---|
3954 | |
---|
3955 | int area = atoi((char*)args); |
---|
3956 | |
---|
3957 | Player *chr = getSelectedPlayer(); |
---|
3958 | if (chr == NULL) |
---|
3959 | { |
---|
3960 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
3961 | SetSentErrorMessage(true); |
---|
3962 | return false; |
---|
3963 | } |
---|
3964 | |
---|
3965 | int offset = area / 32; |
---|
3966 | uint32 val = (uint32)(1 << (area % 32)); |
---|
3967 | |
---|
3968 | if(offset >= 128) |
---|
3969 | { |
---|
3970 | SendSysMessage(LANG_BAD_VALUE); |
---|
3971 | SetSentErrorMessage(true); |
---|
3972 | return false; |
---|
3973 | } |
---|
3974 | |
---|
3975 | uint32 currFields = chr->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset); |
---|
3976 | chr->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, (uint32)(currFields ^ val)); |
---|
3977 | |
---|
3978 | SendSysMessage(LANG_UNEXPLORE_AREA); |
---|
3979 | return true; |
---|
3980 | } |
---|
3981 | |
---|
3982 | bool ChatHandler::HandleUpdate(const char* args) |
---|
3983 | { |
---|
3984 | if(!*args) |
---|
3985 | return false; |
---|
3986 | |
---|
3987 | uint32 updateIndex; |
---|
3988 | uint32 value; |
---|
3989 | |
---|
3990 | char* pUpdateIndex = strtok((char*)args, " "); |
---|
3991 | |
---|
3992 | Unit* chr = getSelectedUnit(); |
---|
3993 | if (chr == NULL) |
---|
3994 | { |
---|
3995 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
3996 | SetSentErrorMessage(true); |
---|
3997 | return false; |
---|
3998 | } |
---|
3999 | |
---|
4000 | if(!pUpdateIndex) |
---|
4001 | { |
---|
4002 | return true; |
---|
4003 | } |
---|
4004 | updateIndex = atoi(pUpdateIndex); |
---|
4005 | //check updateIndex |
---|
4006 | if(chr->GetTypeId() == TYPEID_PLAYER) |
---|
4007 | { |
---|
4008 | if (updateIndex>=PLAYER_END) return true; |
---|
4009 | } |
---|
4010 | else |
---|
4011 | { |
---|
4012 | if (updateIndex>=UNIT_END) return true; |
---|
4013 | } |
---|
4014 | |
---|
4015 | char* pvalue = strtok(NULL, " "); |
---|
4016 | if (!pvalue) |
---|
4017 | { |
---|
4018 | value=chr->GetUInt32Value(updateIndex); |
---|
4019 | |
---|
4020 | PSendSysMessage(LANG_UPDATE, chr->GetGUIDLow(),updateIndex,value); |
---|
4021 | return true; |
---|
4022 | } |
---|
4023 | |
---|
4024 | value=atoi(pvalue); |
---|
4025 | |
---|
4026 | PSendSysMessage(LANG_UPDATE_CHANGE, chr->GetGUIDLow(),updateIndex,value); |
---|
4027 | |
---|
4028 | chr->SetUInt32Value(updateIndex,value); |
---|
4029 | |
---|
4030 | return true; |
---|
4031 | } |
---|
4032 | |
---|
4033 | bool ChatHandler::HandleBankCommand(const char* /*args*/) |
---|
4034 | { |
---|
4035 | m_session->SendShowBank( m_session->GetPlayer()->GetGUID() ); |
---|
4036 | |
---|
4037 | return true; |
---|
4038 | } |
---|
4039 | |
---|
4040 | bool ChatHandler::HandleChangeWeather(const char* args) |
---|
4041 | { |
---|
4042 | if(!*args) |
---|
4043 | return false; |
---|
4044 | |
---|
4045 | //Weather is OFF |
---|
4046 | if (!sWorld.getConfig(CONFIG_WEATHER)) |
---|
4047 | { |
---|
4048 | SendSysMessage(LANG_WEATHER_DISABLED); |
---|
4049 | SetSentErrorMessage(true); |
---|
4050 | return false; |
---|
4051 | } |
---|
4052 | |
---|
4053 | //*Change the weather of a cell |
---|
4054 | char* px = strtok((char*)args, " "); |
---|
4055 | char* py = strtok(NULL, " "); |
---|
4056 | |
---|
4057 | if (!px || !py) |
---|
4058 | return false; |
---|
4059 | |
---|
4060 | uint32 type = (uint32)atoi(px); //0 to 3, 0: fine, 1: rain, 2: snow, 3: sand |
---|
4061 | float grade = (float)atof(py); //0 to 1, sending -1 is instand good weather |
---|
4062 | |
---|
4063 | Player *player = m_session->GetPlayer(); |
---|
4064 | uint32 zoneid = player->GetZoneId(); |
---|
4065 | |
---|
4066 | Weather* wth = sWorld.FindWeather(zoneid); |
---|
4067 | |
---|
4068 | if(!wth) |
---|
4069 | wth = sWorld.AddWeather(zoneid); |
---|
4070 | if(!wth) |
---|
4071 | { |
---|
4072 | SendSysMessage(LANG_NO_WEATHER); |
---|
4073 | SetSentErrorMessage(true); |
---|
4074 | return false; |
---|
4075 | } |
---|
4076 | |
---|
4077 | wth->SetWeather(WeatherType(type), grade); |
---|
4078 | |
---|
4079 | return true; |
---|
4080 | } |
---|
4081 | |
---|
4082 | bool ChatHandler::HandleSetValue(const char* args) |
---|
4083 | { |
---|
4084 | if(!*args) |
---|
4085 | return false; |
---|
4086 | |
---|
4087 | char* px = strtok((char*)args, " "); |
---|
4088 | char* py = strtok(NULL, " "); |
---|
4089 | char* pz = strtok(NULL, " "); |
---|
4090 | |
---|
4091 | if (!px || !py) |
---|
4092 | return false; |
---|
4093 | |
---|
4094 | Unit* target = getSelectedUnit(); |
---|
4095 | if(!target) |
---|
4096 | { |
---|
4097 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
4098 | SetSentErrorMessage(true); |
---|
4099 | return false; |
---|
4100 | } |
---|
4101 | |
---|
4102 | uint64 guid = target->GetGUID(); |
---|
4103 | |
---|
4104 | uint32 Opcode = (uint32)atoi(px); |
---|
4105 | if(Opcode >= target->GetValuesCount()) |
---|
4106 | { |
---|
4107 | PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); |
---|
4108 | return false; |
---|
4109 | } |
---|
4110 | uint32 iValue; |
---|
4111 | float fValue; |
---|
4112 | bool isint32 = true; |
---|
4113 | if(pz) |
---|
4114 | isint32 = (bool)atoi(pz); |
---|
4115 | if(isint32) |
---|
4116 | { |
---|
4117 | iValue = (uint32)atoi(py); |
---|
4118 | sLog.outDebug(GetTrinityString(LANG_SET_UINT), GUID_LOPART(guid), Opcode, iValue); |
---|
4119 | target->SetUInt32Value( Opcode , iValue ); |
---|
4120 | PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), Opcode,iValue); |
---|
4121 | } |
---|
4122 | else |
---|
4123 | { |
---|
4124 | fValue = (float)atof(py); |
---|
4125 | sLog.outDebug(GetTrinityString(LANG_SET_FLOAT), GUID_LOPART(guid), Opcode, fValue); |
---|
4126 | target->SetFloatValue( Opcode , fValue ); |
---|
4127 | PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), Opcode,fValue); |
---|
4128 | } |
---|
4129 | |
---|
4130 | return true; |
---|
4131 | } |
---|
4132 | |
---|
4133 | bool ChatHandler::HandleGetValue(const char* args) |
---|
4134 | { |
---|
4135 | if(!*args) |
---|
4136 | return false; |
---|
4137 | |
---|
4138 | char* px = strtok((char*)args, " "); |
---|
4139 | char* pz = strtok(NULL, " "); |
---|
4140 | |
---|
4141 | if (!px) |
---|
4142 | return false; |
---|
4143 | |
---|
4144 | Unit* target = getSelectedUnit(); |
---|
4145 | if(!target) |
---|
4146 | { |
---|
4147 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
4148 | SetSentErrorMessage(true); |
---|
4149 | return false; |
---|
4150 | } |
---|
4151 | |
---|
4152 | uint64 guid = target->GetGUID(); |
---|
4153 | |
---|
4154 | uint32 Opcode = (uint32)atoi(px); |
---|
4155 | if(Opcode >= target->GetValuesCount()) |
---|
4156 | { |
---|
4157 | PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); |
---|
4158 | return false; |
---|
4159 | } |
---|
4160 | uint32 iValue; |
---|
4161 | float fValue; |
---|
4162 | bool isint32 = true; |
---|
4163 | if(pz) |
---|
4164 | isint32 = (bool)atoi(pz); |
---|
4165 | |
---|
4166 | if(isint32) |
---|
4167 | { |
---|
4168 | iValue = target->GetUInt32Value( Opcode ); |
---|
4169 | sLog.outDebug(GetTrinityString(LANG_GET_UINT), GUID_LOPART(guid), Opcode, iValue); |
---|
4170 | PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), Opcode, iValue); |
---|
4171 | } |
---|
4172 | else |
---|
4173 | { |
---|
4174 | fValue = target->GetFloatValue( Opcode ); |
---|
4175 | sLog.outDebug(GetTrinityString(LANG_GET_FLOAT), GUID_LOPART(guid), Opcode, fValue); |
---|
4176 | PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), Opcode, fValue); |
---|
4177 | } |
---|
4178 | |
---|
4179 | return true; |
---|
4180 | } |
---|
4181 | |
---|
4182 | bool ChatHandler::HandleSet32Bit(const char* args) |
---|
4183 | { |
---|
4184 | if(!*args) |
---|
4185 | return false; |
---|
4186 | |
---|
4187 | char* px = strtok((char*)args, " "); |
---|
4188 | char* py = strtok(NULL, " "); |
---|
4189 | |
---|
4190 | if (!px || !py) |
---|
4191 | return false; |
---|
4192 | |
---|
4193 | uint32 Opcode = (uint32)atoi(px); |
---|
4194 | uint32 Value = (uint32)atoi(py); |
---|
4195 | if (Value > 32) //uint32 = 32 bits |
---|
4196 | return false; |
---|
4197 | |
---|
4198 | sLog.outDebug(GetTrinityString(LANG_SET_32BIT), Opcode, Value); |
---|
4199 | |
---|
4200 | m_session->GetPlayer( )->SetUInt32Value( Opcode , 2^Value ); |
---|
4201 | |
---|
4202 | PSendSysMessage(LANG_SET_32BIT_FIELD, Opcode,1); |
---|
4203 | return true; |
---|
4204 | } |
---|
4205 | |
---|
4206 | bool ChatHandler::HandleMod32Value(const char* args) |
---|
4207 | { |
---|
4208 | if(!*args) |
---|
4209 | return false; |
---|
4210 | |
---|
4211 | char* px = strtok((char*)args, " "); |
---|
4212 | char* py = strtok(NULL, " "); |
---|
4213 | |
---|
4214 | if (!px || !py) |
---|
4215 | return false; |
---|
4216 | |
---|
4217 | uint32 Opcode = (uint32)atoi(px); |
---|
4218 | int Value = atoi(py); |
---|
4219 | |
---|
4220 | if(Opcode >= m_session->GetPlayer()->GetValuesCount()) |
---|
4221 | { |
---|
4222 | PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, m_session->GetPlayer()->GetGUIDLow(), m_session->GetPlayer( )->GetValuesCount()); |
---|
4223 | return false; |
---|
4224 | } |
---|
4225 | |
---|
4226 | sLog.outDebug(GetTrinityString(LANG_CHANGE_32BIT), Opcode, Value); |
---|
4227 | |
---|
4228 | int CurrentValue = (int)m_session->GetPlayer( )->GetUInt32Value( Opcode ); |
---|
4229 | |
---|
4230 | CurrentValue += Value; |
---|
4231 | m_session->GetPlayer( )->SetUInt32Value( Opcode , (uint32)CurrentValue ); |
---|
4232 | |
---|
4233 | PSendSysMessage(LANG_CHANGE_32BIT_FIELD, Opcode,CurrentValue); |
---|
4234 | |
---|
4235 | return true; |
---|
4236 | } |
---|
4237 | |
---|
4238 | bool ChatHandler::HandleAddTeleCommand(const char * args) |
---|
4239 | { |
---|
4240 | if(!*args) |
---|
4241 | return false; |
---|
4242 | |
---|
4243 | Player *player=m_session->GetPlayer(); |
---|
4244 | if (!player) |
---|
4245 | return false; |
---|
4246 | |
---|
4247 | std::string name = args; |
---|
4248 | |
---|
4249 | if(objmgr.GetGameTele(name)) |
---|
4250 | { |
---|
4251 | SendSysMessage(LANG_COMMAND_TP_ALREADYEXIST); |
---|
4252 | SetSentErrorMessage(true); |
---|
4253 | return false; |
---|
4254 | } |
---|
4255 | |
---|
4256 | GameTele tele; |
---|
4257 | tele.position_x = player->GetPositionX(); |
---|
4258 | tele.position_y = player->GetPositionY(); |
---|
4259 | tele.position_z = player->GetPositionZ(); |
---|
4260 | tele.orientation = player->GetOrientation(); |
---|
4261 | tele.mapId = player->GetMapId(); |
---|
4262 | tele.name = name; |
---|
4263 | |
---|
4264 | if(objmgr.AddGameTele(tele)) |
---|
4265 | { |
---|
4266 | SendSysMessage(LANG_COMMAND_TP_ADDED); |
---|
4267 | } |
---|
4268 | else |
---|
4269 | { |
---|
4270 | SendSysMessage(LANG_COMMAND_TP_ADDEDERR); |
---|
4271 | SetSentErrorMessage(true); |
---|
4272 | return false; |
---|
4273 | } |
---|
4274 | |
---|
4275 | return true; |
---|
4276 | } |
---|
4277 | |
---|
4278 | bool ChatHandler::HandleDelTeleCommand(const char * args) |
---|
4279 | { |
---|
4280 | if(!*args) |
---|
4281 | return false; |
---|
4282 | |
---|
4283 | std::string name = args; |
---|
4284 | |
---|
4285 | if(!objmgr.DeleteGameTele(name)) |
---|
4286 | { |
---|
4287 | SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); |
---|
4288 | SetSentErrorMessage(true); |
---|
4289 | return false; |
---|
4290 | } |
---|
4291 | |
---|
4292 | SendSysMessage(LANG_COMMAND_TP_DELETED); |
---|
4293 | return true; |
---|
4294 | } |
---|
4295 | |
---|
4296 | bool ChatHandler::HandleListAurasCommand (const char * /*args*/) |
---|
4297 | { |
---|
4298 | Unit *unit = getSelectedUnit(); |
---|
4299 | if(!unit) |
---|
4300 | { |
---|
4301 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
4302 | SetSentErrorMessage(true); |
---|
4303 | return false; |
---|
4304 | } |
---|
4305 | |
---|
4306 | char const* talentStr = GetTrinityString(LANG_TALENT); |
---|
4307 | char const* passiveStr = GetTrinityString(LANG_PASSIVE); |
---|
4308 | |
---|
4309 | Unit::AuraMap const& uAuras = unit->GetAuras(); |
---|
4310 | PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS, uAuras.size()); |
---|
4311 | for (Unit::AuraMap::const_iterator itr = uAuras.begin(); itr != uAuras.end(); ++itr) |
---|
4312 | { |
---|
4313 | bool talent = GetTalentSpellCost(itr->second->GetId()) > 0; |
---|
4314 | PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, itr->second->GetId(), itr->second->GetEffIndex(), |
---|
4315 | itr->second->GetModifier()->m_auraname, itr->second->GetAuraDuration(), itr->second->GetAuraMaxDuration(), |
---|
4316 | itr->second->GetSpellProto()->SpellName[m_session->GetSessionDbcLocale()], |
---|
4317 | (itr->second->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), |
---|
4318 | IS_PLAYER_GUID(itr->second->GetCasterGUID()) ? "player" : "creature",GUID_LOPART(itr->second->GetCasterGUID())); |
---|
4319 | } |
---|
4320 | for (int i = 0; i < TOTAL_AURAS; i++) |
---|
4321 | { |
---|
4322 | Unit::AuraList const& uAuraList = unit->GetAurasByType(AuraType(i)); |
---|
4323 | if (uAuraList.empty()) continue; |
---|
4324 | PSendSysMessage(LANG_COMMAND_TARGET_LISTAURATYPE, uAuraList.size(), i); |
---|
4325 | for (Unit::AuraList::const_iterator itr = uAuraList.begin(); itr != uAuraList.end(); ++itr) |
---|
4326 | { |
---|
4327 | bool talent = GetTalentSpellCost((*itr)->GetId()) > 0; |
---|
4328 | PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, (*itr)->GetId(), (*itr)->GetEffIndex(), |
---|
4329 | (*itr)->GetSpellProto()->SpellName[m_session->GetSessionDbcLocale()],((*itr)->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), |
---|
4330 | IS_PLAYER_GUID((*itr)->GetCasterGUID()) ? "player" : "creature",GUID_LOPART((*itr)->GetCasterGUID())); |
---|
4331 | } |
---|
4332 | } |
---|
4333 | return true; |
---|
4334 | } |
---|
4335 | |
---|
4336 | bool ChatHandler::HandleResetHonorCommand (const char * args) |
---|
4337 | { |
---|
4338 | char* pName = strtok((char*)args, ""); |
---|
4339 | Player *player = NULL; |
---|
4340 | if (pName) |
---|
4341 | { |
---|
4342 | std::string name = pName; |
---|
4343 | if(!normalizePlayerName(name)) |
---|
4344 | { |
---|
4345 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
4346 | SetSentErrorMessage(true); |
---|
4347 | return false; |
---|
4348 | } |
---|
4349 | |
---|
4350 | uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str()); |
---|
4351 | player = objmgr.GetPlayer(guid); |
---|
4352 | } |
---|
4353 | else |
---|
4354 | player = getSelectedPlayer(); |
---|
4355 | |
---|
4356 | if(!player) |
---|
4357 | { |
---|
4358 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
4359 | return true; |
---|
4360 | } |
---|
4361 | |
---|
4362 | player->SetUInt32Value(PLAYER_FIELD_KILLS, 0); |
---|
4363 | player->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORBALE_KILLS, 0); |
---|
4364 | player->SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, 0); |
---|
4365 | player->SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, 0); |
---|
4366 | player->SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, 0); |
---|
4367 | |
---|
4368 | return true; |
---|
4369 | } |
---|
4370 | |
---|
4371 | static bool HandleResetStatsOrLevelHelper(Player* player) |
---|
4372 | { |
---|
4373 | PlayerInfo const *info = objmgr.GetPlayerInfo(player->getRace(), player->getClass()); |
---|
4374 | if(!info) return false; |
---|
4375 | |
---|
4376 | ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(player->getClass()); |
---|
4377 | if(!cEntry) |
---|
4378 | { |
---|
4379 | sLog.outError("Class %u not found in DBC (Wrong DBC files?)",player->getClass()); |
---|
4380 | return false; |
---|
4381 | } |
---|
4382 | |
---|
4383 | uint8 powertype = cEntry->powerType; |
---|
4384 | |
---|
4385 | uint32 unitfield; |
---|
4386 | if(powertype == POWER_RAGE) |
---|
4387 | unitfield = 0x1100EE00; |
---|
4388 | else if(powertype == POWER_ENERGY) |
---|
4389 | unitfield = 0x00000000; |
---|
4390 | else if(powertype == POWER_MANA) |
---|
4391 | unitfield = 0x0000EE00; |
---|
4392 | else |
---|
4393 | { |
---|
4394 | sLog.outError("Invalid default powertype %u for player (class %u)",powertype,player->getClass()); |
---|
4395 | return false; |
---|
4396 | } |
---|
4397 | |
---|
4398 | // reset m_form if no aura |
---|
4399 | if(!player->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT)) |
---|
4400 | player->m_form = FORM_NONE; |
---|
4401 | |
---|
4402 | player->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE ); |
---|
4403 | player->SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f ); |
---|
4404 | |
---|
4405 | player->setFactionForRace(player->getRace()); |
---|
4406 | |
---|
4407 | player->SetUInt32Value(UNIT_FIELD_BYTES_0, ( ( player->getRace() ) | ( player->getClass() << 8 ) | ( player->getGender() << 16 ) | ( powertype << 24 ) ) ); |
---|
4408 | |
---|
4409 | // reset only if player not in some form; |
---|
4410 | if(player->m_form==FORM_NONE) |
---|
4411 | { |
---|
4412 | switch(player->getGender()) |
---|
4413 | { |
---|
4414 | case GENDER_FEMALE: |
---|
4415 | player->SetDisplayId(info->displayId_f); |
---|
4416 | player->SetNativeDisplayId(info->displayId_f); |
---|
4417 | break; |
---|
4418 | case GENDER_MALE: |
---|
4419 | player->SetDisplayId(info->displayId_m); |
---|
4420 | player->SetNativeDisplayId(info->displayId_m); |
---|
4421 | break; |
---|
4422 | default: |
---|
4423 | break; |
---|
4424 | } |
---|
4425 | } |
---|
4426 | |
---|
4427 | // set UNIT_FIELD_BYTES_1 to init state but preserve m_form value |
---|
4428 | player->SetUInt32Value(UNIT_FIELD_BYTES_1, unitfield); |
---|
4429 | player->SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_UNK3 | UNIT_BYTE2_FLAG_UNK5 ); |
---|
4430 | player->SetByteValue(UNIT_FIELD_BYTES_2, 3, player->m_form); |
---|
4431 | |
---|
4432 | player->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); |
---|
4433 | |
---|
4434 | //-1 is default value |
---|
4435 | player->SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, uint32(-1)); |
---|
4436 | |
---|
4437 | //player->SetUInt32Value(PLAYER_FIELD_BYTES, 0xEEE00000 ); |
---|
4438 | return true; |
---|
4439 | } |
---|
4440 | |
---|
4441 | bool ChatHandler::HandleResetLevelCommand(const char * args) |
---|
4442 | { |
---|
4443 | char* pName = strtok((char*)args, ""); |
---|
4444 | Player *player = NULL; |
---|
4445 | if (pName) |
---|
4446 | { |
---|
4447 | std::string name = pName; |
---|
4448 | if(!normalizePlayerName(name)) |
---|
4449 | { |
---|
4450 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
4451 | SetSentErrorMessage(true); |
---|
4452 | return false; |
---|
4453 | } |
---|
4454 | |
---|
4455 | uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str()); |
---|
4456 | player = objmgr.GetPlayer(guid); |
---|
4457 | } |
---|
4458 | else |
---|
4459 | player = getSelectedPlayer(); |
---|
4460 | |
---|
4461 | if(!player) |
---|
4462 | { |
---|
4463 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
4464 | SetSentErrorMessage(true); |
---|
4465 | return false; |
---|
4466 | } |
---|
4467 | |
---|
4468 | if(!HandleResetStatsOrLevelHelper(player)) |
---|
4469 | return false; |
---|
4470 | |
---|
4471 | player->SetLevel(1); |
---|
4472 | player->InitStatsForLevel(true); |
---|
4473 | player->InitTaxiNodesForLevel(); |
---|
4474 | player->InitTalentForLevel(); |
---|
4475 | player->SetUInt32Value(PLAYER_XP,0); |
---|
4476 | |
---|
4477 | // reset level to summoned pet |
---|
4478 | Pet* pet = player->GetPet(); |
---|
4479 | if(pet && pet->getPetType()==SUMMON_PET) |
---|
4480 | pet->InitStatsForLevel(1); |
---|
4481 | |
---|
4482 | return true; |
---|
4483 | } |
---|
4484 | |
---|
4485 | bool ChatHandler::HandleResetStatsCommand(const char * args) |
---|
4486 | { |
---|
4487 | char* pName = strtok((char*)args, ""); |
---|
4488 | Player *player = NULL; |
---|
4489 | if (pName) |
---|
4490 | { |
---|
4491 | std::string name = pName; |
---|
4492 | if(!normalizePlayerName(name)) |
---|
4493 | { |
---|
4494 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
4495 | SetSentErrorMessage(true); |
---|
4496 | return false; |
---|
4497 | } |
---|
4498 | |
---|
4499 | uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str()); |
---|
4500 | player = objmgr.GetPlayer(guid); |
---|
4501 | } |
---|
4502 | else |
---|
4503 | player = getSelectedPlayer(); |
---|
4504 | |
---|
4505 | if(!player) |
---|
4506 | { |
---|
4507 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
4508 | SetSentErrorMessage(true); |
---|
4509 | return false; |
---|
4510 | } |
---|
4511 | |
---|
4512 | if(!HandleResetStatsOrLevelHelper(player)) |
---|
4513 | return false; |
---|
4514 | |
---|
4515 | player->InitStatsForLevel(true); |
---|
4516 | player->InitTaxiNodesForLevel(); |
---|
4517 | player->InitTalentForLevel(); |
---|
4518 | |
---|
4519 | return true; |
---|
4520 | } |
---|
4521 | |
---|
4522 | bool ChatHandler::HandleResetSpellsCommand(const char * args) |
---|
4523 | { |
---|
4524 | char* pName = strtok((char*)args, ""); |
---|
4525 | Player *player = NULL; |
---|
4526 | uint64 playerGUID = 0; |
---|
4527 | if (pName) |
---|
4528 | { |
---|
4529 | std::string name = pName; |
---|
4530 | |
---|
4531 | if(!normalizePlayerName(name)) |
---|
4532 | { |
---|
4533 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
4534 | SetSentErrorMessage(true); |
---|
4535 | return false; |
---|
4536 | } |
---|
4537 | |
---|
4538 | player = objmgr.GetPlayer(name.c_str()); |
---|
4539 | if(!player) |
---|
4540 | playerGUID = objmgr.GetPlayerGUIDByName(name.c_str()); |
---|
4541 | } |
---|
4542 | else |
---|
4543 | player = getSelectedPlayer(); |
---|
4544 | |
---|
4545 | if(!player && !playerGUID) |
---|
4546 | { |
---|
4547 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
4548 | SetSentErrorMessage(true); |
---|
4549 | return false; |
---|
4550 | } |
---|
4551 | |
---|
4552 | if(player) |
---|
4553 | { |
---|
4554 | player->resetSpells(); |
---|
4555 | |
---|
4556 | ChatHandler(player).SendSysMessage(LANG_RESET_SPELLS); |
---|
4557 | |
---|
4558 | if(m_session->GetPlayer()!=player) |
---|
4559 | PSendSysMessage(LANG_RESET_SPELLS_ONLINE,player->GetName()); |
---|
4560 | } |
---|
4561 | else |
---|
4562 | { |
---|
4563 | CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'",uint32(AT_LOGIN_RESET_SPELLS), GUID_LOPART(playerGUID)); |
---|
4564 | PSendSysMessage(LANG_RESET_SPELLS_OFFLINE,pName); |
---|
4565 | } |
---|
4566 | |
---|
4567 | return true; |
---|
4568 | } |
---|
4569 | |
---|
4570 | bool ChatHandler::HandleResetTalentsCommand(const char * args) |
---|
4571 | { |
---|
4572 | char* pName = strtok((char*)args, ""); |
---|
4573 | Player *player = NULL; |
---|
4574 | uint64 playerGUID = 0; |
---|
4575 | if (pName) |
---|
4576 | { |
---|
4577 | std::string name = pName; |
---|
4578 | if(!normalizePlayerName(name)) |
---|
4579 | { |
---|
4580 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
4581 | SetSentErrorMessage(true); |
---|
4582 | return false; |
---|
4583 | } |
---|
4584 | |
---|
4585 | player = objmgr.GetPlayer(name.c_str()); |
---|
4586 | if(!player) |
---|
4587 | playerGUID = objmgr.GetPlayerGUIDByName(name.c_str()); |
---|
4588 | } |
---|
4589 | else |
---|
4590 | player = getSelectedPlayer(); |
---|
4591 | |
---|
4592 | if(!player && !playerGUID) |
---|
4593 | { |
---|
4594 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
4595 | SetSentErrorMessage(true); |
---|
4596 | return false; |
---|
4597 | } |
---|
4598 | |
---|
4599 | if(player) |
---|
4600 | { |
---|
4601 | player->resetTalents(true); |
---|
4602 | |
---|
4603 | ChatHandler(player).SendSysMessage(LANG_RESET_TALENTS); |
---|
4604 | |
---|
4605 | if(m_session->GetPlayer()!=player) |
---|
4606 | PSendSysMessage(LANG_RESET_TALENTS_ONLINE,player->GetName()); |
---|
4607 | } |
---|
4608 | else |
---|
4609 | { |
---|
4610 | CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'",uint32(AT_LOGIN_RESET_TALENTS), GUID_LOPART(playerGUID) ); |
---|
4611 | PSendSysMessage(LANG_RESET_TALENTS_OFFLINE,pName); |
---|
4612 | } |
---|
4613 | |
---|
4614 | return true; |
---|
4615 | } |
---|
4616 | |
---|
4617 | bool ChatHandler::HandleResetAllCommand(const char * args) |
---|
4618 | { |
---|
4619 | if(!*args) |
---|
4620 | return false; |
---|
4621 | |
---|
4622 | std::string casename = args; |
---|
4623 | |
---|
4624 | AtLoginFlags atLogin; |
---|
4625 | |
---|
4626 | // Command specially created as single command to prevent using short case names |
---|
4627 | if(casename=="spells") |
---|
4628 | { |
---|
4629 | atLogin = AT_LOGIN_RESET_SPELLS; |
---|
4630 | sWorld.SendWorldText(LANG_RESETALL_SPELLS); |
---|
4631 | } |
---|
4632 | else if(casename=="talents") |
---|
4633 | { |
---|
4634 | atLogin = AT_LOGIN_RESET_TALENTS; |
---|
4635 | sWorld.SendWorldText(LANG_RESETALL_TALENTS); |
---|
4636 | } |
---|
4637 | else |
---|
4638 | { |
---|
4639 | PSendSysMessage(LANG_RESETALL_UNKNOWN_CASE,args); |
---|
4640 | SetSentErrorMessage(true); |
---|
4641 | return false; |
---|
4642 | } |
---|
4643 | |
---|
4644 | CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u'",atLogin); |
---|
4645 | HashMapHolder<Player>::MapType const& plist = ObjectAccessor::Instance().GetPlayers(); |
---|
4646 | for(HashMapHolder<Player>::MapType::const_iterator itr = plist.begin(); itr != plist.end(); ++itr) |
---|
4647 | itr->second->SetAtLoginFlag(atLogin); |
---|
4648 | |
---|
4649 | return true; |
---|
4650 | } |
---|
4651 | |
---|
4652 | bool ChatHandler::HandleShutDownCommand(const char* args) |
---|
4653 | { |
---|
4654 | if(!*args) |
---|
4655 | return false; |
---|
4656 | |
---|
4657 | if(std::string(args)=="cancel") |
---|
4658 | { |
---|
4659 | sWorld.ShutdownCancel(); |
---|
4660 | } |
---|
4661 | else |
---|
4662 | { |
---|
4663 | int32 time = atoi(args); |
---|
4664 | |
---|
4665 | ///- Prevent interpret wrong arg value as 0 secs shutdown time |
---|
4666 | if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) |
---|
4667 | return false; |
---|
4668 | |
---|
4669 | sWorld.ShutdownServ(time); |
---|
4670 | } |
---|
4671 | return true; |
---|
4672 | } |
---|
4673 | |
---|
4674 | bool ChatHandler::HandleRestartCommand(const char* args) |
---|
4675 | { |
---|
4676 | if(!*args) |
---|
4677 | return false; |
---|
4678 | |
---|
4679 | if(std::string(args)=="cancel") |
---|
4680 | { |
---|
4681 | sWorld.ShutdownCancel(); |
---|
4682 | } |
---|
4683 | else |
---|
4684 | { |
---|
4685 | int32 time = atoi(args); |
---|
4686 | |
---|
4687 | ///- Prevent interpret wrong arg value as 0 secs shutdown time |
---|
4688 | if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) |
---|
4689 | return false; |
---|
4690 | |
---|
4691 | sWorld.ShutdownServ(time, SHUTDOWN_MASK_RESTART); |
---|
4692 | } |
---|
4693 | return true; |
---|
4694 | } |
---|
4695 | |
---|
4696 | bool ChatHandler::HandleIdleRestartCommand(const char* args) |
---|
4697 | { |
---|
4698 | if(!*args) |
---|
4699 | return false; |
---|
4700 | |
---|
4701 | if(std::string(args)=="cancel") |
---|
4702 | { |
---|
4703 | sWorld.ShutdownCancel(); |
---|
4704 | } |
---|
4705 | else |
---|
4706 | { |
---|
4707 | int32 time = atoi(args); |
---|
4708 | |
---|
4709 | ///- Prevent interpret wrong arg value as 0 secs shutdown time |
---|
4710 | if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) |
---|
4711 | return false; |
---|
4712 | |
---|
4713 | sWorld.ShutdownServ(time,SHUTDOWN_MASK_RESTART+SHUTDOWN_MASK_IDLE); |
---|
4714 | } |
---|
4715 | return true; |
---|
4716 | } |
---|
4717 | |
---|
4718 | bool ChatHandler::HandleIdleShutDownCommand(const char* args) |
---|
4719 | { |
---|
4720 | if(!*args) |
---|
4721 | return false; |
---|
4722 | |
---|
4723 | if(std::string(args)=="cancel") |
---|
4724 | { |
---|
4725 | sWorld.ShutdownCancel(); |
---|
4726 | } |
---|
4727 | else |
---|
4728 | { |
---|
4729 | int32 time = atoi(args); |
---|
4730 | |
---|
4731 | ///- Prevent interpret wrong arg value as 0 secs shutdown time |
---|
4732 | if(time == 0 && (args[0]!='0' || args[1]!='\0') || time < 0) |
---|
4733 | return false; |
---|
4734 | |
---|
4735 | sWorld.ShutdownServ(time,SHUTDOWN_MASK_IDLE); |
---|
4736 | } |
---|
4737 | return true; |
---|
4738 | } |
---|
4739 | |
---|
4740 | bool ChatHandler::HandleAddQuest(const char* args) |
---|
4741 | { |
---|
4742 | Player* player = getSelectedPlayer(); |
---|
4743 | if(!player) |
---|
4744 | { |
---|
4745 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
4746 | SetSentErrorMessage(true); |
---|
4747 | return false; |
---|
4748 | } |
---|
4749 | |
---|
4750 | // .addquest #entry' |
---|
4751 | // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r |
---|
4752 | char* cId = extractKeyFromLink((char*)args,"Hquest"); |
---|
4753 | if(!cId) |
---|
4754 | return false; |
---|
4755 | |
---|
4756 | uint32 entry = atol(cId); |
---|
4757 | |
---|
4758 | Quest const* pQuest = objmgr.GetQuestTemplate(entry); |
---|
4759 | |
---|
4760 | if(!pQuest) |
---|
4761 | { |
---|
4762 | PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND,entry); |
---|
4763 | SetSentErrorMessage(true); |
---|
4764 | return false; |
---|
4765 | } |
---|
4766 | |
---|
4767 | // check item starting quest (it can work incorrectly if added without item in inventory) |
---|
4768 | QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE startquest = '%u' LIMIT 1",entry); |
---|
4769 | if(result) |
---|
4770 | { |
---|
4771 | Field* fields = result->Fetch(); |
---|
4772 | uint32 item_id = fields[0].GetUInt32(); |
---|
4773 | delete result; |
---|
4774 | |
---|
4775 | PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry,item_id); |
---|
4776 | SetSentErrorMessage(true); |
---|
4777 | return false; |
---|
4778 | } |
---|
4779 | |
---|
4780 | // ok, normal (creature/GO starting) quest |
---|
4781 | if( player->CanAddQuest( pQuest, true ) ) |
---|
4782 | { |
---|
4783 | player->AddQuest( pQuest, NULL ); |
---|
4784 | |
---|
4785 | if ( player->CanCompleteQuest( entry ) ) |
---|
4786 | player->CompleteQuest( entry ); |
---|
4787 | } |
---|
4788 | |
---|
4789 | return true; |
---|
4790 | } |
---|
4791 | |
---|
4792 | bool ChatHandler::HandleRemoveQuest(const char* args) |
---|
4793 | { |
---|
4794 | Player* player = getSelectedPlayer(); |
---|
4795 | if(!player) |
---|
4796 | { |
---|
4797 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
4798 | SetSentErrorMessage(true); |
---|
4799 | return false; |
---|
4800 | } |
---|
4801 | |
---|
4802 | // .removequest #entry' |
---|
4803 | // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r |
---|
4804 | char* cId = extractKeyFromLink((char*)args,"Hquest"); |
---|
4805 | if(!cId) |
---|
4806 | return false; |
---|
4807 | |
---|
4808 | uint32 entry = atol(cId); |
---|
4809 | |
---|
4810 | Quest const* pQuest = objmgr.GetQuestTemplate(entry); |
---|
4811 | |
---|
4812 | if(!pQuest) |
---|
4813 | { |
---|
4814 | PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry); |
---|
4815 | SetSentErrorMessage(true); |
---|
4816 | return false; |
---|
4817 | } |
---|
4818 | |
---|
4819 | // remove all quest entries for 'entry' from quest log |
---|
4820 | for(uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot ) |
---|
4821 | { |
---|
4822 | uint32 quest = player->GetQuestSlotQuestId(slot); |
---|
4823 | if(quest==entry) |
---|
4824 | { |
---|
4825 | player->SetQuestSlot(slot,0); |
---|
4826 | |
---|
4827 | // we ignore unequippable quest items in this case, its' still be equipped |
---|
4828 | player->TakeQuestSourceItem( quest, false ); |
---|
4829 | } |
---|
4830 | } |
---|
4831 | |
---|
4832 | // set quest status to not started (will updated in DB at next save) |
---|
4833 | player->SetQuestStatus( entry, QUEST_STATUS_NONE); |
---|
4834 | |
---|
4835 | // reset rewarded for restart repeatable quest |
---|
4836 | player->getQuestStatusMap()[entry].m_rewarded = false; |
---|
4837 | |
---|
4838 | SendSysMessage(LANG_COMMAND_QUEST_REMOVED); |
---|
4839 | return true; |
---|
4840 | } |
---|
4841 | |
---|
4842 | bool ChatHandler::HandleCompleteQuest(const char* args) |
---|
4843 | { |
---|
4844 | Player* player = getSelectedPlayer(); |
---|
4845 | if(!player) |
---|
4846 | { |
---|
4847 | SendSysMessage(LANG_NO_CHAR_SELECTED); |
---|
4848 | SetSentErrorMessage(true); |
---|
4849 | return false; |
---|
4850 | } |
---|
4851 | |
---|
4852 | // .quest complete #entry |
---|
4853 | // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r |
---|
4854 | char* cId = extractKeyFromLink((char*)args,"Hquest"); |
---|
4855 | if(!cId) |
---|
4856 | return false; |
---|
4857 | |
---|
4858 | uint32 entry = atol(cId); |
---|
4859 | |
---|
4860 | Quest const* pQuest = objmgr.GetQuestTemplate(entry); |
---|
4861 | |
---|
4862 | // If player doesn't have the quest |
---|
4863 | if(!pQuest || player->GetQuestStatus(entry) == QUEST_STATUS_NONE) |
---|
4864 | { |
---|
4865 | PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry); |
---|
4866 | SetSentErrorMessage(true); |
---|
4867 | return false; |
---|
4868 | } |
---|
4869 | |
---|
4870 | // Add quest items for quests that require items |
---|
4871 | for(uint8 x = 0; x < QUEST_OBJECTIVES_COUNT; ++x) |
---|
4872 | { |
---|
4873 | uint32 id = pQuest->ReqItemId[x]; |
---|
4874 | uint32 count = pQuest->ReqItemCount[x]; |
---|
4875 | if(!id || !count) |
---|
4876 | continue; |
---|
4877 | |
---|
4878 | uint32 curItemCount = player->GetItemCount(id,true); |
---|
4879 | |
---|
4880 | ItemPosCountVec dest; |
---|
4881 | uint8 msg = player->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, id, count-curItemCount ); |
---|
4882 | if( msg == EQUIP_ERR_OK ) |
---|
4883 | { |
---|
4884 | Item* item = player->StoreNewItem( dest, id, true); |
---|
4885 | player->SendNewItem(item,count-curItemCount,true,false); |
---|
4886 | } |
---|
4887 | } |
---|
4888 | |
---|
4889 | // All creature/GO slain/casted (not required, but otherwise it will display "Creature slain 0/10") |
---|
4890 | for(uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; i++) |
---|
4891 | { |
---|
4892 | uint32 creature = pQuest->ReqCreatureOrGOId[i]; |
---|
4893 | uint32 creaturecount = pQuest->ReqCreatureOrGOCount[i]; |
---|
4894 | |
---|
4895 | if(uint32 spell_id = pQuest->ReqSpell[i]) |
---|
4896 | { |
---|
4897 | for(uint16 z = 0; z < creaturecount; ++z) |
---|
4898 | player->CastedCreatureOrGO(creature,0,spell_id); |
---|
4899 | } |
---|
4900 | else if(creature > 0) |
---|
4901 | { |
---|
4902 | for(uint16 z = 0; z < creaturecount; ++z) |
---|
4903 | player->KilledMonster(creature,0); |
---|
4904 | } |
---|
4905 | else if(creature < 0) |
---|
4906 | { |
---|
4907 | for(uint16 z = 0; z < creaturecount; ++z) |
---|
4908 | player->CastedCreatureOrGO(creature,0,0); |
---|
4909 | } |
---|
4910 | } |
---|
4911 | |
---|
4912 | // If the quest requires reputation to complete |
---|
4913 | if(uint32 repFaction = pQuest->GetRepObjectiveFaction()) |
---|
4914 | { |
---|
4915 | uint32 repValue = pQuest->GetRepObjectiveValue(); |
---|
4916 | uint32 curRep = player->GetReputation(repFaction); |
---|
4917 | if(curRep < repValue) |
---|
4918 | { |
---|
4919 | FactionEntry const *factionEntry = sFactionStore.LookupEntry(repFaction); |
---|
4920 | player->SetFactionReputation(factionEntry,repValue); |
---|
4921 | } |
---|
4922 | } |
---|
4923 | |
---|
4924 | // If the quest requires money |
---|
4925 | int32 ReqOrRewMoney = pQuest->GetRewOrReqMoney(); |
---|
4926 | if(ReqOrRewMoney < 0) |
---|
4927 | player->ModifyMoney(-ReqOrRewMoney); |
---|
4928 | |
---|
4929 | player->CompleteQuest(entry); |
---|
4930 | return true; |
---|
4931 | } |
---|
4932 | |
---|
4933 | bool ChatHandler::HandleBanAccountCommand(const char* args) |
---|
4934 | { |
---|
4935 | return HandleBanHelper(BAN_ACCOUNT,args); |
---|
4936 | } |
---|
4937 | |
---|
4938 | bool ChatHandler::HandleBanCharacterCommand(const char* args) |
---|
4939 | { |
---|
4940 | return HandleBanHelper(BAN_CHARACTER,args); |
---|
4941 | } |
---|
4942 | |
---|
4943 | bool ChatHandler::HandleBanIPCommand(const char* args) |
---|
4944 | { |
---|
4945 | return HandleBanHelper(BAN_IP,args); |
---|
4946 | } |
---|
4947 | |
---|
4948 | bool ChatHandler::HandleBanHelper(BanMode mode, const char* args) |
---|
4949 | { |
---|
4950 | if(!args) |
---|
4951 | return false; |
---|
4952 | |
---|
4953 | char* cnameOrIP = strtok ((char*)args, " "); |
---|
4954 | if (!cnameOrIP) |
---|
4955 | return false; |
---|
4956 | |
---|
4957 | std::string nameOrIP = cnameOrIP; |
---|
4958 | |
---|
4959 | char* duration = strtok (NULL," "); |
---|
4960 | if(!duration || !atoi(duration)) |
---|
4961 | return false; |
---|
4962 | |
---|
4963 | char* reason = strtok (NULL,""); |
---|
4964 | if(!reason) |
---|
4965 | return false; |
---|
4966 | |
---|
4967 | switch(mode) |
---|
4968 | { |
---|
4969 | case BAN_ACCOUNT: |
---|
4970 | if(!AccountMgr::normilizeString(nameOrIP)) |
---|
4971 | { |
---|
4972 | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,nameOrIP.c_str()); |
---|
4973 | SetSentErrorMessage(true); |
---|
4974 | return false; |
---|
4975 | } |
---|
4976 | break; |
---|
4977 | case BAN_CHARACTER: |
---|
4978 | if(!normalizePlayerName(nameOrIP)) |
---|
4979 | { |
---|
4980 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
4981 | SetSentErrorMessage(true); |
---|
4982 | return false; |
---|
4983 | } |
---|
4984 | break; |
---|
4985 | case BAN_IP: |
---|
4986 | if(!IsIPAddress(nameOrIP.c_str())) |
---|
4987 | return false; |
---|
4988 | break; |
---|
4989 | } |
---|
4990 | |
---|
4991 | switch(sWorld.BanAccount(mode, nameOrIP, duration, reason,m_session ? m_session->GetPlayerName() : "")) |
---|
4992 | { |
---|
4993 | case BAN_SUCCESS: |
---|
4994 | if(atoi(duration)>0) |
---|
4995 | PSendSysMessage(LANG_BAN_YOUBANNED,nameOrIP.c_str(),secsToTimeString(TimeStringToSecs(duration),true).c_str(),reason); |
---|
4996 | else |
---|
4997 | PSendSysMessage(LANG_BAN_YOUPERMBANNED,nameOrIP.c_str(),reason); |
---|
4998 | break; |
---|
4999 | case BAN_SYNTAX_ERROR: |
---|
5000 | return false; |
---|
5001 | case BAN_NOTFOUND: |
---|
5002 | switch(mode) |
---|
5003 | { |
---|
5004 | default: |
---|
5005 | PSendSysMessage(LANG_BAN_NOTFOUND,"account",nameOrIP.c_str()); |
---|
5006 | break; |
---|
5007 | case BAN_CHARACTER: |
---|
5008 | PSendSysMessage(LANG_BAN_NOTFOUND,"character",nameOrIP.c_str()); |
---|
5009 | break; |
---|
5010 | case BAN_IP: |
---|
5011 | PSendSysMessage(LANG_BAN_NOTFOUND,"ip",nameOrIP.c_str()); |
---|
5012 | break; |
---|
5013 | |
---|
5014 | } |
---|
5015 | SetSentErrorMessage(true); |
---|
5016 | return false; |
---|
5017 | } |
---|
5018 | |
---|
5019 | return true; |
---|
5020 | } |
---|
5021 | |
---|
5022 | bool ChatHandler::HandleUnBanAccountCommand(const char* args) |
---|
5023 | { |
---|
5024 | return HandleUnBanHelper(BAN_ACCOUNT,args); |
---|
5025 | } |
---|
5026 | |
---|
5027 | bool ChatHandler::HandleUnBanCharacterCommand(const char* args) |
---|
5028 | { |
---|
5029 | return HandleUnBanHelper(BAN_CHARACTER,args); |
---|
5030 | } |
---|
5031 | |
---|
5032 | bool ChatHandler::HandleUnBanIPCommand(const char* args) |
---|
5033 | { |
---|
5034 | return HandleUnBanHelper(BAN_IP,args); |
---|
5035 | } |
---|
5036 | |
---|
5037 | bool ChatHandler::HandleUnBanHelper(BanMode mode, const char* args) |
---|
5038 | { |
---|
5039 | if(!args) |
---|
5040 | return false; |
---|
5041 | |
---|
5042 | char* cnameOrIP = strtok ((char*)args, " "); |
---|
5043 | if(!cnameOrIP) |
---|
5044 | return false; |
---|
5045 | |
---|
5046 | std::string nameOrIP = cnameOrIP; |
---|
5047 | switch(mode) |
---|
5048 | { |
---|
5049 | case BAN_ACCOUNT: |
---|
5050 | if(!AccountMgr::normilizeString(nameOrIP)) |
---|
5051 | { |
---|
5052 | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,nameOrIP.c_str()); |
---|
5053 | SetSentErrorMessage(true); |
---|
5054 | return false; |
---|
5055 | } |
---|
5056 | break; |
---|
5057 | case BAN_CHARACTER: |
---|
5058 | if(!normalizePlayerName(nameOrIP)) |
---|
5059 | { |
---|
5060 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
5061 | SetSentErrorMessage(true); |
---|
5062 | return false; |
---|
5063 | } |
---|
5064 | break; |
---|
5065 | case BAN_IP: |
---|
5066 | if(!IsIPAddress(nameOrIP.c_str())) |
---|
5067 | return false; |
---|
5068 | break; |
---|
5069 | } |
---|
5070 | |
---|
5071 | if(sWorld.RemoveBanAccount(mode,nameOrIP)) |
---|
5072 | PSendSysMessage(LANG_UNBAN_UNBANNED,nameOrIP.c_str()); |
---|
5073 | else |
---|
5074 | PSendSysMessage(LANG_UNBAN_ERROR,nameOrIP.c_str()); |
---|
5075 | |
---|
5076 | return true; |
---|
5077 | } |
---|
5078 | |
---|
5079 | bool ChatHandler::HandleBanInfoAccountCommand(const char* args) |
---|
5080 | { |
---|
5081 | if(!args) |
---|
5082 | return false; |
---|
5083 | |
---|
5084 | char* cname = strtok((char*)args, ""); |
---|
5085 | if(!cname) |
---|
5086 | return false; |
---|
5087 | |
---|
5088 | std::string account_name = cname; |
---|
5089 | if(!AccountMgr::normilizeString(account_name)) |
---|
5090 | { |
---|
5091 | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
---|
5092 | SetSentErrorMessage(true); |
---|
5093 | return false; |
---|
5094 | } |
---|
5095 | |
---|
5096 | uint32 accountid = accmgr.GetId(account_name); |
---|
5097 | if(!accountid) |
---|
5098 | { |
---|
5099 | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
---|
5100 | return true; |
---|
5101 | } |
---|
5102 | |
---|
5103 | return HandleBanInfoHelper(accountid,account_name.c_str()); |
---|
5104 | } |
---|
5105 | |
---|
5106 | bool ChatHandler::HandleBanInfoCharacterCommand(const char* args) |
---|
5107 | { |
---|
5108 | if(!args) |
---|
5109 | return false; |
---|
5110 | |
---|
5111 | char* cname = strtok ((char*)args, ""); |
---|
5112 | if(!cname) |
---|
5113 | return false; |
---|
5114 | |
---|
5115 | std::string name = cname; |
---|
5116 | if(!normalizePlayerName(name)) |
---|
5117 | { |
---|
5118 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
5119 | SetSentErrorMessage(true); |
---|
5120 | return false; |
---|
5121 | } |
---|
5122 | |
---|
5123 | uint32 accountid = objmgr.GetPlayerAccountIdByPlayerName(name); |
---|
5124 | if(!accountid) |
---|
5125 | { |
---|
5126 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
5127 | SetSentErrorMessage(true); |
---|
5128 | return false; |
---|
5129 | } |
---|
5130 | |
---|
5131 | std::string accountname; |
---|
5132 | if(!accmgr.GetName(accountid,accountname)) |
---|
5133 | { |
---|
5134 | PSendSysMessage(LANG_BANINFO_NOCHARACTER); |
---|
5135 | return true; |
---|
5136 | } |
---|
5137 | |
---|
5138 | return HandleBanInfoHelper(accountid,accountname.c_str()); |
---|
5139 | } |
---|
5140 | |
---|
5141 | bool ChatHandler::HandleBanInfoHelper(uint32 accountid, char const* accountname) |
---|
5142 | { |
---|
5143 | QueryResult *result = loginDatabase.PQuery("SELECT FROM_UNIXTIME(bandate), unbandate-bandate, active, unbandate,banreason,bannedby FROM account_banned WHERE id = '%u' ORDER BY bandate ASC",accountid); |
---|
5144 | if(!result) |
---|
5145 | { |
---|
5146 | PSendSysMessage(LANG_BANINFO_NOACCOUNTBAN, accountname); |
---|
5147 | return true; |
---|
5148 | } |
---|
5149 | |
---|
5150 | PSendSysMessage(LANG_BANINFO_BANHISTORY,accountname); |
---|
5151 | do |
---|
5152 | { |
---|
5153 | Field* fields = result->Fetch(); |
---|
5154 | |
---|
5155 | time_t unbandate = time_t(fields[3].GetUInt64()); |
---|
5156 | bool active = false; |
---|
5157 | if(fields[2].GetBool() && (fields[1].GetUInt64() == (uint64)0 ||unbandate >= time(NULL)) ) |
---|
5158 | active = true; |
---|
5159 | bool permanent = (fields[1].GetUInt64() == (uint64)0); |
---|
5160 | std::string bantime = permanent?GetTrinityString(LANG_BANINFO_INFINITE):secsToTimeString(fields[1].GetUInt64(), true); |
---|
5161 | PSendSysMessage(LANG_BANINFO_HISTORYENTRY, |
---|
5162 | fields[0].GetString(), bantime.c_str(), active ? GetTrinityString(LANG_BANINFO_YES):GetTrinityString(LANG_BANINFO_NO), fields[4].GetString(), fields[5].GetString()); |
---|
5163 | }while (result->NextRow()); |
---|
5164 | |
---|
5165 | delete result; |
---|
5166 | return true; |
---|
5167 | } |
---|
5168 | |
---|
5169 | bool ChatHandler::HandleBanInfoIPCommand(const char* args) |
---|
5170 | { |
---|
5171 | if(!args) |
---|
5172 | return false; |
---|
5173 | |
---|
5174 | char* cIP = strtok ((char*)args, ""); |
---|
5175 | if(!cIP) |
---|
5176 | return false; |
---|
5177 | |
---|
5178 | if (!IsIPAddress(cIP)) |
---|
5179 | return false; |
---|
5180 | |
---|
5181 | std::string IP = cIP; |
---|
5182 | |
---|
5183 | loginDatabase.escape_string(IP); |
---|
5184 | QueryResult *result = loginDatabase.PQuery("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason,bannedby,unbandate-bandate FROM ip_banned WHERE ip = '%s'",IP.c_str()); |
---|
5185 | if(!result) |
---|
5186 | { |
---|
5187 | PSendSysMessage(LANG_BANINFO_NOIP); |
---|
5188 | return true; |
---|
5189 | } |
---|
5190 | |
---|
5191 | Field *fields = result->Fetch(); |
---|
5192 | bool permanent = !fields[6].GetUInt64(); |
---|
5193 | PSendSysMessage(LANG_BANINFO_IPENTRY, |
---|
5194 | fields[0].GetString(), fields[1].GetString(), permanent ? GetTrinityString(LANG_BANINFO_NEVER):fields[2].GetString(), |
---|
5195 | permanent ? GetTrinityString(LANG_BANINFO_INFINITE):secsToTimeString(fields[3].GetUInt64(), true).c_str(), fields[4].GetString(), fields[5].GetString()); |
---|
5196 | delete result; |
---|
5197 | return true; |
---|
5198 | } |
---|
5199 | |
---|
5200 | bool ChatHandler::HandleBanListCharacterCommand(const char* args) |
---|
5201 | { |
---|
5202 | loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); |
---|
5203 | |
---|
5204 | char* cFilter = strtok ((char*)args, " "); |
---|
5205 | if(!cFilter) |
---|
5206 | return false; |
---|
5207 | |
---|
5208 | std::string filter = cFilter; |
---|
5209 | loginDatabase.escape_string(filter); |
---|
5210 | QueryResult* result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"),filter.c_str()); |
---|
5211 | if (!result) |
---|
5212 | { |
---|
5213 | PSendSysMessage(LANG_BANLIST_NOCHARACTER); |
---|
5214 | return true; |
---|
5215 | } |
---|
5216 | |
---|
5217 | return HandleBanListHelper(result); |
---|
5218 | } |
---|
5219 | |
---|
5220 | bool ChatHandler::HandleBanListAccountCommand(const char* args) |
---|
5221 | { |
---|
5222 | loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); |
---|
5223 | |
---|
5224 | char* cFilter = strtok((char*)args, " "); |
---|
5225 | std::string filter = cFilter ? cFilter : ""; |
---|
5226 | loginDatabase.escape_string(filter); |
---|
5227 | |
---|
5228 | QueryResult* result; |
---|
5229 | |
---|
5230 | if(filter.empty()) |
---|
5231 | { |
---|
5232 | result = loginDatabase.Query("SELECT account.id, username FROM account, account_banned" |
---|
5233 | " WHERE account.id = account_banned.id AND active = 1 GROUP BY account.id"); |
---|
5234 | } |
---|
5235 | else |
---|
5236 | { |
---|
5237 | result = loginDatabase.PQuery("SELECT account.id, username FROM account, account_banned" |
---|
5238 | " WHERE account.id = account_banned.id AND active = 1 AND username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" GROUP BY account.id", |
---|
5239 | filter.c_str()); |
---|
5240 | } |
---|
5241 | |
---|
5242 | if (!result) |
---|
5243 | { |
---|
5244 | PSendSysMessage(LANG_BANLIST_NOACCOUNT); |
---|
5245 | return true; |
---|
5246 | } |
---|
5247 | |
---|
5248 | return HandleBanListHelper(result); |
---|
5249 | } |
---|
5250 | |
---|
5251 | bool ChatHandler::HandleBanListHelper(QueryResult* result) |
---|
5252 | { |
---|
5253 | PSendSysMessage(LANG_BANLIST_MATCHINGACCOUNT); |
---|
5254 | |
---|
5255 | // Chat short output |
---|
5256 | if(m_session) |
---|
5257 | { |
---|
5258 | do |
---|
5259 | { |
---|
5260 | Field* fields = result->Fetch(); |
---|
5261 | uint32 accountid = fields[0].GetUInt32(); |
---|
5262 | |
---|
5263 | QueryResult* banresult = loginDatabase.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.id=account.id",accountid); |
---|
5264 | if(banresult) |
---|
5265 | { |
---|
5266 | Field* fields2 = banresult->Fetch(); |
---|
5267 | PSendSysMessage("%s",fields2[0].GetString()); |
---|
5268 | delete banresult; |
---|
5269 | } |
---|
5270 | } while (result->NextRow()); |
---|
5271 | } |
---|
5272 | // Console wide output |
---|
5273 | else |
---|
5274 | { |
---|
5275 | SendSysMessage(LANG_BANLIST_ACCOUNTS); |
---|
5276 | SendSysMessage("==============================================================================="); |
---|
5277 | SendSysMessage(LANG_BANLIST_ACCOUNTS_HEADER); |
---|
5278 | do |
---|
5279 | { |
---|
5280 | SendSysMessage("-------------------------------------------------------------------------------"); |
---|
5281 | Field *fields = result->Fetch(); |
---|
5282 | uint32 account_id = fields[0].GetUInt32 (); |
---|
5283 | |
---|
5284 | std::string account_name; |
---|
5285 | |
---|
5286 | // "account" case, name can be get in same quary |
---|
5287 | if(result->GetFieldCount() > 1) |
---|
5288 | account_name = fields[1].GetCppString(); |
---|
5289 | // "character" case, name need extract from another DB |
---|
5290 | else |
---|
5291 | accmgr.GetName (account_id,account_name); |
---|
5292 | |
---|
5293 | // No SQL injection. id is uint32. |
---|
5294 | QueryResult *banInfo = loginDatabase.PQuery("SELECT bandate,unbandate,bannedby,banreason FROM account_banned WHERE id = %u ORDER BY unbandate", account_id); |
---|
5295 | if (banInfo) |
---|
5296 | { |
---|
5297 | Field *fields2 = banInfo->Fetch(); |
---|
5298 | do |
---|
5299 | { |
---|
5300 | time_t t_ban = fields2[0].GetUInt64(); |
---|
5301 | tm* aTm_ban = localtime(&t_ban); |
---|
5302 | |
---|
5303 | if (fields2[0].GetUInt64() == fields2[1].GetUInt64()) |
---|
5304 | { |
---|
5305 | PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|", |
---|
5306 | account_name.c_str(),aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, |
---|
5307 | fields2[2].GetString(),fields2[3].GetString()); |
---|
5308 | } |
---|
5309 | else |
---|
5310 | { |
---|
5311 | time_t t_unban = fields2[1].GetUInt64(); |
---|
5312 | tm* aTm_unban = localtime(&t_unban); |
---|
5313 | PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", |
---|
5314 | account_name.c_str(),aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, |
---|
5315 | aTm_unban->tm_year%100, aTm_unban->tm_mon+1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min, |
---|
5316 | fields2[2].GetString(),fields2[3].GetString()); |
---|
5317 | } |
---|
5318 | }while ( banInfo->NextRow() ); |
---|
5319 | delete banInfo; |
---|
5320 | } |
---|
5321 | }while( result->NextRow() ); |
---|
5322 | SendSysMessage("==============================================================================="); |
---|
5323 | } |
---|
5324 | |
---|
5325 | delete result; |
---|
5326 | return true; |
---|
5327 | } |
---|
5328 | |
---|
5329 | bool ChatHandler::HandleBanListIPCommand(const char* args) |
---|
5330 | { |
---|
5331 | loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); |
---|
5332 | |
---|
5333 | char* cFilter = strtok((char*)args, " "); |
---|
5334 | std::string filter = cFilter ? cFilter : ""; |
---|
5335 | loginDatabase.escape_string(filter); |
---|
5336 | |
---|
5337 | QueryResult* result; |
---|
5338 | |
---|
5339 | if(filter.empty()) |
---|
5340 | { |
---|
5341 | result = loginDatabase.Query ("SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned" |
---|
5342 | " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP())" |
---|
5343 | " ORDER BY unbandate" ); |
---|
5344 | } |
---|
5345 | else |
---|
5346 | { |
---|
5347 | result = loginDatabase.PQuery( "SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned" |
---|
5348 | " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP()) AND ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'") |
---|
5349 | " ORDER BY unbandate",filter.c_str() ); |
---|
5350 | } |
---|
5351 | |
---|
5352 | if(!result) |
---|
5353 | { |
---|
5354 | PSendSysMessage(LANG_BANLIST_NOIP); |
---|
5355 | return true; |
---|
5356 | } |
---|
5357 | |
---|
5358 | PSendSysMessage(LANG_BANLIST_MATCHINGIP); |
---|
5359 | // Chat short output |
---|
5360 | if(m_session) |
---|
5361 | { |
---|
5362 | do |
---|
5363 | { |
---|
5364 | Field* fields = result->Fetch(); |
---|
5365 | PSendSysMessage("%s",fields[0].GetString()); |
---|
5366 | }while (result->NextRow()); |
---|
5367 | } |
---|
5368 | // Console wide output |
---|
5369 | else |
---|
5370 | { |
---|
5371 | SendSysMessage(LANG_BANLIST_IPS);SendSysMessage("==============================================================================="); |
---|
5372 | SendSysMessage(LANG_BANLIST_IPS_HEADER); |
---|
5373 | do |
---|
5374 | { |
---|
5375 | SendSysMessage("-------------------------------------------------------------------------------"); |
---|
5376 | Field *fields = result->Fetch(); |
---|
5377 | time_t t_ban = fields[1].GetUInt64(); |
---|
5378 | tm* aTm_ban = localtime(&t_ban); |
---|
5379 | if ( fields[1].GetUInt64() == fields[2].GetUInt64() ) |
---|
5380 | { |
---|
5381 | PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|", |
---|
5382 | fields[0].GetString(), aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, |
---|
5383 | fields[3].GetString(), fields[4].GetString()); |
---|
5384 | } |
---|
5385 | else |
---|
5386 | { |
---|
5387 | time_t t_unban = fields[2].GetUInt64(); |
---|
5388 | tm* aTm_unban = localtime(&t_unban); |
---|
5389 | PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", |
---|
5390 | fields[0].GetString(), aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, |
---|
5391 | aTm_unban->tm_year%100, aTm_unban->tm_mon+1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min, |
---|
5392 | fields[3].GetString(), fields[4].GetString()); |
---|
5393 | } |
---|
5394 | }while( result->NextRow() ); |
---|
5395 | SendSysMessage("==============================================================================="); |
---|
5396 | } |
---|
5397 | |
---|
5398 | delete result; |
---|
5399 | return true; |
---|
5400 | } |
---|
5401 | |
---|
5402 | bool ChatHandler::HandleRespawnCommand(const char* /*args*/) |
---|
5403 | { |
---|
5404 | Unit* target = getSelectedUnit(); |
---|
5405 | |
---|
5406 | if(target && target->GetTypeId() == TYPEID_UNIT && target->isDead()) |
---|
5407 | { |
---|
5408 | ((Creature*)target)->Respawn(); |
---|
5409 | return true; |
---|
5410 | } |
---|
5411 | |
---|
5412 | Player* pl = m_session->GetPlayer(); |
---|
5413 | |
---|
5414 | CellPair p(Trinity::ComputeCellPair(pl->GetPositionX(), pl->GetPositionY())); |
---|
5415 | Cell cell(p); |
---|
5416 | cell.data.Part.reserved = ALL_DISTRICT; |
---|
5417 | cell.SetNoCreate(); |
---|
5418 | |
---|
5419 | Trinity::RespawnDo u_do; |
---|
5420 | Trinity::WorldObjectWorker<Trinity::RespawnDo> worker(u_do); |
---|
5421 | |
---|
5422 | TypeContainerVisitor<Trinity::WorldObjectWorker<Trinity::RespawnDo>, GridTypeMapContainer > obj_worker(worker); |
---|
5423 | CellLock<GridReadGuard> cell_lock(cell, p); |
---|
5424 | cell_lock->Visit(cell_lock, obj_worker, *MapManager::Instance().GetMap(pl->GetMapId(), pl)); |
---|
5425 | |
---|
5426 | return true; |
---|
5427 | } |
---|
5428 | |
---|
5429 | bool ChatHandler::HandleFlyModeCommand(const char* args) |
---|
5430 | { |
---|
5431 | if(!args) |
---|
5432 | return false; |
---|
5433 | |
---|
5434 | Unit *unit = getSelectedUnit(); |
---|
5435 | if (!unit || (unit->GetTypeId() != TYPEID_PLAYER)) |
---|
5436 | unit = m_session->GetPlayer(); |
---|
5437 | |
---|
5438 | WorldPacket data(12); |
---|
5439 | if (strncmp(args, "on", 3) == 0) |
---|
5440 | data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); |
---|
5441 | else if (strncmp(args, "off", 4) == 0) |
---|
5442 | data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY); |
---|
5443 | else |
---|
5444 | { |
---|
5445 | SendSysMessage(LANG_USE_BOL); |
---|
5446 | return false; |
---|
5447 | } |
---|
5448 | data.append(unit->GetPackGUID()); |
---|
5449 | data << uint32(0); // unknown |
---|
5450 | unit->SendMessageToSet(&data, true); |
---|
5451 | PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, unit->GetName(), args); |
---|
5452 | return true; |
---|
5453 | } |
---|
5454 | |
---|
5455 | bool ChatHandler::HandleLoadPDumpCommand(const char *args) |
---|
5456 | { |
---|
5457 | if (!args) |
---|
5458 | return false; |
---|
5459 | |
---|
5460 | char * file = strtok((char*)args, " "); |
---|
5461 | if(!file) |
---|
5462 | return false; |
---|
5463 | |
---|
5464 | char * account = strtok(NULL, " "); |
---|
5465 | if(!account) |
---|
5466 | return false; |
---|
5467 | |
---|
5468 | std::string account_name = account; |
---|
5469 | if(!AccountMgr::normilizeString(account_name)) |
---|
5470 | { |
---|
5471 | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
---|
5472 | SetSentErrorMessage(true); |
---|
5473 | return false; |
---|
5474 | } |
---|
5475 | |
---|
5476 | uint32 account_id = accmgr.GetId(account_name); |
---|
5477 | if(!account_id) |
---|
5478 | { |
---|
5479 | account_id = atoi(account); // use original string |
---|
5480 | if(!account_id) |
---|
5481 | { |
---|
5482 | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
---|
5483 | SetSentErrorMessage(true); |
---|
5484 | return false; |
---|
5485 | } |
---|
5486 | } |
---|
5487 | |
---|
5488 | if(!accmgr.GetName(account_id,account_name)) |
---|
5489 | { |
---|
5490 | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
---|
5491 | SetSentErrorMessage(true); |
---|
5492 | return false; |
---|
5493 | } |
---|
5494 | |
---|
5495 | char* guid_str = NULL; |
---|
5496 | char* name_str = strtok(NULL, " "); |
---|
5497 | |
---|
5498 | std::string name; |
---|
5499 | if(name_str) |
---|
5500 | { |
---|
5501 | name = name_str; |
---|
5502 | // normalize the name if specified and check if it exists |
---|
5503 | if(!normalizePlayerName(name)) |
---|
5504 | { |
---|
5505 | PSendSysMessage(LANG_INVALID_CHARACTER_NAME); |
---|
5506 | SetSentErrorMessage(true); |
---|
5507 | return false; |
---|
5508 | } |
---|
5509 | |
---|
5510 | if(!ObjectMgr::IsValidName(name,true)) |
---|
5511 | { |
---|
5512 | PSendSysMessage(LANG_INVALID_CHARACTER_NAME); |
---|
5513 | SetSentErrorMessage(true); |
---|
5514 | return false; |
---|
5515 | } |
---|
5516 | |
---|
5517 | guid_str = strtok(NULL, " "); |
---|
5518 | } |
---|
5519 | |
---|
5520 | uint32 guid = 0; |
---|
5521 | |
---|
5522 | if(guid_str) |
---|
5523 | { |
---|
5524 | guid = atoi(guid_str); |
---|
5525 | if(!guid) |
---|
5526 | { |
---|
5527 | PSendSysMessage(LANG_INVALID_CHARACTER_GUID); |
---|
5528 | SetSentErrorMessage(true); |
---|
5529 | return false; |
---|
5530 | } |
---|
5531 | |
---|
5532 | if(objmgr.GetPlayerAccountIdByGUID(guid)) |
---|
5533 | { |
---|
5534 | PSendSysMessage(LANG_CHARACTER_GUID_IN_USE,guid); |
---|
5535 | SetSentErrorMessage(true); |
---|
5536 | return false; |
---|
5537 | } |
---|
5538 | } |
---|
5539 | |
---|
5540 | switch(PlayerDumpReader().LoadDump(file, account_id, name, guid)) |
---|
5541 | { |
---|
5542 | case DUMP_SUCCESS: |
---|
5543 | PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS); |
---|
5544 | break; |
---|
5545 | case DUMP_FILE_OPEN_ERROR: |
---|
5546 | PSendSysMessage(LANG_FILE_OPEN_FAIL,file); |
---|
5547 | SetSentErrorMessage(true); |
---|
5548 | return false; |
---|
5549 | case DUMP_FILE_BROKEN: |
---|
5550 | PSendSysMessage(LANG_DUMP_BROKEN,file); |
---|
5551 | SetSentErrorMessage(true); |
---|
5552 | return false; |
---|
5553 | case DUMP_TOO_MANY_CHARS: |
---|
5554 | PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL,account_name.c_str(),account_id); |
---|
5555 | SetSentErrorMessage(true); |
---|
5556 | return false; |
---|
5557 | default: |
---|
5558 | PSendSysMessage(LANG_COMMAND_IMPORT_FAILED); |
---|
5559 | SetSentErrorMessage(true); |
---|
5560 | return false; |
---|
5561 | } |
---|
5562 | |
---|
5563 | return true; |
---|
5564 | } |
---|
5565 | |
---|
5566 | bool ChatHandler::HandleChangeEntryCommand(const char *args) |
---|
5567 | { |
---|
5568 | if(!args) |
---|
5569 | return false; |
---|
5570 | |
---|
5571 | uint32 newEntryNum = atoi(args); |
---|
5572 | if(!newEntryNum) |
---|
5573 | return false; |
---|
5574 | |
---|
5575 | Unit* unit = getSelectedUnit(); |
---|
5576 | if(!unit || unit->GetTypeId() != TYPEID_UNIT) |
---|
5577 | { |
---|
5578 | SendSysMessage(LANG_SELECT_CREATURE); |
---|
5579 | SetSentErrorMessage(true); |
---|
5580 | return false; |
---|
5581 | } |
---|
5582 | Creature* creature = (Creature*)unit; |
---|
5583 | if(creature->UpdateEntry(newEntryNum)) |
---|
5584 | SendSysMessage(LANG_DONE); |
---|
5585 | else |
---|
5586 | SendSysMessage(LANG_ERROR); |
---|
5587 | return true; |
---|
5588 | } |
---|
5589 | |
---|
5590 | bool ChatHandler::HandleWritePDumpCommand(const char *args) |
---|
5591 | { |
---|
5592 | if(!args) |
---|
5593 | return false; |
---|
5594 | |
---|
5595 | char* file = strtok((char*)args, " "); |
---|
5596 | char* p2 = strtok(NULL, " "); |
---|
5597 | |
---|
5598 | if(!file || !p2) |
---|
5599 | return false; |
---|
5600 | |
---|
5601 | uint32 guid = objmgr.GetPlayerGUIDByName(p2); |
---|
5602 | if(!guid) |
---|
5603 | guid = atoi(p2); |
---|
5604 | |
---|
5605 | if(!objmgr.GetPlayerAccountIdByGUID(guid)) |
---|
5606 | { |
---|
5607 | PSendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
5608 | SetSentErrorMessage(true); |
---|
5609 | return false; |
---|
5610 | } |
---|
5611 | |
---|
5612 | switch(PlayerDumpWriter().WriteDump(file, guid)) |
---|
5613 | { |
---|
5614 | case DUMP_SUCCESS: |
---|
5615 | PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS); |
---|
5616 | break; |
---|
5617 | case DUMP_FILE_OPEN_ERROR: |
---|
5618 | PSendSysMessage(LANG_FILE_OPEN_FAIL,file); |
---|
5619 | SetSentErrorMessage(true); |
---|
5620 | return false; |
---|
5621 | default: |
---|
5622 | PSendSysMessage(LANG_COMMAND_EXPORT_FAILED); |
---|
5623 | SetSentErrorMessage(true); |
---|
5624 | return false; |
---|
5625 | } |
---|
5626 | |
---|
5627 | return true; |
---|
5628 | } |
---|
5629 | |
---|
5630 | bool ChatHandler::HandleMovegensCommand(const char* /*args*/) |
---|
5631 | { |
---|
5632 | Unit* unit = getSelectedUnit(); |
---|
5633 | if(!unit) |
---|
5634 | { |
---|
5635 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
5636 | SetSentErrorMessage(true); |
---|
5637 | return false; |
---|
5638 | } |
---|
5639 | |
---|
5640 | PSendSysMessage(LANG_MOVEGENS_LIST,(unit->GetTypeId()==TYPEID_PLAYER ? "Player" : "Creature" ),unit->GetGUIDLow()); |
---|
5641 | |
---|
5642 | MotionMaster* mm = unit->GetMotionMaster(); |
---|
5643 | for(MotionMaster::const_iterator itr = mm->begin(); itr != mm->end(); ++itr) |
---|
5644 | { |
---|
5645 | switch((*itr)->GetMovementGeneratorType()) |
---|
5646 | { |
---|
5647 | case IDLE_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_IDLE); break; |
---|
5648 | case RANDOM_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_RANDOM); break; |
---|
5649 | case WAYPOINT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_WAYPOINT); break; |
---|
5650 | case ANIMAL_RANDOM_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_ANIMAL_RANDOM); break; |
---|
5651 | case CONFUSED_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_CONFUSED); break; |
---|
5652 | case TARGETED_MOTION_TYPE: |
---|
5653 | { |
---|
5654 | if(unit->GetTypeId()==TYPEID_PLAYER) |
---|
5655 | { |
---|
5656 | TargetedMovementGenerator<Player> const* mgen = static_cast<TargetedMovementGenerator<Player> const*>(*itr); |
---|
5657 | Unit* target = mgen->GetTarget(); |
---|
5658 | if(target) |
---|
5659 | PSendSysMessage(LANG_MOVEGENS_TARGETED_PLAYER,target->GetName(),target->GetGUIDLow()); |
---|
5660 | else |
---|
5661 | SendSysMessage(LANG_MOVEGENS_TARGETED_NULL); |
---|
5662 | } |
---|
5663 | else |
---|
5664 | { |
---|
5665 | TargetedMovementGenerator<Creature> const* mgen = static_cast<TargetedMovementGenerator<Creature> const*>(*itr); |
---|
5666 | Unit* target = mgen->GetTarget(); |
---|
5667 | if(target) |
---|
5668 | PSendSysMessage(LANG_MOVEGENS_TARGETED_CREATURE,target->GetName(),target->GetGUIDLow()); |
---|
5669 | else |
---|
5670 | SendSysMessage(LANG_MOVEGENS_TARGETED_NULL); |
---|
5671 | } |
---|
5672 | break; |
---|
5673 | } |
---|
5674 | case HOME_MOTION_TYPE: |
---|
5675 | if(unit->GetTypeId()==TYPEID_UNIT) |
---|
5676 | { |
---|
5677 | float x,y,z; |
---|
5678 | (*itr)->GetDestination(x,y,z); |
---|
5679 | PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE,x,y,z); |
---|
5680 | } |
---|
5681 | else |
---|
5682 | SendSysMessage(LANG_MOVEGENS_HOME_PLAYER); |
---|
5683 | break; |
---|
5684 | case FLIGHT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_FLIGHT); break; |
---|
5685 | case POINT_MOTION_TYPE: |
---|
5686 | { |
---|
5687 | float x,y,z; |
---|
5688 | (*itr)->GetDestination(x,y,z); |
---|
5689 | PSendSysMessage(LANG_MOVEGENS_POINT,x,y,z); |
---|
5690 | break; |
---|
5691 | } |
---|
5692 | case FLEEING_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_FEAR); break; |
---|
5693 | case DISTRACT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_DISTRACT); break; |
---|
5694 | default: |
---|
5695 | PSendSysMessage(LANG_MOVEGENS_UNKNOWN,(*itr)->GetMovementGeneratorType()); |
---|
5696 | break; |
---|
5697 | } |
---|
5698 | } |
---|
5699 | return true; |
---|
5700 | } |
---|
5701 | |
---|
5702 | bool ChatHandler::HandlePLimitCommand(const char *args) |
---|
5703 | { |
---|
5704 | if(*args) |
---|
5705 | { |
---|
5706 | char* param = strtok((char*)args, " "); |
---|
5707 | if(!param) |
---|
5708 | return false; |
---|
5709 | |
---|
5710 | int l = strlen(param); |
---|
5711 | |
---|
5712 | if( strncmp(param,"player",l) == 0 ) |
---|
5713 | sWorld.SetPlayerLimit(-SEC_PLAYER); |
---|
5714 | else if(strncmp(param,"moderator",l) == 0 ) |
---|
5715 | sWorld.SetPlayerLimit(-SEC_MODERATOR); |
---|
5716 | else if(strncmp(param,"gamemaster",l) == 0 ) |
---|
5717 | sWorld.SetPlayerLimit(-SEC_GAMEMASTER); |
---|
5718 | else if(strncmp(param,"administrator",l) == 0 ) |
---|
5719 | sWorld.SetPlayerLimit(-SEC_ADMINISTRATOR); |
---|
5720 | else if(strncmp(param,"reset",l) == 0 ) |
---|
5721 | sWorld.SetPlayerLimit( sConfig.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT) ); |
---|
5722 | else |
---|
5723 | { |
---|
5724 | int val = atoi(param); |
---|
5725 | if(val < -SEC_ADMINISTRATOR) val = -SEC_ADMINISTRATOR; |
---|
5726 | |
---|
5727 | sWorld.SetPlayerLimit(val); |
---|
5728 | } |
---|
5729 | |
---|
5730 | // kick all low security level players |
---|
5731 | if(sWorld.GetPlayerAmountLimit() > SEC_PLAYER) |
---|
5732 | sWorld.KickAllLess(sWorld.GetPlayerSecurityLimit()); |
---|
5733 | } |
---|
5734 | |
---|
5735 | uint32 pLimit = sWorld.GetPlayerAmountLimit(); |
---|
5736 | AccountTypes allowedAccountType = sWorld.GetPlayerSecurityLimit(); |
---|
5737 | char const* secName = ""; |
---|
5738 | switch(allowedAccountType) |
---|
5739 | { |
---|
5740 | case SEC_PLAYER: secName = "Player"; break; |
---|
5741 | case SEC_MODERATOR: secName = "Moderator"; break; |
---|
5742 | case SEC_GAMEMASTER: secName = "Gamemaster"; break; |
---|
5743 | case SEC_ADMINISTRATOR: secName = "Administrator"; break; |
---|
5744 | default: secName = "<unknown>"; break; |
---|
5745 | } |
---|
5746 | |
---|
5747 | PSendSysMessage("Player limits: amount %u, min. security level %s.",pLimit,secName); |
---|
5748 | |
---|
5749 | return true; |
---|
5750 | } |
---|
5751 | |
---|
5752 | bool ChatHandler::HandleCastCommand(const char* args) |
---|
5753 | { |
---|
5754 | if(!*args) |
---|
5755 | return false; |
---|
5756 | |
---|
5757 | Unit* target = getSelectedUnit(); |
---|
5758 | |
---|
5759 | if(!target) |
---|
5760 | { |
---|
5761 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
5762 | SetSentErrorMessage(true); |
---|
5763 | return false; |
---|
5764 | } |
---|
5765 | |
---|
5766 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form |
---|
5767 | uint32 spell = extractSpellIdFromLink((char*)args); |
---|
5768 | if(!spell) |
---|
5769 | return false; |
---|
5770 | |
---|
5771 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); |
---|
5772 | if(!spellInfo) |
---|
5773 | return false; |
---|
5774 | |
---|
5775 | if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) |
---|
5776 | { |
---|
5777 | PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); |
---|
5778 | SetSentErrorMessage(true); |
---|
5779 | return false; |
---|
5780 | } |
---|
5781 | |
---|
5782 | char* trig_str = strtok(NULL, " "); |
---|
5783 | if(trig_str) |
---|
5784 | { |
---|
5785 | int l = strlen(trig_str); |
---|
5786 | if(strncmp(trig_str,"triggered",l) != 0 ) |
---|
5787 | return false; |
---|
5788 | } |
---|
5789 | |
---|
5790 | bool triggered = (trig_str != NULL); |
---|
5791 | |
---|
5792 | m_session->GetPlayer()->CastSpell(target,spell,triggered); |
---|
5793 | |
---|
5794 | return true; |
---|
5795 | } |
---|
5796 | |
---|
5797 | bool ChatHandler::HandleCastBackCommand(const char* args) |
---|
5798 | { |
---|
5799 | Creature* caster = getSelectedCreature(); |
---|
5800 | |
---|
5801 | if(!caster) |
---|
5802 | { |
---|
5803 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
5804 | SetSentErrorMessage(true); |
---|
5805 | return false; |
---|
5806 | } |
---|
5807 | |
---|
5808 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r |
---|
5809 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form |
---|
5810 | uint32 spell = extractSpellIdFromLink((char*)args); |
---|
5811 | if(!spell || !sSpellStore.LookupEntry(spell)) |
---|
5812 | return false; |
---|
5813 | |
---|
5814 | char* trig_str = strtok(NULL, " "); |
---|
5815 | if(trig_str) |
---|
5816 | { |
---|
5817 | int l = strlen(trig_str); |
---|
5818 | if(strncmp(trig_str,"triggered",l) != 0 ) |
---|
5819 | return false; |
---|
5820 | } |
---|
5821 | |
---|
5822 | bool triggered = (trig_str != NULL); |
---|
5823 | |
---|
5824 | // update orientation at server |
---|
5825 | caster->SetOrientation(caster->GetAngle(m_session->GetPlayer())); |
---|
5826 | |
---|
5827 | // and client |
---|
5828 | WorldPacket data; |
---|
5829 | caster->BuildHeartBeatMsg(&data); |
---|
5830 | caster->SendMessageToSet(&data,true); |
---|
5831 | |
---|
5832 | caster->CastSpell(m_session->GetPlayer(),spell,false); |
---|
5833 | |
---|
5834 | return true; |
---|
5835 | } |
---|
5836 | |
---|
5837 | bool ChatHandler::HandleCastDistCommand(const char* args) |
---|
5838 | { |
---|
5839 | if(!*args) |
---|
5840 | return false; |
---|
5841 | |
---|
5842 | |
---|
5843 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form |
---|
5844 | uint32 spell = extractSpellIdFromLink((char*)args); |
---|
5845 | if(!spell) |
---|
5846 | return false; |
---|
5847 | |
---|
5848 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); |
---|
5849 | if(!spellInfo) |
---|
5850 | return false; |
---|
5851 | |
---|
5852 | if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) |
---|
5853 | { |
---|
5854 | PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); |
---|
5855 | SetSentErrorMessage(true); |
---|
5856 | return false; |
---|
5857 | } |
---|
5858 | |
---|
5859 | char *distStr = strtok(NULL, " "); |
---|
5860 | |
---|
5861 | float dist = 0; |
---|
5862 | |
---|
5863 | if(distStr) |
---|
5864 | sscanf(distStr, "%f", &dist); |
---|
5865 | |
---|
5866 | char* trig_str = strtok(NULL, " "); |
---|
5867 | if(trig_str) |
---|
5868 | { |
---|
5869 | int l = strlen(trig_str); |
---|
5870 | if(strncmp(trig_str,"triggered",l) != 0 ) |
---|
5871 | return false; |
---|
5872 | } |
---|
5873 | |
---|
5874 | bool triggered = (trig_str != NULL); |
---|
5875 | |
---|
5876 | float x,y,z; |
---|
5877 | m_session->GetPlayer()->GetClosePoint(x,y,z,dist); |
---|
5878 | |
---|
5879 | m_session->GetPlayer()->CastSpell(x,y,z,spell,triggered); |
---|
5880 | return true; |
---|
5881 | } |
---|
5882 | |
---|
5883 | bool ChatHandler::HandleCastTargetCommand(const char* args) |
---|
5884 | { |
---|
5885 | Creature* caster = getSelectedCreature(); |
---|
5886 | |
---|
5887 | if(!caster) |
---|
5888 | { |
---|
5889 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
5890 | SetSentErrorMessage(true); |
---|
5891 | return false; |
---|
5892 | } |
---|
5893 | |
---|
5894 | if(!caster->getVictim()) |
---|
5895 | { |
---|
5896 | SendSysMessage(LANG_SELECTED_TARGET_NOT_HAVE_VICTIM); |
---|
5897 | SetSentErrorMessage(true); |
---|
5898 | return false; |
---|
5899 | } |
---|
5900 | |
---|
5901 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form |
---|
5902 | uint32 spell = extractSpellIdFromLink((char*)args); |
---|
5903 | if(!spell || !sSpellStore.LookupEntry(spell)) |
---|
5904 | return false; |
---|
5905 | |
---|
5906 | char* trig_str = strtok(NULL, " "); |
---|
5907 | if(trig_str) |
---|
5908 | { |
---|
5909 | int l = strlen(trig_str); |
---|
5910 | if(strncmp(trig_str,"triggered",l) != 0 ) |
---|
5911 | return false; |
---|
5912 | } |
---|
5913 | |
---|
5914 | bool triggered = (trig_str != NULL); |
---|
5915 | |
---|
5916 | // update orientation at server |
---|
5917 | caster->SetOrientation(caster->GetAngle(m_session->GetPlayer())); |
---|
5918 | |
---|
5919 | // and client |
---|
5920 | WorldPacket data; |
---|
5921 | caster->BuildHeartBeatMsg(&data); |
---|
5922 | caster->SendMessageToSet(&data,true); |
---|
5923 | |
---|
5924 | caster->CastSpell(caster->getVictim(),spell,false); |
---|
5925 | |
---|
5926 | return true; |
---|
5927 | } |
---|
5928 | |
---|
5929 | /* |
---|
5930 | ComeToMe command REQUIRED for 3rd party scripting library to have access to PointMovementGenerator |
---|
5931 | Without this function 3rd party scripting library will get linking errors (unresolved external) |
---|
5932 | when attempting to use the PointMovementGenerator |
---|
5933 | */ |
---|
5934 | bool ChatHandler::HandleComeToMeCommand(const char *args) |
---|
5935 | { |
---|
5936 | Creature* caster = getSelectedCreature(); |
---|
5937 | |
---|
5938 | if(!caster) |
---|
5939 | { |
---|
5940 | SendSysMessage(LANG_SELECT_CREATURE); |
---|
5941 | SetSentErrorMessage(true); |
---|
5942 | return false; |
---|
5943 | } |
---|
5944 | |
---|
5945 | char* newFlagStr = strtok((char*)args, " "); |
---|
5946 | |
---|
5947 | if(!newFlagStr) |
---|
5948 | return false; |
---|
5949 | |
---|
5950 | uint32 newFlags = atoi(newFlagStr); |
---|
5951 | |
---|
5952 | caster->SetUnitMovementFlags(newFlags); |
---|
5953 | |
---|
5954 | Player* pl = m_session->GetPlayer(); |
---|
5955 | |
---|
5956 | caster->GetMotionMaster()->MovePoint(0, pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ()); |
---|
5957 | return true; |
---|
5958 | } |
---|
5959 | |
---|
5960 | bool ChatHandler::HandleCastSelfCommand(const char* args) |
---|
5961 | { |
---|
5962 | if(!*args) |
---|
5963 | return false; |
---|
5964 | |
---|
5965 | Unit* target = getSelectedUnit(); |
---|
5966 | |
---|
5967 | if(!target) |
---|
5968 | { |
---|
5969 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
5970 | SetSentErrorMessage(true); |
---|
5971 | return false; |
---|
5972 | } |
---|
5973 | |
---|
5974 | // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form |
---|
5975 | uint32 spell = extractSpellIdFromLink((char*)args); |
---|
5976 | if(!spell) |
---|
5977 | return false; |
---|
5978 | |
---|
5979 | SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); |
---|
5980 | if(!spellInfo) |
---|
5981 | return false; |
---|
5982 | |
---|
5983 | if(!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) |
---|
5984 | { |
---|
5985 | PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); |
---|
5986 | SetSentErrorMessage(true); |
---|
5987 | return false; |
---|
5988 | } |
---|
5989 | |
---|
5990 | target->CastSpell(target,spell,false); |
---|
5991 | |
---|
5992 | return true; |
---|
5993 | } |
---|
5994 | |
---|
5995 | std::string GetTimeString(uint32 time) |
---|
5996 | { |
---|
5997 | uint16 days = time / DAY, hours = (time % DAY) / HOUR, minute = (time % HOUR) / MINUTE; |
---|
5998 | std::ostringstream ss; |
---|
5999 | if(days) ss << days << "d "; |
---|
6000 | if(hours) ss << hours << "h "; |
---|
6001 | ss << minute << "m"; |
---|
6002 | return ss.str(); |
---|
6003 | } |
---|
6004 | |
---|
6005 | bool ChatHandler::HandleInstanceListBindsCommand(const char* /*args*/) |
---|
6006 | { |
---|
6007 | Player* player = getSelectedPlayer(); |
---|
6008 | if (!player) player = m_session->GetPlayer(); |
---|
6009 | uint32 counter = 0; |
---|
6010 | for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) |
---|
6011 | { |
---|
6012 | Player::BoundInstancesMap &binds = player->GetBoundInstances(i); |
---|
6013 | for(Player::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end(); ++itr) |
---|
6014 | { |
---|
6015 | InstanceSave *save = itr->second.save; |
---|
6016 | std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL)); |
---|
6017 | PSendSysMessage("map: %d inst: %d perm: %s diff: %s canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty() == DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); |
---|
6018 | counter++; |
---|
6019 | } |
---|
6020 | } |
---|
6021 | PSendSysMessage("player binds: %d", counter); |
---|
6022 | counter = 0; |
---|
6023 | Group *group = player->GetGroup(); |
---|
6024 | if(group) |
---|
6025 | { |
---|
6026 | for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) |
---|
6027 | { |
---|
6028 | Group::BoundInstancesMap &binds = group->GetBoundInstances(i); |
---|
6029 | for(Group::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end(); ++itr) |
---|
6030 | { |
---|
6031 | InstanceSave *save = itr->second.save; |
---|
6032 | std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL)); |
---|
6033 | PSendSysMessage("map: %d inst: %d perm: %s diff: %s canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty() == DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); |
---|
6034 | counter++; |
---|
6035 | } |
---|
6036 | } |
---|
6037 | } |
---|
6038 | PSendSysMessage("group binds: %d", counter); |
---|
6039 | |
---|
6040 | return true; |
---|
6041 | } |
---|
6042 | |
---|
6043 | bool ChatHandler::HandleInstanceUnbindCommand(const char* args) |
---|
6044 | { |
---|
6045 | if(!*args) |
---|
6046 | return false; |
---|
6047 | |
---|
6048 | std::string cmd = args; |
---|
6049 | if(cmd == "all") |
---|
6050 | { |
---|
6051 | Player* player = getSelectedPlayer(); |
---|
6052 | if (!player) player = m_session->GetPlayer(); |
---|
6053 | uint32 counter = 0; |
---|
6054 | for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) |
---|
6055 | { |
---|
6056 | Player::BoundInstancesMap &binds = player->GetBoundInstances(i); |
---|
6057 | for(Player::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end();) |
---|
6058 | { |
---|
6059 | if(itr->first != player->GetMapId()) |
---|
6060 | { |
---|
6061 | InstanceSave *save = itr->second.save; |
---|
6062 | std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL)); |
---|
6063 | PSendSysMessage("unbinding map: %d inst: %d perm: %s diff: %s canReset: %s TTR: %s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty() == DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); |
---|
6064 | player->UnbindInstance(itr, i); |
---|
6065 | counter++; |
---|
6066 | } |
---|
6067 | else |
---|
6068 | ++itr; |
---|
6069 | } |
---|
6070 | } |
---|
6071 | PSendSysMessage("instances unbound: %d", counter); |
---|
6072 | } |
---|
6073 | return true; |
---|
6074 | } |
---|
6075 | |
---|
6076 | bool ChatHandler::HandleInstanceStatsCommand(const char* /*args*/) |
---|
6077 | { |
---|
6078 | PSendSysMessage("instances loaded: %d", MapManager::Instance().GetNumInstances()); |
---|
6079 | PSendSysMessage("players in instances: %d", MapManager::Instance().GetNumPlayersInInstances()); |
---|
6080 | PSendSysMessage("instance saves: %d", sInstanceSaveManager.GetNumInstanceSaves()); |
---|
6081 | PSendSysMessage("players bound: %d", sInstanceSaveManager.GetNumBoundPlayersTotal()); |
---|
6082 | PSendSysMessage("groups bound: %d", sInstanceSaveManager.GetNumBoundGroupsTotal()); |
---|
6083 | return true; |
---|
6084 | } |
---|
6085 | |
---|
6086 | bool ChatHandler::HandleInstanceSaveDataCommand(const char * /*args*/) |
---|
6087 | { |
---|
6088 | Player* pl = m_session->GetPlayer(); |
---|
6089 | |
---|
6090 | Map* map = pl->GetMap(); |
---|
6091 | if (!map->IsDungeon()) |
---|
6092 | { |
---|
6093 | PSendSysMessage("Map is not a dungeon."); |
---|
6094 | SetSentErrorMessage(true); |
---|
6095 | return false; |
---|
6096 | } |
---|
6097 | |
---|
6098 | if (!((InstanceMap*)map)->GetInstanceData()) |
---|
6099 | { |
---|
6100 | PSendSysMessage("Map has no instance data."); |
---|
6101 | SetSentErrorMessage(true); |
---|
6102 | return false; |
---|
6103 | } |
---|
6104 | |
---|
6105 | ((InstanceMap*)map)->GetInstanceData()->SaveToDB(); |
---|
6106 | return true; |
---|
6107 | } |
---|
6108 | |
---|
6109 | /// Display the list of GMs |
---|
6110 | bool ChatHandler::HandleGMListFullCommand(const char* /*args*/) |
---|
6111 | { |
---|
6112 | ///- Get the accounts with GM Level >0 |
---|
6113 | QueryResult *result = loginDatabase.Query( "SELECT username,gmlevel FROM account WHERE gmlevel > 0" ); |
---|
6114 | if(result) |
---|
6115 | { |
---|
6116 | SendSysMessage(LANG_GMLIST); |
---|
6117 | SendSysMessage("========================"); |
---|
6118 | SendSysMessage(LANG_GMLIST_HEADER); |
---|
6119 | SendSysMessage("========================"); |
---|
6120 | |
---|
6121 | ///- Circle through them. Display username and GM level |
---|
6122 | do |
---|
6123 | { |
---|
6124 | Field *fields = result->Fetch(); |
---|
6125 | PSendSysMessage("|%15s|%6s|", fields[0].GetString(),fields[1].GetString()); |
---|
6126 | } while( result->NextRow() ); |
---|
6127 | |
---|
6128 | PSendSysMessage("========================"); |
---|
6129 | delete result; |
---|
6130 | } |
---|
6131 | else |
---|
6132 | PSendSysMessage(LANG_GMLIST_EMPTY); |
---|
6133 | return true; |
---|
6134 | } |
---|
6135 | |
---|
6136 | /// Define the 'Message of the day' for the realm |
---|
6137 | bool ChatHandler::HandleServerSetMotdCommand(const char* args) |
---|
6138 | { |
---|
6139 | sWorld.SetMotd(args); |
---|
6140 | PSendSysMessage(LANG_MOTD_NEW, args); |
---|
6141 | return true; |
---|
6142 | } |
---|
6143 | |
---|
6144 | /// Set/Unset the expansion level for an account |
---|
6145 | bool ChatHandler::HandleAccountSetAddonCommand(const char* args) |
---|
6146 | { |
---|
6147 | ///- Get the command line arguments |
---|
6148 | char *szAcc = strtok((char*)args," "); |
---|
6149 | char *szExp = strtok(NULL," "); |
---|
6150 | |
---|
6151 | if(!szAcc) |
---|
6152 | return false; |
---|
6153 | |
---|
6154 | std::string account_name; |
---|
6155 | uint32 account_id; |
---|
6156 | |
---|
6157 | if(!szExp) |
---|
6158 | { |
---|
6159 | Player* player = getSelectedPlayer(); |
---|
6160 | if(!player) |
---|
6161 | return false; |
---|
6162 | |
---|
6163 | account_id = player->GetSession()->GetAccountId(); |
---|
6164 | accmgr.GetName(account_id,account_name); |
---|
6165 | szExp = szAcc; |
---|
6166 | } |
---|
6167 | else |
---|
6168 | { |
---|
6169 | ///- Convert Account name to Upper Format |
---|
6170 | account_name = szAcc; |
---|
6171 | if(!AccountMgr::normilizeString(account_name)) |
---|
6172 | { |
---|
6173 | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
---|
6174 | SetSentErrorMessage(true); |
---|
6175 | return false; |
---|
6176 | } |
---|
6177 | |
---|
6178 | account_id = accmgr.GetId(account_name); |
---|
6179 | if(!account_id) |
---|
6180 | { |
---|
6181 | PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); |
---|
6182 | SetSentErrorMessage(true); |
---|
6183 | return false; |
---|
6184 | } |
---|
6185 | } |
---|
6186 | |
---|
6187 | int lev=atoi(szExp); //get int anyway (0 if error) |
---|
6188 | if(lev < 0) |
---|
6189 | return false; |
---|
6190 | |
---|
6191 | // No SQL injection |
---|
6192 | loginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'",lev,account_id); |
---|
6193 | PSendSysMessage(LANG_ACCOUNT_SETADDON,account_name.c_str(),account_id,lev); |
---|
6194 | return true; |
---|
6195 | } |
---|
6196 | |
---|
6197 | /// Send a message to a player in game |
---|
6198 | bool ChatHandler::HandleSendMessageCommand(const char* args) |
---|
6199 | { |
---|
6200 | ///- Get the command line arguments |
---|
6201 | char* name_str = strtok((char*)args, " "); |
---|
6202 | char* msg_str = strtok(NULL, ""); |
---|
6203 | |
---|
6204 | if(!name_str || !msg_str) |
---|
6205 | return false; |
---|
6206 | |
---|
6207 | std::string name = name_str; |
---|
6208 | |
---|
6209 | if(!normalizePlayerName(name)) |
---|
6210 | return false; |
---|
6211 | |
---|
6212 | ///- Find the player and check that he is not logging out. |
---|
6213 | Player *rPlayer = objmgr.GetPlayer(name.c_str()); |
---|
6214 | if(!rPlayer) |
---|
6215 | { |
---|
6216 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
6217 | SetSentErrorMessage(true); |
---|
6218 | return false; |
---|
6219 | } |
---|
6220 | |
---|
6221 | if(rPlayer->GetSession()->isLogingOut()) |
---|
6222 | { |
---|
6223 | SendSysMessage(LANG_PLAYER_NOT_FOUND); |
---|
6224 | SetSentErrorMessage(true); |
---|
6225 | return false; |
---|
6226 | } |
---|
6227 | |
---|
6228 | ///- Send the message |
---|
6229 | //Use SendAreaTriggerMessage for fastest delivery. |
---|
6230 | rPlayer->GetSession()->SendAreaTriggerMessage("%s", msg_str); |
---|
6231 | rPlayer->GetSession()->SendAreaTriggerMessage("|cffff0000[Message from administrator]:|r"); |
---|
6232 | |
---|
6233 | //Confirmation message |
---|
6234 | PSendSysMessage(LANG_SENDMESSAGE,name.c_str(),msg_str); |
---|
6235 | return true; |
---|
6236 | } |
---|
6237 | |
---|
6238 | bool ChatHandler::HandlePlayAllCommand(const char* args) |
---|
6239 | { |
---|
6240 | if(!*args) |
---|
6241 | return false; |
---|
6242 | |
---|
6243 | uint32 soundId = atoi((char*)args); |
---|
6244 | |
---|
6245 | if(!sSoundEntriesStore.LookupEntry(soundId)) |
---|
6246 | { |
---|
6247 | PSendSysMessage(LANG_SOUND_NOT_EXIST, soundId); |
---|
6248 | SetSentErrorMessage(true); |
---|
6249 | return false; |
---|
6250 | } |
---|
6251 | |
---|
6252 | WorldPacket data(SMSG_PLAY_SOUND, 4); |
---|
6253 | data << uint32(soundId) << m_session->GetPlayer()->GetGUID(); |
---|
6254 | sWorld.SendGlobalMessage(&data); |
---|
6255 | |
---|
6256 | PSendSysMessage(LANG_COMMAND_PLAYED_TO_ALL, soundId); |
---|
6257 | return true; |
---|
6258 | } |
---|
6259 | |
---|
6260 | bool ChatHandler::HandleModifyGenderCommand(const char *args) |
---|
6261 | { |
---|
6262 | if(!*args) return false; |
---|
6263 | Player *player = getSelectedPlayer(); |
---|
6264 | |
---|
6265 | if(!player) |
---|
6266 | { |
---|
6267 | PSendSysMessage(LANG_NO_PLAYER); |
---|
6268 | SetSentErrorMessage(true); |
---|
6269 | return false; |
---|
6270 | } |
---|
6271 | |
---|
6272 | std::string gender = (char*)args; |
---|
6273 | uint32 displayId = player->GetNativeDisplayId(); |
---|
6274 | |
---|
6275 | if(gender == "male") // MALE |
---|
6276 | { |
---|
6277 | if(player->getGender() == GENDER_MALE) |
---|
6278 | { |
---|
6279 | PSendSysMessage("%s is already male", player->GetName()); |
---|
6280 | SetSentErrorMessage(true); |
---|
6281 | return false; |
---|
6282 | } |
---|
6283 | |
---|
6284 | // Set gender |
---|
6285 | player->SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_MALE); |
---|
6286 | // Change display ID |
---|
6287 | player->SetDisplayId(player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1); |
---|
6288 | player->SetNativeDisplayId(player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1); |
---|
6289 | |
---|
6290 | ChatHandler(player).PSendSysMessage("Gender changed. You are now a man!"); |
---|
6291 | PSendSysMessage("Gender changed for %s", player->GetName()); |
---|
6292 | return true; |
---|
6293 | } |
---|
6294 | else if(gender == "female") // FEMALE |
---|
6295 | { |
---|
6296 | if(player->getGender() == GENDER_FEMALE) |
---|
6297 | { |
---|
6298 | PSendSysMessage("%s is already female", player->GetName()); |
---|
6299 | SetSentErrorMessage(true); |
---|
6300 | return false; |
---|
6301 | } |
---|
6302 | |
---|
6303 | // Set gender |
---|
6304 | player->SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_FEMALE); |
---|
6305 | // Change display ID |
---|
6306 | player->SetDisplayId(player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1); |
---|
6307 | player->SetNativeDisplayId(player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1); |
---|
6308 | |
---|
6309 | ChatHandler(player).PSendSysMessage("Gender changed. You are now a woman!"); |
---|
6310 | PSendSysMessage("Gender changed for %s", player->GetName()); |
---|
6311 | return true; |
---|
6312 | } |
---|
6313 | else |
---|
6314 | { |
---|
6315 | PSendSysMessage("You must use male or female as gender."); |
---|
6316 | SetSentErrorMessage(true); |
---|
6317 | return false; |
---|
6318 | } |
---|
6319 | |
---|
6320 | return true; |
---|
6321 | } |
---|
6322 | |
---|
6323 | bool ChatHandler::HandleFreezeCommand(const char *args) |
---|
6324 | { |
---|
6325 | std::string name; |
---|
6326 | Player* player; |
---|
6327 | char* TargetName = strtok((char*)args, " "); //get entered name |
---|
6328 | if (!TargetName) //if no name entered use target |
---|
6329 | { |
---|
6330 | player = getSelectedPlayer(); |
---|
6331 | if (player) //prevent crash with creature as target |
---|
6332 | { |
---|
6333 | name = player->GetName(); |
---|
6334 | normalizePlayerName(name); |
---|
6335 | } |
---|
6336 | } |
---|
6337 | else // if name entered |
---|
6338 | { |
---|
6339 | name = TargetName; |
---|
6340 | normalizePlayerName(name); |
---|
6341 | player = objmgr.GetPlayer(name.c_str()); //get player by name |
---|
6342 | } |
---|
6343 | |
---|
6344 | if (!player) |
---|
6345 | { |
---|
6346 | SendSysMessage(LANG_COMMAND_FREEZE_WRONG); |
---|
6347 | return true; |
---|
6348 | } |
---|
6349 | |
---|
6350 | if (player==m_session->GetPlayer()) |
---|
6351 | { |
---|
6352 | SendSysMessage(LANG_COMMAND_FREEZE_ERROR); |
---|
6353 | return true; |
---|
6354 | } |
---|
6355 | |
---|
6356 | //effect |
---|
6357 | if ((player) && (!(player==m_session->GetPlayer()))) |
---|
6358 | { |
---|
6359 | PSendSysMessage(LANG_COMMAND_FREEZE,name.c_str()); |
---|
6360 | |
---|
6361 | //stop combat + make player unattackable + duel stop + stop some spells |
---|
6362 | player->setFaction(35); |
---|
6363 | player->CombatStop(); |
---|
6364 | if(player->IsNonMeleeSpellCasted(true)) |
---|
6365 | player->InterruptNonMeleeSpells(true); |
---|
6366 | player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); |
---|
6367 | player->SetUInt32Value(PLAYER_DUEL_TEAM, 1); |
---|
6368 | |
---|
6369 | //if player class = hunter || warlock remove pet if alive |
---|
6370 | if((player->getClass() == CLASS_HUNTER) || (player->getClass() == CLASS_WARLOCK)) |
---|
6371 | { |
---|
6372 | if(Pet* pet = player->GetPet()) |
---|
6373 | { |
---|
6374 | pet->SavePetToDB(PET_SAVE_AS_CURRENT); |
---|
6375 | // not let dismiss dead pet |
---|
6376 | if(pet && pet->isAlive()) |
---|
6377 | player->RemovePet(pet,PET_SAVE_NOT_IN_SLOT); |
---|
6378 | } |
---|
6379 | } |
---|
6380 | |
---|
6381 | //stop movement and disable spells |
---|
6382 | uint32 spellID = 9454; |
---|
6383 | //m_session->GetPlayer()->CastSpell(player,spellID,false); |
---|
6384 | SpellEntry const *spellInfo = sSpellStore.LookupEntry( spellID ); |
---|
6385 | if(spellInfo) //TODO: Change the duration of the aura to -1 instead of 5000000 |
---|
6386 | { |
---|
6387 | for(uint32 i = 0;i<3;i++) |
---|
6388 | { |
---|
6389 | uint8 eff = spellInfo->Effect[i]; |
---|
6390 | if (eff>=TOTAL_SPELL_EFFECTS) |
---|
6391 | continue; |
---|
6392 | if( eff == SPELL_EFFECT_APPLY_AREA_AURA_PARTY || eff == SPELL_EFFECT_APPLY_AURA || |
---|
6393 | eff == SPELL_EFFECT_PERSISTENT_AREA_AURA || eff == SPELL_EFFECT_APPLY_AREA_AURA_FRIEND || |
---|
6394 | eff == SPELL_EFFECT_APPLY_AREA_AURA_ENEMY) |
---|
6395 | { |
---|
6396 | Aura *Aur = CreateAura(spellInfo, i, NULL, player); |
---|
6397 | player->AddAura(Aur); |
---|
6398 | } |
---|
6399 | } |
---|
6400 | } |
---|
6401 | |
---|
6402 | //save player |
---|
6403 | player->SaveToDB(); |
---|
6404 | } |
---|
6405 | return true; |
---|
6406 | } |
---|
6407 | |
---|
6408 | bool ChatHandler::HandleUnFreezeCommand(const char *args) |
---|
6409 | { |
---|
6410 | std::string name; |
---|
6411 | Player* player; |
---|
6412 | char* TargetName = strtok((char*)args, " "); //get entered name |
---|
6413 | if (!TargetName) //if no name entered use target |
---|
6414 | { |
---|
6415 | player = getSelectedPlayer(); |
---|
6416 | if (player) //prevent crash with creature as target |
---|
6417 | { |
---|
6418 | name = player->GetName(); |
---|
6419 | } |
---|
6420 | } |
---|
6421 | |
---|
6422 | else // if name entered |
---|
6423 | { |
---|
6424 | name = TargetName; |
---|
6425 | normalizePlayerName(name); |
---|
6426 | player = objmgr.GetPlayer(name.c_str()); //get player by name |
---|
6427 | } |
---|
6428 | |
---|
6429 | //effect |
---|
6430 | if (player) |
---|
6431 | { |
---|
6432 | PSendSysMessage(LANG_COMMAND_UNFREEZE,name.c_str()); |
---|
6433 | |
---|
6434 | //Reset player faction + allow combat + allow duels |
---|
6435 | player->setFactionForRace(player->getRace()); |
---|
6436 | player->RemoveFlag (UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); |
---|
6437 | |
---|
6438 | //allow movement and spells |
---|
6439 | uint32 spellID = 9454; |
---|
6440 | player->RemoveAurasDueToSpell(spellID); |
---|
6441 | |
---|
6442 | //save player |
---|
6443 | player->SaveToDB(); |
---|
6444 | } |
---|
6445 | |
---|
6446 | if (!player) |
---|
6447 | { |
---|
6448 | if (TargetName) |
---|
6449 | { |
---|
6450 | //check for offline players |
---|
6451 | QueryResult *result = CharacterDatabase.PQuery("SELECT characters.guid FROM `characters` WHERE characters.name = '%s'",name.c_str()); |
---|
6452 | if(!result) |
---|
6453 | { |
---|
6454 | SendSysMessage(LANG_COMMAND_FREEZE_WRONG); |
---|
6455 | return true; |
---|
6456 | } |
---|
6457 | //if player found: delete his freeze aura |
---|
6458 | Field *fields=result->Fetch(); |
---|
6459 | uint64 pguid = fields[0].GetUInt64(); |
---|
6460 | delete result; |
---|
6461 | CharacterDatabase.PQuery("DELETE FROM `character_aura` WHERE character_aura.spell = 9454 AND character_aura.guid = '%u'",pguid); |
---|
6462 | PSendSysMessage(LANG_COMMAND_UNFREEZE,name.c_str()); |
---|
6463 | return true; |
---|
6464 | } |
---|
6465 | else |
---|
6466 | { |
---|
6467 | SendSysMessage(LANG_COMMAND_FREEZE_WRONG); |
---|
6468 | return true; |
---|
6469 | } |
---|
6470 | } |
---|
6471 | |
---|
6472 | return true; |
---|
6473 | } |
---|
6474 | |
---|
6475 | bool ChatHandler::HandleListFreezeCommand(const char* args) |
---|
6476 | { |
---|
6477 | //Get names from DB |
---|
6478 | QueryResult *result = CharacterDatabase.PQuery("SELECT characters.name FROM `characters` LEFT JOIN `character_aura` ON (characters.guid = character_aura.guid) WHERE character_aura.spell = 9454"); |
---|
6479 | if(!result) |
---|
6480 | { |
---|
6481 | SendSysMessage(LANG_COMMAND_NO_FROZEN_PLAYERS); |
---|
6482 | return true; |
---|
6483 | } |
---|
6484 | //Header of the names |
---|
6485 | PSendSysMessage(LANG_COMMAND_LIST_FREEZE); |
---|
6486 | |
---|
6487 | //Output of the results |
---|
6488 | do |
---|
6489 | { |
---|
6490 | Field *fields = result->Fetch(); |
---|
6491 | std::string fplayers = fields[0].GetCppString(); |
---|
6492 | PSendSysMessage(LANG_COMMAND_FROZEN_PLAYERS,fplayers.c_str()); |
---|
6493 | } while (result->NextRow()); |
---|
6494 | |
---|
6495 | delete result; |
---|
6496 | return true; |
---|
6497 | } |
---|
6498 | |
---|
6499 | bool ChatHandler::HandleFlushArenaPointsCommand(const char * /*args*/) |
---|
6500 | { |
---|
6501 | sBattleGroundMgr.DistributeArenaPoints(); |
---|
6502 | return true; |
---|
6503 | } |
---|
6504 | |
---|
6505 | bool ChatHandler::HandleGroupLeaderCommand(const char* args) |
---|
6506 | { |
---|
6507 | Player* plr = NULL; |
---|
6508 | Group* group = NULL; |
---|
6509 | uint64 guid = 0; |
---|
6510 | char* cname = strtok((char*)args, " "); |
---|
6511 | |
---|
6512 | if(GetPlayerGroupAndGUIDByName(cname, plr, group, guid)) |
---|
6513 | if(group && group->GetLeaderGUID() != guid) |
---|
6514 | group->ChangeLeader(guid); |
---|
6515 | |
---|
6516 | return true; |
---|
6517 | } |
---|
6518 | |
---|
6519 | bool ChatHandler::HandleGroupDisbandCommand(const char* args) |
---|
6520 | { |
---|
6521 | Player* plr = NULL; |
---|
6522 | Group* group = NULL; |
---|
6523 | uint64 guid = 0; |
---|
6524 | char* cname = strtok((char*)args, " "); |
---|
6525 | |
---|
6526 | if(GetPlayerGroupAndGUIDByName(cname, plr, group, guid)) |
---|
6527 | if(group) |
---|
6528 | group->Disband(); |
---|
6529 | |
---|
6530 | return true; |
---|
6531 | } |
---|
6532 | |
---|
6533 | bool ChatHandler::HandleGroupRemoveCommand(const char* args) |
---|
6534 | { |
---|
6535 | Player* plr = NULL; |
---|
6536 | Group* group = NULL; |
---|
6537 | uint64 guid = 0; |
---|
6538 | char* cname = strtok((char*)args, " "); |
---|
6539 | |
---|
6540 | if(GetPlayerGroupAndGUIDByName(cname, plr, group, guid, true)) |
---|
6541 | if(group) |
---|
6542 | group->RemoveMember(guid, 0); |
---|
6543 | |
---|
6544 | return true; |
---|
6545 | } |
---|