Don't clear RoleOptions on update

Among Us always adds a constant amount of roles to this dict, so it
doesn't make sense to clear this dictionary every time.

Furthermore, previously it was possible to trigger a
ConcurrentModificationException when running Deserialize in parallel
with Serialize. This should no longer happen, as new keys are no longer added
This commit is contained in:
miniduikboot committed 2025-05-28 22:34:57 +02:00
1 parent 0ac0b1d403
commit 46a6005ba5
1 file changed
+1 -3
@@ -16,8 +16,6 @@ public class RoleOptionsCollection
public void Deserialize(IMessageReader reader)
{
Roles.Clear();
var count = reader.ReadPackedInt32();
Roles.EnsureCapacity(count);
for (var i = 0; i < count; i++)
@@ -37,7 +35,7 @@ public class RoleOptionsCollection
_ => throw new ArgumentOutOfRangeException(nameof(roleType), roleType, null),
};
Roles.Add(roleType, new RoleData(roleType, roleOptions, roleRate));
Roles[roleType] = new RoleData(roleType, roleOptions, roleRate);
}
}