Skip to content

Commit

Permalink
fix a station event weighting bug (space-wizards#33584)
Browse files Browse the repository at this point in the history
* fractional weights dont work in StationEvents

* force-int

* sure why not, we can keep floats I guess.
  • Loading branch information
IProduceWidgets authored Dec 6, 2024
1 parent 0e6ec2e commit 3e0b93d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Content.Server/StationEvents/EventManagerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,20 @@ public bool TryBuildLimitedEvents(EntityTableSelector limitedEventsTable, out Di
return null;
}

var sumOfWeights = 0;
var sumOfWeights = 0.0f;

foreach (var stationEvent in availableEvents.Values)
{
sumOfWeights += (int) stationEvent.Weight;
sumOfWeights += stationEvent.Weight;
}

sumOfWeights = _random.Next(sumOfWeights);
sumOfWeights = _random.NextFloat(sumOfWeights);

foreach (var (proto, stationEvent) in availableEvents)
{
sumOfWeights -= (int) stationEvent.Weight;
sumOfWeights -= stationEvent.Weight;

if (sumOfWeights <= 0)
if (sumOfWeights <= 0.0f)
{
return proto.ID;
}
Expand Down

0 comments on commit 3e0b93d

Please sign in to comment.