Capture current mission, AI, map and administration development

Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
This commit is contained in:
2026-10-13 22:52:53 +02:00
parent a951a96edc
commit 6a667d8deb
8104 changed files with 2124945 additions and 2061 deletions
@@ -0,0 +1,281 @@
// Detached mounted counts only. Carried and cargo ammunition never enter these totals.
class ERR_HQMountedAmmoSnapshot
{
bool Complete;
int Weapons;
int Muzzles;
int Magazines;
int Rounds;
int Capacity;
int Chambers;
int LowMagazines;
ERR_HQMountedAmmoSnapshot Snapshot()
{
ERR_HQMountedAmmoSnapshot copy = new ERR_HQMountedAmmoSnapshot();
copy.Complete = Complete; copy.Weapons = Weapons; copy.Muzzles = Muzzles;
copy.Magazines = Magazines; copy.Rounds = Rounds; copy.Capacity = Capacity;
copy.Chambers = Chambers; copy.LowMagazines = LowMagazines;
return copy;
}
bool Valid()
{
if (Weapons < 0 || Weapons > 32 || Muzzles < 0 || Muzzles > 128 || Muzzles > Weapons * 8) return false;
if (Magazines < 0 || Magazines > Muzzles || Magazines > 128) return false;
if (Capacity < Magazines || Capacity > Magazines * 100000 || Rounds < 0 || Rounds > Capacity) return false;
if (Chambers < 0 || Chambers > Muzzles * 32 || LowMagazines < 0 || LowMagazines > Magazines) return false;
return !Complete || (Weapons == 0 || (Muzzles > 0 && Magazines > 0));
}
}
#ifdef WORKBENCH
// Ephemeral opt-in fixture diagnostics; never part of radio reports or policy.
class ERR_HQMountedAmmoDiagnostic
{
int Reasons;
int Nodes;
int Structural;
int Cargo;
int Allowed;
int Managers;
string Detail;
string FirstPrefab;
int FirstPurpose = -1;
void Reject(int reason, string detail, IEntity entity, int purpose = -1)
{
if ((Reasons & reason) == 0) Detail += detail + ";";
if (Reasons == 0)
{
FirstPurpose = purpose;
if (entity && entity.GetPrefabData()) FirstPrefab = entity.GetPrefabData().GetPrefabName();
}
Reasons = Reasons | reason;
}
}
#endif
class ERR_HQMountedAmmoSampler
{
#ifdef WORKBENCH
protected static ref ERR_HQMountedAmmoDiagnostic s_Diagnostic;
static void BeginDiagnostic() { s_Diagnostic = new ERR_HQMountedAmmoDiagnostic(); }
static ERR_HQMountedAmmoDiagnostic EndDiagnostic()
{
ref ERR_HQMountedAmmoDiagnostic result = s_Diagnostic; s_Diagnostic = null; return result;
}
#endif
// Native mounted weapons and loaded magazines use InventoryStorageSlot too,
// but their container is a weapon slot/muzzle rather than deposit storage.
static bool Installed(IEntity entity, InventoryStorageSlot slot, array<IEntity> allowed)
{
if (!entity || !slot) return false;
WeaponSlotComponent mount = WeaponSlotComponent.Cast(slot.GetParentContainer());
if (mount && allowed.Contains(mount.GetOwner()) && mount.GetSlotInfo() == slot && mount.GetWeaponEntity() == entity) return true;
BaseMuzzleComponent muzzle = BaseMuzzleComponent.Cast(slot.GetParentContainer());
if (!muzzle || !allowed.Contains(muzzle.GetOwner())) return false;
BaseMagazineComponent magazine = muzzle.GetMagazine();
return magazine && magazine.GetOwner() == entity;
}
protected static void AddWeapon(BaseWeaponComponent weapon, array<IEntity> allowed, array<BaseWeaponComponent> weapons, ERR_HQMountedAmmoSnapshot result)
{
if (!weapon || !weapon.GetOwner() || !allowed.Contains(weapon.GetOwner()))
{
#ifdef WORKBENCH
IEntity owner = null;
if (weapon) owner = weapon.GetOwner();
if (s_Diagnostic) s_Diagnostic.Reject(16, "weapon-owner-not-allowed", owner);
#endif
result.Complete = false; return;
}
// Native managers can expose both a slot and its physical weapon. Normalize
// one exact current installation before deduplication, never another slot.
WeaponSlotComponent mount = WeaponSlotComponent.Cast(weapon);
if (mount)
{
IEntity mountedEntity = mount.GetWeaponEntity();
InventoryStorageSlot binding = mount.GetSlotInfo();
if (!mountedEntity || !allowed.Contains(mountedEntity) || !binding || binding.GetParentContainer() != mount)
{
#ifdef WORKBENCH
if (s_Diagnostic) s_Diagnostic.Reject(32, "mount-binding-invalid", mountedEntity);
#endif
result.Complete = false; return;
}
InventoryItemComponent mountedItem = InventoryItemComponent.Cast(mountedEntity.FindComponent(InventoryItemComponent));
if (!mountedItem || mountedItem.GetParentSlot() != binding)
{
#ifdef WORKBENCH
if (s_Diagnostic) s_Diagnostic.Reject(64, "mount-item-slot-mismatch", mountedEntity);
#endif
result.Complete = false; return;
}
weapon = BaseWeaponComponent.Cast(mountedEntity.FindComponent(BaseWeaponComponent));
if (!weapon || WeaponSlotComponent.Cast(weapon) || weapon.GetOwner() != mountedEntity)
{
#ifdef WORKBENCH
if (s_Diagnostic) s_Diagnostic.Reject(128, "mount-weapon-invalid", mountedEntity);
#endif
result.Complete = false; return;
}
}
if (weapons.Contains(weapon)) return;
if (weapons.Count() >= 32)
{
#ifdef WORKBENCH
if (s_Diagnostic) s_Diagnostic.Reject(256, "weapon-limit32", weapon.GetOwner());
#endif
result.Complete = false; return;
}
weapons.Insert(weapon);
}
protected static void Collect(IEntity root, ERR_HQMountedAmmoSnapshot result, array<IEntity> allowed, array<BaseWeaponComponent> weapons)
{
if (!root || ChimeraCharacter.Cast(root))
{
#ifdef WORKBENCH
if (s_Diagnostic) s_Diagnostic.Reject(1, "invalid-root", root);
#endif
result.Complete = false; return;
}
result.Complete = true;
array<IEntity> nodes = {root};
// Known deposit cargo must not consume the mounted hierarchy budget. Both
// categories retain independent caps; the unique queue is capped at their sum.
// Skipped crew/unknown nodes remain structural and cannot borrow cargo space.
int structuralNodes = 0;
int cargoNodes = 0;
for (int cursor = 0; cursor < nodes.Count(); cursor++)
{
IEntity entity = nodes[cursor];
bool character = ChimeraCharacter.Cast(entity) != null;
bool excludedCargo;
bool unknownStorage;
// Exact installed slots are checked before deposit exclusion. Never walk
// the children of known cargo or seated character roots.
if (!character)
{
InventoryItemComponent item = InventoryItemComponent.Cast(entity.FindComponent(InventoryItemComponent));
if (item && item.GetParentSlot() && !Installed(entity, item.GetParentSlot(), allowed))
{
BaseInventoryStorageComponent storage = item.GetParentSlot().GetStorage();
if (!storage || storage.GetPurpose() == EStoragePurpose.PURPOSE_UNSET || storage.GetPurpose() == EStoragePurpose.PURPOSE_ANY)
{
#ifdef WORKBENCH
int purpose = -1;
if (storage) purpose = storage.GetPurpose();
if (s_Diagnostic) s_Diagnostic.Reject(2, "ambiguous-storage", entity, purpose);
#endif
result.Complete = false; unknownStorage = true;
}
else excludedCargo = (storage.GetPurpose() & EStoragePurpose.PURPOSE_DEPOSIT) != 0;
}
}
if (excludedCargo)
{
cargoNodes++;
if (cargoNodes > 128)
{
#ifdef WORKBENCH
if (s_Diagnostic) s_Diagnostic.Reject(2048, "cargo-limit128", entity);
#endif
result.Complete = false; break;
}
continue;
}
structuralNodes++;
if (structuralNodes > 128)
{
#ifdef WORKBENCH
if (s_Diagnostic) s_Diagnostic.Reject(1024, "structural-limit128", entity);
#endif
result.Complete = false; break;
}
if (character || unknownStorage) continue;
allowed.Insert(entity);
IEntity child = entity.GetChildren();
while (child)
{
bool repeated = nodes.Contains(child);
if (repeated || nodes.Count() >= 256)
{
#ifdef WORKBENCH
if (s_Diagnostic)
{
if (repeated) s_Diagnostic.Reject(4, "repeated-node", child);
else s_Diagnostic.Reject(8, "queue-limit256", child);
}
#endif
result.Complete = false; break;
}
nodes.Insert(child);
child = child.GetSibling();
}
}
#ifdef WORKBENCH
if (s_Diagnostic)
{
s_Diagnostic.Nodes = nodes.Count(); s_Diagnostic.Allowed = allowed.Count();
s_Diagnostic.Structural = structuralNodes; s_Diagnostic.Cargo = cargoNodes;
}
#endif
foreach (IEntity part : allowed)
{
BaseWeaponManagerComponent manager = BaseWeaponManagerComponent.Cast(part.FindComponent(BaseWeaponManagerComponent));
if (manager)
{
#ifdef WORKBENCH
if (s_Diagnostic) s_Diagnostic.Managers++;
#endif
array<BaseWeaponComponent> listed = {}; manager.GetWeapons(listed);
if (listed.Count() > 8)
{
#ifdef WORKBENCH
if (s_Diagnostic) s_Diagnostic.Reject(512, "manager-limit8", part);
#endif
result.Complete = false;
}
else foreach (BaseWeaponComponent entry : listed) AddWeapon(entry, allowed, weapons, result);
}
BaseWeaponComponent mounted = BaseWeaponComponent.Cast(part.FindComponent(BaseWeaponComponent));
if (mounted) AddWeapon(mounted, allowed, weapons, result);
}
}
static ERR_HQMountedAmmoSnapshot Inspect(IEntity root)
{
ERR_HQMountedAmmoSnapshot result = new ERR_HQMountedAmmoSnapshot();
array<IEntity> allowed = {};
array<BaseWeaponComponent> weapons = {};
Collect(root, result, allowed, weapons);
result.Weapons = weapons.Count();
array<BaseMuzzleComponent> seenMuzzles = {};
array<BaseMagazineComponent> seenMagazines = {};
array<IEntity> magazineOwners = {};
foreach (BaseWeaponComponent weapon : weapons)
{
array<BaseMuzzleComponent> muzzles = {}; weapon.GetMuzzlesList(muzzles);
if (muzzles.IsEmpty() || muzzles.Count() > 8) { result.Complete = false; continue; }
foreach (BaseMuzzleComponent muzzle : muzzles)
{
if (!muzzle || !muzzle.GetOwner() || !allowed.Contains(muzzle.GetOwner())) { result.Complete = false; continue; }
if (seenMuzzles.Contains(muzzle)) continue;
if (seenMuzzles.Count() >= 128) { result.Complete = false; continue; }
seenMuzzles.Insert(muzzle); result.Muzzles++;
int barrels = muzzle.GetBarrelsCount();
if (barrels < 1 || barrels > 32) result.Complete = false;
else for (int barrel = 0; barrel < barrels; barrel++)
if (muzzle.IsBarrelChambered(barrel)) result.Chambers++;
BaseMagazineComponent magazine = muzzle.GetMagazine();
// Projectile-only weapons and absent magazines are unknown, never empty.
if (!magazine || !magazine.GetOwner() || !allowed.Contains(magazine.GetOwner())) { result.Complete = false; continue; }
if (seenMagazines.Contains(magazine)) continue;
if (magazineOwners.Contains(magazine.GetOwner())) { result.Complete = false; continue; }
seenMagazines.Insert(magazine); magazineOwners.Insert(magazine.GetOwner());
int rounds = magazine.GetAmmoCount();
int capacity = magazine.GetMaxAmmoCount();
if (rounds < 0 || capacity < 1 || capacity > 100000 || rounds > capacity) { result.Complete = false; continue; }
result.Magazines++; result.Rounds += rounds; result.Capacity += capacity;
if (rounds <= capacity * 0.25) result.LowMagazines++;
}
}
return result;
}
}
@@ -0,0 +1,175 @@
{
"schema_version": 1,
"authorization": "User authorized RHS, WCS and BMP dependencies on2026-09-20; external assets remain in installed addons. Parachute Framework is required by the requested original paratrooper port and HQ-controlled drops (2026-09-22).",
"direct_ai_dependencies": [
"595F2BF2F44836FB",
"629B2BA37EFFD577",
"5E524E4FEECCA92B",
"65930CB4CD0237B2"
],
"addons": {
"595F2BF2F44836FB": {
"title": "RHS: Status Quo",
"version": "0.16.5208",
"dependencies": [
"58D0FB3206B6F859",
"1337C0DE5DABBEEF",
"BADC0DEDABBEDA5E"
],
"project_sha256": "1b83e9df126db639cfcdb6d5119e65a1581c028becd6c09998143ed527ad0721"
},
"1337C0DE5DABBEEF": {
"title": "RHS: Status Quo - Content Pack 01",
"version": "0.16.5208",
"dependencies": [
"58D0FB3206B6F859"
],
"project_sha256": "65197c50ff6e906a5732564e8b440d80ef1cdbcffead9eb388e1e2b56c1322bc"
},
"BADC0DEDABBEDA5E": {
"title": "RHS: Status Quo - Content Pack 02",
"version": "0.16.5208",
"dependencies": [
"58D0FB3206B6F859"
],
"project_sha256": "6ebd73d663ed6dbf981cd8bc7d19cfd5bcd3c9dec3b9a706fa331d992ef200b4"
},
"5E389BB9F58B79A6": {
"title": "WCS_SpaceCore",
"version": "8.2.1",
"dependencies": [
"58D0FB3206B6F859",
"629B2BA37EFFD577"
],
"project_sha256": "2db2e318e6f45bede0d1173d77af03314f888aedfb31bc767d569ccfb6e70a34"
},
"629B2BA37EFFD577": {
"title": "WCS_Armaments",
"version": "8.2.1",
"dependencies": [
"58D0FB3206B6F859"
],
"project_sha256": "e6ffcf559a2e7898848349c090300ea8eca8cb2e13ecef456a108bcc82efc8b1"
},
"5E524E4FEECCA92B": {
"title": "WCS_BMP-1",
"version": "8.2.0",
"dependencies": [
"58D0FB3206B6F859",
"5E389BB9F58B79A6",
"629B2BA37EFFD577"
],
"project_sha256": "ad44151140adf62e99eaa639984c2b9c400be17481e934186d61c307b5221259"
},
"65930CB4CD0237B2": {
"title": "Parachute Framework",
"version": "1.2.0",
"dependencies": [
"58D0FB3206B6F859"
],
"project_sha256": "183fbb521382a95ad33af9efc547147a80241bd536a29d124c93064b5ae5e8bc"
}
},
"resources": {
"Prefabs/Weapons/Launchers/FIM92_Stinger/Launcher_FIM92_Stinger.et": {
"guid": "3DF204EEE0534EF2",
"addon": "629B2BA37EFFD577",
"verification": "Exact path/type/GUID record in installed owning resourceDatabase.rdb; read-only audit2026-09-20"
},
"Prefabs/Vehicles/Tracked/BMP1/BMP1_Base.et": {
"guid": "1DC01AAACFFA8B63",
"addon": "5E524E4FEECCA92B",
"verification": "Exact path/type/GUID record in installed owning resourceDatabase.rdb; read-only audit2026-09-20"
},
"Prefabs/Weapons/Attachments/Optics/Optic_PSO1/Optic_PSO1M2.et": {
"guid": "A1D5833FF10C6503",
"addon": "595F2BF2F44836FB",
"verification": "Exact path/type/GUID record in installed owning resourceDatabase.rdb; read-only audit 2026-09-20"
},
"Prefabs/Weapons/Attachments/Optics/1p21/Optic_1P21.et": {
"guid": "695AAA77F84EB238",
"addon": "595F2BF2F44836FB",
"verification": "Exact path/type/GUID record in installed owning resourceDatabase.rdb; read-only audit 2026-09-20"
},
"Prefabs/Weapons/Attachments/Optics/m8541/Optic_M8541.et": {
"guid": "333A794F0B55C019",
"addon": "595F2BF2F44836FB",
"verification": "Exact path/type/GUID record in installed owning resourceDatabase.rdb; read-only audit 2026-09-20"
},
"Prefabs/Weapons/Attachments/Optics/1p78/Optic_1P78.et": {
"guid": "8D4BAA235F7EDBEA",
"addon": "595F2BF2F44836FB",
"verification": "Exact path/type/GUID record in installed owning resourceDatabase.rdb; read-only audit 2026-09-20"
},
"Configs/Factions/RHS_ION.conf": {
"guid": "CB76A36EACFBDF35",
"addon": "595F2BF2F44836FB",
"verification": "Exact path/type/GUID in installed owning resourceDatabase.rdb; read-only audit 2026-09-21. Faction keys and physical group slots checked in owning PAK."
},
"Configs/Factions/RHS_RF_MSV.conf": {
"guid": "627A8CDE681D223D",
"addon": "595F2BF2F44836FB",
"verification": "Exact path/type/GUID in installed owning resourceDatabase.rdb; read-only audit 2026-09-21. Faction keys and physical group slots checked in owning PAK."
},
"Configs/Factions/RHS_US_USMC.conf": {
"guid": "F33C7BF22CBF3A8A",
"addon": "595F2BF2F44836FB",
"verification": "Exact path/type/GUID in installed owning resourceDatabase.rdb; read-only audit 2026-09-21. Faction keys and physical group slots checked in owning PAK."
},
"Prefabs/Groups/BLUFOR/RHS_USAF/RHS_USAF_USMC_MEF/Group_USAF_USMC_MEF_FireTeam.et": {
"guid": "19843E954790DF28",
"addon": "595F2BF2F44836FB",
"verification": "Exact path/type/GUID in installed owning resourceDatabase.rdb; read-only audit 2026-09-21. Faction keys and physical group slots checked in owning PAK."
},
"Prefabs/Groups/INDFOR/RHS_ION/RHS_ION_COY/Group_RHS_ION_COY_StaticSecurityTeam.et": {
"guid": "516C8C7400DF2C4D",
"addon": "595F2BF2F44836FB",
"verification": "Exact path/type/GUID in installed owning resourceDatabase.rdb; read-only audit 2026-09-21. Faction keys and physical group slots checked in owning PAK."
},
"Prefabs/Groups/OPFOR/RHS_AFRF/MSV/Flora/Group_RHS_RF_MSV_Flora_FireGroup.et": {
"guid": "AB905EF799E0A0AE",
"addon": "595F2BF2F44836FB",
"verification": "Exact path/type/GUID in installed owning resourceDatabase.rdb; read-only audit 2026-09-21. Faction keys and physical group slots checked in owning PAK."
},
"Prefabs/DeployedParachutes/Core/DeployedParachuteMK4.et": {
"guid": "9ADD554959C09197",
"addon": "65930CB4CD0237B2",
"verification": "Exact installed owning resourceDatabase.rdb path/type/GUID and inspected native prefab/scripts, 2026-09-22."
},
"Prefabs/Weapons/Launchers/9K38_IGLA/Launcher_9K38_IGLA.et": {
"guid": "962C400354E4BD6C",
"addon": "629B2BA37EFFD577",
"verification": "Installed WCS USSR AA character references this exact prefab; inspected launcher has infrared guidance and a loaded disposable muzzle, 2026-09-23."
},
"Prefabs/Characters/Factions/BLUFOR/RHS_USAF/RHS_USAF_MARSOC/RandomSoldiers/Character_RHS_USMC_MARSOC_Rifleman_Random.et": {
"guid": "844936B168DFAB8E",
"addon": "595F2BF2F44836FB",
"verification": "Exact path/type/GUID verified in installed owning resourceDatabase.rdb, 2026-09-26. Response roles and medic stock inspected in RHS character/group prefabs."
},
"Prefabs/Characters/Factions/BLUFOR/RHS_USAF/RHS_USAF_MARSOC/RandomSoldiers/Character_RHS_USMC_MARSOC_Medic_Random.et": {
"guid": "DBB8D1F13930220E",
"addon": "595F2BF2F44836FB",
"verification": "Exact path/type/GUID verified in installed owning resourceDatabase.rdb, 2026-09-26. Response roles and medic stock inspected in RHS character/group prefabs."
},
"Prefabs/Characters/Factions/OPFOR/RHS_AFRF/MSV/Flora/Character_RHS_RF_MSV_Flora_SL.et": {
"guid": "B3C496CCFA72D25E",
"addon": "595F2BF2F44836FB",
"verification": "Exact path/type/GUID verified in installed owning resourceDatabase.rdb, 2026-09-26. Response roles and medic stock inspected in RHS character/group prefabs."
},
"Prefabs/Characters/Factions/OPFOR/RHS_AFRF/MSV/Flora/Character_RHS_RF_MSV_Flora_Medic.et": {
"guid": "D9AF475A4E5DC52C",
"addon": "595F2BF2F44836FB",
"verification": "Exact path/type/GUID verified in installed owning resourceDatabase.rdb, 2026-09-26. Response roles and medic stock inspected in RHS character/group prefabs."
},
"Prefabs/Characters/Factions/INDFOR/RHS_ION_Coy/RandomSoldiers/Character_RHS_ION_Coy_Rifleman_Random.et": {
"guid": "140001FC383DF9A2",
"addon": "595F2BF2F44836FB",
"verification": "Exact path/type/GUID verified in installed owning resourceDatabase.rdb, 2026-09-26. Response roles and medic stock inspected in RHS character/group prefabs."
},
"Prefabs/Characters/Factions/INDFOR/RHS_ION_Coy/RandomSoldiers/Character_RHS_ION_Coy_Medic_Random.et": {
"guid": "0FA8ACE19A772327",
"addon": "595F2BF2F44836FB",
"verification": "Exact path/type/GUID verified in installed owning resourceDatabase.rdb, 2026-09-26. Response roles and medic stock inspected in RHS character/group prefabs."
}
}
}
@@ -0,0 +1,158 @@
{
"Assets/Items/Equipment/Maps/Map_Paper_01/Map_Paper_01_folded.xob": "E443663E5241622A",
"Assets/Items/Equipment/Radios/Radio_R107M/Radio_R107M_01_item.xob": "77C9FCF3FB1246E9",
"Assets/Items/Equipment/workspaces/paper_map.agr": "83675D0B0AB1B2C3",
"Assets/Items/Equipment/workspaces/player_map.asi": "56794534F6B8C3D7",
"Assets/Props/Fabric/Flags/Data/Flag_1_2_SovietArmy.emat": "B47B52D9DA68905D",
"Assets/Props/Fabric/Flags/Data/Flag_1_2_USA.emat": "610803CC3F3D6649",
"Assets/Props/Military/AmmoBox/EquipmentBoxWooden_01/Data/EquipmentBoxWooden_Weapon_01_USSR.emat": "7D2E831AFA5CF50D",
"Assets/Props/Military/AmmoBox/EquipmentBoxWooden_01/EquipmentBoxWooden_Weapon_01.xob": "819ED3266EE5113B",
"Assets/Props/Military/Sandbags/Data/Sandbags_01_Burlap_MLOD.emat": "2169E8EB73E1C127",
"Assets/Props/Military/Sandbags/Data/Sandbags_01_short_Burlap.emat": "31529E064AA7C917",
"Assets/Props/Military/Sandbags/Sandbag_01_short.xob": "268DBDABB3C94AD7",
"Assets/Structures/BuildingsParts/Doors/DoorFrame_door_metal_A_RIGHT_EXT_B.xob": "E3BC73BFBC7AA497",
"Assets/Structures/Walls/Concrete/ConcreteWall_01_3m.xob": "0B96D139FEBCA006",
"Configs/Callsigns/Callsigns_US.conf": "CB7824D572DD0D5C",
"Configs/Callsigns/Callsigns_USSR.conf": "958043CE1648EC43",
"Configs/EntityCatalog/US/Characters_EntityCatalog_US.conf": "B56E8B4D4B195559",
"Configs/EntityCatalog/US/Groups_EntityCatalog_US.conf": "4E70E7C4C2C17D4A",
"Configs/EntityCatalog/US/InventoryItems_EntityCatalog_US.conf": "5F7EC52FC40A03E2",
"Configs/EntityCatalog/US/SupplyContainerItems_EntityCatalog_US.conf": "0BF36EFF9FFAF92B",
"Configs/EntityCatalog/US/WeaponTripod_EntityCatalog_US.conf": "0E4B62F186F97C43",
"Configs/EntityCatalog/USSR/Characters_EntityCatalog_USSR.conf": "3B679F1799D55F6F",
"Configs/EntityCatalog/USSR/Groups_EntityCatalog_USSR.conf": "37D5B75AAC3E72EA",
"Configs/EntityCatalog/USSR/InventoryItems_EntityCatalog_USSR.conf": "C53421647C3D0D2E",
"Configs/EntityCatalog/USSR/SupplyContainerItems_EntityCatalog_USSR.conf": "B4CA6761AC935808",
"Configs/EntityCatalog/USSR/WeaponTripod_EntityCatalog_USSR.conf": "DDF17C8C140BD1F2",
"Configs/Factions/BLUFOR.conf": "E7B7EA4823DD81F0",
"Configs/Factions/FIA.conf": "8053DB656DD18B14",
"Configs/Factions/OPFOR.conf": "B122E3B10BB3404B",
"Configs/GameOverScreen/BaseGameOverScreensConfig.conf": "651583FFFB7FC765",
"Configs/Identities/FactionIdentity_US.conf": "B600946E9ACC17C2",
"Configs/Identities/FactionIdentity_USSR.conf": "FBBCD73926989580",
"Configs/Identities/Territories/FactionHomeTerritory_US.conf": "B548A5B264939A98",
"Configs/Identities/Territories/FactionHomeTerritory_USSR.conf": "31FC78AF00523A99",
"Configs/Map/MapPlain.conf": "A786DD4868598F15",
"Configs/Navmesh/Navmesh_GM_Eden_Soldier.conf": "8BBC73472092902E",
"Configs/Navmesh/Navmesh_GM_Eden_Vehicle.conf": "0228A79846FD8A97",
"Configs/System/ActionContext/ManualCameraContext.conf": "C538807EEE48BED8",
"Configs/System/chimeraInputCommon.conf": "795184CF9AD764DB",
"Configs/System/chimeraMenus.conf": "C747AFB6B750CE9A",
"Configs/Systems/MissionSystems.conf": "C50579A2EC48E8EF",
"Prefabs/AI/Groups/Group_Base.et": "000CD338713F2B5A",
"Prefabs/AI/SCR_AIWorld.et": "E0A05C76552E7F58",
"Prefabs/AI/Waypoints/AIWaypoint_Cycle.et": "35BD6541CBB8AC08",
"Prefabs/AI/Waypoints/AIWaypoint_Defend.et": "93291E72AC23930F",
"Prefabs/AI/Waypoints/AIWaypoint_GetIn.et": "712F4795CF8B91C7",
"Prefabs/AI/Waypoints/AIWaypoint_GetOut.et": "C40316EE26846CAB",
"Prefabs/AI/Waypoints/AIWaypoint_Move.et": "750A8D1695BD6998",
"Prefabs/AI/Waypoints/AIWaypoint_SearchAndDestroy.et": "B3E7B8DC2BAB8ACC",
"Prefabs/Characters/Campaign/Final/OPFOR/USSR_Army/Regular/Campaign_USSR_Player_MortarCrew.et": "86E565387A634103",
"Prefabs/Characters/Factions/BLUFOR/US_Army/Character_US_Base.et": "836E7E39AAC5888B",
"Prefabs/Characters/Factions/BLUFOR/US_Army/Character_US_HeliPilot.et": "42A502E3BB727CEB",
"Prefabs/Characters/Factions/BLUFOR/US_Army/Character_US_Sniper.et": "0F6689B491641155",
"Prefabs/Characters/Factions/BLUFOR/US_Army/Character_US_Unarmed.et": "2F912ED6E399FF47",
"Prefabs/Characters/Factions/BLUFOR/US_Army/GreenBerets/Character_US_SF.et": "36E28C628A2F83CB",
"Prefabs/Characters/Factions/BLUFOR/US_Army/GreenBerets/Character_US_SF_Medic.et": "9A234C5857D92187",
"Prefabs/Characters/Factions/OPFOR/USSR_Army/Character_USSR_AR.et": "23ADBBC31B6A3DC6",
"Prefabs/Characters/Factions/OPFOR/USSR_Army/Character_USSR_AT.et": "1C78331E156A3D65",
"Prefabs/Characters/Factions/OPFOR/USSR_Army/Character_USSR_HeliPilot.et": "A62FA97C4EC64F14",
"Prefabs/Characters/Factions/OPFOR/USSR_Army/Character_USSR_LAT.et": "BF643BE4ADBDFDD3",
"Prefabs/Characters/Factions/OPFOR/USSR_Army/Character_USSR_RTO.et": "612F43A4D5AE765F",
"Prefabs/Characters/Factions/OPFOR/USSR_Army/Character_USSR_Rifleman.et": "DCB41B3746FDD1BE",
"Prefabs/Characters/Factions/OPFOR/USSR_Army/Character_USSR_SL.et": "5436629450D8387A",
"Prefabs/Characters/Factions/OPFOR/USSR_Army/Character_USSR_SR.et": "333DA6244C7DA34C",
"Prefabs/Characters/Factions/OPFOR/USSR_Army/Character_USSR_Sharpshooter.et": "976AC400219898FA",
"Prefabs/Characters/Factions/OPFOR/USSR_Army/Spetsnaz/Character_USSR_SF.et": "2DB452B3EC386B92",
"Prefabs/Characters/Factions/OPFOR/USSR_Army/Spetsnaz/Character_USSR_SF_Medic.et": "8CA70597606992EC",
"Prefabs/Characters/Footwear/CombatBoots_US_01.et": "DAAFD15478BDE1C3",
"Prefabs/Characters/HeadGear/Hat_Patrol_US_01/Hat_Patrol_US_01.et": "F545C1BE7C99954A",
"Prefabs/Characters/HeadGear/Helmet_PASGT_01/Helmet_PASGT_01_base.et": "8A2B2A544F3ED831",
"Prefabs/Characters/Uniforms/Jacket_US_BDU_rolledup.et": "3CCA7A9BB4FD3197",
"Prefabs/Characters/Uniforms/Pants_US_BDU.et": "604BB72BE8E023C2",
"Prefabs/Decals/Dirt/Decal_Dirt_Patch_03.et": "4AD6EB80A8B1FA3A",
"Prefabs/Groups/BLUFOR/Group_US_FireTeam.et": "84E5BBAB25EA23E5",
"Prefabs/Groups/INDFOR/Group_FIA_FireTeam.et": "5BEA04939D148B1D",
"Prefabs/Groups/OPFOR/Group_USSR_Base.et": "8DE0C0830FE0C33D",
"Prefabs/Groups/OPFOR/Group_USSR_RifleSquad.et": "E552DABF3636C2AD",
"Prefabs/Items/Core/Item_Base.et": "C95E11C60810F432",
"Prefabs/Items/Equipment/Backpacks/Backpack_Kolobok.et": "41A9C55B61F375F0",
"Prefabs/Items/Equipment/Binoculars/Binoculars_B8/Binoculars_B8.et": "243948B23D90BECB",
"Prefabs/Items/Equipment/Kits/MedicalKit_01/MedicalKit_01_US.et": "AE578EEA4244D41F",
"Prefabs/Items/Equipment/Kits/MedicalKit_01/MedicalKit_01_USSR.et": "21EF98BFC1EB3793",
"Prefabs/Items/Equipment/Kits/RepairKit_01/RepairKit_01_wrench.et": "33B2DFDCD0EBA3DB",
"Prefabs/Items/Equipment/Maps/Map_Paper_01/PaperMap_01_folded.et": "13772C903CB5E4F7",
"Prefabs/Items/Equipment/Radios/Radio_ANPRC77.et": "9B6B61BB3FE3DFB0",
"Prefabs/Items/Equipment/Radios/Radio_R107M.et": "54C68E438DD34265",
"Prefabs/Items/Equipment/Radios/Radio_R148.et": "E1A5D4B878AA8980",
"Prefabs/Items/Equipment/Watches/Watch_SandY184A.et": "78ED4FEF62BBA728",
"Prefabs/Items/Fuel/Jerrycan_01/Jerrycan_01_item.et": "12D5AD21E383B768",
"Prefabs/Items/Medicine/FieldDressing_01/FieldDressing_USSR_01.et": "C3F1FA1E2EC2B345",
"Prefabs/Items/Medicine/FieldDressing_01/FieldDressing_US_01.et": "A81F501D3EF6F38E",
"Prefabs/Items/Medicine/MorphineInjection_01/MorphineInjection_01.et": "0D9A5DCF89AE7AA9",
"Prefabs/Items/Medicine/SalineBag_01/SalineBag_USSR_01.et": "527D7C5D2E476BDC",
"Prefabs/Items/Medicine/SalineBag_01/SalineBag_US_01.et": "00E36F41CA310E2A",
"Prefabs/Items/Medicine/Tourniquet_01/Tourniquet_US_01.et": "D70216B1B2889129",
"Prefabs/Items/Misc/IntelligenceFolder_E_01/IntelligenceFolder_E_01.et": "6D56FED1E55A8F84",
"Prefabs/MP/Managers/Factions/FactionManager_Base.et": "A242612865F2A48E",
"Prefabs/MP/Managers/Factions/FactionManager_USxUSSR.et": "589540B35EBA8CDC",
"Prefabs/MP/Managers/Loadouts/LoadoutManager_USxUSSR.et": "97EF4C1A41F63DDB",
"Prefabs/MP/Modes/GameMode_Base.et": "0F307326459A1395",
"Prefabs/MP/ScriptedChatEntity.et": "F69BC912AC8236F9",
"Prefabs/Props/EmptyStorages/USSR_AmmoBox_empty.et": "EBBC859CCD94D96D",
"Prefabs/Props/Furniture/Table_01.et": "53506DCB398C7EBE",
"Prefabs/Props/Military/Antennas/Antenna_FIA_02/Antenna_FIA_02_base.et": "B3949F6D215A9F78",
"Prefabs/Props/Military/Sandbags/Sandbag_01_short_burlap.et": "CFFEB23FBEA00322",
"Prefabs/Structures/BuildingParts/Doors/DoorSet_Base.et": "87CADB5ADC989993",
"Prefabs/Structures/BuildingParts/Doors/Door_MetalGate_01_Short_LEFT_EXT_ST_B.et": "34B08027DBDE322A",
"Prefabs/Structures/BuildingParts/Doors/Door_Metal_A_RIGHT_EXT_COV_B.et": "67F17696FF278AE0",
"Prefabs/Structures/Military/Camps/TentSmallUS_01/TentSmallUS_01.et": "01AE5FD77A9A4C21",
"Prefabs/Structures/Military/Camps/TentUSSR_01/TentUSSR_01_base.et": "BE5D5CFA90224646",
"Prefabs/Structures/Military/Camps/TentUS_01/TentUSMedical_01.et": "F8427C3EFC52644E",
"Prefabs/Structures/Walls/Concrete/ConcreteWall_01/ConcreteWall_01_3m.et": "60E5729BEA18F875",
"Prefabs/Systems/Radio/RadioManager.et": "B8E09FAB91C4ECCD",
"Prefabs/Tasks/BaseTask.et": "1D0F815858EE24AD",
"Prefabs/Vehicles/Helicopters/Mi8MT/Mi8MT_armed.et": "7BD282AF716ED639",
"Prefabs/Vehicles/Helicopters/Mi8MT/Mi8MT_unarmed_transport.et": "DF5CCB7C0FF049F4",
"Prefabs/Vehicles/Wheeled/UAZ469/UAZ469.et": "259EE7B78C51B624",
"Prefabs/Vehicles/Wheeled/UAZ469/UAZ469_PKM.et": "0B4DEA8078B78A9B",
"Prefabs/Vehicles/Wheeled/UAZ469/VehParts/Seats/UAZ469_seats_rear.et": "780AAF0A51AEE61A",
"Prefabs/Vehicles/Wheeled/Ural4320/Ural4320_ammo.et": "3336BE330C4F355B",
"Prefabs/Vehicles/Wheeled/Ural4320/Ural4320_transport.et": "16C1F16C9B053801",
"Prefabs/Weapons/Ammo/Ammo_Shell_82mm_HE_O832DU.et": "98EC9C526AFBA282",
"Prefabs/Weapons/Attachments/Optics/Optic_4x20/Optic_4x20.et": "BD496EE1B40DC510",
"Prefabs/Weapons/Attachments/Optics/Optic_ARTII/Optic_ARTII.et": "D2018EDB1BBF4C88",
"Prefabs/Weapons/Attachments/Optics/Optic_PSO1/Optic_PSO1.et": "C850A33226B8F9C1",
"Prefabs/Weapons/Explosives/Mine_PMN4/Mine_PMN4.et": "B05A816C0BF50802",
"Prefabs/Weapons/Handguns/PM/Handgun_PM.et": "C0F7DD85A86B2900",
"Prefabs/Weapons/Magazines/Magazine_545x39_AK_30rnd_Ball.et": "BBB50A815A2F916B",
"Prefabs/Weapons/Magazines/Magazine_762x51_M14_20rnd_SpecialBall.et": "627255315038152A",
"Prefabs/Weapons/Magazines/Magazine_762x54_SVD_10rnd_Sniper.et": "9CCB46C6EE632C1A",
"Prefabs/Weapons/Magazines/Magazine_9x18_PM_8rnd_Ball.et": "8B853CDD11BA916E",
"Prefabs/Weapons/Mortars/2B14/Mortar_2B14.et": "D1FFE458E8AC4BDB",
"Prefabs/Weapons/Rifles/AK74/Rifle_AK74.et": "FA5C25BF66A53DCF",
"Prefabs/World/Game/PerceptionManager.et": "028DAEAD63E056BE",
"Sounds/Items/_SharedData/PickUp/Items_PickUp_Map.acp": "13F8D0DE67678118",
"Sounds/Vehicles/Wheeled/UAZ469/Vehicles_UAZ469_Horn.acp": "7E64D37BE3E1F3FA",
"UI/Fonts/RobotoCondensed/RobotoCondensed_Regular.fnt": "3E7733BAC8C831F6",
"UI/Textures/DeployMenu/Loadout-BG/Loadout_BG_USSR.imageset": "21533F2089005056",
"UI/Textures/DeployMenu/Loadout-BG/Loadout_US_BG.imageset": "F8AC305446D5D480",
"UI/Textures/Editor/EditableEntities/Factions/EditableEntity_Faction_USA.edds": "EB7F65DBC9392557",
"UI/Textures/Editor/EditableEntities/Factions/EditableEntity_Faction_USSR.edds": "40B12B0DF911B856",
"UI/Textures/Flags/US-flag-base-3it.edds": "46FB2FB2C2125A3C",
"UI/Textures/Flags/USSR-flag-base-3it.edds": "50824EB9F2C215AB",
"UI/Textures/Icons/icons_mapMarkersUI-glow.imageset": "67B3A6DC2D712B52",
"UI/Textures/Icons/icons_mapMarkersUI.imageset": "E23427CAC80DA8B7",
"UI/Textures/Icons/icons_wrapperUI-glow.imageset": "00FE3DBDFD15227B",
"UI/Textures/Icons/icons_wrapperUI.imageset": "3262679C50EF4F01",
"UI/layouts/HUD/GameOver/EndScreen/EndScreenContent_NoImage.layout": "C4507D07F3C54831",
"UI/layouts/Menus/PauseMenu/PauseMenuButton.layout": "9ECCD201BCF07E95",
"UI/layouts/Task/TaskListEntry.layout": "B71975032150BAFB",
"UI/layouts/Task/TaskListEntryDescription.layout": "552EB1921B5C548C",
"UI/layouts/WidgetLibrary/Buttons/WLib_ButtonText.layout": "75C912A1C89BE6C2",
"UI/layouts/WidgetLibrary/ComboBox/WLib_ComboBox.layout": "4B5AE6E64037FFB4",
"UI/layouts/WidgetLibrary/EditBox/WLib_EditBox.layout": "0022F0B45ADBC5AC",
"system/textures/defWhite.edds": "A64A8C63E0FBAE87",
"worlds/Eden/Eden.ent": "853E92315D1D9EFE",
"worlds/MP/Navmeshes/LowResEden.nmn": "5E19E60F26327356"
}
@@ -0,0 +1,246 @@
"""Execute actual mounted sampler/snapshot methods against bounded native doubles."""
import re,os
from pathlib import Path
from policy_harness import ROOT, run
p=Path(os.environ.get('ERR_MOUNTED_AMMO_SOURCE',ROOT/'addons/core/Scripts/Game/ERR/10_AI/ERR_HQMountedAmmoSampler.c'))
s=p.read_text()
for forbidden in ('SetAmmoCount','GetOrigin','GetWorld','Spawn','TryMove','DeleteEntity','GetAgents'):
assert forbidden not in s, forbidden
code=re.sub(r'//[^\n]*','',s).replace('protected ','').replace('class ','struct ')
code=code.replace('BaseWeaponManagerComponent.Cast(part.FindComponent(BaseWeaponManagerComponent))','part->manager')
code=code.replace('BaseWeaponComponent.Cast(part.FindComponent(BaseWeaponComponent))','part->weapon')
code=code.replace('BaseWeaponComponent.Cast(mountedEntity.FindComponent(BaseWeaponComponent))','mountedEntity->weapon')
code=code.replace('InventoryItemComponent.Cast(mountedEntity.FindComponent(InventoryItemComponent))','mountedEntity->item')
code=code.replace('WeaponSlotComponent.Cast(weapon)','dynamic_cast<Mount*>(weapon)').replace('binding.GetParentContainer()','binding->mount')
code=code.replace('InventoryItemComponent.Cast(entity.FindComponent(InventoryItemComponent))','entity->item')
code=code.replace('WeaponSlotComponent.Cast(slot.GetParentContainer())','slot->mount').replace('BaseMuzzleComponent.Cast(slot.GetParentContainer())','slot->muzzle')
code=code.replace('EStoragePurpose.','EStoragePurpose::').replace('GetParentSlot().','GetParentSlot()->')
code=code.replace('ChimeraCharacter.Cast(entity) != nullptr','entity->character').replace('ChimeraCharacter.Cast(entity) != null','entity->character')
code=code.replace('ChimeraCharacter.Cast(root)','root->character').replace('ChimeraCharacter.Cast(entity)','entity->character')
code=code.replace('protected static ref ', 'inline static ').replace('static ref ', 'inline static ').replace('ref ', '')
code=re.sub(r'\bERR_HQMountedAmmoDiagnostic (?=\w)', 'ERR_HQMountedAmmoDiagnostic* ',code)
code=code.replace('s_Diagnostic.', 's_Diagnostic->').replace('GetPrefabData().', 'GetPrefabData()->')
code=re.sub(r'\bERR_HQMountedAmmoSnapshot (?=\w)','ERR_HQMountedAmmoSnapshot* ',code)
code=code.replace('array<','Array<').replace('foreach (','for (').replace('null','nullptr')
code=code.replace('Array<IEntity> allowed, Array<BaseWeaponComponent> weapons,','Array<IEntity>& allowed, Array<BaseWeaponComponent>& weapons,')
code=code.replace('Array<IEntity> allowed, Array<BaseWeaponComponent> weapons)', 'Array<IEntity>& allowed, Array<BaseWeaponComponent>& weapons)')
for name in ('copy','result','weapon','root','entity','child','part','manager','mounted','muzzle','magazine','item','storage','mount','mountedEntity','mountedItem'):
code=re.sub(r'\b'+name+r'\.',name+'->',code)
code=re.sub(r'\b(bool|int) (\w+);',r'\1 \2=0;',code).replace('\n}\n','\n};\n')
program=(r'''
#include <cassert>
#include <algorithm>
#include <vector>
#include <string>
using string=std::string;
struct Prefab{string name="fixture";string GetPrefabName(){return name;}};
template<class T>struct Array:std::vector<T>{using std::vector<T>::vector;
int Count(){return this->size();}bool IsEmpty(){return this->empty();}
void Insert(T n){this->push_back(n);}bool Contains(T n){return std::find(this->begin(),this->end(),n)!=this->end();}};
struct Entity;struct Weapon;struct Muzzle;struct Magazine;struct Manager;struct Mount;
struct EStoragePurpose{static const int PURPOSE_UNSET=0,PURPOSE_DEPOSIT=1,PURPOSE_WEAPON_PROXY=2,PURPOSE_ATTACHMENT_PROXY=4,PURPOSE_ANY=127;};
struct Storage{int purpose=EStoragePurpose::PURPOSE_DEPOSIT;int GetPurpose(){return purpose;}};
struct Slot{Mount* mount=nullptr;Muzzle* muzzle=nullptr;Storage* storage=nullptr;Storage* GetStorage(){return storage;}};
struct Item{Slot* slot=nullptr;Slot* GetParentSlot(){return slot;}};
using InventoryStorageSlot=Slot*;using WeaponSlotComponent=Mount*;
using InventoryItemComponent=Item*;using BaseInventoryStorageComponent=Storage*;
using IEntity=Entity*;using BaseWeaponComponent=Weapon*;using BaseMuzzleComponent=Muzzle*;
using BaseMagazineComponent=Magazine*;using BaseWeaponManagerComponent=Manager*;
struct Entity{Prefab prefab;Prefab*GetPrefabData(){return &prefab;}Item* item=nullptr;bool character=false;Entity* child=nullptr;Entity* sibling=nullptr;Manager* manager=nullptr;Weapon* weapon=nullptr;
int reads=0;Entity* GetChildren(){reads++;assert(reads<=1);return child;}Entity* GetSibling(){return sibling;}};
struct Magazine{IEntity owner=nullptr;int rounds=25,capacity=100,reads=0;
IEntity GetOwner(){return owner;}int GetAmmoCount(){reads++;return rounds;}int GetMaxAmmoCount(){return capacity;}};
struct Muzzle{IEntity owner=nullptr;Magazine* mag=nullptr;int barrels=1,chambered=1,reads=0;
IEntity GetOwner(){return owner;}int GetBarrelsCount(){return barrels;}
bool IsBarrelChambered(int b){reads++;return b<chambered;}Magazine* GetMagazine(){return mag;}};
struct Weapon{virtual ~Weapon(){}IEntity owner=nullptr;Array<Muzzle*> muzzles;int reads=0;
IEntity GetOwner(){return owner;}void GetMuzzlesList(Array<Muzzle*>& out){reads++;out=muzzles;}};
struct Mount:Weapon{IEntity weapon=nullptr;Slot* slot=nullptr;
Slot* GetSlotInfo(){return slot;}IEntity GetWeaponEntity(){return weapon;}};
struct Manager{Array<Weapon*> weapons;int reads=0;void GetWeapons(Array<Weapon*>& out){reads++;out=weapons;}};
'''+code+r'''
struct Rig{Entity root,gun,magazine,crew,rifle;Manager manager,crewManager;Weapon weapon,carried;
Muzzle muzzle,carriedMuzzle;Magazine mag,carriedMag;
Rig(){root.child=&gun;gun.sibling=&magazine;magazine.sibling=&crew;crew.character=true;crew.child=&rifle;
root.manager=&manager;manager.weapons={&weapon,&weapon};gun.weapon=&weapon;weapon.owner=&gun;weapon.muzzles={&muzzle,&muzzle};
muzzle.owner=&gun;muzzle.mag=&mag;mag.owner=&magazine;
crew.manager=&crewManager;crewManager.weapons={&carried};rifle.weapon=&carried;carried.owner=&rifle;
carried.muzzles={&carriedMuzzle};carriedMuzzle.owner=&rifle;carriedMuzzle.mag=&carriedMag;carriedMag.owner=&rifle;}
ERR_HQMountedAmmoSnapshot* Inspect(){return ERR_HQMountedAmmoSampler::Inspect(&root);}
};
int main(){
{auto s=ERR_HQMountedAmmoSampler::Inspect(nullptr);assert(!s->Complete&&s->Valid());}
{Entity root;root.character=true;auto s=ERR_HQMountedAmmoSampler::Inspect(&root);assert(!s->Complete&&root.reads==0);}
{Entity root;auto s=ERR_HQMountedAmmoSampler::Inspect(&root);assert(s->Complete&&s->Valid()&&s->Weapons==0);}
{Rig r;auto s=r.Inspect();assert(s->Complete&&s->Valid()&&s->Weapons==1&&s->Muzzles==1&&s->Magazines==1);
assert(s->Rounds==25&&s->Capacity==100&&s->Chambers==1&&s->LowMagazines==1);
assert(r.weapon.reads==1&&r.muzzle.reads==1&&r.mag.reads==1&&r.crew.reads==0&&r.crewManager.reads==0&&r.carried.reads==0);
auto copy=s->Snapshot();s->Complete=false;s->Rounds=0;s->Capacity=0;s->LowMagazines=0;
assert(copy->Complete&&copy->Rounds==25&&copy->Capacity==100&&copy->LowMagazines==1&&copy->Weapons==1&&copy->Muzzles==1&&copy->Magazines==1&&copy->Chambers==1);}
for(int rounds:{0,24,25,26,100}){Rig r;r.mag.rounds=rounds;auto s=r.Inspect();assert(s->Complete&&s->Valid());assert(s->LowMagazines==(rounds<=25));}
{Rig r;Muzzle second;second.owner=&r.gun;second.mag=&r.mag;second.chambered=0;r.weapon.muzzles.Insert(&second);
auto s=r.Inspect();assert(s->Complete&&s->Muzzles==2&&s->Magazines==1&&s->Chambers==1&&s->Rounds==25&&r.mag.reads==1);}
// Manager references into skipped characters, foreign roots, or nulls never count.
for(int kind=0;kind<3;kind++){Rig r;Entity foreign;Weapon w;w.owner=&foreign;
r.manager.weapons.Insert(kind==0?&r.carried:kind==1?&w:nullptr);auto s=r.Inspect();assert(!s->Complete&&s->Valid()&&s->Weapons==1);}
for(int kind=0;kind<3;kind++){Rig r;Entity foreign;
if(kind==0)r.muzzle.owner=&foreign;
if(kind==1)r.mag.owner=&foreign;
if(kind==2)r.mag.owner=nullptr;
auto s=r.Inspect();assert(!s->Complete&&s->Valid()&&s->Rounds==0&&s->Magazines==0);}
// Deposited rifles and nested magazines are excluded; installed magazine slots remain admitted.
{Rig r;Entity cargo,rifle,magEntity;Item item;Slot slot;Storage storage;Weapon rifleWeapon;
r.crew.sibling=&cargo;cargo.child=&rifle;rifle.child=&magEntity;rifle.item=&item;item.slot=&slot;slot.storage=&storage;
rifle.weapon=&rifleWeapon;rifleWeapon.owner=&rifle;auto s=r.Inspect();assert(s->Complete&&s->Weapons==1&&rifle.reads==0&&magEntity.reads==0);}
{Rig r;Item item;Slot slot;Storage storage;r.magazine.item=&item;item.slot=&slot;slot.storage=&storage;
storage.purpose=EStoragePurpose::PURPOSE_ATTACHMENT_PROXY;auto s=r.Inspect();assert(s->Complete&&s->Rounds==25&&s->Magazines==1);}
for(int purpose:{0,127}){Rig r;Item item;Slot slot;Storage storage;r.gun.item=&item;item.slot=&slot;slot.storage=&storage;
storage.purpose=purpose;auto s=r.Inspect();assert(!s->Complete&&s->Weapons==0&&s->Valid());}
// Native purposes support combined flags; any deposit bit excludes the subtree.
{Rig r;Item item;Slot slot;Storage storage;r.gun.item=&item;item.slot=&slot;slot.storage=&storage;
storage.purpose=EStoragePurpose::PURPOSE_DEPOSIT|EStoragePurpose::PURPOSE_ATTACHMENT_PROXY;
auto s=r.Inspect();assert(!s->Complete&&s->Weapons==0&&s->Valid());}
// Manager references cannot rescue a cargo weapon.
{Rig r;Item item;Slot slot;Storage storage;r.gun.item=&item;item.slot=&slot;slot.storage=&storage;
auto s=r.Inspect();assert(!s->Complete&&s->Weapons==0&&s->Valid());}
// Exact native weapon-slot and muzzle containers are not deposit storage.
for(int purpose:{-1,0,127}){Rig r;Item gunItem,magItem;Slot gunSlot,magSlot;Storage storage;Mount mount;
mount.owner=&r.root;mount.weapon=&r.gun;mount.slot=&gunSlot;gunSlot.mount=&mount;r.gun.item=&gunItem;gunItem.slot=&gunSlot;
magSlot.muzzle=&r.muzzle;r.magazine.item=&magItem;magItem.slot=&magSlot;
if(purpose>=0){storage.purpose=purpose;gunSlot.storage=&storage;magSlot.storage=&storage;}
auto s=r.Inspect();assert(s->Complete&&s->Valid()&&s->Weapons==1&&s->Magazines==1&&s->Rounds==25&&s->Chambers==1);}
// No generic missing-storage bypass: foreign container owners, stale slots and
// substituted attached items fail closed, including foreign loaded magazines.
for(int fault=0;fault<6;fault++){Rig r;Entity foreign;Item item;Slot slot,other;Mount mount;
r.gun.item=&item;item.slot=&slot;slot.mount=&mount;mount.owner=&r.root;mount.weapon=&r.gun;mount.slot=&slot;
if(fault==0)mount.owner=&foreign;
if(fault==1)mount.owner=&r.crew;
if(fault==2)mount.weapon=&foreign;
if(fault==3)mount.slot=&other;
if(fault==4)slot.mount=nullptr;
if(fault==5)mount.owner=nullptr;
auto s=r.Inspect();assert(!s->Complete&&s->Weapons==0&&s->Rounds==0&&s->Valid());}
for(int fault=0;fault<3;fault++){Rig r;Entity foreign;Item item;Slot slot;
r.magazine.item=&item;item.slot=&slot;slot.muzzle=&r.muzzle;
if(fault==0)r.muzzle.owner=&foreign;
if(fault==1)r.muzzle.mag=nullptr;
if(fault==2)r.mag.owner=&foreign;
auto s=r.Inspect();assert(!s->Complete&&s->Magazines==0&&s->Rounds==0&&s->Valid());}
// An exact loaded magazine inside an excluded cargo rifle does not re-admit it.
{Rig r;Item item,magItem;Slot slot,magSlot;Storage deposit;r.gun.item=&item;item.slot=&slot;slot.storage=&deposit;
r.magazine.item=&magItem;magItem.slot=&magSlot;magSlot.muzzle=&r.muzzle;
auto s=r.Inspect();assert(!s->Complete&&s->Weapons==0&&s->Magazines==0&&s->Valid());}
// Native manager/FindComponent expose the wrapper and the physical weapon.
// A UAZ's single PKM must be one weapon even when all those paths overlap.
{Rig r;Mount mount;Item item;Slot binding;mount.owner=&r.root;mount.weapon=&r.gun;mount.slot=&binding;
binding.mount=&mount;item.slot=&binding;r.gun.item=&item;r.root.weapon=&mount;mount.muzzles=r.weapon.muzzles;
r.manager.weapons={&mount,&r.weapon,&mount};auto s=r.Inspect();
assert(s->Complete&&s->Valid()&&s->Weapons==1&&s->Muzzles==1&&s->Magazines==1&&s->Rounds==25&&s->Chambers==1);
assert(mount.reads==0&&r.weapon.reads==1&&r.mag.reads==1);}
// Unknown/foreign/empty/nested/stale slot endpoints never become real guns.
for(int fault=0;fault<11;fault++){Rig r;Entity foreign;Mount mount,other;Item item;Slot binding,stale;
mount.owner=&r.root;mount.weapon=&r.gun;mount.slot=&binding;binding.mount=&mount;item.slot=&binding;r.gun.item=&item;
r.root.weapon=&mount;r.manager.weapons={&mount};
if(fault==0)mount.weapon=nullptr;
if(fault==1)mount.weapon=&foreign;
if(fault==2)mount.weapon=&r.root; // nested/self wrapper
if(fault==3)binding.mount=&other;
if(fault==4)item.slot=&stale;
if(fault==5)mount.slot=nullptr;
if(fault==6)r.gun.item=nullptr;
if(fault==7)mount.owner=&foreign;
if(fault==8)r.gun.weapon=nullptr;
if(fault==9){other.owner=&r.gun;r.gun.weapon=&other;} // valid first binding, nested wrapper endpoint
if(fault==10)r.weapon.owner=&foreign; // component found on target belongs elsewhere
auto s=r.Inspect();assert(!s->Complete&&s->Valid()&&s->Weapons<=1&&mount.reads==0&&other.reads==0);}
// Thirty-two genuine installed guns still fit the weapon cap despite wrappers.
{Entity root;Array<Entity> hosts(32),guns(32),mags(32);Array<Weapon> weapons(32);Array<Mount> mounts(32);
Array<Muzzle> muzzles(32);Array<Magazine> magazines(32);Array<Item> items(32);Array<Slot> bindings(32);
root.child=&hosts[0];for(int i=0;i<32;i++){
if(i+1<32)hosts[i].sibling=&hosts[i+1];
hosts[i].child=&guns[i];guns[i].child=&mags[i];hosts[i].weapon=&mounts[i];guns[i].weapon=&weapons[i];
mounts[i].owner=&hosts[i];mounts[i].weapon=&guns[i];mounts[i].slot=&bindings[i];bindings[i].mount=&mounts[i];
items[i].slot=&bindings[i];guns[i].item=&items[i];weapons[i].owner=&guns[i];weapons[i].muzzles={&muzzles[i]};
mounts[i].muzzles=weapons[i].muzzles;muzzles[i].owner=&guns[i];muzzles[i].mag=&magazines[i];magazines[i].owner=&mags[i];}
auto s=ERR_HQMountedAmmoSampler::Inspect(&root);assert(s->Complete&&s->Valid()&&s->Weapons==32&&s->Muzzles==32&&s->Magazines==32&&s->Rounds==800);}
// Missing/projectile-only magazines and unsupported native values stay incomplete.
for(int kind=0;kind<9;kind++){Rig r;
if(kind==0)r.muzzle.mag=nullptr;
if(kind==1)r.weapon.muzzles={nullptr};
if(kind==2)r.weapon.muzzles={};
if(kind==3)r.muzzle.barrels=0;
if(kind==4)r.muzzle.barrels=33;
if(kind==5)r.mag.rounds=-1;
if(kind==6)r.mag.capacity=0;
if(kind==7)r.mag.capacity=100001;
if(kind==8)r.mag.rounds=101;
auto s=r.Inspect();assert(!s->Complete&&s->Valid());}
{Rig r;r.weapon.muzzles=Array<Muzzle*>(9,&r.muzzle);auto s=r.Inspect();assert(!s->Complete&&s->Muzzles==0&&r.muzzle.reads==0);}
{Rig r;r.manager.weapons=Array<Weapon*>(9,&r.weapon);auto s=r.Inspect();assert(!s->Complete&&s->Weapons==1&&s->Valid());}
// Entity budget also bounds enqueue and cycles, rather than only processed work.
for(int count:{128,129,300}){std::vector<Entity> nodes(count);for(int i=0;i<count-1;i++)nodes[i].child=&nodes[i+1];
auto s=ERR_HQMountedAmmoSampler::Inspect(&nodes[0]);assert(s->Complete==(count==128));assert(s->Valid());
int reads=0;for(auto& e:nodes)reads+=e.reads;assert(reads==128);}
{Entity root,child;root.child=&child;child.sibling=&child;auto s=ERR_HQMountedAmmoSampler::Inspect(&root);assert(!s->Complete&&s->Valid());}
{Entity root,child;root.child=&child;child.child=&root;auto s=ERR_HQMountedAmmoSampler::Inspect(&root);assert(!s->Complete&&s->Valid());}
// Maximum weapon and muzzle bounds remain valid detached counts on overflow.
for(int count:{32,33}){Entity root;std::vector<Entity> nodes(count);std::vector<Weapon> weapons(count);
root.child=&nodes[0];for(int i=0;i<count;i++){nodes[i].weapon=&weapons[i];weapons[i].owner=&nodes[i];if(i+1<count)nodes[i].sibling=&nodes[i+1];}
auto s=ERR_HQMountedAmmoSampler::Inspect(&root);assert(!s->Complete&&s->Weapons==32&&s->Valid());}
{Entity root;std::vector<Entity> nodes(18);std::vector<Weapon> weapons(17);std::vector<Muzzle> muzzles(136);Magazine mag;mag.owner=&nodes[17];
root.child=&nodes[0];for(int i=0;i<18;i++){if(i+1<18)nodes[i].sibling=&nodes[i+1];if(i==17)continue;
nodes[i].weapon=&weapons[i];weapons[i].owner=&nodes[i];for(int j=0;j<8;j++){auto& m=muzzles[i*8+j];m.owner=&nodes[i];m.mag=&mag;weapons[i].muzzles.Insert(&m);}}
auto s=ERR_HQMountedAmmoSampler::Inspect(&root);assert(!s->Complete&&s->Muzzles==128&&s->Magazines==1&&s->Chambers==128&&s->Valid());}
{Rig r;Magazine alias;alias.owner=&r.magazine;Muzzle second;second.owner=&r.gun;second.mag=&alias;r.weapon.muzzles.Insert(&second);
auto s=r.Inspect();assert(!s->Complete&&s->Magazines==1&&s->Rounds==25&&alias.reads==0&&s->Valid());}
// Realistic production load: 128 known deposited items plus mounted root,
// gun, loaded magazine and a pruned original crew root exceed128 in total.
// Cargo-first and structure-first traversal both retain the same mounted counts.
for(bool cargoFirst:{false,true}){Rig r;std::vector<Weapon> cargoWeapons(128);std::vector<Entity> cargo(128);std::vector<Item> items(128);std::vector<Slot> slots(128);Storage deposit;
for(int i=0;i<128;i++){cargo[i].weapon=&cargoWeapons[i];cargoWeapons[i].owner=&cargo[i];cargo[i].item=&items[i];items[i].slot=&slots[i];slots[i].storage=&deposit;if(i<127)cargo[i].sibling=&cargo[i+1];}
if(cargoFirst){r.root.child=&cargo[0];cargo.back().sibling=&r.gun;}else{r.crew.sibling=&cargo[0];}
auto snapshot=r.Inspect();assert(snapshot->Complete&&snapshot->Weapons==1&&snapshot->Magazines==1&&snapshot->Rounds==25&&snapshot->Valid());
for(auto& item:cargo){assert(item.reads==0);}for(auto& gun:cargoWeapons){assert(gun.reads==0);}assert(r.weapon.reads==1&&r.carried.reads==0);}
// Independent128 structural/128 cargo limits, in either order and interleaved.
for(int order:{0,1,2})for(int scenario:{0,1,2,3}){
int structures=scenario==1?129:128;int cargoCount=scenario==2||scenario==3?129:(scenario==1?100:128);
if(scenario==2)structures=4;
std::vector<Entity> nodes(structures),cargo(cargoCount);std::vector<Item> items(cargoCount);std::vector<Slot> slots(cargoCount);Storage deposit;std::vector<Entity*> sequence;
for(int i=0;i<cargoCount;i++){cargo[i].item=&items[i];items[i].slot=&slots[i];slots[i].storage=&deposit;}
if(order==0){for(auto& e:cargo)sequence.push_back(&e);for(int i=1;i<structures;i++)sequence.push_back(&nodes[i]);}
if(order==1){for(int i=1;i<structures;i++)sequence.push_back(&nodes[i]);for(auto& e:cargo)sequence.push_back(&e);}
if(order==2){for(int i=0;i<std::max(structures-1,cargoCount);i++){if(i<cargoCount)sequence.push_back(&cargo[i]);if(i+1<structures)sequence.push_back(&nodes[i+1]);}}
nodes[0].child=sequence[0];for(int i=0;i<int(sequence.size())-1;i++)sequence[i]->sibling=sequence[i+1];
auto snapshot=ERR_HQMountedAmmoSampler::Inspect(&nodes[0]);assert(snapshot->Complete==(scenario==0)&&snapshot->Weapons==0&&snapshot->Valid());
int reads=0;for(auto& e:nodes)reads+=e.reads;assert(reads<=128);for(auto& e:cargo)assert(e.reads==0);
}
// Wire validation rejects impossible or malicious counts.
{ERR_HQMountedAmmoSnapshot s;assert(s.Valid());s.Weapons=33;assert(!s.Valid());s.Weapons=1;s.Muzzles=9;assert(!s.Valid());
s.Muzzles=1;s.Magazines=2;assert(!s.Valid());s.Magazines=1;s.Capacity=100001;assert(!s.Valid());s.Capacity=100;s.Rounds=101;assert(!s.Valid());
s.Rounds=25;s.Chambers=33;assert(!s.Valid());s.Chambers=1;s.LowMagazines=2;assert(!s.Valid());s.LowMagazines=1;s.Complete=true;assert(s.Valid());}
}
''')
run(program)
print('PASS: actual mounted hierarchy sampling, ownership exclusion, deduplication, completeness/caps, quarter threshold and detached validation; no runtime policy or ammunition mutation')
# WORKBENCH records are opt-in. Re-run every original geometry/count assertion
# in that build too, plus exact failure witnesses from the same traversal.
cases=r'''
{Rig r;ERR_HQMountedAmmoSampler::BeginDiagnostic();auto snap=r.Inspect();auto*d=ERR_HQMountedAmmoSampler::EndDiagnostic();assert(snap->Complete&&d->Reasons==0&&d->Nodes==4&&d->Allowed==3&&d->Managers==1);assert(!ERR_HQMountedAmmoSampler::EndDiagnostic());}
{Entity root;root.child=&root;ERR_HQMountedAmmoSampler::BeginDiagnostic();auto snap=ERR_HQMountedAmmoSampler::Inspect(&root);auto*d=ERR_HQMountedAmmoSampler::EndDiagnostic();assert(!snap->Complete&&d->Reasons==4&&d->Nodes==1&&d->Allowed==1&&root.reads==1);}
{Entity root;std::vector<Entity> children(128);root.child=&children[0];for(int i=0;i<127;i++)children[i].sibling=&children[i+1];ERR_HQMountedAmmoSampler::BeginDiagnostic();auto snap=ERR_HQMountedAmmoSampler::Inspect(&root);auto*d=ERR_HQMountedAmmoSampler::EndDiagnostic();assert(!snap->Complete&&d->Reasons==1024&&d->Nodes==129&&d->Allowed==128&&d->Structural==129&&d->Cargo==0&&children[127].reads==0);}
for(int purpose:{-1,0,127}){Rig r;Item item;Slot slot;Storage storage;r.gun.item=&item;item.slot=&slot;r.gun.prefab.name="first-gun";if(purpose>=0){slot.storage=&storage;storage.purpose=purpose;}ERR_HQMountedAmmoSampler::BeginDiagnostic();auto snap=r.Inspect();auto*d=ERR_HQMountedAmmoSampler::EndDiagnostic();assert(!snap->Complete&&(d->Reasons&2)&&(d->Reasons&16)&&d->FirstPrefab=="first-gun"&&d->FirstPurpose==purpose&&d->Detail.find("ambiguous-storage;")!=string::npos);}
{Entity root;Manager manager;root.manager=&manager;manager.weapons.resize(9,nullptr);ERR_HQMountedAmmoSampler::BeginDiagnostic();auto snap=ERR_HQMountedAmmoSampler::Inspect(&root);auto*d=ERR_HQMountedAmmoSampler::EndDiagnostic();assert(!snap->Complete&&d->Reasons==512&&d->Managers==1&&manager.reads==1);}
{Rig r;Mount mount;mount.owner=&r.root;r.manager.weapons={&mount};ERR_HQMountedAmmoSampler::BeginDiagnostic();auto snap=r.Inspect();auto*d=ERR_HQMountedAmmoSampler::EndDiagnostic();assert(!snap->Complete&&(d->Reasons&32));}
{ERR_HQMountedAmmoSampler::BeginDiagnostic();auto snap=ERR_HQMountedAmmoSampler::Inspect(nullptr);auto*d=ERR_HQMountedAmmoSampler::EndDiagnostic();assert(!snap->Complete&&d->Reasons==1&&d->Nodes==0&&d->Allowed==0);}
'''
cases+=r'''
for(int which:{0,1}){Entity root;int cargoCount=which==0?129:256;std::vector<Entity> cargo(cargoCount);std::vector<Item> items(cargoCount);std::vector<Slot> slots(cargoCount);Storage storage;root.child=&cargo[0];
for(int i=0;i<cargoCount;i++){cargo[i].item=&items[i];items[i].slot=&slots[i];slots[i].storage=&storage;if(i+1<cargoCount)cargo[i].sibling=&cargo[i+1];}
ERR_HQMountedAmmoSampler::BeginDiagnostic();auto snapshot=ERR_HQMountedAmmoSampler::Inspect(&root);auto*d=ERR_HQMountedAmmoSampler::EndDiagnostic();assert(!snapshot->Complete&&d->Cargo==129&&d->Structural==1&&(d->Reasons&2048));
if(which==0){assert(d->Nodes==130&&!(d->Reasons&8));}else{assert(d->Nodes==256&&(d->Reasons&8));}}
'''
run('#define WORKBENCH\n'+program.replace('int main(){','int main(){'+cases))
print('PASS: WORKBENCH opt-in diagnostics distinguish cycles/cap/storage/manager/mount failures without repeated native traversal')