Example #1
0
void Vehicle::RemoveAllPassengers()
{
    sLog->outDebug(LOG_FILTER_VEHICLES, "Vehicle::RemoveAllPassengers");
    for (SeatMap::iterator itr = m_Seats.begin(); itr != m_Seats.end(); ++itr)
        if (Unit *passenger = ObjectAccessor::GetUnit(*GetBase(), itr->second.passenger))
        {
            ASSERT(passenger->IsInWorld());
            ASSERT(passenger->IsOnVehicle(GetBase()));
            ASSERT(GetSeatForPassenger(passenger));

            if (passenger->IsVehicle())
                passenger->GetVehicleKit()->RemoveAllPassengers();

            if (passenger->GetVehicle() != this)
                sLog->outCrash("Vehicle %u has invalid passenger %u. Seat: %i", me->GetEntry(), passenger->GetEntry(), itr->first);

            passenger->ExitVehicle();
            if (itr->second.passenger)
            {
                sLog->outCrash("Vehicle %u cannot remove passenger %u. "UI64FMTD" is still on vehicle.", me->GetEntry(), passenger->GetEntry(), itr->second.passenger);
                itr->second.passenger = 0;
            }

            // creature passengers mounted on player mounts should be despawned at dismount
            if (GetBase()->GetTypeId() == TYPEID_PLAYER && passenger->ToCreature())
                passenger->ToCreature()->DespawnOrUnsummon();
        }
}
Example #2
0
void Vehicle::RelocatePassengers(float x, float y, float z, float ang)
{
    ASSERT(_me->GetMap());

    // not sure that absolute position calculation is correct, it must depend on vehicle orientation and pitch angle
    for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); ++itr)
        if (Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), itr->second.Passenger))
        {
            ASSERT(passenger->IsInWorld());
            ASSERT(passenger->IsOnVehicle(GetBase()));
            ASSERT(GetSeatForPassenger(passenger));

            float px = x + passenger->m_movementInfo.t_pos.m_positionX;
            float py = y + passenger->m_movementInfo.t_pos.m_positionY;
            float pz = z + passenger->m_movementInfo.t_pos.m_positionZ;
            float po = ang + passenger->m_movementInfo.t_pos.m_orientation;

            passenger->UpdatePosition(px, py, pz, po);
        }
}