From 0c17b0e4bc9d96d9e0ef42923a63e82d30bec2fb Mon Sep 17 00:00:00 2001 From: Lucca Faria Ferri Date: Sat, 28 Jan 2023 10:37:05 -0800 Subject: [PATCH] update fix --- .../GSSystem/GameSystem/GSBackend.cs | 52 ++++++++++--------- .../D3-GameServer/GSSystem/GameSystem/Game.cs | 20 +++---- .../GSSystem/GameSystem/GameUpdateManager.cs | 2 +- .../GSSystem/GameSystem/GameUpdateThread.cs | 2 +- .../GSSystem/GameSystem/QuestManager.cs | 14 ++--- 5 files changed, 46 insertions(+), 44 deletions(-) diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/GSBackend.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/GSBackend.cs index 11f05ef..09ea9a2 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/GSBackend.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/GSBackend.cs @@ -43,8 +43,8 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem { game.SetAct(int.Parse(args[2].Trim())); game.SetGameMode((Game.Mode)int.Parse(args[7].Trim())); - game.IsHardcore = args[6].Trim() == "True" ? true : false; - game.IsSeasoned = args[8].Trim() == "True" ? true : false; + game.IsHardcore = (args[6].Trim() == "True" ? true : false); + game.IsSeasoned = (args[8].Trim() == "True" ? true : false); game.SetDifficulty(int.Parse(args[3].Trim())); if (game.GameMode != Game.Mode.Portals) game.SetQuestProgress(int.Parse(args[4].Trim()), int.Parse(args[5].Trim())); @@ -92,138 +92,140 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem }); } - private void BattleNetSocketSend(string data) => BattleNetSocketSend(data); + private void BattleNetSocketSend(string data) => BattleNetSocketSend(Encoding.UTF8.GetBytes(data)); private bool SenderServerDisconnected() { - Logger.Warn("Blizznet was disconnected!"); + Logger.Warn("MooNetServer was disconnected!"); return true; } public void RegisterGameServer(string ip, int port) { Logger.MethodTrace($"ip {ip}, port {port}"); - BattleNetSocketSend($"rngsr|{ip}/{port}"); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"rngsr|{ip}/{port}")); } public void RegisterPvPGameServer(string ip, int port) { Logger.MethodTrace($"ip {ip}, port {port}"); - BattleNetSocketSend($"rnpvpgsr|{ip}/{port}"); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"rnpvpgsr|{ip}/{port}")); } public void GrantAchievement(ulong gameAccountId, ulong achievementId) { Logger.MethodTrace($"gameAccountId {gameAccountId}, achievementId {achievementId}"); - BattleNetSocketSend($"grachi|{gameAccountId}/{achievementId}"); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"grachi|{gameAccountId}/{achievementId}")); } public void GrantCriteria(ulong gameAccountId, ulong criteriaId) { Logger.MethodTrace($"gameAccountId {gameAccountId}, achievementId {criteriaId}"); - BattleNetSocketSend($"gcrit|{gameAccountId}/{criteriaId}"); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"gcrit|{gameAccountId}/{criteriaId}")); } public void UpdateAchievementCounter(ulong gameAccountId, int type, uint addCounter, int comparand, ulong achievement = 0) { Logger.MethodTrace($"type {type}, addCounter {addCounter}, comparand {comparand}"); - BattleNetSocketSend($"uoacce|{gameAccountId}/{type}/{addCounter}/{comparand}/{achievement}"); + BattleNetSocketSend(Encoding.UTF8.GetBytes( + $"uoacce|{gameAccountId}/{type}/{addCounter}/{comparand}/{achievement}")); } public void UpdateSingleAchievementCounter(ulong gameAccountId, ulong achId, uint addCounter) { Logger.MethodTrace($"type {achId}, addCounter {addCounter}"); - BattleNetSocketSend($"upsnaccr|{gameAccountId}/{achId}/{addCounter}"); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"upsnaccr|{gameAccountId}/{achId}/{addCounter}")); } public void UpdateQuantity(ulong gameAccountId, ulong achievementId, uint addCounter) { Logger.MethodTrace($"achievementId {achievementId}, addCounter {addCounter}"); - BattleNetSocketSend($"upequt|{gameAccountId}/{achievementId}/{addCounter}"); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"upequt|{gameAccountId}/{achievementId}/{addCounter}")); } public void CheckQuestCriteria(ulong gameAccountId, int questId, bool isCoop) { Logger.MethodTrace($"gameAccountId {gameAccountId}, questId {questId}, coop {isCoop}"); - BattleNetSocketSend($"cqc|{gameAccountId}/{questId}/{(isCoop ? "True" : "False")}"); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"cqc|{gameAccountId}/{questId}/{(isCoop ? "True" : "False")}")); } public void CheckKillMonsterCriteria(ulong gameAccountId, int actorId, int type, bool isHardcore) { Logger.MethodTrace($"gameAccountId {gameAccountId}, actorId {actorId}, type {type}, hc {isHardcore}"); - BattleNetSocketSend($"ckmc|{gameAccountId}/{actorId}/{type}/{(isHardcore ? "True" : "False")}"; + BattleNetSocketSend(Encoding.UTF8.GetBytes( + $"ckmc|{gameAccountId}/{actorId}/{type}/{(isHardcore ? "True" : "False")}")); } public void CheckSalvageItemCriteria(ulong gameAccountId, int itemId) { Logger.MethodTrace($"gameAccountId {gameAccountId}, itemId {itemId}"); - BattleNetSocketSend($"csic|{gameAccountId}/{itemId}"; + BattleNetSocketSend(Encoding.UTF8.GetBytes($"csic|{gameAccountId}/{itemId}")); } public void CheckLevelCap(ulong gameAccountId) { Logger.MethodTrace($"gameAccountId {gameAccountId}"); - BattleNetSocketSend($"clc|{gameAccountId}"); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"clc|{gameAccountId}")); } public void CheckConversationCriteria(ulong gameAccountId, int convId) { Logger.MethodTrace($"gameAccountId {gameAccountId}, convId {convId}"); - BattleNetSocketSend($"ccc|{gameAccountId}/{convId}"); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"ccc|{gameAccountId}/{convId}")); } public void CheckLevelAreaCriteria(ulong gameAccountId, int laId) { Logger.MethodTrace($"gameAccountId {gameAccountId}, laId {laId}"); - BattleNetSocketSend($"clac|{gameAccountId}/{laId}"); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"clac|{gameAccountId}/{laId}")); } public void UpdateClient(ulong gameAccountId, int level, int screen) { Logger.MethodTrace($"gameAccountId {gameAccountId}"); - BattleNetSocketSend($"uc|{gameAccountId}/{level}/{screen}"); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"uc|{gameAccountId}/{level}/{screen}")); } public void PlayerJoined(int gameId) { Logger.MethodTrace($"gameId {gameId}"); - BattleNetSocketSend($"gpj|{gameId}"); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"gpj|{gameId}")); } public void PlayerLeft(int gameId) { Logger.MethodTrace($"gameId {gameId}"); - BattleNetSocketSend($"gpl|{gameId}"); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"gpl|{gameId}")); } public void SetGamePublic(int gameId) { Logger.MethodTrace($"gameId {gameId}"); - BattleNetSocketSend($"gsp|{gameId}"); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"gsp|{gameId}")); } public void PvPSaveProgress(ulong gameAccountId, int kills, int wins, int gold) { Logger.MethodTrace($"game account id {gameAccountId}"); - BattleNetSocketSend($"pvpsp|{gameAccountId}/{kills}/{wins}/{gold}"); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"pvpsp|{gameAccountId}/{kills}/{wins}/{gold}")); } public void ParagonLevelUp(ulong gameAccountId) { Logger.MethodTrace($"game account id {gameAccountId}"); - BattleNetSocketSend($"plu|{gameAccountId}"); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"plu|{gameAccountId}")); } public void ToonStateChanged(ulong toonId) { Logger.MethodTrace($"game account id {toonId}"); - BattleNetSocketSend($"tsc|{toonId}"); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"tsc|{toonId}")); } public void UniqueItemIdentified(ulong gameAccountId, ulong itemId) { Logger.MethodTrace($"gameAccountId {gameAccountId}, itemId {itemId}"); - BattleNetSocketSend($"uii|{gameAccountId}/{itemId}"); + BattleNetSocketSend(Encoding.UTF8.GetBytes($"uii|{gameAccountId}/{itemId}")); } } } diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/Game.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/Game.cs index af29d93..d546d75 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/Game.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/Game.cs @@ -447,7 +447,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem } - Interlocked.Add(ref _tickCounter, TickRate + MissedTicks); // +6 ticks per 100ms. Verified by setting LogoutTickTimeMessage.Ticks to 600 which eventually renders a 10 sec logout timer on client. /raist + Interlocked.Add(ref _tickCounter, (TickRate + MissedTicks)); // +6 ticks per 100ms. Verified by setting LogoutTickTimeMessage.Ticks to 600 which eventually renders a 10 sec logout timer on client. /raist MissedTicks = 0; if (UpdateEnabled && !Paused) @@ -490,7 +490,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem if (_tickWatch.ElapsedMilliseconds > UpdateFrequency) { Logger.Trace("Game.Update() took [{0}ms] more than Game.UpdateFrequency [{1}ms].", _tickWatch.ElapsedMilliseconds, UpdateFrequency); - compensation = (int)(UpdateFrequency - _tickWatch.ElapsedMilliseconds % UpdateFrequency); + compensation = (int)(UpdateFrequency - (_tickWatch.ElapsedMilliseconds % UpdateFrequency)); MissedTicks = TickRate * (int)(_tickWatch.ElapsedMilliseconds / UpdateFrequency); } _calcWatch.Stop(); @@ -646,7 +646,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem TiredRiftPaticipatingHeroID = new long[] { 0x0, 0x0, 0x0, 0x0 }, //TiredRiftPaticipatingHeroID } }); - if ((CurrentStep == -1 || CurrentAct == 400) && CurrentQuest == QuestsOrder[0] && CurrentAct != 3000) + if ((CurrentStep == -1 || CurrentAct == 400) && (CurrentQuest == QuestsOrder[0]) && CurrentAct != 3000) { switch (CurrentAct) { @@ -748,7 +748,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem } /**/ - if (!PvP && !(CurrentStep == -1 && CurrentQuest == QuestsOrder[0])) + if (!PvP && !((CurrentStep == -1) && (CurrentQuest == QuestsOrder[0]))) { joinedPlayer.InGameClient.SendMessage(new QuestUpdateMessage() { @@ -1161,8 +1161,8 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem var handicapLevels = (GameBalance)MPQStorage.Data.Assets[SNOGroup.GameBalance][256027].Data; HPModifier = handicapLevels.HandicapLevelTables[diff].HPMod; DmgModifier = handicapLevels.HandicapLevelTables[diff].DmgMod; - XPModifier = 1f + handicapLevels.HandicapLevelTables[diff].XPMod; - GoldModifier = 1f + handicapLevels.HandicapLevelTables[diff].GoldMod; + XPModifier = (1f + handicapLevels.HandicapLevelTables[diff].XPMod); + GoldModifier = (1f + handicapLevels.HandicapLevelTables[diff].GoldMod); } foreach (var wld in _worlds) foreach (var monster in wld.Value.Monsters) @@ -1258,7 +1258,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem BlueTeamWins++; } - if (CurrentPvPRound > 5 || Math.Abs(RedTeamWins - BlueTeamWins) > 5 - CurrentPvPRound) + if (CurrentPvPRound > 5 || Math.Abs(RedTeamWins - BlueTeamWins) > (5 - CurrentPvPRound)) { BroadcastMessage("Battle is over!"); try @@ -1271,7 +1271,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem //foreach (var player in this.Players.Values) //player.World.BuffManager.AddBuff(player, player, new Mooege.Core.GS.Powers.Implementations.PVPRoundEndBuff(TickTimer.WaitSeconds(this, 1200.0f))); foreach (var plr in Players.Keys) - plr.SendMessage(new DataIDDataMessage(Opcodes.PVPArenaWin) { Field0 = RedTeamWins == BlueTeamWins ? 0 : RedTeamWins < BlueTeamWins ? 2 : 3 }); + plr.SendMessage(new DataIDDataMessage(Opcodes.PVPArenaWin) { Field0 = (RedTeamWins == BlueTeamWins ? 0 : (RedTeamWins < BlueTeamWins ? 2 : 3)) }); return; } @@ -1294,7 +1294,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem //foreach (var player in this.Players.Values) //player.World.BuffManager.AddBuff(player, player, new Mooege.Core.GS.Powers.Implementations.PVPRoundEndBuff(TickTimer.WaitSeconds(this, 1200.0f))); foreach (var plr in Players.Keys) - plr.SendMessage(new DataIDDataMessage(Opcodes.PVPArenaWin) { Field0 = RedTeamWins == BlueTeamWins ? 0 : RedTeamWins < BlueTeamWins ? 2 : 3 }); + plr.SendMessage(new DataIDDataMessage(Opcodes.PVPArenaWin) { Field0 = (RedTeamWins == BlueTeamWins ? 0 : (RedTeamWins < BlueTeamWins ? 2 : 3)) }); })); } @@ -1745,7 +1745,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem .Union(((DiIiS_NA.Core.MPQ.FileFormats.Act)MPQStorage.Data.Assets[SNOGroup.Act][70018].Data).WayPointInfo) .Union(((DiIiS_NA.Core.MPQ.FileFormats.Act)MPQStorage.Data.Assets[SNOGroup.Act][236915].Data).WayPointInfo) .Where(w => w.SNOWorld != -1).ToList(); - var wayPointInfo = actData.Where(w => w.Flags == 3 || (isOpenWorld ? w.Flags == 2 : w.Flags == 1)).ToList(); + var wayPointInfo = actData.Where(w => w.Flags == 3 || (isOpenWorld ? (w.Flags == 2) : (w.Flags == 1))).ToList(); //Logger.Debug("GetWayPointWorldById: world id {0}", wayPointInfo[id].SNOWorld); return GetWorld((WorldSno)wayPointInfo[id].SNOWorld); } diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/GameUpdateManager.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/GameUpdateManager.cs index 841e32b..0426f82 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/GameUpdateManager.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/GameUpdateManager.cs @@ -22,7 +22,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem for (int coreId = 0; coreId < CPUCount; coreId++) { var thread = new GameUpdateThread(); - thread.CPUAffinity = 1UL << coreId; + thread.CPUAffinity = (1UL << coreId); UpdateWorkers.Add(thread); var loopThread = new Thread(thread.Run) { Name = "UpdateWorkerThread", IsBackground = true }; ; // create the game update thread. loopThread.Start(); diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/GameUpdateThread.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/GameUpdateThread.cs index b84d29e..53a1867 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/GameUpdateThread.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/GameUpdateThread.cs @@ -96,7 +96,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem if (_tickWatch.ElapsedMilliseconds > 100) { Logger.Trace("Game.Update() took [{0}ms] more than Game.UpdateFrequency [{1}ms].", _tickWatch.ElapsedMilliseconds, 100); - compensation = (int)(100 - _tickWatch.ElapsedMilliseconds % 100); + compensation = (int)(100 - (_tickWatch.ElapsedMilliseconds % 100)); missedTicks = 6 * (int)(_tickWatch.ElapsedMilliseconds / 100); Thread.Sleep(Math.Max(0, compensation)); // sleep until next Update(). } diff --git a/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/QuestManager.cs b/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/QuestManager.cs index 6ab69ee..d42b2cb 100644 --- a/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/QuestManager.cs +++ b/src/DiIiS-NA/D3-GameServer/GSSystem/GameSystem/QuestManager.cs @@ -455,7 +455,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem { snoQuest = questId, annMeter = Meterid, - flMeter = QuestTimerEstimate / duration + flMeter = (QuestTimerEstimate / duration) }); }; }), @@ -571,7 +571,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem if (trigger.Value.triggerType == QuestStepObjectiveType.HadConversation) foreach (var world in Game.Worlds) { - var actors = world.Actors.Values.Where(d => d.Visible && d is InteractiveNPC && (d as InteractiveNPC).Conversations.Any(c => c.ConversationSNO == trigger.Key)); + var actors = world.Actors.Values.Where(d => d.Visible && (d is InteractiveNPC) && (d as InteractiveNPC).Conversations.Any(c => c.ConversationSNO == trigger.Key)); Actor actor = null; if (actors.Count() == 1) actor = actors.First(); if (actor != null) @@ -674,9 +674,9 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem { if (strictFilter) { - if (Game.CurrentQuest == snoQuest && Game.CurrentStep == Step + if ((Game.CurrentQuest == snoQuest) && (Game.CurrentStep == Step) || - Game.CurrentSideQuest == snoQuest && Game.CurrentSideStep == Step) + (Game.CurrentSideQuest == snoQuest) && (Game.CurrentSideStep == Step)) return true; } else @@ -718,7 +718,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem public bool IsInQuestRange(QuestRange range) { - if (range.Header.SNOId == 312431) return Game.CurrentAct == 3000; + if (range.Header.SNOId == 312431) return (Game.CurrentAct == 3000); if (range.Header.SNOId == 214766) return true; bool started = false; @@ -927,7 +927,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem StepID = 4, TaskIndex = AdditionalTaskId, Counter = AdditionalTargetCounter, - Checked = AdditionalTargetNeed <= AdditionalTargetCounter ? 1 : 0 + Checked = (AdditionalTargetNeed <= AdditionalTargetCounter) ? 1 : 0 }); if (MonsterCount < AdditionalTargetCounter + 20) { @@ -1015,7 +1015,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem { foreach (var player in QuestManager.Game.Players.Values) { - var xpReward = 1000 * player.Level * (1 + player.Level / 7) * QuestManager.Game.XPModifier; + var xpReward = 1000 * player.Level * (1 + (player.Level / 7)) * QuestManager.Game.XPModifier; if (Type == BountyData.BountyType.KillUnique) xpReward *= 1.8f; if (Type == BountyData.BountyType.ClearDungeon)