From 4fd4e12d591f9abfa1d0242579e74b8d6b1ddb5e Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sat, 16 Jan 2010 05:37:57 +0300 Subject: [PATCH] [9187] Fixed problem with non-attackable pes/totems at arenas ... and other FFA areas. Problem is result chnages in related flags work after old 3.x switch. * Added high-level functions for FFAPvP state set for unit * Apply FFA PvP to all controlled units also at set, and at summon/load --- src/game/CharacterHandler.cpp | 2 +- src/game/MiscHandler.cpp | 2 +- src/game/Pet.cpp | 3 +++ src/game/Player.cpp | 18 +++++++++--------- src/game/Player.h | 1 - src/game/SpellEffects.cpp | 6 ++++++ src/game/Unit.cpp | 24 ++++++++++++++++++++++-- src/game/Unit.h | 2 ++ src/shared/revision_nr.h | 2 +- 9 files changed, 45 insertions(+), 15 deletions(-) diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 2c9511799..6d428f37f 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -749,7 +749,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder) // Set FFA PvP for non GM in non-rest mode if(sWorld.IsFFAPvPRealm() && !pCurrChar->isGameMaster() && !pCurrChar->HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_RESTING) ) - pCurrChar->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); + pCurrChar->SetFFAPvP(true); if(pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP)) pCurrChar->SetContestedPvP(); diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index c0b42fcd3..d365aa2a9 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -771,7 +771,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) GetPlayer()->SetRestType(REST_TYPE_IN_TAVERN); if(sWorld.IsFFAPvPRealm()) - GetPlayer()->RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); + GetPlayer()->SetFFAPvP(false); return; } diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 15c175033..5283be352 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -225,6 +225,9 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool if(owner->IsPvP()) SetPvP(true); + if(owner->IsFFAPvP()) + SetFFAPvP(true); + SetCanModifyStats(true); InitStatsForLevel(petlevel); InitTalentForLevel(); // set original talents points before spell loading diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 176691bf9..ed9e795cf 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -2231,7 +2231,7 @@ void Player::SetGameMaster(bool on) CallForAllControlledUnits(SetGameMasterOnHelper(),true,true,true,false); - RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); + SetFFAPvP(false); ResetContestedPvP(); getHostileRefManager().setOnlineOfflineState(false); @@ -2253,7 +2253,7 @@ void Player::SetGameMaster(bool on) // restore FFA PvP Server state if(sWorld.IsFFAPvPRealm()) - SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); + SetFFAPvP(true); // restore FFA PvP area state, remove not allowed for GM mounts UpdateArea(m_areaUpdateId); @@ -6312,14 +6312,14 @@ void Player::UpdateArea(uint32 newArea) if(area && (area->flags & AREA_FLAG_ARENA)) { if(!isGameMaster()) - SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); + SetFFAPvP(true); } else { // remove ffa flag only if not ffapvp realm // removal in sanctuaries and capitals is handled in zone update - if(HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP) && !sWorld.IsFFAPvPRealm()) - RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); + if(IsFFAPvP() && !sWorld.IsFFAPvPRealm()) + SetFFAPvP(false); } UpdateAreaDependentAuras(newArea); @@ -6387,7 +6387,7 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea) { SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_SANCTUARY); if(sWorld.IsFFAPvPRealm()) - RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); + SetFFAPvP(false); } else { @@ -6401,7 +6401,7 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea) InnEnter(time(0),GetMapId(),0,0,0); if(sWorld.IsFFAPvPRealm()) - RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); + SetFFAPvP(false); } else // anywhere else { @@ -6415,7 +6415,7 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea) SetRestType(REST_TYPE_NO); if(sWorld.IsFFAPvPRealm()) - SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); + SetFFAPvP(true); } } else // not in tavern (leave city then) @@ -6425,7 +6425,7 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea) // Set player to FFA PVP when not in rested environment. if(sWorld.IsFFAPvPRealm()) - SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); + SetFFAPvP(true); } } } diff --git a/src/game/Player.h b/src/game/Player.h index 969539d6b..7054183bd 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1170,7 +1170,6 @@ class MANGOS_DLL_SPEC Player : public Unit template bool CheckAllControlledUnits(Func const& func, bool withTotems, bool withGuardians, bool withCharms, bool withMiniPet) const; - uint32 GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn void Say(const std::string& text, const uint32 language); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 8d0c9118a..eefaf3042 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -4419,6 +4419,9 @@ void Spell::EffectSummonPet(uint32 i) if(m_caster->IsPvP()) NewSummon->SetPvP(true); + if(m_caster->IsFFAPvP()) + NewSummon->SetFFAPvP(true); + NewSummon->InitStatsForLevel(petlevel, m_caster); NewSummon->InitPetCreateSpells(); NewSummon->InitLevelupSpellsForLevel(); @@ -5934,6 +5937,9 @@ void Spell::EffectSummonTotem(uint32 i, uint8 slot) if(m_caster->IsPvP()) pTotem->SetPvP(true); + if(m_caster->IsFFAPvP()) + pTotem->SetFFAPvP(true); + pTotem->Summon(m_caster); if(slot < MAX_TOTEM && m_caster->GetTypeId() == TYPEID_PLAYER) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index a367fee6b..916a697ae 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -7879,7 +7879,7 @@ bool Unit::IsHostileTo(Unit const* unit) const return false; // PvP FFA state - if(pTester->HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP) && pTarget->HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP)) + if(pTester->IsFFAPvP() && pTarget->IsFFAPvP()) return true; //= PvP states @@ -7991,7 +7991,7 @@ bool Unit::IsFriendlyTo(Unit const* unit) const return true; // PvP FFA state - if(pTester->HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP) && pTarget->HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP)) + if(pTester->IsFFAPvP() && pTarget->IsFFAPvP()) return false; //= PvP states @@ -12755,6 +12755,9 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id) if(IsPvP()) pet->SetPvP(true); + if(IsFFAPvP()) + pet->SetFFAPvP(true); + uint32 level = (creatureTarget->getLevel() < (getLevel() - 5)) ? (getLevel() - 5) : creatureTarget->getLevel(); if(!pet->InitStatsForLevel(level)) @@ -12985,6 +12988,23 @@ void Unit::SetPvP( bool state ) CallForAllControlledUnits(SetPvPHelper(state),true,true,true); } +struct SetFFAPvPHelper +{ + explicit SetFFAPvPHelper(bool _state) : state(_state) {} + void operator()(Unit* unit) const { unit->SetFFAPvP(state); } + bool state; +}; + +void Unit::SetFFAPvP( bool state ) +{ + if(state) + SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); + else + RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); + + CallForAllControlledUnits(SetFFAPvPHelper(state),true,true,true); +} + void Unit::KnockBackFrom(Unit* target, float horizintalSpeed, float verticalSpeed) { float angle = this == target ? GetOrientation() + M_PI : target->GetAngle(this); diff --git a/src/game/Unit.h b/src/game/Unit.h index b789ac8d3..d919286cf 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1009,6 +1009,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject } bool IsPvP() const { return HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); } void SetPvP(bool state); + bool IsFFAPvP() const { return HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); } + void SetFFAPvP(bool state); uint32 GetCreatureType() const; uint32 GetCreatureTypeMask() const { diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index f1b3d446d..2e0bca581 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 "9186" + #define REVISION_NR "9187" #endif // __REVISION_NR_H__ -- 2.11.4.GIT