diff options
author | click <none@none> | 2010-11-12 20:47:03 +0100 |
---|---|---|
committer | click <none@none> | 2010-11-12 20:47:03 +0100 |
commit | e22426c7c0c0aa4088d079a821fc13233ba78887 (patch) | |
tree | 2518027911ed61e51280596570639dbd07209a24 | |
parent | 43d8a64232641979eb823654f97aac52ccc3e63f (diff) |
Core/Scripts: Reinstate commandscripts, now with extra bling and working commands (and yes, we did test it thoroughly this time)
Thanks to Paradox for sorting the commandscripts and chanhandlers out to work as they were intentionally ment to be like.
--HG--
branch : trunk
-rw-r--r-- | sql/base/world_database.sql | 56 | ||||
-rwxr-xr-x | src/server/game/Chat/Chat.cpp | 222 | ||||
-rwxr-xr-x | src/server/game/Chat/Chat.h | 154 | ||||
-rwxr-xr-x | src/server/game/Chat/Commands/Debugcmds.cpp | 1101 | ||||
-rwxr-xr-x | src/server/game/Chat/Commands/Level0.cpp | 148 | ||||
-rwxr-xr-x | src/server/game/Chat/Commands/Level1.cpp | 1572 | ||||
-rwxr-xr-x | src/server/game/Chat/Commands/Level2.cpp | 1580 | ||||
-rwxr-xr-x | src/server/game/Chat/Commands/Level3.cpp | 1525 | ||||
-rwxr-xr-x | src/server/game/Chat/Commands/TicketCommands.cpp | 42 | ||||
-rwxr-xr-x | src/server/game/Scripting/ScriptLoader.cpp | 6 | ||||
-rw-r--r-- | src/server/game/Scripting/ScriptLoader.h | 2 | ||||
-rw-r--r-- | src/server/scripts/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_gm.cpp | 35 | ||||
-rwxr-xr-x | src/server/worldserver/CommandLine/CliRunnable.cpp | 146 |
14 files changed, 105 insertions, 6487 deletions
diff --git a/sql/base/world_database.sql b/sql/base/world_database.sql index 0819301b499..120e47ae6d1 100644 --- a/sql/base/world_database.sql +++ b/sql/base/world_database.sql @@ -446,15 +446,15 @@ INSERT INTO `command` VALUES ('kick',2,'Syntax: .kick [$charactername] [$reason]\r\n\r\nKick the given character name from the world with or without reason. If no character name is provided then the selected player (except for yourself) will be kicked. If no reason is provided, default is \"No Reason\".'), ('learn',3,'Syntax: .learn #spell [all]\r\n\r\nSelected character learn a spell of id #spell. If ''all'' provided then all ranks learned.'), ('learn all',3,'Syntax: .learn all\r\n\r\nLearn all big set different spell maybe useful for Administaror.'), -('learn all_crafts',2,'Syntax: .learn crafts\r\n\r\nLearn all professions and recipes.'), -('learn all_default',1,'Syntax: .learn all_default [$playername]\r\n\r\nLearn for selected/$playername player all default spells for his race/class and spells rewarded by completed quests.'), -('learn all_gm',2,'Syntax: .learn all_gm\r\n\r\nLearn all default spells for Game Masters.'), -('learn all_lang',1,'Syntax: .learn all_lang\r\n\r\nLearn all languages'), -('learn all_myclass',3,'Syntax: .learn all_myclass\r\n\r\nLearn all spells and talents available for his class.'), -('learn all_mypettalents',3,'Syntax: .learn all_mypettalents\r\n\r\nLearn all talents for your pet available for his creature type (only for hunter pets).'), -('learn all_myspells',3,'Syntax: .learn all_myspells\r\n\r\nLearn all spells (except talents and spells with first rank learned as talent) available for his class.'), -('learn all_mytalents',3,'Syntax: .learn all_mytalents\r\n\r\nLearn all talents (and spells with first rank learned as talent) available for his class.'), -('learn all_recipes',2,'Syntax: .learn all_recipes [$profession]\r\rLearns all recipes of specified profession and sets skill level to max.\rExample: .learn all_recipes enchanting'), +('learn all crafts',2,'Syntax: .learn crafts\r\n\r\nLearn all professions and recipes.'), +('learn all default',1,'Syntax: .learn all default [$playername]\r\n\r\nLearn for selected/$playername player all default spells for his race/class and spells rewarded by completed quests.'), +('learn all gm',2,'Syntax: .learn all gm\r\n\r\nLearn all default spells for Game Masters.'), +('learn all lang',1,'Syntax: .learn all lang\r\n\r\nLearn all languages'), +('learn all my class',3,'Syntax: .learn all my class\r\n\r\nLearn all spells and talents available for his class.'), +('learn all my pettalents',3,'Syntax: .learn all my pettalents\r\n\r\nLearn all talents for your pet available for his creature type (only for hunter pets).'), +('learn all my spells',3,'Syntax: .learn all my spells\r\n\r\nLearn all spells (except talents and spells with first rank learned as talent) available for his class.'), +('learn all my talents',3,'Syntax: .learn all my talents\r\n\r\nLearn all talents (and spells with first rank learned as talent) available for his class.'), +('learn all recipes',2,'Syntax: .learn all recipes [$profession]\r\rLearns all recipes of specified profession and sets skill level to max.\rExample: .learn all recipes enchanting'), ('levelup',3,'Syntax: .levelup [$playername] [#numberoflevels]\r\n\r\nIncrease/decrease the level of character with $playername (or the selected if not name provided) by #numberoflevels Or +1 if no #numberoflevels provided). If #numberoflevels is omitted, the level will be increase by 1. If #numberoflevels is 0, the same level will be restarted. If no character is selected and name not provided, increase your level. Command can be used for offline character. All stats and dependent values recalculated. At level decrease talents can be reset if need. Also at level decrease equipped items with greater level requirement can be lost.'), ('linkgrave',3,'Syntax: .linkgrave #graveyard_id [alliance|horde]\r\n\r\nLink current zone to graveyard for any (or alliance/horde faction ghosts). This let character ghost from zone teleport to graveyard after die if graveyard is nearest from linked to zone and accept ghost of this faction. Add only single graveyard at another map and only if no graveyards linked (or planned linked at same map).'), ('list',3,'Syntax: .list $subcommand\nType .list to see the list of possible subcommands or .help list $subcommand to see info on subcommands'), @@ -515,31 +515,31 @@ INSERT INTO `command` VALUES ('notify',1,'Syntax: .notify $MessageToBroadcast\r\n\r\nSend a global message to all players online in screen.'), ('npc',1,'Syntax: .npc $subcommand\nType .npc to see the list of possible subcommands or .help npc $subcommand to see info on subcommands'), ('npc add',2,'Syntax: .npc add #creatureid\r\n\r\nSpawn a creature by the given template id of #creatureid.'), -('npc addformation',1,'Syntax: .npc addformation $leader\nAdd selected creature to a leader''s formation.'), -('npc additem',2,'Syntax: .npc additem #itemId <#maxcount><#incrtime><#extendedcost>r\r\n\r\nAdd item #itemid to item list of selected vendor. Also optionally set max count item in vendor item list and time to item count restoring and items ExtendedCost.'), -('npc addmove',2,'Syntax: .npc addmove #creature_guid [#waittime]\r\n\r\nAdd your current location as a waypoint for creature with guid #creature_guid. And optional add wait time.'), -('npc allowmove',3,'Syntax: .npc allowmove\r\n\r\nEnable or disable movement creatures in world. Not implemented.'), -('npc changeentry',3,'Syntax: .npc changeentry $entry\nSwitch selected creature with another entry from creature_template. - New creature.id value not saved to DB.'), -('npc changelevel',2,'Syntax: .npc changelevel #level\r\n\r\nChange the level of the selected creature to #level.\r\n\r\n#level may range from 1 to 63.'), +('npc add formation',1,'Syntax: .npc add formation $leader\nAdd selected creature to a leader''s formation.'), +('npc add item',2,'Syntax: .npc add item #itemId <#maxcount><#incrtime><#extendedcost>r\r\n\r\nAdd item #itemid to item list of selected vendor. Also optionally set max count item in vendor item list and time to item count restoring and items ExtendedCost.'), +('npc add move',2,'Syntax: .npc add move #creature_guid [#waittime]\r\n\r\nAdd your current location as a waypoint for creature with guid #creature_guid. And optional add wait time.'), +('npc set allowmove',3,'Syntax: .npc set allowmove\r\n\r\nEnable or disable movement creatures in world. Not implemented.'), +('npc set entry',3,'Syntax: .npc set entry $entry\nSwitch selected creature with another entry from creature_template. - New creature.id value not saved to DB.'), +('npc set level',2,'Syntax: .npc set level #level\r\n\r\nChange the level of the selected creature to #level.\r\n\r\n#level may range from 1 to (CONFIG_MAX_PLAYER_LEVEL) + 3.'), ('npc delete',2,'Syntax: .npc delete [#guid]\r\n\r\nDelete creature with guid #guid (or the selected if no guid is provided)'), -('npc delitem',2,'Syntax: .npc delitem #itemId\r\n\r\nRemove item #itemid from item list of selected vendor.'), -('npc factionid',2,'Syntax: .npc factionid #factionid\r\n\r\nSet the faction of the selected creature to #factionid.'), -('npc flag',2,'Syntax: .npc flag #npcflag\r\n\r\nSet the NPC flags of creature template of the selected creature and selected creature to #npcflag. NPC flags will applied to all creatures of selected creature template after server restart or grid unload/load.'), -('npc follow',2,'Syntax: .npc follow\r\n\r\nSelected creature start follow you until death/fight/etc.'), +('npc delete item',2,'Syntax: .npc delete item #itemId\r\n\r\nRemove item #itemid from item list of selected vendor.'), +('npc set factionid',2,'Syntax: .npc set factionid #factionid\r\n\r\nSet the faction of the selected creature to #factionid.'), +('npc set flag',2,'Syntax: .npc set flag #npcflag\r\n\r\nSet the NPC flags of creature template of the selected creature and selected creature to #npcflag. NPC flags will applied to all creatures of selected creature template after server restart or grid unload/load.'), +('npc follow',2,'Syntax: .npc follow start\r\n\r\nSelected creature start follow you until death/fight/etc.'), +('npc follow stop',2,'Syntax: .npc follow stop\r\n\r\nSelected creature (non pet) stop follow you.'), ('npc info',3,'Syntax: .npc info\r\n\r\nDisplay a list of details for the selected creature.\r\n\r\nThe list includes:\r\n- GUID, Faction, NPC flags, Entry ID, Model ID,\r\n- Level,\r\n- Health (current/maximum),\r\n\r\n- Field flags, dynamic flags, faction template, \r\n- Position information,\r\n- and the creature type, e.g. if the creature is a vendor.'), ('npc move',2,'Syntax: .npc move [#creature_guid]\r\n\r\nMove the targeted creature spawn point to your coordinates.'), ('npc playemote',3,'Syntax: .npc playemote #emoteid\r\n\r\nMake the selected creature emote with an emote of id #emoteid.'), ('npc say',1,'Syntax: .npc say $message\nMake selected creature say specified message.'), -('npc setdeathstate',2,'Syntax: .npc setdeathstate on/off\r\n\r\nSet default death state (dead/alive) for npc at spawn.'), -('npc setlink',2,'Syntax: .npc setlink $creatureGUID\r\n\r\nLinks respawn of selected creature to the condition that $creatureGUID defined is alive.'), -('npc setmodel',2,'Syntax: .npc setmodel #displayid\r\n\r\nChange the model id of the selected creature to #displayid.'), -('npc setmovetype',2,'Syntax: .npc setmovetype [#creature_guid] stay/random/way [NODEL]\r\n\r\nSet for creature pointed by #creature_guid (or selected if #creature_guid not provided) movement type and move it to respawn position (if creature alive). Any existing waypoints for creature will be removed from the database if you do not use NODEL. If the creature is dead then movement type will applied at creature respawn.\r\nMake sure you use NODEL, if you want to keep the waypoints.'), -('npc setphase',2,'Syntax: .npc setphase #phasemask\r\n\r\nSelected unit or pet phasemask changed to #phasemask with related world vision update for players. In creature case state saved to DB and persistent. In pet case change active until in game phase changed for owner, owner re-login, or GM-mode enable/disable..'), -('npc spawndist',2,'Syntax: .npc spawndist #dist\r\n\r\nAdjust spawndistance of selected creature to dist.'), -('npc spawntime',2,'Syntax: .npc spawntime #time \r\n\r\nAdjust spawntime of selected creature to time.'), -('npc tempadd',2,'Adds temporary NPC, not saved to database.'), +('npc set deathstate',2,'Syntax: .npc set deathstate on/off\r\n\r\nSet default death state (dead/alive) for npc at spawn.'), +('npc set link',2,'Syntax: .npc set link $creatureGUID\r\n\r\nLinks respawn of selected creature to the condition that $creatureGUID defined is alive.'), +('npc set model',2,'Syntax: .npc set model #displayid\r\n\r\nChange the model id of the selected creature to #displayid.'), +('npc set movetype',2,'Syntax: .npc set movetype [#creature_guid] stay/random/way [NODEL]\r\n\r\nSet for creature pointed by #creature_guid (or selected if #creature_guid not provided) movement type and move it to respawn position (if creature alive). Any existing waypoints for creature will be removed from the database if you do not use NODEL. If the creature is dead then movement type will applied at creature respawn.\r\nMake sure you use NODEL, if you want to keep the waypoints.'), +('npc set phase',2,'Syntax: .npc set phase #phasemask\r\n\r\nSelected unit or pet phasemask changed to #phasemask with related world vision update for players. In creature case state saved to DB and persistent. In pet case change active until in game phase changed for owner, owner re-login, or GM-mode enable/disable..'), +('npc set spawndist',2,'Syntax: .npc set spawndist #dist\r\n\r\nAdjust spawndistance of selected creature to dist.'), +('npc set spawntime',2,'Syntax: .npc set spawntime #time \r\n\r\nAdjust spawntime of selected creature to time.'), +('npc add temp',2,'Syntax: .npc add temp\r\n\r\nAdds temporary NPC, not saved to database.'), ('npc textemote',1,'Syntax: .npc textemote #emoteid\r\n\r\nMake the selected creature to do textemote with an emote of id #emoteid.'), -('npc unfollow',2,'Syntax: .npc unfollow\r\n\r\nSelected creature (non pet) stop follow you.'), ('npc whisper',1,'Syntax: .npc whisper #playerguid #text\r\nMake the selected npc whisper #text to #playerguid.'), ('npc yell',1,'Syntax: .npc yell $message\nMake selected creature yell specified message.'), ('pdump',3,'Syntax: .pdump $subcommand\nType .pdump to see the list of possible subcommands or .help pdump $subcommand to see info on subcommands'), diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index bba11c08b22..0aaecd233f5 100755 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -90,27 +90,6 @@ static size_t appendCommandTable(ChatCommand* target, const ChatCommand* source) ChatCommand * ChatHandler::getCommandTable() { - static ChatCommand accountSetCommandTable[] = - { - { "addon", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleAccountSetAddonCommand>, "", NULL }, - { "gmlevel", SEC_CONSOLE, true, OldHandler<&ChatHandler::HandleAccountSetGmLevelCommand>, "", NULL }, - { "password", SEC_CONSOLE, true, OldHandler<&ChatHandler::HandleAccountSetPasswordCommand>, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - - static ChatCommand accountCommandTable[] = - { - { "addon", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleAccountAddonCommand>, "", NULL }, - { "create", SEC_CONSOLE, true, OldHandler<&ChatHandler::HandleAccountCreateCommand>, "", NULL }, - { "delete", SEC_CONSOLE, true, OldHandler<&ChatHandler::HandleAccountDeleteCommand>, "", NULL }, - { "onlinelist", SEC_CONSOLE, true, OldHandler<&ChatHandler::HandleAccountOnlineListCommand>, "", NULL }, - { "lock", SEC_PLAYER, false, OldHandler<&ChatHandler::HandleAccountLockCommand>, "", NULL }, - { "set", SEC_ADMINISTRATOR, true, NULL, "", accountSetCommandTable }, - { "password", SEC_PLAYER, false, OldHandler<&ChatHandler::HandleAccountPasswordCommand>, "", NULL }, - { "", SEC_PLAYER, false, OldHandler<&ChatHandler::HandleAccountCommand>, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand banCommandTable[] = { { "account", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleBanAccountCommand>, "", NULL }, @@ -181,59 +160,6 @@ ChatCommand * ChatHandler::getCommandTable() { NULL, 0, false, NULL, "", NULL } }; - static ChatCommand debugPlayCommandTable[] = - { - { "cinematic", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleDebugPlayCinematicCommand>, "", NULL }, - { "movie", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleDebugPlayMovieCommand>, "", NULL }, - { "sound", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleDebugPlaySoundCommand>, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - - static ChatCommand debugSendCommandTable[] = - { - { "buyerror", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugSendBuyErrorCommand>, "", NULL }, - { "channelnotify", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugSendChannelNotifyCommand>, "", NULL }, - { "chatmmessage", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugSendChatMsgCommand>, "", NULL }, - { "equiperror", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugSendEquipErrorCommand>, "", NULL }, - { "largepacket", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugSendLargePacketCommand>, "", NULL }, - { "opcode", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugSendOpcodeCommand>, "", NULL }, - { "poi", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugSendPoiCommand>, "", NULL }, - { "qpartymsg", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugSendQuestPartyMsgCommand>, "", NULL }, - { "qinvalidmsg", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugSendQuestInvalidMsgCommand>, "", NULL }, - { "sellerror", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugSendSellErrorCommand>, "", NULL }, - { "setphaseshift", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugSendSetPhaseShiftCommand>, "", NULL }, - { "spellfail", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugSendSpellFailCommand>, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - - static ChatCommand debugCommandTable[] = - { - { "setbit", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugSet32Bit>, "", NULL }, - { "threat", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugThreatList>, "", NULL }, - { "hostil", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugHostileRefList>, "", NULL }, - { "anim", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleDebugAnimCommand>, "", NULL }, - { "arena", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugArenaCommand>, "", NULL }, - { "bg", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugBattlegroundCommand>, "", NULL }, - { "getitemstate", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugGetItemStateCommand>, "", NULL }, - { "lootrecipient", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleDebugGetLootRecipientCommand>, "", NULL }, - { "getvalue", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugGetValueCommand>, "", NULL }, - { "getitemvalue", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugGetItemValueCommand>, "", NULL }, - { "Mod32Value", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugMod32ValueCommand>, "", NULL }, - { "play", SEC_MODERATOR, false, NULL, "", debugPlayCommandTable }, - { "send", SEC_ADMINISTRATOR, false, NULL, "", debugSendCommandTable }, - { "setaurastate", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugSetAuraStateCommand>, "", NULL }, - { "setitemvalue", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugSetItemValueCommand>, "", NULL }, - { "setvalue", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugSetValueCommand>, "", NULL }, - { "spawnvehicle", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugSpawnVehicle>, "", NULL }, - { "setvid", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugSetVehicleId>, "", NULL }, - { "entervehicle", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugEnterVehicle>, "", NULL }, - { "uws", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugUpdateWorldStateCommand>, "", NULL }, - { "update", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugUpdateCommand>, "", NULL }, - { "itemexpire", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugItemExpireCommand>, "", NULL }, - { "areatriggers", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleDebugAreaTriggers>, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand eventCommandTable[] = { { "activelist", SEC_GAMEMASTER, true, OldHandler<&ChatHandler::HandleEventActiveListCommand>, "", NULL }, @@ -243,39 +169,12 @@ ChatCommand * ChatHandler::getCommandTable() { NULL, 0, false, NULL, "", NULL } }; - static ChatCommand gmCommandTable[] = - { - { "chat", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleGMChatCommand>, "", NULL }, - { "fly", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleGMFlyCommand>, "", NULL }, - { "ingame", SEC_PLAYER, true, OldHandler<&ChatHandler::HandleGMListIngameCommand>, "", NULL }, - { "list", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleGMListFullCommand>, "", NULL }, - { "visible", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleGMVisibleCommand>, "", NULL }, - { "", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleGMCommand>, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - - static ChatCommand goCommandTable[] = - { - { "creature", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleGoCreatureCommand>, "", NULL }, - { "graveyard", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleGoGraveyardCommand>, "", NULL }, - { "grid", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleGoGridCommand>, "", NULL }, - { "object", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleGoObjectCommand>, "", NULL }, - { "taxinode", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleGoTaxinodeCommand>, "", NULL }, - { "trigger", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleGoTriggerCommand>, "", NULL }, - { "zonexy", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleGoZoneXYCommand>, "", NULL }, - { "xy", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleGoXYCommand>, "", NULL }, - { "xyz", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleGoXYZCommand>, "", NULL }, - { "ticket", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleGoTicketCommand>, "", NULL }, - { "", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleGoXYZCommand>, "", NULL }, - { 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::HandleGOInfoCommand>, "", 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 }, @@ -321,22 +220,6 @@ ChatCommand * ChatHandler::getCommandTable() { NULL, 0, false, NULL, "", NULL } }; - static ChatCommand learnCommandTable[] = - { - { "all", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleLearnAllCommand>, "", NULL }, - { "all_gm", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleLearnAllGMCommand>, "", NULL }, - { "all_crafts", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleLearnAllCraftsCommand>, "", NULL }, - { "all_default", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleLearnAllDefaultCommand>, "", NULL }, - { "all_lang", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleLearnAllLangCommand>, "", NULL }, - { "all_myclass", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleLearnAllMyClassCommand>, "", NULL }, - { "all_mypettalents",SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleLearnAllMyPetTalentsCommand>,"", NULL }, - { "all_myspells", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleLearnAllMySpellsCommand>, "", NULL }, - { "all_mytalents", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleLearnAllMyTalentsCommand>, "", NULL }, - { "all_recipes", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleLearnAllRecipesCommand>, "", NULL }, - { "", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleLearnCommand>, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand listCommandTable[] = { { "creature", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleListCreatureCommand>, "", NULL }, @@ -374,77 +257,6 @@ ChatCommand * ChatHandler::getCommandTable() { NULL, 0, false, NULL, "", NULL } }; - static ChatCommand modifyCommandTable[] = - { - { "hp", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleModifyHPCommand>, "", NULL }, - { "mana", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleModifyManaCommand>, "", NULL }, - { "rage", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleModifyRageCommand>, "", NULL }, - { "runicpower", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleModifyRunicPowerCommand>, "", NULL }, - { "energy", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleModifyEnergyCommand>, "", NULL }, - { "money", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleModifyMoneyCommand>, "", NULL }, - { "speed", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleModifySpeedCommand>, "", NULL }, - { "swim", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleModifySwimCommand>, "", NULL }, - { "scale", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleModifyScaleCommand>, "", NULL }, - { "bit", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleModifyBitCommand>, "", NULL }, - { "bwalk", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleModifyBWalkCommand>, "", NULL }, - { "fly", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleModifyFlyCommand>, "", NULL }, - { "aspeed", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleModifyASpeedCommand>, "", NULL }, - { "faction", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleModifyFactionCommand>, "", NULL }, - { "spell", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleModifySpellCommand>, "", NULL }, - { "tp", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleModifyTalentCommand>, "", NULL }, - { "mount", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleModifyMountCommand>, "", NULL }, - { "honor", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleModifyHonorCommand>, "", NULL }, - { "rep", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleModifyRepCommand>, "", NULL }, - { "arena", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleModifyArenaCommand>, "", NULL }, - { "drunk", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleModifyDrunkCommand>, "", NULL }, - { "standstate", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleModifyStandStateCommand>, "", NULL }, - { "morph", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleModifyMorphCommand>, "", NULL }, - { "phase", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleModifyPhaseCommand>, "", NULL }, - { "gender", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleModifyGenderCommand>, "", NULL }, - { NULL, 0, false, NULL, "", NULL } - }; - - static ChatCommand npcCommandTable[] = - { - { "add", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcAddCommand>, "", NULL }, - { "additem", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcAddVendorItemCommand>, "", NULL }, - { "addmove", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcAddMoveCommand>, "", NULL }, - { "allowmove", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleNpcAllowMovementCommand>, "", NULL }, - { "changeentry", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleNpcChangeEntryCommand>, "", NULL }, - { "changelevel", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcChangeLevelCommand>, "", NULL }, - { "delete", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcDeleteCommand>, "", NULL }, - { "delitem", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcDelVendorItemCommand>, "", NULL }, - { "factionid", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcFactionIdCommand>, "", NULL }, - { "flag", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcFlagCommand>, "", NULL }, - { "follow", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcFollowCommand>, "", NULL }, - { "info", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleNpcInfoCommand>, "", NULL }, - { "move", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcMoveCommand>, "", NULL }, - { "playemote", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleNpcPlayEmoteCommand>, "", NULL }, - { "setmodel", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcSetModelCommand>, "", NULL }, - { "setmovetype", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcSetMoveTypeCommand>, "", NULL }, - { "setphase", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcSetPhaseCommand>, "", NULL }, - { "spawndist", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcSpawnDistCommand>, "", NULL }, - { "spawntime", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcSpawnTimeCommand>, "", NULL }, - { "say", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleNpcSayCommand>, "", NULL }, - { "textemote", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleNpcTextEmoteCommand>, "", NULL }, - { "unfollow", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcUnFollowCommand>, "", NULL }, - { "whisper", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleNpcWhisperCommand>, "", NULL }, - { "yell", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleNpcYellCommand>, "", NULL }, - { "tempadd", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleTempAddSpwCommand>, "", NULL }, - { "tame", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcTameCommand>, "", NULL }, - { "setdeathstate", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcSetDeathStateCommand>, "", NULL }, - { "addformation", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleNpcAddFormationCommand>, "", NULL }, - { "setlink", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcSetLinkCommand>, "", NULL }, - - //{ TODO: fix or remove this commands - { "addweapon", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleNpcAddWeaponCommand>, "", NULL }, - { "name", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcNameCommand>, "", NULL }, - { "subname", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleNpcSubNameCommand>, "", NULL }, - //} - - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand petCommandTable[] = { { "create", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleCreatePetCommand>, "", NULL }, @@ -534,7 +346,6 @@ ChatCommand * ChatHandler::getCommandTable() { "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 }, -// { "auctions", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAuctionsCommand>, "", 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 }, @@ -720,22 +531,8 @@ ChatCommand * ChatHandler::getCommandTable() { NULL, 0, false, NULL, "", NULL } }; - static ChatCommand achievementCommandTable[] = - { - { "add", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleAchievementAddCommand>, "", NULL}, - { NULL, 0, false, NULL, "", NULL } - }; - static ChatCommand commandTable[] = { - { "account", SEC_PLAYER, true, NULL, "", accountCommandTable }, - { "achievement", SEC_ADMINISTRATOR, false, NULL, "", achievementCommandTable}, - { "gm", SEC_MODERATOR, true, NULL, "", gmCommandTable }, - { "npc", SEC_MODERATOR, false, NULL, "", npcCommandTable }, - { "go", SEC_MODERATOR, false, NULL, "", goCommandTable }, - { "learn", SEC_MODERATOR, false, NULL, "", learnCommandTable }, - { "modify", SEC_MODERATOR, false, NULL, "", modifyCommandTable }, - { "debug", SEC_MODERATOR, true, NULL, "", debugCommandTable }, { "tele", SEC_MODERATOR, true, NULL, "", teleCommandTable }, { "character", SEC_GAMEMASTER, true, NULL, "", characterCommandTable}, { "event", SEC_GAMEMASTER, false, NULL, "", eventCommandTable }, @@ -1077,6 +874,23 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, co if (!table[i].Handler || !isAvailable(table[i])) continue; + bool match = false; + if (strlen(table[i].Name) > strlen(cmd.c_str())) + { + for (uint32 j = 0; table[j].Name != NULL; ++j) + { + if (strcmp(table[j].Name,cmd.c_str()) != 0) + continue; + else + { + match = true; + break; + } + } + } + if (match) + continue; + SetSentErrorMessage(false); // table[i].Name == "" is special case: send original command to handler if ((table[i].Handler)(this, strlen(table[i].Name) != 0 ? text : oldtext)) diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h index 56f254463e1..6a90ae9c9a4 100755 --- a/src/server/game/Chat/Chat.h +++ b/src/server/game/Chat/Chat.h @@ -46,6 +46,7 @@ class ChatCommand class ChatHandler { public: + WorldSession * GetSession() { return m_session; } explicit ChatHandler(WorldSession* session) : m_session(session) {} explicit ChatHandler(Player* player) : m_session(player->GetSession()) {} ~ChatHandler() {} @@ -119,6 +120,7 @@ class ChatHandler GameObject* GetNearbyGameObject(); GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry); + void SetSentErrorMessage(bool val){ sentErrorMessage = val;}; protected: explicit ChatHandler() : m_session(NULL) {} // for CLI subclass @@ -127,17 +129,6 @@ class ChatHandler bool ShowHelpForCommand(ChatCommand *table, const char* cmd); bool ShowHelpForSubCommands(ChatCommand *table, char const* cmd, char const* subcmd); - bool HandleAccountCommand(const char* args); - bool HandleAccountAddonCommand(const char* args); - bool HandleAccountCreateCommand(const char* args); - bool HandleAccountDeleteCommand(const char* args); - bool HandleAccountLockCommand(const char* args); - bool HandleAccountOnlineListCommand(const char* args); - bool HandleAccountPasswordCommand(const char* args); - bool HandleAccountSetAddonCommand(const char* args); - bool HandleAccountSetGmLevelCommand(const char* args); - bool HandleAccountSetPasswordCommand(const char* args); - bool HandleNameAnnounceCommand(const char* args); bool HandleGMNameAnnounceCommand(const char* args); bool HandleGMAnnounceCommand(const char* args); @@ -175,51 +166,11 @@ class ChatHandler bool HandleChannelSetPublic(const char *args); - bool HandleDebugAnimCommand(const char* args); - bool HandleDebugArenaCommand(const char * args); - bool HandleDebugBattlegroundCommand(const char * args); - bool HandleDebugGetItemStateCommand(const char * args); - bool HandleDebugGetLootRecipientCommand(const char * args); - bool HandleDebugGetValueCommand(const char* args); - bool HandleDebugGetItemValueCommand(const char* args); - bool HandleDebugMod32ValueCommand(const char* args); - bool HandleDebugSetAuraStateCommand(const char * args); - bool HandleDebugSetItemValueCommand(const char * args); - bool HandleDebugItemExpireCommand(const char * args); - bool HandleDebugSetVehicleId(const char * args); - bool HandleDebugEnterVehicle(const char * args); - bool HandleDebugSetValueCommand(const char* args); - bool HandleDebugSpawnVehicle(const char * args); - bool HandleDebugSpellCheckCommand(const char* args); - bool HandleDebugUpdateCommand(const char* args); - bool HandleDebugUpdateWorldStateCommand(const char* args); - bool HandleDebugAreaTriggers(const char* args); - - bool HandleDebugSet32Bit(const char* args); - bool HandleDebugThreatList(const char * args); - bool HandleDebugHostileRefList(const char * args); bool HandlePossessCommand(const char* args); bool HandleUnPossessCommand(const char* args); bool HandleBindSightCommand(const char* args); bool HandleUnbindSightCommand(const char* args); - bool HandleDebugPlayCinematicCommand(const char* args); - bool HandleDebugPlayMovieCommand(const char* args); - bool HandleDebugPlaySoundCommand(const char* args); - - bool HandleDebugSendBuyErrorCommand(const char* args); - bool HandleDebugSendChannelNotifyCommand(const char* args); - bool HandleDebugSendChatMsgCommand(const char* args); - bool HandleDebugSendEquipErrorCommand(const char* args); - bool HandleDebugSendLargePacketCommand(const char * args); - bool HandleDebugSendOpcodeCommand(const char* args); - bool HandleDebugSendPoiCommand(const char* args); - bool HandleDebugSendQuestPartyMsgCommand(const char* args); - bool HandleDebugSendQuestInvalidMsgCommand(const char* args); - bool HandleDebugSendSellErrorCommand(const char* args); - bool HandleDebugSendSetPhaseShiftCommand(const char * args); - bool HandleDebugSendSpellFailCommand(const char* args); - bool HandleEventActiveListCommand(const char* args); bool HandleEventStartCommand(const char* args); bool HandleEventStopCommand(const char* args); @@ -227,7 +178,7 @@ class ChatHandler bool HandleGameObjectAddCommand(const char* args); bool HandleGameObjectDeleteCommand(const char* args); - bool HandleGOInfoCommand(const char* args); + bool HandleGameObjectInfoCommand(const char* args); bool HandleGameObjectMoveCommand(const char* args); bool HandleGameObjectNearCommand(const char* args); bool HandleGameObjectPhaseCommand(const char* args); @@ -235,26 +186,6 @@ class ChatHandler bool HandleGameObjectTargetCommand(const char* args); bool HandleGameObjectTurnCommand(const char* args); - bool HandleGMCommand(const char* args); - bool HandleGMChatCommand(const char* args); - bool HandleGMFlyCommand(const char* args); - bool HandleGMListFullCommand(const char* args); - bool HandleGMListIngameCommand(const char* args); - bool HandleGMVisibleCommand(const char* args); - - bool HandleGoCommand(const char* args); - bool HandleGoCreatureCommand(const char* args); - bool HandleGoGraveyardCommand(const char* args); - bool HandleGoGridCommand(const char* args); - bool HandleGoObjectCommand(const char* args); - bool HandleGoTaxinodeCommand(const char* args); - bool HandleGoTriggerCommand(const char* args); - bool HandleGoXYCommand(const char* args); - bool HandleGoXYZCommand(const char* args); - bool HandleGoZoneXYCommand(const char* args); - - bool HandleGoTicketCommand(const char* args); - bool HandleGuildCreateCommand(const char* args); bool HandleGuildInviteCommand(const char* args); bool HandleGuildUninviteCommand(const char* args); @@ -270,18 +201,6 @@ class ChatHandler bool HandleInstanceStatsCommand(const char* args); bool HandleInstanceSaveDataCommand(const char * args); - bool HandleLearnCommand(const char* args); - bool HandleLearnAllCommand(const char* args); - bool HandleLearnAllGMCommand(const char* args); - bool HandleLearnAllCraftsCommand(const char* args); - bool HandleLearnAllRecipesCommand(const char* args); - bool HandleLearnAllDefaultCommand(const char* args); - bool HandleLearnAllLangCommand(const char* args); - bool HandleLearnAllMyClassCommand(const char* args); - bool HandleLearnAllMyPetTalentsCommand(const char* args); - bool HandleLearnAllMySpellsCommand(const char* args); - bool HandleLearnAllMyTalentsCommand(const char* args); - bool HandleListAurasCommand(const char * args); bool HandleListCreatureCommand(const char* args); bool HandleListItemCommand(const char* args); @@ -305,65 +224,6 @@ class ChatHandler bool HandleLookupMapCommand(const char* args); bool HandleLookupTitleCommand(const char * args); - bool HandleModifyHPCommand(const char* args); - bool HandleModifyManaCommand(const char* args); - bool HandleModifyRageCommand(const char* args); - bool HandleModifyRunicPowerCommand(const char* args); - bool HandleModifyEnergyCommand(const char* args); - bool HandleModifyMoneyCommand(const char* args); - bool HandleModifyASpeedCommand(const char* args); - bool HandleModifySpeedCommand(const char* args); - bool HandleModifyBWalkCommand(const char* args); - bool HandleModifyFlyCommand(const char* args); - bool HandleModifySwimCommand(const char* args); - bool HandleModifyScaleCommand(const char* args); - bool HandleModifyMountCommand(const char* args); - bool HandleModifyBitCommand(const char* args); - bool HandleModifyFactionCommand(const char* args); - bool HandleModifySpellCommand(const char* args); - bool HandleModifyTalentCommand (const char* args); - bool HandleModifyHonorCommand (const char* args); - bool HandleModifyRepCommand(const char* args); - bool HandleModifyArenaCommand(const char* args); - bool HandleModifyPhaseCommand(const char* args); - bool HandleModifyGenderCommand(const char* args); - - //-----------------------Npc Commands----------------------- - bool HandleNpcAddCommand(const char* args); - bool HandleNpcAddMoveCommand(const char* args); - bool HandleNpcAddVendorItemCommand(const char* args); - bool HandleNpcAllowMovementCommand(const char* args); - bool HandleNpcChangeEntryCommand(const char *args); - bool HandleNpcChangeLevelCommand(const char* args); - bool HandleNpcDeleteCommand(const char* args); - bool HandleNpcDelVendorItemCommand(const char* args); - bool HandleNpcFactionIdCommand(const char* args); - bool HandleNpcFlagCommand(const char* args); - bool HandleNpcFollowCommand(const char* args); - bool HandleNpcInfoCommand(const char* args); - bool HandleNpcMoveCommand(const char* args); - bool HandleNpcPlayEmoteCommand(const char* args); - bool HandleNpcSayCommand(const char* args); - bool HandleNpcSetDeathStateCommand(const char* args); - bool HandleNpcSetModelCommand(const char* args); - bool HandleNpcSetMoveTypeCommand(const char* args); - bool HandleNpcSetPhaseCommand(const char* args); - bool HandleNpcSpawnDistCommand(const char* args); - bool HandleNpcSpawnTimeCommand(const char* args); - bool HandleNpcTameCommand(const char* args); - bool HandleNpcTextEmoteCommand(const char* args); - bool HandleNpcUnFollowCommand(const char* args); - bool HandleNpcWhisperCommand(const char* args); - bool HandleNpcYellCommand(const char* args); - bool HandleNpcAddFormationCommand(const char* args); - bool HandleNpcSetLinkCommand(const char* args); - - //TODO: NpcCommands that needs to be fixed : - bool HandleNpcAddWeaponCommand(const char* args); - bool HandleNpcNameCommand(const char* args); - bool HandleNpcSubNameCommand(const char* args); - //---------------------------------------------------------- - bool HandlePDumpLoadCommand(const char *args); bool HandlePDumpWriteCommand(const char *args); @@ -545,7 +405,6 @@ class ChatHandler bool HandleGPSCommand(const char* args); bool HandleTaxiCheatCommand(const char* args); bool HandleWhispersCommand(const char* args); - bool HandleModifyDrunkCommand(const char* args); bool HandleGUIDCommand(const char* args); bool HandleItemMoveCommand(const char* args); @@ -561,11 +420,9 @@ class ChatHandler bool HandleCooldownCommand(const char* args); bool HandleUnLearnCommand(const char* args); bool HandleGetDistanceCommand(const char* args); - bool HandleModifyStandStateCommand(const char* args); bool HandleDieCommand(const char* args); bool HandleDamageCommand(const char *args); bool HandleReviveCommand(const char* args); - bool HandleModifyMorphCommand(const char* args); bool HandleAuraCommand(const char* args); bool HandleUnAuraCommand(const char* args); bool HandleLinkGraveCommand(const char* args); @@ -593,9 +450,6 @@ class ChatHandler bool HandleChangeWeather(const char* args); bool HandleKickPlayerCommand(const char * args); - // Achievement commands - bool HandleAchievementAddCommand(const char* args); - // GM ticket command handlers bool HandleGMTicketListCommand(const char* args); bool HandleGMTicketListOnlineCommand(const char* args); @@ -629,7 +483,6 @@ class ChatHandler bool HandleRepairitemsCommand(const char* args); bool HandleTempGameObjectCommand(const char* args); - bool HandleTempAddSpwCommand(const char* args); //! Development Commands @@ -665,7 +518,6 @@ class ChatHandler void HandleCharacterDeletedListHelper(DeletedInfoList const& foundList); void HandleCharacterDeletedRestoreHelper(DeletedInfo const& delInfo); - void SetSentErrorMessage(bool val){ sentErrorMessage = val;}; private: WorldSession * m_session; // != NULL for chat command call and NULL for CLI command diff --git a/src/server/game/Chat/Commands/Debugcmds.cpp b/src/server/game/Chat/Commands/Debugcmds.cpp index a83df8e57ce..c831fde2ecd 100755 --- a/src/server/game/Chat/Commands/Debugcmds.cpp +++ b/src/server/game/Chat/Commands/Debugcmds.cpp @@ -37,1103 +37,4 @@ #include "SpellMgr.h" #include "ScriptMgr.h" -bool ChatHandler::HandleDebugSendSpellFailCommand(const char* args) -{ - if (!*args) - return false; - - char* px = strtok((char*)args, " "); - if (!px) - return false; - - uint8 failnum = (uint8)atoi(px); - if (failnum == 0 && *px != '0') - return false; - - char* p1 = strtok(NULL, " "); - uint8 failarg1 = p1 ? (uint8)atoi(p1) : 0; - - char* p2 = strtok(NULL, " "); - uint8 failarg2 = p2 ? (uint8)atoi(p2) : 0; - - WorldPacket data(SMSG_CAST_FAILED, 5); - data << uint8(0); - data << uint32(133); - data << uint8(failnum); - if (p1 || p2) - data << uint32(failarg1); - if (p2) - data << uint32(failarg2); - - m_session->SendPacket(&data); - - return true; -} - -bool ChatHandler::HandleDebugSendPoiCommand(const char* args) -{ - if (!*args) - return false; - - Player *pPlayer = m_session->GetPlayer(); - Unit* target = getSelectedUnit(); - if (!target) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - return true; - } - - char* icon_text = strtok((char*)args, " "); - char* flags_text = strtok(NULL, " "); - if (!icon_text || !flags_text) - return false; - - uint32 icon = atol(icon_text); - uint32 flags = atol(flags_text); - - sLog.outDetail("Command : POI, NPC = %u, icon = %u flags = %u", target->GetGUIDLow(), icon,flags); - pPlayer->PlayerTalkClass->SendPointOfInterest(target->GetPositionX(), target->GetPositionY(), Poi_Icon(icon), flags, 30, "Test POI"); - return true; -} - -bool ChatHandler::HandleDebugSendEquipErrorCommand(const char* args) -{ - if (!*args) - return false; - - uint8 msg = atoi(args); - m_session->GetPlayer()->SendEquipError(msg, NULL, NULL); - return true; -} - -bool ChatHandler::HandleDebugSendSellErrorCommand(const char* args) -{ - if (!*args) - return false; - - uint8 msg = atoi(args); - m_session->GetPlayer()->SendSellError(msg, 0, 0, 0); - return true; -} - -bool ChatHandler::HandleDebugSendBuyErrorCommand(const char* args) -{ - if (!*args) - return false; - - uint8 msg = atoi(args); - m_session->GetPlayer()->SendBuyError(msg, 0, 0, 0); - return true; -} - -bool ChatHandler::HandleDebugSendOpcodeCommand(const char* /*args*/) -{ - Unit *unit = getSelectedUnit(); - Player *player = NULL; - if (!unit || (unit->GetTypeId() != TYPEID_PLAYER)) - player = m_session->GetPlayer(); - else - player = (Player*)unit; - if (!unit) unit = player; - - std::ifstream ifs("opcode.txt"); - if (ifs.bad()) - return false; - - uint32 opcode; - ifs >> opcode; - - WorldPacket data(opcode, 0); - - while (!ifs.eof()) - { - std::string type; - ifs >> type; - - if (type == "") - break; - - if (type == "uint8") - { - uint16 val1; - ifs >> val1; - data << uint8(val1); - } - else if (type == "uint16") - { - uint16 val2; - ifs >> val2; - data << val2; - } - else if (type == "uint32") - { - uint32 val3; - ifs >> val3; - data << val3; - } - else if (type == "uint64") - { - uint64 val4; - ifs >> val4; - data << val4; - } - else if (type == "float") - { - float val5; - ifs >> val5; - data << val5; - } - else if (type == "string") - { - std::string val6; - ifs >> val6; - data << val6; - } - else if (type == "appitsguid") - { - data.append(unit->GetPackGUID()); - } - else if (type == "appmyguid") - { - data.append(player->GetPackGUID()); - } - else if (type == "appgoguid") - { - GameObject *obj = GetNearbyGameObject(); - if (!obj) - { - PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, 0); - SetSentErrorMessage(true); - ifs.close(); - return false; - } - data.append(obj->GetPackGUID()); - } - else if (type == "goguid") - { - GameObject *obj = GetNearbyGameObject(); - if (!obj) - { - PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, 0); - SetSentErrorMessage(true); - ifs.close(); - return false; - } - data << uint64(obj->GetGUID()); - } - else if (type == "myguid") - { - data << uint64(player->GetGUID()); - } - else if (type == "itsguid") - { - data << uint64(unit->GetGUID()); - } - else if (type == "pos") - { - data << unit->GetPositionX(); - data << unit->GetPositionY(); - data << unit->GetPositionZ(); - } - else if (type == "mypos") - { - data << player->GetPositionX(); - data << player->GetPositionY(); - data << player->GetPositionZ(); - } - else - { - sLog.outDebug("Sending opcode: unknown type '%s'", type.c_str()); - break; - } - } - ifs.close(); - sLog.outDebug("Sending opcode %u", data.GetOpcode()); - data.hexlike(); - player->GetSession()->SendPacket(&data); - PSendSysMessage(LANG_COMMAND_OPCODESENT, data.GetOpcode(), unit->GetName()); - return true; -} - -bool ChatHandler::HandleDebugUpdateWorldStateCommand(const char* args) -{ - char* w = strtok((char*)args, " "); - char* s = strtok(NULL, " "); - - if (!w || !s) - return false; - - uint32 world = (uint32)atoi(w); - uint32 state = (uint32)atoi(s); - m_session->GetPlayer()->SendUpdateWorldState(world, state); - return true; -} - -bool ChatHandler::HandleDebugAreaTriggers(const char* /*args*/) -{ - Player* plr = m_session->GetPlayer(); - if (!plr->isDebugAreaTriggers) - { - PSendSysMessage(LANG_DEBUG_AREATRIGGER_ON); - plr->isDebugAreaTriggers = true; - } else { - PSendSysMessage(LANG_DEBUG_AREATRIGGER_OFF); - plr->isDebugAreaTriggers = false; - } - return true; -} - -bool ChatHandler::HandleDebugPlayCinematicCommand(const char* args) -{ - // USAGE: .debug play cinematic #cinematicid - // #cinematicid - ID decimal number from CinemaicSequences.dbc (1st column) - if (!*args) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - uint32 dwId = atoi((char*)args); - - if (!sCinematicSequencesStore.LookupEntry(dwId)) - { - PSendSysMessage(LANG_CINEMATIC_NOT_EXIST, dwId); - SetSentErrorMessage(true); - return false; - } - - m_session->GetPlayer()->SendCinematicStart(dwId); - return true; -} - -bool ChatHandler::HandleDebugPlayMovieCommand(const char* args) -{ - // USAGE: .debug play movie #movieid - // #movieid - ID decimal number from Movie.dbc (1st column) - if (!*args) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - uint32 dwId = atoi((char*)args); - - if (!sMovieStore.LookupEntry(dwId)) - { - PSendSysMessage(LANG_MOVIE_NOT_EXIST, dwId); - SetSentErrorMessage(true); - return false; - } - - m_session->GetPlayer()->SendMovieStart(dwId); - return true; -} - -//Play sound -bool ChatHandler::HandleDebugPlaySoundCommand(const char* args) -{ - // USAGE: .debug playsound #soundid - // #soundid - ID decimal number from SoundEntries.dbc (1st column) - if (!*args) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - uint32 dwSoundId = atoi((char*)args); - - if (!sSoundEntriesStore.LookupEntry(dwSoundId)) - { - PSendSysMessage(LANG_SOUND_NOT_EXIST, dwSoundId); - SetSentErrorMessage(true); - return false; - } - - Unit* unit = getSelectedUnit(); - if (!unit) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - SetSentErrorMessage(true); - return false; - } - - if (m_session->GetPlayer()->GetSelection()) - unit->PlayDistanceSound(dwSoundId,m_session->GetPlayer()); - else - unit->PlayDirectSound(dwSoundId,m_session->GetPlayer()); - - PSendSysMessage(LANG_YOU_HEAR_SOUND, dwSoundId); - return true; -} - -//Send notification in channel -bool ChatHandler::HandleDebugSendChannelNotifyCommand(const char* args) -{ - if (!*args) - return false; - - const char *name = "test"; - uint8 code = atoi(args); - - WorldPacket data(SMSG_CHANNEL_NOTIFY, (1+10)); - data << code; // notify type - data << name; // channel name - data << uint32(0); - data << uint32(0); - m_session->SendPacket(&data); - return true; -} - -//Send notification in chat -bool ChatHandler::HandleDebugSendChatMsgCommand(const char* args) -{ - if (!*args) - return false; - - const char *msg = "testtest"; - uint8 type = atoi(args); - WorldPacket data; - ChatHandler::FillMessageData(&data, m_session, type, 0, "chan", m_session->GetPlayer()->GetGUID(), msg, m_session->GetPlayer()); - m_session->SendPacket(&data); - return true; -} - -bool ChatHandler::HandleDebugSendQuestPartyMsgCommand(const char* args) -{ - uint32 msg = atol((char*)args); - m_session->GetPlayer()->SendPushToPartyResponse(m_session->GetPlayer(), msg); - return true; -} - -bool ChatHandler::HandleDebugGetLootRecipientCommand(const char* /*args*/) -{ - Creature* target = getSelectedCreature(); - if (!target) - return false; - - PSendSysMessage("loot recipient: %s", target->hasLootRecipient()?(target->GetLootRecipient()?target->GetLootRecipient()->GetName():"offline"):"no loot recipient"); - return true; -} - -bool ChatHandler::HandleDebugSendQuestInvalidMsgCommand(const char* args) -{ - uint32 msg = atol((char*)args); - m_session->GetPlayer()->SendCanTakeQuestResponse(msg); - return true; -} - -bool ChatHandler::HandleDebugGetItemStateCommand(const char* args) -{ - if (!*args) - return false; - - std::string state_str = args; - - ItemUpdateState state = ITEM_UNCHANGED; - bool list_queue = false, check_all = false; - if (state_str == "unchanged") state = ITEM_UNCHANGED; - else if (state_str == "changed") state = ITEM_CHANGED; - else if (state_str == "new") state = ITEM_NEW; - else if (state_str == "removed") state = ITEM_REMOVED; - else if (state_str == "queue") list_queue = true; - else if (state_str == "check_all") check_all = true; - else return false; - - Player* player = getSelectedPlayer(); - if (!player) player = m_session->GetPlayer(); - - if (!list_queue && !check_all) - { - state_str = "The player has the following " + state_str + " items: "; - SendSysMessage(state_str.c_str()); - for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i) - { - if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END) - continue; - - Item *item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); - if (!item) continue; - if (!item->IsBag()) - { - if (item->GetState() == state) - PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID())); - } - else - { - Bag *bag = (Bag*)item; - for (uint8 j = 0; j < bag->GetBagSize(); ++j) - { - Item* item2 = bag->GetItemByPos(j); - if (item2 && item2->GetState() == state) - PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID())); - } - } - } - } - - if (list_queue) - { - std::vector<Item *> &updateQueue = player->GetItemUpdateQueue(); - for (size_t i = 0; i < updateQueue.size(); ++i) - { - Item *item = updateQueue[i]; - if (!item) continue; - - Bag *container = item->GetContainer(); - uint8 bag_slot = container ? container->GetSlot() : uint8(INVENTORY_SLOT_BAG_0); - - std::string st; - switch(item->GetState()) - { - case ITEM_UNCHANGED: st = "unchanged"; break; - case ITEM_CHANGED: st = "changed"; break; - case ITEM_NEW: st = "new"; break; - case ITEM_REMOVED: st = "removed"; break; - } - - PSendSysMessage("bag: %d slot: %d guid: %d - state: %s", bag_slot, item->GetSlot(), item->GetGUIDLow(), st.c_str()); - } - if (updateQueue.empty()) - PSendSysMessage("updatequeue empty"); - } - - if (check_all) - { - bool error = false; - std::vector<Item *> &updateQueue = player->GetItemUpdateQueue(); - for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i) - { - if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END) - continue; - - Item *item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); - if (!item) continue; - - if (item->GetSlot() != i) - { - PSendSysMessage("item at slot %d, guid %d has an incorrect slot value: %d", i, item->GetGUIDLow(), item->GetSlot()); - error = true; continue; - } - - if (item->GetOwnerGUID() != player->GetGUID()) - { - PSendSysMessage("for the item at slot %d and itemguid %d, owner's guid (%d) and player's guid (%d) don't match!", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow()); - error = true; continue; - } - - if (Bag *container = item->GetContainer()) - { - PSendSysMessage("item at slot: %d guid: %d has a container (slot: %d, guid: %d) but shouldnt!", item->GetSlot(), item->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow()); - error = true; continue; - } - - if (item->IsInUpdateQueue()) - { - uint16 qp = item->GetQueuePos(); - if (qp > updateQueue.size()) - { - PSendSysMessage("item at slot: %d guid: %d has a queuepos (%d) larger than the update queue size! ", item->GetSlot(), item->GetGUIDLow(), qp); - error = true; continue; - } - - if (updateQueue[qp] == NULL) - { - PSendSysMessage("item at slot: %d guid: %d has a queuepos (%d) that points to NULL in the queue!", item->GetSlot(), item->GetGUIDLow(), qp); - error = true; continue; - } - - if (updateQueue[qp] != item) - { - PSendSysMessage("item at slot: %d guid: %d has has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", item->GetSlot(), item->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow()); - error = true; continue; - } - } - else if (item->GetState() != ITEM_UNCHANGED) - { - PSendSysMessage("item at slot: %d guid: %d is not in queue but should be (state: %d)!", item->GetSlot(), item->GetGUIDLow(), item->GetState()); - error = true; continue; - } - - if (item->IsBag()) - { - Bag *bag = (Bag*)item; - for (uint8 j = 0; j < bag->GetBagSize(); ++j) - { - Item* item2 = bag->GetItemByPos(j); - if (!item2) continue; - - if (item2->GetSlot() != j) - { - PSendSysMessage("the item in bag %d slot %d, guid %d has an incorrect slot value: %d", bag->GetSlot(), j, item2->GetGUIDLow(), item2->GetSlot()); - error = true; continue; - } - - if (item2->GetOwnerGUID() != player->GetGUID()) - { - PSendSysMessage("for the item in bag %d at slot %d and itemguid %d, owner's guid (%d) and player's guid (%d) don't match!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID()), player->GetGUIDLow()); - error = true; continue; - } - - Bag *container = item2->GetContainer(); - if (!container) - { - PSendSysMessage("the item in bag %d at slot %d with guid %d has no container!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow()); - error = true; continue; - } - - if (container != bag) - { - PSendSysMessage("the item in bag %d at slot %d with guid %d has a different container(slot %d guid %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow()); - error = true; continue; - } - - if (item2->IsInUpdateQueue()) - { - uint16 qp = item2->GetQueuePos(); - if (qp > updateQueue.size()) - { - PSendSysMessage("item in bag: %d at slot: %d guid: %d has a queuepos (%d) larger than the update queue size! ", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp); - error = true; continue; - } - - if (updateQueue[qp] == NULL) - { - PSendSysMessage("item in bag: %d at slot: %d guid: %d has a queuepos (%d) that points to NULL in the queue!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp); - error = true; continue; - } - - if (updateQueue[qp] != item2) - { - PSendSysMessage("item in bag: %d at slot: %d guid: %d has has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow()); - error = true; continue; - } - } - else if (item2->GetState() != ITEM_UNCHANGED) - { - PSendSysMessage("item in bag: %d at slot: %d guid: %d is not in queue but should be (state: %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), item2->GetState()); - error = true; continue; - } - } - } - } - - for (size_t i = 0; i < updateQueue.size(); ++i) - { - Item *item = updateQueue[i]; - if (!item) continue; - - if (item->GetOwnerGUID() != player->GetGUID()) - { - PSendSysMessage("queue(" SIZEFMTD "): for the an item (guid %d), the owner's guid (%d) and player's guid (%d) don't match!", i, item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow()); - error = true; continue; - } - - if (item->GetQueuePos() != i) - { - PSendSysMessage("queue(" SIZEFMTD "): for the an item (guid %d), the queuepos doesn't match it's position in the queue!", i, item->GetGUIDLow()); - error = true; continue; - } - - if (item->GetState() == ITEM_REMOVED) continue; - Item *test = player->GetItemByPos(item->GetBagSlot(), item->GetSlot()); - - if (test == NULL) - { - PSendSysMessage("queue(" SIZEFMTD "): the bag(%d) and slot(%d) values for the item with guid %d are incorrect, the player doesn't have an item at that position!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow()); - error = true; continue; - } - - if (test != item) - { - PSendSysMessage("queue(" SIZEFMTD "): the bag(%d) and slot(%d) values for the item with guid %d are incorrect, the item with guid %d is there instead!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), test->GetGUIDLow()); - error = true; continue; - } - } - if (!error) - SendSysMessage("All OK!"); - } - - return true; -} - -bool ChatHandler::HandleDebugBattlegroundCommand(const char * /*args*/) -{ - sBattlegroundMgr.ToggleTesting(); - return true; -} - -bool ChatHandler::HandleDebugArenaCommand(const char * /*args*/) -{ - sBattlegroundMgr.ToggleArenaTesting(); - return true; -} - -bool ChatHandler::HandleDebugThreatList(const char * /*args*/) -{ - Creature* target = getSelectedCreature(); - if (!target || target->isTotem() || target->isPet()) - return false; - - std::list<HostileReference*>& tlist = target->getThreatManager().getThreatList(); - std::list<HostileReference*>::iterator itr; - uint32 cnt = 0; - PSendSysMessage("Threat list of %s (guid %u)",target->GetName(), target->GetGUIDLow()); - for (itr = tlist.begin(); itr != tlist.end(); ++itr) - { - Unit* unit = (*itr)->getTarget(); - if (!unit) - continue; - ++cnt; - PSendSysMessage(" %u. %s (guid %u) - threat %f",cnt,unit->GetName(), unit->GetGUIDLow(), (*itr)->getThreat()); - } - SendSysMessage("End of threat list."); - return true; -} - -bool ChatHandler::HandleDebugHostileRefList(const char * /*args*/) -{ - Unit* target = getSelectedUnit(); - if (!target) - target = m_session->GetPlayer(); - HostileReference* ref = target->getHostileRefManager().getFirst(); - uint32 cnt = 0; - PSendSysMessage("Hostil reference list of %s (guid %u)",target->GetName(), target->GetGUIDLow()); - while (ref) - { - if (Unit * unit = ref->getSource()->getOwner()) - { - ++cnt; - PSendSysMessage(" %u. %s (guid %u) - threat %f",cnt,unit->GetName(), unit->GetGUIDLow(), ref->getThreat()); - } - ref = ref->next(); - } - SendSysMessage("End of hostil reference list."); - return true; -} - -bool ChatHandler::HandleDebugSetVehicleId(const char *args) -{ - Unit* target = getSelectedUnit(); - if (!target || target->IsVehicle()) - return false; - - if (!args) - return false; - - char* i = strtok((char*)args, " "); - if (!i) - return false; - - uint32 id = (uint32)atoi(i); - //target->SetVehicleId(id); - PSendSysMessage("Vehicle id set to %u", id); - return true; -} - -bool ChatHandler::HandleDebugEnterVehicle(const char * args) -{ - Unit* target = getSelectedUnit(); - if (!target || !target->IsVehicle()) - return false; - - if (!args) - return false; - - char* i = strtok((char*)args, " "); - if (!i) - return false; - - char* j = strtok(NULL, " "); - - uint32 entry = (uint32)atoi(i); - int8 seatId = j ? (int8)atoi(j) : -1; - - if (!entry) - m_session->GetPlayer()->EnterVehicle(target, seatId); - else - { - Creature *passenger = NULL; - Trinity::AllCreaturesOfEntryInRange check(m_session->GetPlayer(), entry, 20.0f); - Trinity::CreatureSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(m_session->GetPlayer(), passenger, check); - m_session->GetPlayer()->VisitNearbyObject(30.0f, searcher); - if (!passenger || passenger == target) - return false; - passenger->EnterVehicle(target, seatId); - } - - PSendSysMessage("Unit %u entered vehicle %d", entry, (int32)seatId); - return true; -} - -bool ChatHandler::HandleDebugSpawnVehicle(const char* args) -{ - if (!*args) - return false; - - char* e = strtok((char*)args, " "); - char* i = strtok(NULL, " "); - - if (!e) - return false; - - uint32 entry = (uint32)atoi(e); - - float x, y, z, o = m_session->GetPlayer()->GetOrientation(); - m_session->GetPlayer()->GetClosePoint(x, y, z, m_session->GetPlayer()->GetObjectSize()); - - if (!i) - return m_session->GetPlayer()->SummonCreature(entry, x, y, z, o); - - uint32 id = (uint32)atoi(i); - - CreatureInfo const *ci = sObjectMgr.GetCreatureTemplate(entry); - - if (!ci) - return false; - - VehicleEntry const *ve = sVehicleStore.LookupEntry(id); - - if (!ve) - return false; - - Creature *v = new Creature; - - Map *map = m_session->GetPlayer()->GetMap(); - - if (!v->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_VEHICLE), map, m_session->GetPlayer()->GetPhaseMask(), entry, id, m_session->GetPlayer()->GetTeam(), x, y, z, o)) - { - delete v; - return false; - } - - map->Add(v->ToCreature()); - - return true; -} - -bool ChatHandler::HandleDebugSendLargePacketCommand(const char* /*args*/) -{ - const char* stuffingString = "This is a dummy string to push the packet's size beyond 128000 bytes. "; - std::ostringstream ss; - while (ss.str().size() < 128000) - ss << stuffingString; - SendSysMessage(ss.str().c_str()); - return true; -} - -bool ChatHandler::HandleDebugSendSetPhaseShiftCommand(const char* args) -{ - if (!*args) - return false; - - uint32 PhaseShift = atoi(args); - m_session->SendSetPhaseShift(PhaseShift); - return true; -} - -bool ChatHandler::HandleDebugGetItemValueCommand(const char* args) -{ - if (!*args) - return false; - - char* e = strtok((char*)args, " "); - char* f = strtok(NULL, " "); - - if (!e || !f) - return false; - - uint32 guid = (uint32)atoi(e); - uint32 index = (uint32)atoi(f); - - Item *i = m_session->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM)); - - if (!i) - return false; - - if (index >= i->GetValuesCount()) - return false; - - uint32 value = i->GetUInt32Value(index); - - PSendSysMessage("Item %u: value at %u is %u", guid, index, value); - - return true; -} - -bool ChatHandler::HandleDebugSetItemValueCommand(const char* args) -{ - if (!*args) - return false; - - char* e = strtok((char*)args, " "); - char* f = strtok(NULL, " "); - char* g = strtok(NULL, " "); - - if (!e || !f || !g) - return false; - - uint32 guid = (uint32)atoi(e); - uint32 index = (uint32)atoi(f); - uint32 value = (uint32)atoi(g); - - Item *i = m_session->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM)); - - if (!i) - return false; - - if (index >= i->GetValuesCount()) - return false; - - i->SetUInt32Value(index, value); - - return true; -} - -bool ChatHandler::HandleDebugItemExpireCommand(const char* args) -{ - if (!*args) - return false; - - char* e = strtok((char*)args, " "); - if (!e) - return false; - - uint32 guid = (uint32)atoi(e); - - Item *i = m_session->GetPlayer()->GetItemByGuid(MAKE_NEW_GUID(guid, 0, HIGHGUID_ITEM)); - - if (!i) - return false; - - m_session->GetPlayer()->DestroyItem(i->GetBagSlot(), i->GetSlot(), true); - sScriptMgr.OnItemExpire(m_session->GetPlayer(), i->GetProto()); - - return true; -} - -//show animation -bool ChatHandler::HandleDebugAnimCommand(const char* args) -{ - if (!*args) - return false; - - uint32 anim_id = atoi((char*)args); - m_session->GetPlayer()->HandleEmoteCommand(anim_id); - return true; -} - -bool ChatHandler::HandleDebugSetAuraStateCommand(const char* args) -{ - if (!*args) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Unit* unit = getSelectedUnit(); - if (!unit) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - SetSentErrorMessage(true); - return false; - } - - int32 state = atoi((char*)args); - if (!state) - { - // reset all states - for (int i = 1; i <= 32; ++i) - unit->ModifyAuraState(AuraState(i),false); - return true; - } - - unit->ModifyAuraState(AuraState(abs(state)),state > 0); - return true; -} - -bool ChatHandler::HandleDebugSetValueCommand(const char* args) -{ - if (!*args) - return false; - - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - char* pz = strtok(NULL, " "); - - if (!px || !py) - return false; - - WorldObject* target = getSelectedObject(); - if (!target) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - SetSentErrorMessage(true); - return false; - } - - uint64 guid = target->GetGUID(); - - uint32 Opcode = (uint32)atoi(px); - if (Opcode >= target->GetValuesCount()) - { - PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); - return false; - } - uint32 iValue; - float fValue; - bool isint32 = true; - if (pz) - isint32 = (bool)atoi(pz); - if (isint32) - { - iValue = (uint32)atoi(py); - sLog.outDebug(GetTrinityString(LANG_SET_UINT), GUID_LOPART(guid), Opcode, iValue); - target->SetUInt32Value(Opcode , iValue); - PSendSysMessage(LANG_SET_UINT_FIELD, GUID_LOPART(guid), Opcode,iValue); - } - else - { - fValue = (float)atof(py); - sLog.outDebug(GetTrinityString(LANG_SET_FLOAT), GUID_LOPART(guid), Opcode, fValue); - target->SetFloatValue(Opcode , fValue); - PSendSysMessage(LANG_SET_FLOAT_FIELD, GUID_LOPART(guid), Opcode,fValue); - } - - return true; -} - -bool ChatHandler::HandleDebugGetValueCommand(const char* args) -{ - if (!*args) - return false; - - char* px = strtok((char*)args, " "); - char* pz = strtok(NULL, " "); - - if (!px) - return false; - - Unit* target = getSelectedUnit(); - if (!target) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - SetSentErrorMessage(true); - return false; - } - - uint64 guid = target->GetGUID(); - - uint32 Opcode = (uint32)atoi(px); - if (Opcode >= target->GetValuesCount()) - { - PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, GUID_LOPART(guid), target->GetValuesCount()); - return false; - } - uint32 iValue; - float fValue; - bool isint32 = true; - if (pz) - isint32 = (bool)atoi(pz); - - if (isint32) - { - iValue = target->GetUInt32Value(Opcode); - sLog.outDebug(GetTrinityString(LANG_GET_UINT), GUID_LOPART(guid), Opcode, iValue); - PSendSysMessage(LANG_GET_UINT_FIELD, GUID_LOPART(guid), Opcode, iValue); - } - else - { - fValue = target->GetFloatValue(Opcode); - sLog.outDebug(GetTrinityString(LANG_GET_FLOAT), GUID_LOPART(guid), Opcode, fValue); - PSendSysMessage(LANG_GET_FLOAT_FIELD, GUID_LOPART(guid), Opcode, fValue); - } - - return true; -} - -bool ChatHandler::HandleDebugMod32ValueCommand(const char* args) -{ - if (!*args) - return false; - - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - - if (!px || !py) - return false; - - uint32 Opcode = (uint32)atoi(px); - int Value = atoi(py); - - if (Opcode >= m_session->GetPlayer()->GetValuesCount()) - { - PSendSysMessage(LANG_TOO_BIG_INDEX, Opcode, m_session->GetPlayer()->GetGUIDLow(), m_session->GetPlayer()->GetValuesCount()); - return false; - } - - sLog.outDebug(GetTrinityString(LANG_CHANGE_32BIT), Opcode, Value); - - int CurrentValue = (int)m_session->GetPlayer()->GetUInt32Value(Opcode); - - CurrentValue += Value; - m_session->GetPlayer()->SetUInt32Value(Opcode , (uint32)CurrentValue); - - PSendSysMessage(LANG_CHANGE_32BIT_FIELD, Opcode,CurrentValue); - - return true; -} - -bool ChatHandler::HandleDebugUpdateCommand(const char* args) -{ - if (!*args) - return false; - - uint32 updateIndex; - uint32 value; - - char* pUpdateIndex = strtok((char*)args, " "); - - Unit* chr = getSelectedUnit(); - if (chr == NULL) - { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); - SetSentErrorMessage(true); - return false; - } - - if (!pUpdateIndex) - { - return true; - } - updateIndex = atoi(pUpdateIndex); - //check updateIndex - if (chr->GetTypeId() == TYPEID_PLAYER) - { - if (updateIndex >= PLAYER_END) return true; - } - else - { - if (updateIndex >= UNIT_END) return true; - } - - char* pvalue = strtok(NULL, " "); - if (!pvalue) - { - value=chr->GetUInt32Value(updateIndex); - - PSendSysMessage(LANG_UPDATE, chr->GetGUIDLow(),updateIndex,value); - return true; - } - - value=atoi(pvalue); - - PSendSysMessage(LANG_UPDATE_CHANGE, chr->GetGUIDLow(),updateIndex,value); - - chr->SetUInt32Value(updateIndex,value); - - return true; -} +// This file is deprecated
\ No newline at end of file diff --git a/src/server/game/Chat/Commands/Level0.cpp b/src/server/game/Chat/Commands/Level0.cpp index f0ae7eade65..a1321b81125 100755 --- a/src/server/game/Chat/Commands/Level0.cpp +++ b/src/server/game/Chat/Commands/Level0.cpp @@ -52,13 +52,6 @@ bool ChatHandler::HandleCommandsCommand(const char* /*args*/) return true; } -bool ChatHandler::HandleAccountCommand(const char* /*args*/) -{ - AccountTypes gmlevel = m_session->GetSecurity(); - PSendSysMessage(LANG_ACCOUNT_LEVEL, uint32(gmlevel)); - return true; -} - bool ChatHandler::HandleStartCommand(const char* /*args*/) { Player *chr = m_session->GetPlayer(); @@ -151,147 +144,6 @@ bool ChatHandler::HandleSaveCommand(const char* /*args*/) return true; } -bool ChatHandler::HandleGMListIngameCommand(const char* /*args*/) -{ - bool first = true; - - ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, *HashMapHolder<Player>::GetLock(), true); - HashMapHolder<Player>::MapType &m = sObjectAccessor.GetPlayers(); - for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) - { - AccountTypes itr_sec = itr->second->GetSession()->GetSecurity(); - if ((itr->second->isGameMaster() || (itr_sec > SEC_PLAYER && itr_sec <= AccountTypes(sWorld.getIntConfig(CONFIG_GM_LEVEL_IN_GM_LIST)))) && - (!m_session || itr->second->IsVisibleGloballyFor(m_session->GetPlayer()))) - { - if (first) - { - SendSysMessage(LANG_GMS_ON_SRV); - first = false; - } - - SendSysMessage(GetNameLink(itr->second).c_str()); - } - } - - if (first) - SendSysMessage(LANG_GMS_NOT_LOGGED); - - return true; -} - -bool ChatHandler::HandleAccountPasswordCommand(const char* args) -{ - if (!*args) - { - SendSysMessage(LANG_CMD_SYNTAX); - SetSentErrorMessage(true); - return false; - } - - char *old_pass = strtok((char*)args, " "); - char *new_pass = strtok(NULL, " "); - char *new_pass_c = strtok(NULL, " "); - - if (!old_pass || !new_pass || !new_pass_c) - { - SendSysMessage(LANG_CMD_SYNTAX); - SetSentErrorMessage(true); - return false; - } - - std::string password_old = old_pass; - std::string password_new = new_pass; - std::string password_new_c = new_pass_c; - - if (!sAccountMgr.CheckPassword(m_session->GetAccountId(), password_old)) - { - SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD); - SetSentErrorMessage(true); - return false; - } - - if (strcmp(new_pass, new_pass_c) != 0) - { - SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH); - SetSentErrorMessage(true); - return false; - } - - AccountOpResult result = sAccountMgr.ChangePassword(m_session->GetAccountId(), password_new); - switch(result) - { - case AOR_OK: - SendSysMessage(LANG_COMMAND_PASSWORD); - break; - case AOR_PASS_TOO_LONG: - SendSysMessage(LANG_PASSWORD_TOO_LONG); - SetSentErrorMessage(true); - return false; - default: - SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD); - SetSentErrorMessage(true); - return false; - } - - return true; -} - -bool ChatHandler::HandleAccountAddonCommand(const char* args) -{ - if (!*args) - { - SendSysMessage(LANG_CMD_SYNTAX); - SetSentErrorMessage(true); - return false; - } - - char *szExp = strtok((char*)args, " "); - - uint32 account_id = m_session->GetAccountId(); - - int expansion = atoi(szExp); //get int anyway (0 if error) - if (expansion < 0 || uint8(expansion) > sWorld.getIntConfig(CONFIG_EXPANSION)) - { - SendSysMessage(LANG_IMPROPER_VALUE); - SetSentErrorMessage(true); - return false; - } - - // No SQL injection - LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'", expansion, account_id); - PSendSysMessage(LANG_ACCOUNT_ADDON, expansion); - return true; -} - -bool ChatHandler::HandleAccountLockCommand(const char* args) -{ - if (!*args) - { - SendSysMessage(LANG_USE_BOL); - SetSentErrorMessage(true); - return false; - } - - std::string argstr = (char*)args; - if (argstr == "on") - { - LoginDatabase.PExecute("UPDATE account SET locked = '1' WHERE id = '%d'",m_session->GetAccountId()); - PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED); - return true; - } - - if (argstr == "off") - { - LoginDatabase.PExecute("UPDATE account SET locked = '0' WHERE id = '%d'",m_session->GetAccountId()); - PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED); - return true; - } - - SendSysMessage(LANG_USE_BOL); - SetSentErrorMessage(true); - return false; -} - /// Display the 'Message of the day' for the realm bool ChatHandler::HandleServerMotdCommand(const char* /*args*/) { diff --git a/src/server/game/Chat/Commands/Level1.cpp b/src/server/game/Chat/Commands/Level1.cpp index 209b0fdbb1a..0cd416275f3 100755 --- a/src/server/game/Chat/Commands/Level1.cpp +++ b/src/server/game/Chat/Commands/Level1.cpp @@ -39,104 +39,6 @@ #include "VMapFactory.h" #endif -//-----------------------Npc Commands----------------------- -bool ChatHandler::HandleNpcSayCommand(const char* args) -{ - if (!*args) - return false; - - Creature* pCreature = getSelectedCreature(); - if (!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - pCreature->MonsterSay(args, LANG_UNIVERSAL, 0); - - // make some emotes - char lastchar = args[strlen(args) - 1]; - switch(lastchar) - { - case '?': pCreature->HandleEmoteCommand(EMOTE_ONESHOT_QUESTION); break; - case '!': pCreature->HandleEmoteCommand(EMOTE_ONESHOT_EXCLAMATION); break; - default: pCreature->HandleEmoteCommand(EMOTE_ONESHOT_TALK); break; - } - - return true; -} - -bool ChatHandler::HandleNpcYellCommand(const char* args) -{ - if (!*args) - return false; - - Creature* pCreature = getSelectedCreature(); - if (!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - pCreature->MonsterYell(args, LANG_UNIVERSAL, 0); - - // make an emote - pCreature->HandleEmoteCommand(EMOTE_ONESHOT_SHOUT); - - return true; -} - -//show text emote by creature in chat -bool ChatHandler::HandleNpcTextEmoteCommand(const char* args) -{ - if (!*args) - return false; - - Creature* pCreature = getSelectedCreature(); - - if (!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - pCreature->MonsterTextEmote(args, 0); - - return true; -} - -// make npc whisper to player -bool ChatHandler::HandleNpcWhisperCommand(const char* args) -{ - if (!*args) - return false; - - char* receiver_str = strtok((char*)args, " "); - char* text = strtok(NULL, ""); - - uint64 guid = m_session->GetPlayer()->GetSelection(); - Creature* pCreature = m_session->GetPlayer()->GetMap()->GetCreature(guid); - - if (!pCreature || !receiver_str || !text) - { - return false; - } - - uint64 receiver_guid= atol(receiver_str); - - // check online security - if (HasLowerSecurity(sObjectMgr.GetPlayer(receiver_guid), 0)) - return false; - - pCreature->MonsterWhisper(text,receiver_guid); - - return true; -} -//---------------------------------------------------------- - bool ChatHandler::HandleNameAnnounceCommand(const char* args) { WorldPacket data; @@ -211,112 +113,6 @@ bool ChatHandler::HandleGMNotifyCommand(const char* args) return true; } -//Enable\Dissable GM Mode -bool ChatHandler::HandleGMCommand(const char* args) -{ - if (!*args) - { - if (m_session->GetPlayer()->isGameMaster()) - m_session->SendNotification(LANG_GM_ON); - else - m_session->SendNotification(LANG_GM_OFF); - return true; - } - - std::string argstr = (char*)args; - - if (argstr == "on") - { - m_session->GetPlayer()->SetGameMaster(true); - m_session->SendNotification(LANG_GM_ON); - m_session->GetPlayer()->UpdateTriggerVisibility(); - #ifdef _DEBUG_VMAPS - VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); - vMapManager->processCommand("stoplog"); - #endif - return true; - } - - if (argstr == "off") - { - m_session->GetPlayer()->SetGameMaster(false); - m_session->SendNotification(LANG_GM_OFF); - m_session->GetPlayer()->UpdateTriggerVisibility(); - #ifdef _DEBUG_VMAPS - VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); - vMapManager->processCommand("startlog"); - #endif - return true; - } - - SendSysMessage(LANG_USE_BOL); - SetSentErrorMessage(true); - return false; -} - -// Enables or disables hiding of the staff badge -bool ChatHandler::HandleGMChatCommand(const char* args) -{ - if (!*args) - { - if (m_session->GetPlayer()->isGMChat()) - m_session->SendNotification(LANG_GM_CHAT_ON); - else - m_session->SendNotification(LANG_GM_CHAT_OFF); - return true; - } - - std::string argstr = (char*)args; - - if (argstr == "on") - { - m_session->GetPlayer()->SetGMChat(true); - m_session->SendNotification(LANG_GM_CHAT_ON); - return true; - } - - if (argstr == "off") - { - m_session->GetPlayer()->SetGMChat(false); - m_session->SendNotification(LANG_GM_CHAT_OFF); - return true; - } - - SendSysMessage(LANG_USE_BOL); - SetSentErrorMessage(true); - return false; -} - -//Enable\Dissable Invisible mode -bool ChatHandler::HandleGMVisibleCommand(const char* args) -{ - if (!*args) - { - PSendSysMessage(LANG_YOU_ARE, m_session->GetPlayer()->isGMVisible() ? GetTrinityString(LANG_VISIBLE) : GetTrinityString(LANG_INVISIBLE)); - return true; - } - - std::string argstr = (char*)args; - - if (argstr == "on") - { - m_session->GetPlayer()->SetGMVisible(true); - m_session->SendNotification(LANG_INVISIBLE_VISIBLE); - return true; - } - - if (argstr == "off") - { - m_session->SendNotification(LANG_INVISIBLE_INVISIBLE); - m_session->GetPlayer()->SetGMVisible(false); - return true; - } - - SendSysMessage(LANG_USE_BOL); - SetSentErrorMessage(true); - return false; -} - bool ChatHandler::HandleGPSCommand(const char* args) { WorldObject *obj = NULL; @@ -699,393 +495,6 @@ bool ChatHandler::HandleRecallCommand(const char* args) return true; } -//Edit Player HP -bool ChatHandler::HandleModifyHPCommand(const char* args) -{ - if (!*args) - return false; - - int32 hp = atoi((char*)args); - int32 hpm = atoi((char*)args); - - if (hp < 1 || hpm < 1 || hpm < hp) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - if (HasLowerSecurity(chr, 0)) - return false; - - PSendSysMessage(LANG_YOU_CHANGE_HP, GetNameLink(chr).c_str(), hp, hpm); - if (needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_HP_CHANGED, GetNameLink().c_str(), hp, hpm); - - chr->SetMaxHealth(hpm); - chr->SetHealth(hp); - - return true; -} - -//Edit Player Mana -bool ChatHandler::HandleModifyManaCommand(const char* args) -{ - if (!*args) - return false; - - int32 mana = atoi((char*)args); - int32 manam = atoi((char*)args); - - if (mana <= 0 || manam <= 0 || manam < mana) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(chr, 0)) - return false; - - PSendSysMessage(LANG_YOU_CHANGE_MANA, GetNameLink(chr).c_str(), mana, manam); - if (needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_MANA_CHANGED, GetNameLink().c_str(), mana, manam); - - chr->SetMaxPower(POWER_MANA,manam); - chr->SetPower(POWER_MANA, mana); - - return true; -} - -//Edit Player Energy -bool ChatHandler::HandleModifyEnergyCommand(const char* args) -{ - if (!*args) - return false; - - // char* pmana = strtok((char*)args, " "); - // if (!pmana) - // return false; - - // char* pmanaMax = strtok(NULL, " "); - // if (!pmanaMax) - // return false; - - // int32 manam = atoi(pmanaMax); - // int32 mana = atoi(pmana); - - int32 energy = atoi((char*)args)*10; - int32 energym = atoi((char*)args)*10; - - if (energy <= 0 || energym <= 0 || energym < energy) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (!chr) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(chr, 0)) - return false; - - PSendSysMessage(LANG_YOU_CHANGE_ENERGY, GetNameLink(chr).c_str(), energy/10, energym/10); - if (needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, GetNameLink().c_str(), energy/10, energym/10); - - chr->SetMaxPower(POWER_ENERGY,energym); - chr->SetPower(POWER_ENERGY, energy); - - sLog.outDetail(GetTrinityString(LANG_CURRENT_ENERGY),chr->GetMaxPower(POWER_ENERGY)); - - return true; -} - -//Edit Player Rage -bool ChatHandler::HandleModifyRageCommand(const char* args) -{ - if (!*args) - return false; - - // char* pmana = strtok((char*)args, " "); - // if (!pmana) - // return false; - - // char* pmanaMax = strtok(NULL, " "); - // if (!pmanaMax) - // return false; - - // int32 manam = atoi(pmanaMax); - // int32 mana = atoi(pmana); - - int32 rage = atoi((char*)args)*10; - int32 ragem = atoi((char*)args)*10; - - if (rage <= 0 || ragem <= 0 || ragem < rage) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(chr, 0)) - return false; - - PSendSysMessage(LANG_YOU_CHANGE_RAGE, GetNameLink(chr).c_str(), rage/10, ragem/10); - if (needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_RAGE_CHANGED, GetNameLink().c_str(), rage/10, ragem/10); - - chr->SetMaxPower(POWER_RAGE,ragem); - chr->SetPower(POWER_RAGE, rage); - - return true; -} - -// Edit Player Runic Power -bool ChatHandler::HandleModifyRunicPowerCommand(const char* args) -{ - if (!*args) - return false; - - int32 rune = atoi((char*)args)*10; - int32 runem = atoi((char*)args)*10; - - if (rune <= 0 || runem <= 0 || runem < rune) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_YOU_CHANGE_RUNIC_POWER, GetNameLink(chr).c_str(), rune/10, runem/10); - if (needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_RUNIC_POWER_CHANGED, GetNameLink().c_str(), rune/10, runem/10); - - chr->SetMaxPower(POWER_RUNIC_POWER,runem); - chr->SetPower(POWER_RUNIC_POWER, rune); - - return true; -} - -//Edit Player Faction -bool ChatHandler::HandleModifyFactionCommand(const char* args) -{ - if (!*args) - return false; - - char* pfactionid = extractKeyFromLink((char*)args,"Hfaction"); - - Creature* chr = getSelectedCreature(); - if (!chr) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - if (!pfactionid) - { - if (chr) - { - uint32 factionid = chr->getFaction(); - uint32 flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS); - uint32 npcflag = chr->GetUInt32Value(UNIT_NPC_FLAGS); - uint32 dyflag = chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS); - PSendSysMessage(LANG_CURRENT_FACTION,chr->GetGUIDLow(),factionid,flag,npcflag,dyflag); - } - return true; - } - - if (!chr) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - uint32 factionid = atoi(pfactionid); - uint32 flag; - - char *pflag = strtok(NULL, " "); - if (!pflag) - flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS); - else - flag = atoi(pflag); - - char* pnpcflag = strtok(NULL, " "); - - uint32 npcflag; - if (!pnpcflag) - npcflag = chr->GetUInt32Value(UNIT_NPC_FLAGS); - else - npcflag = atoi(pnpcflag); - - char* pdyflag = strtok(NULL, " "); - - uint32 dyflag; - if (!pdyflag) - dyflag = chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS); - else - dyflag = atoi(pdyflag); - - if (!sFactionTemplateStore.LookupEntry(factionid)) - { - PSendSysMessage(LANG_WRONG_FACTION, factionid); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_YOU_CHANGE_FACTION, chr->GetGUIDLow(),factionid,flag,npcflag,dyflag); - - chr->setFaction(factionid); - chr->SetUInt32Value(UNIT_FIELD_FLAGS,flag); - chr->SetUInt32Value(UNIT_NPC_FLAGS,npcflag); - chr->SetUInt32Value(UNIT_DYNAMIC_FLAGS,dyflag); - - return true; -} - -//Edit Player Spell -bool ChatHandler::HandleModifySpellCommand(const char* args) -{ - if (!*args) return false; - char* pspellflatid = strtok((char*)args, " "); - if (!pspellflatid) - return false; - - char* pop = strtok(NULL, " "); - if (!pop) - return false; - - char* pval = strtok(NULL, " "); - if (!pval) - return false; - - uint16 mark; - - char* pmark = strtok(NULL, " "); - - uint8 spellflatid = atoi(pspellflatid); - uint8 op = atoi(pop); - uint16 val = atoi(pval); - if (!pmark) - mark = 65535; - else - mark = atoi(pmark); - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(chr, 0)) - return false; - - PSendSysMessage(LANG_YOU_CHANGE_SPELLFLATID, spellflatid, val, mark, GetNameLink(chr).c_str()); - if (needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_SPELLFLATID_CHANGED, GetNameLink().c_str(), spellflatid, val, mark); - - WorldPacket data(SMSG_SET_FLAT_SPELL_MODIFIER, (1+1+2+2)); - data << uint8(spellflatid); - data << uint8(op); - data << uint16(val); - data << uint16(mark); - chr->GetSession()->SendPacket(&data); - - return true; -} - -//Edit Player TP -bool ChatHandler::HandleModifyTalentCommand (const char* args) -{ - if (!*args) - return false; - - int tp = atoi((char*)args); - if (tp < 0) - return false; - - Unit* target = getSelectedUnit(); - if (!target) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - if (target->GetTypeId() == TYPEID_PLAYER) - { - // check online security - if (HasLowerSecurity((Player*)target, 0)) - return false; - target->ToPlayer()->SetFreeTalentPoints(tp); - target->ToPlayer()->SendTalentsInfoData(false); - return true; - } - else if (target->ToCreature()->isPet()) - { - Unit *owner = target->GetOwner(); - if (owner && owner->GetTypeId() == TYPEID_PLAYER && ((Pet *)target)->IsPermanentPetFor(owner->ToPlayer())) - { - // check online security - if (HasLowerSecurity((Player*)owner, 0)) - return false; - ((Pet *)target)->SetFreeTalentPoints(tp); - owner->ToPlayer()->SendTalentsInfoData(true); - return true; - } - } - - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; -} - //Enable On\OFF all taxi paths bool ChatHandler::HandleTaxiCheatCommand(const char* args) { @@ -1132,711 +541,6 @@ bool ChatHandler::HandleTaxiCheatCommand(const char* args) return false; } -//Edit Player Aspeed -bool ChatHandler::HandleModifyASpeedCommand(const char* args) -{ - if (!*args) - return false; - - float ASpeed = (float)atof((char*)args); - - if (ASpeed > 50.0f || ASpeed < 0.1f) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(chr, 0)) - return false; - - std::string chrNameLink = GetNameLink(chr); - - if (chr->isInFlight()) - { - PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str()); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_YOU_CHANGE_ASPEED, ASpeed, chrNameLink.c_str()); - if (needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_ASPEED_CHANGED, GetNameLink().c_str(), ASpeed); - - chr->SetSpeed(MOVE_WALK, ASpeed,true); - chr->SetSpeed(MOVE_RUN, ASpeed,true); - chr->SetSpeed(MOVE_SWIM, ASpeed,true); - //chr->SetSpeed(MOVE_TURN, ASpeed,true); - chr->SetSpeed(MOVE_FLIGHT, ASpeed,true); - return true; -} - -//Edit Player Speed -bool ChatHandler::HandleModifySpeedCommand(const char* args) -{ - if (!*args) - return false; - - float Speed = (float)atof((char*)args); - - if (Speed > 50.0f || Speed < 0.1f) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(chr, 0)) - return false; - - std::string chrNameLink = GetNameLink(chr); - - if (chr->isInFlight()) - { - PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str()); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_YOU_CHANGE_SPEED, Speed, chrNameLink.c_str()); - if (needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_SPEED_CHANGED, GetNameLink().c_str(), Speed); - - chr->SetSpeed(MOVE_RUN,Speed,true); - - return true; -} - -//Edit Player Swim Speed -bool ChatHandler::HandleModifySwimCommand(const char* args) -{ - if (!*args) - return false; - - float Swim = (float)atof((char*)args); - - if (Swim > 50.0f || Swim < 0.1f) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(chr, 0)) - return false; - - std::string chrNameLink = GetNameLink(chr); - - if (chr->isInFlight()) - { - PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str()); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_YOU_CHANGE_SWIM_SPEED, Swim, chrNameLink.c_str()); - if (needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_SWIM_SPEED_CHANGED, GetNameLink().c_str(), Swim); - - chr->SetSpeed(MOVE_SWIM,Swim,true); - - return true; -} - -//Edit Player Walk Speed -bool ChatHandler::HandleModifyBWalkCommand(const char* args) -{ - if (!*args) - return false; - - float BSpeed = (float)atof((char*)args); - - if (BSpeed > 50.0f || BSpeed < 0.1f) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(chr, 0)) - return false; - - std::string chrNameLink = GetNameLink(chr); - - if (chr->isInFlight()) - { - PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str()); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage(LANG_YOU_CHANGE_BACK_SPEED, BSpeed, chrNameLink.c_str()); - if (needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_BACK_SPEED_CHANGED, GetNameLink().c_str(), BSpeed); - - chr->SetSpeed(MOVE_RUN_BACK,BSpeed,true); - - return true; -} - -//Edit Player Fly -bool ChatHandler::HandleModifyFlyCommand(const char* args) -{ - if (!*args) - return false; - - float FSpeed = (float)atof((char*)args); - - if (FSpeed > 50.0f || FSpeed < 0.1f) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(chr, 0)) - return false; - - PSendSysMessage(LANG_YOU_CHANGE_FLY_SPEED, FSpeed, GetNameLink(chr).c_str()); - if (needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_FLY_SPEED_CHANGED, GetNameLink().c_str(), FSpeed); - - chr->SetSpeed(MOVE_FLIGHT,FSpeed,true); - - return true; -} - -//Edit Player Scale -bool ChatHandler::HandleModifyScaleCommand(const char* args) -{ - if (!*args) - return false; - - float Scale = (float)atof((char*)args); - if (Scale > 10.0f || Scale < 0.1f) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(chr, 0)) - return false; - - PSendSysMessage(LANG_YOU_CHANGE_SIZE, Scale, GetNameLink(chr).c_str()); - if (needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_SIZE_CHANGED, GetNameLink().c_str(), Scale); - - chr->SetFloatValue(OBJECT_FIELD_SCALE_X, Scale); - - return true; -} - -//Enable Player mount -bool ChatHandler::HandleModifyMountCommand(const char* args) -{ - if (!*args) - return false; - - uint16 mId = 1147; - float speed = (float)15; - uint32 num = 0; - - num = atoi((char*)args); - switch(num) - { - case 1: - mId=14340; - break; - case 2: - mId=4806; - break; - case 3: - mId=6471; - break; - case 4: - mId=12345; - break; - case 5: - mId=6472; - break; - case 6: - mId=6473; - break; - case 7: - mId=10670; - break; - case 8: - mId=10719; - break; - case 9: - mId=10671; - break; - case 10: - mId=10672; - break; - case 11: - mId=10720; - break; - case 12: - mId=14349; - break; - case 13: - mId=11641; - break; - case 14: - mId=12244; - break; - case 15: - mId=12242; - break; - case 16: - mId=14578; - break; - case 17: - mId=14579; - break; - case 18: - mId=14349; - break; - case 19: - mId=12245; - break; - case 20: - mId=14335; - break; - case 21: - mId=207; - break; - case 22: - mId=2328; - break; - case 23: - mId=2327; - break; - case 24: - mId=2326; - break; - case 25: - mId=14573; - break; - case 26: - mId=14574; - break; - case 27: - mId=14575; - break; - case 28: - mId=604; - break; - case 29: - mId=1166; - break; - case 30: - mId=2402; - break; - case 31: - mId=2410; - break; - case 32: - mId=2409; - break; - case 33: - mId=2408; - break; - case 34: - mId=2405; - break; - case 35: - mId=14337; - break; - case 36: - mId=6569; - break; - case 37: - mId=10661; - break; - case 38: - mId=10666; - break; - case 39: - mId=9473; - break; - case 40: - mId=9476; - break; - case 41: - mId=9474; - break; - case 42: - mId=14374; - break; - case 43: - mId=14376; - break; - case 44: - mId=14377; - break; - case 45: - mId=2404; - break; - case 46: - mId=2784; - break; - case 47: - mId=2787; - break; - case 48: - mId=2785; - break; - case 49: - mId=2736; - break; - case 50: - mId=2786; - break; - case 51: - mId=14347; - break; - case 52: - mId=14346; - break; - case 53: - mId=14576; - break; - case 54: - mId=9695; - break; - case 55: - mId=9991; - break; - case 56: - mId=6448; - break; - case 57: - mId=6444; - break; - case 58: - mId=6080; - break; - case 59: - mId=6447; - break; - case 60: - mId=4805; - break; - case 61: - mId=9714; - break; - case 62: - mId=6448; - break; - case 63: - mId=6442; - break; - case 64: - mId=14632; - break; - case 65: - mId=14332; - break; - case 66: - mId=14331; - break; - case 67: - mId=8469; - break; - case 68: - mId=2830; - break; - case 69: - mId=2346; - break; - default: - SendSysMessage(LANG_NO_MOUNT); - SetSentErrorMessage(true); - return false; - } - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(chr, 0)) - return false; - - PSendSysMessage(LANG_YOU_GIVE_MOUNT, GetNameLink(chr).c_str()); - if (needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_MOUNT_GIVED, GetNameLink().c_str()); - - chr->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP); - chr->Mount(mId); - - WorldPacket data(SMSG_FORCE_RUN_SPEED_CHANGE, (8+4+1+4)); - data.append(chr->GetPackGUID()); - data << (uint32)0; - data << (uint8)0; //new 2.1.0 - data << float(speed); - chr->SendMessageToSet(&data, true); - - data.Initialize(SMSG_FORCE_SWIM_SPEED_CHANGE, (8+4+4)); - data.append(chr->GetPackGUID()); - data << (uint32)0; - data << float(speed); - chr->SendMessageToSet(&data, true); - - return true; -} - -//Edit Player money -bool ChatHandler::HandleModifyMoneyCommand(const char* args) -{ - if (!*args) - return false; - - Player *chr = getSelectedPlayer(); - if (chr == NULL) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(chr, 0)) - return false; - - int32 addmoney = atoi((char*)args); - - uint32 moneyuser = chr->GetMoney(); - - if (addmoney < 0) - { - int32 newmoney = int32(moneyuser) + addmoney; - - sLog.outDetail(GetTrinityString(LANG_CURRENT_MONEY), moneyuser, addmoney, newmoney); - if (newmoney <= 0) - { - PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, GetNameLink(chr).c_str()); - if (needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_ALL_MONEY_GONE, GetNameLink().c_str()); - - chr->SetMoney(0); - } - else - { - if (newmoney > MAX_MONEY_AMOUNT) - newmoney = MAX_MONEY_AMOUNT; - - PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(addmoney), GetNameLink(chr).c_str()); - if (needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, GetNameLink().c_str(), abs(addmoney)); - chr->SetMoney(newmoney); - } - } - else - { - PSendSysMessage(LANG_YOU_GIVE_MONEY, addmoney, GetNameLink(chr).c_str()); - if (needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, GetNameLink().c_str(), addmoney); - - if (addmoney >=MAX_MONEY_AMOUNT) - chr->SetMoney(MAX_MONEY_AMOUNT); - else - chr->ModifyMoney(addmoney); - } - - sLog.outDetail(GetTrinityString(LANG_NEW_MONEY), moneyuser, addmoney, chr->GetMoney()); - - return true; -} - -//Edit Unit field -bool ChatHandler::HandleModifyBitCommand(const char* args) -{ - if (!*args) - return false; - - Unit *unit = getSelectedUnit(); - if (!unit) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (unit->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity(unit->ToPlayer(), 0)) - return false; - - char* pField = strtok((char*)args, " "); - if (!pField) - return false; - - char* pBit = strtok(NULL, " "); - if (!pBit) - return false; - - uint16 field = atoi(pField); - uint32 bit = atoi(pBit); - - if (field < OBJECT_END || field >= unit->GetValuesCount()) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - if (bit < 1 || bit > 32) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - if (unit->HasFlag(field, (1<<(bit-1)))) - { - unit->RemoveFlag(field, (1<<(bit-1))); - PSendSysMessage(LANG_REMOVE_BIT, bit, field); - } - else - { - unit->SetFlag(field, (1<<(bit-1))); - PSendSysMessage(LANG_SET_BIT, bit, field); - } - return true; -} - -bool ChatHandler::HandleModifyHonorCommand (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; - - int32 amount = (uint32)atoi(args); - - target->ModifyHonorPoints(amount); - - PSendSysMessage(LANG_COMMAND_MODIFY_HONOR, GetNameLink(target).c_str(), target->GetHonorPoints()); - - return true; -} - -bool ChatHandler::HandleTeleCommand(const char * args) -{ - if (!*args) - return false; - - Player* _player = m_session->GetPlayer(); - - // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r - GameTele const* tele = extractGameTeleFromLink((char*)args); - - if (!tele) - { - SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); - SetSentErrorMessage(true); - return false; - } - - if (_player->isInCombat()) - { - SendSysMessage(LANG_YOU_IN_COMBAT); - SetSentErrorMessage(true); - return false; - } - - MapEntry const * me = sMapStore.LookupEntry(tele->mapId); - if (!me || me->IsBattlegroundOrArena()) - { - SendSysMessage(LANG_CANNOT_TELE_TO_BG); - SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - _player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation); - return true; -} - bool ChatHandler::HandleLookupAreaCommand(const char* args) { if (!*args) @@ -2311,279 +1015,3 @@ bool ChatHandler::HandleGroupSummonCommand(const char* args) return true; } - -bool ChatHandler::HandleGoTaxinodeCommand(const char* args) -{ - Player* _player = m_session->GetPlayer(); - - if (!*args) - return false; - - char* cNodeId = extractKeyFromLink((char*)args,"Htaxinode"); - if (!cNodeId) - return false; - - int32 i_nodeId = atoi(cNodeId); - if (!i_nodeId) - return false; - - TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i_nodeId); - if (!node) - { - PSendSysMessage(LANG_COMMAND_GOTAXINODENOTFOUND,i_nodeId); - SetSentErrorMessage(true); - return false; - } - - if ((node->x == 0.0f && node->y == 0.0f && node->z == 0.0f) || - !MapManager::IsValidMapCoord(node->map_id,node->x,node->y,node->z)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,node->x,node->y,node->map_id); - SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - _player->TeleportTo(node->map_id, node->x, node->y, node->z, _player->GetOrientation()); - return true; -} - -//teleport at coordinates -bool ChatHandler::HandleGoXYCommand(const char* args) -{ - if (!*args) - return false; - - Player* _player = m_session->GetPlayer(); - - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - char* pmapid = strtok(NULL, " "); - - if (!px || !py) - return false; - - float x = (float)atof(px); - float y = (float)atof(py); - uint32 mapid; - if (pmapid) - mapid = (uint32)atoi(pmapid); - else - mapid = _player->GetMapId(); - - if (!MapManager::IsValidMapCoord(mapid,x,y)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); - SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - Map const *map = sMapMgr.CreateBaseMap(mapid); - float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); - - _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); - - return true; -} - -//teleport at coordinates, including Z -bool ChatHandler::HandleGoXYZCommand(const char* args) -{ - if (!*args) - return false; - - Player* _player = m_session->GetPlayer(); - - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - char* pz = strtok(NULL, " "); - char* pmapid = strtok(NULL, " "); - - if (!px || !py || !pz) - return false; - - float x = (float)atof(px); - float y = (float)atof(py); - float z = (float)atof(pz); - uint32 mapid; - if (pmapid) - mapid = (uint32)atoi(pmapid); - else - mapid = _player->GetMapId(); - - if (!MapManager::IsValidMapCoord(mapid,x,y,z)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); - SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); - - return true; -} - -//teleport at coordinates -bool ChatHandler::HandleGoZoneXYCommand(const char* args) -{ - if (!*args) - return false; - - Player* _player = m_session->GetPlayer(); - - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - char* tail = strtok(NULL,""); - - char* cAreaId = extractKeyFromLink(tail,"Harea"); // string or [name] Shift-click form |color|Harea:area_id|h[name]|h|r - - if (!px || !py) - return false; - - float x = (float)atof(px); - float y = (float)atof(py); - - // prevent accept wrong numeric args - if ((x == 0.0f && *px != '0') || (y == 0.0f && *py != '0')) - return false; - - uint32 areaid = cAreaId ? (uint32)atoi(cAreaId) : _player->GetZoneId(); - - AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaid); - - if (x < 0 || x > 100 || y < 0 || y > 100 || !areaEntry) - { - PSendSysMessage(LANG_INVALID_ZONE_COORD,x,y,areaid); - SetSentErrorMessage(true); - return false; - } - - // update to parent zone if exist (client map show only zones without parents) - AreaTableEntry const* zoneEntry = areaEntry->zone ? GetAreaEntryByAreaID(areaEntry->zone) : areaEntry; - - Map const *map = sMapMgr.CreateBaseMap(zoneEntry->mapid); - - if (map->Instanceable()) - { - PSendSysMessage(LANG_INVALID_ZONE_MAP,areaEntry->ID,areaEntry->area_name[GetSessionDbcLocale()],map->GetId(),map->GetMapName()); - SetSentErrorMessage(true); - return false; - } - - Zone2MapCoordinates(x,y,zoneEntry->ID); - - if (!MapManager::IsValidMapCoord(zoneEntry->mapid,x,y)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,zoneEntry->mapid); - SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); - _player->TeleportTo(zoneEntry->mapid, x, y, z, _player->GetOrientation()); - - return true; -} - -//teleport to grid -bool ChatHandler::HandleGoGridCommand(const char* args) -{ - if (!*args) return false; - Player* _player = m_session->GetPlayer(); - - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - char* pmapid = strtok(NULL, " "); - - if (!px || !py) - return false; - - float grid_x = (float)atof(px); - float grid_y = (float)atof(py); - uint32 mapid; - if (pmapid) - mapid = (uint32)atoi(pmapid); - else mapid = _player->GetMapId(); - - // center of grid - float x = (grid_x-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS; - float y = (grid_y-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS; - - if (!MapManager::IsValidMapCoord(mapid,x,y)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); - SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - Map const *map = sMapMgr.CreateBaseMap(mapid); - float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); - _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); - - return true; -} - -bool ChatHandler::HandleModifyDrunkCommand(const char* args) -{ - if (!*args) return false; - - uint32 drunklevel = (uint32)atoi(args); - if (drunklevel > 100) - drunklevel = 100; - - uint16 drunkMod = drunklevel * 0xFFFF / 100; - - m_session->GetPlayer()->SetDrunkValue(drunkMod); - - return true; -} - diff --git a/src/server/game/Chat/Commands/Level2.cpp b/src/server/game/Chat/Commands/Level2.cpp index 2e52a9e5c96..ae86c290b7b 100755 --- a/src/server/game/Chat/Commands/Level2.cpp +++ b/src/server/game/Chat/Commands/Level2.cpp @@ -136,256 +136,6 @@ bool ChatHandler::HandleUnmuteCommand(const char* args) return true; } -bool ChatHandler::HandleGoTriggerCommand(const char* args) -{ - Player* _player = m_session->GetPlayer(); - - if (!*args) - return false; - - char *atId = strtok((char*)args, " "); - if (!atId) - return false; - - int32 i_atId = atoi(atId); - - if (!i_atId) - return false; - - AreaTriggerEntry const* at = sAreaTriggerStore.LookupEntry(i_atId); - if (!at) - { - PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND,i_atId); - SetSentErrorMessage(true); - return false; - } - - if (!MapManager::IsValidMapCoord(at->mapid,at->x,at->y,at->z)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,at->x,at->y,at->mapid); - SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - _player->TeleportTo(at->mapid, at->x, at->y, at->z, _player->GetOrientation()); - return true; -} - -bool ChatHandler::HandleGoGraveyardCommand(const char* args) -{ - Player* _player = m_session->GetPlayer(); - - if (!*args) - return false; - - char *gyId = strtok((char*)args, " "); - if (!gyId) - return false; - - int32 i_gyId = atoi(gyId); - - if (!i_gyId) - return false; - - WorldSafeLocsEntry const* gy = sWorldSafeLocsStore.LookupEntry(i_gyId); - if (!gy) - { - PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST,i_gyId); - SetSentErrorMessage(true); - return false; - } - - if (!MapManager::IsValidMapCoord(gy->map_id,gy->x,gy->y,gy->z)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,gy->x,gy->y,gy->map_id); - SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - _player->TeleportTo(gy->map_id, gy->x, gy->y, gy->z, _player->GetOrientation()); - return true; -} - -/** \brief Teleport the GM to the specified creature -* -* .gocreature <GUID> --> TP using creature.guid -* .gocreature azuregos --> TP player to the mob with this name -* Warning: If there is more than one mob with this name -* you will be teleported to the first one that is found. -* .gocreature id 6109 --> TP player to the mob, that has this creature_template.entry -* Warning: If there is more than one mob with this "id" -* you will be teleported to the first one that is found. -*/ -//teleport to creature -bool ChatHandler::HandleGoCreatureCommand(const char* args) -{ - if (!*args) - return false; - Player* _player = m_session->GetPlayer(); - - // "id" or number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r - char* pParam1 = extractKeyFromLink((char*)args,"Hcreature"); - if (!pParam1) - return false; - - std::ostringstream whereClause; - - // User wants to teleport to the NPC's template entry - if (strcmp(pParam1, "id") == 0) - { - //sLog.outError("DEBUG: ID found"); - - // Get the "creature_template.entry" - // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r - char* tail = strtok(NULL,""); - if (!tail) - return false; - char* cId = extractKeyFromLink(tail,"Hcreature_entry"); - if (!cId) - return false; - - int32 tEntry = atoi(cId); - //sLog.outError("DEBUG: ID value: %d", tEntry); - if (!tEntry) - return false; - - whereClause << "WHERE id = '" << tEntry << "'"; - } - else - { - //sLog.outError("DEBUG: ID *not found*"); - - int32 guid = atoi(pParam1); - - // Number is invalid - maybe the user specified the mob's name - if (!guid) - { - std::string name = pParam1; - WorldDatabase.escape_string(name); - whereClause << ", creature_template WHERE creature.id = creature_template.entry AND creature_template.name "_LIKE_" '" << name << "'"; - } - else - { - whereClause << "WHERE guid = '" << guid << "'"; - } - } - //sLog.outError("DEBUG: %s", whereClause.c_str()); - - QueryResult result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map FROM creature %s", whereClause.str().c_str()); - if (!result) - { - SendSysMessage(LANG_COMMAND_GOCREATNOTFOUND); - SetSentErrorMessage(true); - return false; - } - if (result->GetRowCount() > 1) - SendSysMessage(LANG_COMMAND_GOCREATMULTIPLE); - - Field *fields = result->Fetch(); - float x = fields[0].GetFloat(); - float y = fields[1].GetFloat(); - float z = fields[2].GetFloat(); - float ort = fields[3].GetFloat(); - int mapid = fields[4].GetUInt16(); - - if (!MapManager::IsValidMapCoord(mapid,x,y,z,ort)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); - SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - _player->TeleportTo(mapid, x, y, z, ort); - return true; -} - -//teleport to gameobject -bool ChatHandler::HandleGoObjectCommand(const char* args) -{ - if (!*args) - return false; - - Player* _player = m_session->GetPlayer(); - - // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hgameobject"); - if (!cId) - return false; - - int32 guid = atoi(cId); - if (!guid) - return false; - - float x, y, z, ort; - int mapid; - - // by DB guid - if (GameObjectData const* go_data = sObjectMgr.GetGOData(guid)) - { - x = go_data->posX; - y = go_data->posY; - z = go_data->posZ; - ort = go_data->orientation; - mapid = go_data->mapid; - } - else - { - SendSysMessage(LANG_COMMAND_GOOBJNOTFOUND); - SetSentErrorMessage(true); - return false; - } - - if (!MapManager::IsValidMapCoord(mapid,x,y,z,ort)) - { - PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); - SetSentErrorMessage(true); - return false; - } - - // stop flight if need - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } - // save only in non-flight case - else - _player->SaveRecallPosition(); - - _player->TeleportTo(mapid, x, y, z, ort); - return true; -} - bool ChatHandler::HandleGameObjectTargetCommand(const char* args) { Player* pl = m_session->GetPlayer(); @@ -837,1050 +587,7 @@ bool ChatHandler::HandleGUIDCommand(const char* /*args*/) return true; } -bool ChatHandler::HandleModifyRepCommand(const char * args) -{ - if (!*args) return false; - - Player* target = NULL; - target = getSelectedPlayer(); - - if (!target) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(target, 0)) - return false; - - char* factionTxt = extractKeyFromLink((char*)args,"Hfaction"); - if (!factionTxt) - return false; - - uint32 factionId = atoi(factionTxt); - - int32 amount = 0; - char *rankTxt = strtok(NULL, " "); - if (!factionTxt || !rankTxt) - return false; - - amount = atoi(rankTxt); - if ((amount == 0) && (rankTxt[0] != '-') && !isdigit(rankTxt[0])) - { - std::string rankStr = rankTxt; - std::wstring wrankStr; - if (!Utf8toWStr(rankStr,wrankStr)) - return false; - wstrToLower(wrankStr); - - int r = 0; - amount = -42000; - for (; r < MAX_REPUTATION_RANK; ++r) - { - std::string rank = GetTrinityString(ReputationRankStrIndex[r]); - if (rank.empty()) - continue; - - std::wstring wrank; - if (!Utf8toWStr(rank,wrank)) - continue; - - wstrToLower(wrank); - - if (wrank.substr(0,wrankStr.size()) == wrankStr) - { - char *deltaTxt = strtok(NULL, " "); - if (deltaTxt) - { - int32 delta = atoi(deltaTxt); - if ((delta < 0) || (delta > ReputationMgr::PointsInRank[r] -1)) - { - PSendSysMessage(LANG_COMMAND_FACTION_DELTA, (ReputationMgr::PointsInRank[r]-1)); - SetSentErrorMessage(true); - return false; - } - amount += delta; - } - break; - } - amount += ReputationMgr::PointsInRank[r]; - } - if (r >= MAX_REPUTATION_RANK) - { - PSendSysMessage(LANG_COMMAND_FACTION_INVPARAM, rankTxt); - SetSentErrorMessage(true); - return false; - } - } - - FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionId); - - if (!factionEntry) - { - PSendSysMessage(LANG_COMMAND_FACTION_UNKNOWN, factionId); - SetSentErrorMessage(true); - return false; - } - - if (factionEntry->reputationListID < 0) - { - PSendSysMessage(LANG_COMMAND_FACTION_NOREP_ERROR, factionEntry->name[GetSessionDbcLocale()], factionId); - SetSentErrorMessage(true); - return false; - } - - target->GetReputationMgr().SetReputation(factionEntry,amount); - PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->name[GetSessionDbcLocale()], factionId, - GetNameLink(target).c_str(), target->GetReputationMgr().GetReputation(factionEntry)); - return true; -} - -//-----------------------Npc Commands----------------------- -//add spawn of creature -bool ChatHandler::HandleNpcAddCommand(const char* args) -{ - if (!*args) - return false; - char* charID = extractKeyFromLink((char*)args,"Hcreature_entry"); - if (!charID) - return false; - - char* team = strtok(NULL, " "); - int32 teamval = 0; - if (team) { teamval = atoi(team); } - if (teamval < 0) { teamval = 0; } - - uint32 id = atoi(charID); - - Player *chr = m_session->GetPlayer(); - float x = chr->GetPositionX(); - float y = chr->GetPositionY(); - float z = chr->GetPositionZ(); - float o = chr->GetOrientation(); - Map *map = chr->GetMap(); - - if (chr->GetTransport()) - { - uint32 tguid = chr->GetTransport()->AddNPCPassenger(0, id, chr->GetTransOffsetX(), chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO()); - if (tguid > 0) - WorldDatabase.PQuery("INSERT INTO creature_transport (guid, npc_entry, transport_entry, TransOffsetX, TransOffsetY, TransOffsetZ, TransOffsetO) values (%u, %u, %f, %f, %f, %f, %u)", tguid, id, chr->GetTransport()->GetEntry(), chr->GetTransOffsetX(), chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO()); - - return true; - } - - Creature* pCreature = new Creature; - if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, (uint32)teamval, x, y, z, o)) - { - delete pCreature; - return false; - } - - pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); - - uint32 db_guid = pCreature->GetDBTableGUIDLow(); - - // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); - pCreature->LoadFromDB(db_guid, map); - - map->Add(pCreature); - sObjectMgr.AddCreatureToGrid(db_guid, sObjectMgr.GetCreatureData(db_guid)); - return true; -} - -//add item in vendorlist -bool ChatHandler::HandleNpcAddVendorItemCommand(const char* args) -{ - if (!*args) - return false; - - char* pitem = extractKeyFromLink((char*)args,"Hitem"); - if (!pitem) - { - SendSysMessage(LANG_COMMAND_NEEDITEMSEND); - SetSentErrorMessage(true); - return false; - } - - uint32 itemId = atol(pitem); - - char* fmaxcount = strtok(NULL, " "); //add maxcount, default: 0 - uint32 maxcount = 0; - if (fmaxcount) - maxcount = atol(fmaxcount); - - char* fincrtime = strtok(NULL, " "); //add incrtime, default: 0 - uint32 incrtime = 0; - if (fincrtime) - incrtime = atol(fincrtime); - - char* fextendedcost = strtok(NULL, " "); //add ExtendedCost, default: 0 - uint32 extendedcost = fextendedcost ? atol(fextendedcost) : 0; - - Creature* vendor = getSelectedCreature(); - - uint32 vendor_entry = vendor ? vendor->GetEntry() : 0; - - if (!sObjectMgr.IsVendorItemValid(vendor_entry,itemId,maxcount,incrtime,extendedcost,m_session->GetPlayer())) - { - SetSentErrorMessage(true); - return false; - } - - sObjectMgr.AddVendorItem(vendor_entry,itemId,maxcount,incrtime,extendedcost); - - ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(itemId); - - PSendSysMessage(LANG_ITEM_ADDED_TO_LIST,itemId,pProto->Name1,maxcount,incrtime,extendedcost); - return true; -} - -//del item from vendor list -bool ChatHandler::HandleNpcDelVendorItemCommand(const char* args) -{ - if (!*args) - return false; - - Creature* vendor = getSelectedCreature(); - if (!vendor || !vendor->isVendor()) - { - SendSysMessage(LANG_COMMAND_VENDORSELECTION); - SetSentErrorMessage(true); - return false; - } - - char* pitem = extractKeyFromLink((char*)args,"Hitem"); - if (!pitem) - { - SendSysMessage(LANG_COMMAND_NEEDITEMSEND); - SetSentErrorMessage(true); - return false; - } - uint32 itemId = atol(pitem); - - if (!sObjectMgr.RemoveVendorItem(vendor->GetEntry(),itemId)) - { - PSendSysMessage(LANG_ITEM_NOT_IN_LIST,itemId); - SetSentErrorMessage(true); - return false; - } - - ItemPrototype const* pProto = sObjectMgr.GetItemPrototype(itemId); - - PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST,itemId,pProto->Name1); - return true; -} - -//add move for creature -bool ChatHandler::HandleNpcAddMoveCommand(const char* args) -{ - if (!*args) - return false; - - char* guid_str = strtok((char*)args, " "); - char* wait_str = strtok((char*)NULL, " "); - - uint32 lowguid = atoi((char*)guid_str); - - Creature* pCreature = NULL; - - /* FIXME: impossible without entry - if (lowguid) - pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_GUID(lowguid,HIGHGUID_UNIT)); - */ - - // attempt check creature existence by DB data - if (!pCreature) - { - CreatureData const* data = sObjectMgr.GetCreatureData(lowguid); - if (!data) - { - PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - } - else - { - // obtain real GUID for DB operations - lowguid = pCreature->GetDBTableGUIDLow(); - } - - int wait = wait_str ? atoi(wait_str) : 0; - - if (wait < 0) - wait = 0; - - //Player* player = m_session->GetPlayer(); - - //WaypointMgr.AddLastNode(lowguid, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), wait, 0); - - // update movement type - WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE,lowguid); - if (pCreature && pCreature->GetWaypointPath()) - { - pCreature->SetDefaultMovementType(WAYPOINT_MOTION_TYPE); - pCreature->GetMotionMaster()->Initialize(); - if (pCreature->isAlive()) // dead creature will reset movement generator at respawn - { - pCreature->setDeathState(JUST_DIED); - pCreature->Respawn(true); - } - pCreature->SaveToDB(); - } - - SendSysMessage(LANG_WAYPOINT_ADDED); - - return true; -} - -//change level of creature or pet -bool ChatHandler::HandleNpcChangeLevelCommand(const char* args) -{ - if (!*args) - return false; - - uint8 lvl = (uint8) atoi((char*)args); - if (lvl < 1 || lvl > sWorld.getIntConfig(CONFIG_MAX_PLAYER_LEVEL) + 3) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Creature* pCreature = getSelectedCreature(); - if (!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - if (pCreature->isPet()) - { - if (((Pet*)pCreature)->getPetType() == HUNTER_PET) - { - pCreature->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForLevel(lvl)/4); - pCreature->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); - } - ((Pet*)pCreature)->GivePetLevel(lvl); - } - else - { - pCreature->SetMaxHealth(100 + 30*lvl); - pCreature->SetHealth(100 + 30*lvl); - pCreature->SetLevel(lvl); - pCreature->SaveToDB(); - } - - return true; -} - -//set npcflag of creature -bool ChatHandler::HandleNpcFlagCommand(const char* args) -{ - if (!*args) - return false; - - uint32 npcFlags = (uint32) atoi((char*)args); - - Creature* pCreature = getSelectedCreature(); - - if (!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - pCreature->SetUInt32Value(UNIT_NPC_FLAGS, npcFlags); - - WorldDatabase.PExecute("UPDATE creature_template SET npcflag = '%u' WHERE entry = '%u'", npcFlags, pCreature->GetEntry()); - - SendSysMessage(LANG_VALUE_SAVED_REJOIN); - - return true; -} - -bool ChatHandler::HandleNpcDeleteCommand(const char* args) -{ - Creature* unit = NULL; - - if (*args) - { - // number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hcreature"); - if (!cId) - return false; - - uint32 lowguid = atoi(cId); - if (!lowguid) - return false; - - if (CreatureData const* cr_data = sObjectMgr.GetCreatureData(lowguid)) - unit = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(lowguid, cr_data->id, HIGHGUID_UNIT)); - } - else - unit = getSelectedCreature(); - - if (!unit || unit->isPet() || unit->isTotem()) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - // Delete the creature - unit->CombatStop(); - unit->DeleteFromDB(); - unit->AddObjectToRemoveList(); - - SendSysMessage(LANG_COMMAND_DELCREATMESSAGE); - - return true; -} - -//move selected creature -bool ChatHandler::HandleNpcMoveCommand(const char* args) -{ - uint32 lowguid = 0; - - Creature* pCreature = getSelectedCreature(); - - if (!pCreature) - { - // number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r - char* cId = extractKeyFromLink((char*)args,"Hcreature"); - if (!cId) - return false; - - lowguid = atoi(cId); - - /* FIXME: impossibel without entry - if (lowguid) - pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_GUID(lowguid,HIGHGUID_UNIT)); - */ - - // Attempting creature load from DB data - if (!pCreature) - { - CreatureData const* data = sObjectMgr.GetCreatureData(lowguid); - if (!data) - { - PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - - uint32 map_id = data->mapid; - - if (m_session->GetPlayer()->GetMapId() != map_id) - { - PSendSysMessage(LANG_COMMAND_CREATUREATSAMEMAP, lowguid); - SetSentErrorMessage(true); - return false; - } - } - else - { - lowguid = pCreature->GetDBTableGUIDLow(); - } - } - else - { - lowguid = pCreature->GetDBTableGUIDLow(); - } - - float x = m_session->GetPlayer()->GetPositionX(); - float y = m_session->GetPlayer()->GetPositionY(); - float z = m_session->GetPlayer()->GetPositionZ(); - float o = m_session->GetPlayer()->GetOrientation(); - - if (pCreature) - { - if (CreatureData const* data = sObjectMgr.GetCreatureData(pCreature->GetDBTableGUIDLow())) - { - const_cast<CreatureData*>(data)->posX = x; - const_cast<CreatureData*>(data)->posY = y; - const_cast<CreatureData*>(data)->posZ = z; - const_cast<CreatureData*>(data)->orientation = o; - } - pCreature->GetMap()->CreatureRelocation(pCreature,x, y, z,o); - pCreature->GetMotionMaster()->Initialize(); - if (pCreature->isAlive()) // dead creature will reset movement generator at respawn - { - pCreature->setDeathState(JUST_DIED); - pCreature->Respawn(); - } - } - - WorldDatabase.PExecute("UPDATE creature SET position_x = '%f', position_y = '%f', position_z = '%f', orientation = '%f' WHERE guid = '%u'", x, y, z, o, lowguid); - PSendSysMessage(LANG_COMMAND_CREATUREMOVED); - return true; -} - -/**HandleNpcSetMoveTypeCommand - * Set the movement type for an NPC.<br/> - * <br/> - * Valid movement types are: - * <ul> - * <li> stay - NPC wont move </li> - * <li> random - NPC will move randomly according to the spawndist </li> - * <li> way - NPC will move with given waypoints set </li> - * </ul> - * additional parameter: NODEL - so no waypoints are deleted, if you - * change the movement type - */ -bool ChatHandler::HandleNpcSetMoveTypeCommand(const char* args) -{ - if (!*args) - return false; - - // 3 arguments: - // GUID (optional - you can also select the creature) - // stay|random|way (determines the kind of movement) - // NODEL (optional - tells the system NOT to delete any waypoints) - // this is very handy if you want to do waypoints, that are - // later switched on/off according to special events (like escort - // quests, etc) - char* guid_str = strtok((char*)args, " "); - char* type_str = strtok((char*)NULL, " "); - char* dontdel_str = strtok((char*)NULL, " "); - - bool doNotDelete = false; - - if (!guid_str) - return false; - - uint32 lowguid = 0; - Creature* pCreature = NULL; - - if (dontdel_str) - { - //sLog.outError("DEBUG: All 3 params are set"); - - // All 3 params are set - // GUID - // type - // doNotDEL - if (stricmp(dontdel_str, "NODEL") == 0) - { - //sLog.outError("DEBUG: doNotDelete = true;"); - doNotDelete = true; - } - } - else - { - // Only 2 params - but maybe NODEL is set - if (type_str) - { - sLog.outError("DEBUG: Only 2 params "); - if (stricmp(type_str, "NODEL") == 0) - { - //sLog.outError("DEBUG: type_str, NODEL "); - doNotDelete = true; - type_str = NULL; - } - } - } - - if (!type_str) // case .setmovetype $move_type (with selected creature) - { - type_str = guid_str; - pCreature = getSelectedCreature(); - if (!pCreature || pCreature->isPet()) - return false; - lowguid = pCreature->GetDBTableGUIDLow(); - } - else // case .setmovetype #creature_guid $move_type (with selected creature) - { - lowguid = atoi((char*)guid_str); - - /* impossible without entry - if (lowguid) - pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_GUID(lowguid,HIGHGUID_UNIT)); - */ - - // attempt check creature existence by DB data - if (!pCreature) - { - CreatureData const* data = sObjectMgr.GetCreatureData(lowguid); - if (!data) - { - PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid); - SetSentErrorMessage(true); - return false; - } - } - else - { - lowguid = pCreature->GetDBTableGUIDLow(); - } - } - - // now lowguid is low guid really existed creature - // and pCreature point (maybe) to this creature or NULL - - MovementGeneratorType move_type; - - std::string type = type_str; - - if (type == "stay") - move_type = IDLE_MOTION_TYPE; - else if (type == "random") - move_type = RANDOM_MOTION_TYPE; - else if (type == "way") - move_type = WAYPOINT_MOTION_TYPE; - else - return false; - - // update movement type - //if (doNotDelete == false) - // WaypointMgr.DeletePath(lowguid); - - if (pCreature) - { - // update movement type - if (doNotDelete == false) - pCreature->LoadPath(0); - - pCreature->SetDefaultMovementType(move_type); - pCreature->GetMotionMaster()->Initialize(); - if (pCreature->isAlive()) // dead creature will reset movement generator at respawn - { - pCreature->setDeathState(JUST_DIED); - pCreature->Respawn(); - } - pCreature->SaveToDB(); - } - if (doNotDelete == false) - { - PSendSysMessage(LANG_MOVE_TYPE_SET,type_str); - } - else - { - PSendSysMessage(LANG_MOVE_TYPE_SET_NODEL,type_str); - } - - return true; -} - -//set model of creature -bool ChatHandler::HandleNpcSetModelCommand(const char* args) -{ - if (!*args) - return false; - - uint32 displayId = (uint32) atoi((char*)args); - - Creature *pCreature = getSelectedCreature(); - - if (!pCreature || pCreature->isPet()) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - pCreature->SetDisplayId(displayId); - pCreature->SetNativeDisplayId(displayId); - - pCreature->SaveToDB(); - - return true; -} -//set faction of creature -bool ChatHandler::HandleNpcFactionIdCommand(const char* args) -{ - if (!*args) - return false; - - uint32 factionId = (uint32) atoi((char*)args); - - if (!sFactionTemplateStore.LookupEntry(factionId)) - { - PSendSysMessage(LANG_WRONG_FACTION, factionId); - SetSentErrorMessage(true); - return false; - } - - Creature* pCreature = getSelectedCreature(); - - if (!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - pCreature->setFaction(factionId); - - // faction is set in creature_template - not inside creature - - // update in memory - if (CreatureInfo const *cinfo = pCreature->GetCreatureInfo()) - { - const_cast<CreatureInfo*>(cinfo)->faction_A = factionId; - const_cast<CreatureInfo*>(cinfo)->faction_H = factionId; - } - - // and DB - WorldDatabase.PExecute("UPDATE creature_template SET faction_A = '%u', faction_H = '%u' WHERE entry = '%u'", factionId, factionId, pCreature->GetEntry()); - - return true; -} -//set spawn dist of creature -bool ChatHandler::HandleNpcSpawnDistCommand(const char* args) -{ - if (!*args) - return false; - - float option = (float)(atof((char*)args)); - if (option < 0.0f) - { - SendSysMessage(LANG_BAD_VALUE); - return false; - } - - MovementGeneratorType mtype = IDLE_MOTION_TYPE; - if (option >0.0f) - mtype = RANDOM_MOTION_TYPE; - - Creature *pCreature = getSelectedCreature(); - uint32 u_guidlow = 0; - - if (pCreature) - u_guidlow = pCreature->GetDBTableGUIDLow(); - else - return false; - - pCreature->SetRespawnRadius((float)option); - pCreature->SetDefaultMovementType(mtype); - pCreature->GetMotionMaster()->Initialize(); - if (pCreature->isAlive()) // dead creature will reset movement generator at respawn - { - pCreature->setDeathState(JUST_DIED); - pCreature->Respawn(); - } - - WorldDatabase.PExecute("UPDATE creature SET spawndist=%f, MovementType=%i WHERE guid=%u",option,mtype,u_guidlow); - PSendSysMessage(LANG_COMMAND_SPAWNDIST,option); - return true; -} -//spawn time handling -bool ChatHandler::HandleNpcSpawnTimeCommand(const char* args) -{ - if (!*args) - return false; - - char* stime = strtok((char*)args, " "); - - if (!stime) - return false; - - int i_stime = atoi((char*)stime); - - if (i_stime < 0) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Creature *pCreature = getSelectedCreature(); - uint32 u_guidlow = 0; - - if (pCreature) - u_guidlow = pCreature->GetDBTableGUIDLow(); - else - return false; - - WorldDatabase.PExecute("UPDATE creature SET spawntimesecs=%i WHERE guid=%u",i_stime,u_guidlow); - pCreature->SetRespawnDelay((uint32)i_stime); - PSendSysMessage(LANG_COMMAND_SPAWNTIME,i_stime); - - return true; -} -//npc follow handling -bool ChatHandler::HandleNpcFollowCommand(const char* /*args*/) -{ - Player *player = m_session->GetPlayer(); - Creature *creature = getSelectedCreature(); - - if (!creature) - { - PSendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - // Follow player - Using pet's default dist and angle - creature->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, creature->GetFollowAngle()); - - PSendSysMessage(LANG_CREATURE_FOLLOW_YOU_NOW, creature->GetName()); - return true; -} -//npc unfollow handling -bool ChatHandler::HandleNpcUnFollowCommand(const char* /*args*/) -{ - Player *player = m_session->GetPlayer(); - Creature *creature = getSelectedCreature(); - - if (!creature) - { - PSendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - if (/*creature->GetMotionMaster()->empty() ||*/ - creature->GetMotionMaster()->GetCurrentMovementGeneratorType () != TARGETED_MOTION_TYPE) - { - PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName()); - SetSentErrorMessage(true); - return false; - } - - TargetedMovementGenerator<Creature> const* mgen - = static_cast<TargetedMovementGenerator<Creature> const*>((creature->GetMotionMaster()->top())); - - if (mgen->GetTarget() != player) - { - PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName()); - SetSentErrorMessage(true); - return false; - } - - // reset movement - creature->GetMotionMaster()->MovementExpired(true); - - PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName()); - return true; -} -//npc tame handling -bool ChatHandler::HandleNpcTameCommand(const char* /*args*/) -{ - Creature *creatureTarget = getSelectedCreature (); - if (!creatureTarget || creatureTarget->isPet ()) - { - PSendSysMessage (LANG_SELECT_CREATURE); - SetSentErrorMessage (true); - return false; - } - - Player *player = m_session->GetPlayer (); - - if (player->GetPetGUID ()) - { - SendSysMessage (LANG_YOU_ALREADY_HAVE_PET); - SetSentErrorMessage (true); - return false; - } - - CreatureInfo const* cInfo = creatureTarget->GetCreatureInfo(); - - if (!cInfo->isTameable (player->CanTameExoticPets())) - { - PSendSysMessage (LANG_CREATURE_NON_TAMEABLE,cInfo->Entry); - SetSentErrorMessage (true); - return false; - } - - // Everything looks OK, create new pet - Pet* pet = player->CreateTamedPetFrom (creatureTarget); - if (!pet) - { - PSendSysMessage (LANG_CREATURE_NON_TAMEABLE,cInfo->Entry); - SetSentErrorMessage (true); - return false; - } - - // place pet before player - float x,y,z; - player->GetClosePoint (x,y,z,creatureTarget->GetObjectSize (),CONTACT_DISTANCE); - pet->Relocate (x,y,z,M_PI-player->GetOrientation ()); - - // set pet to defensive mode by default (some classes can't control controlled pets in fact). - pet->SetReactState(REACT_DEFENSIVE); - - // calculate proper level - uint8 level = (creatureTarget->getLevel() < (player->getLevel() - 5)) ? (player->getLevel() - 5) : creatureTarget->getLevel(); - - // prepare visual effect for levelup - pet->SetUInt32Value(UNIT_FIELD_LEVEL, level - 1); - - // add to world - pet->GetMap()->Add(pet->ToCreature()); - - // visual effect for levelup - pet->SetUInt32Value(UNIT_FIELD_LEVEL, level); - - // caster have pet now - player->SetMinion(pet, true); - - pet->SavePetToDB(PET_SAVE_AS_CURRENT); - player->PetSpellInitialize(); - - return true; -} -//npc phasemask handling -//change phasemask of creature or pet -bool ChatHandler::HandleNpcSetPhaseCommand(const char* args) -{ - if (!*args) - return false; - - uint32 phasemask = (uint32) atoi((char*)args); - if (phasemask == 0) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - Creature* pCreature = getSelectedCreature(); - if (!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - pCreature->SetPhaseMask(phasemask,true); - - if (!pCreature->isPet()) - pCreature->SaveToDB(); - - return true; -} -//npc deathstate handling -bool ChatHandler::HandleNpcSetDeathStateCommand(const char* args) -{ - if (!*args) - return false; - - Creature* pCreature = getSelectedCreature(); - if (!pCreature || pCreature->isPet()) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - if (strncmp(args, "on", 3) == 0) - pCreature->SetDeadByDefault(true); - else if (strncmp(args, "off", 4) == 0) - pCreature->SetDeadByDefault(false); - else - { - SendSysMessage(LANG_USE_BOL); - SetSentErrorMessage(true); - return false; - } - - pCreature->SaveToDB(); - pCreature->Respawn(); - - return true; -} - -//TODO: NpcCommands that need to be fixed : - -bool ChatHandler::HandleNpcNameCommand(const char* /*args*/) -{ - /* Temp. disabled - if (!*args) - return false; - - if (strlen((char*)args)>75) - { - PSendSysMessage(LANG_TOO_LONG_NAME, strlen((char*)args)-75); - return true; - } - - for (uint8 i = 0; i < strlen(args); ++i) - { - if (!isalpha(args[i]) && args[i] != ' ') - { - SendSysMessage(LANG_CHARS_ONLY); - return false; - } - } - - uint64 guid; - guid = m_session->GetPlayer()->GetSelection(); - if (guid == 0) - { - SendSysMessage(LANG_NO_SELECTION); - return true; - } - - Creature* pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid); - - if (!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - return true; - } - - pCreature->SetName(args); - uint32 idname = sObjectMgr.AddCreatureTemplate(pCreature->GetName()); - pCreature->SetUInt32Value(OBJECT_FIELD_ENTRY, idname); - - pCreature->SaveToDB(); - */ - - return true; -} - -bool ChatHandler::HandleNpcSubNameCommand(const char* /*args*/) -{ - /* Temp. disabled - - if (!*args) - args = ""; - - if (strlen((char*)args)>75) - { - - PSendSysMessage(LANG_TOO_LONG_SUBNAME, strlen((char*)args)-75); - return true; - } - - for (uint8 i = 0; i < strlen(args); i++) - { - if (!isalpha(args[i]) && args[i] != ' ') - { - SendSysMessage(LANG_CHARS_ONLY); - return false; - } - } - uint64 guid; - guid = m_session->GetPlayer()->GetSelection(); - if (guid == 0) - { - SendSysMessage(LANG_NO_SELECTION); - return true; - } - - Creature* pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid); - - if (!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - return true; - } - - uint32 idname = sObjectMgr.AddCreatureSubName(pCreature->GetName(),args,pCreature->GetUInt32Value(UNIT_FIELD_DISPLAYID)); - pCreature->SetUInt32Value(OBJECT_FIELD_ENTRY, idname); - - pCreature->SaveToDB(); - */ - return true; -} - -//move item to other slot + //move item to other slot bool ChatHandler::HandleItemMoveCommand(const char* args) { if (!*args) @@ -1931,27 +638,6 @@ bool ChatHandler::HandleDeMorphCommand(const char* /*args*/) return true; } -//morph creature or player -bool ChatHandler::HandleModifyMorphCommand(const char* args) -{ - if (!*args) - return false; - - uint16 display_id = (uint16)atoi((char*)args); - - Unit *target = getSelectedUnit(); - if (!target) - target = m_session->GetPlayer(); - - // check online security - else if (target->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)target, 0)) - return false; - - target->SetDisplayId(display_id); - - return true; -} - //kick player bool ChatHandler::HandleKickPlayerCommand(const char *args) { @@ -2068,28 +754,8 @@ bool ChatHandler::HandleKickPlayerCommand(const char *args) return true; } -//set temporary phase mask for player -bool ChatHandler::HandleModifyPhaseCommand(const char* args) -{ - if (!*args) - return false; - - uint32 phasemask = (uint32)atoi((char*)args); - - Unit *target = getSelectedUnit(); - if (!target) - target = m_session->GetPlayer(); - - // check online security - else if (target->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)target, 0)) - return false; - - target->SetPhaseMask(phasemask,true); - - return true; -} //show info of gameobject -bool ChatHandler::HandleGOInfoCommand(const char* args) +bool ChatHandler::HandleGameObjectInfoCommand(const char* args) { uint32 entry = 0; uint32 type = 0; @@ -3334,18 +2000,6 @@ bool ChatHandler::HandleCharacterReputationCommand(const char* args) return true; } -//change standstate -bool ChatHandler::HandleModifyStandStateCommand(const char* args) -{ - if (!*args) - return false; - - uint32 anim_id = atoi((char*)args); - m_session->GetPlayer()->SetUInt32Value(UNIT_NPC_EMOTESTATE , anim_id); - - return true; -} - bool ChatHandler::HandleHonorAddCommand(const char* args) { if (!*args) @@ -3634,137 +2288,6 @@ bool ChatHandler::HandleCombatStopCommand(const char* args) return true; } -void ChatHandler::HandleLearnSkillRecipesHelper(Player* player,uint32 skill_id) -{ - uint32 classmask = player->getClassMask(); - - for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) - { - SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j); - if (!skillLine) - continue; - - // wrong skill - if (skillLine->skillId != skill_id) - continue; - - // not high rank - if (skillLine->forward_spellid) - continue; - - // skip racial skills - if (skillLine->racemask != 0) - continue; - - // skip wrong class skills - if (skillLine->classmask && (skillLine->classmask & classmask) == 0) - continue; - - SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId); - if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,player,false)) - continue; - - player->learnSpell(skillLine->spellId, false); - } -} - -bool ChatHandler::HandleLearnAllCraftsCommand(const char* /*args*/) -{ - - for (uint32 i = 0; i < sSkillLineStore.GetNumRows(); ++i) - { - SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(i); - if (!skillInfo) - continue; - - if ((skillInfo->categoryId == SKILL_CATEGORY_PROFESSION || skillInfo->categoryId == SKILL_CATEGORY_SECONDARY) && - skillInfo->canLink) // only prof. with recipes have - { - HandleLearnSkillRecipesHelper(m_session->GetPlayer(),skillInfo->id); - } - } - - SendSysMessage(LANG_COMMAND_LEARN_ALL_CRAFT); - return true; -} - -bool ChatHandler::HandleLearnAllRecipesCommand(const char* args) -{ - // Learns all recipes of specified profession and sets skill to max - // Example: .learn all_recipes enchanting - - Player* target = getSelectedPlayer(); - if (!target) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - return false; - } - - if (!*args) - return false; - - std::wstring wnamepart; - - if (!Utf8toWStr(args,wnamepart)) - return false; - - // converting string that we try to find to lower case - wstrToLower(wnamepart); - - std::string name; - - SkillLineEntry const *targetSkillInfo = NULL; - for (uint32 i = 1; i < sSkillLineStore.GetNumRows(); ++i) - { - SkillLineEntry const *skillInfo = sSkillLineStore.LookupEntry(i); - if (!skillInfo) - continue; - - if ((skillInfo->categoryId != SKILL_CATEGORY_PROFESSION && - skillInfo->categoryId != SKILL_CATEGORY_SECONDARY) || - !skillInfo->canLink) // only prof with recipes have set - continue; - - int loc = GetSessionDbcLocale(); - name = skillInfo->name[loc]; - if (name.empty()) - continue; - - if (!Utf8FitTo(name, wnamepart)) - { - loc = 0; - for (; loc < TOTAL_LOCALES; ++loc) - { - if (loc == GetSessionDbcLocale()) - continue; - - name = skillInfo->name[loc]; - if (name.empty()) - continue; - - if (Utf8FitTo(name, wnamepart)) - break; - } - } - - if (loc < TOTAL_LOCALES) - { - targetSkillInfo = skillInfo; - break; - } - } - - if (!targetSkillInfo) - return false; - - HandleLearnSkillRecipesHelper(target,targetSkillInfo->id); - - uint16 maxLevel = target->GetPureMaxSkillValue(targetSkillInfo->id); - target->SetSkill(targetSkillInfo->id, target->GetSkillStep(targetSkillInfo->id), maxLevel, maxLevel); - PSendSysMessage(LANG_COMMAND_LEARN_ALL_RECIPES, name.c_str()); - return true; -} - bool ChatHandler::HandleLookupPlayerIpCommand(const char* args) { @@ -4135,26 +2658,6 @@ bool ChatHandler::HandleActivateObjectCommand(const char *args) return true; } -// add creature, temp only -bool ChatHandler::HandleTempAddSpwCommand(const char* args) -{ - if (!*args) - return false; - char* charID = strtok((char*)args, " "); - if (!charID) - return false; - - Player *chr = m_session->GetPlayer(); - - uint32 id = atoi(charID); - if (!id) - return false; - - chr->SummonCreature(id, *chr, TEMPSUMMON_CORPSE_DESPAWN, 120); - - return true; -} - // add go, temp only bool ChatHandler::HandleTempGameObjectCommand(const char* args) { @@ -4187,85 +2690,6 @@ bool ChatHandler::HandleTempGameObjectCommand(const char* args) return true; } -bool ChatHandler::HandleNpcAddFormationCommand(const char* args) -{ - if (!*args) - return false; - - uint32 leaderGUID = (uint32) atoi((char*)args); - Creature *pCreature = getSelectedCreature(); - - if (!pCreature || !pCreature->GetDBTableGUIDLow()) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - uint32 lowguid = pCreature->GetDBTableGUIDLow(); - if (pCreature->GetFormation()) - { - PSendSysMessage("Selected creature is already member of group %u", pCreature->GetFormation()->GetId()); - return false; - } - - if (!lowguid) - return false; - - Player *chr = m_session->GetPlayer(); - FormationInfo *group_member; - - group_member = new FormationInfo; - group_member->follow_angle = (pCreature->GetAngle(chr) - chr->GetOrientation()) * 180 / M_PI; - group_member->follow_dist = sqrtf(pow(chr->GetPositionX() - pCreature->GetPositionX(),int(2))+pow(chr->GetPositionY()-pCreature->GetPositionY(),int(2))); - group_member->leaderGUID = leaderGUID; - group_member->groupAI = 0; - - CreatureGroupMap[lowguid] = group_member; - pCreature->SearchFormation(); - - WorldDatabase.PExecute("INSERT INTO creature_formations (leaderGUID, memberGUID, dist, angle, groupAI) VALUES ('%u','%u','%f', '%f', '%u')", - leaderGUID, lowguid, group_member->follow_dist, group_member->follow_angle, group_member->groupAI); - - PSendSysMessage("Creature %u added to formation with leader %u", lowguid, leaderGUID); - - return true; - } - -bool ChatHandler::HandleNpcSetLinkCommand(const char* args) -{ - if (!*args) - return false; - - uint32 linkguid = (uint32) atoi((char*)args); - - Creature* pCreature = getSelectedCreature(); - - if (!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - if (!pCreature->GetDBTableGUIDLow()) - { - PSendSysMessage("Selected creature %u isn't in creature table", pCreature->GetGUIDLow()); - SetSentErrorMessage(true); - return false; - } - - if (!sObjectMgr.SetCreatureLinkedRespawn(pCreature->GetDBTableGUIDLow(), linkguid)) - { - PSendSysMessage("Selected creature can't link with guid '%u'", linkguid); - SetSentErrorMessage(true); - return false; - } - - PSendSysMessage("LinkGUID '%u' added to creature with DBTableGUID: '%u'", linkguid, pCreature->GetDBTableGUIDLow()); - return true; -} - bool ChatHandler::HandleLookupTitleCommand(const char* args) { if (!*args) diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp index ab9e56d81f1..fcb29b623fe 100755 --- a/src/server/game/Chat/Commands/Level3.cpp +++ b/src/server/game/Chat/Commands/Level3.cpp @@ -1186,169 +1186,6 @@ bool ChatHandler::HandleReloadSmartScripts(const char* /*args*/) return true; } -bool ChatHandler::HandleAccountSetGmLevelCommand(const char *args) -{ - if (!*args) - return false; - - std::string targetAccountName; - uint32 targetAccountId = 0; - uint32 targetSecurity = 0; - uint32 gm = 0; - char* arg1 = strtok((char*)args, " "); - char* arg2 = strtok(NULL, " "); - char* arg3 = strtok(NULL, " "); - bool isAccountNameGiven = true; - - if (arg1 && !arg3) - { - if (!getSelectedPlayer()) - return false; - isAccountNameGiven = false; - } - - // Check for second parameter - if (!isAccountNameGiven && !arg2) - return false; - - // Check for account - if (isAccountNameGiven) - { - targetAccountName = arg1; - if (!AccountMgr::normalizeString(targetAccountName)) - { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,targetAccountName.c_str()); - SetSentErrorMessage(true); - return false; - } - } - - // Check for invalid specified GM level. - gm = (isAccountNameGiven) ? atoi(arg2) : atoi(arg1); - if (gm > SEC_CONSOLE) - { - SendSysMessage(LANG_BAD_VALUE); - SetSentErrorMessage(true); - return false; - } - - // m_session == NULL only for console - targetAccountId = (isAccountNameGiven) ? sAccountMgr.GetId(targetAccountName) : getSelectedPlayer()->GetSession()->GetAccountId(); - int32 gmRealmID = (isAccountNameGiven) ? atoi(arg3) : atoi(arg2); - uint32 plSecurity; - if (m_session) - plSecurity = sAccountMgr.GetSecurity(m_session->GetAccountId(), gmRealmID); - else - plSecurity = SEC_CONSOLE; - - // can set security level only for target with less security and to less security that we have - // This is also reject self apply in fact - targetSecurity = sAccountMgr.GetSecurity(targetAccountId, gmRealmID); - if (targetSecurity >= plSecurity || gm >= plSecurity) - { - SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); - SetSentErrorMessage(true); - return false; - } - - // Check and abort if the target gm has a higher rank on one of the realms and the new realm is -1 - if (gmRealmID == -1) - { - QueryResult result = LoginDatabase.PQuery("SELECT * FROM account_access WHERE id = '%u' AND gmlevel > '%d'", targetAccountId, gm); - if (result) - { - SendSysMessage(LANG_YOURS_SECURITY_IS_LOW); - SetSentErrorMessage(true); - return false; - } - } - - // Check if provided realmID has a negative value other than -1 - if (gmRealmID < -1) - { - SendSysMessage(LANG_INVALID_REALMID); - SetSentErrorMessage(true); - return false; - } - - // If gmRealmID is -1, delete all values for the account id, else, insert values for the specific realmID - if (gmRealmID == -1) - LoginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u'", targetAccountId); - else - LoginDatabase.PExecute("DELETE FROM account_access WHERE id = '%u' AND (RealmID = '%d' OR RealmID = '-1')", targetAccountId, realmID); - - if (gm != 0) - LoginDatabase.PExecute("INSERT INTO account_access VALUES ('%u','%d','%d')", targetAccountId, gm, realmID); - PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm); - return true; -} - -/// Set password for account -bool ChatHandler::HandleAccountSetPasswordCommand(const char *args) -{ - if (!*args) - return false; - - ///- Get the command line arguments - char *szAccount = strtok ((char*)args," "); - char *szPassword1 = strtok (NULL," "); - char *szPassword2 = strtok (NULL," "); - - if (!szAccount||!szPassword1 || !szPassword2) - return false; - - std::string account_name = szAccount; - if (!AccountMgr::normalizeString(account_name)) - { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - SetSentErrorMessage(true); - return false; - } - - uint32 targetAccountId = sAccountMgr.GetId(account_name); - if (!targetAccountId) - { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - SetSentErrorMessage(true); - return false; - } - - /// can set password only for target with less security - /// This is also reject self apply in fact - if (HasLowerSecurityAccount (NULL,targetAccountId,true)) - return false; - - if (strcmp(szPassword1,szPassword2)) - { - SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH); - SetSentErrorMessage (true); - return false; - } - - AccountOpResult result = sAccountMgr.ChangePassword(targetAccountId, szPassword1); - - switch (result) - { - case AOR_OK: - SendSysMessage(LANG_COMMAND_PASSWORD); - break; - case AOR_NAME_NOT_EXIST: - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - SetSentErrorMessage(true); - return false; - case AOR_PASS_TOO_LONG: - SendSysMessage(LANG_PASSWORD_TOO_LONG); - SetSentErrorMessage(true); - return false; - default: - SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD); - SetSentErrorMessage(true); - return false; - } - - return true; -} - bool ChatHandler::HandleMaxSkillCommand(const char* /*args*/) { Player* SelectedPlayer = getSelectedPlayer(); @@ -1424,34 +1261,6 @@ bool ChatHandler::HandleSetSkillCommand(const char *args) return true; } -bool ChatHandler::HandleAchievementAddCommand(const char *args) -{ - if (!*args) - return false; - - uint32 achievementId = atoi((char*)args); - if (!achievementId) - { - if (char* cId = extractKeyFromLink((char*)args, "Hachievement")) - achievementId = atoi(cId); - if (!achievementId) - return false; - } - - Player* target = getSelectedPlayer(); - if (!target) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - if (AchievementEntry const* pAE = GetAchievementStore()->LookupEntry(achievementId)) - target->CompletedAchievement(pAE, true); - - return true; -} - bool ChatHandler::HandleUnLearnCommand(const char *args) { if (!*args) @@ -1524,916 +1333,6 @@ bool ChatHandler::HandleCooldownCommand(const char *args) return true; } -bool ChatHandler::HandleLearnAllCommand(const char* /*args*/) -{ - static const char *allSpellList[] = - { - "3365", - "6233", - "6247", - "6246", - "6477", - "6478", - "22810", - "8386", - "21651", - "21652", - "522", - "7266", - "8597", - "2479", - "22027", - "6603", - "5019", - "133", - "168", - "227", - "5009", - "9078", - "668", - "203", - "20599", - "20600", - "81", - "20597", - "20598", - "20864", - "1459", - "5504", - "587", - "5143", - "118", - "5505", - "597", - "604", - "1449", - "1460", - "2855", - "1008", - "475", - "5506", - "1463", - "12824", - "8437", - "990", - "5145", - "8450", - "1461", - "759", - "8494", - "8455", - "8438", - "6127", - "8416", - "6129", - "8451", - "8495", - "8439", - "3552", - "8417", - "10138", - "12825", - "10169", - "10156", - "10144", - "10191", - "10201", - "10211", - "10053", - "10173", - "10139", - "10145", - "10192", - "10170", - "10202", - "10054", - "10174", - "10193", - "12826", - "2136", - "143", - "145", - "2137", - "2120", - "3140", - "543", - "2138", - "2948", - "8400", - "2121", - "8444", - "8412", - "8457", - "8401", - "8422", - "8445", - "8402", - "8413", - "8458", - "8423", - "8446", - "10148", - "10197", - "10205", - "10149", - "10215", - "10223", - "10206", - "10199", - "10150", - "10216", - "10207", - "10225", - "10151", - "116", - "205", - "7300", - "122", - "837", - "10", - "7301", - "7322", - "6143", - "120", - "865", - "8406", - "6141", - "7302", - "8461", - "8407", - "8492", - "8427", - "8408", - "6131", - "7320", - "10159", - "8462", - "10185", - "10179", - "10160", - "10180", - "10219", - "10186", - "10177", - "10230", - "10181", - "10161", - "10187", - "10220", - "2018", - "2663", - "12260", - "2660", - "3115", - "3326", - "2665", - "3116", - "2738", - "3293", - "2661", - "3319", - "2662", - "9983", - "8880", - "2737", - "2739", - "7408", - "3320", - "2666", - "3323", - "3324", - "3294", - "22723", - "23219", - "23220", - "23221", - "23228", - "23338", - "10788", - "10790", - "5611", - "5016", - "5609", - "2060", - "10963", - "10964", - "10965", - "22593", - "22594", - "596", - "996", - "499", - "768", - "17002", - "1448", - "1082", - "16979", - "1079", - "5215", - "20484", - "5221", - "15590", - "17007", - "6795", - "6807", - "5487", - "1446", - "1066", - "5421", - "3139", - "779", - "6811", - "6808", - "1445", - "5216", - "1737", - "5222", - "5217", - "1432", - "6812", - "9492", - "5210", - "3030", - "1441", - "783", - "6801", - "20739", - "8944", - "9491", - "22569", - "5226", - "6786", - "1433", - "8973", - "1828", - "9495", - "9006", - "6794", - "8993", - "5203", - "16914", - "6784", - "9635", - "22830", - "20722", - "9748", - "6790", - "9753", - "9493", - "9752", - "9831", - "9825", - "9822", - "5204", - "5401", - "22831", - "6793", - "9845", - "17401", - "9882", - "9868", - "20749", - "9893", - "9899", - "9895", - "9832", - "9902", - "9909", - "22832", - "9828", - "9851", - "9883", - "9869", - "17406", - "17402", - "9914", - "20750", - "9897", - "9848", - "3127", - "107", - "204", - "9116", - "2457", - "78", - "18848", - "331", - "403", - "2098", - "1752", - "11278", - "11288", - "11284", - "6461", - "2344", - "2345", - "6463", - "2346", - "2352", - "775", - "1434", - "1612", - "71", - "2468", - "2458", - "2467", - "7164", - "7178", - "7367", - "7376", - "7381", - "21156", - "5209", - "3029", - "5201", - "9849", - "9850", - "20719", - "22568", - "22827", - "22828", - "22829", - "6809", - "8972", - "9005", - "9823", - "9827", - "6783", - "9913", - "6785", - "6787", - "9866", - "9867", - "9894", - "9896", - "6800", - "8992", - "9829", - "9830", - "780", - "769", - "6749", - "6750", - "9755", - "9754", - "9908", - "20745", - "20742", - "20747", - "20748", - "9746", - "9745", - "9880", - "9881", - "5391", - "842", - "3025", - "3031", - "3287", - "3329", - "1945", - "3559", - "4933", - "4934", - "4935", - "4936", - "5142", - "5390", - "5392", - "5404", - "5420", - "6405", - "7293", - "7965", - "8041", - "8153", - "9033", - "9034", - //"9036", problems with ghost state - "16421", - "21653", - "22660", - "5225", - "9846", - "2426", - "5916", - "6634", - //"6718", phasing stealth, annoying for learn all case. - "6719", - "8822", - "9591", - "9590", - "10032", - "17746", - "17747", - "8203", - "11392", - "12495", - "16380", - "23452", - "4079", - "4996", - "4997", - "4998", - "4999", - "5000", - "6348", - "6349", - "6481", - "6482", - "6483", - "6484", - "11362", - "11410", - "11409", - "12510", - "12509", - "12885", - "13142", - "21463", - "23460", - "11421", - "11416", - "11418", - "1851", - "10059", - "11423", - "11417", - "11422", - "11419", - "11424", - "11420", - "27", - "31", - "33", - "34", - "35", - "15125", - "21127", - "22950", - "1180", - "201", - "12593", - "16770", - "6057", - "12051", - "18468", - "12606", - "12605", - "18466", - "12502", - "12043", - "15060", - "12042", - "12341", - "12848", - "12344", - "12353", - "18460", - "11366", - "12350", - "12352", - "13043", - "11368", - "11113", - "12400", - "11129", - "16766", - "12573", - "12580", - "12472", - "12953", - "12488", - "11189", - "12985", - "12519", - "16758", - "11958", - "12490", - "11426", - "3565", - "3562", - "18960", - "3567", - "3561", - "3566", - "3563", - "1953", - "2139", - "12505", - "13018", - "12522", - "12523", - "5146", - "5144", - "5148", - "8419", - "8418", - "10213", - "10212", - "10157", - "12524", - "13019", - "12525", - "13020", - "12526", - "13021", - "18809", - "13031", - "13032", - "13033", - "4036", - "3920", - "3919", - "3918", - "7430", - "3922", - "3923", - "7411", - "7418", - "7421", - "13262", - "7412", - "7415", - "7413", - "7416", - "13920", - "13921", - "7745", - "7779", - "7428", - "7457", - "7857", - "7748", - "7426", - "13421", - "7454", - "13378", - "7788", - "14807", - "14293", - "7795", - "6296", - "20608", - "755", - "444", - "427", - "428", - "442", - "447", - "3578", - "3581", - "19027", - "3580", - "665", - "3579", - "3577", - "6755", - "3576", - "2575", - "2577", - "2578", - "2579", - "2580", - "2656", - "2657", - "2576", - "3564", - "10248", - "8388", - "2659", - "14891", - "3308", - "3307", - "10097", - "2658", - "3569", - "16153", - "3304", - "10098", - "4037", - "3929", - "3931", - "3926", - "3924", - "3930", - "3977", - "3925", - "136", - "228", - "5487", - "43", - "202", - "0" - }; - - int loop = 0; - while (strcmp(allSpellList[loop], "0")) - { - uint32 spell = atol((char*)allSpellList[loop++]); - - if (m_session->GetPlayer()->HasSpell(spell)) - continue; - - SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); - if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) - { - PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); - continue; - } - - m_session->GetPlayer()->learnSpell(spell, false); - } - - SendSysMessage(LANG_COMMAND_LEARN_MANY_SPELLS); - - return true; -} - -bool ChatHandler::HandleLearnAllGMCommand(const char* /*args*/) -{ - static const char *gmSpellList[] = - { - "24347", // Become A Fish, No Breath Bar - "35132", // Visual Boom - "38488", // Attack 4000-8000 AOE - "38795", // Attack 2000 AOE + Slow Down 90% - "15712", // Attack 200 - "1852", // GM Spell Silence - "31899", // Kill - "31924", // Kill - "29878", // Kill My Self - "26644", // More Kill - - "28550", //Invisible 24 - "23452", //Invisible + Target - "0" - }; - - uint16 gmSpellIter = 0; - while (strcmp(gmSpellList[gmSpellIter], "0")) - { - uint32 spell = atol((char*)gmSpellList[gmSpellIter++]); - - SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); - if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) - { - PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); - continue; - } - - m_session->GetPlayer()->learnSpell(spell, false); - } - - SendSysMessage(LANG_LEARNING_GM_SKILLS); - return true; -} - -bool ChatHandler::HandleLearnAllMyClassCommand(const char* /*args*/) -{ - HandleLearnAllMySpellsCommand(""); - HandleLearnAllMyTalentsCommand(""); - return true; -} - -bool ChatHandler::HandleLearnAllMySpellsCommand(const char* /*args*/) -{ - ChrClassesEntry const* clsEntry = sChrClassesStore.LookupEntry(m_session->GetPlayer()->getClass()); - if (!clsEntry) - return true; - uint32 family = clsEntry->spellfamily; - - for (uint32 i = 0; i < sSpellStore.GetNumRows(); ++i) - { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(i); - if (!spellInfo) - continue; - - // skip server-side/triggered spells - if (spellInfo->spellLevel == 0) - continue; - - // skip wrong class/race skills - if (!m_session->GetPlayer()->IsSpellFitByClassAndRace(spellInfo->Id)) - continue; - - // skip other spell families - if (spellInfo->SpellFamilyName != family) - continue; - - // skip spells with first rank learned as talent (and all talents then also) - uint32 first_rank = sSpellMgr.GetFirstSpellInChain(spellInfo->Id); - if (GetTalentSpellCost(first_rank) > 0) - continue; - - // skip broken spells - if (!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) - continue; - - m_session->GetPlayer()->learnSpell(i, false); - } - - SendSysMessage(LANG_COMMAND_LEARN_CLASS_SPELLS); - return true; -} - -bool ChatHandler::HandleLearnAllMyTalentsCommand(const char* /*args*/) -{ - Player* player = m_session->GetPlayer(); - uint32 classMask = player->getClassMask(); - - for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i) - { - TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); - if (!talentInfo) - continue; - - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); - if (!talentTabInfo) - continue; - - if ((classMask & talentTabInfo->ClassMask) == 0) - continue; - - // search highest talent rank - uint32 spellId = 0; - for (int8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank) - { - if (talentInfo->RankID[rank] != 0) - { - spellId = talentInfo->RankID[rank]; - break; - } - } - - if (!spellId) // ??? none spells in talent - continue; - - SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); - if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) - continue; - - // learn highest rank of talent and learn all non-talent spell ranks (recursive by tree) - player->learnSpellHighRank(spellId); - player->AddTalent(spellId, player->GetActiveSpec(), true); - } - - player->SetFreeTalentPoints(0); - - SendSysMessage(LANG_COMMAND_LEARN_CLASS_TALENTS); - return true; -} - -bool ChatHandler::HandleLearnAllMyPetTalentsCommand(const char* /*args*/) -{ - Player* player = m_session->GetPlayer(); - - Pet* pet = player->GetPet(); - if (!pet) - { - SendSysMessage(LANG_NO_PET_FOUND); - SetSentErrorMessage(true); - return false; - } - - CreatureInfo const *ci = pet->GetCreatureInfo(); - if (!ci) - { - SendSysMessage(LANG_WRONG_PET_TYPE); - SetSentErrorMessage(true); - return false; - } - - CreatureFamilyEntry const *pet_family = sCreatureFamilyStore.LookupEntry(ci->family); - if (!pet_family) - { - SendSysMessage(LANG_WRONG_PET_TYPE); - SetSentErrorMessage(true); - return false; - } - - if (pet_family->petTalentType < 0) // not hunter pet - { - SendSysMessage(LANG_WRONG_PET_TYPE); - SetSentErrorMessage(true); - return false; - } - - for (uint32 i = 0; i < sTalentStore.GetNumRows(); ++i) - { - TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); - if (!talentInfo) - continue; - - TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); - if (!talentTabInfo) - continue; - - // prevent learn talent for different family (cheating) - if (((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask) == 0) - continue; - - // search highest talent rank - uint32 spellid = 0; - - for (int8 rank = MAX_TALENT_RANK-1; rank >= 0; --rank) - { - if (talentInfo->RankID[rank] != 0) - { - spellid = talentInfo->RankID[rank]; - break; - } - } - - if (!spellid) // ??? none spells in talent - continue; - - SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid); - if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) - continue; - - // learn highest rank of talent and learn all non-talent spell ranks (recursive by tree) - pet->learnSpellHighRank(spellid); - } - - pet->SetFreeTalentPoints(0); - - SendSysMessage(LANG_COMMAND_LEARN_PET_TALENTS); - return true; -} - -bool ChatHandler::HandleLearnAllLangCommand(const char* /*args*/) -{ - // skipping UNIVERSAL language (0) - for (uint8 i = 1; i < LANGUAGES_COUNT; ++i) - m_session->GetPlayer()->learnSpell(lang_description[i].spell_id, false); - - SendSysMessage(LANG_COMMAND_LEARN_ALL_LANG); - return true; -} - -bool ChatHandler::HandleLearnAllDefaultCommand(const char *args) -{ - Player* target; - if (!extractPlayerTarget((char*)args,&target)) - return false; - - target->learnDefaultSpells(); - target->learnQuestRewardedSpells(); - - PSendSysMessage(LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST,GetNameLink(target).c_str()); - return true; -} - -bool ChatHandler::HandleLearnCommand(const char *args) -{ - Player* targetPlayer = getSelectedPlayer(); - - if (!targetPlayer) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form - uint32 spell = extractSpellIdFromLink((char*)args); - if (!spell || !sSpellStore.LookupEntry(spell)) - return false; - - char const* allStr = strtok(NULL," "); - bool allRanks = allStr ? (strncmp(allStr, "all", strlen(allStr)) == 0) : false; - - SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); - if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) - { - PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); - SetSentErrorMessage(true); - return false; - } - - if (!allRanks && targetPlayer->HasSpell(spell)) - { - if (targetPlayer == m_session->GetPlayer()) - SendSysMessage(LANG_YOU_KNOWN_SPELL); - else - PSendSysMessage(LANG_TARGET_KNOWN_SPELL,GetNameLink(targetPlayer).c_str()); - SetSentErrorMessage(true); - return false; - } - - if (allRanks) - targetPlayer->learnSpellHighRank(spell); - else - targetPlayer->learnSpell(spell, false); - - uint32 first_spell = sSpellMgr.GetFirstSpellInChain(spell); - if (GetTalentSpellCost(first_spell)) - targetPlayer->SendTalentsInfoData(false); - - return true; -} - bool ChatHandler::HandleAddItemCommand(const char *args) { if (!*args) @@ -4214,28 +3113,6 @@ bool ChatHandler::HandleDamageCommand(const char * args) return true; } -bool ChatHandler::HandleModifyArenaCommand(const char * args) -{ - if (!*args) - return false; - - Player *target = getSelectedPlayer(); - if (!target) - { - SendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - int32 amount = (uint32)atoi(args); - - target->ModifyArenaPoints(amount); - - PSendSysMessage(LANG_COMMAND_MODIFY_ARENA, GetNameLink(target).c_str(), target->GetArenaPoints()); - - return true; -} - bool ChatHandler::HandleReviveCommand(const char *args) { Player* target; @@ -4421,189 +3298,6 @@ bool ChatHandler::HandleNearGraveCommand(const char *args) return true; } -//-----------------------Npc Commands----------------------- -bool ChatHandler::HandleNpcAllowMovementCommand(const char* /*args*/) -{ - if (sWorld.getAllowMovement()) - { - sWorld.SetAllowMovement(false); - SendSysMessage(LANG_CREATURE_MOVE_DISABLED); - } - else - { - sWorld.SetAllowMovement(true); - SendSysMessage(LANG_CREATURE_MOVE_ENABLED); - } - return true; -} - -bool ChatHandler::HandleNpcChangeEntryCommand(const char *args) -{ - if (!*args) - return false; - - uint32 newEntryNum = atoi(args); - if (!newEntryNum) - return false; - - Unit* unit = getSelectedUnit(); - if (!unit || unit->GetTypeId() != TYPEID_UNIT) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - Creature* creature = unit->ToCreature(); - if (creature->UpdateEntry(newEntryNum)) - SendSysMessage(LANG_DONE); - else - SendSysMessage(LANG_ERROR); - return true; -} - -bool ChatHandler::HandleNpcInfoCommand(const char* /*args*/) -{ - Creature* target = getSelectedCreature(); - - if (!target) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - uint32 faction = target->getFaction(); - uint32 npcflags = target->GetUInt32Value(UNIT_NPC_FLAGS); - uint32 displayid = target->GetDisplayId(); - uint32 nativeid = target->GetNativeDisplayId(); - uint32 Entry = target->GetEntry(); - CreatureInfo const* cInfo = target->GetCreatureInfo(); - - int64 curRespawnDelay = target->GetRespawnTimeEx()-time(NULL); - if (curRespawnDelay < 0) - curRespawnDelay = 0; - std::string curRespawnDelayStr = secsToTimeString(uint64(curRespawnDelay),true); - std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true); - - PSendSysMessage(LANG_NPCINFO_CHAR, target->GetDBTableGUIDLow(), faction, npcflags, Entry, displayid, nativeid); - PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel()); - PSendSysMessage(LANG_NPCINFO_HEALTH,target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth()); - PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUInt32Value(UNIT_FIELD_FLAGS), target->GetUInt32Value(UNIT_DYNAMIC_FLAGS), target->getFaction()); - PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str()); - PSendSysMessage(LANG_NPCINFO_LOOT, cInfo->lootid,cInfo->pickpocketLootId,cInfo->SkinLootId); - PSendSysMessage(LANG_NPCINFO_DUNGEON_ID, target->GetInstanceId()); - PSendSysMessage(LANG_NPCINFO_PHASEMASK, target->GetPhaseMask()); - PSendSysMessage(LANG_NPCINFO_ARMOR, target->GetArmor()); - PSendSysMessage(LANG_NPCINFO_POSITION,float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ())); - if (const CreatureData* const linked = target->GetLinkedRespawnCreatureData()) - if (CreatureInfo const *master = GetCreatureInfo(linked->id)) - PSendSysMessage(LANG_NPCINFO_LINKGUID, sObjectMgr.GetLinkedRespawnGuid(target->GetDBTableGUIDLow()), linked->id, master->Name); - - if ((npcflags & UNIT_NPC_FLAG_VENDOR)) - { - SendSysMessage(LANG_NPCINFO_VENDOR); - } - if ((npcflags & UNIT_NPC_FLAG_TRAINER)) - { - SendSysMessage(LANG_NPCINFO_TRAINER); - } - - return true; -} - -//play npc emote -bool ChatHandler::HandleNpcPlayEmoteCommand(const char *args) -{ - uint32 emote = atoi((char*)args); - - Creature* target = getSelectedCreature(); - if (!target) - { - SendSysMessage(LANG_SELECT_CREATURE); - SetSentErrorMessage(true); - return false; - } - - if (target->GetTransport()) - if (target->GetGUIDTransport()) - WorldDatabase.PQuery("UPDATE creature_transport SET emote=%u WHERE transport_entry=%u AND guid=%u", emote, target->GetTransport()->GetEntry(), target->GetGUIDTransport()); - - target->SetUInt32Value(UNIT_NPC_EMOTESTATE,emote); - - return true; -} - -//TODO: NpcCommands that needs to be fixed : - -bool ChatHandler::HandleNpcAddWeaponCommand(const char* /*args*/) -{ - /*if (!*args) - return false; - - uint64 guid = m_session->GetPlayer()->GetSelection(); - if (guid == 0) - { - SendSysMessage(LANG_NO_SELECTION); - return true; - } - - Creature *pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid); - - if (!pCreature) - { - SendSysMessage(LANG_SELECT_CREATURE); - return true; - } - - char* pSlotID = strtok((char*)args, " "); - if (!pSlotID) - return false; - - char* pItemID = strtok(NULL, " "); - if (!pItemID) - return false; - - uint32 ItemID = atoi(pItemID); - uint32 SlotID = atoi(pSlotID); - - ItemPrototype* tmpItem = sObjectMgr.GetItemPrototype(ItemID); - - bool added = false; - if (tmpItem) - { - switch(SlotID) - { - case 1: - pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, ItemID); - added = true; - break; - case 2: - pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_01, ItemID); - added = true; - break; - case 3: - pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_02, ItemID); - added = true; - break; - default: - PSendSysMessage(LANG_ITEM_SLOT_NOT_EXIST,SlotID); - added = false; - break; - } - - if (added) - PSendSysMessage(LANG_ITEM_ADDED_TO_SLOT,ItemID,tmpItem->Name1,SlotID); - } - else - { - PSendSysMessage(LANG_ITEM_NOT_FOUND,ItemID); - return true; - } - */ - return true; -} -//---------------------------------------------------------- - bool ChatHandler::HandleExploreCheatCommand(const char *args) { if (!*args) @@ -4883,36 +3577,49 @@ bool ChatHandler::HandleChangeWeather(const char *args) return true; } -bool ChatHandler::HandleDebugSet32Bit(const char *args) +bool ChatHandler::HandleTeleCommand(const char* args) { if (!*args) return false; - WorldObject* target = getSelectedObject(); - if (!target) + Player* me = GetSession()->GetPlayer(); + + // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r + GameTele const* tele = extractGameTeleFromLink((char*)args); + + if (!tele) { - SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); + SendSysMessage(LANG_COMMAND_TELE_NOTFOUND); SetSentErrorMessage(true); return false; } - char* px = strtok((char*)args, " "); - char* py = strtok(NULL, " "); - - if (!px || !py) + if (me->isInCombat()) + { + SendSysMessage(LANG_YOU_IN_COMBAT); + SetSentErrorMessage(true); return false; + } - uint32 Opcode = (uint32)atoi(px); - uint32 Value = (uint32)atoi(py); - if (Value > 32) //uint32 = 32 bits + MapEntry const * map = sMapStore.LookupEntry(tele->mapId); + if (!map || map->IsBattlegroundOrArena()) + { + SendSysMessage(LANG_CANNOT_TELE_TO_BG); + SetSentErrorMessage(true); return false; + } - sLog.outDebug(GetTrinityString(LANG_SET_32BIT), Opcode, Value); - - uint32 iValue = Value ? 1 << (Value - 1) : 0; - target->SetUInt32Value(Opcode , iValue); + // stop flight if need + if (me->isInFlight()) + { + me->GetMotionMaster()->MovementExpired(); + me->CleanupAfterTaxiFlight(); + } + // save only in non-flight case + else + me->SaveRecallPosition(); - PSendSysMessage(LANG_SET_32BIT_FIELD, Opcode, iValue); + me->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation); return true; } @@ -6290,32 +4997,6 @@ bool ChatHandler::HandleRespawnCommand(const char* /*args*/) return true; } -bool ChatHandler::HandleGMFlyCommand(const char *args) -{ - if (!*args) - return false; - - Player *target = getSelectedPlayer(); - if (!target) - target = m_session->GetPlayer(); - - WorldPacket data(12); - if (strncmp(args, "on", 3) == 0) - data.SetOpcode(SMSG_MOVE_SET_CAN_FLY); - else if (strncmp(args, "off", 4) == 0) - data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY); - else - { - SendSysMessage(LANG_USE_BOL); - return false; - } - data.append(target->GetPackGUID()); - data << uint32(0); // unknown - target->SendMessageToSet(&data, true); - PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, GetNameLink(target).c_str(), args); - return true; -} - bool ChatHandler::HandlePDumpLoadCommand(const char *args) { if (!*args) @@ -6981,33 +5662,6 @@ bool ChatHandler::HandleInstanceSaveDataCommand(const char * /*args*/) return true; } -/// Display the list of GMs -bool ChatHandler::HandleGMListFullCommand(const char* /*args*/) -{ - ///- Get the accounts with GM Level >0 - QueryResult result = LoginDatabase.Query("SELECT a.username,aa.gmlevel FROM account a, account_access aa WHERE a.id=aa.id AND aa.gmlevel > 0"); - if (result) - { - SendSysMessage(LANG_GMLIST); - SendSysMessage(" ======================== "); - SendSysMessage(LANG_GMLIST_HEADER); - SendSysMessage(" ======================== "); - - ///- Circle through them. Display username and GM level - do - { - Field *fields = result->Fetch(); - PSendSysMessage("|%15s|%6s|", fields[0].GetCString(),fields[1].GetCString()); - } - while (result->NextRow()); - - PSendSysMessage(" ======================== "); - } - else - PSendSysMessage(LANG_GMLIST_EMPTY); - return true; -} - /// Define the 'Message of the day' for the realm bool ChatHandler::HandleServerSetMotdCommand(const char *args) { @@ -7039,66 +5693,6 @@ bool ChatHandler::HandleServerSetClosedCommand(const char *args) return false; } -/// Set/Unset the expansion level for an account -bool ChatHandler::HandleAccountSetAddonCommand(const char *args) -{ - ///- Get the command line arguments - char *szAcc = strtok((char*)args," "); - char *szExp = strtok(NULL," "); - - if (!szAcc) - return false; - - std::string account_name; - uint32 account_id; - - if (!szExp) - { - Player* player = getSelectedPlayer(); - if (!player) - return false; - - account_id = player->GetSession()->GetAccountId(); - sAccountMgr.GetName(account_id,account_name); - szExp = szAcc; - } - else - { - ///- Convert Account name to Upper Format - account_name = szAcc; - if (!AccountMgr::normalizeString(account_name)) - { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - SetSentErrorMessage(true); - return false; - } - - account_id = sAccountMgr.GetId(account_name); - if (!account_id) - { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - SetSentErrorMessage(true); - return false; - } - - } - - // Let set addon state only for lesser (strong) security level - // or to self account - if (m_session && m_session->GetAccountId () != account_id && - HasLowerSecurityAccount (NULL,account_id,true)) - return false; - - int expansion = atoi(szExp); //get int anyway (0 if error) - if (expansion < 0 || uint8(expansion) > sWorld.getIntConfig(CONFIG_EXPANSION)) - return false; - - // No SQL injection - LoginDatabase.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'",expansion,account_id); - PSendSysMessage(LANG_ACCOUNT_SETADDON,account_name.c_str(),account_id,expansion); - return true; -} - //Send items by mail bool ChatHandler::HandleSendItemsCommand(const char *args) { @@ -7297,67 +5891,6 @@ bool ChatHandler::HandleFlushArenaPointsCommand(const char * /*args*/) return true; } -bool ChatHandler::HandleModifyGenderCommand(const char *args) -{ - if (!*args) - return false; - - Player *player = getSelectedPlayer(); - - if (!player) - { - PSendSysMessage(LANG_PLAYER_NOT_FOUND); - SetSentErrorMessage(true); - return false; - } - - PlayerInfo const* info = sObjectMgr.GetPlayerInfo(player->getRace(), player->getClass()); - if (!info) - return false; - - char const* gender_str = (char*)args; - int gender_len = strlen(gender_str); - - Gender gender; - - if (!strncmp(gender_str, "male", gender_len)) // MALE - { - if (player->getGender() == GENDER_MALE) - return true; - - gender = GENDER_MALE; - } - else if (!strncmp(gender_str, "female", gender_len)) // FEMALE - { - if (player->getGender() == GENDER_FEMALE) - return true; - - gender = GENDER_FEMALE; - } - else - { - SendSysMessage(LANG_MUST_MALE_OR_FEMALE); - SetSentErrorMessage(true); - return false; - } - - // Set gender - player->SetByteValue(UNIT_FIELD_BYTES_0, 2, gender); - player->SetByteValue(PLAYER_BYTES_3, 0, gender); - - // Change display ID - player->InitDisplayIds(); - - char const* gender_full = gender ? "female" : "male"; - - PSendSysMessage(LANG_YOU_CHANGE_GENDER, GetNameLink(player).c_str(), gender_full); - - if (needReportToTarget(player)) - ChatHandler(player).PSendSysMessage(LANG_YOUR_GENDER_CHANGED, gender_full, GetNameLink().c_str()); - - return true; -} - bool ChatHandler::HandleChannelSetPublic(const char *args) { if (!*args) diff --git a/src/server/game/Chat/Commands/TicketCommands.cpp b/src/server/game/Chat/Commands/TicketCommands.cpp index fcee0a210ea..81b4a475ab4 100755 --- a/src/server/game/Chat/Commands/TicketCommands.cpp +++ b/src/server/game/Chat/Commands/TicketCommands.cpp @@ -439,48 +439,6 @@ bool ChatHandler::HandleToggleGMTicketSystem(const char* /* args */) return true; } -bool ChatHandler::HandleGoTicketCommand(const char * args) -{ - if (!*args) - return false; - - char *cstrticket_id = strtok((char*)args, " "); - - if (!cstrticket_id) - return false; - - uint64 ticket_id = atoi(cstrticket_id); - if (!ticket_id) - return false; - - GM_Ticket *ticket = sTicketMgr.GetGMTicket(ticket_id); - if (!ticket) - { - SendSysMessage(LANG_COMMAND_TICKETNOTEXIST); - return true; - } - - float x, y, z; - int mapid; - - x = ticket->pos_x; - y = ticket->pos_y; - z = ticket->pos_z; - mapid = ticket->map; - - Player* _player = m_session->GetPlayer(); - if (_player->isInFlight()) - { - _player->GetMotionMaster()->MovementExpired(); - _player->CleanupAfterTaxiFlight(); - } - else - _player->SaveRecallPosition(); - - _player->TeleportTo(mapid, x, y, z, 1, 0); - return true; -} - bool ChatHandler::HandleGMTicketEscalateCommand(const char *args) { if (!*args) diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp index f3f062ac713..d904e171290 100755 --- a/src/server/game/Scripting/ScriptLoader.cpp +++ b/src/server/game/Scripting/ScriptLoader.cpp @@ -44,7 +44,6 @@ void AddSC_example_spell_scripts(); void AddSC_SmartSCripts(); -/* //Commands void AddSC_account_commandscript(); void AddSC_achievement_commandscript(); @@ -54,7 +53,6 @@ void AddSC_go_commandscript(); void AddSC_learn_commandscript(); void AddSC_modify_commandscript(); void AddSC_debug_commandscript(); -*/ #ifdef SCRIPTS //world @@ -581,9 +579,7 @@ void AddScripts() AddExampleScripts(); AddSpellScripts(); AddSC_SmartSCripts(); -/* AddCommandScripts(); -*/ #ifdef SCRIPTS AddWorldScripts(); AddEasternKingdomsScripts(); @@ -623,7 +619,6 @@ void AddSpellScripts() AddSC_example_spell_scripts(); } -/* void AddCommandScripts() { AddSC_account_commandscript(); @@ -635,7 +630,6 @@ void AddCommandScripts() AddSC_modify_commandscript(); AddSC_debug_commandscript(); } -*/ void AddWorldScripts() { diff --git a/src/server/game/Scripting/ScriptLoader.h b/src/server/game/Scripting/ScriptLoader.h index 8d7e7c244c3..409b3db4b7f 100644 --- a/src/server/game/Scripting/ScriptLoader.h +++ b/src/server/game/Scripting/ScriptLoader.h @@ -8,9 +8,7 @@ void AddScripts(); void AddExampleScripts(); void AddSpellScripts(); -/* void AddCommandScripts(); -*/ void AddWorldScripts(); void AddEasternKingdomsScripts(); void AddKalimdorScripts(); diff --git a/src/server/scripts/CMakeLists.txt b/src/server/scripts/CMakeLists.txt index db62d24761e..42f10bc6645 100644 --- a/src/server/scripts/CMakeLists.txt +++ b/src/server/scripts/CMakeLists.txt @@ -25,8 +25,7 @@ endif() message(STATUS "SCRIPT PREPARATIONS") include(Spells/CMakeLists.txt) -# temporarily disabled -# include(Commands/CMakeLists.txt) +include(Commands/CMakeLists.txt) include(Examples/CMakeLists.txt) diff --git a/src/server/scripts/Commands/cs_gm.cpp b/src/server/scripts/Commands/cs_gm.cpp index 41fa7a3b4d7..c9a36ca2f5b 100644 --- a/src/server/scripts/Commands/cs_gm.cpp +++ b/src/server/scripts/Commands/cs_gm.cpp @@ -43,7 +43,7 @@ class gm_commandscript : public CommandScript }; static ChatCommand commandTable[] = { - { "gm", SEC_MODERATOR, true, NULL, "", gmCommandTable }, + { "gm", SEC_MODERATOR, false, NULL, "", gmCommandTable }, { NULL, 0, false, NULL, "", NULL } }; return commandTable; @@ -111,6 +111,7 @@ class gm_commandscript : public CommandScript static bool HandleGMListIngameCommand(ChatHandler* handler, const char* /*args*/) { bool first = true; + bool footer = false; ACE_GUARD_RETURN(ACE_Thread_Mutex, guard, *HashMapHolder<Player>::GetLock(), true); HashMapHolder<Player>::MapType &m = sObjectAccessor.GetPlayers(); @@ -122,17 +123,24 @@ class gm_commandscript : public CommandScript { if (first) { - handler->SendSysMessage(LANG_GMS_ON_SRV); first = false; + footer = true; + handler->SendSysMessage(LANG_GMS_ON_SRV); + handler->SendSysMessage("========================"); } - - handler->SendSysMessage(handler->GetNameLink(itr->second).c_str()); + const char* name = itr->second->GetName(); + uint8 security = itr_sec; + uint8 max = ((16 - strlen(name)) / 2); + if (handler->GetSession()) + handler->PSendSysMessage("|%s GMLevel %u", name, security); + else + handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max, " ", security); } } - + if (footer) + handler->SendSysMessage("========================"); if (first) handler->SendSysMessage(LANG_GMS_NOT_LOGGED); - return true; } @@ -144,19 +152,22 @@ class gm_commandscript : public CommandScript if (result) { handler->SendSysMessage(LANG_GMLIST); - handler->SendSysMessage(" ======================== "); - handler->SendSysMessage(LANG_GMLIST_HEADER); - handler->SendSysMessage(" ======================== "); - + handler->SendSysMessage("========================"); ///- Cycle through them. Display username and GM level do { Field *fields = result->Fetch(); - handler->PSendSysMessage("|%15s|%6s|", fields[0].GetCString(),fields[1].GetCString()); + const char* name = fields[0].GetCString(); + uint8 security = fields[1].GetUInt8(); + uint8 max = ((16 - strlen(name)) / 2); + if (handler->GetSession()) + handler->PSendSysMessage("|%s GMLevel %u", name, security); + else + handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max, " ", security); } while (result->NextRow()); - handler->PSendSysMessage(" ======================== "); + handler->SendSysMessage("========================"); } else handler->PSendSysMessage(LANG_GMLIST_EMPTY); diff --git a/src/server/worldserver/CommandLine/CliRunnable.cpp b/src/server/worldserver/CommandLine/CliRunnable.cpp index c6bc310de57..e3a7fef571a 100755 --- a/src/server/worldserver/CommandLine/CliRunnable.cpp +++ b/src/server/worldserver/CommandLine/CliRunnable.cpp @@ -117,63 +117,6 @@ void commandFinished(void*, bool /*success*/) printf("TC> "); fflush(stdout); } -/// Delete a user account and all associated characters in this realm -/// \todo This function has to be enhanced to respect the login/realm split (delete char, delete account chars in realm, delete account chars in realm then delete account -bool ChatHandler::HandleAccountDeleteCommand(const char* args) -{ - if (!*args) - return false; - - ///- Get the account name from the command line - char *account_name_str=strtok ((char*)args," "); - if (!account_name_str) - return false; - - std::string account_name = account_name_str; - if (!AccountMgr::normalizeString(account_name)) - { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - SetSentErrorMessage(true); - return false; - } - - uint32 account_id = sAccountMgr.GetId(account_name); - if (!account_id) - { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - SetSentErrorMessage(true); - return false; - } - - /// Commands not recommended call from chat, but support anyway - /// can delete only for account with less security - /// This is also reject self apply in fact - if (HasLowerSecurityAccount (NULL,account_id,true)) - return false; - - AccountOpResult result = sAccountMgr.DeleteAccount(account_id); - switch(result) - { - case AOR_OK: - PSendSysMessage(LANG_ACCOUNT_DELETED,account_name.c_str()); - break; - case AOR_NAME_NOT_EXIST: - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); - SetSentErrorMessage(true); - return false; - case AOR_DB_INTERNAL_ERROR: - PSendSysMessage(LANG_ACCOUNT_NOT_DELETED_SQL_ERROR,account_name.c_str()); - SetSentErrorMessage(true); - return false; - default: - PSendSysMessage(LANG_ACCOUNT_NOT_DELETED,account_name.c_str()); - SetSentErrorMessage(true); - return false; - } - - return true; -} - /** * Collects all GUIDs (and related info) from deleted characters which are still in the database. * @@ -540,95 +483,6 @@ bool ChatHandler::HandleServerExitCommand(const char* /*args*/) return true; } -/// Display info on users currently in the realm -bool ChatHandler::HandleAccountOnlineListCommand(const char* /*args*/) -{ - ///- Get the list of accounts ID logged to the realm - QueryResult resultDB = CharacterDatabase.Query("SELECT name,account,map,zone FROM characters WHERE online > 0"); - if (!resultDB) - { - SendSysMessage(LANG_ACCOUNT_LIST_EMPTY); - return true; - } - - ///- Display the list of account/characters online - SendSysMessage(LANG_ACCOUNT_LIST_BAR_HEADER); - SendSysMessage(LANG_ACCOUNT_LIST_HEADER); - SendSysMessage(LANG_ACCOUNT_LIST_BAR); - - ///- Circle through accounts - do - { - Field *fieldsDB = resultDB->Fetch(); - std::string name = fieldsDB[0].GetString(); - uint32 account = fieldsDB[1].GetUInt32(); - - ///- Get the username, last IP and GM level of each account - // No SQL injection. account is uint32. - QueryResult resultLogin = - LoginDatabase.PQuery("SELECT a.username, a.last_ip, aa.gmlevel, a.expansion " - "FROM account a " - "LEFT JOIN account_access aa " - "ON (a.id = aa.id) " - "WHERE a.id = '%u'", account); - if (resultLogin) - { - Field *fieldsLogin = resultLogin->Fetch(); - PSendSysMessage(LANG_ACCOUNT_LIST_LINE, - fieldsLogin[0].GetCString(),name.c_str(),fieldsLogin[1].GetCString(),fieldsDB[2].GetInt32(),fieldsDB[3].GetInt32(),fieldsLogin[3].GetUInt32(),fieldsLogin[2].GetUInt32()); - } - else - PSendSysMessage(LANG_ACCOUNT_LIST_ERROR,name.c_str()); - - }while (resultDB->NextRow()); - - SendSysMessage(LANG_ACCOUNT_LIST_BAR); - return true; -} - -/// Create an account -bool ChatHandler::HandleAccountCreateCommand(const char* args) -{ - if (!*args) - return false; - - ///- %Parse the command line arguments - char *szAcc = strtok((char*)args, " "); - char *szPassword = strtok(NULL, " "); - if (!szAcc || !szPassword) - return false; - - // normalized in sAccountMgr.CreateAccount - std::string account_name = szAcc; - std::string password = szPassword; - - AccountOpResult result = sAccountMgr.CreateAccount(account_name, password); - switch(result) - { - case AOR_OK: - PSendSysMessage(LANG_ACCOUNT_CREATED,account_name.c_str()); - break; - case AOR_NAME_TOO_LONG: - SendSysMessage(LANG_ACCOUNT_TOO_LONG); - SetSentErrorMessage(true); - return false; - case AOR_NAME_ALREDY_EXIST: - SendSysMessage(LANG_ACCOUNT_ALREADY_EXIST); - SetSentErrorMessage(true); - return false; - case AOR_DB_INTERNAL_ERROR: - PSendSysMessage(LANG_ACCOUNT_NOT_CREATED_SQL_ERROR,account_name.c_str()); - SetSentErrorMessage(true); - return false; - default: - PSendSysMessage(LANG_ACCOUNT_NOT_CREATED,account_name.c_str()); - SetSentErrorMessage(true); - return false; - } - - return true; -} - /// Set the level of logging bool ChatHandler::HandleServerSetLogFileLevelCommand(const char *args) { |