Esempio n. 1
0
        int teamchange(PacketStream ps)
        {
            byte id       = ps.ReadByte();
            byte new_team = ps.ReadByte();
            byte new_skin = ps.ReadByte();

            PlayerObject tmp = players[id];

            LogConsole(String.Format("{0} joins team {1} with skin {2}", tmp.Name, new_team, new_skin));

            if (new_team == 1 || new_team == 2)
            {
                tmp.Team = new_team;
                tmp.Skin = new_skin;
            }

            return(1);
        }
Esempio n. 2
0
        int rotationUpdate(PacketStream ps)
        {
            byte  id       = ps.ReadByte();
            float rotation = ps.ReadFloat();

            players[id].Rotation = rotation;

            return(1);
        }
Esempio n. 3
0
        int weaponbuy(PacketStream ps)
        {
            byte player_id = ps.ReadByte();
            byte wpn_id    = ps.ReadByte();

            if (player_id == own_id)
            {
                botLogics.OnWeaponBuy(wpn_id);
            }
            short money = ps.ReadShort();
            byte  uk0   = ps.ReadByte(); // 0

            players[player_id].Money = money;

            //LogConsole("Weaponbuy: " + wpn_id + " " + money);

            return(1);
        }
Esempio n. 4
0
        int spawnitem(PacketStream ps)
        {
            byte  wpn_id = ps.ReadByte();
            short tilex  = ps.ReadShort();
            short tiley  = ps.ReadShort();
            short uk1    = ps.ReadShort();

            return(1);
        }
Esempio n. 5
0
        int fire(PacketStream ps)
        {
            byte id = ps.ReadByte();

            if (id == own_id)
            {
                botLogics.OnFire();
            }
            return(1);
        }
Esempio n. 6
0
        int positionUpdate(PacketStream ps)
        {
            byte         id  = ps.ReadByte();
            short        px  = ps.ReadShort();
            short        py  = ps.ReadShort();
            PlayerObject tmp = players[id];

            tmp.X = px; tmp.Y = py;
            return(1);
        }
Esempio n. 7
0
        int setpos(PacketStream ps)
        {
            byte  id = ps.ReadByte();
            short x  = ps.ReadShort();
            short y  = ps.ReadShort();

            players[id].X = x;
            players[id].Y = y;
            return(1);
        }
Esempio n. 8
0
        int roundstart(PacketStream ps)
        {
            ps.ReadByte();//unknown
            int count = ps.ReadByte();

            for (int i = 0; i < count; i++)
            {
                byte id = ps.ReadByte();

                if (id == own_id)
                {
                    botLogics.OnRoundStart();
                }

                short sx     = ps.ReadShort();
                short sy     = ps.ReadShort();
                float rot    = ps.ReadFloat();
                byte  wpn_id = ps.ReadByte();

                /*if (team == 1)
                 *  team = 2;
                 * else if (team == 2)
                 *  team = 1;*/
                byte uk2 = ps.ReadByte();
                byte uk3 = ps.ReadByte();


                if (id > 0 && id < 33)
                {
                    PlayerObject tmp = players[id];
                    tmp.Id = id;
                    //LogConsole(String.Format("mass spawn {0} wpn:{1} uk:{2} uk:{3}", tmp.Name, wpn_id, uk2, uk3));

                    tmp.X      = sx; tmp.Y = sy; tmp.Rotation = rot; tmp.Currentweapon = wpn_id;
                    tmp.Health = 100;
                }
                else
                {
                    return(0);
                }
            }

            short money = ps.ReadShort();

            byte wpnCount = ps.ReadByte();

            for (int j = 0; j < wpnCount; j++)
            {
                ps.ReadByte();
            }

            return(1);
        }
Esempio n. 9
0
        int chatmsg(PacketStream ps)
        {
            byte id     = ps.ReadByte();
            byte uk2    = ps.ReadByte();
            byte strlen = ps.ReadByte();

            ps.ReadByte();
            string txt = ps.ReadString(strlen);

            if (id != 0 && players[id] != null)
            {
                LogConsole(String.Format("[P] {0}: {1}", players[id].Name, txt));
            }
            else
            {
                LogConsole(String.Format("[U]: {0}", txt));
            }
            return(1);
        }
Esempio n. 10
0
        /// <summary>
        /// Function determines what happens when information about a server is returned
        /// </summary>
        /// <param name="ps"></param>
        /// <param name="svi"></param>
        /// <returns></returns>
        private int OnServerInformationReceive(PacketStream ps, ServerInformation svi)
        {
            byte cmd = ps.ReadByte();

            if (cmd == 1)
            {
                ps.ReadByte(); // dunno?
                svi.Name           = ps.ReadString();
                svi.Map            = ps.ReadString();
                svi.CurrentClients = ps.ReadByte();
                svi.MaxClients     = ps.ReadByte();
                byte gamemode = ps.ReadByte();

                AddServerToGrid(svi);
            }
            else if (cmd == 5)
            {
                //player info
            }
            return(0);
        }
Esempio n. 11
0
        int spawnmsg(PacketStream ps)
        {
            byte id = ps.ReadByte();

            short spawnx = ps.ReadShort();
            short spawny = ps.ReadShort();

            // float rot = ps.ReadFloat();

            ps.ReadByte();
            ps.ReadByte();
            ps.ReadByte();
            ps.ReadByte();



            byte wpns = ps.ReadByte(); // 50?

            for (int j = 0; j < wpns; j++)
            {
                ps.ReadByte();
                ps.ReadByte();
            }
            //byte uk = ps.ReadByte(); // 0
            //byte uk2 = ps.ReadByte();
            //short money = ps.ReadShort(); // 200
            //byte numweapons = ps.ReadByte(); // 1

            //LogConsole(String.Format("{0} spawned at {1}/{2}", id, spawnx, spawny));

            if (id > 0 && id < 33)
            {
                PlayerObject tmp = players[id];
                tmp.X = spawnx;
                tmp.Y = spawny;
                return(1);
            }
            else
            {
                return(0);
            }
            //tmp.Currentweapon = wpn;
            //tmp.Money = money;

            //if (id == own_id)
            //{
            //LogConsole(String.Format("{0} spawned with: {1} / {2} / {3} / {4} / {5} {6}", tmp.Name, spawnx, spawny,wpn,rot,wpn,uk,uk2));
            //}
        }
Esempio n. 12
0
        int killmsg(PacketStream ps)
        {
            byte  victim = ps.ReadByte();
            byte  source = ps.ReadByte();
            byte  wpn_id = ps.ReadByte();
            short sx     = ps.ReadShort();
            short sy     = ps.ReadShort();

            PlayerObject tmp = players[victim];

            tmp.Health = 0;

            if (victim == own_id)
            {
                botLogics.OnDeath();
            }

            if (source == own_id)
            {
                botLogics.OnKill(victim);
            }
            return(1);
        }
Esempio n. 13
0
        int positionRotationUpdate(PacketStream ps)
        {
            byte  id  = ps.ReadByte();
            short x   = ps.ReadShort();
            short y   = ps.ReadShort();
            float rot = ps.ReadFloat();

            if (id >= 0 && id <= 32)
            {
                PlayerObject tmp = players[id];
                tmp.Id       = id;
                tmp.X        = x;
                tmp.Y        = y;
                tmp.Rotation = rot;
                return(1);
            }
            return(0);
        }
Esempio n. 14
0
        int usepress(PacketStream ps)
        {
            //LogConsole("Using or sth? " + ps);
            byte id  = ps.ReadByte();
            byte uk2 = ps.ReadByte();

            ps.ReadByte(); ps.ReadByte(); ps.ReadByte(); ps.ReadByte();
            short x = ps.ReadShort();
            short y = ps.ReadShort();

            //LogConsole("Defuse bomb: " + ps.ToString());
            return(1);
        }
Esempio n. 15
0
        /// <summary>
        /// Constructs the list of servers, based on the packet received from usgn.de
        /// </summary>
        /// <param name="ps"></param>
        /// <returns></returns>
        private int OnUsgnServerPacket(PacketStream ps)
        {
            short num_servers = ps.ReadShort();

            for (int i = 0; i < num_servers; i++)
            {
                byte[] ipdata = new byte[4];
                for (int j = 0; j < 4; j++)
                {
                    ipdata[3 - j] = ps.ReadByte();
                }

                IPAddress ipa  = new IPAddress(ipdata);
                ushort    port = (ushort)ps.ReadShort();
                RequestServerInformation(ipa, port);
                ServerInformation svi = new ServerInformation(ipa, port);
                serverList.Add(svi);
            }
            return(num_servers);
        }
Esempio n. 16
0
        int weapondrop(PacketStream ps)
        {
            byte  id      = ps.ReadByte();
            byte  wpn_id  = ps.ReadByte();
            short ammo_in = ps.ReadShort();
            short ammo    = ps.ReadShort();
            byte  uk0     = ps.ReadByte(); //mode?
            byte  uk1     = ps.ReadByte(); //mode?
            byte  uk2     = ps.ReadByte(); //mode?
            int   tilex   = ps.ReadInt();
            int   tiley   = ps.ReadInt();

            ps.ReadByte();


            botLogics.OnWeaponDrop((int)wpn_id, tilex, tiley, ammo, ammo_in);

            return(1);
        }
Esempio n. 17
0
 int newname(PacketStream ps)
 {
     byte id = ps.ReadByte();
     string new_name = ps.ReadString();
     players[id].Name = new_name;
     return 1;
 }
Esempio n. 18
0
        public void process_packet(PacketStream ps,int pktNum)
        {
            if (pktNum % 2 == 0) // if the packet is an even number, it means the server send a reliable packet, we have to send a acknowledge packet back
            {
                PacketStream h_shake = new PacketStream();
                h_shake.WriteShort(packetNumber); // own packet number
                h_shake.WriteByte(1);
                h_shake.WriteShort(pktNum); // their packet number
                ch.SendStream(h_shake,false);
            }

            while (!ps.AtEnd())
            {

                int type1 = ps.ReadByte();

                if (known_table[type1] != null)
                {
                    known_table[type1](ps);
                }
                else
                {
                    LogConsole("unknown packet: type: " + type1 + "  packet: " + ps);
                    ps.SkipAll();
                }
            }

            //if (!ps.AtEnd())
              //  process_packet(ps, pktNum);
        }
Esempio n. 19
0
 int advancedfire(PacketStream ps)
 {
     byte id = ps.ReadByte();
     byte status = ps.ReadByte();
     players[id].WeaponStatus = status;
     return 1;
 }
Esempio n. 20
0
 int bomb(PacketStream ps)
 {
     byte id = ps.ReadByte();
     byte typ = ps.ReadByte();
     ps.SkipAll(); // needs to be fixed
     return 1;
 }
Esempio n. 21
0
 int playerjoin(PacketStream ps)
 {
     byte id = ps.ReadByte();
     PlayerObject temp = players[id];
     temp.Name = ps.ReadString();
     ps.ReadByte();
     LogConsole(String.Format("[P] {0} connected!", temp.Name));
     return 1;
 }
Esempio n. 22
0
 int weaponchange(PacketStream ps)
 {
     byte id = ps.ReadByte();
     byte wpn_id = ps.ReadByte();
     byte wpn_status = ps.ReadByte(); // unknown
     //LogConsole(String.Format("{0} changed to weapon {1}", players[id].Name, wpn_id));
     players[id].Currentweapon = wpn_id;
     players[id].WeaponStatus = wpn_status;
     return 1;
 }
Esempio n. 23
0
        int weapondrop(PacketStream ps)
        {
            byte id = ps.ReadByte();
            byte wpn_id = ps.ReadByte();
            short ammo_in = ps.ReadShort();
            short ammo = ps.ReadShort();
            byte uk0 = ps.ReadByte();//mode?
            byte uk1 = ps.ReadByte();//mode?
            byte uk2 = ps.ReadByte();//mode?
            int tilex = ps.ReadInt();
            int tiley = ps.ReadInt();
            ps.ReadByte();

            botLogics.OnWeaponDrop((int)wpn_id, tilex, tiley, ammo, ammo_in);

            return 1;
        }
Esempio n. 24
0
        /// <summary>
        /// Function determines what happens when information about a server is returned
        /// </summary>
        /// <param name="ps"></param>
        /// <param name="svi"></param>
        /// <returns></returns>
        private int OnServerInformationReceive(PacketStream ps,ServerInformation svi)
        {
            byte cmd = ps.ReadByte();
            if (cmd == 1)
            {
                ps.ReadByte(); // dunno?
                svi.Name = ps.ReadString();
                svi.Map = ps.ReadString();
                svi.CurrentClients = ps.ReadByte();
                svi.MaxClients = ps.ReadByte();
                byte gamemode = ps.ReadByte();

                AddServerToGrid(svi);
            }
            else if (cmd == 5)
            {
                //player info
            }
            return 0;
        }
Esempio n. 25
0
        int chatmsg(PacketStream ps)
        {
            byte id = ps.ReadByte();
            byte uk2 = ps.ReadByte();
            byte strlen = ps.ReadByte();
            ps.ReadByte();
            string txt = ps.ReadString(strlen);

            if (id != 0 && players[id] != null)
                LogConsole(String.Format("[P] {0}: {1}", players[id].Name, txt));
            else
                LogConsole(String.Format("[U]: {0}", txt));
            return 1;
        }
Esempio n. 26
0
 int unknown1(PacketStream ps)
 {            // Dont know!!
     ps.ReadByte();
     ps.ReadByte();
     return(1);
 }
Esempio n. 27
0
 int positionUpdate(PacketStream ps)
 {
     byte id = ps.ReadByte();
     short px = ps.ReadShort();
     short py = ps.ReadShort();
     PlayerObject tmp = players[id];
     tmp.X = px; tmp.Y = py;
     return 1;
 }
Esempio n. 28
0
        int positionRotationUpdate(PacketStream ps)
        {
            byte id = ps.ReadByte();
            short x = ps.ReadShort();
            short y = ps.ReadShort();
            float rot = ps.ReadFloat();

            if (id >= 0 && id <= 32)
            {
                PlayerObject tmp = players[id];
                tmp.Id = id;
                tmp.X = x;
                tmp.Y = y;
                tmp.Rotation = rot;
                return 1;
            }
            return 0;
        }
Esempio n. 29
0
        int playerleave(PacketStream ps)
        {
            byte id = ps.ReadByte();
            byte reason = ps.ReadByte();// discard reason
            PlayerObject tmp = players[id];

            string textReason;

            switch (reason)
            {
                case 0:
                    textReason = "normal";
                    break;
                case 2:
                    textReason = "kicked";
                    break;
                case 6:
                    textReason = "banned";
                    break;
                case 13:
                    textReason = "voted";
                    break;
                case 15:
                    textReason = "speedhacker";
                    break;
                default:
                    textReason = "unknown";
                    break;
            }
            LogConsole(String.Format("{0} left the server! reason:{1} {2}", tmp.Name,reason, textReason));
            players[id] = new PlayerObject(); // make a new one/overwrite the old one
            players[id].Id = 0;

            if (id == own_id)
                cl.Close();

            return 1;
        }
Esempio n. 30
0
        int weaponpickup(PacketStream ps)
        {
            byte id = ps.ReadByte();
            byte uk0 = ps.ReadByte();
            byte uk1 = ps.ReadByte(); // 2 0
            byte wpn_id = ps.ReadByte();
            short ammon_in = ps.ReadShort();
            short ammo = ps.ReadShort();

            if (id == own_id)
            {
                botLogics.OnWeaponPickup(wpn_id, ammo, ammon_in);
            }
            ps.ReadByte();
            return 1;
        }
Esempio n. 31
0
 int specpos(PacketStream ps)
 {
     ps.ReadByte(); ps.ReadByte(); ps.ReadByte();
     return(1);
 }
Esempio n. 32
0
        int killmsg(PacketStream ps)
        {
            byte victim = ps.ReadByte();
            byte source = ps.ReadByte();
            byte wpn_id = ps.ReadByte();
            short sx = ps.ReadShort();
            short sy = ps.ReadShort();

            PlayerObject tmp = players[victim];
            tmp.Health = 0;

            if (victim == own_id)
                botLogics.OnDeath();

            if (source == own_id)
                botLogics.OnKill(victim);
            return 1;
        }
Esempio n. 33
0
        int hit(PacketStream ps)
        {
            byte victim_id = ps.ReadByte();
            byte source_id = ps.ReadByte();
            byte health = ps.ReadByte();
            byte uk0 = ps.ReadByte();

            PlayerObject tmp = players[victim_id];
            tmp.Health = health;
            return 1;
        }
Esempio n. 34
0
        int joinroutine_known(PacketStream ps)
        {
            int type2 = ps.ReadByte();
            if (type2 == 0)
            {
                String serverKey = ps.ReadString();
                send_join_packet_252_1(local_player, serverKey);
            }
            else if (type2 == 2)
            {
                byte state = ps.ReadByte();
                if (state == 0)
                {
                    own_id = ps.ReadByte();
                    String mapName = ps.ReadString();
                    String skey = ps.ReadString();
                    send_map_confirmation(mapName, skey);
                }
                else
                {
                    if (state == 1)
                        LogConsole("Error: wrong password!");
                    else if (state == 3)
                        LogConsole("Error: server is full!");
                    else if (state == 4)
                        LogConsole("Error: banned!");
                    else if (state == 23)
                        LogConsole("Error: maximum number of clients reached!");
                    else if (state == 22)
                        LogConsole("Error: invalid precon send to server!");
                    else
                        LogConsole("Error on joining: " + state);

                    cl.Close();
                }
            }
            else if (type2 == 3)
            {

            }
            else if (type2 == 4)
            {
                ps.ReadByte();
                send_map_name_252_05();
            }
            else if (type2 == 6)
            {
                ps.SkipAll();//server data
            }
            else if (type2 == 7)
            {
                //Player data
                int type3 = ps.ReadByte();
                if (type3 == 1)
                {
                    int onlinePlayer = ps.ReadByte();
                    for (int i = 0; i < onlinePlayer; i++)
                    {
                        PlayerObject temp;

                        byte id = ps.ReadByte();
                        temp = players[id];

                        temp.Id = id;
                        temp.Name = StringHelper.DecodePlayerName(ps.ReadString());

                        string lulz = StringHelper.DecodePlayerName(ps.ReadString());

                        lulz += 'a';

                        //ps.ReadByte();//uk
                        temp.Team = ps.ReadByte();
                        ps.ReadByte(); ps.ReadByte(); //uks
                        temp.Score = ps.ReadShort();
                        temp.Death = ps.ReadShort();
                        temp.X = ps.ReadShort();
                        ps.ReadShort();//uk tile_x
                        temp.Y = ps.ReadShort();
                        ps.ReadShort(); // uk tile_y?
                        ps.ReadShort();// rotation??
                        temp.Health = ps.ReadByte();
                        temp.Armor = ps.ReadByte();
                        ps.ReadByte();//uk
                        temp.Currentweapon = ps.ReadByte();
                        ps.ReadByte();

                        players[temp.Id] = temp;
                    }

                    LogConsole("Own player: " + players[own_id].ToString());
                }
                else if (type3 == 2)
                {
                    //hostage data
                    ps.SkipAll();
                }
                else if (type3 == 3)
                {
                    // item data
                    //ps.SkipAll();
                    int count = ps.ReadByte();
                    for (int i = 0; i < count; i++)
                    {
                        ps.ReadByte();
                        ps.ReadByte();
                        byte wpn_id = ps.ReadByte();
                        short tilex = ps.ReadShort();
                        short tiley = ps.ReadShort();
                        short ammoin = ps.ReadShort();
                        short ammo = ps.ReadShort();

                        botLogics.OnWeaponDrop(wpn_id, tilex, tiley, ammo, ammoin);
                    }
                }
                else if (type3 == 4) //entity data
                {
                    ps.SkipAll();
                }
                else if (type3 == 5) //DynamicObjectData
                {
                    ps.SkipAll();
                }
                else if (type3 == 6) // ProjectileData
                {
                    ps.SkipAll();
                }
                else if (type3 == 7) //DynamicObjectImageData
                {
                    ps.SkipAll();
                }
                else if (type3 == 8)
                {
                    ps.SkipAll();
                }
                else if (type3 == 200) // final ack
                {
                    LogConsole("Connected!");
                    ps.ReadString();
                    ps.ReadByte(); ps.ReadByte(); ps.ReadByte();
                    send_unknown_packet_28();
                    //send_spec_pos_32(440, 660);
                }
            }
            else if (type2 == 50) // okay wtf?
                ps.SkipAll();
            return 1;
        }
Esempio n. 35
0
        int spawnmsg(PacketStream ps)
        {
            byte id = ps.ReadByte();

            short spawnx = ps.ReadShort();
            short spawny = ps.ReadShort();

               // float rot = ps.ReadFloat();

            ps.ReadByte();
            ps.ReadByte();
            ps.ReadByte();
            ps.ReadByte();

            byte wpns = ps.ReadByte(); // 50?

            for (int j = 0; j < wpns; j++)
            {
                ps.ReadByte();
                ps.ReadByte();
            }
            //byte uk = ps.ReadByte(); // 0
            //byte uk2 = ps.ReadByte();
            //short money = ps.ReadShort(); // 200
            //byte numweapons = ps.ReadByte(); // 1

            //LogConsole(String.Format("{0} spawned at {1}/{2}", id, spawnx, spawny));

            if (id > 0 && id < 33)
            {
                PlayerObject tmp = players[id];
                tmp.X = spawnx;
                tmp.Y = spawny;
                return 1;
            }
            else
                return 0;
            //tmp.Currentweapon = wpn;
            //tmp.Money = money;

            //if (id == own_id)
            //{
            //LogConsole(String.Format("{0} spawned with: {1} / {2} / {3} / {4} / {5} {6}", tmp.Name, spawnx, spawny,wpn,rot,wpn,uk,uk2));
            //}
        }
Esempio n. 36
0
        int weaponbuy(PacketStream ps)
        {
            byte player_id = ps.ReadByte();
            byte wpn_id = ps.ReadByte();
            if (player_id == own_id)
            {
                botLogics.OnWeaponBuy(wpn_id);
            }
            short money = ps.ReadShort();
            byte uk0 = ps.ReadByte(); // 0

            players[player_id].Money = money;

            //LogConsole("Weaponbuy: " + wpn_id + " " + money);

            return 1;
        }
Esempio n. 37
0
 int pinglist(PacketStream ps)
 {
     byte count = ps.ReadByte();
     for (int i = 0; i < count; i++)
     {
         byte id = ps.ReadByte();
         ushort ping = (ushort)ps.ReadShort();
     }
     return 1;
 }
Esempio n. 38
0
 int vote(PacketStream ps)
 {
     byte typ = ps.ReadByte();
     string data = ps.ReadString();
     botLogics.OnVote(data);
     return 1;
 }
Esempio n. 39
0
 int spawnitem(PacketStream ps)
 {
     byte wpn_id = ps.ReadByte();
     short tilex = ps.ReadShort();
     short tiley = ps.ReadShort();
     short uk1 = ps.ReadShort();
     return 1;
 }
Esempio n. 40
0
 int projectile(PacketStream ps)
 {
     byte player_id = ps.ReadByte();//one who throws the nade
     byte wpn_id = ps.ReadByte();
     short x_origin = ps.ReadShort();
     short y_origin = ps.ReadShort();
     float angle = ps.ReadFloat();
     byte uk0 = ps.ReadByte();
     ps.ReadByte(); // discard 0
     return 1;
 }
Esempio n. 41
0
 int fire(PacketStream ps)
 {
     byte id = ps.ReadByte();
     if (id == own_id)
     {
         botLogics.OnFire();
     }
     return 1;
 }
Esempio n. 42
0
        int joinroutine_known(PacketStream ps)
        {
            int type2 = ps.ReadByte();

            if (type2 == 0)
            {
                String serverKey = ps.ReadString();
                send_join_packet_252_1(local_player, serverKey);
            }
            else if (type2 == 2)
            {
                byte state = ps.ReadByte();
                if (state == 0)
                {
                    own_id = ps.ReadByte();
                    String mapName = ps.ReadString();
                    String skey    = ps.ReadString();
                    send_map_confirmation(mapName, skey);
                }
                else
                {
                    if (state == 1)
                    {
                        LogConsole("Error: wrong password!");
                    }
                    else if (state == 3)
                    {
                        LogConsole("Error: server is full!");
                    }
                    else if (state == 4)
                    {
                        LogConsole("Error: banned!");
                    }
                    else if (state == 23)
                    {
                        LogConsole("Error: maximum number of clients reached!");
                    }
                    else if (state == 22)
                    {
                        LogConsole("Error: invalid precon send to server!");
                    }
                    else
                    {
                        LogConsole("Error on joining: " + state);
                    }

                    cl.Close();
                }
            }
            else if (type2 == 3)
            {
            }
            else if (type2 == 4)
            {
                ps.ReadByte();
                send_map_name_252_05();
            }
            else if (type2 == 6)
            {
                ps.SkipAll();//server data
            }
            else if (type2 == 7)
            {
                //Player data
                int type3 = ps.ReadByte();
                if (type3 == 1)
                {
                    int onlinePlayer = ps.ReadByte();
                    for (int i = 0; i < onlinePlayer; i++)
                    {
                        PlayerObject temp;

                        byte id = ps.ReadByte();
                        temp = players[id];

                        temp.Id   = id;
                        temp.Name = StringHelper.DecodePlayerName(ps.ReadString());

                        string lulz = StringHelper.DecodePlayerName(ps.ReadString());

                        lulz += 'a';

                        //ps.ReadByte();//uk
                        temp.Team = ps.ReadByte();
                        ps.ReadByte(); ps.ReadByte(); //uks
                        temp.Score = ps.ReadShort();
                        temp.Death = ps.ReadShort();
                        temp.X     = ps.ReadShort();
                        ps.ReadShort(); //uk tile_x
                        temp.Y = ps.ReadShort();
                        ps.ReadShort(); // uk tile_y?
                        ps.ReadShort(); // rotation??
                        temp.Health = ps.ReadByte();
                        temp.Armor  = ps.ReadByte();
                        ps.ReadByte();//uk
                        temp.Currentweapon = ps.ReadByte();
                        ps.ReadByte();

                        players[temp.Id] = temp;
                    }

                    LogConsole("Own player: " + players[own_id].ToString());
                }
                else if (type3 == 2)
                {
                    //hostage data
                    ps.SkipAll();
                }
                else if (type3 == 3)
                {
                    // item data
                    //ps.SkipAll();
                    int count = ps.ReadByte();
                    for (int i = 0; i < count; i++)
                    {
                        ps.ReadByte();
                        ps.ReadByte();
                        byte  wpn_id = ps.ReadByte();
                        short tilex  = ps.ReadShort();
                        short tiley  = ps.ReadShort();
                        short ammoin = ps.ReadShort();
                        short ammo   = ps.ReadShort();

                        botLogics.OnWeaponDrop(wpn_id, tilex, tiley, ammo, ammoin);
                    }
                }
                else if (type3 == 4) //entity data
                {
                    ps.SkipAll();
                }
                else if (type3 == 5) //DynamicObjectData
                {
                    ps.SkipAll();
                }
                else if (type3 == 6) // ProjectileData
                {
                    ps.SkipAll();
                }
                else if (type3 == 7) //DynamicObjectImageData
                {
                    ps.SkipAll();
                }
                else if (type3 == 8)
                {
                    ps.SkipAll();
                }
                else if (type3 == 200) // final ack
                {
                    LogConsole("Connected!");
                    ps.ReadString();
                    ps.ReadByte(); ps.ReadByte(); ps.ReadByte();
                    send_unknown_packet_28();
                    //send_spec_pos_32(440, 660);
                }
            }
            else if (type2 == 50) // okay wtf?
            {
                ps.SkipAll();
            }
            return(1);
        }
Esempio n. 43
0
        int reload(PacketStream ps)
        {
            byte id = ps.ReadByte();
            byte status = ps.ReadByte();

            if (status != 1 && id == own_id)
                botLogics.OnReloadFinish();

            return 1;
        }
Esempio n. 44
0
 /// <summary>
 /// This function parses the packet
 /// </summary>
 /// <param name="ar"></param>
 private void OnReceive(IAsyncResult ar)
 {
     EndPoint ep = new IPEndPoint(IPAddress.Any, 0);
     int length = serverlistSocket.EndReceiveFrom(ar, ref ep);
     IPEndPoint ipe = (IPEndPoint)ep;
     PacketStream ps = new PacketStream(buffer, length);
     short pkt = ps.ReadShort();
     byte type = ps.ReadByte();
     int retn;
     switch (type)
     {
         case 0x14:
             retn = OnUsgnServerPacket(ps);
             break;
         case 0xfb:
             ServerInformation svi = GetServerFromList(ep);
             if(svi != null)
                 OnServerInformationReceive(ps,svi);
             break;
         default:
             break;
     }
     ReceiveMessages(); // start receivin' the shizzle again
 }
Esempio n. 45
0
        int rotationUpdate(PacketStream ps)
        {
            byte id = ps.ReadByte();
            float rotation = ps.ReadFloat();
            players[id].Rotation = rotation;

            return 1;
        }
Esempio n. 46
0
        /// <summary>
        /// Constructs the list of servers, based on the packet received from usgn.de
        /// </summary>
        /// <param name="ps"></param>
        /// <returns></returns>
        private int OnUsgnServerPacket(PacketStream ps)
        {
            short num_servers = ps.ReadShort();
            for (int i = 0; i < num_servers; i++)
            {
                byte[] ipdata = new byte[4];
                for (int j = 0;j < 4; j++) { ipdata[3-j] = ps.ReadByte(); }

                IPAddress ipa = new IPAddress(ipdata);
                ushort port = (ushort)ps.ReadShort();
                RequestServerInformation(ipa, port);
                ServerInformation svi = new ServerInformation(ipa,port);
                serverList.Add(svi);

            }
            return num_servers;
        }
Esempio n. 47
0
        int roundstart(PacketStream ps)
        {
            ps.ReadByte();//unknown
            int count = ps.ReadByte();
            for (int i = 0; i < count; i++)
            {
                byte id = ps.ReadByte();

                if (id == own_id)
                    botLogics.OnRoundStart();

                short sx = ps.ReadShort();
                short sy = ps.ReadShort();
                float rot = ps.ReadFloat();
                byte wpn_id = ps.ReadByte();
                /*if (team == 1)
                    team = 2;
                else if (team == 2)
                    team = 1;*/
                byte uk2 = ps.ReadByte();
                byte uk3 = ps.ReadByte();

                if (id > 0 && id < 33)
                {
                    PlayerObject tmp = players[id];
                    tmp.Id = id;
                    //LogConsole(String.Format("mass spawn {0} wpn:{1} uk:{2} uk:{3}", tmp.Name, wpn_id, uk2, uk3));

                    tmp.X = sx; tmp.Y = sy; tmp.Rotation = rot; tmp.Currentweapon = wpn_id;
                    tmp.Health = 100;
                }
                else
                    return 0;

            }

            short money = ps.ReadShort();

            byte wpnCount = ps.ReadByte();
            for (int j = 0; j < wpnCount; j++)
            {
                ps.ReadByte();
            }

            return 1;
        }
Esempio n. 48
0
 int setpos(PacketStream ps)
 {
     byte id = ps.ReadByte();
     short x = ps.ReadShort();
     short y = ps.ReadShort();
     players[id].X = x;
     players[id].Y = y;
     return 1;
 }
Esempio n. 49
0
 int usepress(PacketStream ps)
 {
     //LogConsole("Using or sth? " + ps);
     byte id = ps.ReadByte();
     byte uk2 = ps.ReadByte();
     ps.ReadByte(); ps.ReadByte(); ps.ReadByte(); ps.ReadByte();
     short x = ps.ReadShort();
     short y = ps.ReadShort();
     //LogConsole("Defuse bomb: " + ps.ToString());
     return 1;
 }