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,52 @@
"""Actual scope sampling/identity selection; native weapon/camera APIs doubled."""
from policy_harness import ROOT, body, run
p=ROOT/'addons/core/Scripts/Game/ERR/00_Core/ERR_ObserverScope.c'
def adapt(s):
import re
s=s.replace('out vector view[4]', 'vector (&view)[4]').replace('out vector data','vector& data').replace('out float fov','float& fov').replace('out RplId weaponId','RplId& weaponId').replace('null','nullptr')
for cls in ('ChimeraCharacter','CharacterControllerComponent','BaseWeaponManagerComponent','SCR_2DOpticsComponent','SCR_2DPIPSightsComponent','RplComponent'):
s=re.sub(r'\b'+cls+r' (\w+)',cls+r'* \1',s);s=s.replace(cls+'.',cls+'::')
for name in ('character','control','weapons','optic','rpl','pip','actor'):
s=s.replace(name+'.',name+'->')
for name in ('GetCharacterController()','GetCurrentWeapon()','GetOwner()','GetPIPCamera()'):
s=s.replace(name+'.',name+'->')
s=s.replace('FindComponent(RplComponent)','FindComponent()').replace('RplId.','RplId::').replace('Math.','Math::').replace('vector.Zero','vector::Zero')
return s
run(r'''
#include <cassert>
#include <cmath>
#include <limits>
struct vector{float a=0,b=0,c=0;float&operator[](int i){return i==0?a:(i==1?b:c);}bool operator==(vector o){return a==o.a&&b==o.b&&c==o.c;}static vector Zero;};vector vector::Zero;
vector Vector(float a,float b,float c){return {a,b,c};}
struct RplId{int id=-1;RplId(int n=-1):id(n){}static RplId Invalid(){return {};}bool operator==(RplId o){return id==o.id;}bool operator!=(RplId o){return id!=o.id;}};
namespace Math{float Round(float n){return std::round(n);}}
struct RplComponent{RplId id=10;RplId Id(){return id;}static RplComponent*Cast(RplComponent*p){return p;}};
struct Camera{void GetWorldCameraTransform(vector (&v)[4]){v[3]={1,2,3};}};
struct SCR_2DOpticsComponent{bool ads=true,lit=false;float fov=12,offset=.1;virtual ~SCR_2DOpticsComponent(){}static SCR_2DOpticsComponent*Cast(SCR_2DOpticsComponent*p){return p;}bool IsSightADSActive(){return ads;}float GetFOV(){return fov;}float GetCurrentReticleOffsetY(){return offset;}bool ERR_ObserverIlluminated(){return lit;}};
struct SCR_2DPIPSightsComponent:SCR_2DOpticsComponent{bool enabled=true;Camera*camera=nullptr;static SCR_2DPIPSightsComponent*Cast(SCR_2DOpticsComponent*p){return dynamic_cast<SCR_2DPIPSightsComponent*>(p);}bool IsPIPEnabled(){return enabled;}Camera*GetPIPCamera(){return camera;}};
struct Weapon{RplComponent rpl;Weapon*GetOwner(){return this;}RplComponent*FindComponent(){return &rpl;}};
struct BaseWeaponManagerComponent{Weapon*weapon=nullptr;SCR_2DOpticsComponent*optic=nullptr;int index=0;Weapon*GetCurrentWeapon(){return weapon;}SCR_2DOpticsComponent*GetCurrentSights(){return optic;}int GetCurrentSightsIndex(){return index;}};
struct CharacterControllerComponent{bool ads=true;BaseWeaponManagerComponent weapons;bool IsWeaponADS(){return ads;}BaseWeaponManagerComponent*GetWeaponManagerComponent(){return &weapons;}};
struct ChimeraCharacter{CharacterControllerComponent control;CharacterControllerComponent*GetCharacterController(){return &control;}static ChimeraCharacter*Cast(ChimeraCharacter*p){return p;}};using IEntity=ChimeraCharacter*;
struct Scope{
'''+''.join(adapt(body(p,s)) for s in ('static bool Valid(', 'static void Sample(', 'static SCR_2DOpticsComponent Resolve('))+r'''
};
int main(){
ChimeraCharacter actor;Weapon weapon;SCR_2DOpticsComponent optic;actor.control.weapons.weapon=&weapon;actor.control.weapons.optic=&optic;
vector view[4],data;float fov=60;RplId id;
Scope::Sample(&actor,view,fov,id,data);assert(id==RplId(10)&&fov==12&&data[0]==1&&data[1]==.1f);
assert(Scope::Resolve(&actor,id,data)==&optic);
actor.control.weapons.index=1;assert(!Scope::Resolve(&actor,id,data));actor.control.weapons.index=0;
assert(!Scope::Resolve(&actor,11,data));assert(!Scope::Resolve(nullptr,id,data));
actor.control.ads=false;fov=60;Scope::Sample(&actor,view,fov,id,data);assert(id==RplId(-1)&&data==vector::Zero&&fov==60);actor.control.ads=true;
optic.ads=false;Scope::Sample(&actor,view,fov,id,data);assert(id==RplId(-1));optic.ads=true;
optic.fov=std::numeric_limits<float>::quiet_NaN();Scope::Sample(&actor,view,fov,id,data);assert(id==RplId(-1));optic.fov=12;
SCR_2DPIPSightsComponent pip;actor.control.weapons.optic=&pip;
Scope::Sample(&actor,view,fov,id,data);assert(id==RplId(-1)); // no camera yet
Camera camera;pip.camera=&camera;pip.lit=true;Scope::Sample(&actor,view,fov,id,data);
assert(id==RplId(10)&&data[2]==1&&view[3]==Vector(1,2,3)&&fov==12);
pip.enabled=false;view[3]={7,8,9};Scope::Sample(&actor,view,fov,id,data);assert(view[3]==Vector(7,8,9)); // 2D keeps sampled player pose
actor.control.weapons.weapon=nullptr;Scope::Sample(&actor,view,fov,id,data);assert(id==RplId(-1));
}
''')
print('PASS: production scope sampling preserves ordinary views, selects active ADS only, carries zoom/zeroing/illumination and rejects mismatched/unstreamed optics; native APIs doubled')
@@ -0,0 +1,114 @@
"""Execute actual camera sample validation/interpolation; native math substituted."""
import re
from policy_harness import ROOT,body,run
p=ROOT/'addons/core/Scripts/Game/ERR/00_Core/ERR_ObserverPlayerView.c'
def adapt(s):
for name in ['ERR_ObserverScope','ERR_ObserverViewRules','Math','Math3D','vector','RplId']:s=s.replace(name+'.',name+'::')
s=s.replace('out vector','vector').replace('out float ','float& ')
s=re.sub(r'ERR_ObserverViewSample (\w+)', r'ERR_ObserverViewSample* \1',s)
s=re.sub(r'(sample|start|end)\.', r'\1->',s)
return re.sub(r'(m_Samples\[\d+\])\.',r'\1->',s)
rules='\n'.join(adapt(body(p,k)) for k in ['static bool Sample(', 'static bool Fresh('])
methods='\n'.join(adapt(body(p,k)) for k in ['void Clear(', 'void Push(', 'bool Read('])
baseline=ROOT/'docs/evidence/observer-smoothing-2026-10-09/baseline/addons/core/Scripts/Game/ERR/00_Core/ERR_ObserverPlayerView.c'
old_methods='\n'.join(adapt(body(baseline,k)) for k in ['void Clear(', 'void Push(', 'bool Read('])
run(r'''
#include <cassert>
#include <cmath>
#include <algorithm>
#include <limits>
#include <vector>
#include <iostream>
struct vector {float operator[](int i){return i==0?x:(i==1?y:z);}bool operator==(vector b){return x==b.x&&y==b.y&&z==b.z;}static vector Zero;float x=0,y=0,z=0;vector operator+(vector v){return{x+v.x,y+v.y,z+v.z};}vector operator-(vector v){return{x-v.x,y-v.y,z-v.z};}vector operator*(float n){return{x*n,y*n,z*n};}
float LengthSq(){return x*x+y*y+z*z;}void Normalize(){float n=sqrt(LengthSq());x/=n;y/=n;z/=n;}
static float Dot(vector a,vector b){return a.x*b.x+a.y*b.y+a.z*b.z;}static vector Lerp(vector a,vector b,float f){return a+(b-a)*f;}
};
vector vector::Zero;
namespace Math {float Round(float f){return std::round(f);}float AbsFloat(float f){return fabs(f);}float Max(float a,float b){return std::max(a,b);}float Min(float a,float b){return std::min(a,b);}float Clamp(float n,float a,float b){return std::clamp(n,a,b);}float Lerp(float a,float b,float f){return a+(b-a)*f;}}
vector cross(vector a,vector b){return{a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x};}
namespace Math3D {void DirectionAndUpMatrix(vector forward,vector up,vector* out){auto right=cross(up,forward);right.Normalize();out[0]=right;out[1]=cross(forward,right);out[2]=forward;}}
struct RplId {int value=-1;RplId(int v=-1):value(v){}static RplId Invalid(){return{};}bool operator==(RplId a){return value==a.value;}bool operator!=(RplId a){return value!=a.value;}};
struct ERR_ObserverViewRules {'''+rules+r'''};
struct ERR_ObserverScope {'''+adapt(body(ROOT/'addons/core/Scripts/Game/ERR/00_Core/ERR_ObserverScope.c','static bool Valid('))+r'''};
struct ERR_ObserverViewSample {int Stamp;vector Position,Forward,Up;float Fov,Near;};
template<class T>struct Array:std::vector<T>{int Count(){return this->size();}bool IsEmpty(){return this->empty();}void Clear(){this->clear();}void Insert(T v){this->push_back(v);}void Remove(int i){this->erase(this->begin()+i);}};
struct Buffer {RplId m_ScopeWeapon;vector m_ScopeData;RplId m_Target;int m_Stamp=-1;float m_Received=-1,m_Playback=0,m_ReadAt=0;Array<ERR_ObserverViewSample*> m_Samples;
'''+methods+r'''};
struct Baseline {RplId m_ScopeWeapon;vector m_ScopeData;RplId m_Target;int m_Stamp=-1;float m_Received=-1;vector m_Position,m_Forward,m_Up,m_StartPosition,m_StartForward,m_StartUp;float m_Fov=0,m_Near=0,m_StartFov=0,m_Blend=1;
'''+old_methods+r'''};
bool close(float a,float b){return fabs(a-b)<0.0001;}
int main(){
vector pos{.1,1.6,.2},forward{0,0,1},up{0,1,0};
assert(ERR_ObserverViewRules::Sample(pos,forward,up,60,.0125));
assert(!ERR_ObserverViewRules::Sample({31,0,0},forward,up,60,.0125));
assert(!ERR_ObserverViewRules::Sample(pos,{},up,60,.0125));
assert(!ERR_ObserverViewRules::Sample(pos,forward,forward,60,.0125));
float nan=std::numeric_limits<float>::quiet_NaN();
assert(!ERR_ObserverViewRules::Sample({nan,0,0},forward,up,60,.0125));
assert(!ERR_ObserverViewRules::Sample(pos,{nan,0,1},up,60,.0125));
assert(!ERR_ObserverViewRules::Sample(pos,forward,up,nan,.0125));
assert(!ERR_ObserverViewRules::Sample(pos,forward,up,60,nan));
assert(!ERR_ObserverViewRules::Sample(pos,forward,up,0,.0125));
Buffer b;vector matrix[4];float fov,nearPlane;
assert(!b.Read(1,100,1,matrix,fov,nearPlane));
b.Push(1,100,100,pos,forward,up,60,.0125, -1, {});assert(b.Read(1,100,.01,matrix,fov,nearPlane));assert(close(matrix[3].y,1.6)&&close(fov,60));
// Actual lean/roll and zoom, without forcing world-up or a hard-coded camera FOV.
vector leanedUp{.6,.8,0};b.Push(1,150,150,{.3,1.4,.2},forward,leanedUp,30,.02, -1, {});
assert(b.Read(1,225,.025,matrix,fov,nearPlane));assert(close(matrix[3].x,.2)&&close(fov,45)&&matrix[1].x>0);
assert(b.Read(1,250,.025,matrix,fov,nearPlane));assert(close(matrix[3].x,.3)&&close(fov,30)&&close(matrix[1].x,.6)&&close(nearPlane,.02));
b.Push(1,149,270,{9,9,9},forward,up,80,.1, -1, {}); // out-of-order packet cannot rewind the view
assert(b.Read(1,275,.025,matrix,fov,nearPlane)&&close(matrix[3].x,.3));
for(int i=0;i<1000;i++)assert(b.Read(1,300,.016,matrix,fov,nearPlane)&&close(matrix[3].x,.3)); // no integration drift
assert(!b.Read(1,501,.01,matrix,fov,nearPlane)); // gap beyond 350 ms, no stale head approximation
assert(!b.Read(2,250,.01,matrix,fov,nearPlane)); // target switch never inherits previous pose
b.Push(2,200,600,{1,2,3},forward,up,75,.1, -1, {});assert(b.Read(2,600,0,matrix,fov,nearPlane)&&close(matrix[3].x,1));
b.Clear();assert(!b.Read(2,600,0,matrix,fov,nearPlane));
b.Push(1,700,700,pos,forward,up,12,.02,22,{1,0,1});
assert(b.Read(1,700,0,matrix,fov,nearPlane)&&close(fov,12)&&b.m_ScopeWeapon==RplId(22));
b.Push(1,701,710,pos,forward,up,60,.02,22,{nan,0,1});
assert(b.m_Stamp==700&&b.m_ScopeData[0]==1);
b.Push(1,702,720,pos,forward,up,60,.02,-1,{});
assert(b.Read(1,720,0,matrix,fov,nearPlane)&&close(fov,60)&&b.m_ScopeWeapon==RplId(-1));
assert(!ERR_ObserverScope::Valid(-1,{1,0,0}));
assert(!ERR_ObserverScope::Valid(22,{1.5,0,0}));
assert(!ERR_ObserverScope::Valid(22,{1,91,0}));
assert(!ERR_ObserverScope::Valid(22,{1,0,2}));
assert(!ERR_ObserverViewRules::Fresh(100,101));
// Real interpolation bodies, same constant-speed poses, uneven packet arrivals.
// Different client/server clock origins, dropped packets and varied render FPS.
for(float frame:{1000.f/30,1000.f/60,1000.f/144}){
Buffer smooth;Baseline old;int packet=0;float prevNew=0,prevOld=0,lastNewStep=0,lastOldStep=0;
float newVariation=0,oldVariation=0;int delay[]={0,25,5,35,0,15};
for(float t=0;t<2500;t+=frame){
while(packet<=50&&packet*50+delay[packet%6]<=t){
if(packet%13!=12){ // occasional single-packet loss
vector location{packet*.05f,1.6,0};
smooth.Push(1,70000+packet*50,10000+t,location,forward,up,60,.02,-1,{});
old.Push(1,70000+packet*50,10000+t,location,forward,up,60,.02,-1,{});
}
packet++;
}
assert(smooth.Read(1,10000+t,frame/1000,matrix,fov,nearPlane));float nextNew=matrix[3].x;
assert(old.Read(1,10000+t,frame/1000,matrix,fov,nearPlane));float nextOld=matrix[3].x;
float newStep=nextNew-prevNew,oldStep=nextOld-prevOld;
assert(newStep>=-0.0001); // no timeline rewind
if(t>500){newVariation+=fabs(newStep-lastNewStep);oldVariation+=fabs(oldStep-lastOldStep);}
prevNew=nextNew;prevOld=nextOld;lastNewStep=newStep;lastOldStep=oldStep;
assert(smooth.m_Samples.Count()<=12);
}
std::cout<<"frame_ms="<<frame<<" buffered_step_variation="<<newVariation<<" baseline="<<oldVariation<<"\n";
assert(newVariation<oldVariation*.25f);
}
// Holding an unrendered stream stays bounded; opening it resumes near live.
Buffer parked;
for(int i=0;i<1000;i++)parked.Push(1,i*50,i*50,pos,forward,up,60,.02,-1,{});
assert(parked.m_Samples.Count()==12);
assert(parked.Read(1,49950,0,matrix,fov,nearPlane)&&close(matrix[3].x,pos.x));
// Scope changes, reacquisition after expiry and target changes snap to their
// own pose instead of blending through another sight or another player.
parked.Push(1,50000,50400,{2,1,0},forward,up,30,.02,-1,{});
assert(parked.Read(1,50400,0,matrix,fov,nearPlane)&&close(matrix[3].x,2));
parked.Clear();assert(parked.m_Samples.IsEmpty()&&parked.m_ScopeWeapon==RplId(-1));
}
''')
print('PASS: actual view buffer validates samples, follows position/roll/FOV, rejects stale/foreign/reordered data, buffers jitter without drift, bounds memory and expires gaps')
@@ -0,0 +1,85 @@
"""Production relay authority/leases and delivery, with owner RPC/native data doubled."""
import re
from policy_harness import ROOT,body,run
p=ROOT/'addons/core/Scripts/Game/ERR/00_Core/ERR_ObserverPlayerView.c'
def adapt(s):
s=s.replace('protected ', '').replace('null','nullptr')
for cls in ['ERR_GameMode','ERR_PlayerLife','SCR_PlayerController','RplComponent']:
s=re.sub(r'\b'+cls+r' (\w+)\b',cls+r'* \1',s)
for obj in ['mode','life','watcher','source','component']:s=s.replace(obj+'.',obj+'->')
s=s.replace('m_ERRViewWatchers[i].','m_ERRViewWatchers[i]->')
for cls in ['ERR_ObserverScope','ERR_GameMode','ERR_Actors','ERR_ObserverRules','ERR_ObserverViewRules','Replication','SCR_PlayerController','RplComponent','SCR_FactionManager','RplId','Math','vector']:s=s.replace(cls+'.',cls+'::')
s=s.replace('GetGame().','GetGame()->').replace('GetWorld().','GetWorld()->').replace('GetPlayerManager().','GetPlayerManager()->').replace('Players().','Players()->').replace('Get().','Get()->')
s=s.replace('actor.FindComponent(RplComponent)', 'actor->FindComponent()')
s=s.replace('Rpc(ERR_EnableViewPublisher)', 'SendLease()')
return s
methods='\n'.join(adapt(body(p,k)) for k in ['bool ERR_ViewRecipient(', 'protected void ERR_RequestPlayerView(', 'void ERR_AddViewWatcher(', 'protected void ERR_EnableViewPublisher(', 'protected void ERR_SubmitPlayerView(', 'protected void ERR_ReceivePlayerView('])
run(r'''
#include <cassert>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
struct vector {float operator[](int i){return i==0?x:(i==1?y:z);}bool operator==(vector b){return x==b.x&&y==b.y&&z==b.z;}static vector Zero;float x=0,y=0,z=0;float LengthSq(){return x*x+y*y+z*z;}static float Dot(vector a,vector b){return a.x*b.x+a.y*b.y+a.z*b.z;}};
vector vector::Zero;
namespace Math{float Round(float f){return std::round(f);}float AbsFloat(float a){return fabs(a);}}
struct RplId{int value=-1;RplId(int i=-1):value(i){}static RplId Invalid(){return{-1};}bool operator==(RplId b){return value==b.value;}bool operator!=(RplId b){return value!=b.value;}};
struct RplComponent{RplId id{11};RplId Id(){return id;}static RplComponent* Cast(RplComponent* p){return p;}};
struct Actor {bool alive=true,conscious=true;int faction=1;RplComponent replication;RplComponent* FindComponent(){return &replication;}};using IEntity=Actor*;
struct ERR_PlayerLife {int ConnectionId=1;bool valid=true;};
struct Roster {std::map<IEntity,ERR_PlayerLife*> lives;ERR_PlayerLife* CurrentActor(IEntity a){auto p=lives.find(a);return p!=lives.end()&&p->second->valid?p->second:nullptr;}};
struct ERR_GameMode {bool active=true;Roster roster;static ERR_GameMode* current;static ERR_GameMode* Get(){return current;}bool Active(){return active;}Roster* Players(){return &roster;}int PlayerFaction(){return 1;}};ERR_GameMode* ERR_GameMode::current;
namespace ERR_Actors {bool Alive(IEntity a){return a&&a->alive;}bool CanFight(IEntity a){return Alive(a)&&a->conscious;}}
namespace SCR_FactionManager{int SGetFaction(IEntity a){return a?a->faction:0;}}
namespace ERR_ObserverReason{int NONE=0,UNCONSCIOUS=4;}
struct ERR_ObserverRules {'''+body(ROOT/'addons/core/Scripts/Game/ERR/00_Core/ERR_Observer.c','static bool View(').replace('ERR_ObserverReason.','ERR_ObserverReason::')+r'''};
struct ERR_ObserverViewRules {'''+adapt(body(p,'static bool Sample('))+r'''};
struct ERR_ObserverScope {'''+adapt(body(ROOT/'addons/core/Scripts/Game/ERR/00_Core/ERR_ObserverScope.c','static bool Valid('))+r'''};
namespace Replication{bool server=true;bool IsServer(){return server;}}
struct SCR_PlayerController;
struct Game {float now=1000;SCR_PlayerController* local=nullptr;std::map<int,SCR_PlayerController*> controllers;
Game* GetWorld(){return this;}Game* GetPlayerManager(){return this;}float GetWorldTime(){return now;}SCR_PlayerController* GetPlayerController(){return local;}SCR_PlayerController* GetPlayerController(int id){return controllers[id];}} game;
Game* GetGame(){return &game;}
template<class T>struct Array:std::vector<T>{int Count(){return this->size();}bool Contains(T v){return std::find(this->begin(),this->end(),v)!=this->end();}void Insert(T v){this->push_back(v);}void Remove(int i){this->erase(this->begin()+i);}};
struct Buffer{int pushes=0;void Push(RplId,int,float,vector,vector,vector,float,float,RplId,vector){pushes++;}};
struct SCR_PlayerController {
int id=0;IEntity controlled=nullptr,m_ERRServerObserved=nullptr,m_ERRViewSourceBody=nullptr;RplId m_ERRObservedId;
int m_ERRObserverReason=1,m_ERRViewInputSequence=0,leases=0,deliveries=0;float m_ERRViewLeaseUntil=-1,m_ERRViewServerRequestAt=-1000,m_ERRViewLeaseSent=-1000,m_ERRViewPublishUntil=-1,m_ERRViewLastPacket=-1000;
Array<SCR_PlayerController*> m_ERRViewWatchers;Buffer m_ERRViewBuffer;
int GetPlayerId(){return id;}IEntity GetControlledEntity(){return controlled;}static SCR_PlayerController* Cast(SCR_PlayerController* p){return p;}
void SendLease(){leases++;}
void ERR_DeliverPlayerView(RplId,int,vector,vector,vector,float,float,RplId,vector){deliveries++;}
'''+methods+r'''
};
int main(){
ERR_GameMode mode;ERR_GameMode::current=&mode;Actor target,dead,revived;dead.alive=false;
ERR_PlayerLife sourceLife;mode.roster.lives[&target]=&sourceLife;
SCR_PlayerController source,watcher,stranger;source.id=1;watcher.id=2;stranger.id=3;
source.controlled=&target;watcher.controlled=&dead;watcher.m_ERRServerObserved=&target;watcher.m_ERRObservedId={11};
game.controllers={{1,&source},{2,&watcher},{3,&stranger}};
assert(!watcher.ERR_ViewRecipient(&target,game.now)); // no lease
watcher.ERR_RequestPlayerView();assert(source.m_ERRViewWatchers.Count()==1&&source.leases==1);
watcher.ERR_RequestPlayerView();assert(source.leases==1); // bounded requests
vector position{0,1.6,0},forward{0,0,1},up{0,1,0};
source.ERR_SubmitPlayerView(1,position,forward,up,60,.0125, -1, {});assert(watcher.deliveries==1);
source.ERR_SubmitPlayerView(2,position,forward,up,60,.0125, -1, {});assert(watcher.deliveries==1); // packet rate bound
game.now+=50;source.ERR_SubmitPlayerView(1,position,forward,up,60,.0125, -1, {});assert(watcher.deliveries==1); // replay
source.ERR_SubmitPlayerView(2,{999,0,0},forward,up,60,.0125, -1, {});assert(watcher.deliveries==1);
source.ERR_SubmitPlayerView(2,position,forward,up,60,.0125, -1, {});assert(watcher.deliveries==2);
game.now+=50;source.ERR_SubmitPlayerView(3,position,forward,up,12,.0125,22,{99,0,0});assert(watcher.deliveries==2&&source.m_ERRViewInputSequence==2); // malformed scope cannot advance sequence or deliver
game.now+=50;watcher.controlled=&revived;source.ERR_SubmitPlayerView(3,position,forward,up,60,.0125, -1, {});assert(watcher.deliveries==2&&source.m_ERRViewWatchers.Count()==0); // no stream to recovered players
watcher.controlled=&dead;game.now+=500;watcher.ERR_RequestPlayerView();assert(source.m_ERRViewWatchers.Count()==1);
target.faction=2;game.now+=50;source.ERR_SubmitPlayerView(4,position,forward,up,60,.0125, -1, {});assert(watcher.deliveries==2);target.faction=1;
game.now+=500;watcher.ERR_RequestPlayerView();game.now+=1600;source.ERR_SubmitPlayerView(5,position,forward,up,60,.0125, -1, {});assert(watcher.deliveries==2&&source.m_ERRViewWatchers.Count()==0); // lease expired
watcher.ERR_RequestPlayerView();watcher.m_ERRServerObserved=nullptr;game.now+=50;source.ERR_SubmitPlayerView(6,position,forward,up,60,.0125, -1, {});assert(watcher.deliveries==2); // target switch
watcher.m_ERRServerObserved=&target;game.now+=500;watcher.ERR_RequestPlayerView();game.controllers[1]=&stranger;source.ERR_SubmitPlayerView(7,position,forward,up,60,.0125, -1, {});assert(watcher.deliveries==2);game.controllers[1]=&source;
sourceLife.valid=false;game.now+=50;source.ERR_SubmitPlayerView(7,position,forward,up,60,.0125, -1, {});assert(watcher.deliveries==2);sourceLife.valid=true;
game.local=&watcher;watcher.ERR_ReceivePlayerView({11},1,position,forward,up,60,.0125, -1, {});assert(watcher.m_ERRViewBuffer.pushes==1);
watcher.ERR_ReceivePlayerView({22},2,position,forward,up,60,.0125, -1, {});assert(watcher.m_ERRViewBuffer.pushes==1);
game.local=&stranger;watcher.ERR_ReceivePlayerView({11},3,position,forward,up,60,.0125, -1, {});assert(watcher.m_ERRViewBuffer.pushes==1);
game.local=&watcher;mode.active=false;watcher.ERR_ReceivePlayerView({11},4,position,forward,up,60,.0125, -1, {});assert(watcher.m_ERRViewBuffer.pushes==1);
mode.active=true;game.local=&source;source.ERR_EnableViewPublisher();assert(source.m_ERRViewPublishUntil==game.now+2000);
}
''')
print('PASS: actual relay rejects noncanonical sources, live/foreign/stale viewers, invalid/replayed/fast packets; bounds leases and owner-only target delivery')