aboutsummaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorsilver1ce <none@none>2010-01-06 12:15:02 +0200
committersilver1ce <none@none>2010-01-06 12:15:02 +0200
commitf82d5cb3fcef169cf7a62f83935fa6d6b105589d (patch)
tree690e156be323518c0c2ad5372f01684097b5e2f7 /src/game
parent4a0af0314ee066f37ecb2a7fb8096ae8180dc966 (diff)
fixed the bug that GetVmapHeight returns incorrect height on terrains(flying units fall below map etc)
also unlocked max ray lenght for getHeight, by default it's 10 yards --HG-- branch : trunk
Diffstat (limited to 'src/game')
-rw-r--r--src/game/Creature.cpp2
-rw-r--r--src/game/Map.cpp29
-rw-r--r--src/game/Map.h2
-rw-r--r--src/game/Player.cpp2
-rw-r--r--src/game/Spell.cpp2
5 files changed, 18 insertions, 19 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index 818e01bb396..9fcd1cd48ac 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -1477,7 +1477,7 @@ bool Creature::FallGround()
float x, y, z;
GetPosition(x, y, z);
- float ground_Z = GetMap()->GetVmapHeight(x, y, z, true);
+ float ground_Z = GetMap()->GetVmapHeight(x, y, z);
if (fabs(ground_Z - z) < 0.1f)
return false;
diff --git a/src/game/Map.cpp b/src/game/Map.cpp
index 8e72be7ad5e..4fe35bd889b 100644
--- a/src/game/Map.cpp
+++ b/src/game/Map.cpp
@@ -1994,24 +1994,23 @@ float Map::GetHeight(float x, float y, float z, bool pUseVmaps) const
}
}
-float Map::GetVmapHeight(float x, float y, float z, bool useMaps) const
+float Map::GetVmapHeight(float x, float y, float z) const
{
float mapHeight;
- float vmapHeight;
- if (useMaps)
- {
- mapHeight = GetHeight(x, y, z, false);
- if (fabs(mapHeight - z) < 0.1)
- return mapHeight;
- }
- else
- mapHeight = INVALID_HEIGHT;
+
+ mapHeight = GetHeight(x, y, z, false);
+ if (fabs(mapHeight - z) < 0.1)
+ return mapHeight;
+
VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager();
- if (vmgr->isLineOfSightCalcEnabled())
- bool result = vmgr->getObjectHitPos(GetId(), x, y, z + 2.0f, x, y, mapHeight, x, y, vmapHeight, 0);
- else
- return INVALID_HEIGHT;
- return vmapHeight;
+ if (!vmgr->isLineOfSightCalcEnabled())
+ return mapHeight;
+
+ float vmapHeight = vmgr->getHeight(GetId(), x, y, z + 2.0f, z + 2.0f - mapHeight);
+ if (vmapHeight > VMAP_INVALID_HEIGHT_VALUE)
+ return vmapHeight;
+
+ return mapHeight;
}
uint16 Map::GetAreaFlag(float x, float y, float z) const
diff --git a/src/game/Map.h b/src/game/Map.h
index 494618baa8e..a1958677807 100644
--- a/src/game/Map.h
+++ b/src/game/Map.h
@@ -333,7 +333,7 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O
// some calls like isInWater should not use vmaps due to processor power
// can return INVALID_HEIGHT if under z+2 z coord not found height
float GetHeight(float x, float y, float z, bool pCheckVMap=true) const;
- float GetVmapHeight(float x, float y, float z, bool useMaps) const;
+ float GetVmapHeight(float x, float y, float z) const;
bool IsInWater(float x, float y, float z, float min_depth = 2.0f) const;
ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData *data = 0) const;
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 8c98e1c0876..ed728429f1e 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -4476,7 +4476,7 @@ bool Player::FallGround(uint8 FallMode)
float x, y, z;
GetPosition(x, y, z);
- float ground_Z = GetMap()->GetVmapHeight(x, y, z, true);
+ float ground_Z = GetMap()->GetVmapHeight(x, y, z);
float z_diff = 0.0f;
if ((z_diff = fabs(ground_Z - z)) < 0.1f)
return false;
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 9aa54f9b14e..6db68f9a92c 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -5177,7 +5177,7 @@ SpellCastResult Spell::CheckCast(bool strict)
{
float x, y, z;
m_caster->GetPosition(x, y, z);
- float ground_Z = m_caster->GetMap()->GetVmapHeight(x, y, z, true);
+ float ground_Z = m_caster->GetMap()->GetVmapHeight(x, y, z);
if (fabs(ground_Z - z) < 0.1f)
return SPELL_FAILED_DONT_REPORT;
break;