Files
WoW-Hybrid-gateway/tests/observed_spell_cast_test.cpp

452 lines
24 KiB
C++

#include "optional_test_codec.hpp"
#include "world_translation.hpp"
#include "gateway/cast_visual_profile.hpp"
#include "gateway/server_cast_identity.hpp"
#include "serializer.h"
#include <algorithm>
#include <chrono>
#include <cstdlib>
#include <dlfcn.h>
#include <iostream>
using namespace gateway;
namespace {
using Codec=decltype(&gw_codec_serialize);
constexpr uint64_t self=42,peer=19,unit=(0xf130ULL<<48)|(150ULL<<24)|20;
constexpr uint32_t start=0x131,go=0x132;
unsigned checks=0;
void check(bool ok,const char* why){
++checks;
if(!ok)throw Error(why);
}
Bytes packed(uint64_t id){
Bytes bytes;
le(bytes,id,8);
return pack_guid(bytes);
}
LegacyPacket event(uint32_t op,uint64_t caster,uint32_t spell,uint64_t target,
bool projectile=false,uint32_t display=0,uint32_t inventory_type=0){
Bytes bytes=packed(caster);
append(bytes,packed(caster));
le(bytes,spell,4);
le(bytes,(op==start?2:0x100)|(projectile?0x20:0),2);
if(op==start)le(bytes,1500,4);
else{
le(bytes,target?1:0,1);
if(target)le(bytes,target,8);
le(bytes,0,1);
}
le(bytes,target?2:0,2);
if(target)append(bytes,packed(target));
if(projectile){le(bytes,display,4);le(bytes,inventory_type,4);}
return {op,bytes};
}
NativeWorldTranslation world(uint8_t race=1,uint8_t cls=8){
NativeWorldTranslation w;
w.selected.guid=self;w.selected.race=race;w.selected.cls=cls;w.selected.level=20;
w.realm=70;w.location=WorldLocation{0,{0,0,0,0}};w.self_created=true;
w.entities.self_presentation_ready=true;w.entities.self_position_generation=1;
for(auto id:{peer,unit}){
auto& actor=w.entities.actors[id];
actor.kind=id==peer?4:3;actor.eligible=true;actor.sent=true;
actor.generation=1;actor.presentation_realm=w.realm;actor.presentation_map=0;
actor.modern=id==peer?forever_player_guid(id,w.realm):forever_creature_guid(id,150,w.realm,0);
}
return w;
}
std::vector<LegacyPacket> translate(NativeWorldTranslation& w,const LegacyPacket& p,Codec codec){
const auto envelope=w.translate(p,0x46010046,0,codec);
Reader r(envelope);auto count=r.le(4);
std::vector<LegacyPacket> out;
while(count--){const auto opcode=uint32_t(r.le(4));out.push_back({opcode,r.take(r.le(4))});}
r.end();return out;
}
Guid128 guid(Reader& r){
auto raw=unpack_guid(r,16);
Guid128 out{};std::copy(raw.begin(),raw.end(),out.begin());return out;
}
struct Wire {
Guid128 actor,id,target;
uint32_t spell,visual,flags,time,ammo;
Bytes lists;
};
Wire cast(const std::vector<LegacyPacket>& packets,uint32_t opcode,uint32_t expected_script=0){
check(packets.size()==1 && packets.front().opcode==opcode,"expected one authoritative cast event");
Reader r(packets.front().body);
Wire b{};
b.actor=guid(r);check(guid(r)==b.actor,"caster and caster unit");
b.id=guid(r);check(guid(r)==Guid128{},"OriginalCastID");
b.spell=r.le(4);b.visual=r.le(4);check(r.le(4)==expected_script,"ScriptVisualID");
b.flags=r.le(4);check(!r.le(4) && !r.le(4),"extended cast flags");
b.time=r.le(4);auto flags=r.le(4);b.target=guid(r);
check(flags==(b.target==Guid128{}?0u:2u),"target flag");
check(guid(r)==Guid128{} && guid(r)==Guid128{} && !r.le(2),"target optional fields");
check(!r.le(4) && !r.le(4),"unobserved flight time and pitch");
b.ammo=r.le(4);check(!r.le(1) && !r.le(8),"destination index and immunities");
check(!r.le(8) && guid(r)==Guid128{},"heal prediction");
b.lists=r.take(r.left());return b;
}
// #126 (report ea5c6e): the 70334 spell queue sends the next CastSpell during the last ~400 ms of a cast. Turtle
// refuses it (CAST_FAILED SPELL_IN_PROGRESS) while the first cast keeps running. The refused request must not
// orphan the running one: its GO has to complete the client's own cast (same CastID, matched-request flag), or the
// client keeps the first cast's animation/state while the spell result arrives under a foreign server identity.
NativeWorldTranslation::PendingCast request(NativeWorldTranslation& w,uint32_t spell,uint8_t id){
ForeverSpellRequest req{};req.spell=spell;req.visual=236677;req.cast[0]=id;
req.target_flags=2;req.unit=w.entities.actors.at(peer).modern;
return NativeWorldTranslation::PendingCast{req,forever_player_guid(self,w.realm)};
}
LegacyPacket refused(uint32_t spell){Bytes b;le(b,spell,4);le(b,2,1);le(b,97,1);return {0x130,b};} // SPELL_IN_PROGRESS
void queued_request_refused(Codec codec){
for(bool go_first:{false,true}){
auto w=world();
w.pending_cast=request(w,133,61);
cast({translate(w,event(start,self,133,peer),codec).back()},0x69002d);
check(w.cast_prepared,"first cast started");
w.queue_cast(request(w,2054,62)); // the client's queued second request replaces the pending one
if(go_first){
auto done=cast(translate(w,event(go,self,133,peer),codec),0x69002c);
check(done.id[0]==61 && done.flags==0x40100,"first cast completes as the client's own cast while second waits");
check(w.pending_cast && w.pending_cast->spell.cast[0]==62,"queued request kept after first GO");
auto failed=translate(w,refused(2054),codec);
check(!failed.empty() && !w.pending_cast,"queued request refused");
}else{
auto failed=translate(w,refused(2054),codec);
check(!failed.empty(),"queued request refusal reaches client");
check(w.pending_cast && w.pending_cast->spell.cast[0]==61 && w.cast_prepared,"running cast restored after queued refusal");
auto done=cast(translate(w,event(go,self,133,peer),codec),0x69002c);
check(done.id[0]==61 && done.flags==0x40100 && !w.pending_cast,"running cast completes with its own CastID");
}
}
}
// #136 (Gitea #6): Heroic Strike is a next-swing cast. Its GO arrives at the next main-hand swing, seconds after the
// request; instants pressed meanwhile (Mortal Strike) must not orphan it, or the client never completes its own HS
// cast (no damage presentation, HS stays queued, swing feel off). TrinityCore keeps it in CURRENT_MELEE_SPELL.
void next_swing_survives_instants(Codec codec){
for(bool hs_start:{false,true}){
auto w=world();
w.queue_cast(request(w,11567,71)); // Heroic Strike rank 8, waits for the swing
if(hs_start)translate(w,event(start,self,11567,peer),codec);
w.queue_cast(request(w,12294,72)); // Mortal Strike pressed before the swing
translate(w,event(start,self,12294,peer),codec);
auto ms=cast(translate(w,event(go,self,12294,peer),codec),0x69002c);
check(ms.id[0]==72,"instant completes with its own CastID");
auto hs=translate(w,event(go,self,11567,peer),codec);
check(!hs.empty(),hs_start?"started next-swing cast lost after an instant":"queued next-swing cast lost after an instant");
auto done=cast({hs.back()},0x69002c);
check(done.id[0]==71 && done.flags==0x40100,"next-swing GO completes the client's own HS cast");
}
}
void repeats(Codec codec,uint8_t race,uint8_t cls,uint32_t spell,uint32_t display,uint32_t slot){
auto w=world(race,cls);
ForeverSpellRequest unrelated{};
unrelated.spell=133;unrelated.cast[0]=0x71;
const auto player=forever_player_guid(self,w.realm);
w.pending_cast=NativeWorldTranslation::PendingCast{unrelated,player};
Guid128 prior{};
for(unsigned i=0;i<2;++i){
const auto a=cast(translate(w,event(start,self,spell,peer,true,display,slot),codec),0x69002d);
const auto b=cast(translate(w,event(go,self,spell,peer,true,display,slot),codec),0x69002c);
check(a.id!=prior && a.id==b.id && a.id!=unrelated.cast,"per-shot cast identity");
check(a.actor==player && b.actor==player && a.target==w.entities.actors.at(peer).modern && b.target==a.target,"self and target identity");
check(a.flags==0x22 && b.flags==0x120 && a.time==1500,"server ranged cast flags and duration");
check(a.spell==spell && b.spell==spell && a.visual==cast_visual_profile::link(spell) && b.visual==a.visual,"effective spell visual");
const uint32_t wanted_ammo=display==5996?737993:0; // The admitted 5996/24 item render route.
check(a.ammo==wanted_ammo && b.ammo==wanted_ammo,"native ammo display");
check(w.pending_cast && w.pending_cast->spell.cast==unrelated.cast && !w.cast_prepared,"unrelated request retained");
check(w.observed_casts.empty(),"completed cast removed");
prior=a.id;
}
const auto standalone=cast(translate(w,event(go,self,spell,peer,true,display,slot),codec),0x69002c);
check(standalone.id!=prior && w.pending_cast && w.observed_casts.empty(),"independent GO-only shot");
}
void pending_completion(Codec codec){
auto w=world();
ForeverSpellRequest req{};
req.spell=133;req.visual=236677;req.cast[0]=63;
req.target_flags=2;req.unit=w.entities.actors.at(peer).modern;
w.pending_cast=NativeWorldTranslation::PendingCast{req,forever_player_guid(self,w.realm)};
auto client=translate(w,event(start,self,133,peer),codec);
check(client.size()==2 && client[0].opcode==0x69002b && w.cast_prepared,"client request prepares exactly once");
auto first=cast({client[1]},0x69002d);
check(first.flags==0x40002 && first.id==req.cast && first.visual==req.visual,"matched client provenance");
auto server=cast(translate(w,event(go,peer,133,self),codec),0x69002c);
check(server.id!=req.cast && server.actor==w.entities.actors.at(peer).modern && w.cast_prepared,"other actor same spell leaves prepared local cast");
auto wand=cast(translate(w,event(go,self,5019,peer,true,0,26),codec),0x69002c);
check(wand.id!=req.cast && wand.visual==0 && w.pending_cast && w.cast_prepared,"real wand GO keeps local cast active");
auto other_target=cast(translate(w,event(go,self,133,unit),codec),0x69002c);
check(other_target.id!=req.cast && other_target.flags==0x100 && w.cast_prepared,"same spell on a different explicit unit leaves user cast active");
auto last=cast(translate(w,event(go,self,133,peer),codec),0x69002c);
check(last.id==req.cast && last.flags==0x40100 && !w.pending_cast && !w.cast_prepared,"matching cast still completes");
}
void original_wire(Codec codec){
auto w=world();
const auto bytes=unhex("012a012a9b13000020010113000000000000000114000000000000000b0002000113000000001a000000");
// Original emits raw 64-bit hit/miss IDs. Bind a second synthetic peer (20)
// so the transmitted reflected miss is observable in the native writer.
auto& victim=w.entities.actors[20];
victim=w.entities.actors.at(peer);
victim.modern=forever_player_guid(20,w.realm);
const auto b=cast(translate(w,{go,bytes},codec),0x69002c);
Bytes lists={0,1,0,1,0,1,0,1,0,0,0,0};
append(lists,pack_guid(w.entities.actors.at(peer).modern));
append(lists,pack_guid(victim.modern));
append(lists,Bytes{0,11,0,0});
check(b.lists==lists,"one hit and one reflected miss with original outcomes");
auto truncated=bytes;truncated.pop_back();
check(translate(w,{go,truncated},codec).empty(),"flagged incomplete projectile tail held");
auto no_unit=event(go,self,10444,peer);
no_unit.body.erase(no_unit.body.begin()+packed(self).size(),
no_unit.body.begin()+2*packed(self).size());
no_unit.body.insert(no_unit.body.begin()+packed(self).size(),0);
check(translate(w,no_unit,codec).empty(),"Flametongue source suppresses caster unit");
auto unknown=event(go,self,5019,peer,true,2147480000,26);
check(cast(translate(w,unknown,codec),0x69002c).ammo==0,"unproven ammunition uses no invented display");
}
void actors_and_cleanup(Codec codec){
auto w=world();
auto a=cast(translate(w,event(start,peer,5143,self),codec),0x69002d);
auto b=cast(translate(w,event(start,unit,5143,peer),codec),0x69002d);
check(a.id!=b.id && a.visual==239917 && b.visual==239917,"simultaneous actors and channel cast link");
auto other=cast(translate(w,event(go,peer,7268,unit),codec),0x69002c);
check(other.visual==240768 && w.observed_casts.size()==2,"distinct triggered visual and no unrelated completion");
check(cast(translate(w,event(go,peer,5143,self),codec),0x69002c).id==a.id,"peer correlated");
check(cast(translate(w,event(go,unit,5143,peer),codec),0x69002c).id==b.id,"NPC correlated");
const auto before=w.server_cast_counter;
auto invalid=event(go,peer,5143,unit);invalid.body.push_back(0xff);
check(translate(w,invalid,codec).empty(),"malformed unsolicited packet held");
w.entities.actors[unit].eligible=false;
check(translate(w,event(go,peer,5143,unit),codec).empty(),"unknown visible target held");
check(translate(w,event(start,unit,5143,peer),codec).empty(),"hidden NPC cannot cast");
w.entities.actors[unit].eligible=true;
w.entities.actors[peer].presentation_map=1;
check(translate(w,event(go,peer,5143,self),codec).empty(),"other-map caster held");
w.entities.actors[peer].presentation_map=0;
check(w.server_cast_counter==before,"held source events consumed no identity");
auto prev=cast(translate(w,event(start,peer,5143,self),codec),0x69002d);
++w.entities.actors[peer].generation;
check(cast(translate(w,event(go,peer,5143,self),codec),0x69002c).id!=prev.id,"recreated actor cannot reuse cast");
auto key=std::pair{peer,5143u};
prev=cast(translate(w,event(start,peer,5143,self),codec),0x69002d);
w.observed_casts.at(key).expires=std::chrono::steady_clock::now()-std::chrono::seconds(1);
check(cast(translate(w,event(go,peer,5143,self),codec),0x69002c).id!=prev.id && w.observed_casts.empty(),"expired START is discarded");
cast(translate(w,event(start,peer,5143,self),codec),0x69002d);
const auto awaiting=w.observed_casts.at(key).identity;
const auto independent=cast(translate(w,event(go,peer,5143,unit),codec),0x69002c);
check(independent.id!=awaiting && w.observed_casts.at(key).identity==awaiting,"different explicit target cannot claim prior START");
Bytes fail;le(fail,peer,8);le(fail,5143,4);
{
const auto interrupted=translate(w,{0x2a6,fail},codec);
check(interrupted.size()==1 && interrupted.front().opcode==0x690046,"observed interrupt ends the native cast bar");
Reader fr(interrupted.front().body);const auto caster=guid(fr);check(guid(fr)==awaiting && fr.le(4)==5143,"interrupt keeps START identity");
check(caster==w.bindings().at(peer),"interrupt names the bound caster");
}
check(w.observed_casts.empty(),"source failure clears START");
check(translate(w,{0x2a6,fail},codec).empty(),"no START, no native interrupt");
cast(translate(w,event(start,self,5143,peer),codec),0x69002d);
Bytes destroy;le(destroy,peer,8);
translate(w,{0xaa,destroy},codec);
check(w.observed_casts.empty(),"target destroy clears START");
for(uint32_t i=0;i<256;++i)
check(translate(w,event(start,self,1000+i,self),codec).size()==1,"bounded source START");
check(w.observed_casts.size()==256 && translate(w,event(start,self,1500,self),codec).empty(),"outstanding START bound");
check(cast(translate(w,event(go,self,1500,self),codec),0x69002c).spell==1500,"unmatched GO still stands on its own");
translate(w,{0x4d,{}},codec);
check(w.observed_casts.empty() && !w.self_created,"logout clears START");
}
Bytes button_request(uint32_t spell, const Guid128& cast_id, const Guid128& target, uint32_t visual, uint32_t script_visual=0) {
Bytes out=pack_guid(cast_id);
le(out,0,1);
for (int i=0;i<3;++i) le(out,0,4);
le(out,spell,4);
le(out,visual,4);
le(out,script_visual,4);
le(out,target==Guid128{}?0:2,4);
append(out,pack_guid(target));
append(out,pack_guid(Guid128{}));
append(out,pack_guid(Guid128{}));
le(out,0,2); le(out,0,4); le(out,0,4);
append(out,pack_guid(Guid128{}));
for (int i=0;i<3;++i) le(out,0,4);
le(out,0,1); le(out,0,1);
return out;
}
void clicked_visuals(Codec codec){
auto w=world(10,8);
Guid128 client_cast{};
for(uint32_t spell=51949;spell<=51954;++spell){
const auto link=cast_visual_profile::link(spell);
check(link!=0,"Arcane Rupture rank has a native visual link");
w.spells.insert(spell);
for(const uint32_t script : {0u,730u}){
++client_cast[0];
const auto action=button_request(spell,client_cast,{},0,script);
check(w.gameplay(0x3e0176,action).opcode==0x12e,"Arcane Rupture button reaches source");
w.gameplay_sent(0x3e0176,action);
const auto started=translate(w,event(start,self,spell,0),codec);
check(started.size()==2 && started.front().opcode==0x69002b,"matching client cast is prepared");
const auto a=cast({started.back()},0x69002d,script);
const auto b=cast(translate(w,event(go,self,spell,0),codec),0x69002c,script);
const uint32_t expected=script?0:link;
check(a.visual==expected && b.visual==expected,"both stages keep scripted or use verified default visual");
check(a.id==client_cast && b.id==client_cast,"matching Arcane Rupture cast identities");
}
}
}
void retired_self_melee_victim(Codec codec){
auto w=world(1,5);
const auto player=forever_player_guid(self,w.realm);
const auto first=w.entities.actors.at(unit);
const auto second=w.entities.actors.at(peer).modern;
auto attack=[&](uint64_t victim){
Bytes bytes;le(bytes,self,8);le(bytes,victim,8);
return translate(w,{0x143,bytes},codec);
};
auto stop=[&](uint64_t victim,bool dead=false){
auto bytes=packed(self);append(bytes,packed(victim));le(bytes,dead,4);
return translate(w,{0x144,bytes},codec);
};
auto expect_attack=[&](const std::vector<LegacyPacket>& out,uint32_t opcode,Guid128 target,bool dead=false){
check(out.size()==1 && out[0].opcode==opcode,"owned melee event count and opcode");
Reader r(out[0].body);
check(guid(r)==player && guid(r)==target,"native attack uses the published owner and victim");
if(opcode==0x4d0018)check(r.le(1)==(dead?0x80:0),"native stop preserves the real dead bit");
r.end();
};
auto remove=[&](uint64_t id){
Bytes bytes;le(bytes,id,8);
const auto out=translate(w,{0xaa,bytes},codec);
check(id==self ? !w.entities.self_presentation_ready : !w.bindings().contains(id),
"genuine source destroy retires the published object");
check(std::none_of(out.begin(),out.end(),[](const auto& p){return p.opcode==0x4d0018;}),
"removal alone does not manufacture an attack stop");
};
auto heal=[&]{
constexpr uint32_t spell=2050;
w.spells.insert(spell);
Guid128 id{};id[0]=41;
auto action=button_request(spell,id,player,0);
check(w.gameplay(0x3e0176,action).opcode==0x12e,"Lesser Heal reaches source");
w.gameplay_sent(0x3e0176,action);
auto started=translate(w,event(start,self,spell,self),codec);
check(started.size()==2 && started[0].opcode==0x69002b &&
cast({started[1]},0x69002d).id==id,"ordinary self heal prepares and starts");
auto result=cast(translate(w,event(go,self,spell,self),codec),0x69002c);
check(result.id==id && result.flags==0x40100 && !w.pending_cast,"ordinary self heal completes without combat events");
};
expect_attack(attack(unit),0x4d0017,first.modern);
remove(unit);
auto retired=stop(unit,true);
check(!retired.empty(),"genuine self stop for the previously published retired victim must survive");
expect_attack(retired,0x4d0018,first.modern,true);
check(stop(unit).empty(),"retired identity is consumed by its stop");
heal();
w.entities.actors[unit]=first;
expect_attack(attack(unit),0x4d0017,first.modern);
Bytes out_of_range;le(out_of_range,1,4);le(out_of_range,0,1);le(out_of_range,4,1);
le(out_of_range,1,4);append(out_of_range,packed(unit));
translate(w,{0xa9,out_of_range},codec);
check(!w.bindings().contains(unit),"source out-of-range removes the first target");
expect_attack(attack(peer),0x4d0017,second);
check(stop(unit).empty(),"a retired previous target cannot stop the replacement attack");
w.entities.actors[unit]=first;
check(stop(unit).empty(),"re-entering visibility cannot redirect a late stop");
expect_attack(stop(0),0x4d0018,{});
remove(peer);
check(stop(peer).empty(),"source empty-victim stop also consumes the previous target");
expect_attack(attack(unit),0x4d0017,first.modern);
remove(unit);
remove(self);
check(stop(unit).empty(),"an owned object removal retires its remembered target");
expect_attack(stop(0),0x4d0018,{});
}
void shoot_until_stopped(Codec codec){
for(uint8_t race=1;race<=10;++race){
for(uint8_t cls : {3,5,8,9}){
auto w=world(race,cls);
const uint32_t spell=cls==3?75:5019;
const uint32_t ammo=cls==3?5996:0;
const uint32_t slot=cls==3?24:26;
w.spells.insert(spell);
Guid128 client_cast{};client_cast[0]=0x61;
const auto action=button_request(spell,client_cast,w.entities.actors.at(peer).modern,cast_visual_profile::link(spell));
const auto outgoing=w.gameplay(0x3e0176,action);
check(outgoing.opcode==0x12e,"first click asks source to cast");
w.gameplay_sent(0x3e0176,action);
const auto started=translate(w,event(start,self,spell,peer,true,ammo,slot),codec);
check(started.size()==2 && started[0].opcode==0x69002b && started[1].opcode==0x69002d,"only clicked cast receives prepare");
const auto client_go=cast(translate(w,event(go,self,spell,peer,true,ammo,slot),codec),0x69002c);
check(client_go.id==client_cast && !w.pending_cast,"first shot consumes matching client request");
Guid128 last=client_cast;
for(unsigned shot=0;shot<4;++shot){
const auto a=cast(translate(w,event(start,self,spell,peer,true,ammo,slot),codec),0x69002d);
const auto b=cast(translate(w,event(go,self,spell,peer,true,ammo,slot),codec),0x69002c);
check(a.id==b.id && b.id!=last && b.id!=client_cast,"unique paired authoritative shot identity");
check((b.flags&0x40000)==0 && (b.flags&0x20)!=0,"repeat carries ranged flag");
check(b.spell==spell && b.target==client_go.target && b.ammo==client_go.ammo,"repeat placed on original target");
last=b.id;
}
const auto cancel=w.gameplay(0x3f0084,{});
check(cancel.opcode==0x26d && cancel.body.empty(),"toggle-off asks the source to stop auto-repeat");
const auto stopped=translate(w,{0x29c,{}},codec);
check(stopped.size()==1 && stopped[0].opcode==0x470189 &&
stopped[0].body==pack_guid(forever_player_guid(self,w.realm)),"server stops this character's auto-repeat");
}
}
auto inactive=world();
bool rejected=false;
try{inactive.gameplay(0x3f0084,Bytes{1});}catch(const Error&){rejected=true;}
check(rejected,"auto-repeat cancellation rejects trailing bytes");
inactive.self_created=false;
rejected=false;
try{inactive.gameplay(0x3f0084,{});}catch(const Error&){rejected=true;}
check(rejected,"auto-repeat cancellation requires an in-world character");
}
}
int main(){
try{
auto path=std::getenv("GW_TEST_CODEC_PATH");
if (test_fixture::optional_codec_missing(path)) return 77;
auto* handle=dlopen(path,RTLD_NOW|RTLD_LOCAL);
if(!handle)throw Error(dlerror());
const auto codec=reinterpret_cast<Codec>(dlsym(handle,"gw_codec_serialize"));
check(codec!=nullptr,"codec entry point");
for(uint8_t race:{1,9,10}){
for(uint8_t cls:{5,8,9})repeats(codec,race,cls,5019,0,26);
repeats(codec,race,3,75,5996,24);
}
clicked_visuals(codec);
retired_self_melee_victim(codec);
shoot_until_stopped(codec);
pending_completion(codec);
queued_request_refused(codec);
next_swing_survives_instants(codec);
original_wire(codec);
actors_and_cleanup(codec);
dlclose(handle);
std::cout<<checks<<" observed cast checks passed\n";
}catch(const std::exception& e){std::cerr<<e.what()<<'\n';return 1;}
}