diff options
author | megamage <none@none> | 2009-02-15 17:33:36 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-02-15 17:33:36 -0600 |
commit | bb75ff7b79e89dac82f3ee1c740eb6079c7ec43b (patch) | |
tree | a48ea1fe70e395573e7ca4be4058fe894bbc2bdf /src | |
parent | 058b7c32e40332a620d8e294b4defba81e14dfc0 (diff) |
*Cleanup of charm/farsight code. Hope this can fix some crash bugs.
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Level3.cpp | 24 | ||||
-rw-r--r-- | src/game/MovementHandler.cpp | 4 | ||||
-rw-r--r-- | src/game/PetHandler.cpp | 14 | ||||
-rw-r--r-- | src/game/Player.cpp | 72 | ||||
-rw-r--r-- | src/game/Player.h | 12 | ||||
-rw-r--r-- | src/game/SpellAuras.cpp | 4 | ||||
-rw-r--r-- | src/game/TemporarySummon.cpp | 4 | ||||
-rw-r--r-- | src/game/Unit.cpp | 25 | ||||
-rw-r--r-- | src/game/Unit.h | 4 | ||||
-rw-r--r-- | src/game/WorldSession.cpp | 8 |
10 files changed, 41 insertions, 130 deletions
diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index a36571d20a4..f1a08f0b2c4 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -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; } diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index 8c808e3a53a..b8dede604d2 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -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(); } } diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index e4269ddafd6..907b7b7a95a 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -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(); } } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 02e6e94f94c..0e4987c6da8 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -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()); } diff --git a/src/game/Player.h b/src/game/Player.h index a149e559a3a..7137738d20d 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -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; } diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 39954b0107d..5c03f41def7 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -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; diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp index 553f7644b64..1508c6cf95c 100644 --- a/src/game/TemporarySummon.cpp +++ b/src/game/TemporarySummon.cpp @@ -172,10 +172,6 @@ void TemporarySummon::Summon(TempSummonType type, uint32 lifetime) void TemporarySummon::UnSummon() { - RemoveCharmedOrPossessedBy(NULL); - - CombatStop(); - CleanupsBeforeDelete(); AddObjectToRemoveList(); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index e7ff4e3ec62..6bb085eca11 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -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); diff --git a/src/game/Unit.h b/src/game/Unit.h index 7050121c5bb..e796256cfa2 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -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); diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index e043bbe9659..7f28d3e4e94 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -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); |