diff options
author | Vincent_Michael <Vincent_Michael@gmx.de> | 2013-02-22 23:10:30 +0100 |
---|---|---|
committer | Vincent_Michael <Vincent_Michael@gmx.de> | 2013-02-22 23:10:30 +0100 |
commit | 2672d134436be24c2388a8005e74ee0e439a9d7e (patch) | |
tree | d2fb57396e330b6ac9d07595c8e703abca27e539 /src | |
parent | 7d37629c17286ceef31e0746da50c73cade7a958 (diff) | |
parent | 729a37363b7613b95fa2c629adfa68c0b7dc3835 (diff) |
Merge branch 'master' of github.com:TrinityCore/TrinityCore into 4.3.4
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 6 | ||||
-rw-r--r-- | src/server/game/Entities/Vehicle/Vehicle.cpp | 31 | ||||
-rw-r--r-- | src/server/game/Entities/Vehicle/Vehicle.h | 31 |
3 files changed, 50 insertions, 18 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 58f2edf5f74..da9780a9793 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2112,9 +2112,11 @@ bool Creature::LoadCreaturesAddon(bool reload) SetByteValue(UNIT_FIELD_BYTES_1, 3, uint8((cainfo->bytes1 >> 24) & 0xFF)); //! Suspected correlation between UNIT_FIELD_BYTES_1, offset 3, value 0x2: - //! If no inhabittype_fly (if no MovementFlag_DisableGravity flag found in sniffs) + //! If no inhabittype_fly (if no MovementFlag_DisableGravity or MovementFlag_CanFly flag found in sniffs) + //! Check using InhabitType as movement flags are assigned dynamically + //! basing on whether the creature is in air or not //! Set MovementFlag_Hover. Otherwise do nothing. - if (GetByteValue(UNIT_FIELD_BYTES_1, 3) & UNIT_BYTE1_FLAG_HOVER && !IsLevitating()) + if (GetByteValue(UNIT_FIELD_BYTES_1, 3) & UNIT_BYTE1_FLAG_HOVER && !(GetCreatureTemplate()->InhabitType & INHABIT_AIR)) AddUnitMovementFlag(MOVEMENTFLAG_HOVER); } diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index 5e80fab217f..4405d776119 100644 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -256,7 +256,7 @@ void Vehicle::RemoveAllPassengers() /// Setting to_Abort to true will cause @VehicleJoinEvent::Abort to be executed on next @Unit::UpdateEvents call /// This will properly "reset" the pending join process for the passenger. - while (_pendingJoinEvents.size()) + while (!_pendingJoinEvents.empty()) { VehicleJoinEvent* e = _pendingJoinEvents.front(); e->to_Abort = true; @@ -422,12 +422,12 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId) /// @Prevent adding passengers when vehicle is uninstalling. (Bad script in OnUninstall/OnRemovePassenger/PassengerBoarded hook.) if (_status == STATUS_UNINSTALLING) { - sLog->outError(LOG_FILTER_VEHICLES, "Passenger GuidLow: %u, Entry: %u, attempting to board vehicle GuidLow: %u, Entry: %u during uninstall! SeatId: %i", + sLog->outError(LOG_FILTER_VEHICLES, "Passenger GuidLow: %u, Entry: %u, attempting to board vehicle GuidLow: %u, Entry: %u during uninstall! SeatId: %d", unit->GetGUIDLow(), unit->GetEntry(), _me->GetGUIDLow(), _me->GetEntry(), (int32)seatId); return false; } - sLog->outDebug(LOG_FILTER_VEHICLES, "Unit %s scheduling enter vehicle (entry: %u, vehicleId: %u, guid: %u (dbguid: %s) on seat %d", + sLog->outDebug(LOG_FILTER_VEHICLES, "Unit %s scheduling enter vehicle (entry: %u, vehicleId: %u, guid: %u (dbguid: %u) on seat %d", unit->GetName().c_str(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUIDLow(), (_me->GetTypeId() == TYPEID_UNIT ? _me->ToCreature()->GetDBTableGUIDLow() : 0), (int32)seatId); @@ -706,6 +706,31 @@ void Vehicle::CancelJoinEvent(VehicleJoinEvent* e) } /** + * @fn void Vehicle::RemovePendingEvent(VehicleJoinEvent* e) + * + * @brief Removes @VehicleJoinEvent objects from pending join event store. + * This method only removes it after it's executed or aborted to prevent leaving + * pointers to deleted events. + * + * @author Shauren + * @date 22-2-2013 + * + * @param [in] e The VehicleJoinEvent* to remove from pending event store. + */ + +void Vehicle::RemovePendingEvent(VehicleJoinEvent* e) +{ + for (std::deque<VehicleJoinEvent*>::iterator itr = _pendingJoinEvents.begin(); itr != _pendingJoinEvents.end(); ++itr) + { + if (*itr == e) + { + _pendingJoinEvents.erase(itr); + break; + } + } +} + +/** * @fn bool VehicleJoinEvent::Execute(uint64, uint32) * * @brief Actually adds the passenger @Passenger to vehicle @Target. diff --git a/src/server/game/Entities/Vehicle/Vehicle.h b/src/server/game/Entities/Vehicle/Vehicle.h index 7ec0df8e533..40aea1a2d02 100644 --- a/src/server/game/Entities/Vehicle/Vehicle.h +++ b/src/server/game/Entities/Vehicle/Vehicle.h @@ -27,11 +27,19 @@ struct VehicleEntry; class Unit; -typedef std::set<uint64> GuidSet; class VehicleJoinEvent; +typedef std::set<uint64> GuidSet; + class Vehicle : public TransportBase { + protected: + friend bool Unit::CreateVehicleKit(uint32 id, uint32 creatureEntry); + Vehicle(Unit* unit, VehicleEntry const* vehInfo, uint32 creatureEntry); + + friend void Unit::RemoveVehicleKit(); + ~Vehicle(); + public: void Install(); void Uninstall(); @@ -61,19 +69,13 @@ class Vehicle : public TransportBase void SetLastShootPos(Position const& pos) { m_lastShootPos.Relocate(pos); } Position GetLastShootPos() { return m_lastShootPos; } - SeatMap Seats; ///< The collection of all seats on the vehicle. Including vacant ones. + SeatMap Seats; ///< The collection of all seats on the vehicle. Including vacant ones. VehicleSeatEntry const* GetSeatForPassenger(Unit* passenger); protected: friend class VehicleJoinEvent; - uint32 UsableSeatNum; ///< Number of seats that match VehicleSeatEntry::UsableByPlayer, used for proper display flags - - protected: - friend bool Unit::CreateVehicleKit(uint32 id, uint32 creatureEntry); - Vehicle(Unit* unit, VehicleEntry const* vehInfo, uint32 creatureEntry); - friend void Unit::RemoveVehicleKit(); - ~Vehicle(); + uint32 UsableSeatNum; ///< Number of seats that match VehicleSeatEntry::UsableByPlayer, used for proper display flags private: enum Status @@ -92,15 +94,16 @@ class Vehicle : public TransportBase /// This method transforms supplied global coordinates into local offsets void CalculatePassengerOffset(float& x, float& y, float& z, float& o); - Unit* _me; ///< The underlying unit with the vehicle kit. Can be player or creature. - VehicleEntry const* _vehicleInfo; ///< DBC data for vehicle + Unit* _me; ///< The underlying unit with the vehicle kit. Can be player or creature. + VehicleEntry const* _vehicleInfo; ///< DBC data for vehicle GuidSet vehiclePlayers; - uint32 _creatureEntry; ///< Can be different than the entry of _me in case of players - Status _status; ///< Internal variable for sanity checks + uint32 _creatureEntry; ///< Can be different than the entry of _me in case of players + Status _status; ///< Internal variable for sanity checks Position m_lastShootPos; std::deque<VehicleJoinEvent*> _pendingJoinEvents; ///< Collection of delayed join events for prospective passengers void CancelJoinEvent(VehicleJoinEvent* e); + void RemovePendingEvent(VehicleJoinEvent* e); }; class VehicleJoinEvent : public BasicEvent @@ -108,6 +111,7 @@ class VehicleJoinEvent : public BasicEvent friend class Vehicle; protected: VehicleJoinEvent(Vehicle* v, Unit* u) : Target(v), Passenger(u), Seat(Target->Seats.end()) {} + ~VehicleJoinEvent() { Target->RemovePendingEvent(this); } bool Execute(uint64, uint32); void Abort(uint64); @@ -115,4 +119,5 @@ class VehicleJoinEvent : public BasicEvent Unit* Passenger; SeatMap::iterator Seat; }; + #endif |