aboutsummaryrefslogtreecommitdiff
path: root/src/server/collision
diff options
context:
space:
mode:
authorLopin <davca.hr@seznam.cz>2011-07-11 16:14:26 +0200
committerLopin <davca.hr@seznam.cz>2011-07-11 16:14:26 +0200
commite35e4d6e23d607deb75a61413fc4bc0a2ceedd18 (patch)
tree30762b38cbd250c804a9a3eeecc8b668be5c6414 /src/server/collision
parent72ea9c9fa86fa88a5cbdd971d817c6903abf725a (diff)
Core/Disables: Allow to disable certain vMaps through Disables system. Wiki will be updated soon
Diffstat (limited to 'src/server/collision')
-rw-r--r--src/server/collision/CMakeLists.txt1
-rw-r--r--src/server/collision/Management/VMapManager2.cpp179
-rwxr-xr-xsrc/server/collision/Management/VMapManager2.h49
3 files changed, 114 insertions, 115 deletions
diff --git a/src/server/collision/CMakeLists.txt b/src/server/collision/CMakeLists.txt
index 340072b393c..0ea62fb1ed0 100644
--- a/src/server/collision/CMakeLists.txt
+++ b/src/server/collision/CMakeLists.txt
@@ -41,6 +41,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/src/server/shared/Dynamic
${CMAKE_SOURCE_DIR}/src/server/shared/Logging
${CMAKE_SOURCE_DIR}/src/server/shared/Threading
+ ${CMAKE_SOURCE_DIR}/src/server/game/Conditions
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/Management
${CMAKE_CURRENT_SOURCE_DIR}/Maps
diff --git a/src/server/collision/Management/VMapManager2.cpp b/src/server/collision/Management/VMapManager2.cpp
index 5b2d6fafc20..b6dc8c7bac4 100644
--- a/src/server/collision/Management/VMapManager2.cpp
+++ b/src/server/collision/Management/VMapManager2.cpp
@@ -26,20 +26,19 @@
#include "WorldModel.h"
#include "VMapDefinitions.h"
#include "Log.h"
+#include <G3D/Vector3.h>
+#include <ace/Null_Mutex.h>
+#include <ace/Singleton.h>
+#include "DisableMgr.h"
using G3D::Vector3;
namespace VMAP
{
-
- //=========================================================
-
VMapManager2::VMapManager2()
{
}
- //=========================================================
-
VMapManager2::~VMapManager2(void)
{
for (InstanceTreeMap::iterator i = iInstanceMapTrees.begin(); i != iInstanceMapTrees.end(); ++i)
@@ -52,8 +51,6 @@ namespace VMAP
}
}
- //=========================================================
-
Vector3 VMapManager2::convertPositionToInternalRep(float x, float y, float z) const
{
Vector3 pos;
@@ -65,8 +62,6 @@ namespace VMAP
return pos;
}
- //=========================================================
-
Vector3 VMapManager2::convertPositionToMangosRep(float x, float y, float z) const
{
Vector3 pos;
@@ -77,197 +72,196 @@ namespace VMAP
return pos;
}
- //=========================================================
// move to MapTree too?
- std::string VMapManager2::getMapFileName(unsigned int pMapId)
+ std::string VMapManager2::getMapFileName(unsigned int mapId)
{
std::stringstream fname;
fname.width(3);
- fname << std::setfill('0') << pMapId << std::string(MAP_FILENAME_EXTENSION2);
+ fname << std::setfill('0') << mapId << std::string(MAP_FILENAME_EXTENSION2);
+
return fname.str();
}
- //=========================================================
-
- int VMapManager2::loadMap(const char* pBasePath, unsigned int pMapId, int x, int y)
+ int VMapManager2::loadMap(const char* basePath, unsigned int mapId, int x, int y)
{
int result = VMAP_LOAD_RESULT_IGNORED;
if (isMapLoadingEnabled())
{
- if (_loadMap(pMapId, pBasePath, x, y))
+ if (_loadMap(mapId, basePath, x, y))
result = VMAP_LOAD_RESULT_OK;
else
result = VMAP_LOAD_RESULT_ERROR;
}
+
return result;
}
- //=========================================================
// load one tile (internal use only)
-
- bool VMapManager2::_loadMap(unsigned int pMapId, const std::string &basePath, uint32 tileX, uint32 tileY)
+ bool VMapManager2::_loadMap(unsigned int mapId, const std::string& basePath, uint32 tileX, uint32 tileY)
{
- InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(pMapId);
+ InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(mapId);
if (instanceTree == iInstanceMapTrees.end())
{
- std::string mapFileName = getMapFileName(pMapId);
- StaticMapTree *newTree = new StaticMapTree(pMapId, basePath);
+ std::string mapFileName = getMapFileName(mapId);
+ StaticMapTree* newTree = new StaticMapTree(mapId, basePath);
if (!newTree->InitMap(mapFileName, this))
return false;
- instanceTree = iInstanceMapTrees.insert(InstanceTreeMap::value_type(pMapId, newTree)).first;
+ instanceTree = iInstanceMapTrees.insert(InstanceTreeMap::value_type(mapId, newTree)).first;
}
+
return instanceTree->second->LoadMapTile(tileX, tileY, this);
}
- //=========================================================
-
- void VMapManager2::unloadMap(unsigned int pMapId)
+ void VMapManager2::unloadMap(unsigned int mapId)
{
- InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(pMapId);
+ InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(mapId);
if (instanceTree != iInstanceMapTrees.end())
{
instanceTree->second->UnloadMap(this);
if (instanceTree->second->numLoadedTiles() == 0)
{
delete instanceTree->second;
- iInstanceMapTrees.erase(pMapId);
+ iInstanceMapTrees.erase(mapId);
}
}
}
- //=========================================================
-
- void VMapManager2::unloadMap(unsigned int pMapId, int x, int y)
+ void VMapManager2::unloadMap(unsigned int mapId, int x, int y)
{
- InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(pMapId);
+ InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(mapId);
if (instanceTree != iInstanceMapTrees.end())
{
instanceTree->second->UnloadMapTile(x, y, this);
if (instanceTree->second->numLoadedTiles() == 0)
{
delete instanceTree->second;
- iInstanceMapTrees.erase(pMapId);
+ iInstanceMapTrees.erase(mapId);
}
}
}
- //==========================================================
-
- bool VMapManager2::isInLineOfSight(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2)
+ bool VMapManager2::isInLineOfSight(unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2)
{
- if (!isLineOfSightCalcEnabled()) return true;
- bool result = true;
- InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(pMapId);
+ if (!isLineOfSightCalcEnabled() || sDisableMgr->IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_LOS))
+ return true;
+
+ InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(mapId);
if (instanceTree != iInstanceMapTrees.end())
{
Vector3 pos1 = convertPositionToInternalRep(x1, y1, z1);
Vector3 pos2 = convertPositionToInternalRep(x2, y2, z2);
if (pos1 != pos2)
{
- result = instanceTree->second->isInLineOfSight(pos1, pos2);
+ return instanceTree->second->isInLineOfSight(pos1, pos2);
}
}
- return result;
+
+ return true;
}
- //=========================================================
+
/**
get the hit position and return true if we hit something
otherwise the result pos will be the dest pos
*/
- bool VMapManager2::getObjectHitPos(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float &ry, float& rz, float pModifyDist)
+ bool VMapManager2::getObjectHitPos(unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float &ry, float& rz, float modifyDist)
{
- bool result = false;
- rx=x2;
- ry=y2;
- rz=z2;
- if (isLineOfSightCalcEnabled())
+ if (isLineOfSightCalcEnabled() && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_LOS))
{
- InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(pMapId);
+ InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(mapId);
if (instanceTree != iInstanceMapTrees.end())
{
Vector3 pos1 = convertPositionToInternalRep(x1, y1, z1);
Vector3 pos2 = convertPositionToInternalRep(x2, y2, z2);
Vector3 resultPos;
- result = instanceTree->second->getObjectHitPos(pos1, pos2, resultPos, pModifyDist);
+ bool result = instanceTree->second->getObjectHitPos(pos1, pos2, resultPos, modifyDist);
resultPos = convertPositionToMangosRep(resultPos.x, resultPos.y, resultPos.z);
rx = resultPos.x;
ry = resultPos.y;
rz = resultPos.z;
+ return result;
}
}
- return result;
+
+ rx = x2;
+ ry = y2;
+ rz = z2;
+
+ return false;
}
- //=========================================================
/**
get height or INVALID_HEIGHT if no height available
*/
- float VMapManager2::getHeight(unsigned int pMapId, float x, float y, float z, float maxSearchDist)
+ float VMapManager2::getHeight(unsigned int mapId, float x, float y, float z, float maxSearchDist)
{
- float height = VMAP_INVALID_HEIGHT_VALUE; //no height
- if (isHeightCalcEnabled())
+ if (isHeightCalcEnabled() && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_HEIGHT))
{
- InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(pMapId);
+ InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(mapId);
if (instanceTree != iInstanceMapTrees.end())
{
Vector3 pos = convertPositionToInternalRep(x, y, z);
- height = instanceTree->second->getHeight(pos, maxSearchDist);
+ float height = instanceTree->second->getHeight(pos, maxSearchDist);
if (!(height < G3D::inf()))
- {
- height = VMAP_INVALID_HEIGHT_VALUE; //no height
- }
+ return height = VMAP_INVALID_HEIGHT_VALUE; // No height
+
+ return height;
}
}
- return height;
- }
- //=========================================================
+ return VMAP_INVALID_HEIGHT_VALUE;
+ }
- bool VMapManager2::getAreaInfo(unsigned int pMapId, float x, float y, float &z, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const
+ bool VMapManager2::getAreaInfo(unsigned int mapId, float x, float y, float& z, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const
{
- bool result=false;
- InstanceTreeMap::const_iterator instanceTree = iInstanceMapTrees.find(pMapId);
- if (instanceTree != iInstanceMapTrees.end())
+ if (!sDisableMgr->IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_AREAFLAG))
{
- Vector3 pos = convertPositionToInternalRep(x, y, z);
- result = instanceTree->second->getAreaInfo(pos, flags, adtId, rootId, groupId);
- // z is not touched by convertPositionToMangosRep(), so just copy
- z = pos.z;
+ InstanceTreeMap::const_iterator instanceTree = iInstanceMapTrees.find(mapId);
+ if (instanceTree != iInstanceMapTrees.end())
+ {
+ Vector3 pos = convertPositionToInternalRep(x, y, z);
+ bool result = instanceTree->second->getAreaInfo(pos, flags, adtId, rootId, groupId);
+ // z is not touched by convertPositionToMangosRep(), so just copy
+ z = pos.z;
+ return result;
+ }
}
- return(result);
+
+ return false;
}
- bool VMapManager2::GetLiquidLevel(uint32 pMapId, float x, float y, float z, uint8 ReqLiquidType, float &level, float &floor, uint32 &type) const
+ bool VMapManager2::GetLiquidLevel(uint32 mapId, float x, float y, float z, uint8 reqLiquidType, float& level, float& floor, uint32& type) const
{
- InstanceTreeMap::const_iterator instanceTree = iInstanceMapTrees.find(pMapId);
- if (instanceTree != iInstanceMapTrees.end())
+ if (!sDisableMgr->IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_LIQUIDSTATUS))
{
- LocationInfo info;
- Vector3 pos = convertPositionToInternalRep(x, y, z);
- if (instanceTree->second->GetLocationInfo(pos, info))
+ InstanceTreeMap::const_iterator instanceTree = iInstanceMapTrees.find(mapId);
+ if (instanceTree != iInstanceMapTrees.end())
{
- floor = info.ground_Z;
- ASSERT(floor < std::numeric_limits<float>::max());
- type = info.hitModel->GetLiquidType();
- if (ReqLiquidType && !(type & ReqLiquidType))
- return false;
- if (info.hitInstance->GetLiquidLevel(pos, info, level))
- return true;
+ LocationInfo info;
+ Vector3 pos = convertPositionToInternalRep(x, y, z);
+ if (instanceTree->second->GetLocationInfo(pos, info))
+ {
+ floor = info.ground_Z;
+ ASSERT(floor < std::numeric_limits<float>::max());
+ type = info.hitModel->GetLiquidType();
+ if (reqLiquidType && !(type & reqLiquidType))
+ return false;
+ if (info.hitInstance->GetLiquidLevel(pos, info, level))
+ return true;
+ }
}
}
+
return false;
}
- //=========================================================
-
- WorldModel* VMapManager2::acquireModelInstance(const std::string &basepath, const std::string &filename)
+ WorldModel* VMapManager2::acquireModelInstance(const std::string& basepath, const std::string& filename)
{
ModelFileMap::iterator model = iLoadedModelFiles.find(filename);
if (model == iLoadedModelFiles.end())
{
- WorldModel *worldmodel = new WorldModel();
+ WorldModel* worldmodel = new WorldModel();
if (!worldmodel->readFile(basepath + filename + ".vmo"))
{
sLog->outError("VMapManager2: could not load '%s%s.vmo'", basepath.c_str(), filename.c_str());
@@ -290,18 +284,17 @@ namespace VMAP
sLog->outError("VMapManager2: trying to unload non-loaded file '%s'", filename.c_str());
return;
}
- if( model->second.decRefCount() == 0)
+ if (model->second.decRefCount() == 0)
{
sLog->outDebug(LOG_FILTER_MAPS, "VMapManager2: unloading file '%s'", filename.c_str());
delete model->second.getModel();
iLoadedModelFiles.erase(model);
}
}
- //=========================================================
- bool VMapManager2::existsMap(const char* pBasePath, unsigned int pMapId, int x, int y)
+ bool VMapManager2::existsMap(const char* basePath, unsigned int mapId, int x, int y)
{
- return StaticMapTree::CanLoadMap(std::string(pBasePath), pMapId, x, y);
+ return StaticMapTree::CanLoadMap(std::string(basePath), mapId, x, y);
}
} // namespace VMAP
diff --git a/src/server/collision/Management/VMapManager2.h b/src/server/collision/Management/VMapManager2.h
index 617218319c2..dc1b4c84ade 100755
--- a/src/server/collision/Management/VMapManager2.h
+++ b/src/server/collision/Management/VMapManager2.h
@@ -22,7 +22,6 @@
#include "IVMapManager.h"
#include "Dynamic/UnorderedMap.h"
#include "Define.h"
-#include <G3D/Vector3.h>
//===========================================================
@@ -40,6 +39,11 @@ Additionally a table to match map ids and map names is used.
//===========================================================
+namespace G3D
+{
+ class Vector3;
+}
+
namespace VMAP
{
class StaticMapTree;
@@ -48,17 +52,17 @@ namespace VMAP
class ManagedModel
{
public:
- ManagedModel(): iModel(0), iRefCount(0) {}
- void setModel(WorldModel *model) { iModel = model; }
- WorldModel *getModel() { return iModel; }
+ ManagedModel() : iModel(0), iRefCount(0) {}
+ void setModel(WorldModel* model) { iModel = model; }
+ WorldModel* getModel() { return iModel; }
void incRefCount() { ++iRefCount; }
int decRefCount() { return --iRefCount; }
protected:
- WorldModel *iModel;
+ WorldModel* iModel;
int iRefCount;
};
- typedef UNORDERED_MAP<uint32 , StaticMapTree *> InstanceTreeMap;
+ typedef UNORDERED_MAP<uint32, StaticMapTree*> InstanceTreeMap;
typedef UNORDERED_MAP<std::string, ManagedModel> ModelFileMap;
class VMapManager2 : public IVMapManager
@@ -68,44 +72,45 @@ namespace VMAP
ModelFileMap iLoadedModelFiles;
InstanceTreeMap iInstanceMapTrees;
- bool _loadMap(uint32 pMapId, const std::string &basePath, uint32 tileX, uint32 tileY);
+ bool _loadMap(uint32 mapId, const std::string& basePath, uint32 tileX, uint32 tileY);
/* void _unloadMap(uint32 pMapId, uint32 x, uint32 y); */
public:
// public for debug
G3D::Vector3 convertPositionToInternalRep(float x, float y, float z) const;
G3D::Vector3 convertPositionToMangosRep(float x, float y, float z) const;
- static std::string getMapFileName(unsigned int pMapId);
+ static std::string getMapFileName(unsigned int mapId);
VMapManager2();
~VMapManager2(void);
- int loadMap(const char* pBasePath, unsigned int pMapId, int x, int y);
+ int loadMap(const char* pBasePath, unsigned int mapId, int x, int y);
- void unloadMap(unsigned int pMapId, int x, int y);
- void unloadMap(unsigned int pMapId);
+ void unloadMap(unsigned int mapId, int x, int y);
+ void unloadMap(unsigned int mapId);
- bool isInLineOfSight(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2) ;
+ bool isInLineOfSight(unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2) ;
/**
fill the hit pos and return true, if an object was hit
*/
- bool getObjectHitPos(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float &ry, float& rz, float pModifyDist);
- float getHeight(unsigned int pMapId, float x, float y, float z, float maxSearchDist);
+ bool getObjectHitPos(unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float& ry, float& rz, float modifyDist);
+ float getHeight(unsigned int mapId, float x, float y, float z, float maxSearchDist);
- bool processCommand(char * /*pCommand*/) { return false; } // for debug and extensions
+ bool processCommand(char* /*command*/) { return false; } // for debug and extensions
- bool getAreaInfo(unsigned int pMapId, float x, float y, float &z, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const;
- bool GetLiquidLevel(uint32 pMapId, float x, float y, float z, uint8 ReqLiquidType, float &level, float &floor, uint32 &type) const;
+ bool getAreaInfo(unsigned int pMapId, float x, float y, float& z, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const;
+ bool GetLiquidLevel(uint32 pMapId, float x, float y, float z, uint8 reqLiquidType, float& level, float& floor, uint32& type) const;
- WorldModel* acquireModelInstance(const std::string &basepath, const std::string &filename);
- void releaseModelInstance(const std::string &filename);
+ WorldModel* acquireModelInstance(const std::string& basepath, const std::string& filename);
+ void releaseModelInstance(const std::string& filename);
// what's the use of this? o.O
- virtual std::string getDirFileName(unsigned int pMapId, int /*x*/, int /*y*/) const
+ virtual std::string getDirFileName(unsigned int mapId, int /*x*/, int /*y*/) const
{
- return getMapFileName(pMapId);
+ return getMapFileName(mapId);
}
- virtual bool existsMap(const char* pBasePath, unsigned int pMapId, int x, int y);
+ virtual bool existsMap(const char* basePath, unsigned int mapId, int x, int y);
};
}
+
#endif