Esempio n. 1
0
        public static void LoginPersona(Blaze.Packet p, PlayerInfo pi, NetworkStream ns)
        {
            uint             t    = Blaze.GetUnixTimeStamp();
            List <Blaze.Tdf> SESS = new List <Blaze.Tdf>();

            SESS.Add(Blaze.TdfInteger.Create("BUID", pi.userId));
            SESS.Add(Blaze.TdfInteger.Create("FRST", 0));
            SESS.Add(Blaze.TdfString.Create("KEY\0", "some_client_key"));
            SESS.Add(Blaze.TdfInteger.Create("LLOG", t));
            SESS.Add(Blaze.TdfString.Create("MAIL", ""));
            List <Blaze.Tdf> PDTL = new List <Blaze.Tdf>();

            PDTL.Add(Blaze.TdfString.Create("DSNM", pi.profile.name));
            PDTL.Add(Blaze.TdfInteger.Create("LAST", t));
            PDTL.Add(Blaze.TdfInteger.Create("PID\0", pi.userId));
            PDTL.Add(Blaze.TdfInteger.Create("STAS", 0));
            PDTL.Add(Blaze.TdfInteger.Create("XREF", 0));
            PDTL.Add(Blaze.TdfInteger.Create("XTYP", 0));
            SESS.Add(Blaze.TdfStruct.Create("PDTL", PDTL));
            SESS.Add(Blaze.TdfInteger.Create("UID\0", pi.userId));
            byte[] buff = Blaze.CreatePacket(p.Component, p.Command, 0, 0x1000, p.ID, SESS);
            ns.Write(buff, 0, buff.Length);
            ns.Flush();

            AsyncUserSessions.NotifyUserAdded(pi, p, pi, ns);
            AsyncUserSessions.NotifyUserStatus(pi, p, pi, ns);
        }
Esempio n. 2
0
        public static void LogoutPersona(Blaze.Packet p, PlayerInfo pi, NetworkStream ns)
        {
            List <Blaze.Tdf> result = new List <Blaze.Tdf>();

            byte[] buff = Blaze.CreatePacket(p.Component, p.Command, 0, 0x1000, p.ID, result);
            ns.Write(buff, 0, buff.Length);
            ns.Flush();

            AsyncUserSessions.NotifyUserRemoved(pi, p, pi.userId, ns);
            AsyncUserSessions.NotifyUserStatus(pi, p, pi, ns);
        }
Esempio n. 3
0
        public static void JoinGame(Blaze.Packet p, PlayerInfo pi, NetworkStream ns)
        {
            PlayerInfo srv = null;

            foreach (PlayerInfo info in BlazeServer.allClients)
            {
                if (info.isServer)
                {
                    srv = info;
                    break;
                }
            }
            if (srv == null)
            {
                BlazeServer.Log("[CLNT] #" + pi.userId + " : cant find game to join!", System.Drawing.Color.Red);
                return;
            }
            pi.game = srv.game;
            pi.slot = srv.game.getNextSlot();
            BlazeServer.Log("[CLNT] #" + pi.userId + " : assigned Slot Id " + pi.slot, System.Drawing.Color.Blue);
            if (pi.slot == 255)
            {
                BlazeServer.Log("[CLNT] #" + pi.userId + " : server full!", System.Drawing.Color.Red);
                return;
            }
            srv.game.setNextSlot((int)pi.userId);
            srv.game.players[pi.slot] = pi;

            List <Blaze.Tdf> result = new List <Blaze.Tdf>();

            result.Add(Blaze.TdfInteger.Create("GID\0", srv.game.id));
            result.Add(Blaze.TdfInteger.Create("JGS\0", 0));
            byte[] buff = Blaze.CreatePacket(p.Component, p.Command, 0, 0x1000, p.ID, result);
            ns.Write(buff, 0, buff.Length);
            ns.Flush();

            pi.stat = 2;

            AsyncUserSessions.NotifyUserAdded(pi, p, pi, ns);
            AsyncUserSessions.NotifyUserStatus(pi, p, pi, ns);
            AsyncGameManager.NotifyClientGameSetup(pi, p, pi, srv, ns);

            AsyncUserSessions.NotifyUserAdded(srv, p, pi, srv.ns);
            AsyncUserSessions.NotifyUserStatus(srv, p, pi, srv.ns);
            AsyncUserSessions.UserSessionExtendedDataUpdateNotification(srv, p, pi, srv.ns);
            AsyncGameManager.NotifyPlayerJoining(srv, p, pi, srv.ns);
        }
Esempio n. 4
0
        public static void UpdateNetworkInfo(Blaze.Packet p, PlayerInfo pi, NetworkStream ns)
        {
            List <Blaze.Tdf> input = Blaze.ReadPacketContent(p);

            Blaze.TdfUnion  addr = (Blaze.TdfUnion)input[0];
            Blaze.TdfStruct valu = (Blaze.TdfStruct)addr.UnionContent;
            Blaze.TdfStruct exip = (Blaze.TdfStruct)valu.Values[0];
            Blaze.TdfStruct inip = (Blaze.TdfStruct)valu.Values[1];
            pi.inIp   = ((Blaze.TdfInteger)inip.Values[0]).Value;
            pi.exIp   = ((Blaze.TdfInteger)exip.Values[0]).Value;
            pi.exPort = pi.inPort = (uint)((Blaze.TdfInteger)inip.Values[1]).Value;
            Blaze.TdfStruct nqos = (Blaze.TdfStruct)input[2];
            pi.nat = ((Blaze.TdfInteger)nqos.Values[1]).Value;
            byte[] buff = Blaze.CreatePacket(p.Component, p.Command, 0, 0x1000, p.ID, new List <Blaze.Tdf>());
            ns.Write(buff, 0, buff.Length);
            ns.Flush();
            AsyncUserSessions.UserSessionExtendedDataUpdateNotification(pi, p, pi, ns);
        }
Esempio n. 5
0
        public static void UpdateMeshConnection(Blaze.Packet p, PlayerInfo pi, NetworkStream ns)
        {
            List <Blaze.Tdf>       input   = Blaze.ReadPacketContent(p);
            List <Blaze.TdfStruct> entries = (List <Blaze.TdfStruct>)((Blaze.TdfList)input[1]).List;

            Blaze.TdfInteger pid  = (Blaze.TdfInteger)entries[0].Values[1];
            Blaze.TdfInteger stat = (Blaze.TdfInteger)entries[0].Values[2];
            byte[]           buff = Blaze.CreatePacket(p.Component, p.Command, 0, 0x1000, p.ID, new List <Blaze.Tdf>());
            ns.Write(buff, 0, buff.Length);
            ns.Flush();

            PlayerInfo target = null;

            foreach (PlayerInfo info in BlazeServer.allClients)
            {
                if (info.userId == pid.Value)
                {
                    target = info;
                    break;
                }
            }
            if (target != null)
            {
                if (stat.Value == 2)
                {
                    if (pi.isServer)
                    {
                        AsyncUserSessions.UserSessionExtendedDataUpdateNotification(pi, p, target, ns);
                        AsyncGameManager.NotifyGamePlayerStateChange(pi, p, target, ns, 4);
                        AsyncGameManager.NotifyPlayerJoinCompleted(pi, p, target, ns);
                    }
                    else
                    {
                        AsyncGameManager.NotifyGamePlayerStateChange(pi, p, pi, ns, 4);
                        AsyncGameManager.NotifyPlayerJoinCompleted(pi, p, pi, ns);
                    }
                }
                else
                {
                    AsyncUserSessions.NotifyUserRemoved(pi, p, pid.Value, ns);
                }
            }
        }