[9012] fix crash when achievement is completed and player isn't in world

also don't divide money loot for players who are not inside the
same map..
and player shouldn't be able to reclaim his corpse if it isn't in same map

and some other related cleanups
This commit is contained in:
balrok 2009-12-17 12:00:11 +01:00
parent 6057be2656
commit 7c4acf31e2
8 changed files with 26 additions and 24 deletions

View file

@ -592,7 +592,8 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement)
data << uint32(0); // 1=link supplied string as player name, 0=display plain string data << uint32(0); // 1=link supplied string as player name, 0=display plain string
sWorld.SendGlobalMessage(&data); 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()); CellPair p = MaNGOS::ComputeCellPair(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());

View file

@ -471,22 +471,11 @@ void BattleGroundWS::HandleAreaTrigger(Player *Source, uint32 Trigger)
switch(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(). 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(). 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 case 3706: // Alliance elixir of regeneration spawn
//buff_guid = m_BgObjects[BG_WS_OBJECT_REGENBUFF_1];
break;
case 3708: // Horde elixir of regeneration spawn case 3708: // Horde elixir of regeneration spawn
//buff_guid = m_BgObjects[BG_WS_OBJECT_REGENBUFF_2];
break;
case 3707: // Alliance elixir of berserk spawn case 3707: // Alliance elixir of berserk spawn
//buff_guid = m_BgObjects[BG_WS_OBJECT_BERSERKBUFF_1];
break;
case 3709: // Horde elixir of berserk spawn case 3709: // Horde elixir of berserk spawn
//buff_guid = m_BgObjects[BG_WS_OBJECT_BERSERKBUFF_2];
break; break;
case 3646: // Alliance Flag spawn case 3646: // Alliance Flag spawn
if (m_FlagState[BG_TEAM_HORDE] && !m_FlagState[BG_TEAM_ALLIANCE]) 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); Source->GetSession()->SendAreaTriggerMessage("Warning: Unhandled AreaTrigger in Battleground: %u", Trigger);
break; break;
} }
//if (buff_guid)
// HandleTriggerBuff(buff_guid,Source);
} }
bool BattleGroundWS::SetupBattleGround() bool BattleGroundWS::SetupBattleGround()

View file

@ -221,7 +221,7 @@ void WorldSession::HandleLootMoneyOpcode( WorldPacket & /*recv_data*/ )
Player* playerGroup = itr->getSource(); Player* playerGroup = itr->getSource();
if(!playerGroup) if(!playerGroup)
continue; 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); playersNear.push_back(playerGroup);
} }

View file

@ -636,7 +636,7 @@ void WorldSession::HandleReclaimCorpseOpcode(WorldPacket &recv_data)
if(corpse->GetGhostTime() + GetPlayer()->GetCorpseReclaimDelay(corpse->GetType()==CORPSE_RESURRECTABLE_PVP) > time(NULL)) if(corpse->GetGhostTime() + GetPlayer()->GetCorpseReclaimDelay(corpse->GetType()==CORPSE_RESURRECTABLE_PVP) > time(NULL))
return; return;
if (!corpse->IsWithinDist(GetPlayer(), CORPSE_RECLAIM_RADIUS, true)) if (!corpse->IsWithinDistInMap(GetPlayer(), CORPSE_RECLAIM_RADIUS, true))
return; return;
uint64 guid; uint64 guid;

View file

@ -1429,6 +1429,16 @@ bool WorldObject::isInBackInMap(WorldObject const* target, float distance, float
return IsWithinDistInMap(target, distance) && !HasInArc( 2 * M_PI - arc, target ); 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 void WorldObject::GetRandomPoint( float x, float y, float z, float distance, float &rand_x, float &rand_y, float &rand_z) const
{ {
if(distance == 0) if(distance == 0)

View file

@ -436,11 +436,13 @@ class MANGOS_DLL_SPEC WorldObject : public Object
bool IsWithinDist3d(float x, float y, float z, float dist2compare) const; bool IsWithinDist3d(float x, float y, float z, float dist2compare) const;
bool IsWithinDist2d(float x, float y, float dist2compare) const; bool IsWithinDist2d(float x, float y, float dist2compare) const;
bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D) 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 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); return obj && _IsWithinDist(obj,dist2compare,is3D);
} }
bool IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D = true) const bool IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D = true) const
{ {
return obj && IsInMap(obj) && _IsWithinDist(obj,dist2compare,is3D); 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 HasInArc( const float arcangle, const WorldObject* obj ) const;
bool isInFrontInMap(WorldObject const* target,float distance, float arc = M_PI) 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 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 virtual void CleanupsBeforeDelete(); // used in destructor or explicitly before mass creature delete to remove cross-references to already deleted units

View file

@ -705,26 +705,27 @@ namespace MaNGOS
default: continue; default: continue;
} }
// we don't need to check InMap here, it's already done some lines above
switch(i_push_type) switch(i_push_type)
{ {
case PUSH_IN_FRONT: 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()); i_data->push_back(itr->getSource());
break; break;
case PUSH_IN_FRONT_90: 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()); i_data->push_back(itr->getSource());
break; break;
case PUSH_IN_FRONT_30: 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()); i_data->push_back(itr->getSource());
break; break;
case PUSH_IN_FRONT_15: 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()); i_data->push_back(itr->getSource());
break; break;
case PUSH_IN_BACK: 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()); i_data->push_back(itr->getSource());
break; break;
case PUSH_SELF_CENTER: case PUSH_SELF_CENTER:

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "9011" #define REVISION_NR "9012"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__