Warmup-safe skill assignment, PerfLog header
- Treat null GameRules as "not ready" so skills are never assigned during warmup right after plugin load/hot-reload (SetSkill + RoundStart) - PerfLog writes a header line on first measurement so the perf file appears immediately when PerfMode is active
This commit is contained in:
parent
b68a033b4c
commit
380d2ca731
5 changed files with 22 additions and 3 deletions
|
|
@ -14,7 +14,22 @@ namespace src.player
|
|||
|
||||
public static bool Enabled => Config.LoadedConfig.PerfMode;
|
||||
|
||||
public static long Start() => Enabled ? Stopwatch.GetTimestamp() : 0;
|
||||
private static bool _headerWritten;
|
||||
|
||||
public static long Start()
|
||||
{
|
||||
if (!Enabled) return 0;
|
||||
|
||||
// Write a header on the first measurement so the perf file appears immediately
|
||||
// when PerfMode is active - makes "is it working?" instantly visible.
|
||||
if (!_headerWritten)
|
||||
{
|
||||
_headerWritten = true;
|
||||
Write($"PerfMode enabled (plugin v{Instance.ModuleVersion})");
|
||||
}
|
||||
|
||||
return Stopwatch.GetTimestamp();
|
||||
}
|
||||
|
||||
// One-shot measurement: logs "label took X.XXms" when the elapsed time reaches the threshold.
|
||||
public static void End(string label, long startTimestamp, double thresholdMs = 1.0)
|
||||
|
|
|
|||
|
|
@ -595,7 +595,7 @@ namespace src.player
|
|||
{
|
||||
lock (setLock)
|
||||
{
|
||||
bool isWarmup = Instance.GameRules != null && Instance.GameRules.WarmupPeriod == true;
|
||||
bool isWarmup = Instance.GameRules == null || Instance.GameRules.WarmupPeriod == true;
|
||||
isTransmitRegistered = false;
|
||||
Instance.AddTimer(.1f, () => DisableAll(), CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
|
||||
|
||||
|
|
@ -877,7 +877,9 @@ namespace src.player
|
|||
{
|
||||
if (Instance == null) return;
|
||||
|
||||
if (Instance.GameRules != null && Instance.GameRules.WarmupPeriod == true)
|
||||
// GameRules can be null for a short window right after plugin load/hot-reload;
|
||||
// treat that as "not ready" so skills are never assigned during warmup by accident.
|
||||
if (Instance.GameRules == null || Instance.GameRules.WarmupPeriod == true)
|
||||
{
|
||||
setSkillTimer?.Kill();
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue