diff --git a/Server/Client.cs b/Server/Client.cs index 455820e..4b85e69 100644 --- a/Server/Client.cs +++ b/Server/Client.cs @@ -41,7 +41,7 @@ namespace PSO2SERVER public bool IsClosed { get; private set; } public SocketClient Socket { get; private set; } // Game properties, TODO Consider moving these somewhere else - public Player User { get; set; } + public Account _account { get; set; } public Character Character { get; set; } //public Zone.Zone CurrentZone { get; set; } public Map CurrentZone; @@ -240,7 +240,8 @@ namespace PSO2SERVER { // Check for and create packets directory if it doesn't exist var packetPath = string.Format( - "packets/{0}" + "packets/0x{0:X2}-0x{1:X2}/{2}" + , typeA, typeB , _server.StartTime.ToShortDateString().Replace('/', '-') ); @@ -272,9 +273,11 @@ namespace PSO2SERVER { // Check for and create packets directory if it doesn't exist var packetPath = string.Format( - "UnkClientPackets/{0}" + "UnkClientPackets/0x{0:X2}-0x{1:X2}/{2}" + , typeA, typeB , _server.StartTime.ToShortDateString().Replace('/', '-') ); + if (!Directory.Exists(packetPath)) Directory.CreateDirectory(packetPath); diff --git a/Server/ConsoleSystem.cs b/Server/ConsoleSystem.cs index e0fc59b..40b04ce 100644 --- a/Server/ConsoleSystem.cs +++ b/Server/ConsoleSystem.cs @@ -277,7 +277,7 @@ namespace PSO2SERVER // SpawnClone var spawnClone = new ConsoleCommand(SpawnClone, "spawnclone"); spawnClone.Arguments.Add(new ConsoleCommandArgument("Username", false)); - spawnClone.Arguments.Add(new ConsoleCommandArgument("Player Name", false)); + spawnClone.Arguments.Add(new ConsoleCommandArgument("Account Name", false)); spawnClone.Arguments.Add(new ConsoleCommandArgument("X", false)); spawnClone.Arguments.Add(new ConsoleCommandArgument("Y", false)); spawnClone.Arguments.Add(new ConsoleCommandArgument("Z", false)); @@ -653,7 +653,7 @@ namespace PSO2SERVER // This is probably not the right way to do this ServerApp.Instance.Server.Clients[i].Socket.Close(); Logger.WriteCommand(client, - "[CMD] Logged out user " + ServerApp.Instance.Server.Clients[i].User.Username); + "[CMD] Logged out user " + ServerApp.Instance.Server.Clients[i]._account.Username); } Logger.WriteCommand(client, "[CMD] Logged out all players successfully"); @@ -695,17 +695,17 @@ namespace PSO2SERVER if (z == 0) z = 134.375f; - var fakePlayer = new Player + var fakePlayer = new Account { Username = name, Nickname = playerName, - PlayerId = (12345678 + new Random().Next()) + AccountId = (12345678 + new Random().Next()) }; var fakeChar = new Character { Character_ID = 12345678 + new Random().Next(), - Player = fakePlayer, + Account = fakePlayer, Name = playerName, Looks = client.Character.Looks, Jobs = client.Character.Jobs @@ -878,7 +878,7 @@ namespace PSO2SERVER var id = 0; if (client != null) { - id = client.User.PlayerId; + id = client._account.AccountId; foundPlayer = true; } else @@ -912,7 +912,7 @@ namespace PSO2SERVER var id = 0; if (client != null) { - id = client.User.PlayerId; + id = client._account.AccountId; foundPlayer = true; } else diff --git a/Server/Database/ServerEf.cs b/Server/Database/ServerEf.cs index 9fb60d4..4028c41 100644 --- a/Server/Database/ServerEf.cs +++ b/Server/Database/ServerEf.cs @@ -35,7 +35,20 @@ namespace PSO2SERVER.Database public float PosZ { get; set; } } - public class Player + public class Account + { + [Key] + public int AccountId { get; set; } + + public string Username { get; set; } + public string Password { get; set; } + public string Nickname { get; set; } + public string SettingsIni { get; set; } + public string Cpu_Info { get; set; } + public string Video_Info { get; set; } + } + + public class PlayerSystemInfo { [Key] public int PlayerId { get; set; } @@ -90,7 +103,7 @@ namespace PSO2SERVER.Database public class ServerEf : DbContext { public DbSet ServerInfos { get; set; } - public DbSet Players { get; set; } + public DbSet Account { get; set; } public DbSet Characters { get; set; } public DbSet Teleports { get; set; } public DbSet NPCs { get; set; } @@ -126,7 +139,7 @@ namespace PSO2SERVER.Database ServerInfos.Add(revision); //TODO Possibly move this somewhere else? - Database.ExecuteSqlCommand("ALTER TABLE Players AUTO_INCREMENT=10000000"); + Database.ExecuteSqlCommand("ALTER TABLE Account AUTO_INCREMENT=10000000"); } SaveChanges(); diff --git a/Server/Helper.cs b/Server/Helper.cs index 4782a94..349c432 100644 --- a/Server/Helper.cs +++ b/Server/Helper.cs @@ -49,7 +49,7 @@ namespace PSO2SERVER public static int FindPlayerByUsername(string name) { for (var i = 0; i < ServerApp.Instance.Server.Clients.Count; i++) - if (name.ToLower() == ServerApp.Instance.Server.Clients[i].User.Username.ToLower()) + if (name.ToLower() == ServerApp.Instance.Server.Clients[i]._account.Username.ToLower()) return i; return -1; diff --git a/Server/Models/Character.cs b/Server/Models/Character.cs index bf4184c..644b070 100644 --- a/Server/Models/Character.cs +++ b/Server/Models/Character.cs @@ -309,7 +309,7 @@ namespace PSO2SERVER.Models public string Unk4 { get; set; } - public virtual Player Player { get; set; } + public virtual Account Account { get; set; } } diff --git a/Server/Packets/Handlers/03-ServerHandler/03-03-InitialLoad.cs b/Server/Packets/Handlers/03-ServerHandler/03-03-InitialLoad.cs index 0a5ef10..e5feaa3 100644 --- a/Server/Packets/Handlers/03-ServerHandler/03-03-InitialLoad.cs +++ b/Server/Packets/Handlers/03-ServerHandler/03-03-InitialLoad.cs @@ -31,13 +31,13 @@ namespace PSO2SERVER.Packets.Handlers public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) { - // Set Player ID + // Set Account ID //var setPlayerId = new PacketWriter(); - //setPlayerId.WritePlayerHeader((uint)context.User.PlayerId); + //setPlayerId.WritePlayerHeader((uint)context._account.AccountId); //context.SendPacket(0x06, 0x00, 0, setPlayerId.ToArray()); - context.SendPacket(new SetPlayerIDPacket(context.User.PlayerId)); + context.SendPacket(new SetPlayerIDPacket(context._account.AccountId)); - // Spawn Player + // Spawn Account new CharacterSpawn().HandlePacket(context, flags, data, position, size); } diff --git a/Server/Packets/Handlers/03-ServerHandler/03-0C-PingResponse.cs b/Server/Packets/Handlers/03-ServerHandler/03-0C-ServerPong.cs similarity index 87% rename from Server/Packets/Handlers/03-ServerHandler/03-0C-PingResponse.cs rename to Server/Packets/Handlers/03-ServerHandler/03-0C-ServerPong.cs index 1ca8130..bc7df78 100644 --- a/Server/Packets/Handlers/03-ServerHandler/03-0C-PingResponse.cs +++ b/Server/Packets/Handlers/03-ServerHandler/03-0C-ServerPong.cs @@ -6,13 +6,13 @@ using PSO2SERVER.Database; namespace PSO2SERVER.Packets.Handlers { [PacketHandlerAttr(0x03, 0x0C)] - public class PingResponse : PacketHandler + public class ServerPong : PacketHandler { #region implemented abstract members of PacketHandler public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) { - Logger.Write("[HI!] 收到 {0} Ping回应 ", context.User.Username); + Logger.Write("[HI!] 收到 {0} Ping回应 ", context._account.Username); } #endregion diff --git a/Server/Packets/Handlers/03-ServerHandler/03-10-MapLoaded.cs b/Server/Packets/Handlers/03-ServerHandler/03-10-MapLoaded.cs index e4acad2..842075a 100644 --- a/Server/Packets/Handlers/03-ServerHandler/03-10-MapLoaded.cs +++ b/Server/Packets/Handlers/03-ServerHandler/03-10-MapLoaded.cs @@ -34,7 +34,7 @@ namespace PSO2SERVER.Packets.Handlers public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) { - if (context.User == null || context.Character == null) + if (context._account == null || context.Character == null) return; context.SendPacket(new LoadingScreenRemovePacket()); diff --git a/Server/Packets/Handlers/03-ServerHandler/03-12-CampshipTeleport.cs b/Server/Packets/Handlers/03-ServerHandler/03-12-CampshipTeleport.cs index 09672e7..dbefa7e 100644 --- a/Server/Packets/Handlers/03-ServerHandler/03-12-CampshipTeleport.cs +++ b/Server/Packets/Handlers/03-ServerHandler/03-12-CampshipTeleport.cs @@ -15,7 +15,7 @@ namespace PSO2SERVER.Packets.Handlers if (context.currentParty.currentQuest == null) return; - var instanceName = String.Format("{0}-{1}", context.currentParty.currentQuest.name, context.User.Nickname); + var instanceName = String.Format("{0}-{1}", context.currentParty.currentQuest.name, context._account.Nickname); ZoneManager.Instance.NewInstance(instanceName, new Map("campship", 150, 0, Map.MapType.Campship, 0)); // todo: add next map ZoneManager.Instance.AddMapToInstance(instanceName, new Map("area1", 311, -1, Map.MapType.Other, (Map.MapFlags)0x6) { GenerationArgs = new Map.GenParam((uint)new Random().Next(), 2, 3)}); diff --git a/Server/Packets/Handlers/03-ServerHandler/03-16-CampshipTeleportDown.cs b/Server/Packets/Handlers/03-ServerHandler/03-16-CampshipTeleportDown.cs index 5785fd9..2a5da47 100644 --- a/Server/Packets/Handlers/03-ServerHandler/03-16-CampshipTeleportDown.cs +++ b/Server/Packets/Handlers/03-ServerHandler/03-16-CampshipTeleportDown.cs @@ -18,7 +18,7 @@ namespace PSO2SERVER.Packets.Handlers // TODO: WTF terribad hax? if (context.CurrentLocation.PosZ >= 20) { - var instanceName = String.Format("{0}-{1}", context.currentParty.currentQuest.name, context.User.Nickname); + var instanceName = String.Format("{0}-{1}", context.currentParty.currentQuest.name, context._account.Nickname); Map forest = ZoneManager.Instance.MapFromInstance("area1", instanceName); forest.SpawnClient(context, new PSOLocation(0, 1, 0, -0, -37, 0.314f, 145.5f)); diff --git a/Server/Packets/Handlers/03-ServerHandler/03-35-TeleportLobbyToCasino.cs b/Server/Packets/Handlers/03-ServerHandler/03-35-TeleportLobbyToCasino.cs index dcd3422..d2049c7 100644 --- a/Server/Packets/Handlers/03-ServerHandler/03-35-TeleportLobbyToCasino.cs +++ b/Server/Packets/Handlers/03-ServerHandler/03-35-TeleportLobbyToCasino.cs @@ -15,11 +15,11 @@ namespace PSO2SERVER.Packets.Handlers /// (0x03, 0x35) Move Lobby -> Casino. public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) { - if (context.User == null) + if (context._account == null) return; // Dunno what these are yet. - context.SendPacket(0x11, 0xA, 0x0, BitConverter.GetBytes(context.User.PlayerId)); + context.SendPacket(0x11, 0xA, 0x0, BitConverter.GetBytes(context._account.AccountId)); context.SendPacket(0x1E, 0xC, 0x0, BitConverter.GetBytes(101)); Map casinoMap = ZoneManager.Instance.MapFromInstance("casino", "lobby"); diff --git a/Server/Packets/Handlers/03-ServerHandler/03-39-TeleportLobbyToBridge.cs b/Server/Packets/Handlers/03-ServerHandler/03-39-TeleportLobbyToBridge.cs index 9aee467..8038f61 100644 --- a/Server/Packets/Handlers/03-ServerHandler/03-39-TeleportLobbyToBridge.cs +++ b/Server/Packets/Handlers/03-ServerHandler/03-39-TeleportLobbyToBridge.cs @@ -15,11 +15,11 @@ namespace PSO2SERVER.Packets.Handlers /// (0x03, 0x39) Move Lobby -> Bridge. public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) { - if (context.User == null) + if (context._account == null) return; // Dunno what these are yet. - context.SendPacket(0x11, 0xA, 0x0, BitConverter.GetBytes(context.User.PlayerId)); + context.SendPacket(0x11, 0xA, 0x0, BitConverter.GetBytes(context._account.AccountId)); context.SendPacket(0x1E, 0xC, 0x0, BitConverter.GetBytes(101)); Map bridgeMap = ZoneManager.Instance.MapFromInstance("bridge", "lobby"); diff --git a/Server/Packets/Handlers/03-ServerHandler/03-3C-TeleportLobbyToCafe.cs b/Server/Packets/Handlers/03-ServerHandler/03-3C-TeleportLobbyToCafe.cs index 3632645..a106350 100644 --- a/Server/Packets/Handlers/03-ServerHandler/03-3C-TeleportLobbyToCafe.cs +++ b/Server/Packets/Handlers/03-ServerHandler/03-3C-TeleportLobbyToCafe.cs @@ -15,11 +15,11 @@ namespace PSO2SERVER.Packets.Handlers /// (0x03, 0x3C) Move Lobby -> Cafe. public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) { - if (context.User == null) + if (context._account == null) return; // Dunno what these are yet. - context.SendPacket(0x11, 0xA, 0x0, BitConverter.GetBytes(context.User.PlayerId)); + context.SendPacket(0x11, 0xA, 0x0, BitConverter.GetBytes(context._account.AccountId)); context.SendPacket(0x1E, 0xC, 0x0, BitConverter.GetBytes(101)); Map dstMap = ZoneManager.Instance.MapFromInstance("cafe", "lobby"); diff --git a/Server/Packets/Handlers/04-ObjectHandler/04-08-MovementActionHandler.cs b/Server/Packets/Handlers/04-ObjectHandler/04-08-MovementActionHandler.cs index 9fc15e7..1cd999c 100644 --- a/Server/Packets/Handlers/04-ObjectHandler/04-08-MovementActionHandler.cs +++ b/Server/Packets/Handlers/04-ObjectHandler/04-08-MovementActionHandler.cs @@ -37,7 +37,7 @@ namespace PSO2SERVER.Packets.Handlers if (c == context || c.Character == null || c.CurrentZone != context.CurrentZone) continue; //PacketWriter output = new PacketWriter(); - //output.WriteStruct(new ObjectHeader((uint)context.User.PlayerId, EntityType.Player)); + //output.WriteStruct(new ObjectHeader((uint)context._account.AccountId, EntityType.Account)); //output.WriteStruct(preformer); //output.Write(preData); //output.WriteAscii(command, 0x4315, 0x7A); @@ -48,7 +48,7 @@ namespace PSO2SERVER.Packets.Handlers //c.SendPacket(0x4, 0x80, 0x44, output.ToArray()); - c.SendPacket(new MovementActionServerPacket(context.User.PlayerId, preformer, preData + c.SendPacket(new MovementActionServerPacket(context._account.AccountId, preformer, preData , command, rest, thingCount, things, final)); } } diff --git a/Server/Packets/Handlers/04-ObjectHandler/04-13-UNK.cs b/Server/Packets/Handlers/04-ObjectHandler/04-13-UNK.cs index 2bf28f1..c637406 100644 --- a/Server/Packets/Handlers/04-ObjectHandler/04-13-UNK.cs +++ b/Server/Packets/Handlers/04-ObjectHandler/04-13-UNK.cs @@ -18,7 +18,7 @@ namespace PSO2SERVER.Packets.Handlers // //// TODO: WTF terribad hax? // //if (context.CurrentLocation.PosZ >= 20) // //{ - // // var instanceName = String.Format("{0}-{1}", context.currentParty.currentQuest.name, context.User.Nickname); + // // var instanceName = String.Format("{0}-{1}", context.currentParty.currentQuest.name, context._account.Nickname); // // Map forest = ZoneManager.Instance.MapFromInstance("area1", instanceName); // // forest.SpawnClient(context, new PSOLocation(0, 1, 0, -0, -37, 0.314f, 145.5f)); diff --git a/Server/Packets/Handlers/04-ObjectHandler/04-14-ObjectInteract.cs b/Server/Packets/Handlers/04-ObjectHandler/04-14-ObjectInteract.cs index 35aca05..4547e84 100644 --- a/Server/Packets/Handlers/04-ObjectHandler/04-14-ObjectInteract.cs +++ b/Server/Packets/Handlers/04-ObjectHandler/04-14-ObjectInteract.cs @@ -31,7 +31,7 @@ namespace PSO2SERVER.Packets.Handlers srcObj = new PSOObject { Header = srcObject, - Name = "Player" + Name = "Account" }; } else @@ -53,7 +53,7 @@ namespace PSO2SERVER.Packets.Handlers if (teleporterEndpoint == null) { Logger.WriteError("[OBJ] Teleporter for {0} in {1} does not contain a destination!", srcObj.Header.ID, "lobby"); - // Teleport Player to default point + // Teleport Account to default point context.SendPacket(new TeleportTransferPacket(srcObj, new PSOLocation(0f, 1f, 0f, -0.000031f, -0.417969f, 0.000031f, 134.375f))); // Unhide player context.SendPacket(new ObjectActionPacket(dstObject, srcObject, new ObjectHeader(), new ObjectHeader(), "Forwarded")); @@ -70,7 +70,7 @@ namespace PSO2SERVER.Packets.Handlers PosY = teleporterEndpoint.PosY, PosZ = teleporterEndpoint.PosZ, }; - // Teleport Player + // Teleport Account context.SendPacket(new TeleportTransferPacket(srcObj, endpointLocation)); // Unhide player context.SendPacket(new ObjectActionPacket(dstObject, srcObject, new ObjectHeader(), new ObjectHeader(), "Forwarded")); @@ -80,9 +80,9 @@ namespace PSO2SERVER.Packets.Handlers if (command == "READY") { - context.SendPacket(new ObjectActionPacket(new ObjectHeader((uint)context.User.PlayerId, EntityType.Player), srcObj.Header, srcObj.Header, + context.SendPacket(new ObjectActionPacket(new ObjectHeader((uint)context._account.AccountId, EntityType.Player), srcObj.Header, srcObj.Header, new ObjectHeader(), "FavsNeutral")); - context.SendPacket(new ObjectActionPacket(new ObjectHeader((uint)context.User.PlayerId, EntityType.Player), srcObj.Header, srcObj.Header, + context.SendPacket(new ObjectActionPacket(new ObjectHeader((uint)context._account.AccountId, EntityType.Player), srcObj.Header, srcObj.Header, new ObjectHeader(), "AP")); // Short for Appear, Thanks Zapero! } @@ -93,7 +93,7 @@ namespace PSO2SERVER.Packets.Handlers if (client.Character == null || client == context) continue; - client.SendPacket(new ObjectActionPacket(new ObjectHeader((uint)client.User.PlayerId, EntityType.Player), srcObj.Header, + client.SendPacket(new ObjectActionPacket(new ObjectHeader((uint)client._account.AccountId, EntityType.Player), srcObj.Header, new ObjectHeader(dstObject.ID, EntityType.Player), new ObjectHeader(), "SitSuccess")); } } diff --git a/Server/Packets/Handlers/04-ObjectHandler/04-3C-ActionUpdateHandler.cs b/Server/Packets/Handlers/04-ObjectHandler/04-3C-ActionUpdateHandler.cs index 13d743d..709f39a 100644 --- a/Server/Packets/Handlers/04-ObjectHandler/04-3C-ActionUpdateHandler.cs +++ b/Server/Packets/Handlers/04-ObjectHandler/04-3C-ActionUpdateHandler.cs @@ -23,12 +23,12 @@ namespace PSO2SERVER.Packets.Handlers if (c == context || c.Character == null || c.CurrentZone != context.CurrentZone) continue; //PacketWriter writer = new PacketWriter(); - //writer.WriteStruct(new ObjectHeader((uint)c.User.PlayerId, EntityType.Player)); + //writer.WriteStruct(new ObjectHeader((uint)c._account.AccountId, EntityType.Account)); //writer.WriteStruct(actor); //writer.Write(rest); //c.SendPacket(0x4, 0x81, 0x40, writer.ToArray()); - c.SendPacket(new ActionUpdateServerPacket(c.User.PlayerId, actor, rest)); + c.SendPacket(new ActionUpdateServerPacket(c._account.AccountId, actor, rest)); } } diff --git a/Server/Packets/Handlers/07-ChatHandler/07-00-ChatHandler.cs b/Server/Packets/Handlers/07-ChatHandler/07-00-ChatHandler.cs index 6a9337c..9e3eb76 100644 --- a/Server/Packets/Handlers/07-ChatHandler/07-00-ChatHandler.cs +++ b/Server/Packets/Handlers/07-ChatHandler/07-00-ChatHandler.cs @@ -36,7 +36,7 @@ namespace PSO2SERVER.Packets.Handlers { command.Run(args, args.Length, full, context); valid = true; - Logger.WriteCommand(null, "[CMD] {0} 发送指令 {1}", context.User.Username, full); + Logger.WriteCommand(null, "[CMD] {0} 发送指令 {1}", context._account.Username, full); } if (valid) @@ -51,7 +51,7 @@ namespace PSO2SERVER.Packets.Handlers Logger.Write("[CHT] <{0}> 频道{1}说 {2}", context.Character.Name, channel, message); var writer = new PacketWriter(); - writer.WritePlayerHeader((uint) context.User.PlayerId); + writer.WritePlayerHeader((uint) context._account.AccountId); writer.Write(channel); writer.WriteUtf16(message, 0x9D3F, 0x44); diff --git a/Server/Packets/Handlers/0E-PartyHandler/0E-0C-QuestCounterHandler.cs b/Server/Packets/Handlers/0E-PartyHandler/0E-0C-QuestCounterHandler.cs index 69943ff..7d69476 100644 --- a/Server/Packets/Handlers/0E-PartyHandler/0E-0C-QuestCounterHandler.cs +++ b/Server/Packets/Handlers/0E-PartyHandler/0E-0C-QuestCounterHandler.cs @@ -41,7 +41,7 @@ namespace PSO2SERVER.Packets.Handlers questDef = def }; context.currentParty.currentQuest = quest; - context.SendPacket(new SetQuestInfoPacket(def, context.User)); + context.SendPacket(new SetQuestInfoPacket(def, context._account)); context.SendPacket(new QuestStartPacket(def, diff)); } diff --git a/Server/Packets/Handlers/0E-PartyHandler/0E-28-PlayerIsBusyState.cs b/Server/Packets/Handlers/0E-PartyHandler/0E-28-PlayerIsBusyState.cs index d1c5964..8ec6a9a 100644 --- a/Server/Packets/Handlers/0E-PartyHandler/0E-28-PlayerIsBusyState.cs +++ b/Server/Packets/Handlers/0E-PartyHandler/0E-28-PlayerIsBusyState.cs @@ -18,7 +18,7 @@ namespace PSO2SERVER.Packets.Handlers if (c.Character == null || c.CurrentZone != context.CurrentZone) continue; - c.SendPacket(new NewBusyStatePacket(context.User.PlayerId, BusyState.Busy)); + c.SendPacket(new NewBusyStatePacket(context._account.AccountId, BusyState.Busy)); } } } diff --git a/Server/Packets/Handlers/0E-PartyHandler/0E-29-PlayerIsNotBusyState.cs b/Server/Packets/Handlers/0E-PartyHandler/0E-29-PlayerIsNotBusyState.cs index e033852..dd5d254 100644 --- a/Server/Packets/Handlers/0E-PartyHandler/0E-29-PlayerIsNotBusyState.cs +++ b/Server/Packets/Handlers/0E-PartyHandler/0E-29-PlayerIsNotBusyState.cs @@ -19,7 +19,7 @@ namespace PSO2SERVER.Packets.Handlers if (c.Character == null || c.CurrentZone != context.CurrentZone) continue; - c.SendPacket(new NewBusyStatePacket(context.User.PlayerId, BusyState.NotBusy)); + c.SendPacket(new NewBusyStatePacket(context._account.AccountId, BusyState.NotBusy)); } } } diff --git a/Server/Packets/Handlers/11-ClientHandler/11-00-Login.cs b/Server/Packets/Handlers/11-ClientHandler/11-00-Login.cs index a4db6d8..52e28d8 100644 --- a/Server/Packets/Handlers/11-ClientHandler/11-00-Login.cs +++ b/Server/Packets/Handlers/11-ClientHandler/11-00-Login.cs @@ -37,13 +37,13 @@ namespace PSO2SERVER.Packets.Handlers // What am I doing here even using (var db = new ServerEf()) { - var users = from u in db.Players + var users = from u in db.Account where u.Username.ToLower().Equals(username.ToLower()) select u; var error = ""; - Player user; + Account user; if (!users.Any()) { @@ -62,7 +62,7 @@ namespace PSO2SERVER.Packets.Handlers else // We're all good! { // 直接插入新账户至数据库 - user = new Player + user = new Account { Username = username.ToLower(), Password = BCrypt.Net.BCrypt.HashPassword(password), @@ -70,7 +70,7 @@ namespace PSO2SERVER.Packets.Handlers // Since we can't display the nickname prompt yet, just default it to the username SettingsIni = File.ReadAllText(ServerApp.ServerSettingsKey) }; - db.Players.Add(user); + db.Account.Add(user); db.SaveChanges(); context.SendPacket(0x11, 0x1e, 0x0, new byte[0x44]); // Request nickname @@ -96,7 +96,7 @@ namespace PSO2SERVER.Packets.Handlers } } - context.SendPacket(new LoginDataPacket("Server AuthList 1", error, (user == null) ? (uint)0 : (uint)user.PlayerId)); + context.SendPacket(new LoginDataPacket("Server AuthList 1", error, (user == null) ? (uint)0 : (uint)user.AccountId)); // Mystery packet //var mystery = new PacketWriter(); @@ -110,12 +110,7 @@ namespace PSO2SERVER.Packets.Handlers return; } - // Settings packet - var settings = new PacketWriter(); - settings.WriteAscii(user.SettingsIni, 0x54AF, 0x100); - context.SendPacket(0x2B, 2, 4, settings.ToArray()); - - context.User = user; + context._account = user; } diff --git a/Server/Packets/Handlers/11-ClientHandler/11-02-CharacterList.cs b/Server/Packets/Handlers/11-ClientHandler/11-02-CharacterList.cs index 2c5c3ee..89c81be 100644 --- a/Server/Packets/Handlers/11-ClientHandler/11-02-CharacterList.cs +++ b/Server/Packets/Handlers/11-ClientHandler/11-02-CharacterList.cs @@ -11,10 +11,10 @@ namespace PSO2SERVER.Packets.Handlers public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) { - if (context.User == null) + if (context._account == null) return; - context.SendPacket(new CharacterListPacket(context.User.PlayerId)); + context.SendPacket(new CharacterListPacket(context._account.AccountId)); } #endregion diff --git a/Server/Packets/Handlers/11-ClientHandler/11-04-CharacterSelected.cs b/Server/Packets/Handlers/11-ClientHandler/11-04-CharacterSelected.cs index 1a25bd0..9527bfa 100644 --- a/Server/Packets/Handlers/11-ClientHandler/11-04-CharacterSelected.cs +++ b/Server/Packets/Handlers/11-ClientHandler/11-04-CharacterSelected.cs @@ -23,7 +23,7 @@ namespace PSO2SERVER.Packets.Handlers public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) { - if (context.User == null) + if (context._account == null) return; var reader = new PacketReader(data, position, size); @@ -31,7 +31,7 @@ namespace PSO2SERVER.Packets.Handlers var charId = pkt.CharId; - //Logger.Write("id {0}", charId); + Logger.Write("id {0}", charId); if (context.Character == null) // On character create, this is already set. { @@ -39,14 +39,14 @@ namespace PSO2SERVER.Packets.Handlers { try { - var character = db.Characters.FirstOrDefault(c => c.Character_ID == charId); + var character = db.Characters.FirstOrDefault(c => c.Player_ID == charId); - if (character == null || character.Player == null || character.Player.PlayerId != context.User.PlayerId) + if (character == null || character.Account == null || character.Account.AccountId != context._account.AccountId) { Logger.WriteError("数据库中未找到 {0} 角色ID {1} ({2})" - , context.User.Username + , context._account.Username , charId - , context.User.PlayerId + , context._account.AccountId ); context.Socket.Close(); return; diff --git a/Server/Packets/Handlers/11-ClientHandler/11-05-CharacterCreate.cs b/Server/Packets/Handlers/11-ClientHandler/11-05-CharacterCreate.cs index dc3d5f2..8ff39f9 100644 --- a/Server/Packets/Handlers/11-ClientHandler/11-05-CharacterCreate.cs +++ b/Server/Packets/Handlers/11-ClientHandler/11-05-CharacterCreate.cs @@ -14,7 +14,7 @@ namespace PSO2SERVER.Packets.Handlers public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) { - if (context.User == null) + if (context._account == null) return; @@ -33,20 +33,20 @@ namespace PSO2SERVER.Packets.Handlers var looks = reader.ReadStruct(); var jobs = reader.ReadStruct(); - Logger.WriteInternal("[CHR] {0} 创建了名为 {1} 的新角色.", context.User.Username, name); + Logger.WriteInternal("[CHR] {0} 创建了名为 {1} 的新角色.", context._account.Username, name); var newCharacter = new Character { Name = name, Jobs = jobs, Looks = looks, - Player = context.User + Account = context._account }; // Add to database using (var db = new ServerEf()) { // Check if any characters exist for this player - var existingCharacters = db.Characters.Where(c => c.Player.PlayerId == context.User.PlayerId).ToList(); + var existingCharacters = db.Characters.Where(c => c.Account.AccountId == context._account.AccountId).ToList(); if (existingCharacters.Count > 0) { // Increment ID if characters already exist @@ -58,18 +58,20 @@ namespace PSO2SERVER.Packets.Handlers newCharacter.Character_ID = 1; } - //Logger.Write("newCharacter.CharacterId {0} {1}", newCharacter.CharacterId, context.User.PlayerId); + newCharacter.Player_ID = context._account.AccountId; + + //Logger.Write("newCharacter.CharacterId {0} {1}", newCharacter.CharacterId, context._account.AccountId); db.Characters.Add(newCharacter); - db.Entry(newCharacter.Player).State = EntityState.Modified; + db.Entry(newCharacter.Account).State = EntityState.Modified; db.SaveChanges(); } // Assign character to player context.Character = newCharacter; - // Set Player ID - context.SendPacket(new CharacterCreateResponsePacket(CharacterCreateResponsePacket.CharacterCreationStatus.Success, (uint)context.User.PlayerId)); + // Set Account ID + context.SendPacket(new CharacterCreateResponsePacket(CharacterCreateResponsePacket.CharacterCreationStatus.Success, (uint)context._account.AccountId)); // Spawn context.SendPacket(new NoPayloadPacket(0x11, 0x3E)); diff --git a/Server/Packets/Handlers/11-ClientHandler/11-06-DeleteCharacter.cs b/Server/Packets/Handlers/11-ClientHandler/11-06-DeleteCharacter.cs index 26bc360..284082e 100644 --- a/Server/Packets/Handlers/11-ClientHandler/11-06-DeleteCharacter.cs +++ b/Server/Packets/Handlers/11-ClientHandler/11-06-DeleteCharacter.cs @@ -16,7 +16,7 @@ namespace PSO2SERVER.Packets.Handlers var reader = new PacketReader(data); var id = reader.ReadInt32(); - Logger.Write("[CHR] {0} 正在删除ID {1} 的角色", context.User.Username, id); + Logger.Write("[CHR] {0} 正在删除ID {1} 的角色", context._account.Username, id); // Delete Character using (var db = new ServerEf()) diff --git a/Server/Packets/Handlers/11-ClientHandler/11-2D-SystemInformation.cs b/Server/Packets/Handlers/11-ClientHandler/11-2D-SystemInformation.cs new file mode 100644 index 0000000..d67e793 --- /dev/null +++ b/Server/Packets/Handlers/11-ClientHandler/11-2D-SystemInformation.cs @@ -0,0 +1,68 @@ +using System; +using System.Data.Entity.Infrastructure; +using System.IO; +using System.Linq; +using PSO2SERVER.Database; +using PSO2SERVER.Models; +using PSO2SERVER.Packets.PSOPackets; + +namespace PSO2SERVER.Packets.Handlers +{ + [PacketHandlerAttr(0x11, 0x2D)] + class SystemInformation : PacketHandler + { + public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) + { + var reader = new PacketReader(data, position, size); + + var cpu_info = reader.ReadAscii(0x883D, 0x9F); + var video_info = reader.ReadAscii(0x883D, 0x9F); + //reader.BaseStream.Seek(8, SeekOrigin.Current); + //var vram = reader.ReadInt64(); + //var windows_version = reader.ReadAscii(0x883D, 0x9F); + + + //Logger.Write("Setting 内容: " + windows_version); + + + + using (var db = new ServerEf()) + { + try + { + var player = db.Account.FirstOrDefault(w => w.AccountId == context._account.AccountId); + if (player == null) + { + Logger.WriteError("未找到 AccountId: {0}", context._account.AccountId); + return; + } + + if (!string.IsNullOrWhiteSpace(cpu_info)) + { + player.Cpu_Info = cpu_info; + } + + if (!string.IsNullOrWhiteSpace(video_info)) + { + player.Video_Info = video_info; + } + + // 保存更改并捕获可能的异常 + db.SaveChanges(); + } + catch (DbUpdateException dbEx) + { + Logger.WriteError("数据库更新时发生异常: {0}", dbEx.Message); + // 处理数据库更新错误 + } + catch (Exception ex) + { + Logger.WriteError("构建数据包时发生异常: {0}", ex.Message); + // 处理其他异常情况 + } + } + + //context.SendPacket(new LoadSettingsPacket(context._account.AccountId)); + } + } +} diff --git a/Server/Packets/Handlers/11-ClientHandler/11-3E-CharacterSpawn.cs b/Server/Packets/Handlers/11-ClientHandler/11-3E-CharacterSpawn.cs index 62abe42..2d60ff3 100644 --- a/Server/Packets/Handlers/11-ClientHandler/11-3E-CharacterSpawn.cs +++ b/Server/Packets/Handlers/11-ClientHandler/11-3E-CharacterSpawn.cs @@ -17,7 +17,7 @@ namespace PSO2SERVER.Packets.Handlers public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) { - if (context.User == null || context.Character == null) + if (context._account == null || context.Character == null) return; // Looks/Jobs diff --git a/Server/Packets/Handlers/2B-SettingHandler/2B-00-SettingsRequest.cs b/Server/Packets/Handlers/2B-SettingHandler/2B-00-SettingsRequest.cs new file mode 100644 index 0000000..02f30f7 --- /dev/null +++ b/Server/Packets/Handlers/2B-SettingHandler/2B-00-SettingsRequest.cs @@ -0,0 +1,18 @@ +using System; +using PSO2SERVER.Models; +using PSO2SERVER.Packets.PSOPackets; + +namespace PSO2SERVER.Packets.Handlers +{ + [PacketHandlerAttr(0x2B, 0x00)] + class SettingsRequest : PacketHandler + { + public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) + { + //var info = string.Format("[<--] 接收到的数据 (hex): "); + //Logger.WriteHex(info, data); + + context.SendPacket(new LoadSettingsPacket(context._account.AccountId)); + } + } +} diff --git a/Server/Packets/Handlers/2B-SettingHandler/2B-01-SavePlayerSettings.cs b/Server/Packets/Handlers/2B-SettingHandler/2B-01-SavePlayerSettings.cs new file mode 100644 index 0000000..76f3db2 --- /dev/null +++ b/Server/Packets/Handlers/2B-SettingHandler/2B-01-SavePlayerSettings.cs @@ -0,0 +1,56 @@ +using System; +using System.Data.Entity.Infrastructure; +using System.Linq; +using PSO2SERVER.Database; +using PSO2SERVER.Models; +using PSO2SERVER.Packets.PSOPackets; + +namespace PSO2SERVER.Packets.Handlers +{ + [PacketHandlerAttr(0x2B, 0x01)] + class SavePlayerSettings : PacketHandler + { + public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) + { + var reader = new PacketReader(data, position, size); + + var setting = reader.ReadAscii(0xCEF1, 0xB5); + + using (var db = new ServerEf()) + { + try + { + var player = db.Account.FirstOrDefault(w => w.AccountId == context._account.AccountId); + if (player == null) + { + Logger.WriteError("未找到 AccountId: {0}", context._account.AccountId); + return; + } + + if (string.IsNullOrWhiteSpace(setting)) + { + Logger.WriteError("新的设置内容无效。"); + return; + } + + player.SettingsIni = setting; + + // 保存更改并捕获可能的异常 + db.SaveChanges(); + } + catch (DbUpdateException dbEx) + { + Logger.WriteError("数据库更新时发生异常: {0}", dbEx.Message); + // 处理数据库更新错误 + } + catch (Exception ex) + { + Logger.WriteError("构建数据包时发生异常: {0}", ex.Message); + // 处理其他异常情况 + } + } + + //context.SendPacket(new LoadSettingsPacket(context._account.AccountId)); + } + } +} diff --git a/Server/Packets/Handlers/2F-SymbolHandler/2F-06-SymbolArtHandler.cs b/Server/Packets/Handlers/2F-SymbolHandler/2F-06-SymbolArtHandler.cs index 46205f8..880b6b0 100644 --- a/Server/Packets/Handlers/2F-SymbolHandler/2F-06-SymbolArtHandler.cs +++ b/Server/Packets/Handlers/2F-SymbolHandler/2F-06-SymbolArtHandler.cs @@ -12,7 +12,7 @@ namespace PSO2SERVER.Packets.Handlers { public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) { - context.SendPacket(new SymbolArtListPacket(new Models.ObjectHeader((uint)context.User.PlayerId, Models.EntityType.Player))); + context.SendPacket(new SymbolArtListPacket(new Models.ObjectHeader((uint)context._account.AccountId, Models.EntityType.Player))); } } } diff --git a/Server/Packets/PSOPackets/03-ServerPacket/03-0B-ServerPingPacket.cs b/Server/Packets/PSOPackets/03-ServerPacket/03-0B-ServerPingPacket.cs new file mode 100644 index 0000000..8fc3e6e --- /dev/null +++ b/Server/Packets/PSOPackets/03-ServerPacket/03-0B-ServerPingPacket.cs @@ -0,0 +1,24 @@ +using System; +using System.IO; +using PSO2SERVER.Models; + +namespace PSO2SERVER.Packets.PSOPackets +{ + class ServerPingPacket : Packet + { + public ServerPingPacket() + { + } + + public override byte[] Build() + { + PacketWriter writer = new PacketWriter(); + return writer.ToArray(); + } + + public override PacketHeader GetHeader() + { + return new PacketHeader(0x03, 0x0B, PacketFlags.None); + } + } +} diff --git a/Server/Packets/PSOPackets/08-SpawnPacket/08-04-CharacterSpawnPacket.cs b/Server/Packets/PSOPackets/08-SpawnPacket/08-04-CharacterSpawnPacket.cs index 44d10ef..9351f39 100644 --- a/Server/Packets/PSOPackets/08-SpawnPacket/08-04-CharacterSpawnPacket.cs +++ b/Server/Packets/PSOPackets/08-SpawnPacket/08-04-CharacterSpawnPacket.cs @@ -37,8 +37,8 @@ namespace PSO2SERVER.Packets.PSOPackets { var writer = new PacketWriter(); - // Player header - writer.WritePlayerHeader((uint)_character.Player.PlayerId); + // Account header + writer.WritePlayerHeader((uint)_character.Account.AccountId); // Spawn position writer.Write(Position); @@ -54,7 +54,7 @@ namespace PSO2SERVER.Packets.PSOPackets writer.Write((uint)(IsItMe ? 47 : 39)); // 0x58 writer.Write((ushort)559); // 0x5C writer.Write((ushort)306); // 0x5E - writer.Write((uint)_character.Player.PlayerId); // player ID copy + writer.Write((uint)_character.Account.AccountId); // player ID copy writer.Write((uint)0); // "char array ugggghhhhh" according to PolarisLegacy writer.Write((uint)0); // "voiceParam_unknown4" writer.Write((uint)0); // "voiceParam_unknown8" @@ -65,7 +65,7 @@ namespace PSO2SERVER.Packets.PSOPackets writer.WriteFixedLengthUtf16("", 32); // title? writer.Write((uint)0); // 0x204 writer.Write((uint)0); // gmflag? - writer.WriteFixedLengthUtf16(_character.Player.Nickname, 16); // nickname, maybe not 16 chars? + writer.WriteFixedLengthUtf16(_character.Account.Nickname, 16); // nickname, maybe not 16 chars? for (var i = 0; i < 64; i++) writer.Write((byte)0); diff --git a/Server/Packets/PSOPackets/0E-PartyPacket/0E-02-PartyInitPacket.cs b/Server/Packets/PSOPackets/0E-PartyPacket/0E-02-PartyInitPacket.cs index 5091de8..32415db 100644 --- a/Server/Packets/PSOPackets/0E-PartyPacket/0E-02-PartyInitPacket.cs +++ b/Server/Packets/PSOPackets/0E-PartyPacket/0E-02-PartyInitPacket.cs @@ -22,14 +22,14 @@ namespace PSO2SERVER.Packets.PSOPackets // xor: 0xD863, sub: 0xA9 PacketWriter writer = new PacketWriter(); writer.WriteBytes(0, 12); // Unknown 12 bytes, not obj header - writer.WriteStruct(new ObjectHeader((uint)members[0].Player.PlayerId, EntityType.Player)); // Player receiving the thing + writer.WriteStruct(new ObjectHeader((uint)members[0].Account.AccountId, EntityType.Player)); // Account receiving the thing writer.WriteStruct(members.Length); // Likely partymembercount for(int i = 0; i < members.Length; i++) { - writer.WriteStruct(new ObjectHeader((uint)members[i].Player.PlayerId, EntityType.Player)); // Header of player + writer.WriteStruct(new ObjectHeader((uint)members[i].Account.AccountId, EntityType.Player)); // Header of player writer.WriteUtf16(members[i].Name, 0xD863, 0xA9); - writer.WriteUtf16(members[i].Player.Nickname, 0xD863, 0xA9); + writer.WriteUtf16(members[i].Account.Nickname, 0xD863, 0xA9); writer.Write((byte)members[i].Jobs.entries.hunter.level); // Active class level writer.Write((byte)0); // idk writer.Write((byte)4); // idk diff --git a/Server/Packets/PSOPackets/0E-PartyPacket/0E-25-SetQuestInfoPacket.cs b/Server/Packets/PSOPackets/0E-PartyPacket/0E-25-SetQuestInfoPacket.cs index e70f12b..600dd4d 100644 --- a/Server/Packets/PSOPackets/0E-PartyPacket/0E-25-SetQuestInfoPacket.cs +++ b/Server/Packets/PSOPackets/0E-PartyPacket/0E-25-SetQuestInfoPacket.cs @@ -10,9 +10,9 @@ namespace PSO2SERVER.Packets.PSOPackets { QuestDefiniton questdef; - Database.Player p; + Database.Account p; - public SetQuestInfoPacket(QuestDefiniton questdef, Database.Player p) + public SetQuestInfoPacket(QuestDefiniton questdef, Database.Account p) { this.questdef = questdef; this.p = p; @@ -26,7 +26,7 @@ namespace PSO2SERVER.Packets.PSOPackets writer.Write((ushort)0); writer.Write((ushort)0); writer.Write((ushort)1); - writer.WriteStruct(new ObjectHeader((uint)p.PlayerId, EntityType.Player)); + writer.WriteStruct(new ObjectHeader((uint)p.AccountId, EntityType.Player)); writer.Write(0); writer.Write((ushort)0); writer.Write((ushort)0); diff --git a/Server/Packets/PSOPackets/11-ClientPacket/11-03-CharacterListPacket.cs b/Server/Packets/PSOPackets/11-ClientPacket/11-03-CharacterListPacket.cs index 7d4af36..108500a 100644 --- a/Server/Packets/PSOPackets/11-ClientPacket/11-03-CharacterListPacket.cs +++ b/Server/Packets/PSOPackets/11-ClientPacket/11-03-CharacterListPacket.cs @@ -41,7 +41,7 @@ namespace PSO2SERVER.Packets.PSOPackets using (var db = new ServerEf()) { var chars = db.Characters - .Where(w => w.Player.PlayerId == _PlayerId) + .Where(w => w.Account.AccountId == _PlayerId) .OrderBy(o => o.Character_ID) // TODO: Order by last played .Select(s => s); diff --git a/Server/Packets/PSOPackets/1C-AlliancePacket/1C-1F-GuildInfoPacket.cs b/Server/Packets/PSOPackets/1C-AlliancePacket/1C-1F-GuildInfoPacket.cs index 94724c2..353cb34 100644 --- a/Server/Packets/PSOPackets/1C-AlliancePacket/1C-1F-GuildInfoPacket.cs +++ b/Server/Packets/PSOPackets/1C-AlliancePacket/1C-1F-GuildInfoPacket.cs @@ -32,13 +32,13 @@ namespace PSO2SERVER.Packets.PSOPackets // Nickname // TODO: The above and below may be switched around, need more data - writer.WriteFixedLengthUtf16(_character.Player.Nickname, 16); + writer.WriteFixedLengthUtf16(_character.Account.Nickname, 16); // Padding? for (var i = 0; i < 36; i++) writer.Write((byte) 0); - // Player name + // Account name writer.WriteFixedLengthUtf16(_character.Name, 16); // Unknown? diff --git a/Server/Packets/PSOPackets/2B-SettingsPacket/2B-02-LoadSettingsPacket.cs b/Server/Packets/PSOPackets/2B-SettingsPacket/2B-02-LoadSettingsPacket.cs index 9cc34e5..c47fe4b 100644 --- a/Server/Packets/PSOPackets/2B-SettingsPacket/2B-02-LoadSettingsPacket.cs +++ b/Server/Packets/PSOPackets/2B-SettingsPacket/2B-02-LoadSettingsPacket.cs @@ -1,6 +1,8 @@ -using PSO2SERVER.Models; +using PSO2SERVER.Database; +using PSO2SERVER.Models; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; @@ -8,22 +10,62 @@ namespace PSO2SERVER.Packets.PSOPackets { public class LoadSettingsPacket : Packet { - - public LoadSettingsPacket() + private int _PlayerId; + public LoadSettingsPacket(int PlayerId) { + _PlayerId = PlayerId; } #region implemented abstract members of Packet public override byte[] Build() { - var pkt = new PacketWriter(); - return pkt.ToArray(); + var writer = new PacketWriter(); + + using (var db = new ServerEf()) + { + try + { + // 使用 FirstOrDefault 以避免异常 + var player = db.Account.FirstOrDefault(w => w.AccountId == _PlayerId); + + if (player == null) + { + Logger.WriteError("未找到 AccountId: {0}", _PlayerId); + // 可以选择返回一个特定的错误包或空数组 + return Array.Empty(); + } + + // 确保 SettingsIni 不为 null + if (player.SettingsIni != null) + { + writer.WriteAscii(player.SettingsIni, 0x54AF, 0x100); + } + else + { + Logger.WriteError("AccountId: {0} 的 SettingsIni 为 null, 载入默认值", _PlayerId); + player.SettingsIni = File.ReadAllText(ServerApp.ServerSettingsKey); + + // 保存更改并捕获可能的异常 + db.SaveChanges(); + + // 可以选择如何处理此情况 + writer.WriteAscii(player.SettingsIni, 0x54AF, 0x100); + } + } + catch (Exception ex) + { + Logger.WriteError("构建数据包时发生异常: {0}", ex.Message); + // 处理异常情况,例如返回错误包 + } + } + + return writer.ToArray(); } public override PacketHeader GetHeader() { - return new PacketHeader(0x2B, 0x02, PacketFlags.None); + return new PacketHeader(0x2B, 0x02, PacketFlags.PACKED); } #endregion diff --git a/Server/Packets/PSOPackets/UN-UN-SetScenePacket.cs b/Server/Packets/PSOPackets/UN-UN-SetScenePacket.cs deleted file mode 100644 index 1344219..0000000 --- a/Server/Packets/PSOPackets/UN-UN-SetScenePacket.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace PSO2SERVER.Packets.PSOPackets -{ - class SetScenePacket - { - } -} diff --git a/Server/Packets/PacketReader.cs b/Server/Packets/PacketReader.cs index ebf524f..05e8ff1 100644 --- a/Server/Packets/PacketReader.cs +++ b/Server/Packets/PacketReader.cs @@ -35,6 +35,7 @@ namespace PSO2SERVER.Packets } var charCount = magic - 1; var padding = 4 - (charCount & 3); + //Logger.Write("charCount = " + charCount + " padding = " + padding); var data = ReadBytes((int) charCount); for (var i = 0; i < padding; i++) diff --git a/Server/Party/Party.cs b/Server/Party/Party.cs index 124528c..fe84761 100644 --- a/Server/Party/Party.cs +++ b/Server/Party/Party.cs @@ -40,7 +40,7 @@ namespace PSO2SERVER.Party { if(!members.Contains(c)) { - Logger.WriteWarning("[PTY] Client {0} was trying to be removed from {1}, but he was never in {1}!", c.User.Username, name); + Logger.WriteWarning("[PTY] Client {0} was trying to be removed from {1}, but he was never in {1}!", c._account.Username, name); return; } diff --git a/Server/Party/PartyManager.cs b/Server/Party/PartyManager.cs index 072af1d..1f2ec80 100644 --- a/Server/Party/PartyManager.cs +++ b/Server/Party/PartyManager.cs @@ -41,7 +41,7 @@ namespace PSO2SERVER.Party if (GetCurrentPartyForClient(c) != null) return; // For now - parties.Add(new Party(c.User.Username, c), c.User.Username); + parties.Add(new Party(c._account.Username, c), c._account.Username); } public void AddPlayerToParty(Client c, Party p) diff --git a/Server/Server.cs b/Server/Server.cs index 94de1b6..771ad85 100644 --- a/Server/Server.cs +++ b/Server/Server.cs @@ -59,10 +59,10 @@ namespace PSO2SERVER // TODO: Disconnect a client if we don't get a response in a certain amount of time foreach (var client in Clients) { - if (client != null && client.User != null) + if (client != null && client._account != null) { - Logger.Write("[HEY] Pinging " + client.User.Username); - client.SendPacket(new NoPayloadPacket(0x03, 0x0B)); + Logger.Write("[HEY] Pinging " + client._account.Username); + client.SendPacket(new ServerPingPacket()); } } } diff --git a/Server/Server.csproj b/Server/Server.csproj index 90cb502..368720f 100644 --- a/Server/Server.csproj +++ b/Server/Server.csproj @@ -171,7 +171,7 @@ - + @@ -202,7 +202,11 @@ + + + + @@ -344,7 +348,6 @@ - diff --git a/Server/Zone/Map.cs b/Server/Zone/Map.cs index 91d4476..f6ceff5 100644 --- a/Server/Zone/Map.cs +++ b/Server/Zone/Map.cs @@ -110,7 +110,7 @@ namespace PSO2SERVER.Zone { //PacketWriter writer = new PacketWriter(); //writer.WriteStruct(new ObjectHeader(3, EntityType.Map)); - //writer.WriteStruct(new ObjectHeader((uint)c.User.PlayerId, EntityType.Player)); + //writer.WriteStruct(new ObjectHeader((uint)c._account.AccountId, EntityType.Account)); //writer.Write(0x1); // 8 Zeros //writer.Write(0); // 8 Zeros //writer.Write(~(uint)Type); // F4 FF FF FF @@ -132,7 +132,7 @@ namespace PSO2SERVER.Zone _map.GenerationArgs.xsize = GenerationArgs.xsize; _map.GenerationArgs.ysize = GenerationArgs.ysize; - c.SendPacket(new MapTransferPacket(_map, c.User.PlayerId)); + c.SendPacket(new MapTransferPacket(_map, c._account.AccountId)); } if (c.CurrentZone != null) @@ -141,9 +141,9 @@ namespace PSO2SERVER.Zone } //var setPlayerId = new PacketWriter(); - //setPlayerId.WritePlayerHeader((uint)c.User.PlayerId); + //setPlayerId.WritePlayerHeader((uint)c._account.AccountId); //c.SendPacket(0x06, 0x00, 0, setPlayerId.ToArray()); - c.SendPacket(new SetPlayerIDPacket(c.User.PlayerId)); + c.SendPacket(new SetPlayerIDPacket(c._account.AccountId)); // Spawn Character c.SendPacket(new CharacterSpawnPacket(c.Character, location)); @@ -175,7 +175,7 @@ namespace PSO2SERVER.Zone Clients.Add(c); - Logger.Write("[MAP] {0} 已生成至 {1}.", c.User.Username, Name); + Logger.Write("[MAP] {0} 已生成至 {1}.", c._account.Username, Name); if (InstanceName != null && ZoneManager.Instance.playerCounter.ContainsKey(InstanceName)) { @@ -195,10 +195,10 @@ namespace PSO2SERVER.Zone foreach (Client other in Clients) { //PacketWriter writer = new PacketWriter(); - //writer.WriteStruct(new ObjectHeader((uint)other.User.PlayerId, EntityType.Player)); - //writer.WriteStruct(new ObjectHeader((uint)c.User.PlayerId, EntityType.Player)); + //writer.WriteStruct(new ObjectHeader((uint)other._account.AccountId, EntityType.Account)); + //writer.WriteStruct(new ObjectHeader((uint)c._account.AccountId, EntityType.Account)); //other.SendPacket(0x4, 0x3B, 0x40, writer.ToArray()); - other.SendPacket(new DespawnPlayerPacket(other.User.PlayerId, c.User.PlayerId)); + other.SendPacket(new DespawnPlayerPacket(other._account.AccountId, c._account.AccountId)); } if (InstanceName != null && ZoneManager.Instance.playerCounter.ContainsKey(InstanceName))