Files
EscapistsReintroduced/docs/evidence/server-items-2026-10-02/fixture.c
T
jakub 6a667d8deb Capture current mission, AI, map and administration development
Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
2026-10-13 22:52:53 +02:00

85 lines
3.9 KiB
C

modded class ArmaReforgerScripted
{
protected bool m_ERRItemsTestStarted;
protected bool m_ERRItemsTestDone;
protected bool m_ERRItemsMenuOpened;
override void OnUpdate(BaseWorld world, float timeslice)
{
super.OnUpdate(world, timeslice);
ERR_GameMode mode = ERR_GameMode.Get();
if (!mode) return;
if (!Replication.IsServer())
{
if (GetPlayerController() && !m_ERRItemsMenuOpened) { m_ERRItemsMenuOpened = true; ERR_AdminMenu.Open(); }
return;
}
if (!mode.Active() || m_ERRItemsTestDone) return;
ERR_ServerItemCatalog catalog = GetGame().ERR_ServerItems();
if (!m_ERRItemsTestStarted)
{
m_ERRItemsTestStarted = true;
array<string> replies = {};
mode.Admin().Execute(mode, true, "hq heli timer set 17", replies);
PrintFormat("ERR ITEMS TIMER FIXED: saved=%1 runtime=%2", mode.Settings().Get("heliTimerMinutes"), mode.Settings().Runtime("heliTimerMinutes"));
mode.Admin().Execute(mode, false, "hq heli timer set 19", replies);
PrintFormat("ERR ITEMS TIMER UNAUTHORIZED: saved=%1", mode.Settings().Get("heliTimerMinutes"));
mode.Admin().Execute(mode, true, "hq heli timer set random", replies);
PrintFormat("ERR ITEMS TIMER RANDOM: saved=%1 runtime=%2", mode.Settings().Get("heliTimerMinutes"), mode.Settings().Runtime("heliTimerMinutes"));
}
array<string> values = {}; catalog.Snapshot(mode, values, "", 0);
if (!values.Contains("itemsScan=Catalog complete")) return;
string selected;
foreach (string line : values)
{
if (line.IndexOf("serverMod=") != 0) continue;
Print("ERR ITEMS MOD: " + line);
array<string> parts = {}; line.Substring(10,line.Length()-10).Split("|", parts, false);
if (parts.Count() == 3 && parts[0] != "58d0fb3206b6f859" && parts[2].ToInt() > 0) selected = parts[0];
}
values.Clear();
foreach (string key : ERR_Settings.Keys()) values.Insert(key + "=" + mode.Settings().Get(key).ToString());
mode.Admin().Capabilities(values);
catalog.Snapshot(mode, values, selected, 0);
foreach (string row : values) if (row.IndexOf("serverItem=") == 0) Print("ERR ITEMS ROW: " + row);
JsonSaveContext json = new JsonSaveContext(); json.EnableTypeDiscriminator(false); json.WriteValue("values", values); json.SaveToFile("$profile:ERRItemsSnapshot.json");
m_ERRItemsTestDone = true;
Print("ERR ITEMS SERVER COMPLETE");
}
}
// Presentation fixture only. Actual server values copied by the test supervisor;
// this does not authenticate a player or bypass a production command boundary.
modded class ERR_AdminMenu
{
protected float m_ERRItemCaptureWait;
protected int m_ERRItemCapture;
override protected void RequestSnapshot()
{
JsonLoadContext json = new JsonLoadContext(); array<string> values = {};
if (!json.LoadFromFile("$profile:ERRItemsSnapshot.json") || !json.ReadValue("values", values)) return;
array<string> status = {}; ReceiveSnapshot(true, values, status);
}
override void OnMenuUpdate(float tDelta)
{
super.OnMenuUpdate(tDelta);
if (m_ERRItemCapture >= 3) return;
int page = 0; if (m_ERRItemCapture == 1) page = 9; if (m_ERRItemCapture == 2) page = 3;
ShowPage(page); m_ERRItemCaptureWait += tDelta;
if (m_ERRItemCaptureWait < 4) return;
bool ready = m_Ready && !m_ServerAddonKeys.IsEmpty();
SCR_EditBoxComponent timer = SCR_EditBoxComponent.GetEditBoxComponent("heliTimerMinutes", GetRootWidget());
ready = ready && timer && timer.IsEnabled();
PrintFormat("ERR ITEMS UI PAGE: page=%1 ready=%2 mods=%3 loadedRows=%4", page, ready, m_ServerAddonKeys.Count(), m_ServerAddonRows.Count());
System.MakeScreenshot("$logs:items-page-" + page.ToString());
m_ERRItemCaptureWait = 0; m_ERRItemCapture++;
if (m_ERRItemCapture == 3) Print("ERR ITEMS UI COMPLETE");
}
}
modded class SCR_RespawnSystemComponent
{
override void UpdateLoadingPlaceholder(float dt)
{
super.UpdateLoadingPlaceholder(dt);
if (ERR_AdminMenu.GetOpenMenu() && m_wLoadingPlaceholder) m_wLoadingPlaceholder.SetVisible(false);
}
}