Use dictionary and hashset for admin log entities and players respectively

Add test for duplicate player ids in an admin log not throwing
This commit is contained in:
DrSmugleaf
2021-12-26 00:50:10 +01:00
parent 82d9c38c96
commit 0ca8c705ab
5 changed files with 65 additions and 25 deletions

View File

@@ -40,22 +40,20 @@ public ref struct LogStringHandler
format = argument[0] == '@' ? argument[1..] : argument;
}
if (!Values.TryAdd(format, value))
if (Values.TryAdd(format, value) ||
Values[format] == (object?) value)
{
if (Values[format] == (object?) value)
{
return;
}
return;
}
var originalFormat = format;
var i = 2;
var originalFormat = format;
var i = 2;
format = $"{originalFormat}_{i}";
while (!Values.TryAdd(format, value))
{
format = $"{originalFormat}_{i}";
while (!Values.TryAdd(format, value))
{
format = $"{originalFormat}_{i}";
i++;
}
i++;
}
}