Files
WoW-Hybrid-gateway/tests/quest_log_original_writer.cpp
praxisandClaude Fable 5.2 7f2139d8d0 Offline test fixtures
883 files, from working commit b1a079a.

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

55 lines
2.7 KiB
C++

// SPDX-License-Identifier: GPL-2.0-or-later
// Linked with the exact extracted/pinned QuestLog + narrow PlayerData writers.
#include "gateway/quest_log.hpp"
#include "UpdateFields.h"
#include "ByteBuffer.h"
#include "UpdateFieldImpl.h"
#include "Errors.h"
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <iterator>
#include <string>
// Reuse the established source-codec ByteBuffer adapter; the original writers
// themselves are extracted unchanged, except existing unrelated-branch gating.
void ByteBuffer::append(uint8 const* src, size_t count) {
if (!src || !count || _wpos + count > 1048576) throw ByteBufferPositionException(_wpos,size(),count);
FlushBits();
if (_storage.size() < _wpos + count) _storage.resize(_wpos + count);
std::memcpy(_storage.data() + _wpos,src,count); _wpos += count;
}
void ByteBuffer::put(size_t pos,uint8 const* src,size_t count) {
if (!src || pos > size() || count > size()-pos) throw ByteBufferPositionException(pos,size(),count);
std::memcpy(_storage.data()+pos,src,count);
}
ByteBufferPositionException::ByteBufferPositionException(size_t,size_t,size_t):ByteBufferException("buffer range"){}
ByteBufferInvalidValueException::ByteBufferInvalidValueException(char const*,std::string_view):ByteBufferException("invalid buffer value"){}
namespace Trinity {
[[noreturn]] void Assert(char const*,int,char const*,char const*,std::string) noexcept { std::abort(); }
[[noreturn]] void Assert(char const*,int,char const*,char const*,std::string,char const*,...) noexcept { std::abort(); }
}
std::string GetDebugInfo() { return {}; }
int main(int argc, char** argv) {
if (argc != 2) return 2;
try {
gateway::Bytes input{std::istreambuf_iterator<char>(std::cin),{}};
gateway::Bytes output;
if (std::string(argv[1]) == "--values") output = gateway::serialize_quest_log_update(input);
else if (std::string(argv[1]) == "--array-create") {
auto data = gateway::parse_quest_log_update_input(input);
UF::PlayerData player;
gateway::apply_quest_log_projection(player,data.projection);
ByteBuffer bytes;
for (unsigned i = 0; i < 175; ++i) player.QuestLog[i].WriteCreate(bytes,nullptr,nullptr);
UF::WriteMapFieldCreate(player.QuestLogQuestIdToIndex,bytes,nullptr,static_cast<Player const*>(nullptr));
bytes << uint32(0); // Source has no QuestSessionQuestLog entries.
bytes.FlushBits();
output.assign(bytes.data(),bytes.data()+bytes.size());
} else return 2;
std::cout.write(reinterpret_cast<char const*>(output.data()),output.size());
return 0;
} catch (const gateway::Error&) { return 1; }
}