127 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
44 lines
2.0 KiB
C++
44 lines
2.0 KiB
C++
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
#pragma once
|
|
#include "gateway/protocol.hpp"
|
|
#include <array>
|
|
#include <limits>
|
|
|
|
namespace gateway {
|
|
// Byte layout of the pinned Trinity QuestPOIQueryResponse writer. This pure
|
|
// serializer does not assert that a blob is valid for a quest, that a region
|
|
// represents an objective, or that the native client consumes this format.
|
|
struct QuestPoiPoint { int32_t x=0,y=0,z=0; };
|
|
struct QuestPoiBlob {
|
|
// BlobIndex, ObjectiveIndex, QuestObjectiveID, QuestObjectID, MapID,
|
|
// UiMapID, Priority, Flags, WorldEffectID, PlayerConditionID,
|
|
// NavigationPlayerConditionID, SpawnTrackingID, in that order.
|
|
std::array<int32_t,12> fields{};
|
|
std::vector<QuestPoiPoint> points;
|
|
bool merge=false;
|
|
};
|
|
struct QuestPoiRecord { int32_t quest=0;std::vector<QuestPoiBlob> blobs; };
|
|
inline Bytes serialize_quest_poi_response(std::span<const QuestPoiRecord> records){
|
|
if(records.size()>175)throw Error("Quest POI response quest bound");
|
|
Bytes out;le(out,records.size(),4);le(out,records.size(),4);
|
|
auto write_point=[&](int32_t value){
|
|
if(value<std::numeric_limits<int16_t>::min() || value>std::numeric_limits<int16_t>::max())
|
|
throw Error("Quest POI point outside int16 range");
|
|
le(out,uint16_t(int16_t(value)),2);
|
|
};
|
|
for(const auto& record:records){
|
|
if(record.blobs.size()>128)throw Error("Quest POI response blob bound");
|
|
le(out,uint32_t(record.quest),4);le(out,record.blobs.size(),4);
|
|
for(const auto& blob:record.blobs){
|
|
if(blob.points.size()>4096)throw Error("Quest POI response point bound");
|
|
for(auto value:blob.fields)le(out,uint32_t(value),4);
|
|
le(out,blob.points.size(),4);
|
|
for(const auto& p:blob.points){write_point(p.x);write_point(p.y);write_point(p.z);}
|
|
le(out,blob.merge?0x80:0,1); // Original ByteBuffer writes the first bit MSB-first.
|
|
if(out.size()>1024*1024)throw Error("Quest POI response byte bound");
|
|
}
|
|
}
|
|
return out;
|
|
}
|
|
}
|