Initialize shared Metin2 SDK with rendering optimizations and tests

This commit is contained in:
shen
2026-10-11 17:52:55 -07:00
commit 86759bb726
147 changed files with 27272 additions and 0 deletions
+66
View File
@@ -0,0 +1,66 @@
#pragma once
#include <cstdint>
#include <string>
#include <vector>
#include <unordered_map>
#include <array>
#include <utility>
#include <span>
#include <filesystem>
#include "eterpack/types.h"
namespace proto {
struct ItemProtoRecord {
uint32_t vnum = 0;
uint32_t range = 0; // vnum range for grouped items
std::string name;
std::string locale_name;
uint8_t type = 0;
uint8_t subtype = 0;
uint8_t weight = 0;
uint8_t size = 1;
uint32_t anti_flags = 0;
uint32_t flags = 0;
uint32_t wear_flags = 0;
uint32_t immune_flags = 0;
uint32_t buy_price = 0;
uint32_t sell_price = 0;
std::array<std::pair<uint8_t, int32_t>, 2> limits{};
std::array<std::pair<uint8_t, int32_t>, 3> applies{};
std::array<int32_t, 6> values{};
std::array<int32_t, 8> sockets{};
uint32_t refined_vnum = 0;
uint16_t refine_set = 0;
uint8_t alter_to_magic_percent = 0;
uint8_t specular = 0;
uint8_t gain_socket_percent = 0;
};
class ItemProto {
public:
ItemProto() = default;
bool load(std::span<const uint8_t> data, const uint32_t key[4] = eterpack::DEFAULT_ITEM_PROTO_KEY);
bool load_file(const std::filesystem::path& filepath, const uint32_t key[4] = eterpack::DEFAULT_ITEM_PROTO_KEY);
const ItemProtoRecord* find(uint32_t vnum) const;
const std::vector<ItemProtoRecord>& get_records() const { return m_records; }
size_t size() const { return m_records.size(); }
bool empty() const { return m_records.empty(); }
void clear();
private:
std::vector<ItemProtoRecord> m_records;
std::unordered_map<uint32_t, size_t> m_vnum_map;
std::vector<size_t> m_ranged_indices;
};
} // namespace proto
+99
View File
@@ -0,0 +1,99 @@
#pragma once
#include <cstdint>
#include <string>
#include <vector>
#include <unordered_map>
#include <array>
#include <span>
#include <filesystem>
#include "eterpack/types.h"
namespace proto {
struct MobSkillLevel {
uint32_t vnum = 0;
uint8_t level = 0;
};
struct MobRecord {
uint32_t vnum = 0;
std::string name;
std::string locale_name;
uint8_t type = 0;
uint8_t rank = 0;
uint8_t battle_type = 0;
uint8_t level = 1;
uint8_t size = 0;
uint32_t gold_min = 0;
uint32_t gold_max = 0;
uint32_t exp = 0;
uint32_t max_hp = 0;
uint8_t regen_cycle = 0;
uint8_t regen_percent = 0;
uint16_t def = 0;
uint32_t ai_flag = 0;
uint32_t race_flag = 0;
uint32_t immune_flag = 0;
uint8_t str = 0;
uint8_t dex = 0;
uint8_t con = 0;
uint8_t intel = 0;
uint32_t damage_min = 0;
uint32_t damage_max = 0;
int16_t attack_speed = 0;
int16_t moving_speed = 0;
uint8_t aggressive_hp_pct = 0;
uint16_t aggressive_sight = 0;
uint16_t attack_range = 0;
std::array<int8_t, 6> enchants{};
std::array<int8_t, 11> resists{};
uint32_t resurrection_vnum = 0;
uint32_t drop_item_vnum = 0;
uint8_t mount_capacity = 0;
uint8_t on_click_type = 0;
uint8_t empire = 0;
std::string folder;
float damage_multiply = 1.0f;
uint32_t summon_vnum = 0;
uint32_t drain_sp = 0;
uint32_t monster_color = 0;
uint32_t polymorph_item_vnum = 0;
std::array<MobSkillLevel, 5> skills{};
uint8_t berserk_point = 0;
uint8_t stone_skin_point = 0;
uint8_t god_speed_point = 0;
uint8_t death_blow_point = 0;
uint8_t revive_point = 0;
};
class MobProto {
public:
MobProto() = default;
bool load(std::span<const uint8_t> data, const uint32_t key[4] = eterpack::DEFAULT_MOB_PROTO_KEY);
bool load_file(const std::filesystem::path& filepath, const uint32_t key[4] = eterpack::DEFAULT_MOB_PROTO_KEY);
const MobRecord* find(uint32_t vnum) const;
const std::vector<MobRecord>& get_records() const { return m_records; }
size_t size() const { return m_records.size(); }
bool empty() const { return m_records.empty(); }
void clear();
private:
std::vector<MobRecord> m_records;
std::unordered_map<uint32_t, size_t> m_vnum_map;
};
} // namespace proto
+4
View File
@@ -0,0 +1,4 @@
#pragma once
#include "proto/item_proto.h"
#include "proto/mob_proto.h"