Inheritance: BaseClient
        static public void HandlePacket(BaseClient client, PacketIn packet)
        {
            LobbyClient cclient = (LobbyClient)client;

            byte sloid = packet.GetUint8();

            Program.CharMgr.SetEnter(cclient.Account.Id, sloid);

            WorldInfo Info = Program.CharMgr.GetWorldInfo(cclient.Account.WorldId);

            PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_WORLD_ENTER);

            if (Info == null)
            {
                Out.WriteUInt32R(1);
            }
            else
            {
                Out.WriteUInt32R(0);

                Out.WriteInt32R(Info.Ip);            // WorldServerIp
                Out.WriteUInt16R((UInt16)Info.Port); // Port
                Out.WriteInt64R(TCPManager.GetTimeStamp());
            }

            cclient.SendTCP(Out);
        }
        static public void Send(LobbyClient client)
        {
            Program.CharMgr.LoadCharacters(client.Account.Id);

            CharacterInfo[] _Chars = Program.CharMgr.GetInfos(client.Account.Id);
            WorldInfo       Info   = Program.CharMgr.GetWorldInfo(client.Account.WorldId);

            PacketOut Out = new PacketOut((UInt32)Opcodes.CHARACTER_LIST);

            Out.WriteByte((byte)_Chars.Length);
            foreach (CharacterInfo Char in _Chars)
            {
                Out.WriteByte(Char.Character.SlotId);
                Out.WriteByte(Char.Character.Faction);
                Out.WriteByte((byte)(Info.RpcID == 0 ? 0 : 1));
                Out.WriteUInt32R((UInt32)Info._Info.Id);
                Out.WriteUnicodeString(Info._Info.Name, 32);
                Out.WriteUnicodeString(Char.Character.Name, 32);
            }

            client.SendTCP(Out);

            if (_Chars.Length <= 0)
            {
                WORLD_LIST.Send(client);
            }
        }
        static public void HandlePacket(BaseClient client, PacketIn packet)
        {
            LobbyClient cclient = (LobbyClient)client;

            UInt32 WorldUid = packet.GetUint32R();
            string Name     = packet.GetUnicodeString();

            PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CHARACTER_NAME_CHECK);

            if (CheckName(Name) == 0)
            {
                cclient.CreateChar        = new DBCharacter();
                cclient.CreateChar.AcctId = cclient.Account.Id;
                cclient.CreateChar.Name   = Name;

                if (cclient.Account.WorldId != WorldUid)
                {
                    Program.CharMgr.SetAccountWorld(cclient.Account.Id, (int)WorldUid);
                }

                Out.WriteUInt32(0);
            }
            else
            {
                cclient.CreateChar = null;
                Out.WriteUInt32(1);
            }

            cclient.SendTCP(Out);
        }
Exemple #4
0
        static public void Send(LobbyClient client, int code)
        {
            PacketOut packet = new PacketOut((UInt32)Opcodes.ANS_LOGIN_FAILED);

            packet.WriteInt32R(code);
            client.SendTCP(packet);
        }
Exemple #5
0
        static public void HandlePacket(BaseClient client, PacketIn packet)
        {
            LobbyClient cclient = client as LobbyClient;

            byte[] PublicKey = new byte[64];
            for (int i = 0; i < 64; ++i)
            {
                PublicKey[i] = packet.GetUint8();
            }
            Reverse(PublicKey, 64);
            cclient.A = PublicKey;

            UInt16 unk = packet.GetUint16();

            byte[] Proof = new byte[20];
            for (int i = 0; i < 20; ++i)
            {
                Proof[i] = packet.GetUint8();
            }
            Reverse(Proof, 20);
            cclient.Proof = Proof;

            if (IsValid(cclient))
            {
                ANS_LOGIN_SUCCES.Send(cclient);
            }
            else
            {
                cclient.Disconnect();
            }
        }
Exemple #6
0
        static public void HandlePacket(BaseClient client, PacketIn packet)
        {
            LobbyClient cclient = client as LobbyClient;

            byte freeslot = Program.CharMgr.GetFreeSlot(cclient.Account.Id);

            if (freeslot == 0 || cclient.CreateChar == null)
            {
                ANS_CHARACTER_CREATE.Send(cclient);
            }
            else
            {
                cclient.CreateChar.SlotId  = freeslot;
                cclient.CreateChar.Faction = packet.GetUint8();
                cclient.CreateChar.Gender  = packet.GetUint8();
                cclient.CreateChar.Version = (int)packet.GetUint32R();
                cclient.CreateChar.Seconds = (int)packet.GetUint32R();

                byte[] Custom = new byte[packet.Length - packet.Position];
                packet.Read(Custom, 0, Custom.Length);

                cclient.CreateChar.Custom = BitConverter.ToString(Custom);

                Program.CharMgr.CreateCharacter(cclient.CreateChar);
                ANS_CHARACTER_CREATE.Send(cclient);
            }
        }
Exemple #7
0
 public static void Send(LobbyClient client)
 {
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_LOGIN_SUCCESS);
     Out.WriteParsedString("Welcome to rebornAPB", 48);
     Out.WriteUInt32Reverse(client.Account.IsAdmin);
     Out.WriteInt64Reverse(TCPManager.GetTimeStamp());
     Out.WriteByte(0x13);
     Out.WriteByte(0x29);
     Out.WriteUInt16Reverse(0x12);
     Out.WriteByte(0x0E);
     Out.WriteByte(0x07);
     Out.WriteUInt16Reverse(9999);
     Out.WriteInt32Reverse(1450);
     Out.WriteUInt32Reverse((uint)client.Account.RTW_Points);
     for (int i = 1; i < 6; ++i) Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)client.Account.Index, i, true, "", ""));
     Out.WriteInt32Reverse(0);
     Out.WriteUInt16(0x957D);
     Out.WriteUInt16(0x0400);
     Out.WriteUInt16(0x5052);
     Out.WriteUInt16(0x4F45);
     Out.WriteUInt16(0x552E);
     Out.WriteUInt16(0x3232);
     Out.WriteUInt16(0x3738);
     Out.WriteUInt16(0x3031);
     Out.WriteUInt16(0);
     Out.WriteUInt16(0x0067);
     Out.WriteUInt64(0x526C624331313256);
     Out.WriteUInt64(0x486E314100000000);
     Out.WriteUInt16(0);
     Out.WriteStringBytes("");
     Out.WriteByte(0);
     client.Send(Out);
 }
Exemple #8
0
        public static void Send(LobbyClient cclient)
        {
            PacketOut Out = new PacketOut((uint)Opcodes.WORLD_LIST);

            Out.WriteInt32Reverse((int)ResponseCodes.RC_SUCCESS);
            lock (Program.worldListener.Worlds)
            {
                Out.WriteUInt16Reverse((ushort)Program.worldListener.Worlds.Count);
                foreach (KeyValuePair <uint, World.World> info in Program.worldListener.Worlds)
                {
                    Out.WriteUInt32Reverse(info.Key);
                    Out.WriteParsedString(info.Value.Name, 32);
                    Out.WriteByte((byte)info.Value.Id);
                    Out.WriteByte(0); //m_nPopulation %d
                    Out.WriteByte(0); //m_nEnfFaction %d
                    Out.WriteByte(0); //m_nCrimFaction %d
                    Out.WriteByte(0); //m_nPremiumOnly %d
                    Out.WriteByte(info.Value.IP1);
                    Out.WriteByte(info.Value.IP2);
                    Out.WriteByte(info.Value.IP3);
                    Out.WriteByte(info.Value.IP4);
                }
            }
            cclient.Send(Out);
        }
Exemple #9
0
 static public void Register(LobbyClient client)
 {
     //TODO - generate token when registering from site and give user download link for "token.id" file
     Random getrandom = new Random();
     String token = getrandom.Next(10000000, 99999999).ToString();
     MySqlCommand cmd = new MySqlCommand("UPDATE `accounts` SET `token` = @token WHERE `email` = @email", Connection.Instance);
     try
     {
         cmd.Prepare();
         cmd.Parameters.AddWithValue("@email", client.Account.Email);
         cmd.Parameters.AddWithValue("@token", token);
         cmd.ExecuteNonQuery();
         client.Account.token = token;
     }
     catch (MySqlException ex) { Log.Error("Register()", "MySQL failed! " + ex.ToString()); }
     String Id = Convert.ToString(client.Account.Id);
     String Pass = client.Account.Password;
     Byte[] salt = new byte[10];
     Random random = new Random();
     random.NextBytes(salt);
     random = null;
     client.Account.Salt = (new FrameWork.NetWork.Crypto.BigInteger(1, salt)).ToString(16);
     client.Account.Verifier = Auth.computeVerifier(salt, Id, Pass).ToString(16);
     client.Account.Save();
 }
Exemple #10
0
        public int HandlePacket(BaseClient client, PacketIn packet)
        {
            LobbyClient cclient = client as LobbyClient;

            Send(cclient);
            return(0);
        }
Exemple #11
0
 static public bool IsValid(LobbyClient client)
 {
     if (client.Account.Index < 1) return false;
     Console.WriteLine("Account ID: " + Convert.ToString(client.Account.Index));
     Byte[] proof = Auth.computeProof(Convert.ToString(client.Account.Index), client.serverModulus, client.clientModulus, client.Verifier, client.Salt, out client.SessionId);
     for (int i = 0; i < proof.Length; i++) if (proof[i] != client.Proof[i]) return false;
     return true;
 }
Exemple #12
0
        static public void HandlePacket(BaseClient client, PacketIn packet)
        {
            LobbyClient cclient = client as LobbyClient;

            packet.Skip(24);
            string Email = packet.GetUnicodeString().ToUpper();

            Log.Notice("ASK_LOGIN", "Authentification de : " + Email);

            SendLoginResult(cclient, Email, Program.CharMgr.LoadAccount(Email));
        }
Exemple #13
0
 public static void Send(LobbyClient client)
 {
     Log.Debug("LOGIN_SALT", "Sent to " + client.Account.Username);
     client.serverModulus = Auth.computeServerModulus(client.Verifier);
     PacketOut Out = new PacketOut((UInt32)Opcodes.LOGIN_SALT);
     Out.WriteUInt32Reverse((uint)client.Account.Index);
     Out.Write(client.serverModulus.B.ToByteArrayUnsigned(), 0, 64);
     Out.WriteByte(0x40);
     Out.WriteByte(0);
     Out.Write(client.Salt, 0, 10);
     client.Send(Out);
 }
Exemple #14
0
 static public void Register(LobbyClient client)
 {
     String Id = Convert.ToString(client.Account.Index);
     String Pass = client.Account.Password;
     Byte[] salt = new byte[10];
     Random random = new Random();
     random.NextBytes(salt);
     random = null;
     client.Account.Salt = (new FrameWork.NetWork.Crypto.BigInteger(1, salt)).ToString(16);
     client.Account.Verifier = Auth.computeVerifier(salt, Id, Pass).ToString(16);
     Databases.AccountTable.Update(client.Account);
 }
        static public void Send(LobbyClient client)
        {
            PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_LOGIN_SUCCESS);

            Out.WriteUnicodeString(client.Account.RealTag, 48);

            Out.WriteUInt32R(21); // Account Type

            Out.WriteInt64R(TCPManager.GetTimeStamp());

            // Temps avant expiration du compte
            Out.WriteByte(0x13);    // ms
            Out.WriteByte(0x29);    // sec
            Out.WriteUInt16R(0x12); // Hour

            // Date de création
            Out.WriteByte(0x0E);                    // day
            Out.WriteByte(0x07);                    // month
            Out.WriteUInt16R(2010);                 // Year

            Out.WriteInt32R(1450);                  // Temps de jeu (secondes)
            Out.WriteInt32R(client.Account.Points); // Points APB

            for (int i = 1; i < 6; ++i)
            {
                Out.WriteInt32R(
                    Program.FileMgr.GetFileVersion(client.Account.Id, i, true, "", "")); // Config file, Server Version
            }
            Out.WriteInt32R(0);

            Out.WriteUInt16(0x957D);
            Out.WriteUInt16(0x0400);

            Out.WriteUInt16(0x5052);
            Out.WriteUInt16(0x4F45);
            Out.WriteUInt16(0x552E);
            Out.WriteUInt16(0x3232);
            Out.WriteUInt16(0x3738);
            Out.WriteUInt16(0x3031);
            Out.WriteUInt16(0);

            Out.WriteUInt16(0x0067);

            Out.WriteUInt64(0x526C624331313256);
            Out.WriteUInt64(0x486E314100000000);
            Out.WriteUInt16(0);
            Out.WriteStringBytes("");
            Out.WriteByte(0);

            client.SendTCP(Out);

            ANS_CHARACTER_INFO.Send(client);
        }
 static public void Send(LobbyClient client)
 {
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CHARACTER_CREATE);
     if (client.Pending == null) Out.WriteInt32Reverse((int)ResponseCodes.RC_FAILED);
     else
     {
         Out.WriteInt32Reverse((int)ResponseCodes.RC_SUCCESS);
         Out.WriteInt32Reverse(client.Pending.Slot);
     }
     client.Pending = null;
     client.Send(Out);
 }
Exemple #17
0
        public static void Send(LobbyClient client)
        {
            Log.Debug("LOGIN_SALT", "Send to " + client.Account.Email);
            MakeSalt(client);

            PacketOut Out = new PacketOut((UInt32)Opcodes.LOGIN_SALT);
            Out.WriteInt32R(client.Account.Id);
            Out.Write(client.B, 0, 64);
            Out.WriteByte(0x40);
            Out.WriteByte(0);
            Out.Write(client.Salt, 0, 10);
            client.SendTCP(Out);
        }
 public static void Send(LobbyClient client)
 {
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CHARACTER_CREATE);
     if (client.CreateChar == null)
         Out.WriteInt32R(1);
     else
     {
         Out.WriteInt32R(0);
         Out.WriteInt32R(client.CreateChar.SlotId);
     }
     client.CreateChar = null;
     client.SendTCP(Out);
 }
        public static void Send(LobbyClient client)
        {
            PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_LOGIN_SUCCESS);
            Out.WriteUnicodeString(client.Account.RealTag,48);

            Out.WriteUInt32R(21); // Account Type

            Out.WriteInt64R(TCPManager.GetTimeStamp());

            // Temps avant expiration du compte
            Out.WriteByte(0x13); // ms
            Out.WriteByte(0x29); // sec
            Out.WriteUInt16R(0x12); // Hour

            // Date de création
            Out.WriteByte(0x0E); // day
            Out.WriteByte(0x07); // month
            Out.WriteUInt16R(2010); // Year

            Out.WriteInt32R(1450); // Temps de jeu (secondes)
            Out.WriteInt32R(client.Account.Points); // Points APB

            for(int i=1;i<6;++i)
                Out.WriteInt32R(
                    Program.FileMgr.GetFileVersion(client.Account.Id, i, true, "", "")); // Config file, Server Version

            Out.WriteInt32R(0);

            Out.WriteUInt16(0x957D);
            Out.WriteUInt16(0x0400);

            Out.WriteUInt16(0x5052);
            Out.WriteUInt16(0x4F45);
            Out.WriteUInt16(0x552E);
            Out.WriteUInt16(0x3232);
            Out.WriteUInt16(0x3738);
            Out.WriteUInt16(0x3031);
            Out.WriteUInt16(0);

            Out.WriteUInt16(0x0067);

            Out.WriteUInt64(0x526C624331313256);
            Out.WriteUInt64(0x486E314100000000);
            Out.WriteUInt16(0);
            Out.WriteStringBytes("");
            Out.WriteByte(0);

            client.SendTCP(Out);

            ANS_CHARACTER_INFO.Send(client);
        }
Exemple #20
0
 static public void Send(LobbyClient client)
 {
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CHARACTER_CREATE);
     if (client.Pending.Index < 1) Out.WriteInt32Reverse((int)ResponseCodes.RC_FAILED);
     else
     {
         Out.WriteInt32Reverse((int)ResponseCodes.RC_SUCCESS);
         Out.WriteInt32Reverse(client.Pending.Slot);
     }
     client.Pending = default(CharacterEntry);
     client.Send(Out);
     System.Threading.Thread.Sleep(200);
     client.Disconnect();
 }
Exemple #21
0
 static public void Send(LobbyClient client)
 {
     PacketOut Out = new PacketOut((UInt32)Opcodes.LOGIN_PUZZLE);
     Out.WriteInt32Reverse(Program.Version[0]);
     Out.WriteInt32Reverse(Program.Version[1]);
     Out.WriteInt32Reverse(Program.Version[2]);
     Out.WriteInt32Reverse(Program.Build);
     Out.WriteByte(0x05);
     for (int i = 0; i < client.ECrypt.Key.Length; i++) Out.WriteByte(client.ECrypt.Key[i]);
     Out.WriteUInt32Reverse(0);
     Out.WriteUInt32Reverse(0);
     Out.WriteUInt32Reverse(0);
     client.SendTCP(Out);
 }
Exemple #22
0
        static public void Send(LobbyClient client)
        {
            Log.Debug("LOGIN_SALT", "Send to " + client.Account.Email);
            MakeSalt(client);

            PacketOut Out = new PacketOut((UInt32)Opcodes.LOGIN_SALT);

            Out.WriteInt32R(client.Account.Id);
            Out.Write(client.B, 0, 64);
            Out.WriteByte(0x40);
            Out.WriteByte(0);
            Out.Write(client.Salt, 0, 10);
            client.SendTCP(Out);
        }
Exemple #23
0
        static public bool IsValid(LobbyClient client)
        {
            if (client.Account == null)
            {
                return(false);
            }

            return(true);

            client.serv.CalculateSecret(new BigInteger(client.A));
            BigInteger Pro   = new BigInteger(client.Proof);
            BigInteger check = Srp6Utilities.ValidatePublicValue(client.N, Pro);

            return(check.IntValue > 0);
        }
        static public void HandlePacket(BaseClient client, PacketIn packet)
        {
            LobbyClient cclient = (LobbyClient)client;

            byte FileId = packet.GetUint8();

            PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CONFIGFILE_LOAD);

            Out.WriteInt32R(0);
            Out.WriteByte(FileId);

            byte[] Result = ZlibMgr.Compress(
                Program.FileMgr.GetFileByte(cclient.Account.Id, FileId, true, "", ""),
                zlibConst.Z_DEFAULT_COMPRESSION, 0);
            cclient.SendTCP(Out);
        }
Exemple #25
0
        static public void Send(LobbyClient client)
        {
            PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CHARACTER_CREATE);

            if (client.CreateChar == null)
            {
                Out.WriteInt32R(1);
            }
            else
            {
                Out.WriteInt32R(0);
                Out.WriteInt32R(client.CreateChar.SlotId);
            }
            client.CreateChar = null;
            client.SendTCP(Out);
        }
Exemple #26
0
        public static void Send(LobbyClient client)
        {
            PacketOut Out = new PacketOut((UInt32)Opcodes.LOGIN_PUZZLE);
            Out.WriteInt32R(Program.Version[0]);
            Out.WriteInt32R(Program.Version[1]);
            Out.WriteInt32R(Program.Version[2]);
            Out.WriteInt32R(Program.Build);

            Out.WriteByte(0x05);

            Out.WriteInt64R(-313054979819954861);

            Out.WriteUInt32R(0);
            Out.WriteUInt32R(0);
            Out.WriteUInt32R(0);
            client.SendTCP(Out);
        }
Exemple #27
0
 public static void Send(LobbyClient client)
 {
     PacketOut Out = new PacketOut((UInt32)Opcodes.LOGIN_PUZZLE);
     if(Program.version == GameVersion.RTW_CB)
     {
         Out.WriteInt32Reverse(0);
         Out.WriteInt32Reverse(6);
         Out.WriteInt32Reverse(0);
         Out.WriteInt32Reverse(509927);
     }
     else if(Program.version == GameVersion.RTW_DVD)
     {
         Out.WriteInt32Reverse(1);
         Out.WriteInt32Reverse(1);
         Out.WriteInt32Reverse(0);
         Out.WriteInt32Reverse(534979);
     }
     else if (Program.version == GameVersion.RTW_LAST)
     {
         Out.WriteInt32Reverse(1);
         Out.WriteInt32Reverse(4);
         Out.WriteInt32Reverse(1);
         Out.WriteInt32Reverse(555239);
     }
     else if (Program.version == GameVersion.G1_LATEST)
     {
         Out.WriteInt32Reverse(1);
         Out.WriteInt32Reverse(19);
         Out.WriteInt32Reverse(4);
         Out.WriteInt32Reverse(766569);
     }
     else if (Program.version == GameVersion.G1_ENGUPD)
     {
         Out.WriteInt32Reverse(2);
         Out.WriteInt32Reverse(0);
         Out.WriteInt32Reverse(0);
         Out.WriteInt32Reverse(750394);
     }
     Out.WriteByte(0x05);
     for (int i = 0; i < client.ECrypt.Key.Length; i++) Out.WriteByte(client.ECrypt.Key[i]);
     Out.WriteUInt32Reverse(0);
     Out.WriteUInt32Reverse(0);
     Out.WriteUInt32Reverse(0);
     client.SendTCP(Out);
 }
Exemple #28
0
        static public void Send(LobbyClient client)
        {
            PacketOut Out = new PacketOut((UInt32)Opcodes.LOGIN_PUZZLE);

            Out.WriteInt32R(Program.Version[0]);
            Out.WriteInt32R(Program.Version[1]);
            Out.WriteInt32R(Program.Version[2]);
            Out.WriteInt32R(Program.Build);

            Out.WriteByte(0x05);

            Out.WriteInt64R(-313054979819954861);

            Out.WriteUInt32R(0);
            Out.WriteUInt32R(0);
            Out.WriteUInt32R(0);
            client.SendTCP(Out);
        }
Exemple #29
0
 public static void SendLoginResult(LobbyClient client,string Email,bool result)
 {
     if(!result)
     {
         Log.Error("ASK_LOGN","Compte introuvable !");
         ANS_LOGIN_FAILED.Send(client, 10010);
         client.Disconnect();
     }
     else
     {
         Log.Success("ASK_LOGN","Authentification en cours.");
         client.Account = Program.CharMgr.GetAccount(Email);
         if (client.Account == null)
             SendLoginResult(client, Email, false);
         else
             LOGIN_SALT.Send(client);
     }
 }
Exemple #30
0
 static public void Send(LobbyClient client)
 {
     PacketOut Out = new PacketOut((UInt32)Opcodes.WORLD_LIST);
     Out.WriteInt32Reverse((int)ResponseCodes.RC_SUCCESS);
     lock (Program.worldListener.Worlds)
     {
         Out.WriteUInt16Reverse((UInt16)Program.worldListener.Worlds.Count);
         foreach (KeyValuePair<UInt32, World.World> info in Program.worldListener.Worlds)
         {
             Out.WriteUInt32Reverse((UInt32)info.Key);
             Out.WriteParsedString(info.Value.Name, 32);
             Out.WriteByte(1);
             Out.WriteByte(info.Value.Population);
             Out.WriteByte(info.Value.EnforcerRecommended ? (Byte)1 : (Byte)0);
             Out.WriteByte(info.Value.CriminalRecommended ? (Byte)1 : (Byte)0);
         }
     }
     client.Send(Out);
 }
Exemple #31
0
        public static void MakeSalt(LobbyClient client)
        {
            string Id = Convert.ToString(client.Account.Id);
            string Email = client.Account.Email;
            string Pass = client.Account.Password;

            byte[] I = Encoding.ASCII.GetBytes(Id);
            byte[] P = Encoding.ASCII.GetBytes(Pass);
            byte[] s = new byte[10];
            client.random.NextBytes(s);

            Srp6VerifierGenerator gen = new Srp6VerifierGenerator();
            gen.Init(client.N, client.g, new Sha1Digest());
            BigInteger v = gen.GenerateVerifier(s, I, P);

            client.serv.Init(client.N, client.g, v, new Sha1Digest(), client.random);

            BigInteger B_s = client.serv.GenerateServerCredentials();
            client.B = B_s.ToByteArray();
            client.Salt = s;
        }
Exemple #32
0
 public Byte GetFreeSlot(LobbyClient client)
 {
     try
     {
         Byte[] slots = new Byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
         if (client.Characters.Count != 0)
         {
             for (int i = 0; i < slots.Length; i++)
                 foreach (CharacterEntry ch in client.Characters)
                     if (ch.Slot != slots[i])
                         return slots[i];
         }
         else return 1;
     }
     catch(Exception e)
     {
         Console.WriteLine(e.ToString());
         return 0;
     }
     return 0;
 }
Exemple #33
0
 static public void SendLoginResult(LobbyClient client, string Email, bool result)
 {
     if (!result)
     {
         Log.Error("ASK_LOGN", "Compte introuvable !");
         ANS_LOGIN_FAILED.Send(client, 10010);
         client.Disconnect();
     }
     else
     {
         Log.Success("ASK_LOGN", "Authentification en cours.");
         client.Account = Program.CharMgr.GetAccount(Email);
         if (client.Account == null)
         {
             SendLoginResult(client, Email, false);
         }
         else
         {
             LOGIN_SALT.Send(client);
         }
     }
 }
        static public void HandlePacket(BaseClient client, PacketIn packet)
        {
            LobbyClient cclient = (LobbyClient)client;

            byte   FileId  = packet.GetUint8();
            UInt32 Version = packet.GetUint32R();

            byte[] File = new byte[packet.Length - packet.Position];
            packet.Read(File, 0, File.Length);

            File = ZlibMgr.Decompress(File);

            Log.Debug("ConfigSave", "Config saved : fileid=" + FileId + ", Version=" + Version + ",Size=" + File.Length);

            Program.FileMgr.SaveInfo(cclient.Account.Id, FileId, File);

            PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CONFIGFILE_SAVE);

            Out.WriteUInt32R(0);
            Out.WriteByte(FileId);
            Out.Write(File, 0, File.Length);
            cclient.SendTCP(Out);
        }
Exemple #35
0
        public static void Send(LobbyClient client)
        {
            List<WorldInfo> _Worlds = Program.CharMgr.GetWorlds();

            PacketOut Out = new PacketOut((UInt32)Opcodes.WORLD_LIST);
            Out.WriteInt32R(0); // Returned Code

            Out.WriteUInt16R((UInt16)_Worlds.Count); // World Count

            foreach (WorldInfo Info in _Worlds)
            {
                Out.WriteUInt32R((UInt32)Info._Info.Id); // WorldUid

                Out.WriteUnicodeString(Info._Info.Name, 32); // WorldName

                Out.WriteByte((byte)(Info.RpcID == 0 ? 0 : 1)); // Status
                Out.WriteByte(Info._Info.Population); // Pop  0:Low 1:Medium 2:High
                Out.WriteByte(Info._Info.Enf); // enf recommended , true or false
                Out.WriteByte(Info._Info.Crim); // crim recommended , true or false
            }

            client.SendTCP(Out);
        }
Exemple #36
0
 static public void Send(LobbyClient client)
 {
     client.Characters = Databases.CharacterTable.Select(c => c.AccountIndex == client.Account.Index);
     PacketOut Out = new PacketOut((UInt32)Opcodes.CHARACTER_LIST);
     Out.WriteByte((Byte)client.Characters.Count);
     lock (Program.worldListener.Worlds)
     {
         foreach (CharacterEntry chr in client.Characters)
         {
             Out.WriteByte(chr.Slot);
             Out.WriteByte(chr.Faction);
             Out.WriteByte(1);
             Out.WriteUInt32Reverse((uint)chr.World);
             World.World info = null;
             Program.worldListener.Worlds.TryGetValue((uint)chr.World, out info);
             if (info != null) Out.WriteParsedString(info.Name, 32);
             else Out.WriteParsedString("(undefined)", 32);
             Out.WriteParsedString(chr.Name, 32);
         }
     }
     client.Send(Out);
     if (client.Characters.Count <= 0) WORLD_LIST.Send(client);
 }
Exemple #37
0
        static public void MakeSalt(LobbyClient client)
        {
            string Id    = Convert.ToString(client.Account.Id);
            string Email = client.Account.Email;
            string Pass  = client.Account.Password;

            byte[] I = Encoding.ASCII.GetBytes(Id);
            byte[] P = Encoding.ASCII.GetBytes(Pass);
            byte[] s = new byte[10];
            client.random.NextBytes(s);

            Srp6VerifierGenerator gen = new Srp6VerifierGenerator();

            gen.Init(client.N, client.g, new Sha1Digest());
            BigInteger v = gen.GenerateVerifier(s, I, P);

            client.serv.Init(client.N, client.g, v, new Sha1Digest(), client.random);

            BigInteger B_s = client.serv.GenerateServerCredentials();

            client.B    = B_s.ToByteArray();
            client.Salt = s;
        }
Exemple #38
0
 static public void Send(LobbyClient client)
 {
     client.Characters = new Characters(client.Account.Id);
     PacketOut Out = new PacketOut((UInt32)Opcodes.CHARACTER_LIST);
     Out.WriteByte(client.Characters.Length);
     lock (Program.worldListener.Worlds)
     {
         foreach (KeyValuePair<Byte, Character> pair in client.Characters.List)
         {
             Out.WriteByte(pair.Value.Slot);
             Out.WriteByte(pair.Value.Faction);
             Out.WriteByte(1);
             Out.WriteUInt32Reverse(pair.Value.WorldId);
             World.World info = null;
             Program.worldListener.Worlds.TryGetValue(pair.Value.WorldId, out info);
             if (info != null) Out.WriteParsedString(info.Name, 32);
             else Out.WriteParsedString("(undefined)", 32);
             Out.WriteParsedString(pair.Value.Name, 32);
         }
     }
     client.Send(Out);
     if (client.Characters.Length <= 0) WORLD_LIST.Send(client);
 }
        static public void HandlePacket(BaseClient client, PacketIn packet)
        {
            LobbyClient cclient = client as LobbyClient;

            byte slotid = packet.GetUint8();

            CharacterInfo Info = Program.CharMgr.GetInfoBySlotId(cclient.Account.Id, slotid);

            PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CHARACTER_INFO);

            if (Info == null || (Info != null & Info.Character == null))
            {
                Out.WriteUInt32R(1);
            }
            else
            {
                DBCharacter Char = Info.Character;

                Out.WriteUInt32R(0);                 // Return code

                Out.WriteByte(Char.SlotId);          // Slot
                Out.WriteByte(Char.Gender);          // Gender
                Out.WriteUInt32R(1);                 // PlayTime
                Out.WriteUInt32R((UInt32)Char.Rank); // Ranking
                Out.WriteByte(Char.Threat);          // Threat

                Out.WriteUInt32R((UInt32)(40000));

                Out.WriteUnicodeString("APB-EMU", 60); // Clan Name

                byte[] Custom = Char.GetaCustom();
                Out.Write(Custom, 0, Custom.Length);
            }

            cclient.SendTCP(Out);
        }
Exemple #40
0
        static public void Send(LobbyClient client)
        {
            List <WorldInfo> _Worlds = Program.CharMgr.GetWorlds();

            PacketOut Out = new PacketOut((UInt32)Opcodes.WORLD_LIST);

            Out.WriteInt32R(0);                      // Returned Code

            Out.WriteUInt16R((UInt16)_Worlds.Count); // World Count

            foreach (WorldInfo Info in _Worlds)
            {
                Out.WriteUInt32R((UInt32)Info._Info.Id);        // WorldUid

                Out.WriteUnicodeString(Info._Info.Name, 32);    // WorldName

                Out.WriteByte((byte)(Info.RpcID == 0 ? 0 : 1)); // Status
                Out.WriteByte(Info._Info.Population);           // Pop  0:Low 1:Medium 2:High
                Out.WriteByte(Info._Info.Enf);                  // enf recommended , true or false
                Out.WriteByte(Info._Info.Crim);                 // crim recommended , true or false
            }

            client.SendTCP(Out);
        }
Exemple #41
0
        protected override BaseClient GetNewClient()
        {
            LobbyClient client = new LobbyClient(this);

            return(client);
        }
Exemple #42
0
 static public bool IsBanned(LobbyClient client)
 {
     if (client.Account.IsBanned.Equals(1)) return true;
     else return false;
 }
Exemple #43
0
 static public void Send(LobbyClient client, int code)
 {
     PacketOut packet = new PacketOut((UInt32)Opcodes.ANS_LOGIN_FAILED);
     packet.WriteInt32Reverse(code);
     client.Send(packet);
 }
Exemple #44
0
        static public void HandlePacket(BaseClient client, PacketIn packet)
        {
            LobbyClient cclient = client as LobbyClient;

            WORLD_LIST.Send(cclient);
        }
Exemple #45
0
 protected override BaseClient GetNewClient()
 {
     LobbyClient client = new LobbyClient(this);
     return client;
 }