diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp index e4c0b590f..1a4a55412 100644 --- a/src/game/AchievementMgr.cpp +++ b/src/game/AchievementMgr.cpp @@ -592,7 +592,8 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement) data << uint32(0); // 1=link supplied string as player name, 0=display plain string sWorld.SendGlobalMessage(&data); } - else + // if player is in world he can tell his friends about new achievement + else if (GetPlayer()->IsInWorld()) { CellPair p = MaNGOS::ComputeCellPair(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY()); diff --git a/src/game/BattleGroundWS.cpp b/src/game/BattleGroundWS.cpp index 847ce6bc1..71c5aa30c 100644 --- a/src/game/BattleGroundWS.cpp +++ b/src/game/BattleGroundWS.cpp @@ -471,22 +471,11 @@ void BattleGroundWS::HandleAreaTrigger(Player *Source, uint32 Trigger) switch(Trigger) { case 3686: // Alliance elixir of speed spawn. Trigger not working, because located inside other areatrigger, can be replaced by IsWithinDist(object, dist) in BattleGround::Update(). - //buff_guid = m_BgObjects[BG_WS_OBJECT_SPEEDBUFF_1]; - break; case 3687: // Horde elixir of speed spawn. Trigger not working, because located inside other areatrigger, can be replaced by IsWithinDist(object, dist) in BattleGround::Update(). - //buff_guid = m_BgObjects[BG_WS_OBJECT_SPEEDBUFF_2]; - break; case 3706: // Alliance elixir of regeneration spawn - //buff_guid = m_BgObjects[BG_WS_OBJECT_REGENBUFF_1]; - break; case 3708: // Horde elixir of regeneration spawn - //buff_guid = m_BgObjects[BG_WS_OBJECT_REGENBUFF_2]; - break; case 3707: // Alliance elixir of berserk spawn - //buff_guid = m_BgObjects[BG_WS_OBJECT_BERSERKBUFF_1]; - break; case 3709: // Horde elixir of berserk spawn - //buff_guid = m_BgObjects[BG_WS_OBJECT_BERSERKBUFF_2]; break; case 3646: // Alliance Flag spawn if (m_FlagState[BG_TEAM_HORDE] && !m_FlagState[BG_TEAM_ALLIANCE]) @@ -508,9 +497,6 @@ void BattleGroundWS::HandleAreaTrigger(Player *Source, uint32 Trigger) Source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger); break; } - - //if (buff_guid) - // HandleTriggerBuff(buff_guid,Source); } bool BattleGroundWS::SetupBattleGround() diff --git a/src/game/LootHandler.cpp b/src/game/LootHandler.cpp index a19e8d014..4a772ba80 100644 --- a/src/game/LootHandler.cpp +++ b/src/game/LootHandler.cpp @@ -221,7 +221,7 @@ void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ ) Player* playerGroup = itr->getSource(); if(!playerGroup) continue; - if (player->IsWithinDist(playerGroup,sWorld.getConfig(CONFIG_GROUP_XP_DISTANCE),false)) + if (player->IsWithinDistInMap(playerGroup,sWorld.getConfig(CONFIG_GROUP_XP_DISTANCE),false)) playersNear.push_back(playerGroup); } diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index c0950dbaf..1094865fa 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -636,7 +636,7 @@ void WorldSession::HandleReclaimCorpseOpcode(WorldPacket &recv_data) if(corpse->GetGhostTime() + GetPlayer()->GetCorpseReclaimDelay(corpse->GetType()==CORPSE_RESURRECTABLE_PVP) > time(NULL)) return; - if (!corpse->IsWithinDist(GetPlayer(), CORPSE_RECLAIM_RADIUS, true)) + if (!corpse->IsWithinDistInMap(GetPlayer(), CORPSE_RECLAIM_RADIUS, true)) return; uint64 guid; diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 495de195e..cc59980f7 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1429,6 +1429,16 @@ bool WorldObject::isInBackInMap(WorldObject const* target, float distance, float return IsWithinDistInMap(target, distance) && !HasInArc( 2 * M_PI - arc, target ); } +bool WorldObject::isInFront(WorldObject const* target, float distance, float arc) const +{ + return IsWithinDist(target, distance) && HasInArc( arc, target ); +} + +bool WorldObject::isInBack(WorldObject const* target, float distance, float arc) const +{ + return IsWithinDist(target, distance) && !HasInArc( 2 * M_PI - arc, target ); +} + void WorldObject::GetRandomPoint( float x, float y, float z, float distance, float &rand_x, float &rand_y, float &rand_z) const { if(distance == 0) diff --git a/src/game/Object.h b/src/game/Object.h index 4707f4717..3372ec23e 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -436,11 +436,13 @@ class MANGOS_DLL_SPEC WorldObject : public Object bool IsWithinDist3d(float x, float y, float z, float dist2compare) const; bool IsWithinDist2d(float x, float y, float dist2compare) const; bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D) const; + + // use only if you will sure about placing both object at same map bool IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D = true) const - // use only if you will sure about placing both object at same map { return obj && _IsWithinDist(obj,dist2compare,is3D); } + bool IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D = true) const { return obj && IsInMap(obj) && _IsWithinDist(obj,dist2compare,is3D); @@ -457,6 +459,8 @@ class MANGOS_DLL_SPEC WorldObject : public Object bool HasInArc( const float arcangle, const WorldObject* obj ) const; bool isInFrontInMap(WorldObject const* target,float distance, float arc = M_PI) const; bool isInBackInMap(WorldObject const* target, float distance, float arc = M_PI) const; + bool isInFront(WorldObject const* target,float distance, float arc = M_PI) const; + bool isInBack(WorldObject const* target, float distance, float arc = M_PI) const; virtual void CleanupsBeforeDelete(); // used in destructor or explicitly before mass creature delete to remove cross-references to already deleted units diff --git a/src/game/Spell.h b/src/game/Spell.h index 096511463..206b0f073 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -705,26 +705,27 @@ namespace MaNGOS default: continue; } + // we don't need to check InMap here, it's already done some lines above switch(i_push_type) { case PUSH_IN_FRONT: - if(i_spell.GetCaster()->isInFrontInMap((Unit*)(itr->getSource()), i_radius, 2*M_PI/3 )) + if(i_spell.GetCaster()->isInFront((Unit*)(itr->getSource()), i_radius, 2*M_PI/3 )) i_data->push_back(itr->getSource()); break; case PUSH_IN_FRONT_90: - if(i_spell.GetCaster()->isInFrontInMap((Unit*)(itr->getSource()), i_radius, M_PI/2 )) + if(i_spell.GetCaster()->isInFront((Unit*)(itr->getSource()), i_radius, M_PI/2 )) i_data->push_back(itr->getSource()); break; case PUSH_IN_FRONT_30: - if(i_spell.GetCaster()->isInFrontInMap((Unit*)(itr->getSource()), i_radius, M_PI/6 )) + if(i_spell.GetCaster()->isInFront((Unit*)(itr->getSource()), i_radius, M_PI/6 )) i_data->push_back(itr->getSource()); break; case PUSH_IN_FRONT_15: - if(i_spell.GetCaster()->isInFrontInMap((Unit*)(itr->getSource()), i_radius, M_PI/12 )) + if(i_spell.GetCaster()->isInFront((Unit*)(itr->getSource()), i_radius, M_PI/12 )) i_data->push_back(itr->getSource()); break; case PUSH_IN_BACK: - if(i_spell.GetCaster()->isInBackInMap((Unit*)(itr->getSource()), i_radius, 2*M_PI/3 )) + if(i_spell.GetCaster()->isInBack((Unit*)(itr->getSource()), i_radius, 2*M_PI/3 )) i_data->push_back(itr->getSource()); break; case PUSH_SELF_CENTER: diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index aea038566..00de098e1 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 "9011" + #define REVISION_NR "9012" #endif // __REVISION_NR_H__