From aacb838e605d128a28429ab746ce005f1d38ff69 Mon Sep 17 00:00:00 2001 From: Schmoozerd Date: Fri, 10 Aug 2012 22:55:35 +0200 Subject: [PATCH] [0063] Fix a bug with SCRIPT_COMMAND_KILL_CREDIT This bug can happen if a (group) kill credit is provided without involved creature. Thanks to Atari for pointing! --- src/game/Player.cpp | 4 +++- src/game/ScriptMgr.cpp | 7 ++++++- src/shared/revision_nr.h | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index d02392b0c..ee74d462f 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -21229,6 +21229,8 @@ void Player::RewardSinglePlayerAtKill(Unit* pVictim) void Player::RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewardSource) { + MANGOS_ASSERT((!GetGroup() || pRewardSource) && "Player::RewardPlayerAndGroupAtEvent called for Group-Case but no source for range searching provided"); + ObjectGuid creature_guid = pRewardSource && pRewardSource->GetTypeId() == TYPEID_UNIT ? pRewardSource->GetObjectGuid() : ObjectGuid(); // prepare data for near group iteration @@ -21241,7 +21243,7 @@ void Player::RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewar continue; if (!pGroupGuy->IsAtGroupRewardDistance(pRewardSource)) - continue; // member (alive or dead) or his corpse at req. distance + continue; // member (alive or dead) or his corpse at req. distance // quest objectives updated only for alive group member or dead but with not released body if (pGroupGuy->isAlive() || !pGroupGuy->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) diff --git a/src/game/ScriptMgr.cpp b/src/game/ScriptMgr.cpp index ab8b22ee1..e3214b1e4 100644 --- a/src/game/ScriptMgr.cpp +++ b/src/game/ScriptMgr.cpp @@ -1254,7 +1254,12 @@ void ScriptAction::HandleScriptStep() } if (m_script->killCredit.isGroupCredit) - pPlayer->RewardPlayerAndGroupAtEvent(creatureEntry, pRewardSource); + { + WorldObject* pSearcher = pRewardSource ? pRewardSource : (pSource ? pSource : pTarget); + if (pSearcher != pRewardSource) + sLog.outDebug(" DB-SCRIPTS: Process table `%s` id %u, SCRIPT_COMMAND_KILL_CREDIT called for groupCredit without creature as searcher, script might need adjustment.", m_table, m_script->id); + pPlayer->RewardPlayerAndGroupAtEvent(creatureEntry, pSearcher); + } else pPlayer->KilledMonsterCredit(creatureEntry, pRewardSource ? pRewardSource->GetObjectGuid() : ObjectGuid()); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 8bf9ce41c..f3da71d91 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "0062" + #define REVISION_NR "0063" #endif // __REVISION_NR_H__