Files
Viano-Core/tests/clientless/test_flight_area_query.py
T
Nico 0173a434f4 Improve AdventureBot recruitment, world presence and performance
Manage Arthoran as a persistent level-60 tank profile, add Worgen forms and mounts, enable PvP and recruit through native LFG with preparation actions and player invitations.

Reduce repeated route and flight-planning work, bound failed-travel retries and add runtime timing diagnostics. Include 86 passing tests and measurements with 110 online bots.
2026-10-29 01:36:35 +01:00

34 lines
1.9 KiB
Python

"""Production phased area lookup must use TerrainInfo's map/zone/area order."""
from pathlib import Path
import subprocess,tempfile
root=Path(__file__).resolve().parents[2]
s=(root/'src/server/game/World/ClientlessFlightMgr.cpp').read_text()
a=s.index('std::pair < uint32, uint32 > ClientlessFlightMgr::AreaZone(')
b=s.index('bool ClientlessFlightMgr::Enabled(',a)
code=r'''
#include <cassert>
#include <cstring>
#include <cstdint>
#include <string>
#include <unordered_map>
#include <memory>
using uint32=uint32_t;
struct Position{float x=1,y=2,z=3;float GetPositionX()const{return x;}float GetPositionY()const{return y;}float GetPositionZ()const{return z;}};
struct Player{int GetPhaseShift()const{return 17;}};
struct TerrainInfo{int calls=0;void GetZoneAndAreaId(int phase,uint32 map,uint32& zone,uint32& area,Position const&){assert(phase==17&&map==530);++calls;zone=3430;area=3460;}};
struct TerrainMgr{std::shared_ptr<TerrainInfo> value=std::make_shared<TerrainInfo>();auto LoadTerrain(uint32 map){assert(map==530);return value;}} sTerrainMgr;
class ClientlessFlightMgr{public:
mutable std::unordered_map<std::string,std::pair<uint32,uint32>> _planningAreas;
mutable std::unordered_map<uint32,std::shared_ptr<TerrainInfo>> _planningTerrain;
std::pair<uint32,uint32> AreaZone(Player const*,uint32,Position const&)const;
};
'''
code+=s[a:b]+r'''
int main(){ClientlessFlightMgr mgr;Player p;Position pos;auto r=mgr.AreaZone(&p,530,pos);assert(r.first==3460&&r.second==3430);assert(mgr.AreaZone(&p,530,pos)==r);assert(sTerrainMgr.value->calls==1);pos.x=1.0000001f;mgr.AreaZone(&p,530,pos);assert(sTerrainMgr.value->calls==2);}
'''
with tempfile.TemporaryDirectory(prefix='vcore-area-query-') as folder:
cpp=Path(folder)/'test.cpp';binary=Path(folder)/'test';cpp.write_text(code)
subprocess.run(['c++','-std=c++17',str(cpp),'-o',str(binary)],check=True)
subprocess.run([str(binary)],check=True)
print('Native terrain query map/phase, area/zone ordering and cache passed.')