diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 7cb8049bb..ca8c28714 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -1935,3 +1935,22 @@ void Map::PlayDirectSoundToMap(uint32 soundId, uint32 zoneId /*=0*/) if (!zoneId || itr->getSource()->GetZoneId() == zoneId) itr->getSource()->SendDirectMessage(&data); } + +/** + * Function to check if a point is in line of sight from an other point + */ +bool Map::IsInLineOfSight(float srcX, float srcY, float srcZ, float destX, float destY, float destZ) +{ + VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); + return vMapManager->isInLineOfSight(GetId(), srcX, srcY, srcZ, destX, destY, destZ); +} + +/** + * get the hit position and return true if we hit something + * otherwise the result pos will be the dest pos + */ +bool Map::GetObjectHitPos(float srcX, float srcY, float srcZ, float destX, float destY, float destZ, float& resX, float &resY, float& resZ, float pModifyDist) +{ + VMAP::IVMapManager* vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); + return vMapManager->getObjectHitPos(GetId(), srcX, srcY, srcZ, destX, destY, destZ, resX, resY, resZ, pModifyDist); +} diff --git a/src/game/Map.h b/src/game/Map.h index a3111ee58..5093b0d56 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -260,6 +260,9 @@ class MANGOS_DLL_SPEC Map : public GridRefManager void MonsterYellToMap(CreatureInfo const* cinfo, int32 textId, uint32 language, Unit* target, uint32 senderLowGuid = 0); void PlayDirectSoundToMap(uint32 soundId, uint32 zoneId = 0); + // VMap System + bool IsInLineOfSight(float srcX, float srcY, float srcZ, float destX, float destY, float destZ); + bool GetObjectHitPos(float srcX, float srcY, float srcZ, float destX, float destY, float destZ, float& resX, float &resY, float& resZ, float pModifyDist); // Get Holder for Creature Linking CreatureLinkingHolder* GetCreatureLinkingHolder() { return &m_creatureLinkingHolder; } diff --git a/src/game/Object.cpp b/src/game/Object.cpp index b775a2508..970528500 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1101,8 +1101,7 @@ bool WorldObject::IsWithinLOS(float ox, float oy, float oz) const { float x,y,z; GetPosition(x,y,z); - VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager(); - return vMapManager->isInLineOfSight(GetMapId(), x, y, z+2.0f, ox, oy, oz+2.0f); + return GetMap()->IsInLineOfSight(x, y, z+2.0f, ox, oy, oz+2.0f); } bool WorldObject::GetDistanceOrder(WorldObject const* obj1, WorldObject const* obj2, bool is3D /* = true */) const diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index e064358cd..9dcb98f79 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -8777,10 +8777,10 @@ void Spell::EffectBlock(SpellEffectIndex /*eff_idx*/) void Spell::EffectLeapForward(SpellEffectIndex eff_idx) { - if(unitTarget->IsTaxiFlying()) + if (unitTarget->IsTaxiFlying()) return; - if( m_spellInfo->rangeIndex == 1) //self range + if (m_spellInfo->rangeIndex == 1) // self range { float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[eff_idx])); @@ -8790,14 +8790,8 @@ void Spell::EffectLeapForward(SpellEffectIndex eff_idx) float ox, oy, oz; unitTarget->GetPosition(ox, oy, oz); - float fx2, fy2, fz2; // getObjectHitPos overwrite last args in any result case - if(VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(unitTarget->GetMapId(), ox,oy,oz+0.5f, fx,fy,oz+0.5f,fx2,fy2,fz2, -0.5f)) - { - fx = fx2; - fy = fy2; - fz = fz2; + if (unitTarget->GetMap()->GetObjectHitPos(ox,oy,oz+0.5f, fx,fy,oz+0.5f,fx,fy,fz, -0.5f)) unitTarget->UpdateAllowedPositionZ(fx, fy, fz); - } unitTarget->NearTeleportTo(fx, fy, fz, unitTarget->GetOrientation(), unitTarget == m_caster); } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 55ffd5d93..c8d8a4f56 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -10640,13 +10640,7 @@ void Unit::KnockBackFrom(Unit* target, float horizontalSpeed, float verticalSpee float fx = ox + dis * vcos; float fy = oy + dis * vsin; float fz = oz; - float fx2, fy2, fz2; // getObjectHitPos overwrite last args in any result case - if(VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(GetMapId(), ox,oy,oz+0.5f, fx,fy,oz+0.5f,fx2,fy2,fz2, -0.5f)) - { - fx = fx2; - fy = fy2; - fz = fz2; - } + GetMap()->GetObjectHitPos(ox,oy,oz+0.5f, fx,fy,oz+0.5f,fx,fy,fz, -0.5f); UpdateAllowedPositionZ(fx, fy, fz); GetMotionMaster()->MoveJump(fx,fy,fz,horizontalSpeed,max_height); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index e0aa1059a..8afd51785 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 "12026" + #define REVISION_NR "12027" #endif // __REVISION_NR_H__