From aee304fb96dde013ea5ef6fd6ea9e2114561270c Mon Sep 17 00:00:00 2001 From: Atony <75191600+AtonyGit@users.noreply.github.com> Date: Sat, 22 Nov 2025 08:19:58 -0600 Subject: [PATCH] Fix nullable roletype errors --- .../Roles/LogicRoleSelectionNormalPatch.cs | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/MiraAPI/Patches/Roles/LogicRoleSelectionNormalPatch.cs b/MiraAPI/Patches/Roles/LogicRoleSelectionNormalPatch.cs index d32f0dd..0d00008 100644 --- a/MiraAPI/Patches/Roles/LogicRoleSelectionNormalPatch.cs +++ b/MiraAPI/Patches/Roles/LogicRoleSelectionNormalPatch.cs @@ -71,15 +71,22 @@ public static class LogicRoleSelectionNormalPatch } __instance.AssignRolesFromList(players, teamMax, list, ref num); - if (defaultRole != null) + var defaultRole2 = team is RoleTeamTypes.Crewmate ? RoleTypes.Crewmate : RoleTypes.Impostor; + try { - while (list.Count < players.Count && list.Count + num < teamMax) - { - list.Add(defaultRole.Value); - } - - __instance.AssignRolesFromList(players, teamMax, list, ref num); + defaultRole2 = defaultRole.Value; } + catch + { + // Ignored + } + + while (list.Count < players.Count && list.Count + num < teamMax) + { + list.Add(defaultRole2); + } + + __instance.AssignRolesFromList(players, teamMax, list, ref num); return false; }