mirror of
https://github.com/araxiaonline/TrinityCore2.git
synced 2026-06-18 13:59:39 -04:00
*Cleanup of charm/farsight code. Hope this can fix some crash bugs.
--HG-- branch : trunk
This commit is contained in:
+10
-14
@@ -7290,19 +7290,19 @@ bool ChatHandler::HandlePossessCommand(const char* args)
|
||||
if(!pUnit)
|
||||
return false;
|
||||
|
||||
// Don't allow unlimited possession of players
|
||||
if (pUnit->GetTypeId() == TYPEID_PLAYER)
|
||||
return false;
|
||||
|
||||
pUnit->SetCharmedOrPossessedBy(m_session->GetPlayer(), true);
|
||||
|
||||
m_session->GetPlayer()->CastSpell(pUnit, 530, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleUnPossessCommand(const char* args)
|
||||
{
|
||||
// Use this command to also unpossess ourselves
|
||||
m_session->GetPlayer()->RemoveCharmedOrPossessedBy(NULL);
|
||||
Unit* pUnit = getSelectedUnit();
|
||||
if(!pUnit) pUnit = m_session->GetPlayer();
|
||||
|
||||
pUnit->RemoveSpellsCausingAura(SPELL_AURA_MOD_CHARM);
|
||||
pUnit->RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS_PET);
|
||||
pUnit->RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7312,11 +7312,7 @@ bool ChatHandler::HandleBindSightCommand(const char* args)
|
||||
if (!pUnit)
|
||||
return false;
|
||||
|
||||
if (m_session->GetPlayer()->isPossessing())
|
||||
return false;
|
||||
|
||||
pUnit->AddPlayerToVision(m_session->GetPlayer());
|
||||
|
||||
m_session->GetPlayer()->CastSpell(pUnit, 6277, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7325,6 +7321,6 @@ bool ChatHandler::HandleUnbindSightCommand(const char* args)
|
||||
if (m_session->GetPlayer()->isPossessing())
|
||||
return false;
|
||||
|
||||
m_session->GetPlayer()->RemoveFarsightTarget();
|
||||
m_session->GetPlayer()->StopCastingBindSight();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ void WorldSession::HandlePossessedMovement(WorldPacket& recv_data, MovementInfo&
|
||||
// Remove possession if possessed unit enters a transport
|
||||
if (MovementFlags & MOVEMENTFLAG_ONTRANSPORT)
|
||||
{
|
||||
GetPlayer()->RemovePossess(true);
|
||||
GetPlayer()->Uncharm();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ void WorldSession::HandlePossessedMovement(WorldPacket& recv_data, MovementInfo&
|
||||
|
||||
if(movementInfo.z < -500.0f)
|
||||
{
|
||||
GetPlayer()->RemovePossess(false);
|
||||
GetPlayer()->Uncharm();
|
||||
plr->HandleFallUnderMap();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-12
@@ -153,12 +153,7 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
|
||||
p->setDeathState(CORPSE);
|
||||
}
|
||||
else // charmed or possessed
|
||||
{
|
||||
if (_player->isPossessing())
|
||||
_player->RemovePossess(true);
|
||||
else
|
||||
_player->Uncharm();
|
||||
}
|
||||
_player->Uncharm();
|
||||
break;
|
||||
default:
|
||||
sLog.outError("WORLD: unknown PET flag Action %i and spellid %i.\n", flag, spellid);
|
||||
@@ -495,12 +490,7 @@ void WorldSession::HandlePetAbandon( WorldPacket & recv_data )
|
||||
_player->RemovePet((Pet*)pet,PET_SAVE_AS_DELETED);
|
||||
}
|
||||
else if(pet->GetGUID() == _player->GetCharmGUID())
|
||||
{
|
||||
if (_player->isPossessing())
|
||||
_player->RemovePossess(true);
|
||||
else
|
||||
_player->Uncharm();
|
||||
}
|
||||
_player->Uncharm();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-63
@@ -471,9 +471,6 @@ Player::~Player ()
|
||||
for(BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr)
|
||||
itr->second.save->RemovePlayer(this);
|
||||
|
||||
if (m_uint32Values && isPossessing())
|
||||
RemovePossess(false);
|
||||
|
||||
delete m_declinedname;
|
||||
}
|
||||
|
||||
@@ -1351,12 +1348,6 @@ void Player::setDeathState(DeathState s)
|
||||
RemoveMiniPet();
|
||||
RemoveGuardians();
|
||||
|
||||
// remove possession
|
||||
if(isPossessing())
|
||||
RemovePossess(false);
|
||||
else
|
||||
RemoveFarsightTarget();
|
||||
|
||||
// save value before aura remove in Unit::setDeathState
|
||||
ressSpellId = GetUInt32Value(PLAYER_SELF_RES_SPELL);
|
||||
|
||||
@@ -1619,18 +1610,6 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
|
||||
|
||||
SetSemaphoreTeleport(true);
|
||||
|
||||
// Remove any possession on the player before teleporting
|
||||
if (isPossessedByPlayer())
|
||||
((Player*)GetCharmer())->RemovePossess();
|
||||
|
||||
// Remove player's possession before teleporting
|
||||
if (isPossessing())
|
||||
RemovePossess(false);
|
||||
|
||||
// Empty vision list and clear farsight (if it hasn't already been cleared by RemovePossess) before teleporting
|
||||
RemoveAllFromVision();
|
||||
RemoveFarsightTarget();
|
||||
|
||||
// The player was ported to another map and looses the duel immediatly.
|
||||
// We have to perform this check before the teleport, otherwise the
|
||||
// ObjectAccessor won't find the flag.
|
||||
@@ -1857,12 +1836,13 @@ void Player::RemoveFromWorld()
|
||||
if(IsInWorld())
|
||||
{
|
||||
///- Release charmed creatures, unsummon totems and remove pets/guardians
|
||||
RemovePossess(false);
|
||||
Uncharm();
|
||||
StopCastingCharm();
|
||||
StopCastingBindSight();
|
||||
RemoveCharmAuras();
|
||||
RemoveBindSightAuras();
|
||||
UnsummonAllTotems();
|
||||
RemoveMiniPet();
|
||||
RemoveGuardians();
|
||||
RemoveFarsightTarget();
|
||||
}
|
||||
|
||||
for(int i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; i++)
|
||||
@@ -16270,6 +16250,8 @@ void Player::Uncharm()
|
||||
return;
|
||||
|
||||
charm->RemoveSpellsCausingAura(SPELL_AURA_MOD_CHARM);
|
||||
charm->RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS_PET);
|
||||
charm->RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS);
|
||||
}
|
||||
|
||||
void Player::BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const
|
||||
@@ -19054,41 +19036,6 @@ void Player::HandleFallUnderMap()
|
||||
}
|
||||
}
|
||||
|
||||
void Player::RemovePossess(bool attack)
|
||||
{
|
||||
if(Unit *u = GetCharm())
|
||||
u->RemoveCharmedOrPossessedBy(this);
|
||||
|
||||
/*else if (target->isAlive())
|
||||
{
|
||||
// If we're still hostile to our target, continue attacking otherwise reset threat and go home
|
||||
if (Unit* victim = target->getVictim())
|
||||
{
|
||||
FactionTemplateEntry const* t_faction = target->getFactionTemplateEntry();
|
||||
FactionTemplateEntry const* v_faction = victim->getFactionTemplateEntry();
|
||||
// Unit::IsHostileTo will always return true since the unit is always hostile to its victim
|
||||
if (t_faction && v_faction && !t_faction->IsHostileTo(*v_faction))
|
||||
{
|
||||
// Stop combat and remove the target from the threat lists of all its victims
|
||||
target->CombatStop();
|
||||
target->getHostilRefManager().deleteReferences();
|
||||
target->DeleteThreatList();
|
||||
target->GetMotionMaster()->Clear();
|
||||
target->GetMotionMaster()->MoveTargetedHome();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
target->GetMotionMaster()->Clear();
|
||||
target->GetMotionMaster()->MoveTargetedHome();
|
||||
}
|
||||
|
||||
// Add high amount of threat on the player
|
||||
if(attack)
|
||||
target->AddThreat(this, 1000000.0f);
|
||||
}*/
|
||||
}
|
||||
|
||||
void Player::SetViewport(uint64 guid, bool moveable)
|
||||
{
|
||||
WorldPacket data(SMSG_CLIENT_CONTROL_UPDATE, 8+1);
|
||||
@@ -19106,14 +19053,13 @@ WorldObject* Player::GetFarsightTarget() const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Player::RemoveFarsightTarget()
|
||||
void Player::StopCastingBindSight()
|
||||
{
|
||||
if (WorldObject* fTarget = GetFarsightTarget())
|
||||
{
|
||||
if (fTarget->isType(TYPEMASK_PLAYER | TYPEMASK_UNIT))
|
||||
((Unit*)fTarget)->RemovePlayerFromVision(this);
|
||||
((Unit*)fTarget)->RemoveSpellsCausingAura(SPELL_AURA_BIND_SIGHT);
|
||||
}
|
||||
ClearFarsight();
|
||||
}
|
||||
|
||||
void Player::ClearFarsight()
|
||||
@@ -19132,7 +19078,7 @@ void Player::SetFarsightTarget(WorldObject* obj)
|
||||
return;
|
||||
|
||||
// Remove the current target if there is one
|
||||
RemoveFarsightTarget();
|
||||
StopCastingBindSight();
|
||||
|
||||
SetUInt64Value(PLAYER_FARSIGHT, obj->GetGUID());
|
||||
}
|
||||
|
||||
+3
-9
@@ -899,17 +899,11 @@ class TRINITY_DLL_SPEC Player : public Unit
|
||||
void RemoveFromWorld();
|
||||
|
||||
void SetViewport(uint64 guid, bool movable);
|
||||
void RemovePossess(bool attack = true);
|
||||
void StopCharmOrPossess()
|
||||
{
|
||||
if(isPossessing())
|
||||
RemovePossess(true);
|
||||
else if(GetCharm())
|
||||
Uncharm();
|
||||
}
|
||||
void StopCastingCharm() { Uncharm(); }
|
||||
void StopBindSight();
|
||||
WorldObject* GetFarsightTarget() const;
|
||||
void ClearFarsight();
|
||||
void RemoveFarsightTarget();
|
||||
void StopCastingBindSight();
|
||||
void SetFarsightTarget(WorldObject* target);
|
||||
// Controls if vision is currently on farsight object, updated in FAR_SIGHT opcode
|
||||
void SetFarsightVision(bool apply) { m_farsightVision = apply; }
|
||||
|
||||
@@ -2172,11 +2172,11 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
|
||||
{
|
||||
Creature *totem = ObjectAccessor::GetCreature(*caster, guid);
|
||||
if (totem && totem->isTotem())
|
||||
totem->AddPlayerToVision((Player*)caster);
|
||||
((Player*)caster)->CastSpell(totem, 6277, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
((Player*)caster)->RemoveFarsightTarget();
|
||||
((Player*)caster)->StopCastingBindSight();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -172,10 +172,6 @@ void TemporarySummon::Summon(TempSummonType type, uint32 lifetime)
|
||||
|
||||
void TemporarySummon::UnSummon()
|
||||
{
|
||||
RemoveCharmedOrPossessedBy(NULL);
|
||||
|
||||
CombatStop();
|
||||
|
||||
CleanupsBeforeDelete();
|
||||
AddObjectToRemoveList();
|
||||
|
||||
|
||||
+11
-14
@@ -8480,22 +8480,25 @@ void Unit::RemovePlayerFromVision(Player* plr)
|
||||
plr->ClearFarsight();
|
||||
}
|
||||
|
||||
void Unit::RemoveAllFromVision()
|
||||
void Unit::RemoveBindSightAuras()
|
||||
{
|
||||
while (!m_sharedVision.empty())
|
||||
/*while (!m_sharedVision.empty())
|
||||
{
|
||||
Player* plr = *m_sharedVision.begin();
|
||||
m_sharedVision.erase(m_sharedVision.begin());
|
||||
plr->ClearFarsight();
|
||||
}
|
||||
}*/
|
||||
RemoveSpellsCausingAura(SPELL_AURA_BIND_SIGHT);
|
||||
}
|
||||
|
||||
void Unit::UncharmSelf()
|
||||
void Unit::RemoveCharmAuras()
|
||||
{
|
||||
if (!GetCharmer())
|
||||
return;
|
||||
|
||||
RemoveSpellsCausingAura(SPELL_AURA_MOD_CHARM);
|
||||
RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS_PET);
|
||||
RemoveSpellsCausingAura(SPELL_AURA_MOD_POSSESS);
|
||||
}
|
||||
|
||||
void Unit::UnsummonAllTotems()
|
||||
@@ -10298,10 +10301,6 @@ void Unit::setDeathState(DeathState s)
|
||||
RemoveAllAurasOnDeath();
|
||||
UnsummonAllTotems();
|
||||
|
||||
// Possessed unit died, restore control to possessor
|
||||
RemoveCharmedOrPossessedBy(NULL);
|
||||
RemoveAllFromVision();
|
||||
|
||||
ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, false);
|
||||
ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, false);
|
||||
// remove aurastates allowing special moves
|
||||
@@ -11152,15 +11151,13 @@ void Unit::CleanupsBeforeDelete()
|
||||
{
|
||||
if(m_uint32Values) // only for fully created object
|
||||
{
|
||||
RemoveCharmedOrPossessedBy(NULL);
|
||||
RemoveAllFromVision();
|
||||
RemoveAllAuras();
|
||||
InterruptNonMeleeSpells(true);
|
||||
m_Events.KillAllEvents(false); // non-delatable (currently casted spells) will not deleted now but it will deleted at call in Map::RemoveAllObjectsInRemoveList
|
||||
CombatStop();
|
||||
ClearComboPointHolders();
|
||||
DeleteThreatList();
|
||||
getHostilRefManager().setOnlineOfflineState(false);
|
||||
RemoveAllAuras();
|
||||
RemoveAllGameObjects();
|
||||
RemoveAllDynObjects();
|
||||
GetMotionMaster()->Clear(false); // remove different non-standard movement generators.
|
||||
@@ -12982,14 +12979,14 @@ void Unit::SetCharmedOrPossessedBy(Unit* charmer, bool possess)
|
||||
|
||||
// Charmer stop charming
|
||||
if(charmer->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)charmer)->StopCharmOrPossess();
|
||||
((Player*)charmer)->StopCastingCharm();
|
||||
|
||||
// Charmed stop charming
|
||||
if(GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)this)->StopCharmOrPossess();
|
||||
((Player*)this)->StopCastingCharm();
|
||||
|
||||
// Charmed stop being charmed
|
||||
RemoveCharmedOrPossessedBy(NULL);
|
||||
RemoveCharmAuras();
|
||||
|
||||
// Set charmed
|
||||
charmer->SetCharm(this);
|
||||
|
||||
+2
-2
@@ -1095,8 +1095,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
||||
SharedVisionList const& GetSharedVisionList() { return m_sharedVision; }
|
||||
void AddPlayerToVision(Player* plr);
|
||||
void RemovePlayerFromVision(Player* plr);
|
||||
void RemoveAllFromVision();
|
||||
void UncharmSelf();
|
||||
void RemoveBindSightAuras();
|
||||
void RemoveCharmAuras();
|
||||
|
||||
Pet* CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id = 0);
|
||||
|
||||
|
||||
@@ -249,14 +249,6 @@ void WorldSession::LogoutPlayer(bool Save)
|
||||
|
||||
if (_player)
|
||||
{
|
||||
// Unpossess the current possessed unit of player
|
||||
_player->StopCharmOrPossess();
|
||||
|
||||
// Remove any possession of this player on logout
|
||||
_player->RemoveCharmedOrPossessedBy(NULL);
|
||||
|
||||
//_player->DestroyForNearbyPlayers();
|
||||
|
||||
if (uint64 lguid = GetPlayer()->GetLootGUID())
|
||||
DoLootRelease(lguid);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user