Files
WoW-Hybrid-gateway/tests/quest_poi_dataset_runtime_test.cpp
praxisandClaude Fable 5.2 7f2139d8d0 Offline test fixtures
883 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

45 lines
3.6 KiB
C++

// SPDX-License-Identifier: GPL-2.0-or-later
#include "world_translation.hpp"
#include <iostream>
#include <source_location>
using namespace gateway;
static void check(bool ok,std::source_location l=std::source_location::current()){if(!ok)throw Error("terrain POI runtime line "+std::to_string(l.line()));}
static Bytes request(std::initializer_list<int32_t> ids){Bytes b;le(b,ids.size(),4);for(auto id:ids)le(b,uint32_t(id),4);for(size_t i=ids.size();i<175;++i)le(b,0,4);return b;}
static Bytes definition(uint32_t id,uint32_t object=0,int storage=-1){
Bytes b;le(b,id,4);for(auto n:{2,9,12,0,0,0,0,0,0,0,0,0,0,0})le(b,n,4);
for(unsigned i=0;i<24;++i)le(b,0,4);
for(auto s:{"Fixture","Objectives","Details",""})cstring(b,s);
for(int i=0;i<4;++i){le(b,storage==i?object:0,4);le(b,storage==i?8:0,4);le(b,storage==i+4?object:0,4);le(b,storage==i+4?8:0,4);}
for(unsigned i=0;i<4;++i)cstring(b,"");return b;
}
static int codec(uint32_t,const uint8_t*,uint32_t,uint32_t,uint8_t* out,uint32_t cap,uint32_t* needed){*needed=1;if(cap<1)return GW_CODEC_CAPACITY;out[0]=0;return GW_CODEC_OK;}
int main(){try{
NativeWorldTranslation w;w.selected.guid=4509;w.realm=70;w.self_created=true;w.location=WorldLocation{};
(void)w.entities.self_quest_log.observe({{198,60141},{201,7},{204,870}},true);
const auto query=request({60141,7,870,60141,5723,-1});
check(!w.queue_quest_poi(query,true));w.local_gameobject_authority=true;check(!w.queue_quest_poi(query,false));
check(!w.queue_quest_poi(Bytes{},true));check(w.queue_quest_poi(query,true));
check(w.quest_poi_pending.size()==3 && w.quest_poi_waiting_definitions.size()==3 && w.requests.size()==3);
check(!w.queue_quest_poi(query,true));check(!w.local_presentation_pending());
(void)w.translate({0x05d,definition(60141,51868,4)},0x46010046,0,codec);
check(w.quest_poi_waiting_definitions.size()==2 && !w.take_quest_poi());
(void)w.translate({0x05d,definition(7,6,0)},0x46010046,0,codec);
const auto delivered=w.translate({0x05d,definition(870)},0x46010046,0,codec);
Reader bundle(delivered);const auto packets=bundle.le(4);Bytes poi;unsigned emitted=0;
for(size_t i=0;i<packets;++i){const auto op=bundle.le(4),size=bundle.le(4);const auto body=bundle.take(size);if(op==0x67001d){poi.assign(body.begin(),body.end());++emitted;}}
bundle.end();check(emitted==1 && !w.local_presentation_pending());
std::optional<LegacyPacket> out;
Reader p(poi);check(p.le(4)==3 && p.le(4)==3);
for(auto expected:{60141,7,870}){
check(p.le(4)==uint32_t(expected));const auto blobs=p.le(4);check(blobs==uint32_t(expected==60141?4:3));
for(size_t i=0;i<blobs;++i){p.take(48);const auto points=p.le(4);p.take(points*6);check(p.le(1)==0);}
}p.end();check(!w.take_quest_poi());
check(!w.queue_quest_poi(request({5723,-1}),true));
check(w.queue_quest_poi(query,true));(void)w.entities.self_quest_log.observe({{198,0}},false);
out=w.take_quest_poi();check(bool(out));Reader q(out->body);check(q.le(4)==2 && q.le(4)==2);
check(w.queue_quest_poi(query,true));LegacyObjectUpdate u;u.kind=0;u.guid=4509;u.fields={{202,0}};w.observe_quest_poi_updates({u});check(w.quest_poi_pending.empty());
check(w.queue_quest_poi(query,true));u.kind=4;u.removed={4509};w.observe_quest_poi_updates({u});check(w.quest_poi_pending.empty());
check(w.queue_quest_poi(query,true));w.logout_complete=true;check(!w.take_quest_poi());check(!w.queue_quest_poi(query,true));
std::cout<<"Terrain POI runtime: local opt-in, active-only dedup, genuine definition wait, delivery, abandon/update/logout gates pass\n";return 0;
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}}