CPython opens the stdlib zip with its own stdio, so it needs a real path.
On the desktop res:// is a directory and globalize_path() is enough; in an
exported build res:// is inside the PCK, which nothing outside Godot reads.
make_stdlib_zip.py now also writes <out>.sha256
mtpython_stdlib_project copies python27.zip + .sha256 into project/
(gitignored), and both export presets' include_filter lists them, so
they enter the PCK — checked with --export-pack
extension/src/python_stdlib.{h,cpp} (Metin2Python.stdlib_path in
GDScript): reads the bytes out of the PCK, writes
user://python27.zip.part, hashes the file as written against the
shipped digest, then renames. A sandbox copy is reused only when it
matches, so a first start killed mid-copy and a zip replaced by a new
build both re-stage instead of feeding zipimport a torn file.
PythonHost::SetDefaultStdLibPath / DefaultStdLibPath() answer with that
path ($MT_PYTHON_STDLIB still wins). python_stdlib.cpp is the only unit
that knows res:// / user://; port_platform stays godot-free.
Also fixes the Windows gate, which step 3b broke: without mtpython the
MinGW build compiled UserInterface/StdAfx.h (it includes ScriptLib/StdAfx.h,
as the original PCH does). port/CMakeLists.txt excludes that header and
PythonPackModule.cpp with ScriptLib, and platform/CMakeLists.txt excludes
platform/ScriptLib/ the same way.
Not done: on-device staging. The macOS test drives the mobile path with
force_stage=true, and nothing in the app boot calls it yet — the
interpreter only starts in the process with 2V0.
gates: python_stdlib_test.gd PASS (in-place path, staging, sha256, bytes
equal res://, no .part, ZIPReader finds encodings/__init__.py, no re-copy
on a second call, corrupted copy re-staged) · macOS ctest 27/27 ·
mingw + android + ios port_platform compile clean · port_map.py check 0
errors · key leak check 8/8 none.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
step 3a — 标准库:
tools/py_embed/make_stdlib_zip.py packs the vendored Lib/ into
<build>/python27.zip (397 modules, 6876547 bytes, ZIP_STORED — the zlib
module is trimmed out of our CPython, so zipimport cannot inflate).
The mtpython_stdlib target builds it; py_embed_test and the launcher test
both run against it.
platform/ScriptLib/PythonHost sets the embedding flags before
Py_Initialize and, after it, puts the zip on sys.path and re-registers
encodings.search_function with codecs — 2.7 builds the codec registry
once, at startup, so replacing sys.path afterwards needs it back.
step 3b — pack 模块:
UserInterface/PythonPackModule.cpp copied verbatim; packExist/packGet/
initpack read root/ and uiscript/ through CEterPackManager, i.e. through
asset_io. The CHINA_CRYPT_KEY block in that unit is CAccountConnector's
and is kept #if 0 until the login slice (2V1). UserInterface/StdAfx.h is
a documented partial mirror — the original is the whole client's PCH.
The launcher test now runs initpack() as RunMainScript does (its first
line), reads system.py / uiscript / locale text back out of the packs, and
confirms cp1252 decoding works off the zip. system.py still stops at
"No module named app" — the C++ modules are the 2V0 slice.
gates: port_map.py check 0 errors · key leak check 8/8 none · macOS ctest
27/27 · android + ios port_platform compile clean.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Link mtpython into port_logic and copy 40250's ScriptLib launcher across:
PythonLauncher, PythonUtils and PythonMarshal, plus the 12 forwarding headers
that make its `#include <Python-2.7/*>` lines compile unchanged. symtable.h
forward-declares mod_ty rather than including Python-ast.h, whose one-word
macros (Delete, Module, Set, Print) collide with EterLib/Pool.h — the same
clash 40250 sidestepped by commenting out PySymtable_Build.
Two `// PORT:` edits: `unsigned char(val)` is an MSVC extension (PythonUtils.cpp,
twice), and PyObject_AsCharBuffer wants a Py_ssize_t* (TraceFunc).
port_python_launcher_test drives the launcher in the order UserInterface.cpp
does (:241-434): Create(), __DEBUG__/__COMMAND_LINE__, TRUE/FALSE, a CRLF script
through RunMemoryTextFile, a .pyc through RunCompiledFile, then RunFile reading
system.py out of the real pack. It stops at `ImportError: No module named app`,
i.e. the first C++ module RunMainScript registers — that is the 2V0 slice, and
the stdlib behind it is step 3. The host flags (Py_NoSiteFlag and friends) sit
in the test for now; step 3 moves them into the platform layer.
port-map statuses are set only for what the test actually executes: 10 of 12
launcher functions and 4 of 11 marshal ones (the small-.pyc path delegates to
CPython's own reader, so the ported r_object stays unreached). PythonUtils
compiles but nothing calls it until the binding modules arrive, so it stays TODO.
Windows has no mtpython yet, so port_logic drops ScriptLib and the shims there.
Tests: macOS ctest 27/27 incl. port.python_launcher; port_logic (with ScriptLib)
also compiles for android arm64 (NDK API 24) and ios arm64.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The embedded 40250 script layer needs its own interpreter on five platforms.
2.7 is end-of-life, so nothing can be fetched from the target SDKs and the
source is vendored (official 2.7.18 tarball, trimmed to 25MB; Lib/ stays for
step 3's python27.zip).
cpython-2.7.18/CMakeLists.txt builds one `mtpython` static library from exactly
the 133 objects the reference libpython2.7.a contains, off by default behind
-DMTGODOT_EMBED_PYTHON=ON. The source list and the built-in module table
(config/config.c, 39 entries) are shared; pyconfig.h is a probe result and is
not, so each platform keeps its own under config/<platform>/, regenerated by
tools/py_embed/gen_pyconfig.sh and checked against the shared table.
Three vendor patches, documented in docs/THIRD-PARTY.md: configure/configure.ac
learn arm64 on macOS, and posixmodule.c undefines the process-control calls it
hard-defines past pyconfig.h when building for iOS.
macOS (ctest python.embed: every builtin imports, codecs and pickle work off the
vendored Lib/), Android arm64 and iOS arm64 build. Linux needs a Linux host and
Windows needs a MinGW-vs-MSVC decision; both are noted for step 4.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
tools/asset_manifest.py records path/size/sha256 of pack/Index, every .eix/.epk
and Eternexus/root/*.msm (audit/assets/40250-client.json). The gate script sets
MT_ASSETS_STRICT=1, verifies the manifest, runs the native pack/proto tests and
four Godot tests, and fails on a missing client, a mismatch or a skip.
MT_40250_CLIENT now comes from the environment for the native tests too.
remote_player_test accepts both weighted WAIT variants (wait/wait_1).
PORT-PLAN §5 records the 2D status.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Read-only scanner for Client/pack following PackInitialize -> CEterPackManager
-> CEterPack::__BuildIndex/Get2. Keys are read from the reference EterPack.cpp
at run time; none are stored. Pure-Python TEA + LZO1X.
- 136 registered packs, 54,891 entries: NONE/COMPRESS/SECURITY only, no
PANAMA/HybridCrypt, all entries decode
- first-registered pack wins; 2,282 shadowed entries (2,194 differ)
- metin2_patch_{sd,mineral,mundi} use a second packer layout; 4 SECURITY
files fail 40250's CRC check and never load in the original
- no case collisions; paths are already lowercase
- PORT-PLAN: read EPK on device via ported EterPack, base install minus
extra locales, rebuild dict in Index order on any pack change
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Fix the per-function inventory against the clang-derived platform skeleton:
strip comments, accept indented qualified definitions in namespace blocks,
long parameter/initializer lists and all-caps qualified ctors, and skip
constructor initializer entries. Split EterBase by unit: tea/lzo/cipher/
Random/Stl/Timer/Poly become logic, the file/OS units stay platform; drop
the 8 obsolete platform stubs and regenerate audit/slices.
Baseline: logic 3343, python 5175, platform 2091 (10609), 0 done.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
- Mirror the remaining non-Python 2V3 closure headers (98 more, 173 total): EffectLib,
EterGrnLib, SpeedTreeLib, SphereLib, PRTerrainLib, EterImageLib, EterBase/Poly, cipher/tea,
EterLib Grp*/IME/Input/MSWindow/StateManager, GameLib actor/map/race headers, EterPack.
- SDK shims: granny.h, SpeedTreeRT.h, imm.h, Dimm.h (the SDK MIDL header, not mirrored),
dinput/d3dx8 additions; D3D8 render-state enums, FVF macros and the COM resource hierarchy;
more Win32 GDI/handle types with layout static_asserts.
- PORT edits for MSVC-permissive code (typename, friend visibility, <algorithm>, pointer→uintptr_t)
and PRTerrainLib/StdAfx.h dropping the ScriptLib/Python include.
- port_logic links the vendored cryptopp/minilzo.
- extension/src/platform: port_platform target with 103 generated stub files (1917 function
stubs, 146 static members) from the new platform_stub.py (clang -ast-dump-filter);
MT_PLATFORM_STUB() marks every unimplemented body. libmtgodot links port_platform and
port_gate.sh builds it.
Gate: macOS, Android, iOS, Windows (mingw) PASS; Linux BLOCKED (no toolchain).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
76 closure headers (EterBase, EterLocale, EterPack, EterLib, GameLib, MilesLib,
EffectLib, SphereLib, EterImageLib) copied by the new port_copy.py (CP949->UTF-8,
LF, include-path case only); platform-class headers go to the mirror path too, as
the interface platform/ implements. Six manual `// PORT:` edits (Random, Singleton,
Pool, Stl, Utils, FlyTarget).
- common/D3D8Types.h: D3D8 value types with SDK values/layout, opaque COM interfaces
- common/shim/sdk (d3d8/d3dx8/mss) on every platform, common/shim/win32 off Windows
- Win32Types/Win32Crt: HRESULT, GUID, LARGE_INTEGER, LOGFONT/TEXTMETRIC, _atoi64,
CRITICAL_SECTION on std::recursive_mutex
- header gate prepends each library's StdAfx.h (40250's precompiled header)
port_gate: macOS, Android, iOS, Windows (mingw) PASS; Linux BLOCKED (no toolchain).
ScriptLib/EterPythonLib/UserInterface wait for 2P (their StdAfx includes Python).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
D3DXVECTOR2/3/4, D3DXMATRIX, D3DXQUATERNION, D3DXPLANE, D3DXCOLOR with
d3dx8math.inl operator semantics, plus the D3DX* functions the 2V3 slice
logic uses. Covered by port.common; port_gate passes on macOS, Android,
iOS and Windows (mingw).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
port_deps.py resolves explicit #include edges plus the implicit edges each
40250 library's StdAfx.h supplies (symbol index restricted to StdAfx-visible
headers), writes cumulative slice lists and the P0 topological order.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
- keep 40250 widths/overflow semantics (Win32 long = 32-bit), fixed-width
serialized structs with static_assert, instead of copying C type names
- 2A base batch (types, header closure, port_logic target, platform stubs,
header gate, port-map re-baseline) and include-order porting
- 2R pack inventory: six EPK compression types, HybridCrypt key source,
index override order, path case, mobile delivery
- 2P: shared source list, per-platform pyconfig.h, all five platforms
- 2V minimal vertical slice; old and new paths coexist until wired
- strict asset tests (MT_ASSETS vs M2_ASSETS), RUN_AS_IS instead of N_A,
void the 6 pre-architecture 'done' functions
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Records the root/uiscript/locale comparison: npclist, msm contents and
motion/combo registration match; msm location differs; item_proto and
mob_proto use a different record layout and TEA instead of XChaCha20,
so proto.cpp cannot read them; pack contents not yet compared.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Records the decisions (mirror-layout logic port, embedded CPython 2.7 UI),
layers and code layout, batch route and status, and the directory/toolchain
setup needed to resume on another machine. Marks the older refactor plan as
superseded and points CLAUDE.md/AGENTS.md/roadmap at it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
libpython2.7.a cross-builds with NDK 27.2 (API 24) after disabling
HAVE_LANGINFO_H; 30 C modules built in. On a OnePlus 13 (API 36) the
harness runs system.py -> prototype.RunApp() and imports the root modules
with results identical to macOS (66/74; the 8 failures are stub values or
dev-only scripts). py_embed_spike.py now isolates __main__ like
CPythonLauncher and reports stdlib usage.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Handle late main-character data, guarded model construction, bounded retries and map correction. Validate player model sources and add lifecycle and real-asset visual regressions.
Include pending material and character-selection changes, updated A1 screenshot, and the detailed rendering repair plan. Hair occlusion, full UI parity and final macOS package acceptance remain unfinished.
CLIENT-GAP-FIX §2.1/§2.3/§2.4/§2.5 (+ §2.2 steps 4-5):
- §2.1 two-layer model: EntityStore is data-only. Entries are created only by
mut_spawn / mut_spawn_full / mut_spawn_main and removed only by mut_despawn /
main-vid table clear. Every other mut_* now does find-or-return with a
MT_NET_TRACE-gated debug log; no pending / replay buffer. Visibility moves to
net_world.gd::_update_visibility() — per frame it walks client.get_entities()
and mirrors is_main / AFFECT_SHOW_ALWAYS(bit 7) / IsWall(14201-14204) /
planar-distance < CHAR_STAGE_VIEW_BOUND (200*100 cm), building a node on entry
and fading + freeing it past +10 while keeping the data row (_fading guard).
Gate is fail-open when the data layer is not queryable (no get_entities /
_main_vid == 0 / no pos_cm) so existing fake-client tests are unaffected.
- §2.3 one overwrite rule: mut_spawn_full() does a clean whole-row value replace
(m_ents[vid] = e), no preservation of prior move state on VID reuse; mut_spawn()
now delegates to it. net_world._on_spawn destroys + recreates a node when the
vid already has one; mount/dismount rebuild keeps the old global_position.
- §2.4 points bounds: mut_set_points() clamps counts > POINT_MAX_NUM (255) and
zeroes the tail of a short snapshot; mut_set_point() rejects type >= 255.
- §2.5 field apply order + affect flags: new EntityStore::mut_affect_flags(vid,
lo, hi) assembles v = lo | (hi << 32) and queues a dirty tick; mut_char_update
guild/alignment/pk changes now also push Info. net_world._apply_field_updates()
applies fields in the reference call order (NetworkActorManager.cpp:470).
- §2.2 steps 4-5: mut_char_info() / mut_shop_sign() drop the touch()-creates-
entity path. Steps 1-3 (m_pending_actor two-packet merge) remain W1-owned.
Tests: ./build.sh Debug exit 0; ctest 16/16 (net.entity_store gains a §2.1
data-layer assertion block). New project/net_world_vis_test.gd for scene-node
visibility. GDScript regressions green: netbridge_test, gamescene_test,
netplay_test, p9_test, combat_fx_test, player_motion_test, net_world_vis_test.
Follow-up for W1: call mut_affect_flags(vid, affect_flag[0], affect_flag[1])
from classic_parser.cpp after GC_CHARACTER_ADD[2] / GC_CHARACTER_UPDATE
(mut_char_update has no affect param). wire_classic.h already has the wanted
static_assert on GCPoints.points.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014yvAPqPivoY7vmBbzgqK4W
§1.5 CG_CLIENT_VERSION: send_client_version() now branches on locale. EUROPE
(this project's locale) sends CGClientVersion2 (header 0xf1, 67B, timestamp
"1215955205"); non-EUROPE sends CGClientVersion (0xfd) + CMake-injected
MT_BUILD_TIMESTAMP in C __TIMESTAMP__ form. New ClassicSession::set_executable_name()
(default "metin2.bin"; TODO(W0): M2Client passes OS::get_executable_path().get_file()).
m_version_sent set only after send_fixed() succeeds. wire_classic.h gains
CGClientVersion2 + size-table entry.
§1.10 fixed-length text: new extension/src/net/text_codec.h — to_wire()/
from_wire_str() apply a hard byte cap without splitting a UTF-8 multibyte
sequence; godot::String overloads are __has_include-guarded so mtnet stays
godot-free. classic_session.cpp routes 8 fixed-length name/sign/comment fills
through to_wire(); parser reads GC_CHAR_ADDITIONAL_INFO name via from_wire_str().
New net_text_codec_test (ctest net.text_codec). Locale codepage (CP949/CP1252)
transcoding remains a follow-up; wire bytes are currently UTF-8 (ASCII round-trips).
§2.2 two-packet PC/NPC merge: ClassicParser GC_CHARACTER_ADD drops invisible
races (20025/20038/20039); PC/NPC only stash a bare Entity into m_pending_actor;
everything else spawns immediately with a name from root/npclist.txt (new
npc_names.h + set_npclist_path(); $MT_ASSETS/$M2_ASSETS fallback; TODO(W0):
M2Client passes the asset root). GC_CHAR_ADDITIONAL_INFO with no pending entry
records m_last_error + m_unhandled_headers and drops (never half-creates);
on a hit it merges the pending Entity with the additional-info's 9 fields into
one mut_spawn_full() then erases the pending entry. New pending_actor_count()
test hook; net_classic_session_test updated (version assertions -> 0xf1;
stash -> merge -> spawn, immediate monster spawn, invisible-race drop,
no-pending additional-info is a no-op). Depends on W2 §2.2 steps 4-5
(entity_store mut_char_info touch / mut_shop_sign cleanup) — the merge works
with current W2 code as-is.
Build + ctest 17/17 (16 + net.text_codec); netbridge_test, p10_test green.
Docs: CLIENT-GAP.md W1 row + increment-50 change-log entry; CLIENT-GAP-FIX.md
§1.5/§1.10/§2.2 status + facts and C.5 batch record.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014yvAPqPivoY7vmBbzgqK4W
Implement the in-game Help window as a 1:1 migration of uihelp.py's
HelpWindow (single-page: ENABLE_HELP_MULTIPAGE = 0 -> LoadDialogSinglePage).
- project/ui/help_ui.gd (new): loads the real helpwindow.py uiscript via
UiScript -> UiBuild; _relabel() resolves the <HELP_*>/<CLOSE> placeholders
(produced when UiManager has no locale callback) from the project Locale
table (en) with verbatim English fallbacks, covering the original script's
two duplicate help_02 rows (right/middle camera). open/close/toggle/is_open;
close_button -> close; ESC handled by the UiManager window stack.
- project/ui/system_menu_ui.gd: help_button changed from the placeholder toast
to close() + open_help(); adds const HelpUI, an injectable help_ui member,
_ensure_help() (lazy build, reuses the menu's ui/client/assets_root),
open_help(), toggle_help(); setup() gains an optional 6th arg (old 5-arg
callers unaffected).
- project/game_scene.gd: single elif in _unhandled_input — KEY_H without
ctrl/meta -> system_menu_ui.toggle_help() (Ctrl+H stays free for
/user_horse_ride).
- project/help_ui_test.gd (new): headless SceneTree test — helpwindow.py load,
19 verbatim help rows + taskbar labels bound and non-placeholder,
close_button text, rows() helper, close/open/toggle, ESC stack top,
SystemMenuUI.open_help() lazy build.
Tests: help_ui_test, system_menu_ui_test, gamescene_test, ui_test all PASS
(plus system_option_ui_test, char_status_ui_test). No build/ in this worktree
so C++ ctest not run (no C++ change). Real-server and visual (.sub textures)
not verified. Docs: CLIENT-GAP.md W3 row + increment 50 bullet;
CLIENT-GAP-FIX.md §8.3 status/改动/测试/验收 + C.5 batch record.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014yvAPqPivoY7vmBbzgqK4W
Rendering fixes (real):
- m2_material shaders: cull_disabled -> cull_back (inside-of-mesh faces were
z-winning and darkening/hiding the head under the ShaderMaterial path).
- drop `* COLOR` from the shader (meshes carry no ARRAY_COLOR).
Animation: convert gr2 global poses to Godot *local* bone poses and set via
set_bone_pose (was set_bone_global_pose). MTGODOT_VERIFY=1 confirms
get_bone_global_pose(i) == conv(world[i]) for all 75 bones (<=2.6e-5).
Head/upper-armor collapse on dance_1 is NOT a Godot-route bug:
- reproduced identically in xrender-poc's bgfx demo at the same anim/t
- reproduced by the new MTGODOT_CPUSKIN=1 reference path (same LBS math as
xrender's validated skin_mesh)
- `general/wait` / `run` render correctly in all three
=> upstream libgr2 Curve::eval (degree-2 quaternion B-spline) vs Granny.
Demo default animation switched to general/wait; documented in MIDREVIEW §4
and README. Debug scaffolding gated behind MTGODOT_VERIFY / MTGODOT_CPUSKIN.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WaHYEY9rwLWt21PULiYjeJ
- docs/MIDREVIEW.md: what M0'-M2.5 proved, bridge-layer LOC (~1100),
key technical conclusions (4x4 transpose, animation method B, no
handedness flip needed), remaining risks, recommendation = enter Phase 2
with a 3-item wrap-up (compare.py, dump_materials oracle, refocused perf).
- harness MTGODOT_STRESS=N: grid of N animated warriors, vsync off, dumps
test/godot-macos-stress.json. Frame times are throttle-capped in a
background window (~30fps to 50 chars, 52ms at 100); the reliable signals
are build cost ~165ms/char and the 100-char breakout.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WaHYEY9rwLWt21PULiYjeJ
- extension/: godot-cpp submodule (master, API 4.7), Metin2Model node
registered, links xrender-poc/libgr2 via sibling-dir reference.
- project/: Godot 4.7 project — orbit camera + DirectionalLight3D (shadows)
+ WorldEnvironment/procedural sky + placeholder cube; main.gd probes the
extension and can run libgr2 on a real .gr2 (MTGODOT_PROBE_GR2).
- build.sh one-shot build into project/bin/.
- docs/GODOT-POC-PLAN.md (phased: Phase 1 macOS -> M0'/M1/M2/M2.5).
Verified on this machine:
[mtgodot] Metin2Model registered OK — libgr2 linked
probe_gr2(warrior_cheongrin.gr2) -> gr2 OK: format_version=6 sections=8
Metal Forward+ renders the scene (test/golden/m0-scaffold.png).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WaHYEY9rwLWt21PULiYjeJ