diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 2af090520..28ab92b86 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -1016,12 +1016,12 @@ float Map::GetHeight(float x, float y, float z, bool pUseVmaps, float maxSearchD // find raw .map surface under Z coordinates float mapHeight; float z2 = z + 2.f; - if(GridMap *gmap = const_cast(this)->GetGrid(x, y)) + if (GridMap *gmap = const_cast(this)->GetGrid(x, y)) { float _mapheight = gmap->getHeight(x,y); // look from a bit higher pos to find the floor, ignore under surface case - if(z2 > _mapheight) + if (z2 > _mapheight) mapHeight = _mapheight; else mapHeight = VMAP_INVALID_HEIGHT_VALUE; @@ -1030,11 +1030,17 @@ float Map::GetHeight(float x, float y, float z, bool pUseVmaps, float maxSearchD mapHeight = VMAP_INVALID_HEIGHT_VALUE; float vmapHeight; - if(pUseVmaps) + if (pUseVmaps) { VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager(); - if(vmgr->isHeightCalcEnabled()) + if (vmgr->isHeightCalcEnabled()) { + // if mapHeight has been found search vmap height at least until mapHeight point + // this prevent case when original Z "too high above ground and vmap height search fail" + // this will not affect most normal cases (no map in instance, or stay at ground at continent) + if (mapHeight > INVALID_HEIGHT && z2 - mapHeight > maxSearchDist) + maxSearchDist = z2 - mapHeight + 1.0f; // 1.0 make sure that we not fail for case when map height near but above for vamp height + // look from a bit higher pos to find the floor vmapHeight = vmgr->getHeight(GetId(), x, y, z2, maxSearchDist); } @@ -1047,15 +1053,15 @@ float Map::GetHeight(float x, float y, float z, bool pUseVmaps, float maxSearchD // mapHeight set for any above raw ground Z or <= INVALID_HEIGHT // vmapheight set for any under Z value or <= INVALID_HEIGHT - if( vmapHeight > INVALID_HEIGHT ) + if (vmapHeight > INVALID_HEIGHT) { - if( mapHeight > INVALID_HEIGHT ) + if (mapHeight > INVALID_HEIGHT) { // we have mapheight and vmapheight and must select more appropriate // we are already under the surface or vmap height above map heigt // or if the distance of the vmap height is less the land height distance - if( z < mapHeight || vmapHeight > mapHeight || fabs(mapHeight-z) > fabs(vmapHeight-z) ) + if (z < mapHeight || vmapHeight > mapHeight || fabs(mapHeight-z) > fabs(vmapHeight-z)) return vmapHeight; else return mapHeight; // better use .map surface height @@ -1064,12 +1070,6 @@ float Map::GetHeight(float x, float y, float z, bool pUseVmaps, float maxSearchD else return vmapHeight; // we have only vmapHeight (if have) } - else if (pUseVmaps && z2 - mapHeight > maxSearchDist) - { - // with vmaps we can only give definite result up to maxSearchDist, - // in other cases mapHeight might or might not be the true height. - return VMAP_INVALID_HEIGHT_VALUE; - } return mapHeight; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 270a0533b..bb6048b72 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10438" + #define REVISION_NR "10439" #endif // __REVISION_NR_H__