Fix GeoLite crash, add PerfMode profiling, reload cache invalidation
- GeoLite/MaxMind lookup wrapped in try/catch and disabled for the session on failure (stops the per-tick exception spam when the assembly cannot load during hot-reload) - New PerfMode config option: writes performance logs to logs/perf_<date>.txt (DisableAll/SetSkill/PlayerDeath totals, per-skill SkillAction timings, aggregated OnTick/CheckTransmit avg-max summaries) - css_reload now invalidates the skill-info and freeze-time caches - Removed the last null-forgiving player lookups (Command, Armored, Baseball, FriendlyFire, OneShot)
This commit is contained in:
parent
25cd8eb989
commit
b68a033b4c
14 changed files with 157 additions and 10 deletions
|
|
@ -80,6 +80,7 @@ namespace src.utils
|
|||
public bool EnableBotSkills { get; set; }
|
||||
public bool EnableBotKickDebug { get; set; }
|
||||
public bool DebugMode { get; set; }
|
||||
public bool PerfMode { get; set; }
|
||||
public string? AlternativeSkillButton { get; set; }
|
||||
public float SkillTimeBeforeStart { get; set; }
|
||||
public float SkillHudDuration { get; set; }
|
||||
|
|
@ -107,6 +108,7 @@ namespace src.utils
|
|||
EnableBotSkills = true;
|
||||
EnableBotKickDebug = false;
|
||||
DebugMode = false;
|
||||
PerfMode = false;
|
||||
AlternativeSkillButton = null;
|
||||
SkillTimeBeforeStart = 7;
|
||||
SkillHudDuration = -1;
|
||||
|
|
|
|||
|
|
@ -172,6 +172,8 @@ namespace src.utils
|
|||
return key;
|
||||
}
|
||||
|
||||
private static bool _geoLiteBroken = false;
|
||||
|
||||
private static string GetLangCode(CCSPlayerController? player)
|
||||
{
|
||||
if (player == null || !player.IsValid || player.IsBot) return defaultLangCode;
|
||||
|
|
@ -180,10 +182,24 @@ namespace src.utils
|
|||
if (!string.IsNullOrEmpty(fileLangCode))
|
||||
return fileLangCode;
|
||||
|
||||
if (Config.LoadedConfig.LanguageSystem.DisableGeoLite == true)
|
||||
if (Config.LoadedConfig.LanguageSystem.DisableGeoLite == true || _geoLiteBroken)
|
||||
return defaultLangCode;
|
||||
|
||||
string? geoliteLandCode = GetLangCodeFromDatabase(GetPlayerIP(player)) ?? defaultLangCode;
|
||||
string? geoliteLandCode;
|
||||
try
|
||||
{
|
||||
geoliteLandCode = GetLangCodeFromDatabase(GetPlayerIP(player)) ?? defaultLangCode;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// MaxMind.Db can fail to load (e.g. hot-reload while the old AssemblyLoadContext is
|
||||
// unloading) or the .mmdb can be corrupt; fall back to the default language and stop
|
||||
// trying for the rest of the session instead of throwing every HUD tick.
|
||||
_geoLiteBroken = true;
|
||||
Server.PrintToConsole($"[jRandomSkills] GeoLite lookup disabled for this session: {ex.GetType().Name}: {ex.Message}");
|
||||
geoliteLandCode = defaultLangCode;
|
||||
}
|
||||
|
||||
ChangePlayerLanguage(player, geoliteLandCode);
|
||||
return geoliteLandCode;
|
||||
}
|
||||
|
|
@ -197,6 +213,9 @@ namespace src.utils
|
|||
return parts.Length > 1 ? parts[0] : playerIP;
|
||||
}
|
||||
|
||||
// NoInlining keeps the MaxMind.Db type references out of GetLangCode, so an assembly-load
|
||||
// failure surfaces inside the try/catch at the call site instead of when GetLangCode is JITed.
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
|
||||
private static string? GetLangCodeFromDatabase(string? playerIP)
|
||||
{
|
||||
if (string.IsNullOrEmpty(playerIP)) return null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue