aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/Collision/Management/IVMapManager.h13
-rw-r--r--src/common/Collision/Management/MMapManager.cpp51
-rw-r--r--src/common/Collision/Management/MMapManager.h5
-rw-r--r--src/common/Collision/Management/VMapManager2.cpp57
-rw-r--r--src/common/Collision/Management/VMapManager2.h6
-rw-r--r--src/common/Collision/Maps/MapDefines.h41
6 files changed, 50 insertions, 123 deletions
diff --git a/src/common/Collision/Management/IVMapManager.h b/src/common/Collision/Management/IVMapManager.h
index ec198ffcc70..59cb8409f46 100644
--- a/src/common/Collision/Management/IVMapManager.h
+++ b/src/common/Collision/Management/IVMapManager.h
@@ -31,20 +31,13 @@ This is the minimum interface to the VMapMamager.
namespace VMAP
{
-
- enum VMAP_LOAD_RESULT
- {
- VMAP_LOAD_RESULT_ERROR,
- VMAP_LOAD_RESULT_OK,
- VMAP_LOAD_RESULT_IGNORED
- };
-
enum class LoadResult : uint8
{
Success,
FileNotFound,
VersionMismatch,
- ReadFromFileFailed
+ ReadFromFileFailed,
+ DisabledInConfig
};
#define VMAP_INVALID_HEIGHT -100000.0f // for check
@@ -83,7 +76,7 @@ namespace VMAP
virtual ~IVMapManager(void) { }
- virtual int loadMap(char const* pBasePath, unsigned int pMapId, int x, int y) = 0;
+ virtual LoadResult loadMap(char const* pBasePath, unsigned int pMapId, int x, int y) = 0;
virtual LoadResult existsMap(char const* pBasePath, unsigned int pMapId, int x, int y) = 0;
diff --git a/src/common/Collision/Management/MMapManager.cpp b/src/common/Collision/Management/MMapManager.cpp
index 01e1489825a..ab51cd3e7ba 100644
--- a/src/common/Collision/Management/MMapManager.cpp
+++ b/src/common/Collision/Management/MMapManager.cpp
@@ -37,7 +37,6 @@ namespace MMAP
void MMapManager::InitializeThreadUnsafe(std::unordered_map<uint32, std::vector<uint32>> const& mapData)
{
- childMapData = mapData;
// the caller must pass the list of all mapIds that will be used in the VMapManager2 lifetime
for (std::pair<uint32 const, std::vector<uint32>> const& mapId : mapData)
{
@@ -119,21 +118,6 @@ namespace MMAP
bool MMapManager::loadMap(std::string const& basePath, uint32 mapId, int32 x, int32 y)
{
- if (!loadMapImpl(basePath, mapId, x, y))
- return false;
-
- bool success = true;
- auto childMaps = childMapData.find(mapId);
- if (childMaps != childMapData.end())
- for (uint32 childMapId : childMaps->second)
- if (!loadMapImpl(basePath, childMapId, x, y))
- success = false;
-
- return success;
- }
-
- bool MMapManager::loadMapImpl(std::string const& basePath, uint32 mapId, int32 x, int32 y)
- {
// make sure the mmap is loaded and ready to load tiles
if (!loadMapData(basePath, mapId))
return false;
@@ -228,21 +212,6 @@ namespace MMAP
bool MMapManager::loadMapInstance(std::string const& basePath, uint32 mapId, uint32 instanceId)
{
- if (!loadMapInstanceImpl(basePath, mapId, instanceId))
- return false;
-
- bool success = true;
- auto childMaps = childMapData.find(mapId);
- if (childMaps != childMapData.end())
- for (uint32 childMapId : childMaps->second)
- if (!loadMapInstanceImpl(basePath, childMapId, instanceId))
- success = false;
-
- return success;
- }
-
- bool MMapManager::loadMapInstanceImpl(std::string const& basePath, uint32 mapId, uint32 instanceId)
- {
if (!loadMapData(basePath, mapId))
return false;
@@ -267,16 +236,6 @@ namespace MMAP
bool MMapManager::unloadMap(uint32 mapId, int32 x, int32 y)
{
- auto childMaps = childMapData.find(mapId);
- if (childMaps != childMapData.end())
- for (uint32 childMapId : childMaps->second)
- unloadMapImpl(childMapId, x, y);
-
- return unloadMapImpl(mapId, x, y);
- }
-
- bool MMapManager::unloadMapImpl(uint32 mapId, int32 x, int32 y)
- {
// check if we have this map loaded
MMapDataSet::const_iterator itr = GetMMapData(mapId);
if (itr == loadedMMaps.end())
@@ -320,16 +279,6 @@ namespace MMAP
bool MMapManager::unloadMap(uint32 mapId)
{
- auto childMaps = childMapData.find(mapId);
- if (childMaps != childMapData.end())
- for (uint32 childMapId : childMaps->second)
- unloadMapImpl(childMapId);
-
- return unloadMapImpl(mapId);
- }
-
- bool MMapManager::unloadMapImpl(uint32 mapId)
- {
MMapDataSet::iterator itr = loadedMMaps.find(mapId);
if (itr == loadedMMaps.end() || !itr->second)
{
diff --git a/src/common/Collision/Management/MMapManager.h b/src/common/Collision/Management/MMapManager.h
index d2862631fa6..1627036cd00 100644
--- a/src/common/Collision/Management/MMapManager.h
+++ b/src/common/Collision/Management/MMapManager.h
@@ -76,10 +76,6 @@ namespace MMAP
uint32 getLoadedMapsCount() const { return uint32(loadedMMaps.size()); }
private:
bool loadMapData(std::string const& basePath, uint32 mapId);
- bool loadMapImpl(std::string const& basePath, uint32 mapId, int32 x, int32 y);
- bool loadMapInstanceImpl(std::string const& basePath, uint32 mapId, uint32 instanceId);
- bool unloadMapImpl(uint32 mapId, int32 x, int32 y);
- bool unloadMapImpl(uint32 mapId);
uint32 packTileID(int32 x, int32 y);
MMapDataSet::const_iterator GetMMapData(uint32 mapId) const;
@@ -87,7 +83,6 @@ namespace MMAP
uint32 loadedTiles;
bool thread_safe_environment;
- std::unordered_map<uint32, std::vector<uint32>> childMapData;
std::unordered_map<uint32, uint32> parentMapData;
};
}
diff --git a/src/common/Collision/Management/VMapManager2.cpp b/src/common/Collision/Management/VMapManager2.cpp
index 3ab64e99251..8afd4449dce 100644
--- a/src/common/Collision/Management/VMapManager2.cpp
+++ b/src/common/Collision/Management/VMapManager2.cpp
@@ -78,7 +78,6 @@ namespace VMAP
void VMapManager2::InitializeThreadUnsafe(std::unordered_map<uint32, std::vector<uint32>> const& mapData)
{
// the caller must pass the list of all mapIds that will be used in the VMapManager2 lifetime
- iChildMapData = mapData;
for (std::pair<uint32 const, std::vector<uint32>> const& mapId : mapData)
{
iInstanceMapTrees.insert(InstanceTreeMap::value_type(mapId.first, nullptr));
@@ -110,37 +109,11 @@ namespace VMAP
return fname.str();
}
- int VMapManager2::loadMap(char const* basePath, unsigned int mapId, int x, int y)
+ LoadResult VMapManager2::loadMap(char const* basePath, unsigned int mapId, int x, int y)
{
- int result = VMAP_LOAD_RESULT_IGNORED;
- if (isMapLoadingEnabled())
- {
- LoadResult parentLoadResult = loadSingleMap(mapId, basePath, x, y);
- if (parentLoadResult == LoadResult::Success || parentLoadResult == LoadResult::FileNotFound)
- {
- if (parentLoadResult == LoadResult::Success)
- result = VMAP_LOAD_RESULT_OK;
- // else VMAP_LOAD_RESULT_IGNORED
-
- auto childMaps = iChildMapData.find(mapId);
- if (childMaps != iChildMapData.end())
- for (uint32 childMapId : childMaps->second)
- {
- LoadResult childLoadResult = loadSingleMap(childMapId, basePath, x, y);
- if (childLoadResult != LoadResult::Success && childLoadResult != LoadResult::FileNotFound)
- result = VMAP_LOAD_RESULT_ERROR;
- }
- }
- else
- result = VMAP_LOAD_RESULT_ERROR;
- }
-
- return result;
- }
+ if (!isMapLoadingEnabled())
+ return LoadResult::DisabledInConfig;
- // load one tile (internal use only)
- LoadResult VMapManager2::loadSingleMap(uint32 mapId, const std::string& basePath, uint32 tileX, uint32 tileY)
- {
auto instanceTree = iInstanceMapTrees.find(mapId);
if (instanceTree == iInstanceMapTrees.end())
{
@@ -148,7 +121,7 @@ namespace VMAP
instanceTree = iInstanceMapTrees.insert(InstanceTreeMap::value_type(mapId, nullptr)).first;
else
ABORT_MSG("Invalid mapId %u tile [%u, %u] passed to VMapManager2 after startup in thread unsafe environment",
- mapId, tileX, tileY);
+ mapId, x, y);
}
if (!instanceTree->second)
@@ -164,21 +137,11 @@ namespace VMAP
instanceTree->second = newTree;
}
- return instanceTree->second->LoadMapTile(tileX, tileY, this);
+ return instanceTree->second->LoadMapTile(x, y, this);
}
void VMapManager2::unloadMap(unsigned int mapId, int x, int y)
{
- auto childMaps = iChildMapData.find(mapId);
- if (childMaps != iChildMapData.end())
- for (uint32 childMapId : childMaps->second)
- unloadSingleMap(childMapId, x, y);
-
- unloadSingleMap(mapId, x, y);
- }
-
- void VMapManager2::unloadSingleMap(uint32 mapId, int x, int y)
- {
auto instanceTree = iInstanceMapTrees.find(mapId);
if (instanceTree != iInstanceMapTrees.end() && instanceTree->second)
{
@@ -193,16 +156,6 @@ namespace VMAP
void VMapManager2::unloadMap(unsigned int mapId)
{
- auto childMaps = iChildMapData.find(mapId);
- if (childMaps != iChildMapData.end())
- for (uint32 childMapId : childMaps->second)
- unloadSingleMap(childMapId);
-
- unloadSingleMap(mapId);
- }
-
- void VMapManager2::unloadSingleMap(uint32 mapId)
- {
auto instanceTree = iInstanceMapTrees.find(mapId);
if (instanceTree != iInstanceMapTrees.end() && instanceTree->second)
{
diff --git a/src/common/Collision/Management/VMapManager2.h b/src/common/Collision/Management/VMapManager2.h
index 64c550c48cf..b18d52ac042 100644
--- a/src/common/Collision/Management/VMapManager2.h
+++ b/src/common/Collision/Management/VMapManager2.h
@@ -68,7 +68,6 @@ namespace VMAP
// Tree to check collision
ModelFileMap iLoadedModelFiles;
InstanceTreeMap iInstanceMapTrees;
- std::unordered_map<uint32, std::vector<uint32>> iChildMapData;
std::unordered_map<uint32, uint32> iParentMapData;
bool thread_safe_environment;
// Mutex for iLoadedModelFiles
@@ -89,14 +88,11 @@ namespace VMAP
void InitializeThreadUnsafe(std::unordered_map<uint32, std::vector<uint32>> const& mapData);
- int loadMap(char const* pBasePath, unsigned int mapId, int x, int y) override;
- LoadResult loadSingleMap(uint32 mapId, const std::string& basePath, uint32 tileX, uint32 tileY);
+ LoadResult loadMap(char const* pBasePath, unsigned int mapId, int x, int y) override;
void unloadMap(unsigned int mapId, int x, int y) override;
- void unloadSingleMap(uint32 mapId, int x, int y);
void unloadMap(unsigned int mapId) override;
- void unloadSingleMap(uint32 mapId);
bool isInLineOfSight(unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2, ModelIgnoreFlags ignoreFlags) override ;
/**
diff --git a/src/common/Collision/Maps/MapDefines.h b/src/common/Collision/Maps/MapDefines.h
index c95fa1ede2a..ced17e3c25a 100644
--- a/src/common/Collision/Maps/MapDefines.h
+++ b/src/common/Collision/Maps/MapDefines.h
@@ -20,6 +20,7 @@
#include "Define.h"
#include "EnumFlag.h"
+#include "Optional.h"
#include <array>
/// Represents a map magic value of 4 bytes (used in versions)
@@ -120,4 +121,44 @@ struct map_liquidHeader
float liquidLevel;
};
+enum ZLiquidStatus : uint32
+{
+ LIQUID_MAP_NO_WATER = 0x00000000,
+ LIQUID_MAP_ABOVE_WATER = 0x00000001,
+ LIQUID_MAP_WATER_WALK = 0x00000002,
+ LIQUID_MAP_IN_WATER = 0x00000004,
+ LIQUID_MAP_UNDER_WATER = 0x00000008
+};
+
+#define MAP_LIQUID_STATUS_SWIMMING (LIQUID_MAP_IN_WATER | LIQUID_MAP_UNDER_WATER)
+#define MAP_LIQUID_STATUS_IN_CONTACT (MAP_LIQUID_STATUS_SWIMMING | LIQUID_MAP_WATER_WALK)
+
+struct LiquidData
+{
+ EnumFlag<map_liquidHeaderTypeFlags> type_flags = map_liquidHeaderTypeFlags::NoWater;
+ uint32 entry;
+ float level;
+ float depth_level;
+};
+
+struct PositionFullTerrainStatus
+{
+ struct AreaInfo
+ {
+ AreaInfo(int32 _adtId, int32 _rootId, int32 _groupId, uint32 _flags) : adtId(_adtId), rootId(_rootId), groupId(_groupId), mogpFlags(_flags) { }
+ int32 const adtId;
+ int32 const rootId;
+ int32 const groupId;
+ uint32 const mogpFlags;
+ };
+
+ PositionFullTerrainStatus() : areaId(0), floorZ(0.0f), outdoors(true), liquidStatus(LIQUID_MAP_NO_WATER) { }
+ uint32 areaId;
+ float floorZ;
+ bool outdoors;
+ ZLiquidStatus liquidStatus;
+ Optional<AreaInfo> areaInfo;
+ Optional<LiquidData> liquidInfo;
+};
+
#endif // MapDefines_h__