示例#1
0
        public static void Handle(ulong clientId, Packet packet, SslStream stream)
        {
            Dictionary <string, Tdf> data = Utilities.DecodePayload(packet.payload);

            TdfInteger gid  = (TdfInteger)data["GID"];
            TdfList    pcap = (TdfList)data["PCAP"];

            Database.UpdateGameCapacity(gid.value, pcap.list);

            TdfEncoder encoder = new TdfEncoder();

            byte[] payload = encoder.Encode();

            Utilities.SendPacket(new Packet
            {
                componentId = Component.GAMEMANAGER,
                commandId   = 0x5,
                errorCode   = 0,
                msgType     = MessageType.REPLY,
                msgNum      = packet.msgNum,

                payload     = payload,
                payloadSize = payload.Length
            }, stream);

            GameCapacityChangeNotification.Notify(gid.value, pcap.list, stream);
        }
示例#2
0
        private TdfList DecodeTdfList(string label)
        {
            // read list type
            byte listType = (byte)_stream.ReadByte();

            // read list size
            int listSize = _stream.ReadByte();

            // read list
            ArrayList data = DecodeList((TdfBaseType)listType, listSize);

            TdfList list = new TdfList(label, (TdfBaseType)listType, data);

            return(list);
        }
示例#3
0
        private void WriteTdfList(TdfList tdf)
        {
            // write list type
            _stream.WriteByte((byte)tdf.listType);

            // write list size
            _stream.WriteByte((byte)tdf.list.Count);

            if (tdf.stub)
            {
                _stream.WriteByte(2);
            }

            // write list
            WriteList(tdf.listType, tdf.list);
        }
        public static void Handle(ulong clientId, Packet packet, SslStream stream)
        {
            Dictionary <string, Tdf> data = Utilities.DecodePayload(packet.payload);

            TdfList    targ     = (TdfList)data["TARG"];
            List <Tdf> targData = (List <Tdf>)targ.list[0];
            TdfInteger stat     = (TdfInteger)targData[2];

            TdfEncoder encoder = new TdfEncoder();

            byte[] payload = encoder.Encode();

            Utilities.SendPacket(new Packet
            {
                componentId = Component.GAMEMANAGER,
                commandId   = 0x1D,
                errorCode   = 0,
                msgType     = MessageType.REPLY,
                msgNum      = packet.msgNum,

                payload     = payload,
                payloadSize = payload.Length
            }, stream);

            var client = ClientManager.GetClient(clientId);

            switch ((PlayerState)stat.value)
            {
            case PlayerState.DISCONNECTED:
                // TODO: GameManager.RemovePlayer?
                Log.Warn("*updateMeshConnection -> RemovePlayer*");
                break;

            case PlayerState.CONNECTED:
                GamePlayerStateChangeNotification.Notify(clientId, stream);
                PlayerJoinCompletedNotification.Notify(client.gameId, client.persona.id, stream);
                break;

            default:
                Log.Warn("Unknown PlayerState in updateMeshCommand: " + stat.value);
                break;
            }
        }
        public static void Handle(ulong clientId, Packet packet, SslStream stream)
        {
            Dictionary <string, Tdf> data = Utilities.DecodePayload(packet.payload);
            TdfInteger vid = (TdfInteger)data["VID"];
            TdfList    eid = (TdfList)data["EID"];

            ClientManager.UpdateViewID(clientId, vid.value);
            ClientManager.UpdateEntityIDs(clientId, eid.list);

            Utilities.SendPacket(new Packet
            {
                componentId = Component.STATS,
                commandId   = 0x10,
                errorCode   = 0,
                msgType     = MessageType.REPLY,
                msgNum      = packet.msgNum,

                payload     = null,
                payloadSize = 0
            }, stream);
        }
        public static void Handle(ulong clientId, Packet packet, SslStream stream)
        {
            var client = ClientManager.GetClient(clientId);

            string player_awards       = "player_awards";
            string player_awards2      = "player_awards2";
            string player_weapons1     = "player_weapons1";
            string player_statcategory = "player_statcategory";
            string player_core         = "player_core";
            string coopplayer_coop     = "coopplayer_coop";
            string player_reset        = "player_reset";

            string[] catg = new string[1433];

            for (int j = 0; j < 993; j++)
            {
                catg[j] = player_awards;
            }
            for (int k = 993; k < 1166; k++)
            {
                catg[k] = player_awards2;
            }
            for (int l = 1166; l < 1296; l++)
            {
                catg[l] = player_weapons1;
            }
            for (int m = 1296; m < 1406; m++)
            {
                catg[m] = player_statcategory;
            }
            for (int n = 1406; n < 1427; n++)
            {
                catg[n] = player_core;
            }
            catg[1427] = coopplayer_coop;
            catg[1428] = player_core;
            catg[1429] = player_core;
            catg[1430] = player_core;
            catg[1431] = player_statcategory;
            catg[1432] = player_reset;

            TdfList stat = new TdfList("STAT", TdfBaseType.TDF_TYPE_STRUCT, new ArrayList {
            });

            for (int i = 0; i < 1433; i++)
            {
                stat.list.Add(new List <Tdf>
                {
                    new TdfString("CATG", catg[i]),
                    new TdfString("DFLT", "0.00"),
                    new TdfInteger("DRVD", 0x0),
                    new TdfString("FRMT", "%.2f"),
                    new TdfString("KIND", ""),
                    new TdfString("LDSC", ""),
                    new TdfString("META", ""),
                    new TdfString("NAME", Utilities.GetStatName(i)),
                    new TdfString("SDSC", ""),
                    new TdfInteger("TYPE", 0x1)
                });
            }

            Dictionary <string, Tdf> data = Utilities.DecodePayload(packet.payload);

            TdfEncoder encoder = new TdfEncoder();

            encoder.WriteTdf(new List <Tdf>
            {
                new TdfString("CNAM", player_awards),
                new TdfString("DESC", "player_mpdefault2"), // TODO: fetch name from decoded data
                new TdfVector2("ETYP", 30722, 1),
                new TdfString("META", ""),
                new TdfString("NAME", "player_mpdefault2"),
                stat
            });

            byte[] payload = encoder.Encode();

            Utilities.SendPacket(new Packet
            {
                componentId = Component.STATS,
                commandId   = 0x4,
                errorCode   = 0,
                msgType     = MessageType.REPLY,
                msgNum      = packet.msgNum,

                payload     = payload,
                payloadSize = payload.Length
            }, stream);
        }
        public static void Handle(ulong clientId, Packet packet, SslStream stream)
        {
            Dictionary <string, Tdf> data = Utilities.DecodePayload(packet.payload);
            TdfString etag = (TdfString)data["ETAG"];

            bool onlineAccess = false;

            if (etag.value == "ONLINE_ACCESS")
            {
                onlineAccess = true;
            }

            var client = ClientManager.GetClient(clientId);

            TdfEncoder encoder = new TdfEncoder();

            if (onlineAccess == false)
            {
                TdfList nlst = new TdfList("NLST", TdfBaseType.TDF_TYPE_STRUCT, new ArrayList
                {
                    new List <Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2011-11-02T11:2Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1234632478),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "303566"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "DR:224766400"),
                        new TdfInteger("STAT", 1),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "ONLINE_ACCESS"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 1),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },
                    new List <Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2011-11-02T11:2Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1294632417),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "303566"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "303566"),
                        new TdfInteger("STAT", 1),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "PROJECT10_CODE_CONSUMED_LE1"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 1),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },
                    new List <Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2013-02-22T14:40Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 5674749135),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "306678"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "OFB-EAST:50401"),
                        new TdfInteger("STAT", 1),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "BF3:PREMIUM_ACCESS"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 5),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },
                    new List <Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2014-05-29T6:15Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1005150961807),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "305060"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "DR:235665900"),
                        new TdfInteger("STAT", 2),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "ONLINE_ACCESS"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 1),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },
                    new List <Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2013-02-22T14:40Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1002134961807),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "305061"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "DR:235663400"),
                        new TdfInteger("STAT", 2),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "ONLINE_ACCESS"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 1),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },
                    new List <Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2012-06-04T21:13Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1771457489),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "306678"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "OFB-EAST:50400"),
                        new TdfInteger("STAT", 1),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "BF3:PREMIUM_ACCESS"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 5),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },

                    // DLC 1 - Back 2 Karkand
                    new List <Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2012-06-04T21:13Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1771457490),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "302777"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "OFB-EAST:50400"),
                        new TdfInteger("STAT", 1),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "BF3:PC:B2K_PURCHASE"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 5),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },

                    // DLC 2
                    new List <Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2012-06-04T21:13Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1771457491),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "302776"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "OFB-EAST:48215"),
                        new TdfInteger("STAT", 1),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "BF3:PC:XPACK2_PURCHASE"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 5),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },

                    // DLC 3
                    new List <Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2014-02-07T20:15Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1004743136441),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "302778"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "OFB-EAST:51080"),
                        new TdfInteger("STAT", 1),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "BF3:PC:XPACK3_PURCHASE"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 5),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },

                    // DLC 4
                    new List <Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2012-11-26T9:4Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1000808118611),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "303129"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "OFB-EAST:55171"),
                        new TdfInteger("STAT", 1),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "BF3:PC:XPACK4_PURCHASE"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 5),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },

                    // DLC 5
                    new List <Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2013-03-07T2:21Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1002246118611),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "306409"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "OFB-EAST:109546437"),
                        new TdfInteger("STAT", 1),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "BF3:PC:XPACK5_PURCHASE"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 5),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },

                    // COOP shortcut
                    new List <Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2012-04-17T15:57Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1684196754),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "306215"),
                        new TdfInteger("PRCA", 1),
                        new TdfString("PRID", "OFB-EAST:48642"),
                        new TdfInteger("STAT", 1),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "BF3:SHORTCUT:COOP"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 5),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    }
                });

                encoder.WriteTdf(new List <Tdf>
                {
                    nlst
                });
            }

            byte[] payload = encoder.Encode();

            Utilities.SendPacket(new Packet
            {
                componentId = Component.AUTHENTICATION,
                commandId   = 0x1D,
                errorCode   = 0,
                msgType     = MessageType.REPLY,
                msgNum      = packet.msgNum,

                payload     = payload,
                payloadSize = payload.Length
            }, stream);
        }
        public static void Handle(ulong clientId, Packet packet, SslStream stream)
        {
            // decode payload
            Dictionary<string, Tdf> data = Utilities.DecodePayload(packet.payload);

            // read client type
            TdfStruct cdat = (TdfStruct)data["CDAT"];
            TdfInteger type = (TdfInteger)cdat.data.Find(tdf => tdf.label == "TYPE");
            TdfString svcn = (TdfString)cdat.data.Find(tdf => tdf.label == "SVCN");

            TdfStruct cinf = (TdfStruct)data["CINF"];
            TdfInteger loc = (TdfInteger)cinf.data.Find(tdf => tdf.label == "LOC");

            // set client type
            ClientManager.UpdateClientType(clientId, (ClientType)type.value);
            ClientManager.UpdateClientLocalization(clientId, loc.value);
            ClientManager.UpdateClientService(clientId, svcn.value);

            var client = ClientManager.GetClient(clientId);

            TdfList cids = new TdfList("CIDS", TdfBaseType.TDF_TYPE_INTEGER, new ArrayList
            {
                //1, 25, 4, 27, 28, 6, 7, 9, 10, 11, 30720, 30721, 30722, 30723, 20, 30725, 30726, 2000
            });
            cids.list.AddRange((new ulong[] { 1, 25, 4, 27, 28, 6, 7, 9, 10, 11, 30720, 30721, 30722, 30723, 20, 30725, 30726, 2000 }).ToArray());

            TdfEncoder encoder = new TdfEncoder();

            encoder.WriteTdf(new List<Tdf>
            {
                new TdfInteger("ANON", 0),
                new TdfString("ASRC", "300294"),
                cids,
                new TdfString("CNGN", ""),
                new TdfStruct("CONF", new List<Tdf>
                {
                    new TdfMap("CONF", TdfBaseType.TDF_TYPE_STRING, TdfBaseType.TDF_TYPE_STRING, new Dictionary<object, object>
                    {
                        { "connIdleTimeout", "90s" },
                        { "defaultRequestTimeout", "80s" },
                        { "pingPeriod", "20s" },
                        { "voipHeadsetUpdateRate", "1000" },
                        { "xlspConnectionIdleTimeout", "300" }
                    })
                }),
                new TdfString("INST", client.service),
                new TdfInteger("MINR", 0),
                new TdfString("NASP", "cem_ea_id"), // TODO: check if present in decoded data
                new TdfString("PILD", ""),
                new TdfString("PLAT", "pc"), // TODO: fetch from decoded data
                new TdfString("PTAG", ""),
                new TdfStruct("QOSS", new List<Tdf>
                {
                    // bandwidth ping site info
                    new TdfStruct("BWPS", new List<Tdf>
                    {
                        new TdfString("PSA", "127.0.0.1"), // ping site address
                        new TdfInteger("PSP", 17502), // ping site port
                        new TdfString("SNA", "ams") // ping site name
                    }),
                    new TdfInteger("LNP", 10), // number of latency probes
                    new TdfMap("LTPS", TdfBaseType.TDF_TYPE_STRING, TdfBaseType.TDF_TYPE_STRUCT, new Dictionary<object, object>
                    {
                        { "ams", new List<Tdf>
                            {
                                new TdfString("PSA", "127.0.0.1"), // ping site address
                                new TdfInteger("PSP", 17502), // ping site port
                                new TdfString("SNA", "ams") // ping site name
                            }
                        }
                    }),
                    new TdfInteger("SVID", 1161889797) // service ID
                }),
                new TdfString("RSRC", "300294"),
                new TdfString("SVER", "Blaze 3.15.08.0 (CL# 1060080)")
            });

            byte[] payload = encoder.Encode();

            Utilities.SendPacket(new Packet
            {
                componentId = Component.UTIL,
                commandId = 0x7,
                errorCode = 0,
                msgType = MessageType.REPLY,
                msgNum = packet.msgNum,

                payload = payload,
                payloadSize = payload.Length
            }, stream);
        }
        public static void Handle(ulong clientId, Packet packet, SslStream stream)
        {
            Dictionary<string, Tdf> data = Utilities.DecodePayload(packet.payload);
            TdfString etag = (TdfString)data["ETAG"];

            bool onlineAccess = false;

            if (etag.value == "ONLINE_ACCESS")
            {
                onlineAccess = true;
            }

            var client = ClientManager.GetClient(clientId);

            TdfEncoder encoder = new TdfEncoder();

            if (onlineAccess == false)
            {
                TdfList nlst = new TdfList("NLST", TdfBaseType.TDF_TYPE_STRUCT, new ArrayList
                {
                    new List<Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2011-11-02T11:2Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1234632478),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "303566"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "DR:224766400"),
                        new TdfInteger("STAT", 1),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "ONLINE_ACCESS"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 1),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },
                    new List<Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2011-11-02T11:2Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1294632417),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "303566"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "303566"),
                        new TdfInteger("STAT", 1),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "PROJECT10_CODE_CONSUMED_LE1"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 1),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },
                    new List<Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2013-02-22T14:40Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 5674749135),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "306678"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "OFB-EAST:50401"),
                        new TdfInteger("STAT", 1),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "BF3:PREMIUM_ACCESS"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 5),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },
                    new List<Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2014-05-29T6:15Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1005150961807),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "305060"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "DR:235665900"),
                        new TdfInteger("STAT", 2),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "ONLINE_ACCESS"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 1),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },
                    new List<Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2013-02-22T14:40Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1002134961807),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "305061"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "DR:235663400"),
                        new TdfInteger("STAT", 2),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "ONLINE_ACCESS"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 1),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },
                    new List<Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2012-06-04T21:13Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1771457489),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "306678"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "OFB-EAST:50400"),
                        new TdfInteger("STAT", 1),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "BF3:PREMIUM_ACCESS"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 5),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },

                    // DLC 1 - Back 2 Karkand
                    new List<Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2012-06-04T21:13Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1771457490),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "302777"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "OFB-EAST:50400"),
                        new TdfInteger("STAT", 1),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "BF3:PC:B2K_PURCHASE"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 5),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },

                    // DLC 2
                    new List<Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2012-06-04T21:13Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1771457491),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "302776"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "OFB-EAST:48215"),
                        new TdfInteger("STAT", 1),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "BF3:PC:XPACK2_PURCHASE"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 5),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },

                    // DLC 3
                    new List<Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2014-02-07T20:15Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1004743136441),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "302778"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "OFB-EAST:51080"),
                        new TdfInteger("STAT", 1),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "BF3:PC:XPACK3_PURCHASE"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 5),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },

                    // DLC 4
                    new List<Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2012-11-26T9:4Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1000808118611),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "303129"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "OFB-EAST:55171"),
                        new TdfInteger("STAT", 1),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "BF3:PC:XPACK4_PURCHASE"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 5),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },

                    // DLC 5
                    new List<Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2013-03-07T2:21Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1002246118611),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "306409"),
                        new TdfInteger("PRCA", 2),
                        new TdfString("PRID", "OFB-EAST:109546437"),
                        new TdfInteger("STAT", 1),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "BF3:PC:XPACK5_PURCHASE"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 5),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    },

                    // COOP shortcut
                    new List<Tdf>
                    {
                        new TdfString("DEVI", ""),
                        new TdfString("GDAY", "2012-04-17T15:57Z"),
                        new TdfString("GNAM", "BF3PC"),
                        new TdfInteger("ID", 1684196754),
                        new TdfInteger("ISCO", 0),
                        new TdfInteger("PID", 0),
                        new TdfString("PJID", "306215"),
                        new TdfInteger("PRCA", 1),
                        new TdfString("PRID", "OFB-EAST:48642"),
                        new TdfInteger("STAT", 1),
                        new TdfInteger("STRC", 0),
                        new TdfString("TAG", "BF3:SHORTCUT:COOP"),
                        new TdfString("TDAY", ""),
                        new TdfInteger("TYPE", 5),
                        new TdfInteger("UCNT", 0),
                        new TdfInteger("VER", 0)
                    }
                });

                encoder.WriteTdf(new List<Tdf>
                {
                    nlst
                });
            }

            byte[] payload = encoder.Encode();

            Utilities.SendPacket(new Packet
            {
                componentId = Component.AUTHENTICATION,
                commandId = 0x1D,
                errorCode = 0,
                msgType = MessageType.REPLY,
                msgNum = packet.msgNum,

                payload = payload,
                payloadSize = payload.Length
            }, stream);
        }
示例#10
0
        public static void Handle(ulong clientId, Packet packet)
        {
            var client = ClientManager.GetClient(clientId);

            Dictionary <string, Tdf> data = Utilities.DecodePayload(packet.payload);

            TdfMap     attr = (TdfMap)data["ATTR"];
            TdfString  gnam = (TdfString)data["GNAM"];
            TdfInteger gset = (TdfInteger)data["GSET"];
            TdfList    pcap = (TdfList)data["PCAP"];
            TdfInteger igno = (TdfInteger)data["IGNO"];
            TdfInteger pmax = (TdfInteger)data["PMAX"];
            TdfInteger nres = (TdfInteger)data["NRES"];

            // network topology
            TdfInteger ntop = (TdfInteger)data["NTOP"];
            TdfInteger voip = (TdfInteger)data["VOIP"];

            TdfInteger pres = (TdfInteger)data["PRES"]; // TdfMin
            TdfInteger qcap = (TdfInteger)data["QCAP"];
            //TdfString uuid = (TdfString)data["UUID"];

            TdfList hnet = (TdfList)data["HNET"];

            TdfStruct  exip     = (TdfStruct)hnet.list[0];
            TdfInteger exipIP   = (TdfInteger)exip.data.Find(tdf => tdf.label == "IP");
            TdfInteger exipPort = (TdfInteger)exip.data.Find(tdf => tdf.label == "PORT");

            TdfStruct  inip     = (TdfStruct)hnet.list[1];
            TdfInteger inipIP   = (TdfInteger)inip.data.Find(tdf => tdf.label == "IP");
            TdfInteger inipPort = (TdfInteger)inip.data.Find(tdf => tdf.label == "PORT");

            // TODO: don't get gameId as result but get by clientId after creating the game

            /* ulong gameId = GameManager.CreateGame(
             *
             *  (int)gset.value,
             *  (int)igno.value,
             *  (int)nres.value,
             *  (int)ntop.value,
             *  "714b05dc-93bc-49ac-961c-cb38b574f30a"
             * ); */

            var level    = attr.map["level"].ToString();
            var gametype = attr.map["levellocation"].ToString();

            var game = new Database.Game();

            game.clientId        = clientId;
            game.name            = gnam.value;
            game.attributes      = attr.map;
            game.capacity        = pcap.list;
            game.level           = attr.map["level"].ToString();
            game.gametype        = attr.map["levellocation"].ToString();
            game.maxPlayers      = (ushort)pmax.value;
            game.notResetable    = (byte)nres.value;
            game.queueCapacity   = (ushort)qcap.value;
            game.presenceMode    = (PresenceMode)pres.value;
            game.state           = GameState.INITIALIZING;
            game.networkTopology = (GameNetworkTopology)ntop.value;
            game.voipTopology    = (VoipTopology)voip.value;

            Database.NetworkInfo internalNetworkInfo = new Database.NetworkInfo();
            internalNetworkInfo.ip   = inipIP.value;
            internalNetworkInfo.port = (ushort)inipPort.value;

            Database.NetworkInfo externalNetworkInfo = new Database.NetworkInfo();
            externalNetworkInfo.ip   = exipIP.value;
            externalNetworkInfo.port = (ushort)exipPort.value;

            game.internalNetworkInfo = internalNetworkInfo;
            game.externalNetworkInfo = externalNetworkInfo;

            ulong gameId = Database.CreateGame(game);

            TdfEncoder encoder = new TdfEncoder();

            encoder.WriteTdf(new List <Tdf>
            {
                // this one is tdfmin
                new TdfInteger("GID", (ulong)gameId)
            });

            byte[] payload = encoder.Encode();

            Utilities.SendPacket(new Packet
            {
                componentId = Component.GAMEMANAGER,
                commandId   = 0x1,
                errorCode   = 0,
                msgType     = MessageType.REPLY,
                msgNum      = packet.msgNum,

                payload     = payload,
                payloadSize = payload.Length
            }, client.stream);

            GameStateChangeNotification.Notify(gameId, game.state, client.stream);
            GameSetupNotification.Notify(clientId, gameId, client.stream);
        }
        public static void Handle(ulong clientId, Packet packet, SslStream stream)
        {
            var client = ClientManager.GetClient(clientId);

            string player_awards = "player_awards";
            string player_awards2 = "player_awards2";
            string player_weapons1 = "player_weapons1";
            string player_statcategory = "player_statcategory";
            string player_core = "player_core";
            string coopplayer_coop = "coopplayer_coop";
            string player_reset = "player_reset";

            string[] catg = new string[1433];

            for (int j = 0; j < 993; j++)
                catg[j] = player_awards;
            for (int k = 993; k < 1166; k++)
                catg[k] = player_awards2;
            for (int l = 1166; l < 1296; l++)
                catg[l] = player_weapons1;
            for (int m = 1296; m < 1406; m++)
                catg[m] = player_statcategory;
            for (int n = 1406; n < 1427; n++)
                catg[n] = player_core;
            catg[1427] = coopplayer_coop;
            catg[1428] = player_core;
            catg[1429] = player_core;
            catg[1430] = player_core;
            catg[1431] = player_statcategory;
            catg[1432] = player_reset;

            TdfList stat = new TdfList("STAT", TdfBaseType.TDF_TYPE_STRUCT, new ArrayList { });

            for (int i = 0; i < 1433; i++)
            {
                stat.list.Add(new List<Tdf>
                {
                    new TdfString("CATG", catg[i]),
                    new TdfString("DFLT", "0.00"),
                    new TdfInteger("DRVD", 0x0),
                    new TdfString("FRMT", "%.2f"),
                    new TdfString("KIND", ""),
                    new TdfString("LDSC", ""),
                    new TdfString("META", ""),
                    new TdfString("NAME", Utilities.GetStatName(i)),
                    new TdfString("SDSC", ""),
                    new TdfInteger("TYPE", 0x1)
                });
            }

            Dictionary<string, Tdf> data = Utilities.DecodePayload(packet.payload);

            TdfEncoder encoder = new TdfEncoder();

            encoder.WriteTdf(new List<Tdf>
            {
                new TdfString("CNAM", player_awards),
                new TdfString("DESC", "player_mpdefault2"), // TODO: fetch name from decoded data
                new TdfVector2("ETYP", 30722, 1),
                new TdfString("META", ""),
                new TdfString("NAME", "player_mpdefault2"),
                stat
            });

            byte[] payload = encoder.Encode();

            Utilities.SendPacket(new Packet
            {
                componentId = Component.STATS,
                commandId = 0x4,
                errorCode = 0,
                msgType = MessageType.REPLY,
                msgNum = packet.msgNum,

                payload = payload,
                payloadSize = payload.Length
            }, stream);
        }
示例#12
0
        public static void Handle(ulong clientId, Packet packet, SslStream stream)
        {
            // decode payload
            Dictionary <string, Tdf> data = Utilities.DecodePayload(packet.payload);

            // read client type
            TdfStruct  cdat = (TdfStruct)data["CDAT"];
            TdfInteger type = (TdfInteger)cdat.data.Find(tdf => tdf.label == "TYPE");
            TdfString  svcn = (TdfString)cdat.data.Find(tdf => tdf.label == "SVCN");

            TdfStruct  cinf = (TdfStruct)data["CINF"];
            TdfInteger loc  = (TdfInteger)cinf.data.Find(tdf => tdf.label == "LOC");

            // set client type
            ClientManager.UpdateClientType(clientId, (ClientType)type.value);
            ClientManager.UpdateClientLocalization(clientId, loc.value);
            ClientManager.UpdateClientService(clientId, svcn.value);

            var client = ClientManager.GetClient(clientId);

            TdfList cids = new TdfList("CIDS", TdfBaseType.TDF_TYPE_INTEGER, new ArrayList
            {
                //1, 25, 4, 27, 28, 6, 7, 9, 10, 11, 30720, 30721, 30722, 30723, 20, 30725, 30726, 2000
            });

            cids.list.AddRange((new ulong[] { 1, 25, 4, 27, 28, 6, 7, 9, 10, 11, 30720, 30721, 30722, 30723, 20, 30725, 30726, 2000 }).ToArray());

            TdfEncoder encoder = new TdfEncoder();

            encoder.WriteTdf(new List <Tdf>
            {
                new TdfInteger("ANON", 0),
                new TdfString("ASRC", "300294"),
                cids,
                new TdfString("CNGN", ""),
                new TdfStruct("CONF", new List <Tdf>
                {
                    new TdfMap("CONF", TdfBaseType.TDF_TYPE_STRING, TdfBaseType.TDF_TYPE_STRING, new Dictionary <object, object>
                    {
                        { "connIdleTimeout", "90s" },
                        { "defaultRequestTimeout", "80s" },
                        { "pingPeriod", "20s" },
                        { "voipHeadsetUpdateRate", "1000" },
                        { "xlspConnectionIdleTimeout", "300" }
                    })
                }),
                new TdfString("INST", client.service),
                new TdfInteger("MINR", 0),
                new TdfString("NASP", "cem_ea_id"), // TODO: check if present in decoded data
                new TdfString("PILD", ""),
                new TdfString("PLAT", "pc"),        // TODO: fetch from decoded data
                new TdfString("PTAG", ""),
                new TdfStruct("QOSS", new List <Tdf>
                {
                    // bandwidth ping site info
                    new TdfStruct("BWPS", new List <Tdf>
                    {
                        new TdfString("PSA", "127.0.0.1"), // ping site address
                        new TdfInteger("PSP", 17502),      // ping site port
                        new TdfString("SNA", "ams")        // ping site name
                    }),
                    new TdfInteger("LNP", 10),             // number of latency probes
                    new TdfMap("LTPS", TdfBaseType.TDF_TYPE_STRING, TdfBaseType.TDF_TYPE_STRUCT, new Dictionary <object, object>
                    {
                        { "ams", new List <Tdf>
                          {
                              new TdfString("PSA", "127.0.0.1"), // ping site address
                              new TdfInteger("PSP", 17502),      // ping site port
                              new TdfString("SNA", "ams")        // ping site name
                          } }
                    }),
                    new TdfInteger("SVID", 1161889797) // service ID
                }),
                new TdfString("RSRC", "300294"),
                new TdfString("SVER", "Blaze 3.15.08.0 (CL# 1060080)")
            });

            byte[] payload = encoder.Encode();

            Utilities.SendPacket(new Packet
            {
                componentId = Component.UTIL,
                commandId   = 0x7,
                errorCode   = 0,
                msgType     = MessageType.REPLY,
                msgNum      = packet.msgNum,

                payload     = payload,
                payloadSize = payload.Length
            }, stream);
        }
        public static void Notify(ulong clientId, SslStream stream, bool ulst = false)
        {
            var client = ClientManager.GetClient(clientId);

            TdfEncoder encoder = new TdfEncoder();

            TdfList pslm = new TdfList("PSLM", TdfBaseType.TDF_TYPE_INTEGER, new ArrayList {
            });

            pslm.list.AddRange(new ulong[] { 268374015, 268374015, 268374015, 268374015, 268374015 });

            TdfStruct data = new TdfStruct("DATA", new List <Tdf>
            {
                new TdfUnion("ADDR", NetworkAddressMember.MEMBER_IPPAIRADDRESS, new List <Tdf>
                {
                    new TdfStruct("VALU", new List <Tdf>
                    {
                        new TdfStruct("EXIP", new List <Tdf>
                        {
                            new TdfInteger("IP", client.externalNetworkInfo.ip),
                            new TdfInteger("PORT", client.externalNetworkInfo.port)
                        }),
                        new TdfStruct("INIP", new List <Tdf>
                        {
                            new TdfInteger("IP", client.internalNetworkInfo.ip),
                            new TdfInteger("PORT", client.internalNetworkInfo.port)
                        })
                    })
                }),
                new TdfString("BPS", "ams"),
                new TdfString("CTY", ""),
                new TdfInteger("HWFG", 0),
                pslm,
                new TdfInteger("UATT", 0)
            });

            if (ulst == true)
            {
                data.data.Add(new TdfList("ULST", TdfBaseType.TDF_TYPE_BLAZE_OBJECT_ID, new ArrayList
                {
                    new TdfVector3("0", 0x4, 0x1, client.gameId)
                }));
            }

            encoder.WriteTdf(new List <Tdf>
            {
                data,
                new TdfInteger("USID", client.persona.id)
            });

            byte[] payload = encoder.Encode();

            Utilities.SendPacket(new Packet
            {
                componentId = Component.USERSESSIONS,
                commandId   = 0x1,
                errorCode   = 0,
                msgType     = MessageType.NOTIFICATION,
                msgNum      = 0,

                payload     = payload,
                payloadSize = payload.Length
            }, stream);
        }