diff options
author | Giacomo Pozzoni <giacomopoz@gmail.com> | 2019-08-04 11:33:29 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-12-18 14:08:25 +0100 |
commit | 6d5086da1747816e1a4e8518e16ab1923de22e1a (patch) | |
tree | 5243ec829adb0b97ccca447405f97212e2c981b6 /src/server/game/Phasing/PhasingHandler.cpp | |
parent | a90073dadde9fac1ef2effe4e60988ff3619983a (diff) |
Core/Vehicle: Change vehicle accessories' phase according to the player on the vehicle (#23646)
* Core/Vehicle: Change vehicle accessories' phase according to the player on the vehicle
* Get the root vehicle to set the phase to all accessories. Attempt to get the accessories to stay mounted on the vehicle.
* Fix the accessories to stay mounted on the vehicle
(cherry picked from commit 15e85f882fdb7b5d1d48302907e76c993ee4e923)
Diffstat (limited to 'src/server/game/Phasing/PhasingHandler.cpp')
-rw-r--r-- | src/server/game/Phasing/PhasingHandler.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/server/game/Phasing/PhasingHandler.cpp b/src/server/game/Phasing/PhasingHandler.cpp index 9fdb411395d..e1432b49351 100644 --- a/src/server/game/Phasing/PhasingHandler.cpp +++ b/src/server/game/Phasing/PhasingHandler.cpp @@ -23,11 +23,13 @@ #include "Language.h" #include "Map.h" #include "MiscPackets.h" +#include "ObjectAccessor.h" #include "ObjectMgr.h" #include "PartyPackets.h" #include "PhaseShift.h" #include "Player.h" #include "SpellAuraEffects.h" +#include "Vehicle.h" #include <sstream> namespace @@ -52,13 +54,19 @@ template<typename Func> inline void ForAllControlled(Unit* unit, Func&& func) { for (Unit* controlled : unit->m_Controlled) - if (controlled->GetTypeId() != TYPEID_PLAYER) + if (controlled->GetTypeId() != TYPEID_PLAYER + && !controlled->GetVehicle()) // Player inside nested vehicle should not phase the root vehicle and its accessories (only direct root vehicle control does) func(controlled); for (ObjectGuid summonGuid : unit->m_SummonSlot) if (!summonGuid.IsEmpty()) if (Creature* summon = unit->GetMap()->GetCreature(summonGuid)) func(summon); + + if (Vehicle const* vehicle = unit->GetVehicleKit()) + for (auto seat = vehicle->Seats.begin(); seat != vehicle->Seats.end(); ++seat) + if (Unit* passenger = ObjectAccessor::GetUnit(*unit, seat->second.Passenger.Guid)) + func(passenger); } } |