예제 #1
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            uint id = 0;

            if (client.Version >= GameClient.eClientVersion.Version1126)
            {
                id = packet.ReadIntLowEndian();
            }
            else
            {
                id = packet.ReadShort();
            }
            GameClient target = WorldMgr.GetClientFromID(id);

            if (target == null)
            {
                log.Warn($"Client {client.SessionID}:{client.TcpEndpointAddress} account {client.Account?.Name ?? "null"} requested invalid client {id} --- disconnecting");

                client.Disconnect();
                return;
            }

            // DOLConsole.WriteLine("player creation request "+target.Player.Name);
            if (target.IsPlaying && target.Player != null && target.Player.ObjectState == GameObject.eObjectState.Active)
            {
                client.Out.SendPlayerCreate(target.Player);
                client.Out.SendLivingEquipmentUpdate(target.Player);
            }
        }
예제 #2
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            // for 1.115c+ The First client packet Changes.
            if (client.Version < GameClient.eClientVersion.Version1115)
            {
                int  rc4        = packet.ReadByte();
                byte clientType = (byte)packet.ReadByte();
                client.ClientType   = (GameClient.eClientType)(clientType & 0x0F);
                client.ClientAddons = (GameClient.eClientAddons)(clientType & 0xF0);
                client.MajorBuild   = (byte)packet.ReadByte();
                client.MinorBuild   = (byte)packet.ReadByte();
                client.MinorRev     = packet.ReadString(1);
                if (rc4 == 1)
                {
                    //DOLConsole.Log("SBox=\n");
                    //DOLConsole.LogDump(client.PacketProcessor.Encoding.SBox);
                    packet.Read(client.PacketProcessor.Encoding.SBox, 0, 256);
                    client.PacketProcessor.Encoding.EncryptionState = eEncryptionState.PseudoRC4Encrypted;
                    //DOLConsole.WriteLine(client.Socket.RemoteEndPoint.ToString()+": SBox set!");
                    //DOLConsole.Log("SBox=\n");
                    //DOLConsole.LogDump(((PacketEncoding168)client.PacketProcessor.Encoding).SBox);
                }
                else
                {
                    //Send the crypt key to the client
                    client.Out.SendVersionAndCryptKey();
                }
            }
            else
            {
                // if the DataSize is above 7 then the RC4 key is bundled
                if (packet.DataSize > 7)
                {
                    if (Properties.CLIENT_ENABLE_ENCRYPTION_RC4)
                    {
                        var length = packet.ReadIntLowEndian();
                        var key    = new byte[length];
                        packet.Read(key, 0, (int)length);
                        client.PacketProcessor.Encoding.SBox            = key;
                        client.PacketProcessor.Encoding.EncryptionState = eEncryptionState.PseudoRC4Encrypted;
                    }
                    return;
                }

                // register client type
                byte clientType = (byte)packet.ReadByte();
                client.ClientType   = (GameClient.eClientType)(clientType & 0x0F);
                client.ClientAddons = (GameClient.eClientAddons)(clientType & 0xF0);
                // the next 4 bytes are the game.dll version but not in string form
                // ie: 01 01 19 61 = 1.125a
                // this version is handled elsewhere before being sent here.
                packet.Skip(3);                         // skip the numbers in the version
                client.MinorRev = packet.ReadString(1); // get the minor revision letter // 1125d support
                packet.Skip(2);                         // build


                //Send the crypt key to the client
                client.Out.SendVersionAndCryptKey();
            }
        }
            /// <summary>
            /// Reads up ONE character iteration on the packet stream
            /// </summary>
            /// <param name="packet"></param>
            /// <param name="client"></param>
            public CreationCharacterData(GSPacketIn packet, GameClient client)
            {
                //unk - probably indicates customize or create (these are moved from 1.99 4 added bytes)
                if (client.Version >= GameClient.eClientVersion.Version1104)
                {
                    packet.ReadIntLowEndian();
                }

                CharName   = packet.ReadString(24);
                CustomMode = packet.ReadByte();
                EyeSize    = packet.ReadByte();
                LipSize    = packet.ReadByte();
                EyeColor   = packet.ReadByte();
                HairColor  = packet.ReadByte();
                FaceType   = packet.ReadByte();
                HairStyle  = packet.ReadByte();
                packet.Skip(3);
                MoodType = packet.ReadByte();
                packet.Skip(8);

                Operation = packet.ReadInt();
                var unk = packet.ReadByte();

                packet.Skip(24);                 //Location String
                packet.Skip(24);                 //Skip class name
                packet.Skip(24);                 //Skip race name

                var level = packet.ReadByte();   //not safe!

                Class = packet.ReadByte();
                Realm = packet.ReadByte();

                //The following byte contains
                //1bit=start location ... in ShroudedIsles you can choose ...
                //1bit=first race bit
                //1bit=unknown
                //1bit=gender (0=male, 1=female)
                //4bit=race
                byte startRaceGender = (byte)packet.ReadByte();

                Race            = (startRaceGender & 0x0F) + ((startRaceGender & 0x40) >> 2);
                Gender          = ((startRaceGender >> 4) & 0x01);
                SIStartLocation = ((startRaceGender >> 7) != 0);

                CreationModel = packet.ReadShortLowEndian();
                Region        = packet.ReadByte();
                packet.Skip(1);                 //TODO second byte of region unused currently
                packet.Skip(4);                 //TODO Unknown Int / last used?

                Strength     = packet.ReadByte();
                Dexterity    = packet.ReadByte();
                Constitution = packet.ReadByte();
                Quickness    = packet.ReadByte();
                Intelligence = packet.ReadByte();
                Piety        = packet.ReadByte();
                Empathy      = packet.ReadByte();
                Charisma     = packet.ReadByte();

                packet.Skip(40);                         //TODO equipment

                var activeRightSlot = packet.ReadByte(); // 0x9C
                var activeLeftSlot  = packet.ReadByte(); // 0x9D
                var siZone          = packet.ReadByte(); // 0x9E

                // skip 4 bytes added in 1.99
                if (client.Version >= GameClient.eClientVersion.Version199 && client.Version < GameClient.eClientVersion.Version1104)
                {
                    packet.Skip(4);
                }

                // New constitution must be read before skipping 4 bytes
                NewConstitution = packet.ReadByte();                 // 0x9F
            }
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            string accountName = packet.ReadString(24);

            log.Debug("CharacterCreateRequestHandler for account " + accountName + " using version " + client.Version);

            if (!accountName.StartsWith(client.Account.Name))// TODO more correctly check, client send accountName as account-S, -N, -H (if it not fit in 20, then only account)
            {
                if (ServerProperties.Properties.BAN_HACKERS)
                {
                    DBBannedAccount b = new DBBannedAccount();
                    b.Author = "SERVER";
                    b.Ip = client.TcpEndpointAddress;
                    b.Account = client.Account.Name;
                    b.DateBan = DateTime.Now;
                    b.Type = "B";
                    b.Reason = String.Format("Autoban wrong Account '{0}'", GameServer.Database.Escape(accountName));
                    GameServer.Database.AddObject(b);
                    GameServer.Database.SaveObject(b);
                    GameServer.Instance.LogCheatAction(b.Reason + ". Account: " + b.Account);
                }

                client.Disconnect();
                return;
            }

            if (client.Version >= GameClient.eClientVersion.Version1104)
            {
                packet.ReadIntLowEndian(); //unk - probably indicates customize or create
            }

            int charsCount = client.Version < GameClient.eClientVersion.Version173 ? 8 : 10;
            for (int i = 0; i < charsCount; i++)
            {
                string charName = packet.ReadString(24);

                //log.DebugFormat("Character[{0}] = {1}", i, charName);

                if (charName.Length == 0)
                {
                    // 1.104+  if character is not in list but is in DB then delete the character
                    if (client.Version >= GameClient.eClientVersion.Version1104)
                    {
                        CheckForDeletedCharacter(accountName, client, i);
                    }

                    //If the charname is empty, skip the other bytes
                    packet.Skip(160);
                    if (client.Version >= GameClient.eClientVersion.Version199)
                    {
                        // skip 4 bytes added in 1.99
                        packet.Skip(4);
                    }
                }
                else
                {
                    // Graveen: changed the following to allow GMs to have special chars in their names (_,-, etc..)
                    Regex nameCheck = new Regex("^[A-Z][a-zA-Z]");
                    if (charName.Length < 3 || !nameCheck.IsMatch(charName))
                    {
                        if (client.Account.PrivLevel == 1)
                        {
                            if (ServerProperties.Properties.BAN_HACKERS)
                            {
                                DBBannedAccount b = new DBBannedAccount();
                                b.Author = "SERVER";
                                b.Ip = client.TcpEndpointAddress;
                                b.Account = client.Account.Name;
                                b.DateBan = DateTime.Now;
                                b.Type = "B";
                                b.Reason = String.Format("Autoban bad CharName '{0}'", GameServer.Database.Escape(charName));
                                GameServer.Database.AddObject(b);
                                GameServer.Database.SaveObject(b);
                                GameServer.Instance.LogCheatAction(b.Reason + ". Account: " + b.Account);
                            }

                            client.Disconnect();
                            return;
                        }
                    }

                    String select = String.Format("Name = '{0}'", GameServer.Database.Escape(charName));
                    DOLCharacters character = GameServer.Database.SelectObject<DOLCharacters>(select);
                    if (character != null)
                    {
                        if (character.AccountName != client.Account.Name)
                        {
                            if (Properties.BAN_HACKERS == true)
                            {
                                DBBannedAccount b = new DBBannedAccount();
                                b.Author = "SERVER";
                                b.Ip = client.TcpEndpointAddress;
                                b.Account = client.Account.Name;
                                b.DateBan = DateTime.Now;
                                b.Type = "B";
                                b.Reason = String.Format("Autoban CharName '{0}' on wrong Account '{1}'", GameServer.Database.Escape(charName), GameServer.Database.Escape(client.Account.Name));
                                GameServer.Database.AddObject(b);
                                GameServer.Database.SaveObject(b);
                                GameServer.Instance.LogCheatAction(string.Format(b.Reason + ". Client Account: {0}, DB Account: {1}", client.Account.Name, character.AccountName));
                            }

                            client.Disconnect();
                            return;
                        }

                        byte customizationMode = (byte)packet.ReadByte();

                        // log.DebugFormat("CustomizationMode = {0} for charName {1}", customizationMode, charName);

                        // check for update to existing character
                        CheckCharacterForUpdates(client, packet, character, charName, customizationMode);
                    }
                    else
                    {
                        // create new character and return
                        CreateCharacter(client, packet, charName, i);
                    }
                }
            }
        }
예제 #5
0
 public void _HandlePacket1126(GameClient client, GSPacketIn packet)
 {
     var id = packet.ReadIntLowEndian();
 }