diff --git a/src/DiIiS-NA/BGS-Server/Battle/BattleClient.cs b/src/DiIiS-NA/BGS-Server/Battle/BattleClient.cs index 251f036..a586f4f 100644 --- a/src/DiIiS-NA/BGS-Server/Battle/BattleClient.cs +++ b/src/DiIiS-NA/BGS-Server/Battle/BattleClient.cs @@ -40,6 +40,7 @@ using System.Linq; using System.Net.Security; //Blizzless Project 2022 using System.Threading.Tasks; +using DiIiS_NA.GameServer.MessageSystem.Message.Definitions.Text; namespace DiIiS_NA.LoginServer.Battle { @@ -135,6 +136,14 @@ namespace DiIiS_NA.LoginServer.Battle }, notification, callback => { })); } + public void SendServerMessage(string text) + { + InGameClient.SendMessage(new BroadcastTextMessage() + { + Field0 = text + }); + } + public void LeaveAllChannels() { List _channels = this.Channels.Values.ToList(); @@ -405,10 +414,8 @@ namespace DiIiS_NA.LoginServer.Battle { if (this.SocketConnection == null || !this.SocketConnection.Active) return; var listenerId = this.GetRemoteObjectId(targetObject.DynamicId); -#if DEBUG - Logger.Trace("[RPC: {0}] Method: {1} Target: {2} [localId: {3}, remoteId: {4}].", this, rpc.Method, + Logger.Debug("[RPC: {0}] Method: {1} Target: {2} [localId: {3}, remoteId: {4}].", this.GetType().Name, rpc.Method.Name, targetObject.ToString(), targetObject.DynamicId, listenerId); -#endif rpc(listenerId); } @@ -425,9 +432,7 @@ namespace DiIiS_NA.LoginServer.Battle try { if (this.SocketConnection == null || !this.SocketConnection.Active) return; -#if DEBUG - Logger.Trace("[RPC: {0}] Method: {1} Target: N/A", this, rpc.Method); -#endif + Logger.Debug("[RPC: {0}] Method: {1} Target: N/A", this.GetType().Name, rpc.Method.Name); rpc(0); } catch { } diff --git a/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/ChannelService.cs b/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/ChannelService.cs index 4a03b5e..f12c73c 100644 --- a/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/ChannelService.cs +++ b/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/ChannelService.cs @@ -90,7 +90,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services //*/ Channel channel = ChannelManager.GetChannelByDynamicId(((controller as HandlerController).LastCallHeader).ObjectId); - Logger.Trace("UpdateChannelState(): {0}", request.ToString()); + Logger.Debug("UpdateChannelState(): {0}", request.ToString()); foreach (bgs.protocol.Attribute attribute in request.StateChange.AttributeList) { @@ -99,7 +99,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services if (attribute.HasValue && !attribute.Value.MessageValue.IsEmpty) //Sometimes not present -Egris { var gameCreateParams = D3.OnlineService.GameCreateParams.ParseFrom(attribute.Value.MessageValue); - Logger.Trace("D3.Party.GameCreateParams: {0}", gameCreateParams.ToString()); + Logger.Debug("D3.Party.GameCreateParams: {0}", gameCreateParams.ToString()); //D3.OnlineService.EntityId hero = gameCreateParams.Coop.ResumeFromSaveHeroId; bool clear_quests = ((controller as HandlerController).Client.GameChannel != null && gameCreateParams.CampaignOrAdventureMode.QuestStepId == -1 && (gameCreateParams.CampaignOrAdventureMode.SnoQuest == 87700 || @@ -205,7 +205,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services .SetValue(bgs.protocol.Variant.CreateBuilder()); channel.AddAttribute(attr.Build()); - Logger.Trace("D3.Party.ScreenStatus = null"); + Logger.Debug("D3.Party.ScreenStatus = null"); } else { @@ -218,7 +218,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services .SetValue(bgs.protocol.Variant.CreateBuilder().SetMessageValue(oldScreen.ToByteString())); channel.AddAttribute(attr.Build()); - Logger.Trace("Client moving to Screen: {0}, with Status: {1}", oldScreen.Screen, oldScreen.Status); + Logger.Debug("Client moving to Screen: {0}, with Status: {1}", oldScreen.Screen, oldScreen.Status); } } else if (attribute.Name == "D3.Party.JoinPermissionPreviousToLock") @@ -232,7 +232,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services .SetValue(joinPermission); channel.AddAttribute(attr.Build()); - Logger.Trace("D3.Party.JoinPermissionPreviousToLock = {0}", joinPermission.IntValue); + Logger.Debug("D3.Party.JoinPermissionPreviousToLock = {0}", joinPermission.IntValue); } else if (attribute.Name == "D3.Party.JoinPermissionPreviousToClose") { @@ -245,7 +245,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services .SetValue(joinPermission); channel.AddAttribute(attr.Build()); - Logger.Trace("D3.Party.JoinPermissionPreviousToClose = {0}", joinPermission.IntValue); + Logger.Debug("D3.Party.JoinPermissionPreviousToClose = {0}", joinPermission.IntValue); } else if (attribute.Name == "D3.Party.LockReasons") { @@ -258,7 +258,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services .SetValue(lockReason); channel.AddAttribute(attr.Build()); - Logger.Trace("D3.Party.LockReasons = {0}", lockReason.IntValue); + Logger.Debug("D3.Party.LockReasons = {0}", lockReason.IntValue); } else if (attribute.Name == "D3.Party.GameId") { @@ -270,10 +270,10 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services .SetValue(bgs.protocol.Variant.CreateBuilder().SetMessageValue(gameId.ToByteString()).Build()); channel.AddAttribute(attr.Build()); - Logger.Trace("D3.Party.GameId = {0}", gameId.GameInstanceId); + Logger.Debug("D3.Party.GameId = {0}", gameId.GameInstanceId); } else - Logger.Trace("D3.Party.GameId = null"); + Logger.Debug("D3.Party.GameId = null"); } else if (attribute.Name == "D3.Party.EnterGame.Members") @@ -286,10 +286,10 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services .SetValue(bgs.protocol.Variant.CreateBuilder().SetMessageValue(members.ToByteString()).Build()); channel.AddAttribute(attr.Build()); - Logger.Trace("D3.Party.EnterGame.Members = {0}", members.ToString()); + Logger.Debug("D3.Party.EnterGame.Members = {0}", members.ToString()); } else - Logger.Trace("D3.Party.EnterGame.Members = null"); + Logger.Debug("D3.Party.EnterGame.Members = null"); } else if (attribute.Name == "D3.Party.JoinPermission") @@ -302,10 +302,10 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services .SetValue(bgs.protocol.Variant.CreateBuilder().SetMessageValue(permission.ToByteString()).Build()); channel.AddAttribute(attr.Build()); - Logger.Trace("D3.Party.JoinPermission = {0}", permission.ToString()); + Logger.Debug("D3.Party.JoinPermission = {0}", permission.ToString()); } else - Logger.Trace("D3.Party.JoinPermission = null"); + Logger.Debug("D3.Party.JoinPermission = null"); } else if (attribute.Name == "D3.Party.EnterGame.Leader.AtQueueStart") @@ -318,15 +318,15 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services .SetValue(bgs.protocol.Variant.CreateBuilder().SetMessageValue(queueStart.ToByteString()).Build()); channel.AddAttribute(attr.Build()); - Logger.Trace("D3.Party.EnterGame.Leader.AtQueueStart = {0}", queueStart.ToString()); + Logger.Debug("D3.Party.EnterGame.Leader.AtQueueStart = {0}", queueStart.ToString()); } else - Logger.Trace("D3.Party.EnterGame.Leader.AtQueueStart = null"); + Logger.Debug("D3.Party.EnterGame.Leader.AtQueueStart = null"); } else { - Logger.Warn("UpdateChannelState(): Unknown attribute: {0}", attribute.Name); + Logger.Debug("UpdateChannelState(): Unknown attribute: {0}", attribute.Name); } } diff --git a/src/DiIiS-NA/D3-GameServer/ClientSystem/GameServer.cs b/src/DiIiS-NA/D3-GameServer/ClientSystem/GameServer.cs index 35ddd59..3df47dd 100644 --- a/src/DiIiS-NA/D3-GameServer/ClientSystem/GameServer.cs +++ b/src/DiIiS-NA/D3-GameServer/ClientSystem/GameServer.cs @@ -22,7 +22,7 @@ namespace DiIiS_NA.GameServer.ClientSystem { private new static readonly Logger Logger = LogManager.CreateLogger("GS"); // hide the Server.Logger so that tiny-logger can show the actual server as log source. - public static GSBackend GSBackend { get; set; } + public static GsBackend GSBackend { get; set; } public static int MaintenanceTime = -1; public Bot DiscordBot { get; set; } diff --git a/src/DiIiS-NA/D3-GameServer/CommandManager/CommandManager.cs b/src/DiIiS-NA/D3-GameServer/CommandManager/CommandManager.cs index ae084a7..580f863 100644 --- a/src/DiIiS-NA/D3-GameServer/CommandManager/CommandManager.cs +++ b/src/DiIiS-NA/D3-GameServer/CommandManager/CommandManager.cs @@ -111,15 +111,19 @@ namespace DiIiS_NA.GameServer.CommandManager } if (found == false) - output = string.Format("Unknown command: {0} {1}", command, parameters); + output = $"Unknown command: {command} {parameters}"; if (output == string.Empty) return true; - output = "[System] " + output; - - invokerClient.SendServerWhisper(output); - + if (output.Contains("\n")) + { + invokerClient.SendServerWhisper("[SYSTEM]\n" + output + "\n\n"); + } + else + { + invokerClient.SendServerWhisper("[SYSTEM] " + output); + } return true; } @@ -149,14 +153,23 @@ namespace DiIiS_NA.GameServer.CommandManager public override string Fallback(string[] parameters = null, BattleClient invokerClient = null) { var output = "Available commands: "; - foreach (var pair in CommandGroups) + if (invokerClient != null) { - if (invokerClient != null && pair.Key.MinUserLevel > invokerClient.Account.UserLevel) continue; - output += pair.Key.Name + ", "; + foreach (var pair in CommandGroups.Where(pair => + pair.Key.MinUserLevel > invokerClient?.Account.UserLevel)) + { + output += "!" + pair.Key.Name + ": " + pair.Key.Help + "\n\n"; + } + } + else + { + foreach (var pair in CommandGroups) + { + output += "!" + pair.Key.Name + ": " + pair.Key.Help + "\n\n"; + } } - output = output.Substring(0, output.Length - 2) + "."; - return output + "\nType 'help ' to get help."; + return output + "Type 'help ' to get help about a specific command."; } } @@ -165,7 +178,7 @@ namespace DiIiS_NA.GameServer.CommandManager { public override string Fallback(string[] parameters = null, BattleClient invokerClient = null) { - return "usage: help "; + return "usage: help \nType 'commands' to get a list of available commands."; } public override string Handle(string parameters, BattleClient invokerClient = null) diff --git a/src/DiIiS-NA/D3-GameServer/CommandManager/GameCommands.cs b/src/DiIiS-NA/D3-GameServer/CommandManager/GameCommands.cs index 2400672..56384bf 100644 --- a/src/DiIiS-NA/D3-GameServer/CommandManager/GameCommands.cs +++ b/src/DiIiS-NA/D3-GameServer/CommandManager/GameCommands.cs @@ -302,7 +302,7 @@ namespace DiIiS_NA.GameServer.CommandManager } } - [CommandGroup("stashup", "Upgrade Stash.\n !stashup", Account.UserLevels.Tester)] + [CommandGroup("stashup", "Upgrade Stash.", Account.UserLevels.Tester)] public class StashUpCommand : CommandGroup { [DefaultCommand] diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/ActorSystem/Actor.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/ActorSystem/Actor.cs index 4d9da6b..c3b1043 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/ActorSystem/Actor.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/ActorSystem/Actor.cs @@ -1299,7 +1299,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem { int snoConversationList = WorldGenerator.DefaultConversationLists[(int)SNO];//Tags[MarkerKeys.ConversationList].Id; - Logger.Trace(" (ReadTags) actor {0} GlobalID {2} has a conversation list {1}", NameSNO, snoConversationList, GlobalID); + Logger.Debug(" (ReadTags) actor {0} GlobalID {2} has a conversation list {1}", NameSNO, snoConversationList, GlobalID); if (MPQStorage.Data.Assets[SNOGroup.ConversationList].ContainsKey(snoConversationList)) ConversationList = MPQStorage.Data.Assets[SNOGroup.ConversationList][snoConversationList].Data as DiIiS_NA.Core.MPQ.FileFormats.ConversationList; @@ -1362,10 +1362,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem #endregion - public override string ToString() - { - return $"[Actor] [Type: {ActorType}] SNOId:{SNO} GlobalId: {GlobalID} Position: {Position} Name: {Name}"; - } + public override string ToString() => $"[Actor] [Type: {ActorType}] SNOId:{SNO} GlobalId: {GlobalID} Position: {Position} Name: {Name}"; } // This should probably be the same as GBHandleType (probably merge them once all actor classes are created) diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/GSBackend.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/GSBackend.cs index eafe4da..e3073ac 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/GSBackend.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/GSBackend.cs @@ -15,7 +15,7 @@ using WatsonTcp; namespace DiIiS_NA.GameServer.GSSystem.GameSystem { - public class GSBackend + public class GsBackend { private static readonly Logger Logger = LogManager.CreateLogger("GSBackend"); @@ -23,17 +23,17 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem public WatsonTcpClient BattleNetSocket; - public GSBackend(string BattletHost, int BattlePort) + public GsBackend(string battletHost, int battlePort) { - BattleNetSocket = new WatsonTcpClient(BattletHost, BattlePort, _senderServerConnected, _senderServerDisconnected, _senderMessageReceived, false); + BattleNetSocket = new WatsonTcpClient(battletHost, battlePort, SenderServerConnected, SenderServerDisconnected, SenderMessageReceived, false); } - private bool _senderMessageReceived(byte[] data) + private bool SenderMessageReceived(byte[] data) { string msg = ""; if (data != null && data.Length > 0) msg = Encoding.UTF8.GetString(data); - Logger.Trace("Сообщение от Battle.net: {0}", msg); + Logger.Debug("Message from Battle.net: {0}", msg); var message = msg.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); var args = message[1].Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); @@ -61,28 +61,28 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem } catch (Exception e) { - Logger.WarnException(e, "Ошибка создания игры: "); + Logger.WarnException(e, "Error creating game: "); } }); break; default: - Logger.Warn("Неизвестное сообщение: {0}|{1}", message[0], message[1]); + Logger.Warn("Unknown message: {0}|{1}", message[0], message[1]); break; } return true; } - private bool _senderServerConnected() + private bool SenderServerConnected() { - //Logger.Info("GameServer подключен к BattleNet."); + Logger.Info("GameServer connected to BattleNet."); System.Threading.Thread.Sleep(3000); - string BackEndIP = Config.Instance.BindIP; - int BackEndPort = Config.Instance.Port; - bool PVP = false; - if (!PVP) - RegisterGameServer(BackEndIP, BackEndPort); + string backEndIp = Config.Instance.BindIP; + int backEndPort = Config.Instance.Port; + bool pvp = false; + if (!pvp) + RegisterGameServer(backEndIp, backEndPort); else - RegisterPvPGameServer(BackEndIP, BackEndPort); + RegisterPvPGameServer(backEndIp, backEndPort); return true; } @@ -97,7 +97,9 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem }); } - private bool _senderServerDisconnected() + private void BattleNetSocketSend(string data) => BattleNetSocketSend(Encoding.UTF8.GetBytes(data)); + + private bool SenderServerDisconnected() { Logger.Warn("MooNetServer was disconnected!"); return true; @@ -105,128 +107,130 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem public void RegisterGameServer(string ip, int port) { - Logger.Trace("RegisterGameServer(): ip {0}, port {1}", ip, port); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("rngsr|{0}/{1}", ip, port))); + Logger.Debug("RegisterGameServer(): ip {0}, port {1}", ip, port); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"rngsr|{ip}/{port}")); } public void RegisterPvPGameServer(string ip, int port) { - Logger.Trace("RegisterPvPGameServer(): ip {0}, port {1}", ip, port); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("rnpvpgsr|{0}/{1}", ip, port))); + Logger.Debug("RegisterPvPGameServer(): ip {0}, port {1}", ip, port); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"rnpvpgsr|{ip}/{port}")); } public void GrantAchievement(ulong gameAccountId, ulong achievementId) { - Logger.Trace("GrantAchievement(): gameAccountId {0}, achievementId {1}", gameAccountId, achievementId); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("grachi|{0}/{1}", gameAccountId, achievementId))); + Logger.Debug("GrantAchievement(): gameAccountId {0}, achievementId {1}", gameAccountId, achievementId); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"grachi|{gameAccountId}/{achievementId}")); } public void GrantCriteria(ulong gameAccountId, ulong criteriaId) { - Logger.Trace("GrantCriteria(): gameAccountId {0}, criteriaId {1}", gameAccountId, criteriaId); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("gcrit|{0}/{1}", gameAccountId, criteriaId))); + Logger.Debug("GrantCriteria(): gameAccountId {0}, criteriaId {1}", gameAccountId, criteriaId); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"gcrit|{gameAccountId}/{criteriaId}")); } public void UpdateAchievementCounter(ulong gameAccountId, int type, uint addCounter, int comparand, ulong achievement = 0) { - Logger.Trace("UpdateAchievementCounter(): type {0}, addCounter {1}, comparand {2}", type, addCounter, comparand); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("uoacce|{0}/{1}/{2}/{3}/{4}", gameAccountId, type, addCounter, comparand, achievement))); + Logger.Debug("UpdateAchievementCounter(): type {0}, addCounter {1}, comparand {2}", type, addCounter, comparand); + BattleNetSocketSend(Encoding.UTF8.GetBytes( + $"uoacce|{gameAccountId}/{type}/{addCounter}/{comparand}/{achievement}")); } public void UpdateSingleAchievementCounter(ulong gameAccountId, ulong achId, uint addCounter) { - Logger.Trace("UpdateSingleAchievementCounter(): type {0}, addCounter {1}", achId, addCounter); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("upsnaccr|{0}/{1}/{2}", gameAccountId, achId, addCounter))); + Logger.Debug("UpdateSingleAchievementCounter(): type {0}, addCounter {1}", achId, addCounter); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"upsnaccr|{gameAccountId}/{achId}/{addCounter}")); } public void UpdateQuantity(ulong gameAccountId, ulong achievementId, uint addCounter) { - Logger.Trace("UpdateQuantity(): achievementId {0}, addCounter {1}", achievementId, addCounter); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("upequt|{0}/{1}/{2}", gameAccountId, achievementId, addCounter))); + Logger.Debug("UpdateQuantity(): achievementId {0}, addCounter {1}", achievementId, addCounter); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"upequt|{gameAccountId}/{achievementId}/{addCounter}")); } public void CheckQuestCriteria(ulong gameAccountId, int questId, bool isCoop) { - Logger.Trace("CheckQuestCriteria(): gameAccountId {0}, questId {1}, coop {2}", gameAccountId, questId, isCoop); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("cqc|{0}/{1}/{2}", gameAccountId, questId, (isCoop ? "True" : "False")))); + Logger.Debug("CheckQuestCriteria(): gameAccountId {0}, questId {1}, coop {2}", gameAccountId, questId, isCoop); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"cqc|{gameAccountId}/{questId}/{(isCoop ? "True" : "False")}")); } public void CheckKillMonsterCriteria(ulong gameAccountId, int actorId, int type, bool isHardcore) { - Logger.Trace("CheckKillMonsterCriteria(): gameAccountId {0}, actorId {1}, type {2}, hc {3}", gameAccountId, actorId, type, isHardcore); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("ckmc|{0}/{1}/{2}/{3}", gameAccountId, actorId, type, (isHardcore ? "True" : "False")))); + Logger.Debug("CheckKillMonsterCriteria(): gameAccountId {0}, actorId {1}, type {2}, hc {3}", gameAccountId, actorId, type, isHardcore); + BattleNetSocketSend(Encoding.UTF8.GetBytes( + $"ckmc|{gameAccountId}/{actorId}/{type}/{(isHardcore ? "True" : "False")}")); } public void CheckSalvageItemCriteria(ulong gameAccountId, int itemId) { - Logger.Trace("CheckSalvageItemCriteria(): gameAccountId {0}, itemId {1}", gameAccountId, itemId); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("csic|{0}/{1}", gameAccountId, itemId))); + Logger.Debug("CheckSalvageItemCriteria(): gameAccountId {0}, itemId {1}", gameAccountId, itemId); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"csic|{gameAccountId}/{itemId}")); } public void CheckLevelCap(ulong gameAccountId) { - Logger.Trace("CheckLevelCap(): gameAccountId {0}", gameAccountId); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("clc|{0}", gameAccountId))); + Logger.Debug("CheckLevelCap(): gameAccountId {0}", gameAccountId); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"clc|{gameAccountId}")); } public void CheckConversationCriteria(ulong gameAccountId, int convId) { - Logger.Trace("CheckConversationCriteria(): gameAccountId {0}, convId {1}", gameAccountId, convId); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("ccc|{0}/{1}", gameAccountId, convId))); + Logger.Debug("CheckConversationCriteria(): gameAccountId {0}, convId {1}", gameAccountId, convId); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"ccc|{gameAccountId}/{convId}")); } public void CheckLevelAreaCriteria(ulong gameAccountId, int laId) { - Logger.Trace("CheckLevelAreaCriteria(): gameAccountId {0}, laId {1}", gameAccountId, laId); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("clac|{0}/{1}", gameAccountId, laId))); + Logger.Debug("CheckLevelAreaCriteria(): gameAccountId {0}, laId {1}", gameAccountId, laId); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"clac|{gameAccountId}/{laId}")); } public void UpdateClient(ulong gameAccountId, int level, int screen) { - Logger.Trace("UpdateClient(): gameAccountId {0}", gameAccountId); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("uc|{0}/{1}/{2}", gameAccountId, level, screen))); + Logger.Debug("UpdateClient(): gameAccountId {0}", gameAccountId); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"uc|{gameAccountId}/{level}/{screen}")); } public void PlayerJoined(int gameId) { - Logger.Trace("PlayerJoined(): gameId {0}", gameId); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("gpj|{0}", gameId))); + Logger.Debug("PlayerJoined(): gameId {0}", gameId); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"gpj|{gameId}")); } public void PlayerLeft(int gameId) { - Logger.Trace("PlayerLeft(): gameId {0}", gameId); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("gpl|{0}", gameId))); + Logger.Debug("PlayerLeft(): gameId {0}", gameId); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"gpl|{gameId}")); } public void SetGamePublic(int gameId) { - Logger.Trace("SetGamePublic(): gameId {0}", gameId); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("gsp|{0}", gameId))); + Logger.Debug("SetGamePublic(): gameId {0}", gameId); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"gsp|{gameId}")); } public void PvPSaveProgress(ulong gameAccountId, int kills, int wins, int gold) { - Logger.Trace("PvPSaveProgress(): gameAccountId {0}", gameAccountId); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("pvpsp|{0}/{1}/{2}/{3}", gameAccountId, kills, wins, gold))); + Logger.Debug("PvPSaveProgress(): gameAccountId {0}", gameAccountId); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"pvpsp|{gameAccountId}/{kills}/{wins}/{gold}")); } public void ParagonLevelUp(ulong gameAccountId) { - Logger.Trace("ParagonLevelUp(): gameAccountId {0}", gameAccountId); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("plu|{0}", gameAccountId))); + Logger.Debug("ParagonLevelUp(): gameAccountId {0}", gameAccountId); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"plu|{gameAccountId}")); } - public void ToonStateChanged(ulong toonID) + public void ToonStateChanged(ulong toonId) { - Logger.Trace("ToonStateChanged(): toonID {0}", toonID); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("tsc|{0}", toonID))); + Logger.Debug("ToonStateChanged(): toonID {0}", toonId); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"tsc|{toonId}")); } public void UniqueItemIdentified(ulong gameAccountId, ulong itemId) { - Logger.Trace("UniqueItemIdentified(): gameAccountId {0}, itemId {1}", gameAccountId, itemId); - BattleNetSocketSend(Encoding.UTF8.GetBytes(string.Format("uii|{0}/{1}", gameAccountId, itemId))); + Logger.Debug("UniqueItemIdentified(): gameAccountId {0}, itemId {1}", gameAccountId, itemId); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"uii|{gameAccountId}/{itemId}")); } } } diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/GeneratorsSystem/WorldGenerator.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/GeneratorsSystem/WorldGenerator.cs index 6b42c7c..e647c40 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/GeneratorsSystem/WorldGenerator.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/GeneratorsSystem/WorldGenerator.cs @@ -2690,7 +2690,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem if (world.QuadTree.Query(new Core.Types.Misc.Circle(location.Vector3D.X, location.Vector3D.Y, 60f)).Count > 0 || world.QuadTree.Query(new Core.Types.Misc.Circle(location.Vector3D.X, location.Vector3D.Y, 5f)).Count > 0) { - Logger.Trace("Load actor {0} ignored - waypoint nearby.", actorSno); + Logger.Debug("Load actor {0} ignored - waypoint nearby.", actorSno); return 0; } @@ -2731,7 +2731,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GeneratorsSystem if (world.QuadTree.Query(new DiIiS_NA.GameServer.Core.Types.Misc.Circle(location.Vector3D.X, location.Vector3D.Y, 60f)).Count > 0 || world.QuadTree.Query(new DiIiS_NA.GameServer.Core.Types.Misc.Circle(location.Vector3D.X, location.Vector3D.Y, 40f)).Count > 0) { - Logger.Trace("Load actor {0} ignored - waypoint nearby.", actorSno); + Logger.Debug("Load actor {0} ignored - waypoint nearby.", actorSno); return; } diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/PlayerSystem/Player.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/PlayerSystem/Player.cs index 859b1bb..4cccfb9 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/PlayerSystem/Player.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/PlayerSystem/Player.cs @@ -2371,6 +2371,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem Message = "Пампам" }); //*/ + #endregion if (World == null) return; @@ -2433,7 +2434,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem VacuumPickup(); if (World.Game.OnLoadWorldActions.ContainsKey(World.SNO)) { - Logger.Trace("OnLoadWorldActions: {0}", World.SNO); + Logger.Debug("OnLoadWorldActions: {0}", World.SNO); lock (World.Game.OnLoadWorldActions[World.SNO]) { try @@ -2449,7 +2450,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem } if (World.Game.OnLoadSceneActions.ContainsKey(CurrentScene.SceneSNO.Id)) { - Logger.Trace("OnLoadSceneActions: {0}", CurrentScene.SceneSNO.Id); + Logger.Debug("OnLoadSceneActions: {0}", CurrentScene.SceneSNO.Id); lock (World.Game.OnLoadSceneActions[CurrentScene.SceneSNO.Id]) { try @@ -2530,7 +2531,8 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem { var wpWorld = World.Game.GetWayPointWorldById(tryWaypointMessage.nWaypoint); var wayPoint = wpWorld.GetWayPointById(tryWaypointMessage.nWaypoint); - Logger.Warn("---Waypoint Debug---"); + if (wayPoint == null) return; + Logger.Debug("---Waypoint Debug---"); var proximity = new RectangleF(wayPoint.Position.X - 1f, wayPoint.Position.Y - 1f, 2f, 2f); var scenes = wpWorld.QuadTree.Query(proximity); if (scenes.Count == 0) return; // cork (is it real?) @@ -2544,9 +2546,8 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem } var levelArea = scene.Specification.SNOLevelAreas[0]; - Logger.Warn($"OnTryWaypoint: Id: {tryWaypointMessage.nWaypoint}, WorldId: {wpWorld.SNO}, levelArea: {levelArea}"); - if (wayPoint == null) return; - Logger.Warn($"WpWorld: {wpWorld}, wayPoint: {wayPoint}"); + Logger.Debug($"OnTryWaypoint: Id: {tryWaypointMessage.nWaypoint}, WorldId: {wpWorld.SNO}, levelArea: {levelArea}"); + Logger.Debug($"WpWorld: {wpWorld}, wayPoint: {wayPoint}"); InGameClient.SendMessage(new SimpleMessage(Opcodes.LoadingWarping)); if (wpWorld == World) Teleport(wayPoint.Position); @@ -2577,19 +2578,16 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem PlayerIndex = PlayerIndex, LevelAreaSNO = levelArea }); - Logger.Warn("---Waypoint Debug End---"); + Logger.Debug("---Waypoint Debug End---"); } public void RefreshReveal() { - float Range = 200f; + float range = 200f; if (InGameClient.Game.CurrentEncounter.activated) - Range = 360f; + range = 360f; - List actors_around = GetActorsInRange(Range); - - foreach (var actor in actors_around) - if (actor is not Player) - actor.Unreveal(this); + foreach (var actor in GetActorsInRange(range).Where(actor => actor is not Player)) + actor.Unreveal(this); RevealActorsToPlayer(); } private void OnRequestBuyItem(GameClient client, RequestBuyItemMessage requestBuyItemMessage) diff --git a/src/DiIiS-NA/Program.cs b/src/DiIiS-NA/Program.cs index 7ef54d5..585e74a 100644 --- a/src/DiIiS-NA/Program.cs +++ b/src/DiIiS-NA/Program.cs @@ -319,7 +319,7 @@ namespace DiIiS_NA Logger.Info("Discord bot Disabled.."); } DiIiS_NA.GameServer.GSSystem.GeneratorsSystem.SpawnGenerator.RegenerateDensity(); - DiIiS_NA.GameServer.ClientSystem.GameServer.GSBackend = new GSBackend(DiIiS_NA.LoginServer.Config.Instance.BindIP, DiIiS_NA.LoginServer.Config.Instance.WebPort); + DiIiS_NA.GameServer.ClientSystem.GameServer.GSBackend = new GsBackend(DiIiS_NA.LoginServer.Config.Instance.BindIP, DiIiS_NA.LoginServer.Config.Instance.WebPort); return true; }