Files
Viano-Core/tests/clientless/test_undercity_arrival.py
T
Nico 3aa780662e Complete AdventureBot navigation, instance travel and shutdown fixes
Finish capital waiting travel and adaptive flight entry up to 10,000 yards.
Preserve checked vertical climbs, recover blocked ground departures and find
validated dry landings. Retain group routes and Undercity arrival constraints.

Restore defense from native combat references, coordinate instance rendezvous
and browser reentry, finalize clientless sessions before map destruction and
transfer Halaa capture-point ownership safely.

Include the associated regression tests, investigation reports and reusable
diagnostic scripts. Keep generated runtime evidence and server binaries local
through scoped ignore rules. Validation/build/live evidence is recorded in the
session checkpoint and individual reports.
2026-11-05 10:35:34 +01:00

73 lines
5.3 KiB
Python

"""Run the explicit Undercity policy and production final-arrival/goal guards."""
from pathlib import Path
import subprocess,tempfile
root=Path(__file__).resolve().parents[2]
s=(root/'src/server/game/World/ClientlessActionExecutorMgr.cpp').read_text()
def function(prefix,source=s):
a=source.index(prefix);b=source.index('{',a);depth=1;z=b+1
while depth:
depth+=(source[z]=='{')-(source[z]=='}');z+=1
return source[a:z]
behavior=(root/'src/server/game/World/AdventureBehaviorMgr.cpp').read_text()
policy=function('std::string RequiredLocationArrivalNode(',behavior)
queue=function('void AdventureBehaviorMgr::Queue(',behavior)
queue=queue[:queue.index(' if(auto group=')]+" r.Queued=sClientlessPlayerMgr->QueueAction(player->GetGUID().GetCounter(),std::move(a));\n}"
goal=function('bool ClientlessActionExecutorMgr::GetTravelGoal(')
gate=function('bool ClientlessActionExecutorMgr::StartFinalLocalLeg(')
gate=gate[:gate.index(' Position destination;')]+'return true;\n}'
code=r'''
#include <cassert>
#include <cmath>
#include <string>
#include <map>
using uint32=unsigned;
#define TC_LOG_INFO(...) ((void)0)
struct Guid{unsigned GetCounter(){return 121;}};
struct Player{Guid GetGUID(){return {};}unsigned map=0;float x=0,y=0,z=0;unsigned GetMapId(){return map;}int GetPhaseShift()const{return 0;}float GetExactDist(float a,float b,float c){return std::sqrt((a-x)*(a-x)+(b-y)*(b-y)+(c-z)*(c-z));}};
struct AdventureLocation{struct{unsigned MapId=0;}Point;unsigned ZoneId=1497,AreaId=1497;};
struct Catalog{AdventureLocation location;AdventureLocation const*Find(std::string const& key){return key=="war-quarter"?&location:nullptr;}}catalog;auto sAdventureLocationMgr=&catalog;
struct ClientlessAction{std::string Name;std::map<std::string,std::string>Parameters;};
struct Players{ClientlessAction last;bool QueueAction(unsigned,ClientlessAction action){last=action;return true;}}players;auto sClientlessPlayerMgr=&players;
struct AdventureBehaviorMgr{struct Record{bool Queued=false;};void Queue(Player*,Record&,std::string const&,std::string const&,std::string const&,bool);};
struct ClientlessTravelNode{unsigned MapId=0;float X=1568.62,Y=267.97,Z=-43.1,O=0;std::string Key="taxi_11";};
struct Graph{ClientlessTravelNode taxi;bool missing=false;ClientlessTravelNode const*FindNode(std::string const& key){return !missing&&key=="taxi_11"?&taxi:nullptr;}}graph;auto sClientlessTravelGraphMgr=&graph;
enum class ClientlessActionExecutionState{Failed};
struct ClientlessActionExecutorMgr{
struct Record{std::string RequiredArrivalNode="taxi_11",FinalLocationId="war-quarter",PlannedDestinationNode="surface";bool RequiredArrivalReached=false,Active=true,FinalLocalLegPending=true;unsigned FinalMapId=0;float FinalX=1724.8,FinalY=368.623,FinalZ=-60.4843,FinalO=0;
struct{std::string ActionName="travel_to_location",Detail;ClientlessActionExecutionState State;}Status;};
unsigned recoveries=0;bool GetTravelGoal(Record const&,ClientlessTravelNode&)const;
bool StartFinalLocalLeg(Player*,unsigned,Record&);
bool RecoverTravel(Player*,unsigned,Record&,unsigned,std::string reason){assert(reason=="required-arrival-node-not-reached");++recoveries;return false;}
};
'''+policy+'\n'+queue+'\n'+goal+'\n'+gate+r'''
int main(){
Player p;AdventureLocation point;
assert(RequiredLocationArrivalNode(point)=="taxi_11");
point.ZoneId=85;assert(RequiredLocationArrivalNode(point)=="taxi_11");
point.AreaId=153;assert(RequiredLocationArrivalNode(point).empty());
point.ZoneId=point.AreaId=1497;point.Point.MapId=1;assert(RequiredLocationArrivalNode(point).empty());
AdventureBehaviorMgr behavior;AdventureBehaviorMgr::Record activity;
behavior.Queue(&p,activity,"travel_to_location","id","war-quarter",false);
assert(activity.Queued&&players.last.Parameters.at("arrival_node")=="taxi_11"&&players.last.Parameters.at("id")=="war-quarter");
catalog.location.ZoneId=85;catalog.location.AreaId=153;
behavior.Queue(&p,activity,"travel_to_location","id","war-quarter",false);
assert(!players.last.Parameters.count("arrival_node"));
ClientlessActionExecutorMgr mgr;ClientlessActionExecutorMgr::Record r;ClientlessTravelNode target;
assert(mgr.GetTravelGoal(r,target)&&target.Key=="taxi_11"&&target.Z==-43.1f);
p.x=1568.62;p.y=267.97;p.z=70; // same XY above the underground arrival node is insufficient
assert(!mgr.StartFinalLocalLeg(&p,121,r)&&!r.RequiredArrivalReached&&mgr.recoveries==1);
p.z=-43.1;assert(mgr.StartFinalLocalLeg(&p,121,r)&&r.RequiredArrivalReached);
assert(r.FinalLocationId=="war-quarter"&&r.FinalZ<-60); // original location retained
assert(mgr.GetTravelGoal(r,target)&&target.Key=="location:war-quarter"&&target.Z<-60);
ClientlessActionExecutorMgr::Record unavailable;graph.missing=true;
assert(!mgr.GetTravelGoal(unavailable,target));assert(!mgr.StartFinalLocalLeg(&p,121,unavailable));
graph.missing=false;ClientlessActionExecutorMgr::Record ordinary;ordinary.RequiredArrivalNode.clear();
p.z=70;assert(mgr.StartFinalLocalLeg(&p,121,ordinary));
}
'''
with tempfile.TemporaryDirectory() as folder:
p=Path(folder);(p/'test.cpp').write_text(code)
subprocess.run(['c++','-std=c++17',str(p/'test.cpp'),'-o',str(p/'test')],check=True)
subprocess.run([str(p/'test')],check=True)
print('Undercity arrival: explicit map/area policy, hard taxi goal before entry, 3D arrival gate, missing anchor rejection and original final target preserved.')