Simplify content controls and add vehicle roles; record Workshop 0.0.144
continuous-integration/drone/push Build is passing

Discover installed mod vehicles and save independent garage, traffic, patrol and convoy assignments. Retire the superseded RHS 1.9 overrides. Include native menu, crew/driving and publication evidence.
This commit is contained in:
2026-11-06 22:06:38 +01:00
parent 518a1a5744
commit 460d9808e5
116 changed files with 14244 additions and 404 deletions
+50
View File
@@ -0,0 +1,50 @@
"""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 <cassert>
#include <algorithm>
#include <string>
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<string>','Array<string>').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 <cassert>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
struct string:std::string{using std::string::string;bool IsEmpty(){return empty();}};
template<class T>struct Array:std::vector<T>{using std::vector<T>::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::map<string,ERR_VehicleEntry*>m_Entries;void Start(){}bool Allowed(string p,int r){auto it=m_Entries.find(p);return it!=m_Entries.end()&&(it->second->allowed&(1<<r));}int selected=0;int RandomInt(int,int count){return std::min(selected,count-1);}
'''+choice+r'''
};
int main(){
ERR_VehicleEntry original{"a",4,4},other{"b",4,4},added{"c",0,0};Catalog c;c.m_Entries={{"a",&original},{"b",&other},{"c",&added}};
c.selected=9;assert(c.Choose(2,"a")=="a"); // Existing default distribution is preserved.
added.allowed=4;assert(c.Choose(2,"a")=="c"); // Explicitly assigned new content participates.
assert(c.Choose(1,"a").IsEmpty()); // Independent uses.
original.allowed=0;added.allowed=0;assert(c.Choose(2,"a")=="b");
assert(c.Choose(2,"a",false).IsEmpty()); // Garages keep farm defaults out of ordinary parking slots.
other.allowed=0;assert(c.Choose(2,"a").IsEmpty()); // No disabled fallback.
added.allowed=4;assert(c.Choose(2,"",false)=="c");
}
''')
print('PASS: actual vehicle selection preserves default distribution, admits assigned additions, isolates uses, respects garage default scope and never restores disabled fallbacks')