127 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
32 lines
1.3 KiB
C++
32 lines
1.3 KiB
C++
#pragma once
|
|
#include "gateway/object_updates.hpp"
|
|
#include <algorithm>
|
|
#include <cmath>
|
|
namespace gateway {
|
|
// Pinned Tortoise QueryHandler::HandleCorpseQueryOpcode. A location is not a
|
|
// corpse object identity and must never be used to fabricate a reclaim GUID.
|
|
struct TurtleCorpseLocation {
|
|
bool valid=false;
|
|
uint32_t map=0,actual_map=0;
|
|
std::array<float,3> position{};
|
|
};
|
|
inline TurtleCorpseLocation turtle_corpse_location(std::span<const uint8_t> body) {
|
|
Reader r(body);auto valid=r.le(1);if(valid>1)throw Error("invalid source corpse presence");
|
|
TurtleCorpseLocation result;result.valid=valid;
|
|
if(valid){
|
|
result.map=uint32_t(r.le(4));
|
|
for(auto& v:result.position){v=r.f32();if(!std::isfinite(v))throw Error("nonfinite corpse location");}
|
|
result.actual_map=uint32_t(r.le(4));
|
|
}
|
|
r.end();return result;
|
|
}
|
|
inline Guid128 forever_corpse_guid(uint64_t source,uint16_t realm,uint32_t map) {
|
|
// Source HIGHGUID_CORPSE f101 uses a32-bit counter, not a creature entry.
|
|
if((source>>32)!=0xf1010000ULL || !uint32_t(source) || realm>8191 || map>8191)
|
|
throw Error("unsupported source corpse identity");
|
|
Bytes raw;le(raw,uint32_t(source),8);
|
|
le(raw,(uint64_t(14)<<58)|(uint64_t(realm)<<42)|(uint64_t(map)<<29),8);
|
|
Guid128 result{};std::copy(raw.begin(),raw.end(),result.begin());return result;
|
|
}
|
|
}
|