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:
@@ -0,0 +1,39 @@
|
||||
"""Regression: a native regroup must not strand another original driver."""
|
||||
from policy_harness import ROOT,body,run
|
||||
p=ROOT/'addons/core/Scripts/Game/ERR/10_AI/ERR_HunterCrewRecovery.c'
|
||||
s=body(p,'bool AdoptSeatedDriver(').replace('IEntity occupant','IEntity* occupant')
|
||||
for name in ['m_Unit']:
|
||||
s=s.replace(name+'.',name+'->')
|
||||
s=s.replace('Seats[0].','Seats[0]->').replace('ERR_Actors.','ERR_Actors::')
|
||||
run(r'''
|
||||
#include <cassert>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
template<class T>struct Array:std::vector<T>{bool IsEmpty(){return this->empty();}bool Contains(T item){return std::find(this->begin(),this->end(),item)!=this->end();}};
|
||||
struct IEntity{bool fit=true,player=false;int group=1;};
|
||||
struct Seat{IEntity*occupant=nullptr;IEntity*GetOccupant(){return occupant;}};
|
||||
struct Unit{int Group=1;Array<Seat*>Seats;Array<IEntity*>Members;IEntity*Driver=nullptr;};
|
||||
namespace ERR_Actors{bool CanFight(IEntity*x){return x&&x->fit;}bool Player(IEntity*x){return x&&x->player;}int Group(IEntity*x){return x?x->group:0;}}
|
||||
struct Recovery{Unit*m_Unit=nullptr;int cancelled=0,notes=0;void SuspendBoarding(){cancelled++;}void Note(std::string){notes++;}
|
||||
'''+s+r'''
|
||||
};
|
||||
int main(){
|
||||
IEntity first,second;Seat seat;seat.occupant=&second;Unit unit;unit.Driver=&first;unit.Seats.push_back(&seat);unit.Members.push_back(&first);unit.Members.push_back(&second);Recovery r;r.m_Unit=&unit;
|
||||
assert(r.AdoptSeatedDriver()&&unit.Driver==&second&&r.cancelled==1&&r.notes==1);
|
||||
assert(!r.AdoptSeatedDriver()&&r.cancelled==1);
|
||||
for(int bad=0;bad<7;bad++){
|
||||
Unit u=unit;u.Driver=&first;IEntity candidate;u.Members.push_back(&candidate);Seat s;s.occupant=&candidate;u.Seats.clear();u.Seats.push_back(&s);Recovery x;x.m_Unit=&u;
|
||||
if(bad==0)candidate.fit=false;
|
||||
if(bad==1)candidate.player=true;
|
||||
if(bad==2)candidate.group=2;
|
||||
if(bad==3)u.Members.clear();
|
||||
if(bad==4)s.occupant=nullptr;
|
||||
if(bad==5)u.Seats.clear();
|
||||
if(bad==6)u.Seats[0]=nullptr;
|
||||
assert(!x.AdoptSeatedDriver()&&u.Driver==&first&&x.cancelled==0);
|
||||
}
|
||||
Recovery empty;assert(!empty.AdoptSeatedDriver());
|
||||
}
|
||||
''')
|
||||
print('PASS: accept a fit original crew member assigned by native boarding; reject outsiders, players, casualties, wrong group and missing compartments')
|
||||
Reference in New Issue
Block a user