diff options
Diffstat (limited to 'src/game/MapManager.h')
-rw-r--r-- | src/game/MapManager.h | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/src/game/MapManager.h b/src/game/MapManager.h index ce2e9ab012b..b07a26ed0f0 100644 --- a/src/game/MapManager.h +++ b/src/game/MapManager.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,14 +23,14 @@ #include "Platform/Define.h" #include "Policies/Singleton.h" -#include "zthread/Mutex.h" +#include "ace/Thread_Mutex.h" #include "Common.h" #include "Map.h" #include "GridStates.h" class Transport; -class TRINITY_DLL_DECL MapManager : public Trinity::Singleton<MapManager, Trinity::ClassLevelLockable<MapManager, ZThread::Mutex> > +class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::ClassLevelLockable<MapManager, ACE_Thread_Mutex> > { friend class Trinity::OperatorNew<MapManager>; @@ -40,25 +40,34 @@ class TRINITY_DLL_DECL MapManager : public Trinity::Singleton<MapManager, Trinit public: Map* GetMap(uint32, const WorldObject* obj); - Map* FindMap(uint32 mapid) { return _findMap(mapid); } - Map* FindMap(uint32 mapid, uint32 instanceId); + Map const* CreateBaseMap(uint32 id) const { return const_cast<MapManager*>(this)->_createBaseMap(id); } + Map* FindMap(uint32 mapid, uint32 instanceId = 0) const; // only const version for outer users - Map const* GetBaseMap(uint32 id) const { return const_cast<MapManager*>(this)->_GetBaseMap(id); } void DeleteInstance(uint32 mapid, uint32 instanceId); - inline uint16 GetAreaFlag(uint32 mapid, float x, float y) const + uint16 GetAreaFlag(uint32 mapid, float x, float y, float z) const { - Map const* m = GetBaseMap(mapid); - return m->GetAreaFlag(x, y); + Map const* m = CreateBaseMap(mapid); + return m->GetAreaFlag(x, y, z); + } + uint32 GetAreaId(uint32 mapid, float x, float y, float z) const + { + return Map::GetAreaIdByAreaFlag(GetAreaFlag(mapid, x, y, z),mapid); + } + uint32 GetZoneId(uint32 mapid, float x, float y, float z) const + { + return Map::GetZoneIdByAreaFlag(GetAreaFlag(mapid, x, y, z),mapid); + } + void GetZoneAndAreaId(uint32& zoneid, uint32& areaid, uint32 mapid, float x, float y, float z) + { + Map::GetZoneAndAreaIdByAreaFlag(zoneid,areaid,GetAreaFlag(mapid, x, y, z),mapid); } - inline uint32 GetAreaId(uint32 mapid, float x, float y) { return Map::GetAreaId(GetAreaFlag(mapid, x, y),mapid); } - inline uint32 GetZoneId(uint32 mapid, float x, float y) { return Map::GetZoneId(GetAreaFlag(mapid, x, y),mapid); } void Initialize(void); - void Update(time_t); + void Update(uint32); - inline void SetGridCleanUpDelay(uint32 t) + void SetGridCleanUpDelay(uint32 t) { if( t < MIN_GRID_DELAY ) i_gridCleanUpDelay = MIN_GRID_DELAY; @@ -66,7 +75,7 @@ class TRINITY_DLL_DECL MapManager : public Trinity::Singleton<MapManager, Trinit i_gridCleanUpDelay = t; } - inline void SetMapUpdateInterval(uint32 t) + void SetMapUpdateInterval(uint32 t) { if( t > MIN_MAP_UPDATE_DELAY ) t = MIN_MAP_UPDATE_DELAY; @@ -75,7 +84,7 @@ class TRINITY_DLL_DECL MapManager : public Trinity::Singleton<MapManager, Trinit i_timer.Reset(); } - //void LoadGrid(int mapid, float x, float y, const WorldObject* obj, bool no_unload = false); + //void LoadGrid(int mapid, int instId, float x, float y, const WorldObject* obj, bool no_unload = false); void UnloadAll(); static bool ExistMapAndVMap(uint32 mapid, float x, float y); @@ -96,6 +105,11 @@ class TRINITY_DLL_DECL MapManager : public Trinity::Singleton<MapManager, Trinit return IsValidMAP(mapid) && Trinity::IsValidMapCoord(x,y,z,o); } + static bool IsValidMapCoord(WorldLocation const& loc) + { + return IsValidMapCoord(loc.mapid,loc.coord_x,loc.coord_y,loc.coord_z,loc.orientation); + } + void DoDelayedMovesAndRemoves(); void LoadTransports(); @@ -108,7 +122,7 @@ class TRINITY_DLL_DECL MapManager : public Trinity::Singleton<MapManager, Trinit bool CanPlayerEnter(uint32 mapid, Player* player); void RemoveBonesFromMap(uint32 mapid, uint64 guid, float x, float y); - inline uint32 GenerateInstanceId() { return ++i_MaxInstanceId; } + uint32 GenerateInstanceId() { return ++i_MaxInstanceId; } void InitMaxInstanceId(); /* statistics */ @@ -127,14 +141,14 @@ class TRINITY_DLL_DECL MapManager : public Trinity::Singleton<MapManager, Trinit MapManager(const MapManager &); MapManager& operator=(const MapManager &); - Map* _GetBaseMap(uint32 id); + Map* _createBaseMap(uint32 id); Map* _findMap(uint32 id) const { MapMapType::const_iterator iter = i_maps.find(id); return (iter == i_maps.end() ? NULL : iter->second); } - typedef Trinity::ClassLevelLockable<MapManager, ZThread::Mutex>::Lock Guard; + typedef MaNGOS::ClassLevelLockable<MapManager, ACE_Thread_Mutex>::Lock Guard; uint32 i_gridCleanUpDelay; MapMapType i_maps; IntervalTimer i_timer; |