Core/Vehicles: Implemented vehicle seat flag that makes passengers unselectable and dropped redundant UNIT_STATE_ONVEHICLE (it is only checked in the same places as unselectable unit flag)
This commit is contained in:
1 parent
44c844d6fd
commit
13208ff257
9 files changed
+53
-36
No files matched your search
@@ -62,7 +62,7 @@ Vehicle::~Vehicle()
|
||||
/// @Uninstall must be called before this.
|
||||
ASSERT(_status == STATUS_UNINSTALLING);
|
||||
for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); ++itr)
|
||||
ASSERT(!itr->second.Passenger);
|
||||
ASSERT(itr->second.IsEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -299,7 +299,7 @@ bool Vehicle::HasEmptySeat(int8 seatId) const
|
||||
SeatMap::const_iterator seat = Seats.find(seatId);
|
||||
if (seat == Seats.end())
|
||||
return false;
|
||||
return !seat->second.Passenger;
|
||||
return seat->second.IsEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -321,7 +321,7 @@ Unit* Vehicle::GetPassenger(int8 seatId) const
|
||||
if (seat == Seats.end())
|
||||
return NULL;
|
||||
|
||||
return ObjectAccessor::GetUnit(*GetBase(), seat->second.Passenger);
|
||||
return ObjectAccessor::GetUnit(*GetBase(), seat->second.Passenger.Guid);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -344,7 +344,7 @@ SeatMap::const_iterator Vehicle::GetNextEmptySeat(int8 seatId, bool next) const
|
||||
if (seat == Seats.end())
|
||||
return seat;
|
||||
|
||||
while (seat->second.Passenger || (!seat->second.SeatInfo->CanEnterOrExit() && !seat->second.SeatInfo->IsUsableByOverride()))
|
||||
while (!seat->second.IsEmpty() || (!seat->second.SeatInfo->CanEnterOrExit() && !seat->second.SeatInfo->IsUsableByOverride()))
|
||||
{
|
||||
if (next)
|
||||
{
|
||||
@@ -449,7 +449,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.Passenger && (seat->second.SeatInfo->CanEnterOrExit() || seat->second.SeatInfo->IsUsableByOverride()))
|
||||
if (seat->second.IsEmpty() && (seat->second.SeatInfo->CanEnterOrExit() || seat->second.SeatInfo->IsUsableByOverride()))
|
||||
break;
|
||||
|
||||
if (seat == Seats.end()) // no available seat
|
||||
@@ -472,14 +472,14 @@ bool Vehicle::AddPassenger(Unit* unit, int8 seatId)
|
||||
|
||||
e->Seat = seat;
|
||||
_pendingJoinEvents.push_back(e);
|
||||
if (seat->second.Passenger)
|
||||
if (!seat->second.IsEmpty())
|
||||
{
|
||||
Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), seat->second.Passenger);
|
||||
Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), seat->second.Passenger.Guid);
|
||||
ASSERT(passenger);
|
||||
passenger->ExitVehicle();
|
||||
}
|
||||
|
||||
ASSERT(!seat->second.Passenger);
|
||||
ASSERT(seat->second.IsEmpty());
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -507,11 +507,14 @@ Vehicle* Vehicle::RemovePassenger(Unit* unit)
|
||||
TC_LOG_DEBUG(LOG_FILTER_VEHICLES, "Unit %s exit vehicle entry %u id %u dbguid %u seat %d",
|
||||
unit->GetName().c_str(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUIDLow(), (int32)seat->first);
|
||||
|
||||
seat->second.Passenger = 0;
|
||||
if (seat->second.SeatInfo->CanEnterOrExit() && ++UsableSeatNum)
|
||||
_me->SetFlag(UNIT_NPC_FLAGS, (_me->GetTypeId() == TYPEID_PLAYER ? UNIT_NPC_FLAG_PLAYER_VEHICLE : UNIT_NPC_FLAG_SPELLCLICK));
|
||||
|
||||
unit->ClearUnitState(UNIT_STATE_ONVEHICLE);
|
||||
// Remove UNIT_FLAG_NOT_SELECTABLE if passenger did not have it before entering vehicle
|
||||
if (seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_PASSENGER_NOT_SELECTABLE && !seat->second.Passenger.IsUnselectable)
|
||||
unit->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
|
||||
|
||||
seat->second.Passenger.Reset();
|
||||
|
||||
if (_me->GetTypeId() == TYPEID_UNIT && unit->GetTypeId() == TYPEID_PLAYER && seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL)
|
||||
_me->RemoveCharmedBy(unit);
|
||||
@@ -552,7 +555,7 @@ void Vehicle::RelocatePassengers()
|
||||
// not sure that absolute position calculation is correct, it must depend on vehicle pitch angle
|
||||
for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); ++itr)
|
||||
{
|
||||
if (Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), itr->second.Passenger))
|
||||
if (Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), itr->second.Passenger.Guid))
|
||||
{
|
||||
ASSERT(passenger->IsInWorld());
|
||||
|
||||
@@ -578,7 +581,7 @@ void Vehicle::RelocatePassengers()
|
||||
bool Vehicle::IsVehicleInUse() const
|
||||
{
|
||||
for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); ++itr)
|
||||
if (itr->second.Passenger)
|
||||
if (!itr->second.IsEmpty())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -625,7 +628,7 @@ void Vehicle::InitMovementInfoForBase()
|
||||
VehicleSeatEntry const* Vehicle::GetSeatForPassenger(Unit const* passenger) const
|
||||
{
|
||||
for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); ++itr)
|
||||
if (itr->second.Passenger == passenger->GetGUID())
|
||||
if (itr->second.Passenger.Guid == passenger->GetGUID())
|
||||
return itr->second.SeatInfo;
|
||||
|
||||
return NULL;
|
||||
@@ -648,7 +651,7 @@ SeatMap::iterator Vehicle::GetSeatIteratorForPassenger(Unit* passenger)
|
||||
{
|
||||
SeatMap::iterator itr;
|
||||
for (itr = Seats.begin(); itr != Seats.end(); ++itr)
|
||||
if (itr->second.Passenger == passenger->GetGUID())
|
||||
if (itr->second.Passenger.Guid == passenger->GetGUID())
|
||||
return itr;
|
||||
|
||||
return Seats.end();
|
||||
@@ -670,7 +673,7 @@ uint8 Vehicle::GetAvailableSeatCount() const
|
||||
uint8 ret = 0;
|
||||
SeatMap::const_iterator itr;
|
||||
for (itr = Seats.begin(); itr != Seats.end(); ++itr)
|
||||
if (!itr->second.Passenger && (itr->second.SeatInfo->CanEnterOrExit() || itr->second.SeatInfo->IsUsableByOverride()))
|
||||
if (itr->second.IsEmpty() && (itr->second.SeatInfo->CanEnterOrExit() || itr->second.SeatInfo->IsUsableByOverride()))
|
||||
++ret;
|
||||
|
||||
return ret;
|
||||
@@ -806,7 +809,8 @@ bool VehicleJoinEvent::Execute(uint64, uint32)
|
||||
Target->RemovePendingEventsForPassenger(Passenger);
|
||||
|
||||
Passenger->SetVehicle(Target);
|
||||
Seat->second.Passenger = Passenger->GetGUID();
|
||||
Seat->second.Passenger.Guid = Passenger->GetGUID();
|
||||
Seat->second.Passenger.IsUnselectable = Passenger->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
|
||||
if (Seat->second.SeatInfo->CanEnterOrExit())
|
||||
{
|
||||
ASSERT(Target->UsableSeatNum);
|
||||
@@ -836,8 +840,8 @@ bool VehicleJoinEvent::Execute(uint64, uint32)
|
||||
player->UnsummonPetTemporaryIfAny();
|
||||
}
|
||||
|
||||
if (Seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_HIDE_PASSENGER)
|
||||
Passenger->AddUnitState(UNIT_STATE_ONVEHICLE);
|
||||
if (Seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_PASSENGER_NOT_SELECTABLE)
|
||||
Passenger->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
|
||||
|
||||
Passenger->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
|
||||
VehicleSeatEntry const* veSeat = Seat->second.SeatInfo;
|
||||
|
||||
Reference in new issue
Block a user