diff options
author | click <none@none> | 2010-11-16 21:27:25 +0100 |
---|---|---|
committer | click <none@none> | 2010-11-16 21:27:25 +0100 |
commit | 95e956a0b5145ad0a260557ce9ae1290cdacad2d (patch) | |
tree | 383a6b273e31ab72e352d2394ab951c1d5b20ec2 | |
parent | e87223b453f1f958b077d9f98234d4cb9fc71557 (diff) |
Core/Scripts: Convert more commands over to CommandScripts (moves gobject, honor, quest, reload, titles and wp commands to scripts) - Patch by Paradox
(Also fixes a minor visual error on GM-listings (gm ingame/gm list) when the respective user had an R in his/her name).
Closes issue 4792.
--HG--
branch : trunk
-rw-r--r-- | sql/base/world_database.sql | 27 | ||||
-rw-r--r-- | sql/updates/10460_world_command.sql | 36 | ||||
-rwxr-xr-x | src/server/game/Chat/Chat.cpp | 175 | ||||
-rwxr-xr-x | src/server/game/Chat/Chat.h | 140 | ||||
-rwxr-xr-x | src/server/game/Chat/Commands/Debugcmds.cpp | 23 | ||||
-rwxr-xr-x | src/server/game/Chat/Commands/Level2.cpp | 1713 | ||||
-rwxr-xr-x | src/server/game/Chat/Commands/Level3.cpp | 1388 | ||||
-rwxr-xr-x | src/server/game/Chat/Commands/TicketCommands.cpp | 6 | ||||
-rwxr-xr-x | src/server/game/Scripting/ScriptLoader.cpp | 13 | ||||
-rw-r--r-- | src/server/scripts/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/server/scripts/Commands/CMakeLists.txt | 13 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_gm.cpp | 14 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_gobject.cpp | 677 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_honor.cpp | 120 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_quest.cpp | 260 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_reload.cpp | 1302 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_titles.cpp | 250 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_wp.cpp | 981 |
18 files changed, 3676 insertions, 3463 deletions
diff --git a/sql/base/world_database.sql b/sql/base/world_database.sql index d75ba033309..594c34469c8 100644 --- a/sql/base/world_database.sql +++ b/sql/base/world_database.sql @@ -413,13 +413,13 @@ INSERT INTO `command` VALUES ('gobject',2,'Syntax: .gobject $subcommand\nType .gobject to see the list of possible subcommands or .help gobject $subcommand to see info on subcommands'), ('gobject activate',2,'Syntax: .gobject activate #guid\r\n\r\nActivates an object like a door or a button.'), ('gobject add',2,'Syntax: .gobject add #id <spawntimeSecs>\r\n\r\nAdd a game object from game object templates to the world at your current location using the #id.\r\nspawntimesecs sets the spawntime, it is optional.\r\n\r\nNote: this is a copy of .gameobject.'), +('gobject add temp',2,'Adds a temporary gameobject that is not saved to DB.'), ('gobject delete',2,'Syntax: .gobject delete #go_guid\r\nDelete gameobject with guid #go_guid.'), ('gobject info', 2, 'Syntax: .gobject info [$object_entry]\r\n\r\nQuery Gameobject information for selected gameobject or given entry.'), ('gobject move',2,'Syntax: .gobject move #goguid [#x #y #z]\r\n\r\nMove gameobject #goguid to character coordinates (or to (#x,#y,#z) coordinates if its provide).'), ('gobject near',2,'Syntax: .gobject near [#distance]\r\n\r\nOutput gameobjects at distance #distance from player. Output gameobject guids and coordinates sorted by distance from character. If #distance not provided use 10 as default value.'), -('gobject setphase',2,'Syntax: .gobject setphase #guid #phasemask\r\n\r\nGameobject with DB guid #guid phasemask changed to #phasemask with related world vision update for players. Gameobject state saved to DB and persistent.'), +('gobject set phase',2,'Syntax: .gobject set phase #guid #phasemask\r\n\r\nGameobject with DB guid #guid phasemask changed to #phasemask with related world vision update for players. Gameobject state saved to DB and persistent.'), ('gobject target',2,'Syntax: .gobject target [#go_id|#go_name_part]\r\n\r\nLocate and show position nearest gameobject. If #go_id or #go_name_part provide then locate and show position of nearest gameobject with gameobject template id #go_id or name included #go_name_part as part.'), -('gobject tempadd',2,'Adds a temporary gameobject that is not saved to DB.'), ('gobject turn',2,'Syntax: .gobject turn #goguid \r\n\r\nSet for gameobject #goguid orientation same as current character orientation.'), ('gps',1,'Syntax: .gps [$name|$shift-link]\r\n\r\nDisplay the position information for a selected character or creature (also if player name $name provided then for named player, or if creature/gameobject shift-link provided then pointed creature/gameobject if it loaded). Position information includes X, Y, Z, and orientation, map Id and zone Id'), ('groupsummon',1,'Syntax: .groupsummon [$charactername]\r\n\r\nTeleport the given character and his group to you. Teleported only online characters but original selected group member can be offline.'), @@ -434,7 +434,7 @@ INSERT INTO `command` VALUES ('hidearea',3,'Syntax: .hidearea #areaid\r\n\r\nHide the area of #areaid to the selected character. If no character is selected, hide this area to you.'), ('honor',2,'Syntax: .honor $subcommand\nType .honor to see the list of possible subcommands or .help honor $subcommand to see info on subcommands'), ('honor add',2,'Syntax: .honor add $amount\r\n\r\nAdd a certain amount of honor (gained today) to the selected player.'), -('honor addkill',2,'Syntax: .honor addkikll\r\n\r\nAdd the targeted unit as one of your pvp kills today (you only get honor if it''s a racial leader or a player)'), +('honor add kill',2,'Syntax: .honor add kill\r\n\r\nAdd the targeted unit as one of your pvp kills today (you only get honor if it''s a racial leader or a player)'), ('honor update',2,'Syntax: .honor update\r\n\r\nForce the yesterday''s honor fields to be updated with today''s data, which will get reset for the selected player.'), ('hover',3,'Syntax: .hover #flag\r\n\r\nEnable or disable hover mode for your character.\r\n\r\nUse a #flag of value 1 to enable, use a #flag value of 0 to disable hover.'), ('instance',3,'Syntax: .instance $subcommand\nType .instance to see the list of possible subcommands or .help instance $subcommand to see info on subcommands'), @@ -463,7 +463,6 @@ INSERT INTO `command` VALUES ('list item',3,'Syntax: .list item #item_id [#max_count]\r\n\r\nOutput items with item id #item_id found in all character inventories, mails, auctions, and guild banks. Output item guids, item owner guid, owner account and owner name (guild name and guid in case guild bank). Will be output maximum #max_count items. If #max_count not provided use 10 as default value.'), ('list object',3,'Syntax: .list object #gameobject_id [#max_count]\r\n\r\nOutput gameobjects with gameobject id #gameobject_id found in world. Output gameobject guids and coordinates sorted by distance from character. Will be output maximum #max_count gameobject. If #max_count not provided use 10 as default value.'), ('listfreeze',1,'Syntax: .listfreeze\r\n\r\nSearch and output all frozen players.'), -('loadpath',3,'Syntax: .loadpath $pathid\nLoad path changes ingame - IMPORTANT: must be applied first for new paths before .path load #pathid '), ('lookup',3,'Syntax: .lookup $subcommand\nType .lookup to see the list of possible subcommands or .help lookup $subcommand to see info on subcommands'), ('lookup area',1,'Syntax: .lookup area $namepart\r\n\r\nLooks up an area by $namepart, and returns all matches with their area ID''s.'), ('lookup creature',3,'Syntax: .lookup creature $namepart\r\n\r\nLooks up a creature by $namepart, and returns all matches with their creature ID''s.'), @@ -560,14 +559,14 @@ INSERT INTO `command` VALUES ('recall',1,'Syntax: .recall [$playername]\r\n\r\nTeleport $playername or selected player to the place where he has been before last use of a teleportation command. If no $playername is entered and no player is selected, it will teleport you.'), ('reload',3,'Syntax: .reload $subcommand\nType .reload to see the list of possible subcommands or .help reload $subcommand to see info on subcommands'), ('reload all',3,'Syntax: .reload all\r\n\r\nReload all tables with reload support added and that can be _safe_ reloaded.'), -('reload all_gossips',3,'Syntax: .reload all_gossips\nReload gossip_menu, gossip_menu_option, gossip_scripts, npc_gossip, points_of_interest tables.'), -('reload all_item',3,'Syntax: .reload all_item\nReload page_text, item_enchantment_table tables.'), -('reload all_locales',3,'Syntax: .reload all_locales\r\n\r\nReload all `locales_*` tables with reload support added and that can be _safe_ reloaded.'), -('reload all_loot',3,'Syntax: .reload all_loot\r\n\r\nReload all `*_loot_template` tables. This can be slow operation with lags for server run.'), -('reload all_npc',3,'Syntax: .reload all_npc\nReload npc_gossip, npc_option, npc_trainer, npc vendor, points of interest tables.'), -('reload all_quest',3,'Syntax: .reload all_quest\r\n\r\nReload all quest related tables if reload support added for this table and this table can be _safe_ reloaded.'), -('reload all_scripts',3,'Syntax: .reload all_scripts\nReload gameobject_scripts, event_scripts, quest_end_scripts, quest_start_scripts, spell_scripts, db_script_string, waypoint_scripts tables.'), -('reload all_spell',3,'Syntax: .reload all\r\n\r\nReload all `spell_*` tables with reload support added and that can be _safe_ reloaded.'), +('reload all gossips',3,'Syntax: .reload all gossips\nReload gossip_menu, gossip_menu_option, gossip_scripts, npc_gossip, points_of_interest tables.'), +('reload all item',3,'Syntax: .reload all item\nReload page_text, item_enchantment_table tables.'), +('reload all locales',3,'Syntax: .reload all locales\r\n\r\nReload all `locales_*` tables with reload support added and that can be _safe_ reloaded.'), +('reload all loot',3,'Syntax: .reload all loot\r\n\r\nReload all `*_loot_template` tables. This can be slow operation with lags for server run.'), +('reload all npc',3,'Syntax: .reload all npc\nReload npc_gossip, npc_option, npc_trainer, npc vendor, points of interest tables.'), +('reload all quest',3,'Syntax: .reload all quest\r\n\r\nReload all quest related tables if reload support added for this table and this table can be _safe_ reloaded.'), +('reload all scripts',3,'Syntax: .reload all scripts\nReload gameobject_scripts, event_scripts, quest_end_scripts, quest_start_scripts, spell_scripts, db_script_string, waypoint_scripts tables.'), +('reload all spell',3,'Syntax: .reload all spell\r\n\r\nReload all `spell_*` tables with reload support added and that can be _safe_ reloaded.'), ('reload areatrigger_involvedrelation',3,'Syntax: .reload areatrigger_involvedrelation\nReload areatrigger_involvedrelation table.'), ('reload areatrigger_tavern',3,'Syntax: .reload areatrigger_tavern\nReload areatrigger_tavern table.'), ('reload areatrigger_teleport',3,'Syntax: .reload areatrigger_teleport\nReload areatrigger_teleport table.'), @@ -702,7 +701,7 @@ INSERT INTO `command` VALUES ('titles add',2,'Syntax: .titles add #title\r\nAdd title #title (id or shift-link) to known titles list for selected player.'), ('titles current',2,'Syntax: .titles current #title\r\nSet title #title (id or shift-link) as current selected titl for selected player. If title not in known title list for player then it will be added to list.'), ('titles remove',2,'Syntax: .titles remove #title\r\nRemove title #title (id or shift-link) from known titles list for selected player.'), -('titles setmask',2,'Syntax: .titles setmask #mask\r\n\r\nAllows user to use all titles from #mask.\r\n\r\n #mask=0 disables the title-choose-field'), +('titles set mask',2,'Syntax: .titles set mask #mask\r\n\r\nAllows user to use all titles from #mask.\r\n\r\n #mask=0 disables the title-choose-field'), ('unaura',3,'Syntax: .unaura #spellid\r\n\r\nRemove aura due to spell #spellid from the selected Unit.'), ('unban',3,'Syntax: .unban $subcommand\nType .unban to see the list of possible subcommands or .help unban $subcommand to see info on subcommands'), ('unban account',3,'Syntax: .unban account $Name\r\nUnban accounts for account name pattern.'), @@ -716,8 +715,10 @@ INSERT INTO `command` VALUES ('waterwalk',2,'Syntax: .waterwalk on/off\r\n\r\nSet on/off waterwalk state for selected player or self if no player selected.'), ('wchange',3,'Syntax: .wchange #weathertype #status\r\n\r\nSet current weather to #weathertype with an intensity of #status.\r\n\r\n#weathertype can be 1 for rain, 2 for snow, and 3 for sand. #status can be 0 for disabled, and 1 for enabled.'), ('whispers',1,'Syntax: .whispers on|off\r\nEnable/disable accepting whispers by GM from players. By default use trinityd.conf setting.'), +('wp add',2,'Syntax: .wp add\r\n\r\nAdd a waypoint for the selected creature at your current position.'), ('wp event',2,'Syntax: .wp event $subcommand\nType .path event to see the list of possible subcommands or .help path event $subcommand to see info on subcommands.'), ('wp load',2,'Syntax: .wp load $pathid\nLoad pathid number for selected creature. Creature must have no waypoint data.'), +('wp reload',3,'Syntax: .wp reload $pathid\nLoad path changes ingame - IMPORTANT: must be applied first for new paths before .wp load #pathid '), ('wp show',2,'Syntax: .wp show $option\nOptions:\non $pathid (or selected creature with loaded path) - Show path\noff - Hide path\ninfo $slected_waypoint - Show info for selected waypoint.'), ('wp unload',2,'Syntax: .wp unload\nUnload path for selected creature.'); /*!40000 ALTER TABLE `command` ENABLE KEYS */; diff --git a/sql/updates/10460_world_command.sql b/sql/updates/10460_world_command.sql new file mode 100644 index 00000000000..83343f0fff0 --- /dev/null +++ b/sql/updates/10460_world_command.sql @@ -0,0 +1,36 @@ +-- Rename changed gobject commands +DELETE FROM `command` WHERE `name` IN ('gobject setphase','gobject tempadd','gobject set phase','gobject add temp'); +INSERT INTO `command` (`name`, `security`, `help`) VALUES +('gobject set phase',2,'Syntax: .gobject set phase #guid #phasemask\r\n\r\nGameobject with DB guid #guid phasemask changed to #phasemask with related world vision update for players. Gameobject state saved to DB and persistent.'), +('gobject add temp',2,'Adds a temporary gameobject that is not saved to DB.'); + +-- Rename changed honor commands +DELETE FROM `command` WHERE `name` IN ('honor addkill','honor add kill'); +INSERT INTO `command` (`name`, `security`, `help`) VALUES +('honor add kill',2,'Syntax: .honor add kill\r\n\r\nAdd the targeted unit as one of your pvp kills today (you only get honor if it''s a racial leader or a player)'); + +-- Add wp add command +DELETE FROM `command` WHERE `name` IN ('wp add','wp addwp'); +INSERT INTO `command` (`name`, `security`, `help`) VALUES +('wp add',2,'Syntax: .wp add\r\n\r\nAdd a waypoint for the selected creature at your current position.'); + +-- Rename changed loadpath command and move it to wp reload +DELETE FROM `command` WHERE `name` IN ('loadpath','wp reload'); +INSERT INTO `command` (`name`, `security`, `help`) VALUES +('wp reload',3,'Syntax: .wp reload $pathid\nLoad path changes ingame - IMPORTANT: must be applied first for new paths before .wp load #pathid '); + +DELETE FROM `command` WHERE `name` LIKE 'reload all%'; +INSERT INTO `command` (`name`, `security`, `help`) VALUES +('reload all',3,'Syntax: .reload all\r\n\r\nReload all tables with reload support added and that can be _safe_ reloaded.'), +('reload all gossips',3,'Syntax: .reload all gossips\nReload gossip_menu, gossip_menu_option, gossip_scripts, npc_gossip, points_of_interest tables.'), +('reload all item',3,'Syntax: .reload all item\nReload page_text, item_enchantment_table tables.'), +('reload all locales',3,'Syntax: .reload all locales\r\n\r\nReload all `locales_*` tables with reload support added and that can be _safe_ reloaded.'), +('reload all loot',3,'Syntax: .reload all loot\r\n\r\nReload all `*_loot_template` tables. This can be slow operation with lags for server run.'), +('reload all npc',3,'Syntax: .reload all npc\nReload npc_gossip, npc_option, npc_trainer, npc vendor, points of interest tables.'), +('reload all quest',3,'Syntax: .reload all quest\r\n\r\nReload all quest related tables if reload support added for this table and this table can be _safe_ reloaded.'), +('reload all scripts',3,'Syntax: .reload all scripts\nReload gameobject_scripts, event_scripts, quest_end_scripts, quest_start_scripts, spell_scripts, db_script_string, waypoint_scripts tables.'), +('reload all spell',3,'Syntax: .reload all spell\r\n\r\nReload all `spell_*` tables with reload support added and that can be _safe_ reloaded.'); + +DELETE FROM `command` WHERE `name` IN ('titles setmask','titles set mask'); +INSERT INTO `command` (`name`, `security`, `help`) VALUES +('titles set mask',2,'Syntax: .titles set mask #mask\r\n\r\nAllows user to use all titles from #mask.\r\n\r\n #mask=0 disables the title-choose-field'); diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index 2aaa3992572..b23f2c824e9 100755 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -160,22 +160,6 @@ ChatCommand * ChatHandler::getCommandTable() { NULL, 0, false, NULL, "", NULL } }; - static ChatCommand gobjectCommandTable[] = - { - { "activate", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleActivateObjectCommand>, "", NULL }, - { "add", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleGameObjectAddCommand>, "", NULL }, - { "delete", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleGameObjectDeleteCommand>, "", NULL }, - { "info", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleGameObjectInfoCommand>, "", NULL }, - { "move", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleGameObjectMoveCommand>, "", NULL }, - { "near", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleGameObjectNearCommand>, "", NULL }, - { "state", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleGameObjectStateCommand>, "", NULL }, - { "setphase", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleGameObjectPhaseCommand>, "", NULL }, - { "target", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleGameObjectTargetCommand>, "", NULL }, - { "tempadd", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleTempGameObjectCommand>, "", NULL }, - { "turn", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleGameObjectTurnCommand>, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand groupCommandTable[] = { { "leader", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleGroupLeaderCommand>, "", NULL }, @@ -194,14 +178,6 @@ ChatCommand * ChatHandler::getCommandTable() { NULL, 0, false, NULL, "", NULL } }; - static ChatCommand honorCommandTable[] = - { - { "add", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleHonorAddCommand>, "", NULL }, - { "addkill", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleHonorAddKillCommand>, "", NULL }, - { "update", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleHonorUpdateCommand>, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand instanceCommandTable[] = { { "listbinds", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleInstanceListBindsCommand>, "", NULL }, @@ -264,124 +240,6 @@ ChatCommand * ChatHandler::getCommandTable() { NULL, 0, false, NULL, "", NULL } }; - static ChatCommand questCommandTable[] = - { - { "add", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleQuestAdd>, "", NULL }, - { "complete", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleQuestComplete>, "", NULL }, - { "remove", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleQuestRemove>, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - - static ChatCommand reloadCommandTable[] = - { - { "all", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllCommand>, "", NULL }, - { "all_achievement",SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllAchievementCommand>,"", NULL }, - { "all_area", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllAreaCommand>, "", NULL }, - { "all_eventai", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllEventAICommand>, "", NULL }, - { "all_gossips", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllGossipsCommand>, "", NULL }, - { "all_item", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllItemCommand>, "", NULL }, - { "all_locales", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllLocalesCommand>, "", NULL }, - { "all_loot", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllLootCommand>, "", NULL }, - { "all_npc", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllNpcCommand>, "", NULL }, - { "all_quest", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllQuestCommand>, "", NULL }, - { "all_scripts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllScriptsCommand>, "", NULL }, - { "all_spell", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllSpellCommand>, "", NULL }, - - { "config", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadConfigCommand>, "", NULL }, - - { "access_requirement", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAccessRequirementCommand>, "", NULL }, - { "achievement_criteria_data", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAchievementCriteriaDataCommand>, "", NULL }, - { "achievement_reward", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAchievementRewardCommand>, "", NULL }, - { "areatrigger_involvedrelation", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadQuestAreaTriggersCommand>, "", NULL }, - { "areatrigger_tavern", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAreaTriggerTavernCommand>, "", NULL }, - { "areatrigger_teleport", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAreaTriggerTeleportCommand>, "", NULL }, - { "autobroadcast", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAutobroadcastCommand>, "", NULL }, - { "command", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadCommandCommand>, "", NULL }, - { "conditions", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadConditions>, "", NULL }, - { "creature_text", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadCreatureText>, "", NULL }, - { "creature_ai_scripts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadEventAIScriptsCommand>, "", NULL }, - { "creature_ai_summons", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadEventAISummonsCommand>, "", NULL }, - { "creature_ai_texts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadEventAITextsCommand>, "", NULL }, - { "creature_involvedrelation", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadCreatureQuestInvRelationsCommand>,"",NULL }, - { "creature_linked_respawn", SEC_GAMEMASTER, true, OldHandler<&ChatHandler::HandleReloadCreatureLinkedRespawnCommand>, "", NULL }, - { "creature_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesCreatureCommand>, "", NULL }, - { "creature_onkill_reputation", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadOnKillReputationCommand>, "", NULL }, - { "creature_questrelation", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadCreatureQuestRelationsCommand>, "", NULL }, - { "creature_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadCreatureTemplateCommand>, "", NULL }, - //{ "db_script_string", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadDbScriptStringCommand>, "", NULL }, - { "disables", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadDisablesCommand>, "", NULL }, - { "disenchant_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesDisenchantCommand>, "", NULL }, - { "event_scripts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadEventScriptsCommand>, "", NULL }, - { "fishing_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesFishingCommand>, "", NULL }, - { "game_graveyard_zone", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadGameGraveyardZoneCommand>, "", NULL }, - { "game_tele", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadGameTeleCommand>, "", NULL }, - { "gameobject_involvedrelation", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadGOQuestInvRelationsCommand>, "", NULL }, - { "gameobject_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesGameobjectCommand>, "", NULL }, - { "gameobject_questrelation", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadGOQuestRelationsCommand>, "", NULL }, - { "gameobject_scripts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadGameObjectScriptsCommand>, "", NULL }, - { "gossip_menu", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadGossipMenuCommand>, "", NULL }, - { "gossip_menu_option", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadGossipMenuOptionCommand>, "", NULL }, - { "gossip_scripts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadGossipScriptsCommand>, "", NULL }, - { "item_enchantment_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadItemEnchantementsCommand>, "", NULL }, - { "item_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesItemCommand>, "", NULL }, - { "item_set_names", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadItemSetNamesCommand>, "", NULL }, - { "lfg_dungeon_encounters", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLfgEncountersCommand>, "", NULL }, - { "lfg_dungeon_rewards", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLfgRewardsCommand>, "", NULL }, - { "locales_achievement_reward", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLocalesAchievementRewardCommand>,"", NULL }, - { "locales_creature", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLocalesCreatureCommand>, "", NULL }, - { "locales_gameobject", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLocalesGameobjectCommand>, "", NULL }, - { "locales_gossip_menu_option", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLocalesGossipMenuOptionCommand>, "", NULL }, - { "locales_item", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLocalesItemCommand>, "", NULL }, - { "locales_item_set_name", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLocalesItemSetNameCommand>, "", NULL }, - { "locales_npc_text", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLocalesNpcTextCommand>, "", NULL }, - { "locales_page_text", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLocalesPageTextCommand>, "", NULL }, - { "locales_points_of_interest", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLocalesPointsOfInterestCommand>, "", NULL }, - { "locales_quest", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLocalesQuestCommand>, "", NULL }, - { "mail_level_reward", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadMailLevelRewardCommand>, "", NULL }, - { "mail_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesMailCommand>, "", NULL }, - { "milling_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesMillingCommand>, "", NULL }, - { "npc_gossip", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadNpcGossipCommand>, "", NULL }, - { "npc_spellclick_spells", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellClickSpellsCommand>, "",NULL}, - { "npc_trainer", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadNpcTrainerCommand>, "", NULL }, - { "npc_vendor", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadNpcVendorCommand>, "", NULL }, - { "page_text", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadPageTextsCommand>, "", NULL }, - { "pickpocketing_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesPickpocketingCommand>,"",NULL}, - { "points_of_interest", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadPointsOfInterestCommand>, "", NULL }, - { "prospecting_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesProspectingCommand>,"", NULL }, - { "quest_end_scripts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadQuestEndScriptsCommand>, "", NULL }, - { "quest_poi", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadQuestPOICommand>, "", NULL }, - { "quest_start_scripts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadQuestStartScriptsCommand>, "", NULL }, - { "quest_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadQuestTemplateCommand>, "", NULL }, - { "reference_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesReferenceCommand>, "", NULL }, - { "reserved_name", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadReservedNameCommand>, "", NULL }, - { "reputation_reward_rate", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadReputationRewardRateCommand>, "", NULL }, - { "reputation_spillover_template",SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadReputationRewardRateCommand>, "", NULL }, - { "smart_scripts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSmartScripts>, "", NULL }, - { "skill_discovery_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSkillDiscoveryTemplateCommand>, "", NULL }, - { "skill_extra_item_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSkillExtraItemTemplateCommand>, "", NULL }, - { "skill_fishing_base_level", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSkillFishingBaseLevelCommand>, "", NULL }, - { "skinning_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesSkinningCommand>, "", NULL }, - { "spell_required", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellRequiredCommand>, "", NULL }, - { "spell_area", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellAreaCommand>, "", NULL }, - { "spell_bonus_data", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellBonusesCommand>, "", NULL }, - { "spell_group", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellGroupsCommand>, "", NULL }, - { "spell_learn_spell", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellLearnSpellCommand>, "", NULL }, - { "spell_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesSpellCommand>, "", NULL }, - { "spell_linked_spell", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellLinkedSpellCommand>, "", NULL }, - { "spell_pet_auras", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellPetAurasCommand>, "", NULL }, - { "spell_proc_event", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellProcEventCommand>, "", NULL }, - { "spell_scripts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellScriptsCommand>, "", NULL }, - { "spell_target_position", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellTargetPositionCommand>, "", NULL }, - { "spell_threats", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellThreatsCommand>, "", NULL }, - { "spell_group_stack_rules", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellGroupStackRulesCommand>, "", NULL }, - { "trinity_string", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadTrinityStringCommand>, "", NULL }, - { "auctions", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAuctionsCommand>, "", NULL }, - { "waypoint_scripts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadWpScriptsCommand>, "", NULL }, - { "gm_tickets", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleGMTicketReloadCommand>, "", NULL }, - - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand resetCommandTable[] = { { "achievements", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleResetAchievementsCommand>, "", NULL }, @@ -456,15 +314,6 @@ ChatCommand * ChatHandler::getCommandTable() { NULL, 0, false, NULL, "", NULL } }; - static ChatCommand titlesCommandTable[] = - { - { "add", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleTitlesAddCommand>, "", NULL }, - { "current", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleTitlesCurrentCommand>, "", NULL }, - { "remove", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleTitlesRemoveCommand>, "", NULL }, - { "setmask", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleTitlesSetMaskCommand>, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand unbanCommandTable[] = { { "account", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleUnBanAccountCommand>, "", NULL }, @@ -474,17 +323,6 @@ ChatCommand * ChatHandler::getCommandTable() { NULL, 0, false, NULL, "", NULL } }; - static ChatCommand wpCommandTable[] = - { - { "show", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleWpShowCommand>, "", NULL }, - { "addwp", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleWpAddCommand>, "", NULL }, - { "load", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleWpLoadPathCommand>, "", NULL }, - { "modify", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleWpModifyCommand>, "", NULL }, - { "event", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleWpEventCommand>, "", NULL }, - { "unload", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleWpUnLoadPathCommand>, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand ticketResponseCommandTable[] = { { "append", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleGMTicketResponseAppendCommand>, "", NULL }, @@ -515,12 +353,6 @@ ChatCommand * ChatHandler::getCommandTable() static ChatCommand commandTable[] = { { "character", SEC_GAMEMASTER, true, NULL, "", characterCommandTable}, - { "gobject", SEC_GAMEMASTER, false, NULL, "", gobjectCommandTable }, - { "honor", SEC_GAMEMASTER, false, NULL, "", honorCommandTable }, - { "wp", SEC_GAMEMASTER, false, NULL, "", wpCommandTable }, - { "titles", SEC_GAMEMASTER, false, NULL, "", titlesCommandTable }, - { "quest", SEC_ADMINISTRATOR, false, NULL, "", questCommandTable }, - { "reload", SEC_ADMINISTRATOR, true, NULL, "", reloadCommandTable }, { "list", SEC_ADMINISTRATOR, true, NULL, "", listCommandTable }, { "lookup", SEC_ADMINISTRATOR, true, NULL, "", lookupCommandTable }, { "pdump", SEC_ADMINISTRATOR, true, NULL, "", pdumpCommandTable }, @@ -533,7 +365,6 @@ ChatCommand * ChatHandler::getCommandTable() { "channel", SEC_ADMINISTRATOR, true, NULL, "", channelCommandTable }, { "pet", SEC_GAMEMASTER, false, NULL, "", petCommandTable }, - { "loadpath", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleReloadAllPaths>, "", NULL }, { "ticket", SEC_MODERATOR, false, NULL, "", ticketCommandTable }, { "aura", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleAuraCommand>, "", NULL }, @@ -613,9 +444,9 @@ ChatCommand * ChatHandler::getCommandTable() // can't use vector as vector storage is implementation-dependent, eg, there can be alignment gaps between elements static ChatCommand* commandTableCache = 0; - if (load_command_table) + if (LoadCommandTable()) { - load_command_table = false; + SetLoadCommandTable(false); { // count total number of top-level commands @@ -891,7 +722,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, co } } // some commands have custom error messages. Don't send the default one in these cases. - else if (!sentErrorMessage) + else if (!HasSentErrorMessage()) { if (!table[i].Help.empty()) SendSysMessage(table[i].Help.c_str()); diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h index 5918e79237a..ceaf8548fe1 100755 --- a/src/server/game/Chat/Chat.h +++ b/src/server/game/Chat/Chat.h @@ -79,7 +79,6 @@ class ChatHandler static ChatCommand* getCommandTable(); bool isValidChatMessage(const char* msg); - bool HasSentErrorMessage() { return sentErrorMessage;} void SendGlobalSysMessage(const char *str); bool hasStringAbbr(const char* name, const char* part); @@ -120,7 +119,10 @@ class ChatHandler GameObject* GetNearbyGameObject(); GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry); + bool HasSentErrorMessage() { return sentErrorMessage;} void SetSentErrorMessage(bool val){ sentErrorMessage = val;}; + static bool LoadCommandTable() { return load_command_table;} + static void SetLoadCommandTable(bool val){ load_command_table = val;}; protected: explicit ChatHandler() : m_session(NULL) {} // for CLI subclass @@ -171,26 +173,12 @@ class ChatHandler bool HandleBindSightCommand(const char* args); bool HandleUnbindSightCommand(const char* args); - bool HandleGameObjectAddCommand(const char* args); - bool HandleGameObjectDeleteCommand(const char* args); - bool HandleGameObjectInfoCommand(const char* args); - bool HandleGameObjectMoveCommand(const char* args); - bool HandleGameObjectNearCommand(const char* args); - bool HandleGameObjectPhaseCommand(const char* args); - bool HandleGameObjectStateCommand(const char* args); - bool HandleGameObjectTargetCommand(const char* args); - bool HandleGameObjectTurnCommand(const char* args); - bool HandleGuildCreateCommand(const char* args); bool HandleGuildInviteCommand(const char* args); bool HandleGuildUninviteCommand(const char* args); bool HandleGuildRankCommand(const char* args); bool HandleGuildDeleteCommand(const char* args); - bool HandleHonorAddCommand(const char* args); - bool HandleHonorAddKillCommand(const char* args); - bool HandleHonorUpdateCommand(const char* args); - bool HandleInstanceListBindsCommand(const char* args); bool HandleInstanceUnbindCommand(const char* args); bool HandleInstanceStatsCommand(const char* args); @@ -222,115 +210,6 @@ class ChatHandler bool HandlePDumpLoadCommand(const char *args); bool HandlePDumpWriteCommand(const char *args); - bool HandleQuestAdd(const char * args); - bool HandleQuestRemove(const char * args); - bool HandleQuestComplete(const char * args); - - bool HandleReloadAllCommand(const char* args); - bool HandleReloadAllAchievementCommand(const char* args); - bool HandleReloadAllAreaCommand(const char* args); - bool HandleReloadAllGossipsCommand(const char* args); - bool HandleReloadAllItemCommand(const char* args); - bool HandleReloadAllLootCommand(const char* args); - bool HandleReloadAllNpcCommand(const char* args); - bool HandleReloadAllQuestCommand(const char* args); - bool HandleReloadAllScriptsCommand(const char* args); - bool HandleReloadAllEventAICommand(const char* args); - bool HandleReloadAllSpellCommand(const char* args); - bool HandleReloadAllLocalesCommand(const char* args); - - bool HandleReloadConfigCommand(const char* args); - - bool HandleReloadAccessRequirementCommand(const char* args); - bool HandleReloadAchievementCriteriaDataCommand(const char* args); - bool HandleReloadAchievementRewardCommand(const char* args); - bool HandleReloadAreaTriggerTavernCommand(const char* args); - bool HandleReloadAreaTriggerTeleportCommand(const char* args); - bool HandleReloadAutobroadcastCommand(const char* args); - bool HandleReloadEventScriptsCommand(const char* args); - bool HandleReloadEventAITextsCommand(const char* args); - bool HandleReloadEventAISummonsCommand(const char* args); - bool HandleReloadEventAIScriptsCommand(const char* args); - bool HandleReloadCommandCommand(const char* args); - bool HandleReloadOnKillReputationCommand(const char* args); - bool HandleReloadCreatureTemplateCommand(const char* args); - bool HandleReloadCreatureQuestRelationsCommand(const char* args); - bool HandleReloadCreatureQuestInvRelationsCommand(const char* args); - bool HandleReloadCreatureLinkedRespawnCommand(const char* args); - bool HandleReloadDbScriptStringCommand(const char* args); - bool HandleReloadGameGraveyardZoneCommand(const char* args); - bool HandleReloadGameObjectScriptsCommand(const char* args); - bool HandleReloadGameTeleCommand(const char* args); - bool HandleReloadGossipMenuCommand(const char* args); - bool HandleReloadGossipMenuOptionCommand(const char* args); - bool HandleReloadGossipScriptsCommand(const char* args); - bool HandleReloadGOQuestRelationsCommand(const char* args); - bool HandleReloadGOQuestInvRelationsCommand(const char* args); - bool HandleReloadItemEnchantementsCommand(const char* args); - bool HandleReloadItemSetNamesCommand(const char* args); - bool HandleReloadLfgEncountersCommand(const char* args); - bool HandleReloadLfgRewardsCommand(const char* args); - bool HandleReloadLocalesAchievementRewardCommand(const char* args); - bool HandleReloadLocalesCreatureCommand(const char* args); - bool HandleReloadLocalesGameobjectCommand(const char* args); - bool HandleReloadLocalesGossipMenuOptionCommand(const char* args); - bool HandleReloadLocalesItemCommand(const char* args); - bool HandleReloadLocalesItemSetNameCommand(const char* args); - bool HandleReloadLocalesNpcTextCommand(const char* args); - bool HandleReloadLocalesPageTextCommand(const char* args); - bool HandleReloadLocalesPointsOfInterestCommand(const char* args); - bool HandleReloadLocalesQuestCommand(const char* args); -// bool HandleReloadAuctionsCommand(const char* args); - bool HandleReloadLootTemplatesCreatureCommand(const char* args); - bool HandleReloadLootTemplatesDisenchantCommand(const char* args); - bool HandleReloadLootTemplatesFishingCommand(const char* args); - bool HandleReloadLootTemplatesGameobjectCommand(const char* args); - bool HandleReloadLootTemplatesItemCommand(const char* args); - bool HandleReloadLootTemplatesMailCommand(const char* args); - bool HandleReloadMailLevelRewardCommand(const char* args); - bool HandleReloadLootTemplatesMillingCommand(const char* args); - bool HandleReloadLootTemplatesPickpocketingCommand(const char* args); - bool HandleReloadLootTemplatesProspectingCommand(const char* args); - bool HandleReloadLootTemplatesReferenceCommand(const char* args); - bool HandleReloadLootTemplatesSkinningCommand(const char* args); - bool HandleReloadLootTemplatesSpellCommand(const char* args); - bool HandleReloadTrinityStringCommand(const char* args); - bool HandleReloadNpcGossipCommand(const char* args); - bool HandleReloadNpcTrainerCommand(const char* args); - bool HandleReloadNpcVendorCommand(const char* args); - bool HandleReloadPageTextsCommand(const char* args); - bool HandleReloadPointsOfInterestCommand(const char* args); - bool HandleReloadSpellClickSpellsCommand(const char* args); - bool HandleReloadQuestAreaTriggersCommand(const char* args); - bool HandleReloadQuestEndScriptsCommand(const char* args); - bool HandleReloadQuestPOICommand(const char* args); - bool HandleReloadQuestStartScriptsCommand(const char* args); - bool HandleReloadQuestTemplateCommand(const char* args); - bool HandleReloadReservedNameCommand(const char*); - bool HandleReloadReputationRewardRateCommand(const char* args); - bool HandleReloadReputationSpilloverTemplateCommand(const char* args); - bool HandleReloadSkillDiscoveryTemplateCommand(const char* args); - bool HandleReloadSkillExtraItemTemplateCommand(const char* args); - bool HandleReloadSkillFishingBaseLevelCommand(const char* args); - bool HandleReloadSpellRequiredCommand(const char* args); - bool HandleReloadSpellAreaCommand(const char* args); - bool HandleReloadSpellGroupsCommand(const char* args); - bool HandleReloadSpellLearnSpellCommand(const char* args); - bool HandleReloadSpellLinkedSpellCommand(const char* args); - bool HandleReloadSpellProcEventCommand(const char* args); - bool HandleReloadSpellBonusesCommand(const char* args); - bool HandleReloadSpellScriptsCommand(const char* args); - bool HandleReloadSpellTargetPositionCommand(const char* args); - bool HandleReloadSpellThreatsCommand(const char* args); - bool HandleReloadSpellPetAurasCommand(const char* args); - bool HandleReloadDisablesCommand(const char* args); - bool HandleReloadSpellGroupStackRulesCommand(const char* args); - bool HandleReloadAuctionsCommand(const char* args); - bool HandleReloadWpScriptsCommand(const char* args); - bool HandleReloadConditions(const char* args); - bool HandleReloadCreatureText(const char* args); - bool HandleReloadSmartScripts(const char* args); - bool HandleResetAchievementsCommand(const char * args); bool HandleResetAllCommand(const char * args); bool HandleResetHonorCommand(const char * args); @@ -361,24 +240,11 @@ class ChatHandler bool HandleServerSetLogFileLevelCommand(const char* args); bool HandleServerSetDiffTimeCommand(const char* args); - bool HandleTitlesAddCommand(const char* args); - bool HandleTitlesCurrentCommand(const char* args); - bool HandleTitlesRemoveCommand(const char* args); - bool HandleTitlesSetMaskCommand(const char* args); - bool HandleUnBanAccountCommand(const char* args); bool HandleUnBanAccountByCharCommand(const char* args); bool HandleUnBanCharacterCommand(const char* args); bool HandleUnBanIPCommand(const char* args); - bool HandleWpAddCommand(const char* args); - bool HandleWpLoadPathCommand(const char* args); - bool HandleWpUnLoadPathCommand(const char* args); - bool HandleWpModifyCommand(const char* args); - bool HandleWpEventCommand(const char* args); - bool HandleWpShowCommand(const char* args); - bool HandleReloadAllPaths(const char *args); - bool HandleHelpCommand(const char* args); bool HandleCommandsCommand(const char* args); bool HandleStartCommand(const char* args); diff --git a/src/server/game/Chat/Commands/Debugcmds.cpp b/src/server/game/Chat/Commands/Debugcmds.cpp index c831fde2ecd..691dab52911 100755 --- a/src/server/game/Chat/Commands/Debugcmds.cpp +++ b/src/server/game/Chat/Commands/Debugcmds.cpp @@ -16,25 +16,4 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "Common.h" -#include "DatabaseEnv.h" -#include "WorldPacket.h" -#include "Vehicle.h" -#include "Player.h" -#include "Opcodes.h" -#include "Chat.h" -#include "Log.h" -#include "Unit.h" -#include "GossipDef.h" -#include "Language.h" -#include "BattlegroundMgr.h" -#include <fstream> -#include "ObjectMgr.h" -#include "Cell.h" -#include "CellImpl.h" -#include "GridNotifiers.h" -#include "GridNotifiersImpl.h" -#include "SpellMgr.h" -#include "ScriptMgr.h" - -// This file is deprecated
\ No newline at end of file +// This file is deprecated diff --git a/src/server/game/Chat/Commands/Level2.cpp b/src/server/game/Chat/Commands/Level2.cpp index e291957cd13..3c7adbb4d5f 100755 --- a/src/server/game/Chat/Commands/Level2.cpp +++ b/src/server/game/Chat/Commands/Level2.cpp @@ -136,442 +136,6 @@ bool ChatHandler::HandleUnmuteCommand(const char* args) return true; } -bool ChatHandler::HandleGameObjectTargetCommand(const char* args) -{ - Player* pl = m_session->GetPlayer(); - QueryResult result; - GameEventMgr::ActiveEvents const& activeEventsList = sGameEventMgr.GetActiveEventList(); - if (*args) - { - // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hgameobject_entry"); - if (!cId) - return false; - - uint32 id = atol(cId); - - if (id) - result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, orientation, map, phaseMask, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE map = '%i' AND id = '%u' ORDER BY order_ ASC LIMIT 1", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),id); - else - { - std::string name = cId; - WorldDatabase.escape_string(name); - result = WorldDatabase.PQuery( - "SELECT guid, id, position_x, position_y, position_z, orientation, map, phaseMask, (POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ " - "FROM gameobject,gameobject_template WHERE gameobject_template.entry = gameobject.id AND map = %i AND name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" ORDER BY order_ ASC LIMIT 1", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),name.c_str()); - } - } - else - { - std::ostringstream eventFilter; - eventFilter << " AND (event IS NULL "; - bool initString = true; - - for (GameEventMgr::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr) - { - if (initString) - { - eventFilter << "OR event IN (" <<*itr; - initString =false; - } - else - eventFilter << "," << *itr; - } - - if (!initString) - eventFilter << "))"; - else - eventFilter << ")"; - - result = WorldDatabase.PQuery("SELECT gameobject.guid, id, position_x, position_y, position_z, orientation, map, phaseMask, " - "(POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ FROM gameobject " - "LEFT OUTER JOIN game_event_gameobject on gameobject.guid=game_event_gameobject.guid WHERE map = '%i' %s ORDER BY order_ ASC LIMIT 10", - m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ(), m_session->GetPlayer()->GetMapId(),eventFilter.str().c_str()); - } - - if (!result) - { - SendSysMessage(LANG_COMMAND_TARGETOBJNOTFOUND); - return true; - } - - bool found = false; - float x, y, z, o; - uint32 lowguid, id; - uint16 mapid, phase; - uint32 pool_id; - - do - { - Field *fields = result->Fetch(); - lowguid = fields[0].GetUInt32(); - id = fields[1].GetUInt32(); - x = fields[2].GetFloat(); - y = fields[3].GetFloat(); - z = fields[4].GetFloat(); - o = fields[5].GetFloat(); - mapid = fields[6].GetUInt16(); - phase = fields[7].GetUInt16(); - pool_id = sPoolMgr.IsPartOfAPool<GameObject>(lowguid); - if (!pool_id || sPoolMgr.IsSpawnedObject<GameObject>(lowguid)) - found = true; - } while (result->NextRow() && (!found)); - - if (!found) - { - PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); - return false; - } - - GameObjectInfo const* goI = sObjectMgr.GetGameObjectInfo(id); - - if (!goI) - { - PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); - return false; - } - - GameObject* target = m_session->GetPlayer()->GetMap()->GetGameObject(MAKE_NEW_GUID(lowguid,id,HIGHGUID_GAMEOBJECT)); - - PSendSysMessage(LANG_GAMEOBJECT_DETAIL, lowguid, goI->name, lowguid, id, x, y, z, mapid, o, phase); - - if (target) - { - int32 curRespawnDelay = int32(target->GetRespawnTimeEx()-time(NULL)); - if (curRespawnDelay < 0) - curRespawnDelay = 0; - - std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay,true); - std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true); - - PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str()); - } - return true; -} - -//delete object by selection or guid -bool ChatHandler::HandleGameObjectDeleteCommand(const char* args) -{ - // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hgameobject"); - if (!cId) - return false; - - uint32 lowguid = atoi(cId); - if (!lowguid) - return false; - - GameObject* obj = NULL; - - // by DB guid - if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) - obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); - - if (!obj) - { - PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - uint64 owner_guid = obj->GetOwnerGUID(); - if (owner_guid) - { - Unit* owner = ObjectAccessor::GetUnit(*m_session->GetPlayer(),owner_guid); - if (!owner || !IS_PLAYER_GUID(owner_guid)) - { - PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(owner_guid), obj->GetGUIDLow()); - SetSentErrorMessage(true); - return false; - } - - owner->RemoveGameObject(obj,false); - } - - obj->SetRespawnTime(0); // not save respawn time - obj->Delete(); - obj->DeleteFromDB(); - - PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, obj->GetGUIDLow()); - - return true; -} - -//turn selected object -bool ChatHandler::HandleGameObjectTurnCommand(const char* args) -{ - // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hgameobject"); - if (!cId) - return false; - - uint32 lowguid = atoi(cId); - if (!lowguid) - return false; - - GameObject* obj = NULL; - - // by DB guid - if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) - obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); - - if (!obj) - { - PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - char* po = strtok(NULL, " "); - float o; - - if (po) - { - o = (float)atof(po); - } - else - { - Player *chr = m_session->GetPlayer(); - o = chr->GetOrientation(); - } - - obj->Relocate(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), o); - obj->UpdateRotationFields(); - obj->DestroyForNearbyPlayers(); - obj->UpdateObjectVisibility(); - - obj->SaveToDB(); - obj->Refresh(); - - PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name, obj->GetGUIDLow(), o); - - return true; -} - -//move selected object -bool ChatHandler::HandleGameObjectMoveCommand(const char* args) -{ - // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hgameobject"); - if (!cId) - return false; - - uint32 lowguid = atoi(cId); - if (!lowguid) - return false; - - GameObject* obj = NULL; - - // by DB guid - if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) - obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); - - if (!obj) - { - PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - char* px = strtok(NULL, " "); - char* py = strtok(NULL, " "); - char* pz = strtok(NULL, " "); - - if (!px) - { - Player *chr = m_session->GetPlayer(); - obj->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), obj->GetOrientation()); - obj->DestroyForNearbyPlayers(); - obj->UpdateObjectVisibility(); - } - else - { - if (!py || !pz) - return false; - - float x = (float)atof(px); - float y = (float)atof(py); - float z = (float)atof(pz); - - if (!MapManager::IsValidMapCoord(obj->GetMapId(),x,y,z)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,obj->GetMapId()); - SetSentErrorMessage(true); - return false; - } - - obj->Relocate(x, y, z, obj->GetOrientation()); - obj->DestroyForNearbyPlayers(); - obj->UpdateObjectVisibility(); - } - - obj->SaveToDB(); - obj->Refresh(); - - PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name, obj->GetGUIDLow()); - - return true; -} - -//spawn go -bool ChatHandler::HandleGameObjectAddCommand(const char* args) -{ - if (!*args) - return false; - - // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hgameobject_entry"); - if (!cId) - return false; - - uint32 id = atol(cId); - if (!id) - return false; - - char* spawntimeSecs = strtok(NULL, " "); - - const GameObjectInfo *gInfo = sObjectMgr.GetGameObjectInfo(id); - - if (!gInfo) - { - PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); - SetSentErrorMessage(true); - return false; - } - - if (gInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(gInfo->displayId)) - { - // report to DB errors log as in loading case - sLog.outErrorDb("Gameobject (Entry %u GoType: %u) have invalid displayId (%u), not spawned.",id, gInfo->type, gInfo->displayId); - PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA,id); - SetSentErrorMessage(true); - return false; - } - - Player *chr = m_session->GetPlayer(); - float x = float(chr->GetPositionX()); - float y = float(chr->GetPositionY()); - float z = float(chr->GetPositionZ()); - float o = float(chr->GetOrientation()); - Map *map = chr->GetMap(); - - GameObject* pGameObj = new GameObject; - uint32 db_lowGUID = sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT); - - if (!pGameObj->Create(db_lowGUID, gInfo->id, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY)) - { - delete pGameObj; - return false; - } - - if (spawntimeSecs) - { - uint32 value = atoi((char*)spawntimeSecs); - pGameObj->SetRespawnTime(value); - //sLog.outDebug("*** spawntimeSecs: %d", value); - } - - // fill the gameobject data and save to the db - pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()),chr->GetPhaseMaskForSpawn()); - - // this will generate a new guid if the object is in an instance - if (!pGameObj->LoadFromDB(db_lowGUID, map)) - { - delete pGameObj; - return false; - } - - sLog.outDebug(GetTrinityString(LANG_GAMEOBJECT_CURRENT), gInfo->name, db_lowGUID, x, y, z, o); - - map->Add(pGameObj); - - // TODO: is it really necessary to add both the real and DB table guid here ? - sObjectMgr.AddGameobjectToGrid(db_lowGUID, sObjectMgr.GetGOData(db_lowGUID)); - - PSendSysMessage(LANG_GAMEOBJECT_ADD,id,gInfo->name,db_lowGUID,x,y,z); - return true; -} - -//set pahsemask for selected object -bool ChatHandler::HandleGameObjectPhaseCommand(const char* args) -{ - // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hgameobject"); - if (!cId) - return false; - - uint32 lowguid = atoi(cId); - if (!lowguid) - return false; - - GameObject* obj = NULL; - - // by DB guid - if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) - obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); - - if (!obj) - { - PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - char* phaseStr = strtok (NULL, " "); - uint32 phasemask = phaseStr? atoi(phaseStr) : 0; - if (phasemask == 0) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - obj->SetPhaseMask(phasemask,true); - obj->SaveToDB(); - return true; -} - -bool ChatHandler::HandleGameObjectNearCommand(const char* args) -{ - float distance = (!*args) ? 10.0f : (float)(atof(args)); - uint32 count = 0; - - Player* pl = m_session->GetPlayer(); - QueryResult result = WorldDatabase.PQuery("SELECT guid, id, 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 map='%u' AND (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) <= '%f' ORDER BY order_", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), - pl->GetMapId(),pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),distance*distance); - - if (result) - { - do - { - Field *fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); - uint32 entry = fields[1].GetUInt32(); - float x = fields[2].GetFloat(); - float y = fields[3].GetFloat(); - float z = fields[4].GetFloat(); - int mapid = fields[5].GetUInt16(); - - GameObjectInfo const * gInfo = sObjectMgr.GetGameObjectInfo(entry); - - if (!gInfo) - continue; - - PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name, x, y, z, mapid); - - ++count; - } while (result->NextRow()); - } - - PSendSysMessage(LANG_COMMAND_NEAROBJMESSAGE,distance,count); - return true; -} - bool ChatHandler::HandleGUIDCommand(const char* /*args*/) { uint64 guid = m_session->GetPlayer()->GetSelection(); @@ -754,45 +318,6 @@ bool ChatHandler::HandleKickPlayerCommand(const char *args) return true; } -//show info of gameobject -bool ChatHandler::HandleGameObjectInfoCommand(const char* args) -{ - uint32 entry = 0; - uint32 type = 0; - uint32 displayid = 0; - std::string name; - uint32 lootId = 0; - - if (!*args) - { - if (WorldObject * obj = getSelectedObject()) - entry = obj->GetEntry(); - } - else - entry = atoi((char*)args); - - GameObjectInfo const* goinfo = sObjectMgr.GetGameObjectInfo(entry); - - if (!goinfo) - return false; - - type = goinfo->type; - displayid = goinfo->displayId; - name = goinfo->name; - if (type == GAMEOBJECT_TYPE_CHEST) - lootId = goinfo->chest.lootId; - else if (type == GAMEOBJECT_TYPE_FISHINGHOLE) - lootId = goinfo->fishinghole.lootId; - - PSendSysMessage(LANG_GOINFO_ENTRY, entry); - PSendSysMessage(LANG_GOINFO_TYPE, type); - PSendSysMessage(LANG_GOINFO_LOOTID, lootId); - PSendSysMessage(LANG_GOINFO_DISPLAYID, displayid); - PSendSysMessage(LANG_GOINFO_NAME, name.c_str()); - - return true; -} - //show info of player bool ChatHandler::HandlePInfoCommand(const char* args) { @@ -920,931 +445,6 @@ bool ChatHandler::HandlePInfoCommand(const char* args) return true; } -/////WAYPOINT COMMANDS - -/** - * Add a waypoint to a creature. - * - * The user can either select an npc or provide its GUID. - * - * The user can even select a visual waypoint - then the new waypoint - * is placed *after* the selected one - this makes insertion of new - * waypoints possible. - * - * eg: - * .wp add 12345 - * -> adds a waypoint to the npc with the GUID 12345 - * - * .wp add - * -> adds a waypoint to the currently selected creature - * - * - * @param args if the user did not provide a GUID, it is NULL - * - * @return true - command did succeed, false - something went wrong - */ -bool ChatHandler::HandleWpAddCommand(const char* args) -{ - sLog.outDebug("DEBUG: HandleWpAddCommand"); - - // optional - char* path_number = NULL; - uint32 pathid = 0; - - if (*args) - path_number = strtok((char*)args, " "); - - uint32 point = 0; - Creature* target = getSelectedCreature(); - - if (!path_number) - { - if (target) - pathid = target->GetWaypointPath(); - else - { - QueryResult result = WorldDatabase.Query("SELECT MAX(id) FROM waypoint_data"); - uint32 maxpathid = result->Fetch()->GetInt32(); - pathid = maxpathid+1; - sLog.outDebug("DEBUG: HandleWpAddCommand - New path started."); - PSendSysMessage("%s%s|r", "|cff00ff00", "New path started."); - } - } - else - pathid = atoi(path_number); - - // path_id -> ID of the Path - // point -> number of the waypoint (if not 0) - - if (!pathid) - { - sLog.outDebug("DEBUG: HandleWpAddCommand - Current creature haven't loaded path."); - PSendSysMessage("%s%s|r", "|cffff33ff", "Current creature haven't loaded path."); - return true; - } - - sLog.outDebug("DEBUG: HandleWpAddCommand - point == 0"); - - QueryResult result = WorldDatabase.PQuery("SELECT MAX(point) FROM waypoint_data WHERE id = '%u'",pathid); - - if (result) - point = (*result)[0].GetUInt32(); - - Player* player = m_session->GetPlayer(); - //Map *map = player->GetMap(); - - WorldDatabase.PExecute("INSERT INTO waypoint_data (id, point, position_x, position_y, position_z) VALUES ('%u','%u','%f', '%f', '%f')", - pathid, point+1, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); - - PSendSysMessage("%s%s%u%s%u%s|r", "|cff00ff00", "PathID: |r|cff00ffff", pathid, "|r|cff00ff00: Waypoint |r|cff00ffff", point+1,"|r|cff00ff00 created. "); - return true; -} // HandleWpAddCommand - -bool ChatHandler::HandleWpLoadPathCommand(const char *args) -{ - if (!*args) - return false; - - // optional - char* path_number = NULL; - - if (*args) - path_number = strtok((char*)args, " "); - - uint32 pathid = 0; - uint32 guidlow = 0; - Creature* target = getSelectedCreature(); - - // Did player provide a path_id? - if (!path_number) - sLog.outDebug("DEBUG: HandleWpLoadPathCommand - No path number provided"); - - if (!target) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - if (target->GetEntry() == 1) - { - PSendSysMessage("%s%s|r", "|cffff33ff", "You want to load path to a waypoint? Aren't you?"); - SetSentErrorMessage(true); - return false; - } - - pathid = atoi(path_number); - - if (!pathid) - { - PSendSysMessage("%s%s|r", "|cffff33ff", "No vallid path number provided."); - return true; - } - - guidlow = target->GetDBTableGUIDLow(); - QueryResult result = WorldDatabase.PQuery("SELECT guid FROM creature_addon WHERE guid = '%u'",guidlow); - - if (result) - WorldDatabase.PExecute("UPDATE creature_addon SET path_id = '%u' WHERE guid = '%u'", pathid, guidlow); - else - WorldDatabase.PExecute("INSERT INTO creature_addon(guid,path_id) VALUES ('%u','%u')", guidlow, pathid); - - WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE, guidlow); - - target->LoadPath(pathid); - target->SetDefaultMovementType(WAYPOINT_MOTION_TYPE); - target->GetMotionMaster()->Initialize(); - target->MonsterSay("Path loaded.",0,0); - - return true; -} - -bool ChatHandler::HandleReloadAllPaths(const char* args) -{ - if (!*args) - return false; - - uint32 id = atoi(args); - - if (!id) - return false; - - PSendSysMessage("%s%s|r|cff00ffff%u|r", "|cff00ff00", "Loading Path: ", id); - sWaypointMgr->UpdatePath(id); - return true; -} - -bool ChatHandler::HandleWpUnLoadPathCommand(const char * /*args*/) -{ - uint32 guidlow = 0; - Creature* target = getSelectedCreature(); - - if (!target) - { - PSendSysMessage("%s%s|r", "|cff33ffff", "You must select target."); - return true; - } - - if (target->GetCreatureAddon()) - { - if (target->GetCreatureAddon()->path_id != 0) - { - WorldDatabase.PExecute("DELETE FROM creature_addon WHERE guid = %u", target->GetGUIDLow()); - target->UpdateWaypointID(0); - WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", IDLE_MOTION_TYPE, guidlow); - target->LoadPath(0); - target->SetDefaultMovementType(IDLE_MOTION_TYPE); - target->GetMotionMaster()->MoveTargetedHome(); - target->GetMotionMaster()->Initialize(); - target->MonsterSay("Path unloaded.",0,0); - return true; - } - PSendSysMessage("%s%s|r", "|cffff33ff", "Target have no loaded path."); - } - return true; -} - -bool ChatHandler::HandleWpEventCommand(const char* args) -{ - if (!*args) - return false; - - char* show_str = strtok((char*)args, " "); - std::string show = show_str; - - // Check - if ((show != "add") && (show != "mod") && (show != "del") && (show != "listid")) return false; - - char* arg_id = strtok(NULL, " "); - uint32 id = 0; - - if (show == "add") - { - if (arg_id) - id = atoi(arg_id); - - if (id) - { - QueryResult result = WorldDatabase.PQuery("SELECT id FROM waypoint_scripts WHERE guid = %u", id); - - if (!result) - { - WorldDatabase.PExecute("INSERT INTO waypoint_scripts(guid)VALUES(%u)", id); - PSendSysMessage("%s%s%u|r", "|cff00ff00", "Wp Event: New waypoint event added: ", id); - } - else - PSendSysMessage("|cff00ff00Wp Event: You have choosed an existing waypoint script guid: %u|r", id); - } - else - { - QueryResult result = WorldDatabase.Query("SELECT MAX(guid) FROM waypoint_scripts"); - id = result->Fetch()->GetUInt32(); - WorldDatabase.PExecute("INSERT INTO waypoint_scripts(guid)VALUES(%u)", id+1); - PSendSysMessage("%s%s%u|r", "|cff00ff00","Wp Event: New waypoint event added: |r|cff00ffff", id+1); - } - - return true; - } - - if (show == "listid") - { - if (!arg_id) - { - PSendSysMessage("%s%s|r", "|cff33ffff","Wp Event: You must provide waypoint script id."); - return true; - } - - id = atoi(arg_id); - - uint32 a2, a3, a4, a5, a6; - float a8, a9, a10, a11; - char const* a7; - - QueryResult result = WorldDatabase.PQuery("SELECT guid, delay, command, datalong, datalong2, dataint, x, y, z, o FROM waypoint_scripts WHERE id = %u", id); - - if (!result) - { - PSendSysMessage("%s%s%u|r", "|cff33ffff", "Wp Event: No waypoint scripts found on id: ", id); - return true; - } - - Field *fields; - - do - { - fields = result->Fetch(); - a2 = fields[0].GetUInt32(); - a3 = fields[1].GetUInt32(); - a4 = fields[2].GetUInt32(); - a5 = fields[3].GetUInt32(); - a6 = fields[4].GetUInt32(); - a7 = fields[5].GetCString(); - a8 = fields[6].GetFloat(); - a9 = fields[7].GetFloat(); - a10 = fields[8].GetFloat(); - a11 = fields[9].GetFloat(); - - PSendSysMessage("|cffff33ffid:|r|cff00ffff %u|r|cff00ff00, guid: |r|cff00ffff%u|r|cff00ff00, delay: |r|cff00ffff%u|r|cff00ff00, command: |r|cff00ffff%u|r|cff00ff00, datalong: |r|cff00ffff%u|r|cff00ff00, datalong2: |r|cff00ffff%u|r|cff00ff00, datatext: |r|cff00ffff%s|r|cff00ff00, posx: |r|cff00ffff%f|r|cff00ff00, posy: |r|cff00ffff%f|r|cff00ff00, posz: |r|cff00ffff%f|r|cff00ff00, orientation: |r|cff00ffff%f|r", id, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); - } - while (result->NextRow()); - } - - if (show == "del") - { - id = atoi(arg_id); - - QueryResult result = WorldDatabase.PQuery("SELECT guid FROM waypoint_scripts WHERE guid = %u", id); - - if (result) - { - WorldDatabase.PExecute("DELETE FROM waypoint_scripts WHERE guid = %u", id); - PSendSysMessage("%s%s%u|r","|cff00ff00","Wp Event: Waypoint script removed: ", id); - } - else - PSendSysMessage("|cffff33ffWp Event: ERROR: you have selected a non existing script: %u|r", id); - - return true; - } - - if (show == "mod") - { - if (!arg_id) - { - SendSysMessage("|cffff33ffERROR: Waypoint script guid not present.|r"); - return true; - } - - id = atoi(arg_id); - - if (!id) - { - SendSysMessage("|cffff33ffERROR: No vallid waypoint script id not present.|r"); - return true; - } - - char* arg_2 = strtok(NULL," "); - - if (!arg_2) - { - SendSysMessage("|cffff33ffERROR: No argument present.|r"); - return true; - } - - std::string arg_string = arg_2; - - if ((arg_string != "setid") && (arg_string != "delay") && (arg_string != "command") - && (arg_string != "datalong") && (arg_string != "datalong2") && (arg_string != "dataint") && (arg_string != "posx") - && (arg_string != "posy") && (arg_string != "posz") && (arg_string != "orientation")) - { - SendSysMessage("|cffff33ffERROR: No valid argument present.|r"); - return true; - } - - char* arg_3; - std::string arg_str_2 = arg_2; - arg_3 = strtok(NULL," "); - - if (!arg_3) - { - SendSysMessage("|cffff33ffERROR: No additional argument present.|r"); - return true; - } - - float coord; - - if (arg_str_2 == "setid") - { - uint32 newid = atoi(arg_3); - PSendSysMessage("%s%s|r|cff00ffff%u|r|cff00ff00%s|r|cff00ffff%u|r","|cff00ff00","Wp Event: Wypoint scipt guid: ", newid," id changed: ", id); - WorldDatabase.PExecute("UPDATE waypoint_scripts SET id='%u' WHERE guid='%u'", - newid, id); return true; - } - else - { - QueryResult result = WorldDatabase.PQuery("SELECT id FROM waypoint_scripts WHERE guid='%u'",id); - - if (!result) - { - SendSysMessage("|cffff33ffERROR: You have selected an non existing waypoint script guid.|r"); - return true; - } - - if (arg_str_2 == "posx") - { - coord = (float)(atof(arg_3)); - WorldDatabase.PExecute("UPDATE waypoint_scripts SET x='%f' WHERE guid='%u'", - coord, id); - PSendSysMessage("|cff00ff00Waypoint script:|r|cff00ffff %u|r|cff00ff00 position_x updated.|r", id); - return true; - } - else if (arg_str_2 == "posy") - { - coord = (float)(atof(arg_3)); - WorldDatabase.PExecute("UPDATE waypoint_scripts SET y='%f' WHERE guid='%u'", - coord, id); - PSendSysMessage("|cff00ff00Waypoint script: %u position_y updated.|r", id); - return true; - } - else if (arg_str_2 == "posz") - { - coord = (float)(atof(arg_3)); - WorldDatabase.PExecute("UPDATE waypoint_scripts SET z='%f' WHERE guid='%u'", - coord, id); - PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 position_z updated.|r", id); - return true; - } - else if (arg_str_2 == "orientation") - { - coord = (float)(atof(arg_3)); - WorldDatabase.PExecute("UPDATE waypoint_scripts SET o='%f' WHERE guid='%u'", - coord, id); - PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 orientation updated.|r", id); - return true; - } - else if (arg_str_2 == "dataint") - { - WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%u' WHERE guid='%u'", - arg_2, atoi(arg_3), id); - PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 dataint updated.|r", id); - return true; - } - else - { - std::string arg_str_3 = arg_3; - WorldDatabase.escape_string(arg_str_3); - WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%s' WHERE guid='%u'", - arg_2, arg_str_3.c_str(), id); - } - } - PSendSysMessage("%s%s|r|cff00ffff%u:|r|cff00ff00 %s %s|r","|cff00ff00","Waypoint script:", id, arg_2,"updated."); - } - return true; -} - -bool ChatHandler::HandleWpModifyCommand(const char* args) -{ - sLog.outDebug("DEBUG: HandleWpModifyCommand"); - - if (!*args) - return false; - - // first arg: add del text emote spell waittime move - char* show_str = strtok((char*)args, " "); - if (!show_str) - { - return false; - } - - std::string show = show_str; - // Check - // Remember: "show" must also be the name of a column! - if ((show != "delay") && (show != "action") && (show != "action_chance") - && (show != "move_flag") && (show != "del") && (show != "move") && (show != "wpadd") -) - { - return false; - } - - // Next arg is: <PATHID> <WPNUM> <ARGUMENT> - char* arg_str = NULL; - - // Did user provide a GUID - // or did the user select a creature? - // -> variable lowguid is filled with the GUID of the NPC - uint32 pathid = 0; - uint32 point = 0; - uint32 wpGuid = 0; - Creature* target = getSelectedCreature(); - - if (!target || target->GetEntry() != VISUAL_WAYPOINT) - { - SendSysMessage("|cffff33ffERROR: You must select a waypoint.|r"); - return false; - } - - sLog.outDebug("DEBUG: HandleWpModifyCommand - User did select an NPC"); - // The visual waypoint - Creature* wpCreature = NULL; - wpGuid = target->GetGUIDLow(); - - // Did the user select a visual spawnpoint? - if (wpGuid) - wpCreature = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); - // attempt check creature existence by DB data - else - { - PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, wpGuid); - return false; - } - // User did select a visual waypoint? - // Check the creature - if (wpCreature->GetEntry() == VISUAL_WAYPOINT) - { - QueryResult result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE wpguid = %u", wpGuid); - - if (!result) - { - sLog.outDebug("DEBUG: HandleWpModifyCommand - No waypoint found - used 'wpguid'"); - - PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUIDLow()); - // Select waypoint number from database - // Since we compare float values, we have to deal with - // some difficulties. - // Here we search for all waypoints that only differ in one from 1 thousand - // (0.001) - There is no other way to compare C++ floats with mySQL floats - // See also: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html - const char* maxDIFF = "0.01"; - result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE (abs(position_x - %f) <= %s) and (abs(position_y - %f) <= %s) and (abs(position_z - %f) <= %s)", - wpCreature->GetPositionX(), maxDIFF, wpCreature->GetPositionY(), maxDIFF, wpCreature->GetPositionZ(), maxDIFF); - if (!result) - { - PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid); - return true; - } - } - sLog.outDebug("DEBUG: HandleWpModifyCommand - After getting wpGuid"); - - do - { - Field *fields = result->Fetch(); - pathid = fields[0].GetUInt32(); - point = fields[1].GetUInt32(); - } - while (result->NextRow()); - - // We have the waypoint number and the GUID of the "master npc" - // Text is enclosed in "<>", all other arguments not - arg_str = strtok((char*)NULL, " "); - } - - sLog.outDebug("DEBUG: HandleWpModifyCommand - Parameters parsed - now execute the command"); - - // Check for argument - if (show != "del" && show != "move" && arg_str == NULL) - { - PSendSysMessage(LANG_WAYPOINT_ARGUMENTREQ, show_str); - return false; - } - - if (show == "del" && target) - { - PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid); - - // wpCreature - Creature* wpCreature = NULL; - - if (wpGuid != 0) - { - wpCreature = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); - wpCreature->CombatStop(); - wpCreature->DeleteFromDB(); - wpCreature->AddObjectToRemoveList(); - } - - WorldDatabase.PExecute("DELETE FROM waypoint_data WHERE id='%u' AND point='%u'", - pathid, point); - WorldDatabase.PExecute("UPDATE waypoint_data SET point=point-1 WHERE id='%u' AND point>'%u'", - pathid, point); - - PSendSysMessage(LANG_WAYPOINT_REMOVED); - return true; - } // del - - if (show == "move" && target) - { - PSendSysMessage("|cff00ff00DEBUG: wp move, PathID: |r|cff00ffff%u|r", pathid); - - Player *chr = m_session->GetPlayer(); - Map *map = chr->GetMap(); - { - // wpCreature - Creature* wpCreature = NULL; - // What to do: - // Move the visual spawnpoint - // Respawn the owner of the waypoints - if (wpGuid != 0) - { - wpCreature = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); - wpCreature->CombatStop(); - wpCreature->DeleteFromDB(); - wpCreature->AddObjectToRemoveList(); - // re-create - Creature* wpCreature2 = new Creature; - if (!wpCreature2->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0, 0, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation())) - { - PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT); - delete wpCreature2; - return false; - } - - wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); - // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); - wpCreature2->LoadFromDB(wpCreature2->GetDBTableGUIDLow(), map); - map->Add(wpCreature2); - //sMapMgr.GetMap(npcCreature->GetMapId())->Add(wpCreature2); - } - - WorldDatabase.PExecute("UPDATE waypoint_data SET position_x = '%f',position_y = '%f',position_z = '%f' where id = '%u' AND point='%u'", - chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), pathid, point); - - PSendSysMessage(LANG_WAYPOINT_CHANGED); - } - return true; - } // move - - const char *text = arg_str; - - if (text == 0) - { - // show_str check for present in list of correct values, no sql injection possible - WorldDatabase.PExecute("UPDATE waypoint_data SET %s=NULL WHERE id='%u' AND point='%u'", - show_str, pathid, point); - } - else - { - // show_str check for present in list of correct values, no sql injection possible - std::string text2 = text; - WorldDatabase.escape_string(text2); - WorldDatabase.PExecute("UPDATE waypoint_data SET %s='%s' WHERE id='%u' AND point='%u'", - show_str, text2.c_str(), pathid, point); - } - - PSendSysMessage(LANG_WAYPOINT_CHANGED_NO, show_str); - return true; -} - -bool ChatHandler::HandleWpShowCommand(const char* args) -{ - sLog.outDebug("DEBUG: HandleWpShowCommand"); - - if (!*args) - return false; - - // first arg: on, off, first, last - char* show_str = strtok((char*)args, " "); - if (!show_str) - return false; - - // second arg: GUID (optional, if a creature is selected) - char* guid_str = strtok((char*)NULL, " "); - sLog.outDebug("DEBUG: HandleWpShowCommand: show_str: %s guid_str: %s", show_str, guid_str); - - uint32 pathid = 0; - Creature* target = getSelectedCreature(); - - // Did player provide a PathID? - - if (!guid_str) - { - sLog.outDebug("DEBUG: HandleWpShowCommand: !guid_str"); - // No PathID provided - // -> Player must have selected a creature - - if (!target) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - pathid = target->GetWaypointPath(); - } - else - { - sLog.outDebug("|cff00ff00DEBUG: HandleWpShowCommand: PathID provided|r"); - // PathID provided - // Warn if player also selected a creature - // -> Creature selection is ignored <- - if (target) - SendSysMessage(LANG_WAYPOINT_CREATSELECTED); - - pathid = atoi((char*)guid_str); - } - - sLog.outDebug("DEBUG: HandleWpShowCommand: danach"); - - std::string show = show_str; - uint32 Maxpoint; - - sLog.outDebug("DEBUG: HandleWpShowCommand: PathID: %u", pathid); - - //PSendSysMessage("wpshow - show: %s", show); - - // Show info for the selected waypoint - if (show == "info") - { - // Check if the user did specify a visual waypoint - if (target->GetEntry() != VISUAL_WAYPOINT) - { - PSendSysMessage(LANG_WAYPOINT_VP_SELECT); - SetSentErrorMessage(true); - return false; - } - - QueryResult result = WorldDatabase.PQuery("SELECT id, point, delay, move_flag, action, action_chance FROM waypoint_data WHERE wpguid = %u", target->GetGUIDLow()); - - if (!result) - { - SendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM); - return true; - } - - SendSysMessage("|cff00ffffDEBUG: wp show info:|r"); - do - { - Field *fields = result->Fetch(); - pathid = fields[0].GetUInt32(); - uint32 point = fields[1].GetUInt32(); - uint32 delay = fields[2].GetUInt32(); - uint32 flag = fields[3].GetUInt32(); - uint32 ev_id = fields[4].GetUInt32(); - uint32 ev_chance = fields[5].GetUInt32(); - - PSendSysMessage("|cff00ff00Show info: for current point: |r|cff00ffff%u|r|cff00ff00, Path ID: |r|cff00ffff%u|r", point, pathid); - PSendSysMessage("|cff00ff00Show info: delay: |r|cff00ffff%u|r", delay); - PSendSysMessage("|cff00ff00Show info: Move flag: |r|cff00ffff%u|r", flag); - PSendSysMessage("|cff00ff00Show info: Waypoint event: |r|cff00ffff%u|r", ev_id); - PSendSysMessage("|cff00ff00Show info: Event chance: |r|cff00ffff%u|r", ev_chance); - } - while (result->NextRow()); - - return true; - } - - if (show == "on") - { - QueryResult result = WorldDatabase.PQuery("SELECT point, position_x,position_y,position_z FROM waypoint_data WHERE id = '%u'", pathid); - - if (!result) - { - SendSysMessage("|cffff33ffPath no found.|r"); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage("|cff00ff00DEBUG: wp on, PathID: |cff00ffff%u|r", pathid); - - // Delete all visuals for this NPC - QueryResult result2 = WorldDatabase.PQuery("SELECT wpguid FROM waypoint_data WHERE id = '%u' and wpguid <> 0", pathid); - - if (result2) - { - bool hasError = false; - do - { - Field *fields = result2->Fetch(); - uint32 wpguid = fields[0].GetUInt32(); - Creature* pCreature = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpguid,VISUAL_WAYPOINT,HIGHGUID_UNIT)); - - if (!pCreature) - { - PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, wpguid); - hasError = true; - WorldDatabase.PExecute("DELETE FROM creature WHERE guid = '%u'", wpguid); - } - else - { - pCreature->CombatStop(); - pCreature->DeleteFromDB(); - pCreature->AddObjectToRemoveList(); - } - - } - while (result2->NextRow()); - - if (hasError) - { - PSendSysMessage(LANG_WAYPOINT_TOOFAR1); - PSendSysMessage(LANG_WAYPOINT_TOOFAR2); - PSendSysMessage(LANG_WAYPOINT_TOOFAR3); - } - } - - do - { - Field *fields = result->Fetch(); - uint32 point = fields[0].GetUInt32(); - float x = fields[1].GetFloat(); - float y = fields[2].GetFloat(); - float z = fields[3].GetFloat(); - - uint32 id = VISUAL_WAYPOINT; - - Player *chr = m_session->GetPlayer(); - Map *map = chr->GetMap(); - float o = chr->GetOrientation(); - - Creature* wpCreature = new Creature; - if (!wpCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o)) - { - PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); - delete wpCreature; - return false; - } - - sLog.outDebug("DEBUG: UPDATE waypoint_data SET wpguid = '%u' WHERE id = '%u' and point = '%u'", wpCreature->GetGUIDLow(), pathid, point); - // set "wpguid" column to the visual waypoint - WorldDatabase.PExecute("UPDATE waypoint_data SET wpguid = '%u' WHERE id = '%u' and point = '%u'", wpCreature->GetGUIDLow(), pathid, point); - - wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); - // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); - wpCreature->LoadFromDB(wpCreature->GetDBTableGUIDLow(),map); - map->Add(wpCreature); - - if (target) - { - wpCreature->SetDisplayId(target->GetDisplayId()); - wpCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5); - wpCreature->SetLevel(point > STRONG_MAX_LEVEL ? STRONG_MAX_LEVEL : point); - } - } - while (result->NextRow()); - - SendSysMessage("|cff00ff00Showing the current creature's path.|r"); - return true; - } - - if (show == "first") - { - PSendSysMessage("|cff00ff00DEBUG: wp first, GUID: %u|r", pathid); - - QueryResult result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z FROM waypoint_data WHERE point='1' AND id = '%u'",pathid); - if (!result) - { - PSendSysMessage(LANG_WAYPOINT_NOTFOUND, pathid); - SetSentErrorMessage(true); - return false; - } - - Field *fields = result->Fetch(); - float x = fields[0].GetFloat(); - float y = fields[1].GetFloat(); - float z = fields[2].GetFloat(); - uint32 id = VISUAL_WAYPOINT; - - Player *chr = m_session->GetPlayer(); - float o = chr->GetOrientation(); - Map *map = chr->GetMap(); - - Creature* pCreature = new Creature; - if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT),map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o)) - { - PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); - delete pCreature; - return false; - } - - pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); - pCreature->LoadFromDB(pCreature->GetDBTableGUIDLow(), map); - map->Add(pCreature); - - if (target) - { - pCreature->SetDisplayId(target->GetDisplayId()); - pCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5); - } - - return true; - } - - if (show == "last") - { - PSendSysMessage("|cff00ff00DEBUG: wp last, PathID: |r|cff00ffff%u|r", pathid); - - QueryResult result = WorldDatabase.PQuery("SELECT MAX(point) FROM waypoint_data WHERE id = '%u'",pathid); - if (result) - Maxpoint = (*result)[0].GetUInt32(); - else - Maxpoint = 0; - - result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z FROM waypoint_data WHERE point ='%u' AND id = '%u'",Maxpoint, pathid); - if (!result) - { - PSendSysMessage(LANG_WAYPOINT_NOTFOUNDLAST, pathid); - SetSentErrorMessage(true); - return false; - } - Field *fields = result->Fetch(); - float x = fields[0].GetFloat(); - float y = fields[1].GetFloat(); - float z = fields[2].GetFloat(); - uint32 id = VISUAL_WAYPOINT; - - Player *chr = m_session->GetPlayer(); - float o = chr->GetOrientation(); - Map *map = chr->GetMap(); - - Creature* pCreature = new Creature; - if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o)) - { - PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id); - delete pCreature; - return false; - } - - pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); - pCreature->LoadFromDB(pCreature->GetDBTableGUIDLow(), map); - map->Add(pCreature); - - if (target) - { - pCreature->SetDisplayId(target->GetDisplayId()); - pCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5); - } - - return true; - } - - if (show == "off") - { - QueryResult result = WorldDatabase.PQuery("SELECT guid FROM creature WHERE id = '%u'", 1); - if (!result) - { - SendSysMessage(LANG_WAYPOINT_VP_NOTFOUND); - SetSentErrorMessage(true); - return false; - } - bool hasError = false; - do - { - Field *fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); - Creature* pCreature = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(guid,VISUAL_WAYPOINT,HIGHGUID_UNIT)); - if (!pCreature) - { - PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, guid); - hasError = true; - WorldDatabase.PExecute("DELETE FROM creature WHERE guid = '%u'", guid); - } - else - { - pCreature->CombatStop(); - pCreature->DeleteFromDB(); - pCreature->AddObjectToRemoveList(); - } - } - while (result->NextRow()); - // set "wpguid" column to "empty" - no visual waypoint spawned - WorldDatabase.PExecute("UPDATE waypoint_data SET wpguid = '0'"); - //WorldDatabase.PExecute("UPDATE creature_movement SET wpguid = '0' WHERE wpguid <> '0'"); - - if (hasError) - { - PSendSysMessage(LANG_WAYPOINT_TOOFAR1); - PSendSysMessage(LANG_WAYPOINT_TOOFAR2); - PSendSysMessage(LANG_WAYPOINT_TOOFAR3); - } - - SendSysMessage(LANG_WAYPOINT_VP_ALLREMOVED); - return true; - } - - PSendSysMessage("|cffff33ffDEBUG: wpshow - no valid command found|r"); - return true; -} - -//////////// WAYPOINT COMMANDS // - //rename characters bool ChatHandler::HandleCharacterRenameCommand(const char* args) { @@ -2000,64 +600,6 @@ bool ChatHandler::HandleCharacterReputationCommand(const char* args) return true; } -bool ChatHandler::HandleHonorAddCommand(const char* args) -{ - if (!*args) - return false; - - Player *target = getSelectedPlayer(); - if (!target) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(target, 0)) - return false; - - uint32 amount = (uint32)atoi(args); - target->RewardHonor(NULL, 1, amount); - return true; -} - -bool ChatHandler::HandleHonorAddKillCommand(const char* /*args*/) -{ - Unit *target = getSelectedUnit(); - if (!target) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (target->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)target, 0)) - return false; - - m_session->GetPlayer()->RewardHonor(target, 1); - return true; -} - -bool ChatHandler::HandleHonorUpdateCommand(const char* /*args*/) -{ - Player *target = getSelectedPlayer(); - if (!target) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(target, 0)) - return false; - - target->UpdateHonorFields(); - return true; -} - bool ChatHandler::HandleLookupEventCommand(const char* args) { if (!*args) @@ -2463,73 +1005,6 @@ bool ChatHandler::HandlePetTpCommand(const char *args) return true; } -bool ChatHandler::HandleActivateObjectCommand(const char *args) -{ - if (!*args) - return false; - - char* cId = extractKeyFromLink((char*)args,"Hgameobject"); - if (!cId) - return false; - - uint32 lowguid = atoi(cId); - if (!lowguid) - return false; - - GameObject* obj = NULL; - - // by DB guid - if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) - obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); - - if (!obj) - { - PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - // Activate - obj->SetLootState(GO_READY); - obj->UseDoorOrButton(10000); - - PSendSysMessage("Object activated!"); - - return true; -} - -// add go, temp only -bool ChatHandler::HandleTempGameObjectCommand(const char* args) -{ - if (!*args) - return false; - char* charID = strtok((char*)args, " "); - if (!charID) - return false; - - Player *chr = m_session->GetPlayer(); - - char* spawntime = strtok(NULL, " "); - uint32 spawntm = 300; - - if (spawntime) - spawntm = atoi((char*)spawntime); - - float x = chr->GetPositionX(); - float y = chr->GetPositionY(); - float z = chr->GetPositionZ(); - float ang = chr->GetOrientation(); - - float rot2 = sin(ang/2); - float rot3 = cos(ang/2); - - uint32 id = atoi(charID); - - chr->SummonGameObject(id,x,y,z,ang,0,0,rot2,rot3,spawntm); - - return true; -} - bool ChatHandler::HandleLookupTitleCommand(const char* args) { if (!*args) @@ -2613,149 +1088,6 @@ bool ChatHandler::HandleLookupTitleCommand(const char* args) return true; } -bool ChatHandler::HandleTitlesAddCommand(const char* args) -{ - // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r - char* id_p = extractKeyFromLink((char*)args,"Htitle"); - if (!id_p) - return false; - - int32 id = atoi(id_p); - if (id <= 0) - { - PSendSysMessage(LANG_INVALID_TITLE_ID, id); - SetSentErrorMessage(true); - return false; - } - - Player * target = getSelectedPlayer(); - if (!target) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(target, 0)) - return false; - - CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); - if (!titleInfo) - { - PSendSysMessage(LANG_INVALID_TITLE_ID, id); - SetSentErrorMessage(true); - return false; - } - - std::string tNameLink = GetNameLink(target); - - char const* targetName = target->GetName(); - char titleNameStr[80]; - snprintf(titleNameStr,80,titleInfo->name[GetSessionDbcLocale()],targetName); - - target->SetTitle(titleInfo); - PSendSysMessage(LANG_TITLE_ADD_RES, id, titleNameStr, tNameLink.c_str()); - - return true; -} - -bool ChatHandler::HandleTitlesRemoveCommand(const char* args) -{ - // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r - char* id_p = extractKeyFromLink((char*)args,"Htitle"); - if (!id_p) - return false; - - int32 id = atoi(id_p); - if (id <= 0) - { - PSendSysMessage(LANG_INVALID_TITLE_ID, id); - SetSentErrorMessage(true); - return false; - } - - Player * target = getSelectedPlayer(); - if (!target) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(target, 0)) - return false; - - CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); - if (!titleInfo) - { - PSendSysMessage(LANG_INVALID_TITLE_ID, id); - SetSentErrorMessage(true); - return false; - } - - target->SetTitle(titleInfo,true); - - std::string tNameLink = GetNameLink(target); - - char const* targetName = target->GetName(); - char titleNameStr[80]; - snprintf(titleNameStr,80,titleInfo->name[GetSessionDbcLocale()],targetName); - - PSendSysMessage(LANG_TITLE_REMOVE_RES, id, titleNameStr, tNameLink.c_str()); - - if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE))) - { - target->SetUInt32Value(PLAYER_CHOSEN_TITLE,0); - PSendSysMessage(LANG_CURRENT_TITLE_RESET, tNameLink.c_str()); - } - - return true; -} - -//Edit Player KnownTitles -bool ChatHandler::HandleTitlesSetMaskCommand(const char* args) -{ - if (!*args) - return false; - - uint64 titles = 0; - - sscanf((char*)args, UI64FMTD, &titles); - - Player *target = getSelectedPlayer(); - if (!target) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(target, 0)) - return false; - - uint64 titles2 = titles; - - for (uint32 i = 1; i < sCharTitlesStore.GetNumRows(); ++i) - if (CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i)) - titles2 &= ~(uint64(1) << tEntry->bit_index); - - titles &= ~titles2; // remove not existed titles - - target->SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES, titles); - SendSysMessage(LANG_DONE); - - if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE))) - { - target->SetUInt32Value(PLAYER_CHOSEN_TITLE,0); - PSendSysMessage(LANG_CURRENT_TITLE_RESET,GetNameLink(target).c_str()); - } - - return true; -} - bool ChatHandler::HandleCharacterTitlesCommand(const char* args) { if (!*args) @@ -2795,48 +1127,3 @@ bool ChatHandler::HandleCharacterTitlesCommand(const char* args) } return true; } - -bool ChatHandler::HandleTitlesCurrentCommand(const char* args) -{ - // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r - char* id_p = extractKeyFromLink((char*)args,"Htitle"); - if (!id_p) - return false; - - int32 id = atoi(id_p); - if (id <= 0) - { - PSendSysMessage(LANG_INVALID_TITLE_ID, id); - SetSentErrorMessage(true); - return false; - } - - Player * target = getSelectedPlayer(); - if (!target) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(target, 0)) - return false; - - CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); - if (!titleInfo) - { - PSendSysMessage(LANG_INVALID_TITLE_ID, id); - SetSentErrorMessage(true); - return false; - } - - std::string tNameLink = GetNameLink(target); - - target->SetTitle(titleInfo); // to be sure that title now known - target->SetUInt32Value(PLAYER_CHOSEN_TITLE,titleInfo->bit_index); - - PSendSysMessage(LANG_TITLE_CURRENT_RES, id, titleInfo->name[GetSessionDbcLocale()], tNameLink.c_str()); - - return true; -} diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp index 521d8e287cd..bfb6c79768c 100755 --- a/src/server/game/Chat/Commands/Level3.cpp +++ b/src/server/game/Chat/Commands/Level3.cpp @@ -61,1131 +61,6 @@ #include "CreatureTextMgr.h" #include "SmartAI.h" -//reload commands -bool ChatHandler::HandleReloadAllCommand(const char*) -{ - HandleReloadSkillFishingBaseLevelCommand(""); - - HandleReloadAllAchievementCommand(""); - HandleReloadAllAreaCommand(""); - HandleReloadAllEventAICommand(""); - HandleReloadAllLootCommand(""); - HandleReloadAllNpcCommand(""); - HandleReloadAllQuestCommand(""); - HandleReloadAllSpellCommand(""); - HandleReloadAllItemCommand(""); - HandleReloadAllGossipsCommand(""); - HandleReloadAllLocalesCommand(""); - - HandleReloadAccessRequirementCommand(""); - HandleReloadMailLevelRewardCommand(""); - HandleReloadCommandCommand(""); - HandleReloadReservedNameCommand(""); - HandleReloadTrinityStringCommand(""); - HandleReloadGameTeleCommand(""); - - HandleReloadAutobroadcastCommand(""); - return true; -} - -bool ChatHandler::HandleReloadAllAchievementCommand(const char*) -{ - HandleReloadAchievementCriteriaDataCommand(""); - HandleReloadAchievementRewardCommand(""); - return true; -} - -bool ChatHandler::HandleReloadAllAreaCommand(const char*) -{ - //HandleReloadQuestAreaTriggersCommand(""); -- reloaded in HandleReloadAllQuestCommand - HandleReloadAreaTriggerTeleportCommand(""); - HandleReloadAreaTriggerTavernCommand(""); - HandleReloadGameGraveyardZoneCommand(""); - return true; -} - -bool ChatHandler::HandleReloadAllLootCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables..."); - LoadLootTables(); - SendGlobalGMSysMessage("DB tables `*_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadAllNpcCommand(const char* args) -{ - if(*args != 'a') // will be reloaded from all_gossips - HandleReloadNpcGossipCommand("a"); - HandleReloadNpcTrainerCommand("a"); - HandleReloadNpcVendorCommand("a"); - HandleReloadPointsOfInterestCommand("a"); - HandleReloadSpellClickSpellsCommand("a"); - return true; -} - -bool ChatHandler::HandleReloadAllQuestCommand(const char* /*args*/) -{ - HandleReloadQuestAreaTriggersCommand("a"); - HandleReloadQuestPOICommand("a"); - HandleReloadQuestTemplateCommand("a"); - - sLog.outString("Re-Loading Quests Relations..."); - sObjectMgr.LoadQuestRelations(); - SendGlobalGMSysMessage("DB tables `*_questrelation` and `*_involvedrelation` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAllScriptsCommand(const char*) -{ - if (sWorld.IsScriptScheduled()) - { - PSendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - sLog.outString("Re-Loading Scripts..."); - HandleReloadGameObjectScriptsCommand("a"); - HandleReloadGossipScriptsCommand("a"); - HandleReloadEventScriptsCommand("a"); - HandleReloadQuestEndScriptsCommand("a"); - HandleReloadQuestStartScriptsCommand("a"); - HandleReloadSpellScriptsCommand("a"); - SendGlobalGMSysMessage("DB tables `*_scripts` reloaded."); - HandleReloadDbScriptStringCommand("a"); - HandleReloadWpScriptsCommand("a"); - return true; -} - -bool ChatHandler::HandleReloadAllEventAICommand(const char*) -{ - HandleReloadEventAITextsCommand("a"); - HandleReloadEventAISummonsCommand("a"); - HandleReloadEventAIScriptsCommand("a"); - return true; -} - -bool ChatHandler::HandleReloadAllSpellCommand(const char*) -{ - HandleReloadSkillDiscoveryTemplateCommand("a"); - HandleReloadSkillExtraItemTemplateCommand("a"); - HandleReloadSpellRequiredCommand("a"); - HandleReloadSpellAreaCommand("a"); - HandleReloadSpellGroupsCommand("a"); - HandleReloadSpellLearnSpellCommand("a"); - HandleReloadSpellLinkedSpellCommand("a"); - HandleReloadSpellProcEventCommand("a"); - HandleReloadSpellBonusesCommand("a"); - HandleReloadSpellTargetPositionCommand("a"); - HandleReloadSpellThreatsCommand("a"); - HandleReloadSpellGroupStackRulesCommand("a"); - HandleReloadSpellPetAurasCommand("a"); - return true; -} - -bool ChatHandler::HandleReloadAllGossipsCommand(const char* args) -{ - HandleReloadGossipMenuCommand("a"); - HandleReloadGossipMenuOptionCommand("a"); - if(*args != 'a') // already reload from all_scripts - HandleReloadGossipScriptsCommand("a"); - HandleReloadNpcGossipCommand("a"); - HandleReloadPointsOfInterestCommand("a"); - return true; -} - -bool ChatHandler::HandleReloadAllItemCommand(const char*) -{ - HandleReloadPageTextsCommand("a"); - HandleReloadItemEnchantementsCommand("a"); - return true; -} - -bool ChatHandler::HandleReloadAllLocalesCommand(const char* /*args*/) -{ - HandleReloadLocalesAchievementRewardCommand("a"); - HandleReloadLocalesCreatureCommand("a"); - HandleReloadLocalesGameobjectCommand("a"); - HandleReloadLocalesGossipMenuOptionCommand("a"); - HandleReloadLocalesItemCommand("a"); - HandleReloadLocalesNpcTextCommand("a"); - HandleReloadLocalesPageTextCommand("a"); - HandleReloadLocalesPointsOfInterestCommand("a"); - HandleReloadLocalesQuestCommand("a"); - return true; -} - -bool ChatHandler::HandleReloadConfigCommand(const char* /*args*/) -{ - sLog.outString("Re-Loading config settings..."); - sWorld.LoadConfigSettings(true); - sMapMgr.InitializeVisibilityDistanceInfo(); - SendGlobalGMSysMessage("World config settings reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAccessRequirementCommand(const char*) -{ - sLog.outString("Re-Loading Access Requirement definitions..."); - sObjectMgr.LoadAccessRequirements(); - SendGlobalGMSysMessage("DB table `access_requirement` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAchievementCriteriaDataCommand(const char*) -{ - sLog.outString("Re-Loading Additional Achievement Criteria Data..."); - sAchievementMgr.LoadAchievementCriteriaData(); - SendGlobalGMSysMessage("DB table `achievement_criteria_data` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAchievementRewardCommand(const char*) -{ - sLog.outString("Re-Loading Achievement Reward Data..."); - sAchievementMgr.LoadRewards(); - SendGlobalGMSysMessage("DB table `achievement_reward` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAreaTriggerTavernCommand(const char*) -{ - sLog.outString("Re-Loading Tavern Area Triggers..."); - sObjectMgr.LoadTavernAreaTriggers(); - SendGlobalGMSysMessage("DB table `areatrigger_tavern` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAreaTriggerTeleportCommand(const char*) -{ - sLog.outString("Re-Loading AreaTrigger teleport definitions..."); - sObjectMgr.LoadAreaTriggerTeleports(); - SendGlobalGMSysMessage("DB table `areatrigger_teleport` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAutobroadcastCommand(const char*) -{ - sLog.outString("Re-Loading Autobroadcast..."); - sWorld.LoadAutobroadcasts(); - SendGlobalGMSysMessage("DB table `autobroadcast` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadCommandCommand(const char*) -{ - load_command_table = true; - SendGlobalGMSysMessage("DB table `command` will be reloaded at next chat command use."); - return true; -} - -bool ChatHandler::HandleReloadOnKillReputationCommand(const char*) -{ - sLog.outString("Re-Loading creature award reputation definitions..."); - sObjectMgr.LoadReputationOnKill(); - SendGlobalGMSysMessage("DB table `creature_onkill_reputation` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadCreatureTemplateCommand(const char* args) -{ - if (!*args) - return false; - - uint32 entry = (uint32) atoi((char*)args); - QueryResult result = WorldDatabase.PQuery("SELECT difficulty_entry_1,difficulty_entry_2,difficulty_entry_3,KillCredit1,KillCredit2,modelid1,modelid2,modelid3,modelid4,name,subname,IconName,gossip_menu_id,minlevel,maxlevel,exp,faction_A,faction_H,npcflag,speed_walk,speed_run,scale,rank,mindmg,maxdmg,dmgschool,attackpower,dmg_multiplier,baseattacktime,rangeattacktime,unit_class,unit_flags,dynamicflags,family,trainer_type,trainer_spell,trainer_class,trainer_race,minrangedmg,maxrangedmg,rangedattackpower,type,type_flags,lootid,pickpocketloot,skinloot,resistance1,resistance2,resistance3,resistance4,resistance5,resistance6,spell1,spell2,spell3,spell4,spell5,spell6,spell7,spell8,PetSpellDataId,VehicleId,mingold,maxgold,AIName,MovementType,InhabitType,Health_mod,Mana_mod,Armor_mod,RacialLeader,questItem1,questItem2,questItem3,questItem4,questItem5,questItem6,movementId,RegenHealth,equipment_id,mechanic_immune_mask,flags_extra,ScriptName FROM creature_template WHERE entry = %u", entry); - if (!result) - { - PSendSysMessage(LANG_COMMAND_CREATURETEMPLATE_NOTFOUND, entry); - SetSentErrorMessage(true); - return false; - } - - CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(entry); - if (!cInfo) - { - PSendSysMessage(LANG_COMMAND_CREATURESTORAGE_NOTFOUND, entry); - SetSentErrorMessage(true); - return false; - } - - sLog.outString("Reloading creature template entry %u", entry); - - Field *fields = result->Fetch(); - - const_cast<CreatureInfo*>(cInfo)->DifficultyEntry[0] = fields[0].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->DifficultyEntry[1] = fields[1].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->DifficultyEntry[2] = fields[2].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->KillCredit[0] = fields[3].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->KillCredit[1] = fields[4].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->Modelid1 = fields[5].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->Modelid2 = fields[6].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->Modelid3 = fields[7].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->Modelid4 = fields[8].GetUInt32(); - size_t len = 0; - if (const char* temp = fields[9].GetCString()) - { - delete[] cInfo->Name; - len = strlen(temp)+1; - const_cast<CreatureInfo*>(cInfo)->Name = new char[len]; - strncpy(cInfo->Name, temp, len); - } - if (const char* temp = fields[10].GetCString()) - { - delete[] cInfo->SubName; - len = strlen(temp)+1; - const_cast<CreatureInfo*>(cInfo)->SubName = new char[len]; - strncpy(cInfo->SubName, temp, len); - } - if (const char* temp = fields[11].GetCString()) - { - delete[] cInfo->IconName; - len = strlen(temp)+1; - const_cast<CreatureInfo*>(cInfo)->IconName = new char[len]; - strncpy(cInfo->IconName, temp, len); - } - const_cast<CreatureInfo*>(cInfo)->GossipMenuId = fields[12].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->minlevel = fields[13].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->maxlevel = fields[14].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->expansion = fields[15].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->faction_A = fields[16].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->faction_H = fields[17].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->npcflag = fields[18].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->speed_walk = fields[19].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->speed_run = fields[20].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->scale = fields[21].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->rank = fields[22].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->mindmg = fields[23].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->maxdmg = fields[24].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->dmgschool = fields[25].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->attackpower = fields[26].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->dmg_multiplier = fields[27].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->baseattacktime = fields[28].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->rangeattacktime = fields[29].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->unit_class = fields[30].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->unit_flags = fields[31].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->dynamicflags = fields[32].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->family = fields[33].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->trainer_type = fields[34].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->trainer_spell = fields[35].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->trainer_class = fields[36].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->trainer_race = fields[37].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->minrangedmg = fields[38].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->maxrangedmg = fields[39].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->rangedattackpower = fields[40].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->type = fields[41].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->type_flags = fields[42].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->lootid = fields[43].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->pickpocketLootId = fields[44].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->SkinLootId = fields[45].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->resistance1 = fields[46].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->resistance2 = fields[47].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->resistance3 = fields[48].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->resistance4 = fields[49].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->resistance5 = fields[50].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->resistance6 = fields[51].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->spells[0] = fields[52].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->spells[1] = fields[53].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->spells[2] = fields[54].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->spells[3] = fields[55].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->spells[4] = fields[56].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->spells[5] = fields[57].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->spells[6] = fields[58].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->spells[7] = fields[59].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->PetSpellDataId = fields[60].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->VehicleId = fields[61].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->mingold = fields[62].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->maxgold = fields[63].GetUInt32(); - if (const char* temp = fields[64].GetCString()) - { - delete[] cInfo->AIName; - len = strlen(temp)+1; - const_cast<CreatureInfo*>(cInfo)->AIName = new char[len]; - strncpy(const_cast<char*>(cInfo->AIName), temp, len); - } - const_cast<CreatureInfo*>(cInfo)->MovementType = fields[65].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->InhabitType = fields[66].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->ModHealth = fields[67].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->ModMana = fields[68].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->ModArmor = fields[69].GetFloat(); - const_cast<CreatureInfo*>(cInfo)->RacialLeader = fields[70].GetBool(); - const_cast<CreatureInfo*>(cInfo)->questItems[0] = fields[71].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->questItems[1] = fields[72].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->questItems[2] = fields[73].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->questItems[3] = fields[74].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->questItems[4] = fields[75].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->questItems[5] = fields[76].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->movementId = fields[77].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->RegenHealth = fields[78].GetBool(); - const_cast<CreatureInfo*>(cInfo)->equipmentId = fields[79].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->MechanicImmuneMask = fields[80].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->flags_extra = fields[81].GetUInt32(); - const_cast<CreatureInfo*>(cInfo)->ScriptID = sObjectMgr.GetScriptId(fields[82].GetCString()); - - sObjectMgr.CheckCreatureTemplate(cInfo); - - SendGlobalGMSysMessage("Creature template reloaded."); - return true; -} - -bool ChatHandler::HandleReloadCreatureQuestRelationsCommand(const char*) -{ - sLog.outString("Loading Quests Relations... (`creature_questrelation`)"); - sObjectMgr.LoadCreatureQuestRelations(); - SendGlobalGMSysMessage("DB table `creature_questrelation` (creature quest givers) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadCreatureLinkedRespawnCommand(const char * /*args*/) -{ - sLog.outString("Loading Linked Respawns... (`creature_linked_respawn`)"); - sObjectMgr.LoadCreatureLinkedRespawn(); - SendGlobalGMSysMessage("DB table `creature_linked_respawn` (creature linked respawns) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadCreatureQuestInvRelationsCommand(const char*) -{ - sLog.outString("Loading Quests Relations... (`creature_involvedrelation`)"); - sObjectMgr.LoadCreatureInvolvedRelations(); - SendGlobalGMSysMessage("DB table `creature_involvedrelation` (creature quest takers) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadGossipMenuCommand(const char*) -{ - sLog.outString("Re-Loading `gossip_menu` Table!"); - sObjectMgr.LoadGossipMenu(); - SendGlobalGMSysMessage("DB table `gossip_menu` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadGossipMenuOptionCommand(const char*) -{ - sLog.outString("Re-Loading `gossip_menu_option` Table!"); - sObjectMgr.LoadGossipMenuItems(); - SendGlobalGMSysMessage("DB table `gossip_menu_option` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadGOQuestRelationsCommand(const char*) -{ - sLog.outString("Loading Quests Relations... (`gameobject_questrelation`)"); - sObjectMgr.LoadGameobjectQuestRelations(); - SendGlobalGMSysMessage("DB table `gameobject_questrelation` (gameobject quest givers) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadGOQuestInvRelationsCommand(const char*) -{ - sLog.outString("Loading Quests Relations... (`gameobject_involvedrelation`)"); - sObjectMgr.LoadGameobjectInvolvedRelations(); - SendGlobalGMSysMessage("DB table `gameobject_involvedrelation` (gameobject quest takers) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadQuestAreaTriggersCommand(const char*) -{ - sLog.outString("Re-Loading Quest Area Triggers..."); - sObjectMgr.LoadQuestAreaTriggers(); - SendGlobalGMSysMessage("DB table `areatrigger_involvedrelation` (quest area triggers) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadQuestTemplateCommand(const char*) -{ - sLog.outString("Re-Loading Quest Templates..."); - sObjectMgr.LoadQuests(); - SendGlobalGMSysMessage("DB table `quest_template` (quest definitions) reloaded."); - - /// dependent also from `gameobject` but this table not reloaded anyway - sLog.outString("Re-Loading GameObjects for quests..."); - sObjectMgr.LoadGameObjectForQuests(); - SendGlobalGMSysMessage("Data GameObjects for quests reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesCreatureCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`creature_loot_template`)"); - LoadLootTemplates_Creature(); - LootTemplates_Creature.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `creature_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesDisenchantCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`disenchant_loot_template`)"); - LoadLootTemplates_Disenchant(); - LootTemplates_Disenchant.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `disenchant_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesFishingCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`fishing_loot_template`)"); - LoadLootTemplates_Fishing(); - LootTemplates_Fishing.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `fishing_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesGameobjectCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`gameobject_loot_template`)"); - LoadLootTemplates_Gameobject(); - LootTemplates_Gameobject.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `gameobject_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesItemCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`item_loot_template`)"); - LoadLootTemplates_Item(); - LootTemplates_Item.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `item_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesMillingCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`milling_loot_template`)"); - LoadLootTemplates_Milling(); - LootTemplates_Milling.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `milling_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesPickpocketingCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`pickpocketing_loot_template`)"); - LoadLootTemplates_Pickpocketing(); - LootTemplates_Pickpocketing.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `pickpocketing_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesProspectingCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`prospecting_loot_template`)"); - LoadLootTemplates_Prospecting(); - LootTemplates_Prospecting.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `prospecting_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesMailCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`mail_loot_template`)"); - LoadLootTemplates_Mail(); - LootTemplates_Mail.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `mail_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesReferenceCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`reference_loot_template`)"); - LoadLootTemplates_Reference(); - SendGlobalGMSysMessage("DB table `reference_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesSkinningCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`skinning_loot_template`)"); - LoadLootTemplates_Skinning(); - LootTemplates_Skinning.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `skinning_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadLootTemplatesSpellCommand(const char*) -{ - sLog.outString("Re-Loading Loot Tables... (`spell_loot_template`)"); - LoadLootTemplates_Spell(); - LootTemplates_Spell.CheckLootRefs(); - SendGlobalGMSysMessage("DB table `spell_loot_template` reloaded."); - sConditionMgr.LoadConditions(true); - return true; -} - -bool ChatHandler::HandleReloadTrinityStringCommand(const char*) -{ - sLog.outString("Re-Loading trinity_string Table!"); - sObjectMgr.LoadTrinityStrings(); - SendGlobalGMSysMessage("DB table `trinity_string` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadNpcGossipCommand(const char*) -{ - sLog.outString("Re-Loading `npc_gossip` Table!"); - sObjectMgr.LoadNpcTextId(); - SendGlobalGMSysMessage("DB table `npc_gossip` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadNpcTrainerCommand(const char*) -{ - sLog.outString("Re-Loading `npc_trainer` Table!"); - sObjectMgr.LoadTrainerSpell(); - SendGlobalGMSysMessage("DB table `npc_trainer` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadNpcVendorCommand(const char*) -{ - sLog.outString("Re-Loading `npc_vendor` Table!"); - sObjectMgr.LoadVendors(); - SendGlobalGMSysMessage("DB table `npc_vendor` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadPointsOfInterestCommand(const char*) -{ - sLog.outString("Re-Loading `points_of_interest` Table!"); - sObjectMgr.LoadPointsOfInterest(); - SendGlobalGMSysMessage("DB table `points_of_interest` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadQuestPOICommand(const char*) -{ - sLog.outString( "Re-Loading Quest POI ..." ); - sObjectMgr.LoadQuestPOI(); - SendGlobalGMSysMessage("DB Table `quest_poi` and `quest_poi_points` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellClickSpellsCommand(const char*) -{ - sLog.outString("Re-Loading `npc_spellclick_spells` Table!"); - sObjectMgr.LoadNPCSpellClickSpells(); - SendGlobalGMSysMessage("DB table `npc_spellclick_spells` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadReservedNameCommand(const char*) -{ - sLog.outString("Loading ReservedNames... (`reserved_name`)"); - sObjectMgr.LoadReservedPlayersNames(); - SendGlobalGMSysMessage("DB table `reserved_name` (player reserved names) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadReputationRewardRateCommand(const char*) -{ - sLog.outString( "Re-Loading `reputation_reward_rate` Table!" ); - sObjectMgr.LoadReputationRewardRate(); - SendGlobalSysMessage("DB table `reputation_reward_rate` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadReputationSpilloverTemplateCommand(const char*) -{ - sLog.outString( "Re-Loading `reputation_spillover_template` Table!" ); - sObjectMgr.LoadReputationSpilloverTemplate(); - SendGlobalSysMessage("DB table `reputation_spillover_template` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSkillDiscoveryTemplateCommand(const char* /*args*/) -{ - sLog.outString("Re-Loading Skill Discovery Table..."); - LoadSkillDiscoveryTable(); - SendGlobalGMSysMessage("DB table `skill_discovery_template` (recipes discovered at crafting) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSkillExtraItemTemplateCommand(const char* /*args*/) -{ - sLog.outString("Re-Loading Skill Extra Item Table..."); - LoadSkillExtraItemTable(); - SendGlobalGMSysMessage("DB table `skill_extra_item_template` (extra item creation when crafting) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSkillFishingBaseLevelCommand(const char* /*args*/) -{ - sLog.outString("Re-Loading Skill Fishing base level requirements..."); - sObjectMgr.LoadFishingBaseSkillLevel(); - SendGlobalGMSysMessage("DB table `skill_fishing_base_level` (fishing base level for zone/subzone) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellAreaCommand(const char*) -{ - sLog.outString("Re-Loading SpellArea Data..."); - sSpellMgr.LoadSpellAreas(); - SendGlobalGMSysMessage("DB table `spell_area` (spell dependences from area/quest/auras state) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellRequiredCommand(const char*) -{ - sLog.outString("Re-Loading Spell Required Data... "); - sSpellMgr.LoadSpellRequired(); - SendGlobalGMSysMessage("DB table `spell_required` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellGroupsCommand(const char*) -{ - sLog.outString("Re-Loading Spell Groups..."); - sSpellMgr.LoadSpellGroups(); - SendGlobalGMSysMessage("DB table `spell_group` (spell groups) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellLearnSpellCommand(const char*) -{ - sLog.outString("Re-Loading Spell Learn Spells..."); - sSpellMgr.LoadSpellLearnSpells(); - SendGlobalGMSysMessage("DB table `spell_learn_spell` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellLinkedSpellCommand(const char*) -{ - sLog.outString("Re-Loading Spell Linked Spells..."); - sSpellMgr.LoadSpellLinked(); - SendGlobalGMSysMessage("DB table `spell_linked_spell` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellProcEventCommand(const char*) -{ - sLog.outString("Re-Loading Spell Proc Event conditions..."); - sSpellMgr.LoadSpellProcEvents(); - SendGlobalGMSysMessage("DB table `spell_proc_event` (spell proc trigger requirements) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellBonusesCommand(const char*) -{ - sLog.outString("Re-Loading Spell Bonus Data..."); - sSpellMgr.LoadSpellBonusess(); - SendGlobalGMSysMessage("DB table `spell_bonus_data` (spell damage/healing coefficients) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellTargetPositionCommand(const char*) -{ - sLog.outString("Re-Loading Spell target coordinates..."); - sSpellMgr.LoadSpellTargetPositions(); - SendGlobalGMSysMessage("DB table `spell_target_position` (destination coordinates for spell targets) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellThreatsCommand(const char*) -{ - sLog.outString("Re-Loading Aggro Spells Definitions..."); - sSpellMgr.LoadSpellThreats(); - SendGlobalGMSysMessage("DB table `spell_threat` (spell aggro definitions) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellGroupStackRulesCommand(const char*) -{ - sLog.outString("Re-Loading Spell Group Stack Rules..."); - sSpellMgr.LoadSpellGroupStackRules(); - SendGlobalGMSysMessage("DB table `spell_group_stack_rules` (spell stacking definitions) reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSpellPetAurasCommand(const char*) -{ - sLog.outString("Re-Loading Spell pet auras..."); - sSpellMgr.LoadSpellPetAuras(); - SendGlobalGMSysMessage("DB table `spell_pet_auras` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadPageTextsCommand(const char*) -{ - sLog.outString("Re-Loading Page Texts..."); - sObjectMgr.LoadPageTexts(); - SendGlobalGMSysMessage("DB table `page_texts` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadItemEnchantementsCommand(const char*) -{ - sLog.outString("Re-Loading Item Random Enchantments Table..."); - LoadRandomEnchantmentsTable(); - SendGlobalGMSysMessage("DB table `item_enchantment_template` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadItemSetNamesCommand(const char*) -{ - sLog.outString("Re-Loading Item set names..."); - LoadRandomEnchantmentsTable(); - SendGlobalGMSysMessage("DB table `item_set_names` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadGossipScriptsCommand(const char* arg) -{ - if (sWorld.IsScriptScheduled()) - { - SendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - if (*arg != 'a') - sLog.outString("Re-Loading Scripts from `gossip_scripts`..."); - - sObjectMgr.LoadGossipScripts(); - - if (*arg != 'a') - SendGlobalGMSysMessage("DB table `gossip_scripts` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadGameObjectScriptsCommand(const char* arg) -{ - if (sWorld.IsScriptScheduled()) - { - SendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - if (*arg != 'a') - sLog.outString("Re-Loading Scripts from `gameobject_scripts`..."); - - sObjectMgr.LoadGameObjectScripts(); - - if (*arg != 'a') - SendGlobalGMSysMessage("DB table `gameobject_scripts` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadEventScriptsCommand(const char* arg) -{ - if (sWorld.IsScriptScheduled()) - { - SendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - if (*arg != 'a') - sLog.outString("Re-Loading Scripts from `event_scripts`..."); - - sObjectMgr.LoadEventScripts(); - - if (*arg != 'a') - SendGlobalGMSysMessage("DB table `event_scripts` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadWpScriptsCommand(const char* arg) -{ - if (sWorld.IsScriptScheduled()) - { - SendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - if (*arg != 'a') - sLog.outString("Re-Loading Scripts from `waypoint_scripts`..."); - - sObjectMgr.LoadWaypointScripts(); - - if (*arg != 'a') - SendGlobalGMSysMessage("DB table `waypoint_scripts` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadEventAITextsCommand(const char* /*args*/) -{ - - sLog.outString("Re-Loading Texts from `creature_ai_texts`..."); - sEventAIMgr.LoadCreatureEventAI_Texts(); - SendGlobalGMSysMessage("DB table `creature_ai_texts` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadEventAISummonsCommand(const char* /*args*/) -{ - sLog.outString("Re-Loading Summons from `creature_ai_summons`..."); - sEventAIMgr.LoadCreatureEventAI_Summons(); - SendGlobalGMSysMessage("DB table `creature_ai_summons` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadEventAIScriptsCommand(const char* /*args*/) -{ - sLog.outString("Re-Loading Scripts from `creature_ai_scripts`..."); - sEventAIMgr.LoadCreatureEventAI_Scripts(); - SendGlobalGMSysMessage("DB table `creature_ai_scripts` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadQuestEndScriptsCommand(const char* arg) -{ - if (sWorld.IsScriptScheduled()) - { - SendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - if (*arg != 'a') - sLog.outString("Re-Loading Scripts from `quest_end_scripts`..."); - - sObjectMgr.LoadQuestEndScripts(); - - if (*arg != 'a') - SendGlobalGMSysMessage("DB table `quest_end_scripts` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadQuestStartScriptsCommand(const char* arg) -{ - if (sWorld.IsScriptScheduled()) - { - SendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - if (*arg != 'a') - sLog.outString("Re-Loading Scripts from `quest_start_scripts`..."); - - sObjectMgr.LoadQuestStartScripts(); - - if (*arg != 'a') - SendGlobalGMSysMessage("DB table `quest_start_scripts` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadSpellScriptsCommand(const char* arg) -{ - if (sWorld.IsScriptScheduled()) - { - SendSysMessage("DB scripts used currently, please attempt reload later."); - SetSentErrorMessage(true); - return false; - } - - if (*arg != 'a') - sLog.outString("Re-Loading Scripts from `spell_scripts`..."); - - sObjectMgr.LoadSpellScripts(); - - if (*arg != 'a') - SendGlobalGMSysMessage("DB table `spell_scripts` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadDbScriptStringCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Script strings from `db_script_string`..."); - sObjectMgr.LoadDbScriptStrings(); - SendGlobalGMSysMessage("DB table `db_script_string` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadGameGraveyardZoneCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Graveyard-zone links..."); - - sObjectMgr.LoadGraveyardZones(); - - SendGlobalGMSysMessage("DB table `game_graveyard_zone` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadGameTeleCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Game Tele coordinates..."); - - sObjectMgr.LoadGameTele(); - - SendGlobalGMSysMessage("DB table `game_tele` reloaded."); - - return true; -} - -bool ChatHandler::HandleReloadDisablesCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading disables table..."); - sDisableMgr.LoadDisables(); - sLog.outString("Checking quest disables..."); - sDisableMgr.CheckQuestDisables(); - SendGlobalGMSysMessage("DB table `disables` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLocalesAchievementRewardCommand(const char*) -{ - sLog.outString("Re-Loading Locales Achievement Reward Data..."); - sAchievementMgr.LoadRewardLocales(); - SendGlobalGMSysMessage("DB table `locales_achievement_reward` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLfgEncountersCommand(const char*) -{ - sLog.outString("Re-Loading dungeon encounter lfg associations..."); - sLFGMgr.LoadDungeonEncounters(); - SendGlobalGMSysMessage("DB table `lfg_dungeon_encounters` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLfgRewardsCommand(const char*) -{ - sLog.outString("Re-Loading lfg dungeon rewards..."); - sLFGMgr.LoadRewards(); - SendGlobalGMSysMessage("DB table `lfg_dungeon_rewards` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLocalesCreatureCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Locales Creature ..."); - sObjectMgr.LoadCreatureLocales(); - SendGlobalGMSysMessage("DB table `locales_creature` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLocalesGameobjectCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Locales Gameobject ... "); - sObjectMgr.LoadGameObjectLocales(); - SendGlobalGMSysMessage("DB table `locales_gameobject` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLocalesGossipMenuOptionCommand(const char* /*arg*/) -{ - sLog.outString( "Re-Loading Locales Gossip Menu Option ... "); - sObjectMgr.LoadGossipMenuItemsLocales(); - SendGlobalGMSysMessage("DB table `locales_gossip_menu_option` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLocalesItemCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Locales Item ... "); - sObjectMgr.LoadItemLocales(); - SendGlobalGMSysMessage("DB table `locales_item` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLocalesItemSetNameCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Locales Item set name... "); - sObjectMgr.LoadItemSetNameLocales(); - SendGlobalGMSysMessage("DB table `locales_item_set_name` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLocalesNpcTextCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Locales NPC Text ... "); - sObjectMgr.LoadNpcTextLocales(); - SendGlobalGMSysMessage("DB table `locales_npc_text` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLocalesPageTextCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Locales Page Text ... "); - sObjectMgr.LoadPageTextLocales(); - SendGlobalGMSysMessage("DB table `locales_page_text` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLocalesPointsOfInterestCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Locales Points Of Interest ... "); - sObjectMgr.LoadPointOfInterestLocales(); - SendGlobalGMSysMessage("DB table `locales_points_of_interest` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadLocalesQuestCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Locales Quest ... "); - sObjectMgr.LoadQuestLocales(); - SendGlobalGMSysMessage("DB table `locales_quest` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadMailLevelRewardCommand(const char* /*arg*/) -{ - sLog.outString("Re-Loading Player level dependent mail rewards..."); - sObjectMgr.LoadMailLevelRewards(); - SendGlobalGMSysMessage("DB table `mail_level_reward` reloaded."); - return true; -} - -bool ChatHandler::HandleReloadAuctionsCommand(const char * /*args*/) -{ - ///- Reload dynamic data tables from the database - sLog.outString("Re-Loading Auctions..."); - sAuctionMgr.LoadAuctionItems(); - sAuctionMgr.LoadAuctions(); - SendGlobalGMSysMessage("Auctions reloaded."); - return true; -} - -bool ChatHandler::HandleReloadConditions(const char* /*args*/) -{ - sLog.outString("Re-Loading Conditions..."); - sConditionMgr.LoadConditions(true); - SendGlobalGMSysMessage("Conditions reloaded."); - return true; -} - -bool ChatHandler::HandleReloadCreatureText(const char* /*args*/) -{ - sLog.outString("Re-Loading Creature Texts..."); - sCreatureTextMgr.LoadCreatureTexts(); - SendGlobalGMSysMessage("Creature Texts reloaded."); - return true; -} - -bool ChatHandler::HandleReloadSmartScripts(const char* /*args*/) -{ - sLog.outString("Re-Loading Smart Scripts..."); - sSmartScriptMgr.LoadSmartAIFromDB(); - SendGlobalGMSysMessage("Smart Scripts reloaded."); - return true; -} - bool ChatHandler::HandleMaxSkillCommand(const char* /*args*/) { Player* SelectedPlayer = getSelectedPlayer(); @@ -1784,65 +659,6 @@ bool ChatHandler::HandleListObjectCommand(const char *args) return true; } -bool ChatHandler::HandleGameObjectStateCommand(const char *args) -{ - // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r - char* cId = extractKeyFromLink((char*)args, "Hgameobject"); - if (!cId) - return false; - - uint32 lowguid = atoi(cId); - if (!lowguid) - return false; - - GameObject* gobj = NULL; - - if (GameObjectData const* goData = sObjectMgr.GetGOData(lowguid)) - gobj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, goData->id); - - if (!gobj) - { - PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - char* ctype = strtok(NULL, " "); - if (!ctype) - return false; - - int32 type = atoi(ctype); - if (type < 0) - { - if (type == -1) - gobj->SendObjectDeSpawnAnim(gobj->GetGUID()); - else if (type == -2) - { - return false; - } - return true; - } - - char* cstate = strtok(NULL, " "); - if (!cstate) - return false; - - int32 state = atoi(cstate); - - if (type < 4) - gobj->SetByteValue(GAMEOBJECT_BYTES_1, type, state); - else if (type == 4) - { - WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM,8+4); - data << gobj->GetGUID(); - data << (uint32)(state); - gobj->SendMessageToSet(&data, true); - } - PSendSysMessage("Set gobject type %d state %d", type, state); - - return true; -} - bool ChatHandler::HandleListCreatureCommand(const char *args) { if (!*args) @@ -4033,210 +2849,6 @@ bool ChatHandler::HandleServerIdleShutDownCommand(const char *args) return true; } -bool ChatHandler::HandleQuestAdd(const char *args) -{ - Player* player = getSelectedPlayer(); - if (!player) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // .addquest #entry' - // number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hquest"); - if (!cId) - return false; - - uint32 entry = atol(cId); - - Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry); - - if (!pQuest) - { - PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND,entry); - SetSentErrorMessage(true); - return false; - } - - // check item starting quest (it can work incorrectly if added without item in inventory) - for (uint32 id = 0; id < sItemStorage.MaxEntry; id++) - { - ItemPrototype const *pProto = sItemStorage.LookupEntry<ItemPrototype>(id); - if (!pProto) - continue; - - if (pProto->StartQuest == entry) - { - PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry, pProto->ItemId); - SetSentErrorMessage(true); - return false; - } - } - - // ok, normal (creature/GO starting) quest - if (player->CanAddQuest(pQuest, true)) - { - player->AddQuest(pQuest, NULL); - - if (player->CanCompleteQuest(entry)) - player->CompleteQuest(entry); - } - - return true; -} - -bool ChatHandler::HandleQuestRemove(const char *args) -{ - Player* player = getSelectedPlayer(); - if (!player) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // .removequest #entry' - // number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hquest"); - if (!cId) - return false; - - uint32 entry = atol(cId); - - Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry); - - if (!pQuest) - { - PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry); - SetSentErrorMessage(true); - return false; - } - - // remove all quest entries for 'entry' from quest log - for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot) - { - uint32 quest = player->GetQuestSlotQuestId(slot); - if (quest == entry) - { - player->SetQuestSlot(slot,0); - - // we ignore unequippable quest items in this case, its' still be equipped - player->TakeQuestSourceItem(quest, false); - } - } - - // set quest status to not started (will updated in DB at next save) - player->SetQuestStatus(entry, QUEST_STATUS_NONE); - - // reset rewarded for restart repeatable quest - player->getQuestStatusMap()[entry].m_rewarded = false; - - SendSysMessage(LANG_COMMAND_QUEST_REMOVED); - return true; -} - -bool ChatHandler::HandleQuestComplete(const char *args) -{ - Player* player = getSelectedPlayer(); - if (!player) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // .quest complete #entry - // number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hquest"); - if (!cId) - return false; - - uint32 entry = atol(cId); - - Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry); - - // If player doesn't have the quest - if (!pQuest || player->GetQuestStatus(entry) == QUEST_STATUS_NONE) - { - PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry); - SetSentErrorMessage(true); - return false; - } - - // Add quest items for quests that require items - for (uint8 x = 0; x < QUEST_ITEM_OBJECTIVES_COUNT; ++x) - { - uint32 id = pQuest->ReqItemId[x]; - uint32 count = pQuest->ReqItemCount[x]; - if (!id || !count) - continue; - - uint32 curItemCount = player->GetItemCount(id,true); - - ItemPosCountVec dest; - uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, id, count-curItemCount); - if (msg == EQUIP_ERR_OK) - { - Item* item = player->StoreNewItem(dest, id, true); - player->SendNewItem(item,count-curItemCount,true,false); - } - } - - // All creature/GO slain/casted (not required, but otherwise it will display "Creature slain 0/10") - for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) - { - int32 creature = pQuest->ReqCreatureOrGOId[i]; - uint32 creaturecount = pQuest->ReqCreatureOrGOCount[i]; - - if (uint32 spell_id = pQuest->ReqSpell[i]) - { - for (uint16 z = 0; z < creaturecount; ++z) - player->CastedCreatureOrGO(creature,0,spell_id); - } - else if (creature > 0) - { - if (CreatureInfo const* cInfo = sObjectMgr.GetCreatureTemplate(creature)) - for (uint16 z = 0; z < creaturecount; ++z) - player->KilledMonster(cInfo,0); - } - else if (creature < 0) - { - for (uint16 z = 0; z < creaturecount; ++z) - player->CastedCreatureOrGO(creature,0,0); - } - } - - // If the quest requires reputation to complete - if (uint32 repFaction = pQuest->GetRepObjectiveFaction()) - { - uint32 repValue = pQuest->GetRepObjectiveValue(); - uint32 curRep = player->GetReputationMgr().GetReputation(repFaction); - if (curRep < repValue) - if (FactionEntry const *factionEntry = sFactionStore.LookupEntry(repFaction)) - player->GetReputationMgr().SetReputation(factionEntry,repValue); - } - - // If the quest requires a SECOND reputation to complete - if (uint32 repFaction = pQuest->GetRepObjectiveFaction2()) - { - uint32 repValue2 = pQuest->GetRepObjectiveValue2(); - uint32 curRep = player->GetReputationMgr().GetReputation(repFaction); - if (curRep < repValue2) - if (FactionEntry const *factionEntry = sFactionStore.LookupEntry(repFaction)) - player->GetReputationMgr().SetReputation(factionEntry,repValue2); - } - - // If the quest requires money - int32 ReqOrRewMoney = pQuest->GetRewOrReqMoney(); - if (ReqOrRewMoney < 0) - player->ModifyMoney(-ReqOrRewMoney); - - player->CompleteQuest(entry); - return true; -} - bool ChatHandler::HandleBanAccountCommand(const char *args) { return HandleBanHelper(BAN_ACCOUNT,args); diff --git a/src/server/game/Chat/Commands/TicketCommands.cpp b/src/server/game/Chat/Commands/TicketCommands.cpp index 018e4da0ad6..34f04041bc4 100755 --- a/src/server/game/Chat/Commands/TicketCommands.cpp +++ b/src/server/game/Chat/Commands/TicketCommands.cpp @@ -427,12 +427,6 @@ bool ChatHandler::HandleGMTicketDeleteByIdCommand(const char* args) return true; } -bool ChatHandler::HandleGMTicketReloadCommand(const char* /* args */) -{ - sTicketMgr.LoadGMTickets(); - return true; -} - bool ChatHandler::HandleToggleGMTicketSystem(const char* /* args */) { sTicketMgr.SetStatus(!sTicketMgr.GetStatus()); diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp index 531f956c3c4..65a22002534 100755 --- a/src/server/game/Scripting/ScriptLoader.cpp +++ b/src/server/game/Scripting/ScriptLoader.cpp @@ -15,7 +15,6 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "ScriptPCH.h" #include "ScriptLoader.h" @@ -51,10 +50,16 @@ void AddSC_debug_commandscript(); void AddSC_event_commandscript(); void AddSC_gm_commandscript(); void AddSC_go_commandscript(); +void AddSC_gobject_commandscript(); +void AddSC_honor_commandscript(); void AddSC_learn_commandscript(); void AddSC_modify_commandscript(); void AddSC_npc_commandscript(); +void AddSC_quest_commandscript(); +void AddSC_reload_commandscript(); void AddSC_tele_commandscript(); +void AddSC_titles_commandscript(); +void AddSC_wp_commandscript(); #ifdef SCRIPTS //world @@ -629,10 +634,16 @@ void AddCommandScripts() AddSC_event_commandscript(); AddSC_gm_commandscript(); AddSC_go_commandscript(); + AddSC_gobject_commandscript(); + AddSC_honor_commandscript(); AddSC_learn_commandscript(); AddSC_modify_commandscript(); AddSC_npc_commandscript(); + AddSC_quest_commandscript(); + AddSC_reload_commandscript(); AddSC_tele_commandscript(); + AddSC_titles_commandscript(); + AddSC_wp_commandscript(); } void AddWorldScripts() diff --git a/src/server/scripts/CMakeLists.txt b/src/server/scripts/CMakeLists.txt index 3c02e382ec0..17d4bfc91e5 100644 --- a/src/server/scripts/CMakeLists.txt +++ b/src/server/scripts/CMakeLists.txt @@ -81,6 +81,7 @@ include_directories( ${CMAKE_SOURCE_DIR}/src/server/game/AI/CoreAI ${CMAKE_SOURCE_DIR}/src/server/game/AI/EventAI ${CMAKE_SOURCE_DIR}/src/server/game/AI/ScriptedAI + ${CMAKE_SOURCE_DIR}/src/server/game/AI/SmartScripts ${CMAKE_SOURCE_DIR}/src/server/game/AuctionHouse ${CMAKE_SOURCE_DIR}/src/server/game/Battlegrounds ${CMAKE_SOURCE_DIR}/src/server/game/Battlegrounds/Zones diff --git a/src/server/scripts/Commands/CMakeLists.txt b/src/server/scripts/Commands/CMakeLists.txt index 1eac1322b0e..b688ee3e306 100644 --- a/src/server/scripts/Commands/CMakeLists.txt +++ b/src/server/scripts/Commands/CMakeLists.txt @@ -11,12 +11,12 @@ set(scripts_STAT_SRCS Commands/cs_tele.cpp # Commands/cs_character.cpp Commands/cs_event.cpp -# Commands/cs_gobject.cpp -# Commands/cs_honor.cpp -# Commands/cs_wp.cpp -# Commands/cs_titles.cpp -# Commands/cs_quest.cpp -# Commands/cs_reload.cpp + Commands/cs_gobject.cpp + Commands/cs_honor.cpp + Commands/cs_wp.cpp + Commands/cs_titles.cpp + Commands/cs_quest.cpp + Commands/cs_reload.cpp # Commands/cs_list.cpp # Commands/cs_lookup.cpp # Commands/cs_pdump.cpp @@ -27,7 +27,6 @@ set(scripts_STAT_SRCS # Commands/cs_server.cpp # Commands/cs_channel.cpp # Commands/cs_pet.cpp -# Commands/cs_loadpath.cpp # Commands/cs_ticket.cpp # Commands/cs_aura.cpp # Commands/cs_unaura.cpp diff --git a/src/server/scripts/Commands/cs_gm.cpp b/src/server/scripts/Commands/cs_gm.cpp index 07846c3cb43..3bbd560ef0b 100644 --- a/src/server/scripts/Commands/cs_gm.cpp +++ b/src/server/scripts/Commands/cs_gm.cpp @@ -133,10 +133,13 @@ class gm_commandscript : public CommandScript const char* name = itr->second->GetName(); uint8 security = itr_sec; uint8 max = ((16 - strlen(name)) / 2); + uint8 max2 = max; + if (((max)+(max2)+(strlen(name))) == 16) + max2 = ((max)-1); if (handler->GetSession()) - handler->PSendSysMessage("|%s GMLevel %u", name, security); + handler->PSendSysMessage("| %s GMLevel %u", name, security); else - handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max, " ", security); + handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max2, " ", security); } } if (footer) @@ -162,10 +165,13 @@ class gm_commandscript : public CommandScript const char* name = fields[0].GetCString(); uint8 security = fields[1].GetUInt8(); uint8 max = ((16 - strlen(name)) / 2); + uint8 max2 = max; + if (((max)+(max2)+(strlen(name))) == 16) + max2 = ((max)-1); if (handler->GetSession()) - handler->PSendSysMessage("|%s GMLevel %u", name, security); + handler->PSendSysMessage("| %s GMLevel %u", name, security); else - handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max, " ", security); + handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max2, " ", security); } while (result->NextRow()); diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp new file mode 100644 index 00000000000..8940005bbb9 --- /dev/null +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -0,0 +1,677 @@ +/* + * Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/* ScriptData +Name: gobject_commandscript +%Complete: 100 +Comment: All gobject related commands +Category: commandscripts +EndScriptData */ + +#include "ScriptMgr.h" +#include "GameEventMgr.h" +#include "ObjectMgr.h" +#include "PoolMgr.h" +#include "MapManager.h" +#include "Chat.h" + +class gobject_commandscript : public CommandScript +{ + public: + gobject_commandscript() : CommandScript("gobject_commandscript") { } + + ChatCommand* GetCommands() const + { + static ChatCommand gobjectAddCommandTable[] = + { + { "temp", SEC_GAMEMASTER, false, &HandleGameObjectAddTempCommand, "", NULL }, + { "", SEC_GAMEMASTER, false, &HandleGameObjectAddCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand gobjectSetCommandTable[] = + { + { "phase", SEC_GAMEMASTER, false, &HandleGameObjectSetPhaseCommand, "", NULL }, + { "state", SEC_GAMEMASTER, false, &HandleGameObjectSetStateCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand gobjectCommandTable[] = + { + { "activate", SEC_GAMEMASTER, false, &HandleGameObjectActivateCommand, "", NULL }, + { "delete", SEC_GAMEMASTER, false, &HandleGameObjectDeleteCommand, "", NULL }, + { "info", SEC_GAMEMASTER, false, &HandleGameObjectInfoCommand, "", NULL }, + { "move", SEC_GAMEMASTER, false, &HandleGameObjectMoveCommand, "", NULL }, + { "near", SEC_GAMEMASTER, false, &HandleGameObjectNearCommand, "", NULL }, + { "target", SEC_GAMEMASTER, false, &HandleGameObjectTargetCommand, "", NULL }, + { "turn", SEC_GAMEMASTER, false, &HandleGameObjectTurnCommand, "", NULL }, + { "add", SEC_GAMEMASTER, false, NULL, "", gobjectAddCommandTable }, + { "set", SEC_GAMEMASTER, false, NULL, "", gobjectSetCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = + { + { "gobject", SEC_GAMEMASTER, false, NULL, "", gobjectCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; + } + +static bool HandleGameObjectActivateCommand(ChatHandler* handler, const char* args) +{ + if (!*args) + return false; + + char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject"); + if (!cId) + return false; + + uint32 lowguid = atoi(cId); + if (!lowguid) + return false; + + GameObject* obj = NULL; + + // by DB guid + if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) + obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); + + if (!obj) + { + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + handler->SetSentErrorMessage(true); + return false; + } + + // Activate + obj->SetLootState(GO_READY); + obj->UseDoorOrButton(10000); + + handler->PSendSysMessage("Object activated!"); + + return true; +} + +//spawn go +static bool HandleGameObjectAddCommand(ChatHandler* handler, const char* args) +{ + if (!*args) + return false; + + // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject_entry"); + if (!cId) + return false; + + uint32 id = atol(cId); + if (!id) + return false; + + char* spawntimeSecs = strtok(NULL, " "); + + const GameObjectInfo *gInfo = sObjectMgr.GetGameObjectInfo(id); + + if (!gInfo) + { + handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); + handler->SetSentErrorMessage(true); + return false; + } + + if (gInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(gInfo->displayId)) + { + // report to DB errors log as in loading case + sLog.outErrorDb("Gameobject (Entry %u GoType: %u) have invalid displayId (%u), not spawned.",id, gInfo->type, gInfo->displayId); + handler->PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA,id); + handler->SetSentErrorMessage(true); + return false; + } + + Player *chr = handler->GetSession()->GetPlayer(); + float x = float(chr->GetPositionX()); + float y = float(chr->GetPositionY()); + float z = float(chr->GetPositionZ()); + float o = float(chr->GetOrientation()); + Map *map = chr->GetMap(); + + GameObject* pGameObj = new GameObject; + uint32 db_lowGUID = sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT); + + if (!pGameObj->Create(db_lowGUID, gInfo->id, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY)) + { + delete pGameObj; + return false; + } + + if (spawntimeSecs) + { + uint32 value = atoi((char*)spawntimeSecs); + pGameObj->SetRespawnTime(value); + //sLog.outDebug("*** spawntimeSecs: %d", value); + } + + // fill the gameobject data and save to the db + pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()),chr->GetPhaseMaskForSpawn()); + + // this will generate a new guid if the object is in an instance + if (!pGameObj->LoadFromDB(db_lowGUID, map)) + { + delete pGameObj; + return false; + } + + sLog.outDebug(handler->GetTrinityString(LANG_GAMEOBJECT_CURRENT), gInfo->name, db_lowGUID, x, y, z, o); + + map->Add(pGameObj); + + // TODO: is it really necessary to add both the real and DB table guid here ? + sObjectMgr.AddGameobjectToGrid(db_lowGUID, sObjectMgr.GetGOData(db_lowGUID)); + + handler->PSendSysMessage(LANG_GAMEOBJECT_ADD,id,gInfo->name,db_lowGUID,x,y,z); + return true; +} + +// add go, temp only +static bool HandleGameObjectAddTempCommand(ChatHandler* handler, const char* args) +{ + if (!*args) + return false; + char* charID = strtok((char*)args, " "); + if (!charID) + return false; + + Player *chr = handler->GetSession()->GetPlayer(); + + char* spawntime = strtok(NULL, " "); + uint32 spawntm = 300; + + if (spawntime) + spawntm = atoi((char*)spawntime); + + float x = chr->GetPositionX(); + float y = chr->GetPositionY(); + float z = chr->GetPositionZ(); + float ang = chr->GetOrientation(); + + float rot2 = sin(ang/2); + float rot3 = cos(ang/2); + + uint32 id = atoi(charID); + + chr->SummonGameObject(id,x,y,z,ang,0,0,rot2,rot3,spawntm); + + return true; +} + +static bool HandleGameObjectTargetCommand(ChatHandler* handler, const char* args) +{ + Player* pl = handler->GetSession()->GetPlayer(); + QueryResult result; + GameEventMgr::ActiveEvents const& activeEventsList = sGameEventMgr.GetActiveEventList(); + if (*args) + { + // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject_entry"); + if (!cId) + return false; + + uint32 id = atol(cId); + + if (id) + result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, orientation, map, phaseMask, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE map = '%i' AND id = '%u' ORDER BY order_ ASC LIMIT 1", + pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),id); + else + { + std::string name = cId; + WorldDatabase.escape_string(name); + result = WorldDatabase.PQuery( + "SELECT guid, id, position_x, position_y, position_z, orientation, map, phaseMask, (POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ " + "FROM gameobject,gameobject_template WHERE gameobject_template.entry = gameobject.id AND map = %i AND name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" ORDER BY order_ ASC LIMIT 1", + pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),name.c_str()); + } + } + else + { + std::ostringstream eventFilter; + eventFilter << " AND (event IS NULL "; + bool initString = true; + + for (GameEventMgr::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr) + { + if (initString) + { + eventFilter << "OR event IN (" <<*itr; + initString =false; + } + else + eventFilter << "," << *itr; + } + + if (!initString) + eventFilter << "))"; + else + eventFilter << ")"; + + result = WorldDatabase.PQuery("SELECT gameobject.guid, id, position_x, position_y, position_z, orientation, map, phaseMask, " + "(POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ FROM gameobject " + "LEFT OUTER JOIN game_event_gameobject on gameobject.guid=game_event_gameobject.guid WHERE map = '%i' %s ORDER BY order_ ASC LIMIT 10", + handler->GetSession()->GetPlayer()->GetPositionX(), handler->GetSession()->GetPlayer()->GetPositionY(), handler->GetSession()->GetPlayer()->GetPositionZ(), handler->GetSession()->GetPlayer()->GetMapId(),eventFilter.str().c_str()); + } + + if (!result) + { + handler->SendSysMessage(LANG_COMMAND_TARGETOBJNOTFOUND); + return true; + } + + bool found = false; + float x, y, z, o; + uint32 lowguid, id; + uint16 mapid, phase; + uint32 pool_id; + + do + { + Field *fields = result->Fetch(); + lowguid = fields[0].GetUInt32(); + id = fields[1].GetUInt32(); + x = fields[2].GetFloat(); + y = fields[3].GetFloat(); + z = fields[4].GetFloat(); + o = fields[5].GetFloat(); + mapid = fields[6].GetUInt16(); + phase = fields[7].GetUInt16(); + pool_id = sPoolMgr.IsPartOfAPool<GameObject>(lowguid); + if (!pool_id || sPoolMgr.IsSpawnedObject<GameObject>(lowguid)) + found = true; + } while (result->NextRow() && (!found)); + + if (!found) + { + handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); + return false; + } + + GameObjectInfo const* goI = sObjectMgr.GetGameObjectInfo(id); + + if (!goI) + { + handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); + return false; + } + + GameObject* target = handler->GetSession()->GetPlayer()->GetMap()->GetGameObject(MAKE_NEW_GUID(lowguid,id,HIGHGUID_GAMEOBJECT)); + + handler->PSendSysMessage(LANG_GAMEOBJECT_DETAIL, lowguid, goI->name, lowguid, id, x, y, z, mapid, o, phase); + + if (target) + { + int32 curRespawnDelay = int32(target->GetRespawnTimeEx()-time(NULL)); + if (curRespawnDelay < 0) + curRespawnDelay = 0; + + std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay,true); + std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true); + + handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str()); + } + return true; +} + +//delete object by selection or guid +static bool HandleGameObjectDeleteCommand(ChatHandler* handler, const char* args) +{ + // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject"); + if (!cId) + return false; + + uint32 lowguid = atoi(cId); + if (!lowguid) + return false; + + GameObject* obj = NULL; + + // by DB guid + if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) + obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); + + if (!obj) + { + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + handler->SetSentErrorMessage(true); + return false; + } + + uint64 owner_guid = obj->GetOwnerGUID(); + if (owner_guid) + { + Unit* owner = ObjectAccessor::GetUnit(*handler->GetSession()->GetPlayer(),owner_guid); + if (!owner || !IS_PLAYER_GUID(owner_guid)) + { + handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(owner_guid), obj->GetGUIDLow()); + handler->SetSentErrorMessage(true); + return false; + } + + owner->RemoveGameObject(obj,false); + } + + obj->SetRespawnTime(0); // not save respawn time + obj->Delete(); + obj->DeleteFromDB(); + + handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, obj->GetGUIDLow()); + + return true; +} + +//turn selected object +static bool HandleGameObjectTurnCommand(ChatHandler* handler, const char* args) +{ + // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject"); + if (!cId) + return false; + + uint32 lowguid = atoi(cId); + if (!lowguid) + return false; + + GameObject* obj = NULL; + + // by DB guid + if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) + obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); + + if (!obj) + { + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + handler->SetSentErrorMessage(true); + return false; + } + + char* po = strtok(NULL, " "); + float o; + + if (po) + { + o = (float)atof(po); + } + else + { + Player *chr = handler->GetSession()->GetPlayer(); + o = chr->GetOrientation(); + } + + obj->Relocate(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), o); + obj->UpdateRotationFields(); + obj->DestroyForNearbyPlayers(); + obj->UpdateObjectVisibility(); + + obj->SaveToDB(); + obj->Refresh(); + + handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name, obj->GetGUIDLow(), o); + + return true; +} + +//move selected object +static bool HandleGameObjectMoveCommand(ChatHandler* handler, const char* args) +{ + // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject"); + if (!cId) + return false; + + uint32 lowguid = atoi(cId); + if (!lowguid) + return false; + + GameObject* obj = NULL; + + // by DB guid + if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) + obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); + + if (!obj) + { + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + handler->SetSentErrorMessage(true); + return false; + } + + char* px = strtok(NULL, " "); + char* py = strtok(NULL, " "); + char* pz = strtok(NULL, " "); + + if (!px) + { + Player *chr = handler->GetSession()->GetPlayer(); + obj->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), obj->GetOrientation()); + obj->DestroyForNearbyPlayers(); + obj->UpdateObjectVisibility(); + } + else + { + if (!py || !pz) + return false; + + float x = (float)atof(px); + float y = (float)atof(py); + float z = (float)atof(pz); + + if (!MapManager::IsValidMapCoord(obj->GetMapId(),x,y,z)) + { + handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,obj->GetMapId()); + handler->SetSentErrorMessage(true); + return false; + } + + obj->Relocate(x, y, z, obj->GetOrientation()); + obj->DestroyForNearbyPlayers(); + obj->UpdateObjectVisibility(); + } + + obj->SaveToDB(); + obj->Refresh(); + + handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name, obj->GetGUIDLow()); + + return true; +} + +//set pahsemask for selected object +static bool HandleGameObjectSetPhaseCommand(ChatHandler* handler, const char* args) +{ + // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject"); + if (!cId) + return false; + + uint32 lowguid = atoi(cId); + if (!lowguid) + return false; + + GameObject* obj = NULL; + + // by DB guid + if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) + obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id); + + if (!obj) + { + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + handler->SetSentErrorMessage(true); + return false; + } + + char* phaseStr = strtok (NULL, " "); + uint32 phasemask = phaseStr? atoi(phaseStr) : 0; + if (phasemask == 0) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; + } + + obj->SetPhaseMask(phasemask,true); + obj->SaveToDB(); + return true; +} + +static bool HandleGameObjectNearCommand(ChatHandler* handler, const char* args) +{ + float distance = (!*args) ? 10.0f : (float)(atof(args)); + uint32 count = 0; + + Player* pl = handler->GetSession()->GetPlayer(); + QueryResult result = WorldDatabase.PQuery("SELECT guid, id, 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 map='%u' AND (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) <= '%f' ORDER BY order_", + pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), + pl->GetMapId(),pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),distance*distance); + + if (result) + { + do + { + Field *fields = result->Fetch(); + uint32 guid = fields[0].GetUInt32(); + uint32 entry = fields[1].GetUInt32(); + float x = fields[2].GetFloat(); + float y = fields[3].GetFloat(); + float z = fields[4].GetFloat(); + int mapid = fields[5].GetUInt16(); + + GameObjectInfo const * gInfo = sObjectMgr.GetGameObjectInfo(entry); + + if (!gInfo) + continue; + + handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name, x, y, z, mapid); + + ++count; + } while (result->NextRow()); + } + + handler->PSendSysMessage(LANG_COMMAND_NEAROBJMESSAGE,distance,count); + return true; +} + +//show info of gameobject +static bool HandleGameObjectInfoCommand(ChatHandler* handler, const char* args) +{ + uint32 entry = 0; + uint32 type = 0; + uint32 displayid = 0; + std::string name; + uint32 lootId = 0; + + if (!*args) + { + if (WorldObject * obj = handler->getSelectedObject()) + entry = obj->GetEntry(); + } + else + entry = atoi((char*)args); + + GameObjectInfo const* goinfo = sObjectMgr.GetGameObjectInfo(entry); + + if (!goinfo) + return false; + + type = goinfo->type; + displayid = goinfo->displayId; + name = goinfo->name; + if (type == GAMEOBJECT_TYPE_CHEST) + lootId = goinfo->chest.lootId; + else if (type == GAMEOBJECT_TYPE_FISHINGHOLE) + lootId = goinfo->fishinghole.lootId; + + handler->PSendSysMessage(LANG_GOINFO_ENTRY, entry); + handler->PSendSysMessage(LANG_GOINFO_TYPE, type); + handler->PSendSysMessage(LANG_GOINFO_LOOTID, lootId); + handler->PSendSysMessage(LANG_GOINFO_DISPLAYID, displayid); + handler->PSendSysMessage(LANG_GOINFO_NAME, name.c_str()); + + return true; +} +static bool HandleGameObjectSetStateCommand(ChatHandler* handler, const char* args) +{ + // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject"); + if (!cId) + return false; + + uint32 lowguid = atoi(cId); + if (!lowguid) + return false; + + GameObject* gobj = NULL; + + if (GameObjectData const* goData = sObjectMgr.GetGOData(lowguid)) + gobj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, goData->id); + + if (!gobj) + { + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid); + handler->SetSentErrorMessage(true); + return false; + } + + char* ctype = strtok(NULL, " "); + if (!ctype) + return false; + + int32 type = atoi(ctype); + if (type < 0) + { + if (type == -1) + gobj->SendObjectDeSpawnAnim(gobj->GetGUID()); + else if (type == -2) + { + return false; + } + return true; + } + + char* cstate = strtok(NULL, " "); + if (!cstate) + return false; + + int32 state = atoi(cstate); + + if (type < 4) + gobj->SetByteValue(GAMEOBJECT_BYTES_1, type, state); + else if (type == 4) + { + WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM,8+4); + data << gobj->GetGUID(); + data << (uint32)(state); + gobj->SendMessageToSet(&data, true); + } + handler->PSendSysMessage("Set gobject type %d state %d", type, state); + + return true; +} + +}; + +void AddSC_gobject_commandscript() +{ + new gobject_commandscript(); +} diff --git a/src/server/scripts/Commands/cs_honor.cpp b/src/server/scripts/Commands/cs_honor.cpp new file mode 100644 index 00000000000..211fdd30155 --- /dev/null +++ b/src/server/scripts/Commands/cs_honor.cpp @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/* ScriptData +Name: honor_commandscript +%Complete: 100 +Comment: All honor related commands +Category: commandscripts +EndScriptData */ + +#include "ScriptMgr.h" +#include "ObjectMgr.h" +#include "Chat.h" + +class honor_commandscript : public CommandScript +{ + public: + honor_commandscript() : CommandScript("honor_commandscript") { } + + ChatCommand* GetCommands() const + { + static ChatCommand honorAddCommandTable[] = + { + { "kill", SEC_GAMEMASTER, false, &HandleHonorAddKillCommand, "", NULL }, + { "", SEC_GAMEMASTER, false, &HandleHonorAddCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand honorCommandTable[] = + { + { "add", SEC_GAMEMASTER, false, NULL, "", honorAddCommandTable }, + { "update", SEC_GAMEMASTER, false, &HandleHonorUpdateCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = + { + { "honor", SEC_GAMEMASTER, false, NULL, "", honorCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; + } + + +static bool HandleHonorAddCommand(ChatHandler* handler, const char* args) +{ + if (!*args) + return false; + + Player *target = handler->getSelectedPlayer(); + if (!target) + { + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); + return false; + } + + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; + + uint32 amount = (uint32)atoi(args); + target->RewardHonor(NULL, 1, amount); + return true; +} + +static bool HandleHonorAddKillCommand(ChatHandler* handler, const char* /*args*/) +{ + Unit *target = handler->getSelectedUnit(); + if (!target) + { + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); + return false; + } + + // check online security + if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity((Player*)target, 0)) + return false; + + handler->GetSession()->GetPlayer()->RewardHonor(target, 1); + return true; +} + +static bool HandleHonorUpdateCommand(ChatHandler* handler, const char* /*args*/) +{ + Player *target = handler->getSelectedPlayer(); + if (!target) + { + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); + return false; + } + + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; + + target->UpdateHonorFields(); + return true; +} + +}; + +void AddSC_honor_commandscript() +{ + new honor_commandscript(); +} diff --git a/src/server/scripts/Commands/cs_quest.cpp b/src/server/scripts/Commands/cs_quest.cpp new file mode 100644 index 00000000000..07dbaee0855 --- /dev/null +++ b/src/server/scripts/Commands/cs_quest.cpp @@ -0,0 +1,260 @@ +/* + * Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/* ScriptData +Name: quest_commandscript +%Complete: 100 +Comment: All quest related commands +Category: commandscripts +EndScriptData */ + +#include "ScriptMgr.h" +#include "ObjectMgr.h" +#include "Chat.h" + +class quest_commandscript : public CommandScript +{ + public: + quest_commandscript() : CommandScript("quest_commandscript") { } + + ChatCommand* GetCommands() const + { + static ChatCommand questCommandTable[] = + { + { "add", SEC_ADMINISTRATOR, false, &HandleQuestAdd, "", NULL }, + { "complete", SEC_ADMINISTRATOR, false, &HandleQuestComplete, "", NULL }, + { "remove", SEC_ADMINISTRATOR, false, &HandleQuestRemove, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = + { + { "quest", SEC_ADMINISTRATOR, false, NULL, "", questCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; + } + +static bool HandleQuestAdd(ChatHandler* handler, const char* args) +{ + Player* player = handler->getSelectedPlayer(); + if (!player) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } + + // .addquest #entry' + // number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hquest"); + if (!cId) + return false; + + uint32 entry = atol(cId); + + Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry); + + if (!pQuest) + { + handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND,entry); + handler->SetSentErrorMessage(true); + return false; + } + + // check item starting quest (it can work incorrectly if added without item in inventory) + for (uint32 id = 0; id < sItemStorage.MaxEntry; id++) + { + ItemPrototype const *pProto = sItemStorage.LookupEntry<ItemPrototype>(id); + if (!pProto) + continue; + + if (pProto->StartQuest == entry) + { + handler->PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry, pProto->ItemId); + handler->SetSentErrorMessage(true); + return false; + } + } + + // ok, normal (creature/GO starting) quest + if (player->CanAddQuest(pQuest, true)) + { + player->AddQuest(pQuest, NULL); + + if (player->CanCompleteQuest(entry)) + player->CompleteQuest(entry); + } + + return true; +} + +static bool HandleQuestRemove(ChatHandler* handler, const char* args) +{ + Player* player = handler->getSelectedPlayer(); + if (!player) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } + + // .removequest #entry' + // number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hquest"); + if (!cId) + return false; + + uint32 entry = atol(cId); + + Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry); + + if (!pQuest) + { + handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry); + handler->SetSentErrorMessage(true); + return false; + } + + // remove all quest entries for 'entry' from quest log + for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot) + { + uint32 quest = player->GetQuestSlotQuestId(slot); + if (quest == entry) + { + player->SetQuestSlot(slot,0); + + // we ignore unequippable quest items in this case, its' still be equipped + player->TakeQuestSourceItem(quest, false); + } + } + + // set quest status to not started (will updated in DB at next save) + player->SetQuestStatus(entry, QUEST_STATUS_NONE); + + // reset rewarded for restart repeatable quest + player->getQuestStatusMap()[entry].m_rewarded = false; + + handler->SendSysMessage(LANG_COMMAND_QUEST_REMOVED); + return true; +} + +static bool HandleQuestComplete(ChatHandler* handler, const char* args) +{ + Player* player = handler->getSelectedPlayer(); + if (!player) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } + + // .quest complete #entry + // number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r + char* cId = handler->extractKeyFromLink((char*)args,"Hquest"); + if (!cId) + return false; + + uint32 entry = atol(cId); + + Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry); + + // If player doesn't have the quest + if (!pQuest || player->GetQuestStatus(entry) == QUEST_STATUS_NONE) + { + handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry); + handler->SetSentErrorMessage(true); + return false; + } + + // Add quest items for quests that require items + for (uint8 x = 0; x < QUEST_ITEM_OBJECTIVES_COUNT; ++x) + { + uint32 id = pQuest->ReqItemId[x]; + uint32 count = pQuest->ReqItemCount[x]; + if (!id || !count) + continue; + + uint32 curItemCount = player->GetItemCount(id,true); + + ItemPosCountVec dest; + uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, id, count-curItemCount); + if (msg == EQUIP_ERR_OK) + { + Item* item = player->StoreNewItem(dest, id, true); + player->SendNewItem(item,count-curItemCount,true,false); + } + } + + // All creature/GO slain/casted (not required, but otherwise it will display "Creature slain 0/10") + for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) + { + int32 creature = pQuest->ReqCreatureOrGOId[i]; + uint32 creaturecount = pQuest->ReqCreatureOrGOCount[i]; + + if (uint32 spell_id = pQuest->ReqSpell[i]) + { + for (uint16 z = 0; z < creaturecount; ++z) + player->CastedCreatureOrGO(creature,0,spell_id); + } + else if (creature > 0) + { + if (CreatureInfo const* cInfo = sObjectMgr.GetCreatureTemplate(creature)) + for (uint16 z = 0; z < creaturecount; ++z) + player->KilledMonster(cInfo,0); + } + else if (creature < 0) + { + for (uint16 z = 0; z < creaturecount; ++z) + player->CastedCreatureOrGO(creature,0,0); + } + } + + // If the quest requires reputation to complete + if (uint32 repFaction = pQuest->GetRepObjectiveFaction()) + { + uint32 repValue = pQuest->GetRepObjectiveValue(); + uint32 curRep = player->GetReputationMgr().GetReputation(repFaction); + if (curRep < repValue) + if (FactionEntry const *factionEntry = sFactionStore.LookupEntry(repFaction)) + player->GetReputationMgr().SetReputation(factionEntry,repValue); + } + + // If the quest requires a SECOND reputation to complete + if (uint32 repFaction = pQuest->GetRepObjectiveFaction2()) + { + uint32 repValue2 = pQuest->GetRepObjectiveValue2(); + uint32 curRep = player->GetReputationMgr().GetReputation(repFaction); + if (curRep < repValue2) + if (FactionEntry const *factionEntry = sFactionStore.LookupEntry(repFaction)) + player->GetReputationMgr().SetReputation(factionEntry,repValue2); + } + + // If the quest requires money + int32 ReqOrRewMoney = pQuest->GetRewOrReqMoney(); + if (ReqOrRewMoney < 0) + player->ModifyMoney(-ReqOrRewMoney); + + player->CompleteQuest(entry); + return true; +} + +}; + +void AddSC_quest_commandscript() +{ + new quest_commandscript(); +} diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp new file mode 100644 index 00000000000..85e2f5a0965 --- /dev/null +++ b/src/server/scripts/Commands/cs_reload.cpp @@ -0,0 +1,1302 @@ +/* + * Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/* ScriptData +Name: reload_commandscript +%Complete: 100 +Comment: All reload related commands +Category: commandscripts +EndScriptData */ + +#include "ScriptMgr.h" +#include "ObjectMgr.h" +#include "SpellMgr.h" +#include "TicketMgr.h" +#include "MapManager.h" +#include "CreatureEventAIMgr.h" +#include "DisableMgr.h" +#include "LFGMgr.h" +#include "AuctionHouseMgr.h" +#include "CreatureTextMgr.h" +#include "SmartAI.h" +#include "SkillDiscovery.h" +#include "SkillExtraItems.h" +#include "Chat.h" + +class reload_commandscript : public CommandScript +{ + public: + reload_commandscript() : CommandScript("reload_commandscript") { } + + ChatCommand* GetCommands() const + { + static ChatCommand reloadAllCommandTable[] = + { + { "achievement",SEC_ADMINISTRATOR, true, &HandleReloadAllAchievementCommand,"", NULL }, + { "area", SEC_ADMINISTRATOR, true, &HandleReloadAllAreaCommand, "", NULL }, + { "eventai", SEC_ADMINISTRATOR, true, &HandleReloadAllEventAICommand, "", NULL }, + { "gossips", SEC_ADMINISTRATOR, true, &HandleReloadAllGossipsCommand, "", NULL }, + { "item", SEC_ADMINISTRATOR, true, &HandleReloadAllItemCommand, "", NULL }, + { "locales", SEC_ADMINISTRATOR, true, &HandleReloadAllLocalesCommand, "", NULL }, + { "loot", SEC_ADMINISTRATOR, true, &HandleReloadAllLootCommand, "", NULL }, + { "npc", SEC_ADMINISTRATOR, true, &HandleReloadAllNpcCommand, "", NULL }, + { "quest", SEC_ADMINISTRATOR, true, &HandleReloadAllQuestCommand, "", NULL }, + { "scripts", SEC_ADMINISTRATOR, true, &HandleReloadAllScriptsCommand, "", NULL }, + { "spell", SEC_ADMINISTRATOR, true, &HandleReloadAllSpellCommand, "", NULL }, + { "", SEC_ADMINISTRATOR, true, &HandleReloadAllCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand reloadCommandTable[] = + { + { "auctions", SEC_ADMINISTRATOR, true, &HandleReloadAuctionsCommand, "", NULL }, + { "access_requirement", SEC_ADMINISTRATOR, true, &HandleReloadAccessRequirementCommand, "", NULL }, + { "achievement_criteria_data", SEC_ADMINISTRATOR, true, &HandleReloadAchievementCriteriaDataCommand, "", NULL }, + { "achievement_reward", SEC_ADMINISTRATOR, true, &HandleReloadAchievementRewardCommand, "", NULL }, + { "all", SEC_ADMINISTRATOR, true, NULL, "", reloadAllCommandTable }, + { "areatrigger_involvedrelation", SEC_ADMINISTRATOR, true, &HandleReloadQuestAreaTriggersCommand, "", NULL }, + { "areatrigger_tavern", SEC_ADMINISTRATOR, true, &HandleReloadAreaTriggerTavernCommand, "", NULL }, + { "areatrigger_teleport", SEC_ADMINISTRATOR, true, &HandleReloadAreaTriggerTeleportCommand, "", NULL }, + { "autobroadcast", SEC_ADMINISTRATOR, true, &HandleReloadAutobroadcastCommand, "", NULL }, + { "command", SEC_ADMINISTRATOR, true, &HandleReloadCommandCommand, "", NULL }, + { "conditions", SEC_ADMINISTRATOR, true, &HandleReloadConditions, "", NULL }, + { "config", SEC_ADMINISTRATOR, true, &HandleReloadConfigCommand, "", NULL }, + { "creature_text", SEC_ADMINISTRATOR, true, &HandleReloadCreatureText, "", NULL }, + { "creature_ai_scripts", SEC_ADMINISTRATOR, true, &HandleReloadEventAIScriptsCommand, "", NULL }, + { "creature_ai_summons", SEC_ADMINISTRATOR, true, &HandleReloadEventAISummonsCommand, "", NULL }, + { "creature_ai_texts", SEC_ADMINISTRATOR, true, &HandleReloadEventAITextsCommand, "", NULL }, + { "creature_involvedrelation", SEC_ADMINISTRATOR, true, &HandleReloadCreatureQuestInvRelationsCommand, "",NULL }, + { "creature_linked_respawn", SEC_GAMEMASTER, true, &HandleReloadCreatureLinkedRespawnCommand, "", NULL }, + { "creature_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesCreatureCommand, "", NULL }, + { "creature_onkill_reputation", SEC_ADMINISTRATOR, true, &HandleReloadOnKillReputationCommand, "", NULL }, + { "creature_questrelation", SEC_ADMINISTRATOR, true, &HandleReloadCreatureQuestRelationsCommand, "", NULL }, + { "creature_template", SEC_ADMINISTRATOR, true, &HandleReloadCreatureTemplateCommand, "", NULL }, + //{ "db_script_string", SEC_ADMINISTRATOR, true, &HandleReloadDbScriptStringCommand, "", NULL }, + { "disables", SEC_ADMINISTRATOR, true, &HandleReloadDisablesCommand, "", NULL }, + { "disenchant_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesDisenchantCommand, "", NULL }, + { "event_scripts", SEC_ADMINISTRATOR, true, &HandleReloadEventScriptsCommand, "", NULL }, + { "fishing_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesFishingCommand, "", NULL }, + { "game_graveyard_zone", SEC_ADMINISTRATOR, true, &HandleReloadGameGraveyardZoneCommand, "", NULL }, + { "game_tele", SEC_ADMINISTRATOR, true, &HandleReloadGameTeleCommand, "", NULL }, + { "gameobject_involvedrelation", SEC_ADMINISTRATOR, true, &HandleReloadGOQuestInvRelationsCommand, "", NULL }, + { "gameobject_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesGameobjectCommand, "", NULL }, + { "gameobject_questrelation", SEC_ADMINISTRATOR, true, &HandleReloadGOQuestRelationsCommand, "", NULL }, + { "gameobject_scripts", SEC_ADMINISTRATOR, true, &HandleReloadGameObjectScriptsCommand, "", NULL }, + { "gm_tickets", SEC_ADMINISTRATOR, true, &HandleReloadGMTicketsCommand, "", NULL }, + { "gossip_menu", SEC_ADMINISTRATOR, true, &HandleReloadGossipMenuCommand, "", NULL }, + { "gossip_menu_option", SEC_ADMINISTRATOR, true, &HandleReloadGossipMenuOptionCommand, "", NULL }, + { "gossip_scripts", SEC_ADMINISTRATOR, true, &HandleReloadGossipScriptsCommand, "", NULL }, + { "item_enchantment_template", SEC_ADMINISTRATOR, true, &HandleReloadItemEnchantementsCommand, "", NULL }, + { "item_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesItemCommand, "", NULL }, + { "item_set_names", SEC_ADMINISTRATOR, true, &HandleReloadItemSetNamesCommand, "", NULL }, + { "lfg_dungeon_encounters", SEC_ADMINISTRATOR, true, &HandleReloadLfgEncountersCommand, "", NULL }, + { "lfg_dungeon_rewards", SEC_ADMINISTRATOR, true, &HandleReloadLfgRewardsCommand, "", NULL }, + { "locales_achievement_reward", SEC_ADMINISTRATOR, true, &HandleReloadLocalesAchievementRewardCommand, "", NULL }, + { "locales_creature", SEC_ADMINISTRATOR, true, &HandleReloadLocalesCreatureCommand, "", NULL }, + { "locales_gameobject", SEC_ADMINISTRATOR, true, &HandleReloadLocalesGameobjectCommand, "", NULL }, + { "locales_gossip_menu_option", SEC_ADMINISTRATOR, true, &HandleReloadLocalesGossipMenuOptionCommand, "", NULL }, + { "locales_item", SEC_ADMINISTRATOR, true, &HandleReloadLocalesItemCommand, "", NULL }, + { "locales_item_set_name", SEC_ADMINISTRATOR, true, &HandleReloadLocalesItemSetNameCommand, "", NULL }, + { "locales_npc_text", SEC_ADMINISTRATOR, true, &HandleReloadLocalesNpcTextCommand, "", NULL }, + { "locales_page_text", SEC_ADMINISTRATOR, true, &HandleReloadLocalesPageTextCommand, "", NULL }, + { "locales_points_of_interest", SEC_ADMINISTRATOR, true, &HandleReloadLocalesPointsOfInterestCommand, "", NULL }, + { "locales_quest", SEC_ADMINISTRATOR, true, &HandleReloadLocalesQuestCommand, "", NULL }, + { "mail_level_reward", SEC_ADMINISTRATOR, true, &HandleReloadMailLevelRewardCommand, "", NULL }, + { "mail_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesMailCommand, "", NULL }, + { "milling_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesMillingCommand, "", NULL }, + { "npc_gossip", SEC_ADMINISTRATOR, true, &HandleReloadNpcGossipCommand, "", NULL }, + { "npc_spellclick_spells", SEC_ADMINISTRATOR, true, &HandleReloadSpellClickSpellsCommand, "",NULL}, + { "npc_trainer", SEC_ADMINISTRATOR, true, &HandleReloadNpcTrainerCommand, "", NULL }, + { "npc_vendor", SEC_ADMINISTRATOR, true, &HandleReloadNpcVendorCommand, "", NULL }, + { "page_text", SEC_ADMINISTRATOR, true, &HandleReloadPageTextsCommand, "", NULL }, + { "pickpocketing_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesPickpocketingCommand, "",NULL}, + { "points_of_interest", SEC_ADMINISTRATOR, true, &HandleReloadPointsOfInterestCommand, "", NULL }, + { "prospecting_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesProspectingCommand, "", NULL }, + { "quest_end_scripts", SEC_ADMINISTRATOR, true, &HandleReloadQuestEndScriptsCommand, "", NULL }, + { "quest_poi", SEC_ADMINISTRATOR, true, &HandleReloadQuestPOICommand, "", NULL }, + { "quest_start_scripts", SEC_ADMINISTRATOR, true, &HandleReloadQuestStartScriptsCommand, "", NULL }, + { "quest_template", SEC_ADMINISTRATOR, true, &HandleReloadQuestTemplateCommand, "", NULL }, + { "reference_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesReferenceCommand, "", NULL }, + { "reserved_name", SEC_ADMINISTRATOR, true, &HandleReloadReservedNameCommand, "", NULL }, + { "reputation_reward_rate", SEC_ADMINISTRATOR, true, &HandleReloadReputationRewardRateCommand, "", NULL }, + { "reputation_spillover_template",SEC_ADMINISTRATOR, true, &HandleReloadReputationRewardRateCommand, "", NULL }, + { "skill_discovery_template", SEC_ADMINISTRATOR, true, &HandleReloadSkillDiscoveryTemplateCommand, "", NULL }, + { "skill_extra_item_template", SEC_ADMINISTRATOR, true, &HandleReloadSkillExtraItemTemplateCommand, "", NULL }, + { "skill_fishing_base_level", SEC_ADMINISTRATOR, true, &HandleReloadSkillFishingBaseLevelCommand, "", NULL }, + { "skinning_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesSkinningCommand, "", NULL }, + { "smart_scripts", SEC_ADMINISTRATOR, true, &HandleReloadSmartScripts, "", NULL }, + { "spell_required", SEC_ADMINISTRATOR, true, &HandleReloadSpellRequiredCommand, "", NULL }, + { "spell_area", SEC_ADMINISTRATOR, true, &HandleReloadSpellAreaCommand, "", NULL }, + { "spell_bonus_data", SEC_ADMINISTRATOR, true, &HandleReloadSpellBonusesCommand, "", NULL }, + { "spell_group", SEC_ADMINISTRATOR, true, &HandleReloadSpellGroupsCommand, "", NULL }, + { "spell_learn_spell", SEC_ADMINISTRATOR, true, &HandleReloadSpellLearnSpellCommand, "", NULL }, + { "spell_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesSpellCommand, "", NULL }, + { "spell_linked_spell", SEC_ADMINISTRATOR, true, &HandleReloadSpellLinkedSpellCommand, "", NULL }, + { "spell_pet_auras", SEC_ADMINISTRATOR, true, &HandleReloadSpellPetAurasCommand, "", NULL }, + { "spell_proc_event", SEC_ADMINISTRATOR, true, &HandleReloadSpellProcEventCommand, "", NULL }, + { "spell_scripts", SEC_ADMINISTRATOR, true, &HandleReloadSpellScriptsCommand, "", NULL }, + { "spell_target_position", SEC_ADMINISTRATOR, true, &HandleReloadSpellTargetPositionCommand, "", NULL }, + { "spell_threats", SEC_ADMINISTRATOR, true, &HandleReloadSpellThreatsCommand, "", NULL }, + { "spell_group_stack_rules", SEC_ADMINISTRATOR, true, &HandleReloadSpellGroupStackRulesCommand, "", NULL }, + { "trinity_string", SEC_ADMINISTRATOR, true, &HandleReloadTrinityStringCommand, "", NULL }, + { "waypoint_scripts", SEC_ADMINISTRATOR, true, &HandleReloadWpScriptsCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = + { + { "reload", SEC_ADMINISTRATOR, true, NULL, "", reloadCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; + } + +//reload commands +static bool HandleReloadGMTicketsCommand(ChatHandler* handler, const char* /*args*/) +{ + sTicketMgr.LoadGMTickets(); + return true; +} + +static bool HandleReloadAllCommand(ChatHandler* handler, const char* /*args*/) +{ + HandleReloadSkillFishingBaseLevelCommand(handler,""); + + HandleReloadAllAchievementCommand(handler,""); + HandleReloadAllAreaCommand(handler,""); + HandleReloadAllEventAICommand(handler,""); + HandleReloadAllLootCommand(handler,""); + HandleReloadAllNpcCommand(handler,""); + HandleReloadAllQuestCommand(handler,""); + HandleReloadAllSpellCommand(handler,""); + HandleReloadAllItemCommand(handler,""); + HandleReloadAllGossipsCommand(handler,""); + HandleReloadAllLocalesCommand(handler,""); + + HandleReloadAccessRequirementCommand(handler,""); + HandleReloadMailLevelRewardCommand(handler,""); + HandleReloadCommandCommand(handler,""); + HandleReloadReservedNameCommand(handler,""); + HandleReloadTrinityStringCommand(handler,""); + HandleReloadGameTeleCommand(handler,""); + + HandleReloadAutobroadcastCommand(handler,""); + return true; +} + +static bool HandleReloadAllAchievementCommand(ChatHandler* handler, const char* /*args*/) +{ + HandleReloadAchievementCriteriaDataCommand(handler,""); + HandleReloadAchievementRewardCommand(handler,""); + return true; +} + +static bool HandleReloadAllAreaCommand(ChatHandler* handler, const char* /*args*/) +{ + //HandleReloadQuestAreaTriggersCommand(handler,""); -- reloaded in HandleReloadAllQuestCommand + HandleReloadAreaTriggerTeleportCommand(handler,""); + HandleReloadAreaTriggerTavernCommand(handler,""); + HandleReloadGameGraveyardZoneCommand(handler,""); + return true; +} + +static bool HandleReloadAllLootCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Loot Tables..."); + LoadLootTables(); + handler->SendGlobalGMSysMessage("DB tables `*_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; +} + +static bool HandleReloadAllNpcCommand(ChatHandler* handler, const char* args) +{ + if(*args != 'a') // will be reloaded from all_gossips + HandleReloadNpcGossipCommand(handler,"a"); + HandleReloadNpcTrainerCommand(handler,"a"); + HandleReloadNpcVendorCommand(handler,"a"); + HandleReloadPointsOfInterestCommand(handler,"a"); + HandleReloadSpellClickSpellsCommand(handler,"a"); + return true; +} + +static bool HandleReloadAllQuestCommand(ChatHandler* handler, const char* /*args*/) +{ + HandleReloadQuestAreaTriggersCommand(handler,"a"); + HandleReloadQuestPOICommand(handler,"a"); + HandleReloadQuestTemplateCommand(handler,"a"); + + sLog.outString("Re-Loading Quests Relations..."); + sObjectMgr.LoadQuestRelations(); + handler->SendGlobalGMSysMessage("DB tables `*_questrelation` and `*_involvedrelation` reloaded."); + return true; +} + +static bool HandleReloadAllScriptsCommand(ChatHandler* handler, const char* /*args*/) +{ + if (sWorld.IsScriptScheduled()) + { + handler->PSendSysMessage("DB scripts used currently, please attempt reload later."); + handler->SetSentErrorMessage(true); + return false; + } + + sLog.outString("Re-Loading Scripts..."); + HandleReloadGameObjectScriptsCommand(handler,"a"); + HandleReloadGossipScriptsCommand(handler,"a"); + HandleReloadEventScriptsCommand(handler,"a"); + HandleReloadQuestEndScriptsCommand(handler,"a"); + HandleReloadQuestStartScriptsCommand(handler,"a"); + HandleReloadSpellScriptsCommand(handler,"a"); + handler->SendGlobalGMSysMessage("DB tables `*_scripts` reloaded."); + HandleReloadDbScriptStringCommand(handler,"a"); + HandleReloadWpScriptsCommand(handler,"a"); + return true; +} + +static bool HandleReloadAllEventAICommand(ChatHandler* handler, const char* /*args*/) +{ + HandleReloadEventAITextsCommand(handler,"a"); + HandleReloadEventAISummonsCommand(handler,"a"); + HandleReloadEventAIScriptsCommand(handler,"a"); + return true; +} + +static bool HandleReloadAllSpellCommand(ChatHandler* handler, const char* /*args*/) +{ + HandleReloadSkillDiscoveryTemplateCommand(handler,"a"); + HandleReloadSkillExtraItemTemplateCommand(handler,"a"); + HandleReloadSpellRequiredCommand(handler,"a"); + HandleReloadSpellAreaCommand(handler,"a"); + HandleReloadSpellGroupsCommand(handler,"a"); + HandleReloadSpellLearnSpellCommand(handler,"a"); + HandleReloadSpellLinkedSpellCommand(handler,"a"); + HandleReloadSpellProcEventCommand(handler,"a"); + HandleReloadSpellBonusesCommand(handler,"a"); + HandleReloadSpellTargetPositionCommand(handler,"a"); + HandleReloadSpellThreatsCommand(handler,"a"); + HandleReloadSpellGroupStackRulesCommand(handler,"a"); + HandleReloadSpellPetAurasCommand(handler,"a"); + return true; +} + +static bool HandleReloadAllGossipsCommand(ChatHandler* handler, const char* args) +{ + HandleReloadGossipMenuCommand(handler,"a"); + HandleReloadGossipMenuOptionCommand(handler,"a"); + if(*args != 'a') // already reload from all_scripts + HandleReloadGossipScriptsCommand(handler,"a"); + HandleReloadNpcGossipCommand(handler,"a"); + HandleReloadPointsOfInterestCommand(handler,"a"); + return true; +} + +static bool HandleReloadAllItemCommand(ChatHandler* handler, const char* /*args*/) +{ + HandleReloadPageTextsCommand(handler,"a"); + HandleReloadItemEnchantementsCommand(handler,"a"); + return true; +} + +static bool HandleReloadAllLocalesCommand(ChatHandler* handler, const char* /*args*/) +{ + HandleReloadLocalesAchievementRewardCommand(handler,"a"); + HandleReloadLocalesCreatureCommand(handler,"a"); + HandleReloadLocalesGameobjectCommand(handler,"a"); + HandleReloadLocalesGossipMenuOptionCommand(handler,"a"); + HandleReloadLocalesItemCommand(handler,"a"); + HandleReloadLocalesNpcTextCommand(handler,"a"); + HandleReloadLocalesPageTextCommand(handler,"a"); + HandleReloadLocalesPointsOfInterestCommand(handler,"a"); + HandleReloadLocalesQuestCommand(handler,"a"); + return true; +} + +static bool HandleReloadConfigCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading config settings..."); + sWorld.LoadConfigSettings(true); + sMapMgr.InitializeVisibilityDistanceInfo(); + handler->SendGlobalGMSysMessage("World config settings reloaded."); + return true; +} + +static bool HandleReloadAccessRequirementCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Access Requirement definitions..."); + sObjectMgr.LoadAccessRequirements(); + handler->SendGlobalGMSysMessage("DB table `access_requirement` reloaded."); + return true; +} + +static bool HandleReloadAchievementCriteriaDataCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Additional Achievement Criteria Data..."); + sAchievementMgr.LoadAchievementCriteriaData(); + handler->SendGlobalGMSysMessage("DB table `achievement_criteria_data` reloaded."); + return true; +} + +static bool HandleReloadAchievementRewardCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Achievement Reward Data..."); + sAchievementMgr.LoadRewards(); + handler->SendGlobalGMSysMessage("DB table `achievement_reward` reloaded."); + return true; +} + +static bool HandleReloadAreaTriggerTavernCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Tavern Area Triggers..."); + sObjectMgr.LoadTavernAreaTriggers(); + handler->SendGlobalGMSysMessage("DB table `areatrigger_tavern` reloaded."); + return true; +} + +static bool HandleReloadAreaTriggerTeleportCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading AreaTrigger teleport definitions..."); + sObjectMgr.LoadAreaTriggerTeleports(); + handler->SendGlobalGMSysMessage("DB table `areatrigger_teleport` reloaded."); + return true; +} + +static bool HandleReloadAutobroadcastCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Autobroadcast..."); + sWorld.LoadAutobroadcasts(); + handler->SendGlobalGMSysMessage("DB table `autobroadcast` reloaded."); + return true; +} + +static bool HandleReloadCommandCommand(ChatHandler* handler, const char* /*args*/) +{ + handler->SetLoadCommandTable(true); + handler->SendGlobalGMSysMessage("DB table `command` will be reloaded at next chat command use."); + return true; +} + +static bool HandleReloadOnKillReputationCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading creature award reputation definitions..."); + sObjectMgr.LoadReputationOnKill(); + handler->SendGlobalGMSysMessage("DB table `creature_onkill_reputation` reloaded."); + return true; +} + +static bool HandleReloadCreatureTemplateCommand(ChatHandler* handler, const char* args) +{ + if (!*args) + return false; + + uint32 entry = (uint32) atoi((char*)args); + QueryResult result = WorldDatabase.PQuery("SELECT difficulty_entry_1,difficulty_entry_2,difficulty_entry_3,KillCredit1,KillCredit2,modelid1,modelid2,modelid3,modelid4,name,subname,IconName,gossip_menu_id,minlevel,maxlevel,exp,faction_A,faction_H,npcflag,speed_walk,speed_run,scale,rank,mindmg,maxdmg,dmgschool,attackpower,dmg_multiplier,baseattacktime,rangeattacktime,unit_class,unit_flags,dynamicflags,family,trainer_type,trainer_spell,trainer_class,trainer_race,minrangedmg,maxrangedmg,rangedattackpower,type,type_flags,lootid,pickpocketloot,skinloot,resistance1,resistance2,resistance3,resistance4,resistance5,resistance6,spell1,spell2,spell3,spell4,spell5,spell6,spell7,spell8,PetSpellDataId,VehicleId,mingold,maxgold,AIName,MovementType,InhabitType,Health_mod,Mana_mod,Armor_mod,RacialLeader,questItem1,questItem2,questItem3,questItem4,questItem5,questItem6,movementId,RegenHealth,equipment_id,mechanic_immune_mask,flags_extra,ScriptName FROM creature_template WHERE entry = %u", entry); + if (!result) + { + handler->PSendSysMessage(LANG_COMMAND_CREATURETEMPLATE_NOTFOUND, entry); + handler->SetSentErrorMessage(true); + return false; + } + + CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(entry); + if (!cInfo) + { + handler->PSendSysMessage(LANG_COMMAND_CREATURESTORAGE_NOTFOUND, entry); + handler->SetSentErrorMessage(true); + return false; + } + + sLog.outString("Reloading creature template entry %u", entry); + + Field *fields = result->Fetch(); + + const_cast<CreatureInfo*>(cInfo)->DifficultyEntry[0] = fields[0].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->DifficultyEntry[1] = fields[1].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->DifficultyEntry[2] = fields[2].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->KillCredit[0] = fields[3].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->KillCredit[1] = fields[4].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->Modelid1 = fields[5].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->Modelid2 = fields[6].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->Modelid3 = fields[7].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->Modelid4 = fields[8].GetUInt32(); + size_t len = 0; + if (const char* temp = fields[9].GetCString()) + { + delete[] cInfo->Name; + len = strlen(temp)+1; + const_cast<CreatureInfo*>(cInfo)->Name = new char[len]; + strncpy(cInfo->Name, temp, len); + } + if (const char* temp = fields[10].GetCString()) + { + delete[] cInfo->SubName; + len = strlen(temp)+1; + const_cast<CreatureInfo*>(cInfo)->SubName = new char[len]; + strncpy(cInfo->SubName, temp, len); + } + if (const char* temp = fields[11].GetCString()) + { + delete[] cInfo->IconName; + len = strlen(temp)+1; + const_cast<CreatureInfo*>(cInfo)->IconName = new char[len]; + strncpy(cInfo->IconName, temp, len); + } + const_cast<CreatureInfo*>(cInfo)->GossipMenuId = fields[12].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->minlevel = fields[13].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->maxlevel = fields[14].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->expansion = fields[15].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->faction_A = fields[16].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->faction_H = fields[17].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->npcflag = fields[18].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->speed_walk = fields[19].GetFloat(); + const_cast<CreatureInfo*>(cInfo)->speed_run = fields[20].GetFloat(); + const_cast<CreatureInfo*>(cInfo)->scale = fields[21].GetFloat(); + const_cast<CreatureInfo*>(cInfo)->rank = fields[22].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->mindmg = fields[23].GetFloat(); + const_cast<CreatureInfo*>(cInfo)->maxdmg = fields[24].GetFloat(); + const_cast<CreatureInfo*>(cInfo)->dmgschool = fields[25].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->attackpower = fields[26].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->dmg_multiplier = fields[27].GetFloat(); + const_cast<CreatureInfo*>(cInfo)->baseattacktime = fields[28].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->rangeattacktime = fields[29].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->unit_class = fields[30].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->unit_flags = fields[31].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->dynamicflags = fields[32].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->family = fields[33].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->trainer_type = fields[34].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->trainer_spell = fields[35].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->trainer_class = fields[36].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->trainer_race = fields[37].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->minrangedmg = fields[38].GetFloat(); + const_cast<CreatureInfo*>(cInfo)->maxrangedmg = fields[39].GetFloat(); + const_cast<CreatureInfo*>(cInfo)->rangedattackpower = fields[40].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->type = fields[41].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->type_flags = fields[42].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->lootid = fields[43].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->pickpocketLootId = fields[44].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->SkinLootId = fields[45].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->resistance1 = fields[46].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->resistance2 = fields[47].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->resistance3 = fields[48].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->resistance4 = fields[49].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->resistance5 = fields[50].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->resistance6 = fields[51].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->spells[0] = fields[52].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->spells[1] = fields[53].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->spells[2] = fields[54].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->spells[3] = fields[55].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->spells[4] = fields[56].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->spells[5] = fields[57].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->spells[6] = fields[58].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->spells[7] = fields[59].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->PetSpellDataId = fields[60].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->VehicleId = fields[61].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->mingold = fields[62].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->maxgold = fields[63].GetUInt32(); + if (const char* temp = fields[64].GetCString()) + { + delete[] cInfo->AIName; + len = strlen(temp)+1; + const_cast<CreatureInfo*>(cInfo)->AIName = new char[len]; + strncpy(const_cast<char*>(cInfo->AIName), temp, len); + } + const_cast<CreatureInfo*>(cInfo)->MovementType = fields[65].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->InhabitType = fields[66].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->ModHealth = fields[67].GetFloat(); + const_cast<CreatureInfo*>(cInfo)->ModMana = fields[68].GetFloat(); + const_cast<CreatureInfo*>(cInfo)->ModArmor = fields[69].GetFloat(); + const_cast<CreatureInfo*>(cInfo)->RacialLeader = fields[70].GetBool(); + const_cast<CreatureInfo*>(cInfo)->questItems[0] = fields[71].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->questItems[1] = fields[72].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->questItems[2] = fields[73].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->questItems[3] = fields[74].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->questItems[4] = fields[75].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->questItems[5] = fields[76].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->movementId = fields[77].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->RegenHealth = fields[78].GetBool(); + const_cast<CreatureInfo*>(cInfo)->equipmentId = fields[79].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->MechanicImmuneMask = fields[80].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->flags_extra = fields[81].GetUInt32(); + const_cast<CreatureInfo*>(cInfo)->ScriptID = sObjectMgr.GetScriptId(fields[82].GetCString()); + + sObjectMgr.CheckCreatureTemplate(cInfo); + + handler->SendGlobalGMSysMessage("Creature template reloaded."); + return true; +} + +static bool HandleReloadCreatureQuestRelationsCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Loading Quests Relations... (`creature_questrelation`)"); + sObjectMgr.LoadCreatureQuestRelations(); + handler->SendGlobalGMSysMessage("DB table `creature_questrelation` (creature quest givers) reloaded."); + return true; +} + +static bool HandleReloadCreatureLinkedRespawnCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Loading Linked Respawns... (`creature_linked_respawn`)"); + sObjectMgr.LoadCreatureLinkedRespawn(); + handler->SendGlobalGMSysMessage("DB table `creature_linked_respawn` (creature linked respawns) reloaded."); + return true; +} + +static bool HandleReloadCreatureQuestInvRelationsCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Loading Quests Relations... (`creature_involvedrelation`)"); + sObjectMgr.LoadCreatureInvolvedRelations(); + handler->SendGlobalGMSysMessage("DB table `creature_involvedrelation` (creature quest takers) reloaded."); + return true; +} + +static bool HandleReloadGossipMenuCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading `gossip_menu` Table!"); + sObjectMgr.LoadGossipMenu(); + handler->SendGlobalGMSysMessage("DB table `gossip_menu` reloaded."); + sConditionMgr.LoadConditions(true); + return true; +} + +static bool HandleReloadGossipMenuOptionCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading `gossip_menu_option` Table!"); + sObjectMgr.LoadGossipMenuItems(); + handler->SendGlobalGMSysMessage("DB table `gossip_menu_option` reloaded."); + sConditionMgr.LoadConditions(true); + return true; +} + +static bool HandleReloadGOQuestRelationsCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Loading Quests Relations... (`gameobject_questrelation`)"); + sObjectMgr.LoadGameobjectQuestRelations(); + handler->SendGlobalGMSysMessage("DB table `gameobject_questrelation` (gameobject quest givers) reloaded."); + return true; +} + +static bool HandleReloadGOQuestInvRelationsCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Loading Quests Relations... (`gameobject_involvedrelation`)"); + sObjectMgr.LoadGameobjectInvolvedRelations(); + handler->SendGlobalGMSysMessage("DB table `gameobject_involvedrelation` (gameobject quest takers) reloaded."); + return true; +} + +static bool HandleReloadQuestAreaTriggersCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Quest Area Triggers..."); + sObjectMgr.LoadQuestAreaTriggers(); + handler->SendGlobalGMSysMessage("DB table `areatrigger_involvedrelation` (quest area triggers) reloaded."); + return true; +} + +static bool HandleReloadQuestTemplateCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Quest Templates..."); + sObjectMgr.LoadQuests(); + handler->SendGlobalGMSysMessage("DB table `quest_template` (quest definitions) reloaded."); + + /// dependent also from `gameobject` but this table not reloaded anyway + sLog.outString("Re-Loading GameObjects for quests..."); + sObjectMgr.LoadGameObjectForQuests(); + handler->SendGlobalGMSysMessage("Data GameObjects for quests reloaded."); + return true; +} + +static bool HandleReloadLootTemplatesCreatureCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Loot Tables... (`creature_loot_template`)"); + LoadLootTemplates_Creature(); + LootTemplates_Creature.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `creature_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; +} + +static bool HandleReloadLootTemplatesDisenchantCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Loot Tables... (`disenchant_loot_template`)"); + LoadLootTemplates_Disenchant(); + LootTemplates_Disenchant.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `disenchant_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; +} + +static bool HandleReloadLootTemplatesFishingCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Loot Tables... (`fishing_loot_template`)"); + LoadLootTemplates_Fishing(); + LootTemplates_Fishing.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `fishing_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; +} + +static bool HandleReloadLootTemplatesGameobjectCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Loot Tables... (`gameobject_loot_template`)"); + LoadLootTemplates_Gameobject(); + LootTemplates_Gameobject.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `gameobject_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; +} + +static bool HandleReloadLootTemplatesItemCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Loot Tables... (`item_loot_template`)"); + LoadLootTemplates_Item(); + LootTemplates_Item.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `item_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; +} + +static bool HandleReloadLootTemplatesMillingCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Loot Tables... (`milling_loot_template`)"); + LoadLootTemplates_Milling(); + LootTemplates_Milling.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `milling_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; +} + +static bool HandleReloadLootTemplatesPickpocketingCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Loot Tables... (`pickpocketing_loot_template`)"); + LoadLootTemplates_Pickpocketing(); + LootTemplates_Pickpocketing.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `pickpocketing_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; +} + +static bool HandleReloadLootTemplatesProspectingCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Loot Tables... (`prospecting_loot_template`)"); + LoadLootTemplates_Prospecting(); + LootTemplates_Prospecting.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `prospecting_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; +} + +static bool HandleReloadLootTemplatesMailCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Loot Tables... (`mail_loot_template`)"); + LoadLootTemplates_Mail(); + LootTemplates_Mail.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `mail_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; +} + +static bool HandleReloadLootTemplatesReferenceCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Loot Tables... (`reference_loot_template`)"); + LoadLootTemplates_Reference(); + handler->SendGlobalGMSysMessage("DB table `reference_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; +} + +static bool HandleReloadLootTemplatesSkinningCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Loot Tables... (`skinning_loot_template`)"); + LoadLootTemplates_Skinning(); + LootTemplates_Skinning.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `skinning_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; +} + +static bool HandleReloadLootTemplatesSpellCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Loot Tables... (`spell_loot_template`)"); + LoadLootTemplates_Spell(); + LootTemplates_Spell.CheckLootRefs(); + handler->SendGlobalGMSysMessage("DB table `spell_loot_template` reloaded."); + sConditionMgr.LoadConditions(true); + return true; +} + +static bool HandleReloadTrinityStringCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading trinity_string Table!"); + sObjectMgr.LoadTrinityStrings(); + handler->SendGlobalGMSysMessage("DB table `trinity_string` reloaded."); + return true; +} + +static bool HandleReloadNpcGossipCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading `npc_gossip` Table!"); + sObjectMgr.LoadNpcTextId(); + handler->SendGlobalGMSysMessage("DB table `npc_gossip` reloaded."); + return true; +} + +static bool HandleReloadNpcTrainerCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading `npc_trainer` Table!"); + sObjectMgr.LoadTrainerSpell(); + handler->SendGlobalGMSysMessage("DB table `npc_trainer` reloaded."); + return true; +} + +static bool HandleReloadNpcVendorCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading `npc_vendor` Table!"); + sObjectMgr.LoadVendors(); + handler->SendGlobalGMSysMessage("DB table `npc_vendor` reloaded."); + return true; +} + +static bool HandleReloadPointsOfInterestCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading `points_of_interest` Table!"); + sObjectMgr.LoadPointsOfInterest(); + handler->SendGlobalGMSysMessage("DB table `points_of_interest` reloaded."); + return true; +} + +static bool HandleReloadQuestPOICommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString( "Re-Loading Quest POI ..." ); + sObjectMgr.LoadQuestPOI(); + handler->SendGlobalGMSysMessage("DB Table `quest_poi` and `quest_poi_points` reloaded."); + return true; +} + +static bool HandleReloadSpellClickSpellsCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading `npc_spellclick_spells` Table!"); + sObjectMgr.LoadNPCSpellClickSpells(); + handler->SendGlobalGMSysMessage("DB table `npc_spellclick_spells` reloaded."); + return true; +} + +static bool HandleReloadReservedNameCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Loading ReservedNames... (`reserved_name`)"); + sObjectMgr.LoadReservedPlayersNames(); + handler->SendGlobalGMSysMessage("DB table `reserved_name` (player reserved names) reloaded."); + return true; +} + +static bool HandleReloadReputationRewardRateCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString( "Re-Loading `reputation_reward_rate` Table!" ); + sObjectMgr.LoadReputationRewardRate(); + handler->SendGlobalSysMessage("DB table `reputation_reward_rate` reloaded."); + return true; +} + +static bool HandleReloadReputationSpilloverTemplateCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString( "Re-Loading `reputation_spillover_template` Table!" ); + sObjectMgr.LoadReputationSpilloverTemplate(); + handler->SendGlobalSysMessage("DB table `reputation_spillover_template` reloaded."); + return true; +} + +static bool HandleReloadSkillDiscoveryTemplateCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Skill Discovery Table..."); + LoadSkillDiscoveryTable(); + handler->SendGlobalGMSysMessage("DB table `skill_discovery_template` (recipes discovered at crafting) reloaded."); + return true; +} + +static bool HandleReloadSkillExtraItemTemplateCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Skill Extra Item Table..."); + LoadSkillExtraItemTable(); + handler->SendGlobalGMSysMessage("DB table `skill_extra_item_template` (extra item creation when crafting) reloaded."); + return true; +} + +static bool HandleReloadSkillFishingBaseLevelCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Skill Fishing base level requirements..."); + sObjectMgr.LoadFishingBaseSkillLevel(); + handler->SendGlobalGMSysMessage("DB table `skill_fishing_base_level` (fishing base level for zone/subzone) reloaded."); + return true; +} + +static bool HandleReloadSpellAreaCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading SpellArea Data..."); + sSpellMgr.LoadSpellAreas(); + handler->SendGlobalGMSysMessage("DB table `spell_area` (spell dependences from area/quest/auras state) reloaded."); + return true; +} + +static bool HandleReloadSpellRequiredCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Spell Required Data... "); + sSpellMgr.LoadSpellRequired(); + handler->SendGlobalGMSysMessage("DB table `spell_required` reloaded."); + return true; +} + +static bool HandleReloadSpellGroupsCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Spell Groups..."); + sSpellMgr.LoadSpellGroups(); + handler->SendGlobalGMSysMessage("DB table `spell_group` (spell groups) reloaded."); + return true; +} + +static bool HandleReloadSpellLearnSpellCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Spell Learn Spells..."); + sSpellMgr.LoadSpellLearnSpells(); + handler->SendGlobalGMSysMessage("DB table `spell_learn_spell` reloaded."); + return true; +} + +static bool HandleReloadSpellLinkedSpellCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Spell Linked Spells..."); + sSpellMgr.LoadSpellLinked(); + handler->SendGlobalGMSysMessage("DB table `spell_linked_spell` reloaded."); + return true; +} + +static bool HandleReloadSpellProcEventCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Spell Proc Event conditions..."); + sSpellMgr.LoadSpellProcEvents(); + handler->SendGlobalGMSysMessage("DB table `spell_proc_event` (spell proc trigger requirements) reloaded."); + return true; +} + +static bool HandleReloadSpellBonusesCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Spell Bonus Data..."); + sSpellMgr.LoadSpellBonusess(); + handler->SendGlobalGMSysMessage("DB table `spell_bonus_data` (spell damage/healing coefficients) reloaded."); + return true; +} + +static bool HandleReloadSpellTargetPositionCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Spell target coordinates..."); + sSpellMgr.LoadSpellTargetPositions(); + handler->SendGlobalGMSysMessage("DB table `spell_target_position` (destination coordinates for spell targets) reloaded."); + return true; +} + +static bool HandleReloadSpellThreatsCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Aggro Spells Definitions..."); + sSpellMgr.LoadSpellThreats(); + handler->SendGlobalGMSysMessage("DB table `spell_threat` (spell aggro definitions) reloaded."); + return true; +} + +static bool HandleReloadSpellGroupStackRulesCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Spell Group Stack Rules..."); + sSpellMgr.LoadSpellGroupStackRules(); + handler->SendGlobalGMSysMessage("DB table `spell_group_stack_rules` (spell stacking definitions) reloaded."); + return true; +} + +static bool HandleReloadSpellPetAurasCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Spell pet auras..."); + sSpellMgr.LoadSpellPetAuras(); + handler->SendGlobalGMSysMessage("DB table `spell_pet_auras` reloaded."); + return true; +} + +static bool HandleReloadPageTextsCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Page Texts..."); + sObjectMgr.LoadPageTexts(); + handler->SendGlobalGMSysMessage("DB table `page_texts` reloaded."); + return true; +} + +static bool HandleReloadItemEnchantementsCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Item Random Enchantments Table..."); + LoadRandomEnchantmentsTable(); + handler->SendGlobalGMSysMessage("DB table `item_enchantment_template` reloaded."); + return true; +} + +static bool HandleReloadItemSetNamesCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Item set names..."); + LoadRandomEnchantmentsTable(); + handler->SendGlobalGMSysMessage("DB table `item_set_names` reloaded."); + return true; +} + +static bool HandleReloadGossipScriptsCommand(ChatHandler* handler, const char* args) +{ + if (sWorld.IsScriptScheduled()) + { + handler->SendSysMessage("DB scripts used currently, please attempt reload later."); + handler->SetSentErrorMessage(true); + return false; + } + + if (*args != 'a') + sLog.outString("Re-Loading Scripts from `gossip_scripts`..."); + + sObjectMgr.LoadGossipScripts(); + + if (*args != 'a') + handler->SendGlobalGMSysMessage("DB table `gossip_scripts` reloaded."); + + return true; +} + +static bool HandleReloadGameObjectScriptsCommand(ChatHandler* handler, const char* args) +{ + if (sWorld.IsScriptScheduled()) + { + handler->SendSysMessage("DB scripts used currently, please attempt reload later."); + handler->SetSentErrorMessage(true); + return false; + } + + if (*args != 'a') + sLog.outString("Re-Loading Scripts from `gameobject_scripts`..."); + + sObjectMgr.LoadGameObjectScripts(); + + if (*args != 'a') + handler->SendGlobalGMSysMessage("DB table `gameobject_scripts` reloaded."); + + return true; +} + +static bool HandleReloadEventScriptsCommand(ChatHandler* handler, const char* args) +{ + if (sWorld.IsScriptScheduled()) + { + handler->SendSysMessage("DB scripts used currently, please attempt reload later."); + handler->SetSentErrorMessage(true); + return false; + } + + if (*args != 'a') + sLog.outString("Re-Loading Scripts from `event_scripts`..."); + + sObjectMgr.LoadEventScripts(); + + if (*args != 'a') + handler->SendGlobalGMSysMessage("DB table `event_scripts` reloaded."); + + return true; +} + +static bool HandleReloadWpScriptsCommand(ChatHandler* handler, const char* args) +{ + if (sWorld.IsScriptScheduled()) + { + handler->SendSysMessage("DB scripts used currently, please attempt reload later."); + handler->SetSentErrorMessage(true); + return false; + } + + if (*args != 'a') + sLog.outString("Re-Loading Scripts from `waypoint_scripts`..."); + + sObjectMgr.LoadWaypointScripts(); + + if (*args != 'a') + handler->SendGlobalGMSysMessage("DB table `waypoint_scripts` reloaded."); + + return true; +} + +static bool HandleReloadEventAITextsCommand(ChatHandler* handler, const char* /*args*/) +{ + + sLog.outString("Re-Loading Texts from `creature_ai_texts`..."); + sEventAIMgr.LoadCreatureEventAI_Texts(); + handler->SendGlobalGMSysMessage("DB table `creature_ai_texts` reloaded."); + return true; +} + +static bool HandleReloadEventAISummonsCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Summons from `creature_ai_summons`..."); + sEventAIMgr.LoadCreatureEventAI_Summons(); + handler->SendGlobalGMSysMessage("DB table `creature_ai_summons` reloaded."); + return true; +} + +static bool HandleReloadEventAIScriptsCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Scripts from `creature_ai_scripts`..."); + sEventAIMgr.LoadCreatureEventAI_Scripts(); + handler->SendGlobalGMSysMessage("DB table `creature_ai_scripts` reloaded."); + return true; +} + +static bool HandleReloadQuestEndScriptsCommand(ChatHandler* handler, const char* args) +{ + if (sWorld.IsScriptScheduled()) + { + handler->SendSysMessage("DB scripts used currently, please attempt reload later."); + handler->SetSentErrorMessage(true); + return false; + } + + if (*args != 'a') + sLog.outString("Re-Loading Scripts from `quest_end_scripts`..."); + + sObjectMgr.LoadQuestEndScripts(); + + if (*args != 'a') + handler->SendGlobalGMSysMessage("DB table `quest_end_scripts` reloaded."); + + return true; +} + +static bool HandleReloadQuestStartScriptsCommand(ChatHandler* handler, const char* args) +{ + if (sWorld.IsScriptScheduled()) + { + handler->SendSysMessage("DB scripts used currently, please attempt reload later."); + handler->SetSentErrorMessage(true); + return false; + } + + if (*args != 'a') + sLog.outString("Re-Loading Scripts from `quest_start_scripts`..."); + + sObjectMgr.LoadQuestStartScripts(); + + if (*args != 'a') + handler->SendGlobalGMSysMessage("DB table `quest_start_scripts` reloaded."); + + return true; +} + +static bool HandleReloadSpellScriptsCommand(ChatHandler* handler, const char* args) +{ + if (sWorld.IsScriptScheduled()) + { + handler->SendSysMessage("DB scripts used currently, please attempt reload later."); + handler->SetSentErrorMessage(true); + return false; + } + + if (*args != 'a') + sLog.outString("Re-Loading Scripts from `spell_scripts`..."); + + sObjectMgr.LoadSpellScripts(); + + if (*args != 'a') + handler->SendGlobalGMSysMessage("DB table `spell_scripts` reloaded."); + + return true; +} + +static bool HandleReloadDbScriptStringCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Script strings from `db_script_string`..."); + sObjectMgr.LoadDbScriptStrings(); + handler->SendGlobalGMSysMessage("DB table `db_script_string` reloaded."); + return true; +} + +static bool HandleReloadGameGraveyardZoneCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Graveyard-zone links..."); + + sObjectMgr.LoadGraveyardZones(); + + handler->SendGlobalGMSysMessage("DB table `game_graveyard_zone` reloaded."); + + return true; +} + +static bool HandleReloadGameTeleCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Game Tele coordinates..."); + + sObjectMgr.LoadGameTele(); + + handler->SendGlobalGMSysMessage("DB table `game_tele` reloaded."); + + return true; +} + +static bool HandleReloadDisablesCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading disables table..."); + sDisableMgr.LoadDisables(); + sLog.outString("Checking quest disables..."); + sDisableMgr.CheckQuestDisables(); + handler->SendGlobalGMSysMessage("DB table `disables` reloaded."); + return true; +} + +static bool HandleReloadLocalesAchievementRewardCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Locales Achievement Reward Data..."); + sAchievementMgr.LoadRewardLocales(); + handler->SendGlobalGMSysMessage("DB table `locales_achievement_reward` reloaded."); + return true; +} + +static bool HandleReloadLfgEncountersCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading dungeon encounter lfg associations..."); + sLFGMgr.LoadDungeonEncounters(); + handler->SendGlobalGMSysMessage("DB table `lfg_dungeon_encounters` reloaded."); + return true; +} + +static bool HandleReloadLfgRewardsCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading lfg dungeon rewards..."); + sLFGMgr.LoadRewards(); + handler->SendGlobalGMSysMessage("DB table `lfg_dungeon_rewards` reloaded."); + return true; +} + +static bool HandleReloadLocalesCreatureCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Locales Creature ..."); + sObjectMgr.LoadCreatureLocales(); + handler->SendGlobalGMSysMessage("DB table `locales_creature` reloaded."); + return true; +} + +static bool HandleReloadLocalesGameobjectCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Locales Gameobject ... "); + sObjectMgr.LoadGameObjectLocales(); + handler->SendGlobalGMSysMessage("DB table `locales_gameobject` reloaded."); + return true; +} + +static bool HandleReloadLocalesGossipMenuOptionCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString( "Re-Loading Locales Gossip Menu Option ... "); + sObjectMgr.LoadGossipMenuItemsLocales(); + handler->SendGlobalGMSysMessage("DB table `locales_gossip_menu_option` reloaded."); + return true; +} + +static bool HandleReloadLocalesItemCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Locales Item ... "); + sObjectMgr.LoadItemLocales(); + handler->SendGlobalGMSysMessage("DB table `locales_item` reloaded."); + return true; +} + +static bool HandleReloadLocalesItemSetNameCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Locales Item set name... "); + sObjectMgr.LoadItemSetNameLocales(); + handler->SendGlobalGMSysMessage("DB table `locales_item_set_name` reloaded."); + return true; +} + +static bool HandleReloadLocalesNpcTextCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Locales NPC Text ... "); + sObjectMgr.LoadNpcTextLocales(); + handler->SendGlobalGMSysMessage("DB table `locales_npc_text` reloaded."); + return true; +} + +static bool HandleReloadLocalesPageTextCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Locales Page Text ... "); + sObjectMgr.LoadPageTextLocales(); + handler->SendGlobalGMSysMessage("DB table `locales_page_text` reloaded."); + return true; +} + +static bool HandleReloadLocalesPointsOfInterestCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Locales Points Of Interest ... "); + sObjectMgr.LoadPointOfInterestLocales(); + handler->SendGlobalGMSysMessage("DB table `locales_points_of_interest` reloaded."); + return true; +} + +static bool HandleReloadLocalesQuestCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Locales Quest ... "); + sObjectMgr.LoadQuestLocales(); + handler->SendGlobalGMSysMessage("DB table `locales_quest` reloaded."); + return true; +} + +static bool HandleReloadMailLevelRewardCommand(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Player level dependent mail rewards..."); + sObjectMgr.LoadMailLevelRewards(); + handler->SendGlobalGMSysMessage("DB table `mail_level_reward` reloaded."); + return true; +} + +static bool HandleReloadAuctionsCommand(ChatHandler* handler, const char* /*args*/) +{ + ///- Reload dynamic data tables from the database + sLog.outString("Re-Loading Auctions..."); + sAuctionMgr.LoadAuctionItems(); + sAuctionMgr.LoadAuctions(); + handler->SendGlobalGMSysMessage("Auctions reloaded."); + return true; +} + +static bool HandleReloadConditions(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Conditions..."); + sConditionMgr.LoadConditions(true); + handler->SendGlobalGMSysMessage("Conditions reloaded."); + return true; +} + +static bool HandleReloadCreatureText(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Creature Texts..."); + sCreatureTextMgr.LoadCreatureTexts(); + handler->SendGlobalGMSysMessage("Creature Texts reloaded."); + return true; +} + +static bool HandleReloadSmartScripts(ChatHandler* handler, const char* /*args*/) +{ + sLog.outString("Re-Loading Smart Scripts..."); + sSmartScriptMgr.LoadSmartAIFromDB(); + handler->SendGlobalGMSysMessage("Smart Scripts reloaded."); + return true; +} + +}; + +void AddSC_reload_commandscript() +{ + new reload_commandscript(); +} diff --git a/src/server/scripts/Commands/cs_titles.cpp b/src/server/scripts/Commands/cs_titles.cpp new file mode 100644 index 00000000000..cf7bb4f828d --- /dev/null +++ b/src/server/scripts/Commands/cs_titles.cpp @@ -0,0 +1,250 @@ +/* + * Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/* ScriptData +Name: titles_commandscript +%Complete: 100 +Comment: All titles related commands +Category: commandscripts +EndScriptData */ + +#include "ScriptMgr.h" +#include "ObjectMgr.h" +#include "Chat.h" + +class titles_commandscript : public CommandScript +{ + public: + titles_commandscript() : CommandScript("titles_commandscript") { } + + ChatCommand* GetCommands() const + { + static ChatCommand titlesSetCommandTable[] = + { + { "mask", SEC_GAMEMASTER, false, &HandleTitlesSetMaskCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand titlesCommandTable[] = + { + { "add", SEC_GAMEMASTER, false, &HandleTitlesAddCommand, "", NULL }, + { "current", SEC_GAMEMASTER, false, &HandleTitlesCurrentCommand, "", NULL }, + { "remove", SEC_GAMEMASTER, false, &HandleTitlesRemoveCommand, "", NULL }, + { "set", SEC_GAMEMASTER, false, NULL, "", titlesSetCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = + { + { "titles", SEC_GAMEMASTER, false, NULL, "", titlesCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; + } + +static bool HandleTitlesCurrentCommand(ChatHandler* handler, const char* args) +{ + // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r + char* id_p = handler->extractKeyFromLink((char*)args,"Htitle"); + if (!id_p) + return false; + + int32 id = atoi(id_p); + if (id <= 0) + { + handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id); + handler->SetSentErrorMessage(true); + return false; + } + + Player * target = handler->getSelectedPlayer(); + if (!target) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } + + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; + + CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); + if (!titleInfo) + { + handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id); + handler->SetSentErrorMessage(true); + return false; + } + + std::string tNameLink = handler->GetNameLink(target); + + target->SetTitle(titleInfo); // to be sure that title now known + target->SetUInt32Value(PLAYER_CHOSEN_TITLE,titleInfo->bit_index); + + handler->PSendSysMessage(LANG_TITLE_CURRENT_RES, id, titleInfo->name[handler->GetSessionDbcLocale()], tNameLink.c_str()); + + return true; +} + +static bool HandleTitlesAddCommand(ChatHandler* handler, const char* args) +{ + // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r + char* id_p = handler->extractKeyFromLink((char*)args,"Htitle"); + if (!id_p) + return false; + + int32 id = atoi(id_p); + if (id <= 0) + { + handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id); + handler->SetSentErrorMessage(true); + return false; + } + + Player * target = handler->getSelectedPlayer(); + if (!target) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } + + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; + + CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); + if (!titleInfo) + { + handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id); + handler->SetSentErrorMessage(true); + return false; + } + + std::string tNameLink = handler->GetNameLink(target); + + char const* targetName = target->GetName(); + char titleNameStr[80]; + snprintf(titleNameStr,80,titleInfo->name[handler->GetSessionDbcLocale()],targetName); + + target->SetTitle(titleInfo); + handler->PSendSysMessage(LANG_TITLE_ADD_RES, id, titleNameStr, tNameLink.c_str()); + + return true; +} + +static bool HandleTitlesRemoveCommand(ChatHandler* handler, const char* args) +{ + // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r + char* id_p = handler->extractKeyFromLink((char*)args,"Htitle"); + if (!id_p) + return false; + + int32 id = atoi(id_p); + if (id <= 0) + { + handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id); + handler->SetSentErrorMessage(true); + return false; + } + + Player * target = handler->getSelectedPlayer(); + if (!target) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } + + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; + + CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); + if (!titleInfo) + { + handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id); + handler->SetSentErrorMessage(true); + return false; + } + + target->SetTitle(titleInfo,true); + + std::string tNameLink = handler->GetNameLink(target); + + char const* targetName = target->GetName(); + char titleNameStr[80]; + snprintf(titleNameStr,80,titleInfo->name[handler->GetSessionDbcLocale()],targetName); + + handler->PSendSysMessage(LANG_TITLE_REMOVE_RES, id, titleNameStr, tNameLink.c_str()); + + if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE))) + { + target->SetUInt32Value(PLAYER_CHOSEN_TITLE,0); + handler->PSendSysMessage(LANG_CURRENT_TITLE_RESET, tNameLink.c_str()); + } + + return true; +} + +//Edit Player KnownTitles +static bool HandleTitlesSetMaskCommand(ChatHandler* handler, const char* args) +{ + if (!*args) + return false; + + uint64 titles = 0; + + sscanf((char*)args, UI64FMTD, &titles); + + Player *target = handler->getSelectedPlayer(); + if (!target) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } + + // check online security + if (handler->HasLowerSecurity(target, 0)) + return false; + + uint64 titles2 = titles; + + for (uint32 i = 1; i < sCharTitlesStore.GetNumRows(); ++i) + if (CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i)) + titles2 &= ~(uint64(1) << tEntry->bit_index); + + titles &= ~titles2; // remove not existed titles + + target->SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES, titles); + handler->SendSysMessage(LANG_DONE); + + if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE))) + { + target->SetUInt32Value(PLAYER_CHOSEN_TITLE,0); + handler->PSendSysMessage(LANG_CURRENT_TITLE_RESET,handler->GetNameLink(target).c_str()); + } + + return true; +} + +}; + +void AddSC_titles_commandscript() +{ + new titles_commandscript(); +} diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp new file mode 100644 index 00000000000..3aac13b5911 --- /dev/null +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -0,0 +1,981 @@ +/* + * Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/* ScriptData +Name: wp_commandscript +%Complete: 100 +Comment: All wp related commands +Category: commandscripts +EndScriptData */ + +#include "ScriptMgr.h" +#include "ObjectMgr.h" +#include "WaypointManager.h" +#include "Chat.h" + +class wp_commandscript : public CommandScript +{ + public: + wp_commandscript() : CommandScript("wp_commandscript") { } + + ChatCommand* GetCommands() const + { + static ChatCommand wpCommandTable[] = + { + { "add", SEC_GAMEMASTER, false, &HandleWpAddCommand, "", NULL }, + { "event", SEC_GAMEMASTER, false, &HandleWpEventCommand, "", NULL }, + { "load", SEC_GAMEMASTER, false, &HandleWpLoadCommand, "", NULL }, + { "modify", SEC_GAMEMASTER, false, &HandleWpModifyCommand, "", NULL }, + { "unload", SEC_GAMEMASTER, false, &HandleWpUnLoadCommand, "", NULL }, + { "reload", SEC_ADMINISTRATOR, false, &HandleWpReloadCommand, "", NULL }, + { "show", SEC_GAMEMASTER, false, &HandleWpShowCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = + { + { "wp", SEC_GAMEMASTER, false, NULL, "", wpCommandTable }, + { NULL, 0, false, NULL, "", NULL } + }; + return commandTable; + } + +/** + * Add a waypoint to a creature. + * + * The user can either select an npc or provide its GUID. + * + * The user can even select a visual waypoint - then the new waypoint + * is placed *after* the selected one - this makes insertion of new + * waypoints possible. + * + * eg: + * .wp add 12345 + * -> adds a waypoint to the npc with the GUID 12345 + * + * .wp add + * -> adds a waypoint to the currently selected creature + * + * + * @param args if the user did not provide a GUID, it is NULL + * + * @return true - command did succeed, false - something went wrong + */ +static bool HandleWpAddCommand(ChatHandler* handler, const char* args) +{ + sLog.outDebug("DEBUG: HandleWpAddCommand"); + + // optional + char* path_number = NULL; + uint32 pathid = 0; + + if (*args) + path_number = strtok((char*)args, " "); + + uint32 point = 0; + Creature* target = handler->getSelectedCreature(); + + if (!path_number) + { + if (target) + pathid = target->GetWaypointPath(); + else + { + QueryResult result = WorldDatabase.Query("SELECT MAX(id) FROM waypoint_data"); + uint32 maxpathid = result->Fetch()->GetInt32(); + pathid = maxpathid+1; + sLog.outDebug("DEBUG: HandleWpAddCommand - New path started."); + handler->PSendSysMessage("%s%s|r", "|cff00ff00", "New path started."); + } + } + else + pathid = atoi(path_number); + + // path_id -> ID of the Path + // point -> number of the waypoint (if not 0) + + if (!pathid) + { + sLog.outDebug("DEBUG: HandleWpAddCommand - Current creature haven't loaded path."); + handler->PSendSysMessage("%s%s|r", "|cffff33ff", "Current creature haven't loaded path."); + return true; + } + + sLog.outDebug("DEBUG: HandleWpAddCommand - point == 0"); + + QueryResult result = WorldDatabase.PQuery("SELECT MAX(point) FROM waypoint_data WHERE id = '%u'",pathid); + + if (result) + point = (*result)[0].GetUInt32(); + + Player* player = handler->GetSession()->GetPlayer(); + //Map *map = player->GetMap(); + + WorldDatabase.PExecute("INSERT INTO waypoint_data (id, point, position_x, position_y, position_z) VALUES ('%u','%u','%f', '%f', '%f')", + pathid, point+1, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); + + handler->PSendSysMessage("%s%s%u%s%u%s|r", "|cff00ff00", "PathID: |r|cff00ffff", pathid, "|r|cff00ff00: Waypoint |r|cff00ffff", point+1,"|r|cff00ff00 created. "); + return true; +} // HandleWpAddCommand + +static bool HandleWpLoadCommand(ChatHandler* handler, const char* args) +{ + if (!*args) + return false; + + // optional + char* path_number = NULL; + + if (*args) + path_number = strtok((char*)args, " "); + + uint32 pathid = 0; + uint32 guidlow = 0; + Creature* target = handler->getSelectedCreature(); + + // Did player provide a path_id? + if (!path_number) + sLog.outDebug("DEBUG: HandleWpLoadPathCommand - No path number provided"); + + if (!target) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } + + if (target->GetEntry() == 1) + { + handler->PSendSysMessage("%s%s|r", "|cffff33ff", "You want to load path to a waypoint? Aren't you?"); + handler->SetSentErrorMessage(true); + return false; + } + + pathid = atoi(path_number); + + if (!pathid) + { + handler->PSendSysMessage("%s%s|r", "|cffff33ff", "No vallid path number provided."); + return true; + } + + guidlow = target->GetDBTableGUIDLow(); + QueryResult result = WorldDatabase.PQuery("SELECT guid FROM creature_addon WHERE guid = '%u'",guidlow); + + if (result) + WorldDatabase.PExecute("UPDATE creature_addon SET path_id = '%u' WHERE guid = '%u'", pathid, guidlow); + else + WorldDatabase.PExecute("INSERT INTO creature_addon(guid,path_id) VALUES ('%u','%u')", guidlow, pathid); + + WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE, guidlow); + + target->LoadPath(pathid); + target->SetDefaultMovementType(WAYPOINT_MOTION_TYPE); + target->GetMotionMaster()->Initialize(); + target->MonsterSay("Path loaded.",0,0); + + return true; +} + +static bool HandleWpReloadCommand(ChatHandler* handler, const char* args) +{ + if (!*args) + return false; + + uint32 id = atoi(args); + + if (!id) + return false; + + handler->PSendSysMessage("%s%s|r|cff00ffff%u|r", "|cff00ff00", "Loading Path: ", id); + sWaypointMgr->UpdatePath(id); + return true; +} +static bool HandleWpUnLoadCommand(ChatHandler* handler, const char* /*args*/) +{ + uint32 guidlow = 0; + Creature* target = handler->getSelectedCreature(); + + if (!target) + { + handler->PSendSysMessage("%s%s|r", "|cff33ffff", "You must select target."); + return true; + } + + if (target->GetCreatureAddon()) + { + if (target->GetCreatureAddon()->path_id != 0) + { + WorldDatabase.PExecute("DELETE FROM creature_addon WHERE guid = %u", target->GetGUIDLow()); + target->UpdateWaypointID(0); + WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", IDLE_MOTION_TYPE, guidlow); + target->LoadPath(0); + target->SetDefaultMovementType(IDLE_MOTION_TYPE); + target->GetMotionMaster()->MoveTargetedHome(); + target->GetMotionMaster()->Initialize(); + target->MonsterSay("Path unloaded.",0,0); + return true; + } + handler->PSendSysMessage("%s%s|r", "|cffff33ff", "Target have no loaded path."); + } + return true; +} + +static bool HandleWpEventCommand(ChatHandler* handler, const char* args) +{ + if (!*args) + return false; + + char* show_str = strtok((char*)args, " "); + std::string show = show_str; + + // Check + if ((show != "add") && (show != "mod") && (show != "del") && (show != "listid")) return false; + + char* arg_id = strtok(NULL, " "); + uint32 id = 0; + + if (show == "add") + { + if (arg_id) + id = atoi(arg_id); + + if (id) + { + QueryResult result = WorldDatabase.PQuery("SELECT id FROM waypoint_scripts WHERE guid = %u", id); + + if (!result) + { + WorldDatabase.PExecute("INSERT INTO waypoint_scripts(guid)VALUES(%u)", id); + handler->PSendSysMessage("%s%s%u|r", "|cff00ff00", "Wp Event: New waypoint event added: ", id); + } + else + handler->PSendSysMessage("|cff00ff00Wp Event: You have choosed an existing waypoint script guid: %u|r", id); + } + else + { + QueryResult result = WorldDatabase.Query("SELECT MAX(guid) FROM waypoint_scripts"); + id = result->Fetch()->GetUInt32(); + WorldDatabase.PExecute("INSERT INTO waypoint_scripts(guid)VALUES(%u)", id+1); + handler->PSendSysMessage("%s%s%u|r", "|cff00ff00","Wp Event: New waypoint event added: |r|cff00ffff", id+1); + } + + return true; + } + + if (show == "listid") + { + if (!arg_id) + { + handler->PSendSysMessage("%s%s|r", "|cff33ffff","Wp Event: You must provide waypoint script id."); + return true; + } + + id = atoi(arg_id); + + uint32 a2, a3, a4, a5, a6; + float a8, a9, a10, a11; + char const* a7; + + QueryResult result = WorldDatabase.PQuery("SELECT guid, delay, command, datalong, datalong2, dataint, x, y, z, o FROM waypoint_scripts WHERE id = %u", id); + + if (!result) + { + handler->PSendSysMessage("%s%s%u|r", "|cff33ffff", "Wp Event: No waypoint scripts found on id: ", id); + return true; + } + + Field *fields; + + do + { + fields = result->Fetch(); + a2 = fields[0].GetUInt32(); + a3 = fields[1].GetUInt32(); + a4 = fields[2].GetUInt32(); + a5 = fields[3].GetUInt32(); + a6 = fields[4].GetUInt32(); + a7 = fields[5].GetCString(); + a8 = fields[6].GetFloat(); + a9 = fields[7].GetFloat(); + a10 = fields[8].GetFloat(); + a11 = fields[9].GetFloat(); + + handler->PSendSysMessage("|cffff33ffid:|r|cff00ffff %u|r|cff00ff00, guid: |r|cff00ffff%u|r|cff00ff00, delay: |r|cff00ffff%u|r|cff00ff00, command: |r|cff00ffff%u|r|cff00ff00, datalong: |r|cff00ffff%u|r|cff00ff00, datalong2: |r|cff00ffff%u|r|cff00ff00, datatext: |r|cff00ffff%s|r|cff00ff00, posx: |r|cff00ffff%f|r|cff00ff00, posy: |r|cff00ffff%f|r|cff00ff00, posz: |r|cff00ffff%f|r|cff00ff00, orientation: |r|cff00ffff%f|r", id, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); + } + while (result->NextRow()); + } + + if (show == "del") + { + id = atoi(arg_id); + + QueryResult result = WorldDatabase.PQuery("SELECT guid FROM waypoint_scripts WHERE guid = %u", id); + + if (result) + { + WorldDatabase.PExecute("DELETE FROM waypoint_scripts WHERE guid = %u", id); + handler->PSendSysMessage("%s%s%u|r","|cff00ff00","Wp Event: Waypoint script removed: ", id); + } + else + handler->PSendSysMessage("|cffff33ffWp Event: ERROR: you have selected a non existing script: %u|r", id); + + return true; + } + + if (show == "mod") + { + if (!arg_id) + { + handler->SendSysMessage("|cffff33ffERROR: Waypoint script guid not present.|r"); + return true; + } + + id = atoi(arg_id); + + if (!id) + { + handler->SendSysMessage("|cffff33ffERROR: No vallid waypoint script id not present.|r"); + return true; + } + + char* arg_2 = strtok(NULL," "); + + if (!arg_2) + { + handler->SendSysMessage("|cffff33ffERROR: No argument present.|r"); + return true; + } + + std::string arg_string = arg_2; + + if ((arg_string != "setid") && (arg_string != "delay") && (arg_string != "command") + && (arg_string != "datalong") && (arg_string != "datalong2") && (arg_string != "dataint") && (arg_string != "posx") + && (arg_string != "posy") && (arg_string != "posz") && (arg_string != "orientation")) + { + handler->SendSysMessage("|cffff33ffERROR: No valid argument present.|r"); + return true; + } + + char* arg_3; + std::string arg_str_2 = arg_2; + arg_3 = strtok(NULL," "); + + if (!arg_3) + { + handler->SendSysMessage("|cffff33ffERROR: No additional argument present.|r"); + return true; + } + + float coord; + + if (arg_str_2 == "setid") + { + uint32 newid = atoi(arg_3); + handler->PSendSysMessage("%s%s|r|cff00ffff%u|r|cff00ff00%s|r|cff00ffff%u|r","|cff00ff00","Wp Event: Wypoint scipt guid: ", newid," id changed: ", id); + WorldDatabase.PExecute("UPDATE waypoint_scripts SET id='%u' WHERE guid='%u'", + newid, id); return true; + } + else + { + QueryResult result = WorldDatabase.PQuery("SELECT id FROM waypoint_scripts WHERE guid='%u'",id); + + if (!result) + { + handler->SendSysMessage("|cffff33ffERROR: You have selected an non existing waypoint script guid.|r"); + return true; + } + + if (arg_str_2 == "posx") + { + coord = (float)(atof(arg_3)); + WorldDatabase.PExecute("UPDATE waypoint_scripts SET x='%f' WHERE guid='%u'", + coord, id); + handler->PSendSysMessage("|cff00ff00Waypoint script:|r|cff00ffff %u|r|cff00ff00 position_x updated.|r", id); + return true; + } + else if (arg_str_2 == "posy") + { + coord = (float)(atof(arg_3)); + WorldDatabase.PExecute("UPDATE waypoint_scripts SET y='%f' WHERE guid='%u'", + coord, id); + handler->PSendSysMessage("|cff00ff00Waypoint script: %u position_y updated.|r", id); + return true; + } + else if (arg_str_2 == "posz") + { + coord = (float)(atof(arg_3)); + WorldDatabase.PExecute("UPDATE waypoint_scripts SET z='%f' WHERE guid='%u'", + coord, id); + handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 position_z updated.|r", id); + return true; + } + else if (arg_str_2 == "orientation") + { + coord = (float)(atof(arg_3)); + WorldDatabase.PExecute("UPDATE waypoint_scripts SET o='%f' WHERE guid='%u'", + coord, id); + handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 orientation updated.|r", id); + return true; + } + else if (arg_str_2 == "dataint") + { + WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%u' WHERE guid='%u'", + arg_2, atoi(arg_3), id); + handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 dataint updated.|r", id); + return true; + } + else + { + std::string arg_str_3 = arg_3; + WorldDatabase.escape_string(arg_str_3); + WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%s' WHERE guid='%u'", + arg_2, arg_str_3.c_str(), id); + } + } + handler->PSendSysMessage("%s%s|r|cff00ffff%u:|r|cff00ff00 %s %s|r","|cff00ff00","Waypoint script:", id, arg_2,"updated."); + } + return true; +} + +static bool HandleWpModifyCommand(ChatHandler* handler, const char* args) +{ + sLog.outDebug("DEBUG: HandleWpModifyCommand"); + + if (!*args) + return false; + + // first arg: add del text emote spell waittime move + char* show_str = strtok((char*)args, " "); + if (!show_str) + { + return false; + } + + std::string show = show_str; + // Check + // Remember: "show" must also be the name of a column! + if ((show != "delay") && (show != "action") && (show != "action_chance") + && (show != "move_flag") && (show != "del") && (show != "move") && (show != "wpadd") +) + { + return false; + } + + // Next arg is: <PATHID> <WPNUM> <ARGUMENT> + char* arg_str = NULL; + + // Did user provide a GUID + // or did the user select a creature? + // -> variable lowguid is filled with the GUID of the NPC + uint32 pathid = 0; + uint32 point = 0; + uint32 wpGuid = 0; + Creature* target = handler->getSelectedCreature(); + + if (!target || target->GetEntry() != VISUAL_WAYPOINT) + { + handler->SendSysMessage("|cffff33ffERROR: You must select a waypoint.|r"); + return false; + } + + sLog.outDebug("DEBUG: HandleWpModifyCommand - User did select an NPC"); + // The visual waypoint + Creature* wpCreature = NULL; + wpGuid = target->GetGUIDLow(); + + // Did the user select a visual spawnpoint? + if (wpGuid) + wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); + // attempt check creature existence by DB data + else + { + handler->PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, wpGuid); + return false; + } + // User did select a visual waypoint? + // Check the creature + if (wpCreature->GetEntry() == VISUAL_WAYPOINT) + { + QueryResult result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE wpguid = %u", wpGuid); + + if (!result) + { + sLog.outDebug("DEBUG: HandleWpModifyCommand - No waypoint found - used 'wpguid'"); + + handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUIDLow()); + // Select waypoint number from database + // Since we compare float values, we have to deal with + // some difficulties. + // Here we search for all waypoints that only differ in one from 1 thousand + // (0.001) - There is no other way to compare C++ floats with mySQL floats + // See also: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html + const char* maxDIFF = "0.01"; + result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE (abs(position_x - %f) <= %s) and (abs(position_y - %f) <= %s) and (abs(position_z - %f) <= %s)", + wpCreature->GetPositionX(), maxDIFF, wpCreature->GetPositionY(), maxDIFF, wpCreature->GetPositionZ(), maxDIFF); + if (!result) + { + handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid); + return true; + } + } + sLog.outDebug("DEBUG: HandleWpModifyCommand - After getting wpGuid"); + + do + { + Field *fields = result->Fetch(); + pathid = fields[0].GetUInt32(); + point = fields[1].GetUInt32(); + } + while (result->NextRow()); + + // We have the waypoint number and the GUID of the "master npc" + // Text is enclosed in "<>", all other arguments not + arg_str = strtok((char*)NULL, " "); + } + + sLog.outDebug("DEBUG: HandleWpModifyCommand - Parameters parsed - now execute the command"); + + // Check for argument + if (show != "del" && show != "move" && arg_str == NULL) + { + handler->PSendSysMessage(LANG_WAYPOINT_ARGUMENTREQ, show_str); + return false; + } + + if (show == "del" && target) + { + handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid); + + // wpCreature + Creature* wpCreature = NULL; + + if (wpGuid != 0) + { + wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); + wpCreature->CombatStop(); + wpCreature->DeleteFromDB(); + wpCreature->AddObjectToRemoveList(); + } + + WorldDatabase.PExecute("DELETE FROM waypoint_data WHERE id='%u' AND point='%u'", + pathid, point); + WorldDatabase.PExecute("UPDATE waypoint_data SET point=point-1 WHERE id='%u' AND point>'%u'", + pathid, point); + + handler->PSendSysMessage(LANG_WAYPOINT_REMOVED); + return true; + } // del + + if (show == "move" && target) + { + handler->PSendSysMessage("|cff00ff00DEBUG: wp move, PathID: |r|cff00ffff%u|r", pathid); + + Player *chr = handler->GetSession()->GetPlayer(); + Map *map = chr->GetMap(); + { + // wpCreature + Creature* wpCreature = NULL; + // What to do: + // Move the visual spawnpoint + // Respawn the owner of the waypoints + if (wpGuid != 0) + { + wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT)); + wpCreature->CombatStop(); + wpCreature->DeleteFromDB(); + wpCreature->AddObjectToRemoveList(); + // re-create + Creature* wpCreature2 = new Creature; + if (!wpCreature2->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0, 0, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation())) + { + handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT); + delete wpCreature2; + return false; + } + + wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); + // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); + wpCreature2->LoadFromDB(wpCreature2->GetDBTableGUIDLow(), map); + map->Add(wpCreature2); + //sMapMgr.GetMap(npcCreature->GetMapId())->Add(wpCreature2); + } + + WorldDatabase.PExecute("UPDATE waypoint_data SET position_x = '%f',position_y = '%f',position_z = '%f' where id = '%u' AND point='%u'", + chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), pathid, point); + + handler->PSendSysMessage(LANG_WAYPOINT_CHANGED); + } + return true; + } // move + + const char *text = arg_str; + + if (text == 0) + { + // show_str check for present in list of correct values, no sql injection possible + WorldDatabase.PExecute("UPDATE waypoint_data SET %s=NULL WHERE id='%u' AND point='%u'", + show_str, pathid, point); + } + else + { + // show_str check for present in list of correct values, no sql injection possible + std::string text2 = text; + WorldDatabase.escape_string(text2); + WorldDatabase.PExecute("UPDATE waypoint_data SET %s='%s' WHERE id='%u' AND point='%u'", + show_str, text2.c_str(), pathid, point); + } + + handler->PSendSysMessage(LANG_WAYPOINT_CHANGED_NO, show_str); + return true; +} + +static bool HandleWpShowCommand(ChatHandler* handler, const char* args) +{ + sLog.outDebug("DEBUG: HandleWpShowCommand"); + + if (!*args) + return false; + + // first arg: on, off, first, last + char* show_str = strtok((char*)args, " "); + if (!show_str) + return false; + + // second arg: GUID (optional, if a creature is selected) + char* guid_str = strtok((char*)NULL, " "); + sLog.outDebug("DEBUG: HandleWpShowCommand: show_str: %s guid_str: %s", show_str, guid_str); + + uint32 pathid = 0; + Creature* target = handler->getSelectedCreature(); + + // Did player provide a PathID? + + if (!guid_str) + { + sLog.outDebug("DEBUG: HandleWpShowCommand: !guid_str"); + // No PathID provided + // -> Player must have selected a creature + + if (!target) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } + + pathid = target->GetWaypointPath(); + } + else + { + sLog.outDebug("|cff00ff00DEBUG: HandleWpShowCommand: PathID provided|r"); + // PathID provided + // Warn if player also selected a creature + // -> Creature selection is ignored <- + if (target) + handler->SendSysMessage(LANG_WAYPOINT_CREATSELECTED); + + pathid = atoi((char*)guid_str); + } + + sLog.outDebug("DEBUG: HandleWpShowCommand: danach"); + + std::string show = show_str; + uint32 Maxpoint; + + sLog.outDebug("DEBUG: HandleWpShowCommand: PathID: %u", pathid); + + //handler->PSendSysMessage("wpshow - show: %s", show); + + // Show info for the selected waypoint + if (show == "info") + { + // Check if the user did specify a visual waypoint + if (target->GetEntry() != VISUAL_WAYPOINT) + { + handler->PSendSysMessage(LANG_WAYPOINT_VP_SELECT); + handler->SetSentErrorMessage(true); + return false; + } + + QueryResult result = WorldDatabase.PQuery("SELECT id, point, delay, move_flag, action, action_chance FROM waypoint_data WHERE wpguid = %u", target->GetGUIDLow()); + + if (!result) + { + handler->SendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM); + return true; + } + + handler->SendSysMessage("|cff00ffffDEBUG: wp show info:|r"); + do + { + Field *fields = result->Fetch(); + pathid = fields[0].GetUInt32(); + uint32 point = fields[1].GetUInt32(); + uint32 delay = fields[2].GetUInt32(); + uint32 flag = fields[3].GetUInt32(); + uint32 ev_id = fields[4].GetUInt32(); + uint32 ev_chance = fields[5].GetUInt32(); + + handler->PSendSysMessage("|cff00ff00Show info: for current point: |r|cff00ffff%u|r|cff00ff00, Path ID: |r|cff00ffff%u|r", point, pathid); + handler->PSendSysMessage("|cff00ff00Show info: delay: |r|cff00ffff%u|r", delay); + handler->PSendSysMessage("|cff00ff00Show info: Move flag: |r|cff00ffff%u|r", flag); + handler->PSendSysMessage("|cff00ff00Show info: Waypoint event: |r|cff00ffff%u|r", ev_id); + handler->PSendSysMessage("|cff00ff00Show info: Event chance: |r|cff00ffff%u|r", ev_chance); + } + while (result->NextRow()); + + return true; + } + + if (show == "on") + { + QueryResult result = WorldDatabase.PQuery("SELECT point, position_x,position_y,position_z FROM waypoint_data WHERE id = '%u'", pathid); + + if (!result) + { + handler->SendSysMessage("|cffff33ffPath no found.|r"); + handler->SetSentErrorMessage(true); + return false; + } + + handler->PSendSysMessage("|cff00ff00DEBUG: wp on, PathID: |cff00ffff%u|r", pathid); + + // Delete all visuals for this NPC + QueryResult result2 = WorldDatabase.PQuery("SELECT wpguid FROM waypoint_data WHERE id = '%u' and wpguid <> 0", pathid); + + if (result2) + { + bool hasError = false; + do + { + Field *fields = result2->Fetch(); + uint32 wpguid = fields[0].GetUInt32(); + Creature* pCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpguid,VISUAL_WAYPOINT,HIGHGUID_UNIT)); + + if (!pCreature) + { + handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, wpguid); + hasError = true; + WorldDatabase.PExecute("DELETE FROM creature WHERE guid = '%u'", wpguid); + } + else + { + pCreature->CombatStop(); + pCreature->DeleteFromDB(); + pCreature->AddObjectToRemoveList(); + } + + } + while (result2->NextRow()); + + if (hasError) + { + handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR1); + handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR2); + handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR3); + } + } + + do + { + Field *fields = result->Fetch(); + uint32 point = fields[0].GetUInt32(); + float x = fields[1].GetFloat(); + float y = fields[2].GetFloat(); + float z = fields[3].GetFloat(); + + uint32 id = VISUAL_WAYPOINT; + + Player *chr = handler->GetSession()->GetPlayer(); + Map *map = chr->GetMap(); + float o = chr->GetOrientation(); + + Creature* wpCreature = new Creature; + if (!wpCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o)) + { + handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); + delete wpCreature; + return false; + } + + sLog.outDebug("DEBUG: UPDATE waypoint_data SET wpguid = '%u' WHERE id = '%u' and point = '%u'", wpCreature->GetGUIDLow(), pathid, point); + // set "wpguid" column to the visual waypoint + WorldDatabase.PExecute("UPDATE waypoint_data SET wpguid = '%u' WHERE id = '%u' and point = '%u'", wpCreature->GetGUIDLow(), pathid, point); + + wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); + // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); + wpCreature->LoadFromDB(wpCreature->GetDBTableGUIDLow(),map); + map->Add(wpCreature); + + if (target) + { + wpCreature->SetDisplayId(target->GetDisplayId()); + wpCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5); + wpCreature->SetLevel(point > STRONG_MAX_LEVEL ? STRONG_MAX_LEVEL : point); + } + } + while (result->NextRow()); + + handler->SendSysMessage("|cff00ff00Showing the current creature's path.|r"); + return true; + } + + if (show == "first") + { + handler->PSendSysMessage("|cff00ff00DEBUG: wp first, GUID: %u|r", pathid); + + QueryResult result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z FROM waypoint_data WHERE point='1' AND id = '%u'",pathid); + if (!result) + { + handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUND, pathid); + handler->SetSentErrorMessage(true); + return false; + } + + Field *fields = result->Fetch(); + float x = fields[0].GetFloat(); + float y = fields[1].GetFloat(); + float z = fields[2].GetFloat(); + uint32 id = VISUAL_WAYPOINT; + + Player *chr = handler->GetSession()->GetPlayer(); + float o = chr->GetOrientation(); + Map *map = chr->GetMap(); + + Creature* pCreature = new Creature; + if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT),map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o)) + { + handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id); + delete pCreature; + return false; + } + + pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); + pCreature->LoadFromDB(pCreature->GetDBTableGUIDLow(), map); + map->Add(pCreature); + + if (target) + { + pCreature->SetDisplayId(target->GetDisplayId()); + pCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5); + } + + return true; + } + + if (show == "last") + { + handler->PSendSysMessage("|cff00ff00DEBUG: wp last, PathID: |r|cff00ffff%u|r", pathid); + + QueryResult result = WorldDatabase.PQuery("SELECT MAX(point) FROM waypoint_data WHERE id = '%u'",pathid); + if (result) + Maxpoint = (*result)[0].GetUInt32(); + else + Maxpoint = 0; + + result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z FROM waypoint_data WHERE point ='%u' AND id = '%u'",Maxpoint, pathid); + if (!result) + { + handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDLAST, pathid); + handler->SetSentErrorMessage(true); + return false; + } + Field *fields = result->Fetch(); + float x = fields[0].GetFloat(); + float y = fields[1].GetFloat(); + float z = fields[2].GetFloat(); + uint32 id = VISUAL_WAYPOINT; + + Player *chr = handler->GetSession()->GetPlayer(); + float o = chr->GetOrientation(); + Map *map = chr->GetMap(); + + Creature* pCreature = new Creature; + if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o)) + { + handler->PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id); + delete pCreature; + return false; + } + + pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); + pCreature->LoadFromDB(pCreature->GetDBTableGUIDLow(), map); + map->Add(pCreature); + + if (target) + { + pCreature->SetDisplayId(target->GetDisplayId()); + pCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5); + } + + return true; + } + + if (show == "off") + { + QueryResult result = WorldDatabase.PQuery("SELECT guid FROM creature WHERE id = '%u'", 1); + if (!result) + { + handler->SendSysMessage(LANG_WAYPOINT_VP_NOTFOUND); + handler->SetSentErrorMessage(true); + return false; + } + bool hasError = false; + do + { + Field *fields = result->Fetch(); + uint32 guid = fields[0].GetUInt32(); + Creature* pCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(guid,VISUAL_WAYPOINT,HIGHGUID_UNIT)); + if (!pCreature) + { + handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, guid); + hasError = true; + WorldDatabase.PExecute("DELETE FROM creature WHERE guid = '%u'", guid); + } + else + { + pCreature->CombatStop(); + pCreature->DeleteFromDB(); + pCreature->AddObjectToRemoveList(); + } + } + while (result->NextRow()); + // set "wpguid" column to "empty" - no visual waypoint spawned + WorldDatabase.PExecute("UPDATE waypoint_data SET wpguid = '0'"); + //WorldDatabase.PExecute("UPDATE creature_movement SET wpguid = '0' WHERE wpguid <> '0'"); + + if (hasError) + { + handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR1); + handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR2); + handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR3); + } + + handler->SendSysMessage(LANG_WAYPOINT_VP_ALLREMOVED); + return true; + } + + handler->PSendSysMessage("|cffff33ffDEBUG: wpshow - no valid command found|r"); + return true; +} + +}; + +void AddSC_wp_commandscript() +{ + new wp_commandscript(); +} |