883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
54 lines
4.4 KiB
C++
54 lines
4.4 KiB
C++
#include "gateway/turtle_combat_logs.hpp"
|
|
#include <cassert>
|
|
#include <functional>
|
|
#include <iostream>
|
|
using namespace gateway;
|
|
namespace {
|
|
Bytes full(uint64_t value){Bytes b;le(b,value,8);return b;}
|
|
Bytes packed(uint64_t value){return pack_guid(full(value));}
|
|
void rejects(const std::function<void()>& f){try{f();}catch(const Error&){return;}assert(false);}
|
|
template<class F>void malformed(const Bytes& b,F f){
|
|
for(size_t n=0;n<b.size();++n){try{assert(!f(std::span<const uint8_t>(b.data(),n)));}catch(const Error&) {}}
|
|
auto tail=b;tail.push_back(0);try{assert(!f(tail));}catch(const Error&){}
|
|
}
|
|
}
|
|
int main(){
|
|
const uint64_t caster=0x0010200000003040ULL,target=0xf130004455006677ULL;
|
|
Guid128 ng1{},ng2{};ng1[0]=0x34;ng1[15]=0x80;ng2[2]=0xaa;ng2[13]=0x42;
|
|
std::map<uint64_t,Guid128> known{{caster,ng1},{target,ng2}};
|
|
Bytes b=packed(target);append(b,packed(caster));le(b,1234,4);le(b,777,4);le(b,1,1);
|
|
auto heal=turtle_spell_heal_log(b);assert(heal&&heal->target==target&&heal->caster==caster&&heal->amount==777&&heal->critical);malformed(b,turtle_spell_heal_log);
|
|
auto heal_expected=pack_guid(ng2);append(heal_expected,pack_guid(ng1));le(heal_expected,1234,4);le(heal_expected,777,4);le(heal_expected,777,4);le(heal_expected,0xffffffffu,4);le(heal_expected,0,4);le(heal_expected,0,4);le(heal_expected,0x80,1);
|
|
assert(forever_spell_heal_log(*heal,known)==heal_expected);
|
|
rejects([&]{(void)forever_spell_heal_log(*heal,{});});heal->amount=0x80000000;rejects([&]{(void)forever_spell_heal_log(*heal,known);});
|
|
b.back()=2;assert(!turtle_spell_heal_log(b));
|
|
for(int32_t power:{-2,0,1,2,3,4}){
|
|
b=packed(target);append(b,packed(caster));le(b,1234,4);le(b,uint32_t(power),4);le(b,999,4);
|
|
auto event=turtle_spell_energize_log(b);assert(event&&event->power_type==power&&event->amount==999);malformed(b,turtle_spell_energize_log);
|
|
}
|
|
b=packed(target);append(b,packed(caster));le(b,1234,4);le(b,5,4);le(b,999,4);assert(!turtle_spell_energize_log(b));
|
|
for(unsigned reason=0;reason<=11;++reason){
|
|
b.clear();le(b,1234,4);le(b,caster,8);le(b,0,1);le(b,2,4);le(b,target,8);le(b,reason,1);le(b,caster,8);le(b,reason,1);
|
|
auto event=turtle_spell_miss_log(b);assert(event&&event->caster==caster&&event->targets.size()==2&&event->targets[0].target==target&&event->targets[1].miss_info==reason);malformed(b,turtle_spell_miss_log);
|
|
}
|
|
b.back()=12;assert(!turtle_spell_miss_log(b));b[13]=0xff;b[14]=0xff;b[15]=0xff;b[16]=0xff;assert(!turtle_spell_miss_log(b));
|
|
for(unsigned type=0;type<=5;++type){
|
|
b=full(target);le(b,type,1);le(b,100,4);le(b,7,4);le(b,uint32_t(-3),4);
|
|
auto event=turtle_environmental_damage_log(b);assert(event&&event->victim==target&&event->absorbed==7&&event->resisted==-3);
|
|
auto expected=pack_guid(ng2);le(expected,type,1);le(expected,100,4);le(expected,uint32_t(-3),4);le(expected,7,4);le(expected,0,1);
|
|
assert(forever_environmental_damage_log(*event,known)==expected);malformed(b,turtle_environmental_damage_log);
|
|
rejects([&]{(void)forever_environmental_damage_log(*event,{});});event->damage=0x80000000;rejects([&]{(void)forever_environmental_damage_log(*event,known);});
|
|
}
|
|
b=full(target);le(b,6,1);le(b,0,4);le(b,0,4);le(b,0,4);assert(!turtle_environmental_damage_log(b));
|
|
b=full(caster);append(b,full(target));auto kill=turtle_party_kill_log(b);assert(kill&&kill->killer==caster&&kill->victim==target);malformed(b,turtle_party_kill_log);
|
|
b=packed(target);append(b,packed(caster));le(b,2,4);le(b,1234,4);le(b,5678,4);
|
|
auto dispel=turtle_spell_dispel_log(b);assert(dispel&&dispel->removed_spells==std::vector<uint32_t>({1234,5678}));malformed(b,turtle_spell_dispel_log);
|
|
b=full(caster);append(b,full(target));le(b,1234,4);le(b,0,1);
|
|
auto immune=turtle_spell_immune_log(b);assert(immune&&immune->caster==caster&&immune->target==target);
|
|
auto expected=pack_guid(ng1);append(expected,pack_guid(ng2));le(expected,1234,4);le(expected,0,1);
|
|
assert(forever_spell_immune_log(*immune,known)==expected);malformed(b,turtle_spell_immune_log);
|
|
rejects([&]{(void)forever_spell_immune_log(*immune,{{caster,ng1}});});b.back()=1;assert(!turtle_spell_immune_log(b));
|
|
assert(NativeEnvironmentalDamageLogOpcode==0x69000e&&NativeSpellImmuneLogOpcode==0x69001d);
|
|
std::cout<<"Source7 exact shapes, full64/packed distinction, real enum bounds, malformed tails/counts and original native heal/environmental/immune byte goldens PASS\n";
|
|
}
|