127 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
76 lines
3.0 KiB
C++
76 lines
3.0 KiB
C++
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
#pragma once
|
|
#include "gateway/protocol.hpp"
|
|
#include <array>
|
|
#include <map>
|
|
#include <vector>
|
|
|
|
namespace UF { struct PlayerData; }
|
|
|
|
namespace gateway {
|
|
// Pinned Tortoise UpdateFields.h: PLAYER_QUEST_LOG_1_1..LAST_3, twenty triples.
|
|
// This projects the existing layout; it does not enlarge the Source quest log.
|
|
inline constexpr uint16_t SourceQuestLogFirstField = 198;
|
|
inline constexpr unsigned SourceQuestLogSlots = 20;
|
|
inline constexpr unsigned SourceQuestLogWordsPerSlot = 3;
|
|
inline constexpr unsigned NativeQuestLogSlots = 175;
|
|
inline constexpr unsigned NativeQuestLogObjectives = 24;
|
|
inline constexpr bool source_quest_log_field(unsigned field) noexcept {
|
|
return field >= SourceQuestLogFirstField &&
|
|
field < SourceQuestLogFirstField + SourceQuestLogSlots * SourceQuestLogWordsPerSlot;
|
|
}
|
|
|
|
struct QuestLogSlot {
|
|
uint8_t slot = 0;
|
|
uint32_t quest_id = 0;
|
|
uint16_t state_flags = 0;
|
|
uint32_t end_time = 0; // absolute Unix seconds, widened to native int64 without scaling
|
|
std::array<uint8_t, 4> counters{};
|
|
// Genuine Source inventory counts, mapped to native objective slots4..7.
|
|
std::array<uint16_t, 4> item_counters{};
|
|
auto operator<=>(const QuestLogSlot&) const = default;
|
|
};
|
|
struct QuestLogIndex {
|
|
uint32_t quest_id = 0;
|
|
uint8_t slot = 0;
|
|
auto operator<=>(const QuestLogIndex&) const = default;
|
|
};
|
|
struct QuestLogProjection {
|
|
std::vector<QuestLogSlot> slots;
|
|
std::vector<QuestLogIndex> erased_indices, indices;
|
|
bool source_create = false;
|
|
bool waiting_for_create = false;
|
|
uint32_t unmapped_state_bits = 0;
|
|
bool empty() const noexcept { return slots.empty() && erased_indices.empty() && indices.empty(); }
|
|
};
|
|
|
|
// Actor-generation-owned state. A Source create establishes absent words as zero.
|
|
// Sparse updates preserve the other words in their slot and every untouched slot.
|
|
class SourceQuestLogState {
|
|
public:
|
|
void clear() noexcept;
|
|
bool initialized() const noexcept { return initialized_; }
|
|
QuestLogProjection observe(const std::map<uint16_t, uint32_t>& fields, bool create);
|
|
std::vector<uint32_t> active_quests() const;
|
|
QuestLogProjection set_item_counts(const std::map<uint32_t, std::array<uint16_t, 4>>&);
|
|
private:
|
|
std::array<std::array<uint32_t, 3>, SourceQuestLogSlots> words_{};
|
|
bool initialized_ = false;
|
|
std::map<uint32_t, std::array<uint16_t, 4>> item_counts_;
|
|
};
|
|
|
|
QuestLogProjection source_quest_log_create(const std::map<uint16_t, uint32_t>& fields);
|
|
Bytes quest_log_update_input(uint16_t realm, uint32_t map, uint64_t self, const QuestLogProjection&);
|
|
struct QuestLogWireUpdate {
|
|
uint16_t realm = 0;
|
|
uint32_t map = 0;
|
|
uint64_t self = 0;
|
|
QuestLogProjection projection;
|
|
};
|
|
QuestLogWireUpdate parse_quest_log_update_input(std::span<const uint8_t>);
|
|
|
|
// Trinity-facing implementation is compiled with the existing source-writer codec.
|
|
void apply_quest_log_projection(UF::PlayerData&, const QuestLogProjection&);
|
|
Bytes serialize_quest_log_update(std::span<const uint8_t>);
|
|
}
|