rodecomp/Source/Utility/Lexicon/LexiconSerializer.h
ragnarok-clanker 54c2ba6f52 Confirm fn_17632 (LexiconBoundary::Load)
Batch #15986 by Yommy: 0 byte-identical, 1 confirmed by peer review.

- fn_17632 LexiconBoundary::Load: logic confirmed by peer review (already on main)

Peer-reviewed-by: alisonrag, youko
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
2026-11-10 14:18:12 +00:00

54 lines
1.5 KiB
C++

#ifndef RAGNAROK_SOURCE_UTILITY_LEXICON_LEXICONSERIALIZER_H
#define RAGNAROK_SOURCE_UTILITY_LEXICON_LEXICONSERIALIZER_H
#include <cstdint>
struct LexiconNode {
/* 0000 */ unsigned char value;
/* 0001 */ unsigned char terminal;
/* 0002 */ unsigned char unknown_0002[2];
/* 0004 */ LexiconNode* sibling;
/* 0008 */ LexiconNode* child;
};
struct LexiconHeader {
/* 0000 */ unsigned char unknown_0000[0x104];
/* 0104 */ std::uint32_t wordCount;
/* 0108 */ std::uint32_t nodeCount;
/* 010C */ std::uint32_t total;
/* 0110 */ std::uint32_t size;
/* 0114 */ unsigned char loaded;
};
struct LexiconSerializer {
// INLINED
LexiconSerializer() : root(nullptr), wordCount(0), nodeCount(0), serializedSize(0), buffer(nullptr), header{} {
}
// INLINED
~LexiconSerializer() {
if (this->buffer != nullptr) {
delete this->buffer;
}
this->Destroy(this->root);
}
/* 0000 */ LexiconNode* root;
/* 0004 */ int wordCount;
/* 0008 */ int nodeCount;
/* 000C */ std::uint32_t serializedSize;
/* 0010 */ unsigned char* buffer;
/* 0014 */ LexiconHeader header;
bool Load(const char* path);
bool Insert(const unsigned char* word, int length);
void Destroy(LexiconNode* node);
std::uint32_t Serialize(LexiconNode* node, std::uint32_t offset, unsigned char terminal);
};
#if defined(_WIN32) && !defined(_WIN64)
static_assert(sizeof(LexiconNode) == 12);
static_assert(sizeof(LexiconHeader) == 0x118);
static_assert(sizeof(LexiconSerializer) == 300);
#endif
#endif