34 lines
2.2 KiB
Python
34 lines
2.2 KiB
Python
"""Exercise actual actor-group lookup with distinct inherited vehicle and controlled character agents."""
|
|
from policy_harness import ROOT, body, run
|
|
source=body(ROOT/'addons/core/Scripts/Game/ERR/ERR_Actors.c','static SCR_AIGroup Group(')
|
|
source=source.replace('static SCR_AIGroup Group(IEntity actor)', 'static SCR_AIGroup* Group(IEntity* actor)')
|
|
source=source.replace('AIControlComponent control', 'AIControlComponent* control')
|
|
source=source.replace('AIControlComponent.Cast(', 'AIControlComponent::Cast(').replace('SCR_AIGroup.Cast(', 'SCR_AIGroup::Cast(')
|
|
source=source.replace('actor.FindComponent(AIControlComponent)', 'actor->FindComponent()')
|
|
source=source.replace('control.', 'control->').replace('GetControlAIAgent().', 'GetControlAIAgent()->').replace('null', 'nullptr')
|
|
run(r'''
|
|
#include <cassert>
|
|
struct SCR_AIGroup {static SCR_AIGroup* Cast(SCR_AIGroup* g){return g;}};
|
|
struct Agent {SCR_AIGroup* parent=nullptr;SCR_AIGroup* GetParentGroup(){return parent;}};
|
|
struct AIControlComponent {
|
|
Agent* inherited=nullptr;Agent* controlled=nullptr;int inheritedReads=0;
|
|
static AIControlComponent* Cast(AIControlComponent* c){return c;}
|
|
Agent* GetAIAgent(){inheritedReads++;return inherited;}Agent* GetControlAIAgent(){return controlled;}
|
|
};
|
|
struct IEntity {AIControlComponent* control=nullptr;AIControlComponent* FindComponent(){return control;}};
|
|
struct Actors {
|
|
'''+source+r'''
|
|
};
|
|
int main(){
|
|
assert(!Actors::Group(nullptr));IEntity actor;assert(!Actors::Group(&actor));
|
|
AIControlComponent control;actor.control=&control;assert(!Actors::Group(&actor));
|
|
SCR_AIGroup foot,convoy,vehicle;Agent personal{&foot},delegated{&vehicle};
|
|
control.controlled=&personal;control.inherited=&personal;assert(Actors::Group(&actor)==&foot);
|
|
personal.parent=&convoy;control.inherited=&delegated;
|
|
assert(Actors::Group(&actor)==&convoy&&control.inheritedReads==0);
|
|
control.controlled=nullptr;assert(!Actors::Group(&actor)&&control.inheritedReads==0);
|
|
control.controlled=&personal;personal.parent=nullptr;assert(!Actors::Group(&actor));
|
|
}
|
|
''')
|
|
print('PASS: actual actor group lookup retains controlled character membership when seated/inherited vehicle agents differ; missing control or parent refuses')
|