Skip to content

Commit

Permalink
[12027] Add some VMap LoS checking functions to Map scope
Browse files Browse the repository at this point in the history
  • Loading branch information
Reamer authored and Schmoozerd committed Jul 5, 2012
1 parent 0e531be commit 752e4aa
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 19 deletions.
19 changes: 19 additions & 0 deletions src/game/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
3 changes: 3 additions & 0 deletions src/game/Map.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
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; }
Expand Down
3 changes: 1 addition & 2 deletions src/game/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 3 additions & 9 deletions src/game/SpellEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]));

Expand All @@ -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);
}
Expand Down
8 changes: 1 addition & 7 deletions src/game/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "12026"
#define REVISION_NR "12027"
#endif // __REVISION_NR_H__

0 comments on commit 752e4aa

Please sign in to comment.