mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
[7437] Fixed client visible instance ids for battlegrounds. Patch provided by balrok. Thx.
Signed-off-by: Triply <triply@getmangos.com>
This commit is contained in:
parent
6a24242cb5
commit
b6064c373e
6 changed files with 63 additions and 15 deletions
|
|
@ -128,6 +128,7 @@ BattleGround::BattleGround()
|
||||||
m_TypeID = BattleGroundTypeId(0);
|
m_TypeID = BattleGroundTypeId(0);
|
||||||
m_InstanceID = 0;
|
m_InstanceID = 0;
|
||||||
m_Status = STATUS_NONE;
|
m_Status = STATUS_NONE;
|
||||||
|
m_ClientInstanceID = 0;
|
||||||
m_EndTime = 0;
|
m_EndTime = 0;
|
||||||
m_LastResurrectTime = 0;
|
m_LastResurrectTime = 0;
|
||||||
m_QueueId = QUEUE_ID_MAX_LEVEL_19;
|
m_QueueId = QUEUE_ID_MAX_LEVEL_19;
|
||||||
|
|
|
||||||
|
|
@ -298,6 +298,7 @@ class BattleGround
|
||||||
BGQueueIdBasedOnLevel GetQueueId() const { return m_QueueId; }
|
BGQueueIdBasedOnLevel GetQueueId() const { return m_QueueId; }
|
||||||
uint32 GetInstanceID() const { return m_InstanceID; }
|
uint32 GetInstanceID() const { return m_InstanceID; }
|
||||||
BattleGroundStatus GetStatus() const { return m_Status; }
|
BattleGroundStatus GetStatus() const { return m_Status; }
|
||||||
|
uint32 GetClientInstanceID() const { return m_ClientInstanceID; }
|
||||||
uint32 GetStartTime() const { return m_StartTime; }
|
uint32 GetStartTime() const { return m_StartTime; }
|
||||||
uint32 GetEndTime() const { return m_EndTime; }
|
uint32 GetEndTime() const { return m_EndTime; }
|
||||||
uint32 GetLastResurrectTime() const { return m_LastResurrectTime; }
|
uint32 GetLastResurrectTime() const { return m_LastResurrectTime; }
|
||||||
|
|
@ -328,6 +329,7 @@ class BattleGround
|
||||||
}
|
}
|
||||||
void SetInstanceID(uint32 InstanceID) { m_InstanceID = InstanceID; }
|
void SetInstanceID(uint32 InstanceID) { m_InstanceID = InstanceID; }
|
||||||
void SetStatus(BattleGroundStatus Status) { m_Status = Status; }
|
void SetStatus(BattleGroundStatus Status) { m_Status = Status; }
|
||||||
|
void SetClientInstanceID(uint32 InstanceID) { m_ClientInstanceID = InstanceID; }
|
||||||
void SetStartTime(uint32 Time) { m_StartTime = Time; }
|
void SetStartTime(uint32 Time) { m_StartTime = Time; }
|
||||||
void SetEndTime(uint32 Time) { m_EndTime = Time; }
|
void SetEndTime(uint32 Time) { m_EndTime = Time; }
|
||||||
void SetLastResurrectTime(uint32 Time) { m_LastResurrectTime = Time; }
|
void SetLastResurrectTime(uint32 Time) { m_LastResurrectTime = Time; }
|
||||||
|
|
@ -526,6 +528,7 @@ class BattleGround
|
||||||
BattleGroundTypeId m_TypeID;
|
BattleGroundTypeId m_TypeID;
|
||||||
uint32 m_InstanceID; //BattleGround Instance's GUID!
|
uint32 m_InstanceID; //BattleGround Instance's GUID!
|
||||||
BattleGroundStatus m_Status;
|
BattleGroundStatus m_Status;
|
||||||
|
uint32 m_ClientInstanceID; //the instance-id which is sent to the client and without any other internal use
|
||||||
uint32 m_StartTime;
|
uint32 m_StartTime;
|
||||||
uint32 m_EndTime;
|
uint32 m_EndTime;
|
||||||
uint32 m_LastResurrectTime;
|
uint32 m_LastResurrectTime;
|
||||||
|
|
|
||||||
|
|
@ -110,9 +110,9 @@ void WorldSession::HandleBattleGroundJoinOpcode( WorldPacket & recv_data )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// get bg instance or bg template if instance not found
|
// get bg instance or bg template if instance not found
|
||||||
BattleGround * bg = 0;
|
BattleGround * bg = NULL;
|
||||||
if(instanceId)
|
if(instanceId)
|
||||||
BattleGround *bg = sBattleGroundMgr.GetBattleGround(instanceId, bgTypeId);
|
BattleGround *bg = sBattleGroundMgr.GetBattleGroundThroughClientInstance(instanceId, bgTypeId, _player->GetBattleGroundQueueIdFromLevel(bgTypeId));
|
||||||
|
|
||||||
if(!bg && !(bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId)))
|
if(!bg && !(bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId)))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1148,6 +1148,8 @@ void BattleGroundMgr::DeleteAllBattleGrounds()
|
||||||
{
|
{
|
||||||
BattleGround * bg = itr->second;
|
BattleGround * bg = itr->second;
|
||||||
m_BattleGrounds[i].erase(itr++);
|
m_BattleGrounds[i].erase(itr++);
|
||||||
|
if(!m_ClientBattleGroundIds[i][bg->GetQueueId()].empty())
|
||||||
|
m_ClientBattleGroundIds[i][bg->GetQueueId()].erase(bg->GetClientInstanceID());
|
||||||
delete bg;
|
delete bg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1182,6 +1184,8 @@ void BattleGroundMgr::Update(uint32 diff)
|
||||||
{
|
{
|
||||||
BattleGround * bg = itr->second;
|
BattleGround * bg = itr->second;
|
||||||
m_BattleGrounds[i].erase(itr);
|
m_BattleGrounds[i].erase(itr);
|
||||||
|
if(!m_ClientBattleGroundIds[i][bg->GetQueueId()].empty())
|
||||||
|
m_ClientBattleGroundIds[i][bg->GetQueueId()].erase(bg->GetClientInstanceID());
|
||||||
delete bg;
|
delete bg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1237,7 +1241,7 @@ void BattleGroundMgr::BuildBattleGroundStatusPacket(WorldPacket *data, BattleGro
|
||||||
*data << uint32(QueueSlot); // queue id (0...2) - player can be in 3 queues in time
|
*data << uint32(QueueSlot); // queue id (0...2) - player can be in 3 queues in time
|
||||||
// uint64 in client
|
// uint64 in client
|
||||||
*data << uint64( uint64(arenatype ? arenatype : bg->GetArenaType()) | (uint64(0x0D) << 8) | (uint64(bg->GetTypeID()) << 16) | (uint64(0x1F90) << 48) );
|
*data << uint64( uint64(arenatype ? arenatype : bg->GetArenaType()) | (uint64(0x0D) << 8) | (uint64(bg->GetTypeID()) << 16) | (uint64(0x1F90) << 48) );
|
||||||
*data << uint32(0); // unknown
|
*data << uint32(bg->GetClientInstanceID());
|
||||||
// alliance/horde for BG and skirmish/rated for Arenas
|
// alliance/horde for BG and skirmish/rated for Arenas
|
||||||
// following displays the minimap-icon 0 = faction icon 1 = arenaicon
|
// following displays the minimap-icon 0 = faction icon 1 = arenaicon
|
||||||
*data << uint8(bg->isArena());
|
*data << uint8(bg->isArena());
|
||||||
|
|
@ -1495,6 +1499,25 @@ void BattleGroundMgr::InvitePlayer(Player* plr, uint32 bgInstanceGUID, BattleGro
|
||||||
plr->m_Events.AddEvent(removeEvent, plr->m_Events.CalculateTime(INVITE_ACCEPT_WAIT_TIME));
|
plr->m_Events.AddEvent(removeEvent, plr->m_Events.CalculateTime(INVITE_ACCEPT_WAIT_TIME));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BattleGround * BattleGroundMgr::GetBattleGroundThroughClientInstance(uint32 instanceId, BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id)
|
||||||
|
{
|
||||||
|
//cause at HandleBattleGroundJoinOpcode the clients sends the instanceid he gets from
|
||||||
|
//SMSG_BATTLEFIELD_LIST we need to find the battleground with this clientinstance-id
|
||||||
|
BattleGround* bg = GetBattleGroundTemplate(bgTypeId);
|
||||||
|
if( !bg )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if(bg->isArena())
|
||||||
|
return GetBattleGround(instanceId, bgTypeId);
|
||||||
|
|
||||||
|
for(BattleGroundSet::iterator itr = m_BattleGrounds[bgTypeId].begin(); itr != m_BattleGrounds[bgTypeId].end(); ++itr)
|
||||||
|
{
|
||||||
|
if(itr->second->GetClientInstanceID() == instanceId)
|
||||||
|
return itr->second;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
BattleGround * BattleGroundMgr::GetBattleGround(uint32 InstanceID, BattleGroundTypeId bgTypeId)
|
BattleGround * BattleGroundMgr::GetBattleGround(uint32 InstanceID, BattleGroundTypeId bgTypeId)
|
||||||
{
|
{
|
||||||
//search if needed
|
//search if needed
|
||||||
|
|
@ -1519,6 +1542,28 @@ BattleGround * BattleGroundMgr::GetBattleGroundTemplate(BattleGroundTypeId bgTyp
|
||||||
return m_BattleGrounds[bgTypeId].empty() ? NULL : m_BattleGrounds[bgTypeId].begin()->second;
|
return m_BattleGrounds[bgTypeId].empty() ? NULL : m_BattleGrounds[bgTypeId].begin()->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32 BattleGroundMgr::CreateClientVisibleInstanceId(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id)
|
||||||
|
{
|
||||||
|
if( IsArenaType(bgTypeId) )
|
||||||
|
return 0; //arenas don't have client-instanceids
|
||||||
|
|
||||||
|
// we create here an instanceid, which is just for
|
||||||
|
// displaying this to the client and without any other use..
|
||||||
|
// the client-instanceIds are unique for each battleground-type
|
||||||
|
// the instance-id just needs to be as low as possible, beginning with 1
|
||||||
|
// the following works, because std::set is default ordered with "<"
|
||||||
|
// the optimalization would be to use as bitmask std::vector<uint32> - but that would only make code unreadable
|
||||||
|
uint32 lastId = 0;
|
||||||
|
for(std::set<uint32>::iterator itr = m_ClientBattleGroundIds[bgTypeId][queue_id].begin(); itr != m_ClientBattleGroundIds[bgTypeId][queue_id].end();)
|
||||||
|
{
|
||||||
|
if( (++lastId) != *itr) //if there is a gap between the ids, we will break..
|
||||||
|
break;
|
||||||
|
lastId = *itr;
|
||||||
|
}
|
||||||
|
m_ClientBattleGroundIds[bgTypeId][queue_id].insert(lastId + 1);
|
||||||
|
return lastId + 1;
|
||||||
|
}
|
||||||
|
|
||||||
// create a new battleground that will really be used to play
|
// create a new battleground that will really be used to play
|
||||||
BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id, uint8 arenaType, bool isRated)
|
BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id, uint8 arenaType, bool isRated)
|
||||||
{
|
{
|
||||||
|
|
@ -1588,6 +1633,7 @@ BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeI
|
||||||
|
|
||||||
// generate a new instance id
|
// generate a new instance id
|
||||||
bg->SetInstanceID(MapManager::Instance().GenerateInstanceId()); // set instance id
|
bg->SetInstanceID(MapManager::Instance().GenerateInstanceId()); // set instance id
|
||||||
|
bg->SetClientInstanceID(CreateClientVisibleInstanceId(bgTypeId, queue_id));
|
||||||
|
|
||||||
// reset the new bg (set status to status_wait_queue from status_none)
|
// reset the new bg (set status to status_wait_queue from status_none)
|
||||||
bg->Reset();
|
bg->Reset();
|
||||||
|
|
@ -1862,16 +1908,11 @@ void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket *data, const uint6
|
||||||
uint32 count = 0;
|
uint32 count = 0;
|
||||||
*data << uint32(0x00); // number of bg instances
|
*data << uint32(0x00); // number of bg instances
|
||||||
|
|
||||||
for(BattleGroundSet::iterator itr = m_BattleGrounds[bgTypeId].begin(); itr != m_BattleGrounds[bgTypeId].end(); ++itr)
|
uint32 queue_id = plr->GetBattleGroundQueueIdFromLevel(bgTypeId);
|
||||||
|
for(std::set<uint32>::iterator itr = m_ClientBattleGroundIds[bgTypeId][queue_id].begin(); itr != m_ClientBattleGroundIds[bgTypeId][queue_id].end();++itr)
|
||||||
{
|
{
|
||||||
// skip sending battleground template
|
*data << uint32(*itr);
|
||||||
if( itr == m_BattleGrounds[bgTypeId].begin() )
|
++count;
|
||||||
continue;
|
|
||||||
if( PlayerLevel >= itr->second->GetMinLevel() && PlayerLevel <= itr->second->GetMaxLevel() )
|
|
||||||
{
|
|
||||||
*data << uint32(itr->second->GetInstanceID());
|
|
||||||
++count;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
data->put<uint32>( count_pos , count);
|
data->put<uint32>( count_pos , count);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -193,15 +193,17 @@ class BattleGroundMgr
|
||||||
void InvitePlayer(Player* plr, uint32 bgInstanceGUID, BattleGroundTypeId bgTypeId, uint32 team);
|
void InvitePlayer(Player* plr, uint32 bgInstanceGUID, BattleGroundTypeId bgTypeId, uint32 team);
|
||||||
|
|
||||||
/* Battlegrounds */
|
/* Battlegrounds */
|
||||||
|
BattleGround* GetBattleGroundThroughClientInstance(uint32 instanceId, BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id);
|
||||||
BattleGround* GetBattleGround(uint32 InstanceID, BattleGroundTypeId bgTypeId); //there must be uint32 because MAX_BATTLEGROUND_TYPE_ID means unknown
|
BattleGround* GetBattleGround(uint32 InstanceID, BattleGroundTypeId bgTypeId); //there must be uint32 because MAX_BATTLEGROUND_TYPE_ID means unknown
|
||||||
|
|
||||||
BattleGround * GetBattleGroundTemplate(BattleGroundTypeId bgTypeId);
|
BattleGround* GetBattleGroundTemplate(BattleGroundTypeId bgTypeId);
|
||||||
BattleGround * CreateNewBattleGround(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id, uint8 arenaType, bool isRated);
|
BattleGround* CreateNewBattleGround(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id, uint8 arenaType, bool isRated);
|
||||||
|
|
||||||
uint32 CreateBattleGround(BattleGroundTypeId bgTypeId, bool IsArena, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam, uint32 LevelMin, uint32 LevelMax, char* BattleGroundName, uint32 MapID, float Team1StartLocX, float Team1StartLocY, float Team1StartLocZ, float Team1StartLocO, float Team2StartLocX, float Team2StartLocY, float Team2StartLocZ, float Team2StartLocO);
|
uint32 CreateBattleGround(BattleGroundTypeId bgTypeId, bool IsArena, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam, uint32 LevelMin, uint32 LevelMax, char* BattleGroundName, uint32 MapID, float Team1StartLocX, float Team1StartLocY, float Team1StartLocZ, float Team1StartLocO, float Team2StartLocX, float Team2StartLocY, float Team2StartLocZ, float Team2StartLocO);
|
||||||
|
|
||||||
void AddBattleGround(uint32 InstanceID, BattleGroundTypeId bgTypeId, BattleGround* BG) { m_BattleGrounds[bgTypeId][InstanceID] = BG; };
|
void AddBattleGround(uint32 InstanceID, BattleGroundTypeId bgTypeId, BattleGround* BG) { m_BattleGrounds[bgTypeId][InstanceID] = BG; };
|
||||||
void RemoveBattleGround(uint32 instanceID, BattleGroundTypeId bgTypeId) { m_BattleGrounds[bgTypeId].erase(instanceID); }
|
void RemoveBattleGround(uint32 instanceID, BattleGroundTypeId bgTypeId) { m_BattleGrounds[bgTypeId].erase(instanceID); }
|
||||||
|
uint32 CreateClientVisibleInstanceId(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id);
|
||||||
|
|
||||||
void CreateInitialBattleGrounds();
|
void CreateInitialBattleGrounds();
|
||||||
void DeleteAllBattleGrounds();
|
void DeleteAllBattleGrounds();
|
||||||
|
|
@ -245,6 +247,7 @@ class BattleGroundMgr
|
||||||
|
|
||||||
/* Battlegrounds */
|
/* Battlegrounds */
|
||||||
BattleGroundSet m_BattleGrounds[MAX_BATTLEGROUND_TYPE_ID];
|
BattleGroundSet m_BattleGrounds[MAX_BATTLEGROUND_TYPE_ID];
|
||||||
|
std::set<uint32> m_ClientBattleGroundIds[MAX_BATTLEGROUND_TYPE_ID][MAX_BATTLEGROUND_QUEUES]; //the instanceids just visible for the client
|
||||||
uint32 m_NextRatingDiscardUpdate;
|
uint32 m_NextRatingDiscardUpdate;
|
||||||
uint64 m_NextAutoDistributionTime;
|
uint64 m_NextAutoDistributionTime;
|
||||||
uint32 m_AutoDistributionTimeChecker;
|
uint32 m_AutoDistributionTimeChecker;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "7436"
|
#define REVISION_NR "7437"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue