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,42 @@
|
||||
"""Run the production recursive cargo-seat collector against aliased native layouts."""
|
||||
from policy_harness import ROOT, body, run
|
||||
source = ROOT / 'addons/core/Scripts/Game/ERR/10_AI/ERR_RescueFlightComponent.c'
|
||||
s = '\n'.join(body(source, name) for name in ('protected void CargoSeats(', 'protected int CargoCapacity('))
|
||||
s = s.replace('protected ', '').replace('IEntity entity', 'IEntity* entity').replace('IEntity child', 'IEntity* child')
|
||||
s = s.replace('array<BaseCompartmentSlot> seats)', 'std::vector<BaseCompartmentSlot*>& seats)')
|
||||
s = s.replace('array<BaseCompartmentSlot>', 'std::vector<BaseCompartmentSlot*>')
|
||||
s = s.replace('BaseCompartmentManagerComponent manager = BaseCompartmentManagerComponent.Cast(entity.FindComponent(BaseCompartmentManagerComponent));', 'auto* manager = entity->manager;')
|
||||
s = s.replace('foreach (BaseCompartmentSlot slot : slots)', 'for (auto* slot : slots)')
|
||||
s = s.replace('!seats.Contains(slot)', 'std::find(seats.begin(), seats.end(), slot) == seats.end()').replace('seats.Insert(slot)', 'seats.push_back(slot)').replace('seats.Count()', 'seats.size()')
|
||||
for name in ('entity', 'manager', 'child', 'slot'):
|
||||
s = s.replace(name + '.', name + '->')
|
||||
s = s.replace('ECompartmentType.', 'ECompartmentType::')
|
||||
run(r'''
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
namespace ECompartmentType { enum {PILOT,CARGO,TURRET}; }
|
||||
struct BaseCompartmentSlot {
|
||||
int type=ECompartmentType::CARGO; bool accessible=true,occupied=false,reserved=false,locked=false;
|
||||
int GetType(){return type;} bool IsCompartmentAccessible(){return accessible;}
|
||||
bool IsOccupied(){return occupied;} bool IsReserved(){return reserved;} bool IsGetInLocked(){return locked;}
|
||||
};
|
||||
struct Manager {std::vector<BaseCompartmentSlot*> slots;void GetCompartments(std::vector<BaseCompartmentSlot*>& out){out=slots;}};
|
||||
struct IEntity {Manager* manager=nullptr;IEntity* child=nullptr;IEntity* sibling=nullptr;IEntity* GetChildren(){return child;}IEntity* GetSibling(){return sibling;}};
|
||||
struct Actual {
|
||||
''' + s + r'''
|
||||
};
|
||||
int main(){
|
||||
BaseCompartmentSlot first,second,blocked,taken,reserved,locked,pilot;
|
||||
blocked.accessible=false;taken.occupied=true;reserved.reserved=true;locked.locked=true;pilot.type=ECompartmentType::PILOT;
|
||||
Manager rootSeats{{&first,&second,nullptr,&blocked,&taken,&reserved,&locked,&pilot}};
|
||||
Manager benchSeats{{&first,&second}};
|
||||
IEntity bench{&benchSeats},root{&rootSeats,&bench};
|
||||
Actual actual;
|
||||
assert(actual.CargoCapacity(&root)==2); // Parent and child expose the same native seats.
|
||||
second.occupied=true;assert(actual.CargoCapacity(&root)==1);
|
||||
first.locked=true;assert(actual.CargoCapacity(&root)==0);
|
||||
IEntity empty;assert(actual.CargoCapacity(&empty)==0);
|
||||
}
|
||||
''')
|
||||
print('PASS: unique usable cargo seats; duplicate parent/child slots, crew, occupied, reserved and locked seats excluded')
|
||||
Reference in New Issue
Block a user