"""Production candidate and patrol crew limits for optional discovered vehicles.""" from policy_harness import ROOT, body, run p=ROOT/'addons/core/Scripts/Game/ERR/00_Core/ERR_ServerVehicleCatalog.c' s=body(p,'static bool Candidate(')+'\n'+body(p,'static bool PatrolSeats(') run(r''' #include #include #include struct string:std::string{using std::string::string;void ToLower(){std::transform(begin(),end(),begin(),[](unsigned char c){return std::tolower(c);});}bool Contains(string s){return find(s)!=npos;}bool EndsWith(string s){return size()>=s.size()&&compare(size()-s.size(),s.size(),s)==0;}}; ''' + s + r''' int main(){ assert(Candidate("{guid}Prefabs/Vehicles/MyAddon_NewCar.et")); assert(!Candidate("Prefabs/Vehicles/Car_Base.et")); assert(!Candidate("Prefabs/Vehicles/Parts/Engine.et")); assert(!Candidate("Prefabs/Vehicles/Turrets/PKM.et")); assert(!Candidate("Prefabs/Vehicles/Car_wreck.et")); assert(!Candidate("Prefabs/Weapons/Gun.et")); assert(PatrolSeats(1,0,3,4));assert(PatrolSeats(1,1,0,2));assert(PatrolSeats(1,0,14,15)); assert(!PatrolSeats(0,1,3,4));assert(!PatrolSeats(2,1,3,6));assert(!PatrolSeats(1,0,0,1)); assert(!PatrolSeats(1,0,15,16));assert(!PatrolSeats(1,1,1,5)); } ''') print('PASS: optional vehicle discovery excludes parts/wrecks/base templates; bounded custom patrol crews accept cars and gun crews without extra bodies') choice=body(p,'ResourceName Choose(int role, ResourceName preferred, bool otherDefaults = true)') choice=choice.replace('ResourceName','string').replace('array','Array').replace('Math.RandomInt','RandomInt') choice=choice.replace('foreach (string key, ERR_VehicleEntry entry : m_Entries)', 'for (auto& [key, entry] : m_Entries)').replace('entry.', 'entry->') run(r''' #include #include #include #include #include struct string:std::string{using std::string::string;bool IsEmpty(){return empty();}}; templatestruct Array:std::vector{using std::vector::vector;bool Contains(T v){return std::find(this->begin(),this->end(),v)!=this->end();}void Insert(T v){this->push_back(v);}bool IsEmpty(){return this->empty();}int Count(){return this->size();}}; struct ERR_VehicleEntry{string Prefab;int Defaults;int allowed;}; struct Catalog{std::mapm_Entries;void Start(){}bool Allowed(string p,int r){auto it=m_Entries.find(p);return it!=m_Entries.end()&&(it->second->allowed&(1<