Files
EscapistsReintroduced/tests/test_native_local_admission_probe.py
T
jakub cab998fb64 Combine Workshop addon and fix prison startup
Merge owned systems into one addon while preserving resource identities. Gate player admission on the replicated prison scene, restore the original framed door, and hold enemy AI until escape. Correct scenario branding and author metadata, include publishing assets, and retain regression and native verification evidence.
2026-09-20 16:42:52 +02:00

53 lines
2.9 KiB
Python

"""Native fixture's actual snapshot predicate rejects changed life/body evidence."""
from policy_harness import ROOT, body, run
p=ROOT/'addons/core/Scripts/Game/ERR/00_Core/ERR_NativeLocalAdmissionProbe.c'
s=body(p,'protected bool Unchanged()').replace('protected ','').replace('ERR_Phase.PRISON','1').replace('GetGame().','GetGame()->')
for name in ['m_Mode','m_Controller','m_Life','m_Logic']:
s=s.replace(name+'.',name+'->')
s=s.replace('Players().','Players()->').replace('GetPlayerManager().','GetPlayerManager()->')
run('''#include <cassert>
using IEntity=void*;
struct UUID {int value=1; bool operator==(UUID o){return value==o.value;}};
struct Life {UUID AccountId;bool Connected=true,UsedLife=true;IEntity Actor=nullptr;};
struct Controller {IEntity actor=nullptr;IEntity GetControlledEntity(){return actor;}};
struct Roster {Life* life=nullptr;Life* current=nullptr;bool canEnter=false;Life* Get(int){return life;}Life* CurrentActor(IEntity){return current;}bool CanEnter(int,int){return canEnter;}};
struct Mode {Roster roster;Roster* Players(){return &roster;}};
struct Manager {Controller* controller=nullptr;Controller* GetPlayerController(int){return controller;}};
struct Game {Manager manager;Manager* GetPlayerManager(){return &manager;}};Game game;Game* GetGame(){return &game;}
struct Logic {bool idle=true;bool ERR_LocalProbeIdle(int){return idle;}};
struct Probe {
Mode mode;Life life,other;Controller controller;Logic logic;int actor=0;
Mode* m_Mode=&mode;Life* m_Life=&life;Controller* m_Controller=&controller;Logic* m_Logic=&logic;IEntity m_Actor=&actor;
UUID m_Key;int m_Connection=1,m_Participants=1,participants=1;
Probe(){life.Actor=m_Actor;controller.actor=m_Actor;mode.roster.life=&life;mode.roster.current=&life;game.manager.controller=&controller;}
int Participants(){return participants;}
'''+s+'''};
int main(){
Probe baseline;assert(baseline.Unchanged());
for(int fault=0;fault<13;++fault){
Probe p;
if(fault==0)p.m_Controller=nullptr;
if(fault==1)p.m_Actor=nullptr;
if(fault==2)p.m_Life=nullptr;
if(fault==3)p.mode.roster.life=&p.other;
if(fault==4)p.mode.roster.current=nullptr;
if(fault==5)p.life.AccountId.value=2;
if(fault==6)p.life.Connected=false;
if(fault==7)p.life.UsedLife=false;
if(fault==8)p.life.Actor=nullptr;
if(fault==9)p.controller.actor=nullptr;
if(fault==10)game.manager.controller=nullptr;
if(fault==11)p.participants=2;
if(fault==12)p.logic.idle=false;
assert(!p.Unchanged());
}
Probe spent;spent.mode.roster.canEnter=true;assert(!spent.Unchanged());
}
''')
source=p.read_text()
assert source.startswith('#ifdef WORKBENCH')
assert 'UUID.GenV4' not in source and 'OnPlayerDisconnected_S(' not in source
assert 'm_Logic.OnPlayerAuditSuccess_S(m_Connection);' in source
assert 'm_Logic.ERR_LocalProbeRefuseController(m_Connection)' in source
print('PASS: native local-admission snapshot rejects changed life/key/body/participant/pending state; authentication is not simulated')