From b7d2b858fa514bccc1edf499abbb67a60d7cfa24 Mon Sep 17 00:00:00 2001 From: MatuxGG Date: Wed, 25 Sep 2024 17:09:00 +0200 Subject: [PATCH] Version 4.0.1 - 2024.9.4 --- GLMod/Class/VanillaEvents.cs | 4 +-- GLMod/EventPatch/PlayerControlPatch.cs | 40 ++++++++++++-------------- GLMod/GLMod.cs | 24 ++++++++-------- GLMod/GLMod.csproj | 2 +- 4 files changed, 34 insertions(+), 36 deletions(-) diff --git a/GLMod/Class/VanillaEvents.cs b/GLMod/Class/VanillaEvents.cs index ff5e484..814859e 100644 --- a/GLMod/Class/VanillaEvents.cs +++ b/GLMod/Class/VanillaEvents.cs @@ -15,8 +15,8 @@ public static void startGameVanilla() GLMod.StartGame("******", GLMod.gameMap, false); foreach (PlayerControl p in PlayerControl.AllPlayerControls) { - string role = p.Data.Role.TeamType == RoleTeamTypes.Crewmate ? "Crewmate" : "Impostor"; - GLMod.AddPlayer(p.Data.PlayerName, p.Data.Role.Role.ToString(), role); + string role = p?.Data?.Role?.TeamType == RoleTeamTypes.Crewmate ? "Crewmate" : "Impostor"; + GLMod.AddPlayer(p?.Data?.PlayerName, p?.Data?.Role?.Role.ToString(), role); } GLMod.SendGame(); GLMod.AddMyPlayer(); diff --git a/GLMod/EventPatch/PlayerControlPatch.cs b/GLMod/EventPatch/PlayerControlPatch.cs index aaf9324..a1fb001 100644 --- a/GLMod/EventPatch/PlayerControlPatch.cs +++ b/GLMod/EventPatch/PlayerControlPatch.cs @@ -141,38 +141,36 @@ public static void Postfix(PlayerControl __instance) try { - if (AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started) + if (AmongUsClient.Instance.GameState != InnerNet.InnerNetClient.GameStates.Started) { - if (gameStarted) return; - + gameStarted = false; + return; + } + if (gameStarted) return; - int nbImp = GameOptionsManager.Instance.CurrentGameOptions.NumImpostors; - int realImp = 0; - foreach (PlayerControl p in PlayerControl.AllPlayerControls) + int nbImp = GameOptionsManager.Instance.CurrentGameOptions.NumImpostors; + int realImp = 0; + foreach (PlayerControl p in PlayerControl.AllPlayerControls) + { + if (p?.Data?.Role?.IsImpostor == true) { - if (p.Data.Role.IsImpostor) - { - realImp++; - } + realImp++; } + } - if (nbImp != realImp) return; - // Start game - GLMod.gameMap = GLMod.getMapName(); + if (nbImp != realImp) return; - VanillaEvents.startGameVanilla(); - gameStarted = true; - } - else - { - gameStarted = false; - } + // Start game + GLMod.gameMap = GLMod.getMapName(); + + VanillaEvents.startGameVanilla(); + gameStarted = true; } catch (Exception e) { - GLMod.logError("[VanillaFixedUpdate] Catch exception " + e.Message); + GLMod.logError("[VanillaFixedUpdate] Catch exception " + e.Message + " / stack = " + e.StackTrace); } diff --git a/GLMod/GLMod.cs b/GLMod/GLMod.cs index 802519e..1205fce 100644 --- a/GLMod/GLMod.cs +++ b/GLMod/GLMod.cs @@ -758,23 +758,23 @@ public static string getMapName() { try { - //if (PlayerControl.GameOptions.MapId == 0) - // return "The Skeld"; + if (GameOptionsManager.Instance.currentGameOptions.MapId == (byte)MapNames.Skeld) + return "The Skeld"; - //if (PlayerControl.GameOptions.MapId == 1) - // return "MiraHQ"; + if (GameOptionsManager.Instance.currentGameOptions.MapId == (byte)MapNames.Mira) + return "MiraHQ"; - //if (PlayerControl.GameOptions.MapId == 2) - // return "Polus"; + if (GameOptionsManager.Instance.currentGameOptions.MapId == (byte)MapNames.Polus) + return "Polus"; - //if (PlayerControl.GameOptions.MapId == 3) - // return "dlekSehT"; + if (GameOptionsManager.Instance.currentGameOptions.MapId == (byte)MapNames.Dleks) + return "dlekSehT"; - //if (PlayerControl.GameOptions.MapId == 4) - // return "Airship"; + if (GameOptionsManager.Instance.currentGameOptions.MapId == (byte)MapNames.Airship) + return "Airship"; - //if (PlayerControl.GameOptions.MapId == 5) - // return "Submerged"; + if (GameOptionsManager.Instance.currentGameOptions.MapId == (byte)MapNames.Fungle) + return "The Fungle"; return "Unknown"; } catch (Exception e) diff --git a/GLMod/GLMod.csproj b/GLMod/GLMod.csproj index eb97e0e..620cc42 100644 --- a/GLMod/GLMod.csproj +++ b/GLMod/GLMod.csproj @@ -2,7 +2,7 @@ net6.0 4.0.0 - v2024.6.18s + v2024.9.4s GLMod Matux