Files
Viano-Core/tests/clientless/test_adventure_poi_binding.py
T
Nico 649915e575
clang PCH / build (push) Waiting to run
GCC PCH / build (push) Waiting to run
Fix AdventureBot travel recovery, area eligibility and safe build logout
2026-10-30 12:43:22 +01:00

35 lines
1.9 KiB
Python

"""Native gossip binding resolves POI maps independently of overlapping continent XY."""
from pathlib import Path
import subprocess,tempfile
root=Path(__file__).resolve().parents[2]
code=r'''
#include "AdventurePoiPolicy.h"
#include <cassert>
using namespace AdventurePoiPolicy;
int main(){
Menus menus{{100,{{101,0}}},{101,{{100,140},{0,141}}}};
std::vector<Root> roots{{100,{571,5800,600,650}}};
auto bindings=Bind(menus,roots);Anchor chosen;
assert(Select(bindings,140,5831,508,chosen)&&chosen.Map==571&&chosen.Z==650);
assert(!Select(bindings,999,5831,508,chosen));
// A much closer unrelated teleport anchor on map1 is not part of gossip ownership.
roots.push_back({999,{1,5831,508,3}});bindings=Bind(menus,roots);
assert(Select(bindings,140,5831,508,chosen)&&chosen.Map==571);
// Native association with several maps is ambiguous; do not guess by XY.
roots.push_back({100,{0,5831,508,3}});bindings=Bind(menus,roots);
assert(!Select(bindings,140,5831,508,chosen));
// A floating platform must not become the terrain hundreds of yards below.
assert(Height(640,-100000,[](float from){return from<658?184.f:658.f;})==658);
assert(Height(650,-100000,[](float from){return from<675?650.f:675.f;})==650);
assert(Height(640,-100000,[](float){return -100000.f;})==-100000);
// Choose a nearby guard's height only after its map has been established.
roots.pop_back();roots.push_back({100,{571,5832,508,658}});bindings=Bind(menus,roots);
assert(Select(bindings,140,5831,508,chosen)&&chosen.Map==571&&chosen.Z==658);
}
'''
with tempfile.TemporaryDirectory()as d:
p=Path(d);(p/'test.cpp').write_text(code)
subprocess.run(['c++','-std=c++17','-I'+str(root/'src/server/game/World'),str(p/'test.cpp'),'-o',str(p/'test')],check=True)
subprocess.run([str(p/'test')],check=True)
print('POI native gossip graph: recursive menus/cycles, unique map, ambiguity rejection, local height anchor.')