From 96e9b9bba3e98ae01261a5e9b1d9036a90cfea86 Mon Sep 17 00:00:00 2001 From: shnok Date: Mon, 28 Oct 2024 02:49:09 +0800 Subject: [PATCH] charselect, enterworld, system messages --- .../Datatable/Json/SkillEffectTable.cs | 4 +- .../Assets/Scripts/Datatable/SkillTable.cs | 2 +- .../Scripts/Game/Manager/GameManager.cs | 2 +- .../ClientLibrary/AsynchronousClient.cs | 2 - .../ClientLibrary/Packet/ClientPacket.cs | 1 - .../ClientPackets/Auth/EnterWorldPacket.cs | 7 + ...acket.cs.meta => EnterWorldPacket.cs.meta} | 0 .../ClientPackets/Auth/LoadWorldPacket.cs | 6 - .../Auth/RequestCharSelectPacket.cs | 12 +- .../Packet/Gameserver/GameClientPacketType.cs | 2 +- .../Packet/Gameserver/GameServerPacketType.cs | 62 ++++---- .../ServerPackets/Auth/CharSelectedPacket.cs | 137 ++++++++++++++++++ .../CharSelectedPacket.cs.meta} | 0 .../Auth/CharSelectionInfoPacket.cs | 2 +- .../ServerPackets/Auth/VersionCheckPacket.cs | 4 - .../ServerPackets/PlayerInfoPacket.cs | 107 -------------- .../ServerPackets/SystemMessagePacket.cs | 14 +- .../ClientLibrary/Packet/ServerPacket.cs | 3 - .../Gameserver/GameClientPacketHandler.cs | 2 +- .../Gameserver/GameServerPacketHandler.cs | 8 +- .../Assets/Scripts/Networking/GameClient.cs | 2 +- 21 files changed, 204 insertions(+), 175 deletions(-) create mode 100644 l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ClientPackets/Auth/EnterWorldPacket.cs rename l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ClientPackets/Auth/{LoadWorldPacket.cs.meta => EnterWorldPacket.cs.meta} (100%) delete mode 100644 l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ClientPackets/Auth/LoadWorldPacket.cs create mode 100644 l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Auth/CharSelectedPacket.cs rename l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/{PlayerInfoPacket.cs.meta => Auth/CharSelectedPacket.cs.meta} (100%) delete mode 100644 l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/PlayerInfoPacket.cs diff --git a/l2-unity/Assets/Scripts/Datatable/Json/SkillEffectTable.cs b/l2-unity/Assets/Scripts/Datatable/Json/SkillEffectTable.cs index 65f1022bb..34c5d0e03 100644 --- a/l2-unity/Assets/Scripts/Datatable/Json/SkillEffectTable.cs +++ b/l2-unity/Assets/Scripts/Datatable/Json/SkillEffectTable.cs @@ -49,8 +49,8 @@ public void CacheEffects() { SkillEffects.TryAdd(kvp.Value.EffectId, skillEffect); kvp.Value.SkillEffect = skillEffect; - skillEffect.CastingActions?.ForEach((e) => Debug.LogWarning(e.EffectClass)); - skillEffect.ShotActions?.ForEach((e) => Debug.LogWarning(e.EffectClass)); + // skillEffect.CastingActions?.ForEach((e) => Debug.LogWarning(e.EffectClass)); + // skillEffect.ShotActions?.ForEach((e) => Debug.LogWarning(e.EffectClass)); } } } diff --git a/l2-unity/Assets/Scripts/Datatable/SkillTable.cs b/l2-unity/Assets/Scripts/Datatable/SkillTable.cs index 64aefa136..f7d8259b2 100644 --- a/l2-unity/Assets/Scripts/Datatable/SkillTable.cs +++ b/l2-unity/Assets/Scripts/Datatable/SkillTable.cs @@ -142,7 +142,7 @@ public void CacheSkills() Skill skill = new Skill(kvp.Key, skillNameArray, skillgrpArray, skillSoundgrp); Skills.Add(kvp.Key, skill); - Debug.LogWarning($"ID:{skill.SkillNameDatas[0].Id} Name:{skill.SkillNameDatas[0].Name} Effect:{skill.EffectId}"); + // Debug.LogWarning($"ID:{skill.SkillNameDatas[0].Id} Name:{skill.SkillNameDatas[0].Name} Effect:{skill.EffectId}"); } } diff --git a/l2-unity/Assets/Scripts/Game/Manager/GameManager.cs b/l2-unity/Assets/Scripts/Game/Manager/GameManager.cs index dc7b5d958..567a8fcf7 100644 --- a/l2-unity/Assets/Scripts/Game/Manager/GameManager.cs +++ b/l2-unity/Assets/Scripts/Game/Manager/GameManager.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using UnityEngine; -using static PlayerInfoPacket; +using static CharSelectedPacket; using static ServerListPacket; public class GameManager : MonoBehaviour diff --git a/l2-unity/Assets/Scripts/Networking/ClientLibrary/AsynchronousClient.cs b/l2-unity/Assets/Scripts/Networking/ClientLibrary/AsynchronousClient.cs index 6451b674e..4919a15f5 100644 --- a/l2-unity/Assets/Scripts/Networking/ClientLibrary/AsynchronousClient.cs +++ b/l2-unity/Assets/Scripts/Networking/ClientLibrary/AsynchronousClient.cs @@ -157,8 +157,6 @@ public void StartReceiving() lengthHi = stream.ReadByte(); length = (lengthHi * 256) + lengthLo; - Debug.LogWarning(length); - if (lengthHi == -1 || !_connected) { Debug.Log("Server terminated the connection."); diff --git a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/ClientPacket.cs b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/ClientPacket.cs index a4c0be033..7c3167682 100644 --- a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/ClientPacket.cs +++ b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/ClientPacket.cs @@ -34,7 +34,6 @@ protected void WriteS(String s) if (s != null) { byte[] d = Encoding.GetEncoding("UTF-16LE").GetBytes(s); - UnityEngine.Debug.Log(StringUtils.ByteArrayToString(d)); _buffer.AddRange(d); WriteB((byte)0); WriteB((byte)0); diff --git a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ClientPackets/Auth/EnterWorldPacket.cs b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ClientPackets/Auth/EnterWorldPacket.cs new file mode 100644 index 000000000..39c92a8fc --- /dev/null +++ b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ClientPackets/Auth/EnterWorldPacket.cs @@ -0,0 +1,7 @@ +public class EnterWorldPacket : ClientPacket +{ + public EnterWorldPacket() : base((byte)GameClientPacketType.EnterWorld) + { + BuildPacket(); + } +} \ No newline at end of file diff --git a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ClientPackets/Auth/LoadWorldPacket.cs.meta b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ClientPackets/Auth/EnterWorldPacket.cs.meta similarity index 100% rename from l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ClientPackets/Auth/LoadWorldPacket.cs.meta rename to l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ClientPackets/Auth/EnterWorldPacket.cs.meta diff --git a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ClientPackets/Auth/LoadWorldPacket.cs b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ClientPackets/Auth/LoadWorldPacket.cs deleted file mode 100644 index f0cccb553..000000000 --- a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ClientPackets/Auth/LoadWorldPacket.cs +++ /dev/null @@ -1,6 +0,0 @@ -public class LoadWorldPacket : ClientPacket { - public LoadWorldPacket() : base((byte)GameClientPacketType.LoadWorld) { - SetData(new byte[] { (byte)GameClientPacketType.LoadWorld, 0x02}); - BuildPacket(); - } -} \ No newline at end of file diff --git a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ClientPackets/Auth/RequestCharSelectPacket.cs b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ClientPackets/Auth/RequestCharSelectPacket.cs index 6334f9750..62faa2f22 100644 --- a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ClientPackets/Auth/RequestCharSelectPacket.cs +++ b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ClientPackets/Auth/RequestCharSelectPacket.cs @@ -1,6 +1,14 @@ -public class RequestCharSelectPacket : ClientPacket { - public RequestCharSelectPacket(int slot) : base((byte)GameClientPacketType.RequestCharSelect) { +public class RequestCharSelectPacket : ClientPacket +{ + public RequestCharSelectPacket(int slot) : base((byte)GameClientPacketType.RequestCharSelect) + { WriteB((byte)slot); + WriteB(0); + WriteB(0); + WriteI(0); + WriteI(0); + WriteI(0); + WriteI(0); BuildPacket(); } } diff --git a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/GameClientPacketType.cs b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/GameClientPacketType.cs index ae7cea5d0..8d18eeb63 100644 --- a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/GameClientPacketType.cs +++ b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/GameClientPacketType.cs @@ -1,7 +1,7 @@ public enum GameClientPacketType : byte { ProtocolVersion = 0x00, - LoadWorld = 0x03, + EnterWorld = 0x03, AuthRequest = 0x08, Disconnect = 0x09, RequestAttack = 0x0a, diff --git a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/GameServerPacketType.cs b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/GameServerPacketType.cs index 49010e324..a203bc9f9 100644 --- a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/GameServerPacketType.cs +++ b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/GameServerPacketType.cs @@ -1,10 +1,12 @@ -public enum GameServerPacketType : byte +public enum GameServerPacketType : int { VersionCheck = 0x00, CharSelectionInfo = 0x13, LoginFail = 0x14, + CharSelected = 0x15, CharCreateOk = 0x19, CharCreateFail = 0x1a, + SystemMessage = 0x64, @@ -23,36 +25,34 @@ public enum GameServerPacketType : byte - MessagePacket = 0xF4, - SystemMessage = 0xF5, - PlayerInfo = 0xF6, - ObjectPosition = 0xF7, - RemoveObject = 0xF8, - ObjectRotation = 0xF9, - ObjectAnimation = 0xFA, - ApplyDamage = 0xFB, - NpcInfo = 0xFC, - ObjectMoveTo = 0xFD, - UserInfo = 0xFE, - ObjectMoveDirection = 0xFF, - GameTime = 0xD0, - EntitySetTarget = 0xD1, - AutoAttackStart = 0xD2, - AutoAttackStop = 0xD3, - ActionFailed = 0xD4, - ServerClose = 0xD5, - StatusUpdate = 0xD6, - ActionAllowed = 0xD7, - InventoryItemList = 0xD8, - InventoryUpdate = 0xD9, - LeaveWorld = 0xDA, - RestartReponse = 0xDB, - ShortcutInit = 0xDC, - ShortcutRegister = 0xDD, - SocialAction = 0xDE, - ChangeWaitType = 0xDF, - ChangeMoveType = 0xE0, + MessagePacket = 0xFF4, + ObjectPosition = 0xFF7, + RemoveObject = 0xFF8, + ObjectRotation = 0xFF9, + ObjectAnimation = 0xFFA, + ApplyDamage = 0xFFB, + NpcInfo = 0xFFC, + ObjectMoveTo = 0xFFD, + UserInfo = 0xFFE, + ObjectMoveDirection = 0xFFF, + GameTime = 0xFD0, + EntitySetTarget = 0xFD1, + AutoAttackStart = 0xFD2, + AutoAttackStop = 0xFD3, + ActionFailed = 0xFD4, + ServerClose = 0xFD5, + StatusUpdate = 0xFD6, + ActionAllowed = 0xFD7, + InventoryItemList = 0xFD8, + InventoryUpdate = 0xFD9, + LeaveWorld = 0xFDA, + RestartReponse = 0xFDB, + ShortcutInit = 0xFDC, + ShortcutRegister = 0xFDD, + SocialAction = 0xFDE, + ChangeWaitType = 0xFDF, + ChangeMoveType = 0xFE0, - Ping = 0xE1, + Ping = 0xFE1, } diff --git a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Auth/CharSelectedPacket.cs b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Auth/CharSelectedPacket.cs new file mode 100644 index 000000000..00ccdca2e --- /dev/null +++ b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Auth/CharSelectedPacket.cs @@ -0,0 +1,137 @@ +using UnityEngine; +using System; + +public class CharSelectedPacket : ServerPacket +{ + public struct PlayerInfo + { + public NetworkIdentity Identity { get; set; } + public PlayerStatus Status { get; set; } + public PlayerStats Stats { get; set; } + public PlayerAppearance Appearance { get; set; } + public bool Running { get; set; } + } + + private PlayerInfo _info; + public PlayerInfo PacketPlayerInfo { get { return _info; } } + + + public CharSelectedPacket(byte[] d) : base(d) + { + _info = new PlayerInfo(); + _info.Identity = new NetworkIdentity(); + _info.Status = new PlayerStatus(); + _info.Stats = new PlayerStats(); + _info.Appearance = new PlayerAppearance(); + _info.Appearance = new PlayerAppearance(); + Parse(); + } + + public override void Parse() + { + try + { + _info.Identity.Name = ReadS(); + _info.Identity.Id = ReadI(); + _info.Identity.Title = ReadS(); + ReadI(); //sessionId + ReadI(); //clanId + + ReadI(); + + _info.Appearance.Sex = (byte)ReadI(); + _info.Appearance.Race = (byte)ReadI(); + _info.Identity.PlayerClass = (byte)ReadI(); + + ReadI(); + + _info.Identity.SetPosZ(ReadI() / 52.5f); + _info.Identity.SetPosX(ReadI() / 52.5f); + _info.Identity.SetPosY(ReadI() / 52.5f); + _info.Status.Hp = (int)ReadD(); + _info.Status.Mp = (int)ReadD(); + _info.Stats.Sp = ReadI(); + _info.Stats.Exp = (int)ReadL(); + _info.Stats.Level = ReadI(); + _info.Stats.Karma = ReadI(); + _info.Stats.PkKills = ReadI(); + _info.Stats.Int = ReadB(); + _info.Stats.Str = ReadB(); + _info.Stats.Con = ReadB(); + _info.Stats.Men = ReadB(); + _info.Stats.Dex = ReadB(); + _info.Stats.Wit = ReadB(); + + for (int i = 0; i < 30; i++) + { + ReadI(); + } + + ReadI(); + ReadI(); + + ReadI(); //Game time + + ReadI(); + + _info.Identity.PlayerClass = (byte)ReadI(); + _info.Identity.IsMage = CharacterClassParser.IsMage((CharacterClass)_info.Identity.PlayerClass); + // _info.Identity.Heading = ReadF(); + _info.Identity.Owned = true; + + ReadI(); + ReadI(); + ReadI(); + ReadI(); + + + // // Status + // _info.Stats.MaxHp = ReadI(); + // _info.Stats.MaxMp = ReadI(); + // _info.Status.Cp = ReadI(); + // _info.Stats.MaxCp = ReadI(); + // // Combat + // _info.Stats.RunSpeed = ReadI(); + // _info.Stats.WalkSpeed = ReadI(); + // _info.Stats.PAtkSpd = ReadI(); + // _info.Stats.MAtkSpd = ReadI(); + // _info.Stats.AttackRange = ReadF(); + // _info.Stats.PAtk = ReadI(); + // _info.Stats.PDef = ReadI(); + // _info.Stats.PEvasion = ReadI(); + // _info.Stats.PAccuracy = ReadI(); + // _info.Stats.MEvasion = ReadI(); + // _info.Stats.MAccuracy = ReadI(); + // _info.Stats.PCritical = ReadI(); + // _info.Stats.MCritical = ReadI(); + // _info.Stats.MAtk = ReadI(); + // _info.Stats.MDef = ReadI(); + // // Stats + // _info.Stats.MaxExp = ReadI(); + // _info.Stats.CurrWeight = ReadI(); + // _info.Stats.MaxWeight = ReadI(); + // // Social + // _info.Stats.PvpKills = ReadI(); + // _info.Status.PvpFlag = ReadL(); + // // Appearance + // _info.Appearance.CollisionHeight = ReadF(); + // _info.Appearance.CollisionRadius = ReadF(); + // _info.Appearance.Face = ReadB(); + // _info.Appearance.HairStyle = ReadB(); + // _info.Appearance.HairColor = ReadB(); + // // Gear + // _info.Appearance.LHand = ReadI(); + // _info.Appearance.RHand = ReadI(); + // _info.Appearance.Chest = ReadI(); + // _info.Appearance.Legs = ReadI(); + // _info.Appearance.Gloves = ReadI(); + // _info.Appearance.Feet = ReadI(); + + // _info.Running = ReadI() == 1; + } + catch (Exception e) + { + Debug.LogError(e); + } + } +} \ No newline at end of file diff --git a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/PlayerInfoPacket.cs.meta b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Auth/CharSelectedPacket.cs.meta similarity index 100% rename from l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/PlayerInfoPacket.cs.meta rename to l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Auth/CharSelectedPacket.cs.meta diff --git a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Auth/CharSelectionInfoPacket.cs b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Auth/CharSelectionInfoPacket.cs index 87a12a70b..6938bcfee 100644 --- a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Auth/CharSelectionInfoPacket.cs +++ b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Auth/CharSelectionInfoPacket.cs @@ -50,9 +50,9 @@ public override void Parse() ReadI(); - float y = ReadI() / 52.5f; float z = ReadI() / 52.5f; float x = ReadI() / 52.5f; + float y = ReadI() / 52.5f; character.Position = new Vector3(x, y, z); diff --git a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Auth/VersionCheckPacket.cs b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Auth/VersionCheckPacket.cs index 36b0ca436..48c9048dd 100644 --- a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Auth/VersionCheckPacket.cs +++ b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/Auth/VersionCheckPacket.cs @@ -15,9 +15,5 @@ public override void Parse() BlowFishKey = ReadB(8); UseBlowfishCipher = ReadI() == 1; AuthAllowed = ReadI() == 1; - - UnityEngine.Debug.Log($"Blowfish key: [{8}]: {StringUtils.ByteArrayToString(BlowFishKey)}"); - UnityEngine.Debug.Log($"UseBlowfishCipher: [{AuthAllowed}]"); - UnityEngine.Debug.Log($"AuthAllowed: [{AuthAllowed}]"); } } diff --git a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/PlayerInfoPacket.cs b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/PlayerInfoPacket.cs deleted file mode 100644 index c62a78a03..000000000 --- a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/PlayerInfoPacket.cs +++ /dev/null @@ -1,107 +0,0 @@ -using UnityEngine; -using System; - -public class PlayerInfoPacket : ServerPacket -{ - public struct PlayerInfo - { - public NetworkIdentity Identity { get; set; } - public PlayerStatus Status { get; set; } - public PlayerStats Stats { get; set; } - public PlayerAppearance Appearance { get; set; } - public bool Running { get; set; } - } - - private PlayerInfo _info; - public PlayerInfo PacketPlayerInfo { get { return _info; } } - - - public PlayerInfoPacket(byte[] d) : base(d) - { - _info = new PlayerInfo(); - _info.Identity = new NetworkIdentity(); - _info.Status = new PlayerStatus(); - _info.Stats = new PlayerStats(); - _info.Appearance = new PlayerAppearance(); - _info.Appearance = new PlayerAppearance(); - Parse(); - } - - public override void Parse() - { - try - { - _info.Identity.Id = ReadI(); - _info.Identity.Name = ReadS(); - _info.Identity.PlayerClass = ReadB(); - _info.Identity.IsMage = ReadB() == 1; - _info.Identity.Heading = ReadF(); - _info.Identity.SetPosX(ReadF()); - _info.Identity.SetPosY(ReadF()); - _info.Identity.SetPosZ(ReadF()); - _info.Identity.Owned = true; - // Status - _info.Stats.Level = ReadI(); - _info.Status.Hp = ReadI(); - _info.Stats.MaxHp = ReadI(); - _info.Status.Mp = ReadI(); - _info.Stats.MaxMp = ReadI(); - _info.Status.Cp = ReadI(); - _info.Stats.MaxCp = ReadI(); - // Combat - _info.Stats.RunSpeed = ReadI(); - _info.Stats.WalkSpeed = ReadI(); - _info.Stats.PAtkSpd = ReadI(); - _info.Stats.MAtkSpd = ReadI(); - _info.Stats.AttackRange = ReadF(); - _info.Stats.PAtk = ReadI(); - _info.Stats.PDef = ReadI(); - _info.Stats.PEvasion = ReadI(); - _info.Stats.PAccuracy = ReadI(); - _info.Stats.MEvasion = ReadI(); - _info.Stats.MAccuracy = ReadI(); - _info.Stats.PCritical = ReadI(); - _info.Stats.MCritical = ReadI(); - _info.Stats.MAtk = ReadI(); - _info.Stats.MDef = ReadI(); - // Stats - _info.Stats.Con = ReadB(); - _info.Stats.Dex = ReadB(); - _info.Stats.Str = ReadB(); - _info.Stats.Men = ReadB(); - _info.Stats.Wit = ReadB(); - _info.Stats.Int = ReadB(); - _info.Stats.Sp = ReadI(); - _info.Stats.Exp = ReadI(); - _info.Stats.MaxExp = ReadI(); - _info.Stats.CurrWeight = ReadI(); - _info.Stats.MaxWeight = ReadI(); - // Social - _info.Stats.PkKills = ReadI(); - _info.Stats.PvpKills = ReadI(); - _info.Status.PvpFlag = ReadL(); - _info.Stats.Karma = ReadI(); - // Appearance - _info.Appearance.CollisionHeight = ReadF(); - _info.Appearance.CollisionRadius = ReadF(); - _info.Appearance.Race = ReadB(); - _info.Appearance.Sex = ReadB(); - _info.Appearance.Face = ReadB(); - _info.Appearance.HairStyle = ReadB(); - _info.Appearance.HairColor = ReadB(); - // Gear - _info.Appearance.LHand = ReadI(); - _info.Appearance.RHand = ReadI(); - _info.Appearance.Chest = ReadI(); - _info.Appearance.Legs = ReadI(); - _info.Appearance.Gloves = ReadI(); - _info.Appearance.Feet = ReadI(); - - _info.Running = ReadI() == 1; - } - catch (Exception e) - { - Debug.LogError(e); - } - } -} \ No newline at end of file diff --git a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/SystemMessagePacket.cs b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/SystemMessagePacket.cs index 9cfac5828..4934eac64 100644 --- a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/SystemMessagePacket.cs +++ b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/Gameserver/ServerPackets/SystemMessagePacket.cs @@ -21,14 +21,14 @@ public override void Parse() { _smId = ReadI(); - byte paramCount = ReadB(); + int paramCount = ReadI(); _params = new SMParam[paramCount]; for (int i = 0; i < paramCount; i++) { - byte paramType = ReadB(); + byte paramType = (byte)ReadI(); SMParam param = new SMParam((SMParamType)paramType); @@ -39,8 +39,6 @@ public override void Parse() param.SetValue(ReadS()); break; case SMParamType.TYPE_LONG_NUMBER: - param.SetValue(ReadL()); - break; case SMParamType.TYPE_ITEM_NAME: case SMParamType.TYPE_CASTLE_NAME: case SMParamType.TYPE_INT_NUMBER: @@ -54,14 +52,14 @@ public override void Parse() case SMParamType.TYPE_SKILL_NAME: int[] array = new int[2]; array[0] = ReadI(); // SkillId - array[1] = ReadI(); ; // SkillLevel + array[1] = ReadI(); // SkillLevel param.SetValue(array); break; case SMParamType.TYPE_ZONE_NAME: float[] array2 = new float[3]; - array2[0] = ReadF(); // x - array2[1] = ReadF(); // y - array2[2] = ReadF(); // z + array2[0] = ReadI(); // x + array2[1] = ReadI(); // y + array2[2] = ReadI(); // z param.SetValue(array2); break; } diff --git a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/ServerPacket.cs b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/ServerPacket.cs index 4673b1095..aaf669df3 100644 --- a/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/ServerPacket.cs +++ b/l2-unity/Assets/Scripts/Networking/ClientLibrary/Packet/ServerPacket.cs @@ -63,9 +63,6 @@ protected virtual double ReadD() Array.Copy(_packetData, _iterator, data, 0, 8); // Array.Reverse(data); double value = BitConverter.ToDouble(data, 0); - Debug.Log("DOUBLE ARRAY: " + StringUtils.ByteArrayToString(data)); - Debug.Log("IT INDEX: " + _iterator); - Debug.Log("DOUBLE VALUE: " + value); _iterator += 8; return value; } diff --git a/l2-unity/Assets/Scripts/Networking/ClientLibrary/PacketHandler/Gameserver/GameClientPacketHandler.cs b/l2-unity/Assets/Scripts/Networking/ClientLibrary/PacketHandler/Gameserver/GameClientPacketHandler.cs index 695544080..8a5b3aef2 100644 --- a/l2-unity/Assets/Scripts/Networking/ClientLibrary/PacketHandler/Gameserver/GameClientPacketHandler.cs +++ b/l2-unity/Assets/Scripts/Networking/ClientLibrary/PacketHandler/Gameserver/GameClientPacketHandler.cs @@ -57,7 +57,7 @@ public void UpdatePosition(Vector3 position) public void SendLoadWorld() { - LoadWorldPacket packet = new LoadWorldPacket(); + EnterWorldPacket packet = new EnterWorldPacket(); SendPacket(packet); } diff --git a/l2-unity/Assets/Scripts/Networking/ClientLibrary/PacketHandler/Gameserver/GameServerPacketHandler.cs b/l2-unity/Assets/Scripts/Networking/ClientLibrary/PacketHandler/Gameserver/GameServerPacketHandler.cs index e2d57144b..754087919 100644 --- a/l2-unity/Assets/Scripts/Networking/ClientLibrary/PacketHandler/Gameserver/GameServerPacketHandler.cs +++ b/l2-unity/Assets/Scripts/Networking/ClientLibrary/PacketHandler/Gameserver/GameServerPacketHandler.cs @@ -33,7 +33,7 @@ public override void HandlePacket(byte[] data) case GameServerPacketType.SystemMessage: OnSystemMessageReceive(data); break; - case GameServerPacketType.PlayerInfo: + case GameServerPacketType.CharSelected: OnPlayerInfoReceive(data); break; case GameServerPacketType.ObjectPosition: @@ -117,6 +117,9 @@ public override void HandlePacket(byte[] data) case GameServerPacketType.CharCreateFail: OnCharCreateFail(data); break; + default: + Debug.LogWarning($"Received unhandled packet with OPCode [{packetType}]."); + break; } } @@ -168,7 +171,6 @@ private void OnPingReceive() private void OnKeyReceive(byte[] data) { - Debug.LogWarning("Onkeyreceive"); VersionCheckPacket packet = new VersionCheckPacket(data); if (!packet.AuthAllowed) @@ -265,7 +267,7 @@ private void OnSystemMessageReceive(byte[] data) private void OnPlayerInfoReceive(byte[] data) { - PlayerInfoPacket packet = new PlayerInfoPacket(data); + CharSelectedPacket packet = new CharSelectedPacket(data); if (GameManager.Instance.GameState != GameState.IN_GAME) { _eventProcessor.QueueEvent(() => diff --git a/l2-unity/Assets/Scripts/Networking/GameClient.cs b/l2-unity/Assets/Scripts/Networking/GameClient.cs index af26fed66..6af09cdd9 100644 --- a/l2-unity/Assets/Scripts/Networking/GameClient.cs +++ b/l2-unity/Assets/Scripts/Networking/GameClient.cs @@ -1,6 +1,6 @@ using UnityEngine; using L2_login; -using static PlayerInfoPacket; +using static CharSelectedPacket; using System; public class GameClient : DefaultClient