Index: src/game/IVMapManager.h =================================================================== --- src/game/IVMapManager.h (revision 4063) +++ src/game/IVMapManager.h (working copy) @@ -19,6 +19,8 @@ #ifndef _IVMAPMANAGER_H #define _IVMAPMANAGER_H +#include + //=========================================================== /** @@ -70,6 +72,9 @@ It is enabled by default. If it is enabled in mid game the maps have to loaded manualy */ virtual void setEnableHeightCalc(bool pVal) =0; + virtual bool isHeightCalcEnabled() const =0; + virtual bool isMapLoadingEnabled() const =0; + virtual std::string getDirFileName(unsigned int pMapId, int x, int y) const =0; /** Block maps from being used. parameter: String of map ids. Delimiter = "," Index: src/game/Map.cpp =================================================================== --- src/game/Map.cpp (revision 4063) +++ src/game/Map.cpp (working copy) @@ -71,6 +71,19 @@ delete [] tmp; fclose(pf); + if(VMAP::VMapFactory::createOrGetVMapManager()->isMapLoadingEnabled()) + { + int vmapLoadResult = VMAP::VMapFactory::createOrGetVMapManager()->loadMap((sWorld.GetDataPath()+ "vmaps").c_str(), mapid, y,x); // x and y are swaped !! + if(vmapLoadResult != VMAP::VMAP_LOAD_RESULT_OK) + { + std::string name = VMAP::VMapFactory::createOrGetVMapManager()->getDirFileName(mapid,x,y); + sLog.outError("Could not load vmap file '%s'", (sWorld.GetDataPath()+"vmaps/"+name).c_str()); + return false; + } + + VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(mapid, y, x); // x and y are swaped + } + return true; } //========================================= @@ -1244,33 +1257,40 @@ if(!GridMaps[gx][gy]) //this map is not loaded GridMaps[gx][gy]=Map::LoadMAP(i_id,i_InstanceId,gx,gy); -#ifdef MANGOS_USE_VMAP_HEIGHT + + if(VMAP::VMapFactory::createOrGetVMapManager()->isHeightCalcEnabled()) + { float height = 0; bool mapHeightFound = false; - if(GridMaps[gx][gy]) { + if(GridMaps[gx][gy]) + { height = GridMaps[gx][gy]->Z[(int)(lx)][(int)(ly)]; mapHeightFound = true; } - if(pUseVmaps) { + if(pUseVmaps) + { float vmapheight = VMAP::VMapFactory::createOrGetVMapManager()->getHeight(GetId(), x, y, z + 4); // look from a bit higher pos to find the floor // if the land map did not find the height or if we are already under the surface and vmap found a height // or if the distance of the vmap height is less the land height distance - if(!mapHeightFound || (z -100000) || abs(height-z) > abs(vmapheight-z)) { + if(!mapHeightFound || (z -100000) || abs(height-z) > abs(vmapheight-z)) + { height = vmapheight; mapHeightFound = true; } } - if(!mapHeightFound || height < -100000) { + if(!mapHeightFound || height < -100000) + { height = 0; // fallback (should not happen) } - return height; -#else - - if(GridMaps[gx][gy]) - return GridMaps[gx][gy]->Z[(int)(lx)][(int)(ly)]; + return height; + } else - return 0; - #endif + { + if(GridMaps[gx][gy]) + return GridMaps[gx][gy]->Z[(int)(lx)][(int)(ly)]; + else + return 0; + } } uint16 Map::GetAreaFlag(float x, float y ) Index: src/game/VMapManager.h =================================================================== --- src/game/VMapManager.h (revision 4063) +++ src/game/VMapManager.h (working copy) @@ -127,9 +127,7 @@ private: bool _loadMap(const char* pBasePath, unsigned int pMapId, int x, int y, bool pForceTileLoad=false); void _unloadMap(unsigned int pMapId, int x, int y); - inline bool isMapLoadingEnabled() { return(iEnableLineOfSightCalc || iEnableHeightCalc ); } - inline bool isLineOfSightCalcEnabled() { return(iEnableLineOfSightCalc); } - inline bool isHeightCalcEnabled() { return(iEnableHeightCalc); } + bool isLineOfSightCalcEnabled() const { return(iEnableLineOfSightCalc); } public: // public for debug Vector3 convertPositionToInternalRep(float x, float y, float z) const; @@ -158,8 +156,9 @@ void setEnableLineOfSightCalc(bool pVal) { iEnableLineOfSightCalc = pVal; } void setEnableHeightCalc(bool pVal) { iEnableHeightCalc = pVal; } + bool isHeightCalcEnabled() const { return(iEnableHeightCalc); } + bool isMapLoadingEnabled() const { return(iEnableLineOfSightCalc || iEnableHeightCalc ); } void preventMapsFromBeingUsed(const char* pMapIdString); - }; } #endif Index: src/game/World.cpp =================================================================== --- src/game/World.cpp (revision 4063) +++ src/game/World.cpp (working copy) @@ -424,8 +424,8 @@ sLog.outString("Using DataDir %s",m_dataPath.c_str()); - bool enableLOS = sConfig.GetBoolDefault("vmap.enableLOS", true); - bool enableHeight = sConfig.GetBoolDefault("vmap.enableHeight", true); + bool enableLOS = sConfig.GetBoolDefault("vmap.enableLOS", false); + bool enableHeight = sConfig.GetBoolDefault("vmap.enableHeight", false); std::string ignoreMapIds = sConfig.GetStringDefault("vmap.ignoreMapIds", ""); std::string ignoreSpellIds = sConfig.GetStringDefault("vmap.ignoreSpellIds", ""); VMAP::VMapFactory::createOrGetVMapManager()->setEnableLineOfSightCalc(enableLOS); @@ -447,7 +447,7 @@ ||m_configs[CONFIG_EXPANSION] && ( !MapManager::ExistMAP(530,10349.6,-6357.29) || !MapManager::ExistMAP(530,-3961.64,-13931.2) ) ) { - sLog.outError("Correct *.map files not found in path '%smaps'. Please place *.map files in the directory pointed by this path or correct the DataDir value in the mangosd.conf file.",m_dataPath.c_str()); + sLog.outError("Correct *.map files not found in path '%smaps' OR (if you have LOS. Please place *.map files in the directory pointed by this path or correct the DataDir value in the mangosd.conf file.",m_dataPath.c_str()); exit(1); }