Include the current addon, terrain integrations, tools, regression tests and recorded development evidence.
186 lines
22 KiB
Python
186 lines
22 KiB
Python
"""Execute the exact original truck-to-courier pickup; no engine coverage claim."""
|
|
import os,re
|
|
from pathlib import Path
|
|
from policy_harness import ROOT,run
|
|
from test_finite_magazine_reservation import translated_reservation
|
|
p=Path(os.environ.get('ERR_MOUNTED_PICKUP_SOURCE',ROOT/'addons/core/Scripts/Game/ERR/10_AI/ERR_MountedAmmoPickup.c'))
|
|
s=p.read_text()
|
|
for forbidden in ('TrySpawn','SetAmmoCount','SetOrigin','SetTransform','DeleteEntity','TrySwap','TryInsert','TryRemove','PerformAction'):
|
|
assert forbidden not in s,forbidden
|
|
assert s.count('TryMoveItemToStorage(')==1
|
|
assert s.index('m_Reservation.Commit()') < s.index('TryMoveItemToStorage(')
|
|
code=s[s.index('class ERR_MountedAmmoPickup\n'):]
|
|
code=re.sub(r'//[^\n]*','',code).replace('protected ','').replace('notnull ','').replace('ref ','').replace('class ','struct ')
|
|
code=code.replace('void ERR_MountedAmmoPickup(','ERR_MountedAmmoPickup(')
|
|
code=code.replace('array<','Array<').replace('null','nullptr')
|
|
# Only engine component lookup/casts are doubled; all transaction methods execute.
|
|
cast_types={'InventoryItemComponent':'item','BaseMagazineComponent':'magazine','InventoryStorageManagerComponent':'inventory'}
|
|
for kind,field in cast_types.items():
|
|
code=re.sub(kind+r'\.Cast\(([^;\n]*?)\.FindComponent\('+kind+r'\)\)',lambda m:m[1]+'.'+field,code)
|
|
code=code.replace('WeaponSlotComponent.Cast(m_WeaponSlot.GetParentContainer())','dynamic_cast<Mount*>(m_WeaponSlot.GetParentContainer())')
|
|
code=code.replace('ERR_HQ.Cast(m_Mode.Command())','m_Mode.Command()').replace('ChimeraCharacter.Cast(m_Worker)','m_Worker')
|
|
for name in ('ERR_GameMode','ERR_MountedAmmoTransferState','ERR_ForceRules','ERR_Actors','ERR_ConvoyRules','ERR_EnemyEquipmentRules','ERR_InfantryAmmoTransfer','Replication','SCR_Global','CompartmentAccessComponent','EMuzzleType','EStoragePurpose','vector','TraceFlags','ERR_InfantryAmmoAccess'):
|
|
code=code.replace(name+'.',name+'::')
|
|
for name in ('m_Mode','mode','task','originalRoster','m_Task','m_Receipt','m_Donor','m_Target','m_Truck','m_Root','m_DonorRecord','m_TargetRecord','m_Roster','m_Weapon','m_WeaponSlot','m_Muzzle','m_Loaded','m_Incoming','m_Mount','m_FromStorage','m_ToStorage','m_OldMagazine','m_NewMagazine','m_Carried','m_TruckInventory','m_Reservation','m_Callback','m_Worker','gunItem','loadedItem','incomingItem','gun','item','hq','vehicle','entity','slot','inventory','magazine','character','trace','m_FromSlot','m_ToSlot','m_Destination','owner','storage'):
|
|
code=re.sub(r'\b'+name+r'\.',name+'->',code)
|
|
code=code.replace(').',' )->')
|
|
# Physics/vector return values, unlike components, are not pointers.
|
|
code=code.replace('GetVelocity( )->Length()', 'GetVelocity().Length()').replace('GetAngularVelocity( )->Length()', 'GetAngularVelocity().Length()')
|
|
code=code.replace('ERR_FiniteMagazineReservation m_Reservation','ERR_FiniteMagazineReservation* m_Reservation').replace('ERR_FiniteMagazineReservation pickupReservation','ERR_FiniteMagazineReservation* pickupReservation')
|
|
code=code.replace('ERR_MountedPickupCallback m_Callback','ERR_MountedPickupCallback* m_Callback')
|
|
code=code.replace('TraceParam trace = new TraceParam()', 'TraceParam* trace = new TraceParam()')
|
|
code=code.replace('TraceMove(trace, AccessFilter)', 'TraceMove(trace, [this](IEntity e){return AccessFilter(e);})')
|
|
code=re.sub(r'\b(bool|int|IEntity|Vehicle|ERR_GameMode|ERR_ConvoyTask|ERR_ConvoyReceipt|ERR_ConvoyVehicle|SCR_AIGroup|ERR_ForceRecord|ERR_HQStatusSampler|BaseWeaponComponent|WeaponSlotComponent|InventoryStorageSlot|BaseMuzzleComponent|BaseMagazineComponent|BaseInventoryStorageComponent|InventoryStorageManagerComponent|ERR_FiniteMagazineReservation\*|ERR_MountedPickupCallback\*) (\w+);',r'\1 \2{};',code)
|
|
code=code.replace('\n}\n','\n};\n')
|
|
callbacks=[]
|
|
for name in ('OnComplete','OnAllComplete','OnFailed','OnAllFailed'):
|
|
m=re.search('protected override void '+name+r'\(\) (\{[^\n]+\})',s)
|
|
callbacks.append('void ERR_MountedPickupCallback::'+name+'() '+m[1].replace('Transfer.','Transfer->'))
|
|
pre=r'''
|
|
#include <cassert>
|
|
#include <cmath>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <algorithm>
|
|
#include <functional>
|
|
#include <limits>
|
|
using string=std::string;
|
|
template<class T>struct Array:std::vector<T>{using std::vector<T>::vector;int Count(){return this->size();}bool Contains(T x){return std::find(this->begin(),this->end(),x)!=this->end();}void Insert(T x){this->push_back(x);}void RemoveItem(T x){this->erase(std::remove(this->begin(),this->end(),x),this->end());}};
|
|
struct vector{float x=0,y=0,z=0;float Length(){return std::sqrt(x*x+y*y+z*z);}static float Distance(vector a,vector b){return vector{a.x-b.x,a.y-b.y,a.z-b.z}.Length();}};
|
|
struct Entity;struct Group;struct Mode;struct Task;struct Receipt;struct ConvoyVehicle;struct Record;struct Roster;struct Weapon;struct Mount;struct Slot;struct Muzzle;struct Magazine;struct Storage;struct Inventory;struct HQ;
|
|
using IEntity=Entity*;using Vehicle=Entity*;using ChimeraCharacter=Entity*;using SCR_AIGroup=Group*;using ERR_GameMode=Mode*;using ERR_ConvoyTask=Task*;using ERR_ConvoyReceipt=Receipt*;using ERR_ConvoyVehicle=ConvoyVehicle*;using ERR_ForceRecord=Record*;using ERR_HQStatusSampler=Roster*;using BaseWeaponComponent=Weapon*;using WeaponSlotComponent=Mount*;using InventoryStorageSlot=Slot*;using BaseMuzzleComponent=Muzzle*;using BaseMagazineComponent=Magazine*;using BaseInventoryStorageComponent=Storage*;using InventoryStorageManagerComponent=Inventory*;using ERR_HQ=HQ*;
|
|
struct Component{virtual ~Component()=default;};
|
|
struct Item{Slot*slot=nullptr;Slot*GetParentSlot(){return slot;}};using InventoryItemComponent=Item*;
|
|
struct Physics{vector velocity,angular;vector GetVelocity(){return velocity;}vector GetAngularVelocity(){return angular;}};
|
|
struct Entity{Entity*parent=nullptr;bool alive=true,eligible=true,awake=true;IEntity seated=nullptr;Item*item=nullptr;Magazine*magazine=nullptr;Inventory*inventory=nullptr;Physics*physics=nullptr;vector position;Physics*GetPhysics(){return physics;}vector GetOrigin(){return position;}vector AimingPosition(){return position;}};
|
|
struct Slot{Storage*storage=nullptr;Component*container=nullptr;IEntity attached=nullptr;bool locked=false;vector point{1,0,0};Storage*GetStorage(){return storage;}Component*GetParentContainer(){return container;}IEntity GetAttachedEntity(){return attached;}bool IsLocked(){return locked;}void GetWorldTransform(vector mat[4]){mat[3]=point;}};
|
|
struct Storage{IEntity owner=nullptr;IEntity GetOwner(){return owner;}};
|
|
struct Well{int type=1;int Type(){return type;}bool IsInherited(int t){return t==type;}};
|
|
struct Magazine{IEntity owner=nullptr;Well*well=nullptr;int rounds=100,capacity=100;bool used=false;IEntity GetOwner(){return owner;}Well*GetMagazineWell(){return well;}int GetAmmoCount(){return rounds;}int GetMaxAmmoCount(){return capacity;}bool IsUsed(){return used;}};
|
|
struct Muzzle:Component{IEntity owner=nullptr;Magazine*mag=nullptr;Well*well=nullptr;int kind=0;IEntity GetOwner(){return owner;}Magazine*GetMagazine(){return mag;}Well*GetMagazineWell(){return well;}int GetMuzzleType(){return kind;}};
|
|
struct Weapon{IEntity owner=nullptr;Array<Muzzle*>muzzles;IEntity GetOwner(){return owner;}void GetMuzzlesList(Array<Muzzle*>&a){a=muzzles;}};
|
|
struct Mount:Component{IEntity owner=nullptr;IEntity gun=nullptr;Slot*slot=nullptr;IEntity GetOwner(){return owner;}IEntity GetWeaponEntity(){return gun;}Slot*GetSlotInfo(){return slot;}};
|
|
struct Group{};
|
|
struct Record{string Id;};
|
|
struct Ledger{SCR_AIGroup donor=nullptr,target=nullptr;Record*d=nullptr,*t=nullptr;Record*FindGroup(SCR_AIGroup g){return g==donor?d:g==target?t:nullptr;}};
|
|
struct HQ{bool valid=true;bool ValidateBoundVehicle(SCR_AIGroup g,IEntity e){return valid&&g&&e;}};
|
|
struct Mode{inline static Mode*current=nullptr;bool active=true;Ledger*ledger=nullptr;HQ*hq=nullptr;static Mode*Get(){return current;}bool Active(){return active;}Ledger*Forces(){return ledger;}HQ*Command(){return hq;}};
|
|
struct Receipt{bool Consumed=true;Array<string>Records;};
|
|
struct ConvoyVehicle{int Index=0;IEntity Entity=nullptr;SCR_AIGroup Group=nullptr;bool Released=false,Registered=true,crew=true,Arrived=false;IEntity Driver=nullptr;Array<IEntity>Members;bool CrewValid(ERR_GameMode){return crew;}};
|
|
struct Task{bool Ready=true,Stopped=false;ERR_ConvoyReceipt Receipt=nullptr;Array<ERR_ConvoyVehicle>Vehicles;};
|
|
struct Roster{SCR_AIGroup group=nullptr;IEntity root=nullptr,worker=nullptr;bool valid=true;IEntity InitialMember(int slot){return slot==1?worker:nullptr;}bool OwnsRoster(SCR_AIGroup g){return valid&&g==group;}bool ValidateBoundVehicle(IEntity e){return valid&&e==root;}bool CanAttribute(int slot,IEntity e,bool observe){assert(!observe);return valid&&slot==1&&e==worker;}};
|
|
struct Replication{inline static bool server=true;static bool IsServer(){return server;}};struct SCR_Global{inline static bool editor=false;static bool IsEditMode(){return editor;}};
|
|
struct ERR_Actors{static bool Alive(IEntity e){return e&&e->alive;}static bool CanFight(IEntity e){return e&&e->alive&&e->awake;}};
|
|
struct ERR_ConvoyRules{static bool PartOf(IEntity e,IEntity root){for(int i=0;e&&i<32;i++,e=e->parent)if(e==root)return true;return false;}};
|
|
struct ERR_InfantryAmmoTransfer{static bool StoredUnder(IEntity e,IEntity root){return ERR_ConvoyRules::PartOf(e,root);}};
|
|
struct ERR_EnemyEquipmentRules{static bool Eligible(ERR_GameMode m,SCR_AIGroup g,IEntity e){return m&&g&&e&&e->eligible;}};
|
|
struct CompartmentAccessComponent{static IEntity GetVehicleIn(IEntity e){return e?e->seated:nullptr;}};
|
|
struct ERR_ForceRules{static bool Finite(float x){return std::isfinite(x);}static bool FiniteVector(vector v){return Finite(v.x)&&Finite(v.y)&&Finite(v.z);}};
|
|
struct EMuzzleType{static const int MT_BaseMuzzle=0;};struct EStoragePurpose{static const int PURPOSE_DEPOSIT=1;};
|
|
struct TraceParam{vector Start,End;int Flags=0,LayerMask=0;};struct TraceFlags{static const int WORLD=1,ENTS=2;};const int TRACE_LAYER_CAMERA=4;
|
|
struct World{float fraction=1;Array<IEntity>blockers;int calls=0;float TraceMove(TraceParam*t,std::function<bool(IEntity)>filter){assert(t->Flags==3&&t->LayerMask==4);calls++;for(auto*e:blockers)if(filter(e))return 0;return fraction;}};
|
|
struct Game{World*world=nullptr;World*GetWorld(){return world;}};Game*game=nullptr;Game*GetGame(){return game;}
|
|
struct ScriptedInventoryOperationCallback{virtual void OnComplete(){}virtual void OnAllComplete(){}virtual void OnFailed(){}virtual void OnAllFailed(){}virtual ~ScriptedInventoryOperationCallback()=default;};
|
|
struct ERR_MountedAmmoPickup;
|
|
struct ERR_MountedPickupCallback:ScriptedInventoryOperationCallback{ERR_MountedAmmoPickup*Transfer=nullptr;void OnComplete()override;void OnAllComplete()override;void OnFailed()override;void OnAllFailed()override;};
|
|
struct Inventory{IEntity owner=nullptr;Array<IEntity>items;Array<Storage*>storages;Storage*selected=nullptr;bool allow=true,accept=true;int queries=0,calls=0,ack=0;ScriptedInventoryOperationCallback*last=nullptr;std::function<void()>effect;
|
|
IEntity GetOwner(){return owner;}void GetItems(Array<IEntity>&a,int p){assert(p==1);a=items;}void GetStorages(Array<Storage*>&a,int p){assert(p==1);a=storages;}
|
|
Storage*FindStorageForItem(IEntity,int p){assert(p==1);return selected;}
|
|
bool CanMoveItemToStorage(IEntity a,Storage*b,int slot){assert(a&&b&&slot==-1);queries++;return allow;}
|
|
bool TryMoveItemToStorage(IEntity a,Storage*b,int slot,ScriptedInventoryOperationCallback*cb){assert(a&&b&&slot==-1);calls++;last=cb;if(effect)effect();if(ack==1)cb->OnComplete();if(ack==-1)cb->OnFailed();return accept;}
|
|
bool CanSwapItemStorages(IEntity a,IEntity b){assert(a&&b&&a!=b);queries++;return allow;}
|
|
bool TrySwapItemStorages(IEntity a,IEntity b,ScriptedInventoryOperationCallback*cb){assert(a&&b&&a!=b);calls++;last=cb;if(effect)effect();if(ack==1)cb->OnComplete();if(ack==-1)cb->OnFailed();return accept;}};
|
|
enum ERR_MountedAmmoTransferState{FAILED=-1,PENDING,SUCCEEDED};
|
|
struct ERR_InfantryAmmoAccess{inline static bool clear=true;static bool Clear(Vehicle v,IEntity e){return v&&e&&clear;}};
|
|
'''
|
|
code=code.replace('ERR_GameMode::Get()', 'Mode::Get()')
|
|
main=r'''
|
|
struct Fixture{
|
|
Mode mode;Ledger ledger;HQ hq;Group dg,tg;Record dr{"donor"},tr{"target"};Receipt receipt;Task task;ConvoyVehicle donor,target;Roster roster;
|
|
Entity truck,root,worker,driver,targetDriver,gun,loaded,incoming,foreign;Physics dp,tp;Item gunItem,oldItem,newItem;Slot weaponSlot,fromSlot,toSlot,carrySlot;Storage truckStorage,carryStorage,gunStorage;Inventory carried,truckInventory;
|
|
Well well;Weapon weapon;Mount mount;Muzzle muzzle;Magazine oldMag,newMag;Array<IEntity>stock,spent;ERR_FiniteMagazineReservation reservation;
|
|
Fixture():reservation(&stock,&spent,&incoming){Mode::current=&mode;mode.ledger=&ledger;mode.hq=&hq;ledger.donor=&dg;ledger.target=&tg;ledger.d=&dr;ledger.t=&tr;
|
|
receipt.Records={"target","donor","2","3","4","5"};task.Receipt=&receipt;task.Vehicles.resize(6,nullptr);task.Vehicles[0]=⌖task.Vehicles[1]=&donor;
|
|
donor.Index=1;donor.Entity=&truck;donor.Group=&dg;donor.Driver=&driver;target.Entity=&root;target.Group=&tg;target.Driver=&targetDriver;target.Members={&worker,&targetDriver};truck.physics=&dp;root.physics=&tp;
|
|
roster.group=&tg;roster.root=&root;roster.worker=&worker;gun.parent=&root;loaded.parent=&gun;gun.item=&gunItem;loaded.item=&oldItem;incoming.item=&newItem;
|
|
gunItem.slot=&weaponSlot;oldItem.slot=&toSlot;newItem.slot=&fromSlot;weaponSlot.attached=&gun;weaponSlot.container=&mount;mount.slot=&weaponSlot;mount.gun=&gun;mount.owner=&root;
|
|
weapon.owner=&gun;weapon.muzzles={&muzzle};muzzle.owner=&gun;muzzle.mag=&oldMag;muzzle.well=&well;oldMag.owner=&loaded;oldMag.rounds=25;oldMag.used=true;newMag.owner=&incoming;oldMag.well=&well;newMag.well=&well;
|
|
loaded.magazine=&oldMag;incoming.magazine=&newMag;toSlot.attached=&loaded;toSlot.container=&muzzle;toSlot.storage=&gunStorage;gunStorage.owner=&gun;
|
|
fromSlot.attached=&incoming;fromSlot.storage=&truckStorage;truckStorage.owner=&truck;carrySlot.storage=&carryStorage;carryStorage.owner=&worker;
|
|
carried.owner=&worker;carried.storages={&carryStorage};carried.selected=&carryStorage;worker.inventory=&carried;
|
|
truckInventory.owner=&truck;truckInventory.items={&incoming};truckInventory.storages={&truckStorage};truck.inventory=&truckInventory;stock={&incoming};assert(reservation.Reserve());ERR_InfantryAmmoAccess::clear=true;}
|
|
ERR_MountedAmmoPickup Job(){return ERR_MountedAmmoPickup(&mode,&task,0,&roster,1,&weapon,&muzzle,&loaded,&incoming,&reservation);}
|
|
void Move(){fromSlot.attached=nullptr;carrySlot.attached=&incoming;newItem.slot=&carrySlot;truckInventory.items.clear();carried.items={&incoming};}
|
|
};
|
|
int main(){
|
|
// Inline completion must not resurrect a cancelled transaction or stale authority.
|
|
for(int loss=0;loss<4;loss++){Fixture f;auto t=f.Job();
|
|
f.truckInventory.ack=1;f.truckInventory.effect=[&](){if(loss==0)t.Stop();if(loss==1)f.task.Stopped=true;if(loss==2)f.mode.active=false;if(loss==3)f.target.Released=true;f.Move();};
|
|
assert(t.Tick(0)==FAILED&&t.Submitted()&&!t.Unresolved());
|
|
assert(t.Tick(1)==FAILED&&f.truckInventory.calls==1&&f.spent.Count()==1&&!f.reservation.ReleaseUnsubmitted());}
|
|
// Cancellation with acknowledgement but no custody keeps quarantine; later exact
|
|
// movement settles uncertainty without success, another submission or a refund.
|
|
{Fixture f;auto t=f.Job();f.truckInventory.ack=1;f.truckInventory.effect=[&](){t.Stop();};
|
|
assert(t.Tick(0)==FAILED&&t.Unresolved());f.Move();assert(!t.Unresolved());
|
|
assert(t.Tick(1)==FAILED&&f.truckInventory.calls==1&&f.spent.Count()==1&&!f.reservation.ReleaseUnsubmitted());}
|
|
|
|
// No personal firearm exists in the fixture: compatibility is the pinned mounted muzzle.
|
|
{Fixture f;auto t=f.Job();assert(t.Tick(0)==PENDING&&t.Submitted()&&t.Unresolved());assert(f.truckInventory.calls==1&&f.reservation.CommittedFor(&f.incoming));
|
|
f.truckInventory.last->OnComplete();assert(t.Tick(1)==PENDING&&t.Unresolved());f.Move();assert(t.Tick(2)==SUCCEEDED&&!t.Unresolved());
|
|
assert(t.Tick(9000)==SUCCEEDED&&f.truckInventory.calls==1&&f.spent.Count()==1&&f.oldMag.rounds==25&&f.newMag.rounds==100);}
|
|
{Fixture f;auto t=f.Job();t.Tick(0);f.Move();assert(t.Tick(1)==PENDING);f.truckInventory.last->OnAllComplete();assert(t.Tick(2)==SUCCEEDED);}
|
|
// Authored cargo access can be reachable beyond four metres from the vehicle origin.
|
|
{Fixture f;f.worker.position={-1,0,5};auto t=f.Job();assert(t.Tick(0)==PENDING&&t.Submitted());}
|
|
// A valid original convoy remains serviceable at a stationary route endpoint.
|
|
{Fixture f;f.donor.Arrived=true;f.target.Arrived=true;auto t=f.Job();assert(t.Tick(0)==PENDING&&t.Submitted());}
|
|
// The shared reservation is irrevocable before entering a synchronously-calling engine.
|
|
{Fixture f;f.truckInventory.accept=false;f.truckInventory.ack=1;f.truckInventory.effect=[&]{assert(f.reservation.CommittedFor(&f.incoming));assert(!f.reservation.ReleaseUnsubmitted());f.Move();};auto t=f.Job();assert(t.Tick(0)==SUCCEEDED&&!t.Unresolved());}
|
|
{Fixture f;auto a=f.Job();auto b=f.Job();assert(a.Tick(0)==PENDING&&b.Tick(0)==FAILED&&!b.Submitted()&&f.truckInventory.calls==1);}
|
|
{Fixture f;f.truckInventory.accept=false;auto t=f.Job();assert(t.Tick(0)==FAILED&&t.Submitted()&&t.Unresolved()&&!f.reservation.ReleaseUnsubmitted());f.truckInventory.last->OnFailed();assert(!t.Unresolved());assert(t.Tick(1)==FAILED&&f.truckInventory.calls==1);}
|
|
// Failure beats success; partial movement remains quarantined even after failure callback.
|
|
{Fixture f;auto t=f.Job();t.Tick(0);f.truckInventory.last->OnComplete();f.truckInventory.last->OnFailed();assert(t.Tick(1)==FAILED&&!t.Unresolved());f.truckInventory.last->OnAllComplete();assert(t.Tick(2)==FAILED);}
|
|
{Fixture f;auto t=f.Job();t.Tick(0);f.newItem.slot=&f.carrySlot;f.truckInventory.last->OnFailed();assert(t.Tick(1)==FAILED&&t.Unresolved());}
|
|
{Fixture f;auto t=f.Job();t.Stop();assert(t.Tick(0)==FAILED&&!t.Submitted()&&f.truckInventory.calls==0&&f.reservation.ReleaseUnsubmitted());}
|
|
{Fixture f;auto t=f.Job();t.Tick(0);t.Stop();f.mode.active=false;f.Move();f.truckInventory.last->OnComplete();assert(!t.Unresolved()&&t.Tick(1)==FAILED&&f.truckInventory.calls==1);}
|
|
{Fixture f;auto t=f.Job();t.Tick(0);assert(t.Tick(8000)==FAILED&&t.Unresolved()&&f.truckInventory.calls==1);}
|
|
{Fixture f;auto t=f.Job();t.Tick(10);assert(t.Tick(9)==FAILED&&t.Unresolved()&&f.truckInventory.calls==1);}
|
|
// Native deletion clears the weak exact identity: no item can arrive later.
|
|
// Retain the spent slot, do not count delivery, and never retry on late callbacks.
|
|
{Fixture f;auto t=f.Job();assert(t.Tick(0)==PENDING&&t.Unresolved());
|
|
t.m_Incoming=nullptr;f.reservation.m_Item=nullptr;f.stock[0]=nullptr;f.spent[0]=nullptr;
|
|
f.fromSlot.attached=nullptr;f.truckInventory.items.clear();
|
|
assert(t.Tick(1)==FAILED&&!t.Unresolved()&&f.spent.Count()==1&&!f.reservation.ReleaseUnsubmitted());
|
|
f.truckInventory.last->OnComplete();f.truckInventory.last->OnFailed();
|
|
assert(t.Tick(2)==FAILED&&!t.Unresolved()&&f.truckInventory.calls==1&&f.spent.Count()==1);}
|
|
// Damage, worker loss, source capture and a moved-but-existing item remain uncertain.
|
|
for(int k=0;k<4;k++){Fixture f;auto t=f.Job();assert(t.Tick(0)==PENDING);
|
|
if(k==0){f.incoming.alive=false;}if(k==1){t.m_Worker=nullptr;}
|
|
if(k==2){f.donor.Released=true;}if(k==3){f.truckInventory.items.clear();f.newItem.slot=nullptr;}
|
|
t.Stop();assert(t.Unresolved()&&t.Tick(1)==FAILED&&f.truckInventory.calls==1);}
|
|
// Original identity, carried capacity and source access losses fail before any submission.
|
|
for(int k=0;k<43;k++){Fixture f;auto t=f.Job();
|
|
switch(k){case 0:f.task.Stopped=true;break;case 1:f.task.Ready=false;break;case 2:f.donor.Released=true;break;case 3:f.target.Released=true;break;
|
|
case 4:f.receipt.Consumed=false;break;case 5:f.roster.valid=false;break;case 6:f.worker.seated=&f.root;break;case 7:f.worker.awake=false;break;
|
|
case 8:f.worker.eligible=false;break;case 9:f.hq.valid=false;break;case 10:f.dp.velocity.x=.3;break;case 11:f.tp.angular.x=.2;break;
|
|
case 12:f.target.crew=false;break;case 13:f.mount.gun=&f.foreign;break;case 14:f.muzzle.mag=nullptr;break;case 15:f.fromSlot.locked=true;break;
|
|
case 16:f.oldItem.slot=nullptr;break;case 17:f.newMag.used=true;break;case 18:f.oldMag.rounds=26;break;case 19:f.newMag.rounds=25;break;
|
|
case 20:f.newMag.capacity=0;break;case 21:f.oldMag.rounds=-1;break;case 22:f.newMag.rounds=101;break;case 23:f.truckInventory.allow=false;break;
|
|
case 24:f.truckInventory.items.clear();break;case 25:f.truckInventory.items.resize(129,&f.foreign);break;case 26:f.carried.storages.resize(65,&f.gunStorage);break;
|
|
case 27:f.gunStorage.owner=&f.foreign;break;case 28:f.fromSlot.storage=&f.gunStorage;break;case 29:f.task.Vehicles[0]=&f.donor;break;
|
|
case 30:f.worker.inventory=&f.truckInventory;break;case 31:f.weapon.muzzles.resize(9,&f.muzzle);break;case 32:f.ledger.t=&f.dr;break;case 33:f.target.Members.clear();break;
|
|
case 34:f.carried.selected=nullptr;break;case 35:ERR_InfantryAmmoAccess::clear=false;break;case 36:f.donor.Registered=false;break;
|
|
case 37:f.donor.Driver=&f.foreign;break;case 38:f.target.Driver=&f.foreign;break;case 39:f.target.Registered=false;break;
|
|
case 40:f.carried.items={&f.incoming};break;case 41:f.carried.selected=&f.gunStorage;break;case 42:f.toSlot.locked=true;break;}
|
|
assert(t.Tick(0)==FAILED&&!t.Submitted()&&f.truckInventory.calls==0&&f.spent.Count()==1&&f.reservation.ReleaseUnsubmitted());}
|
|
// Loss while pending is terminal; a late exact receipt settles quarantine without resuming.
|
|
for(int k=0;k<5;k++){Fixture f;auto t=f.Job();assert(t.Tick(0)==PENDING);switch(k){case 0:f.task.Stopped=true;break;case 1:f.roster.valid=false;break;case 2:f.mode.active=false;break;case 3:f.target.Driver=&f.foreign;break;case 4:f.muzzle.mag=nullptr;break;}
|
|
assert(t.Tick(1)==FAILED&&t.Unresolved());f.Move();f.truckInventory.last->OnComplete();assert(!t.Unresolved()&&t.Tick(2)==FAILED&&f.truckInventory.calls==1);}
|
|
// Invalid construction cannot reach inventory mutation.
|
|
for(int k=0;k<9;k++){Fixture f;switch(k){case 0:f.donor.Entity=nullptr;break;case 1:f.target.Entity=nullptr;break;case 2:f.task.Vehicles[1]=nullptr;break;case 3:f.task.Vehicles[0]=nullptr;break;
|
|
case 4:f.roster.worker=nullptr;break;case 5:f.gun.item=nullptr;break;case 6:f.incoming.item=nullptr;break;case 7:f.loaded.item=nullptr;break;case 8:f.target.Driver=&f.worker;break;}
|
|
auto t=f.Job();assert(t.Tick(0)==FAILED&&!t.Submitted()&&f.truckInventory.calls==0);}
|
|
}
|
|
'''
|
|
run(pre+translated_reservation()+code+'\n'+'\n'.join(callbacks)+main)
|
|
print('PASS: actual mounted pickup, exact finite ownership, pre-submission commit, physical custody, bounded callback and quarantine lifecycle; no native coverage claim')
|