From bd48d0ebe71bd9c1d64ba86d52ed6f58a7336fa7 Mon Sep 17 00:00:00 2001 From: zorix Date: Fri, 20 Sep 2013 16:58:27 +0200 Subject: Core/Battleground: Add missing NULL pointer check for player if is not in world Core/Spell: Add absolute value for delta because can be nevgative Close #10846 --- src/server/game/Battlegrounds/BattlegroundMgr.cpp | 12 +++++++++++- src/server/game/Spells/SpellInfo.cpp | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index f6a3148edc3..8accb93f0f0 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -376,7 +376,9 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg) } } - data->WriteBits(bg->GetPlayerScoresSize(), 21); + size_t count_pos = data->bitwpos(); + data->WriteBits(0, 21); + uint32 count = 0; for (Battleground::BattlegroundScoreMap::const_iterator itr = bg->GetPlayerScoresBegin(); itr != bg->GetPlayerScoresEnd(); ++itr) { if (!bg->IsPlayerInBattleground(itr->first)) @@ -386,6 +388,12 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg) } Player* player = ObjectAccessor::FindPlayer(itr->first); + if (!player) + { + TC_LOG_ERROR(LOG_FILTER_BATTLEGROUND, "Player " UI64FMTD " has scoreboard entry for battleground %u but is not in world!", itr->first, bg->GetTypeID(true)); + continue; + } + ObjectGuid playerGUID = itr->first; BattlegroundScore* score = itr->second; @@ -539,8 +547,10 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg) // if (unk 4) << uint32() unk buff.WriteByteSeq(playerGUID[7]); buff.WriteByteSeq(playerGUID[2]); + ++count; } + data->PutBits(count_pos, count, 21); data->WriteBit(bg->GetStatus() == STATUS_WAIT_LEAVE); // If Ended if (isRated) // arena diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index b74ed66a953..0efe252f597 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -452,7 +452,7 @@ int32 SpellEffectInfo::CalcValue(Unit const* caster, int32 const* bp, Unit const float preciseBasePoints = ScalingMultiplier * multiplier; if (DeltaScalingMultiplier) { - float delta = DeltaScalingMultiplier * ScalingMultiplier * multiplier * 0.5f; + float delta = fabs(DeltaScalingMultiplier * ScalingMultiplier * multiplier * 0.5f); preciseBasePoints += frand(-delta, delta); } -- cgit v1.2.3 From 7c721506a9478924c6c98f0fc35fb7c4eb97ac32 Mon Sep 17 00:00:00 2001 From: zorix Date: Wed, 22 Jan 2014 00:41:23 +0100 Subject: Core/Battleground: Offline players will displayed on scoreboard --- src/server/game/Battlegrounds/Battleground.cpp | 2 ++ src/server/game/Battlegrounds/Battleground.h | 1 + src/server/game/Battlegrounds/BattlegroundMgr.cpp | 26 +++++++++++++++++------ 3 files changed, 23 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index e6012313c68..cbeeddb985b 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -1190,10 +1190,12 @@ void Battleground::AddPlayer(Player* player) uint64 guid = player->GetGUID(); uint32 team = player->GetBGTeam(); + int32 primaryTree = player->GetPrimaryTalentTree(player->GetActiveSpec()); BattlegroundPlayer bp; bp.OfflineRemoveTime = 0; bp.Team = team; + bp.PrimaryTree = primaryTree; // Add to list/maps m_Players[guid] = bp; diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h index 7f166b92f80..64b1d80e095 100644 --- a/src/server/game/Battlegrounds/Battleground.h +++ b/src/server/game/Battlegrounds/Battleground.h @@ -160,6 +160,7 @@ struct BattlegroundPlayer { time_t OfflineRemoveTime; // for tracking and removing offline players from queue after 5 minutes uint32 Team; // Player's team + int32 PrimaryTree; // Player's primary tree }; struct BattlegroundObjectInfo diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index 8accb93f0f0..ab7cab504c8 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -379,6 +379,7 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg) size_t count_pos = data->bitwpos(); data->WriteBits(0, 21); uint32 count = 0; + BattlegroundPlayerMap const& bgPlayers = bg->GetPlayers(); for (Battleground::BattlegroundScoreMap::const_iterator itr = bg->GetPlayerScoresBegin(); itr != bg->GetPlayerScoresEnd(); ++itr) { if (!bg->IsPlayerInBattleground(itr->first)) @@ -387,11 +388,24 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg) continue; } - Player* player = ObjectAccessor::FindPlayer(itr->first); - if (!player) + uint32 team; + int32 primaryTree; + if (Player* player = ObjectAccessor::FindPlayer(itr->first)) { - TC_LOG_ERROR(LOG_FILTER_BATTLEGROUND, "Player " UI64FMTD " has scoreboard entry for battleground %u but is not in world!", itr->first, bg->GetTypeID(true)); - continue; + team = player->GetBGTeam(); + primaryTree = player->GetPrimaryTalentTree(player->GetActiveSpec()); + } + else + { + BattlegroundPlayerMap::const_iterator itr2 = bgPlayers.find(itr->first); + if (itr2 == bgPlayers.end()) + { + TC_LOG_ERROR(LOG_FILTER_BATTLEGROUND, "Player " UI64FMTD " has scoreboard entry for battleground %u but do not have battleground data!", itr->first, bg->GetTypeID(true)); + continue; + } + + team = itr2->second.Team; + primaryTree = itr2->second.PrimaryTree; } ObjectGuid playerGUID = itr->first; @@ -409,7 +423,7 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg) data->WriteBit(playerGUID[5]); data->WriteBit(playerGUID[1]); data->WriteBit(playerGUID[6]); - data->WriteBit(player->GetBGTeam() == HORDE ? 0 : 1); + data->WriteBit(team == HORDE ? 0 : 1); data->WriteBit(playerGUID[7]); buff << uint32(score->HealingDone); // healing done @@ -431,7 +445,7 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg) buff.WriteByteSeq(playerGUID[1]); buff.WriteByteSeq(playerGUID[6]); - buff << int32(player->GetPrimaryTalentTree(player->GetActiveSpec())); + buff << int32(primaryTree); switch (bg->GetTypeID(true)) // Custom values { -- cgit v1.2.3