Files
praxisandClaude Fable 5.2 c2194c59d4 Protocol core: packet translation between source and native
127 files, from working commit b1a079a.

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

35 lines
1.6 KiB
C++

#pragma once
#include "gateway/protocol.hpp"
#include "gateway/turtle_entity_profile.hpp"
#include <array>
#include <map>
namespace gateway {
inline constexpr unsigned SourceExploredZoneWords =
turtle_entity_fields::PLAYER_EXPLORED_ZONES_END-turtle_entity_fields::PLAYER_EXPLORED_ZONES_1+1;
static_assert(SourceExploredZoneWords==64);
inline bool source_explored_zone_field(unsigned field){
return field>=turtle_entity_fields::PLAYER_EXPLORED_ZONES_1 &&
field<=turtle_entity_fields::PLAYER_EXPLORED_ZONES_END;
}
inline std::array<uint64_t,32> source_explored_zone_pairs(const std::map<uint16_t,uint32_t>& fields,bool create){
std::array<uint64_t,32> result{};
for(unsigned i=0;i<SourceExploredZoneWords;++i){
auto word=fields.find(turtle_entity_fields::PLAYER_EXPLORED_ZONES_1+i);
if(word==fields.end()){
if(!create)throw Error("explored-zone update requires cached complete Source bitmap");
continue; // Absent full-create fields are known zeros.
}
result[i/2]|=uint64_t(word->second)<<(32*(i%2));
}
return result;
}
inline Bytes forever_exploration_experience(std::span<const uint8_t> body){
Reader r(body);auto area=r.le(4),experience=r.le(4);r.end();
if(area>0x7fffffff || experience>0x7fffffff)throw Error("native exploration experience bound");
// Both Source and native Write serialize area,XP. The native constructor
// takes XP,area instead; its argument order is not the wire order.
// This notification grants no map bits.
Bytes result;le(result,area,4);le(result,experience,4);return result;
}
}