Пример #1
0
        static public void F_DUMP_ARENAS_LARGE(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (!cclient.HasAccount())
            {
                cclient.Disconnect();
                return;
            }

            byte      CharacterSlot = packet.GetUint8();
            Character Char          = CharMgr.GetAccountChar(cclient._Account.AccountId).GetCharacterBySlot(CharacterSlot);

            if (Char == null)
            {
                Log.Error("F_DUMP_ARENAS_LARGE", "Can not find character on slot : " + CharacterSlot);
                cclient.Disconnect();
                return;
            }

            if (cclient.Plr == null)
            {
                cclient.Plr = Player.CreatePlayer(cclient, Char);
            }

            PacketOut Out = new PacketOut((byte)Opcodes.F_WORLD_ENTER);

            Out.WriteUInt16(0x0608); // TODO
            Out.Fill(0, 20);
            Out.WriteString("38699", 5);
            Out.WriteString("38700", 5);
            Out.WriteString("0.0.0.0", 20);
            cclient.SendTCP(Out);
        }
Пример #2
0
        public static void F_DUMP_ARENAS_LARGE(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (!cclient.HasAccount())
            {
                cclient.Disconnect("No Account in F_DUMP_ARENAS_LARGE");
                return;
            }

            if (Program.Rm.OnlinePlayers >= Program.Rm.MaxPlayers && cclient._Account.GmLevel < 1)
            {
                PacketOut Out = new PacketOut((byte)Opcodes.F_LOGINQUEUE);
                client.SendPacket(Out);
                return;
            }

            byte      CharacterSlot = packet.GetUint8();
            Character Char          = CharMgr.GetAccountChar(cclient._Account.AccountId).GetCharacterBySlot(CharacterSlot);

            if (Char == null)
            {
                Log.Error("F_DUMP_ARENAS_LARGE", "Can not find character on slot : " + CharacterSlot);
                cclient.Disconnect("Character not found in F_DUMP_ARENAS_LARGE");
                return;
            }

            {
                if (cclient.Plr == null)
                {
                    cclient.Plr = Player.CreatePlayer(cclient, Char);
                }

                if (cclient.Plr == null)
                {
                    cclient.Disconnect("NULL Player from CreatePlayer?");
                    return;
                }

                if (cclient.Plr.Client != cclient)
                {
                    cclient.Plr.Client?.Disconnect("Ghost client");
                    cclient.Plr.Destroy();
                    cclient.Disconnect("Player already exists");

                    return;
                }

                PacketOut Out = new PacketOut((byte)Opcodes.F_WORLD_ENTER, 64);
                Out.WriteUInt16(0x0608); // TODO
                Out.Fill(0, 20);
                Out.WriteString("38699", 5);
                Out.WriteString("38700", 5);
                Out.WriteString("0.0.0.0", 20);
                cclient.SendPacket(Out);
            }
        }
Пример #3
0
        static public void F_CONNECT(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            packet.Skip(8);
            UInt32 Tag   = packet.GetUint32();
            string Token = packet.GetString(80);

            packet.Skip(21);
            string Username = packet.GetString(23);

            // TODO
            AuthResult Result = Program.AcctMgr.CheckToken(Username, Token);

            if (Result != AuthResult.AUTH_SUCCESS)
            {
                Log.Error("F_CONNECT", "Invalid Token =" + Username);
                cclient.Disconnect();
            }
            else
            {
                cclient._Account = Program.AcctMgr.GetAccount(Username);
                if (cclient._Account == null)
                {
                    Log.Error("F_CONNECT", "Invalid Account =" + Username);
                    cclient.Disconnect();
                }
                else
                {
                    //Log.Success("F_CONNECT", "MeId=" + cclient.Id);

                    GameClient Other = (cclient.Server as TCPServer).GetClientByAccount(cclient, cclient._Account.AccountId);
                    if (Other != null)
                    {
                        Other.Disconnect();
                    }

                    {
                        PacketOut Out = new PacketOut((byte)Opcodes.S_CONNECTED);
                        Out.WriteUInt32(0);
                        Out.WriteUInt32(Tag);
                        Out.WriteByte(Program.Rm.RealmId);
                        Out.WriteUInt32(0);// this was 1// setting this at 0 removes the server population box
                        Out.WritePascalString(Username);
                        Out.WritePascalString(Program.Rm.Name);
                        Out.WriteByte(0);
                        Out.WriteUInt16(0);
                        cclient.SendPacket(Out);
                    }
                }
            }
        }
        static public void F_CONNECT(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            packet.Skip(8);
            UInt32 Tag   = packet.GetUint32();
            string Token = packet.GetString(80);

            packet.Skip(21);
            string Username = packet.GetString(23);

            Log.Debug("Connect", "Connexion avec : " + Token + ",User="******"F_CONNECT", "MeId=" + cclient.Id);

                    GameClient Other = (cclient.Server as TCPServer).GetClientByAccount(cclient, cclient._Account.AccountId);
                    if (Other != null)
                    {
                        Other.Disconnect();
                    }

                    PacketOut Out = new PacketOut((byte)Opcodes.S_CONNECTED);
                    Out.WriteUInt32(0);
                    Out.WriteUInt32(Tag);
                    Out.WriteByte(Program.Rm.RealmId);
                    Out.WriteUInt32(0);
                    Out.WritePascalString(Username);
                    Out.WritePascalString(Program.Rm.Name);
                    Out.WriteByte(0);
                    Out.WriteUInt16(0);
                    cclient.SendTCP(Out);
                }
            }
        }
Пример #5
0
        static public void F_PLAYER_ENTER_FULL(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            UInt16 SID;
            byte   unk1, serverID, characterSlot;

            SID      = packet.GetUint16();
            unk1     = packet.GetUint8();
            serverID = packet.GetUint8();
            string CharName = packet.GetString(24);

            packet.Skip(2);
            string Language = packet.GetString(2);

            packet.Skip(4);
            characterSlot = packet.GetUint8();

            Log.Success("F_PLAYER_ENTER_FULL", "Entrer en jeu de : " + CharName + ",Slot=" + characterSlot);

            if (Program.Rm.RealmId != serverID)
            {
                cclient.Disconnect();
            }
            else
            {
                PacketOut Out = new PacketOut((byte)Opcodes.S_PID_ASSIGN);
                Out.WriteUInt16R((ushort)cclient.Id);
                cclient.SendTCP(Out);
            }
        }
Пример #6
0
Файл: Player.cs Проект: uvbs/DoR
        static public Player CreatePlayer(GameClient Client, Character Char)
        {
            GameClient Other = (Client.Server as TCPServer).GetClientByAccount(Client, Char.AccountId);

            if (Other != null)
            {
                Other.Disconnect();
            }

            Player Plr = new Player(Client, Char);

            return(Plr);
        }
Пример #7
0
        static public void F_DISCONNECT(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (cclient._Account == null)
            {
                return;
            }

            GameClient OtherClient = (client.Server as TCPServer).GetClientByAccount(cclient, cclient._Account.AccountId);

            if (OtherClient != null)
            {
                OtherClient.Disconnect();
            }
        }
Пример #8
0
        static public void F_DELETE_CHARACTER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            byte Slot = packet.GetUint8();

            if (cclient._Account == null)
            {
                cclient.Disconnect();
                return;
            }

            CharMgr.RemoveCharacter(Slot, cclient._Account.AccountId);

            PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE);

            Out.WritePascalString(cclient._Account.Username);
            cclient.SendTCP(Out);
        }
Пример #9
0
        public override void Dispose()
        {
            RemovePlayer(this);

            SendLeave();
            StopQuit();

            EvtInterface.Notify("Leave", this, null);
            SocInterface.Stop();

            Save();

            if (_Client != null)
            {
                _Client.Plr = null;
                _Client.Disconnect();
            }

            base.Dispose();
        }
Пример #10
0
        public static void F_DELETE_CHARACTER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            byte Slot = packet.GetUint8();

            if (cclient._Account == null)
            {
                cclient.Disconnect("Null Account in F_DELETE_CHARACTER");
                return;
            }

            CharMgr.RemoveCharacter(Slot, cclient);

            PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE, 24);

            Out.FillString(cclient._Account.Username, 21);
            Out.Fill(0, 3);
            cclient.SendPacket(Out);
        }
Пример #11
0
        static public void F_RENAME_CHARACTER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            packet.Skip(3);

            string OldName = packet.GetString(24);
            string NewName = packet.GetString(24);

            Log.Success("F_RENAME_CHARACTER", "Renaming: '" + OldName + "' To: '" + NewName + "'");

            if (NewName.Length > 2 && !CharMgr.NameIsUsed(NewName))
            {
                Character Char = CharMgr.GetCharacter(OldName);

                if (Char == null || Char.AccountId != cclient._Account.AccountId)
                {
                    Log.Error("CharacterRename", "Hack: Tried to rename character which account dosen't own");
                    cclient.Disconnect();
                    return;
                }

                Char.Name = NewName;
                CharMgr.Database.SaveObject(Char);

                // Wrong response? Perhaps needs to send F_REQUEST_CHAR_RESPONSE again.
                PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE);
                Out.WritePascalString(cclient._Account.Username);
                cclient.SendPacket(Out);
            }
            else
            {
                // Wrong response?
                PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_ERROR);
                Out.WritePascalString(cclient._Account.Username);
                cclient.SendPacket(Out);
            }
        }
        public static void F_PLAYER_ENTER_FULL(BaseClient client, PacketIn packet)
        {
            GameClient cclient = (GameClient)client;

            ushort SID;
            byte   unk1, serverID, characterSlot;

            SID      = packet.GetUint16();
            unk1     = packet.GetUint8();
            serverID = packet.GetUint8();
            string CharName = packet.GetString(24);

            packet.Skip(2);
            string Language = packet.GetString(2);

            packet.Skip(4);
            characterSlot = packet.GetUint8();

            Log.Debug("F_PLAYER_ENTER_FULL", "Enter the game : " + CharName + ",Slot=" + characterSlot);

            if (Program.Rm.RealmId != serverID)
            {
                cclient.Disconnect("Requested realm ID does not match this server's ID");
            }
            else
            {
                PacketOut Out = new PacketOut((byte)Opcodes.S_PID_ASSIGN, 2);
                Out.WriteUInt16R((ushort)cclient.Id);
                cclient.SendPacket(Out);

                if (cclient.Plr != null)
                {
                    cclient.Plr.DisconnectType = Player.EDisconnectType.Unclean;
                }
            }
        }
        public static void F_CONNECT(BaseClient client, PacketIn packet)
        {
            Log.Success("F_CONNECT", "Entering F_CONNECT " + client.Id.ToString() + " " + packet.Opcode.ToString());
            GameClient cclient = (GameClient)client;

            packet.Skip(8);
            uint   Tag   = packet.GetUint32();
            string Token = packet.GetString(80);

            packet.Skip(21);
            string Username = packet.GetString(23);

            // TODO
            AuthResult Result = Program.AcctMgr.CheckToken(Username, Token);

#if DEBUG
            Result = AuthResult.AUTH_SUCCESS;
#endif

            if (Result == AuthResult.AUTH_ACCT_SUSPENDED)
            {
                Log.Error("F_CONNECT", "Banned Account =" + Username);
                cclient.Disconnect("Banned account");
            }
            else if (Result != AuthResult.AUTH_SUCCESS)
            {
                Log.Error("F_CONNECT", "Invalid Token =" + Username + " " + Result);

                // Kick people who spam the god damn button for 5 minutes straight before they clock on.
                PacketOut Out = new PacketOut((byte)Opcodes.F_PLAYER_QUIT, 4);
                Out.WriteHexStringBytes("01000000");
                cclient.SendPacket(Out);

                cclient.Disconnect("Invalid token");
            }
            else
            {
                cclient._Account = Program.AcctMgr.GetAccount(Username);
                if (cclient._Account == null)
                {
                    Log.Error("F_CONNECT", "Invalid Account =" + Username);
                    cclient.Disconnect("Invalid account");
                }
                else
                {
                    Log.Success("F_CONNECT", "MeId=" + cclient.Id);

                    GameClient Other = ((TCPServer)cclient.Server).GetClientByAccount(cclient, cclient._Account.AccountId);
                    if (Other != null)
                    {
                        Other.Disconnect("Failed to get GameClient for account");
                    }

                    // Check if ip is banned. (they may have been just banned so launcher server wouldnt have picked it up)
                    if (!Program.AcctMgr.CheckIp(cclient.GetIp().Split(':')[0]))
                    {
                        Log.Error("F_CONNECT", "Banned IP =" + Username);
                        cclient.Disconnect("Banned by IP");
                    }

                    // Load characters before connection instead of later on
                    CharMgr.LoadCharacters(cclient._Account.AccountId);

                    {
                        cclient.PacketLog = cclient._Account.PacketLog;

                        PacketOut Out = new PacketOut((byte)Opcodes.S_CONNECTED, 48);
                        Out.WriteUInt32(0);
                        Out.WriteUInt32(Tag);
                        Out.WriteByte(Program.Rm.RealmId);
                        Out.WriteByte(0);
                        Out.WriteByte(0);
                        Out.WriteByte(0);
                        Out.WriteByte(0); // TRANSFER_FLAG (1 - Low population server..free transfers...)
                        Out.WritePascalString(Username);
                        Out.WritePascalString(Program.Rm.Name);
                        Out.WriteByte(0);
                        Out.WriteUInt16(0);
                        cclient.SendPacket(Out);
                    }
                }
            }
        }