Core/Vehicle: merged Joschiwald's multiple join event fix for vehicle seats

This commit is contained in:
Ovalord
2018-02-20 21:15:09 +01:00
parent 17af2f8277
commit 8862ab8482
2 changed files with 15 additions and 3 deletions

View File

@@ -367,7 +367,7 @@ SeatMap::const_iterator Vehicle::GetNextEmptySeat(int8 seatId, bool next) const
if (seat == Seats.end())
return seat;
while (!seat->second.IsEmpty() || (!seat->second.SeatInfo->CanEnterOrExit() && !seat->second.SeatInfo->IsUsableByOverride()))
while (!seat->second.IsEmpty() || HasPendingEventForSeat(seat->first) || (!seat->second.SeatInfo->CanEnterOrExit() && !seat->second.SeatInfo->IsUsableByOverride()))
{
if (next)
{
@@ -472,7 +472,7 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
if (seatId < 0) // no specific seat requirement
{
for (seat = Seats.begin(); seat != Seats.end(); ++seat)
if (seat->second.IsEmpty() && (seat->second.SeatInfo->CanEnterOrExit() || seat->second.SeatInfo->IsUsableByOverride()))
if (seat->second.IsEmpty() && !HasPendingEventForSeat(seat->first) && (seat->second.SeatInfo->CanEnterOrExit() || seat->second.SeatInfo->IsUsableByOverride()))
break;
if (seat == Seats.end()) // no available seat
@@ -704,7 +704,7 @@ uint8 Vehicle::GetAvailableSeatCount() const
uint8 ret = 0;
SeatMap::const_iterator itr;
for (itr = Seats.begin(); itr != Seats.end(); ++itr)
if (itr->second.IsEmpty() && (itr->second.SeatInfo->CanEnterOrExit() || itr->second.SeatInfo->IsUsableByOverride()))
if (itr->second.IsEmpty() && !HasPendingEventForSeat(itr->first) && (itr->second.SeatInfo->CanEnterOrExit() || itr->second.SeatInfo->IsUsableByOverride()))
++ret;
return ret;
@@ -785,6 +785,16 @@ void Vehicle::RemovePendingEventsForPassenger(Unit* passenger)
}
}
bool Vehicle::HasPendingEventForSeat(int8 seatId) const
{
for (PendingJoinEventContainer::const_iterator itr = _pendingJoinEvents.begin(); itr != _pendingJoinEvents.end(); ++itr)
{
if ((*itr)->Seat->first == seatId)
return true;
}
return false;
}
/**
* @fn bool VehicleJoinEvent::Execute(uint64, uint32)
*

View File

@@ -105,6 +105,8 @@ class TC_GAME_API Vehicle : public TransportBase
void RemovePendingEvent(VehicleJoinEvent* e);
void RemovePendingEventsForSeat(int8 seatId);
bool HasPendingEventForSeat(int8 seatId) const;
private:
Unit* _me; ///< The underlying unit with the vehicle kit. Can be player or creature.
VehicleEntry const* _vehicleInfo; ///< DBC data for vehicle