Core/Vehicles: use pointers instead of tempoary copies
This commit is contained in:
1 parent
045ae21e49
commit
df4018b10d
5 files changed
+35
-21
No files matched your search
@@ -13465,7 +13465,7 @@ void Unit::_ExitVehicle(Position const* exitPosition)
|
||||
return;
|
||||
|
||||
// This should be done before dismiss, because there may be some aura removal
|
||||
VehicleSeatAddon const seatAddon = m_vehicle->GetSeatAddonForSeatOfPassenger(this);
|
||||
VehicleSeatAddon const* seatAddon = m_vehicle->GetSeatAddonForSeatOfPassenger(this);
|
||||
Vehicle* vehicle = m_vehicle->RemovePassenger(this);
|
||||
Player* player = ToPlayer();
|
||||
|
||||
@@ -13491,10 +13491,13 @@ void Unit::_ExitVehicle(Position const* exitPosition)
|
||||
pos.SetOrientation(GetOrientation());
|
||||
|
||||
// Change exit position based on seat entry
|
||||
if (seatAddon.ExitParameter == VehicleExitParameters::VehicleExitParamOffset)
|
||||
pos.RelocateOffset({ seatAddon.ExitParameterX, seatAddon.ExitParameterY, seatAddon.ExitParameterZ, seatAddon.ExitParameterO });
|
||||
else if (seatAddon.ExitParameter == VehicleExitParameters::VehicleExitParamDest)
|
||||
pos.Relocate({ seatAddon.ExitParameterX, seatAddon.ExitParameterY, seatAddon.ExitParameterZ, seatAddon.ExitParameterO });
|
||||
if (seatAddon)
|
||||
{
|
||||
if (seatAddon->ExitParameter == VehicleExitParameters::VehicleExitParamOffset)
|
||||
pos.RelocateOffset({ seatAddon->ExitParameterX, seatAddon->ExitParameterY, seatAddon->ExitParameterZ, seatAddon->ExitParameterO });
|
||||
else if (seatAddon->ExitParameter == VehicleExitParameters::VehicleExitParamDest)
|
||||
pos.Relocate({ seatAddon->ExitParameterX, seatAddon->ExitParameterY, seatAddon->ExitParameterZ, seatAddon->ExitParameterO });
|
||||
}
|
||||
}
|
||||
|
||||
float height = pos.GetPositionZ() + vehicle->GetBase()->GetCollisionHeight();
|
||||
|
||||
@@ -41,7 +41,7 @@ UsableSeatNum(0), _me(unit), _vehicleInfo(vehInfo), _creatureEntry(creatureEntry
|
||||
if (uint32 seatId = _vehicleInfo->SeatID[i])
|
||||
if (VehicleSeatEntry const* veSeat = sVehicleSeatStore.LookupEntry(seatId))
|
||||
{
|
||||
VehicleSeatAddon addon = sObjectMgr->GetVehicleSeatAddon(seatId);
|
||||
VehicleSeatAddon const* addon = sObjectMgr->GetVehicleSeatAddon(seatId);
|
||||
Seats.insert(std::make_pair(i, VehicleSeat(veSeat, addon)));
|
||||
if (veSeat->CanEnterOrExit())
|
||||
++UsableSeatNum;
|
||||
@@ -396,15 +396,26 @@ SeatMap::const_iterator Vehicle::GetNextEmptySeat(int8 seatId, bool next) const
|
||||
return seat;
|
||||
}
|
||||
|
||||
VehicleSeatAddon const Vehicle::GetSeatAddonForSeatOfPassenger(Unit const* passenger) const
|
||||
/**
|
||||
* @fn VehicleSeatAddon const Vehicle::GetSeatAddonForSeatOfPassenger(Unit const* passenger) const
|
||||
*
|
||||
* @brief Gets the vehicle seat addon data for the seat of a passenger
|
||||
*
|
||||
* @author Ovahlord
|
||||
* @date 28-1-2020
|
||||
*
|
||||
* @param passenger Identifier for the current seat user
|
||||
*
|
||||
* @return The seat addon data for the currently used seat of a passenger
|
||||
*/
|
||||
|
||||
VehicleSeatAddon const* Vehicle::GetSeatAddonForSeatOfPassenger(Unit const* passenger) const
|
||||
{
|
||||
for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); itr++)
|
||||
{
|
||||
if (!itr->second.IsEmpty() && itr->second.Passenger.Guid == passenger->GetGUID())
|
||||
return itr->second.SeatAddon;
|
||||
}
|
||||
|
||||
return VehicleSeatAddon();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -873,7 +884,7 @@ bool VehicleJoinEvent::Execute(uint64, uint32)
|
||||
Passenger->RemoveAurasByType(SPELL_AURA_MOUNTED);
|
||||
|
||||
VehicleSeatEntry const* veSeat = Seat->second.SeatInfo;
|
||||
VehicleSeatAddon const veSeatAddon = Seat->second.SeatAddon;
|
||||
VehicleSeatAddon const* veSeatAddon = Seat->second.SeatAddon;
|
||||
|
||||
Player* player = Passenger->ToPlayer();
|
||||
if (player)
|
||||
@@ -895,7 +906,7 @@ bool VehicleJoinEvent::Execute(uint64, uint32)
|
||||
if (veSeat->HasFlag(VEHICLE_SEAT_FLAG_PASSENGER_NOT_SELECTABLE))
|
||||
Passenger->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
|
||||
|
||||
float o = veSeatAddon.SeatOrientationOffset;
|
||||
float o = veSeatAddon ? veSeatAddon->SeatOrientationOffset : 0.f;
|
||||
float x = veSeat->AttachmentOffset.X;
|
||||
float y = veSeat->AttachmentOffset.Y;
|
||||
float z = veSeat->AttachmentOffset.Z;
|
||||
|
||||
@@ -52,7 +52,7 @@ class TC_GAME_API Vehicle : public TransportBase
|
||||
bool HasEmptySeat(int8 seatId) const;
|
||||
Unit* GetPassenger(int8 seatId) const;
|
||||
SeatMap::const_iterator GetNextEmptySeat(int8 seatId, bool next) const;
|
||||
VehicleSeatAddon const GetSeatAddonForSeatOfPassenger(Unit const* passenger) const;
|
||||
VehicleSeatAddon const* GetSeatAddonForSeatOfPassenger(Unit const* passenger) const;
|
||||
uint8 GetAvailableSeatCount() const;
|
||||
|
||||
bool AddPassenger(Unit* passenger, int8 seatId = -1);
|
||||
|
||||
@@ -77,9 +77,9 @@ enum VehicleSpells
|
||||
|
||||
enum class VehicleExitParameters
|
||||
{
|
||||
VehicleExitParamNone, // provided parameters will be ignored
|
||||
VehicleExitParamOffset, // provided parameters will be used as offset values
|
||||
VehicleExitParamDest, // provided parameters will be used as absolute destination
|
||||
VehicleExitParamNone = 0, // provided parameters will be ignored
|
||||
VehicleExitParamOffset = 1, // provided parameters will be used as offset values
|
||||
VehicleExitParamDest = 2, // provided parameters will be used as absolute destination
|
||||
VehicleExitParamMax
|
||||
};
|
||||
|
||||
@@ -114,7 +114,7 @@ struct VehicleSeatAddon
|
||||
|
||||
struct VehicleSeat
|
||||
{
|
||||
explicit VehicleSeat(VehicleSeatEntry const* seatInfo, VehicleSeatAddon const seatAddon) : SeatInfo(seatInfo), SeatAddon(seatAddon)
|
||||
explicit VehicleSeat(VehicleSeatEntry const* seatInfo, VehicleSeatAddon const* seatAddon) : SeatInfo(seatInfo), SeatAddon(seatAddon)
|
||||
{
|
||||
Passenger.Reset();
|
||||
}
|
||||
@@ -122,7 +122,7 @@ struct VehicleSeat
|
||||
bool IsEmpty() const { return Passenger.Guid.IsEmpty(); }
|
||||
|
||||
VehicleSeatEntry const* SeatInfo;
|
||||
VehicleSeatAddon const SeatAddon;
|
||||
VehicleSeatAddon const* SeatAddon;
|
||||
PassengerInfo Passenger;
|
||||
};
|
||||
|
||||
|
||||
@@ -1557,13 +1557,13 @@ class TC_GAME_API ObjectMgr
|
||||
|
||||
uint32 GetGameObjectTypeByEntry(uint32 entry) const;
|
||||
|
||||
VehicleSeatAddon const GetVehicleSeatAddon(uint32 seatId) const
|
||||
VehicleSeatAddon const* GetVehicleSeatAddon(uint32 seatId) const
|
||||
{
|
||||
VehicleSeatAddonContainer::const_iterator itr = _vehicleSeatAddonStore.find(seatId);
|
||||
if (itr == _vehicleSeatAddonStore.end())
|
||||
return VehicleSeatAddon();
|
||||
return nullptr;
|
||||
|
||||
return itr->second;
|
||||
return &itr->second;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Reference in new issue
Block a user