Various external fixes - part 2

- ported fixes from cmangos repositories
This commit is contained in:
H0zen 2016-02-17 19:39:14 +02:00
parent 50e913d252
commit 95991c8a81
10 changed files with 104 additions and 21 deletions

View File

@ -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")

View File

@ -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
/// </summary>
/// <param name="player">The player.</param>
/// <param name="plr_guid">The plr_guid.</param>
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());
}
/// <summary>
/// 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
/// </summary>
/// <returns>The winner team</returns>
Team BattleGround::GetPrematureWinner()
{
uint32 hPlayers = GetPlayersCountByTeam(HORDE);
uint32 aPlayers = GetPlayersCountByTeam(ALLIANCE);
if (aPlayers > hPlayers)
{ return ALLIANCE; }
if (hPlayers > aPlayers)
{ return HORDE; }
return TEAM_NONE;
}

View File

@ -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
*

View File

@ -593,3 +593,21 @@ void BattleGroundAB::UpdatePlayerScore(Player* source, uint32 type, uint32 value
break;
}
}
/// <summary>
/// Gets the premature finish winning team.
/// </summary>
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();
}

View File

@ -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 */
/**

View File

@ -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();
}

View File

@ -505,6 +505,13 @@ class BattleGroundAV : public BattleGround
*/
virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* plr) override;
/**
* @brief
*
* @return Team
*/
virtual Team GetPrematureWinner() override;
/**
* @brief
*

View File

@ -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();
}

View File

@ -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 */

View File

@ -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());