diff --git a/cmake/SetDefinitions.cmake b/cmake/SetDefinitions.cmake
index 91b77666..dfe31481 100644
--- a/cmake/SetDefinitions.cmake
+++ b/cmake/SetDefinitions.cmake
@@ -115,7 +115,7 @@ elseif(UNIX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SSE_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SSE_FLAGS}")
endif()
- add_definitions(-DHAVE_SSE2 -D__SSE2__)
+ add_definitions(-DHAVE_SSE2)
if(NOT DEBUG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --no-warnings")
diff --git a/src/game/BattleGround/BattleGround.cpp b/src/game/BattleGround/BattleGround.cpp
index 18cea5cb..4719ad98 100644
--- a/src/game/BattleGround/BattleGround.cpp
+++ b/src/game/BattleGround/BattleGround.cpp
@@ -350,14 +350,7 @@ void BattleGround::Update(uint32 diff)
}
else if (m_PrematureCountDownTimer < diff)
{
- // time's up!
- Team winner = TEAM_NONE;
- if (GetPlayersCountByTeam(ALLIANCE) >= GetMinPlayersPerTeam())
- { winner = ALLIANCE; }
- else if (GetPlayersCountByTeam(HORDE) >= GetMinPlayersPerTeam())
- { winner = HORDE; }
-
- EndBattleGround(winner);
+ EndBattleGround(GetPrematureWinner());
m_PrematureCountDown = false;
}
else if (!sBattleGroundMgr.isTesting())
@@ -1233,9 +1226,10 @@ void BattleGround::AddOrSetPlayerToCorrectBgGroup(Player* plr, ObjectGuid plr_gu
/// This method should be called when player logs into running battleground
///
/// The player.
-/// The plr_guid.
-void BattleGround::EventPlayerLoggedIn(Player* player, ObjectGuid plr_guid)
+void BattleGround::EventPlayerLoggedIn(Player* player)
{
+ ObjectGuid plr_guid = player->GetObjectGuid();
+
// player is correct pointer
for (OfflineQueue::iterator itr = m_OfflineQueue.begin(); itr != m_OfflineQueue.end(); ++itr)
{
@@ -1808,3 +1802,22 @@ WorldSafeLocsEntry const* BattleGround::GetClosestGraveYard(Player* player)
{
return sObjectMgr.GetClosestGraveYard(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetTeam());
}
+
+///
+/// Gets the winner in case of premature finish of the BG.
+/// Different BG's may have different criteria for choosing the winner besides simple player accounting
+///
+/// The winner team
+Team BattleGround::GetPrematureWinner()
+{
+ uint32 hPlayers = GetPlayersCountByTeam(HORDE);
+ uint32 aPlayers = GetPlayersCountByTeam(ALLIANCE);
+
+ if (aPlayers > hPlayers)
+ { return ALLIANCE; }
+
+ if (hPlayers > aPlayers)
+ { return HORDE; }
+
+ return TEAM_NONE;
+}
diff --git a/src/game/BattleGround/BattleGround.h b/src/game/BattleGround/BattleGround.h
index c6bd9580..c0fb4583 100644
--- a/src/game/BattleGround/BattleGround.h
+++ b/src/game/BattleGround/BattleGround.h
@@ -467,6 +467,12 @@ class BattleGround
* @return Team
*/
Team GetWinner() const { return m_Winner; }
+ /**
+ * @brief
+ *
+ * @return Team
+ */
+ virtual Team GetPrematureWinner();
/**
* @brief
*
@@ -1040,9 +1046,8 @@ class BattleGround
* @brief
*
* @param player
- * @param plr_guid
*/
- void EventPlayerLoggedIn(Player* player, ObjectGuid plr_guid);
+ void EventPlayerLoggedIn(Player* player);
/**
* @brief
*
diff --git a/src/game/BattleGround/BattleGroundAB.cpp b/src/game/BattleGround/BattleGroundAB.cpp
index ada14f81..57590c87 100644
--- a/src/game/BattleGround/BattleGroundAB.cpp
+++ b/src/game/BattleGround/BattleGroundAB.cpp
@@ -593,3 +593,21 @@ void BattleGroundAB::UpdatePlayerScore(Player* source, uint32 type, uint32 value
break;
}
}
+
+///
+/// Gets the premature finish winning team.
+///
+Team BattleGroundAB::GetPrematureWinner()
+{
+ int32 hordeScore = m_TeamScores[TEAM_INDEX_HORDE];
+ int32 allianceScore = m_TeamScores[TEAM_INDEX_ALLIANCE];
+
+ if (hordeScore > allianceScore)
+ { return HORDE; }
+
+ if (allianceScore > hordeScore)
+ { return ALLIANCE; }
+
+ // If the values are equal, fall back to number of players on each team
+ return BattleGround::GetPrematureWinner();
+}
diff --git a/src/game/BattleGround/BattleGroundAB.h b/src/game/BattleGround/BattleGroundAB.h
index f6428f13..1aa37547 100644
--- a/src/game/BattleGround/BattleGroundAB.h
+++ b/src/game/BattleGround/BattleGroundAB.h
@@ -302,6 +302,13 @@ class BattleGroundAB : public BattleGround
*/
virtual void EventPlayerClickedOnFlag(Player* source, GameObject* target_obj) override;
+ /* Premature finish */
+ /**
+ * @brief
+ *
+ */
+ virtual Team GetPrematureWinner() override;
+
private:
/* Gameobject spawning/despawning */
/**
diff --git a/src/game/BattleGround/BattleGroundAV.cpp b/src/game/BattleGround/BattleGroundAV.cpp
index b0433707..cad189df 100644
--- a/src/game/BattleGround/BattleGroundAV.cpp
+++ b/src/game/BattleGround/BattleGroundAV.cpp
@@ -821,3 +821,17 @@ void BattleGroundAV::Reset()
InitNode(BG_AV_NODES_SNOWFALL_GRAVE, BG_AV_TEAM_NEUTRAL, false); // give snowfall neutral owner
}
+
+Team BattleGroundAV::GetPrematureWinner()
+{
+ int32 hordeScore = m_TeamScores[TEAM_INDEX_HORDE];
+ int32 allianceScore = m_TeamScores[TEAM_INDEX_ALLIANCE];
+
+ if (hordeScore > allianceScore)
+ { return HORDE; }
+ if (allianceScore > hordeScore)
+ { return ALLIANCE; }
+
+ // If the values are equal, fall back to number of players on each team
+ return BattleGround::GetPrematureWinner();
+}
diff --git a/src/game/BattleGround/BattleGroundAV.h b/src/game/BattleGround/BattleGroundAV.h
index ce8b454a..778a7cea 100644
--- a/src/game/BattleGround/BattleGroundAV.h
+++ b/src/game/BattleGround/BattleGroundAV.h
@@ -505,6 +505,13 @@ class BattleGroundAV : public BattleGround
*/
virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* plr) override;
+ /**
+ * @brief
+ *
+ * @return Team
+ */
+ virtual Team GetPrematureWinner() override;
+
/**
* @brief
*
diff --git a/src/game/BattleGround/BattleGroundWS.cpp b/src/game/BattleGround/BattleGroundWS.cpp
index 209a9783..052a25bd 100644
--- a/src/game/BattleGround/BattleGroundWS.cpp
+++ b/src/game/BattleGround/BattleGroundWS.cpp
@@ -622,3 +622,17 @@ void BattleGroundWS::FillInitialWorldStates(WorldPacket& data, uint32& count)
else
{ FillInitialWorldState(data, count, BG_WS_FLAG_STATE_ALLIANCE, 1); }
}
+
+Team BattleGroundWS::GetPrematureWinner()
+{
+ int32 hordeScore = m_TeamScores[TEAM_INDEX_HORDE];
+ int32 allianceScore = m_TeamScores[TEAM_INDEX_ALLIANCE];
+
+ if (hordeScore > allianceScore)
+ { return HORDE; }
+ if (allianceScore > hordeScore)
+ { return ALLIANCE; }
+
+ // If the values are equal, fall back to number of players on each team
+ return BattleGround::GetPrematureWinner();
+}
diff --git a/src/game/BattleGround/BattleGroundWS.h b/src/game/BattleGround/BattleGroundWS.h
index 0f2a3faa..91047182 100644
--- a/src/game/BattleGround/BattleGroundWS.h
+++ b/src/game/BattleGround/BattleGroundWS.h
@@ -351,6 +351,11 @@ class BattleGroundWS : public BattleGround
* @param count
*/
virtual void FillInitialWorldStates(WorldPacket& data, uint32& count) override;
+ /**
+ * @brief
+ *
+ */
+ virtual Team GetPrematureWinner() override;
private:
ObjectGuid m_flagCarrierAlliance; /**< TODO */
diff --git a/src/game/Object/Player.cpp b/src/game/Object/Player.cpp
index 7b1fba63..df25e174 100644
--- a/src/game/Object/Player.cpp
+++ b/src/game/Object/Player.cpp
@@ -13512,18 +13512,18 @@ void Player::_LoadIntoDataField(const char* data, uint32 startOffset, uint32 cou
bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder)
{
- // 0 1 2 3 4 5 6 7 8 9 10 11
- // SELECT guid, account, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags,"
+ // 0 1 2 3 4 5 6 7 8 9 10 11
+ // SELECT guid, account, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags,
// 12 13 14 15 16 17 18 19 20 21 22 23 24
- //"position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost,"
+ // position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost,
// 25 26 27 28 29 30 31 32 33 34 35 36 37
- //"resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path,
+ // resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path,
// 38 39 40 41 42
- //"honor_highest_rank, honor_standing, stored_honor_rating, stored_dishonorablekills, stored_honorable_kills,"
+ // honor_highest_rank, honor_standing, stored_honor_rating, stored_dishonorablekills, stored_honorable_kills,
// 43 44
- //"watchedFaction, drunk,"
+ // watchedFaction, drunk,
// 45 46 47 48 49 50 51 52 53 54
- //"health, power1, power2, power3, power4, power5, exploredZones, equipmentCache, ammoId, actionBars FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid));
+ // health, power1, power2, power3, power4, power5, exploredZones, equipmentCache, ammoId, actionBars FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid));
QueryResult* result = holder->GetResult(PLAYER_LOGIN_QUERY_LOADFROM);
if (!result)
@@ -13679,7 +13679,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder)
m_bgData.bgTypeID = currentBg->GetTypeID(); // bg data not marked as modified
// join player to battleground group
- currentBg->EventPlayerLoggedIn(this, GetObjectGuid());
+ currentBg->EventPlayerLoggedIn(this);
currentBg->AddOrSetPlayerToCorrectBgGroup(this, GetObjectGuid(), m_bgData.bgTeam);
SetInviteForBattleGroundQueueType(bgQueueTypeId, currentBg->GetInstanceID());