aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Maps
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2015-05-08 00:03:15 +0200
committerShauren <shauren.trinity@gmail.com>2015-05-08 00:03:15 +0200
commit5b725db033c656bda5e718ea05a79005946e089e (patch)
treec15ad544c542cdd7dd7cb395c8ec6d3d35e4d2e9 /src/server/game/Maps
parent0972552e84068cf453231b372bcb232cf2d2f42b (diff)
Core/Garrisons: Basics for garrisons
Diffstat (limited to 'src/server/game/Maps')
-rw-r--r--src/server/game/Maps/Map.cpp9
-rw-r--r--src/server/game/Maps/Map.h2
-rw-r--r--src/server/game/Maps/MapInstanced.cpp21
-rw-r--r--src/server/game/Maps/MapInstanced.h3
4 files changed, 32 insertions, 3 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 989e7b5f825..d65682dc6ce 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -448,8 +448,7 @@ bool Map::EnsureGridLoaded(const Cell &cell)
setGridObjectDataLoaded(true, cell.GridX(), cell.GridY());
- ObjectGridLoader loader(*grid, this, cell);
- loader.LoadN();
+ LoadGridObjects(grid, cell);
// Add resurrectable corpses to world object list in grid
sObjectAccessor->AddCorpsesToGrid(GridCoord(cell.GridX(), cell.GridY()), grid->GetGridType(cell.CellX(), cell.CellY()), this);
@@ -460,6 +459,12 @@ bool Map::EnsureGridLoaded(const Cell &cell)
return false;
}
+void Map::LoadGridObjects(NGridType* grid, Cell const& cell)
+{
+ ObjectGridLoader loader(*grid, this, cell);
+ loader.LoadN();
+}
+
void Map::LoadGrid(float x, float y)
{
EnsureGridLoaded(Cell(x, y));
diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h
index 02a8292777a..a2faa8cc0a0 100644
--- a/src/server/game/Maps/Map.h
+++ b/src/server/game/Maps/Map.h
@@ -394,6 +394,7 @@ class Map : public GridRefManager<NGridType>
bool IsBattleground() const { return i_mapEntry && i_mapEntry->IsBattleground(); }
bool IsBattleArena() const { return i_mapEntry && i_mapEntry->IsBattleArena(); }
bool IsBattlegroundOrArena() const { return i_mapEntry && i_mapEntry->IsBattlegroundOrArena(); }
+ bool IsGarrison() const { return i_mapEntry && i_mapEntry->IsGarrison(); }
bool GetEntrancePos(int32 &mapid, float &x, float &y)
{
if (!i_mapEntry)
@@ -601,6 +602,7 @@ class Map : public GridRefManager<NGridType>
protected:
void SetUnloadReferenceLock(const GridCoord &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadReferenceLock(on); }
+ virtual void LoadGridObjects(NGridType* grid, Cell const& cell);
std::mutex _mapLock;
std::mutex _gridLock;
diff --git a/src/server/game/Maps/MapInstanced.cpp b/src/server/game/Maps/MapInstanced.cpp
index c48b616788e..473e3163216 100644
--- a/src/server/game/Maps/MapInstanced.cpp
+++ b/src/server/game/Maps/MapInstanced.cpp
@@ -26,6 +26,7 @@
#include "World.h"
#include "Group.h"
#include "Player.h"
+#include "GarrisonMap.h"
MapInstanced::MapInstanced(uint32 id, time_t expiry) : Map(id, expiry, 0, DIFFICULTY_NORMAL)
{
@@ -138,7 +139,7 @@ Map* MapInstanced::CreateInstanceForPlayer(const uint32 mapId, Player* player)
}
}
}
- else
+ else if (!IsGarrison())
{
InstancePlayerBind* pBind = player->GetBoundInstance(GetId(), player->GetDifficultyID(GetEntry()));
InstanceSave* pSave = pBind ? pBind->save : NULL;
@@ -180,6 +181,13 @@ Map* MapInstanced::CreateInstanceForPlayer(const uint32 mapId, Player* player)
map = CreateInstance(newInstanceId, NULL, diff);
}
}
+ else
+ {
+ newInstanceId = player->GetGUID().GetCounter();
+ map = FindInstanceMap(newInstanceId);
+ if (!map)
+ map = CreateGarrison(newInstanceId, player);
+ }
return map;
}
@@ -237,6 +245,17 @@ BattlegroundMap* MapInstanced::CreateBattleground(uint32 InstanceId, Battlegroun
return map;
}
+GarrisonMap* MapInstanced::CreateGarrison(uint32 instanceId, Player* owner)
+{
+ std::lock_guard<std::mutex> lock(_mapLock);
+
+ GarrisonMap* map = new GarrisonMap(GetId(), GetGridExpiry(), instanceId, this, owner->GetGUID());
+ ASSERT(map->IsGarrison());
+
+ m_InstancedMaps[instanceId] = map;
+ return map;
+}
+
// increments the iterator after erase
bool MapInstanced::DestroyInstance(InstancedMaps::iterator &itr)
{
diff --git a/src/server/game/Maps/MapInstanced.h b/src/server/game/Maps/MapInstanced.h
index c385215ba76..e487957ed6e 100644
--- a/src/server/game/Maps/MapInstanced.h
+++ b/src/server/game/Maps/MapInstanced.h
@@ -23,6 +23,8 @@
#include "InstanceSaveMgr.h"
#include "DBCEnums.h"
+class GarrisonMap;
+
class MapInstanced : public Map
{
friend class MapManager;
@@ -66,6 +68,7 @@ class MapInstanced : public Map
private:
InstanceMap* CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty);
BattlegroundMap* CreateBattleground(uint32 InstanceId, Battleground* bg);
+ GarrisonMap* CreateGarrison(uint32 instanceId, Player* owner);
InstancedMaps m_InstancedMaps;