mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
[10880] Avoid constant re-save BG entry data at each save for player at bg/arena.
This commit is contained in:
parent
f7eb7a434e
commit
5b79ef7a5d
3 changed files with 21 additions and 11 deletions
|
|
@ -15301,7 +15301,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder )
|
|||
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(currentBg->GetTypeID(), currentBg->GetArenaType());
|
||||
AddBattleGroundQueueId(bgQueueTypeId);
|
||||
|
||||
m_bgData.bgTypeID = currentBg->GetTypeID();
|
||||
m_bgData.bgTypeID = currentBg->GetTypeID(); // bg data not marked as modified
|
||||
|
||||
//join player to battleground group
|
||||
currentBg->EventPlayerLoggedIn(this, GetObjectGuid());
|
||||
|
|
@ -15321,7 +15321,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder )
|
|||
Relocate(_loc.coord_x, _loc.coord_y, _loc.coord_z, _loc.orientation);
|
||||
|
||||
// We are not in BG anymore
|
||||
m_bgData.bgInstanceID = 0;
|
||||
SetBattleGroundId(0, BATTLEGROUND_TYPE_NONE);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -19301,6 +19301,7 @@ void Player::SetBattleGroundEntryPoint()
|
|||
|
||||
// On taxi we don't need check for dungeon
|
||||
m_bgData.joinPos = WorldLocation(GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
|
||||
m_bgData.m_needSave = true;
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
|
@ -19323,6 +19324,7 @@ void Player::SetBattleGroundEntryPoint()
|
|||
if (const WorldSafeLocsEntry* entry = sObjectMgr.GetClosestGraveYard(GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId(), GetTeam()))
|
||||
{
|
||||
m_bgData.joinPos = WorldLocation(entry->map_id, entry->x, entry->y, entry->z, 0.0f);
|
||||
m_bgData.m_needSave = true;
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
|
@ -19332,12 +19334,14 @@ void Player::SetBattleGroundEntryPoint()
|
|||
else if (!GetMap()->IsBattleGroundOrArena())
|
||||
{
|
||||
m_bgData.joinPos = WorldLocation(GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
|
||||
m_bgData.m_needSave = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// In error cases use homebind position
|
||||
m_bgData.joinPos = WorldLocation(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ, 0.0f);
|
||||
m_bgData.m_needSave = true;
|
||||
}
|
||||
|
||||
void Player::LeaveBattleground(bool teleportToEntryPoint)
|
||||
|
|
@ -22157,6 +22161,10 @@ void Player::_SaveEquipmentSets()
|
|||
|
||||
void Player::_SaveBGData()
|
||||
{
|
||||
// nothing save
|
||||
if (!m_bgData.m_needSave)
|
||||
return;
|
||||
|
||||
CharacterDatabase.PExecute("DELETE FROM character_battleground_data WHERE guid='%u'", GetGUIDLow());
|
||||
if (m_bgData.bgInstanceID)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1010,10 +1010,9 @@ std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi);
|
|||
struct BGData
|
||||
{
|
||||
BGData() : bgInstanceID(0), bgTypeID(BATTLEGROUND_TYPE_NONE), bgAfkReportedCount(0), bgAfkReportedTimer(0),
|
||||
bgTeam(TEAM_NONE), mountSpell(0) { ClearTaxiPath(); }
|
||||
bgTeam(TEAM_NONE), mountSpell(0), m_needSave(false) { ClearTaxiPath(); }
|
||||
|
||||
|
||||
uint32 bgInstanceID; ///< This variable is set to bg->m_InstanceID,
|
||||
uint32 bgInstanceID; ///< This variable is set to bg->m_InstanceID, saved
|
||||
/// when player is teleported to BG - (it is battleground's GUID)
|
||||
BattleGroundTypeId bgTypeID;
|
||||
|
||||
|
|
@ -1021,13 +1020,15 @@ struct BGData
|
|||
uint8 bgAfkReportedCount;
|
||||
time_t bgAfkReportedTimer;
|
||||
|
||||
Team bgTeam; ///< What side the player will be added to
|
||||
Team bgTeam; ///< What side the player will be added to, saved
|
||||
|
||||
|
||||
uint32 mountSpell;
|
||||
uint32 taxiPath[2];
|
||||
uint32 mountSpell; ///< Mount used before join to bg, saved
|
||||
uint32 taxiPath[2]; ///< Current taxi active path start/end nodes, saved
|
||||
|
||||
WorldLocation joinPos; ///< From where player entered BG
|
||||
WorldLocation joinPos; ///< From where player entered BG, saved
|
||||
|
||||
bool m_needSave; ///< true, if saved to DB fields modified after prev. save (marked as "saved" above)
|
||||
|
||||
void ClearTaxiPath() { taxiPath[0] = taxiPath[1] = 0; }
|
||||
bool HasTaxiPath() const { return taxiPath[0] && taxiPath[1]; }
|
||||
|
|
@ -2132,6 +2133,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||
{
|
||||
m_bgData.bgInstanceID = val;
|
||||
m_bgData.bgTypeID = bgTypeId;
|
||||
m_bgData.m_needSave = true;
|
||||
}
|
||||
uint32 AddBattleGroundQueueId(BattleGroundQueueTypeId val)
|
||||
{
|
||||
|
|
@ -2181,7 +2183,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||
WorldLocation const& GetBattleGroundEntryPoint() const { return m_bgData.joinPos; }
|
||||
void SetBattleGroundEntryPoint();
|
||||
|
||||
void SetBGTeam(Team team) { m_bgData.bgTeam = team; }
|
||||
void SetBGTeam(Team team) { m_bgData.bgTeam = team; m_bgData.m_needSave = true; }
|
||||
Team GetBGTeam() const { return m_bgData.bgTeam ? m_bgData.bgTeam : GetTeam(); }
|
||||
|
||||
void LeaveBattleground(bool teleportToEntryPoint = true);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "10879"
|
||||
#define REVISION_NR "10880"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue