Fix bounties(and potentially other things) running out of ids (#32700)
* Make NameIdentifier Ids get refreshed after round restarts Before this commit the existing values would just get shuffled. This means that eventually the server would run out of ids to give to new entities for different groups. As a result everything would get id 0 * Comply with what seemingly is the convention for sawmills * Make it impossible to insert a bounty with a duplicate id * Reduce duplication * Remove unused sawmill * Fix rustbrain and skill issue * Aaaa * Apply suggestions from code review --------- Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
This commit is contained in:
@@ -420,6 +420,13 @@ public sealed partial class CargoSystem
|
||||
return false;
|
||||
|
||||
_nameIdentifier.GenerateUniqueName(uid, BountyNameIdentifierGroup, out var randomVal);
|
||||
var newBounty = new CargoBountyData(bounty, randomVal);
|
||||
// This bounty id already exists! Probably because NameIdentifierSystem ran out of ids.
|
||||
if (component.Bounties.Any(b => b.Id == newBounty.Id))
|
||||
{
|
||||
Log.Error("Failed to add bounty {ID} because another one with the same ID already existed!", newBounty.Id);
|
||||
return false;
|
||||
}
|
||||
component.Bounties.Add(new CargoBountyData(bounty, randomVal));
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Low, $"Added bounty \"{bounty.ID}\" (id:{component.TotalBounties}) to station {ToPrettyString(uid)}");
|
||||
component.TotalBounties++;
|
||||
|
||||
Reference in New Issue
Block a user