Fix regression in game started detection

In Impostor 1.9.x games only started when all players had a role set.
Currently games will start when the first role is assigned, with all
other players defaulting to Crewmate, ignoring the other SetRole
commands that Impostor has not yet processed.

This commit reverts to the previous correct behaviour where SetRole
needs to be called for all players. Also ignore RoleType when
deserializing, as Vanilla roles are not nullable
This commit is contained in:
miniduikboot committed 2024-07-19 20:01:36 +02:00
1 parent 99cf2243bd
commit 3ae24d549c
2 files changed
+5 -2

No files matched your search

@@ -160,7 +160,10 @@ namespace Impostor.Server.Net.Inner.Objects
Disconnected = (flag & 1) != 0;
IsDead = (flag & 4) != 0;
RoleType = (RoleTypes)reader.ReadUInt16(); // TODO ignore the RoleType here and only trust the SetRole rpc?
// Ignore the RoleType here and only trust the SetRole RPC, as
// RoleType is not nullable in vanilla, while Impostor checks game
// starts based on assigned roles.
_ = (RoleTypes)reader.ReadUInt16();
if (reader.ReadBoolean())
{
+1 -1
View File
@@ -398,7 +398,7 @@ namespace Impostor.Server.Net.State
control.PlayerInfo = playerInfo;
// Reset PlayerInfo
playerInfo.RoleType = RoleTypes.Crewmate;
playerInfo.RoleType = null;
playerInfo.RoleWhenAlive = null;
playerInfo.Tasks.Clear();
playerInfo.IsDead = false;