Fixed ragfair offers not being processed Fixes #358

This commit is contained in:
Chomp
2025-06-05 13:41:40 +01:00
parent 2019e7d182
commit 82b8c7d2da
3 changed files with 21 additions and 17 deletions
@@ -18,10 +18,12 @@ public class RagfairCallbacks(
RagfairController _ragfairController,
RagfairTaxService _ragfairTaxService,
RagfairPriceService _ragfairPriceService,
ConfigServer _configServer
ConfigServer _configServer,
TimeUtil _timeUtil
) : IOnLoad, IOnUpdate
{
private readonly RagfairConfig _ragfairConfig = _configServer.GetConfig<RagfairConfig>();
private long _lastRunOnUpdateTimestamp = long.MaxValue;
public Task OnLoad()
{
@@ -30,20 +32,26 @@ public class RagfairCallbacks(
return Task.CompletedTask;
}
public Task OnUpdate(long timeSinceLastRun)
public Task OnUpdate(long secondsSinceLastRun)
{
if (timeSinceLastRun > _ragfairConfig.RunIntervalSeconds)
if (_timeUtil.GetTimeStamp() <= _lastRunOnUpdateTimestamp + _ragfairConfig.RunIntervalSeconds)
{
// There is a flag inside this class that only makes it run once.
_ragfairServer.AddPlayerOffers();
// Check player offers and mail payment to player if sold
_ragfairController.Update();
// Process all offers / expire offers
_ragfairServer.Update();
// Not enough time has passed since last run, exit early
return Task.CompletedTask;
}
// There is a flag inside this class that only makes it run once.
_ragfairServer.AddPlayerOffers();
// Check player offers and mail payment to player if sold
_ragfairController.Update();
// Process all offers / expire offers
_ragfairServer.Update();
// Store last completion time for later use
_lastRunOnUpdateTimestamp = _timeUtil.GetTimeStamp();
return Task.CompletedTask;
}
@@ -2,5 +2,5 @@ namespace SPTarkov.Server.Core.DI;
public interface IOnUpdate
{
Task OnUpdate(long timeSinceLastRun);
Task OnUpdate(long secondsSinceLastRun);
}
+1 -5
View File
@@ -118,11 +118,7 @@ public class App(
updateableName = $"{updateable.GetType().Namespace}.{updateable.GetType().Name}";
}
if (!_onUpdateLastRun.TryGetValue(updateableName, out var lastRunTimeTimestamp))
{
lastRunTimeTimestamp = 0;
}
var lastRunTimeTimestamp = _onUpdateLastRun.GetValueOrDefault(updateableName, 0);
var secondsSinceLastRun = _timeUtil.GetTimeStamp() - lastRunTimeTimestamp;
try