Files

67 lines
3.4 KiB
C++

#pragma once
#include "gateway/queries.hpp"
#include "gateway/object_updates.hpp"
#include <functional>
#include <optional>
namespace gateway {
// Exact classic query reply; retain every source word even when native
// presentation is held. The fifth source string has no proved native role.
struct GameObjectTemplateReply {
uint32_t entry=0,type=0,display=0;
bool found=false;
std::array<std::string,4> names{};
std::string extra_name;
std::array<uint32_t,24> data{};
};
struct GameObjectQuery {uint32_t entry=0;Guid128 guid{};};
GameObjectQuery forever_gameobject_query(std::span<const uint8_t>);
Bytes turtle_gameobject_query(uint32_t entry,uint64_t source_guid);
GameObjectTemplateReply turtle_gameobject_template(std::span<const uint8_t>);
// An explicit resolver supplies reviewed source->native reference identity.
// There is deliberately no raw/same-number fallback for nonzero references.
enum class GameObjectTemplateReference {
Lock,ChestLoot,GameEvent,GameObject,Quest,BroadcastText,PageText,Language,
PageMaterial,Spell,Gossip,Area,SpellFocusObject
};
using GameObjectReferenceResolver=std::function<std::optional<uint32_t>(GameObjectTemplateReference,uint32_t)>;
struct GameObjectTemplateBinding {
uint64_t source_guid=0,request_generation=0,current_generation=0;
uint32_t entry=0,map=0;
uint16_t realm=0;
Guid128 native_guid{};
// Neither base template size nor display namespace closure comes from
// the classic query reply. The caller must supply authoritative proof.
std::optional<float> template_size;
std::optional<uint32_t> native_display_id;
GameObjectReferenceResolver references;
};
enum class GameObjectTemplateHold {
Binding,UnsupportedType,DisplayClosure,TemplateSize,ExtraString,
ReferenceClosure,UnmappedChestField,RestockRange,MissingName,UnmappedMailboxField,
UnmappedTypeField,ScalarRange,MetadataAuthority
};
// An immutable local-template snapshot is separate from a live query reply:
// Size is absent from that wire. A caller may use it only in its explicit
// Source endpoint scope and after matching the received template body.
struct GameObjectTemplateAuthority {
uint32_t entry=0,type=0,source_display=0,native_display=0;
std::array<uint32_t,24> source_data{};
std::string source_name,provenance;
float template_size=0;
GameObjectReferenceResolver references;
};
bool gameobject_template_authority_matches(const GameObjectTemplateReply&,const GameObjectTemplateAuthority&);
// #96: Turtle hardcore graves ("Grave of <name> (level N)") are created per dead character at runtime, so no static
// template table lists them. Only that exact shape is admitted: type 2, a client display, all data words zero.
std::optional<GameObjectTemplateAuthority> turtle_hardcore_grave_authority(const GameObjectTemplateReply&,bool display_known);
struct GameObjectTemplateIssue {GameObjectTemplateHold reason;int source_field=-1;};
struct GameObjectTemplatePacket {uint32_t opcode=0;Bytes body;};
struct GameObjectTemplateProjection {
std::optional<GameObjectTemplatePacket> packet;
std::vector<GameObjectTemplateIssue> held;
};
// Complete QueryGameObjectResponse container, not an unsolicited actor/create.
// Its caller owns actual query admission, source reply correlation and lifetime.
GameObjectTemplateProjection forever_gameobject_template(const GameObjectTemplateReply&,const GameObjectTemplateBinding&);
}