mirror of
https://github.com/Impostor/Impostor.git
synced 2026-10-19 15:51:42 +00:00
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:
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user