implement item translation table

This commit is contained in:
Martin Michelsen
2025-02-20 21:32:12 -08:00
parent 813bd2e0fa
commit d9744a696e
8 changed files with 1293 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
#pragma once
#include <stdint.h>
#include <array>
#include <memory>
#include <phosg/JSON.hh>
#include <string>
#include <unordered_map>
#include "ItemParameterTable.hh"
#include "Types.hh"
#include "Version.hh"
class ItemTranslationTable {
public:
ItemTranslationTable(
const phosg::JSON& json,
const std::array<std::shared_ptr<const ItemParameterTable>, NUM_VERSIONS>& item_parameter_tables);
~ItemTranslationTable() = default;
phosg::JSON json() const;
uint32_t translate(uint32_t primary_identifier, Version from_version, Version to_version) const;
private:
struct Entry {
std::array<uint32_t, NUM_NON_PATCH_VERSIONS> id_for_version;
std::string name;
explicit Entry(const phosg::JSON& json);
phosg::JSON json() const;
};
std::vector<Entry> entries;
std::array<std::unordered_map<uint32_t, size_t>, NUM_NON_PATCH_VERSIONS> entry_index_for_version;
};