2 * Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "Database/DatabaseEnv.h"
21 #include "WorldPacket.h"
22 #include "WorldSession.h"
24 #include "ObjectMgr.h"
25 #include "AccountMgr.h"
26 #include "PlayerDump.h"
30 #include "GameObject.h"
34 #include "ObjectAccessor.h"
35 #include "MapManager.h"
36 #include "SpellAuras.h"
37 #include "ScriptCalls.h"
39 #include "GridNotifiersImpl.h"
42 #include "PointMovementGenerator.h"
43 #include "TargetedMovementGenerator.h"
44 #include "SkillDiscovery.h"
45 #include "SkillExtraItems.h"
46 #include "SystemConfig.h"
47 #include "Config/ConfigEnv.h"
49 #include "ItemEnchantmentMgr.h"
50 #include "InstanceSaveMgr.h"
51 #include "InstanceData.h"
54 bool ChatHandler::HandleReloadCommand(const char* arg
)
56 // this is error catcher for wrong table name in .reload commands
57 PSendSysMessage("Db table with name starting from '%s' not found and can't be reloaded.",arg
);
58 SetSentErrorMessage(true);
62 bool ChatHandler::HandleReloadAllCommand(const char*)
64 HandleReloadAreaTriggerTeleportCommand("");
65 HandleReloadSkillFishingBaseLevelCommand("");
67 HandleReloadAllAreaCommand("");
68 HandleReloadAllLootCommand("");
69 HandleReloadAllNpcCommand("");
70 HandleReloadAllQuestCommand("");
71 HandleReloadAllSpellCommand("");
72 HandleReloadAllItemCommand("");
73 HandleReloadAllLocalesCommand("");
75 HandleReloadCommandCommand("");
76 HandleReloadReservedNameCommand("");
77 HandleReloadMangosStringCommand("");
78 HandleReloadGameTeleCommand("");
82 bool ChatHandler::HandleReloadAllAreaCommand(const char*)
84 //HandleReloadQuestAreaTriggersCommand(""); -- reloaded in HandleReloadAllQuestCommand
85 HandleReloadAreaTriggerTeleportCommand("");
86 HandleReloadAreaTriggerTavernCommand("");
87 HandleReloadGameGraveyardZoneCommand("");
91 bool ChatHandler::HandleReloadAllLootCommand(const char*)
93 sLog
.outString( "Re-Loading Loot Tables..." );
95 SendGlobalSysMessage("DB tables `*_loot_template` reloaded.");
99 bool ChatHandler::HandleReloadAllNpcCommand(const char* /*args*/)
101 HandleReloadNpcGossipCommand("a");
102 HandleReloadNpcTrainerCommand("a");
103 HandleReloadNpcVendorCommand("a");
107 bool ChatHandler::HandleReloadAllQuestCommand(const char* /*args*/)
109 HandleReloadQuestAreaTriggersCommand("a");
110 HandleReloadQuestTemplateCommand("a");
112 sLog
.outString( "Re-Loading Quests Relations..." );
113 objmgr
.LoadQuestRelations();
114 SendGlobalSysMessage("DB tables `*_questrelation` and `*_involvedrelation` reloaded.");
118 bool ChatHandler::HandleReloadAllScriptsCommand(const char*)
120 if(sWorld
.IsScriptScheduled())
122 PSendSysMessage("DB scripts used currently, please attempt reload later.");
123 SetSentErrorMessage(true);
127 sLog
.outString( "Re-Loading Scripts..." );
128 HandleReloadGameObjectScriptsCommand("a");
129 HandleReloadEventScriptsCommand("a");
130 HandleReloadQuestEndScriptsCommand("a");
131 HandleReloadQuestStartScriptsCommand("a");
132 HandleReloadSpellScriptsCommand("a");
133 SendGlobalSysMessage("DB tables `*_scripts` reloaded.");
137 bool ChatHandler::HandleReloadAllSpellCommand(const char*)
139 HandleReloadSkillDiscoveryTemplateCommand("a");
140 HandleReloadSkillExtraItemTemplateCommand("a");
141 HandleReloadSpellAffectCommand("a");
142 HandleReloadSpellChainCommand("a");
143 HandleReloadSpellElixirCommand("a");
144 HandleReloadSpellLearnSpellCommand("a");
145 HandleReloadSpellProcEventCommand("a");
146 HandleReloadSpellScriptTargetCommand("a");
147 HandleReloadSpellTargetPositionCommand("a");
148 HandleReloadSpellThreatsCommand("a");
149 HandleReloadSpellPetAurasCommand("a");
153 bool ChatHandler::HandleReloadAllItemCommand(const char*)
155 HandleReloadPageTextsCommand("a");
156 HandleReloadItemEnchantementsCommand("a");
160 bool ChatHandler::HandleReloadAllLocalesCommand(const char* args
)
162 HandleReloadLocalesCreatureCommand("a");
163 HandleReloadLocalesGameobjectCommand("a");
164 HandleReloadLocalesItemCommand("a");
165 HandleReloadLocalesNpcTextCommand("a");
166 HandleReloadLocalesPageTextCommand("a");
167 HandleReloadLocalesQuestCommand("a");
171 bool ChatHandler::HandleReloadConfigCommand(const char* arg
)
173 sLog
.outString( "Re-Loading config settings..." );
174 sWorld
.LoadConfigSettings(true);
175 SendGlobalSysMessage("World config settings reloaded.");
179 bool ChatHandler::HandleReloadAreaTriggerTavernCommand(const char*)
181 sLog
.outString( "Re-Loading Tavern Area Triggers..." );
182 objmgr
.LoadTavernAreaTriggers();
183 SendGlobalSysMessage("DB table `areatrigger_tavern` reloaded.");
187 bool ChatHandler::HandleReloadAreaTriggerTeleportCommand(const char*)
189 sLog
.outString( "Re-Loading AreaTrigger teleport definitions..." );
190 objmgr
.LoadAreaTriggerTeleports();
191 SendGlobalSysMessage("DB table `areatrigger_teleport` reloaded.");
195 bool ChatHandler::HandleReloadCommandCommand(const char*)
197 load_command_table
= true;
198 SendGlobalSysMessage("DB table `command` will be reloaded at next chat command use.");
202 bool ChatHandler::HandleReloadCreatureQuestRelationsCommand(const char*)
204 sLog
.outString( "Loading Quests Relations... (`creature_questrelation`)" );
205 objmgr
.LoadCreatureQuestRelations();
206 SendGlobalSysMessage("DB table `creature_questrelation` (creature quest givers) reloaded.");
210 bool ChatHandler::HandleReloadCreatureQuestInvRelationsCommand(const char*)
212 sLog
.outString( "Loading Quests Relations... (`creature_involvedrelation`)" );
213 objmgr
.LoadCreatureInvolvedRelations();
214 SendGlobalSysMessage("DB table `creature_involvedrelation` (creature quest takers) reloaded.");
218 bool ChatHandler::HandleReloadGOQuestRelationsCommand(const char*)
220 sLog
.outString( "Loading Quests Relations... (`gameobject_questrelation`)" );
221 objmgr
.LoadGameobjectQuestRelations();
222 SendGlobalSysMessage("DB table `gameobject_questrelation` (gameobject quest givers) reloaded.");
226 bool ChatHandler::HandleReloadGOQuestInvRelationsCommand(const char*)
228 sLog
.outString( "Loading Quests Relations... (`gameobject_involvedrelation`)" );
229 objmgr
.LoadGameobjectInvolvedRelations();
230 SendGlobalSysMessage("DB table `gameobject_involvedrelation` (gameobject quest takers) reloaded.");
234 bool ChatHandler::HandleReloadQuestAreaTriggersCommand(const char*)
236 sLog
.outString( "Re-Loading Quest Area Triggers..." );
237 objmgr
.LoadQuestAreaTriggers();
238 SendGlobalSysMessage("DB table `areatrigger_involvedrelation` (quest area triggers) reloaded.");
242 bool ChatHandler::HandleReloadQuestTemplateCommand(const char*)
244 sLog
.outString( "Re-Loading Quest Templates..." );
246 SendGlobalSysMessage("DB table `quest_template` (quest definitions) reloaded.");
250 bool ChatHandler::HandleReloadLootTemplatesCreatureCommand(const char*)
252 sLog
.outString( "Re-Loading Loot Tables... (`creature_loot_template`)" );
253 LoadLootTemplates_Creature();
254 LootTemplates_Creature
.CheckLootRefs();
255 SendGlobalSysMessage("DB table `creature_loot_template` reloaded.");
259 bool ChatHandler::HandleReloadLootTemplatesDisenchantCommand(const char*)
261 sLog
.outString( "Re-Loading Loot Tables... (`disenchant_loot_template`)" );
262 LoadLootTemplates_Disenchant();
263 LootTemplates_Disenchant
.CheckLootRefs();
264 SendGlobalSysMessage("DB table `disenchant_loot_template` reloaded.");
268 bool ChatHandler::HandleReloadLootTemplatesFishingCommand(const char*)
270 sLog
.outString( "Re-Loading Loot Tables... (`fishing_loot_template`)" );
271 LoadLootTemplates_Fishing();
272 LootTemplates_Fishing
.CheckLootRefs();
273 SendGlobalSysMessage("DB table `fishing_loot_template` reloaded.");
277 bool ChatHandler::HandleReloadLootTemplatesGameobjectCommand(const char*)
279 sLog
.outString( "Re-Loading Loot Tables... (`gameobject_loot_template`)" );
280 LoadLootTemplates_Gameobject();
281 LootTemplates_Gameobject
.CheckLootRefs();
282 SendGlobalSysMessage("DB table `gameobject_loot_template` reloaded.");
286 bool ChatHandler::HandleReloadLootTemplatesItemCommand(const char*)
288 sLog
.outString( "Re-Loading Loot Tables... (`item_loot_template`)" );
289 LoadLootTemplates_Item();
290 LootTemplates_Item
.CheckLootRefs();
291 SendGlobalSysMessage("DB table `item_loot_template` reloaded.");
295 bool ChatHandler::HandleReloadLootTemplatesPickpocketingCommand(const char*)
297 sLog
.outString( "Re-Loading Loot Tables... (`pickpocketing_loot_template`)" );
298 LoadLootTemplates_Pickpocketing();
299 LootTemplates_Pickpocketing
.CheckLootRefs();
300 SendGlobalSysMessage("DB table `pickpocketing_loot_template` reloaded.");
304 bool ChatHandler::HandleReloadLootTemplatesProspectingCommand(const char*)
306 sLog
.outString( "Re-Loading Loot Tables... (`prospecting_loot_template`)" );
307 LoadLootTemplates_Prospecting();
308 LootTemplates_Prospecting
.CheckLootRefs();
309 SendGlobalSysMessage("DB table `prospecting_loot_template` reloaded.");
313 bool ChatHandler::HandleReloadLootTemplatesQuestMailCommand(const char*)
315 sLog
.outString( "Re-Loading Loot Tables... (`quest_mail_loot_template`)" );
316 LoadLootTemplates_QuestMail();
317 LootTemplates_QuestMail
.CheckLootRefs();
318 SendGlobalSysMessage("DB table `quest_mail_loot_template` reloaded.");
322 bool ChatHandler::HandleReloadLootTemplatesReferenceCommand(const char*)
324 sLog
.outString( "Re-Loading Loot Tables... (`reference_loot_template`)" );
325 LoadLootTemplates_Reference();
326 SendGlobalSysMessage("DB table `reference_loot_template` reloaded.");
330 bool ChatHandler::HandleReloadLootTemplatesSkinningCommand(const char*)
332 sLog
.outString( "Re-Loading Loot Tables... (`skinning_loot_template`)" );
333 LoadLootTemplates_Skinning();
334 LootTemplates_Skinning
.CheckLootRefs();
335 SendGlobalSysMessage("DB table `skinning_loot_template` reloaded.");
339 bool ChatHandler::HandleReloadMangosStringCommand(const char*)
341 sLog
.outString( "Re-Loading mangos_string Table!" );
342 objmgr
.LoadMangosStrings();
343 SendGlobalSysMessage("DB table `mangos_string` reloaded.");
347 bool ChatHandler::HandleReloadNpcGossipCommand(const char*)
349 sLog
.outString( "Re-Loading `npc_gossip` Table!" );
350 objmgr
.LoadNpcTextId();
351 SendGlobalSysMessage("DB table `npc_gossip` reloaded.");
355 bool ChatHandler::HandleReloadNpcTrainerCommand(const char*)
357 sLog
.outString( "Re-Loading `npc_trainer` Table!" );
358 objmgr
.LoadTrainerSpell();
359 SendGlobalSysMessage("DB table `npc_trainer` reloaded.");
363 bool ChatHandler::HandleReloadNpcVendorCommand(const char*)
365 sLog
.outString( "Re-Loading `npc_vendor` Table!" );
366 objmgr
.LoadVendors();
367 SendGlobalSysMessage("DB table `npc_vendor` reloaded.");
371 bool ChatHandler::HandleReloadReservedNameCommand(const char*)
373 sLog
.outString( "Loading ReservedNames... (`reserved_name`)" );
374 objmgr
.LoadReservedPlayersNames();
375 SendGlobalSysMessage("DB table `reserved_name` (player reserved names) reloaded.");
379 bool ChatHandler::HandleReloadSkillDiscoveryTemplateCommand(const char* /*args*/)
381 sLog
.outString( "Re-Loading Skill Discovery Table..." );
382 LoadSkillDiscoveryTable();
383 SendGlobalSysMessage("DB table `skill_discovery_template` (recipes discovered at crafting) reloaded.");
387 bool ChatHandler::HandleReloadSkillExtraItemTemplateCommand(const char* /*args*/)
389 sLog
.outString( "Re-Loading Skill Extra Item Table..." );
390 LoadSkillExtraItemTable();
391 SendGlobalSysMessage("DB table `skill_extra_item_template` (extra item creation when crafting) reloaded.");
395 bool ChatHandler::HandleReloadSkillFishingBaseLevelCommand(const char* /*args*/)
397 sLog
.outString( "Re-Loading Skill Fishing base level requirements..." );
398 objmgr
.LoadFishingBaseSkillLevel();
399 SendGlobalSysMessage("DB table `skill_fishing_base_level` (fishing base level for zone/subzone) reloaded.");
403 bool ChatHandler::HandleReloadSpellAffectCommand(const char*)
405 sLog
.outString( "Re-Loading SpellAffect definitions..." );
406 spellmgr
.LoadSpellAffects();
407 SendGlobalSysMessage("DB table `spell_affect` (spell mods apply requirements) reloaded.");
411 bool ChatHandler::HandleReloadSpellChainCommand(const char*)
413 sLog
.outString( "Re-Loading Spell Chain Data... " );
414 spellmgr
.LoadSpellChains();
415 SendGlobalSysMessage("DB table `spell_chain` (spell ranks) reloaded.");
419 bool ChatHandler::HandleReloadSpellElixirCommand(const char*)
421 sLog
.outString( "Re-Loading Spell Elixir types..." );
422 spellmgr
.LoadSpellElixirs();
423 SendGlobalSysMessage("DB table `spell_elixir` (spell exlixir types) reloaded.");
427 bool ChatHandler::HandleReloadSpellLearnSpellCommand(const char*)
429 sLog
.outString( "Re-Loading Spell Learn Spells..." );
430 spellmgr
.LoadSpellLearnSpells();
431 SendGlobalSysMessage("DB table `spell_learn_spell` reloaded.");
435 bool ChatHandler::HandleReloadSpellProcEventCommand(const char*)
437 sLog
.outString( "Re-Loading Spell Proc Event conditions..." );
438 spellmgr
.LoadSpellProcEvents();
439 SendGlobalSysMessage("DB table `spell_proc_event` (spell proc trigger requirements) reloaded.");
443 bool ChatHandler::HandleReloadSpellScriptTargetCommand(const char*)
445 sLog
.outString( "Re-Loading SpellsScriptTarget..." );
446 spellmgr
.LoadSpellScriptTarget();
447 SendGlobalSysMessage("DB table `spell_script_target` (spell targets selection in case specific creature/GO requirements) reloaded.");
451 bool ChatHandler::HandleReloadSpellTargetPositionCommand(const char*)
453 sLog
.outString( "Re-Loading Spell target coordinates..." );
454 spellmgr
.LoadSpellTargetPositions();
455 SendGlobalSysMessage("DB table `spell_target_position` (destination coordinates for spell targets) reloaded.");
459 bool ChatHandler::HandleReloadSpellThreatsCommand(const char*)
461 sLog
.outString( "Re-Loading Aggro Spells Definitions...");
462 spellmgr
.LoadSpellThreats();
463 SendGlobalSysMessage("DB table `spell_threat` (spell aggro definitions) reloaded.");
467 bool ChatHandler::HandleReloadSpellPetAurasCommand(const char*)
469 sLog
.outString( "Re-Loading Spell pet auras...");
470 spellmgr
.LoadSpellPetAuras();
471 SendGlobalSysMessage("DB table `spell_pet_auras` reloaded.");
475 bool ChatHandler::HandleReloadPageTextsCommand(const char*)
477 sLog
.outString( "Re-Loading Page Texts..." );
478 objmgr
.LoadPageTexts();
479 SendGlobalSysMessage("DB table `page_texts` reloaded.");
483 bool ChatHandler::HandleReloadItemEnchantementsCommand(const char*)
485 sLog
.outString( "Re-Loading Item Random Enchantments Table..." );
486 LoadRandomEnchantmentsTable();
487 SendGlobalSysMessage("DB table `item_enchantment_template` reloaded.");
491 bool ChatHandler::HandleReloadGameObjectScriptsCommand(const char* arg
)
493 if(sWorld
.IsScriptScheduled())
495 SendSysMessage("DB scripts used currently, please attempt reload later.");
496 SetSentErrorMessage(true);
501 sLog
.outString( "Re-Loading Scripts from `gameobject_scripts`...");
503 objmgr
.LoadGameObjectScripts();
506 SendGlobalSysMessage("DB table `gameobject_scripts` reloaded.");
511 bool ChatHandler::HandleReloadEventScriptsCommand(const char* arg
)
513 if(sWorld
.IsScriptScheduled())
515 SendSysMessage("DB scripts used currently, please attempt reload later.");
516 SetSentErrorMessage(true);
521 sLog
.outString( "Re-Loading Scripts from `event_scripts`...");
523 objmgr
.LoadEventScripts();
526 SendGlobalSysMessage("DB table `event_scripts` reloaded.");
531 bool ChatHandler::HandleReloadQuestEndScriptsCommand(const char* arg
)
533 if(sWorld
.IsScriptScheduled())
535 SendSysMessage("DB scripts used currently, please attempt reload later.");
536 SetSentErrorMessage(true);
541 sLog
.outString( "Re-Loading Scripts from `quest_end_scripts`...");
543 objmgr
.LoadQuestEndScripts();
546 SendGlobalSysMessage("DB table `quest_end_scripts` reloaded.");
551 bool ChatHandler::HandleReloadQuestStartScriptsCommand(const char* arg
)
553 if(sWorld
.IsScriptScheduled())
555 SendSysMessage("DB scripts used currently, please attempt reload later.");
556 SetSentErrorMessage(true);
561 sLog
.outString( "Re-Loading Scripts from `quest_start_scripts`...");
563 objmgr
.LoadQuestStartScripts();
566 SendGlobalSysMessage("DB table `quest_start_scripts` reloaded.");
571 bool ChatHandler::HandleReloadSpellScriptsCommand(const char* arg
)
573 if(sWorld
.IsScriptScheduled())
575 SendSysMessage("DB scripts used currently, please attempt reload later.");
576 SetSentErrorMessage(true);
581 sLog
.outString( "Re-Loading Scripts from `spell_scripts`...");
583 objmgr
.LoadSpellScripts();
586 SendGlobalSysMessage("DB table `spell_scripts` reloaded.");
591 bool ChatHandler::HandleReloadGameGraveyardZoneCommand(const char* /*arg*/)
593 sLog
.outString( "Re-Loading Graveyard-zone links...");
595 objmgr
.LoadGraveyardZones();
597 SendGlobalSysMessage("DB table `game_graveyard_zone` reloaded.");
602 bool ChatHandler::HandleReloadGameTeleCommand(const char* /*arg*/)
604 sLog
.outString( "Re-Loading Game Tele coordinates...");
606 objmgr
.LoadGameTele();
608 SendGlobalSysMessage("DB table `game_tele` reloaded.");
613 bool ChatHandler::HandleReloadLocalesCreatureCommand(const char* /*arg*/)
615 sLog
.outString( "Re-Loading Locales Creature ...");
616 objmgr
.LoadCreatureLocales();
617 SendGlobalSysMessage("DB table `locales_creature` reloaded.");
621 bool ChatHandler::HandleReloadLocalesGameobjectCommand(const char* /*arg*/)
623 sLog
.outString( "Re-Loading Locales Gameobject ... ");
624 objmgr
.LoadGameObjectLocales();
625 SendGlobalSysMessage("DB table `locales_gameobject` reloaded.");
629 bool ChatHandler::HandleReloadLocalesItemCommand(const char* /*arg*/)
631 sLog
.outString( "Re-Loading Locales Item ... ");
632 objmgr
.LoadItemLocales();
633 SendGlobalSysMessage("DB table `locales_item` reloaded.");
637 bool ChatHandler::HandleReloadLocalesNpcTextCommand(const char* /*arg*/)
639 sLog
.outString( "Re-Loading Locales NPC Text ... ");
640 objmgr
.LoadNpcTextLocales();
641 SendGlobalSysMessage("DB table `locales_npc_text` reloaded.");
645 bool ChatHandler::HandleReloadLocalesPageTextCommand(const char* /*arg*/)
647 sLog
.outString( "Re-Loading Locales Page Text ... ");
648 objmgr
.LoadPageTextLocales();
649 SendGlobalSysMessage("DB table `locales_page_text` reloaded.");
653 bool ChatHandler::HandleReloadLocalesQuestCommand(const char* /*arg*/)
655 sLog
.outString( "Re-Loading Locales Quest ... ");
656 objmgr
.LoadQuestLocales();
657 SendGlobalSysMessage("DB table `locales_quest` reloaded.");
661 bool ChatHandler::HandleLoadScriptsCommand(const char* args
)
663 if(!LoadScriptingModule(args
)) return true;
665 sWorld
.SendWorldText(LANG_SCRIPTS_RELOADED
);
669 bool ChatHandler::HandleSecurityCommand(const char* args
)
671 char* arg1
= strtok((char*)args
, " ");
677 std::string targetName
;
678 uint32 targetAccountId
= 0;
679 uint32 targetSecurity
= 0;
681 Player
* targetPlayer
= getSelectedPlayer();
684 targetName
= targetPlayer
->GetName();
685 targetAccountId
= targetPlayer
->GetSession()->GetAccountId();
686 targetSecurity
= targetPlayer
->GetSession()->GetSecurity();
692 if(!normalizePlayerName(targetName
))
694 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
695 SetSentErrorMessage(true);
699 targetPlayer
= ObjectAccessor::Instance().FindPlayerByName(targetName
.c_str());
702 targetAccountId
= targetPlayer
->GetSession()->GetAccountId();
703 targetSecurity
= targetPlayer
->GetSession()->GetSecurity();
707 uint64 targetGUID
= objmgr
.GetPlayerGUIDByName(targetName
.c_str());
710 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
711 SetSentErrorMessage(true);
714 targetAccountId
= objmgr
.GetPlayerAccountIdByGUID(targetGUID
);
715 targetSecurity
= accmgr
.GetSecurity(targetAccountId
);
718 arg2
= strtok(NULL
, " ");
721 int32 gm
= (int32
)atoi(arg2
);
722 if ( gm
< SEC_PLAYER
|| gm
> SEC_ADMINISTRATOR
)
724 SendSysMessage(LANG_BAD_VALUE
);
725 SetSentErrorMessage(true);
729 // can set security level only for target with less security and to less security that we have
730 if(targetSecurity
>= m_session
->GetSecurity() || uint32(gm
) >= m_session
->GetSecurity() )
732 SendSysMessage(LANG_YOURS_SECURITY_IS_LOW
);
733 SetSentErrorMessage(true);
739 if( targetPlayer
!= m_session
->GetPlayer() )
740 ChatHandler(targetPlayer
).PSendSysMessage(LANG_YOURS_SECURITY_CHANGED
,m_session
->GetPlayer()->GetName(), gm
);
742 targetPlayer
->GetSession()->SetSecurity(gm
);
745 PSendSysMessage(LANG_YOU_CHANGE_SECURITY
, targetName
.c_str(), gm
);
746 loginDatabase
.PExecute("UPDATE account SET gmlevel = '%i' WHERE id = '%u'", gm
, targetAccountId
);
751 bool ChatHandler::HandleAllowMovementCommand(const char* /*args*/)
753 if(sWorld
.getAllowMovement())
755 sWorld
.SetAllowMovement(false);
756 SendSysMessage(LANG_CREATURE_MOVE_DISABLED
);
760 sWorld
.SetAllowMovement(true);
761 SendSysMessage(LANG_CREATURE_MOVE_ENABLED
);
766 bool ChatHandler::HandleMaxSkillCommand(const char* /*args*/)
768 Player
* SelectedPlayer
= getSelectedPlayer();
771 SendSysMessage(LANG_NO_CHAR_SELECTED
);
772 SetSentErrorMessage(true);
776 // each skills that have max skill value dependent from level seted to current level max skill value
777 SelectedPlayer
->UpdateSkillsToMaxSkillsForLevel();
781 bool ChatHandler::HandleSetSkillCommand(const char* args
)
783 // number or [name] Shift-click form |color|Hskill:skill_id|h[name]|h|r
784 char* skill_p
= extractKeyFromLink((char*)args
,"Hskill");
788 char *level_p
= strtok (NULL
, " ");
793 char *max_p
= strtok (NULL
, " ");
795 int32 skill
= atoi(skill_p
);
799 PSendSysMessage(LANG_INVALID_SKILL_ID
, skill
);
800 SetSentErrorMessage(true);
804 int32 level
= atol (level_p
);
806 Player
* target
= getSelectedPlayer();
809 SendSysMessage(LANG_NO_CHAR_SELECTED
);
810 SetSentErrorMessage(true);
814 SkillLineEntry
const* sl
= sSkillLineStore
.LookupEntry(skill
);
817 PSendSysMessage(LANG_INVALID_SKILL_ID
, skill
);
818 SetSentErrorMessage(true);
822 if(!target
->GetSkillValue(skill
))
824 PSendSysMessage(LANG_SET_SKILL_ERROR
, target
->GetName(), skill
, sl
->name
[0]);
825 SetSentErrorMessage(true);
829 int32 max
= max_p
? atol (max_p
) : target
->GetPureMaxSkillValue(skill
);
831 if( level
<= 0 || level
> max
|| max
<= 0 )
834 target
->SetSkill(skill
, level
, max
);
835 PSendSysMessage(LANG_SET_SKILL
, skill
, sl
->name
[0], target
->GetName(), level
, max
);
840 bool ChatHandler::HandleUnLearnCommand(const char* args
)
845 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r
846 uint32 min_id
= extractSpellIdFromLink((char*)args
);
850 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r
851 char* tail
= strtok(NULL
,"");
853 uint32 max_id
= extractSpellIdFromLink(tail
);
857 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r
863 std::swap(min_id
,max_id
);
868 Player
* target
= getSelectedPlayer();
871 SendSysMessage(LANG_NO_CHAR_SELECTED
);
872 SetSentErrorMessage(true);
876 for(uint32 spell
=min_id
;spell
<max_id
;spell
++)
878 if (target
->HasSpell(spell
))
879 target
->removeSpell(spell
);
881 SendSysMessage(LANG_FORGET_SPELL
);
887 bool ChatHandler::HandleCooldownCommand(const char* args
)
889 Player
* target
= getSelectedPlayer();
892 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
893 SetSentErrorMessage(true);
899 target
->RemoveAllSpellCooldown();
900 PSendSysMessage(LANG_REMOVEALL_COOLDOWN
, target
->GetName());
904 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
905 uint32 spell_id
= extractSpellIdFromLink((char*)args
);
909 if(!sSpellStore
.LookupEntry(spell_id
))
911 PSendSysMessage(LANG_UNKNOWN_SPELL
, target
==m_session
->GetPlayer() ? GetMangosString(LANG_YOU
) : target
->GetName());
912 SetSentErrorMessage(true);
916 WorldPacket
data( SMSG_CLEAR_COOLDOWN
, (4+8) );
917 data
<< uint32(spell_id
);
918 data
<< uint64(target
->GetGUID());
919 target
->GetSession()->SendPacket(&data
);
920 target
->RemoveSpellCooldown(spell_id
);
921 PSendSysMessage(LANG_REMOVE_COOLDOWN
, spell_id
, target
==m_session
->GetPlayer() ? GetMangosString(LANG_YOU
) : target
->GetName());
926 bool ChatHandler::HandleLearnAllCommand(const char* /*args*/)
928 static const char *allSpellList
[] =
1311 //"9036", problems with ghost state
1320 //"6718", phasing stealth, annoing for learn all case.
1533 while(strcmp(allSpellList
[loop
], "0"))
1535 uint32 spell
= atol((char*)allSpellList
[loop
++]);
1537 if (m_session
->GetPlayer()->HasSpell(spell
))
1540 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell
);
1541 if(!spellInfo
|| !SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer()))
1543 PSendSysMessage(LANG_COMMAND_SPELL_BROKEN
,spell
);
1547 m_session
->GetPlayer()->learnSpell(spell
);
1550 SendSysMessage(LANG_COMMAND_LEARN_MANY_SPELLS
);
1555 bool ChatHandler::HandleLearnAllGMCommand(const char* /*args*/)
1557 static const char *gmSpellList
[] =
1559 "24347", // Become A Fish, No Breath Bar
1560 "35132", // Visual Boom
1561 "38488", // Attack 4000-8000 AOE
1562 "38795", // Attack 2000 AOE + Slow Down 90%
1563 "15712", // Attack 200
1564 "1852", // GM Spell Silence
1567 "29878", // Kill My Self
1568 "26644", // More Kill
1570 "28550", //Invisible 24
1571 "23452", //Invisible + Target
1575 uint16 gmSpellIter
= 0;
1576 while( strcmp(gmSpellList
[gmSpellIter
], "0") )
1578 uint32 spell
= atol((char*)gmSpellList
[gmSpellIter
++]);
1580 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell
);
1581 if(!spellInfo
|| !SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer()))
1583 PSendSysMessage(LANG_COMMAND_SPELL_BROKEN
,spell
);
1587 m_session
->GetPlayer()->learnSpell(spell
);
1590 SendSysMessage(LANG_LEARNING_GM_SKILLS
);
1594 bool ChatHandler::HandleLearnAllMyClassCommand(const char* /*args*/)
1596 HandleLearnAllMySpellsCommand("");
1597 HandleLearnAllMyTalentsCommand("");
1601 bool ChatHandler::HandleLearnAllMySpellsCommand(const char* /*args*/)
1603 ChrClassesEntry
const* clsEntry
= sChrClassesStore
.LookupEntry(m_session
->GetPlayer()->getClass());
1606 uint32 family
= clsEntry
->spellfamily
;
1608 for (uint32 i
= 0; i
< sSpellStore
.GetNumRows(); i
++)
1610 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(i
);
1614 // skip wrong class/race skills
1615 if(!m_session
->GetPlayer()->IsSpellFitByClassAndRace(spellInfo
->Id
))
1618 // skip other spell families
1619 if( spellInfo
->SpellFamilyName
!= family
)
1622 //TODO: skip triggered spells
1624 // skip spells with first rank learned as talent (and all talents then also)
1625 uint32 first_rank
= spellmgr
.GetFirstSpellInChain(spellInfo
->Id
);
1626 if(GetTalentSpellCost(first_rank
) > 0 )
1629 // skip broken spells
1630 if(!SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer(),false))
1633 m_session
->GetPlayer()->learnSpell(i
);
1636 SendSysMessage(LANG_COMMAND_LEARN_CLASS_SPELLS
);
1640 static void learnAllHighRanks(Player
* player
, uint32 spellid
)
1642 SpellChainMapNext
const& nextMap
= spellmgr
.GetSpellChainNext();
1643 for(SpellChainMapNext::const_iterator itr
= nextMap
.lower_bound(spellid
); itr
!= nextMap
.upper_bound(spellid
); ++itr
)
1645 player
->learnSpell(itr
->second
);
1646 learnAllHighRanks(player
,itr
->second
);
1650 bool ChatHandler::HandleLearnAllMyTalentsCommand(const char* /*args*/)
1652 Player
* player
= m_session
->GetPlayer();
1653 uint32 classMask
= player
->getClassMask();
1655 for (uint32 i
= 0; i
< sTalentStore
.GetNumRows(); i
++)
1657 TalentEntry
const *talentInfo
= sTalentStore
.LookupEntry(i
);
1661 TalentTabEntry
const *talentTabInfo
= sTalentTabStore
.LookupEntry( talentInfo
->TalentTab
);
1665 if( (classMask
& talentTabInfo
->ClassMask
) == 0 )
1668 // search highest talent rank
1671 for(; rank
>= 0; --rank
)
1673 if(talentInfo
->RankID
[rank
]!=0)
1675 spellid
= talentInfo
->RankID
[rank
];
1680 if(!spellid
) // ??? none spells in telent
1683 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spellid
);
1684 if(!spellInfo
|| !SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer(),false))
1687 // learn highest rank of talent
1688 player
->learnSpell(spellid
);
1690 // and learn all non-talent spell ranks (recursive by tree)
1691 learnAllHighRanks(player
,spellid
);
1694 SendSysMessage(LANG_COMMAND_LEARN_CLASS_TALENTS
);
1698 bool ChatHandler::HandleLearnAllLangCommand(const char* /*args*/)
1700 // skipping UNIVERSAL language (0)
1701 for(int i
= 1; i
< LANGUAGES_COUNT
; ++i
)
1702 m_session
->GetPlayer()->learnSpell(lang_description
[i
].spell_id
);
1704 SendSysMessage(LANG_COMMAND_LEARN_ALL_LANG
);
1708 bool ChatHandler::HandleLearnAllDefaultCommand(const char* args
)
1710 char* pName
= strtok((char*)args
, "");
1711 Player
*player
= NULL
;
1714 std::string name
= pName
;
1716 if(!normalizePlayerName(name
))
1718 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
1719 SetSentErrorMessage(true);
1723 player
= objmgr
.GetPlayer(name
.c_str());
1726 player
= getSelectedPlayer();
1730 SendSysMessage(LANG_NO_CHAR_SELECTED
);
1731 SetSentErrorMessage(true);
1735 player
->learnDefaultSpells();
1736 player
->learnQuestRewardedSpells();
1738 PSendSysMessage(LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST
,player
->GetName());
1742 bool ChatHandler::HandleLearnCommand(const char* args
)
1744 Player
* targetPlayer
= getSelectedPlayer();
1748 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
1749 SetSentErrorMessage(true);
1753 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
1754 uint32 spell
= extractSpellIdFromLink((char*)args
);
1755 if(!spell
|| !sSpellStore
.LookupEntry(spell
))
1758 if (targetPlayer
->HasSpell(spell
))
1760 if(targetPlayer
== m_session
->GetPlayer())
1761 SendSysMessage(LANG_YOU_KNOWN_SPELL
);
1763 PSendSysMessage(LANG_TARGET_KNOWN_SPELL
,targetPlayer
->GetName());
1764 SetSentErrorMessage(true);
1768 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell
);
1769 if(!spellInfo
|| !SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer()))
1771 PSendSysMessage(LANG_COMMAND_SPELL_BROKEN
,spell
);
1772 SetSentErrorMessage(true);
1776 targetPlayer
->learnSpell(spell
);
1781 bool ChatHandler::HandleAddItemCommand(const char* args
)
1788 if(args
[0]=='[') // [name] manual form
1790 char* citemName
= citemName
= strtok((char*)args
, "]");
1792 if(citemName
&& citemName
[0])
1794 std::string itemName
= citemName
+1;
1795 WorldDatabase
.escape_string(itemName
);
1796 QueryResult
*result
= WorldDatabase
.PQuery("SELECT entry FROM item_template WHERE name = '%s'", itemName
.c_str());
1799 PSendSysMessage(LANG_COMMAND_COULDNOTFIND
, citemName
+1);
1800 SetSentErrorMessage(true);
1803 itemId
= result
->Fetch()->GetUInt16();
1809 else // item_id or [name] Shift-click form |color|Hitem:item_id:0:0:0|h[name]|h|r
1811 char* cId
= extractKeyFromLink((char*)args
,"Hitem");
1817 char* ccount
= strtok(NULL
, " ");
1822 count
= strtol(ccount
, NULL
, 10);
1827 Player
* pl
= m_session
->GetPlayer();
1828 Player
* plTarget
= getSelectedPlayer();
1832 sLog
.outDetail(GetMangosString(LANG_ADDITEM
), itemId
, count
);
1834 ItemPrototype
const *pProto
= objmgr
.GetItemPrototype(itemId
);
1837 PSendSysMessage(LANG_COMMAND_ITEMIDINVALID
, itemId
);
1838 SetSentErrorMessage(true);
1845 plTarget
->DestroyItemCount(itemId
, -count
, true, false);
1846 PSendSysMessage(LANG_REMOVEITEM
, itemId
, -count
, plTarget
->GetName());
1851 uint32 noSpaceForCount
= 0;
1853 // check space and find places
1854 ItemPosCountVec dest
;
1855 uint8 msg
= plTarget
->CanStoreNewItem( NULL_BAG
, NULL_SLOT
, dest
, itemId
, count
, &noSpaceForCount
);
1856 if( msg
!= EQUIP_ERR_OK
) // convert to possible store amount
1857 count
-= noSpaceForCount
;
1859 if( count
== 0 || dest
.empty()) // can't add any
1861 PSendSysMessage(LANG_ITEM_CANNOT_CREATE
, itemId
, noSpaceForCount
);
1862 SetSentErrorMessage(true);
1866 Item
* item
= plTarget
->StoreNewItem( dest
, itemId
, true, Item::GenerateItemRandomPropertyId(itemId
));
1868 // remove binding (let GM give it to another player later)
1870 for(ItemPosCountVec::const_iterator itr
= dest
.begin(); itr
!= dest
.end(); ++itr
)
1871 if(Item
* item1
= pl
->GetItemByPos(itr
->pos
))
1872 item1
->SetBinding( false );
1874 if(count
> 0 && item
)
1876 pl
->SendNewItem(item
,count
,false,true);
1878 plTarget
->SendNewItem(item
,count
,true,false);
1881 if(noSpaceForCount
> 0)
1882 PSendSysMessage(LANG_ITEM_CANNOT_CREATE
, itemId
, noSpaceForCount
);
1887 bool ChatHandler::HandleAddItemSetCommand(const char* args
)
1892 char* cId
= extractKeyFromLink((char*)args
,"Hitemset"); // number or [name] Shift-click form |color|Hitemset:itemset_id|h[name]|h|r
1896 uint32 itemsetId
= atol(cId
);
1898 // prevent generation all items with itemset field value '0'
1901 PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND
,itemsetId
);
1902 SetSentErrorMessage(true);
1906 Player
* pl
= m_session
->GetPlayer();
1907 Player
* plTarget
= getSelectedPlayer();
1911 sLog
.outDetail(GetMangosString(LANG_ADDITEMSET
), itemsetId
);
1913 QueryResult
*result
= WorldDatabase
.PQuery("SELECT entry FROM item_template WHERE itemset = %u",itemsetId
);
1917 PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND
,itemsetId
);
1919 SetSentErrorMessage(true);
1925 Field
*fields
= result
->Fetch();
1926 uint32 itemId
= fields
[0].GetUInt32();
1928 ItemPosCountVec dest
;
1929 uint8 msg
= plTarget
->CanStoreNewItem( NULL_BAG
, NULL_SLOT
, dest
, itemId
, 1 );
1930 if( msg
== EQUIP_ERR_OK
)
1932 Item
* item
= plTarget
->StoreNewItem( dest
, itemId
, true);
1934 // remove binding (let GM give it to another player later)
1936 item
->SetBinding( false );
1938 pl
->SendNewItem(item
,1,false,true);
1940 plTarget
->SendNewItem(item
,1,true,false);
1944 pl
->SendEquipError( msg
, NULL
, NULL
);
1945 PSendSysMessage(LANG_ITEM_CANNOT_CREATE
, itemId
, 1);
1948 }while( result
->NextRow() );
1955 bool ChatHandler::HandleListItemCommand(const char* args
)
1960 char* cId
= extractKeyFromLink((char*)args
,"Hitem");
1963 uint32 item_id
= atol(cId
);
1965 ItemPrototype
const* itemProto
= item_id
? itemProto
= objmgr
.GetItemPrototype(item_id
) : NULL
;
1969 PSendSysMessage(LANG_COMMAND_ITEMIDINVALID
, item_id
);
1970 SetSentErrorMessage(true);
1974 char* c_count
= strtok(NULL
, " ");
1975 int count
= c_count
? atol(c_count
) : 10;
1980 QueryResult
*result
;
1983 uint32 inv_count
= 0;
1984 result
=CharacterDatabase
.PQuery("SELECT COUNT(item_template) FROM character_inventory WHERE item_template='%u'",item_id
);
1987 inv_count
= (*result
)[0].GetUInt32();
1991 result
=CharacterDatabase
.PQuery(
1993 "SELECT ci.item, cibag.slot AS bag, ci.slot, ci.guid, characters.account,characters.name "
1994 "FROM character_inventory AS ci LEFT JOIN character_inventory AS cibag ON (cibag.item=ci.bag),characters "
1995 "WHERE ci.item_template='%u' AND ci.guid = characters.guid LIMIT %u ",
1996 item_id
,uint32(count
));
2002 Field
*fields
= result
->Fetch();
2003 uint32 item_guid
= fields
[0].GetUInt32();
2004 uint32 item_bag
= fields
[1].GetUInt32();
2005 uint32 item_slot
= fields
[2].GetUInt32();
2006 uint32 owner_guid
= fields
[3].GetUInt32();
2007 uint32 owner_acc
= fields
[4].GetUInt32();
2008 std::string owner_name
= fields
[5].GetCppString();
2010 char const* item_pos
= 0;
2011 if(Player::IsEquipmentPos(item_bag
,item_slot
))
2012 item_pos
= "[equipped]";
2013 else if(Player::IsInventoryPos(item_bag
,item_slot
))
2014 item_pos
= "[in inventory]";
2015 else if(Player::IsBankPos(item_bag
,item_slot
))
2016 item_pos
= "[in bank]";
2020 PSendSysMessage(LANG_ITEMLIST_SLOT
,
2021 item_guid
,owner_name
.c_str(),owner_guid
,owner_acc
,item_pos
);
2022 } while (result
->NextRow());
2024 int64 res_count
= result
->GetRowCount();
2028 if(count
> res_count
)
2035 uint32 mail_count
= 0;
2036 result
=CharacterDatabase
.PQuery("SELECT COUNT(item_template) FROM mail_items WHERE item_template='%u'", item_id
);
2039 mail_count
= (*result
)[0].GetUInt32();
2045 result
=CharacterDatabase
.PQuery(
2047 "SELECT mail_items.item_guid, mail.sender, mail.receiver, char_s.account, char_s.name, char_r.account, char_r.name "
2048 "FROM mail,mail_items,characters as char_s,characters as char_r "
2049 "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",
2050 item_id
,uint32(count
));
2059 Field
*fields
= result
->Fetch();
2060 uint32 item_guid
= fields
[0].GetUInt32();
2061 uint32 item_s
= fields
[1].GetUInt32();
2062 uint32 item_r
= fields
[2].GetUInt32();
2063 uint32 item_s_acc
= fields
[3].GetUInt32();
2064 std::string item_s_name
= fields
[4].GetCppString();
2065 uint32 item_r_acc
= fields
[5].GetUInt32();
2066 std::string item_r_name
= fields
[6].GetCppString();
2068 char const* item_pos
= "[in mail]";
2070 PSendSysMessage(LANG_ITEMLIST_MAIL
,
2071 item_guid
,item_s_name
.c_str(),item_s
,item_s_acc
,item_r_name
.c_str(),item_r
,item_r_acc
,item_pos
);
2072 } while (result
->NextRow());
2074 int64 res_count
= result
->GetRowCount();
2078 if(count
> res_count
)
2085 uint32 auc_count
= 0;
2086 result
=CharacterDatabase
.PQuery("SELECT COUNT(item_template) FROM auctionhouse WHERE item_template='%u'",item_id
);
2089 auc_count
= (*result
)[0].GetUInt32();
2095 result
=CharacterDatabase
.PQuery(
2097 "SELECT auctionhouse.itemguid, auctionhouse.itemowner, characters.account, characters.name "
2098 "FROM auctionhouse,characters WHERE auctionhouse.item_template='%u' AND characters.guid = auctionhouse.itemowner LIMIT %u",
2099 item_id
,uint32(count
));
2108 Field
*fields
= result
->Fetch();
2109 uint32 item_guid
= fields
[0].GetUInt32();
2110 uint32 owner
= fields
[1].GetUInt32();
2111 uint32 owner_acc
= fields
[2].GetUInt32();
2112 std::string owner_name
= fields
[3].GetCppString();
2114 char const* item_pos
= "[in auction]";
2116 PSendSysMessage(LANG_ITEMLIST_AUCTION
, item_guid
, owner_name
.c_str(), owner
, owner_acc
,item_pos
);
2117 } while (result
->NextRow());
2122 if(inv_count
+mail_count
+auc_count
== 0)
2124 SendSysMessage(LANG_COMMAND_NOITEMFOUND
);
2125 SetSentErrorMessage(true);
2129 PSendSysMessage(LANG_COMMAND_LISTITEMMESSAGE
,item_id
,inv_count
+mail_count
+auc_count
,inv_count
,mail_count
,auc_count
);
2134 bool ChatHandler::HandleListObjectCommand(const char* args
)
2139 // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r
2140 char* cId
= extractKeyFromLink((char*)args
,"Hgameobject_entry");
2144 uint32 go_id
= atol(cId
);
2146 GameObjectInfo
const * gInfo
= objmgr
.GetGameObjectInfo(go_id
);
2148 if(!go_id
|| !gInfo
)
2150 PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID
, go_id
);
2151 SetSentErrorMessage(true);
2155 char* c_count
= strtok(NULL
, " ");
2156 int count
= c_count
? atol(c_count
) : 10;
2161 Player
* pl
= m_session
->GetPlayer();
2162 QueryResult
*result
;
2164 uint32 obj_count
= 0;
2165 result
=WorldDatabase
.PQuery("SELECT COUNT(guid) FROM gameobject WHERE id='%u'",go_id
);
2168 obj_count
= (*result
)[0].GetUInt32();
2172 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",
2173 pl
->GetPositionX(), pl
->GetPositionY(), pl
->GetPositionZ(),go_id
,uint32(count
));
2179 Field
*fields
= result
->Fetch();
2180 uint32 guid
= fields
[0].GetUInt32();
2181 float x
= fields
[1].GetFloat();
2182 float y
= fields
[2].GetFloat();
2183 float z
= fields
[3].GetFloat();
2184 int mapid
= fields
[4].GetUInt16();
2186 PSendSysMessage(LANG_GO_LIST
, guid
, guid
, gInfo
->name
, x
, y
, z
, mapid
);
2187 } while (result
->NextRow());
2192 PSendSysMessage(LANG_COMMAND_LISTOBJMESSAGE
,go_id
,obj_count
);
2196 bool ChatHandler::HandleNearObjectCommand(const char* args
)
2198 float distance
= (!*args
) ? 10 : atol(args
);
2201 Player
* pl
= m_session
->GetPlayer();
2202 QueryResult
*result
= WorldDatabase
.PQuery("SELECT guid, id, position_x, position_y, position_z, map, "
2203 "(POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ "
2204 "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_",
2205 pl
->GetPositionX(), pl
->GetPositionY(), pl
->GetPositionZ(),
2206 pl
->GetMapId(),pl
->GetPositionX(), pl
->GetPositionY(), pl
->GetPositionZ(),distance
*distance
);
2212 Field
*fields
= result
->Fetch();
2213 uint32 guid
= fields
[0].GetUInt32();
2214 uint32 entry
= fields
[1].GetUInt32();
2215 float x
= fields
[2].GetFloat();
2216 float y
= fields
[3].GetFloat();
2217 float z
= fields
[4].GetFloat();
2218 int mapid
= fields
[5].GetUInt16();
2220 GameObjectInfo
const * gInfo
= objmgr
.GetGameObjectInfo(entry
);
2225 PSendSysMessage(LANG_GO_LIST
, guid
, guid
, gInfo
->name
, x
, y
, z
, mapid
);
2228 } while (result
->NextRow());
2233 PSendSysMessage(LANG_COMMAND_NEAROBJMESSAGE
,distance
,count
);
2237 bool ChatHandler::HandleListCreatureCommand(const char* args
)
2242 // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r
2243 char* cId
= extractKeyFromLink((char*)args
,"Hcreature_entry");
2247 uint32 cr_id
= atol(cId
);
2249 CreatureInfo
const* cInfo
= objmgr
.GetCreatureTemplate(cr_id
);
2251 if(!cr_id
|| !cInfo
)
2253 PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID
, cr_id
);
2254 SetSentErrorMessage(true);
2258 char* c_count
= strtok(NULL
, " ");
2259 int count
= c_count
? atol(c_count
) : 10;
2264 Player
* pl
= m_session
->GetPlayer();
2265 QueryResult
*result
;
2267 uint32 cr_count
= 0;
2268 result
=WorldDatabase
.PQuery("SELECT COUNT(guid) FROM creature WHERE id='%u'",cr_id
);
2271 cr_count
= (*result
)[0].GetUInt32();
2275 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",
2276 pl
->GetPositionX(), pl
->GetPositionY(), pl
->GetPositionZ(), cr_id
,uint32(count
));
2282 Field
*fields
= result
->Fetch();
2283 uint32 guid
= fields
[0].GetUInt32();
2284 float x
= fields
[1].GetFloat();
2285 float y
= fields
[2].GetFloat();
2286 float z
= fields
[3].GetFloat();
2287 int mapid
= fields
[4].GetUInt16();
2289 PSendSysMessage(LANG_CREATURE_LIST
, guid
, guid
, cInfo
->Name
, x
, y
, z
, mapid
);
2290 } while (result
->NextRow());
2295 PSendSysMessage(LANG_COMMAND_LISTCREATUREMESSAGE
,cr_id
,cr_count
);
2299 bool ChatHandler::HandleLookupItemCommand(const char* args
)
2304 std::string namepart
= args
;
2305 std::wstring wnamepart
;
2307 // converting string that we try to find to lower case
2308 if(!Utf8toWStr(namepart
,wnamepart
))
2311 wstrToLower(wnamepart
);
2315 // Search in `item_template`
2316 for (uint32 id
= 0; id
< sItemStorage
.MaxEntry
; id
++)
2318 ItemPrototype
const *pProto
= sItemStorage
.LookupEntry
<ItemPrototype
>(id
);
2322 int loc_idx
= m_session
->GetSessionDbLocaleIndex();
2325 ItemLocale
const *il
= objmgr
.GetItemLocale(pProto
->ItemId
);
2328 if (il
->Name
.size() > loc_idx
&& !il
->Name
[loc_idx
].empty())
2330 std::string name
= il
->Name
[loc_idx
];
2332 if (Utf8FitTo(name
, wnamepart
))
2334 PSendSysMessage(LANG_ITEM_LIST
, id
, id
, name
.c_str());
2342 std::string name
= pProto
->Name1
;
2346 if (Utf8FitTo(name
, wnamepart
))
2348 PSendSysMessage(LANG_ITEM_LIST
, id
, id
, name
.c_str());
2354 SendSysMessage(LANG_COMMAND_NOITEMFOUND
);
2359 bool ChatHandler::HandleLookupItemSetCommand(const char* args
)
2364 std::string namepart
= args
;
2365 std::wstring wnamepart
;
2367 if(!Utf8toWStr(namepart
,wnamepart
))
2370 // converting string that we try to find to lower case
2371 wstrToLower( wnamepart
);
2373 uint32 counter
= 0; // Counter for figure out that we found smth.
2375 // Search in ItemSet.dbc
2376 for (uint32 id
= 0; id
< sItemSetStore
.GetNumRows(); id
++)
2378 ItemSetEntry
const *set
= sItemSetStore
.LookupEntry(id
);
2381 int loc
= m_session
->GetSessionDbcLocale();
2382 std::string name
= set
->name
[m_session
->GetSessionDbcLocale()];
2386 if (!Utf8FitTo(name
, wnamepart
))
2389 for(; loc
< MAX_LOCALE
; ++loc
)
2391 if(loc
==m_session
->GetSessionDbcLocale())
2394 name
= set
->name
[m_session
->GetSessionDbcLocale()];
2398 if (Utf8FitTo(name
, wnamepart
))
2403 if(loc
< MAX_LOCALE
)
2405 // send item set in "id - [namedlink locale]" format
2406 PSendSysMessage(LANG_ITEMSET_LIST
,id
,id
,name
.c_str(),localeNames
[loc
]);
2411 if (counter
== 0) // if counter == 0 then we found nth
2412 SendSysMessage(LANG_COMMAND_NOITEMSETFOUND
);
2416 bool ChatHandler::HandleLookupSkillCommand(const char* args
)
2418 Player
* target
= getSelectedPlayer();
2421 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
2422 SetSentErrorMessage(true);
2429 std::string namepart
= args
;
2430 std::wstring wnamepart
;
2432 if(!Utf8toWStr(namepart
,wnamepart
))
2435 // converting string that we try to find to lower case
2436 wstrToLower( wnamepart
);
2438 uint32 counter
= 0; // Counter for figure out that we found smth.
2440 // Search in SkillLine.dbc
2441 for (uint32 id
= 0; id
< sSkillLineStore
.GetNumRows(); id
++)
2443 SkillLineEntry
const *skillInfo
= sSkillLineStore
.LookupEntry(id
);
2446 int loc
= m_session
->GetSessionDbcLocale();
2447 std::string name
= skillInfo
->name
[loc
];
2451 if (!Utf8FitTo(name
, wnamepart
))
2454 for(; loc
< MAX_LOCALE
; ++loc
)
2456 if(loc
==m_session
->GetSessionDbcLocale())
2459 name
= skillInfo
->name
[loc
];
2463 if (Utf8FitTo(name
, wnamepart
))
2468 if(loc
< MAX_LOCALE
)
2470 // send skill in "id - [namedlink locale]" format
2471 PSendSysMessage(LANG_SKILL_LIST
,id
,id
,name
.c_str(),localeNames
[loc
],(target
->HasSkill(id
) ? m_session
->GetMangosString(LANG_KNOWN
) : ""));
2477 if (counter
== 0) // if counter == 0 then we found nth
2478 SendSysMessage(LANG_COMMAND_NOSKILLFOUND
);
2482 bool ChatHandler::HandleLookupSpellCommand(const char* args
)
2484 Player
* target
= getSelectedPlayer();
2487 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
2488 SetSentErrorMessage(true);
2495 std::string namepart
= args
;
2496 std::wstring wnamepart
;
2498 if(!Utf8toWStr(namepart
,wnamepart
))
2501 // converting string that we try to find to lower case
2502 wstrToLower( wnamepart
);
2504 uint32 counter
= 0; // Counter for figure out that we found smth.
2506 // Search in Spell.dbc
2507 for (uint32 id
= 0; id
< sSpellStore
.GetNumRows(); id
++)
2509 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(id
);
2512 int loc
= m_session
->GetSessionDbcLocale();
2513 std::string name
= spellInfo
->SpellName
[loc
];
2517 if (!Utf8FitTo(name
, wnamepart
))
2520 for(; loc
< MAX_LOCALE
; ++loc
)
2522 if(loc
==m_session
->GetSessionDbcLocale())
2525 name
= spellInfo
->SpellName
[loc
];
2529 if (Utf8FitTo(name
, wnamepart
))
2534 if(loc
< MAX_LOCALE
)
2536 bool known
= target
->HasSpell(id
);
2537 bool learn
= (spellInfo
->Effect
[0] == SPELL_EFFECT_LEARN_SPELL
);
2539 uint32 telentCost
= GetTalentSpellCost(id
);
2541 bool talent
= (telentCost
> 0);
2542 bool passive
= IsPassiveSpell(id
);
2543 bool active
= target
->HasAura(id
,0) || target
->HasAura(id
,1) || target
->HasAura(id
,2);
2545 // unit32 used to prevent interpreting uint8 as char at output
2546 // find rank of learned spell for learning spell, or talent rank
2547 uint32 rank
= telentCost
? telentCost
: spellmgr
.GetSpellRank(learn
? spellInfo
->EffectTriggerSpell
[0] : id
);
2549 // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
2550 std::ostringstream ss
;
2551 ss
<< id
<< " - |cffffffff|Hspell:" << id
<< "|h[" << name
;
2553 // include rank in link name
2555 ss
<< GetMangosString(LANG_SPELL_RANK
) << rank
;
2557 ss
<< " " << localeNames
[loc
] << "]|h|r";
2560 ss
<< GetMangosString(LANG_TALENT
);
2562 ss
<< GetMangosString(LANG_PASSIVE
);
2564 ss
<< GetMangosString(LANG_LEARN
);
2566 ss
<< GetMangosString(LANG_KNOWN
);
2568 ss
<< GetMangosString(LANG_ACTIVE
);
2570 SendSysMessage(ss
.str().c_str());
2576 if (counter
== 0) // if counter == 0 then we found nth
2577 SendSysMessage(LANG_COMMAND_NOSPELLFOUND
);
2581 bool ChatHandler::HandleLookupQuestCommand(const char* args
)
2583 Player
* target
= getSelectedPlayer();
2586 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
2587 SetSentErrorMessage(true);
2594 std::string namepart
= args
;
2595 std::wstring wnamepart
;
2597 // converting string that we try to find to lower case
2598 if(!Utf8toWStr(namepart
,wnamepart
))
2601 wstrToLower(wnamepart
);
2603 uint32 counter
= 0 ;
2605 ObjectMgr::QuestMap
const& qTemplates
= objmgr
.GetQuestTemplates();
2606 for (ObjectMgr::QuestMap::const_iterator iter
= qTemplates
.begin(); iter
!= qTemplates
.end(); ++iter
)
2608 Quest
* qinfo
= iter
->second
;
2610 int loc_idx
= m_session
->GetSessionDbLocaleIndex();
2613 QuestLocale
const *il
= objmgr
.GetQuestLocale(qinfo
->GetQuestId());
2616 if (il
->Title
.size() > loc_idx
&& !il
->Title
[loc_idx
].empty())
2618 std::string title
= il
->Title
[loc_idx
];
2620 if (Utf8FitTo(title
, wnamepart
))
2622 QuestStatus status
= target
->GetQuestStatus(qinfo
->GetQuestId());
2624 char const* statusStr
= "";
2625 if(status
== QUEST_STATUS_COMPLETE
)
2627 if(target
->GetQuestRewardStatus(qinfo
->GetQuestId()))
2628 statusStr
= GetMangosString(LANG_COMMAND_QUEST_REWARDED
);
2630 statusStr
= GetMangosString(LANG_COMMAND_QUEST_COMPLETE
);
2632 else if(status
== QUEST_STATUS_INCOMPLETE
)
2633 statusStr
= GetMangosString(LANG_COMMAND_QUEST_ACTIVE
);
2635 PSendSysMessage(LANG_QUEST_LIST
,qinfo
->GetQuestId(),qinfo
->GetQuestId(),title
.c_str(),(status
== QUEST_STATUS_COMPLETE
? GetMangosString(LANG_COMPLETE
) : (status
== QUEST_STATUS_INCOMPLETE
? GetMangosString(LANG_ACTIVE
) : "") ));
2643 std::string title
= qinfo
->GetTitle();
2647 if (Utf8FitTo(title
, wnamepart
))
2649 QuestStatus status
= target
->GetQuestStatus(qinfo
->GetQuestId());
2651 char const* statusStr
= "";
2652 if(status
== QUEST_STATUS_COMPLETE
)
2654 if(target
->GetQuestRewardStatus(qinfo
->GetQuestId()))
2655 statusStr
= GetMangosString(LANG_COMMAND_QUEST_REWARDED
);
2657 statusStr
= GetMangosString(LANG_COMMAND_QUEST_COMPLETE
);
2659 else if(status
== QUEST_STATUS_INCOMPLETE
)
2660 statusStr
= GetMangosString(LANG_COMMAND_QUEST_ACTIVE
);
2662 PSendSysMessage(LANG_QUEST_LIST
,qinfo
->GetQuestId(),qinfo
->GetQuestId(), title
.c_str(),(status
== QUEST_STATUS_COMPLETE
? GetMangosString(LANG_COMPLETE
) : (status
== QUEST_STATUS_INCOMPLETE
? GetMangosString(LANG_ACTIVE
) : "") ));
2668 SendSysMessage(LANG_COMMAND_NOQUESTFOUND
);
2673 bool ChatHandler::HandleLookupCreatureCommand(const char* args
)
2678 std::string namepart
= args
;
2679 std::wstring wnamepart
;
2681 // converting string that we try to find to lower case
2682 if(!Utf8toWStr(namepart
,wnamepart
))
2685 wstrToLower(wnamepart
);
2689 for (uint32 id
= 0; id
< sCreatureStorage
.MaxEntry
; id
++ )
2691 CreatureInfo
const* cInfo
= sCreatureStorage
.LookupEntry
<CreatureInfo
>(id
);
2695 int loc_idx
= m_session
->GetSessionDbLocaleIndex();
2698 CreatureLocale
const *cl
= objmgr
.GetCreatureLocale(id
);
2701 if (cl
->Name
.size() > loc_idx
&& !cl
->Name
[loc_idx
].empty())
2703 std::string name
= cl
->Name
[loc_idx
];
2705 if (Utf8FitTo(name
, wnamepart
))
2707 PSendSysMessage(LANG_CREATURE_ENTRY_LIST
, id
, id
, name
.c_str());
2715 std::string name
= cInfo
->Name
;
2719 if (Utf8FitTo(name
, wnamepart
))
2721 PSendSysMessage(LANG_CREATURE_ENTRY_LIST
,id
,id
,name
.c_str());
2727 SendSysMessage(LANG_COMMAND_NOCREATUREFOUND
);
2732 bool ChatHandler::HandleLookupObjectCommand(const char* args
)
2737 std::string namepart
= args
;
2738 std::wstring wnamepart
;
2740 // converting string that we try to find to lower case
2741 if(!Utf8toWStr(namepart
,wnamepart
))
2744 wstrToLower(wnamepart
);
2748 for (uint32 id
= 0; id
< sGOStorage
.MaxEntry
; id
++ )
2750 GameObjectInfo
const* gInfo
= sGOStorage
.LookupEntry
<GameObjectInfo
>(id
);
2754 int loc_idx
= m_session
->GetSessionDbLocaleIndex();
2757 GameObjectLocale
const *gl
= objmgr
.GetGameObjectLocale(id
);
2760 if (gl
->Name
.size() > loc_idx
&& !gl
->Name
[loc_idx
].empty())
2762 std::string name
= gl
->Name
[loc_idx
];
2764 if (Utf8FitTo(name
, wnamepart
))
2766 PSendSysMessage(LANG_GO_ENTRY_LIST
, id
, id
, name
.c_str());
2774 std::string name
= gInfo
->name
;
2778 if(Utf8FitTo(name
, wnamepart
))
2780 PSendSysMessage(LANG_GO_ENTRY_LIST
, id
, id
, name
.c_str());
2786 SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND
);
2791 /** \brief GM command level 3 - Create a guild.
2793 * This command allows a GM (level 3) to create a guild.
2795 * The "args" parameter contains the name of the guild leader
2796 * and then the name of the guild.
2799 bool ChatHandler::HandleGuildCreateCommand(const char* args
)
2808 std::string guildname
;
2810 lname
= strtok((char*)args
, " ");
2811 gname
= strtok(NULL
, "");
2817 SendSysMessage(LANG_INSERT_GUILD_NAME
);
2818 SetSentErrorMessage(true);
2823 player
= ObjectAccessor::Instance().FindPlayerByName(lname
);
2827 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
2828 SetSentErrorMessage(true);
2832 if(!player
->GetGuildId())
2835 if(!guild
->create(player
->GetGUID(),guildname
))
2838 SendSysMessage(LANG_GUILD_NOT_CREATED
);
2839 SetSentErrorMessage(true);
2843 objmgr
.AddGuild(guild
);
2846 SendSysMessage(LANG_PLAYER_IN_GUILD
);
2851 bool ChatHandler::HandleGuildInviteCommand(const char *args
)
2856 char* par1
= strtok((char*)args
, " ");
2857 char* par2
= strtok (NULL
, "");
2861 std::string glName
= par2
;
2862 Guild
* targetGuild
= objmgr
.GetGuildByName(glName
);
2866 std::string plName
= par1
;
2867 if(!normalizePlayerName(plName
))
2869 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
2870 SetSentErrorMessage(true);
2875 if(Player
* targetPlayer
= ObjectAccessor::Instance().FindPlayerByName(plName
.c_str()))
2876 plGuid
= targetPlayer
->GetGUID();
2878 plGuid
= objmgr
.GetPlayerGUIDByName(plName
.c_str());
2883 // players's guild membership checked in AddMember before add
2884 if(!targetGuild
->AddMember(plGuid
,targetGuild
->GetLowestRank()))
2890 bool ChatHandler::HandleGuildUninviteCommand(const char *args
)
2895 char* par1
= strtok((char*)args
, " ");
2898 std::string plName
= par1
;
2899 if(!normalizePlayerName(plName
))
2901 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
2902 SetSentErrorMessage(true);
2908 if(Player
* targetPlayer
= ObjectAccessor::Instance().FindPlayerByName(plName
.c_str()))
2910 plGuid
= targetPlayer
->GetGUID();
2911 glId
= targetPlayer
->GetGuildId();
2915 plGuid
= objmgr
.GetPlayerGUIDByName(plName
.c_str());
2916 glId
= Player::GetGuildIdFromDB(plGuid
);
2919 if(!plGuid
|| !glId
)
2922 Guild
* targetGuild
= objmgr
.GetGuildById(glId
);
2926 targetGuild
->DelMember(plGuid
);
2931 bool ChatHandler::HandleGuildRankCommand(const char *args
)
2936 char* par1
= strtok((char*)args
, " ");
2937 char* par2
= strtok(NULL
, " ");
2940 std::string plName
= par1
;
2941 if(!normalizePlayerName(plName
))
2943 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
2944 SetSentErrorMessage(true);
2950 if(Player
* targetPlayer
= ObjectAccessor::Instance().FindPlayerByName(plName
.c_str()))
2952 plGuid
= targetPlayer
->GetGUID();
2953 glId
= targetPlayer
->GetGuildId();
2957 plGuid
= objmgr
.GetPlayerGUIDByName(plName
.c_str());
2958 glId
= Player::GetGuildIdFromDB(plGuid
);
2961 if(!plGuid
|| !glId
)
2964 Guild
* targetGuild
= objmgr
.GetGuildById(glId
);
2968 uint32 newrank
= uint32(atoi(par2
));
2969 if(newrank
> targetGuild
->GetLowestRank())
2972 targetGuild
->ChangeRank(plGuid
,newrank
);
2977 bool ChatHandler::HandleGuildDeleteCommand(const char* args
)
2982 char* par1
= strtok((char*)args
, " ");
2986 std::string gld
= par1
;
2988 Guild
* targetGuild
= objmgr
.GetGuildByName(gld
);
2992 targetGuild
->Disband();
2997 bool ChatHandler::HandleGetDistanceCommand(const char* /*args*/)
2999 Unit
* pUnit
= getSelectedUnit();
3003 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
3004 SetSentErrorMessage(true);
3008 PSendSysMessage(LANG_DISTANCE
, m_session
->GetPlayer()->GetDistance(pUnit
),m_session
->GetPlayer()->GetDistance2d(pUnit
));
3015 bool ChatHandler::HandleAddWeaponCommand(const char* /*args*/)
3020 uint64 guid = m_session->GetPlayer()->GetSelection();
3023 SendSysMessage(LANG_NO_SELECTION);
3027 Creature *pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid);
3031 SendSysMessage(LANG_SELECT_CREATURE);
3035 char* pSlotID = strtok((char*)args, " ");
3039 char* pItemID = strtok(NULL, " ");
3043 uint32 ItemID = atoi(pItemID);
3044 uint32 SlotID = atoi(pSlotID);
3046 ItemPrototype* tmpItem = objmgr.GetItemPrototype(ItemID);
3054 pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, ItemID);
3058 pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_01, ItemID);
3062 pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_02, ItemID);
3066 PSendSysMessage(LANG_ITEM_SLOT_NOT_EXIST,SlotID);
3072 PSendSysMessage(LANG_ITEM_ADDED_TO_SLOT,ItemID,tmpItem->Name1,SlotID);
3077 PSendSysMessage(LANG_ITEM_NOT_FOUND,ItemID);
3084 bool ChatHandler::HandleDieCommand(const char* /*args*/)
3086 Unit
* target
= getSelectedUnit();
3088 if(!target
|| !m_session
->GetPlayer()->GetSelection())
3090 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
3091 SetSentErrorMessage(true);
3095 if( target
->isAlive() )
3097 m_session
->GetPlayer()->DealDamage(target
, target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, NULL
, false);
3103 bool ChatHandler::HandleDamageCommand(const char * args
)
3108 Unit
* target
= getSelectedUnit();
3110 if(!target
|| !m_session
->GetPlayer()->GetSelection())
3112 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
3113 SetSentErrorMessage(true);
3117 if( !target
->isAlive() )
3120 char* damageStr
= strtok((char*)args
, " ");
3124 int32 damage
= atoi((char*)damageStr
);
3128 char* schoolStr
= strtok((char*)NULL
, " ");
3130 // flat melee damage without resistence/etc reduction
3133 m_session
->GetPlayer()->DealDamage(target
, damage
, NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, NULL
, false);
3134 m_session
->GetPlayer()->SendAttackStateUpdate (HITINFO_NORMALSWING2
, target
, 1, SPELL_SCHOOL_MASK_NORMAL
, damage
, 0, 0, VICTIMSTATE_NORMAL
, 0);
3138 uint32 school
= schoolStr
? atoi((char*)schoolStr
) : SPELL_SCHOOL_NORMAL
;
3139 if(school
>= MAX_SPELL_SCHOOL
)
3142 SpellSchoolMask schoolmask
= SpellSchoolMask(1 << school
);
3144 if ( schoolmask
& SPELL_SCHOOL_MASK_NORMAL
)
3145 damage
= m_session
->GetPlayer()->CalcArmorReducedDamage(target
, damage
);
3147 char* spellStr
= strtok((char*)NULL
, " ");
3149 // melee damage by specific school
3155 m_session
->GetPlayer()->CalcAbsorbResist(target
,schoolmask
, SPELL_DIRECT_DAMAGE
, damage
, &absorb
, &resist
);
3157 if (damage
<= absorb
+ resist
)
3160 damage
-= absorb
+ resist
;
3162 m_session
->GetPlayer()->DealDamage(target
, damage
, NULL
, DIRECT_DAMAGE
, schoolmask
, NULL
, false);
3163 m_session
->GetPlayer()->SendAttackStateUpdate (HITINFO_NORMALSWING2
, target
, 1, schoolmask
, damage
, absorb
, resist
, VICTIMSTATE_NORMAL
, 0);
3169 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
3170 uint32 spellid
= extractSpellIdFromLink((char*)args
);
3171 if(!spellid
|| !sSpellStore
.LookupEntry(spellid
))
3174 m_session
->GetPlayer()->SpellNonMeleeDamageLog(target
, spellid
, damage
, false);
3178 bool ChatHandler::HandleModifyArenaCommand(const char * args
)
3183 Player
*target
= getSelectedPlayer();
3186 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
3187 SetSentErrorMessage(true);
3191 int32 amount
= (uint32
)atoi(args
);
3193 target
->ModifyArenaPoints(amount
);
3195 PSendSysMessage(LANG_COMMAND_MODIFY_ARENA
, target
->GetName(), target
->GetArenaPoints());
3200 bool ChatHandler::HandleReviveCommand(const char* args
)
3202 Player
* SelectedPlayer
= NULL
;
3206 std::string name
= args
;
3207 if(!normalizePlayerName(name
))
3209 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
3210 SetSentErrorMessage(true);
3214 SelectedPlayer
= objmgr
.GetPlayer(name
.c_str());
3217 SelectedPlayer
= getSelectedPlayer();
3221 SendSysMessage(LANG_NO_CHAR_SELECTED
);
3222 SetSentErrorMessage(true);
3226 SelectedPlayer
->ResurrectPlayer(0.5f
);
3227 SelectedPlayer
->SpawnCorpseBones();
3228 SelectedPlayer
->SaveToDB();
3232 bool ChatHandler::HandleAuraCommand(const char* args
)
3234 char* px
= strtok((char*)args
, " ");
3238 Unit
*target
= getSelectedUnit();
3241 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
3242 SetSentErrorMessage(true);
3246 uint32 spellID
= (uint32
)atoi(px
);
3247 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry( spellID
);
3250 for(uint32 i
= 0;i
<3;i
++)
3252 uint8 eff
= spellInfo
->Effect
[i
];
3253 if (eff
>=TOTAL_SPELL_EFFECTS
)
3255 if( IsAreaAuraEffect(eff
) ||
3256 eff
== SPELL_EFFECT_APPLY_AURA
||
3257 eff
== SPELL_EFFECT_PERSISTENT_AREA_AURA
)
3259 Aura
*Aur
= CreateAura(spellInfo
, i
, NULL
, target
);
3260 target
->AddAura(Aur
);
3268 bool ChatHandler::HandleUnAuraCommand(const char* args
)
3270 char* px
= strtok((char*)args
, " ");
3274 Unit
*target
= getSelectedUnit();
3277 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
3278 SetSentErrorMessage(true);
3282 std::string argstr
= args
;
3283 if (argstr
== "all")
3285 target
->RemoveAllAuras();
3289 uint32 spellID
= (uint32
)atoi(px
);
3290 target
->RemoveAurasDueToSpell(spellID
);
3295 bool ChatHandler::HandleLinkGraveCommand(const char* args
)
3300 char* px
= strtok((char*)args
, " ");
3304 uint32 g_id
= (uint32
)atoi(px
);
3308 char* px2
= strtok(NULL
, " ");
3312 else if (strncmp(px2
,"horde",6)==0)
3314 else if (strncmp(px2
,"alliance",9)==0)
3319 WorldSafeLocsEntry
const* graveyard
= sWorldSafeLocsStore
.LookupEntry(g_id
);
3323 PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST
, g_id
);
3324 SetSentErrorMessage(true);
3328 Player
* player
= m_session
->GetPlayer();
3330 uint32 zoneId
= player
->GetZoneId();
3332 AreaTableEntry
const *areaEntry
= GetAreaEntryByAreaID(zoneId
);
3333 if(!areaEntry
|| areaEntry
->zone
!=0 )
3335 PSendSysMessage(LANG_COMMAND_GRAVEYARDWRONGZONE
, g_id
,zoneId
);
3336 SetSentErrorMessage(true);
3340 if(graveyard
->map_id
!= areaEntry
->mapid
&& g_team
!= 0)
3342 SendSysMessage(LANG_COMMAND_GRAVEYARDWRONGTEAM
);
3343 SetSentErrorMessage(true);
3347 if(objmgr
.AddGraveYardLink(g_id
,player
->GetZoneId(),g_team
))
3348 PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED
, g_id
,zoneId
);
3350 PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED
, g_id
,zoneId
);
3355 bool ChatHandler::HandleNearGraveCommand(const char* args
)
3359 size_t argslen
= strlen(args
);
3363 else if (strncmp((char*)args
,"horde",argslen
)==0)
3365 else if (strncmp((char*)args
,"alliance",argslen
)==0)
3370 Player
* player
= m_session
->GetPlayer();
3372 WorldSafeLocsEntry
const* graveyard
= objmgr
.GetClosestGraveYard(
3373 player
->GetPositionX(), player
->GetPositionY(), player
->GetPositionZ(),player
->GetMapId(),g_team
);
3377 uint32 g_id
= graveyard
->ID
;
3379 GraveYardData
const* data
= objmgr
.FindGraveYardData(g_id
,player
->GetZoneId());
3382 PSendSysMessage(LANG_COMMAND_GRAVEYARDERROR
,g_id
);
3383 SetSentErrorMessage(true);
3387 g_team
= data
->team
;
3389 std::string team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_NOTEAM
);
3392 team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_ANY
);
3393 else if(g_team
== HORDE
)
3394 team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_HORDE
);
3395 else if(g_team
== ALLIANCE
)
3396 team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_ALLIANCE
);
3398 PSendSysMessage(LANG_COMMAND_GRAVEYARDNEAREST
, g_id
,team_name
.c_str(),player
->GetZoneId());
3402 std::string team_name
;
3405 team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_ANY
);
3406 else if(g_team
== HORDE
)
3407 team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_HORDE
);
3408 else if(g_team
== ALLIANCE
)
3409 team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_ALLIANCE
);
3411 if(g_team
== ~uint32(0))
3412 PSendSysMessage(LANG_COMMAND_ZONENOGRAVEYARDS
, player
->GetZoneId());
3414 PSendSysMessage(LANG_COMMAND_ZONENOGRAFACTION
, player
->GetZoneId(),team_name
.c_str());
3420 bool ChatHandler::HandleSpawnTransportCommand(const char* /*args*/)
3426 bool ChatHandler::HandlePlayEmoteCommand(const char* args
)
3428 uint32 emote
= atoi((char*)args
);
3430 Creature
* target
= getSelectedCreature();
3433 SendSysMessage(LANG_SELECT_CREATURE
);
3434 SetSentErrorMessage(true);
3438 target
->SetUInt32Value(UNIT_NPC_EMOTESTATE
,emote
);
3443 bool ChatHandler::HandleNpcInfoCommand(const char* /*args*/)
3445 Creature
* target
= getSelectedCreature();
3449 SendSysMessage(LANG_SELECT_CREATURE
);
3450 SetSentErrorMessage(true);
3454 uint32 faction
= target
->getFaction();
3455 uint32 npcflags
= target
->GetUInt32Value(UNIT_NPC_FLAGS
);
3456 uint32 displayid
= target
->GetDisplayId();
3457 uint32 nativeid
= target
->GetNativeDisplayId();
3458 uint32 Entry
= target
->GetEntry();
3459 CreatureInfo
const* cInfo
= target
->GetCreatureInfo();
3461 int32 curRespawnDelay
= target
->GetRespawnTimeEx()-time(NULL
);
3462 if(curRespawnDelay
< 0)
3463 curRespawnDelay
= 0;
3464 std::string curRespawnDelayStr
= secsToTimeString(curRespawnDelay
,true);
3465 std::string defRespawnDelayStr
= secsToTimeString(target
->GetRespawnDelay(),true);
3467 PSendSysMessage(LANG_NPCINFO_CHAR
, target
->GetDBTableGUIDLow(), faction
, npcflags
, Entry
, displayid
, nativeid
);
3468 PSendSysMessage(LANG_NPCINFO_LEVEL
, target
->getLevel());
3469 PSendSysMessage(LANG_NPCINFO_HEALTH
,target
->GetCreateHealth(), target
->GetMaxHealth(), target
->GetHealth());
3470 PSendSysMessage(LANG_NPCINFO_FLAGS
, target
->GetUInt32Value(UNIT_FIELD_FLAGS
), target
->GetUInt32Value(UNIT_DYNAMIC_FLAGS
), target
->getFaction());
3471 PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES
, defRespawnDelayStr
.c_str(),curRespawnDelayStr
.c_str());
3472 PSendSysMessage(LANG_NPCINFO_LOOT
, cInfo
->lootid
,cInfo
->pickpocketLootId
,cInfo
->SkinLootId
);
3473 PSendSysMessage(LANG_NPCINFO_DUNGEON_ID
, target
->GetInstanceId());
3474 PSendSysMessage(LANG_NPCINFO_POSITION
,float(target
->GetPositionX()), float(target
->GetPositionY()), float(target
->GetPositionZ()));
3476 if ((npcflags
& UNIT_NPC_FLAG_VENDOR
) )
3478 SendSysMessage(LANG_NPCINFO_VENDOR
);
3480 if ((npcflags
& UNIT_NPC_FLAG_TRAINER
) )
3482 SendSysMessage(LANG_NPCINFO_TRAINER
);
3488 bool ChatHandler::HandleExploreCheatCommand(const char* args
)
3493 int flag
= atoi((char*)args
);
3495 Player
*chr
= getSelectedPlayer();
3498 SendSysMessage(LANG_NO_CHAR_SELECTED
);
3499 SetSentErrorMessage(true);
3505 PSendSysMessage(LANG_YOU_SET_EXPLORE_ALL
, chr
->GetName());
3506 if(chr
!=m_session
->GetPlayer())
3507 ChatHandler(chr
).PSendSysMessage(LANG_YOURS_EXPLORE_SET_ALL
,m_session
->GetPlayer()->GetName());
3511 PSendSysMessage(LANG_YOU_SET_EXPLORE_NOTHING
, chr
->GetName());
3512 if(chr
!=m_session
->GetPlayer())
3513 ChatHandler(chr
).PSendSysMessage(LANG_YOURS_EXPLORE_SET_NOTHING
,m_session
->GetPlayer()->GetName());
3516 for (uint8 i
=0; i
<128; i
++)
3520 m_session
->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1
+i
,0xFFFFFFFF);
3524 m_session
->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1
+i
,0);
3531 bool ChatHandler::HandleHoverCommand(const char* args
)
3533 char* px
= strtok((char*)args
, " ");
3540 m_session
->GetPlayer()->SetHover(flag
);
3543 SendSysMessage(LANG_HOVER_ENABLED
);
3545 SendSysMessage(LANG_HOVER_DISABLED
);
3550 bool ChatHandler::HandleLevelUpCommand(const char* args
)
3552 char* px
= strtok((char*)args
, " ");
3553 char* py
= strtok((char*)NULL
, " ");
3555 // command format parsing
3556 char* pname
= (char*)NULL
;
3559 if(px
&& py
) // .levelup name level
3561 addlevel
= atoi(py
);
3564 else if(px
&& !py
) // .levelup name OR .levelup level
3566 if(isalpha(px
[0])) // .levelup name
3568 else // .levelup level
3569 addlevel
= atoi(px
);
3571 // else .levelup - nothing do for prepering
3575 uint64 chr_guid
= 0;
3579 if(pname
) // player by name
3582 if(!normalizePlayerName(name
))
3584 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
3585 SetSentErrorMessage(true);
3589 chr
= objmgr
.GetPlayer(name
.c_str());
3590 if(!chr
) // not in game
3592 chr_guid
= objmgr
.GetPlayerGUIDByName(name
);
3595 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
3596 SetSentErrorMessage(true);
3601 else // player by selection
3603 chr
= getSelectedPlayer();
3607 SendSysMessage(LANG_NO_CHAR_SELECTED
);
3608 SetSentErrorMessage(true);
3612 name
= chr
->GetName();
3615 assert(chr
|| chr_guid
);
3617 int32 oldlevel
= chr
? chr
->getLevel() : Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL
,chr_guid
);
3618 int32 newlevel
= oldlevel
+ addlevel
;
3621 if(newlevel
> 255) // hardcoded maximum level
3626 chr
->GiveLevel(newlevel
);
3627 chr
->InitTalentForLevel();
3628 chr
->SetUInt32Value(PLAYER_XP
,0);
3630 if(oldlevel
== newlevel
)
3631 ChatHandler(chr
).SendSysMessage(LANG_YOURS_LEVEL_PROGRESS_RESET
);
3633 if(oldlevel
< newlevel
)
3634 ChatHandler(chr
).PSendSysMessage(LANG_YOURS_LEVEL_UP
,newlevel
-oldlevel
);
3636 if(oldlevel
> newlevel
)
3637 ChatHandler(chr
).PSendSysMessage(LANG_YOURS_LEVEL_DOWN
,newlevel
-oldlevel
);
3641 // update levle and XP at level, all other will be updated at loading
3643 Player::LoadValuesArrayFromDB(values
,chr_guid
);
3644 Player::SetUInt32ValueInArray(values
,UNIT_FIELD_LEVEL
,newlevel
);
3645 Player::SetUInt32ValueInArray(values
,PLAYER_XP
,0);
3646 Player::SaveValuesArrayInDB(values
,chr_guid
);
3649 if(m_session
->GetPlayer() != chr
) // including chr==NULL
3650 PSendSysMessage(LANG_YOU_CHANGE_LVL
,name
.c_str(),newlevel
);
3654 bool ChatHandler::HandleShowAreaCommand(const char* args
)
3659 int area
= atoi((char*)args
);
3661 Player
*chr
= getSelectedPlayer();
3664 SendSysMessage(LANG_NO_CHAR_SELECTED
);
3665 SetSentErrorMessage(true);
3669 int offset
= area
/ 32;
3670 uint32 val
= (uint32
)(1 << (area
% 32));
3674 SendSysMessage(LANG_BAD_VALUE
);
3675 SetSentErrorMessage(true);
3679 uint32 currFields
= chr
->GetUInt32Value(PLAYER_EXPLORED_ZONES_1
+ offset
);
3680 chr
->SetUInt32Value(PLAYER_EXPLORED_ZONES_1
+ offset
, (uint32
)(currFields
| val
));
3682 SendSysMessage(LANG_EXPLORE_AREA
);
3686 bool ChatHandler::HandleHideAreaCommand(const char* args
)
3691 int area
= atoi((char*)args
);
3693 Player
*chr
= getSelectedPlayer();
3696 SendSysMessage(LANG_NO_CHAR_SELECTED
);
3697 SetSentErrorMessage(true);
3701 int offset
= area
/ 32;
3702 uint32 val
= (uint32
)(1 << (area
% 32));
3706 SendSysMessage(LANG_BAD_VALUE
);
3707 SetSentErrorMessage(true);
3711 uint32 currFields
= chr
->GetUInt32Value(PLAYER_EXPLORED_ZONES_1
+ offset
);
3712 chr
->SetUInt32Value(PLAYER_EXPLORED_ZONES_1
+ offset
, (uint32
)(currFields
^ val
));
3714 SendSysMessage(LANG_UNEXPLORE_AREA
);
3718 bool ChatHandler::HandleUpdate(const char* args
)
3726 char* pUpdateIndex
= strtok((char*)args
, " ");
3728 Unit
* chr
= getSelectedUnit();
3731 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
3732 SetSentErrorMessage(true);
3740 updateIndex
= atoi(pUpdateIndex
);
3742 if(chr
->GetTypeId() == TYPEID_PLAYER
)
3744 if (updateIndex
>=PLAYER_END
) return true;
3748 if (updateIndex
>=UNIT_END
) return true;
3751 char* pvalue
= strtok(NULL
, " ");
3754 value
=chr
->GetUInt32Value(updateIndex
);
3756 PSendSysMessage(LANG_UPDATE
, chr
->GetGUIDLow(),updateIndex
,value
);
3762 PSendSysMessage(LANG_UPDATE_CHANGE
, chr
->GetGUIDLow(),updateIndex
,value
);
3764 chr
->SetUInt32Value(updateIndex
,value
);
3769 bool ChatHandler::HandleBankCommand(const char* /*args*/)
3771 m_session
->SendShowBank( m_session
->GetPlayer()->GetGUID() );
3776 bool ChatHandler::HandleChangeWeather(const char* args
)
3782 if (!sWorld
.getConfig(CONFIG_WEATHER
))
3784 SendSysMessage(LANG_WEATHER_DISABLED
);
3785 SetSentErrorMessage(true);
3789 //*Change the weather of a cell
3790 char* px
= strtok((char*)args
, " ");
3791 char* py
= strtok(NULL
, " ");
3796 uint32 type
= (uint32
)atoi(px
); //0 to 3, 0: fine, 1: rain, 2: snow, 3: sand
3797 float grade
= (float)atof(py
); //0 to 1, sending -1 is instand good weather
3799 Player
*player
= m_session
->GetPlayer();
3800 uint32 zoneid
= player
->GetZoneId();
3802 Weather
* wth
= sWorld
.FindWeather(zoneid
);
3805 wth
= sWorld
.AddWeather(zoneid
);
3808 SendSysMessage(LANG_NO_WEATHER
);
3809 SetSentErrorMessage(true);
3813 wth
->SetWeather(WeatherType(type
), grade
);
3818 bool ChatHandler::HandleSetValue(const char* args
)
3823 char* px
= strtok((char*)args
, " ");
3824 char* py
= strtok(NULL
, " ");
3825 char* pz
= strtok(NULL
, " ");
3830 Unit
* target
= getSelectedUnit();
3833 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
3834 SetSentErrorMessage(true);
3838 uint64 guid
= target
->GetGUID();
3840 uint32 Opcode
= (uint32
)atoi(px
);
3841 if(Opcode
>= target
->GetValuesCount())
3843 PSendSysMessage(LANG_TOO_BIG_INDEX
, Opcode
, GUID_LOPART(guid
), target
->GetValuesCount());
3848 bool isint32
= true;
3850 isint32
= (bool)atoi(pz
);
3853 iValue
= (uint32
)atoi(py
);
3854 sLog
.outDebug(GetMangosString(LANG_SET_UINT
), GUID_LOPART(guid
), Opcode
, iValue
);
3855 target
->SetUInt32Value( Opcode
, iValue
);
3856 PSendSysMessage(LANG_SET_UINT_FIELD
, GUID_LOPART(guid
), Opcode
,iValue
);
3860 fValue
= (float)atof(py
);
3861 sLog
.outDebug(GetMangosString(LANG_SET_FLOAT
), GUID_LOPART(guid
), Opcode
, fValue
);
3862 target
->SetFloatValue( Opcode
, fValue
);
3863 PSendSysMessage(LANG_SET_FLOAT_FIELD
, GUID_LOPART(guid
), Opcode
,fValue
);
3869 bool ChatHandler::HandleGetValue(const char* args
)
3874 char* px
= strtok((char*)args
, " ");
3875 char* pz
= strtok(NULL
, " ");
3880 Unit
* target
= getSelectedUnit();
3883 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
3884 SetSentErrorMessage(true);
3888 uint64 guid
= target
->GetGUID();
3890 uint32 Opcode
= (uint32
)atoi(px
);
3891 if(Opcode
>= target
->GetValuesCount())
3893 PSendSysMessage(LANG_TOO_BIG_INDEX
, Opcode
, GUID_LOPART(guid
), target
->GetValuesCount());
3898 bool isint32
= true;
3900 isint32
= (bool)atoi(pz
);
3904 iValue
= target
->GetUInt32Value( Opcode
);
3905 sLog
.outDebug(GetMangosString(LANG_GET_UINT
), GUID_LOPART(guid
), Opcode
, iValue
);
3906 PSendSysMessage(LANG_GET_UINT_FIELD
, GUID_LOPART(guid
), Opcode
, iValue
);
3910 fValue
= target
->GetFloatValue( Opcode
);
3911 sLog
.outDebug(GetMangosString(LANG_GET_FLOAT
), GUID_LOPART(guid
), Opcode
, fValue
);
3912 PSendSysMessage(LANG_GET_FLOAT_FIELD
, GUID_LOPART(guid
), Opcode
, fValue
);
3918 bool ChatHandler::HandleSet32Bit(const char* args
)
3923 char* px
= strtok((char*)args
, " ");
3924 char* py
= strtok(NULL
, " ");
3929 uint32 Opcode
= (uint32
)atoi(px
);
3930 uint32 Value
= (uint32
)atoi(py
);
3931 if (Value
> 32) //uint32 = 32 bits
3934 sLog
.outDebug(GetMangosString(LANG_SET_32BIT
), Opcode
, Value
);
3936 m_session
->GetPlayer( )->SetUInt32Value( Opcode
, 2^Value
);
3938 PSendSysMessage(LANG_SET_32BIT_FIELD
, Opcode
,1);
3942 bool ChatHandler::HandleMod32Value(const char* args
)
3947 char* px
= strtok((char*)args
, " ");
3948 char* py
= strtok(NULL
, " ");
3953 uint32 Opcode
= (uint32
)atoi(px
);
3954 int Value
= atoi(py
);
3956 if(Opcode
>= m_session
->GetPlayer()->GetValuesCount())
3958 PSendSysMessage(LANG_TOO_BIG_INDEX
, Opcode
, m_session
->GetPlayer()->GetGUIDLow(), m_session
->GetPlayer( )->GetValuesCount());
3962 sLog
.outDebug(GetMangosString(LANG_CHANGE_32BIT
), Opcode
, Value
);
3964 int CurrentValue
= (int)m_session
->GetPlayer( )->GetUInt32Value( Opcode
);
3966 CurrentValue
+= Value
;
3967 m_session
->GetPlayer( )->SetUInt32Value( Opcode
, (uint32
)CurrentValue
);
3969 PSendSysMessage(LANG_CHANGE_32BIT_FIELD
, Opcode
,CurrentValue
);
3974 bool ChatHandler::HandleAddTeleCommand(const char * args
)
3979 Player
*player
=m_session
->GetPlayer();
3983 std::string name
= args
;
3985 if(objmgr
.GetGameTele(name
))
3987 SendSysMessage(LANG_COMMAND_TP_ALREADYEXIST
);
3988 SetSentErrorMessage(true);
3993 tele
.position_x
= player
->GetPositionX();
3994 tele
.position_y
= player
->GetPositionY();
3995 tele
.position_z
= player
->GetPositionZ();
3996 tele
.orientation
= player
->GetOrientation();
3997 tele
.mapId
= player
->GetMapId();
4000 if(objmgr
.AddGameTele(tele
))
4002 SendSysMessage(LANG_COMMAND_TP_ADDED
);
4006 SendSysMessage(LANG_COMMAND_TP_ADDEDERR
);
4007 SetSentErrorMessage(true);
4014 bool ChatHandler::HandleDelTeleCommand(const char * args
)
4019 std::string name
= args
;
4021 if(!objmgr
.DeleteGameTele(name
))
4023 SendSysMessage(LANG_COMMAND_TELE_NOTFOUND
);
4024 SetSentErrorMessage(true);
4028 SendSysMessage(LANG_COMMAND_TP_DELETED
);
4032 bool ChatHandler::HandleListAurasCommand (const char * /*args*/)
4034 Unit
*unit
= getSelectedUnit();
4037 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
4038 SetSentErrorMessage(true);
4042 char const* talentStr
= GetMangosString(LANG_TALENT
);
4043 char const* passiveStr
= GetMangosString(LANG_PASSIVE
);
4045 Unit::AuraMap
const& uAuras
= unit
->GetAuras();
4046 PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS
, uAuras
.size());
4047 for (Unit::AuraMap::const_iterator itr
= uAuras
.begin(); itr
!= uAuras
.end(); ++itr
)
4049 bool talent
= GetTalentSpellCost(itr
->second
->GetId()) > 0;
4050 PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL
, itr
->second
->GetId(), itr
->second
->GetEffIndex(),
4051 itr
->second
->GetModifier()->m_auraname
, itr
->second
->GetAuraDuration(), itr
->second
->GetAuraMaxDuration(),
4052 itr
->second
->GetSpellProto()->SpellName
[m_session
->GetSessionDbcLocale()],
4053 (itr
->second
->IsPassive() ? passiveStr
: ""),(talent
? talentStr
: ""),
4054 IS_PLAYER_GUID(itr
->second
->GetCasterGUID()) ? "player" : "creature",GUID_LOPART(itr
->second
->GetCasterGUID()));
4056 for (int i
= 0; i
< TOTAL_AURAS
; i
++)
4058 Unit::AuraList
const& uAuraList
= unit
->GetAurasByType(AuraType(i
));
4059 if (uAuraList
.empty()) continue;
4060 PSendSysMessage(LANG_COMMAND_TARGET_LISTAURATYPE
, uAuraList
.size(), i
);
4061 for (Unit::AuraList::const_iterator itr
= uAuraList
.begin(); itr
!= uAuraList
.end(); ++itr
)
4063 bool talent
= GetTalentSpellCost((*itr
)->GetId()) > 0;
4064 PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE
, (*itr
)->GetId(), (*itr
)->GetEffIndex(),
4065 (*itr
)->GetSpellProto()->SpellName
[m_session
->GetSessionDbcLocale()],((*itr
)->IsPassive() ? passiveStr
: ""),(talent
? talentStr
: ""),
4066 IS_PLAYER_GUID((*itr
)->GetCasterGUID()) ? "player" : "creature",GUID_LOPART((*itr
)->GetCasterGUID()));
4072 bool ChatHandler::HandleResetHonorCommand (const char * args
)
4074 char* pName
= strtok((char*)args
, "");
4075 Player
*player
= NULL
;
4078 std::string name
= pName
;
4079 if(!normalizePlayerName(name
))
4081 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
4082 SetSentErrorMessage(true);
4086 uint64 guid
= objmgr
.GetPlayerGUIDByName(name
.c_str());
4087 player
= objmgr
.GetPlayer(guid
);
4090 player
= getSelectedPlayer();
4094 SendSysMessage(LANG_NO_CHAR_SELECTED
);
4098 player
->SetUInt32Value(PLAYER_FIELD_KILLS
, 0);
4099 player
->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORBALE_KILLS
, 0);
4100 player
->SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY
, 0);
4101 player
->SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION
, 0);
4102 player
->SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION
, 0);
4107 static bool HandleResetStatsOrLevelHelper(Player
* player
)
4109 PlayerInfo
const *info
= objmgr
.GetPlayerInfo(player
->getRace(), player
->getClass());
4110 if(!info
) return false;
4112 ChrClassesEntry
const* cEntry
= sChrClassesStore
.LookupEntry(player
->getClass());
4115 sLog
.outError("Class %u not found in DBC (Wrong DBC files?)",player
->getClass());
4119 uint8 powertype
= cEntry
->powerType
;
4122 if(powertype
== POWER_RAGE
)
4123 unitfield
= 0x1100EE00;
4124 else if(powertype
== POWER_ENERGY
)
4125 unitfield
= 0x00000000;
4126 else if(powertype
== POWER_MANA
)
4127 unitfield
= 0x0000EE00;
4130 sLog
.outError("Invalid default powertype %u for player (class %u)",powertype
,player
->getClass());
4134 // reset m_form if no aura
4135 if(!player
->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT
))
4136 player
->m_form
= FORM_NONE
;
4138 player
->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS
, DEFAULT_WORLD_OBJECT_SIZE
);
4139 player
->SetFloatValue(UNIT_FIELD_COMBATREACH
, 1.5f
);
4141 player
->setFactionForRace(player
->getRace());
4143 player
->SetUInt32Value(UNIT_FIELD_BYTES_0
, ( ( player
->getRace() ) | ( player
->getClass() << 8 ) | ( player
->getGender() << 16 ) | ( powertype
<< 24 ) ) );
4145 // reset only if player not in some form;
4146 if(player
->m_form
==FORM_NONE
)
4148 switch(player
->getGender())
4151 player
->SetDisplayId(info
->displayId_f
);
4152 player
->SetNativeDisplayId(info
->displayId_f
);
4155 player
->SetDisplayId(info
->displayId_m
);
4156 player
->SetNativeDisplayId(info
->displayId_m
);
4163 // set UNIT_FIELD_BYTES_1 to init state but preserve m_form value
4164 player
->SetUInt32Value(UNIT_FIELD_BYTES_1
, unitfield
);
4165 player
->SetByteValue(UNIT_FIELD_BYTES_2
, 1, UNIT_BYTE2_FLAG_UNK3
| UNIT_BYTE2_FLAG_UNK5
);
4166 player
->SetByteValue(UNIT_FIELD_BYTES_2
, 3, player
->m_form
);
4168 player
->SetUInt32Value(UNIT_FIELD_FLAGS
, UNIT_FLAG_PVP_ATTACKABLE
);
4170 //-1 is default value
4171 player
->SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX
, uint32(-1));
4173 //player->SetUInt32Value(PLAYER_FIELD_BYTES, 0xEEE00000 );
4177 bool ChatHandler::HandleResetLevelCommand(const char * args
)
4179 char* pName
= strtok((char*)args
, "");
4180 Player
*player
= NULL
;
4183 std::string name
= pName
;
4184 if(!normalizePlayerName(name
))
4186 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
4187 SetSentErrorMessage(true);
4191 uint64 guid
= objmgr
.GetPlayerGUIDByName(name
.c_str());
4192 player
= objmgr
.GetPlayer(guid
);
4195 player
= getSelectedPlayer();
4199 SendSysMessage(LANG_NO_CHAR_SELECTED
);
4200 SetSentErrorMessage(true);
4204 if(!HandleResetStatsOrLevelHelper(player
))
4207 player
->SetLevel(1);
4208 player
->InitStatsForLevel(true);
4209 player
->InitTaxiNodesForLevel();
4210 player
->InitTalentForLevel();
4211 player
->SetUInt32Value(PLAYER_XP
,0);
4213 // reset level to summoned pet
4214 Pet
* pet
= player
->GetPet();
4215 if(pet
&& pet
->getPetType()==SUMMON_PET
)
4216 pet
->InitStatsForLevel(1);
4221 bool ChatHandler::HandleResetStatsCommand(const char * args
)
4223 char* pName
= strtok((char*)args
, "");
4224 Player
*player
= NULL
;
4227 std::string name
= pName
;
4228 if(!normalizePlayerName(name
))
4230 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
4231 SetSentErrorMessage(true);
4235 uint64 guid
= objmgr
.GetPlayerGUIDByName(name
.c_str());
4236 player
= objmgr
.GetPlayer(guid
);
4239 player
= getSelectedPlayer();
4243 SendSysMessage(LANG_NO_CHAR_SELECTED
);
4244 SetSentErrorMessage(true);
4248 if(!HandleResetStatsOrLevelHelper(player
))
4251 player
->InitStatsForLevel(true);
4252 player
->InitTaxiNodesForLevel();
4253 player
->InitTalentForLevel();
4258 bool ChatHandler::HandleResetSpellsCommand(const char * args
)
4260 char* pName
= strtok((char*)args
, "");
4261 Player
*player
= NULL
;
4262 uint64 playerGUID
= 0;
4265 std::string name
= pName
;
4267 if(!normalizePlayerName(name
))
4269 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
4270 SetSentErrorMessage(true);
4274 player
= objmgr
.GetPlayer(name
.c_str());
4276 playerGUID
= objmgr
.GetPlayerGUIDByName(name
.c_str());
4279 player
= getSelectedPlayer();
4281 if(!player
&& !playerGUID
)
4283 SendSysMessage(LANG_NO_CHAR_SELECTED
);
4284 SetSentErrorMessage(true);
4290 player
->resetSpells();
4292 ChatHandler(player
).SendSysMessage(LANG_RESET_SPELLS
);
4294 if(m_session
->GetPlayer()!=player
)
4295 PSendSysMessage(LANG_RESET_SPELLS_ONLINE
,player
->GetName());
4299 CharacterDatabase
.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'",uint32(AT_LOGIN_RESET_SPELLS
), GUID_LOPART(playerGUID
));
4300 PSendSysMessage(LANG_RESET_SPELLS_OFFLINE
,pName
);
4306 bool ChatHandler::HandleResetTalentsCommand(const char * args
)
4308 char* pName
= strtok((char*)args
, "");
4309 Player
*player
= NULL
;
4310 uint64 playerGUID
= 0;
4313 std::string name
= pName
;
4314 if(!normalizePlayerName(name
))
4316 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
4317 SetSentErrorMessage(true);
4321 player
= objmgr
.GetPlayer(name
.c_str());
4323 playerGUID
= objmgr
.GetPlayerGUIDByName(name
.c_str());
4326 player
= getSelectedPlayer();
4328 if(!player
&& !playerGUID
)
4330 SendSysMessage(LANG_NO_CHAR_SELECTED
);
4331 SetSentErrorMessage(true);
4337 player
->resetTalents(true);
4339 ChatHandler(player
).SendSysMessage(LANG_RESET_TALENTS
);
4341 if(m_session
->GetPlayer()!=player
)
4342 PSendSysMessage(LANG_RESET_TALENTS_ONLINE
,player
->GetName());
4346 CharacterDatabase
.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'",uint32(AT_LOGIN_RESET_TALENTS
), GUID_LOPART(playerGUID
) );
4347 PSendSysMessage(LANG_RESET_TALENTS_OFFLINE
,pName
);
4353 bool ChatHandler::HandleResetAllCommand(const char * args
)
4358 std::string casename
= args
;
4360 AtLoginFlags atLogin
;
4362 // Command specially created as single command to prevent using short case names
4363 if(casename
=="spells")
4365 atLogin
= AT_LOGIN_RESET_SPELLS
;
4366 sWorld
.SendWorldText(LANG_RESETALL_SPELLS
);
4368 else if(casename
=="talents")
4370 atLogin
= AT_LOGIN_RESET_TALENTS
;
4371 sWorld
.SendWorldText(LANG_RESETALL_TALENTS
);
4375 PSendSysMessage(LANG_RESETALL_UNKNOWN_CASE
,args
);
4376 SetSentErrorMessage(true);
4380 CharacterDatabase
.PExecute("UPDATE characters SET at_login = at_login | '%u'",atLogin
);
4381 HashMapHolder
<Player
>::MapType
const& plist
= ObjectAccessor::Instance().GetPlayers();
4382 for(HashMapHolder
<Player
>::MapType::const_iterator itr
= plist
.begin(); itr
!= plist
.end(); ++itr
)
4383 itr
->second
->SetAtLoginFlag(atLogin
);
4388 bool ChatHandler::HandleShutDownCommand(const char* args
)
4393 if(std::string(args
)=="cancel")
4395 sWorld
.ShutdownCancel();
4399 int32 time
= atoi(args
);
4401 ///- Prevent interpret wrong arg value as 0 secs shutdown time
4402 if(time
== 0 && (args
[0]!='0' || args
[1]!='\0') || time
< 0)
4405 sWorld
.ShutdownServ(time
);
4410 bool ChatHandler::HandleRestartCommand(const char* args
)
4415 if(std::string(args
)=="cancel")
4417 sWorld
.ShutdownCancel();
4421 int32 time
= atoi(args
);
4423 ///- Prevent interpret wrong arg value as 0 secs shutdown time
4424 if(time
== 0 && (args
[0]!='0' || args
[1]!='\0') || time
< 0)
4427 sWorld
.ShutdownServ(time
, SHUTDOWN_MASK_RESTART
);
4432 bool ChatHandler::HandleIdleRestartCommand(const char* args
)
4437 if(std::string(args
)=="cancel")
4439 sWorld
.ShutdownCancel();
4443 int32 time
= atoi(args
);
4445 ///- Prevent interpret wrong arg value as 0 secs shutdown time
4446 if(time
== 0 && (args
[0]!='0' || args
[1]!='\0') || time
< 0)
4449 sWorld
.ShutdownServ(time
,SHUTDOWN_MASK_RESTART
+SHUTDOWN_MASK_IDLE
);
4454 bool ChatHandler::HandleIdleShutDownCommand(const char* args
)
4459 if(std::string(args
)=="cancel")
4461 sWorld
.ShutdownCancel();
4465 int32 time
= atoi(args
);
4467 ///- Prevent interpret wrong arg value as 0 secs shutdown time
4468 if(time
== 0 && (args
[0]!='0' || args
[1]!='\0') || time
< 0)
4471 sWorld
.ShutdownServ(time
,SHUTDOWN_MASK_IDLE
);
4476 bool ChatHandler::HandleAddQuest(const char* args
)
4478 Player
* player
= getSelectedPlayer();
4481 SendSysMessage(LANG_NO_CHAR_SELECTED
);
4482 SetSentErrorMessage(true);
4486 // .addquest #entry'
4487 // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r
4488 char* cId
= extractKeyFromLink((char*)args
,"Hquest");
4492 uint32 entry
= atol(cId
);
4494 Quest
const* pQuest
= objmgr
.GetQuestTemplate(entry
);
4498 PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND
,entry
);
4499 SetSentErrorMessage(true);
4503 // check item starting quest (it can work incorrectly if added without item in inventory)
4504 QueryResult
*result
= WorldDatabase
.PQuery("SELECT entry FROM item_template WHERE startquest = '%u' LIMIT 1",entry
);
4507 Field
* fields
= result
->Fetch();
4508 uint32 item_id
= fields
[0].GetUInt32();
4511 PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM
, entry
,item_id
);
4512 SetSentErrorMessage(true);
4516 // ok, normal (creature/GO starting) quest
4517 if( player
->CanAddQuest( pQuest
, true ) )
4519 player
->AddQuest( pQuest
, NULL
);
4521 if ( player
->CanCompleteQuest( entry
) )
4522 player
->CompleteQuest( entry
);
4528 bool ChatHandler::HandleRemoveQuest(const char* args
)
4530 Player
* player
= getSelectedPlayer();
4533 SendSysMessage(LANG_NO_CHAR_SELECTED
);
4534 SetSentErrorMessage(true);
4538 // .removequest #entry'
4539 // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r
4540 char* cId
= extractKeyFromLink((char*)args
,"Hquest");
4544 uint32 entry
= atol(cId
);
4546 Quest
const* pQuest
= objmgr
.GetQuestTemplate(entry
);
4550 PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND
, entry
);
4551 SetSentErrorMessage(true);
4555 // remove all quest entries for 'entry' from quest log
4556 for(uint8 slot
= 0; slot
< MAX_QUEST_LOG_SIZE
; ++slot
)
4558 uint32 quest
= player
->GetQuestSlotQuestId(slot
);
4561 player
->SetQuestSlot(slot
,0);
4563 // we ignore unequippable quest items in this case, its' still be equipped
4564 player
->TakeQuestSourceItem( quest
, false );
4568 // set quest status to not started (will updated in DB at next save)
4569 player
->SetQuestStatus( entry
, QUEST_STATUS_NONE
);
4571 // reset rewarded for restart repeatable quest
4572 player
->getQuestStatusMap()[entry
].m_rewarded
= false;
4574 SendSysMessage(LANG_COMMAND_QUEST_REMOVED
);
4578 bool ChatHandler::HandleCompleteQuest(const char* args
)
4580 Player
* player
= getSelectedPlayer();
4583 SendSysMessage(LANG_NO_CHAR_SELECTED
);
4584 SetSentErrorMessage(true);
4588 // .quest complete #entry
4589 // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r
4590 char* cId
= extractKeyFromLink((char*)args
,"Hquest");
4594 uint32 entry
= atol(cId
);
4596 Quest
const* pQuest
= objmgr
.GetQuestTemplate(entry
);
4598 // If player doesn't have the quest
4599 if(!pQuest
|| player
->GetQuestStatus(entry
) == QUEST_STATUS_NONE
)
4601 PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND
, entry
);
4602 SetSentErrorMessage(true);
4606 // Add quest items for quests that require items
4607 for(uint8 x
= 0; x
< QUEST_OBJECTIVES_COUNT
; ++x
)
4609 uint32 id
= pQuest
->ReqItemId
[x
];
4610 uint32 count
= pQuest
->ReqItemCount
[x
];
4614 uint32 curItemCount
= player
->GetItemCount(id
,true);
4616 ItemPosCountVec dest
;
4617 uint8 msg
= player
->CanStoreNewItem( NULL_BAG
, NULL_SLOT
, dest
, id
, count
-curItemCount
);
4618 if( msg
== EQUIP_ERR_OK
)
4620 Item
* item
= player
->StoreNewItem( dest
, id
, true);
4621 player
->SendNewItem(item
,count
-curItemCount
,true,false);
4625 // All creature/GO slain/casted (not required, but otherwise it will display "Creature slain 0/10")
4626 for(uint8 i
= 0; i
< QUEST_OBJECTIVES_COUNT
; i
++)
4628 uint32 creature
= pQuest
->ReqCreatureOrGOId
[i
];
4629 uint32 creaturecount
= pQuest
->ReqCreatureOrGOCount
[i
];
4631 if(uint32 spell_id
= pQuest
->ReqSpell
[i
])
4633 for(uint16 z
= 0; z
< creaturecount
; ++z
)
4634 player
->CastedCreatureOrGO(creature
,0,spell_id
);
4636 else if(creature
> 0)
4638 for(uint16 z
= 0; z
< creaturecount
; ++z
)
4639 player
->KilledMonster(creature
,0);
4641 else if(creature
< 0)
4643 for(uint16 z
= 0; z
< creaturecount
; ++z
)
4644 player
->CastedCreatureOrGO(creature
,0,0);
4648 // If the quest requires reputation to complete
4649 if(uint32 repFaction
= pQuest
->GetRepObjectiveFaction())
4651 uint32 repValue
= pQuest
->GetRepObjectiveValue();
4652 uint32 curRep
= player
->GetReputation(repFaction
);
4653 if(curRep
< repValue
)
4655 FactionEntry
const *factionEntry
= sFactionStore
.LookupEntry(repFaction
);
4656 player
->SetFactionReputation(factionEntry
,repValue
);
4660 // If the quest requires money
4661 int32 ReqOrRewMoney
= pQuest
->GetRewOrReqMoney();
4662 if(ReqOrRewMoney
< 0)
4663 player
->ModifyMoney(-ReqOrRewMoney
);
4665 player
->CompleteQuest(entry
);
4669 bool ChatHandler::HandleBanCommand(const char* args
)
4674 char* type
= strtok((char*)args
, " ");
4678 char* nameOrIP
= strtok(NULL
, " ");
4683 char* duration
= strtok(NULL
," ");
4684 if(!duration
|| !atoi(duration
))
4687 char* reason
= strtok(NULL
,"");
4691 switch(sWorld
.BanAccount(type
, nameOrIP
, duration
, reason
,m_session
->GetPlayerName()))
4694 if(atoi(duration
)>0)
4695 PSendSysMessage(LANG_BAN_YOUBANNED
,nameOrIP
,secsToTimeString(TimeStringToSecs(duration
),true).c_str(),reason
);
4697 PSendSysMessage(LANG_BAN_YOUPERMBANNED
,nameOrIP
,reason
);
4699 case BAN_SYNTAX_ERROR
:
4702 PSendSysMessage(LANG_BAN_NOTFOUND
,type
,nameOrIP
);
4709 bool ChatHandler::HandleUnBanCommand(const char* args
)
4713 char* type
= strtok((char*)args
, " ");
4716 char* nameOrIP
= strtok(NULL
, " ");
4721 if(sWorld
.RemoveBanAccount(type
,nameOrIP
))
4722 PSendSysMessage(LANG_UNBAN_UNBANNED
,nameOrIP
);
4724 PSendSysMessage(LANG_UNBAN_ERROR
,nameOrIP
);
4729 bool ChatHandler::HandleBanInfoCommand(const char* args
)
4734 char* cType
= strtok((char*)args
, " ");
4735 char* cnameOrIP
= strtok(NULL
, "");
4736 if(!cType
|| !cnameOrIP
)
4739 std::string nameOrIP
= cnameOrIP
;
4740 std::string type
= cType
;
4741 if (!IsIPAddress(cnameOrIP
) && type
=="ip")
4747 //look the accountid up
4749 std::string accountname
;
4750 if(type
== "account")
4752 loginDatabase
.escape_string(nameOrIP
);
4753 QueryResult
*result
= loginDatabase
.PQuery("SELECT id, username FROM account WHERE username = '%s'",nameOrIP
.c_str());
4756 PSendSysMessage(LANG_BANINFO_NOACCOUNT
);
4759 fields
= result
->Fetch();
4760 accountid
= fields
[0].GetUInt32();
4761 accountname
= fields
[1].GetCppString();
4764 else if(type
== "character")
4766 if(!normalizePlayerName(nameOrIP
))
4768 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
4769 SetSentErrorMessage(true);
4773 loginDatabase
.escape_string(nameOrIP
);
4774 QueryResult
*result
= CharacterDatabase
.PQuery("SELECT account FROM characters WHERE name = '%s'", nameOrIP
.c_str());
4777 PSendSysMessage(LANG_BANINFO_NOCHARACTER
);
4780 fields
= result
->Fetch();
4781 accountid
= fields
[0].GetUInt32();
4783 result
= loginDatabase
.PQuery("SELECT username FROM account WHERE id = '%u'", accountid
);
4786 PSendSysMessage(LANG_BANINFO_NOCHARACTER
);
4789 fields
= result
->Fetch();
4790 accountname
= fields
[0].GetCppString();
4796 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
);
4799 PSendSysMessage(LANG_BANINFO_NOACCOUNTBAN
, accountname
.c_str());
4803 PSendSysMessage(LANG_BANINFO_BANHISTORY
,accountname
.c_str());
4806 fields
= result
->Fetch();
4808 time_t unbandate
= time_t(fields
[3].GetUInt64());
4809 bool active
= false;
4810 if(fields
[2].GetBool() && (fields
[1].GetUInt64() == (uint64
)0 ||unbandate
>= time(NULL
)) )
4812 bool permanent
= (fields
[1].GetUInt64() == (uint64
)0);
4813 std::string bantime
= permanent
?GetMangosString(LANG_BANINFO_INFINITE
):secsToTimeString(fields
[1].GetUInt64(), true);
4814 PSendSysMessage(LANG_BANINFO_HISTORYENTRY
,
4815 fields
[0].GetString(), bantime
.c_str(), active
? GetMangosString(LANG_BANINFO_YES
):GetMangosString(LANG_BANINFO_NO
), fields
[4].GetString(), fields
[5].GetString());
4816 }while (result
->NextRow());
4822 loginDatabase
.escape_string(nameOrIP
);
4823 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'",nameOrIP
.c_str());
4826 PSendSysMessage(LANG_BANINFO_NOIP
);
4829 fields
= result
->Fetch();
4830 bool permanent
= (fields
[6].GetUInt64()==(uint64
)0);
4831 PSendSysMessage(LANG_BANINFO_IPENTRY
,
4832 fields
[0].GetString(), fields
[1].GetString(), permanent
? GetMangosString(LANG_BANINFO_NEVER
):fields
[2].GetString(),
4833 permanent
? GetMangosString(LANG_BANINFO_INFINITE
):secsToTimeString(fields
[3].GetUInt64(), true).c_str(), fields
[4].GetString(), fields
[5].GetString());
4839 bool ChatHandler::HandleBanListCommand(const char* args
)
4841 loginDatabase
.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
4844 char* cType
= strtok((char*)args
, " ");
4845 char* cFilter
= strtok(NULL
, "");
4846 if(!cType
|| !cFilter
)
4848 std::string Filter
= cFilter
;
4849 std::string Type
= cType
;
4850 loginDatabase
.escape_string(Filter
);
4852 QueryResult
* result
= NULL
;
4853 Field
*fields
= NULL
;
4856 result
= loginDatabase
.PQuery("SELECT ip FROM ip_banned WHERE ip "_LIKE_
" "_CONCAT3_("'%%'","'%s'","'%%'"),Filter
.c_str());
4859 PSendSysMessage(LANG_BANLIST_NOIP
);
4862 PSendSysMessage(LANG_BANLIST_MATCHINGIP
);
4865 fields
= result
->Fetch();
4866 PSendSysMessage("%s",fields
[0].GetString());
4867 } while (result
->NextRow());
4873 if(Type
== "account")
4875 result
= loginDatabase
.PQuery("SELECT id FROM account WHERE username "_LIKE_
" "_CONCAT3_("'%%'","'%s'","'%%'"),Filter
.c_str());
4878 PSendSysMessage(LANG_BANLIST_NOACCOUNT
);
4881 //do not delete result
4883 else if(Type
== "characters")
4885 result
= CharacterDatabase
.PQuery("SELECT account FROM characters, WHERE name "_LIKE_
" "_CONCAT3_("'%%'","'%s'","'%%'"),Filter
.c_str());
4888 PSendSysMessage(LANG_BANLIST_NOCHARACTER
);
4895 PSendSysMessage(LANG_BANLIST_MATCHINGACCOUNT
);
4898 fields
= result
->Fetch();
4899 uint32 accountid
= fields
[0].GetUInt32();
4900 QueryResult
* banresult
= loginDatabase
.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.active = '1' AND account_banned.id=account.id",accountid
);
4903 Field
* fields2
= banresult
->Fetch();
4904 PSendSysMessage("%s",fields2
[0].GetString());
4907 } while (result
->NextRow());
4913 bool ChatHandler::HandleRespawnCommand(const char* /*args*/)
4915 Player
* pl
= m_session
->GetPlayer();
4917 CellPair
p(MaNGOS::ComputeCellPair(pl
->GetPositionX(), pl
->GetPositionY()));
4919 cell
.data
.Part
.reserved
= ALL_DISTRICT
;
4922 MaNGOS::RespawnDo u_do
;
4923 MaNGOS::WorldObjectWorker
<MaNGOS::RespawnDo
> worker(u_do
);
4925 TypeContainerVisitor
<MaNGOS::WorldObjectWorker
<MaNGOS::RespawnDo
>, GridTypeMapContainer
> obj_worker(worker
);
4926 CellLock
<GridReadGuard
> cell_lock(cell
, p
);
4927 cell_lock
->Visit(cell_lock
, obj_worker
, *MapManager::Instance().GetMap(pl
->GetMapId(), pl
));
4932 bool ChatHandler::HandleFlyModeCommand(const char* args
)
4937 Unit
*unit
= getSelectedUnit();
4938 if (!unit
|| (unit
->GetTypeId() != TYPEID_PLAYER
))
4939 unit
= m_session
->GetPlayer();
4941 WorldPacket
data(12);
4942 if (strncmp(args
, "on", 3) == 0)
4943 data
.SetOpcode(SMSG_MOVE_SET_CAN_FLY
);
4944 else if (strncmp(args
, "off", 4) == 0)
4945 data
.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY
);
4948 SendSysMessage(LANG_USE_BOL
);
4951 data
.append(unit
->GetPackGUID());
4952 data
<< uint32(0); // unknown
4953 unit
->SendMessageToSet(&data
, true);
4954 PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS
, unit
->GetName(), args
);
4958 bool ChatHandler::HandleLoadPDumpCommand(const char *args
)
4963 char * file
= strtok((char*)args
, " "); if(!file
) return false;
4964 char * acc
= strtok(NULL
, " "); if(!acc
) return false;
4968 uint32 account_id
= accmgr
.GetId(acc
);
4971 account_id
= atoi(acc
);
4974 std::string acc_name
;
4975 if(!accmgr
.GetName(account_id
,acc_name
))
4982 char * name
= strtok(NULL
, " ");
4983 char * guid_str
= name
? strtok(NULL
, " ") : NULL
;
4985 uint32 guid
= guid_str
? atoi(guid_str
) : 0;
4987 if(PlayerDumpReader().LoadDump(file
, account_id
, name
? name
: "", guid
))
4988 PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS
);
4990 PSendSysMessage(LANG_COMMAND_IMPORT_FAILED
);
4995 bool ChatHandler::HandleChangeEntryCommand(const char *args
)
5000 uint32 newEntryNum
= atoi(args
);
5004 Unit
* unit
= getSelectedUnit();
5005 if(!unit
|| unit
->GetTypeId() != TYPEID_UNIT
)
5007 SendSysMessage(LANG_SELECT_CREATURE
);
5008 SetSentErrorMessage(true);
5011 Creature
* creature
= (Creature
*)unit
;
5012 if(creature
->UpdateEntry(newEntryNum
))
5013 SendSysMessage(LANG_DONE
);
5015 SendSysMessage(LANG_ERROR
);
5019 bool ChatHandler::HandleWritePDumpCommand(const char *args
)
5024 char* file
= strtok((char*)args
, " ");
5025 char* p2
= strtok(NULL
, " ");
5030 uint32 guid
= objmgr
.GetPlayerGUIDByName(p2
);
5034 if (PlayerDumpWriter().WriteDump(file
, guid
))
5035 PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS
);
5037 PSendSysMessage(LANG_COMMAND_EXPORT_FAILED
);
5042 bool ChatHandler::HandleMovegensCommand(const char* /*args*/)
5044 Unit
* unit
= getSelectedUnit();
5047 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
5048 SetSentErrorMessage(true);
5052 PSendSysMessage(LANG_MOVEGENS_LIST
,(unit
->GetTypeId()==TYPEID_PLAYER
? "Player" : "Creature" ),unit
->GetGUIDLow());
5054 MotionMaster
* mm
= unit
->GetMotionMaster();
5055 for(MotionMaster::const_iterator itr
= mm
->begin(); itr
!= mm
->end(); ++itr
)
5057 switch((*itr
)->GetMovementGeneratorType())
5059 case IDLE_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_IDLE
); break;
5060 case RANDOM_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_RANDOM
); break;
5061 case WAYPOINT_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_WAYPOINT
); break;
5062 case ANIMAL_RANDOM_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_ANIMAL_RANDOM
); break;
5063 case CONFUSED_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_CONFUSED
); break;
5064 case TARGETED_MOTION_TYPE
:
5066 if(unit
->GetTypeId()==TYPEID_PLAYER
)
5068 TargetedMovementGenerator
<Player
> const* mgen
= static_cast<TargetedMovementGenerator
<Player
> const*>(*itr
);
5069 Unit
* target
= mgen
->GetTarget();
5071 PSendSysMessage(LANG_MOVEGENS_TARGETED_PLAYER
,target
->GetName(),target
->GetGUIDLow());
5073 SendSysMessage(LANG_MOVEGENS_TARGETED_NULL
);
5077 TargetedMovementGenerator
<Creature
> const* mgen
= static_cast<TargetedMovementGenerator
<Creature
> const*>(*itr
);
5078 Unit
* target
= mgen
->GetTarget();
5080 PSendSysMessage(LANG_MOVEGENS_TARGETED_CREATURE
,target
->GetName(),target
->GetGUIDLow());
5082 SendSysMessage(LANG_MOVEGENS_TARGETED_NULL
);
5086 case HOME_MOTION_TYPE
:
5087 if(unit
->GetTypeId()==TYPEID_UNIT
)
5090 (*itr
)->GetDestination(x
,y
,z
);
5091 PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE
,x
,y
,z
);
5094 SendSysMessage(LANG_MOVEGENS_HOME_PLAYER
);
5096 case FLIGHT_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_FLIGHT
); break;
5097 case POINT_MOTION_TYPE
:
5100 (*itr
)->GetDestination(x
,y
,z
);
5101 PSendSysMessage(LANG_MOVEGENS_POINT
,x
,y
,z
);
5104 case FLEEING_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_FEAR
); break;
5105 case DISTRACT_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_DISTRACT
); break;
5107 PSendSysMessage(LANG_MOVEGENS_UNKNOWN
,(*itr
)->GetMovementGeneratorType());
5114 bool ChatHandler::HandlePLimitCommand(const char *args
)
5118 char* param
= strtok((char*)args
, " ");
5122 int l
= strlen(param
);
5124 if( strncmp(param
,"player",l
) == 0 )
5125 sWorld
.SetPlayerLimit(-SEC_PLAYER
);
5126 else if(strncmp(param
,"moderator",l
) == 0 )
5127 sWorld
.SetPlayerLimit(-SEC_MODERATOR
);
5128 else if(strncmp(param
,"gamemaster",l
) == 0 )
5129 sWorld
.SetPlayerLimit(-SEC_GAMEMASTER
);
5130 else if(strncmp(param
,"administrator",l
) == 0 )
5131 sWorld
.SetPlayerLimit(-SEC_ADMINISTRATOR
);
5132 else if(strncmp(param
,"reset",l
) == 0 )
5133 sWorld
.SetPlayerLimit( sConfig
.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT
) );
5136 int val
= atoi(param
);
5137 if(val
< -SEC_ADMINISTRATOR
) val
= -SEC_ADMINISTRATOR
;
5139 sWorld
.SetPlayerLimit(val
);
5142 // kick all low security level players
5143 if(sWorld
.GetPlayerAmountLimit() > SEC_PLAYER
)
5144 sWorld
.KickAllLess(sWorld
.GetPlayerSecurityLimit());
5147 uint32 pLimit
= sWorld
.GetPlayerAmountLimit();
5148 AccountTypes allowedAccountType
= sWorld
.GetPlayerSecurityLimit();
5149 char const* secName
= "";
5150 switch(allowedAccountType
)
5152 case SEC_PLAYER
: secName
= "Player"; break;
5153 case SEC_MODERATOR
: secName
= "Moderator"; break;
5154 case SEC_GAMEMASTER
: secName
= "Gamemaster"; break;
5155 case SEC_ADMINISTRATOR
: secName
= "Administrator"; break;
5156 default: secName
= "<unknown>"; break;
5159 PSendSysMessage("Player limits: amount %u, min. security level %s.",pLimit
,secName
);
5164 bool ChatHandler::HandleCastCommand(const char* args
)
5169 Unit
* target
= getSelectedUnit();
5173 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
5174 SetSentErrorMessage(true);
5178 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
5179 uint32 spell
= extractSpellIdFromLink((char*)args
);
5183 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell
);
5187 if(!SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer()))
5189 PSendSysMessage(LANG_COMMAND_SPELL_BROKEN
,spell
);
5190 SetSentErrorMessage(true);
5194 char* trig_str
= strtok(NULL
, " ");
5197 int l
= strlen(trig_str
);
5198 if(strncmp(trig_str
,"triggered",l
) != 0 )
5202 bool triggered
= (trig_str
!= NULL
);
5204 m_session
->GetPlayer()->CastSpell(target
,spell
,triggered
);
5209 bool ChatHandler::HandleCastBackCommand(const char* args
)
5211 Creature
* caster
= getSelectedCreature();
5215 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
5216 SetSentErrorMessage(true);
5220 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r
5221 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
5222 uint32 spell
= extractSpellIdFromLink((char*)args
);
5223 if(!spell
|| !sSpellStore
.LookupEntry(spell
))
5226 char* trig_str
= strtok(NULL
, " ");
5229 int l
= strlen(trig_str
);
5230 if(strncmp(trig_str
,"triggered",l
) != 0 )
5234 bool triggered
= (trig_str
!= NULL
);
5236 // update orientation at server
5237 caster
->SetOrientation(caster
->GetAngle(m_session
->GetPlayer()));
5241 caster
->BuildHeartBeatMsg(&data
);
5242 caster
->SendMessageToSet(&data
,true);
5244 caster
->CastSpell(m_session
->GetPlayer(),spell
,false);
5249 bool ChatHandler::HandleCastDistCommand(const char* args
)
5254 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
5255 uint32 spell
= extractSpellIdFromLink((char*)args
);
5259 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell
);
5263 if(!SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer()))
5265 PSendSysMessage(LANG_COMMAND_SPELL_BROKEN
,spell
);
5266 SetSentErrorMessage(true);
5270 char *distStr
= strtok(NULL
, " ");
5275 sscanf(distStr
, "%f", &dist
);
5277 char* trig_str
= strtok(NULL
, " ");
5280 int l
= strlen(trig_str
);
5281 if(strncmp(trig_str
,"triggered",l
) != 0 )
5285 bool triggered
= (trig_str
!= NULL
);
5288 m_session
->GetPlayer()->GetClosePoint(x
,y
,z
,dist
);
5290 m_session
->GetPlayer()->CastSpell(x
,y
,z
,spell
,triggered
);
5294 bool ChatHandler::HandleCastTargetCommand(const char* args
)
5296 Creature
* caster
= getSelectedCreature();
5300 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
5301 SetSentErrorMessage(true);
5305 if(!caster
->getVictim())
5307 SendSysMessage(LANG_SELECTED_TARGET_NOT_HAVE_VICTIM
);
5308 SetSentErrorMessage(true);
5312 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
5313 uint32 spell
= extractSpellIdFromLink((char*)args
);
5314 if(!spell
|| !sSpellStore
.LookupEntry(spell
))
5317 char* trig_str
= strtok(NULL
, " ");
5320 int l
= strlen(trig_str
);
5321 if(strncmp(trig_str
,"triggered",l
) != 0 )
5325 bool triggered
= (trig_str
!= NULL
);
5327 // update orientation at server
5328 caster
->SetOrientation(caster
->GetAngle(m_session
->GetPlayer()));
5332 caster
->BuildHeartBeatMsg(&data
);
5333 caster
->SendMessageToSet(&data
,true);
5335 caster
->CastSpell(caster
->getVictim(),spell
,false);
5341 ComeToMe command REQUIRED for 3rd party scripting library to have access to PointMovementGenerator
5342 Without this function 3rd party scripting library will get linking errors (unresolved external)
5343 when attempting to use the PointMovementGenerator
5345 bool ChatHandler::HandleComeToMeCommand(const char *args
)
5347 Creature
* caster
= getSelectedCreature();
5351 SendSysMessage(LANG_SELECT_CREATURE
);
5352 SetSentErrorMessage(true);
5356 char* newFlagStr
= strtok((char*)args
, " ");
5361 uint32 newFlags
= atoi(newFlagStr
);
5363 caster
->SetUnitMovementFlags(newFlags
);
5365 Player
* pl
= m_session
->GetPlayer();
5367 caster
->GetMotionMaster()->MovePoint(0, pl
->GetPositionX(), pl
->GetPositionY(), pl
->GetPositionZ());
5371 bool ChatHandler::HandleCastSelfCommand(const char* args
)
5376 Unit
* target
= getSelectedUnit();
5380 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
5381 SetSentErrorMessage(true);
5385 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
5386 uint32 spell
= extractSpellIdFromLink((char*)args
);
5390 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell
);
5394 if(!SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer()))
5396 PSendSysMessage(LANG_COMMAND_SPELL_BROKEN
,spell
);
5397 SetSentErrorMessage(true);
5401 target
->CastSpell(target
,spell
,false);
5406 std::string
GetTimeString(uint32 time
)
5408 uint16 days
= time
/ DAY
, hours
= (time
% DAY
) / HOUR
, minute
= (time
% HOUR
) / MINUTE
;
5409 std::ostringstream ss
;
5410 if(days
) ss
<< days
<< "d ";
5411 if(hours
) ss
<< hours
<< "h ";
5412 ss
<< minute
<< "m";
5416 bool ChatHandler::HandleInstanceListBindsCommand(const char* /*args*/)
5418 Player
* player
= getSelectedPlayer();
5419 if (!player
) player
= m_session
->GetPlayer();
5421 for(uint8 i
= 0; i
< TOTAL_DIFFICULTIES
; i
++)
5423 Player::BoundInstancesMap
&binds
= player
->GetBoundInstances(i
);
5424 for(Player::BoundInstancesMap::iterator itr
= binds
.begin(); itr
!= binds
.end(); ++itr
)
5426 InstanceSave
*save
= itr
->second
.save
;
5427 std::string timeleft
= GetTimeString(save
->GetResetTime() - time(NULL
));
5428 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());
5432 PSendSysMessage("player binds: %d", counter
);
5434 Group
*group
= player
->GetGroup();
5437 for(uint8 i
= 0; i
< TOTAL_DIFFICULTIES
; i
++)
5439 Group::BoundInstancesMap
&binds
= group
->GetBoundInstances(i
);
5440 for(Group::BoundInstancesMap::iterator itr
= binds
.begin(); itr
!= binds
.end(); ++itr
)
5442 InstanceSave
*save
= itr
->second
.save
;
5443 std::string timeleft
= GetTimeString(save
->GetResetTime() - time(NULL
));
5444 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());
5449 PSendSysMessage("group binds: %d", counter
);
5454 bool ChatHandler::HandleInstanceUnbindCommand(const char* args
)
5459 std::string cmd
= args
;
5462 Player
* player
= getSelectedPlayer();
5463 if (!player
) player
= m_session
->GetPlayer();
5465 for(uint8 i
= 0; i
< TOTAL_DIFFICULTIES
; i
++)
5467 Player::BoundInstancesMap
&binds
= player
->GetBoundInstances(i
);
5468 for(Player::BoundInstancesMap::iterator itr
= binds
.begin(); itr
!= binds
.end();)
5470 if(itr
->first
!= player
->GetMapId())
5472 InstanceSave
*save
= itr
->second
.save
;
5473 std::string timeleft
= GetTimeString(save
->GetResetTime() - time(NULL
));
5474 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());
5475 player
->UnbindInstance(itr
, i
);
5482 PSendSysMessage("instances unbound: %d", counter
);
5487 bool ChatHandler::HandleInstanceStatsCommand(const char* /*args*/)
5489 PSendSysMessage("instances loaded: %d", MapManager::Instance().GetNumInstances());
5490 PSendSysMessage("players in instances: %d", MapManager::Instance().GetNumPlayersInInstances());
5491 PSendSysMessage("instance saves: %d", sInstanceSaveManager
.GetNumInstanceSaves());
5492 PSendSysMessage("players bound: %d", sInstanceSaveManager
.GetNumBoundPlayersTotal());
5493 PSendSysMessage("groups bound: %d", sInstanceSaveManager
.GetNumBoundGroupsTotal());
5497 bool ChatHandler::HandleInstanceSaveDataCommand(const char * /*args*/)
5499 Player
* pl
= m_session
->GetPlayer();
5501 Map
* map
= pl
->GetMap();
5502 if (!map
->IsDungeon())
5504 PSendSysMessage("Map is not a dungeon.");
5505 SetSentErrorMessage(true);
5509 if (!((InstanceMap
*)map
)->GetInstanceData())
5511 PSendSysMessage("Map has no instance data.");
5512 SetSentErrorMessage(true);
5516 ((InstanceMap
*)map
)->GetInstanceData()->SaveToDB();