From 2039ae32d03d03223efbe9de092af5194e885950 Mon Sep 17 00:00:00 2001 From: rfi Date: Tue, 28 Nov 2023 21:13:37 +0700 Subject: [PATCH] fix level command! --- AscNet.GameServer/Commands/LevelCommand.cs | 32 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/AscNet.GameServer/Commands/LevelCommand.cs b/AscNet.GameServer/Commands/LevelCommand.cs index 31f7931..d39c246 100644 --- a/AscNet.GameServer/Commands/LevelCommand.cs +++ b/AscNet.GameServer/Commands/LevelCommand.cs @@ -1,4 +1,6 @@ -using AscNet.Common.Util; +using AscNet.Common.MsgPack; +using AscNet.Common.Util; +using AscNet.GameServer.Handlers; using AscNet.Table.V2.share.player; namespace AscNet.GameServer.Commands @@ -15,17 +17,39 @@ namespace AscNet.GameServer.Commands public override void Execute() { - int maxLevel = TableReaderV2.Parse().Count; + List playerLevels = TableReaderV2.Parse(); int level = Miscs.ParseIntOr(Level); if (Level == "max") { - session.player.PlayerData.Level = maxLevel; + session.player.PlayerData.Level = playerLevels.OrderByDescending(x => x.Level).First().Level; + NotifyPlayerLevel notifyPlayerLevel = new() + { + Level = (int)session.player.PlayerData.Level + }; + session.SendPush(notifyPlayerLevel); session.ExpSanityCheck(); } - else if (level > 0) + else if (playerLevels.Any(x => x.Level == level)) { + if (session.player.PlayerData.Level > level) + { + session.player.PlayerData.Level = level; + // Waiting for SendChatResponse, pls fix later + Task.Run(() => + { + // ReconnectPlayerLogout + session.SendPush(new ForceLogoutNotify() { Code = 1030 }); + session.DisconnectProtocol(); + }); + return; + } session.player.PlayerData.Level = level; + NotifyPlayerLevel notifyPlayerLevel = new() + { + Level = (int)session.player.PlayerData.Level + }; + session.SendPush(notifyPlayerLevel); session.ExpSanityCheck(); } else