mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[9597] create battleground map at bg creation
when a bg gets created it will also get it's map
(old behaviour was, that map got's created when first player entered the instance)
the reason why battlegroundmaps aren't instantiated with a player object:
* the only information from player-class we need is player->GetBattleGround()
also we can't use anything else
(e.g. playerlevel can be outside of bg-levelrange)
-> cause bgs depend pretty much on their maps this caused circualr dependencies between map,bg,player
* battlegroundmaps will _always_ be prepared by the bgsystem to set the proper data
* there is not much shared in the creational process with dungeonmaps
even the functioncall is different since players need to enqueue first for bgs,
therefore again the player's way to that instance is only through the bgMgr
This commit is contained in:
parent
db51c29235
commit
24d45c6a08
8 changed files with 24 additions and 21 deletions
|
|
@ -208,7 +208,6 @@ void BattleGround::BroadcastWorker(Do& _do)
|
|||
BattleGround::BattleGround()
|
||||
{
|
||||
m_TypeID = BattleGroundTypeId(0);
|
||||
m_InstanceID = 0;
|
||||
m_Status = STATUS_NONE;
|
||||
m_ClientInstanceID = 0;
|
||||
m_EndTime = 0;
|
||||
|
|
@ -1326,10 +1325,9 @@ void BattleGround::RemoveFromBGFreeSlotQueue()
|
|||
{
|
||||
// set to be able to re-add if needed
|
||||
m_InBGFreeSlotQueue = false;
|
||||
// uncomment this code when battlegrounds will work like instances
|
||||
for (BGFreeSlotQueueType::iterator itr = sBattleGroundMgr.BGFreeSlotQueue[m_TypeID].begin(); itr != sBattleGroundMgr.BGFreeSlotQueue[m_TypeID].end(); ++itr)
|
||||
{
|
||||
if ((*itr)->GetInstanceID() == m_InstanceID)
|
||||
if ((*itr)->GetInstanceID() == GetInstanceID())
|
||||
{
|
||||
sBattleGroundMgr.BGFreeSlotQueue[m_TypeID].erase(itr);
|
||||
return;
|
||||
|
|
@ -1840,4 +1838,4 @@ void BattleGround::SetBracket( PvPDifficultyEntry const* bracketEntry )
|
|||
{
|
||||
m_BracketId = bracketEntry->GetBracketId();
|
||||
SetLevelRange(bracketEntry->minLevel,bracketEntry->maxLevel);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "Common.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "Map.h"
|
||||
|
||||
// magic event-numbers
|
||||
#define BG_EVENT_NONE 255
|
||||
|
|
@ -298,7 +299,9 @@ class BattleGround
|
|||
char const* GetName() const { return m_Name; }
|
||||
BattleGroundTypeId GetTypeID() const { return m_TypeID; }
|
||||
BattleGroundBracketId GetBracketId() const { return m_BracketId; }
|
||||
uint32 GetInstanceID() const { return m_InstanceID; }
|
||||
// the instanceId check is also used to determine a bg-template
|
||||
// that's why the m_map hack is here..
|
||||
uint32 GetInstanceID() { return m_Map?GetBgMap()->GetInstanceId():0; }
|
||||
BattleGroundStatus GetStatus() const { return m_Status; }
|
||||
uint32 GetClientInstanceID() const { return m_ClientInstanceID; }
|
||||
uint32 GetStartTime() const { return m_StartTime; }
|
||||
|
|
@ -323,7 +326,6 @@ class BattleGround
|
|||
void SetTypeID(BattleGroundTypeId TypeID) { m_TypeID = TypeID; }
|
||||
//here we can count minlevel and maxlevel for players
|
||||
void SetBracket(PvPDifficultyEntry const* bracketEntry);
|
||||
void SetInstanceID(uint32 InstanceID) { m_InstanceID = InstanceID; }
|
||||
void SetStatus(BattleGroundStatus Status) { m_Status = Status; }
|
||||
void SetClientInstanceID(uint32 InstanceID) { m_ClientInstanceID = InstanceID; }
|
||||
void SetStartTime(uint32 Time) { m_StartTime = Time; }
|
||||
|
|
@ -562,7 +564,6 @@ class BattleGround
|
|||
private:
|
||||
/* Battleground */
|
||||
BattleGroundTypeId m_TypeID;
|
||||
uint32 m_InstanceID; //BattleGround Instance's GUID!
|
||||
BattleGroundStatus m_Status;
|
||||
uint32 m_ClientInstanceID; //the instance-id which is sent to the client and without any other internal use
|
||||
uint32 m_StartTime;
|
||||
|
|
|
|||
|
|
@ -1576,8 +1576,9 @@ BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeI
|
|||
return 0;
|
||||
}
|
||||
|
||||
// generate a new instance id
|
||||
bg->SetInstanceID(sMapMgr.GenerateInstanceId()); // set instance id
|
||||
// will also set m_bgMap, instanceid
|
||||
sMapMgr.CreateBgMap(bg->GetMapId(), bg);
|
||||
|
||||
bg->SetClientInstanceID(CreateClientVisibleInstanceId(bgTypeId, bracketEntry->GetBracketId()));
|
||||
|
||||
// reset the new bg (set status to status_wait_queue from status_none)
|
||||
|
|
@ -1617,7 +1618,6 @@ uint32 BattleGroundMgr::CreateBattleGround(BattleGroundTypeId bgTypeId, bool IsA
|
|||
|
||||
bg->SetMapId(MapID);
|
||||
bg->SetTypeID(bgTypeId);
|
||||
bg->SetInstanceID(0);
|
||||
bg->SetArenaorBGType(IsArena);
|
||||
bg->SetMinPlayersPerTeam(MinPlayersPerTeam);
|
||||
bg->SetMaxPlayersPerTeam(MaxPlayersPerTeam);
|
||||
|
|
|
|||
|
|
@ -104,11 +104,8 @@ void MapInstanced::UnloadAll(bool pForce)
|
|||
Map::UnloadAll(pForce);
|
||||
}
|
||||
|
||||
/*
|
||||
- return the right instance for the object, based on its InstanceId
|
||||
- create the instance if it's not created already
|
||||
- the player is not actually added to the instance (only in InstanceMap::Add)
|
||||
*/
|
||||
/// returns a new or existing Instance
|
||||
/// in case of battlegrounds it will only return an existing map, those maps are created by bg-system
|
||||
Map* MapInstanced::CreateInstance(const uint32 mapId, Player * player)
|
||||
{
|
||||
if(GetId() != mapId || !player)
|
||||
|
|
@ -119,13 +116,11 @@ Map* MapInstanced::CreateInstance(const uint32 mapId, Player * player)
|
|||
|
||||
if(IsBattleGroundOrArena())
|
||||
{
|
||||
// instantiate or find existing bg map for player
|
||||
// the instance id is set in battlegroundid
|
||||
// find existing bg map for player
|
||||
NewInstanceId = player->GetBattleGroundId();
|
||||
ASSERT(NewInstanceId);
|
||||
map = _FindMap(NewInstanceId);
|
||||
if(!map)
|
||||
map = CreateBattleGroundMap(NewInstanceId, player->GetBattleGround());
|
||||
ASSERT(map);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -58,11 +58,11 @@ class MANGOS_DLL_DECL MapInstanced : public Map
|
|||
|
||||
InstancedMaps &GetInstancedMaps() { return m_InstancedMaps; }
|
||||
virtual void InitVisibilityDistance();
|
||||
BattleGroundMap* CreateBattleGroundMap(uint32 InstanceId, BattleGround* bg);
|
||||
|
||||
private:
|
||||
|
||||
InstanceMap* CreateInstance(uint32 InstanceId, InstanceSave *save, Difficulty difficulty);
|
||||
BattleGroundMap* CreateBattleGroundMap(uint32 InstanceId, BattleGround* bg);
|
||||
|
||||
InstancedMaps m_InstancedMaps;
|
||||
|
||||
|
|
|
|||
|
|
@ -138,6 +138,13 @@ Map* MapManager::CreateMap(uint32 id, const WorldObject* obj)
|
|||
return m;
|
||||
}
|
||||
|
||||
Map* MapManager::CreateBgMap(uint32 mapid, BattleGround* bg)
|
||||
{
|
||||
Map *m = _createBaseMap(mapid);
|
||||
((MapInstanced*)m)->CreateBattleGroundMap(sMapMgr.GenerateInstanceId(), bg);
|
||||
return m;
|
||||
}
|
||||
|
||||
Map* MapManager::FindMap(uint32 mapid, uint32 instanceId) const
|
||||
{
|
||||
Map *map = _findMap(mapid);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include "GridStates.h"
|
||||
|
||||
class Transport;
|
||||
class BattleGround;
|
||||
|
||||
class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::ClassLevelLockable<MapManager, ACE_Thread_Mutex> >
|
||||
{
|
||||
|
|
@ -38,6 +39,7 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
|
|||
public:
|
||||
|
||||
Map* CreateMap(uint32, const WorldObject* obj);
|
||||
Map* CreateBgMap(uint32 mapid, BattleGround* bg);
|
||||
Map const* CreateBaseMap(uint32 id) const { return const_cast<MapManager*>(this)->_createBaseMap(id); }
|
||||
Map* FindMap(uint32 mapid, uint32 instanceId = 0) const;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "9596"
|
||||
#define REVISION_NR "9597"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue