diff --git a/src/DiIiS-NA/BGS-Server/AccountsSystem/GameAccount.cs b/src/DiIiS-NA/BGS-Server/AccountsSystem/GameAccount.cs index 6e3642c..2f9d7ec 100644 --- a/src/DiIiS-NA/BGS-Server/AccountsSystem/GameAccount.cs +++ b/src/DiIiS-NA/BGS-Server/AccountsSystem/GameAccount.cs @@ -948,7 +948,7 @@ public class GameAccount : PersistentRPCObject .SetName("D3.NotificationMessage.Payload") .SetValue(bgs.protocol.Variant.CreateBuilder().SetMessageValue(update.Build().ToByteString()))); - LoggedInClient.MakeRPC((lid) => + LoggedInClient.MakeRpc((lid) => bgs.protocol.notification.v1.NotificationListener.CreateStub(LoggedInClient).OnNotificationReceived( new HandlerController() { diff --git a/src/DiIiS-NA/BGS-Server/Battle/BattleBackend.cs b/src/DiIiS-NA/BGS-Server/Battle/BattleBackend.cs index 18c37ab..34e6a2e 100644 --- a/src/DiIiS-NA/BGS-Server/Battle/BattleBackend.cs +++ b/src/DiIiS-NA/BGS-Server/Battle/BattleBackend.cs @@ -16,19 +16,19 @@ namespace DiIiS_NA.LoginServer.Battle { public class BattleBackend { - private static readonly Logger Logger = LogManager.CreateLogger("BattleNetEmu"); + private static readonly Logger Logger = LogManager.CreateLogger("BattleBackend"); - public WatsonTcpServer GameServerSocket; + public readonly WatsonTcpServer GameServerSocket; public struct ServerDescriptor { - public string GameIP; + public string GameIp; public int GamePort; }; - public Dictionary GameServers = new Dictionary(); + public readonly Dictionary GameServers = new(); - public Dictionary PvPGameServers = new Dictionary(); + private readonly Dictionary _pvPGameServers = new(); public BattleBackend(string battleHost, int port) { @@ -38,33 +38,36 @@ namespace DiIiS_NA.LoginServer.Battle private bool ReceiverClientConnected(string ipPort) { - Logger.Info($"Blizzless server loaded {ipPort} - connecting..."); + Logger.Info($"Blizzless client connected {ipPort}..."); return true; } private bool ReceiverClientDisconnected(string ipPort) { - Logger.Warn("Blizzless server at {0} was disconnected!", ipPort); + Logger.Warn("Blizzless client disconnected $[white]${0}$[/]$!", ipPort); if (GameServers.ContainsKey(ipPort)) GameServers.Remove(ipPort); - if (PvPGameServers.ContainsKey(ipPort)) PvPGameServers.Remove(ipPort); + if (_pvPGameServers.ContainsKey(ipPort)) _pvPGameServers.Remove(ipPort); if (GameServers.Count == 0) Logger.Warn("GameServers list is empty! Unable to use PvE game activities atm."); - if (PvPGameServers.Count == 0) + if (_pvPGameServers.Count == 0) Logger.Warn("PvPGameServers list is empty! Unable to use PvP game activities atm."); return true; } - public void CreateGame(string ipPort, int GameId, int level, int act, int difficulty, int questId, int questStepId, bool isHardcore, int gamemode, bool iSseasoned, int perftest_id = 0) + public void CreateGame(string ipPort, int gameId, int level, int act, int difficulty, int questId, int questStepId, bool isHardcore, int gameMode, bool isSeasoned, int perftestId = 0) { - GameServerSocket.Send(ipPort, Encoding.UTF8.GetBytes(string.Format("diiiscg|{0}/{1}/{2}/{3}/{4}/{5}/{6}/{7}/{8}", GameId, level, act, difficulty, questId, questStepId, isHardcore, gamemode, iSseasoned, perftest_id))); + Send(ipPort, $"diiiscg|{gameId}/{level}/{act}/{difficulty}/{questId}/{questStepId}/{isHardcore}/{gameMode}/{isSeasoned}"); } + + private void Send(string ipPort, string data) + => GameServerSocket.Send(ipPort, Encoding.UTF8.GetBytes(data)); private bool ReceiverMessageReceived(string ipPort, byte[] data) { string msg = ""; if (data != null && data.Length > 0) msg = Encoding.UTF8.GetString(data); - Logger.Trace("Message received from {0}: {1}", ipPort, msg); + Logger.Trace("Message received from $[grey69]${0}$[/]$: $[white]${1}$[/]$", ipPort, msg); var message = msg.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); var args = message[1].Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); @@ -72,134 +75,134 @@ namespace DiIiS_NA.LoginServer.Battle { case "rngsr": if (GameServers.ContainsKey(ipPort)) GameServers.Remove(ipPort); - string rgs_ip = args[0]; - int rgs_port = int.Parse(args[1].Trim()); - GameServers.Add(ipPort, new ServerDescriptor { GameIP = rgs_ip, GamePort = rgs_port }); - Logger.Info("Game server was registered for Blizzless {0}:{1}.", rgs_ip, rgs_port); + string rgsIp = args[0]; + int rgsPort = int.Parse(args[1].Trim()); + GameServers.Add(ipPort, new ServerDescriptor { GameIp = rgsIp, GamePort = rgsPort }); + Logger.Info("Game server was registered for Blizzless {0}:{1}.", rgsIp, rgsPort); break; case "rnpvpgsr": - if (PvPGameServers.ContainsKey(ipPort)) PvPGameServers.Remove(ipPort); - string rpgs_ip = args[0]; - int rpgs_port = int.Parse(args[1].Trim()); - PvPGameServers.Add(ipPort, new ServerDescriptor { GameIP = rpgs_ip, GamePort = rpgs_port }); - Logger.Info("PvP GameServer at {0}:{1} successfully signed and ready to work.", rpgs_ip, rpgs_port); + if (_pvPGameServers.ContainsKey(ipPort)) _pvPGameServers.Remove(ipPort); + string rpgsIp = args[0]; + int rpgsPort = int.Parse(args[1].Trim()); + _pvPGameServers.Add(ipPort, new ServerDescriptor { GameIp = rpgsIp, GamePort = rpgsPort }); + Logger.Info("PvP GameServer at {0}:{1} successfully signed and ready to work.", rpgsIp, rpgsPort); break; case "grachi": - ulong gachi_accId = ulong.Parse(args[0].Trim()); - ulong gachi_achId = ulong.Parse(args[1].Trim()); + ulong gachiAccId = ulong.Parse(args[0].Trim()); + ulong gachiAchId = ulong.Parse(args[1].Trim()); System.Threading.Tasks.Task.Delay(1).ContinueWith((a) => { - foreach (var gachi_invokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == gachi_accId)) - AchievementManager.GrantAchievement(gachi_invokerClient, gachi_achId); + foreach (var gachiInvokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == gachiAccId)) + AchievementManager.GrantAchievement(gachiInvokerClient, gachiAchId); }); break; case "gcrit": - ulong gc_accId = ulong.Parse(args[0].Trim()); - ulong gc_criId = ulong.Parse(args[1].Trim()); + ulong gcAccId = ulong.Parse(args[0].Trim()); + ulong gcCriId = ulong.Parse(args[1].Trim()); System.Threading.Tasks.Task.Delay(1).ContinueWith((a) => { - foreach (var gc_invokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == gc_accId)) - AchievementManager.GrantCriteria(gc_invokerClient, gc_criId); + foreach (var gcInvokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == gcAccId)) + AchievementManager.GrantCriteria(gcInvokerClient, gcCriId); }); break; case "upequt": - ulong uq_accId = ulong.Parse(args[0].Trim()); - ulong uq_achId = ulong.Parse(args[1].Trim()); - uint uq_addCounter = uint.Parse(args[2].Trim()); + ulong uqAccId = ulong.Parse(args[0].Trim()); + ulong uqAchId = ulong.Parse(args[1].Trim()); + uint uqAddCounter = uint.Parse(args[2].Trim()); System.Threading.Tasks.Task.Delay(1).ContinueWith((a) => { - foreach (var uq_invokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == uq_accId)) - AchievementManager.UpdateQuantity(uq_invokerClient, uq_achId, uq_addCounter); + foreach (var uqInvokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == uqAccId)) + AchievementManager.UpdateQuantity(uqInvokerClient, uqAchId, uqAddCounter); }); break; case "uoacce": - ulong uac_accId = ulong.Parse(args[0].Trim()); - int uac_typeId = int.Parse(args[1].Trim()); - uint uac_addCounter = uint.Parse(args[2].Trim()); - int uac_comparand = int.Parse(args[3].Trim()); - ulong uac_achi = ulong.Parse(args[4].Trim()); + ulong uacAccId = ulong.Parse(args[0].Trim()); + int uacTypeId = int.Parse(args[1].Trim()); + uint uacAddCounter = uint.Parse(args[2].Trim()); + int uacComparand = int.Parse(args[3].Trim()); + ulong uacAchi = ulong.Parse(args[4].Trim()); System.Threading.Tasks.Task.Delay(1).ContinueWith((a) => { - if (uac_achi == 0) - foreach (var uac_invokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == uac_accId)) - AchievementManager.UpdateAllCounters(uac_invokerClient, uac_typeId, uac_addCounter, uac_comparand); + if (uacAchi == 0) + foreach (var uacInvokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == uacAccId)) + AchievementManager.UpdateAllCounters(uacInvokerClient, uacTypeId, uacAddCounter, uacComparand); else - foreach (var uac_invokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == uac_accId)) - AchievementManager.UpdateAllCounters(uac_invokerClient, uac_typeId, uac_addCounter, uac_comparand); + foreach (var uacInvokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == uacAccId)) + AchievementManager.UpdateAllCounters(uacInvokerClient, uacTypeId, uacAddCounter, uacComparand); }); break; case "upsnaccr": //UpdateSingleAchievementCounter - ulong usac_accId = ulong.Parse(args[0].Trim()); - ulong usac_achId = ulong.Parse(args[1].Trim()); - uint usac_addCounter = uint.Parse(args[2].Trim()); + ulong usacAccId = ulong.Parse(args[0].Trim()); + ulong usacAchId = ulong.Parse(args[1].Trim()); + uint usacAddCounter = uint.Parse(args[2].Trim()); System.Threading.Tasks.Task.Delay(1).ContinueWith((a) => { - foreach (var usac_invokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == usac_accId)) - AchievementManager.UpdateQuantity(usac_invokerClient, usac_achId, usac_addCounter); + foreach (var usacInvokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == usacAccId)) + AchievementManager.UpdateQuantity(usacInvokerClient, usacAchId, usacAddCounter); }); break; case "cqc": //CheckQuestCriteria - ulong cqc_accId = ulong.Parse(args[0].Trim()); - int cqc_qId = int.Parse(args[1].Trim()); - bool cqc_isCoop = (args[2].Trim() == "True" ? true : false); + ulong cqcAccId = ulong.Parse(args[0].Trim()); + int cqcQId = int.Parse(args[1].Trim()); + bool cqcIsCoop = (args[2].Trim() == "True" ? true : false); System.Threading.Tasks.Task.Delay(1).ContinueWith((a) => { - foreach (var cqc_invokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == cqc_accId)) - AchievementManager.CheckQuestCriteria(cqc_invokerClient, cqc_qId, cqc_isCoop); + foreach (var cqcInvokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == cqcAccId)) + AchievementManager.CheckQuestCriteria(cqcInvokerClient, cqcQId, cqcIsCoop); }); break; case "ckmc": //CheckKillMonsterCriteria - ulong ckmc_accId = ulong.Parse(args[0].Trim()); - int ckmc_actorId = int.Parse(args[1].Trim()); - int ckmc_type = int.Parse(args[2].Trim()); - bool ckmc_isHardcore = (args[3].Trim() == "True" ? true : false); + ulong ckmcAccId = ulong.Parse(args[0].Trim()); + int ckmcActorId = int.Parse(args[1].Trim()); + int ckmcType = int.Parse(args[2].Trim()); + bool ckmcIsHardcore = (args[3].Trim() == "True" ? true : false); System.Threading.Tasks.Task.Delay(1).ContinueWith((a) => { - foreach (var ckmc_invokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == ckmc_accId)) - AchievementManager.CheckKillMonsterCriteria(ckmc_invokerClient, ckmc_actorId, ckmc_type, ckmc_isHardcore); + foreach (var ckmcInvokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == ckmcAccId)) + AchievementManager.CheckKillMonsterCriteria(ckmcInvokerClient, ckmcActorId, ckmcType, ckmcIsHardcore); }); break; case "clc": //CheckLevelCap - ulong clc_accId = ulong.Parse(args[0].Trim()); + ulong clcAccId = ulong.Parse(args[0].Trim()); System.Threading.Tasks.Task.Delay(1).ContinueWith((a) => { - foreach (var clc_invokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == clc_accId)) - AchievementManager.CheckLevelCap(clc_invokerClient); + foreach (var clcInvokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == clcAccId)) + AchievementManager.CheckLevelCap(clcInvokerClient); }); break; case "csic": //CheckSalvageItemCriteria - ulong csic_accId = ulong.Parse(args[0].Trim()); - int csic_itemId = int.Parse(args[1].Trim()); + ulong csicAccId = ulong.Parse(args[0].Trim()); + int csicItemId = int.Parse(args[1].Trim()); System.Threading.Tasks.Task.Delay(1).ContinueWith((a) => { - foreach (var csic_invokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == csic_accId)) - AchievementManager.CheckSalvageItemCriteria(csic_invokerClient, csic_itemId); + foreach (var csicInvokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == csicAccId)) + AchievementManager.CheckSalvageItemCriteria(csicInvokerClient, csicItemId); }); break; case "clac": //CheckLevelAreaCriteria - ulong clac_accId = ulong.Parse(args[0].Trim()); - int clac_laId = int.Parse(args[1].Trim()); + ulong clacAccId = ulong.Parse(args[0].Trim()); + int clacLaId = int.Parse(args[1].Trim()); System.Threading.Tasks.Task.Delay(1).ContinueWith((a) => { - foreach (var clac_invokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == clac_accId)) - AchievementManager.CheckLevelAreaCriteria(clac_invokerClient, clac_laId); + foreach (var clacInvokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == clacAccId)) + AchievementManager.CheckLevelAreaCriteria(clacInvokerClient, clacLaId); }); break; case "ccc": //CheckConversationCriteria - ulong ccc_accId = ulong.Parse(args[0].Trim()); - int ccc_cId = int.Parse(args[1].Trim()); + ulong cccAccId = ulong.Parse(args[0].Trim()); + int cccCId = int.Parse(args[1].Trim()); System.Threading.Tasks.Task.Delay(1).ContinueWith((a) => { - foreach (var ccc_invokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == ccc_accId)) - AchievementManager.CheckConversationCriteria(ccc_invokerClient, ccc_cId); + foreach (var cccInvokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == cccAccId)) + AchievementManager.CheckConversationCriteria(cccInvokerClient, cccCId); }); break; case "plu": //ParagonLevelUp - ulong plu_accId = ulong.Parse(args[0].Trim()); + ulong pluAccId = ulong.Parse(args[0].Trim()); System.Threading.Tasks.Task.Delay(1).ContinueWith((a) => { - var plr_client = PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == plu_accId).FirstOrDefault(); - if (plr_client != null && plr_client.Account.GameAccount. Clan != null) - plr_client.Account.GameAccount.Clan.ParagonRatings[plr_client.Account.GameAccount] = plr_client.Account.GameAccount.DBGameAccount.ParagonLevel; + var plrClient = PlayerManager.OnlinePlayers.FirstOrDefault(c => c.Account.GameAccount.PersistentID == pluAccId); + if (plrClient != null && plrClient.Account.GameAccount. Clan != null) + plrClient.Account.GameAccount.Clan.ParagonRatings[plrClient.Account.GameAccount] = plrClient.Account.GameAccount.DBGameAccount.ParagonLevel; }); break; case "uii": //UniqueItemIdentified - ulong uii_accId = ulong.Parse(args[0].Trim()); - ulong uii_itemId = ulong.Parse(args[1].Trim()); + ulong uiiAccId = ulong.Parse(args[0].Trim()); + ulong uiiItemId = ulong.Parse(args[1].Trim()); System.Threading.Tasks.Task.Delay(1).ContinueWith((a) => { - var plr_client = PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == uii_accId).FirstOrDefault(); - if (plr_client != null && plr_client.Account.GameAccount.Clan != null) + var plrClient = PlayerManager.OnlinePlayers.FirstOrDefault(c => c.Account.GameAccount.PersistentID == uiiAccId); + if (plrClient != null && plrClient.Account.GameAccount.Clan != null) { - var dbItem = DBSessions.SessionGet(uii_itemId); + var dbItem = DBSessions.SessionGet(uiiItemId); if (dbItem != null) { var generator = D3.Items.Generator.CreateBuilder() @@ -219,92 +222,92 @@ namespace DiIiS_NA.LoginServer.Battle generator.AddBaseAffixes(result); } - plr_client.Account.GameAccount.Clan.AddNews(plr_client.Account.GameAccount, 0, generator.Build().ToByteArray()); + plrClient.Account.GameAccount.Clan.AddNews(plrClient.Account.GameAccount, 0, generator.Build().ToByteArray()); } } }); break; case "uc": //UpdateClient - ulong uc_accId = ulong.Parse(args[0].Trim()); - int uc_level = int.Parse(args[1].Trim()); - int uc_screen = int.Parse(args[2].Trim()); + ulong ucAccId = ulong.Parse(args[0].Trim()); + int ucLevel = int.Parse(args[1].Trim()); + int ucScreen = int.Parse(args[2].Trim()); System.Threading.Tasks.Task.Delay(1).ContinueWith((a) => { try { - foreach (var uc_invokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == uc_accId)) + foreach (var ucInvokerClient in PlayerManager.OnlinePlayers.Where(c => c.Account.GameAccount.PersistentID == ucAccId)) { - if (!uc_invokerClient.Account.IsOnline) continue; - uc_invokerClient.Account.GameAccount.ChangedFields.SetPresenceFieldValue(uc_invokerClient.Account.GameAccount.CurrentToon.HeroLevelField); - uc_invokerClient.Account.GameAccount.ChangedFields.SetPresenceFieldValue(uc_invokerClient.Account.GameAccount.CurrentToon.HeroParagonLevelField); - if (uc_screen != -1) uc_invokerClient.Account.GameAccount.ScreenStatus = D3.PartyMessage.ScreenStatus.CreateBuilder().SetScreen(uc_screen).SetStatus(0).Build(); - uc_invokerClient.Account.GameAccount.NotifyUpdate(); + if (!ucInvokerClient.Account.IsOnline) continue; + ucInvokerClient.Account.GameAccount.ChangedFields.SetPresenceFieldValue(ucInvokerClient.Account.GameAccount.CurrentToon.HeroLevelField); + ucInvokerClient.Account.GameAccount.ChangedFields.SetPresenceFieldValue(ucInvokerClient.Account.GameAccount.CurrentToon.HeroParagonLevelField); + if (ucScreen != -1) ucInvokerClient.Account.GameAccount.ScreenStatus = D3.PartyMessage.ScreenStatus.CreateBuilder().SetScreen(ucScreen).SetStatus(0).Build(); + ucInvokerClient.Account.GameAccount.NotifyUpdate(); } } catch { } }); break; case "gpj": //PlayerJoined - int gpj_gameId = int.Parse(args[0].Trim()); + int gpjGameId = int.Parse(args[0].Trim()); System.Threading.Tasks.Task.Delay(1).ContinueWith((a) => { try { - GameFactoryManager.FindGameByDynamicId((ulong)gpj_gameId).PlayersCount++; + GameFactoryManager.FindGameByDynamicId((ulong)gpjGameId).PlayersCount++; } catch { } }); break; case "gpl": //PlayerLeft - int gpl_gameId = int.Parse(args[0].Trim()); + int gplGameId = int.Parse(args[0].Trim()); System.Threading.Tasks.Task.Delay(1).ContinueWith((a) => { try { - if (GameFactoryManager.FindGameByDynamicId((ulong)gpl_gameId) != null) - GameFactoryManager.FindGameByDynamicId((ulong)gpl_gameId).PlayersCount--; + if (GameFactoryManager.FindGameByDynamicId((ulong)gplGameId) != null) + GameFactoryManager.FindGameByDynamicId((ulong)gplGameId).PlayersCount--; } catch { } }); break; case "gsp": //SetGamePublic - int gsp_gameId = int.Parse(args[0].Trim()); + int gspGameId = int.Parse(args[0].Trim()); System.Threading.Tasks.Task.Delay(1).ContinueWith((a) => { try { - GameFactoryManager.FindGameByDynamicId((ulong)gsp_gameId).Public = true; + GameFactoryManager.FindGameByDynamicId((ulong)gspGameId).Public = true; } catch { } }); break; case "tsc": //ToonStateChanged - int tsc_toonId = int.Parse(args[0].Trim()); + int tscToonId = int.Parse(args[0].Trim()); System.Threading.Tasks.Task.Delay(1).ContinueWith((a) => { try { - Toons.ToonManager.GetToonByLowID((ulong)tsc_toonId).StateChanged(); + Toons.ToonManager.GetToonByLowID((ulong)tscToonId).StateChanged(); } catch { } }); break; case "pvpsp": //PvPSaveProgress - ulong pvpsp_gAccId = ulong.Parse(args[0].Trim()); - int pvpsp_kills = int.Parse(args[1].Trim()); - int pvpsp_wins = int.Parse(args[2].Trim()); - int pvpsp_gold = int.Parse(args[3].Trim()); + ulong pvpspGAccId = ulong.Parse(args[0].Trim()); + int pvpspKills = int.Parse(args[1].Trim()); + int pvpspWins = int.Parse(args[2].Trim()); + int pvpspGold = int.Parse(args[3].Trim()); System.Threading.Tasks.Task.Delay(1).ContinueWith((a) => { - var gAcc = GameAccountManager.GetAccountByPersistentID(pvpsp_gAccId); + var gAcc = GameAccountManager.GetAccountByPersistentID(pvpspGAccId); lock (gAcc.DBGameAccount) { var dbGAcc = gAcc.DBGameAccount; - dbGAcc.PvPTotalKilled += (ulong)pvpsp_kills; - dbGAcc.PvPTotalWins += (ulong)pvpsp_wins; - dbGAcc.PvPTotalGold += (ulong)pvpsp_gold; + dbGAcc.PvPTotalKilled += (ulong)pvpspKills; + dbGAcc.PvPTotalWins += (ulong)pvpspWins; + dbGAcc.PvPTotalGold += (ulong)pvpspGold; DBSessions.SessionUpdate(dbGAcc); } }); break; default: - Logger.Warn("Unknown message type: {0}|{1}", message[0], message[1]); + Logger.Warn("Unknown message type: $[white]${0}|{1}$[/]$", message[0], message[1]); break; } return true; diff --git a/src/DiIiS-NA/BGS-Server/Battle/BattleClient.cs b/src/DiIiS-NA/BGS-Server/Battle/BattleClient.cs index 2a0609d..d3cf464 100644 --- a/src/DiIiS-NA/BGS-Server/Battle/BattleClient.cs +++ b/src/DiIiS-NA/BGS-Server/Battle/BattleClient.cs @@ -30,33 +30,33 @@ namespace DiIiS_NA.LoginServer.Battle public ISocketChannel SocketConnection { get; private set; } public IChannelHandlerContext Connect { get; private set; } public bool AuthenticationStatus = false; - public ClientLocale ClientLanguage = ClientLocale.enUS; + public ClientLocale ClientLanguage = ClientLocale.EN_US; public IRpcController ListenerController; private uint _tokenCounter = 0; - public static NO_RESPONSE NO_RESPONSE = NO_RESPONSE.CreateBuilder().Build(); + public static NO_RESPONSE NoResponse = NO_RESPONSE.CreateBuilder().Build(); private readonly Dictionary _pendingResponses = new(); // TODO: Check usage and remove if not needed public bgs.protocol.v2.Attribute AttributeOfServer { get; set; } public Account Account { get; set; } - public const byte ServiceReply = 0xFE; + public const byte SERVICE_REPLY = 0xFE; public SslStream Ssl = null; - private static int REQUEST_SERVICE_ID = 0; - private static int RESPONSE_SERVICE_ID = 254; + private static int _requestServiceId = 0; + private static int _responseServiceId = 254; //public object clientLock = new object(); - public readonly object _serviceLock = new(); - public object messageLock = new(); + public readonly object ServiceLock = new(); + public object MessageLock = new(); private ulong _listenerId; // last targeted rpc object. - public bool MOTDSent { get; private set; } + public bool MotdSent { get; private set; } private ConcurrentDictionary MappedObjects { get; set; } public bool GuildChannelsRevealed = false; public string GameTeamTag = ""; - public ulong CID = 0; + public readonly ulong Cid = 0; #region current channel - public Dictionary Channels = new(); + public readonly Dictionary Channels = new(); - public List ChatChannels = new(); + public readonly List ChatChannels = new(); public Channel PartyChannel; //Used for all non game related messages public Channel GameChannel; //Used for all game related messages @@ -103,7 +103,7 @@ namespace DiIiS_NA.LoginServer.Battle .AddAttribute(bgs.protocol.Attribute.CreateBuilder().SetName("whisper") .SetValue(Variant.CreateBuilder().SetStringValue(text).Build()).Build()).Build(); - MakeRPC((lid) => bgs.protocol.notification.v1.NotificationListener.CreateStub(this). + MakeRpc((lid) => bgs.protocol.notification.v1.NotificationListener.CreateStub(this). OnNotificationReceived(new HandlerController() { ListenerId = lid @@ -120,8 +120,8 @@ namespace DiIiS_NA.LoginServer.Battle public void LeaveAllChannels() { - List _channels = Channels.Values.ToList(); - foreach (var channel in _channels) + List channels = Channels.Values.ToList(); + foreach (var channel in channels) { try { @@ -134,12 +134,12 @@ namespace DiIiS_NA.LoginServer.Battle #endregion - public BattleClient(ISocketChannel socketChannel, DotNetty.Handlers.Tls.TlsHandler TLS) + public BattleClient(ISocketChannel socketChannel, DotNetty.Handlers.Tls.TlsHandler tls) { SocketConnection = socketChannel; Services = new Dictionary(); MappedObjects = new ConcurrentDictionary(); - MOTDSent = false; + MotdSent = false; if (SocketConnection.Active) Logger.Trace("Client - {0} - successfully encrypted the connection", socketChannel.RemoteAddress); } @@ -150,7 +150,7 @@ namespace DiIiS_NA.LoginServer.Battle Header header = msg.GetHeader(); byte[] payload = (byte[])msg.GetPayload(); - if (msg.GetHeader().ServiceId == RESPONSE_SERVICE_ID) + if (msg.GetHeader().ServiceId == _responseServiceId) { if (_pendingResponses.Count == 0) return; RPCCallBack done = _pendingResponses[(int)header.Token]; @@ -276,7 +276,7 @@ namespace DiIiS_NA.LoginServer.Battle #endif service.CallMethod(method, controller, message, - (IMessage m) => { sendResponse(ctx, (int)header.Token, m, controller.Status); }); + (IMessage m) => { SendResponse(ctx, (int)header.Token, m, controller.Status); }); } } catch (NotImplementedException) @@ -319,69 +319,69 @@ namespace DiIiS_NA.LoginServer.Battle /// /// Deutsch. /// - deDE, + DE_DE, /// /// English (EU) /// - enGB, + EN_GB, /// /// English (Singapore) /// - enSG, + EN_SG, /// /// English (US) /// - enUS, + EN_US, /// /// Espanol /// - esES, + ES_ES, /// /// Espanol (Mexico) /// - esMX, + ES_MX, /// /// French /// - frFR, + FR_FR, /// /// Italian /// - itIT, + IT_IT, /// /// Korean /// - koKR, + KO_KR, /// /// Polish /// - plPL, + PL_PL, /// /// Portuguese /// - ptPT, + PT_PT, /// /// Portuguese (Brazil) /// - ptBR, + PT_BR, /// /// Russian /// - ruRU, + RU_RU, /// /// Turkish /// - trTR, + TR_TR, /// /// Chinese /// - zhCN, + ZH_CN, /// /// Chinese (Taiwan) /// - zhTW + ZH_TW } - public virtual void MakeTargetedRPC(RPCObject targetObject, Action rpc) + public virtual void MakeTargetedRpc(RPCObject targetObject, Action rpc) { Task.Run(() => { @@ -400,7 +400,7 @@ namespace DiIiS_NA.LoginServer.Battle //} }); } - public virtual void MakeRPC(Action rpc) + public virtual void MakeRpc(Action rpc) { Task.Run(() => { @@ -444,12 +444,12 @@ namespace DiIiS_NA.LoginServer.Battle var serviceId = Services[serviceHash]; var token = _tokenCounter++; - sendRequest(Connect, serviceHash, GetMethodId(method), token, request, (uint)_listenerId, status); + SendRequest(Connect, serviceHash, GetMethodId(method), token, request, (uint)_listenerId, status); } - public static void sendRequest(IChannelHandlerContext ctx, uint serviceHash, uint methodId, uint token, IMessage request, uint listenerId, uint status) + public static void SendRequest(IChannelHandlerContext ctx, uint serviceHash, uint methodId, uint token, IMessage request, uint listenerId, uint status) { Header.Builder builder = Header.CreateBuilder(); - builder.SetServiceId((uint)REQUEST_SERVICE_ID); + builder.SetServiceId((uint)_requestServiceId); builder.SetServiceHash(serviceHash); builder.SetMethodId(methodId); if (listenerId != 0) @@ -462,7 +462,7 @@ namespace DiIiS_NA.LoginServer.Battle } /// The local objectId. /// The remote objectId over client. - public void MapLocalObjectID(ulong localObjectId, ulong remoteObjectId) + public void MapLocalObjectId(ulong localObjectId, ulong remoteObjectId) { try { @@ -501,10 +501,10 @@ namespace DiIiS_NA.LoginServer.Battle return (uint)(method.Index) + 1; } } - public static void sendResponse(IChannelHandlerContext ctx, int token, IMessage response, uint status) + public static void SendResponse(IChannelHandlerContext ctx, int token, IMessage response, uint status) { Header.Builder builder = Header.CreateBuilder(); - builder.SetServiceId((uint)RESPONSE_SERVICE_ID); + builder.SetServiceId((uint)_responseServiceId); builder.SetToken((uint)token); builder.SetStatus(status); if (response != null) @@ -512,15 +512,15 @@ namespace DiIiS_NA.LoginServer.Battle ctx.Channel.WriteAndFlushAsync(new BNetPacket(builder.Build(), response)); } - public void SendMOTD() + public void SendMotd() { - if (MOTDSent) + if (MotdSent) return; var motd = "Welcome to BlizzLess.Net Alpha-Build Server!"; SendServerWhisper(motd); - MOTDSent = true; + MotdSent = true; } public override void ChannelInactive(IChannelHandlerContext context) diff --git a/src/DiIiS-NA/BGS-Server/Battle/PlayerManager.cs b/src/DiIiS-NA/BGS-Server/Battle/PlayerManager.cs index db7359f..26015e7 100644 --- a/src/DiIiS-NA/BGS-Server/Battle/PlayerManager.cs +++ b/src/DiIiS-NA/BGS-Server/Battle/PlayerManager.cs @@ -26,9 +26,9 @@ namespace DiIiS_NA.LoginServer.Battle public static BattleClient GetClientByEmail(string email) => OnlinePlayers.FirstOrDefault(cli => cli.Account.Email == email); public static BattleClient GetClientByBattleTag(string battleTag) => OnlinePlayers.FirstOrDefault(cli => cli.Account.BattleTag == battleTag); - public static BattleClient GetClientByCID(ulong cid) + public static BattleClient GetClientByCid(ulong cid) { - return OnlinePlayers.FirstOrDefault(bc => bc.CID == cid); + return OnlinePlayers.FirstOrDefault(bc => bc.Cid == cid); } public static void SendWhisper(string message) diff --git a/src/DiIiS-NA/BGS-Server/ChannelSystem/Channel.cs b/src/DiIiS-NA/BGS-Server/ChannelSystem/Channel.cs index 6cdcd8f..09e8494 100644 --- a/src/DiIiS-NA/BGS-Server/ChannelSystem/Channel.cs +++ b/src/DiIiS-NA/BGS-Server/ChannelSystem/Channel.cs @@ -93,7 +93,7 @@ namespace DiIiS_NA.LoginServer.ChannelSystem this.IsGuildChatChannel = false; if ((client != null) && (remoteObjectId != 0)) - client.MapLocalObjectID(this.DynamicId, remoteObjectId); + client.MapLocalObjectId(this.DynamicId, remoteObjectId); if (this.IsChatChannel) Program.Watchdog.AddTask(10, new Action(() => @@ -175,7 +175,7 @@ namespace DiIiS_NA.LoginServer.ChannelSystem .AddStateChange(channelMember) .Build(); - client.MakeTargetedRPC(this, (lid) => + client.MakeTargetedRpc(this, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(client).OnUpdateMemberState(new HandlerController() { ListenerId = lid } , notification, callback => { })); } @@ -201,7 +201,7 @@ namespace DiIiS_NA.LoginServer.ChannelSystem //Notify all Channel members foreach (var n_member in this.Members.Keys) { - n_member.MakeTargetedRPC(this, (lid) => + n_member.MakeTargetedRpc(this, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(n_member).OnUpdateMemberState(new HandlerController() { ListenerId = lid }, notification, callback => { })); } } @@ -213,7 +213,7 @@ namespace DiIiS_NA.LoginServer.ChannelSystem public void Join(BattleClient client, ulong remoteObjectId) { - client.MapLocalObjectID(this.DynamicId, remoteObjectId); + client.MapLocalObjectId(this.DynamicId, remoteObjectId); this.AddMember(client); } @@ -249,7 +249,7 @@ namespace DiIiS_NA.LoginServer.ChannelSystem .AddRangeMember(members) .Build(); - client.MakeTargetedRPC(this, (lid) => + client.MakeTargetedRpc(this, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(client).OnJoin(new HandlerController() { ListenerId = lid }, joinNotification, callback => { })); @@ -276,7 +276,7 @@ namespace DiIiS_NA.LoginServer.ChannelSystem foreach (var pair in this.Members.Where(pair => pair.Value != addedMember)) // only send this to previous members of the channel. { - pair.Key.MakeTargetedRPC(this, (lid) => + pair.Key.MakeTargetedRpc(this, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(pair.Key).OnMemberAdded(new HandlerController() { ListenerId = lid }, addNotification, callback => { })); } @@ -348,10 +348,10 @@ namespace DiIiS_NA.LoginServer.ChannelSystem foreach (var pair in this.Members) { if (pair.Key != client) - pair.Key.MakeTargetedRPC(this, (lid) => + pair.Key.MakeTargetedRpc(this, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(pair.Key).OnMemberRemoved(new HandlerController() { ListenerId = lid }, removeMessage, callback => { })); } - client.MakeTargetedRPC(this, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(client).OnLeave(new HandlerController() { ListenerId = lid }, leaveMessage, callback => + client.MakeTargetedRpc(this, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(client).OnLeave(new HandlerController() { ListenerId = lid }, leaveMessage, callback => { client.UnmapLocalObjectId(this.DynamicId); })); @@ -431,7 +431,7 @@ namespace DiIiS_NA.LoginServer.ChannelSystem foreach (var pair in this.Members) // send to all members of channel even to the actual one that sent the message else he'll not see his own message. { if (pair.Key.Account.IgnoreIds.Contains(client.Account.PersistentID)) continue; - pair.Key.MakeTargetedRPC(this, (lid) => + pair.Key.MakeTargetedRpc(this, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(pair.Key).OnSendMessage(new HandlerController() { ListenerId = lid }, notification, callback => { })); } } diff --git a/src/DiIiS-NA/BGS-Server/ChannelSystem/ChannelInvitationManager.cs b/src/DiIiS-NA/BGS-Server/ChannelSystem/ChannelInvitationManager.cs index 3613acd..d521151 100644 --- a/src/DiIiS-NA/BGS-Server/ChannelSystem/ChannelInvitationManager.cs +++ b/src/DiIiS-NA/BGS-Server/ChannelSystem/ChannelInvitationManager.cs @@ -54,7 +54,7 @@ namespace DiIiS_NA.LoginServer.ChannelSystem var notification = bgs.protocol.channel.v1.InvitationAddedNotification.CreateBuilder().SetInvitation(invitation); - invitee.MakeTargetedRPC(this, (lid) => + invitee.MakeTargetedRpc(this, (lid) => bgs.protocol.channel.v1.ChannelInvitationListener.CreateStub(invitee).OnReceivedInvitationAdded(new HandlerController() { ListenerId = lid }, notification.Build(), callback => { })); } @@ -80,7 +80,7 @@ namespace DiIiS_NA.LoginServer.ChannelSystem _onGoingInvitations.Remove(invitation.Id); GoingInvitations.Remove(request.InvitationId); - client.MakeTargetedRPC(this, (lid) => + client.MakeTargetedRpc(this, (lid) => bgs.protocol.channel.v1.ChannelInvitationListener.CreateStub(client).OnReceivedInvitationRemoved(new HandlerController() { ListenerId = lid }, notification.Build(), callback => { })); channel.Join(client, request.ObjectId); @@ -92,7 +92,7 @@ namespace DiIiS_NA.LoginServer.ChannelSystem foreach (var member in channel.Members.Keys) { - member.MakeTargetedRPC(channel, (lid) => + member.MakeTargetedRpc(channel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(member).OnUpdateChannelState(new HandlerController() { ListenerId = lid }, stateNotification, callback => { })); } @@ -157,7 +157,7 @@ namespace DiIiS_NA.LoginServer.ChannelSystem .SetStateChange(channelStatePermission) .Build(); - JoinClient.MakeTargetedRPC(JoinClient.CurrentChannel, (lid) => + JoinClient.MakeTargetedRpc(JoinClient.CurrentChannel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(JoinClient).OnUpdateChannelState(new HandlerController() { ListenerId = lid }, notificationPermission, callback => { })); } gameFound.StartGame(clients, gameFound.DynamicId); @@ -171,7 +171,7 @@ namespace DiIiS_NA.LoginServer.ChannelSystem .SetValue(Variant.CreateBuilder().SetUintValue(gameFound.RequestId).Build()); notificationFound.AddAttribute(attrF); - JoinClient.MakeRPC((lid) => + JoinClient.MakeRpc((lid) => bgs.protocol.notification.v1.NotificationListener.CreateStub(JoinClient).OnNotificationReceived(new HandlerController() { ListenerId = lid }, notificationFound.Build(), callback => { })); @@ -186,7 +186,7 @@ namespace DiIiS_NA.LoginServer.ChannelSystem notification.SetGameHandle(gh); System.Threading.Tasks.Task.Delay(2000).ContinueWith(delegate { - JoinClient.MakeRPC((lid) => bgs.protocol.matchmaking.v1.GameRequestListener.CreateStub(JoinClient).OnMatchmakingResult(new HandlerController() { ListenerId = lid }, notification.Build(), callback => { })); + JoinClient.MakeRpc((lid) => bgs.protocol.matchmaking.v1.GameRequestListener.CreateStub(JoinClient).OnMatchmakingResult(new HandlerController() { ListenerId = lid }, notification.Build(), callback => { })); }); #endregion @@ -236,9 +236,9 @@ namespace DiIiS_NA.LoginServer.ChannelSystem foreach (var member in channel.Members.Keys) { - member.MakeTargetedRPC(channel, (lid) => + member.MakeTargetedRpc(channel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(member).OnUpdateChannelState(new HandlerController() { ListenerId = lid }, stateNotification, callback => { })); - member.MakeTargetedRPC(channel, (lid) => + member.MakeTargetedRpc(channel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(member).OnJoin(new HandlerController() { ListenerId = lid }, joinstateNotification, callback => { })); } @@ -264,7 +264,7 @@ namespace DiIiS_NA.LoginServer.ChannelSystem - client.MakeTargetedRPC(this, (lid) => bgs.protocol.channel.v1.ChannelInvitationListener.CreateStub(client).OnReceivedInvitationRemoved(new HandlerController() { ListenerId = lid }, notification.Build(), callback => { })); + client.MakeTargetedRpc(this, (lid) => bgs.protocol.channel.v1.ChannelInvitationListener.CreateStub(client).OnReceivedInvitationRemoved(new HandlerController() { ListenerId = lid }, notification.Build(), callback => { })); channel.Join(mem, request.ObjectId); // add invitee to channel -- so inviter and other members will also be notified too. @@ -281,7 +281,7 @@ namespace DiIiS_NA.LoginServer.ChannelSystem foreach (var member in channel.Members.Keys) { - member.MakeTargetedRPC(channel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(member).OnUpdateChannelState(new HandlerController() { ListenerId = lid }, stateNotification, callback => { })); + member.MakeTargetedRpc(channel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(member).OnUpdateChannelState(new HandlerController() { ListenerId = lid }, stateNotification, callback => { })); //member.MakeTargetedRPC(channel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(member).OnJoin(new HandlerController() { ListenerId = lid }, build, callback => { })); } @@ -305,7 +305,7 @@ namespace DiIiS_NA.LoginServer.ChannelSystem _onGoingInvitations.Remove(invitation.Id); GoingInvitations.Remove(request.InvitationId); - inviter.LoggedInClient.MakeTargetedRPC(inviter.LoggedInClient.CurrentChannel, (lid) => + inviter.LoggedInClient.MakeTargetedRpc(inviter.LoggedInClient.CurrentChannel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(inviter.LoggedInClient).OnUpdateChannelState(new HandlerController() { ListenerId = lid }, notification.Build(), callback => { })); } @@ -328,7 +328,7 @@ namespace DiIiS_NA.LoginServer.ChannelSystem _onGoingInvitations.Remove(request.InvitationId); GoingInvitations.Remove(request.InvitationId); - inviter.LoggedInClient.MakeTargetedRPC(inviter.LoggedInClient.CurrentChannel, (lid) => + inviter.LoggedInClient.MakeTargetedRpc(inviter.LoggedInClient.CurrentChannel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(client).OnUpdateChannelState(new HandlerController() { ListenerId = lid }, updateChannelNotification.Build(), callback => { })); //notify invitee about revoke @@ -339,7 +339,7 @@ namespace DiIiS_NA.LoginServer.ChannelSystem if (Subscribers.All(subscriber => subscriber.Key.Account.GameAccount.BnetEntityId.Low != invitation.InviteeIdentity.AccountId.Low)) return; - client.MakeTargetedRPC(this, (lid) => + client.MakeTargetedRpc(this, (lid) => bgs.protocol.channel.v1.ChannelInvitationListener.CreateStub(client).OnReceivedInvitationRemoved(new HandlerController() { ListenerId = lid }, invitationRemoved.Build(), callback => { })); } diff --git a/src/DiIiS-NA/BGS-Server/FriendsSystem/FriendManager.cs b/src/DiIiS-NA/BGS-Server/FriendsSystem/FriendManager.cs index d41c46e..561d52a 100644 --- a/src/DiIiS-NA/BGS-Server/FriendsSystem/FriendManager.cs +++ b/src/DiIiS-NA/BGS-Server/FriendsSystem/FriendManager.cs @@ -67,7 +67,7 @@ namespace DiIiS_NA.LoginServer.FriendsSystem .SetInvitation(invitation) .SetAccountId(invitee.BnetEntityId); - invitee.GameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, (lid) => + invitee.GameAccount.LoggedInClient.MakeTargetedRpc(FriendManager.Instance, (lid) => bgs.protocol.friends.v1.FriendsListener.CreateStub(invitee.GameAccount.LoggedInClient).OnReceivedInvitationAdded(new HandlerController() { ListenerId = lid }, notification.Build(), callback => { })); @@ -89,13 +89,13 @@ namespace DiIiS_NA.LoginServer.FriendsSystem if (inviter.GameAccount.IsOnline) { - inviter.GameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, (lid) => + inviter.GameAccount.LoggedInClient.MakeTargetedRpc(FriendManager.Instance, (lid) => bgs.protocol.friends.v1.FriendsListener.CreateStub(inviter.GameAccount.LoggedInClient).OnReceivedInvitationRemoved(new HandlerController() { ListenerId = lid }, declinedNotification, callback => { })); } if (invitee.GameAccount.IsOnline) { - invitee.GameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, (lid) => + invitee.GameAccount.LoggedInClient.MakeTargetedRpc(FriendManager.Instance, (lid) => bgs.protocol.friends.v1.FriendsListener.CreateStub(invitee.GameAccount.LoggedInClient).OnReceivedInvitationRemoved(new HandlerController() { ListenerId = lid }, declinedNotification, callback => { })); } @@ -144,19 +144,19 @@ namespace DiIiS_NA.LoginServer.FriendsSystem if (inviter.GameAccount.IsOnline) { - inviter.GameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, (lid) => + inviter.GameAccount.LoggedInClient.MakeTargetedRpc(FriendManager.Instance, (lid) => bgs.protocol.friends.v1.FriendsListener.CreateStub(inviter.GameAccount.LoggedInClient).OnReceivedInvitationRemoved(new HandlerController() { ListenerId = lid }, notificationToInviter, callback => { })); - inviter.GameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, (lid) => + inviter.GameAccount.LoggedInClient.MakeTargetedRpc(FriendManager.Instance, (lid) => bgs.protocol.friends.v1.FriendsListener.CreateStub(inviter.GameAccount.LoggedInClient).OnFriendAdded(new HandlerController() { ListenerId = lid }, friendAddedNotificationToInviter, callback => { })); } if (invitee.GameAccount.IsOnline) { - invitee.GameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, (lid) => + invitee.GameAccount.LoggedInClient.MakeTargetedRpc(FriendManager.Instance, (lid) => bgs.protocol.friends.v1.FriendsListener.CreateStub(invitee.GameAccount.LoggedInClient).OnFriendAdded(new HandlerController() { ListenerId = lid }, friendAddedNotificationToInvitee, callback => { })); - invitee.GameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, (lid) => + invitee.GameAccount.LoggedInClient.MakeTargetedRpc(FriendManager.Instance, (lid) => bgs.protocol.friends.v1.FriendsListener.CreateStub(invitee.GameAccount.LoggedInClient).OnReceivedInvitationRemoved(new HandlerController() { ListenerId = lid }, notificationToInvitee, callback => { })); } @@ -177,13 +177,13 @@ namespace DiIiS_NA.LoginServer.FriendsSystem if (inviter.GameAccount.IsOnline) { - inviter.GameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, (lid) => + inviter.GameAccount.LoggedInClient.MakeTargetedRpc(FriendManager.Instance, (lid) => bgs.protocol.friends.v1.FriendsListener.CreateStub(inviter.GameAccount.LoggedInClient).OnReceivedInvitationRemoved(new HandlerController() { ListenerId = lid }, declinedNotification, callback => { })); } if (invitee.GameAccount.IsOnline) { - invitee.GameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, (lid) => + invitee.GameAccount.LoggedInClient.MakeTargetedRpc(FriendManager.Instance, (lid) => bgs.protocol.friends.v1.FriendsListener.CreateStub(invitee.GameAccount.LoggedInClient).OnReceivedInvitationRemoved(new HandlerController() { ListenerId = lid }, declinedNotification, callback => { })); } @@ -215,13 +215,13 @@ namespace DiIiS_NA.LoginServer.FriendsSystem .SetAccountId(remover.BnetEntityId) .Build(); - client.MakeTargetedRPC(FriendManager.Instance, (lid) => + client.MakeTargetedRpc(FriendManager.Instance, (lid) => bgs.protocol.friends.v1.FriendsListener.CreateStub(client).OnFriendRemoved(new HandlerController() { ListenerId = lid }, notifyRemover, callback => { })); if (removee.GameAccount.IsOnline) { var notifyRemovee = bgs.protocol.friends.v1.FriendNotification.CreateBuilder().SetTarget(removerAsFriend).SetAccountId(removee.BnetEntityId).Build(); - removee.GameAccount.LoggedInClient.MakeTargetedRPC(FriendManager.Instance, (lid) => bgs.protocol.friends.v1.FriendsListener.CreateStub(removee.GameAccount.LoggedInClient).OnFriendRemoved(new HandlerController() { ListenerId = lid }, notifyRemovee, callback => { })); + removee.GameAccount.LoggedInClient.MakeTargetedRpc(FriendManager.Instance, (lid) => bgs.protocol.friends.v1.FriendsListener.CreateStub(removee.GameAccount.LoggedInClient).OnFriendRemoved(new HandlerController() { ListenerId = lid }, notifyRemovee, callback => { })); } } diff --git a/src/DiIiS-NA/BGS-Server/FriendsSystem/UserManager.cs b/src/DiIiS-NA/BGS-Server/FriendsSystem/UserManager.cs index e2f6b7c..74c85a5 100644 --- a/src/DiIiS-NA/BGS-Server/FriendsSystem/UserManager.cs +++ b/src/DiIiS-NA/BGS-Server/FriendsSystem/UserManager.cs @@ -39,7 +39,7 @@ namespace DiIiS_NA.LoginServer.FriendsSystem notifyBlock.SetPlayer(blockedPlayer); notifyBlock.SetGameAccountId(blocked.BnetEntityId); - client.MakeTargetedRPC(UserManager.Instance, (lid) => + client.MakeTargetedRpc(UserManager.Instance, (lid) => bgs.protocol.user_manager.v1.UserManagerListener.CreateStub(client).OnBlockedPlayerAdded(new HandlerController() { ListenerId = lid }, notifyBlock.Build(), callback => { })); } @@ -61,7 +61,7 @@ namespace DiIiS_NA.LoginServer.FriendsSystem var notifyUnblock = bgs.protocol.user_manager.v1.BlockedPlayerRemovedNotification.CreateBuilder(); notifyUnblock.SetPlayer(blockedPlayer); - client.MakeTargetedRPC(UserManager.Instance, (lid) => + client.MakeTargetedRpc(UserManager.Instance, (lid) => bgs.protocol.user_manager.v1.UserManagerListener.CreateStub(client).OnBlockedPlayerRemoved(new HandlerController() { ListenerId = lid }, notifyUnblock.Build(), callback => { })); } diff --git a/src/DiIiS-NA/BGS-Server/GamesSystem/GameDescriptor.cs b/src/DiIiS-NA/BGS-Server/GamesSystem/GameDescriptor.cs index 7ebdc79..f54dfee 100644 --- a/src/DiIiS-NA/BGS-Server/GamesSystem/GameDescriptor.cs +++ b/src/DiIiS-NA/BGS-Server/GamesSystem/GameDescriptor.cs @@ -95,7 +95,7 @@ namespace DiIiS_NA.LoginServer.GamesSystem foreach (var client in clients) { - client.MapLocalObjectID(this.DynamicId, objectId); + client.MapLocalObjectId(this.DynamicId, objectId); this.SendConnectionInfo(client); client.Account.GameAccount.ScreenStatus = D3.PartyMessage.ScreenStatus.CreateBuilder().SetScreen(0).SetStatus(0).Build(); client.Account.GameAccount.NotifyUpdate(); @@ -109,7 +109,7 @@ namespace DiIiS_NA.LoginServer.GamesSystem { foreach (var client in clients) { - client.MapLocalObjectID(this.DynamicId, objectId); + client.MapLocalObjectId(this.DynamicId, objectId); this.SendConnectionInfo(client); client.Account.GameAccount.ScreenStatus = D3.PartyMessage.ScreenStatus.CreateBuilder().SetScreen(1).SetStatus(1).Build(); client.Account.GameAccount.NotifyUpdate(); @@ -119,7 +119,7 @@ namespace DiIiS_NA.LoginServer.GamesSystem public bgs.protocol.games.v2.ConnectInfo GetConnectionInfoForClient(BattleClient client) { return bgs.protocol.games.v2.ConnectInfo.CreateBuilder() - .SetAddress(bgs.protocol.Address.CreateBuilder().SetAddress_(this.GServer.Value.GameIP).SetPort((uint)this.GServer.Value.GamePort)) + .SetAddress(bgs.protocol.Address.CreateBuilder().SetAddress_(this.GServer.Value.GameIp).SetPort((uint)this.GServer.Value.GamePort)) .SetToken(Google.ProtocolBuffers.ByteString.CopyFrom(new byte[] { 0x31, 0x33, 0x38, 0x38, 0x35, 0x34, 0x33, 0x33, 0x32, 0x30, 0x38, 0x34, 0x30, 0x30, 0x38, 0x38, 0x35, 0x37, 0x39, 0x36 })) .AddAttribute(bgs.protocol.Attribute.CreateBuilder().SetName("Token").SetValue(bgs.protocol.Variant.CreateBuilder().SetUintValue(0xee34d06ffe821c43L))) @@ -146,7 +146,7 @@ namespace DiIiS_NA.LoginServer.GamesSystem .SetChannelState(channelStatePrivacyLevel) .Build(); - client.MakeTargetedRPC(client.CurrentChannel, (lid) => + client.MakeTargetedRpc(client.CurrentChannel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(client).OnUpdateChannelState(new HandlerController() { ListenerId = lid }, notificationPrivacyLevel, callback => { })); @@ -166,7 +166,7 @@ namespace DiIiS_NA.LoginServer.GamesSystem .SetChannelState(channelStatePartyLock) .Build(); - client.MakeTargetedRPC(client.CurrentChannel, (lid) => + client.MakeTargetedRpc(client.CurrentChannel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(client).OnUpdateChannelState(new HandlerController() { ListenerId = lid }, notificationPartyLock, callback => { })); } } diff --git a/src/DiIiS-NA/BGS-Server/GuildSystem/Guild.cs b/src/DiIiS-NA/BGS-Server/GuildSystem/Guild.cs index f5ede19..b2fd924 100644 --- a/src/DiIiS-NA/BGS-Server/GuildSystem/Guild.cs +++ b/src/DiIiS-NA/BGS-Server/GuildSystem/Guild.cs @@ -486,7 +486,7 @@ namespace DiIiS_NA.LoginServer.GuildSystem .SetTargetAccountId(account.Owner.BnetEntityId) .Build(); - account.LoggedInClient.MakeRPC((lid) => + account.LoggedInClient.MakeRpc((lid) => bgs.protocol.notification.v1.NotificationListener.CreateStub(account.LoggedInClient).OnNotificationReceived(new HandlerController() { ListenerId = lid }, notificationBuilder, callback => { })); @@ -507,7 +507,7 @@ namespace DiIiS_NA.LoginServer.GuildSystem .SetTargetAccountId(account.Owner.BnetEntityId) .Build(); - account.LoggedInClient.MakeRPC((lid) => + account.LoggedInClient.MakeRpc((lid) => bgs.protocol.notification.v1.NotificationListener.CreateStub(account.LoggedInClient).OnNotificationReceived(new HandlerController() { ListenerId = lid }, chatNotificationBuilder, callback => { })); } @@ -540,7 +540,7 @@ namespace DiIiS_NA.LoginServer.GuildSystem foreach (var member in this.Channel.Members) //member.Key.MakeTargetedRPC(this.Channel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(member.Key).OnUpdateChannelState(new HandlerController() { ListenerId = lid }, notification, callback => { })); - member.Key.MakeTargetedRPC(this.Channel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(member.Key).OnJoin(new HandlerController() { ListenerId = lid }, altnotification, callback => { })); + member.Key.MakeTargetedRpc(this.Channel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(member.Key).OnJoin(new HandlerController() { ListenerId = lid }, altnotification, callback => { })); } public void UpdateMemberAttributes(GameAccount member) @@ -565,7 +565,7 @@ namespace DiIiS_NA.LoginServer.GuildSystem .Build(); foreach (var mbr in this.Channel.Members) - mbr.Key.MakeTargetedRPC(this.Channel, (lid) => + mbr.Key.MakeTargetedRpc(this.Channel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(mbr.Key).OnUpdateMemberState(new HandlerController() { ListenerId = lid }, notification, callback => { })); } diff --git a/src/DiIiS-NA/BGS-Server/Objects/PresenceField.cs b/src/DiIiS-NA/BGS-Server/Objects/PresenceField.cs index 0539820..ed15938 100644 --- a/src/DiIiS-NA/BGS-Server/Objects/PresenceField.cs +++ b/src/DiIiS-NA/BGS-Server/Objects/PresenceField.cs @@ -9,7 +9,7 @@ namespace DiIiS_NA.LoginServer.Objects { public class EntityIdPresenceFieldList { - public List Value = new List(); + public List Value = new(); protected FieldKeyHelper.Program _program; protected FieldKeyHelper.OriginatingClass _originatingClass; diff --git a/src/DiIiS-NA/BGS-Server/Objects/RPCObject.cs b/src/DiIiS-NA/BGS-Server/Objects/RPCObject.cs index 9b0e408..54cfa00 100644 --- a/src/DiIiS-NA/BGS-Server/Objects/RPCObject.cs +++ b/src/DiIiS-NA/BGS-Server/Objects/RPCObject.cs @@ -33,7 +33,7 @@ namespace DiIiS_NA.LoginServer.Objects if (this.Subscribers.ContainsKey(client)) return; this.Subscribers.TryAdd(client, 0); - client.MapLocalObjectID(this.DynamicId, remoteObjectId); + client.MapLocalObjectId(this.DynamicId, remoteObjectId); if (client.SocketConnection.Active) { @@ -56,7 +56,7 @@ namespace DiIiS_NA.LoginServer.Objects return new List(); } - public Helpers.FieldKeyHelper ChangedFields = new Helpers.FieldKeyHelper(); + public readonly Helpers.FieldKeyHelper ChangedFields = new(); protected void NotifySubscriptionAdded(BattleClient client) { @@ -96,8 +96,8 @@ namespace DiIiS_NA.LoginServer.Objects var altnotification = bgs.protocol.channel.v1.JoinNotification.CreateBuilder().SetChannelState(channelState); if (gameAccount.LoggedInClient != null) { - gameAccount.LoggedInClient.MakeTargetedRPC(this, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(gameAccount.LoggedInClient).OnUpdateChannelState(new HandlerController() { ListenerId = lid }, notification.Build(), callback => { })); - gameAccount.LoggedInClient.MakeTargetedRPC(this, (lid) => + gameAccount.LoggedInClient.MakeTargetedRpc(this, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(gameAccount.LoggedInClient).OnUpdateChannelState(new HandlerController() { ListenerId = lid }, notification.Build(), callback => { })); + gameAccount.LoggedInClient.MakeTargetedRpc(this, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(gameAccount.LoggedInClient).OnJoin(new HandlerController() { ListenerId = lid }, altnotification.Build(), callback => { })); } } @@ -110,10 +110,10 @@ namespace DiIiS_NA.LoginServer.Objects var channelState = bgs.protocol.channel.v1.ChannelState.CreateBuilder().SetExtension(bgs.protocol.presence.v1.ChannelState.Presence, state); var builder = bgs.protocol.channel.v1.JoinNotification.CreateBuilder().SetChannelState(channelState); var notification = bgs.protocol.channel.v1.UpdateChannelStateNotification.CreateBuilder().SetStateChange(channelState); - client.MakeTargetedRPC(this, (lid) => + client.MakeTargetedRpc(this, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(client).OnJoin(new HandlerController() { ListenerId = lid }, builder.Build(), callback => { })); - client.MakeTargetedRPC(this, (lid) => + client.MakeTargetedRpc(this, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(client).OnUpdateChannelState(new HandlerController() { ListenerId = lid }, notification.Build(), callback => { })); } diff --git a/src/DiIiS-NA/BGS-Server/Objects/RPCObjectManager.cs b/src/DiIiS-NA/BGS-Server/Objects/RPCObjectManager.cs index 484898d..2e0944a 100644 --- a/src/DiIiS-NA/BGS-Server/Objects/RPCObjectManager.cs +++ b/src/DiIiS-NA/BGS-Server/Objects/RPCObjectManager.cs @@ -10,7 +10,7 @@ namespace DiIiS_NA.LoginServer.Objects private static readonly Logger Logger = LogManager.CreateLogger(); private static ulong _nextId = 10000; - public static readonly Dictionary Objects = new Dictionary(); + public static readonly Dictionary Objects = new(); static RPCObjectManager() { } diff --git a/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/AuthenticationService.cs b/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/AuthenticationService.cs index a987e6a..9c485c9 100644 --- a/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/AuthenticationService.cs +++ b/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/AuthenticationService.cs @@ -88,21 +88,21 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services } switch (request.Locale) { - case "deDE": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.deDE; break; - case "enGB": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.enGB; break; - case "enSG": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.enSG; break; - case "enUS": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.enUS; break; - case "esES": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.esES; break; - case "esMX": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.esMX; break; - case "frFR": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.frFR; break; - case "itIT": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.itIT; break; - case "koKR": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.koKR; break; - case "plPL": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.plPL; break; - case "ptBR": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.ptBR; break; - case "ptPT": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.ptPT; break; - case "ruRU": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.ruRU; break; - case "trTR": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.trTR; break; - case "zhCN": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.zhCN; break; + case "deDE": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.DE_DE; break; + case "enGB": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.EN_GB; break; + case "enSG": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.EN_SG; break; + case "enUS": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.EN_US; break; + case "esES": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.ES_ES; break; + case "esMX": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.ES_MX; break; + case "frFR": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.FR_FR; break; + case "itIT": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.IT_IT; break; + case "koKR": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.KO_KR; break; + case "plPL": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.PL_PL; break; + case "ptBR": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.PT_BR; break; + case "ptPT": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.PT_PT; break; + case "ruRU": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.RU_RU; break; + case "trTR": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.TR_TR; break; + case "zhCN": ((HandlerController)controller).Client.ClientLanguage = BattleClient.ClientLocale.ZH_CN; break; } done(NoData.CreateBuilder().Build()); var builder = ChallengeExternalRequest.CreateBuilder(); @@ -124,7 +124,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services builder.SetPayload(ByteString.CopyFromUtf8( $"http://{Program.RESTSERVERIP}:{REST.Config.Instance.PORT}/battlenet/login")); - ((HandlerController)controller).Client.MakeRPC((lid) => ChallengeListener.CreateStub(((HandlerController)controller).Client).OnExternalChallenge(controller, builder.Build(), callback => { })); + ((HandlerController)controller).Client.MakeRpc((lid) => ChallengeListener.CreateStub(((HandlerController)controller).Client).OnExternalChallenge(controller, builder.Build(), callback => { })); #endregion } break; @@ -191,7 +191,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services if (((HandlerController)controller).Client.Account == null) { var complete = LogonResult.CreateBuilder().SetErrorCode(2); - ((HandlerController)controller).Client.MakeRPC((lid) => AuthenticationListener.CreateStub(((HandlerController)controller).Client).OnLogonComplete(controller, complete.Build(), callback => { })); + ((HandlerController)controller).Client.MakeRpc((lid) => AuthenticationListener.CreateStub(((HandlerController)controller).Client).OnLogonComplete(controller, complete.Build(), callback => { })); ((HandlerController)controller).Client.SocketConnection.CloseAsync(); ((HandlerController)controller).Client.Connect.CloseAsync(); } @@ -210,12 +210,12 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services .SetErrorCode(0) .AddGameAccountId(((HandlerController)controller).Client.Account.GameAccount.BnetEntityId); //D3 ((HandlerController)controller).Client.Account.GameAccount.LoggedInClient = ((HandlerController)controller).Client; - ((HandlerController)controller).Client.MakeRPC((lid) => AuthenticationListener.CreateStub(((HandlerController)controller).Client).OnLogonComplete(controller, complete.Build(), callback => { })); + ((HandlerController)controller).Client.MakeRpc((lid) => AuthenticationListener.CreateStub(((HandlerController)controller).Client).OnLogonComplete(controller, complete.Build(), callback => { })); PlayerManager.PlayerConnected(((HandlerController)controller).Client); var selectedGameAccount = GameAccountSelectedRequest.CreateBuilder().SetResult(0).SetGameAccountId(((HandlerController)controller).Client.Account.GameAccount.BnetEntityId); - ((HandlerController)controller).Client.MakeRPC((lid) => + ((HandlerController)controller).Client.MakeRpc((lid) => AuthenticationListener.CreateStub(((HandlerController)controller).Client).OnGameAccountSelected(new HandlerController() { ListenerId = lid }, selectedGameAccount.Build(), callback => { })); } #endregion diff --git a/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/ChannelInvitationService.cs b/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/ChannelInvitationService.cs index 7467bba..6c70cfb 100644 --- a/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/ChannelInvitationService.cs +++ b/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/ChannelInvitationService.cs @@ -101,9 +101,9 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services var builder = JoinNotification.CreateBuilder().SetChannelState(ChannelState.CreateBuilder().AddInvitation(invitation.Clone())); - ((HandlerController) controller).Client.MakeTargetedRPC(channel, (lid) => ChannelListener.CreateStub(((HandlerController) controller).Client) + ((HandlerController) controller).Client.MakeTargetedRpc(channel, (lid) => ChannelListener.CreateStub(((HandlerController) controller).Client) .OnUpdateChannelState(controller, notification.Build(), callback => { })); - ((HandlerController) controller).Client.MakeTargetedRPC(channel, (lid) => + ((HandlerController) controller).Client.MakeTargetedRpc(channel, (lid) => ChannelListener.CreateStub(((HandlerController) controller).Client).OnJoin(new HandlerController() { ListenerId = lid }, builder.Build(), callback => { })); _invitationManager.HandleInvitation(((HandlerController) controller).Client, invitation.Build()); @@ -137,7 +137,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services var notification = SuggestionAddedNotification.CreateBuilder().SetSuggestion(suggestion); - suggestee.LoggedInClient.MakeTargetedRPC(_invitationManager, (lid) => + suggestee.LoggedInClient.MakeTargetedRpc(_invitationManager, (lid) => ChannelInvitationListener.CreateStub(suggestee.LoggedInClient).OnReceivedSuggestionAdded(new HandlerController() { ListenerId = lid }, notification.Build(), callback => { })); } diff --git a/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/ChannelService.cs b/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/ChannelService.cs index 3e0df72..6bdec58 100644 --- a/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/ChannelService.cs +++ b/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/ChannelService.cs @@ -346,7 +346,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services //Notify all Channel members foreach (var member in channel.Members.Keys) { - member.MakeTargetedRPC(channel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(member).OnUpdateChannelState(new HandlerController() { ListenerId = lid }, notification, callback => { })); + member.MakeTargetedRpc(channel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(member).OnUpdateChannelState(new HandlerController() { ListenerId = lid }, notification, callback => { })); } } @@ -401,7 +401,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services //Notify all Channel members foreach (var member in channel.Members.Keys) { - member.MakeTargetedRPC(channel, (lid) => + member.MakeTargetedRpc(channel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub(member).OnUpdateMemberState(new HandlerController() { ListenerId = lid }, notification, callback => { })); } //*/ diff --git a/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/GameRequestService.cs b/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/GameRequestService.cs index 3e2b88e..e0edd97 100644 --- a/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/GameRequestService.cs +++ b/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/GameRequestService.cs @@ -72,7 +72,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services QueueEntryNotification.Builder qen = QueueEntryNotification.CreateBuilder(); qen.SetRequestId(id).SetWaitTimes(timers).AddMember(member).SetRequestInitiator(member); - ((HandlerController) controller).Client.MakeRPC((lid) => GameRequestListener.CreateStub(((HandlerController) controller).Client).OnQueueEntry(new HandlerController() { ListenerId = lid }, qen.Build(), callback => { })); + ((HandlerController) controller).Client.MakeRpc((lid) => GameRequestListener.CreateStub(((HandlerController) controller).Client).OnQueueEntry(new HandlerController() { ListenerId = lid }, qen.Build(), callback => { })); #endregion #region Update Queue @@ -80,7 +80,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services qun.SetRequestId(id) .SetWaitTimes(timers) .SetIsMatchmaking(true); - ((HandlerController) controller).Client.MakeRPC((lid) => GameRequestListener.CreateStub(((HandlerController) controller).Client).OnQueueUpdate(new HandlerController() { ListenerId = lid }, qun.Build(), callback => { })); + ((HandlerController) controller).Client.MakeRpc((lid) => GameRequestListener.CreateStub(((HandlerController) controller).Client).OnQueueUpdate(new HandlerController() { ListenerId = lid }, qun.Build(), callback => { })); #endregion @@ -124,7 +124,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services var joinNotification = bgs.protocol.channel.v1.JoinNotification.CreateBuilder().SetChannelState(channelStatePermission).Build(); - (((HandlerController) controller).Client).MakeTargetedRPC((((HandlerController) controller).Client).CurrentChannel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub((((HandlerController) controller).Client)).OnUpdateChannelState(new HandlerController() { ListenerId = lid }, notificationPermission, callback => { })); + (((HandlerController) controller).Client).MakeTargetedRpc((((HandlerController) controller).Client).CurrentChannel, (lid) => bgs.protocol.channel.v1.ChannelListener.CreateStub((((HandlerController) controller).Client)).OnUpdateChannelState(new HandlerController() { ListenerId = lid }, notificationPermission, callback => { })); } gameFound.StartGame(clients, gameFound.DynamicId); @@ -137,7 +137,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services .SetValue(Variant.CreateBuilder().SetUintValue(gameFound.RequestId).Build()); notificationFound.AddAttribute(attrF); - (((HandlerController) controller).Client).MakeRPC((lid) => + (((HandlerController) controller).Client).MakeRpc((lid) => bgs.protocol.notification.v1.NotificationListener.CreateStub((((HandlerController) controller).Client)).OnNotificationReceived(new HandlerController() { ListenerId = lid }, notificationFound.Build(), callback => { })); @@ -152,7 +152,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services notification.SetGameHandle(gh); System.Threading.Tasks.Task.Delay(2000).ContinueWith(delegate { - ((HandlerController) controller).Client.MakeRPC((lid) => GameRequestListener.CreateStub(((HandlerController) controller).Client).OnMatchmakingResult(new HandlerController() { ListenerId = lid }, notification.Build(), callback => { })); + ((HandlerController) controller).Client.MakeRpc((lid) => GameRequestListener.CreateStub(((HandlerController) controller).Client).OnMatchmakingResult(new HandlerController() { ListenerId = lid }, notification.Build(), callback => { })); }); } } diff --git a/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/GameUtilitiesService.cs b/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/GameUtilitiesService.cs index 23f4f42..4583863 100644 --- a/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/GameUtilitiesService.cs +++ b/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/GameUtilitiesService.cs @@ -197,7 +197,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services builder.AddAttribute(messageId); builder.AddAttribute(payload); - Client.MakeRPC((lid) => + Client.MakeRpc((lid) => NotificationListener.CreateStub(Client) .OnNotificationReceived(new HandlerController() { ListenerId = lid }, builder.Build(), callback => { })); diff --git a/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/NotificationService.cs b/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/NotificationService.cs index a153ea4..a3329d3 100644 --- a/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/NotificationService.cs +++ b/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/NotificationService.cs @@ -42,7 +42,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services .SetSenderAccountId(((HandlerController) controller).Client.Account.BnetEntityId) .Build(); - targetAccount.LoggedInClient.MakeRPC((lid) => + targetAccount.LoggedInClient.MakeRpc((lid) => NotificationListener.CreateStub(targetAccount.LoggedInClient).OnNotificationReceived(controller, notification, callback => { })); } break; diff --git a/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/SessionService.cs b/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/SessionService.cs index b37aee7..70e5716 100644 --- a/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/SessionService.cs +++ b/src/DiIiS-NA/BGS-Server/ServicesSystem/Services/SessionService.cs @@ -28,7 +28,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services n.SetIdentity(request.Identity) .SetReason(0) .SetSessionId(session); - ((HandlerController) controller).Client.MakeRPC((lid) => SessionListener.CreateStub(((HandlerController) controller).Client).OnSessionCreated(controller, n.Build(), callback => { })); + ((HandlerController) controller).Client.MakeRpc((lid) => SessionListener.CreateStub(((HandlerController) controller).Client).OnSessionCreated(controller, n.Build(), callback => { })); } private void DisconnectClient(HandlerController controller) diff --git a/src/DiIiS-NA/D3-GameServer/AchievementSystem/AchievementManager.cs b/src/DiIiS-NA/D3-GameServer/AchievementSystem/AchievementManager.cs index 87a9573..51949f9 100644 --- a/src/DiIiS-NA/D3-GameServer/AchievementSystem/AchievementManager.cs +++ b/src/DiIiS-NA/D3-GameServer/AchievementSystem/AchievementManager.cs @@ -175,7 +175,7 @@ namespace DiIiS_NA.GameServer.AchievementSystem { Task.Run(() => { - lock (client._serviceLock) + lock (client.ServiceLock) { Logger.MethodTrace(MethodBase.GetCurrentMethod(), "id {0}", achievementId); if (client.Account.GameAccount.Achievements.Where(a => a.AchievementId == achievementId && a.Completion != -1).Count() > 0) return; @@ -240,7 +240,7 @@ namespace DiIiS_NA.GameServer.AchievementSystem { Task.Run(() => { - lock (client._serviceLock) + lock (client.ServiceLock) { Logger.MethodTrace(MethodBase.GetCurrentMethod(), "id {0}", criteriaId); D3.AchievementsStaticData.StaticCriteriaDefinition definition = null; @@ -375,7 +375,7 @@ namespace DiIiS_NA.GameServer.AchievementSystem { Task.Run(() => { - lock (client._serviceLock) + lock (client.ServiceLock) { if (additionalQuantity == 0) return; Logger.MethodTrace(MethodBase.GetCurrentMethod(), "id {0}", achievementId); diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/QuestManager.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/QuestManager.cs index 43441b4..2b3f90a 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/QuestManager.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/QuestManager.cs @@ -26,18 +26,18 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem { public class QuestManager { - private static readonly Logger Logger = new Logger("QuestManager"); + private static readonly Logger Logger = new(nameof(QuestManager)); /// /// Accessor for quests /// /// snoId of the quest to retrieve /// - public Dictionary Quests = new Dictionary(); + public readonly Dictionary Quests = new(); - public Dictionary SideQuests = new Dictionary(); + public readonly Dictionary SideQuests = new(); - public List Bounties = new List(); + public readonly List Bounties = new(); public Game Game { get; set; } @@ -191,7 +191,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem if (!Game.Empty) { SaveQuestProgress(true); - Logger.Trace(" (Advance) quest {0} completed: {1}", Game.CurrentQuest, Quests[Game.CurrentQuest].Completed); + Logger.Trace($"$[white]$(Advance)$[/]$ Game {Game.GameId} Advanced to quest $[underline white]${Game.CurrentQuest}$[/], completed $[underline white]${Quests[Game.CurrentQuest].Completed}$[/]$"); foreach (var player in Game.Players.Values) { int xpReward = (int)(Quests[Game.CurrentQuest].RewardXp * Game.XPModifier); @@ -269,7 +269,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem } OnQuestProgress(); AutoSetQuestMarker(); - Logger.Trace(" (Advance) Advanced to quest {0}, step {1}", Game.CurrentQuest, Game.CurrentStep); + Logger.Trace($"$[white]$(Advance)$[/]$ Game {Game.GameId} Advanced to quest $[underline white]${Game.CurrentQuest}$[/], step $[underline white]${Game.CurrentStep}$[/]$"); } public void SideAdvance() @@ -295,7 +295,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem SideQuests[Game.CurrentSideQuest].Steps[Game.CurrentSideStep] == SideQuests[Game.CurrentSideQuest].Steps.Last().Value) { SideQuests[Game.CurrentSideQuest].Completed = true; - Logger.Trace(" (SideAdvance) quest {0} completed: {1}", Game.CurrentSideQuest, SideQuests[Game.CurrentSideQuest].Completed); + Logger.Trace($"$[white]$(Side-Advance)$[/]$ Game {Game.GameId} Side-Advanced to quest {Game.CurrentSideQuest} completed: {SideQuests[Game.CurrentSideQuest].Completed}"); foreach (var player in Game.Players.Values) { @@ -339,7 +339,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem } OnQuestProgress(); - Logger.Trace(" (SideAdvance) Advanced to side quest {0}, step {1}", Game.CurrentSideQuest, Game.CurrentSideStep); + Logger.Trace($"$[white]$(Side-Advance)$[/]$ Game {Game.GameId} Side-Advanced to side-quest {Game.CurrentSideQuest} completed: {Game.CurrentSideStep}"); } public void LaunchSideQuest(int questId, bool forceAbandon = false) @@ -855,7 +855,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem public List LevelAreaChecks { get; set; } public bool Finished = false; - public static Dictionary LevelAreaOverrides = new Dictionary() //first is in-game, second is in-data + public static Dictionary LevelAreaOverrides = new() //first is in-game, second is in-data { {338602, 377700}, //battlefields of eterntity {271234, 370512}, //x1 fortress lv1