Add @YAProxy dependency check + retry at mission init
MissionServer.OnInit now confirms CfgPatches YAProxy exists before loading config; if missing it warns and retries (10x/2s) then logs an actionable error. Belt-and-suspenders for server-pack misconfiguration (requiredAddons already hard-enforces the dependency). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
5a07c85416
commit
fadfbaeee4
1 changed files with 32 additions and 6 deletions
|
|
@ -1,20 +1,46 @@
|
|||
// ============================================================================
|
||||
// YAInteractionMissionInit
|
||||
// ----------------------------------------------------------------------------
|
||||
// Loads the JSON configuration server-side at mission init, before any player
|
||||
// connects. MissionServer only exists on the server, which is exactly where we
|
||||
// want the authoritative config (loot, cooldowns, water amounts) to live.
|
||||
// Server-side init: confirms the @YAProxy dependency is present, then loads the
|
||||
// JSON configuration before any player connects.
|
||||
//
|
||||
// Clients do not run this; they fall back to in-code defaults for action
|
||||
// injection via YAInteractionConfigLoader.EnsureDefaults() (see the loader).
|
||||
// @YAProxy is a hard dependency (requiredAddons + our actions extend
|
||||
// YAProxyActionBase), so it is normally guaranteed. This explicit check gives a
|
||||
// clear log line in a server pack's RPT and defensively waits/retries in case
|
||||
// of an unusual load-timing edge before logging a actionable error.
|
||||
//
|
||||
// Clients don't run this; they use in-code defaults via
|
||||
// YAInteractionConfigLoader.EnsureDefaults().
|
||||
// ============================================================================
|
||||
modded class MissionServer
|
||||
{
|
||||
protected int m_YADepAttempts = 0;
|
||||
protected const int YA_DEP_MAX_ATTEMPTS = 10; // ~20s total (2s apart)
|
||||
|
||||
override void OnInit()
|
||||
{
|
||||
super.OnInit();
|
||||
YA_InitWhenReady();
|
||||
}
|
||||
|
||||
Print("[YAInteraction] MissionServer.OnInit - loading configuration");
|
||||
void YA_InitWhenReady()
|
||||
{
|
||||
if (GetGame().ConfigIsExisting("CfgPatches YAProxy"))
|
||||
{
|
||||
Print("[YAInteraction] Dependency @YAProxy found - loading configuration.");
|
||||
YAInteractionConfigLoader.Init();
|
||||
return;
|
||||
}
|
||||
|
||||
m_YADepAttempts++;
|
||||
if (m_YADepAttempts <= YA_DEP_MAX_ATTEMPTS)
|
||||
{
|
||||
Print(string.Format("[YAInteraction] WARNING: @YAProxy not detected (attempt %1/%2), retrying in 2s...", m_YADepAttempts, YA_DEP_MAX_ATTEMPTS));
|
||||
GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(YA_InitWhenReady, 2000, false);
|
||||
return;
|
||||
}
|
||||
|
||||
Print("[YAInteraction] ERROR: @YAProxy dependency NOT found. Add @YAProxy to the server -mod list (loaded before @YAInteraction). Loading config so JSON still generates, but Search/Sink actions require @YAProxy.");
|
||||
YAInteractionConfigLoader.Init();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue