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
44 lines
2.1 KiB
C++
44 lines
2.1 KiB
C++
// Metin2 地图文本格式的通用解析 —— 对标原客户端 EterBase `LoadMultipleTextData` +
|
||
// `CTokenVectorMap`(`GameLib/Area.cpp`、`PRTerrainLib/TextureSet.cpp` 都用它)。
|
||
//
|
||
// 语义:
|
||
// - 以空白分隔 token;`"..."` 为单 token;`#` 或 `//` 到行尾是注释。
|
||
// - 顶层行 `key v1 v2 ...` -> map[lower(key)] = [v1, v2, ...]
|
||
// - `Start <Name>` ... `End [<Name>]` -> map[lower(Name)] = [块内所有 token 展平]
|
||
// - 重复 key:保留第一个,`dup_count` 记录冲突数(W0 报告用)。
|
||
//
|
||
// 无 godot 依赖,纯 C++20,走 CTest。SHINSOO §9-W0 / §5。
|
||
#pragma once
|
||
#include <map>
|
||
#include <string>
|
||
#include <vector>
|
||
|
||
namespace fmt {
|
||
|
||
struct TokVecMap {
|
||
std::map<std::string, std::vector<std::string>> m;
|
||
int dup_count = 0; // 重复 key 次数
|
||
std::vector<std::string> dup_keys; // 重复的 key 名(去重后)
|
||
|
||
bool has(const std::string& key) const; // key 已小写
|
||
const std::vector<std::string>* find(const std::string& key) const;
|
||
// 便捷取值(key 传入时大小写不敏感)
|
||
std::string str(const std::string& key, const std::string& def = "") const;
|
||
long inum(const std::string& key, long def = 0) const;
|
||
double num(const std::string& key, double def = 0) const;
|
||
};
|
||
|
||
// 解析整段文本。语法层面不会失败(宽容解析);err 仅在明显结构错误时写。
|
||
bool parse_tokvec(const std::string& text, TokVecMap& out, std::string* err);
|
||
bool parse_tokvec_file(const std::string& path, TokVecMap& out, std::string* err);
|
||
|
||
// 小工具:整文件读入字符串。失败返回 false。
|
||
// Whole-file read used by every fmt loader. By default std::ifstream; the host
|
||
// app can install a reader that pulls from res:// (Godot PCK on iOS/Android) via
|
||
// set_file_reader(). The standalone CTests leave it unset -> plain ifstream.
|
||
using FileReader = bool (*)(const std::string& path, std::string& out);
|
||
void set_file_reader(FileReader r); // nullptr resets to the ifstream default
|
||
bool read_file(const std::string& path, std::string& out);
|
||
|
||
} // namespace fmt
|