Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Services/AdService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ private bool IsWarmupStateValid(AdConfig ad)
if (ad.OnlyInWarmup)
return isWarmup;

return !isWarmup;
return true;
}

private bool IsIntervalElapsed(AdConfig ad)
Expand Down
20 changes: 13 additions & 7 deletions Utils/MessageFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,21 +243,27 @@ private string ReplacePlayerVariables(string message, PlayerInfo playerInfo)

public Dictionary<string, string> GetServerVariables()
{
if ((DateTime.Now - _lastServerVarUpdate).TotalSeconds > 5)
bool needsUpdate = (DateTime.Now - _lastServerVarUpdate).TotalSeconds > 5 || _cachedServerVariables.Count == 0;

if (needsUpdate)
{
Server.NextFrame(() =>
try
{
try
var newVariables = GetServerVariablesInternal();
if (newVariables.Count > 0)
{
_cachedServerVariables = GetServerVariablesInternal();
_cachedServerVariables = newVariables;
_lastServerVarUpdate = DateTime.Now;
}
catch (Exception ex)
}
catch (Exception ex)
{
Console.WriteLine($"[AutomaticAds] Error updating server variables: {ex.Message}");
if (_cachedServerVariables.Count == 0)
{
Console.WriteLine($"[AutomaticAds] Error updating server variables: {ex.Message}");
_cachedServerVariables = GetFallbackServerVariables();
}
});
}
}

return _cachedServerVariables.Count > 0 ? _cachedServerVariables : GetFallbackServerVariables();
Expand Down