Files
WoW-Hybrid-gateway/tests/consecration_cast_fixture.hpp
2026-11-23 03:28:32 +02:00

56 lines
2.4 KiB
C++

#pragma once
#include "gateway/roster_translation.hpp"
namespace consecration_fixture {
constexpr uint32_t spell = 26573;
constexpr uint32_t visual = 251002;
inline gateway::Bytes request(const gateway::Guid128& cast) {
using namespace gateway;
Bytes body = pack_guid(cast);
le(body, 0, 1); // Cast flags.
for (int i=0; i<3; ++i) le(body,0,4); // Misc values.
le(body,spell,4); le(body,visual,4); le(body,0,4);
le(body,0,4); // No explicit target or cursor location.
for (int i=0; i<3; ++i) append(body,pack_guid(Guid128{}));
le(body,0,2); // Target presence bits.
le(body,0,4); le(body,0,4); // Trajectory.
append(body,pack_guid(Guid128{})); // Crafting NPC.
for (int i=0; i<3; ++i) le(body,0,4);
le(body,0,2); // Craft flags and optional tail.
return body;
}
inline bool matches_response(const gateway::Bytes& bundle, const gateway::Guid128& cast, bool start, float x) {
using namespace gateway;
Reader packets(bundle);
const auto count = packets.le(4);
bool prepared=false, matched=false;
const Bytes expected(cast.begin(),cast.end());
for (unsigned i=0; i<count; ++i) {
auto op=packets.le(4);
auto payload=packets.take(packets.le(4));
Reader r(payload);
if (op == 0x69002b) {
if (!start || unpack_guid(r,16)!=expected || unpack_guid(r,16)!=expected) return false;
r.end(); prepared=true;
} else if (op == (start ? 0x69002d : 0x69002c)) {
if (start && !prepared) return false;
const auto self=forever_player_guid(42,70);
const Bytes owner(self.begin(),self.end());
if (unpack_guid(r,16)!=owner || unpack_guid(r,16)!=owner || unpack_guid(r,16)!=expected) return false;
unpack_guid(r,16);
if (r.le(4)!=spell) return false;
r.take(24); // Spell visuals, cast flags and time.
if (r.le(4)!=(start?0u:0x40u)) return false;
for (int i=0; i<3; ++i) if (unpack_guid(r,16)!=Bytes(16)) return false;
if (r.le(1)!=(start?0u:0x20u) || r.le(1)!=0) return false;
if (!start && (unpack_guid(r,16)!=Bytes(16) || r.f32()!=x || r.f32()!=-2 || r.f32()!=3.5f)) return false;
matched=true;
}
}
packets.end();
return matched;
}
}