#ifdef WORKBENCH // Explicit fixture payloads, physical radio delivery, production HQ intake. // This does not certify visual detection or an actual ground sweep completing. modded class ERR_HQ { int ERR_MemoryFixtureRegisteredForces() { if (!ERR_NativeHQMemoryProbe.Enabled() || !m_Mode || !m_Mode.Forces()) return -1; int registered; foreach (ERR_HQUnit unit : m_Units) { if (unit.ReservedForSupport || !unit.Group) continue; ERR_ForceRecord record = m_Mode.Forces().FindGroup(unit.Group); if (!record || record.Group != unit.Group || !record.Physical || record.Eliminated) return -1; registered++; } if (m_Mode.Forces().Count() < registered) return -1; return registered; } protected bool ERR_MemoryFixtureHealthy(ERR_HQRoute route) { if (!route || route.Nodes.IsEmpty()) return false; for (int i = 0; i < route.Nodes.Count(); i++) if (!route.Nodes[i] || !route.Nodes[i].Valid(i == route.Nodes.Count() - 1)) return false; return true; } ERR_HQRoute ERR_MemoryFixtureQueue(ERR_HQReport report) { if (!ERR_NativeHQMemoryProbe.Enabled()) return null; foreach (ERR_HQUnit unit : m_Units) { if (unit.ReservedForSupport || !unit.Radio || unit.Uplink || unit.PendingReport || unit.PendingSweep) continue; if (unit.PendingSupplyStatus || unit.PendingStatus) continue; ERR_HQRoute route = m_Network.Route(unit.Radio); if (!ERR_MemoryFixtureHealthy(route)) continue; report.Source = unit.Group; route.MessageId = report.MessageId; route.Payload = "FIXTURE synthetic observed position; " + report.Description(report.ObservedAt); unit.PendingReport = report.Snapshot(); unit.Uplink = route; return route; } return null; } ERR_HQRoute ERR_MemoryFixtureSweep(ERR_HQSearchReport report) { if (!ERR_NativeHQMemoryProbe.Enabled()) return null; foreach (ERR_HQUnit unit : m_Units) { if (unit.ReservedForSupport || !unit.Radio || unit.Uplink || unit.PendingReport || unit.PendingSweep) continue; if (unit.PendingSupplyStatus || unit.PendingStatus) continue; ERR_HQRoute route = m_Network.Route(unit.Radio); if (!ERR_MemoryFixtureHealthy(route)) continue; report.SourceId = unit.Id; route.MessageId = report.MessageId; route.Payload = "FIXTURE synthetic completed sweep; real uplink required"; unit.PendingSweep = report; unit.Uplink = route; return route; } return null; } void ERR_MemoryFixtureReplaySweep(ERR_HQSearchReport report, float now) { if (ERR_NativeHQMemoryProbe.Enabled()) AcceptSweep(report, now); } override void Stop() { super.Stop(); if (!ERR_NativeHQMemoryProbe.Enabled()) return; if (m_Memory.Count() != 0) Print("ERR SMOKE FAIL: HQ memory stop retained beliefs", LogLevel.ERROR); else Print("ERR SMOKE PASS: HQ memory actual command stop clears all belief history"); } } class ERR_NativeHQMemoryProbe { protected ERR_GameMode m_Mode; protected ref ERR_HQRoute m_Route; protected ref ERR_HQReport m_Report; protected ref ERR_HQSearchReport m_Sweep; protected int m_Step; protected int m_BeliefId; protected int m_Revision; protected float m_FirstObserved; protected float m_SecondObserved; protected vector m_FirstPosition; protected float m_Deadline; protected bool m_Failed; protected bool m_ValueChecked; protected bool m_AutoChecked; protected float m_AutoReadyAt = -1; protected int m_RouteRetries; static bool Enabled() { string enabled, outcome; return Replication.IsServer() && System.GetCLIParam("errSmoke", enabled) && enabled == "1" && System.GetCLIParam("errSmokeOutcome", outcome) && outcome == "hq-memory"; } void ERR_NativeHQMemoryProbe(ERR_GameMode mode) { m_Mode = mode; } protected bool Check(bool condition, string description) { if (condition) { Print("ERR SMOKE PASS: HQ memory " + description); return true; } m_Failed = true; Print("ERR SMOKE FAIL: HQ memory " + description, LogLevel.ERROR); return false; } protected float Unaged(ERR_HQBelief belief) { if (!belief) return -1; float decay = ERR_HQMemoryRules.Confidence((belief.EvaluatedAt - belief.ObservedAt) / 1000); if (decay <= 0) return -1; return belief.Confidence / decay; } protected ERR_HQReport Payload(ERR_HQ hq, float now, vector position) { ERR_HQReport report = new ERR_HQReport(); report.MessageId = hq.Journal().Message(); report.Target = m_Mode; report.ObservedAt = now; report.Position = position; report.TravelMode = "on foot"; return report; } // Read-only native road evidence with explicitly arranged delivered-value inputs. // No natural perception, real radio delivery or force movement is claimed here. protected bool LocalRoadPolicy() { SCR_AIWorld world = SCR_AIWorld.Cast(GetGame().GetAIWorld()); if (!Check(world && world.GetRoadNetworkManager(), "road fixture has native Everon road manager")) return false; vector center = m_Mode.PrisonPosition(); array roads = {}; world.GetRoadNetworkManager().GetRoadsInAABB(center + "-500 -1000 -500", center + "500 1000 500", roads); if (!Check(!roads.IsEmpty() && roads.Count() <= 128, "road fixture native query stays within bounded road count")) return false; int attempts, inspected; for (int r = 0; r < roads.Count() && r < 16 && attempts < 8; r++) { BaseRoad road = roads[r]; if (!road || road.GetWidth() < 4) continue; array points = {}; road.GetPoints(points); if (points.Count() < 2 || points.Count() > 1024) continue; for (int p = 1; p < points.Count() && attempts < 8 && inspected < 4096; p++) { inspected++; vector midpoint = vector.Lerp(points[p - 1], points[p], 0.5); vector direction = points[p] - points[p - 1]; direction[1] = 0; if (direction.Length() < 1 || vector.DistanceXZ(center, midpoint) > 500) continue; direction.Normalize(); attempts++; // Three metres/second produces a 60m future lead at this zero-age sample. ERR_HQMemory memory = new ERR_HQMemory(); ERR_HQReport first = new ERR_HQReport(); first.Target = m_Mode; first.MessageId = 1; first.ObservedAt = 6000; first.Position = midpoint - direction * 72; first.TravelMode = "on foot"; ERR_HQReport second = first.Snapshot(); second.MessageId = 2; second.ObservedAt = 10000; second.Position = midpoint - direction * 60; if (!Check(memory.Ingest(first, 6000) && memory.Ingest(second, 10000), "arranged detached road snapshots accepted by private memory")) return false; ERR_HQBelief belief = memory.Get(m_Mode); array reserved = {}; vector chosen; if (!ERR_HQRoadIntercept.Select(belief, 10000, reserved, chosen)) continue; if (!Check(ERR_HQRoadIntercept.Ahead(belief.PredictedPosition, belief.Velocity, chosen) && vector.DistanceXZ(chosen, midpoint) <= 100.1 && ERR_HQRoadIntercept.Standable(chosen), "native road choice is forward, nearby, dry and physically clear")) return false; // Independently measure the chosen point against native segment geometry. bool onRoad; int verifiedSegments; foreach (BaseRoad verify : roads) { if (!verify || verify.GetWidth() < 4) continue; array vertices = {}; verify.GetPoints(vertices); if (vertices.Count() < 2 || vertices.Count() > 1024) continue; verifiedSegments += vertices.Count() - 1; if (!Check(verifiedSegments <= 4096, "road membership verification stays within segment budget")) return false; for (int v = 1; v < vertices.Count(); v++) { vector delta = vertices[v] - vertices[v - 1]; delta[1] = 0; float length = delta.Length(); if (length < 0.01) continue; vector offset = chosen - vertices[v - 1]; offset[1] = 0; float fraction = Math.Clamp(vector.Dot(offset, delta) / (length * length), 0, 1); vector projected = vector.Lerp(vertices[v - 1], vertices[v], fraction); if (vector.DistanceXZ(chosen, projected) < 0.1 && Math.AbsFloat(chosen[1] - projected[1]) <= 2) { onRoad = true; break; } } if (onRoad) break; } if (!Check(onRoad, "chosen intercept lies on an actual native road segment")) return false; PrintFormat("ERR ROAD FIXTURE: arranged origin=%1 velocity=%2 chosen=%3 attempts=%4", belief.Position, belief.Velocity, chosen, attempts); memory.Tick(56000); if (!Check(!ERR_HQRoadIntercept.Select(memory.Get(m_Mode), 56000, reserved, chosen), "same arranged belief aged46seconds refuses road interception")) return false; return true; } } return Check(false, "bounded road fixture found no suitable native candidate; no fallback or force mutation"); } protected bool LocalPolicies() { ERR_ForceLedger ledger = new ERR_ForceLedger(); ERR_ForceRecord force = ledger.Register("memory-value-fixture", ERR_ForceKind.PATROL, "100 0 100", 6); if (!Check(force && ledger.Count() == 1 && !force.Group && !force.Physical, "detached native Core ledger registers one arithmetic fixture without spawning")) return false; if (!Check(ledger.Eliminate(force.Id, 1000), "detached native ledger records elimination")) return false; ERR_ForceRecord duplicate = ledger.Register("memory-value-fixture", ERR_ForceKind.PATROL, "100 0 100", 6); if (!Check(duplicate == force && ledger.Count() == 1 && force.Strength == 0 && force.Eliminated && !force.Group && !force.Physical, "eliminated source re-registration cannot restore strength or spawn")) return false; ERR_HQMemory memory = new ERR_HQMemory(); ERR_HQReport first = new ERR_HQReport(); first.Target = m_Mode; first.MessageId = 1; first.ObservedAt = 0; first.Position = "100 7 100"; first.TravelMode = "on foot"; if (!Check(memory.Ingest(first, 0), "injected value fixture begins with a detached report")) return false; first.Position = "999 7 999"; ERR_HQBelief belief = memory.Get(m_Mode); if (!Check(belief && belief.Position == "100 7 100", "stored snapshot ignores later input mutation")) return false; ERR_HQReport next = first.Snapshot(); next.MessageId = 2; next.ObservedAt = 10000; next.Position = "160 7 100"; if (!Check(memory.Ingest(next, 12000), "newer delivered-value fixture advances trajectory")) return false; belief = memory.Get(m_Mode); if (!Check(belief.HasVelocity && Math.AbsFloat(belief.Speed - 6) < 0.01, "native vector arithmetic infers six metres per second from snapshots")) return false; memory.Tick(610000); belief = memory.Get(m_Mode); if (!Check(belief && Math.AbsFloat(belief.Confidence - 0.5) < 0.001 && belief.Radius > 700, "ten-minute value-clock advance retains a weaker wider belief")) return false; if (!Check(belief.PredictionSeconds == 30 && vector.DistanceXZ(belief.Position, belief.PredictedPosition) <= 300, "old trajectory prediction remains capped in time and distance")) return false; int id = belief.BeliefId; if (!Check(memory.NegativeSearch(id, belief.BeliefRevision, 610000) && !memory.NegativeSearch(id, belief.BeliefRevision, 610000), "negative revision is idempotent")) return false; memory.Clear(); if (!Check(memory.Count() == 0 && !memory.GetById(id), "clear removes detached value history")) return false; return true; } protected bool RemoveRadios(IEntity carrier) { InventoryStorageManagerComponent inventory; if (carrier) inventory = InventoryStorageManagerComponent.Cast(carrier.FindComponent(InventoryStorageManagerComponent)); if (!inventory) return false; array items = {}; inventory.GetItems(items); int removed; foreach (IEntity item : items) { if (!item || !item.FindComponent(BaseRadioComponent)) continue; SCR_EntityHelper.DeleteEntityAndChildren(item); removed++; } return removed > 0; } protected int AutomaticConvoy(ERR_HQ hq) { if (m_AutoChecked) return 1; if (!hq.ConvoyStartup() || !hq.ConvoyStartup().Enabled()) { Check(false, "automatic convoy fixture requires enabled round snapshot"); return -1; } ERR_ConvoyTask task = hq.ConvoyTask(); if (!task) { if (hq.ConvoyStartup().Finished()) { Check(false, "automatic convoy refused: " + hq.ConvoyStatus()); return -1; } return 0; } if (task.Stopped) { Check(false, "automatic convoy stopped: " + task.Reason); return -1; } if (!task.Ready) return 0; float now = GetGame().GetWorld().GetWorldTime(); if (m_AutoReadyAt < 0) m_AutoReadyAt = now; if (now - m_AutoReadyAt < 6000) return 0; if (!Check(hq.ConvoyStartup().Status() == "canonical convoy dispatched" && task.Receipt && task.Receipt.Consumed && task.Vehicles.Count() == 6 && hq.Convoys().Count() == 1, "automatic startup owns one canonical six-vehicle task")) return -1; int crew; int gunners; foreach (ERR_ConvoyVehicle vehicle : task.Vehicles) { if (!Check(vehicle.Registered && !vehicle.Released && vehicle.CrewValid(m_Mode) && vehicle.Members.Count() == ERR_ConvoyPool.CrewCount(vehicle.Index), "automatic convoy exact original seated crew " + vehicle.Index.ToString())) return -1; crew += vehicle.Members.Count(); for (int member = 0; member < vehicle.Members.Count(); member++) { IEntity actor = vehicle.Members[member]; SCR_AICombatComponent combat = SCR_AICombatComponent.Cast(actor.FindComponent(SCR_AICombatComponent)); if (!Check(combat && combat.GetAISkill() >= EAISkill.EXPERT, "original automatic crew has scoped expert floor")) return -1; BaseCompartmentSlot slot = vehicle.Seats[member]; if (slot && slot.GetType() == ECompartmentType.TURRET) { if (!Check(ERR_EnemyGunnerSkill.OriginalGunner(m_Mode, vehicle.Group, actor) && combat.GetAISkill() >= EAISkill.CYLON, "original native turret gunner has scoped skill100")) return -1; gunners++; } } } if (!Check(gunners > 0, "automatic convoy includes confirmed native turret gunners")) return -1; if (!Check(crew == 19 && task.Receipt.OutstandingBodies == 0 && task.Receipt.OutstandingGroups == 0 && hq.ConvoyPool().CommittedBodies() <= 60, "automatic nineteen-body convoy respects shared physical budget")) return -1; if (!Check(!hq.StartScenarioConvoy() && hq.ConvoyTask() == task && hq.Convoys().Count() == 1, "manual request after automatic startup cannot duplicate the convoy")) return -1; m_AutoChecked = true; return 1; } int Tick(ERR_HQ hq, float now) { if (!Enabled() || !hq || !m_Mode || m_Failed) return -1; if (m_Deadline == 0) m_Deadline = now + 150000; if (now > m_Deadline) { Check(false, "fixture deadline"); return -1; } if (m_Step == 0) { if (!hq.ERR_ProbeSquadsReady()) return 0; bool automaticWasChecked = m_AutoChecked; int automatic = AutomaticConvoy(hq); if (automatic <= 0) return automatic; // Startup admission and native crew readiness have their own bounded wait. // Start the original memory/radio deadline once, after automatic proof. if (!automaticWasChecked) m_Deadline = now + 120000; if (!m_ValueChecked) { if (!Check(hq.ERR_MemoryFixtureRegisteredForces() == 6, "actual six site groups are registered once in the Core force ledger")) return -1; if (!LocalPolicies() || !LocalRoadPolicy()) return -1; m_ValueChecked = true; } m_FirstPosition = m_Mode.PrisonPosition() + "300 0 300"; m_Report = Payload(hq, now, m_FirstPosition); m_Route = hq.ERR_MemoryFixtureQueue(m_Report); if (!m_Route) return 0; if (!Check(!hq.Memory().Get(m_Mode) && m_Route.Advance(now, hq.Journal()) == 0, "queued synthetic sighting has no belief while actual transmitter starts")) return -1; if (!Check(!m_Route.Originated && !m_Route.Sending && m_Route.OriginDue - m_Route.StartedAt == 3000, "uplink holds original caller for three seconds before its first network hop")) return -1; if (!Check(RemoveRadios(m_Route.Nodes[0].Carrier), "fixture removes actual transmitting equipment mid-uplink")) return -1; m_Step = 1; return 0; } if (m_Step == 1) { if (hq.Memory().Get(m_Mode)) { Check(false, "interrupted uplink created a belief"); return -1; } if (!m_Route.Failed) return 0; if (!Check(!m_Route.Originated && !m_Route.Sending, "original caller radio loss interrupts call before any hop")) return -1; Print("ERR SMOKE PASS: HQ memory physical uplink loss prevents production Accept"); m_Step = 2; } // A real carrier can fail after selection. Retry with a fresh immutable payload; // a fixture may not hang waiting for a message that production correctly dropped. if (m_Route && m_Route.Failed && m_Step >= 3) { m_RouteRetries++; if (m_RouteRetries > 5) { Check(false, "positive-route retry bound"); return -1; } if (m_Step == 3) m_Step = 2; else if (m_Step == 5) m_Step = 4; else if (m_Step == 7) m_Step = 6; else if (m_Step == 9) m_Step = 8; else if (m_Step == 10) m_Step = 9; m_Route = null; } if (m_Step == 2 || m_Step == 4 || m_Step == 8) { if (m_Step == 4 && now - m_FirstObserved < 4000) return 0; vector position = m_FirstPosition; if (m_Step >= 4) position += "24 0 0"; m_Report = Payload(hq, now, position); m_Route = hq.ERR_MemoryFixtureQueue(m_Report); if (!m_Route) return 0; if (m_Step == 2) m_FirstObserved = now; if (m_Step == 4) m_SecondObserved = now; m_Step++; return 0; } ERR_HQBelief current = hq.Memory().Get(m_Mode); if (m_Step == 3) { if (!current || current.MessageId != m_Report.MessageId) return 0; if (!Check(m_Route.Originated && now - m_Route.StartedAt >= 5000, "delivered uplink includes originating call and physical hop latency")) return -1; if (!Check(current.Position == m_Report.Position && current.SampleCount == 1, "actual uplink delivery reaches production intake exactly once")) return -1; m_BeliefId = current.BeliefId; m_Step = 4; return 0; } if (m_Step == 5) { if (!current || current.MessageId != m_Report.MessageId) return 0; if (!Check(current.BeliefId == m_BeliefId && current.SampleCount == 2 && current.HasVelocity, "second physical delivery extends one stable credible trajectory")) return -1; m_Revision = current.BeliefRevision; m_Step = 6; } if (m_Step == 6) { m_Sweep = new ERR_HQSearchReport(); m_Sweep.MessageId = hq.Journal().Message(); m_Sweep.BeliefId = m_BeliefId; m_Sweep.BeliefRevision = m_Revision; m_Sweep.ObservedAt = now; m_Sweep.Position = current.Position; m_Sweep.SweepCompleted = true; m_Route = hq.ERR_MemoryFixtureSweep(m_Sweep); if (!m_Route) return 0; if (!Check(Unaged(hq.Memory().GetById(m_BeliefId)) > 0.99, "synthetic completed sweep is not knowledge before radio delivery")) return -1; m_Step = 7; return 0; } if (m_Step == 7) { if (!current || Unaged(current) > 0.99) return 0; if (!Check(Math.AbsFloat(Unaged(current) - 0.65) < 0.001 && current.BeliefRevision == m_Revision && current.ObservedAt == m_SecondObserved && current.SampleCount == 2, "delivered negative sweep lowers confidence without inventing a sighting")) return -1; hq.ERR_MemoryFixtureReplaySweep(m_Sweep, now); if (!Check(Math.AbsFloat(Unaged(hq.Memory().Get(m_Mode)) - 0.65) < 0.001, "replayed completed-sweep payload cannot multiply confidence loss")) return -1; m_Step = 8; return 0; } if (m_Step == 9) { if (!current || current.MessageId != m_Report.MessageId) return 0; if (!Check(current.BeliefRevision > m_Revision && Unaged(current) > 0.99, "fresh delivered sighting supersedes prior negative evidence")) return -1; ERR_HQSearchReport stale = new ERR_HQSearchReport(); stale.MessageId = hq.Journal().Message(); stale.BeliefId = m_BeliefId; stale.BeliefRevision = m_Revision; stale.ObservedAt = now; stale.Position = m_FirstPosition; stale.SweepCompleted = true; m_Route = hq.ERR_MemoryFixtureSweep(stale); if (!m_Route) return 0; m_Step = 10; return 0; } if (m_Step == 10) { if (m_Route.Failed) { Check(false, "old-revision fixture sweep route failed"); return -1; } if (m_Route.Cursor < m_Route.Nodes.Count() || m_Route.Sending) return 0; if (!Check(current && current.BeliefRevision > m_Revision && Unaged(current) > 0.99, "delivered old-revision sweep cannot weaken a newer sighting")) return -1; return 1; } return 0; } } #endif