From 03fbc0a69d910ef8058a9db88f9b4b341cd7d59d Mon Sep 17 00:00:00 2001 From: Dehravor Date: Thu, 2 Jan 2014 10:36:13 +0100 Subject: [PATCH 01/12] Core/Guild: Implement GR_RIGHT_VIEWOFFNOTE --- src/server/game/Guilds/Guild.cpp | 12 ++++++++---- src/server/game/Guilds/Guild.h | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index 239c0b17e7..33e16dbf99 100644 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -701,7 +701,7 @@ bool Guild::Member::CheckStats() const return true; } -void Guild::Member::WritePacket(WorldPacket& data) const +void Guild::Member::WritePacket(WorldPacket& data, bool sendOfficerNote) const { data << uint64(m_guid) << uint8(m_flags) @@ -715,8 +715,12 @@ void Guild::Member::WritePacket(WorldPacket& data) const if (!m_flags) data << float(float(::time(NULL) - m_logoutTime) / DAY); - data << m_publicNote - << m_officerNote; + data << m_publicNote; + + if (sendOfficerNote) + data << m_officerNote; + else + data << ""; } // Decreases amount of money/slots left for today. @@ -1312,7 +1316,7 @@ void Guild::HandleRoster(WorldSession* session /*= NULL*/) ritr->WritePacket(data); for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) - itr->second->WritePacket(data); + itr->second->WritePacket(data, _HasRankRight(session->GetPlayer(), GR_RIGHT_VIEWOFFNOTE)); if (session) { diff --git a/src/server/game/Guilds/Guild.h b/src/server/game/Guilds/Guild.h index aa4c002433..c8c7089fee 100644 --- a/src/server/game/Guilds/Guild.h +++ b/src/server/game/Guilds/Guild.h @@ -315,7 +315,7 @@ private: bool LoadFromDB(Field* fields); void SaveToDB(SQLTransaction& trans) const; - void WritePacket(WorldPacket& data) const; + void WritePacket(WorldPacket& data, bool sendOfficerNote) const; uint64 GetGUID() const { return m_guid; } std::string const& GetName() const { return m_name; } From e794e85969c1fec54cbf5140a17272e3d1070a93 Mon Sep 17 00:00:00 2001 From: Dehravor Date: Thu, 2 Jan 2014 10:37:44 +0100 Subject: [PATCH 02/12] Core/Guild: HandleRoster should always have a valid session --- src/server/game/Guilds/Guild.cpp | 14 +++----------- src/server/game/Guilds/Guild.h | 2 +- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index 33e16dbf99..f448fbb9f1 100644 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -1303,7 +1303,7 @@ bool Guild::SetName(std::string const& name) return true; } -void Guild::HandleRoster(WorldSession* session /*= NULL*/) +void Guild::HandleRoster(WorldSession* session) { // Guess size WorldPacket data(SMSG_GUILD_ROSTER, (4 + m_motd.length() + 1 + m_info.length() + 1 + 4 + _GetRanksSize() * (4 + 4 + GUILD_BANK_MAX_TABS * (4 + 4)) + m_members.size() * 50)); @@ -1318,16 +1318,8 @@ void Guild::HandleRoster(WorldSession* session /*= NULL*/) for (Members::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) itr->second->WritePacket(data, _HasRankRight(session->GetPlayer(), GR_RIGHT_VIEWOFFNOTE)); - if (session) - { - TC_LOG_DEBUG("guild", "SMSG_GUILD_ROSTER [%s]", session->GetPlayerInfo().c_str()); - session->SendPacket(&data); - } - else - { - TC_LOG_DEBUG("guild", "SMSG_GUILD_ROSTER [Broadcast]"); - BroadcastPacket(&data); - } + TC_LOG_DEBUG("guild", "SMSG_GUILD_ROSTER [%s]", session->GetPlayerInfo().c_str()); + session->SendPacket(&data); } void Guild::HandleQuery(WorldSession* session) diff --git a/src/server/game/Guilds/Guild.h b/src/server/game/Guilds/Guild.h index c8c7089fee..fca483e92c 100644 --- a/src/server/game/Guilds/Guild.h +++ b/src/server/game/Guilds/Guild.h @@ -661,7 +661,7 @@ public: bool SetName(std::string const& name); // Handle client commands - void HandleRoster(WorldSession* session = NULL); // NULL = broadcast + void HandleRoster(WorldSession* session); void HandleQuery(WorldSession* session); void HandleSetMOTD(WorldSession* session, std::string const& motd); void HandleSetInfo(WorldSession* session, std::string const& info); From d78e69cdc6be1d762dcaaafc489c027896790fa3 Mon Sep 17 00:00:00 2001 From: jackpoz Date: Mon, 13 Jan 2014 22:52:35 +0100 Subject: [PATCH 03/12] Core/Instances: Fix memory leak in InstanceSaveMgr Fix memory leak in InstanceSaveMgr added in 1f170c99efec6c89b9a454a3aa17511341f61659 . Make InstanceSave::SetToDelete() private since it's not supposed to be used by anything other than InstanceSave or its friend class InstanceSaveMgr . --- src/server/game/Instances/InstanceSaveMgr.cpp | 4 ++++ src/server/game/Instances/InstanceSaveMgr.h | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/server/game/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp index e37e6847bd..c46d900260 100644 --- a/src/server/game/Instances/InstanceSaveMgr.cpp +++ b/src/server/game/Instances/InstanceSaveMgr.cpp @@ -164,7 +164,11 @@ void InstanceSaveManager::RemoveInstanceSave(uint32 InstanceId) void InstanceSaveManager::UnloadInstanceSave(uint32 InstanceId) { if (InstanceSave* save = GetInstanceSave(InstanceId)) + { save->UnloadIfEmpty(); + if (save->m_toDelete) + delete save; + } } InstanceSave::InstanceSave(uint16 MapId, uint32 InstanceId, Difficulty difficulty, time_t resetTime, bool canReset) diff --git a/src/server/game/Instances/InstanceSaveMgr.h b/src/server/game/Instances/InstanceSaveMgr.h index 7a89e6488f..1d753ebaa4 100644 --- a/src/server/game/Instances/InstanceSaveMgr.h +++ b/src/server/game/Instances/InstanceSaveMgr.h @@ -115,16 +115,16 @@ class InstanceSave but that would depend on a lot of things that can easily change in future */ Difficulty GetDifficulty() const { return m_difficulty; } + typedef std::list PlayerListType; + typedef std::list GroupListType; + private: + bool UnloadIfEmpty(); /* used to flag the InstanceSave as to be deleted, so the caller can delete it */ void SetToDelete(bool toDelete) { m_toDelete = toDelete; } - typedef std::list PlayerListType; - typedef std::list GroupListType; - private: - bool UnloadIfEmpty(); /* the only reason the instSave-object links are kept is because the object-instSave links need to be broken at reset time */ /// @todo: Check if maybe it's enough to just store the number of players/groups From 6e01c0b0b4205f0d981ec658ae4d61b7e54fbab7 Mon Sep 17 00:00:00 2001 From: joschiwald Date: Wed, 15 Jan 2014 18:21:13 +0100 Subject: [PATCH 04/12] DB: update more creature templates --- .../world/2014_01_15_00_world_misc.sql | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 sql/updates/world/2014_01_15_00_world_misc.sql diff --git a/sql/updates/world/2014_01_15_00_world_misc.sql b/sql/updates/world/2014_01_15_00_world_misc.sql new file mode 100644 index 0000000000..b7c22edc3d --- /dev/null +++ b/sql/updates/world/2014_01_15_00_world_misc.sql @@ -0,0 +1,116 @@ +UPDATE `creature_template` SET `spell1`=66518, `spell2`=0 WHERE `entry`=34929; -- Alliance Gunship Cannon +UPDATE `creature_template` SET `spell1`=66218, `spell2`=66296, `spell8`=0, `unit_flags`=16384, `speed_walk`=2.8, `speed_run`=3.642857 WHERE `entry`=34793; -- Catapult +UPDATE `creature_template` SET `spell1`=66218, `spell2`=66296, `unit_flags`=16384, `speed_walk`=2.8, `speed_run`=3.642857 WHERE `entry`=35413; -- Catapult (1) +UPDATE `creature_template` SET `spell1`=67440, `spell2`=67441, `unit_flags`=16384 WHERE `entry`=34775; -- Demolisher +UPDATE `creature_template` SET `spell1`=68068, `spell2`=67442, `unit_flags`=16384 WHERE `entry`=35415; -- Demolisher (1) +UPDATE `creature_template` SET `spell1`=66456, `spell2`=67195, `faction_A`=1732, `faction_H`=1732, `unit_flags`=16384 WHERE `entry`=34802; -- Glaive Thrower (A) +UPDATE `creature_template` SET `spell1`=67034, `spell2`=67195, `faction_A`=1735, `faction_H`=1735, `unit_flags`=16384 WHERE `entry`=35273; -- Glaive Thrower (H) +UPDATE `creature_template` SET `spell1`=68826, `spell2`=69515, `faction_A`=1735, `faction_H`=1735, `unit_flags`=16384, `minlevel`=80, `maxlevel`=80, `speed_walk`=3.2, `speed_run`=1.14286 WHERE `entry`=35421; -- Glaive Thrower (1) (H) +UPDATE `creature_template` SET `spell1`=68827, `spell2`=69515, `faction_A`=1732, `faction_H`=1732, `unit_flags`=16384 WHERE `entry`=35419; -- Glaive Thrower (1) (A) +UPDATE `creature_template` SET `spell1`=66529, `spell2`=0 WHERE `entry`=34935; -- Horde Gunship Cannon +UPDATE `creature_template` SET `spell1`=67452, `spell2`=66541, `unit_flags`=16384 WHERE `entry`=34944; -- Keep Cannon -- sniff +UPDATE `creature_template` SET `spell1`=68170, `spell2`=68169, `unit_flags`=16384 WHERE `entry`=35429; -- Keep Cannon (1) +UPDATE `creature_template` SET `spell1`=67796, `spell2`=67797, `faction_A`=1735, `faction_H`=1735, `unit_flags`=16640 WHERE `entry`=35069; -- Siege Engine (H) +UPDATE `creature_template` SET `spell1`=67796, `spell2`=67797, `faction_A`=1732, `faction_H`=1732, `unit_flags`=16640 WHERE `entry`=34776; -- Siege Engine (A) +UPDATE `creature_template` SET `spell1`=67816, `spell2`=69502, `faction_A`=1735, `faction_H`=1735, `unit_flags`=16640, `speed_walk`=1.2, `speed_run`=1 WHERE `entry`=35433; -- Siege Engine (1) (H) +UPDATE `creature_template` SET `spell1`=67816, `spell2`=69502, `faction_A`=1732, `faction_H`=1732, `unit_flags`=16640 WHERE `entry`=35431; -- Siege Engine (1) (A) + +UPDATE `creature_template` SET `minlevel`=70, `maxlevel`=70, `spell1`=66186, `faction_A`=1732, `faction_H`=1732, `unit_flags`=16384, `VehicleId`=436 WHERE `entry`=34778; -- Flame Turret (A) +UPDATE `creature_template` SET `minlevel`=70, `maxlevel`=70, `spell1`=66186, `faction_A`=1735, `faction_H`=1735, `unit_flags`=16384 WHERE `entry`=36356; -- Flame Turret (H) +UPDATE `creature_template` SET `minlevel`=80, `maxlevel`=80, `spell1`=68832, `faction_A`=1732, `faction_H`=1732, `unit_flags`=16384 WHERE `entry`=35417; -- Flame Turret (1) (A) +UPDATE `creature_template` SET `minlevel`=80, `maxlevel`=80, `spell1`=68832, `faction_A`=1735, `faction_H`=1735, `unit_flags`=16384 WHERE `entry`=36358; -- Flame Turret (1) (H) + +UPDATE `creature_template` SET `difficulty_entry_1`=35417 WHERE `entry`=34778; -- Flame Turret (A) +UPDATE `creature_template` SET `difficulty_entry_1`=36358 WHERE `entry`=36356; -- Flame Turret (H) + +UPDATE `creature_template` SET `minlevel`=70, `maxlevel`=70, `spell1`=66203, `spell2`=67461, `faction_A`=1732, `faction_H`=1732, `unit_flags`=16384, `VehicleId`=436 WHERE `entry`=34777; -- Siege Turret (A) +UPDATE `creature_template` SET `minlevel`=70, `maxlevel`=70, `spell1`=66203, `spell2`=67461, `faction_A`=1735, `faction_H`=1735, `unit_flags`=16384 WHERE `entry`=36355; -- Siege Turret (H) +UPDATE `creature_template` SET `minlevel`=80, `maxlevel`=80, `spell1`=67462, `spell2`=69505, `faction_A`=1732, `faction_H`=1732, `unit_flags`=16384 WHERE `entry`=35436; -- Siege Turret (1) (A) +UPDATE `creature_template` SET `minlevel`=80, `maxlevel`=80, `spell1`=67462, `spell2`=69505, `faction_A`=1735, `faction_H`=1735, `unit_flags`=16384 WHERE `entry`=36357; -- Siege Turret (1) (H) + +UPDATE `creature_template` SET `difficulty_entry_1`=35436 WHERE `entry`=34777; -- Siege Turret (A) +UPDATE `creature_template` SET `difficulty_entry_1`=36357 WHERE `entry`=36355; -- Siege Turret (H) + +UPDATE `creature_template` SET `speed_walk`=1.2, `speed_run`=1.142857 WHERE `entry` IN (34778,36356,35417,36358,34777,36355,35436,36357); + +UPDATE `creature_template` SET `npcflag`=16777216, `baseattacktime`=2000, `rangeattacktime`=2000, `mechanic_immune_mask`=344276858 WHERE `entry` IN (34929,34793,35413,34775,35415,34802,35273,35421,35419,34935,34944,35429,35069,34776,35433,35431,34778,36356,35417,36358,34777,36355,35436,36357); + +DELETE FROM `vehicle_template_accessory` WHERE `entry` IN (34776,35069); +INSERT INTO `vehicle_template_accessory` (`entry`,`accessory_entry`,`seat_id`,`minion`,`description`,`summontype`,`summontimer`) VALUES +(34776,34778,1,1,'Siege Engine - Flame Turret',6,30000), +(34776,34778,2,1,'Siege Engine - Flame Turret',6,30000), +(34776,34777,7,1,'Siege Engine - Siege Turret',6,30000), +(35069,36356,1,1,'Siege Engine - Flame Turret',6,30000), +(35069,36356,2,1,'Siege Engine - Flame Turret',6,30000), +(35069,36355,7,1,'Siege Engine - Siege Turret',6,30000); + +DELETE FROM `npc_spellclick_spells` WHERE `npc_entry` IN (34929,34793,35413,34775,35415,34802,35273,35421,35419,34935,34944,35429,35069,34776,35433,35431,34778,36356,35417,36358,34777,36355,35436,36357); +INSERT INTO `npc_spellclick_spells` (`npc_entry`, `spell_id`, `cast_flags`, `user_type`) VALUES +(34775,66245,1,0), +(34776,66245,1,0), +(34776,46598,1,0), -- accessorys +(34777,66245,1,0), +(34778,66245,1,0), +(34793,66245,1,0), +(34802,68503,1,0), +(34929,43671,1,0), +(34935,43671,1,0), +(34944,68458,1,0), +(35069,66245,1,0), +(35069,46598,1,0), -- accessorys +(35273,68503,1,0), +(35413,66245,1,0), +(35415,66245,1,0), +(35417,66245,1,0), +(35419,68503,1,0), +(35421,68503,1,0), +(35429,68458,1,0), +(35431,66245,1,0), +(35431,46598,1,0), -- accessorys +(35433,66245,1,0), +(35433,46598,1,0), -- accessorys +(35436,66245,1,0), +(36355,66245,1,0), +(36356,66245,1,0), +(36357,66245,1,0), +(36358,66245,1,0); + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=18 AND `SourceGroup` IN (34776,35069,35431,35433); +INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition`, `ErrorType`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES +(18,34776,66245,0,0,31,0,4,0,0,0,0,0,'','Require player for spellclick'), +(18,34776,46598,0,0,31,0,3,0,0,0,0,0,'','Require unit for spellclick'), +(18,35069,66245,0,0,31,0,4,0,0,0,0,0,'','Require player for spellclick'), +(18,35069,46598,0,0,31,0,3,0,0,0,0,0,'','Require unit for spellclick'), +(18,35431,66245,0,0,31,0,4,0,0,0,0,0,'','Require player for spellclick'), +(18,35431,46598,0,0,31,0,3,0,0,0,0,0,'','Require unit for spellclick'), +(18,35433,66245,0,0,31,0,4,0,0,0,0,0,'','Require player for spellclick'), +(18,35433,46598,0,0,31,0,3,0,0,0,0,0,'','Require unit for spellclick'); + +UPDATE `gameobject_template` SET `flags`=40 WHERE `entry` IN (195121,195276); + + +UPDATE `creature_template` SET `faction_A`=1732, `faction_H`=1732 WHERE `entry`=28312; -- Wintergrasp Siege Engine (A) +UPDATE `creature_template` SET `faction_A`=1735, `faction_H`=1735 WHERE `entry`=32627; -- Wintergrasp Siege Engine (H) +UPDATE `creature_template` SET `faction_A`=1732, `faction_H`=1732 WHERE `entry`=28319; -- Wintergrasp Siege Turret (A) +UPDATE `creature_template` SET `faction_A`=1735, `faction_H`=1735 WHERE `entry`=32629; -- Wintergrasp Siege Turret (H) + +DELETE FROM `npc_spellclick_spells` WHERE `npc_entry` IN (28312,32627,28319,32629); +INSERT INTO `npc_spellclick_spells` (`npc_entry`, `spell_id`, `cast_flags`, `user_type`) VALUES +(28312,60968,1,0), +(28312,46598,1,0), -- accessorys +(32627,60968,1,0), +(32627,46598,1,0), -- accessorys +(28319,60968,1,0), +(32629,60968,1,0); + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceId`=18 AND `SourceGroup` IN (28312,32627,28319,32629); +INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `SourceId`, `ElseGroup`, `ConditionTypeOrReference`, `ConditionTarget`, `ConditionValue1`, `ConditionValue2`, `ConditionValue3`, `NegativeCondition`, `ErrorType`, `ErrorTextId`, `ScriptName`, `Comment`) VALUES +(18,28312,60968,0,0,31,0,4,0,0,0,0,0,'','Require player for spellclick'), +(18,28312,46598,0,0,31,0,3,0,0,0,0,0,'','Require unit for spellclick'), +(18,32627,60968,0,0,31,0,4,0,0,0,0,0,'','Require player for spellclick'), +(18,32627,46598,0,0,31,0,3,0,0,0,0,0,'','Require unit for spellclick'); + + +UPDATE `creature_template` SET `faction_A`=71, `faction_H`=71, `unit_flags`=32768, `baseattacktime`=2000, `rangeattacktime`=2000 WHERE `entry`=5624; -- Undercity Guardian +UPDATE `creature_template` SET `faction_A`=14, `faction_H`=14 WHERE `entry`=25422; -- Mystical Webbing +UPDATE `creature_template` SET `faction_A`=2148, `faction_H`=2148 WHERE `entry`=27189; -- Unu'pe Spearman From cbba22ba6809caf4e9272d8c601756ec0323cc05 Mon Sep 17 00:00:00 2001 From: jackpoz Date: Wed, 15 Jan 2014 20:20:01 +0100 Subject: [PATCH 05/12] Core/SAI: Fix assertion triggered in SmartScript Remove assertion in SmartScript added in b8625f41bd6131e7fb3ff126780da18d5d2959fd and handle SmartScripts with GetBaseObject() returning NULL , like SmartTrigger . In this case SmartScript::mTargetStorage cannot be sanitized and might contain references to free'd WorldObjects if the script doesn't last a single Map::Update() call. --- .../game/AI/SmartScripts/SmartScriptMgr.h | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 08ef71771e..9ba5ccc578 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -1332,7 +1332,6 @@ public: ObjectGuidList(ObjectList* objectList, WorldObject* baseObject) { ASSERT(objectList != NULL); - ASSERT(baseObject != NULL); m_objectList = objectList; m_baseObject = baseObject; m_guidList = new GuidList(); @@ -1345,15 +1344,18 @@ public: ObjectList* GetObjectList() { - //sanitize list using m_guidList - m_objectList->clear(); - - for (GuidList::iterator itr = m_guidList->begin(); itr != m_guidList->end(); ++itr) + if (m_baseObject) { - if (WorldObject* obj = ObjectAccessor::GetWorldObject(*m_baseObject, *itr)) - m_objectList->push_back(obj); - else - TC_LOG_DEBUG("scripts.ai", "SmartScript::mTargetStorage stores a guid to an invalid object: " UI64FMTD, *itr); + //sanitize list using m_guidList + m_objectList->clear(); + + for (GuidList::iterator itr = m_guidList->begin(); itr != m_guidList->end(); ++itr) + { + if (WorldObject* obj = ObjectAccessor::GetWorldObject(*m_baseObject, *itr)) + m_objectList->push_back(obj); + else + TC_LOG_DEBUG("scripts.ai", "SmartScript::mTargetStorage stores a guid to an invalid object: " UI64FMTD, *itr); + } } return m_objectList; From 61f45283ef847b69b769aabe865a3c9baf22ba3b Mon Sep 17 00:00:00 2001 From: Discover- Date: Thu, 16 Jan 2014 20:44:03 +0100 Subject: [PATCH 06/12] Core/Misc: Fix an exploit where moving while consuming something that would fade when the player stands up would stay if the player started moving and using the effect at the same time. Thanks to @FrozenSoul and @jildor. Fixes #6271 --- src/server/game/Handlers/MovementHandler.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/server/game/Handlers/MovementHandler.cpp b/src/server/game/Handlers/MovementHandler.cpp index 08dc860235..0c2eae849b 100644 --- a/src/server/game/Handlers/MovementHandler.cpp +++ b/src/server/game/Handlers/MovementHandler.cpp @@ -381,6 +381,9 @@ void WorldSession::HandleMovementOpcodes(WorldPacket& recvData) if (plrMover) // nothing is charmed, or player charmed { + if (plrMover->IsSitState() && (movementInfo.flags & (MOVEMENTFLAG_MASK_MOVING | MOVEMENTFLAG_MASK_TURNING))) + plrMover->SetStandState(UNIT_STAND_STATE_STAND); + plrMover->UpdateFallInformationIfNeed(movementInfo, opcode); if (movementInfo.pos.GetPositionZ() < -500.0f) From 45dc95c8dc7436ed4a40b7dc12f7e6e133aa0caf Mon Sep 17 00:00:00 2001 From: Discover- Date: Thu, 16 Jan 2014 20:48:37 +0100 Subject: [PATCH 07/12] Core/Items: Fix an exploit where the player was able to send CMSG_SET_AMMO with items they didn't have in their bags. Only a visual bug (not sure if it gave bonuses too, which iirc do appear in later expansions). --- src/server/game/Handlers/ItemHandler.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index 477b6ddfc7..3571410fd5 100644 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -991,9 +991,9 @@ void WorldSession::HandleAutoStoreBankItemOpcode(WorldPacket& recvPacket) void WorldSession::HandleSetAmmoOpcode(WorldPacket& recvData) { - if (!GetPlayer()->IsAlive()) + if (!_player->IsAlive()) { - GetPlayer()->SendEquipError(EQUIP_ERR_YOU_ARE_DEAD, NULL, NULL); + _player->SendEquipError(EQUIP_ERR_YOU_ARE_DEAD, NULL, NULL); return; } @@ -1002,10 +1002,18 @@ void WorldSession::HandleSetAmmoOpcode(WorldPacket& recvData) recvData >> item; - if (!item) - GetPlayer()->RemoveAmmo(); + if (item) + { + if (!_player->GetItemCount(item)) + { + _player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL); + return; + } + + _player->SetAmmo(item); + } else - GetPlayer()->SetAmmo(item); + _player->RemoveAmmo(); } void WorldSession::SendEnchantmentLog(uint64 target, uint64 caster, uint32 itemId, uint32 enchantId) From 940e52236b6e7653d4a1c72f8a82fa0f5bece11d Mon Sep 17 00:00:00 2001 From: joschiwald Date: Fri, 17 Jan 2014 01:07:37 +0100 Subject: [PATCH 08/12] Core/Entities: bg vehicle will also have charmer's faction (save faction before charm and restore old faction after charm) --- PreLoad.cmake | 2 +- src/server/game/AI/CoreAI/CombatAI.cpp | 60 ++++------- src/server/game/AI/CoreAI/CombatAI.h | 20 ++-- src/server/game/Entities/Player/Player.cpp | 13 ++- src/server/game/Entities/Player/Player.h | 2 +- src/server/game/Entities/Unit/Unit.cpp | 113 ++++++++++----------- src/server/game/Entities/Unit/Unit.h | 25 ++--- 7 files changed, 109 insertions(+), 126 deletions(-) diff --git a/PreLoad.cmake b/PreLoad.cmake index 2bdb3042a6..55b8a9dad8 100644 --- a/PreLoad.cmake +++ b/PreLoad.cmake @@ -1,4 +1,4 @@ -# Copyright (C) 2005-2013 Trinity +# Copyright (C) 2008-2014 TrinityCore # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without diff --git a/src/server/game/AI/CoreAI/CombatAI.cpp b/src/server/game/AI/CoreAI/CombatAI.cpp index da55a07367..943919451a 100644 --- a/src/server/game/AI/CoreAI/CombatAI.cpp +++ b/src/server/game/AI/CoreAI/CombatAI.cpp @@ -23,6 +23,10 @@ #include "ObjectAccessor.h" #include "Player.h" +///////////////// +// AggressorAI +///////////////// + int AggressorAI::Permissible(const Creature* creature) { // have some hostile factions, it will be selected by IsHostileTo check at MoveInLineOfSight @@ -40,26 +44,9 @@ void AggressorAI::UpdateAI(uint32 /*diff*/) DoMeleeAttackIfReady(); } -// some day we will delete these useless things -int CombatAI::Permissible(const Creature* /*creature*/) -{ - return PERMIT_BASE_NO; -} - -int ArcherAI::Permissible(const Creature* /*creature*/) -{ - return PERMIT_BASE_NO; -} - -int TurretAI::Permissible(const Creature* /*creature*/) -{ - return PERMIT_BASE_NO; -} - -int VehicleAI::Permissible(const Creature* /*creature*/) -{ - return PERMIT_BASE_NO; -} +///////////////// +// CombatAI +///////////////// void CombatAI::InitializeAI() { @@ -118,7 +105,7 @@ void CombatAI::SpellInterrupted(uint32 spellId, uint32 unTimeMs) } ///////////////// -//CasterAI +// CasterAI ///////////////// void CasterAI::InitializeAI() @@ -182,7 +169,7 @@ void CasterAI::UpdateAI(uint32 diff) } ////////////// -//ArcherAI +// ArcherAI ////////////// ArcherAI::ArcherAI(Creature* c) : CreatureAI(c) @@ -231,7 +218,7 @@ void ArcherAI::UpdateAI(uint32 /*diff*/) } ////////////// -//TurretAI +// TurretAI ////////////// TurretAI::TurretAI(Creature* c) : CreatureAI(c) @@ -269,17 +256,17 @@ void TurretAI::UpdateAI(uint32 /*diff*/) } ////////////// -//VehicleAI +// VehicleAI ////////////// -VehicleAI::VehicleAI(Creature* c) : CreatureAI(c), m_IsVehicleInUse(false), m_ConditionsTimer(VEHICLE_CONDITION_CHECK_TIME) +VehicleAI::VehicleAI(Creature* creature) : CreatureAI(creature), m_ConditionsTimer(VEHICLE_CONDITION_CHECK_TIME) { LoadConditions(); m_DoDismiss = false; m_DismissTimer = VEHICLE_DISMISS_TIME; } -//NOTE: VehicleAI::UpdateAI runs even while the vehicle is mounted +// NOTE: VehicleAI::UpdateAI runs even while the vehicle is mounted void VehicleAI::UpdateAI(uint32 diff) { CheckConditions(diff); @@ -289,7 +276,6 @@ void VehicleAI::UpdateAI(uint32 diff) if (m_DismissTimer < diff) { m_DoDismiss = false; - me->SetVisible(false); me->DespawnOrUnsummon(); } else @@ -297,24 +283,16 @@ void VehicleAI::UpdateAI(uint32 diff) } } -void VehicleAI::Reset() -{ - me->SetVisible(true); -} - void VehicleAI::OnCharmed(bool apply) { - if (m_IsVehicleInUse && !apply && !conditions.empty())//was used and has conditions + if (!me->GetVehicleKit()->IsVehicleInUse() && !apply && !conditions.empty()) // was used and has conditions { - m_DoDismiss = true;//needs reset - me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PLAYER_VEHICLE); - me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); + m_DoDismiss = true; // needs reset } else if (apply) - m_DoDismiss = false;//in use again + m_DoDismiss = false; // in use again - m_DismissTimer = VEHICLE_DISMISS_TIME;//reset timer - m_IsVehicleInUse = apply; + m_DismissTimer = VEHICLE_DISMISS_TIME; // reset timer } void VehicleAI::LoadConditions() @@ -324,7 +302,7 @@ void VehicleAI::LoadConditions() TC_LOG_DEBUG("condition", "VehicleAI::LoadConditions: loaded %u conditions", uint32(conditions.size())); } -void VehicleAI::CheckConditions(const uint32 diff) +void VehicleAI::CheckConditions(uint32 diff) { if (m_ConditionsTimer < diff) { @@ -339,7 +317,7 @@ void VehicleAI::CheckConditions(const uint32 diff) if (!sConditionMgr->IsObjectMeetToConditions(player, me, conditions)) { player->ExitVehicle(); - return;//check other pessanger in next tick + return; // check other pessanger in next tick } } } diff --git a/src/server/game/AI/CoreAI/CombatAI.h b/src/server/game/AI/CoreAI/CombatAI.h index 10716627e8..f73daa2d72 100644 --- a/src/server/game/AI/CoreAI/CombatAI.h +++ b/src/server/game/AI/CoreAI/CombatAI.h @@ -47,7 +47,9 @@ class CombatAI : public CreatureAI void JustDied(Unit* killer); void UpdateAI(uint32 diff); void SpellInterrupted(uint32 spellId, uint32 unTimeMs); - static int Permissible(const Creature*); + + static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; } + protected: EventMap events; SpellVct spells; @@ -72,7 +74,8 @@ struct ArcherAI : public CreatureAI void AttackStart(Unit* who); void UpdateAI(uint32 diff); - static int Permissible(Creature const*); + static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; } + protected: float m_minRange; }; @@ -85,29 +88,30 @@ struct TurretAI : public CreatureAI void AttackStart(Unit* who); void UpdateAI(uint32 diff); - static int Permissible(Creature const*); + static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; } + protected: float m_minRange; }; #define VEHICLE_CONDITION_CHECK_TIME 1000 #define VEHICLE_DISMISS_TIME 5000 + struct VehicleAI : public CreatureAI { public: - explicit VehicleAI(Creature* c); + explicit VehicleAI(Creature* creature); void UpdateAI(uint32 diff); - static int Permissible(Creature const*); - void Reset(); void MoveInLineOfSight(Unit*) { } void AttackStart(Unit*) { } void OnCharmed(bool apply); + static int Permissible(Creature const* /*creature*/) { return PERMIT_BASE_NO; } + private: - bool m_IsVehicleInUse; void LoadConditions(); - void CheckConditions(const uint32 diff); + void CheckConditions(uint32 diff); ConditionList conditions; uint32 m_ConditionsTimer; bool m_DoDismiss; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index bee5427100..4dab652d73 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -759,7 +759,6 @@ Player::Player(WorldSession* session): Unit(true) m_ArmorProficiency = 0; m_canParry = false; m_canBlock = false; - m_canDualWield = false; m_canTitanGrip = false; m_ammoDPS = 0.0f; @@ -23769,14 +23768,18 @@ void Player::ResurectUsingRequestData() SpawnCorpseBones(); } -void Player::SetClientControl(Unit* target, uint8 allowMove) +void Player::SetClientControl(Unit* target, bool allowMove) { WorldPacket data(SMSG_CLIENT_CONTROL_UPDATE, target->GetPackGUID().size()+1); data.append(target->GetPackGUID()); - data << uint8(allowMove); + data << uint8(allowMove ? 1 : 0); GetSession()->SendPacket(&data); - if (target == this) - SetMover(this); + + if (this != target) + SetViewpoint(target, allowMove); + + if (allowMove) + SetMover(target); } void Player::SetMover(Unit* target) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index f04f485fa1..cd73f38823 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -2088,7 +2088,7 @@ class Player : public Unit, public GridObject bool IsKnowHowFlyIn(uint32 mapid, uint32 zone) const; - void SetClientControl(Unit* target, uint8 allowMove); + void SetClientControl(Unit* target, bool allowMove); void SetMover(Unit* target); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index c1ec473bd8..3de062148e 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -258,6 +258,8 @@ Unit::Unit(bool isWorldObject) : m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE); _lastLiquid = NULL; + + _oldFactionId = 0; _isWalkingBeforeCharm = false; } @@ -4830,7 +4832,7 @@ GameObject* Unit::GetGameObject(uint32 spellId) const void Unit::AddGameObject(GameObject* gameObj) { - if (!gameObj || !gameObj->GetOwnerGUID() == 0) + if (!gameObj || gameObj->GetOwnerGUID() != 0) return; m_gameObj.push_back(gameObj); @@ -9219,17 +9221,17 @@ void Unit::SetOwnerGUID(uint64 owner) Unit* Unit::GetOwner() const { - if (uint64 ownerid = GetOwnerGUID()) - { - return ObjectAccessor::GetUnit(*this, ownerid); - } + if (uint64 ownerGUID = GetOwnerGUID()) + return ObjectAccessor::GetUnit(*this, ownerGUID); + return NULL; } Unit* Unit::GetCharmer() const { - if (uint64 charmerid = GetCharmerGUID()) - return ObjectAccessor::GetUnit(*this, charmerid); + if (uint64 charmerGUID = GetCharmerGUID()) + return ObjectAccessor::GetUnit(*this, charmerGUID); + return NULL; } @@ -9565,8 +9567,8 @@ void Unit::SetCharm(Unit* charm, bool apply) } if (charm->GetTypeId() == TYPEID_PLAYER - || !charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_MINION) - || charm->GetOwnerGUID() != GetGUID()) + || !charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_MINION) + || charm->GetOwnerGUID() != GetGUID()) { m_Controlled.erase(charm); } @@ -13577,9 +13579,8 @@ CharmInfo::~CharmInfo() { } void CharmInfo::RestoreState() { - if (_unit->GetTypeId() == TYPEID_UNIT) - if (Creature* creature = _unit->ToCreature()) - creature->SetReactState(_oldReactState); + if (Creature* creature = _unit->ToCreature()) + creature->SetReactState(_oldReactState); } void CharmInfo::InitPetActionBar() @@ -15633,8 +15634,8 @@ void Unit::SetFeared(bool apply) } } - if (GetTypeId() == TYPEID_PLAYER) - ToPlayer()->SetClientControl(this, !apply); + if (Player* player = ToPlayer()) + player->SetClientControl(this, !apply); } void Unit::SetConfused(bool apply) @@ -15655,8 +15656,8 @@ void Unit::SetConfused(bool apply) } } - if (GetTypeId() == TYPEID_PLAYER) - ToPlayer()->SetClientControl(this, !apply); + if (Player* player = ToPlayer()) + player->SetClientControl(this, !apply); } bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* aurApp) @@ -15702,11 +15703,13 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au CombatStop(); /// @todo CombatStop(true) may cause crash (interrupt spells) DeleteThreatList(); + Player* playerCharmer = charmer->ToPlayer(); + // Charmer stop charming - if (charmer->GetTypeId() == TYPEID_PLAYER) + if (playerCharmer) { - charmer->ToPlayer()->StopCastingCharm(); - charmer->ToPlayer()->StopCastingBindSight(); + playerCharmer->StopCastingCharm(); + playerCharmer->StopCastingBindSight(); } // Charmed stop charming @@ -15728,11 +15731,10 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au if (aurApp && aurApp->GetRemoveMode()) return false; - // Set charmed - Map* map = GetMap(); - if (!IsVehicle() || (IsVehicle() && map && !map->IsBattleground())) - setFaction(charmer->getFaction()); + _oldFactionId = getFaction(); + setFaction(charmer->getFaction()); + // Set charmed charmer->SetCharm(this, true); if (GetTypeId() == TYPEID_UNIT) @@ -15745,7 +15747,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au Player* player = ToPlayer(); if (player->isAFK()) player->ToggleAFK(); - player->SetClientControl(this, 0); + player->SetClientControl(this, false); } // charm is set by aura, and aura effect remove handler was called during apply handler execution @@ -15763,25 +15765,21 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au GetCharmInfo()->InitCharmCreateSpells(); } - if (charmer->GetTypeId() == TYPEID_PLAYER) + if (playerCharmer) { switch (type) { case CHARM_TYPE_VEHICLE: SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); - charmer->ToPlayer()->SetClientControl(this, 1); - charmer->ToPlayer()->SetMover(this); - charmer->ToPlayer()->SetViewpoint(this, true); - charmer->ToPlayer()->VehicleSpellInitialize(); + playerCharmer->SetClientControl(this, true); + playerCharmer->VehicleSpellInitialize(); break; case CHARM_TYPE_POSSESS: AddUnitState(UNIT_STATE_POSSESSED); SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); charmer->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); - charmer->ToPlayer()->SetClientControl(this, 1); - charmer->ToPlayer()->SetMover(this); - charmer->ToPlayer()->SetViewpoint(this, true); - charmer->ToPlayer()->PossessSpellInitialize(); + playerCharmer->SetClientControl(this, true); + playerCharmer->PossessSpellInitialize(); break; case CHARM_TYPE_CHARM: if (GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK) @@ -15800,7 +15798,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); // cast can't be helped } } - charmer->ToPlayer()->CharmSpellInitialize(); + playerCharmer->CharmSpellInitialize(); break; default: case CHARM_TYPE_CONVERT: @@ -15837,16 +15835,16 @@ void Unit::RemoveCharmedBy(Unit* charmer) CombatStop(); /// @todo CombatStop(true) may cause crash (interrupt spells) getHostileRefManager().deleteReferences(); DeleteThreatList(); - Map* map = GetMap(); - if (!IsVehicle() || (IsVehicle() && map && !map->IsBattleground())) - RestoreFaction(); - GetMotionMaster()->InitDefault(); - if (type == CHARM_TYPE_POSSESS) + if (_oldFactionId) { - ClearUnitState(UNIT_STATE_POSSESSED); - RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); + setFaction(_oldFactionId); + _oldFactionId = 0; } + else + RestoreFaction(); + + GetMotionMaster()->InitDefault(); if (Creature* creature = ToCreature()) { @@ -15858,8 +15856,6 @@ void Unit::RemoveCharmedBy(Unit* charmer) if (type != CHARM_TYPE_VEHICLE) LastCharmerGUID = charmer->GetGUID(); } - else - ToPlayer()->SetClientControl(this, 1); // If charmer still exists if (!charmer) @@ -15870,24 +15866,23 @@ void Unit::RemoveCharmedBy(Unit* charmer) charmer->SetCharm(this, false); - if (charmer->GetTypeId() == TYPEID_PLAYER) + Player* playerCharmer = charmer->ToPlayer(); + + if (playerCharmer) { switch (type) { case CHARM_TYPE_VEHICLE: - charmer->ToPlayer()->SetClientControl(charmer, 1); - charmer->ToPlayer()->SetViewpoint(this, false); - charmer->ToPlayer()->SetClientControl(this, 0); - if (GetTypeId() == TYPEID_PLAYER) - ToPlayer()->SetMover(this); + playerCharmer->SetClientControl(this, false); + playerCharmer->SetClientControl(charmer, true); + RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); break; case CHARM_TYPE_POSSESS: - charmer->ToPlayer()->SetClientControl(charmer, 1); - charmer->ToPlayer()->SetViewpoint(this, false); - charmer->ToPlayer()->SetClientControl(this, 0); + playerCharmer->SetClientControl(this, false); + playerCharmer->SetClientControl(charmer, true); charmer->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); - if (GetTypeId() == TYPEID_PLAYER) - ToPlayer()->SetMover(this); + RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); + ClearUnitState(UNIT_STATE_POSSESSED); break; case CHARM_TYPE_CHARM: if (GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK) @@ -15908,9 +15903,12 @@ void Unit::RemoveCharmedBy(Unit* charmer) } } + if (Player* player = ToPlayer()) + player->SetClientControl(this, true); + // a guardian should always have charminfo - if (charmer->GetTypeId() == TYPEID_PLAYER && this != charmer->GetFirstControlled()) - charmer->ToPlayer()->SendRemoveControlBar(); + if (playerCharmer && this != charmer->GetFirstControlled()) + playerCharmer->SendRemoveControlBar(); else if (GetTypeId() == TYPEID_PLAYER || (GetTypeId() == TYPEID_UNIT && !ToCreature()->IsGuardian())) DeleteCharmInfo(); } @@ -15967,8 +15965,7 @@ void Unit::RemoveVehicleKit() m_updateFlag &= ~UPDATEFLAG_VEHICLE; m_unitTypeMask &= ~UNIT_MASK_VEHICLE; - RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK); - RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_PLAYER_VEHICLE); + RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK | UNIT_NPC_FLAG_PLAYER_VEHICLE); } bool Unit::IsOnVehicle(const Unit* vehicle) const diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 212c400163..151f20d09f 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -2247,7 +2247,8 @@ class Unit : public WorldObject bool m_cleanupDone; // lock made to not add stuff after cleanup before delete bool m_duringRemoveFromWorld; // lock made to not add stuff after begining removing from world - bool _isWalkingBeforeCharm; // Are we walking before we were charmed? + uint32 _oldFactionId; ///< faction before charm + bool _isWalkingBeforeCharm; ///< Are we walking before we were charmed? time_t _lastDamagedTime; // Part of Evade mechanics }; @@ -2258,31 +2259,31 @@ namespace Trinity class PowerPctOrderPred { public: - PowerPctOrderPred(Powers power, bool ascending = true) : m_power(power), m_ascending(ascending) { } - bool operator() (const Unit* a, const Unit* b) const + PowerPctOrderPred(Powers power, bool ascending = true) : _power(power), _ascending(ascending) { } + bool operator() (Unit const* a, Unit const* b) const { - float rA = a->GetMaxPower(m_power) ? float(a->GetPower(m_power)) / float(a->GetMaxPower(m_power)) : 0.0f; - float rB = b->GetMaxPower(m_power) ? float(b->GetPower(m_power)) / float(b->GetMaxPower(m_power)) : 0.0f; - return m_ascending ? rA < rB : rA > rB; + float rA = a->GetMaxPower(_power) ? float(a->GetPower(_power)) / float(a->GetMaxPower(_power)) : 0.0f; + float rB = b->GetMaxPower(_power) ? float(b->GetPower(_power)) / float(b->GetMaxPower(_power)) : 0.0f; + return _ascending ? rA < rB : rA > rB; } private: - const Powers m_power; - const bool m_ascending; + Powers const _power; + bool const _ascending; }; // Binary predicate for sorting Units based on percent value of health class HealthPctOrderPred { public: - HealthPctOrderPred(bool ascending = true) : m_ascending(ascending) { } - bool operator() (const Unit* a, const Unit* b) const + HealthPctOrderPred(bool ascending = true) : _ascending(ascending) { } + bool operator() (Unit const* a, Unit const* b) const { float rA = a->GetMaxHealth() ? float(a->GetHealth()) / float(a->GetMaxHealth()) : 0.0f; float rB = b->GetMaxHealth() ? float(b->GetHealth()) / float(b->GetMaxHealth()) : 0.0f; - return m_ascending ? rA < rB : rA > rB; + return _ascending ? rA < rB : rA > rB; } private: - const bool m_ascending; + bool const _ascending; }; } #endif From c1a468365b6a312c5efdf30a63c5cd2b1a2d35ef Mon Sep 17 00:00:00 2001 From: Discover- Date: Fri, 17 Jan 2014 08:17:09 +0100 Subject: [PATCH 09/12] Core/Misc: When a player changes its faction its only removed from all its arena teams if cross-faction interaction is turned off. --- src/server/game/Handlers/CharacterHandler.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 6d79091963..94e9306b29 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -1919,6 +1919,8 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) if (result) if (Guild* guild = sGuildMgr->GetGuildById((result->Fetch()[0]).GetUInt32())) guild->DeleteMember(MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER), false, false, true); + + Player::LeaveAllArenaTeams(guid); } if (!HasPermission(rbac::RBAC_PERM_TWO_SIDE_ADD_FRIEND)) @@ -1931,12 +1933,8 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData) stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_FRIEND); stmt->setUInt32(0, lowGuid); trans->Append(stmt); - } - // Leave Arena Teams - Player::LeaveAllArenaTeams(guid); - // Reset homebind and position stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_HOMEBIND); stmt->setUInt32(0, lowGuid); From 101cad1f2872a87be925b74b9d17760381bb9808 Mon Sep 17 00:00:00 2001 From: Zabustak Date: Thu, 2 Jan 2014 22:34:04 +0100 Subject: [PATCH 10/12] Show Kick, Mute and Ban in world --- .../world/2014_01_02_00_trinity_string.sql | 9 ++++++ src/server/game/Miscellaneous/Language.h | 12 +++++++ src/server/game/World/World.cpp | 2 ++ src/server/game/World/World.h | 2 ++ src/server/scripts/Commands/cs_ban.cpp | 30 ++++++++++++++--- src/server/scripts/Commands/cs_misc.cpp | 32 ++++++++++++++----- src/server/worldserver/worldserver.conf.dist | 17 ++++++++++ 7 files changed, 91 insertions(+), 13 deletions(-) create mode 100644 sql/updates/world/2014_01_02_00_trinity_string.sql diff --git a/sql/updates/world/2014_01_02_00_trinity_string.sql b/sql/updates/world/2014_01_02_00_trinity_string.sql new file mode 100644 index 0000000000..ae9943de17 --- /dev/null +++ b/sql/updates/world/2014_01_02_00_trinity_string.sql @@ -0,0 +1,9 @@ + +DELETE FROM trinity_string where entry in (11002, 11003, 11004, 11005, 11006, 11007); +INSERT INTO `trinity_string` VALUES +('11002', 'Server: %s has kicked %s, reason: %s', '', '', '', '', '', '', '', ''), +('11003', 'Server: %s has muted %s for %u minutes, reason: %s', '', '', '', '', '', '', '', ''), +('11004', 'Server: %s has banned character %s for %s, reason: %s', '', '', '', '', '', '', '', ''), +('11005', 'Server: %s has banned character %s permanetly, reason: %s', '', '', '', '', '', '', '', ''), +('11006', 'Server: %s has banned %s for %s, reason: %s', '', '', '', '', '', '', '', ''), +('11007', 'Server: %s has banned %s permanetly, reason: %s', '', '', '', '', '', '', '', ''); diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h index 6f380d42fd..3102e2c685 100644 --- a/src/server/game/Miscellaneous/Language.h +++ b/src/server/game/Miscellaneous/Language.h @@ -1215,6 +1215,18 @@ enum TrinityStrings LANG_AUTO_BROADCAST = 11000, LANG_INVALID_REALMID = 11001, + // Show Kick in world + LANG_COMMAND_KICKMESSAGE_WORLD = 11002, + + // Show Mute in world + LANG_COMMAND_MUTEMESSAGE_WORLD = 11003, + + // Show Ban in world + LANG_BAN_CHARACTER_YOUBANNEDMESSAGE_WORLD = 11004, + LANG_BAN_CHARACTER_YOUPERMBANNEDMESSAGE_WORLD = 11005, + LANG_BAN_ACCOUNT_YOUBANNEDMESSAGE_WORLD = 11006, + LANG_BAN_ACCOUNT_YOUPERMBANNEDMESSAGE_WORLD = 11007, + // NOT RESERVED IDS 12000-1999999999 // `db_script_string` table index 2000000000-2000009999 (MIN_DB_SCRIPT_STRING_ID-MAX_DB_SCRIPT_STRING_ID) // For other tables maybe 2000010000-2147483647 (max index) diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 3658130db3..d5bd097492 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -1173,6 +1173,8 @@ void World::LoadConfigSettings(bool reload) m_bool_configs[CONFIG_NO_RESET_TALENT_COST] = sConfigMgr->GetBoolDefault("NoResetTalentsCost", false); m_bool_configs[CONFIG_SHOW_KICK_IN_WORLD] = sConfigMgr->GetBoolDefault("ShowKickInWorld", false); + m_bool_configs[CONFIG_SHOW_MUTE_IN_WORLD] = sConfigMgr->GetBoolDefault("ShowMuteInWorld", false); + m_bool_configs[CONFIG_SHOW_BAN_IN_WORLD] = sConfigMgr->GetBoolDefault("ShowBanInWorld", false); m_int_configs[CONFIG_INTERVAL_LOG_UPDATE] = sConfigMgr->GetIntDefault("RecordUpdateTimeDiffInterval", 60000); m_int_configs[CONFIG_MIN_LOG_UPDATE] = sConfigMgr->GetIntDefault("MinRecordUpdateTimeDiff", 100); m_int_configs[CONFIG_NUMTHREADS] = sConfigMgr->GetIntDefault("MapUpdate.Threads", 1); diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index 080c9d9006..8c8aebf97d 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -137,6 +137,8 @@ enum WorldBoolConfigs CONFIG_PVP_TOKEN_ENABLE, CONFIG_NO_RESET_TALENT_COST, CONFIG_SHOW_KICK_IN_WORLD, + CONFIG_SHOW_MUTE_IN_WORLD, + CONFIG_SHOW_BAN_IN_WORLD, CONFIG_CHATLOG_CHANNEL, CONFIG_CHATLOG_WHISPER, CONFIG_CHATLOG_SYSCHAN, diff --git a/src/server/scripts/Commands/cs_ban.cpp b/src/server/scripts/Commands/cs_ban.cpp index c32a03f9bd..b1a3dd4bca 100644 --- a/src/server/scripts/Commands/cs_ban.cpp +++ b/src/server/scripts/Commands/cs_ban.cpp @@ -114,9 +114,19 @@ public: case BAN_SUCCESS: { if (atoi(durationStr) > 0) - handler->PSendSysMessage(LANG_BAN_YOUBANNED, name.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr); + { + if (sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD)) + sWorld->SendWorldText(LANG_BAN_CHARACTER_YOUBANNEDMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), name.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr); + else + handler->PSendSysMessage(LANG_BAN_YOUBANNED, name.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr); + } else - handler->PSendSysMessage(LANG_BAN_YOUPERMBANNED, name.c_str(), reasonStr); + { + if (sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD)) + sWorld->SendWorldText(LANG_BAN_CHARACTER_YOUPERMBANNEDMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), name.c_str(), reasonStr); + else + handler->PSendSysMessage(LANG_BAN_YOUPERMBANNED, name.c_str(), reasonStr); + } break; } case BAN_NOTFOUND: @@ -189,9 +199,19 @@ public: { case BAN_SUCCESS: if (atoi(durationStr) > 0) - handler->PSendSysMessage(LANG_BAN_YOUBANNED, nameOrIP.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr); - else - handler->PSendSysMessage(LANG_BAN_YOUPERMBANNED, nameOrIP.c_str(), reasonStr); + { + if (sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD)) + sWorld->SendWorldText(LANG_BAN_ACCOUNT_YOUBANNEDMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), nameOrIP.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr); + else + handler->PSendSysMessage(LANG_BAN_YOUBANNED, nameOrIP.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr); + } + else + { + if (sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD)) + sWorld->SendWorldText(LANG_BAN_ACCOUNT_YOUPERMBANNEDMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), nameOrIP.c_str(), reasonStr); + else + handler->PSendSysMessage(LANG_BAN_YOUPERMBANNED, nameOrIP.c_str(), reasonStr); + } break; case BAN_SYNTAX_ERROR: return false; diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 796416b403..1b8f50b5ea 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -808,12 +808,16 @@ public: if (handler->HasLowerSecurity(target, 0)) return false; - if (sWorld->getBoolConfig(CONFIG_SHOW_KICK_IN_WORLD)) - sWorld->SendWorldText(LANG_COMMAND_KICKMESSAGE, playerName.c_str()); - else - handler->PSendSysMessage(LANG_COMMAND_KICKMESSAGE, playerName.c_str()); + char const* kickReason = strtok(NULL, "\r"); + std::string kickReasonStr = "No reason"; + if (kickReason != NULL) + kickReasonStr = kickReason; - target->GetSession()->KickPlayer(); + if (sWorld->getBoolConfig(CONFIG_SHOW_KICK_IN_WORLD)) + sWorld->SendWorldText(LANG_COMMAND_KICKMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), playerName.c_str(), kickReasonStr.c_str()); + else + handler->PSendSysMessage(LANG_COMMAND_KICKMESSAGE, playerName.c_str()); + target->GetSession()->KickPlayer(); return true; } @@ -1835,7 +1839,17 @@ public: int64 muteTime = time(NULL) + notSpeakTime * MINUTE; target->GetSession()->m_muteTime = muteTime; stmt->setInt64(0, muteTime); - ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notSpeakTime, muteBy.c_str(), muteReasonStr.c_str()); + std::string nameLink = handler->playerLink(targetName); + + if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD)) + { + sWorld->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), nameLink.c_str(), notSpeakTime, muteReasonStr.c_str()); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notSpeakTime, muteBy.c_str(), muteReasonStr.c_str()); + } + else + { + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notSpeakTime, muteBy.c_str(), muteReasonStr.c_str()); + } } else { @@ -1850,8 +1864,10 @@ public: LoginDatabase.Execute(stmt); std::string nameLink = handler->playerLink(targetName); - handler->PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, nameLink.c_str(), notSpeakTime, muteReasonStr.c_str()); - + if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD) && !target) + sWorld->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, handler->GetSession()->GetPlayerName().c_str(), nameLink.c_str(), notSpeakTime, muteReasonStr.c_str()); + else + handler->PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, nameLink.c_str(), notSpeakTime, muteReasonStr.c_str()); return true; } diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist index 1e6d7d92dd..2a47c8f989 100644 --- a/src/server/worldserver/worldserver.conf.dist +++ b/src/server/worldserver/worldserver.conf.dist @@ -2560,6 +2560,23 @@ Guild.AllowMultipleGuildMaster = 0 ShowKickInWorld = 0 +# ShowMuteInWorld +# Description: Determines whether a message is broadcasted to the entire server when a +# player gets muted. +# Default: 0 - (Disabled) +# 1 - (Enabled) + +ShowMuteInWorld = 0 + +# +# ShowBanInWorld +# Description: Determines whether a message is broadcasted to the entire server when a +# player gets banned. +# Default: 0 - (Disabled) +# 1 - (Enabled) + +ShowBanInWorld = 0 + # # RecordUpdateTimeDiffInterval # Description: Time (in milliseconds) update time diff is written to the log file. From ea740deb263afcdd3105c05ed304ad7818bdf434 Mon Sep 17 00:00:00 2001 From: Aokromes Date: Fri, 17 Jan 2014 12:29:48 +0100 Subject: [PATCH 11/12] Rename 2014_01_02_00_trinity_string.sql to 2014_01_17_00_trinity_string.sql --- ...02_00_trinity_string.sql => 2014_01_17_00_trinity_string.sql} | 1 - 1 file changed, 1 deletion(-) rename sql/updates/world/{2014_01_02_00_trinity_string.sql => 2014_01_17_00_trinity_string.sql} (99%) diff --git a/sql/updates/world/2014_01_02_00_trinity_string.sql b/sql/updates/world/2014_01_17_00_trinity_string.sql similarity index 99% rename from sql/updates/world/2014_01_02_00_trinity_string.sql rename to sql/updates/world/2014_01_17_00_trinity_string.sql index ae9943de17..698af0f56c 100644 --- a/sql/updates/world/2014_01_02_00_trinity_string.sql +++ b/sql/updates/world/2014_01_17_00_trinity_string.sql @@ -1,4 +1,3 @@ - DELETE FROM trinity_string where entry in (11002, 11003, 11004, 11005, 11006, 11007); INSERT INTO `trinity_string` VALUES ('11002', 'Server: %s has kicked %s, reason: %s', '', '', '', '', '', '', '', ''), From ebfdeb067f4576d9e9da5c392e43d6a3e6a521ab Mon Sep 17 00:00:00 2001 From: Discover- Date: Fri, 17 Jan 2014 17:54:52 +0100 Subject: [PATCH 12/12] Core/Spells: Rename Spell::EffectSummonDeadPet with Spell::EffectResurrectPet and get rid of two TODO's that are already done. --- src/server/game/Spells/Spell.h | 2 +- src/server/game/Spells/SpellEffects.cpp | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 5653bc1194..72bc195aec 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -301,7 +301,7 @@ class Spell void EffectKnockBack(SpellEffIndex effIndex); void EffectPullTowards(SpellEffIndex effIndex); void EffectDispelMechanic(SpellEffIndex effIndex); - void EffectSummonDeadPet(SpellEffIndex effIndex); + void EffectResurrectPet(SpellEffIndex effIndex); void EffectDestroyAllTotems(SpellEffIndex effIndex); void EffectDurabilityDamage(SpellEffIndex effIndex); void EffectSkill(SpellEffIndex effIndex); diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index b8e5b3ff74..4e57c538c4 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -175,7 +175,7 @@ pEffect SpellEffects[TOTAL_SPELL_EFFECTS]= &Spell::EffectSummonObject, //106 SPELL_EFFECT_SUMMON_OBJECT_SLOT3 &Spell::EffectSummonObject, //107 SPELL_EFFECT_SUMMON_OBJECT_SLOT4 &Spell::EffectDispelMechanic, //108 SPELL_EFFECT_DISPEL_MECHANIC - &Spell::EffectSummonDeadPet, //109 SPELL_EFFECT_SUMMON_DEAD_PET + &Spell::EffectResurrectPet, //109 SPELL_EFFECT_RESURRECT_PET &Spell::EffectDestroyAllTotems, //110 SPELL_EFFECT_DESTROY_ALL_TOTEMS &Spell::EffectDurabilityDamage, //111 SPELL_EFFECT_DURABILITY_DAMAGE &Spell::EffectUnused, //112 SPELL_EFFECT_112 @@ -5049,7 +5049,7 @@ void Spell::EffectDispelMechanic(SpellEffIndex effIndex) } } -void Spell::EffectSummonDeadPet(SpellEffIndex /*effIndex*/) +void Spell::EffectResurrectPet(SpellEffIndex /*effIndex*/) { if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT) return; @@ -5061,9 +5061,9 @@ void Spell::EffectSummonDeadPet(SpellEffIndex /*effIndex*/) if (!player) return; - // Maybe player dismissed dead pet or pet despawned? bool hadPet = true; + if (!player->GetPet()) { // Position passed to SummonPet is irrelevant with current implementation, @@ -5072,13 +5072,8 @@ void Spell::EffectSummonDeadPet(SpellEffIndex /*effIndex*/) hadPet = false; } - // TODO: Better to fail Hunter's "Revive Pet" at cast instead of here when casting ends Pet* pet = player->GetPet(); // Attempt to get current pet - if (!pet) - return; - - // TODO: Better to fail Hunter's "Revive Pet" at cast instead of here when casting ends - if (pet->IsAlive()) + if (!pet || pet->IsAlive()) return; // If player did have a pet before reviving, teleport it