Skip to content

Conversation

@acidphantasm
Copy link

Small fixes for FlagOfferForRemoval and logfix in mod limit hit debug

@qodo-free-for-open-source-projects

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
Use correct global configuration value

Instead of leaving a TODO, fix the offer expiration logic to use the correct
global configuration
Globals.Configuration.RagFair.OfferDurationTimeInHourAfterRemove. This will
prevent server-client desynchronization issues.

Examples:

Libraries/SPTarkov.Server.Core/Controllers/RagfairController.cs [1028-1038]
        var now = timeUtil.GetTimeStamp();
        var configExpireSeconds = RagfairConfig.Sell.ExpireSeconds;

        var differenceInSeconds = playerOffer.EndTime - now;
        if (differenceInSeconds > configExpireSeconds)
        {
            // `expireSeconds` Default is 71 seconds
            // TODO: RagfairConfig.Sell.ExpireSeconds should not exist as it should use
            // Globals.Configuration.RagFair.OfferDurationTimeInHourAfterRemove (the value actually used by client)
            var newEndTime = configExpireSeconds + now;

 ... (clipped 1 lines)

Solution Walkthrough:

Before:

// In RagfairController.cs
public ItemEventRouterResponse FlagOfferForRemoval(...)
{
    ...
    var now = timeUtil.GetTimeStamp();
    var configExpireSeconds = RagfairConfig.Sell.ExpireSeconds; // Incorrect custom config

    var differenceInSeconds = playerOffer.EndTime - now;
    if (differenceInSeconds > configExpireSeconds)
    {
        // TODO: RagfairConfig.Sell.ExpireSeconds should not exist...
        var newEndTime = configExpireSeconds + now;
        playerOffer.EndTime = (long?)Math.Round((double)newEndTime);
    }
    ...
}

After:

// In RagfairController.cs
public ItemEventRouterResponse FlagOfferForRemoval(...)
{
    ...
    var globals = databaseService.GetGlobals();
    var expireTimeSeconds = globals.Configuration.RagFair.OfferDurationTimeInHourAfterRemove * 3600; // Correct global config in seconds

    var now = timeUtil.GetTimeStamp();
    var differenceInSeconds = playerOffer.EndTime - now;
    if (differenceInSeconds > expireTimeSeconds)
    {
        var newEndTime = expireTimeSeconds + now;
        playerOffer.EndTime = (long?)Math.Round((double)newEndTime);
    }
    ...
}
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a significant bug (server-client desync) that the PR author noted but did not fix, and proposes a complete solution, greatly improving the feature's correctness.

High
General
Improve log message time format

Improve the readability of the expiry time in a debug log message by formatting
the TimeSpan with a more concise, custom string.

Libraries/SPTarkov.Server.Core/Controllers/RagfairController.cs [1042-1047]

 if (logger.IsLogEnabled(LogLevel.Debug) && differenceInSeconds is { } remaining)
     {
         logger.Debug(
-            $"Flagged player: {sessionId} offer: {offerId} for expiry in: {TimeSpan.FromSeconds(remaining).ToString()}"
+            $"Flagged player: {sessionId} offer: {offerId} for expiry in: {TimeSpan.FromSeconds(remaining).ToString(@"d'd 'h'h 'm'm 's's'")}"
         );
     }
Suggestion importance[1-10]: 4

__

Why: The suggestion improves the readability of a debug log message by applying a custom format to a TimeSpan, which is a minor but useful enhancement.

Low
  • More

@chompDev chompDev merged commit 432dd2e into sp-tarkov:develop Jan 6, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants