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,60 @@
|
||||
#include "m2_coord.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
|
||||
namespace fmt::m2coord {
|
||||
|
||||
std::string tile_dir(int tile_x, int tile_y) {
|
||||
char buf[16];
|
||||
std::snprintf(buf, sizeof(buf), "%06u", tile_id(tile_x, tile_y));
|
||||
return buf;
|
||||
}
|
||||
|
||||
namespace {
|
||||
Mat3 mul(const Mat3& a, const Mat3& b) {
|
||||
Mat3 r{};
|
||||
for (int i = 0; i < 3; ++i)
|
||||
for (int j = 0; j < 3; ++j)
|
||||
for (int k = 0; k < 3; ++k)
|
||||
r.m[i * 3 + j] += a.m[i * 3 + k] * b.m[k * 3 + j];
|
||||
return r;
|
||||
}
|
||||
Mat3 rot_x(double a) {
|
||||
double c = std::cos(a), s = std::sin(a);
|
||||
return {{1, 0, 0, 0, c, -s, 0, s, c}};
|
||||
}
|
||||
Mat3 rot_y(double a) {
|
||||
double c = std::cos(a), s = std::sin(a);
|
||||
return {{c, 0, s, 0, 1, 0, -s, 0, c}};
|
||||
}
|
||||
Mat3 rot_z(double a) {
|
||||
double c = std::cos(a), s = std::sin(a);
|
||||
return {{c, -s, 0, s, c, 0, 0, 0, 1}};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Mat3 ypr_basis(double yaw_deg, double pitch_deg, double roll_deg) {
|
||||
const double d2r = 3.14159265358979323846 / 180.0;
|
||||
return mul(mul(rot_y(yaw_deg * d2r), rot_x(pitch_deg * d2r)), rot_z(roll_deg * d2r));
|
||||
}
|
||||
|
||||
Mat3 object_basis_godot(double yaw_deg, double pitch_deg, double roll_deg) {
|
||||
// Conjugate the Metin2-space rotation through the Z-up -> Y-up axis swap
|
||||
// C = rotate(-90deg, X): (x,y,z) -> (x,z,-y). R_godot = C * R_m2 * C^-1
|
||||
const Mat3 C{{1, 0, 0, 0, 0, 1, 0, -1, 0}};
|
||||
const Mat3 Ci{{1, 0, 0, 0, 0, -1, 0, 1, 0}};
|
||||
return mul(mul(C, ypr_basis(yaw_deg, pitch_deg, roll_deg)), Ci);
|
||||
}
|
||||
|
||||
bool parse_tile_dir(const std::string& name, int& tile_x, int& tile_y) {
|
||||
if (name.size() != 6) return false;
|
||||
for (char c : name)
|
||||
if (c < '0' || c > '9') return false;
|
||||
long id = std::strtol(name.c_str(), nullptr, 10);
|
||||
tile_x = int(id / 1000);
|
||||
tile_y = int(id % 1000);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace fmt::m2coord
|
||||
Reference in New Issue
Block a user