Files
praxisandClaude Fable 5.2 8e02dccb86 In-client stack: transport, session lifecycle and engine bridge
175 files, from working commit b1a079a.

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

30 lines
1.3 KiB
C++

#pragma once
#include "world_translation.hpp"
#include <algorithm>
#include <span>
namespace gateway::native {
// Called under the transport registry lock. The authenticated roster selection
// was committed only after encoding genuine PLAYER_LOGIN; initial readiness is
// set by the parsed Source 0x12a handler. Self creation is deliberately irrelevant.
inline int copy_initial_spell_ids(bool authenticated,bool roster_seen,
std::span<const Character> roster,const NativeWorldTranslation* world,
uint8_t* output,uint32_t capacity,uint32_t* required) {
if(required)*required=0;
if(!required || (!output && capacity) || capacity>GW_CODEC_BOUND ||
!authenticated || !roster_seen || !world || world->logout_complete ||
!world->talent_spells_ready || !world->selected.guid ||
world->spells.size()>4096)return -1;
const auto guid=world->selected.guid;
if(std::none_of(roster.begin(),roster.end(),[guid](const auto& c){return c.guid==guid;}))return -1;
*required=12u+4u*uint32_t(world->spells.size());
if(capacity<*required)return -3;
auto put=[&output](uint64_t value,unsigned width){
for(unsigned i=0;i<width;++i)*output++=uint8_t(value>>(8*i));
};
put(guid,8);put(world->spells.size(),4);
for(auto spell:world->spells)put(spell,4);
return 0;
}
}