Пример #1
0
        void HandleRequestVehicleSwitchSeat(RequestVehicleSwitchSeat packet)
        {
            Unit vehicle_base = GetPlayer().GetVehicleBase();

            if (!vehicle_base)
            {
                return;
            }

            VehicleSeatRecord seat = GetPlayer().GetVehicle().GetSeatForPassenger(GetPlayer());

            if (!seat.CanSwitchFromSeat())
            {
                Log.outError(LogFilter.Network, "HandleRequestVehicleSwitchSeat: {0} tried to switch seats but current seatflags {1} don't permit that.",
                             GetPlayer().GetGUID().ToString(), seat.Flags[0]);
                return;
            }
            Unit vehUnit;

            if (vehicle_base.GetGUID() == packet.Vehicle)
            {
                GetPlayer().ChangeSeat((sbyte)packet.SeatIndex);
            }
            else if (vehUnit = Global.ObjAccessor.GetUnit(GetPlayer(), packet.Vehicle))
            {
                Vehicle vehicle = vehUnit.GetVehicleKit();
                if (vehicle)
                {
                    if (vehicle.HasEmptySeat((sbyte)packet.SeatIndex))
                    {
                        vehUnit.HandleSpellClick(GetPlayer(), (sbyte)packet.SeatIndex);
                    }
                }
            }
        }
Пример #2
0
        void HandleMoveChangeVehicleSeats(MoveChangeVehicleSeats packet)
        {
            Unit vehicle_base = GetPlayer().GetVehicleBase();

            if (!vehicle_base)
            {
                return;
            }

            VehicleSeatRecord seat = GetPlayer().GetVehicle().GetSeatForPassenger(GetPlayer());

            if (!seat.CanSwitchFromSeat())
            {
                Log.outError(LogFilter.Network, "HandleMoveChangeVehicleSeats, {0} tried to switch seats but current seatflags {1} don't permit that.",
                             GetPlayer().GetGUID().ToString(), seat.Flags);
                return;
            }

            GetPlayer().ValidateMovementInfo(packet.Status);

            if (vehicle_base.GetGUID() != packet.Status.Guid)
            {
                return;
            }

            vehicle_base.m_movementInfo = packet.Status;

            if (packet.DstVehicle.IsEmpty())
            {
                GetPlayer().ChangeSeat(-1, packet.DstSeatIndex != 255);
            }
            else
            {
                Unit vehUnit = Global.ObjAccessor.GetUnit(GetPlayer(), packet.DstVehicle);
                if (vehUnit)
                {
                    Vehicle vehicle = vehUnit.GetVehicleKit();
                    if (vehicle)
                    {
                        if (vehicle.HasEmptySeat((sbyte)packet.DstSeatIndex))
                        {
                            vehUnit.HandleSpellClick(GetPlayer(), (sbyte)packet.DstSeatIndex);
                        }
                    }
                }
            }
        }
Пример #3
0
        void HandleRequestVehicleNextSeat(RequestVehicleNextSeat packet)
        {
            Unit vehicle_base = GetPlayer().GetVehicleBase();

            if (!vehicle_base)
            {
                return;
            }

            VehicleSeatRecord seat = GetPlayer().GetVehicle().GetSeatForPassenger(GetPlayer());

            if (!seat.CanSwitchFromSeat())
            {
                Log.outError(LogFilter.Network, "HandleRequestVehicleNextSeat: {0} tried to switch seats but current seatflags {1} don't permit that.",
                             GetPlayer().GetGUID().ToString(), seat.Flags);
                return;
            }

            GetPlayer().ChangeSeat(-1, true);
        }