From 49fd11ab5aebcbce86ca2ee48711287cf020d798 Mon Sep 17 00:00:00 2001 From: Nefarion Date: Fri, 8 Mar 2013 21:41:30 +0100 Subject: First step of comment style refactoring to doxygen-style. --- src/server/scripts/Commands/cs_account.cpp | 2 +- src/server/scripts/Commands/cs_character.cpp | 4 ++-- src/server/scripts/Commands/cs_gobject.cpp | 2 +- src/server/scripts/Commands/cs_misc.cpp | 2 +- src/server/scripts/Commands/cs_npc.cpp | 6 +++--- src/server/scripts/Commands/cs_wp.cpp | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/server/scripts/Commands') diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index 4dc44bbfc58..3953beab3da 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -140,7 +140,7 @@ public: } /// 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 then delete account) + /// @todo This function has to be enhanced to respect the login/realm split (delete char, delete account chars in realm then delete account) static bool HandleAccountDeleteCommand(ChatHandler* handler, char const* args) { if (!*args) diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp index 5ec40bcd0fc..c29b62975ab 100644 --- a/src/server/scripts/Commands/cs_character.cpp +++ b/src/server/scripts/Commands/cs_character.cpp @@ -443,7 +443,7 @@ public: stmt->setUInt16(0, uint16(AT_LOGIN_CHANGE_RACE)); if (target) { - // TODO : add text into database + /// @todo add text into database handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target).c_str()); target->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE); stmt->setUInt32(1, target->GetGUIDLow()); @@ -451,7 +451,7 @@ public: else { std::string oldNameLink = handler->playerLink(targetName); - // TODO : add text into database + /// @todo add text into database handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, oldNameLink.c_str(), GUID_LOPART(targetGuid)); stmt->setUInt32(1, GUID_LOPART(targetGuid)); } diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index 4093861ae9a..f99e51fb260 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -174,7 +174,7 @@ public: return false; } - // TODO: is it really necessary to add both the real and DB table guid here ? + /// @todo is it really necessary to add both the real and DB table guid here ? sObjectMgr->AddGameobjectToGrid(guidLow, sObjectMgr->GetGOData(guidLow)); handler->PSendSysMessage(LANG_GAMEOBJECT_ADD, objectId, objectInfo->name.c_str(), guidLow, x, y, z); diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 4cdc1e0d9ce..20c50949dcc 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -2211,7 +2211,7 @@ public: // from console show not existed sender MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM); - //- TODO: Fix poor design + /// @todo Fix poor design SQLTransaction trans = CharacterDatabase.BeginTransaction(); MailDraft(subject, text) .SendMailTo(trans, MailReceiver(target, GUID_LOPART(targetGuid)), sender); diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 8dc466296fd..0d898ed45c2 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -82,7 +82,7 @@ public: { "item", SEC_GAMEMASTER, false, &HandleNpcAddVendorItemCommand, "", NULL }, { "move", SEC_GAMEMASTER, false, &HandleNpcAddMoveCommand, "", NULL }, { "temp", SEC_GAMEMASTER, false, &HandleNpcAddTempSpawnCommand, "", NULL }, - //{ TODO: fix or remove this command + //{@todo fix or remove this command { "weapon", SEC_ADMINISTRATOR, false, &HandleNpcAddWeaponCommand, "", NULL }, //} { "", SEC_GAMEMASTER, false, &HandleNpcAddCommand, "", NULL }, @@ -114,7 +114,7 @@ public: { "spawndist", SEC_GAMEMASTER, false, &HandleNpcSetSpawnDistCommand, "", NULL }, { "spawntime", SEC_GAMEMASTER, false, &HandleNpcSetSpawnTimeCommand, "", NULL }, { "data", SEC_ADMINISTRATOR, false, &HandleNpcSetDataCommand, "", NULL }, - //{ TODO: fix or remove these commands + //{ @todo fix or remove these commands { "name", SEC_GAMEMASTER, false, &HandleNpcSetNameCommand, "", NULL }, { "subname", SEC_GAMEMASTER, false, &HandleNpcSetSubNameCommand, "", NULL }, //} @@ -1421,7 +1421,7 @@ public: return true; } - //TODO: NpcCommands that need to be fixed : + /// @todo NpcCommands that need to be fixed : static bool HandleNpcAddWeaponCommand(ChatHandler* /*handler*/, char const* /*args*/) { /*if (!*args) diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index 87b12021212..bb48e94f744 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -700,7 +700,7 @@ public: wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); - //TODO: Should we first use "Create" then use "LoadFromDB"? + /// @todo Should we first use "Create" then use "LoadFromDB"? if (!wpCreature2->LoadCreatureFromDB(wpCreature2->GetDBTableGUIDLow(), map)) { handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT); -- cgit v1.2.3 From 8e8617cfe672d3eda45dfba16eaf532fd551897f Mon Sep 17 00:00:00 2001 From: SgT-Fatality Date: Sat, 9 Mar 2013 15:58:25 +0000 Subject: Scripts/Commands: Fix .mod rep faction not updating client side reputation Closes #7939 Closes #9354 --- src/server/game/Entities/Player/Player.cpp | 4 ++-- src/server/scripts/Commands/cs_modify.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src/server/scripts/Commands') diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index e9f1af5595a..c0d3acd8a8d 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -3134,7 +3134,7 @@ void Player::InitTalentForLevel() // Remove all talent points if (m_usedTalentCount > 0) // Free any used talents { - resetTalents(true); + resetTalents(true); /// @todo: Has to (collectively) be renamed to ResetTalents SetFreeTalentPoints(0); } } @@ -18905,7 +18905,7 @@ void Player::SaveToDB(bool create /*=false*/) if (create) { //! Insert query - //! TO DO: Filter out more redundant fields that can take their default value at player create + /// @todo: Filter out more redundant fields that can take their default value at player create stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER); stmt->setUInt32(index++, GetGUIDLow()); stmt->setUInt32(index++, GetSession()->GetAccountId()); diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp index eaed64db579..7219615736e 100644 --- a/src/server/scripts/Commands/cs_modify.cpp +++ b/src/server/scripts/Commands/cs_modify.cpp @@ -1249,6 +1249,7 @@ public: } target->GetReputationMgr().SetOneFactionReputation(factionEntry, amount, false); + target->GetReputationMgr().SendState(target->GetReputationMgr().GetState(factionEntry)); handler->PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->name[handler->GetSessionDbcLocale()], factionId, handler->GetNameLink(target).c_str(), target->GetReputationMgr().GetReputation(factionEntry)); return true; -- cgit v1.2.3 From 1b45bcd7b9060a512053b631a32867bdf5ed5034 Mon Sep 17 00:00:00 2001 From: Nefarion Date: Sat, 9 Mar 2013 00:55:59 +0100 Subject: Add the following commands: .deserter instance add $time (Adds the instance deserter debuff with $time duration to your target) .deserter bg add $time (Adds the BG deserter debuff with $time duration to your target) .deserter instance remove (Removes the instance deserter debuff) .deserter instance remove (Removes the bg deserter debuff) --- .../world/2013_03_08_01_world_command_deserter.sql | 11 ++ src/server/game/Scripting/ScriptLoader.cpp | 2 + src/server/scripts/Commands/CMakeLists.txt | 1 + src/server/scripts/Commands/cs_deserter.cpp | 197 +++++++++++++++++++++ 4 files changed, 211 insertions(+) create mode 100644 sql/updates/world/2013_03_08_01_world_command_deserter.sql create mode 100644 src/server/scripts/Commands/cs_deserter.cpp (limited to 'src/server/scripts/Commands') diff --git a/sql/updates/world/2013_03_08_01_world_command_deserter.sql b/sql/updates/world/2013_03_08_01_world_command_deserter.sql new file mode 100644 index 00000000000..62b60e973c7 --- /dev/null +++ b/sql/updates/world/2013_03_08_01_world_command_deserter.sql @@ -0,0 +1,11 @@ +DELETE FROM `command` WHERE `name` IN +("deserter instance add", +"deserter instance remove", +"deserter bg add", +"deserter bg remove"); + +INSERT INTO `command` (`name`, `security`, `help`) VALUES +("deserter instance add", 3, "Syntax: .deserter instance add $time \n\n Adds the instance deserter debuff to your target with $time duration."), +("deserter instance remove", 3, "Syntax: .deserter instance remove \n\n Removes the instance deserter debuff from your target."), +("deserter bg add", 3, "Syntax: .deserter bg add $time \n\n Adds the bg deserter debuff to your target with $time duration."), +("deserter bg remove", 3, "Syntax: .deserter bg remove \n\n Removes the bg deserter debuff from your target."); diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp index afc153a5000..845c3fa704d 100644 --- a/src/server/game/Scripting/ScriptLoader.cpp +++ b/src/server/game/Scripting/ScriptLoader.cpp @@ -52,6 +52,7 @@ void AddSC_cast_commandscript(); void AddSC_character_commandscript(); void AddSC_cheat_commandscript(); void AddSC_debug_commandscript(); +void AddSC_deserter_commandscript(); void AddSC_disable_commandscript(); void AddSC_event_commandscript(); void AddSC_gm_commandscript(); @@ -683,6 +684,7 @@ void AddCommandScripts() AddSC_character_commandscript(); AddSC_cheat_commandscript(); AddSC_debug_commandscript(); + AddSC_deserter_commandscript(); AddSC_disable_commandscript(); AddSC_event_commandscript(); AddSC_gm_commandscript(); diff --git a/src/server/scripts/Commands/CMakeLists.txt b/src/server/scripts/Commands/CMakeLists.txt index 83e97b2c80d..15e16c2caf1 100644 --- a/src/server/scripts/Commands/CMakeLists.txt +++ b/src/server/scripts/Commands/CMakeLists.txt @@ -18,6 +18,7 @@ set(scripts_STAT_SRCS Commands/cs_character.cpp Commands/cs_cheat.cpp Commands/cs_debug.cpp + Commands/cs_deserter.cpp Commands/cs_disable.cpp Commands/cs_event.cpp Commands/cs_gm.cpp diff --git a/src/server/scripts/Commands/cs_deserter.cpp b/src/server/scripts/Commands/cs_deserter.cpp new file mode 100644 index 00000000000..758ed5eab81 --- /dev/null +++ b/src/server/scripts/Commands/cs_deserter.cpp @@ -0,0 +1,197 @@ +/* + * Copyright (C) 2008-2013 TrinityCore + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +/** +* @file cs_deserter.cpp +* @brief .deserter related commands +* +* This file contains the CommandScripts for all deserter sub-commands +*/ + +#include "Chat.h" +#include "Player.h" +#include "Language.h" + +enum Spells +{ + LFG_SPELL_DUNGEON_DESERTER = 71041, + BG_SPELL_DESERTER = 26013 +}; + +class deserter_commandscript : public CommandScript +{ +public: + deserter_commandscript() : CommandScript("deserter_commandscript") { } + + /** + * @brief Returns the command structure for the system. + */ + + ChatCommand* GetCommands() const + { + static ChatCommand deserterInstanceCommandTable[] = + { + { "add", SEC_ADMINISTRATOR, false, &HandleDeserterInstanceAdd, "", NULL }, + { "remove", SEC_ADMINISTRATOR, false, &HandleDeserterInstanceRemove, "", NULL }, + { NULL, SEC_PLAYER, false, NULL, "", NULL } + }; + static ChatCommand deserterBGCommandTable[] = + { + { "add", SEC_ADMINISTRATOR, false, &HandleDeserterBGAdd, "", NULL }, + { "remove", SEC_ADMINISTRATOR, false, &HandleDeserterBGRemove, "", NULL }, + { NULL, SEC_PLAYER, false, NULL, "", NULL } + }; + + static ChatCommand deserterCommandTable[] = + { + { "instance", SEC_ADMINISTRATOR, false, NULL, "", deserterInstanceCommandTable }, + { "bg", SEC_ADMINISTRATOR, false, NULL, "", deserterBGCommandTable }, + { NULL, SEC_PLAYER, false, NULL, "", NULL } + }; + static ChatCommand commandTable[] = + { + { "deserter", SEC_ADMINISTRATOR, false, NULL, "", deserterCommandTable }, + { NULL, SEC_PLAYER, false, NULL, "", NULL } + }; + return commandTable; + } + + /** + * @brief Applies the Deserter Debuff to a player + * + * This function applies a Deserter Debuff of the given type (Instance or BG) to the + * selected player, with the provided duration in seconds. + * + * @param handler The ChatHandler, passed by the system. + * @param args The provided duration in seconds. + * @param isInstance provided by the relaying functions, so we don't have + * to write that much code :) + * + * @return true if everything was correct, false if an error occured. + * + * Example Usage: + * @code + * .deserter instance add 3600 (one hour) + * -or- + * .deserter bg add 3600 (one hour) + * @endcode + */ + static bool HandleDeserterAdd(ChatHandler* handler, char const* args, bool isInstance) + { + if (!*args) + return false; + + Player* player = handler->getSelectedPlayer(); + if (!player) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } + char* timeStr = strtok((char*)args, " "); + if (!timeStr) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; + } + uint32 time = atoi(timeStr); + + if (!time) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; + } + + Aura* aura = player->AddAura(isInstance ? LFG_SPELL_DUNGEON_DESERTER : BG_SPELL_DESERTER, player); + + if (!aura) + { + handler->SendSysMessage(LANG_BAD_VALUE); + handler->SetSentErrorMessage(true); + return false; + } + aura->SetDuration(time * IN_MILLISECONDS); + + return true; + } + + /** + * @brief Removes the Deserter Debuff from a player + * + * This function removes a Deserter Debuff of the given type (Instance or BG) from the + * selected player. + * + * @param handler The ChatHandler, passed by the system. + * @param args Should be nothing. + * @param isInstance provided by the relaying functions, so we don't have + * to write that much code :) + * + * @return true if everything was correct, false if an error occured. + * + * Example Usage: + * @code + * .deserter instance remove + * -or- + * .deserter bg remove + * @endcode + */ + static bool HandleDeserterRemove(ChatHandler* handler, char const* args, bool isInstance) + { + Player* player = handler->getSelectedPlayer(); + if (!player) + { + handler->SendSysMessage(LANG_NO_CHAR_SELECTED); + handler->SetSentErrorMessage(true); + return false; + } + + player->RemoveAura(isInstance ? LFG_SPELL_DUNGEON_DESERTER : BG_SPELL_DESERTER); + + return true; + } + + /// @sa HandleDeserterAdd() + static bool HandleDeserterInstanceAdd(ChatHandler* handler, char const* args) + { + return HandleDeserterAdd(handler, args, true); + } + + /// @sa HandleDeserterAdd() + static bool HandleDeserterBGAdd(ChatHandler* handler, char const* args) + { + return HandleDeserterAdd(handler, args, false); + } + + /// @sa HandleDeserterRemove() + static bool HandleDeserterInstanceRemove(ChatHandler* handler, char const* args) + { + return HandleDeserterRemove(handler, args, true); + } + + /// @sa HandleDeserterRemove() + static bool HandleDeserterBGRemove(ChatHandler* handler, char const* args) + { + return HandleDeserterRemove(handler, args, false); + } +}; + +void AddSC_deserter_commandscript() +{ + new deserter_commandscript(); +} -- cgit v1.2.3 From bf17b7b3c036b7575b7245fe792d2ca4c89089f2 Mon Sep 17 00:00:00 2001 From: Nay Date: Sat, 9 Mar 2013 17:55:59 +0000 Subject: Scripts/Commads: Fix non PCH build --- src/server/scripts/Commands/cs_deserter.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/server/scripts/Commands') diff --git a/src/server/scripts/Commands/cs_deserter.cpp b/src/server/scripts/Commands/cs_deserter.cpp index 758ed5eab81..1ac95f86d22 100644 --- a/src/server/scripts/Commands/cs_deserter.cpp +++ b/src/server/scripts/Commands/cs_deserter.cpp @@ -25,6 +25,7 @@ #include "Chat.h" #include "Player.h" #include "Language.h" +#include "ScriptMgr.h" enum Spells { -- cgit v1.2.3 From ab088cf5ba18e7d7076df5052fbbe4e262966d2e Mon Sep 17 00:00:00 2001 From: Nay Date: Sat, 9 Mar 2013 18:48:17 +0000 Subject: SQL: Rename a SQL from PR --- sql/updates/world/2013_03_08_01_world_command_deserter.sql | 11 ----------- sql/updates/world/2013_03_09_02_world_command_deserter.sql | 11 +++++++++++ src/server/scripts/Commands/cs_deserter.cpp | 1 + 3 files changed, 12 insertions(+), 11 deletions(-) delete mode 100644 sql/updates/world/2013_03_08_01_world_command_deserter.sql create mode 100644 sql/updates/world/2013_03_09_02_world_command_deserter.sql (limited to 'src/server/scripts/Commands') diff --git a/sql/updates/world/2013_03_08_01_world_command_deserter.sql b/sql/updates/world/2013_03_08_01_world_command_deserter.sql deleted file mode 100644 index 62b60e973c7..00000000000 --- a/sql/updates/world/2013_03_08_01_world_command_deserter.sql +++ /dev/null @@ -1,11 +0,0 @@ -DELETE FROM `command` WHERE `name` IN -("deserter instance add", -"deserter instance remove", -"deserter bg add", -"deserter bg remove"); - -INSERT INTO `command` (`name`, `security`, `help`) VALUES -("deserter instance add", 3, "Syntax: .deserter instance add $time \n\n Adds the instance deserter debuff to your target with $time duration."), -("deserter instance remove", 3, "Syntax: .deserter instance remove \n\n Removes the instance deserter debuff from your target."), -("deserter bg add", 3, "Syntax: .deserter bg add $time \n\n Adds the bg deserter debuff to your target with $time duration."), -("deserter bg remove", 3, "Syntax: .deserter bg remove \n\n Removes the bg deserter debuff from your target."); diff --git a/sql/updates/world/2013_03_09_02_world_command_deserter.sql b/sql/updates/world/2013_03_09_02_world_command_deserter.sql new file mode 100644 index 00000000000..62b60e973c7 --- /dev/null +++ b/sql/updates/world/2013_03_09_02_world_command_deserter.sql @@ -0,0 +1,11 @@ +DELETE FROM `command` WHERE `name` IN +("deserter instance add", +"deserter instance remove", +"deserter bg add", +"deserter bg remove"); + +INSERT INTO `command` (`name`, `security`, `help`) VALUES +("deserter instance add", 3, "Syntax: .deserter instance add $time \n\n Adds the instance deserter debuff to your target with $time duration."), +("deserter instance remove", 3, "Syntax: .deserter instance remove \n\n Removes the instance deserter debuff from your target."), +("deserter bg add", 3, "Syntax: .deserter bg add $time \n\n Adds the bg deserter debuff to your target with $time duration."), +("deserter bg remove", 3, "Syntax: .deserter bg remove \n\n Removes the bg deserter debuff from your target."); diff --git a/src/server/scripts/Commands/cs_deserter.cpp b/src/server/scripts/Commands/cs_deserter.cpp index 1ac95f86d22..f229828b1ff 100644 --- a/src/server/scripts/Commands/cs_deserter.cpp +++ b/src/server/scripts/Commands/cs_deserter.cpp @@ -26,6 +26,7 @@ #include "Player.h" #include "Language.h" #include "ScriptMgr.h" +#include "SpellAuras.h" enum Spells { -- cgit v1.2.3 From 20eeeaf59764604d629d91e2044972bf00f9c052 Mon Sep 17 00:00:00 2001 From: Vincent_Michael Date: Sat, 9 Mar 2013 20:15:11 +0100 Subject: Core: Fix warnings --- src/server/game/Handlers/SpellHandler.cpp | 2 +- src/server/scripts/Commands/cs_deserter.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/server/scripts/Commands') diff --git a/src/server/game/Handlers/SpellHandler.cpp b/src/server/game/Handlers/SpellHandler.cpp index d1c65951a5d..532d4677545 100644 --- a/src/server/game/Handlers/SpellHandler.cpp +++ b/src/server/game/Handlers/SpellHandler.cpp @@ -275,7 +275,7 @@ void WorldSession::HandleGameObjectUseOpcode(WorldPacket& recvData) { // ignore for remote control state if (_player->m_mover != _player) - if (!_player->IsOnVehicle(_player->m_mover) || !_player->IsMounted() && !obj->GetGOInfo()->IsUsableMounted()) + if (!_player->IsOnVehicle(_player->m_mover) || !(_player->IsMounted() && obj->GetGOInfo()->IsUsableMounted())) return; obj->Use(_player); diff --git a/src/server/scripts/Commands/cs_deserter.cpp b/src/server/scripts/Commands/cs_deserter.cpp index f229828b1ff..3850456fcb3 100644 --- a/src/server/scripts/Commands/cs_deserter.cpp +++ b/src/server/scripts/Commands/cs_deserter.cpp @@ -153,7 +153,7 @@ public: * .deserter bg remove * @endcode */ - static bool HandleDeserterRemove(ChatHandler* handler, char const* args, bool isInstance) + static bool HandleDeserterRemove(ChatHandler* handler, char const* /*args*/, bool isInstance) { Player* player = handler->getSelectedPlayer(); if (!player) -- cgit v1.2.3 From ce0add2121222f362537fff3f680d32cd55afe02 Mon Sep 17 00:00:00 2001 From: Vincent_Michael Date: Sat, 9 Mar 2013 22:19:14 +0100 Subject: Core/Commands: Add mmaps check for command .gps --- sql/updates/world/2013_03_09_03_world_trinity_string.sql | 5 +++++ src/server/scripts/Commands/cs_misc.cpp | 13 ++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 sql/updates/world/2013_03_09_03_world_trinity_string.sql (limited to 'src/server/scripts/Commands') diff --git a/sql/updates/world/2013_03_09_03_world_trinity_string.sql b/sql/updates/world/2013_03_09_03_world_trinity_string.sql new file mode 100644 index 00000000000..3e93289711a --- /dev/null +++ b/sql/updates/world/2013_03_09_03_world_trinity_string.sql @@ -0,0 +1,5 @@ +UPDATE `trinity_string` SET `content_default`='Map: %u (%s) Zone: %u (%s) Area: %u (%s) Phase: %u +X: %f Y: %f Z: %f Orientation: %f +grid[%u,%u]cell[%u,%u] InstanceID: %u + ZoneX: %f ZoneY: %f +GroundZ: %f FloorZ: %f Have height data (Map: %u VMap: %u MMap: %u)' WHERE `entry`=101; diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 20c50949dcc..c6d80cea3a5 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -35,6 +35,7 @@ #include "Pet.h" #include "LFG.h" #include "GroupMgr.h" +#include "MMapFactory.h" class misc_commandscript : public CommandScript { @@ -191,8 +192,9 @@ public: uint32 zoneId, areaId; object->GetZoneAndAreaId(zoneId, areaId); + uint32 mapId = object->GetMapId(); - MapEntry const* mapEntry = sMapStore.LookupEntry(object->GetMapId()); + MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zoneId); AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaId); @@ -211,8 +213,9 @@ public: int gridX = 63 - gridCoord.x_coord; int gridY = 63 - gridCoord.y_coord; - uint32 haveMap = Map::ExistMap(object->GetMapId(), gridX, gridY) ? 1 : 0; - uint32 haveVMap = Map::ExistVMap(object->GetMapId(), gridX, gridY) ? 1 : 0; + uint32 haveMap = Map::ExistMap(mapId, gridX, gridY) ? 1 : 0; + uint32 haveVMap = Map::ExistVMap(mapId, gridX, gridY) ? 1 : 0; + uint32 haveMMap = (MMAP::MMapFactory::IsPathfindingEnabled(mapId) && MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId())) ? 1 : 0; if (haveVMap) { @@ -225,13 +228,13 @@ public: handler->PSendSysMessage("no VMAP available for area info"); handler->PSendSysMessage(LANG_MAP_POSITION, - object->GetMapId(), (mapEntry ? mapEntry->name[handler->GetSessionDbcLocale()] : ""), + mapId, (mapEntry ? mapEntry->name[handler->GetSessionDbcLocale()] : ""), zoneId, (zoneEntry ? zoneEntry->area_name[handler->GetSessionDbcLocale()] : ""), areaId, (areaEntry ? areaEntry->area_name[handler->GetSessionDbcLocale()] : ""), object->GetPhaseMask(), object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), object->GetOrientation(), cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), object->GetInstanceId(), - zoneX, zoneY, groundZ, floorZ, haveMap, haveVMap); + zoneX, zoneY, groundZ, floorZ, haveMap, haveVMap, haveMMap); LiquidData liquidStatus; ZLiquidStatus status = map->getLiquidStatus(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), MAP_ALL_LIQUIDS, &liquidStatus); -- cgit v1.2.3 From 65b16a97bee09e9c5114a35be7b0122987d249e1 Mon Sep 17 00:00:00 2001 From: Vincent_Michael Date: Sat, 9 Mar 2013 22:34:46 +0100 Subject: Core/Commands: Add unit flags 2 for .npc info --- sql/updates/world/2013_03_09_04_world_trinity_string.sql | 4 ++++ src/server/scripts/Commands/cs_npc.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 sql/updates/world/2013_03_09_04_world_trinity_string.sql (limited to 'src/server/scripts/Commands') diff --git a/sql/updates/world/2013_03_09_04_world_trinity_string.sql b/sql/updates/world/2013_03_09_04_world_trinity_string.sql new file mode 100644 index 00000000000..dea2a044c99 --- /dev/null +++ b/sql/updates/world/2013_03_09_04_world_trinity_string.sql @@ -0,0 +1,4 @@ +UPDATE `trinity_string` SET `content_default`='Unit Flags: %u. +Unit Flags 2: %u. +Dynamic Flags: %u. +Faction Template: %u.' WHERE `entry`=542; diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 0d898ed45c2..79a74b0823d 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -647,7 +647,7 @@ public: handler->PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel()); handler->PSendSysMessage(LANG_NPCINFO_EQUIPMENT, target->GetCurrentEquipmentId(), target->GetOriginalEquipmentId()); handler->PSendSysMessage(LANG_NPCINFO_HEALTH, target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth()); - handler->PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUInt32Value(UNIT_FIELD_FLAGS), target->GetUInt32Value(UNIT_DYNAMIC_FLAGS), target->getFaction()); + handler->PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUInt32Value(UNIT_FIELD_FLAGS), target->GetUInt32Value(UNIT_FIELD_FLAGS_2), target->GetUInt32Value(UNIT_DYNAMIC_FLAGS), target->getFaction()); handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(), curRespawnDelayStr.c_str()); handler->PSendSysMessage(LANG_NPCINFO_LOOT, cInfo->lootid, cInfo->pickpocketLootId, cInfo->SkinLootId); handler->PSendSysMessage(LANG_NPCINFO_DUNGEON_ID, target->GetInstanceId()); -- cgit v1.2.3 From 4e789d4c5c83dd6f0f582fe24e9d49b39950fffe Mon Sep 17 00:00:00 2001 From: Vincent_Michael Date: Sat, 9 Mar 2013 23:05:27 +0100 Subject: Core/Commands: Optimize for command .npc near --- src/server/scripts/Commands/cs_npc.cpp | 42 ++++++++-------------- .../Database/Implementation/WorldDatabase.cpp | 1 - .../shared/Database/Implementation/WorldDatabase.h | 1 - 3 files changed, 14 insertions(+), 30 deletions(-) (limited to 'src/server/scripts/Commands') diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 79a74b0823d..f640d257a3a 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -665,43 +665,29 @@ public: static bool HandleNpcNearCommand(ChatHandler* handler, char const* args) { + WorldObject* object = handler->GetSession()->GetPlayer(); float distance = (!*args) ? 10.0f : float((atof(args))); uint32 count = 0; - Player* player = handler->GetSession()->GetPlayer(); + CellCoord pair(Trinity::ComputeCellCoord(object->GetPositionX(), object->GetPositionY())); + Cell cell(pair); + cell.SetNoCreate(); + + std::list creatureList; + Trinity::AnyUnitInObjectRangeCheck check(object, distance); + Trinity::CreatureListSearcher search(object, creatureList, check); + TypeContainerVisitor, GridTypeMapContainer> visit(search); - PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_NEAREST); - stmt->setFloat(0, player->GetPositionX()); - stmt->setFloat(1, player->GetPositionY()); - stmt->setFloat(2, player->GetPositionZ()); - stmt->setUInt32(3, player->GetMapId()); - stmt->setFloat(4, player->GetPositionX()); - stmt->setFloat(5, player->GetPositionY()); - stmt->setFloat(6, player->GetPositionZ()); - stmt->setFloat(7, distance * distance); - PreparedQueryResult result = WorldDatabase.Query(stmt); + cell.Visit(pair, visit, *(object->GetMap()), *object, distance); - if (result) + if (!creatureList.empty()) { - do + for (std::list::iterator itr = creatureList.begin(); itr != creatureList.end(); ++itr) { - Field* fields = result->Fetch(); - uint32 guid = fields[0].GetUInt32(); - uint32 entry = fields[1].GetUInt32(); - float x = fields[2].GetFloat(); - float y = fields[3].GetFloat(); - float z = fields[4].GetFloat(); - uint16 mapId = fields[5].GetUInt16(); - - CreatureTemplate const* creatureTemplate = sObjectMgr->GetCreatureTemplate(entry); - if (!creatureTemplate) - continue; - - handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, creatureTemplate->Name.c_str(), x, y, z, mapId); - + handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, (*itr)->GetGUIDLow(), (*itr)->GetGUIDLow(), (*itr)->GetName().c_str(), + (*itr)->GetPositionX(), (*itr)->GetPositionY(), (*itr)->GetPositionZ(), (*itr)->GetMapId()); ++count; } - while (result->NextRow()); } handler->PSendSysMessage(LANG_COMMAND_NEAR_NPC_MESSAGE, distance, count); diff --git a/src/server/shared/Database/Implementation/WorldDatabase.cpp b/src/server/shared/Database/Implementation/WorldDatabase.cpp index 89f3cf8fdce..94060330d82 100644 --- a/src/server/shared/Database/Implementation/WorldDatabase.cpp +++ b/src/server/shared/Database/Implementation/WorldDatabase.cpp @@ -84,7 +84,6 @@ void WorldDatabaseConnection::DoPrepareStatements() PrepareStatement(WORLD_SEL_ITEM_TEMPLATE_BY_NAME, "SELECT entry FROM item_template WHERE name = ?", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_CREATURE_BY_ID, "SELECT guid FROM creature WHERE id = ?", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_GAMEOBJECT_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM gameobject WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? ORDER BY order_", CONNECTION_SYNCH); - PrepareStatement(WORLD_SEL_CREATURE_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM creature WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? ORDER BY order_", CONNECTION_SYNCH); PrepareStatement(WORLD_INS_CREATURE, "INSERT INTO creature (guid, id , map, spawnMask, phaseMask, modelid, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, spawndist, currentwaypoint, curhealth, curmana, MovementType, npcflag, unit_flags, dynamicflags) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(WORLD_DEL_GAME_EVENT_CREATURE, "DELETE FROM game_event_creature WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_DEL_GAME_EVENT_MODEL_EQUIP, "DELETE FROM game_event_model_equip WHERE guid = ?", CONNECTION_ASYNC); diff --git a/src/server/shared/Database/Implementation/WorldDatabase.h b/src/server/shared/Database/Implementation/WorldDatabase.h index 032baf29dd9..f6fd92b11cd 100644 --- a/src/server/shared/Database/Implementation/WorldDatabase.h +++ b/src/server/shared/Database/Implementation/WorldDatabase.h @@ -104,7 +104,6 @@ enum WorldDatabaseStatements WORLD_SEL_ITEM_TEMPLATE_BY_NAME, WORLD_SEL_CREATURE_BY_ID, WORLD_SEL_GAMEOBJECT_NEAREST, - WORLD_SEL_CREATURE_NEAREST, WORLD_SEL_GAMEOBJECT_TARGET, WORLD_INS_CREATURE, WORLD_DEL_GAME_EVENT_CREATURE, -- cgit v1.2.3 From 4ee0a4a4460ff0a44f39a5359c6e234c9d31fc6b Mon Sep 17 00:00:00 2001 From: Vincent_Michael Date: Sat, 9 Mar 2013 23:28:32 +0100 Subject: Revert "Core/Commands: Optimize for command .npc near" This reverts commit 4e789d4c5c83dd6f0f582fe24e9d49b39950fffe. --- src/server/scripts/Commands/cs_npc.cpp | 42 ++++++++++++++-------- .../Database/Implementation/WorldDatabase.cpp | 1 + .../shared/Database/Implementation/WorldDatabase.h | 1 + 3 files changed, 30 insertions(+), 14 deletions(-) (limited to 'src/server/scripts/Commands') diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index f640d257a3a..79a74b0823d 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -665,29 +665,43 @@ public: static bool HandleNpcNearCommand(ChatHandler* handler, char const* args) { - WorldObject* object = handler->GetSession()->GetPlayer(); float distance = (!*args) ? 10.0f : float((atof(args))); uint32 count = 0; - CellCoord pair(Trinity::ComputeCellCoord(object->GetPositionX(), object->GetPositionY())); - Cell cell(pair); - cell.SetNoCreate(); - - std::list creatureList; - Trinity::AnyUnitInObjectRangeCheck check(object, distance); - Trinity::CreatureListSearcher search(object, creatureList, check); - TypeContainerVisitor, GridTypeMapContainer> visit(search); + Player* player = handler->GetSession()->GetPlayer(); - cell.Visit(pair, visit, *(object->GetMap()), *object, distance); + PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_NEAREST); + stmt->setFloat(0, player->GetPositionX()); + stmt->setFloat(1, player->GetPositionY()); + stmt->setFloat(2, player->GetPositionZ()); + stmt->setUInt32(3, player->GetMapId()); + stmt->setFloat(4, player->GetPositionX()); + stmt->setFloat(5, player->GetPositionY()); + stmt->setFloat(6, player->GetPositionZ()); + stmt->setFloat(7, distance * distance); + PreparedQueryResult result = WorldDatabase.Query(stmt); - if (!creatureList.empty()) + if (result) { - for (std::list::iterator itr = creatureList.begin(); itr != creatureList.end(); ++itr) + do { - handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, (*itr)->GetGUIDLow(), (*itr)->GetGUIDLow(), (*itr)->GetName().c_str(), - (*itr)->GetPositionX(), (*itr)->GetPositionY(), (*itr)->GetPositionZ(), (*itr)->GetMapId()); + Field* fields = result->Fetch(); + uint32 guid = fields[0].GetUInt32(); + uint32 entry = fields[1].GetUInt32(); + float x = fields[2].GetFloat(); + float y = fields[3].GetFloat(); + float z = fields[4].GetFloat(); + uint16 mapId = fields[5].GetUInt16(); + + CreatureTemplate const* creatureTemplate = sObjectMgr->GetCreatureTemplate(entry); + if (!creatureTemplate) + continue; + + handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, creatureTemplate->Name.c_str(), x, y, z, mapId); + ++count; } + while (result->NextRow()); } handler->PSendSysMessage(LANG_COMMAND_NEAR_NPC_MESSAGE, distance, count); diff --git a/src/server/shared/Database/Implementation/WorldDatabase.cpp b/src/server/shared/Database/Implementation/WorldDatabase.cpp index 94060330d82..89f3cf8fdce 100644 --- a/src/server/shared/Database/Implementation/WorldDatabase.cpp +++ b/src/server/shared/Database/Implementation/WorldDatabase.cpp @@ -84,6 +84,7 @@ void WorldDatabaseConnection::DoPrepareStatements() PrepareStatement(WORLD_SEL_ITEM_TEMPLATE_BY_NAME, "SELECT entry FROM item_template WHERE name = ?", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_CREATURE_BY_ID, "SELECT guid FROM creature WHERE id = ?", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_GAMEOBJECT_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM gameobject WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? ORDER BY order_", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_CREATURE_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM creature WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? ORDER BY order_", CONNECTION_SYNCH); PrepareStatement(WORLD_INS_CREATURE, "INSERT INTO creature (guid, id , map, spawnMask, phaseMask, modelid, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, spawndist, currentwaypoint, curhealth, curmana, MovementType, npcflag, unit_flags, dynamicflags) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(WORLD_DEL_GAME_EVENT_CREATURE, "DELETE FROM game_event_creature WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_DEL_GAME_EVENT_MODEL_EQUIP, "DELETE FROM game_event_model_equip WHERE guid = ?", CONNECTION_ASYNC); diff --git a/src/server/shared/Database/Implementation/WorldDatabase.h b/src/server/shared/Database/Implementation/WorldDatabase.h index f6fd92b11cd..032baf29dd9 100644 --- a/src/server/shared/Database/Implementation/WorldDatabase.h +++ b/src/server/shared/Database/Implementation/WorldDatabase.h @@ -104,6 +104,7 @@ enum WorldDatabaseStatements WORLD_SEL_ITEM_TEMPLATE_BY_NAME, WORLD_SEL_CREATURE_BY_ID, WORLD_SEL_GAMEOBJECT_NEAREST, + WORLD_SEL_CREATURE_NEAREST, WORLD_SEL_GAMEOBJECT_TARGET, WORLD_INS_CREATURE, WORLD_DEL_GAME_EVENT_CREATURE, -- cgit v1.2.3