protected override void Process(Entities.User u)
 {
     if (u.Authorized && u.Room != null)
     {
         // [0] = ROOM SLOT
         // [1] = ROOM ID
         byte roomSlot = GetByte(0);
         if (roomSlot < u.Room.MaximumPlayers || u.SpectatorId != -1)
         {
             uint roomId = GetuInt(1);
             if (roomId == u.Room.ID)
             {
                 byte   unknown = GetByte(2); // Seems to be 2 or 0?
                 ushort subType = GetUShort(3);
                 // HANDLE PACKET IN A SEPERATED CLASS //
                 Networking.GameDataHandler handler = Managers.PacketManager.Instance.GetHandler(subType);
                 if (handler != null)
                 {
                     try {
                         handler.Process(u, this.InPacket);
                     } catch { /* error? */ }
                 }
                 else
                 {
                     Log.Instance.WriteBoth("UNKNOWN SUBPACKET :: " + this.InPacket.fullPacket);
                 }
             }
             else
             {
                 u.Disconnect(); // Wrong room targeted - Cheating?
             }
         }
         else
         {
             u.Disconnect(); // Room slot over maximum players - Cheating?
         }
     }
 }
Exemple #2
0
        private void DamageVehicle(Networking.GameDataHandler handler, Entities.Player Attacker, Entities.Vehicle DamagedVehicle, short _damageTaken)
        {
            DamagedVehicle.Damage((ushort)_damageTaken);

            if (DamagedVehicle.IsAlive) //vehicle is still ok
            {
                handler.type = GameSubs.ObjectDamage;
                handler.Set(12, DamagedVehicle.Health);
                handler.Set(13, _damageTaken);
                handler.respond = true;
            }
            else  //vehicle has been destroyed
            {
                if (DamagedVehicle.Team != Team.None)
                {
                    //Creating the death packet from the original buffer
                    foreach (Objects.VehicleSeat Seat in DamagedVehicle.Seats)
                    {
                        Entities.Player Victim = Seat.UsedBy;

                        if (Victim != null && Victim.IsAlive)
                        {
                            Networking.GameDataHandler DeathHandler = Managers.PacketManager.Instance.GetHandler((ushort)GameSubs.PlayerDeath);
                            if (DeathHandler != null)
                            {
                                try
                                {
                                    DeathHandler.Process(Victim.User, handler.GetIncPacket());

                                    if (!isFriendlyFire(Attacker, Victim))
                                    {
                                        Victim.AddDeaths();
                                        Attacker.AddKill(false);
                                    }
                                    else
                                    {
                                        Attacker.SubtractKill();
                                        Attacker.AddFakeDeath();
                                    }
                                    OnDeath(Attacker, Victim);
                                }
                                catch { ServerLogger.Instance.Append(ServerLogger.AlertLevel.ServerError, string.Concat("Could not kill player ", Victim.User.Displayname, " on vehicle ", DamagedVehicle.Code)); }
                            }
                        }
                    }
                }

                //Destroying veh
                handler.type = GameSubs.ObjectDestroy;
                handler.Set(12, DamagedVehicle.Health);
                handler.Set(13, _damageTaken);
                handler.Set(14, 15);
                handler.respond = true;

                if (!isFriendlyFire(Attacker, DamagedVehicle))
                {
                    Attacker.VehiclesDestroyed++;
                    Attacker.User.VehiclesDestroyed++;
                }
                ServerLogger.Instance.Append(ServerLogger.AlertLevel.Gaming, string.Concat(Attacker.User.Displayname, " destroyed a vehicle: ", DamagedVehicle.Code));
            }
        }