Metin2 game client (P0–P11) + mobile asset pipeline
Networked client on the existing Godot 4.7 + libgr2 renderer:
- net: m2dev wire protocol (libsodium KX + XChaCha20), auth/select/game
phases, EntityStore world model, ~all GC/CG headers. char create/delete,
private shop / mall / cube, SHOP_GC_START_EX, guild, party (+ CG_PARTY_SET_STATE),
quests, dragon soul, refine, safebox, exchange.
- UI: in-game windows migrated 1:1 from the reference uiscript/root .py —
char status (/stat), inventory+equipment, select-item ([SELECT_ITEM] quest
token), system-option + game-option + ESC system menu, private-shop 39-grid,
party info board, shop tabs, atlas, minimap, quickbar, chat, …
- EterGrnLib polish: GR2 material blend/two-sided, LOD crossfade, motion-event
dispatch, contact shadow, ray-AABB picking, weapon grip pre-transform.
Portable asset IO (A1) — all extension/libgr2/formats/mtproto reads routed
through godot::FileAccess (res:// PCK works on iOS/Android); standalone-lib
*_path() kept for the non-Godot CTests. AssetResolver + PropertyRegistry
switched to a baked index (bake_asset_index.gd) instead of std::filesystem.
Mobile builds: build-{android,ios}.sh, export-android.sh, pack-assets.sh,
gen-debug-keystore.sh. Assets ship as a zip mounted at runtime by
project/asset_pack.gd (adb push now; HTTP download is a drop-in later).
ctest 10/10, 34 GDScript suites, macOS/iOS/Android all build.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013EJxkHiNKS4kybHS3XKyAJ
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
#include "proto_node.h"
|
||||
|
||||
#include "../asset_io.h"
|
||||
|
||||
#include <godot_cpp/core/class_db.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace godot;
|
||||
|
||||
namespace mtgodot {
|
||||
|
||||
void Metin2Proto::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("load_item_proto", "path"), &Metin2Proto::load_item_proto);
|
||||
ClassDB::bind_method(D_METHOD("load_mob_proto", "path"), &Metin2Proto::load_mob_proto);
|
||||
ClassDB::bind_method(D_METHOD("item", "vnum"), &Metin2Proto::item);
|
||||
ClassDB::bind_method(D_METHOD("mob", "vnum"), &Metin2Proto::mob);
|
||||
ClassDB::bind_method(D_METHOD("item_count"), &Metin2Proto::item_count);
|
||||
ClassDB::bind_method(D_METHOD("mob_count"), &Metin2Proto::mob_count);
|
||||
ClassDB::bind_method(D_METHOD("get_last_error"), &Metin2Proto::get_last_error);
|
||||
}
|
||||
|
||||
bool Metin2Proto::load_item_proto(const String &path) {
|
||||
std::string err;
|
||||
PackedByteArray bytes = mtgodot::read_file(path);
|
||||
std::vector<uint8_t> buf(bytes.ptr(), bytes.ptr() + bytes.size());
|
||||
if (!mtproto::load_proto_bytes(buf, mtproto::ITEM_PROTO_KEY, m_item, &err)) {
|
||||
last_error = String(err.c_str());
|
||||
return false;
|
||||
}
|
||||
m_item_ix.clear();
|
||||
m_item_ix.reserve(m_item.elements);
|
||||
for (uint32_t i = 0; i < m_item.elements; ++i) {
|
||||
mtproto::ItemRecord r = mtproto::parse_item(m_item.record(i), m_item.stride);
|
||||
m_item_ix[r.vnum] = i;
|
||||
}
|
||||
last_error = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Metin2Proto::load_mob_proto(const String &path) {
|
||||
std::string err;
|
||||
PackedByteArray bytes = mtgodot::read_file(path);
|
||||
std::vector<uint8_t> buf(bytes.ptr(), bytes.ptr() + bytes.size());
|
||||
if (!mtproto::load_proto_bytes(buf, mtproto::MOB_PROTO_KEY, m_mob, &err)) {
|
||||
last_error = String(err.c_str());
|
||||
return false;
|
||||
}
|
||||
m_mob_ix.clear();
|
||||
m_mob_ix.reserve(m_mob.elements);
|
||||
for (uint32_t i = 0; i < m_mob.elements; ++i) {
|
||||
mtproto::MobRecord r = mtproto::parse_mob(m_mob.record(i), m_mob.stride);
|
||||
m_mob_ix[r.vnum] = i;
|
||||
}
|
||||
last_error = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
Dictionary Metin2Proto::item(int vnum) const {
|
||||
Dictionary d;
|
||||
auto it = m_item_ix.find((uint32_t)vnum);
|
||||
if (it == m_item_ix.end() || m_item.record(it->second) == nullptr) {
|
||||
return d;
|
||||
}
|
||||
mtproto::ItemRecord r = mtproto::parse_item(m_item.record(it->second), m_item.stride);
|
||||
d["vnum"] = (int)r.vnum;
|
||||
d["vnum_range"] = (int)r.vnum_range;
|
||||
d["name"] = String::utf8(r.name.c_str());
|
||||
d["locale_name"] = String::utf8(r.locale_name.c_str());
|
||||
d["type"] = (int)r.type;
|
||||
d["sub_type"] = (int)r.sub_type;
|
||||
d["weight"] = (int)r.weight;
|
||||
d["size"] = (int)r.size;
|
||||
d["wear_flags"] = (int)r.wear_flags;
|
||||
d["buy_price"] = (int)r.buy_price;
|
||||
d["sell_price"] = (int)r.sell_price;
|
||||
{
|
||||
Array vals;
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
vals.push_back((int)r.values[i]);
|
||||
}
|
||||
d["values"] = vals; // armor: values[3] = body shape index for the race .msm
|
||||
}
|
||||
d["specular"] = (int)r.specular;
|
||||
return d;
|
||||
}
|
||||
|
||||
Dictionary Metin2Proto::mob(int vnum) const {
|
||||
Dictionary d;
|
||||
auto it = m_mob_ix.find((uint32_t)vnum);
|
||||
if (it == m_mob_ix.end() || m_mob.record(it->second) == nullptr) {
|
||||
return d;
|
||||
}
|
||||
mtproto::MobRecord r = mtproto::parse_mob(m_mob.record(it->second), m_mob.stride);
|
||||
d["vnum"] = (int)r.vnum;
|
||||
d["name"] = String::utf8(r.name.c_str());
|
||||
d["locale_name"] = String::utf8(r.locale_name.c_str());
|
||||
d["type"] = (int)r.type;
|
||||
d["rank"] = (int)r.rank;
|
||||
d["battle_type"] = (int)r.battle_type;
|
||||
d["level"] = (int)r.level;
|
||||
d["size"] = (int)r.size;
|
||||
return d;
|
||||
}
|
||||
|
||||
} // namespace mtgodot
|
||||
Reference in New Issue
Block a user