コード例 #1
0
ファイル: PT_Npc.cs プロジェクト: KalOnline/KaLua
        public static void BuyNpcItem(Client client, PacketIn packet)
        {
            int npcWorldId = (int)packet.ReadUInt32();
            byte v1     = packet.ReadByte();
            byte amount = packet.ReadByte();

            int totalPrice = 0;

            ushort[] items   = new ushort[amount];
            ushort[] amounts = new ushort[amount];
            for(int i=0;i<amount;i++)
            {
                items[i]   = packet.ReadUShort();
                amounts[i] = packet.ReadUShort();

                // TODO, calculate correct price
                totalPrice += 100 * amounts[i];
            }

            // TODO, add geon amount check
            for(int i=0;i<amount;i++)
            {
                // should be items, not player items
                PlayerItem item = PlayerItem.Get((int)items[i]);
                client.Character.Player.Inventory.Items.Add(item);
                // update AddToInventory with generic item-object
                client.Send(new Packets.AddToInventory((int)items[i],(int)amounts[i]),"Buy Item");
                // update amout of geons !
            }
        }
コード例 #2
0
ファイル: PT_Npc.cs プロジェクト: sgentens/KaLua
        public static void BuyNpcItem(Client client, PacketIn packet)
        {
            int  npcWorldId = (int)packet.ReadUInt32();
            byte v1         = packet.ReadByte();
            byte amount     = packet.ReadByte();

            int totalPrice = 0;

            ushort[] items   = new ushort[amount];
            ushort[] amounts = new ushort[amount];
            for (int i = 0; i < amount; i++)
            {
                items[i]   = packet.ReadUShort();
                amounts[i] = packet.ReadUShort();

                // TODO, calculate correct price
                totalPrice += 100 * amounts[i];
            }

            // TODO, add geon amount check
            for (int i = 0; i < amount; i++)
            {
                // should be items, not player items
                PlayerItem item = PlayerItem.Get((int)items[i]);
                client.Character.Player.Inventory.Items.Add(item);
                // update AddToInventory with generic item-object
                client.Send(new Packets.AddToInventory((int)items[i], (int)amounts[i]), "Buy Item");
                // update amout of geons !
            }
        }
コード例 #3
0
 public static EntityId ReadPacked(PacketIn packet)
 {
     uint[] setIndices = Utility.GetSetIndices((uint)packet.ReadByte());
     byte[] fullRaw    = new byte[8];
     foreach (uint num in setIndices)
     {
         fullRaw[num] = packet.ReadByte();
     }
     return(new EntityId(fullRaw));
 }
コード例 #4
0
        public static EntityId ReadPacked(ref PacketIn packet)
        {
            var mask = GetSetIndices(packet.ReadByte());

            byte[] rawId = new byte[8];
            foreach (var i in mask)
            {
                rawId[i] = packet.ReadByte();
            }
            return(new EntityId(rawId));
        }
コード例 #5
0
ファイル: PT_Skill.cs プロジェクト: KalOnline/KaLua
        public static void SkillExecute(Client client, PacketIn packet)
        {
            byte skillId  = packet.ReadByte();
            byte skillLvl = packet.ReadByte();

            client.SkillHandler.Execute(skillId,skillLvl);

            if(packet.PacketSize < 9) {
                client.Send(new Packets.SkillExecute(client.Character,skillId,skillLvl));
                return;
            }
        }
コード例 #6
0
        public static void SkillExecute(Client client, PacketIn packet)
        {
            byte skillId  = packet.ReadByte();
            byte skillLvl = packet.ReadByte();

            client.SkillHandler.Execute(skillId, skillLvl);

            if (packet.PacketSize < 9)
            {
                client.Send(new Packets.SkillExecute(client.Character, skillId, skillLvl));
                return;
            }
        }
コード例 #7
0
        public static void CreateCharacter(Client client, PacketIn packet)
        {
            string name         = packet.ReadString();
            byte   type         = packet.ReadByte();
            byte   strength     = packet.ReadByte();
            byte   health       = packet.ReadByte();
            byte   intelligence = packet.ReadByte();
            byte   wisdom       = packet.ReadByte();
            byte   agility      = packet.ReadByte();
            byte   face         = packet.ReadByte();
            byte   hair         = packet.ReadByte();

            if ((strength + health + intelligence + wisdom + agility) != 5)
            {
                ServerConsole.WriteLine(System.Drawing.Color.Red,
                                        "Invalid character creation request from {0}.",
                                        client.User.Username
                                        );
                return;
            }

            int playerId = client.CreateCharacter(name, type, strength, health, intelligence, wisdom, agility, face, hair);

            client.SendPlayerList();
        }
コード例 #8
0
        public void Dump(IndentTextWriter writer)
        {
            var prefix = (Definition == null ? "UNDEFINED " : "");
            var length = Packet.Length - Packet.HeaderSize;

            writer.WriteLine(TimeStampcreator(Timestamp) + string.Format(prefix + Sender + " Packet #{0} ({1}), Length: {2} bytes",
                                                                         Packet.PacketId.RawId, Packet.PacketId, length));
            writer.IndentLevel++;
            if (Definition != null)
            {
                //Definition.Structure.Render(this, writer);
                m_parsedPacket.RenderTo(writer);
            }

            // display the remainder as hexadecimal byte-string
            var remainderLength = Packet.Length - Packet.Position;

            if (remainderLength > 0)
            {
                var byteStr = new List <string>();
                while (Packet.Position < Packet.Length)
                {
                    byteStr.Add(string.Format("{0:X2}", Packet.ReadByte()));
                }
                writer.WriteLine("Remainder (" + remainderLength + " bytes): " + byteStr.ToString(" "));
            }
            writer.IndentLevel--;
        }
コード例 #9
0
 private ClientInformation(PacketIn packet)
 {
     try
     {
         this.ProtocolVersion = packet.ReadByte();
         ushort num = packet.ReadUInt16();
         if (packet.RemainingLength != (int)num)
         {
             ClientInformation.Log.Warn(WCell_Core.Auth_Logon_with_invalid_length, (object)num,
                                        (object)packet.RemainingLength);
         }
         this._clientInstallationType = ClientTypeUtility.Lookup(packet.ReadFourCC());
         this.Version      = new ClientVersion(packet.ReadBytes(5));
         this.Architecture = packet.ReadFourCC().TrimEnd(new char[1]);
         this.OS           = packet.ReadFourCC().TrimEnd(new char[1]);
         this._locale      = ClientLocaleUtility.Lookup(packet.ReadFourCC());
         this.TimeZone     = BitConverter.ToUInt32(packet.ReadBytes(4), 0);
         this.IPAddress    = new XmlIPAddress(packet.ReadBytes(4));
         ClientInformation.Log.Info(WCell_Core.ClientInformationFourCCs, (object)this.ProtocolVersion,
                                    (object)this.ClientInstallationType, (object)this.Version, (object)this.Architecture,
                                    (object)this.OS, (object)this.Locale, (object)this.TimeZone, (object)this.IPAddress);
     }
     catch
     {
     }
 }
コード例 #10
0
 private ClientInformation(PacketIn packet)
 {
     try
     {
         ProtocolVersion = packet.ReadByte();
         ushort num = packet.ReadUInt16();
         if (packet.RemainingLength != num)
         {
             Log.Warn(WCell_Core.Auth_Logon_with_invalid_length, num,
                      packet.RemainingLength);
         }
         _clientInstallationType = ClientTypeUtility.Lookup(packet.ReadFourCC());
         Version      = new ClientVersion(packet.ReadBytes(5));
         Architecture = packet.ReadFourCC().TrimEnd(new char[1]);
         OS           = packet.ReadFourCC().TrimEnd(new char[1]);
         _locale      = ClientLocaleUtility.Lookup(packet.ReadFourCC());
         TimeZone     = BitConverter.ToUInt32(packet.ReadBytes(4), 0);
         IPAddress    = new XmlIPAddress(packet.ReadBytes(4));
         Log.Info(WCell_Core.ClientInformationFourCCs, (object)ProtocolVersion,
                  (object)ClientInstallationType, (object)Version, (object)Architecture,
                  (object)OS, (object)Locale, (object)TimeZone, (object)IPAddress);
     }
     catch
     {
     }
 }
コード例 #11
0
        public static void LearnSkill(Client client, PacketIn packet)
        {
            byte skillId = packet.ReadByte();

            if (client.Character.Player.SkillPoints >= 1)
            {
                if (!client.Character.Skills.ContainsKey(skillId))
                {
                    using (ISession session = Server.Factory.OpenSession())
                    {
                        PlayerSkill skill = new PlayerSkill();
                        skill.Level      = 1;
                        skill.PlayerId   = client.Character.Player.PlayerId;
                        skill.SkillIndex = (int)skillId;

                        client.Character.Skills[skillId] = skill;
                        client.Send(new Packets.SkillSet(skillId, (byte)1));

                        using (ITransaction transaction = session.BeginTransaction())
                        {
                            session.Save(skill);
                            transaction.Commit();
                        }
                    }
                    client.Character.Player.SkillPoints--;
                    client.Send(new Packets.ValueChange(0x18, (byte)client.Character.Player.SkillPoints));
                }
            }
        }
コード例 #12
0
        public void Handle_NameQuery(PacketIn packet)
        {
            WoWGuid guid = new WoWGuid(packet.ReadUInt64());
            string  name = packet.ReadString();

            packet.ReadByte();
            Race      Race   = (Race)packet.ReadUInt32();
            Gender    Gender = (Gender)packet.ReadUInt32();
            Classname Class  = (Classname)packet.ReadUInt32();


            if (objectMgr.objectExists(guid))        // Update existing Object
            {
                Object obj = objectMgr.getObject(guid);
                obj.Name = name;
                objectMgr.updateObject(obj);
            }
            else                    // Create new Object        -- FIXME: Add to new 'names only' list?
            {
                Object obj = new Object(guid);
                obj.Name = name;
                objectMgr.addObject(obj);

                /* Process chat message if we looked them up now */
                for (int i = 0; i < ChatQueued.Count; i++)
                {
                    ChatQueue message = (ChatQueue)ChatQueued[i];
                    if (message.GUID.GetOldGuid() == guid.GetOldGuid())
                    {
                        Log.WriteLine(LogType.Chat, "[{1}] {0}", message.Message, name);
                        ChatQueued.Remove(message);
                    }
                }
            }
        }
コード例 #13
0
ファイル: XClientGameEmulator.cs プロジェクト: Xijezu/XChat
 public ChatMessage(PacketIn p)
 {
     szName    = p.ReadString(21);
     nSize     = p.ReadInt16();
     nType     = (byte)p.ReadByte();
     szMessage = p.ReadString(nSize);
 }
コード例 #14
0
ファイル: PT_Skill.cs プロジェクト: KalOnline/KaLua
        public static void LearnSkill(Client client, PacketIn packet)
        {
            byte skillId = packet.ReadByte();
            if(client.Character.Player.SkillPoints >= 1)
            {
                if(!client.Character.Skills.ContainsKey(skillId))
                {
                    using(ISession session = Server.Factory.OpenSession())
                    {
                        PlayerSkill skill = new PlayerSkill();
                        skill.Level       = 1;
                        skill.PlayerId    = client.Character.Player.PlayerId;
                        skill.SkillIndex  = (int)skillId;

                        client.Character.Skills[skillId] = skill;
                        client.Send(new Packets.SkillSet(skillId,(byte)1));

                        using(ITransaction transaction = session.BeginTransaction())
                        {
                            session.Save(skill);
                            transaction.Commit();
                        }
                    }
                    client.Character.Player.SkillPoints--;
                    client.Send(new Packets.ValueChange(0x18,(byte)client.Character.Player.SkillPoints));
                }
            }
        }
コード例 #15
0
        private ClientInformation(PacketIn packet)
        {
            try
            {
                ProtocolVersion = packet.ReadByte();
                var claimedRemainingLength = packet.ReadUInt16();
                if (packet.RemainingLength != claimedRemainingLength)
                {
                    Log.Warn(WCell_Core.Auth_Logon_with_invalid_length, claimedRemainingLength, packet.RemainingLength);
                }

                var clientInstallationType = packet.ReadFourCC();
                _clientInstallationType = ClientTypeUtility.Lookup(clientInstallationType);

                Version      = new ClientVersion(packet.ReadBytes(5));
                Architecture = packet.ReadFourCC().TrimEnd('\0');
                OS           = packet.ReadFourCC().TrimEnd('\0');

                var locale = packet.ReadFourCC();
                _locale = ClientLocaleUtility.Lookup(locale);

                TimeZone  = BitConverter.ToUInt32(packet.ReadBytes(4), 0);
                IPAddress = new XmlIPAddress(packet.ReadBytes(4));

                Log.Info(WCell_Core.ClientInformationFourCCs, ProtocolVersion, ClientInstallationType, Version, Architecture, OS, Locale, TimeZone, IPAddress);
            }
            catch
            {
            }
        }
コード例 #16
0
 public static void SessionRequest(Client client, PacketIn packet)
 {
     if (packet.ReadByte() == 0)
     {
         client.Send(new Packets.SessionRequest(), "Session Request");
     }
 }
コード例 #17
0
        public static void SkillRequest(Client client, PacketIn packet)
        {
            byte skillId  = packet.ReadByte();
            uint playerId = packet.ReadUInt32();

            client.SkillHandler.Request(skillId, playerId);

            client.Send(new Packets.SkillExecute(client.Character, skillId, 1));
        }
コード例 #18
0
ファイル: PT_Skill.cs プロジェクト: KalOnline/KaLua
        public static void SkillRequest(Client client,PacketIn packet)
        {
            byte skillId  = packet.ReadByte();
            uint playerId = packet.ReadUInt32();

            client.SkillHandler.Request(skillId,playerId);

            client.Send(new Packets.SkillExecute(client.Character,skillId,1));
        }
コード例 #19
0
 public SERVER_LIST(PacketIn p)
 {
     last_login_idx = p.ReadUInt16();
     count          = p.ReadUInt16();
     list           = new SERVER_INFO[count];
     for (int i = 0; i < count; i++)
     {
         list[i] = new SERVER_INFO(p.ReadUInt16(), p.ReadString(21), p.ReadByte() == 1 ? true : false, p.ReadString(256), p.ReadString(16), p.ReadInt32(), p.ReadUInt16());
     }
 }
コード例 #20
0
ファイル: PT_Character.cs プロジェクト: BeshoyFD/kalsharp
 public static void PlayerChange(Client client, PacketIn packet)
 {
     byte b = packet.ReadByte();
     if(b == 1) {
         client.Send(new Packets.AcceptChange());
         client.UnspawnPlayer();
         client.SendPlayerList();
         return;
     }
 }
コード例 #21
0
        /// <summary>
        /// Checks if the client's proof matches our proof.
        /// </summary>
        /// <param name="packet">the packet to read from</param>
        /// <returns>true if the client proof matches; false otherwise</returns>
        public bool IsClientProofValid(PacketIn packet)
        {
            m_srp.PublicEphemeralValueA = packet.ReadBigInteger(32);

            BigInteger proof = packet.ReadBigInteger(20);

            // SHA1 of PublicEphemeralValueA and the 16 random bytes sent in
            // AUTH_LOGON_CHALLENGE from the server
            byte[] arr = packet.ReadBytes(20);

            byte keyCount = packet.ReadByte();

            for (int i = 0; i < keyCount; i++)
            {
                ushort keyUnk1     = packet.ReadUInt16();
                uint   keyUnk2     = packet.ReadUInt32();
                byte[] keyUnkArray = packet.ReadBytes(4);
                // sha of the SRP's PublicEphemeralValueA, PublicEphemeralValueB,
                // and 20 unknown bytes
                byte[] keyUnkSha = packet.ReadBytes(20);
            }

            byte securityFlags = packet.ReadByte();

            if ((securityFlags & 1) != 0)
            {
                // PIN
                byte[] pinRandom = packet.ReadBytes(16);
                byte[] pinSha    = packet.ReadBytes(20);
            }
            if ((securityFlags & 2) != 0)
            {
                byte[] security2Buf = packet.ReadBytes(20);
            }
            if ((securityFlags & 4) != 0)
            {
                byte   arrLen       = packet.ReadByte();
                byte[] security4Buf = packet.ReadBytes(arrLen);
            }

            return(m_srp.IsClientProofValid(proof));
        }
コード例 #22
0
        public void HandleLogonProof(PacketIn packetIn)
        {
            if (packetIn.ReadByte() == 0x00)
            {
                Log.WriteLine(LogType.Success, "Authenitcation successed. Requesting RealmList");

                //Retail server sends a loooooot of informations there!
                RequestRealmlist();
                pLoop.Stop();
            }
        }
コード例 #23
0
        public static void PlayerChange(Client client, PacketIn packet)
        {
            byte b = packet.ReadByte();

            if (b == 1)
            {
                client.Send(new Packets.AcceptChange());
                client.UnspawnPlayer();
                client.SendPlayerList();
                return;
            }
        }
コード例 #24
0
        public void HandleMonsterMove(PacketIn packet)
        {
            byte mask = packet.ReadByte();

            WoWGuid guid = new WoWGuid(mask, packet.ReadBytes(WoWGuid.BitCount8(mask)));

            Object obj = objectMgr.getObject(guid);

            if (obj != null)
            {
                obj.Position = new Coordinate(packet.ReadFloat(), packet.ReadFloat(), packet.ReadFloat());
            }
        }
コード例 #25
0
        public void HandleAuthResponse(PacketIn packet)
        {
            LoginErrorCode error = (LoginErrorCode)packet.ReadByte();

            if (error == LoginErrorCode.AUTH_OK)
            {
                PacketOut outpacket = new PacketOut(WorldServerOpCode.CMSG_CHAR_ENUM);
                Send(outpacket);
            }
            else
            {
                Log.WriteLine(LogType.Error, "M values doesn't match, please try again.");
                Disconnect();
            }
        }
コード例 #26
0
ファイル: Authenticator.cs プロジェクト: uvbs/Asda2-Server
        /// <summary>Checks if the client's proof matches our proof.</summary>
        /// <param name="packet">the packet to read from</param>
        /// <returns>true if the client proof matches; false otherwise</returns>
        public bool IsClientProofValid(PacketIn packet)
        {
            this.m_srp.PublicEphemeralValueA = packet.ReadBigInteger(32);
            BigInteger client_proof = packet.ReadBigInteger(20);

            packet.ReadBytes(20);
            byte num1 = packet.ReadByte();

            for (int index = 0; index < (int)num1; ++index)
            {
                packet.ReadUInt16();
                packet.ReadUInt32();
                packet.ReadBytes(4);
                packet.ReadBytes(20);
            }

            byte num2 = packet.ReadByte();

            if (((int)num2 & 1) != 0)
            {
                packet.ReadBytes(16);
                packet.ReadBytes(20);
            }

            if (((int)num2 & 2) != 0)
            {
                packet.ReadBytes(20);
            }
            if (((int)num2 & 4) != 0)
            {
                byte num3 = packet.ReadByte();
                packet.ReadBytes((int)num3);
            }

            return(this.m_srp.IsClientProofValid(client_proof));
        }
コード例 #27
0
        public static void F_SWITCH_ATTACK_MODE(BaseClient client, PacketIn packet)
        {
            GameClient cclient = (GameClient)client;

            if (!cclient.HasPlayer())
            {
                return;
            }

            if (cclient.Plr.WeaponStance != WeaponStance.Standard)
            {
                packet.Skip(1);
                cclient.Plr.WeaponStance = (WeaponStance)packet.ReadByte();
            }

            cclient.Plr.CbtInterface.IsAttacking = !cclient.Plr.CbtInterface.IsAttacking;
        }
コード例 #28
0
        private static void CommandSelectTitle(Player plr, PacketIn packet)
        {
            packet.ReadByte();

            // Read the titleId
            ushort titleId = packet.GetUint16();

            // Verify player has this title unlocked
            if (titleId != 0 && !plr.TokInterface.HasTok(titleId))
            {
                plr.SendClientMessage("You attempted to select a title that you have not yet unlocked.", ChatLogFilters.CHATLOGFILTERS_USER_ERROR);
            }
            else
            {
                plr.SetTitleId(titleId);
            }
        }
コード例 #29
0
        public void HandleUpdateObjectFieldBlock(PacketIn packet, Object newObject)
        {
            uint lenght = packet.ReadByte();

            UpdateMask UpdateMask = new UpdateMask();

            UpdateMask.SetCount((ushort)(lenght));
            UpdateMask.SetMask(packet.ReadBytes((int)lenght * 4), (ushort)lenght);
            UInt32[] Fields = new UInt32[UpdateMask.GetCount()];

            for (int i = 0; i < UpdateMask.GetCount(); i++)
            {
                if (!UpdateMask.GetBit((ushort)i))
                {
                    UInt32 val = packet.ReadUInt32();
                    newObject.SetField(i, val);
                    Log.WriteLine(LogType.Normal, "Update Field: {0} = {1}", (UpdateFields)i, val);
                }
            }
        }
コード例 #30
0
ファイル: PT_Skill.cs プロジェクト: KalOnline/KaLua
        public static void UpgradeSkill(Client client, PacketIn packet)
        {
            byte skillId = packet.ReadByte();
            if(client.Character.Player.SkillPoints >= 1)
            {
                if(client.Character.Skills.ContainsKey(skillId))
                {
                    client.Character.Skills[skillId].Level += 1;
                    client.Send(new Packets.SkillSet(skillId,(byte)client.Character.Skills[skillId].Level));
                    using(ISession session = Server.Factory.OpenSession())
                    using(ITransaction transaction = session.BeginTransaction())
                    {
                        session.SaveOrUpdate(client.Character.Skills[skillId]);
                        transaction.Commit();
                    }

                    client.Character.Player.SkillPoints--;
                    client.Send(new Packets.ValueChange(0x18,(byte)client.Character.Player.SkillPoints));
                }
            }
        }
コード例 #31
0
        public static void CreatePlayer(Client client, PacketIn packet)
        {
            string name         = packet.ReadString();
            byte   type         = packet.ReadByte();
            byte   strength     = packet.ReadByte();
            byte   health       = packet.ReadByte();
            byte   intelligence = packet.ReadByte();
            byte   wisdom       = packet.ReadByte();
            byte   agility      = packet.ReadByte();
            byte   face         = packet.ReadByte();
            byte   hair         = packet.ReadByte();

            if ((strength + health + intelligence + wisdom + agility) != 5)
            {
                client.Send(new Packets.CharacterCreationError(Packets.CHARACTER_CREATION_ERROR.SHARING_POINTS_ERROR));
                Hackshield.AddOffense(client, OffenseSeverity.IncorrectPacketDetails);
                return;
            }

            //check if name is valid
            if (!Utilities.IsAlnum(name))
            {
                client.Send(new Packets.CharacterError(Packets.CHARACTER_ERROR.INVALID_CHARS));
                return;
            }

            //check if player name is taken
            if (Player.GetPlayer(name) != null)
            {
                client.Send(new Packets.CharacterCreationError(Packets.CHARACTER_CREATION_ERROR.NAME_TAKEN));
                return;
            }

            int playerId = client.CreatePlayer(name, type, strength, health, intelligence, wisdom, agility, face, hair);

            client.SendPlayerList();
        }
コード例 #32
0
        public static void UpgradeSkill(Client client, PacketIn packet)
        {
            byte skillId = packet.ReadByte();

            if (client.Character.Player.SkillPoints >= 1)
            {
                if (client.Character.Skills.ContainsKey(skillId))
                {
                    client.Character.Skills[skillId].Level += 1;
                    client.Send(new Packets.SkillSet(skillId, (byte)client.Character.Skills[skillId].Level));
                    using (ISession session = Server.Factory.OpenSession())
                        using (ITransaction transaction = session.BeginTransaction())
                        {
                            session.SaveOrUpdate(client.Character.Skills[skillId]);
                            transaction.Commit();
                        }

                    client.Character.Player.SkillPoints--;
                    client.Send(new Packets.ValueChange(0x18, (byte)client.Character.Player.SkillPoints));
                }
            }
        }
コード例 #33
0
        public static void DeleteCharacter(Client client, PacketIn packet)
        {
            byte playerId = packet.ReadByte();

            using (ISession session = Server.Factory.OpenSession())
            {
                Player player = (Player)session.Get(typeof(Player), (int)playerId);
                if (player == null)
                {
                    ServerConsole.WriteLine(
                        System.Drawing.Color.Red,
                        "Tried to delete unexisting character with PlayerId ({0)",
                        playerId
                        );
                    return;
                }

                using (ITransaction transaction = session.BeginTransaction())
                {
                    DeletedPlayer dPlayer = new DeletedPlayer();

                    dPlayer.DeletedDate = DateTime.Now;
                    dPlayer.PlayerId    = player.PlayerId;
                    dPlayer.UserId      = player.UserId;

                    session.Save(dPlayer);
                    transaction.Commit();
                }

                using (ITransaction transaction = session.BeginTransaction())
                {
                    player.Status = 0;
                    session.Update(player);
                    transaction.Commit();
                }
            }

            client.SendPlayerList();
        }
コード例 #34
0
ファイル: PT_Character.cs プロジェクト: BeshoyFD/kalsharp
        public static void CreatePlayer(Client client, PacketIn packet)
        {
            string name       = packet.ReadString();
            byte type         = packet.ReadByte();
            byte strength     = packet.ReadByte();
            byte health       = packet.ReadByte();
            byte intelligence = packet.ReadByte();
            byte wisdom       = packet.ReadByte();
            byte agility      = packet.ReadByte();
            byte face         = packet.ReadByte();
            byte hair         = packet.ReadByte();

            if((strength + health + intelligence + wisdom + agility) != 5)
            {
                client.Send(new Packets.CharacterCreationError(Packets.CHARACTER_CREATION_ERROR.SHARING_POINTS_ERROR));
                Hackshield.AddOffense(client, OffenseSeverity.IncorrectPacketDetails);
                return;
            }

            //check if name is valid
            if (!Utilities.IsAlnum(name))
            {
                client.Send(new Packets.CharacterError(Packets.CHARACTER_ERROR.INVALID_CHARS));
                return;
            }

            //check if player name is taken
            if (Player.GetPlayer(name) != null)
            {
                client.Send(new Packets.CharacterCreationError(Packets.CHARACTER_CREATION_ERROR.NAME_TAKEN));
                return;
            }

            int playerId = client.CreatePlayer(name, type, strength, health, intelligence, wisdom, agility, face, hair);
            client.SendPlayerList();
        }
コード例 #35
0
        public void HandleCharEnum(PacketIn packet)
        {
            byte count = packet.ReadByte();

            Character[] characterList = new Character[count];
            for (int i = 0; i < count; i++)
            {
                characterList[i].GUID  = packet.ReadUInt64();
                characterList[i].Name  = packet.ReadString();
                characterList[i].Race  = packet.ReadByte();
                characterList[i].Class = packet.ReadByte();
                packet.ReadByte();
                packet.ReadUInt32();
                packet.ReadByte();
                packet.ReadByte();
                packet.ReadUInt32();
                characterList[i].MapID = packet.ReadUInt32();
                packet.ReadFloat();
                packet.ReadFloat();
                packet.ReadFloat();
                packet.ReadUInt32();
                packet.ReadUInt32();
                packet.ReadByte();

                packet.ReadUInt32();
                packet.ReadUInt32();
                packet.ReadUInt32();
                packet.ReadBytes(9 * 20);
            }

            Log.WriteLine(LogType.Success, "Received info about {0} characters", count);

            Charlist = characterList;
            mCore.Event(new Event(EventType.EVENT_CHARLIST, "", new object[] { Charlist }));
            PingLoop();
        }
コード例 #36
0
        public void HandleRealmlist(PacketIn packetIn)
        {
            //packetIn.ReadByte();
            UInt16 Length      = packetIn.ReadUInt16();
            UInt32 Request     = packetIn.ReadUInt32();
            int    realmscount = packetIn.ReadInt16();

            //Console.Write(packetIn.ToHex());

            Log.WriteLine(LogType.Success, "Got information about {0} realms.", realmscount);
            Realm[] realms = new Realm[realmscount];
            try
            {
                for (int i = 0; i < realmscount; i++)
                {
                    realms[i].Type  = packetIn.ReadByte();
                    realms[i].Color = packetIn.ReadByte();
                    packetIn.ReadByte(); // unk
                    realms[i].Name       = packetIn.ReadString();
                    realms[i].Address    = packetIn.ReadString();
                    realms[i].Population = packetIn.ReadFloat();
                    realms[i].NumChars   = packetIn.ReadByte();
                    realms[i].Language   = packetIn.ReadByte();
                    packetIn.ReadByte();
                }

                Realmlist = realms;
                mCore.Event(new Event(EventType.EVENT_REALMLIST, "", new object[] { Realmlist }));
            }
            catch (Exception ex)
            {
                Log.WriteLine(LogType.Error, "Exception Occured");
                Log.WriteLine(LogType.Error, "Message: {0}", ex.Message);
                Log.WriteLine(LogType.Error, "Stacktrace: {0}", ex.StackTrace);
                Disconnect();
            }
        }
コード例 #37
0
        public void Read(byte[] data, int size)
        {
            PacketIn pIn = new PacketIn(data, 0, size);
            //pIn.SetBuffer(buffer, size);
            //pIn.ReadByte();
            //pIn.ReadByte();
            //pIn.ReadByte();

            //PID = pIn.GetInt16();
            //data4 = pIn.ReadByte();
            //MoveVelocity = pIn.GetIntClamped(-127, 325);
            //FallTime = pIn.GetIntClamped(-2000, 500);

            // 10 -1 92
            List <string> lst = new List <string>();

            for (int i = 0; i < 15; i++)
            {
                if (i > 10)
                {
                    lst.Add(i.ToString() + " " + pIn.ReadByte().ToString().PadLeft(3));
                }
            }

            Log.Error("", string.Join(", ", lst));
            //pIn.Skip(7);
            byte test = (byte)pIn.ReadByte();

            HasEnemyTarget = test & 64;
            //pIn.ReadByte(); //2 or 3 readbyte here seems to give some correct data and would correspond with the original readint(2) of freefall
            //pIn.ReadByte();
            FreeFall = test & 0x1F; //3F pIn.ReadByte() & 48; //BitConverter.ToInt16(pIn.Read(2), 0);
            //Log.Error("freefall", Convert.ToString(test, 2));
            //pIn.ReadByte();
            //pIn.ReadByte();
            //pIn.ReadByte();
            Action = BitConverter.ToInt16(pIn.Read(2), 0); //pIn.ReadByte();
            //pIn.ReadByte();
            //pIn.ReadByte();
            //pIn.ReadByte();
            Strafe = BitConverter.ToInt16(pIn.Read(3), 0); //pIn.ReadByte();

            if (HasEnemyTarget > 0 && data4 == 0)
            {
                data32 = pIn.ReadByte();
            }

            if (data4 == 0)
            {
                Heartbeat = BitConverter.ToInt16(pIn.Read(3), 0); //pIn.ReadByte();
            }
            HasPosition = pIn.ReadByte();

            if (HasPosition > 0)
            {
                Heading           = pIn.GetUint16(); // pIn.GetAngleRad(12);
                HasPositionChange = pIn.ReadByte();
                Grounded          = pIn.ReadByte();

                if (HasPositionChange == 0)
                {
                    X = pIn.GetInt16();
                    Y = pIn.GetInt16();
                }
            }

            if (HasEnemyTarget > 0 && data4 == 0)
            {
                data60 = pIn.ReadByte();
            }

            if (HasPosition > 0)
            {
                if (HasPositionChange == 0)
                {
                    ZoneID = BitConverter.ToInt16(pIn.Read(9), 0); //pIn.GetInt16(); // (9)
                    Z      = pIn.GetInt16();
                }
                else
                {
                    data72 = pIn.GetUint16();
                }
            }

            if (HasPosition > 0 && HasPositionChange > 0)
            {
                data76 = pIn.GetUint16();
                data80 = pIn.GetUint16();
                data84 = BitConverter.ToInt16(pIn.Read(9), 0); //pIn.GetInt16(); // (9)
            }

            if (HasEnemyTarget > 0)
            {
                if (data4 == 0)
                {
                    TargetLos = pIn.ReadByte();
                    data89    = pIn.ReadByte();
                    data90    = pIn.ReadByte();
                    data91    = pIn.ReadByte();
                    data92    = pIn.ReadByte();
                }
            }

            if ((data4 > 0) || (GroundType = BitConverter.ToInt16(pIn.Read(3), 0)) != 0) // (3)
            {
                data100   = pIn.ReadByte();
                Floating2 = pIn.ReadByte();
                data102   = pIn.ReadByte();
                data103   = pIn.ReadByte();
            }

            data104 = pIn.ReadByte();

            if (data4 == 0)
            {
                data105 = pIn.ReadByte();
            }

            data106 = pIn.ReadByte();
            data107 = pIn.ReadByte();
        }
コード例 #38
0
 public static void SessionRequest(Client client,PacketIn packet)
 {
     if(packet.ReadByte() == 0) {
         client.Send(new Packets.SessionRequest(),"Session Request");
     }
 }
コード例 #39
0
ファイル: PT_Stats.cs プロジェクト: KalOnline/KaLua
        public static void SetStats(Client client, PacketIn packet)
        {
            int start;
            byte value;

            switch(packet.ReadByte())
            {
                // Strength
                case 0:
                {
                    start = (client.Character.Player.ClassId == 0) ? 60 : 50;
                    value = client.Character.Stats.Strength;

                    _UpdateStats(client,start,value);

                    client.Character.Stats.Strength += 1;
                    client.Send(new Packets.StatPacket.Strength(client.Character.Stats));

                    break;
                }
                // Health
                case 1:
                {
                    start = 50;
                    value = client.Character.Stats.Health;

                    _UpdateStats(client,start,value);

                    client.Character.Stats.Health += 1;
                    client.Send(new Packets.StatPacket.Health(client.Character.Stats));

                    break;
                }
                // Intelligence
                case 2:
                {
                    start = (client.Character.Player.ClassId == 1) ? 60 : 50;
                    value = client.Character.Stats.Intelligence;

                    _UpdateStats(client,start,value);

                    client.Character.Stats.Intelligence += 1;
                    client.Send(new Packets.StatPacket.Intelligence(client.Character.Stats));

                    break;
                }
                // Wisdom
                case 3:
                {
                    start = 50;
                    value = client.Character.Stats.Wisdom;

                    _UpdateStats(client,start,value);

                    client.Character.Stats.Wisdom += 1;
                    client.Send(new Packets.StatPacket.Wisdom(client.Character.Stats));

                    break;
                }
                // Agility
                case 4:
                {
                    start = (client.Character.Player.ClassId == 2) ? 60 : 50;
                    value = client.Character.Stats.Agility;

                    _UpdateStats(client,start,value);

                    client.Character.Stats.Agility += 1;
                    client.Send(new Packets.StatPacket.Agility(client.Character.Stats));

                    break;
                }
            }
        }
コード例 #40
0
ファイル: PT_Stats.cs プロジェクト: BeshoyFD/kalsharp
        public static void SetStats(Client Client, PacketIn packet)
        {
            int Start;
            int Value;

            switch(packet.ReadByte())
            {
                // Strength
                case 0:
                {
                    Start = (Client.Character.Player.Class == 0) ? 60 : 50;
                    Value = Client.Character.Stats.BaseStats.Strength;

                    _UpdateStats(Client,Start,Value);

                    Client.Character.Stats.BaseStats.Strength += 1;
                    Client.Send(new Packets.StatPacket.Strength(Client.Character));

                    break;
                }
                // Health
                case 1:
                {
                    Start = 50;
                    Value = Client.Character.Stats.Health;

                    _UpdateStats(Client,Start,Value);

                    Client.Character.Stats.BaseStats.Health += 1;
                    Client.Send(new Packets.StatPacket.Health(Client.Character));

                    break;
                }
                // Intelligence
                case 2:
                {
                    Start = (Client.Character.Player.Class == 1) ? 60 : 50;
                    Value = Client.Character.Stats.Intelligence;

                    _UpdateStats(Client,Start,Value);

                    Client.Character.Stats.BaseStats.Intelligence += 1;
                    Client.Send(new Packets.StatPacket.Intelligence(Client.Character));

                    break;
                }
                // Wisdom
                case 3:
                {
                    Start = 50;
                    Value = Client.Character.Stats.Wisdom;

                    _UpdateStats(Client,Start,Value);

                    Client.Character.Stats.BaseStats.Wisdom += 1;
                    Client.Send(new Packets.StatPacket.Wisdom(Client.Character));

                    break;
                }
                // Agility
                case 4:
                {
                    Start = (Client.Character.Player.Class == 2) ? 60 : 50;
                    Value = Client.Character.Stats.Dexterity;

                    _UpdateStats(Client,Start,Value);

                    Client.Character.Stats.BaseStats.Dexterity += 1;
                    Client.Send(new Packets.StatPacket.Agility(Client.Character));

                    break;
                }
            }
        }