Register observable 2V0 gameplay stubs through RunApp

This commit is contained in:
shen
2026-09-22 20:05:22 -07:00
parent b221a9eaf5
commit 9c30f06083
8 changed files with 2014 additions and 14 deletions
+6 -3
View File
@@ -2,7 +2,8 @@
#
# 和 ctest 的 `port.python_launcher` 跑的是同一条序列,区别只有一个:那边是独立可执行文件,这边在
# Godot 进程里,由 GDScript 发起 —— step 4 要验的就是这个差别。2V0 把 C++ 模块注册上之前,
# 在玩法模块补齐前,system.py 会停在下一个未注册的 native import。
# 2V0-e 的玩法桩让 system.py 真正走到 prototype.RunApp();
# 2V0-f 的应用 adapter 尚未创建图形设备,RunApp 捕获 CREATE_DEVICE 并给出原版提示。
#
# 真机上通常没有 40250 的 Client/pack(APK 里只有 python27.zip),所以分两段:解释器 + 标准库这一段
# 不需要 pack,任何平台都跑;system.py 这一段需要 pack,没有就跳过并说清楚。
@@ -10,7 +11,7 @@
# 桌面:python_host_test.gd(--script);真机:MT_TEST_MODE=python 从 client_main.gd 进来。
extends RefCounted
const EXPECTED_STOP := "No module named net"
const EXPECTED_STOP := "Sorry, Your system does not support 3D graphics"
var fail := 0
@@ -50,7 +51,9 @@ func run() -> int:
var err: String = Metin2PythonHost.run_main_script("")
print("system.py -> %s" % err)
_ck(err.contains(EXPECTED_STOP),
"system.py 停在预期的 '%s'(2V0 之后这里会往前走)" % EXPECTED_STOP)
"system.py 进入 prototype.RunApp(),Create() 报告待实现的图形设备")
_ck(Metin2PythonHost.run_line("import net, player, item; assert net.__port_stub__ == 1 and player.__port_stub__ == 1 and item.__port_stub__ == 1") == "",
"2V0 玩法模块桩已注册,调用会记录到 stderr")
else:
print("SKIP: system.py 这一段(没有 40250 Client/pack:%s)" % AssetRoot.client_path())