Files
WoW-Hybrid-gateway/tests/native_warrior_action_diagnostics_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

43 lines
3.7 KiB
C++

#include "../native/entity_translation.hpp"
#include "gateway/protocol.hpp"
#include "gateway/splines.hpp"
#include <bit>
#include <fstream>
#include <iostream>
#include <stdexcept>
using namespace gateway;
static void require(bool value,const char* label){if(!value)throw std::runtime_error(label);}
static Bytes rejected_spline(uint64_t mover,uint64_t target){
Bytes raw;le(raw,mover,8);Bytes body=pack_guid(raw);
for(float value:{1.f,2.f,3.f})le(body,std::bit_cast<uint32_t>(value),4);
le(body,42,4);le(body,3,1);le(body,target,8);le(body,0x400,4);return body;
}
int main(int argc,char** argv){try{
require(argc==2,"output path required");constexpr uint64_t self=1234,target=0xf130000001000009ULL;
auto bad=rejected_spline(self,target);SplineParseObservation observed;
try{(void)turtle_monster_spline(bad,&observed);require(false,"unsupported source flags must remain rejected");}catch(const Error&){}
require(observed.available==31&&observed.flags==0x400&&observed.guid==self&&observed.target==target,"observed fields survive rejected parser");
try{(void)turtle_monster_spline({},&observed);require(false,"empty source spline must reject");}catch(const Error&){}
require(observed.available==0,"unobserved fields cannot retain stale values");
NativeEntityTranslation entity;entity.set_action_scope(self,7,1);
entity.note_spell_queued(20662,target);entity.note_spell_result(20662,0,0);entity.note_spell_go(20662,target);
entity.note_spell_damage(20647,target,600,17);
Character character;character.guid=self;
(void)entity.translate({0xdd,bad},character,7,0,1,{});
require(entity.motion_rejected==1,"rejection counter preserved");
require(entity.action_journal.back().kind==5&&entity.action_journal.back().flags==0x400&&entity.action_journal.back().available==31,"controlled self rejection retained");
(void)entity.translate({0x2fb,{0xff}},character,7,0,1,{});require(entity.action_journal.back().kind==5&&entity.action_journal.back().available==0,"unknown compressed mover fields stay unobserved");
entity.note_spell_result(20549,2,9);
require(entity.action_journal.back().action==0&&entity.action_journal.back().target==0&&entity.action_journal.back().spell==20549,"unrelated failure must not inherit Execute action");
entity.note_spell_queued(20662,target);entity.note_spell_queued(20662,target+1);entity.note_spell_result(20662,2,10);
require(entity.action_journal.back().match==2&&entity.action_journal.back().action==0,"overlapping same-spell results stay ambiguous");
entity.note_spell_go(20662,target+1);
MonsterSpline sent;sent.guid=self;sent.id=99;sent.duration=123;sent.start={1,2,3};sent.points.push_back({4,5,6});Guid128 modern{};modern[0]=1;
entity.motion.push_back({sent,modern});auto bytes=entity.motion_snapshot();require(bytes.size()==2208,"ABI2 fixed bound");
std::ofstream out(argv[1],std::ios::binary);out.write(reinterpret_cast<const char*>(bytes.data()),bytes.size());out.close();require(bool(out),"fixture write failed");
auto before_unknown=entity.action_journal.size();entity.clear_action_scope();entity.note_spell_result(20662,2,9);require(entity.action_journal.size()==before_unknown,"unknown map must not fabricate a scoped action");
const auto previous=entity.action_journal.back().sequence;NativeEntityTranslation next;next.set_action_scope(self,7,1);require(next.action_journal.back().sequence>previous,"sequence must not reset across entity lifetime");
for(unsigned i=0;i<25;++i)next.note_spell_queued(100+i,target);require(next.action_journal.size()==16&&next.pending_actions.size()<=16,"finite diagnostics bound");
return 0;
}catch(const std::exception& error){std::cerr<<error.what()<<"\n";return 1;}}