Compare commits
52
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1359eab806 | ||
|
|
62b61bafd0 | ||
|
|
e9c26b86c1 | ||
|
|
0558166243 | ||
|
|
82251cb524 | ||
|
|
708e1c8379 | ||
|
|
ab516feb7b | ||
|
|
95f1c30be2 | ||
|
|
5decc93798 | ||
|
|
83809631ed | ||
|
|
b61140b8f4 | ||
|
|
fe6e41dc8e | ||
|
|
e271e4ba49 | ||
|
|
a4e96a1559 | ||
|
|
dc24e0e8e1 | ||
|
|
042bd77413 | ||
|
|
e446ae8449 | ||
|
|
3efa607908 | ||
|
|
9fbeaeb7a2 | ||
|
|
0b828387aa | ||
|
|
090dab1fc1 | ||
|
|
108fe17127 | ||
|
|
790037729f | ||
|
|
8653edf4c5 | ||
|
|
fce6a5e06b | ||
|
|
ae0fc25a81 | ||
|
|
b9f5d737cb | ||
|
|
569afb1378 | ||
|
|
a1e7da68a4 | ||
|
|
657e49e52a | ||
|
|
99cf5514c3 | ||
|
|
fc98e6e2b4 | ||
|
|
e70a6abf7a | ||
|
|
507e687867 | ||
|
|
8d01a7a754 | ||
|
|
b9af78ef64 | ||
|
|
a1b63c0afb | ||
|
|
1412806ee9 | ||
|
|
4d7306792e | ||
|
|
0d2a9ebe36 | ||
|
|
178fcf48fe | ||
|
|
f266072f67 | ||
|
|
90f213c4cc | ||
|
|
d11d46c469 | ||
|
|
8164c02709 | ||
|
|
84404cf1f1 | ||
|
|
32372c2a73 | ||
|
|
5dcac9cbd4 | ||
|
|
b14fb2ffe9 | ||
|
|
b8363693f1 | ||
|
|
10f8c9760e | ||
|
|
a22c064587 |
+14
@@ -44,3 +44,17 @@ __pycache__/
|
||||
/android/app/build/
|
||||
/android/build/
|
||||
/android/local.properties
|
||||
|
||||
/Client/autohunt.cfg
|
||||
|
||||
# MeshPort private network identity; SDK build output normally lives under /build.
|
||||
/config/meshport.private.toml
|
||||
/third_party/meshport/target/
|
||||
|
||||
# Local build outputs, caches and legacy restructure leftovers
|
||||
/build_*/
|
||||
/.codex/
|
||||
/android-native/
|
||||
/extension/
|
||||
/script/
|
||||
/test/
|
||||
|
||||
@@ -30,6 +30,7 @@ endif()
|
||||
add_subdirectory(third_party)
|
||||
add_subdirectory(src/codepage)
|
||||
if(MT_BUILD_PORT OR MT_BUILD_NATIVE_RENDER)
|
||||
add_subdirectory(src/meshport)
|
||||
add_subdirectory(src/port)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
PACK
|
||||
*
|
||||
patch_ava2_ui
|
||||
*
|
||||
patch1
|
||||
*
|
||||
season3_eu
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -4,9 +4,10 @@
|
||||
|
||||
## macOS
|
||||
|
||||
需要 CMake、SDL3、Vulkan loader、MoltenVK、glslc(第三方库均已随仓库提供源码,无需子模块):
|
||||
需要 Rust 1.95+、protoc、CMake、SDL3、Vulkan loader、MoltenVK、glslc(第三方库均已随仓库提供源码,无需子模块):
|
||||
|
||||
```sh
|
||||
./scripts/build_meshport.sh macos
|
||||
cmake -S . -B build/release -DCMAKE_BUILD_TYPE=Release \
|
||||
-DMT_BUILD_NATIVE_RENDER=ON -DCMAKE_PREFIX_PATH=/opt/homebrew
|
||||
cmake --build build/release --target mt_native_render -j8
|
||||
@@ -14,6 +15,8 @@ cmake --build build/release --target mt_native_render -j8
|
||||
--live-client "/path/to/40250/Client" --login-screen --width 1024 --height 768
|
||||
```
|
||||
|
||||
MeshPort SDK 源码在 `third_party/meshport`,无需单独检出 MeshPort 项目。频道查询、登录、注册、地图/公会连接及 UDP 都在公共网络层判断:同网段直连,跨网段组网,使用 DHCP 动态 IP;远端连接验证成功后提示“组网成功”。私有配置与构建说明见 [docs/MESHPORT.md](docs/MESHPORT.md)。
|
||||
|
||||
详见 [src/host/README.md](src/host/README.md)。
|
||||
|
||||
## Android
|
||||
|
||||
@@ -74,11 +74,15 @@ if [ ! -f "$OUT/sdl3/lib/libSDL3.so" ] || [ ! -f "$OUT/sdl3/.page16k" ]; then
|
||||
touch "$OUT/sdl3/.page16k"
|
||||
fi
|
||||
|
||||
# --- Embedded application-only networking SDK (source lives in this repository) ---
|
||||
"$REPO/scripts/build_meshport.sh" android
|
||||
|
||||
# --- libmain.so (src/host + port_platform + embedded Python) and its assets ---
|
||||
cmake -S . -B "$OUT/app-build" -G "Unix Makefiles" -Wno-deprecated \
|
||||
-DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN" -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM="android-$API" "$PAGE_SIZES" \
|
||||
-DCMAKE_BUILD_TYPE="$CONFIG" -DMT_BUILD_TOOLS=OFF -DBUILD_TESTING=OFF \
|
||||
-DMT_BUILD_NATIVE_RENDER=ON -DSDL3_DIR="$OUT/sdl3/lib/cmake/SDL3" \
|
||||
-DMT_MESHPORT_LIBRARY="${MT_MESHPORT_LIBRARY:-$REPO/build/meshport-runtime/aarch64-linux-android/release/libmetin2_meshport.a}" \
|
||||
-DCMAKE_FIND_ROOT_PATH="$OUT/sdl3" -DGLSLC="$GLSLC" >/dev/null
|
||||
cmake --build "$OUT/app-build" --target main mt_native_android_assets -j "$JOBS"
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# UI texture addressing, 2026-10-18
|
||||
|
||||
Scope: CGraphicExpandedImageInstance::OnRender / SetRenderingRect and the native sampler path. This does not establish full HUD or Windows visual parity.
|
||||
|
||||
The full reference ExpandedImageInstance unit was read alongside its platform counterpart. The geometry and UV arithmetic remain unchanged. Reference EterLib/StateManager.cpp SetDefaultState sets stage U/V to D3DTADDRESS_WRAP; the runtime ui.py Board.SetSize expands the texture coordinates to repeat a background. The former native UI descriptor unconditionally used CLAMP_TO_EDGE, producing stretched final-row/column stripes.
|
||||
|
||||
UIRenderAddImageNamed now carries stage-0 U/V from CStateManager. Vulkan reuses its D3D sampler cache for non-clamp addressing, preserving independent wrap/mirror/clamp, mip-zero UI filtering and point/linear choice. Direct platform commands retain their previous clamp defaults; the second-stage mask retains clamp. Capture version 11 serializes U/V; version 1–10 remains readable with the old UI clamp behavior.
|
||||
|
||||
Validation:
|
||||
|
||||
- port_grp_resource_test: repeated UV extent, independent wrap/mirror state and explicit clamp.
|
||||
- host_ui_sampler_capture_test: version 11 roundtrip and version 10 backward compatibility.
|
||||
- host.ui_quality regression unchanged.
|
||||
- `ctest --test-dir build/native -R '^(host.ui_sampler_capture|port.grp_resource|host.ui_quality)$' --output-on-failure`: 3 passed.
|
||||
- Native macOS sbtest client: the same AVA2 pickup panel lost its stretched stripes and renders the repeated stone texture. Evidence: build/parity-acceptance-20261018/before-ui-address.png and after-ui-address.png, captured through CUA. The icon for persisted affect 705 also renders.
|
||||
|
||||
No Android visual acceptance or Windows pixel comparison was performed in this round. Aggregate UI contracts remain PARTIAL.
|
||||
@@ -0,0 +1,15 @@
|
||||
# Window lifecycle investigation during AVA2 QA
|
||||
|
||||
The scripted reconnect from a QARunner.OnUpdate callback crashed in UI::CWindow::Update on macOS (DiagnosticReports/mt_native_render-2026-10-18-105610.ips). No C++ lifecycle changes have been made in this investigation.
|
||||
|
||||
Read and compared CWindow::Update, Clear, DeleteChild and reserve-child removal, plus CWindowManager::DestroyWindow, NotifyDestroyWindow, reserve-deletion drain and Update against the 40250 source. Their update/deletion ordering is unchanged. The test driver invokes login-board focus/order/phase changes inside the window traversal; normal user input is dispatched outside that traversal. This is evidence of an unsafe test/reconnect path, not evidence of a differing port algorithm or a fix.
|
||||
|
||||
The acceptance driver now performs a process cold start to validate persisted locks. That cold start and server/db restart read back mask 8, material selection 4 and the preserved fourth attribute. In-process scripted reconnect remains unverified and the crash is retained as an open finding; no global parity status is upgraded.
|
||||
|
||||
## Follow-up: frame-boundary commands and endpoint restoration
|
||||
|
||||
The live host now optionally consumes `--py-command-file` between script frames while the fiber is parked. This replaces commands executed from QARunner.OnUpdate; it changes no CWindow/CWindowManager algorithm. Commands are size-bounded and consumed before execution so an error cannot repeat the same mutation every frame. Producers publish using atomic rename.
|
||||
|
||||
A separate reconnect stall was captured with macOS sample: the host was blocked in gethostbyname, called from LoginWindow.Connect after the original LoginWindow.Open replaced the launch endpoint with the packed login configuration. `mt_live_endpoint` now preserves the explicitly selected/last successful endpoint while that original window opens. Manual server selection and the existing explicit channel-switch flow retain ownership of their targets; account credentials are not copied by the module.
|
||||
|
||||
With the new host command boundary and endpoint restoration, the same macOS process completed three logout/login/character-enter cycles against sbtest without a crash or per-cycle address injection. Evidence: build/parity-acceptance-20261018/reconnect-host-pass.json and client-live-endpoint.log. This verifies this scripted reconnect path, not every physical input or arbitrary mutation during CWindow.Update. No 40250 lifecycle parity status is upgraded and no C++ window changes were made.
|
||||
@@ -651,3 +651,12 @@
|
||||
{"date": "2026-09-30", "action": "user-authorized-render-diagnostics", "units": ["UserInterface/PythonApplication.cpp", "GameLib/MapOutdoorRenderHTP.cpp", "GameLib/MapOutdoorRenderSTP.cpp"], "evidence": "7 same-scene MI 8 Lite runs, 42 two-second sample windows. Baseline 4.88 FPS/205.3ms, no terrain 15.45FPS/64.7ms, no scene 30.03FPS/17.7ms; repeated baseline 4.83 FPS. Normal rendering defaults unchanged. See docs/XIAOMI8LITE-RENDER-ISOLATION-20260930.md."}
|
||||
{"date": "2026-09-30", "unit": "Client/root/uiaffectshower.py", "result": "RUN_AS_IS unchanged; authorized PORT extension for server rates", "evidence": ["src/platform/ScriptLib/ServerBonusScript.inc", "tools/server/autohunt-pull-range/server_bonuses.h", "build/autohunt-fix-test.log", "build/autohunt-fix-mobile-test.log", "build/autohunt-bonuses-android.png"], "finding": "40250 global privileges emit login notices rather than character AFFECT packets; added distinct status channel, packed scripts unchanged."}
|
||||
{"date": "2026-10-01", "unit": "UserInterface/PythonPlayerAutoHunt.cpp", "action": "user-authorized-extension", "evidence": ["docs/AUTO-HUNT-ENHANCEMENTS.md", "build/autohunt-enhance-test.log", "build/autohunt-enhance-mobile-test.log", "build/autohunt-enhance-mac-build.log", "build/autohunt-enhance-android-build.log", "build/qa/autohunt-enhance-ui/settings.png"], "finding": "Added bounded terrain/scene-collision A* and reachability for combat/loot/return; independent learned skill-ID selection with legacy config migration; optional server restart_here and 5-second/70%-HP recovery; acknowledged dismount/cast/remount batching. Original manual movement and packed Python scripts unchanged. Desktop/mobile fake-server integration and macOS/Android builds pass; real-server soak not claimed."}
|
||||
{"date": "2026-10-16", "unit": "UserInterface/PythonApplication.cpp:Destroy / PythonBoot::Stop", "action": "fix-host-teardown-order", "finding": "40250 drains flying instances before effects/characters; host previously reset effects before CFlyingManager destruction. Explicit flying and character cleanup fixes live-projectile shutdown; overall Destroy remains DIVERGENT for unrelated omissions.", "evidence": ["tests/port/port_app_loop_test.cpp", "build/followup-shutdown-before.log", "build/followup-shutdown-after.log"]}
|
||||
{"date": "2026-10-17", "unit": "UserInterface/PythonPlayerAutoHunt.cpp::__AutoHunt_BuildPath", "action": "user-authorized-extension", "finding": "Live snow floor 1 knockback left the player at (18730.742,22544.762), inside blocked attribute row 225. Exact-start-only exemption rejected every path/attack sample, including monsters 90 units away. Permit only the occupied loaded blocked terrain cell, retaining adjacent blocked cells, scene collision and unloaded-data rejection. AutoHunt is an authorized extension, not a newly claimed 40250 counterpart.", "evidence": ["tests/host/autohunt_navigation_test.cpp", "docs/AVA2-FOLLOWUP-20261016.md"], "remaining": "Live dungeon soak pending; no parity status upgraded. Port-map helper script absent on this branch."}
|
||||
{"time": "2026-10-18T10:49:04.284335+00:00", "event": "platform_fix", "unit": "EterLib/GrpExpandedImageInstance.cpp", "result": "ADAPTED", "reason": "Preserve stage-0 U/V in UI command/sampler path instead of unconditional clamp; repeated Board backgrounds validated on macOS. Aggregate UI remains PARTIAL.", "evidence": ["audit/evidence/2026-10-18-ui-addressing.md", "tests/port/port_grp_resource_test.cpp", "tests/host/ui_sampler_capture_test.cpp"]}
|
||||
{"time": "2026-10-18T17:58:20.857552+00:00", "event": "lifecycle_investigation", "units": ["EterPythonLib/PythonWindow.cpp", "EterPythonLib/PythonWindowManager.cpp"], "finding": "Scripted reconnect during OnUpdate crashed; relevant window lifecycle group matches 40250. No code changes or status upgrades; use cold-start QA and retain reconnect finding.", "evidence": ["audit/evidence/2026-10-18-window-lifecycle-qa.md"]}
|
||||
{"time": "2026-10-18T23:43:15.072652+00:00", "event": "platform_endpoint_fix", "unit": "host/live_client + ScriptLib/LiveEndpointScript", "finding": "Preserve explicitly selected live endpoint across login reopen; execute optional local QA commands between parked script frames rather than from window traversal. No original CWindow/CWindowManager code changed.", "evidence": ["tests/wiki/test_live_endpoint.py", "tests/wiki/test_python_command_file.py", "audit/evidence/2026-10-18-window-lifecycle-qa.md", "docs/AVA2-SWITCHBOT.md"], "result": "Three same-process relogins and two cross-core map transfers verified on macOS/sbtest; native cross-channel switching remains pending; no global parity status upgraded."}
|
||||
{"time": "2026-10-19T00:04:44.204859+00:00", "event": "authorized_ava2_extension", "unit": "ScriptLib/NativeChannelScript", "finding": "AVA2 MoveChannelDialog uses native server warp; map ownership/ports announced by trusted P2P peers. No original CWindow lifecycle algorithm or classic Warp packet changed.", "evidence": ["docs/AVA2-NATIVE-CHANNEL.md", "docs/AVA2-SWITCHBOT.md", "tests/wiki/test_native_channel.py"], "result": "macOS/sbtest CH5-CH6-CH5 active switchbot handover, locked attribute/targets, endpoint retention and disconnected target verified; Android offline build only; no global parity status upgrade."}
|
||||
{"time": "2026-10-19T04:37:42.044205+00:00", "event": "authorized_ava2_extension", "unit": "ScriptLib/AttrLockViewsScript", "finding": "AVA2 lock-line styling extended to existing exchange, shop/builder, safebox/mall and GM equipment tooltip setters using bounded read-only contextual queries. Base item packets and CWindow algorithms unchanged.", "evidence": ["docs/AVA2-ATTR-LOCK-VIEWS.md", "tests/wiki/test_attr_lock_ui.py", "tests/wiki/test_attr_lock_views.py"], "result": "macOS/sbtest two-player trade/shop/storage and real GM equipment lock highlights verified; ordinary equipment queries and closed contexts denied. 126 client tests and native macOS/Android builds passed; fixtures and temporary test GM removed. Active switchbot/hyperlink lock metadata remains pending; no aggregate parity upgrade."}
|
||||
{"time": "2026-10-19T05:08:12.881941+00:00", "event": "authorized_ava2_extension", "unit": "ScriptLib/AttrLockSnapshotsScript", "finding": "Owner metadata follows existing item packets; bounded post-entry synchronization bridges loading-phase command loss. Versioned seven-slot chat snapshots and active switchbot lock lines preserve the classic wire layouts and original CWindow algorithms. Chinese active descriptions use measured text width.", "evidence": ["docs/AVA2-ATTR-LOCK-SNAPSHOTS.md", "tests/wiki/test_attr_lock_snapshots.py", "docs/AVA2-PARITY-PLAN.md"], "result": "132 client tests and macOS/Android offline builds passed. macOS/sbtest first-entry sync, immutable link/relay, active roll/stop, slot moves and same-process relogin passed. Final layout measured 348 versus longest text 308; test weapon/902 switchers and original unlocked state restored. Production unchanged; no aggregate parity upgrade."}
|
||||
{"time": "2026-10-19T06:35:09.108370+00:00", "event": "authorized_ava2_extension", "unit": "ScriptLib/Ava2NativeSystems", "finding": "Vendor active AVA2 uiBattlePassEx, uiWiki/WikiUI, uiDropItem and uiEventCalendarNew; preserve classic SHOP_SIGN39 by moving event payload to GC214, configured-db battlepass persistence, real loaded drop data and original CWindow algorithms. Correct active-versus-legacy protocol mapping.", "evidence": ["docs/AVA2-NATIVE-SYSTEMS.md", "tests/wiki/test_native_systems.py", "tools/ava2-native/sources.json", "docs/AVA2-PARITY-PLAN.md"], "result": "146 client tests, 30 server feature scripts with updated version-marker retest, native macOS/Android offline builds; sbtest mission/final idempotency, persistent native views, drop data, scoped calendar/icon verified. Production game a8d606ea deployed; backup /root/backup-native-systems/20261019-083154. No aggregate parity upgrade; phone not tested."}
|
||||
|
||||
+2
-1
@@ -4270,7 +4270,8 @@
|
||||
"2026-09-30: native UI HiDPI font refresh and sampling checks PASS; previous font runtime fails 9 new assertions. Full native CTest: 29 pass, codepage and live login skipped. Actual mac app HD archive/launch/screenshot checks recorded in audit/evidence/2026-09-30-mac-ui-clarity.md. Aggregate HUD parity remains PARTIAL."
|
||||
],
|
||||
"notes": [
|
||||
"2026-10-02: SCREEN waypoint atlas must retain original black RGB under alpha=0; HD minimap.dds colour bleed reproduced, native five-frame waypoint smoke renders clean rings after original-atlas fallback. build/minimap-fix-smoke.png. Full Windows visual parity remains unverified."
|
||||
"2026-10-02: SCREEN waypoint atlas must retain original black RGB under alpha=0; HD minimap.dds colour bleed reproduced, native five-frame waypoint smoke renders clean rings after original-atlas fallback. build/minimap-fix-smoke.png. Full Windows visual parity remains unverified.",
|
||||
"2026-10-18: native UI stage-0 wrap/mirror/clamp now follows CStateManager, fixing repeated Board backgrounds. Three focused CTests and real macOS before/after screenshots pass; audit/evidence/2026-10-18-ui-addressing.md. Aggregate remains PARTIAL; Android/Windows comparison outstanding."
|
||||
]
|
||||
},
|
||||
"remaining": [
|
||||
|
||||
@@ -46,9 +46,10 @@
|
||||
"src/platform/EterLib/GrpExpandedImageInstance.cpp:CGraphicExpandedImageInstance::OnRender"
|
||||
],
|
||||
"test": [
|
||||
"tests/port/port_grp_resource_test.cpp"
|
||||
"tests/port/port_grp_resource_test.cpp",
|
||||
"tests/host/ui_sampler_capture_test.cpp"
|
||||
],
|
||||
"note": "40250: CULLMODE CCW for a mirrored scale, Save/RestoreRenderState SRCBLEND/DESTBLEND per RENDERING_MODE, PDT-stream fill-rect draw. Port: the verbatim vertices plus m_iRenderingMode go to UIRenderAddImage; the Vulkan UI pipeline (cull none) maps SCREEN/COLOR_DODGE to INVDESTCOLOR+ONE and MODULATE to ZERO+SRCCOLOR (ui_batches.cpp). Invariant: same corners, UVs and blend factors."
|
||||
"note": "40250: CULLMODE CCW for a mirrored scale, Save/RestoreRenderState SRCBLEND/DESTBLEND per RENDERING_MODE, PDT-stream fill-rect draw. Port: the verbatim vertices plus m_iRenderingMode go to UIRenderAddImage; the Vulkan UI pipeline (cull none) maps SCREEN/COLOR_DODGE to INVDESTCOLOR+ONE and MODULATE to ZERO+SRCCOLOR (ui_batches.cpp). Invariant: same corners, UVs and blend factors. 2026-10-18: stage-0 U/V addressing is carried into Vulkan UI descriptors; the prior unconditional clamp stretched Board.SetRenderingRect tiling into edge stripes. Native before/after screenshots and independent wrap/mirror/clamp tests are recorded in audit/evidence/2026-10-18-ui-addressing.md."
|
||||
},
|
||||
"CGraphicExpandedImageInstance::SetDepth": {
|
||||
"status": "PORTED",
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/EterPythonLib/PythonWindow.cpp:CWindow::Clear"
|
||||
],
|
||||
"evidence": [
|
||||
"audit/evidence/2026-10-18-window-lifecycle-qa.md"
|
||||
]
|
||||
},
|
||||
"CWindow::DestroyHandle": {
|
||||
@@ -68,12 +71,18 @@
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/EterPythonLib/PythonWindow.cpp:CWindow::__RemoveReserveChildren"
|
||||
],
|
||||
"evidence": [
|
||||
"audit/evidence/2026-10-18-window-lifecycle-qa.md"
|
||||
]
|
||||
},
|
||||
"CWindow::Update": {
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/EterPythonLib/PythonWindow.cpp:CWindow::Update"
|
||||
],
|
||||
"evidence": [
|
||||
"audit/evidence/2026-10-18-window-lifecycle-qa.md"
|
||||
]
|
||||
},
|
||||
"CWindow::Render": {
|
||||
@@ -176,6 +185,9 @@
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/EterPythonLib/PythonWindow.cpp:CWindow::DeleteChild"
|
||||
],
|
||||
"evidence": [
|
||||
"audit/evidence/2026-10-18-window-lifecycle-qa.md"
|
||||
]
|
||||
},
|
||||
"CWindow::SetTop": {
|
||||
|
||||
@@ -146,12 +146,18 @@
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/EterPythonLib/PythonWindowManager.cpp:CWindowManager::NotifyDestroyWindow"
|
||||
],
|
||||
"evidence": [
|
||||
"audit/evidence/2026-10-18-window-lifecycle-qa.md"
|
||||
]
|
||||
},
|
||||
"CWindowManager::DestroyWindow": {
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/EterPythonLib/PythonWindowManager.cpp:CWindowManager::DestroyWindow"
|
||||
],
|
||||
"evidence": [
|
||||
"audit/evidence/2026-10-18-window-lifecycle-qa.md"
|
||||
]
|
||||
},
|
||||
"CWindowManager::IsDragging": {
|
||||
@@ -296,12 +302,18 @@
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/EterPythonLib/PythonWindowManager.cpp:CWindowManager::__ClearReserveDeleteWindowList"
|
||||
],
|
||||
"evidence": [
|
||||
"audit/evidence/2026-10-18-window-lifecycle-qa.md"
|
||||
]
|
||||
},
|
||||
"CWindowManager::Update": {
|
||||
"status": "PORTED",
|
||||
"impl": [
|
||||
"src/port/EterPythonLib/PythonWindowManager.cpp:CWindowManager::Update"
|
||||
],
|
||||
"evidence": [
|
||||
"audit/evidence/2026-10-18-window-lifecycle-qa.md"
|
||||
]
|
||||
},
|
||||
"CWindowManager::Render": {
|
||||
|
||||
@@ -301,7 +301,8 @@
|
||||
"impl": [
|
||||
"src/platform/UserInterface/PythonApplication.cpp:CPythonApplication::Destroy"
|
||||
],
|
||||
"note": "Empty and never called: the host tears down through the singleton resets in PythonBoot::Stop, not 40250 Main's app->Destroy(). 40250's body (window manager, SaveConfig/SaveInterfaceStatus writing into the client dir, managers incl. m_LightManager.Destroy(), device) is not run; porting it needs Stop to call it with config writes redirected out of the 40250 client dir."
|
||||
"note": "Empty and never called: the host tears down through the singleton resets in PythonBoot::Stop, not 40250 Main's app->Destroy(). 40250's body (window manager, SaveConfig/SaveInterfaceStatus writing into the client dir, managers incl. m_LightManager.Destroy(), device) is not run; porting it needs Stop to call it with config writes redirected out of the 40250 client dir. 2026-10-16: PythonBoot::Stop now explicitly drains CFlyingManager before character/effect destruction and destroys characters before their sibling text-tail/item managers. The active-projectile shutdown regression exits 139 before the fix and 0 afterward; remaining CPythonApplication::Destroy omissions retain DIVERGENT.",
|
||||
"test": "tests/port/port_app_loop_test.cpp"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
[CENTER_ALIGN;FONT_SIZE=20;COLOR=ffd700]龙魂石
|
||||
|
||||
[FONT_SIZE=14]打开角色背包中的龙魂石界面查看已有龙魂石。
|
||||
|
||||
[FONT_SIZE=14]龙魂石属性、穿戴条件与强化结果以服务器为准。
|
||||
|
||||
[FONT_SIZE=14]可通过物品悬浮提示核对等级及效果。
|
||||
@@ -0,0 +1,11 @@
|
||||
[CENTER_ALIGN;FONT_SIZE=20;COLOR=ffd700]游戏指南
|
||||
|
||||
[FONT_SIZE=14]在左侧选择职业与装备类别,查看强化材料和金币消耗。
|
||||
|
||||
[FONT_SIZE=14]搜索框支持物品、怪物的中文名称及编号。
|
||||
|
||||
[FONT_SIZE=14]点击物品图标可继续查询其来源,左右箭头可浏览历史。
|
||||
|
||||
[FONT_SIZE=14]怪物页展示当前模板属性、模型和服务器实际掉落。
|
||||
|
||||
[FONT_SIZE=14]百科右上方可以打开活动日历及掉落来源查询。
|
||||
@@ -0,0 +1,9 @@
|
||||
[CENTER_ALIGN;FONT_SIZE=20;COLOR=ffd700]生物学家
|
||||
|
||||
[FONT_SIZE=14]点击小地图旁的研究入口可以查看当前研究。
|
||||
|
||||
[FONT_SIZE=14]按阶段提交指定材料,冷却和奖励由服务器验证。
|
||||
|
||||
[FONT_SIZE=14]完成阶段后领取研究奖励,再进行下一阶段。
|
||||
|
||||
[FONT_SIZE=14]有关药水、奖励重选等操作,请查看研究窗口提示。
|
||||
@@ -0,0 +1,9 @@
|
||||
[CENTER_ALIGN;FONT_SIZE=20;COLOR=ffd700]第六与第七属性
|
||||
|
||||
[FONT_SIZE=14]装备悬浮提示显示该装备已有的全部属性。
|
||||
|
||||
[FONT_SIZE=14]自动洗练窗口可以选择目标属性与最低数值。
|
||||
|
||||
[FONT_SIZE=14]选择条件后请核对属性名称,再开始自动洗练。
|
||||
|
||||
[FONT_SIZE=14]锁定、消耗、洗练结果与停止条件均由服务器验证。
|
||||
@@ -0,0 +1,9 @@
|
||||
[CENTER_ALIGN;FONT_SIZE=20;COLOR=ffd700]时装与外观
|
||||
|
||||
[FONT_SIZE=14]在左侧时装分类中查询当前客户端支持的模板。
|
||||
|
||||
[FONT_SIZE=14]物品悬浮提示显示穿戴限制与属性。
|
||||
|
||||
[FONT_SIZE=14]已有模型的装备可在百科中进行预览。
|
||||
|
||||
[FONT_SIZE=14]实际可穿戴部位与效果以服务器判定为准。
|
||||
@@ -0,0 +1,11 @@
|
||||
[CENTER_ALIGN;FONT_SIZE=20;COLOR=ffd700]掉落查询
|
||||
|
||||
[FONT_SIZE=14]怪物详情展示服务器当前加载的掉落物品。
|
||||
|
||||
[FONT_SIZE=14]宝箱详情展示该宝箱当前加载的奖励内容。
|
||||
|
||||
[FONT_SIZE=14]物品详情可反查怪物及宝箱来源。
|
||||
|
||||
[FONT_SIZE=14]掉落查询窗口可搜索物品并预览掉落该物品的怪物。
|
||||
|
||||
[FONT_SIZE=14]条件掉落受等级、角色状态、活动等影响;列表不承诺每次掉落。
|
||||
@@ -0,0 +1,15 @@
|
||||
[CENTER_ALIGN;FONT_SIZE=20;COLOR=ffd700]活动与战令
|
||||
|
||||
[FONT_SIZE=14]活动日历显示服务器已经发布的排期。
|
||||
|
||||
[FONT_SIZE=14]点击同一天的活动图标可轮换查看该日活动。
|
||||
|
||||
[FONT_SIZE=14]活动时间使用服务器的 UTC 排期,频道与帝国限制显示在详情中。
|
||||
|
||||
[FONT_SIZE=14]没有排期时不会自动开启活动或发放奖励。
|
||||
|
||||
[FONT_SIZE=14]使用当月战令票可激活战令,任务进度由服务器记录。
|
||||
|
||||
[FONT_SIZE=14]任务完成后自动发放任务奖励,背包不足时可重新打开战令重试。
|
||||
|
||||
[FONT_SIZE=14]完成全部任务后,在战令奖励页领取最终奖励。
|
||||
@@ -0,0 +1,7 @@
|
||||
[CENTER_ALIGN;FONT_SIZE=20;COLOR=ffd700]游戏说明
|
||||
|
||||
[FONT_SIZE=14]本百科读取当前服务器导出的公开模板与实际掉落表。
|
||||
|
||||
[FONT_SIZE=14]未实现的系统不会提供虚构物品、奖励或活动排期。
|
||||
|
||||
[FONT_SIZE=14]玩法和账号规则以本服务器运营方发布的说明为准。
|
||||
@@ -0,0 +1,7 @@
|
||||
[CENTER_ALIGN;FONT_SIZE=20;COLOR=ffd700]宠物与坐骑
|
||||
|
||||
[FONT_SIZE=14]此分类列出当前模板中已经支持的宠物与坐骑。
|
||||
|
||||
[FONT_SIZE=14]空分类表示当前版本没有对应模板。
|
||||
|
||||
[FONT_SIZE=14]物品的使用方法、限制与属性请查看悬浮提示。
|
||||
+1971
-50
File diff suppressed because it is too large
Load Diff
+10
-10
@@ -1,21 +1,21 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"catalogue_sha256": "7efea0e88002d717c5d29174cf264a4ba06b0594561d8d25bd6ab7c091da9159",
|
||||
"catalogue_sha256": "638070c02e0ce213ff2616a733d241b3c7b32c9a483eaab4bdcde633fbaecc20",
|
||||
"source_sha256": {
|
||||
"item_proto.txt": "bf3d2c9d72719f1c222266042766cbe2f3fff8f0951666344181b6add0a31009",
|
||||
"item_names.txt": "a6888dfdb0be64f8c8112445b4d54e399a0f8e6ca29799ba33b3bb4160adad2a",
|
||||
"mob_proto.txt": "883a9f877f140e9baead30346b629f2f2c0d7c9c1f538febb2e17f28c9e446ce",
|
||||
"mob_names.txt": "2c7a5275983268b668e21b9f4e39f6d58ee6fde04ada1cbb4a1fd8315bfad391",
|
||||
"refine.tsv": "df6d14fb31b7e281434c927cf96413c6471f0c6b93da752d1b20e1bd082990db"
|
||||
"item_proto.txt": "7d4f5c54983d5ccb5b1db59a734e0c60d7ab6480e807c48c881be39d5769cbd1",
|
||||
"item_names.txt": "7a616550ec56206dcdc540f20f30ed3725fb6c9d6475dbd1a3b6eaddaa29a4d5",
|
||||
"mob_proto.txt": "cfd5c9720192f53d230b1b367f20523833392d87bc323388542a5b141a7b3f6f",
|
||||
"mob_names.txt": "e71e65ebd01a5705978ede20f680f84d7c531e46c18f4fe517da50898281e61b",
|
||||
"refine.tsv": "2aacbea1021cd0c26ed23cb4af376973c748826a65fc7b9453c97f926affb9da"
|
||||
},
|
||||
"items": 5756,
|
||||
"monsters": 763,
|
||||
"refine_recipes": 407,
|
||||
"items": 7510,
|
||||
"monsters": 870,
|
||||
"refine_recipes": 467,
|
||||
"source": "203 public server tables; no player data",
|
||||
"generator_sha256": "9c4e1b6069179c36c080a1136d65cbe52a8e44b3577fb8391e8404f5162ef40b",
|
||||
"localization_sha256": {
|
||||
"item_names_zh.txt": "5604985d7f11039f3d3e38d4e2c07995e80ca3e4f6deb01fe57cd772e9cd0f70",
|
||||
"item_names_zh_overlay.txt": "5d8396f19e7184fafd691b7a255b328237bddc1cdfda8d3cf8a7b074eb528f83",
|
||||
"item_names_zh_overlay.txt": "dcaee419bcc23e72e6dcce1c521a48501b3bbd6b1fd26fa925a213d53515df7e",
|
||||
"mob_names_zh.txt": "fdbfe4b3f3367d5842c0e9bbe0b5e5ea2dbe99fb6e566ef5789f65d3794eab5c",
|
||||
"mob_names_zh_overlay.txt": "7c44a5f6cff5c3c27c13cc4c7be91d619c20c67a8e091222e13ed392ea18d00b"
|
||||
},
|
||||
|
||||
@@ -54,6 +54,13 @@
|
||||
服务端 `item_proto.txt` 里改过的物品使用限制(每行 VNUM、限制类型 0、值 0、限制类型 1、值 1;0 = 无,1 = 等级),
|
||||
由 `locale_proto_patch` 写进客户端 `item_proto`,提示框显示的等级要求与服务端一致。其余字段仍逐字节校验不变。
|
||||
|
||||
## 物品占格与标志(item_shapes_server.tsv)
|
||||
|
||||
服务端给了新用途、改过占格或标志的物品(每行 VNUM、size、flags、anti flags,数值),由 `locale_proto_patch`
|
||||
写进客户端 `item_proto`,背包占格和堆叠与服务端一致;只允许这几条记录的这三个字段变化。目前是 VIP 会员卡
|
||||
38001/38002(`tools/server/vip-card`):40250 原为 size 0,背包里不显示也不能移动。
|
||||
该表跟在 `item_stones_server.tsv` 后面传入(位置参数),所以需要石头表也存在。
|
||||
|
||||
## 物品说明(itemdesc_translate_zh.tsv)
|
||||
|
||||
40250 `itemdesc.txt` 的说明列(第 3 列)和摘要列(第 4 列,“Potion production”“Research”)按英文原文整句翻译,
|
||||
@@ -87,3 +94,19 @@ VNUM 匹配,不复制属性。它与 `server_extracted/database`、`40250_depl
|
||||
## +6 镶嵌石配置修复(2026-10-02)
|
||||
|
||||
当前 203 的 28700~28713 原为 ITEM_NONE,与 server_extracted 备份不同。`item_stones_server.tsv` 恢复备份中的类型、佩戴位置、属性和六个 value 字段;`locale_proto_patch` 只允许这 14 条记录的对应字段变化,其余非名称字段继续逐字节校验。服务端同份配置在 `tools/server/npc-shops/item-mall/stones.tsv`,商店安装时恢复。已有背包内同编号石头也使用新配置。
|
||||
|
||||
## 2026-10-17 帮会设施与系统界面汉化补齐
|
||||
|
||||
1. **帮会建筑与设施(`guildbuildinglist_zh.tsv`)**:
|
||||
- 补齐全部 66 项帮会建筑/设施中文译名(熔炉、锻造所、练兵场、力之祭坛、门墙、景观石与木材)。
|
||||
- 40250 新增的 5 个熔炉(26992–26996)对应译为灵魂水晶熔炉、红玉熔炉、石榴石熔炉、祖母绿熔炉、蓝宝石熔炉。
|
||||
2. **界面与系统提示词(`locale_game_zh_overlay.txt` & `locale_interface_zh_overlay.txt`)**:
|
||||
- 补齐 `MAP_AG`/`MAP_BG`/`MAP_CG`(三大帝国帮会属地)。
|
||||
- 补齐 `PVP_OPTION_PROTECT`(帮会模式)。
|
||||
- 补齐 `SCREENSHOT_SAVE1`/`SCREENSHOT_SAVE2`(截图保存提示与路径说明)。
|
||||
- 补齐 `LOGIN_FAILURE_WEB_BLOCK`(封禁提示)及 `MALL_CANNOT_INSERT`(商城道具栏放入限制)。
|
||||
- 补齐 `TOOLTIP_MEMORIZED_POSITION_ERROR`(坐标记录错误提示)。
|
||||
- 移除龙魂石标签页英文后缀(`locale_interface_zh_overlay.txt`)。
|
||||
3. **物品表与描述**:
|
||||
- 修正 40004(首领召唤戒指)与 38006(魔魔重抽券)中文名。
|
||||
- `itemdesc.txt` 第 2 列道具名同步填充对应中文名称。
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
# VNUM NAME
|
||||
14013 武器锻造所
|
||||
14014 防御道具锻造所
|
||||
14015 首饰锻造所
|
||||
14033 练兵场
|
||||
14043 钻石熔炉
|
||||
14045 火木石熔炉
|
||||
14046 铜熔炉
|
||||
14047 银熔炉
|
||||
14048 金熔炉
|
||||
14049 玉石熔炉
|
||||
14050 玛瑙熔炉
|
||||
14051 珍珠熔炉
|
||||
14052 白金熔炉
|
||||
14053 水晶熔炉
|
||||
14054 紫水晶熔炉
|
||||
14055 天璨熔炉
|
||||
26992 灵魂水晶熔炉
|
||||
26993 红玉熔炉
|
||||
26994 石榴石熔炉
|
||||
26995 祖母绿熔炉
|
||||
26996 蓝宝石熔炉
|
||||
14061 力之祭坛
|
||||
14062 力之祭坛
|
||||
14063 力之祭坛
|
||||
14100 房子(1)
|
||||
14101 石墙(1-1)
|
||||
14102 石墙(1-2)
|
||||
14103 石墙(1-3)
|
||||
14104 大门(1)
|
||||
14105 围墙(1)
|
||||
14110 房子(2)
|
||||
14111 石墙(2-1)
|
||||
14112 石墙(2-2)
|
||||
14113 石墙(2-3)
|
||||
14114 大门(2)
|
||||
14115 围墙(2)
|
||||
14120 房子(3)
|
||||
14121 石墙(3-1)
|
||||
14122 石墙(3-2)
|
||||
14123 石墙(3-3)
|
||||
14124 大门(3)
|
||||
14125 围墙(3)
|
||||
14200 帮会会标
|
||||
14201 围墙大门
|
||||
14202 围墙后壁
|
||||
14203 围墙左壁
|
||||
14204 围墙右壁
|
||||
14300 石头1
|
||||
14301 石头2
|
||||
14302 石头3
|
||||
14303 石头4
|
||||
14304 石头5
|
||||
14305 石头6
|
||||
14306 石头7
|
||||
14307 石头8
|
||||
14308 石头9
|
||||
14309 石头10
|
||||
14400 木头1
|
||||
14401 木头2
|
||||
14402 木头3
|
||||
14403 木头4
|
||||
14404 木头5
|
||||
14405 木头6
|
||||
14406 木头7
|
||||
14407 木头8
|
||||
14408 木头9
|
||||
|
@@ -447,30 +447,13 @@ VNUM LOCALE_NAME
|
||||
27052 新手魔法瓶(小)
|
||||
27053 新手速攻药剂(小)
|
||||
27054 新手轻身药剂(小)
|
||||
28000 屠杀石
|
||||
28004 偏执石
|
||||
28008 创伤石
|
||||
28012 愚钝石
|
||||
28100 屠杀石
|
||||
28104 偏执石
|
||||
28108 创伤石
|
||||
28112 愚钝石
|
||||
28200 屠杀石
|
||||
28204 偏执石
|
||||
28208 创伤石
|
||||
28212 愚钝石
|
||||
28300 屠杀石
|
||||
28304 偏执石
|
||||
28308 创伤石
|
||||
28312 愚钝石
|
||||
28400 屠杀石
|
||||
28404 偏执石
|
||||
28408 创伤石
|
||||
28412 愚钝石
|
||||
28500 屠杀石
|
||||
28504 偏执石
|
||||
28508 创伤石
|
||||
28512 愚钝石
|
||||
28600 鸡血石
|
||||
28601 羊脂玉
|
||||
28602 羚角石
|
||||
@@ -685,12 +668,12 @@ VNUM LOCALE_NAME
|
||||
31092 超冷怪的皮肤碎片
|
||||
35000 药草+
|
||||
35001 虎肝+
|
||||
38001 VIP特权
|
||||
38002 抽奖券(今日)
|
||||
38001 VIP会员卡(7天)
|
||||
38002 VIP会员卡(30天)
|
||||
38003 抽奖券(明日)
|
||||
38004 抽奖重抽券
|
||||
38005 高级抽奖转盘券
|
||||
38006 Momo重抽券
|
||||
38006 魔魔重抽券
|
||||
38010 金币包
|
||||
38050 力量宝箱
|
||||
38051 皇虎水晶
|
||||
@@ -748,6 +731,7 @@ VNUM LOCALE_NAME
|
||||
39041 蓝龙的祝福(中)
|
||||
39042 蓝龙的祝福(大)
|
||||
39043 超级记忆卷
|
||||
40004 首领召唤戒指
|
||||
41005 奥运击剑服(男)
|
||||
41006 奥运击剑服(女)
|
||||
41007 德国击剑服(男)
|
||||
@@ -1898,3 +1882,142 @@ VNUM LOCALE_NAME
|
||||
7167 七翎扇+7
|
||||
7168 七翎扇+8
|
||||
7169 七翎扇+9
|
||||
# AVA2 spirit stones; preserve special-stone grades and keep non-stone quest items unchanged.
|
||||
28000 屠杀石+0
|
||||
28030 鸡血石+0
|
||||
28031 羊脂玉+0
|
||||
28032 羚角石+0
|
||||
28033 虹河石+0
|
||||
28034 青胆石+0
|
||||
28035 精石+0
|
||||
28036 鹰翼石+0
|
||||
28037 木鱼石+0
|
||||
28038 龙骨石+0
|
||||
28039 青石+0
|
||||
28040 彩芒石+0
|
||||
28041 鹿影石+0
|
||||
28042 东海石+0
|
||||
28043 帝王石+0
|
||||
28044 破碑之石+0
|
||||
28045 克首领之石+0
|
||||
28046 普攻强化石+0
|
||||
28047 技能强化石+0
|
||||
28048 普攻抵抗石+0
|
||||
28049 技能抵抗石+0
|
||||
28100 屠杀石+0
|
||||
28104 偏执石+0
|
||||
28108 创伤石+0
|
||||
28112 愚钝石+1
|
||||
28130 鸡血石+1
|
||||
28131 羊脂玉+1
|
||||
28132 羚角石+1
|
||||
28133 虹河石+1
|
||||
28134 青胆石+1
|
||||
28135 精石+1
|
||||
28136 鹰翼石+1
|
||||
28137 木鱼石+1
|
||||
28138 龙骨石+1
|
||||
28139 青石+1
|
||||
28140 彩芒石+1
|
||||
28141 鹿影石+1
|
||||
28142 东海石+1
|
||||
28143 帝王石+1
|
||||
28144 破碑之石+1
|
||||
28145 克首领之石+1
|
||||
28146 普攻强化石+1
|
||||
28147 技能强化石+1
|
||||
28148 普攻抵抗石+1
|
||||
28149 技能抵抗石+1
|
||||
28204 偏执石+2
|
||||
28208 创伤石+2
|
||||
28212 愚钝石+2
|
||||
28230 鸡血石+2
|
||||
28231 羊脂玉+2
|
||||
28232 羚角石+2
|
||||
28233 虹河石+2
|
||||
28234 青胆石+2
|
||||
28235 精石+2
|
||||
28236 鹰翼石+2
|
||||
28237 木鱼石+2
|
||||
28238 龙骨石+2
|
||||
28239 青石+2
|
||||
28240 彩芒石+2
|
||||
28241 鹿影石+2
|
||||
28242 东海石+2
|
||||
28243 帝王石+2
|
||||
28244 破碑之石+2
|
||||
28245 克首领之石+2
|
||||
28246 普攻强化石+2
|
||||
28247 技能强化石+2
|
||||
28248 普攻抵抗石+2
|
||||
28249 技能抵抗石+2
|
||||
28304 偏执石+0
|
||||
28308 创伤石+0
|
||||
28312 愚钝石+3
|
||||
28330 鸡血石+3
|
||||
28331 羊脂玉+3
|
||||
28332 羚角石+3
|
||||
28333 虹河石+3
|
||||
28334 青胆石+3
|
||||
28335 精石+3
|
||||
28336 鹰翼石+3
|
||||
28337 木鱼石+3
|
||||
28338 龙骨石+3
|
||||
28339 青石+3
|
||||
28340 彩芒石+3
|
||||
28341 鹿影石+3
|
||||
28342 东海石+3
|
||||
28343 帝王石+3
|
||||
28344 破碑之石+3
|
||||
28345 克首领之石+3
|
||||
28346 普攻强化石+3
|
||||
28347 技能强化石+3
|
||||
28348 普攻抵抗石+3
|
||||
28349 技能抵抗石+3
|
||||
28404 偏执石+0
|
||||
28408 创伤石+0
|
||||
28412 愚钝石+4
|
||||
28430 鸡血石+4
|
||||
28431 羊脂玉+4
|
||||
28432 羚角石+4
|
||||
28433 虹河石+4
|
||||
28434 青胆石+4
|
||||
28435 精石+4
|
||||
28436 鹰翼石+4
|
||||
28437 木鱼石+4
|
||||
28438 龙骨石+4
|
||||
28439 青石+4
|
||||
28440 彩芒石+4
|
||||
28441 鹿影石+4
|
||||
28442 东海石+4
|
||||
28443 帝王石+4
|
||||
28444 破碑之石+4
|
||||
28445 克首领之石+4
|
||||
28446 普攻强化石+4
|
||||
28447 技能强化石+4
|
||||
28448 普攻抵抗石+4
|
||||
28449 技能抵抗石+4
|
||||
28504 偏执石+0
|
||||
28508 创伤石+5
|
||||
28512 愚钝石+5
|
||||
28530 鸡血石+5
|
||||
28531 羊脂玉+5
|
||||
28532 羚角石+5
|
||||
28533 虹河石+5
|
||||
28534 青胆石+5
|
||||
28535 精石+5
|
||||
28536 鹰翼石+5
|
||||
28537 木鱼石+5
|
||||
28538 龙骨石+5
|
||||
28539 青石+5
|
||||
28540 彩芒石+5
|
||||
28541 鹿影石+5
|
||||
28542 东海石+5
|
||||
28543 帝王石+5
|
||||
28544 破碑之石+5
|
||||
28545 克首领之石+5
|
||||
28546 普攻强化石+5
|
||||
28547 技能强化石+5
|
||||
28548 普攻抵抗石+5
|
||||
28549 技能抵抗石+5
|
||||
28960 碎石片
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# vnum size flags anti flags: item_proto.txt size/flags changed on our server (tools/server/*), mirrored into the
|
||||
# client proto by locale_proto_patch so the item takes a cell and stacks like on the server.
|
||||
# 38001/38002 VIP 会员卡 (tools/server/vip-card): 40250 ships them size 0, no flags; now size 1,
|
||||
# ITEM_STACKABLE | ITEM_LOG (4 | 8192), ANTI_SELL (256).
|
||||
38001 1 8196 256
|
||||
38002 1 8196 256
|
||||
|
@@ -44,3 +44,12 @@ TOOLTIP_SKILL_DURATION 持续时间 : %d秒
|
||||
TOOLTIP_SP_REGEN 精力恢复量 : +%d%%
|
||||
TOOLTIP_TIME_CHARGER_FIX 时间充能 %d秒
|
||||
TOOLTIP_TIME_CHARGER_PER 时间充能 %d%%
|
||||
LOGIN_FAILURE_WEB_BLOCK 该账号已被封禁,详情请查看官网。
|
||||
MALL_CANNOT_INSERT 不能将物品放入商城道具栏。
|
||||
MAP_AG 盛唐帮会属地
|
||||
MAP_BG 秦皇帮会属地
|
||||
MAP_CG 汉武帮会属地
|
||||
PVP_OPTION_PROTECT 帮会模式
|
||||
SCREENSHOT_SAVE1 已保存
|
||||
SCREENSHOT_SAVE2 请在截图文件夹(screenshot)中查看。
|
||||
TOOLTIP_MEMORIZED_POSITION_ERROR 坐标记录错误(%d, %d)
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
KEY VALUE
|
||||
DRAGONSOUL_TAP_TITLE_1 白龙石
|
||||
DRAGONSOUL_TAP_TITLE_2 火龙石
|
||||
DRAGONSOUL_TAP_TITLE_3 风龙石
|
||||
DRAGONSOUL_TAP_TITLE_4 铁龙石
|
||||
DRAGONSOUL_TAP_TITLE_5 雷龙石
|
||||
DRAGONSOUL_TAP_TITLE_6 黑龙石
|
||||
@@ -0,0 +1,26 @@
|
||||
# 2026-10-17 顺序推进验收
|
||||
|
||||
## 戒指与中文界面
|
||||
|
||||
- 戒指十一分类在普通 QA1017 的真实客户端中显示并自动分页;通过菜单传送盛唐一村,服务端/客户端均确认地图 1,局部坐标 59700,68200(全局 469300,964200)。
|
||||
- Lua 5.0 沙盒覆盖全部分类、深层坐标、等级限制、关闭、传送限制及打开菜单后状态变化。49 个目的地按 203 的 map/index、Setting.txt 和原地图目录校验;修正迷雾/黑沙互换、升龙谷与恶鬼塔重叠、地图边界落点。
|
||||
- 帮会功能设施列表显示武器/防具/首饰锻造所及各类熔炉中文;仅打开本地预览窗口,没有发送建造命令。66 条设施名称已打包。
|
||||
- 龙魂石界面显示“龙魂之石”“白龙石”和中文品质页签;本次只检查界面,不计作龙魂功能/资格任务验收。
|
||||
- 语言包生成:locale_interface 326/326 键翻译、itemdesc 2182 个文本单元。百科目录已同步汉化变化,避免生成一致性回归失败。
|
||||
- 截图在忽略目录 build/ordered-acceptance-20261017/{ring-eleven-categories,guild-functional,dragon-soul,switchbot-dark-background}.png。
|
||||
|
||||
## 代码和回归
|
||||
|
||||
戒指、语言数据及生成器、小地图按钮分开提交。tests/wiki 的 85 项测试全部通过;自动洗练测试现在可定位 AVA2 实际目录,原文对比也已运行。
|
||||
macOS mt_native_render 构建通过,发布包包含完整资源及私有动态库,使用本地 ad-hoc 签名,不宣称公证。
|
||||
本轮未做 Android 真机验收,也未将较早的 port.login_flow 既存失败报告为通过。
|
||||
|
||||
## 自动洗练与后续能力
|
||||
|
||||
详见 AVA2-SWITCHBOT.md 的本日记录:真实 CG/GC 171 放入、洗练材料扣除、停止、目标已满足时自动完成已通过。背景改深灰,真实截图确认白字可读。
|
||||
正式服二进制哈希仍为 40335e41d466fd7379c805749978ad6df9c82f5673a3e5b8881b3bee8767663d;strings 确认 CSwitchbotManager / switchbot_end,SQL enum 有 SWITCHBOT。此次只对 sbtest 更新戒指及测试核心二进制,正式服未因本轮测试重启。
|
||||
sbtest 聚怪修复核心:8b3789ef541cede99cd2d2f97af2a724de431b632cb38fdf660ee0e3b3b15673,源码 server b625ba5。尚不宣称完成新核心战斗补拉验收。
|
||||
|
||||
仍待:其余实服戒指落点、属性锁定界面和跨核心洗练;原生批量开箱(滑块/Ctrl+Z/1000)、CG235 拾取/70002 状态、uitrack 双标签页。
|
||||
现有 /mt_chest、/mt_pickup 和两个自建追踪窗口保留,不能当成上述原生功能已经完成。
|
||||
冰雪前轮日志停在第五层,未使用 GM 清怪,也未完成全程;其结果保留在 acceptance-20261017/snow-run.jsonl,不计为通关。
|
||||
@@ -0,0 +1,33 @@
|
||||
# AVA2 聊天链接与活动洗练槽的锁定提示
|
||||
|
||||
接续 `AVA2-ATTR-LOCK-VIEWS.md`。参考 AVA2 `root/uitooltip.py` 的锁定行样式、`HyperlinkItemToolTip` 和 `uiswitchbot.SwitchbotItemTab.OverInItem`。保持本服七属性、三孔的物品封包,锁定位仍存于 `player.mt_item_attr_lock`。
|
||||
|
||||
## 同步
|
||||
|
||||
服务端 `PortAttrLockSend` 在自有物品设置、删除、更新、成功改变锁定和 switchbot 物品更新后发送 `AttrLockItem window cell vnum mask`。与对应物品封包在同一连接中有序发送;客户端保存当时的完整属性/孔快照,只有快照仍一致时才使用掩码。装备窗口和背包窗口共用装备格数据,缓存键统一为 INVENTORY。
|
||||
|
||||
初次装载物品时,游戏界面的命令接收器可能尚未存在;`GameWindow.Open` 时发送聊天请求又会被当前的 Game 阶段保护丢弃。因此界面打开后由更新回调延迟一秒发送 `/attr_lock_sync`,只读同步自己的背包、装备和五个洗练槽;收到 `AttrLockSync` 回执即结束。丢失时每2.25秒重试,最多三次。服务端每角色两秒限频,跳过多格物品的占位格,不接收任意角色ID。
|
||||
|
||||
只有已支持 AVA2 扩展的客户端收到元数据。SQL读取失败发送mask=-1,客户端清除该缓存;物品删除和断线也清理。没有有效缓存时保持原提示和链接,不把未知状态标成锁定。
|
||||
|
||||
## 聊天链接
|
||||
|
||||
原生 `player.GetItemLink` 继续生成名称、颜色和头部。有锁定缓存时,链接保存完整七个属性槽(包括空洞与稀有属性),末尾附加 `mtlock1:mask`。点击后使用发送时的固定快照,按 AVA2 的黄色 `<<属性>>` 样式显示;不查询收件人的背包,也不随原物品后续洗练或移动改变。聊天窗口的链接转发同时保留该后缀。
|
||||
|
||||
旧格式链接仍调用原始解析器。扩展格式检查确切字段数、vnum/flags/孔的32位范围、属性类型/数值范围和mask0~31;非法扩展隐藏提示并拒绝转发。该链接与原有物品链接一样是展示数据,不用于交易或修改物品。额外字段需要本轮客户端才能显示。
|
||||
|
||||
## 活动洗练槽
|
||||
|
||||
保留 AVA2 原 `SetSwitchBotItem` 的物品名称和“正在自动洗练”说明,再追加当前锁定行;不把不断变化的普通属性当作实时结果。收到新缓存时刷新,物品快照变更时隐藏旧提示,停止后切回普通装备提示。中文长句按照原ToolTip的实际文字宽度加40像素扩宽并居中,避免欧洲区按空格分词时说明超出边框。对标签页使用弱引用,关闭窗口不会被提示缓存持有。
|
||||
|
||||
## 验证与范围
|
||||
|
||||
- 客户端 `tests/wiki/test_attr_lock_snapshots.py` 运行实际安装脚本:空属性位/稀有属性、旧链接、非法输入、转发、物品移动、缓存失效、活动提示/停止转换、限次同步和断线清理。
|
||||
- 服务端 `tests/features/test_attr_lock_snapshots.py` 编译真实发送/同步函数:版本和窗口限制、删除、addon成组锁定、SQL失败、仅本人数据、多格去重和限频。
|
||||
- 全部132项客户端回归、服务端两个锁定测试、macOS原生构建和Android离线原生构建通过。Android真机按用户要求暂停。
|
||||
- 最终构建活动提示实测宽度348、最长文字308,边框余量40;`lock-snapshots-layout.json` 记录实际活动槽和mask=8。随后耗材耗尽正常停止,截图 `lock-snapshots-out-of-materials.png` 仅作耗材停止记录,不作为活动提示截图。
|
||||
- macOS/sbtest 的证据在 `build/parity-acceptance-20261018/lock-snapshots-*.json` 和 `lock-snapshots-proof-accepted.log`;测试驱动及账号配置不进入发行包。
|
||||
|
||||
正式服尚未部署本轮代码,AVA2全量系统对齐也尚未完成。后续仍有原生战令、百科/掉落查询、活动日历等条目,见 `AVA2-PARITY-PLAN.md`。
|
||||
|
||||
验收后已离线恢复测试武器1900000191的原属性、背包159格、无锁状态和902个洗练道具;原装备1900000015仍在装备槽4。sbtest按原配置重启,现役game为 `8622d6bc…`,正式服仍为 `40335e41…`。备份与 `cleanup-result.json` 在服务器 `/root/deploy-features/20261018-ava2-parity/attr-snapshots`。
|
||||
@@ -0,0 +1,36 @@
|
||||
# AVA2 属性锁定提示:其他物品视图
|
||||
|
||||
AVA2 `uitooltip.py` 从属性槽7/8取锁定序号,普通属性用 SPECIAL_TITLE_COLOR 和 `<<文字>>` 显示;背包、交易、商店、仓库和装备查看共用这条渲染路径。本项目保持七属性基础封包和独立锁定表,通过只读桥接取得相同的显示信息。
|
||||
|
||||
`AttrLockViewsScript.inc` 调用原 tooltip setter 重画完整内容,保留商店价格、仓库 flags 等;只替换锁定属性行的样式。摆摊编辑仍查询自己的背包。使用弱引用保存 tooltip/他人装备窗口,避免 Python 2 含析构对象的引用环。
|
||||
|
||||
## 查询契约
|
||||
|
||||
保留原 `/attr_lock_info token window cell` 自有物品请求,视图扩展为 `/attr_lock_info token context cell vid`。
|
||||
|
||||
| context | 范围 | 服务端约束 |
|
||||
| --- | --- | --- |
|
||||
| 101 | 自己的交易栏 | 当前互相关联的交易,按显示格查找,物品仍属自己且处于交易中 |
|
||||
| 102 | 对方的交易栏 | 同一交易的对手,只查已摆出的物品 |
|
||||
| 103 | 当前玩家商店 | 查询者仍是访客,物品仍属于店主,ID/vnum与在售记录一致 |
|
||||
| 104 | 自己的仓库 | 仓库已加载,格子在实际容量范围内 |
|
||||
| 105 | 自己的商城仓库 | 商城仓库已加载,格子在实际容量范围内 |
|
||||
| 106 | 他人装备查看 | 沿用当前服 do_view_equip 的GM权限,只能取装备槽;vid为已查看的角色 |
|
||||
|
||||
除106外,vid必须为0;不能用其他玩家ID查询背包、仓库或交易以外的物品。每个角色每秒至多一次查询,SQL首次加载失败返回-1,不能当作“没有锁定”。旧服务端忽略新上下文时,仍显示原始物品内容。
|
||||
|
||||
客户端收到回复时检查请求序号、视图、格子、vnum、属性/孔快照和容器代次。交易/商店刷新、关闭、仓库关闭以及装备查看内容变化会隐藏旧提示;迟到回复不能把已关闭视图重新染色。断线清理全部视图状态。
|
||||
|
||||
## 验证
|
||||
|
||||
- 服务端 `tests/features/test_attr_lock_views.py` 直接编译实际查询、显示格查找和访客物品函数,验证归属、访客关系、非连续显示格、关闭容器、GM权限、非法参数、限频和SQL失败。
|
||||
- 客户端 `tests/wiki/test_attr_lock_views.py` 执行实际嵌入脚本,验证各视图高亮、价格保留、刷新/关闭后的迟到回复,以及弱引用释放。
|
||||
- macOS 两个独立普通QA角色已完成双方交易、自有摆摊预览、查看在售物品、仓库管理员正常开仓和商城仓库提示;高亮值为第4条 `(4,6)`,mask=8。另验证关闭交易/商店后的请求没有返回物品信息,普通玩家无法查询他人装备锁定信息。
|
||||
- 另在独立 `common_sb` 临时授权QA角色,真实 `/view_equip` 查看另一角色已装备武器,确认context106返回mask=8并显示锁定行。原摆摊预览和在售提示都保留12345价格。交易内容刷新使旧提示隐藏,商城/仓库关闭清理状态。
|
||||
- 本机证据:`build/parity-acceptance-20261018/attr-view-*.json`、`peer/attr-view-*.json`、`attr-view-exchange-live.png`、`attr-views-warehouse-proof.log`。测试驱动不进入发行包。
|
||||
|
||||
客户端126项回归、macOS及Android离线编译通过。首个驱动曾用多格物品无效位置、基线禁用的交易删除接口及未经过NPC的仓库密码请求,均未据此修改业务逻辑;最终真实交易、摆摊和NPC仓库各自完成。GM查看证据为 `peer/attr-view-equipment.json`;驱动未处理原武器交换到159格的占位,最后归位断言未通过。测试后停止缓存并备份、核对两件物品ID及所有者,离线将原武器1900000015恢复装备槽4,测试武器1900000191恢复背包159格,该拖回断言不计为通过。
|
||||
|
||||
已移除本轮新增账号、角色、夹具和 `common_sb` 临时GM行,恢复测试武器原无锁状态。恢复操作有SQL备份;sbtest按原CONFIG重启,现役测试game为 `03a7b74a…`,正式服仍 `40335e41…`。清理核对见 `attr-views-cleanup-result.json`;远端备份、日志和结果在 `/root/deploy-features/20261018-ava2-parity/attr-views`。没有修改正式库或正式服二进制。
|
||||
|
||||
后续扩展:聊天链接和活动洗练槽的独立锁定元数据接入见 [锁定快照](AVA2-ATTR-LOCK-SNAPSHOTS.md)。手机真机验收按用户要求暂停,正式服尚未部署本轮变更。
|
||||
@@ -52,3 +52,9 @@
|
||||
- 副本等地图没有做客户端限制:退出后重新登录由服务端按原规则决定角色位置。
|
||||
- macOS 桌面客户端没有中文字体,窗口文字显示为 `?`。
|
||||
- Android 真机测试未做。
|
||||
|
||||
## 2026-10-18 核实与后续
|
||||
|
||||
本地现已提取 AVA2 服务端源码,旧文“服务端源码不在本机”已过时。启用的路径是 do_cmd(SCMD_CHANGE_CHANNEL)→3秒事件→CHARACTER::MoveChannel;原生 uisystem.ChangeChannelWindow 发送 /move_channel。另一个 do_change_channel/ChannelSwitch 分支是注释掉的旧代码,不能照它实现。
|
||||
|
||||
当前 v1 仍是退出重登,故会停止自动洗练。跨核心地图传送已在双测试核心验证 P2P 续洗;跨频道续洗尚未实现。移植实际启用的路径时需适配203的端口布局,不能直接使用 AVA2 写死的100端口步长。
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
# AVA2 原生开箱与拾取接入
|
||||
|
||||
更新:2026-10-18。当前仅部署 sbtest;正式服没有替换二进制或原型。整体 AVA2 对齐任务尚未完成。
|
||||
|
||||
## 开箱
|
||||
|
||||
使用 AVA2 `root/uichestdropinfo.py` 与 `UIScript/ChestDropInfoWindow.py` 的窗口、奖励分页、数量滑块和 `/chest_drop <window> <cell> <count>`。Ctrl+右键预览;Ctrl+Z+右键直接请求当前堆。触屏道具操作菜单继续连接同一个窗口。服务端移植 `OpenChest`、`GiveItemFromSpecialItemGroupNew`、`AutoGiveItemChest`,新界面不再走 `/mt_chest`。
|
||||
|
||||
GC66 的原始布局是 1 字节包头、DWORD 总长度、宝箱 VNUM、奖励条数、VNUM/数量对。接收端先缓存完整帧,再验证条数与总长。掉落缓存随会话清空,迟到响应不会打开关闭的窗口或覆盖另一个宝箱。预览按原版 5×8 网格及物品高度分页。
|
||||
|
||||
当前基础包保留 BYTE 物品数量和 200 单堆上限。请求上限为 AVA2 的 1000,但实际只能开启当前格持有的数量,不能声称已支持单堆 1000。大于 200 的奖励拆成多堆;非堆叠奖励逐个创建,MAKECOUNT 的最小数量不会造成循环下溢。没有改动其他基础物品封包。全服扩大单堆数量仍是后续协议迁移项。
|
||||
|
||||
适配中的修复:滑块不会发 0;空格和替换道具拒绝;交易、锁定、已装备、死亡、观察、传送、商店/仓库/合成状态拒绝;保留基础服等级、竞技场和龙魂资格限制;已有和批次新建的堆均检查孔值;奖励提示走可本地化的服务端命令。原版特殊组的金币/经验/异常效果仍经过对应分支,不把旧版逐个 UseItem 冒充原生发奖。
|
||||
|
||||
## 拾取
|
||||
|
||||
原生 CG235:5 字节头(BYTE header + DWORD count),后接 count 个 DWORD 地面 VID 和常规序列字节。按 AVA2 的客户端收集范围、所有权筛选、500ms 发送间隔发包,服务端最终检查地面状态、距离、所有权、角色状态和分类。计数上限及乘法检查在读 VID 前完成。
|
||||
|
||||
原版 `game_option_0_1.py` 面板提供 18 个“忽略分类”;bit 0 开启,bit 1–18 分别为武器、铠甲、盾、戒指、头盔、手镯、项链、耳环、时装、宠物/坐骑、肩带、护符、书、灵石、金币、宝箱、鞋、腰带。修正 AVA2 服务端“宝箱分类使用 ITEM_METIN”的明显误写。设置通过 `/setpickupmode` 与 `PickUPMode` 回传,原有 `/mt_pickup` 只保留旧客户端兼容。
|
||||
|
||||
为了保留当前 DB 基础结构,mode/rarity 使用现有角色 quest 标记 `ava2_pickup.mode` / `.rarity` 持久化,而非扩大 TPlayerTable。客户端早期请求不返回未加载的默认值;QuestLoad 完成后主动同步,提前修改不能覆盖旧值。
|
||||
|
||||
70002 按 AVA2 恢复 ITEM_USE/USE_SPECIAL,使用消耗一个并添加 705 状态,持续 30 天;重复使用不消耗。倒计时及原版图标随普通 affect 持久化。AVA2 的此处实现仍由拾取键触发,不声称额外实现了无人操作定时拾取。
|
||||
|
||||
当前项目尚无 AVA2 稀有度物品系统,稀有度按钮明确禁用;宠物、未移植时装槽等分类会随相应系统补齐。不能把这部分算作全部能力完成。
|
||||
|
||||
## 公共 UI 与资源
|
||||
|
||||
`Ava2UICompatScript.inc` 补入原版 SetListText/text_x 分支,避免复选框标签盖住勾选框。原始窗口资源进入 ava2items。v1/v2 `.sub` 的图集依赖递归入口统一解析并复制到 `ui/ava2_native/`,不覆盖基础 UI 同名图集;缺依赖时打包失败,避免发布后窗口 Abort。经典窗口脚本未改。
|
||||
|
||||
底层背景拉花另见 `audit/evidence/2026-10-18-ui-addressing.md`:UI 采样现在保留 D3D8 U/V wrap/mirror/clamp。
|
||||
|
||||
## 验证与部署边界
|
||||
|
||||
- 客户端 Python UI/数据回归 92 项通过;物品导入与图集依赖 20 项通过;原始 138 条石头审计继续通过。
|
||||
- 两个服务端测试直接编译执行生产路径:开箱覆盖堆叠、孔隔离、空背包/满背包、状态、等级、龙魂资格、450 个奖励拆堆、非堆叠和 MAKECOUNT;拾取覆盖截断、溢出、开关、距离、所有权及宝箱/灵石独立过滤。
|
||||
- FreeBSD 隔离编译、macOS 原生构建及测试包签名通过。Android arm64 增量原生编译与 debug APK 打包通过,APK 内 libmain.so 哈希与本次编译产物一致;MeshPort 使用现有未修改的缓存静态库,完整脚本因本机无 cargo 不能从头重建 SDK。adb 无设备,未做 Android 真机验收。
|
||||
- 普通 QA1017 / player_sb:GC66 预览返回 10 条实际奖励;滑块 5 个使宝箱 20→15;真实背包回调的 Ctrl 分支打开窗口,Ctrl+Z 分支使剩余 15→0。修饰键仅在同步测试回调中临时模拟,finally 恢复;不声称已完成物理键盘快捷键验收。
|
||||
- 真正网络 CG235:忽略灵石时药水取回、灵石留地;取消过滤后灵石取回。第三只手激活、重复不消耗、冷重启测试 db/auth/core 后设置/余量/状态/图标恢复通过。初始化竞态正是在冷重启中发现并修复。
|
||||
- 证据在忽略目录 `build/parity-acceptance-20261018/`;私有驱动和登录凭据不随资源包发布。
|
||||
- 测试构建目录 `/root/deploy-features/20261018-ava2-parity/`。70002 两套原型备份 `backup-pickup-proto/`;测试物品与 QA 原始道具快照 `fixture.json` / `qa-items-before.json`。
|
||||
- 回退只操作 sbtest:停止测试集群,恢复上述 conf/db 原型备份,channel5/first/game 指回 sbtest/game.ava2-stones,再启动测试集群。不得覆盖正式服 share/bin/game。
|
||||
|
||||
Android 测试 APK 在 android/app/build/outputs/apk/debug/app-debug.apk;配套资源为 build/ava2-parity-20261018/Client。连接设备后应显式用 `android/push-client.sh --locale zh build/ava2-parity-20261018/Client` 同步配套资源,再以 sbtest 端口启动;本轮没有安装到设备或改动其数据。
|
||||
|
||||
下一项是原版 uitrack 双页及其权威服务端数据;其他系统仍按 AVA2-PARITY-PLAN 逐项推进。
|
||||
@@ -0,0 +1,45 @@
|
||||
# AVA2 批量开箱适配进度(v1)
|
||||
|
||||
2026-10-15。修改了 metin2-client 和 metin2-server,AVA2 代码只作参考(`ENABLE_MULTI_CHEST`:`uiinventory.py` 的 Ctrl + 右键、`uichestdropinfo.py`、服务端 `do_chest_drop` / `CHARACTER::OpenChest`)。服务端规则和协议见 `metin2-server/docs/FEATURE-CHEST.md`。
|
||||
|
||||
## 与 AVA2 的差异
|
||||
|
||||
| 项目 | AVA2 | 本实现 |
|
||||
| --- | --- | --- |
|
||||
| 触发 | Ctrl + 右键打开带滑块的窗口;Ctrl + Z + 右键直接开整叠 | Ctrl + 右键打开数量窗口(1 / 10 / 50 / 全部),点“开启”;没有直接开整叠的组合键 |
|
||||
| 命令 | `/chest_drop WINDOW CELL COUNT` | `/mt_chest 1 open CELL COUNT`,不新增包头 |
|
||||
| 开箱过程 | 重写的 `GiveItemFromSpecialItemGroupNew` / `AutoGiveItemChest`,单次最多 1000 | 每个礼盒都调用原 `UseItem` 礼盒路径,检查、奖励组抽取、金币/经验、日志、扣除都不变;单次最多 200 |
|
||||
| 范围 | 一叠 | 同一种礼盒,先开选中的格子,再开背包里其他格子(203 上多数礼盒不叠加) |
|
||||
| 背包满 | 由 AutoGiveItemChest 处理 | 每开一个前要求至少 3 格空位,不足就停止,奖励不会掉在地上 |
|
||||
| 不允许批量 | — | 奖励组含刷怪、怪物组、减速、中毒、吸血的礼盒,以及非 ITEM_GIFTBOX 的物品(例如带任务脚本的宝箱) |
|
||||
|
||||
## 客户端
|
||||
|
||||
- 模块 `mt_chest`(`src/platform/ScriptLib/ChestScript.inc`),在 `PythonBoot.cpp` 中安装。替换了 `uiInventory.InventoryWindow.UseItemSlot`:按住 Ctrl 右键 ITEM_GIFTBOX 时打开窗口,其他情况调用原方法。原方法本身不使用 Ctrl(联机时检查过它的 `co_names`)。
|
||||
- `PythonItemModule.cpp` 新导出 `item.ITEM_TYPE_GIFTBOX`。
|
||||
- 窗口显示礼盒名称、背包内总数、数量按钮(`【】` 表示已选;“全部”最多 200)、开启按钮和上次结果。选中格子里的礼盒被移走时,自动改用背包里同一种礼盒的其他格子。
|
||||
- 等待回复时,以及两次发送间隔不足 0.5 秒时,“开启”按钮不可用。
|
||||
- 结果:聊天框一行“开启 N 个,金币 +N(停止原因)”,之后每行最多 5 种获得的物品(名称 ×数量)。单个礼盒的提示由服务端暂存,不再逐条刷屏;被原路径拒绝时转发一次拒绝提示。
|
||||
- 3 秒没有回复:在聊天框提示一次“服务器尚未启用批量开启”,之后 Ctrl + 右键也走原来的单个使用;再收到回复会自动恢复。
|
||||
- 经验不在汇总里(服务端只汇报背包物品和金币变化)。
|
||||
|
||||
## 证据
|
||||
|
||||
- `tests/wiki/test_chest.py`(CTest:`port.chest`)共 6 项通过,覆盖:
|
||||
- 发送一次、等待回复、获得行累积到 done、数量上限 200、负的金币差、发送间隔;
|
||||
- error 解析,畸形行和其他前缀;
|
||||
- 超时后标记不支持,迟到的回复会恢复;
|
||||
- 聊天汇总行(停止原因、金币、每行 5 种);
|
||||
- 钩子:不按 Ctrl 和非礼盒走原方法,Ctrl + 右键礼盒打开窗口,“全部”,选中格子消失后改用其他格子,命令拦截,超时后回退,窗口关闭;
|
||||
- 与服务端 `port_chest.h` 的常量、错误码和停止原因一致。
|
||||
- `tests/wiki` 全部 57 项通过(1 项跳过)。
|
||||
- 2026-10-15 在 203 channel5 测试核心(13040,独立二进制)用 macOS 客户端以 [SA]Admin 联机验收,礼盒用 `/item` 生成:
|
||||
- 50037(可叠加,30 个)开 10 个:`done 50037 10 10 done 0`,获得 6 种物品,背包差值与 `MTCH1 got` 完全一致;
|
||||
- 50070(不叠加,4 个分在 4 格)开全部:`done 50070 4 4 done 100000`,跨格子全部开启,金币 +100000 与余额变化一致;
|
||||
- 71036(奖励组刷怪):`error kind`,没有扣除;
|
||||
- 连发两条命令:第二条 `error rate`;
|
||||
- 50037 剩余 20 个开全部:`done 50037 20 20 done 0`,获得 11 种;
|
||||
- 不按 Ctrl 右键:原单个使用,礼盒正常扣除;
|
||||
- 日志库只有原路径写的 `SYSTEM`、`TREASURE_EXP`、`TREASURE_GOLD` 行;syserr 没有新错误(只有原有的 `new_quest_lv52` LUA_ERROR)。
|
||||
- 2026-10-15 16:43 部署到 203 正式环境(服务端 bc32475),CH1(13000)用同一场景复验通过(50037 开 10 个 / 剩余 20 个、50070 跨 4 格、71036 拒绝、限速、普通右键不变)。
|
||||
- 未做 Android 真机测试;触屏没有 Ctrl,暂无触屏入口。
|
||||
@@ -115,7 +115,7 @@
|
||||
|
||||
2026-10-15 后续批次:阶段 0 的只读能力协商、阶段 2/3 的掉落/来源/宝箱查询、阶段 4 属性面板已实现并在隔离环境测试;未部署 203,待联机与真机验收。范围和缺口见 AVA2-READONLY-FEATURES.md。
|
||||
|
||||
2026-10-15 再续:龙穴/周任务信息与提醒、共享真实掉落开关的活动日历已实现并在隔离环境验证。副本仅首批龙穴;活动仅月光宝箱/圣诞袜,生产未部署,无生产排期。自动洗练/锁定、战令、模型预览、批量开箱仍待实现。见 AVA2-DUNGEON-CALENDAR.md。
|
||||
2026-10-15 再续:龙穴/周任务信息与提醒、共享真实掉落开关的活动日历已实现并在隔离环境验证。副本仅首批龙穴;活动仅月光宝箱/圣诞袜,生产未部署,无生产排期。自动洗练/锁定、战令、模型预览、批量开箱仍待实现(2026-10-16:模型预览已实现,见 FEATURE-MODEL-PREVIEW.md)。见 AVA2-DUNGEON-CALENDAR.md。
|
||||
|
||||
2026-10-15 自动洗练 v1(阶段 6,不含属性锁定):服务端 mt_switchbot 逐次调用原 UseItem 洗练路径,客户端 mt_switchbot 窗口;隔离环境编译与桩测试通过,macOS 客户端已在 203 测试核心联机验收;未部署 203 正式环境、未做 Android 真机测试。属性锁定仍待存储设计。见 AVA2-SWITCHBOT.md。
|
||||
|
||||
@@ -125,3 +125,6 @@
|
||||
|
||||
2026-10-15 换线(计划外追加,参考 AVA2 ENABLE_CHANNEL_CHANGE):仅客户端,按原流程 /logout → 登录目标频道(serverInfo 频道表 + 保存的账号)→ isAutoSelect 进入同一角色,不做服务端传送;macOS 客户端已在 203 正式频道 CH1↔CH2 联机验收,未做 Android 真机测试。见 AVA2-CHANNEL.md。
|
||||
2026-10-15 世界 Boss 追踪(AVA2 uitrack 世界 Boss 页,只读,不含传送):服务端各核心用原 HEADER_GG_RELAY(名字 #mt_boss)共享定时 Boss 刷新点,旧核心忽略;客户端 mt_boss 窗口 + 刷新提醒,查询种类 bosses(能力位 256);已在 203 两个 channel5 测试核心上做跨核心联机验收,正式核心尚未部署。见 AVA2-BOSS.md。
|
||||
2026-10-15 属性锁定(阶段 6 后半,参考 AVA2 ENABLE_LOCK_ATTR):服务端新表 mt_item_attr_lock(按物品 ID 存锁定掩码,各核心启动时自动建表;不改动物品结构、db 缓存和客户端封包),CItem::ChangeAttribute 保留锁定槽位,手动、自动、GM 洗练全部生效;精炼时锁定随属性复制;最多 2 组,加成武器的 0/1 槽算一组;锁定免费。客户端在自动洗练窗口里加 5 个锁定按钮。已在 203 channel5 测试核心联机验收(洗 10 次锁定的 2 条不变,重新登录后仍在);2026-10-15 16:08 部署到 203 正式环境(服务端 dc71593),CH1 复验通过;未做 Android 真机测试。见 AVA2-SWITCHBOT.md 和服务端 FEATURE-ATTR-LOCK.md。
|
||||
|
||||
2026-10-15 批量开箱(阶段 3 的交互子批,参考 AVA2 ENABLE_MULTI_CHEST /chest_drop):服务端 mt_chest 对同一种礼盒(ITEM_GIFTBOX)逐个调用原 UseItem 开箱路径,可跨格子(203 上多数礼盒不叠加),单次最多 200 个,背包少于 3 格空位即停止;奖励组含刷怪/减速/中毒/吸血的礼盒不允许批量。客户端 Ctrl + 右键礼盒打开数量窗口(1/10/50/全部),结果汇总到聊天框。已在 203 channel5 测试核心联机验收;2026-10-15 16:43 部署到 203 正式环境(服务端 bc32475),CH1 复验通过;未做 Android 真机测试和触屏入口。见 AVA2-CHEST.md 和服务端 FEATURE-CHEST.md。
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
# 2026-10-16 AVA2 上线后补全记录
|
||||
|
||||
基线:客户端 569afb13、服务端 e097b92,均为 feature/ava2-unlock;SDK main 62a5f5a。
|
||||
|
||||
## 退出崩溃
|
||||
|
||||
`PythonBoot::Stop` 先清空飞行物,再销毁角色及其他管理器,恢复原版 `CPythonApplication::Destroy` 的依赖顺序。飞行物清理附件时仍需访问效果管理器,原来的析构顺序造成已销毁单例访问;角色清理也需在 text-tail/item 管理器之前。
|
||||
|
||||
`port_app_loop_test` 在退出时保留一个真实飞行物,修复前退出 139,修复后退出 0;重复 Stop 通过。证据:`build/followup-shutdown-before.log`、`build/followup-shutdown-after.log`。该函数其他未移植行为仍为 DIVERGENT,未提升为完整原版一致。技能要求的 `scripts/port_map.py` 在当前分支不存在,未宣称通过该检查。
|
||||
|
||||
## 密集怪物自动狩猎
|
||||
|
||||
攻击/技能视线判断以前会对挡住的目标完整运行 A*,随后因不是单段路径而拒绝攻击。现在复用同一条直线与体积检查,挡住时直接返回;真正移动寻路仍完整运行 A*。聚怪检测先执行冷却、状态、HP 等廉价条件,再扫描怪物。
|
||||
|
||||
导航回归覆盖开放直线、薄墙、大目标和 240 个被遮挡目标。相同攻击可达性结果下,碰撞查询从 502128 次降为 6432 次(约减少 98.7%)。这是固定场景算法测试,不能代表冰雪副本通关耗时;200 多只怪物楼层仍需无 `/purge` 联机复测。
|
||||
|
||||
## 宝箱和动作资源
|
||||
|
||||
打包器原来见基础 npclist 已有 9018 就跳过整个模型目录。现在种入所有需要的 AVA2 模型文件,再由资源闭包跳过已存在文件;模型编号已知不再等同于资源齐全。
|
||||
|
||||
已实际生成 `build/followup-ava2maps/ava2maps.eix/.epk`(4243 文件),核对包含 hydra_chest 模型、msm、motlist、loop/break/attack/drop 动作及模型引用纹理。用隔离资源目录运行原生假服务器场景,9018 宝箱模型和贴图正常显示,90 帧后正常退出(退出码 0),截图 `build/followup-chest-smoke.png`。该场景不是正式服船防验收。
|
||||
|
||||
motlist 现在参与资源依赖检查,maps.json 的 missing_motions 明确列出缺失文件。本机原始 AVA2 目录仍缺少:
|
||||
|
||||
- defensewave_hydra_boss/drop.msa(以及原始 drop.gr2);
|
||||
- defensewave_minihydra/special_attack1.msa(以及对应原始动作模型)。
|
||||
|
||||
完整扫描还报告 blue_dragon_red/water_dragon_2.gr2、reddragon_room_boss2/normal_attack.msa、zone/eastplain/gaint_build a_01_d.gr2,以及两个 hydra 地形纹理。未通过复制其他动作冒充原始文件。2026-10-16 已继续核查整个客户端包集合:完成 FoxFS 只读解析,46 个包、94,220 个条目均无这四个动作文件;XML 清单、展开源目录和 FILES+SRC.tgz 服务端备份也无对应文件。八个已有资源通过 XXH32 校验并与源文件逐字节一致,原包 motlist 仍包含缺失引用。详见 `docs/AVA2-RESOURCE-AUDIT-20261016.json` 和 `tools/foxfs/README.md`;不能将该分发包自身的缺失引用归为移植漏拷。VDI 未挂载,不声称已清点其文件系统。
|
||||
|
||||
## NPC / sash / 任务函数
|
||||
|
||||
实现、安装、回滚和 sbtest 验收边界见 `tools/server/ava2-followup/README.md`。十个地图目的地可通过现有传送 NPC 菜单进入,三个实例副本送到原入口 NPC;sash 沿用已有任务;只补缺失的 GFquestlib 函数。正式服尚未安装。
|
||||
|
||||
## 构建与剩余验收
|
||||
|
||||
macOS `mt_native_render` 与 Android Release 原生构建均通过,APK 在 `android/app/build/outputs/apk/debug/app-debug.apk`。退出回归、导航回归和 Lua 5.0 测试通过。生成资源包通过,原始缺失资源如实记录。
|
||||
|
||||
未完成的验收:补齐原始动作;真实客户端 NPC 与 sash 点击流程;冰雪密集层全程自动狩猎;正式服启用。不能将过去使用 GM 清怪的楼层计为自动狩猎通过。
|
||||
|
||||
## 2026-10-17 真实客户端验收进展
|
||||
|
||||
使用独立普通角色 QA1017(仅 account_sb/player_sb),未更改 Test 账号或正式服玩家。密码和验收驱动保存在忽略的 build/acceptance-20261017/private,不随客户端发布。
|
||||
|
||||
- 铁匠 20016 的说明、合成和属性吸收菜单可用,真实 CG/GC sash 窗口打开。
|
||||
- 首次验收发现原型导入只选择四件四阶披风,缺少 12 件低阶材料。现在从 AVA2 原始 DumpProto 补齐四组完整合成链;保持 value0 的 1~4 阶与客户端/服务端一致。净化书不在本批开放范围(服务端尚未实现专用清除逻辑)。
|
||||
- 真实合成:85001 + 85001 → 85002,socket0=5,第二件消耗,金币减少 100000。
|
||||
- 真实吸收:85004(20%)吸收 19 号武器,武器消耗,socket1=19;该测试武器没有额外属性,尚不能据此认定非零随机属性复制已经验收。
|
||||
- 退出后数据库确认上述披风结果保存。重登后客户端也确认 socket0=5、socket1=19 保持。
|
||||
- 传送 NPC 20090 两页菜单显示正常,从「冰雪地下城入口」传送到地图 61,点击 20395、普通玩家单人进入地图 352 成功并扣除门票。
|
||||
- 首轮冰雪自动狩猎:旧装备、20 组聚怪,第一层很快死亡,未通过。未使用 /purge。下一轮只在隔离 QA 角色使用有备份的战斗测试属性;结果用于功能/流程验收,不代表普通玩家平衡或真实清图速度。
|
||||
|
||||
sbtest 独立 db 目录保存原型副本,安装器现在同步并备份这些副本,避免 share/conf 已更新但 db 仍读取旧文件。此次补丁备份:/root/deploy-features/20261017-followup/acceptance/sash-stage/backup;战斗装备原值在同目录 combat-backup.json。
|
||||
|
||||
客户端完整资源生成通过(7537 件物品、1468 怪物、4243 地图资源文件),16 项物品回归通过。新增 --ava2-maps-root 支持原始资源的独立展开目录;物品和坐骑原型均支持从原始 FILES+SRC.tgz 读取,不依赖本机 AVA2/TEST 路径。
|
||||
|
||||
本批传送/披风任务和新增低阶原型仍只在 sbtest,尚未正式服推广。旧任务点击、冰雪无清怪通关、最终发布包还未完成。
|
||||
|
||||
第二轮已由客户端自动狩猎完成第一层,约 210 秒进入第二层,未执行 GM 清怪命令;使用 QA 专用测试装备(武器怪物伤害 +100%、攻击 +5000、暴击/穿透 100;铠甲 HP +30000、防御 +1000、冰抗/格挡/闪避 100),不能据此比较普通装备的效率。日志在忽略目录 snow-run.jsonl。
|
||||
|
||||
部署排查修正:整份 conf 覆盖 db 会丢掉原有 db 独有的 25170/30331–30333,第二轮因此无法掉落封印钥匙,已中断。已从最初备份恢复 db,再逐表合并 16 件披风;安装器回归现在明确验证 db 独有行保留。恢复后的磁盘原型已核对四件副本道具,下一次隔离重启加载。第二层及之后不能计为通过。本次事故未涉及正式服。
|
||||
|
||||
### 击退进入禁行格时的自动狩猎卡点
|
||||
|
||||
第三轮在第一层 (18730.742,22544.762) 卡住,日志持续输出目标距离约 90 却无路径。原始雪地图 attr.atr 确认角色站在禁行的第 225 行,相邻第 224 行可走。原来的“只放行精确起点”无法通过任何后续采样,导致目标选择和攻击视线均被拒绝。
|
||||
|
||||
新增 TerrainWalkable 允许离开当前占用的已加载禁行格;相邻禁行格、未加载数据、静态体积碰撞和原来薄墙/拐角检查保持。使用捕获坐标和原属性布局回归:旧回调无路,新回调能到相邻怪物;穿过更深禁区及未知区域仍拒绝。macOS 已重新构建;完整副本复测尚在进行。该模块是用户授权扩展,没有宣称与 40250 逐语句一致。
|
||||
|
||||
旧 52 级任务已真实点击“警备队长的信”(任务 144),数据库状态由 letterfromboss 推进到 askbeakgo(574123079),ghostsleft=4。随后地图 61 重登时该状态的 is_destination_village 分支无报错;主城返回 NPC 的正向分支仍需后续确认。
|
||||
|
||||
导航专项、聚怪安全检查通过;macOS/Android 原生构建及 APK 封装通过,APK 中 libmain.so 与本次构建逐字节一致。port.login_flow 较大回归失败 29 个检查;临时恢复本次修改前的两个导航源码后重建重跑,失败位置和数量完全一致(频道状态、商店、NPC、仓库),随后已恢复当前源码并重建。该测试不能报告通过,也未将现存失败归为本次导航回归。日志:build/acceptance-20261017/{nav-escape-tests,baseline-login-flow}.log。
|
||||
@@ -0,0 +1,20 @@
|
||||
# AVA2 原生换线
|
||||
|
||||
客户端采用 AVA2 `root/uisystem.py::MoveChannelDialog` 和 `UIScript/MoveChannelDialog.py`。复用小地图原换线入口;收到服务端 `ChannelList` 后使用原生窗口,点击切换发送 `/move_channel N`。频道号按服务端列表绑定,支持不连续的测试频道5、6。资源由 `make_items.py` 放入 ava2items,包含原选择按钮及其 sub 引用纹理。
|
||||
|
||||
服务端按 AVA2 实际启用的 `do_cmd(SCMD_CHANGE_CHANNEL)` 执行3秒倒计时,重复命令取消。倒计时结束再次校验状态,然后 `MoveChannel` 使用现有 `WarpSet` 的保存、移除实体和 P2P 洗练状态转移。不会退出登录或清除洗练目标。服务端拒绝死亡、眩晕、交易/商店/强化等忙碌状态、运行中的任务、受限制地图、私人副本,以及未通告目标地图的频道。
|
||||
|
||||
原 AVA2 按100递增端口,不能直接用于203。适配通过同一DB集群的 P2P 核心通告真实游戏端口和 MAP_ALLOW,校验已连接对端的频道/P2P端口身份;5秒心跳、30秒过期,断开立即删除,同频道同地图出现重复归属时拒绝。没有修改经典 GC Warp 封包。
|
||||
|
||||
进入核心时服务端主动发送列表,覆盖首次登录和同地图换线。`UpdateServerInfo` 沿用原版命令更新当前频道和文字;扩展 `ChannelEndpoint` 保存目标游戏地址并保留原auth地址,避免换线后退出重登又回到之前频道。私人地图只列本频道;99频道保留只读窗口。没有原生列表的旧服务端继续用现有退出重登入口,该路径会停止洗练,不能视为原生续洗。
|
||||
|
||||
## 验证
|
||||
|
||||
- macOS/sbtest:CH5:13040→CH6:13050→CH5,洗练active保持1,两个备选目标与第4条锁定值不变,71084为1034→976→919;停止后退回物品并解锁。
|
||||
- 同频道、未开放频道、重复命令取消、任务选择中的拒绝均已验证;换到6后退出重登仍在6,auth仍11040;关闭6后列表只剩5且拒绝旧目标。
|
||||
- 客户端回归119项通过:`python3 -m unittest discover -s tests/wiki`,包括地址校验、auth保留、不连续频道、窗口替换、非法列表、99频道和原生按钮命令。
|
||||
- 服务端路由:`python3 tests/features/test_ava2_channel_registry.py`,覆盖对端身份、地图归属、过期、断开、歧义和原子拒绝非法快照。
|
||||
- macOS和Android原生编译;Android只离线编译,用户暂停手机验收。
|
||||
- 截图和联机测试记录在本机 `build/parity-acceptance-20261018`,不会打入客户端包。
|
||||
|
||||
正式服部署与验收仍需单独完成。
|
||||
@@ -0,0 +1,35 @@
|
||||
# AVA2 原生战令、百科、掉落和日历
|
||||
|
||||
用户授权完成这三组界面、测试后更新203正式服;不进行手机真机测试。
|
||||
|
||||
## 实现
|
||||
|
||||
- 原版脚本:`uiBattlePassEx`、`WikiUI`、`uiWiki`、`uiDropItem`、`uiEventCalendarNew`。原始内容仅转编码/换行;`tools/ava2-native/sources.json` 记录原件哈希。平台和服务器适配另存,原 CWindow 算法未改。
|
||||
- 战令实际采用 `/battle_pass info|activate|reward|close` 与 `BattlePass*`。230 是另一代旧窗口。当前九种服务端任务映射 AVA2 枚举;现有赛季、任务槽与进度/领取主键保留。原生客户端任务完成自动领奖,满包保留待领,重新打开重试;最终奖励需要点击,重复请求不再发奖。旧 `/mt_bp` 继续兼容。
|
||||
- 25150~25161 票由真实月份/服务端校验,确认对话后消耗,沿用原激活规则。SQL 使用 PLAYER_SQL 配置的数据库,sbtest 为 player_sb,正式服为 player。
|
||||
- 百科:当前203公开模板7510物品、870怪物、467强化配方,支持分类、中文/编号搜索、强化消耗、怪物属性、模型、正向掉落和反向来源。当前模板链决定基础编号,非连续石头编号不套用装备连续编号算法。
|
||||
- 掉落:原生 CG215 固定6字节/GC220固定114字节。子类型6/7正查怪物/宝箱,8/9/10扩展反查宝箱/强化家族。读取实际加载掉落表,不改掉落随机数。条件概率无法用单一百分比表示,因此保持原窗口隐藏的概率栏。
|
||||
- 查询串行、合并重复、缓存30秒、每请求4096行上限,超时等待终止包后再发下一个;扩展子类型6表示限流/超限错误,不缓存成空结果。断开清缓存和回调。
|
||||
- 日历:AVA2新日历原GC39与经典摆摊SHOP_SIGN39冲突,使用空闲GC214,保留5字节头/81字节事件结构。只对版本标记mt20261019及以后客户端下发新包。`/event_manager info` 读取与真实掉落共用的UTC区间/频道/帝国规则,15秒刷新,支持原生日历及活动悬浮图标、轮播和倒计时。
|
||||
- 正式服目前只有月光宝箱/圣诞袜接入真实活动门控。没有发布排期时使用有效空排期,不凭空启用其他活动。头像/时装/百科指南按当前可用内容显示。
|
||||
- UI 补齐 ImageBox颜色/事件、占位文本、Bar3D、Grid、RenderTarget裁剪和释放;模型裁剪同时更新纹理坐标,避免滚动时拉伸。中文说明与标签随资源打包,原 AVA2 图片保留。
|
||||
|
||||
## 验证
|
||||
|
||||
- 客户端146项 unittest(包括原件哈希、查询超时/缓存/错误、原子日历解析);服务端30组功能脚本,其中洗练测试的客户端版本断言已更新到19,服务端洗练门槛仍16。
|
||||
- 实际 C++ 处理器测试:6/114/5/81字节、掉落正反查、强化家族、限流/超限、旧版本拒绝、UTC活动及阵营限制。
|
||||
- 原战令 C++ 测试扩展:自动任务奖励、旧领取记录不重复支付、满包重试、最终领奖幂等、数据库隔离。
|
||||
- macOS候选包连sbtest:原生窗口、八任务生产配置、+5石头/护符/普通装备、怪物模型及76行掉落;30006反查4个来源;测试活动两个时段正确显示。2秒在线测试任务自动发奖,最终奖励只领一次,重登仍状态2。
|
||||
- 测试前后备份并恢复QA1017的全部物品、任务旗标、战令进度/领取行和原赛季配置;测试奖励不进入正式服。
|
||||
- macOS与Android离线构建;未安装/测试手机。运行日志和私有联机证据位于忽略目录 `build/native-systems-acceptance-20261018`。
|
||||
|
||||
## 部署
|
||||
|
||||
2026-10-19 08:31:54(203本地时间 CEST,UTC+02)已更新正式服。game SHA256 为 `a8d606ea88731cb5b7bffabbe8ddc78ef806205f6c8a352d78ba6d46a1c6b2f3`,备份 `/root/backup-native-systems/20261019-083154`。auth、13个游戏核心和原db均运行;首次旧核心退出受换页影响超过55秒,未替换程序;等待旧核心正常退出后完成部署。部署使用 `metin2-server/tools/native-systems/deploy.py`,仅切换game与auth,保留db运行,备份游戏程序/排期/战令进度与领取记录。回滚不回退已领取记录,避免重复发奖。
|
||||
|
||||
|
||||
生产活动文件初始化为有效空排期,不复制任何sbtest活动。启动仍有原来的缺失motion accumulation警告,没有新增PORT_BP/查询/Lua错误。手机未测试;macOS正式入口已更新为 `dist/Metin2.app`,旧包保留在 `dist/backups/Metin2-before-native-systems-20261018.app`。Android与四个资源补丁文件位于 `dist/native-systems`。
|
||||
|
||||
回滚:`/usr/local/bin/python3.9 /root/deploy-features/20261018-ava2-parity/native-systems/deploy.py rollback --backup /root/backup-native-systems/20261019-083154`。
|
||||
|
||||
验收为实际窗口创建、界面截图与控件回调驱动的sbtest联机;未使用正式玩家账号进行登录领奖,生产验收采用所有核心存活/端口/候选hash/新增日志检查。
|
||||
@@ -0,0 +1,164 @@
|
||||
# AVA2 客户端对齐计划
|
||||
|
||||
日期:2026-10-16。用户要求把现有实现改成按 AVA2 客户端的方式实现。这改变了 `AVA2-FEATURE-MIGRATION-PLAN.md` 的原则:那份计划只把 AVA2 当参考,用聊天命令(`/mt_*`)和自建窗口适配当前服务器。
|
||||
|
||||
本文是差异清单和计划,不代表功能已实现或已授权部署。
|
||||
|
||||
## 2026-10-17 执行状态
|
||||
|
||||
传送戒指、汉化和小地图入口已分别提交;真实客户端检查了十一分类分页菜单、一次主城传送、帮会功能设施和龙魂石中文界面。
|
||||
戒指共 49 个坐标通过服务端地图矩形及 Lua 5.0 导航检查;不等于 49 次实服落点验收。
|
||||
自动洗练的新客户端在 sbtest 验证了放入、真实消耗洗练、停止和已有目标自动完成;已修正亮黄底色。
|
||||
正式服 game 含新版洗练实现,数据库存在 SWITCHBOT 窗口枚举,旧版“未部署”结论已过时;正式服实际操作与跨核心仍待验证。
|
||||
批量开箱、拾取和追踪面板仍按下方阶段 1 的顺序推进,不能将旧命令窗口算作原生 AVA2 界面完成。
|
||||
石头首批已按 AVA2 原始 138 条记录移植:128 条非空属性、9 条因职业未移植或原始属性为空而锁定、1 条碎石片;sbtest 镶嵌、消耗、同族互斥、实际属性增量和重登保存已通过。尚未发布正式服,旧 +6 存量迁移、商城、掉落及强化配置仍待处理,详见 tools/server/ava2-stones/README.md。
|
||||
正式服等级上限已调整为 120,以下不再把旧 105 级上限列作未解决差异。冰雪、船防和赤龙已通过副本及组队进入测试;这不等于原生副本信息界面、排名和全部活动已经对齐。
|
||||
具体证据和本轮边界见 `AVA2-ACCEPTANCE-20261017.md`。
|
||||
|
||||
## 2026-10-18 执行状态
|
||||
|
||||
原生开箱窗口、GC66 预览和新发奖路径已接入 sbtest,CG235 和原版 18 分类拾取页、70002/705 状态已接入并做真实联机及冷重启保存验收。详见 [AVA2-CHEST-PICKUP.md](AVA2-CHEST-PICKUP.md)。
|
||||
|
||||
仍未完成的边界:基础单堆仍为 200(请求上限 1000),稀有度物品系统未移植,物理快捷键和 Android 真机尚未验收,正式服未部署。下方旧实现描述保留作为迁移前基线,不能据此忽略本段状态,也不能把两项计为全量 AVA2 对齐完成。uitrack 已进入下述联机验收,战令、百科、宠物等仍待推进。
|
||||
|
||||
原生 uitrack 双页窗口、五个世界首领刷新、地图 357 和原生门票兑换商店已接入 sbtest;已验证真实刷新/传送/实体、八项价格与实际道具兑换。旧副本增加真实冷却字段兼容,但八个副本的任务和入场条件尚未全部替换为 AVA2。提醒持久化冷启动已通过,Android 真机验收按用户要求暂停,详见 [AVA2-TRACK.md](AVA2-TRACK.md)。
|
||||
|
||||
属性锁定已在 sbtest 验证:选第4条、实际消耗、洗练保留锁定值、重复操作拒绝、全测试集群冷重启后读回,以及取消和解锁。实现与边界见 [属性锁定说明](../tools/server/ava2-attr-lock/README.md)。进程内脚本重连的测试命令已移到帧间执行,另修复重新打开登录界面时丢失目标端点,同一进程三次重登通过。交易双方、摆摊/商店、仓库/商城仓库和GM他人装备的锁定提示已接入并完成macOS/sbtest验证,见 [其他视图提示](AVA2-ATTR-LOCK-VIEWS.md);聊天链接和活动洗练槽已补独立锁定快照并完成macOS/sbtest验证,见 [锁定快照](AVA2-ATTR-LOCK-SNAPSHOTS.md)。Android真机按用户要求暂停。
|
||||
|
||||
原生换线已接入 sbtest:AVA2 MoveChannelDialog、3秒倒计时和服务端传送,按真实端口/地图归属选核心。macOS验证CH5→CH6→CH5续洗、目标与锁定值保留、实际耗材、重登保留频道和离线目标拒绝;正式服尚未部署,Android仅离线编译。见 [原生换线](AVA2-NATIVE-CHANNEL.md)。
|
||||
|
||||
## 1. 对齐的含义
|
||||
|
||||
对每个系统都使用 AVA2 自己的实现,参考源码如下:
|
||||
|
||||
| 层 | AVA2 来源 | 当前做法 | 对齐后 |
|
||||
|---|---|---|---|
|
||||
| 界面 | `pack_maker/uiscript/uiscript/*.py` + `pack_maker/root/ui*.py` | `ScriptLib/*Script.inc` 里自建窗口 | 原样载入 AVA2 uiscript 和 ui*.py,只补当前客户端缺的接口(沿用 m2 UI 窗口模板) |
|
||||
| Python 模块 | `3. Source BIN/Client/UserInterface/Python*.cpp`(PythonSwitchbot、PythonBattlePass、PythonWiki、PythonDropItem、PythonDungeonInfo…) | 无,状态都在脚本里 | 移植对应 C++ 模块,模块名和接口与 AVA2 相同 |
|
||||
| 协议 | AVA2 `Packet.h` 的功能包头 | `/mt_<system> 1 …` 聊天命令 | 改用 AVA2 功能包头和包结构;基础包仍是 40250 |
|
||||
| 服务端 | `2. Backup SF+SRC and SQL/home/Ava2_src/Srcs/Server` | 自写 `port_*.h` | 按 AVA2 服务端源码移植逻辑 |
|
||||
| 数据 | AVA2 配置与 SQL | 自定义 TSV/表 | 按 AVA2 的 SQL 读写还原表结构,编写迁移脚本 |
|
||||
|
||||
AVA2 功能包头号在当前服务端基本空闲,可以直接沿用:
|
||||
- CG 侧规划时空闲:57、58、143、171、213、215、216、220、221、230、235;其中 171 已由新版自动洗练使用。
|
||||
- GC 侧规划时空闲:66、171、214、216、217、220、224、230;其中 171 已由新版自动洗练使用。
|
||||
- 已经占用且号码与 AVA2 相同:CG 211 / GC 215(肩带)、110(副本)、GC 121(频道)。
|
||||
|
||||
**不在范围内**(除非另外决定):AVA2 的底层结构,包括 8 个 socket、15 条属性、64 位金币、250 级、征服者等级、角色槽数,以及 40250 基础包号和加密方式。这些会改动物品、角色、DB 和每一个基础包,相当于换一套底座(见 `AVA2-40250-COMPARISON.md` §3–§5、§11)。
|
||||
|
||||
## 2. 差异清单
|
||||
|
||||
### 2.1 已上线 203 的系统
|
||||
|
||||
| 系统 | AVA2 | 当前实现 | 主要差异 |
|
||||
|---|---|---|---|
|
||||
| 自动洗练 | `uiswitchbot.py` + `switcher.py`,`PythonSwitchbot`,CG/GC 171,`new_switchbot.cpp`;独立 SWITCHBOT 窗口,5 个物品槽 + 1 个道具槽,0.1 秒/次,换线后通过 P2P 转移继续洗 | `/mt_switchbot`,物品留在背包,一次只洗 1 件,0.25 秒/次,每次调用原 `UseItem`;换线或下线即停止 | 窗口、物品存放(新增窗口类型 = 物品位置枚举和 DB)、协议、速度、换线续洗。**2026-10-16 已在 feature/ava2-unlock 按 AVA2 实现,联机测试通过(武器、戒指、护符、重新登录、同核心换地图;跨核心换线未测);2026-10-17 已确认正式服现役二进制包含实现,当前联机复测见上方执行状态**(`docs/AVA2-SWITCHBOT.md`、服务端 `FEATURE-SWITCHBOT.md`) |
|
||||
| 属性锁定 | `ENABLE_LOCK_ATTR`:把 50348/50349 拖到装备上,选择属性;锁定信息存在属性数组第 7、8 位;物品提示里显示锁定 | 独立表 `mt_item_attr_lock`;旧洗练窗口按钮已移除 | sbtest已补材料选择及背包、交易、摆摊/商店、仓库/商城仓库、GM装备查看提示;聊天链接和活动洗练槽已补锁定快照并通过sbtest验证,基础七属性结构不变 |
|
||||
| 批量开箱 | `/chest_drop`,Ctrl + 右键弹出滑块,Ctrl + Z + 右键开整叠;`AutoGiveItemChest`,单次最多 1000 | `/mt_chest`,固定 1/10/50/全部,单次最多 200,逐个调用原 `UseItem` | 窗口、按键、命令、单次上限、发奖路径 |
|
||||
| 批量拾取 | CG 235 `ITEMS_PICKUP`;70002 自动拾取状态 | `/mt_pickup`,自建 8 类分类窗口,只在按 Z 时触发 | 包、自动拾取状态、分类方式 |
|
||||
| 世界 Boss | `uitrack.py`(世界 Boss + 副本两页) | `mt_boss` 自建窗口;main 已加入传送 | 窗口改为 uitrack,补上副本页 |
|
||||
| 战令 | `uiBattlePassEx` + `/battle_pass` / `BattlePass*` 命令,`battlepass.cpp` / `questlua_battlepass`,任务类型以 AVA2 为准;门票 25150–25161 | TSV 赛季 + 自建窗口;main 已加入门票激活 | 窗口、包、任务类型、表结构 |
|
||||
| VIP 卡 | 待查 AVA2 是否有对应实现 | 自建 | 先确认 AVA2 有没有对应实现 |
|
||||
| 生物学家 | — | 2026-10-14 已按 AVA2 实现 | 已对齐 |
|
||||
|
||||
### 2.2 已实现、未上线的系统(main)
|
||||
|
||||
| 系统 | AVA2 | 当前实现 | 主要差异 |
|
||||
|---|---|---|---|
|
||||
| 百科 | `uiWiki` + `PythonWiki`(本地资料) | `mt_wiki` 自建窗口 + 只读查询协议 | 窗口与模块整体替换 |
|
||||
| 掉落查询 | `uitarget` InfoBoard、`PythonDropItem`、CG 215 / GC 220 | `/mt_features REQUEST mob…` | 包与目标栏入口 |
|
||||
| 宝箱预览 | `uiChestDropInfo` + GC 66 | 查询协议 | 窗口与包 |
|
||||
| 角色详细属性 | `uicharacterdetails.py` | 自建面板 + 查询 | 窗口 |
|
||||
| 副本信息 | `uiDungeonInfo` + `uiDungeonTimer`、CG 213 / GC 217、`dungeon_info`,含排名和传送 | 已有冰雪、船防、赤龙等副本和计时;原生信息页未完整移植 | 原生窗口、排名、完整协议与副本覆盖 |
|
||||
| 活动日历 | `uiEventCalendarNew` + `/event_manager info` / 原 GC39(本服移至 GC214),`char_event_calendar` | 只支持月光宝箱和圣诞袜两种活动 | 活动类型、窗口、GM 管理包 |
|
||||
| 显示开关 | 包括摆摊、宠物、坐骑的显示范围 | 没有这三项 | 补齐 |
|
||||
| 换线 | 服务端 MoveChannel 以 GC Warp 传送到目标频道 | sbtest已使用原生窗口和服务端传送,旧服仍回退退出重登 | macOS原生跨频道续洗及重登已通过;正式服部署和Android真机待做 |
|
||||
| 模型预览 | `uiRenderTarget` | 已按 AVA2 实现(Vulkan) | 基本已对齐 |
|
||||
|
||||
### 2.3 `feature/ava2-unlock` P1–P8
|
||||
|
||||
| 系统 | 与 AVA2 的差异 |
|
||||
|---|---|
|
||||
| 肩带 | 窗口已用 AVA2 的 uisash 和 uiscript;入口放在 NPC 20016 的任务里,AVA2 是 NPC 60003 |
|
||||
| 坐骑时装 / 外观 | 基本一致;缺坐骑显示范围 |
|
||||
| 时装强化石 | 武器时装、肩带外观、特效槽三类强化石仍锁着,因为这三个系统还没移植 |
|
||||
| 护符 | 53996/53997 改成了护符道具,AVA2 里是通用洗练/加持道具;没有元素目标包(目标血条上的元素图标);没有 `uielementchange` / `uielementspelladd`;加入了冰元素,AVA2 没有 |
|
||||
| 新戒指 | 没有 `item_attr_rare_rings` |
|
||||
| 龙甲、守护武器 | 正式服上限已升至 120,旧等级阻碍已解除;仍需逐项核对装备效果与获取途径 |
|
||||
|
||||
### 2.4 尚未开始
|
||||
|
||||
- P9 宠物(`uiPetSystemNew`、`New_PetSystem`)
|
||||
- P10 技能书 50569–50575
|
||||
- P11 第 6/7 条属性(`uiAttr67Add`、72319/72320)
|
||||
- 其他 AVA2 系统,只列出不排期:离线商店、商店搜索、特殊背包/仓库、宝石、卡牌、任务、十二生肖、元素技能、帝国战争。
|
||||
|
||||
## 3. 计划
|
||||
|
||||
每一步都做到:两端各自提交,并附测试、macOS 联机记录和 Android 真机记录。部署 203 每次单独批准。
|
||||
|
||||
### 阶段 0:准备(先做)
|
||||
|
||||
1. 在 203 开发目录完整编译合并后的 `feature/ava2-unlock`(server `c6813cd`),并编译客户端(macOS + Android),确认合并没问题。
|
||||
2. 为每个系统列出 AVA2 的追踪清单:入口、宏、uiscript/ui*.py、Python 模块方法、包结构、服务端处理、SQL。确认实际生效的那一版(old / ex / copia 等多版本并存)。
|
||||
3. 建立通用加载方式:AVA2 uiscript 和 ui*.py 原样放进资源包,用 `interfacemodule` 的方式接入;当前客户端缺的 `app.ENABLE_*` 宏、常量和方法统一补在一个地方。
|
||||
|
||||
### 阶段 1:已上线系统改成 AVA2 实现
|
||||
|
||||
改动玩家正在用的系统,旧版和新版需要同时切换,并有回滚方案。
|
||||
|
||||
1. 自动洗练(原生实现已部署,纯释放速度自然完成已通过;跨核心换地图及sbtest原生跨频道续洗已通过;正式服换线部署和 Android 真机验收待做)+ 属性锁定(sbtest已补材料选择、自有物品、交易、商店、仓库和GM装备查看提示;聊天链接和活动槽锁定快照已在sbtest验证,正式服部署待做):SWITCHBOT 窗口类型、CG/GC 171、`new_switchbot` 和 `PythonSwitchbot`、`uiswitchbot`;存储继续用独立表。
|
||||
2. 批量开箱:`/chest_drop`、滑块、Ctrl + Z、`AutoGiveItemChest`。
|
||||
3. 批量拾取:CG 235、70002 自动拾取。
|
||||
4. 世界 Boss / 副本追踪:uitrack。
|
||||
5. 战令:`uiBattlePassEx`、`/battle_pass` / `BattlePass*`、AVA2 任务类型和表结构;需要迁移现有进度。
|
||||
|
||||
### 阶段 2:main 上未上线的系统
|
||||
|
||||
1. 百科、掉落查询、宝箱预览:`uiWiki` + `PythonWiki`,`PythonDropItem`(CG 215 / GC 220),`uiChestDropInfo`(GC 66)。原有 `/mt_features` 查询协议可以退役。
|
||||
2. 角色详细属性:`uicharacterdetails`。
|
||||
3. 副本信息和计时:`uiDungeonInfo` + `uiDungeonTimer`,CG 213 / GC 217;只列 203 实际存在的副本。
|
||||
4. 活动日历:`uiEventCalendarNew`,`/event_manager info` / GC214(原 GC39 与 SHOP_SIGN 冲突),共享实际活动排期。
|
||||
5. 换线改为服务端传送;显示开关补上摆摊、宠物、坐骑范围。
|
||||
|
||||
### 阶段 3:P1–P8 收尾
|
||||
|
||||
1. 肩带入口改到 NPC 60003(203 上没有这个 NPC,需要新增 NPC 和刷新点)。
|
||||
2. 护符:53996/53997 按 AVA2 用途处理,元素目标包,`uielementchange` / `uielementspelladd`,去掉冰元素。
|
||||
3. 戒指稀有属性 `item_attr_rare_rings`。
|
||||
4. 武器时装、肩带外观、特效槽三个系统,以及对应的强化石。
|
||||
5. MAX_LEVEL 已升至 120;继续核对高等级装备实际效果与获取途径。
|
||||
|
||||
### 阶段 4:P9–P11
|
||||
|
||||
宠物、技能书、第 6/7 条属性,直接按 AVA2 实现。
|
||||
|
||||
### 部署
|
||||
|
||||
- 阶段 1 每个系统都会改动线上协议,客户端和服务端必须一起更新。旧客户端连不上新服务端,需要准备客户端更新包和公告。
|
||||
- 沿用 `20261016-ava2-drops/deploy.sh` 模板:先停服,再备份二进制、配置和数据,最后启动 db 并检查。
|
||||
|
||||
## 4. 协议约定(2026-10-16 已同意)
|
||||
|
||||
- **包头号**:沿用 AVA2 的号码(见 §1 的空闲号列表)。40250 基础包不动。注册方式照肩带:服务端 `packet.h` + `packet_info.cpp` 的 `Set(...)` + `input_main.cpp` 的 case;客户端 `PythonNetworkStream.cpp` 的 `Set(HEADER, TPacketType(size, STATIC/DYNAMIC_SIZE_PACKET))` + `PythonNetworkStreamPhaseGame.cpp` 分发。
|
||||
- **包结构**:header、subheader、字段顺序照抄 AVA2。内嵌的物品数据按当前结构(3 个 socket、7 条属性、32 位金币),与 `TPacketGCItemSet` 一致。
|
||||
- **类型宽度**:只用固定宽度类型,不用 `long`(服务端 i386 上 4 字节,客户端 arm64 上 8 字节);客户端沿用 `LONG`(32 位)加 “PORT: LONG, the 32-bit Win32 long” 注释。`#pragma pack(1)`,两端都写 sizeof 测试(参照 `test_sash.py` 和 `tests/port/classic/wire_classic.h`)。
|
||||
- **变长包**:header + size + subheader,两端都注册为动态长度。
|
||||
- **旧客户端**:未知包头会让任一端断开。做法(自动洗练起):客户端按欧洲区编译,所有语言都发 `CG_CLIENT_VERSION2`;新客户端的 timestamp 是 `1215955205 mt<日期>`(现为 `mt20261016`)。服务端只给日期够新的客户端发新包,旧客户端照常能玩、只是没有新功能。203 是欧洲区,进游戏时用 `atoi` 比对 timestamp 和服务端配置的 `1215955205`(`input_login.cpp` 的 VERSION CHECK,不相等就断开),所以前面的数字不能动。以后要强制更新,就同时改服务端版本号和客户端的这个数字。
|
||||
- **聊天命令退役**:每个系统切到 AVA2 包后,删掉对应的 `/mt_*` 命令和客户端解析;全部切完后 `/mt_features` 能力协商也不再需要。
|
||||
- **服务端逻辑**:按 AVA2 移植。是否保留 40250 原有检查和 ItemLog 见 §5 第 2 项。
|
||||
|
||||
## 5. 待决定
|
||||
|
||||
1. **底层结构**:8 个 socket、15 条属性、64 位金币、等级上限等是否也要对齐?建议不对齐,等级上限单独决定。
|
||||
2. **经济规则**:自动洗练已按“AVA2 的流程和 0.1 秒速度 + 保留现有检查和 ItemLog”实现;批量开箱单次 1000 待定。
|
||||
3. **顺序**:已定,先做阶段 1,从自动洗练开始。自动洗练代码已完成,下一个是批量开箱。
|
||||
|
||||
### 2026-10-18:原生战令、百科/掉落、活动日历
|
||||
|
||||
已替换为 AVA2 原生 `uiBattlePassEx`、`uiWiki` / `WikiUI`、`uiDropItem` 与 `uiEventCalendarNew`,包括活动悬浮图标。
|
||||
注意此前规划混淆了两代实现:CG/GC230 属于旧 `uibattlepass`;214/216 的旧日历不是 `uiEventCalendarNew`。
|
||||
当前实现保留经典 SHOP_SIGN39,将新日历变长包移到214;掉落为 CG215 / GC220。
|
||||
战令沿用现有赛季与进度/领取主键;百科模板和掉落来自当前203数据,日历展示实际已接入的月光宝箱/圣诞袜排期。
|
||||
其他活动的服务端玩法、宠物等不因迁移窗口自动完成,整体 AVA2 对齐仍为 PARTIAL。
|
||||
详见 [AVA2-NATIVE-SYSTEMS.md](AVA2-NATIVE-SYSTEMS.md),生产部署证据在同文档中单列。
|
||||
@@ -0,0 +1,279 @@
|
||||
{
|
||||
"targets": {
|
||||
"d:/ymir work/monster2/defensewave_hydra_boss/drop.msa": {
|
||||
"crc32": "69a15bfa",
|
||||
"source": [],
|
||||
"source_files": [],
|
||||
"archives": [],
|
||||
"server_backup": []
|
||||
},
|
||||
"d:/ymir work/monster2/defensewave_hydra_boss/drop.gr2": {
|
||||
"crc32": "8f4fef23",
|
||||
"source": [],
|
||||
"source_files": [],
|
||||
"archives": [],
|
||||
"server_backup": []
|
||||
},
|
||||
"d:/ymir work/monster2/defensewave_minihydra/special_attack1.msa": {
|
||||
"crc32": "53221dab",
|
||||
"source": [],
|
||||
"source_files": [],
|
||||
"archives": [],
|
||||
"server_backup": []
|
||||
},
|
||||
"d:/ymir work/monster2/defensewave_minihydra/special_attack1.gr2": {
|
||||
"crc32": "b5cca972",
|
||||
"source": [],
|
||||
"source_files": [],
|
||||
"archives": [],
|
||||
"server_backup": []
|
||||
}
|
||||
},
|
||||
"archives": [
|
||||
{
|
||||
"name": "BGM",
|
||||
"entries": 35
|
||||
},
|
||||
{
|
||||
"name": "Costumes",
|
||||
"entries": 340
|
||||
},
|
||||
{
|
||||
"name": "ETC",
|
||||
"entries": 4588
|
||||
},
|
||||
{
|
||||
"name": "Effect",
|
||||
"entries": 2051
|
||||
},
|
||||
{
|
||||
"name": "Map_Sands",
|
||||
"entries": 1289
|
||||
},
|
||||
{
|
||||
"name": "Maps",
|
||||
"entries": 11780
|
||||
},
|
||||
{
|
||||
"name": "Monster",
|
||||
"entries": 3952
|
||||
},
|
||||
{
|
||||
"name": "Monster2",
|
||||
"entries": 9066
|
||||
},
|
||||
{
|
||||
"name": "NPC",
|
||||
"entries": 2147
|
||||
},
|
||||
{
|
||||
"name": "NPC2",
|
||||
"entries": 1111
|
||||
},
|
||||
{
|
||||
"name": "NPC_MOUNT",
|
||||
"entries": 680
|
||||
},
|
||||
{
|
||||
"name": "NPC_PET",
|
||||
"entries": 71
|
||||
},
|
||||
{
|
||||
"name": "PC",
|
||||
"entries": 4428
|
||||
},
|
||||
{
|
||||
"name": "PC2",
|
||||
"entries": 3125
|
||||
},
|
||||
{
|
||||
"name": "Patch_dungeon_meley",
|
||||
"entries": 466
|
||||
},
|
||||
{
|
||||
"name": "Patch_wiki",
|
||||
"entries": 43
|
||||
},
|
||||
{
|
||||
"name": "Sound",
|
||||
"entries": 5277
|
||||
},
|
||||
{
|
||||
"name": "Terrain",
|
||||
"entries": 891
|
||||
},
|
||||
{
|
||||
"name": "Tree",
|
||||
"entries": 393
|
||||
},
|
||||
{
|
||||
"name": "Wheel",
|
||||
"entries": 13
|
||||
},
|
||||
{
|
||||
"name": "Zone",
|
||||
"entries": 5902
|
||||
},
|
||||
{
|
||||
"name": "icon",
|
||||
"entries": 4363
|
||||
},
|
||||
{
|
||||
"name": "item",
|
||||
"entries": 3268
|
||||
},
|
||||
{
|
||||
"name": "locale",
|
||||
"entries": 999
|
||||
},
|
||||
{
|
||||
"name": "metin2_patch_citys",
|
||||
"entries": 463
|
||||
},
|
||||
{
|
||||
"name": "metin2_patch_m_summer",
|
||||
"entries": 985
|
||||
},
|
||||
{
|
||||
"name": "metin2_patch_zodiac",
|
||||
"entries": 2945
|
||||
},
|
||||
{
|
||||
"name": "pack_2019",
|
||||
"entries": 1075
|
||||
},
|
||||
{
|
||||
"name": "pack_2020",
|
||||
"entries": 904
|
||||
},
|
||||
{
|
||||
"name": "patch_battlefied",
|
||||
"entries": 277
|
||||
},
|
||||
{
|
||||
"name": "patch_conqueror_of_yohara",
|
||||
"entries": 5603
|
||||
},
|
||||
{
|
||||
"name": "patch_design_wa",
|
||||
"entries": 95
|
||||
},
|
||||
{
|
||||
"name": "patch_drop_item",
|
||||
"entries": 35
|
||||
},
|
||||
{
|
||||
"name": "patch_dungeon_info",
|
||||
"entries": 78
|
||||
},
|
||||
{
|
||||
"name": "patch_dungeon_new",
|
||||
"entries": 2607
|
||||
},
|
||||
{
|
||||
"name": "patch_new_petsystem",
|
||||
"entries": 846
|
||||
},
|
||||
{
|
||||
"name": "patch_new_select_ui",
|
||||
"entries": 10
|
||||
},
|
||||
{
|
||||
"name": "patch_offline_shop",
|
||||
"entries": 348
|
||||
},
|
||||
{
|
||||
"name": "patch_ranking_guild",
|
||||
"entries": 44
|
||||
},
|
||||
{
|
||||
"name": "patch_search",
|
||||
"entries": 38
|
||||
},
|
||||
{
|
||||
"name": "patch_tournament",
|
||||
"entries": 361
|
||||
},
|
||||
{
|
||||
"name": "patch_yohara",
|
||||
"entries": 441
|
||||
},
|
||||
{
|
||||
"name": "property",
|
||||
"entries": 9988
|
||||
},
|
||||
{
|
||||
"name": "root",
|
||||
"entries": 399
|
||||
},
|
||||
{
|
||||
"name": "textureset",
|
||||
"entries": 234
|
||||
},
|
||||
{
|
||||
"name": "uiscript",
|
||||
"entries": 166
|
||||
}
|
||||
],
|
||||
"verified_controls": [
|
||||
{
|
||||
"path": "d:/ymir work/monster2/defensewave_hydra_boss/wait.msa",
|
||||
"bytes": 199,
|
||||
"sha256": "7f38863ceb4364c465d7715a60b8eab92389a3cc084f451d64938f9145364ab7"
|
||||
},
|
||||
{
|
||||
"path": "d:/ymir work/monster2/defensewave_hydra_boss/wait.gr2",
|
||||
"bytes": 63698,
|
||||
"sha256": "877706e00ce21a74a34a334fc2e626b4cc4e4a1e21800b3fddd30bdef61552c0"
|
||||
},
|
||||
{
|
||||
"path": "d:/ymir work/monster2/defensewave_hydra_boss/motlist.txt",
|
||||
"bytes": 235,
|
||||
"sha256": "69152cdb0d882ebdc9933d08372bcfadf5aed9cddb7478269ce127793d041bf7"
|
||||
},
|
||||
{
|
||||
"path": "d:/ymir work/monster2/defensewave_hydra_boss/special_attack1.msa",
|
||||
"bytes": 15851,
|
||||
"sha256": "045180235a1687aeed6e2b81fd350ffe34b55905dffa1f1768c984ae2e7c8b09"
|
||||
},
|
||||
{
|
||||
"path": "d:/ymir work/monster2/defensewave_hydra_boss/special_attack1.gr2",
|
||||
"bytes": 39715,
|
||||
"sha256": "c1829082ba48782cd6e77d5333fada943c0f727a79d87b5fb56e5dc8bc0f15cd"
|
||||
},
|
||||
{
|
||||
"path": "d:/ymir work/monster2/defensewave_minihydra/wait.msa",
|
||||
"bytes": 198,
|
||||
"sha256": "cbd3315932e53b9088fb0b4adc18b6be4cf5357cd458d4e21974c967412f83e9"
|
||||
},
|
||||
{
|
||||
"path": "d:/ymir work/monster2/defensewave_minihydra/normal_attack1.msa",
|
||||
"bytes": 1248,
|
||||
"sha256": "6ef976e034f385273c6340fdaaa8d6d1d611234e9da9e20f89453a67a64b50f3"
|
||||
},
|
||||
{
|
||||
"path": "d:/ymir work/monster2/defensewave_minihydra/motlist.txt",
|
||||
"bytes": 344,
|
||||
"sha256": "89b447100e5e3dca68f4afb6efd09a59267f4ef309b5f5e4d91e089b41a13942"
|
||||
}
|
||||
],
|
||||
"server_backup_candidates": [
|
||||
"home/srv1/share/data/monster/defensewave_minihydra/defensewave_minihydra.msm",
|
||||
"home/srv1/share/data/monster/defensewave_minihydra/front_damage.msa",
|
||||
"home/srv1/share/data/monster/defensewave_minihydra/front_dead.msa",
|
||||
"home/srv1/share/data/monster/defensewave_minihydra/motlist.txt",
|
||||
"home/srv1/share/data/monster/defensewave_minihydra/normal_attack1.msa",
|
||||
"home/srv1/share/data/monster/defensewave_minihydra/wait.msa",
|
||||
"home/srv1/share/data/monster/defensewave_minihydra/wait1.msa",
|
||||
"home/srv1/share/data/monster/defensewave_hydra_boss/defensewave_hydra_boss.msm",
|
||||
"home/srv1/share/data/monster/defensewave_hydra_boss/front_dead.msa",
|
||||
"home/srv1/share/data/monster/defensewave_hydra_boss/motlist.txt",
|
||||
"home/srv1/share/data/monster/defensewave_hydra_boss/special_attack1.msa",
|
||||
"home/srv1/share/data/monster/defensewave_hydra_boss/special_attack2.msa",
|
||||
"home/srv1/share/data/monster/defensewave_hydra_boss/special_attack3.msa",
|
||||
"home/srv1/share/data/monster/defensewave_hydra_boss/wait.msa"
|
||||
],
|
||||
"archive_count": 46,
|
||||
"entry_count": 94220,
|
||||
"note": "VDI guest filesystem not mounted; packed client, XML manifests and source controls audited."
|
||||
}
|
||||
+95
-45
@@ -1,57 +1,107 @@
|
||||
# AVA2 自动洗练适配进度(v1,不含属性锁定)
|
||||
# AVA2 自动洗练(按 AVA2 移植)
|
||||
|
||||
2026-10-15。修改了 metin2-client 和 metin2-server,AVA2 代码只作参考。服务端规则和协议见 `metin2-server/docs/FEATURE-SWITCHBOT.md`。
|
||||
2026-10-16 起替换 v1(`/mt_switchbot` / `MTSB1`)。服务端规则和协议见 `metin2-server/docs/FEATURE-SWITCHBOT.md`,计划见 `docs/AVA2-PARITY-PLAN.md` 阶段 1。
|
||||
|
||||
## 与 AVA2 的差异
|
||||
## 和 AVA2 相同的部分
|
||||
|
||||
| 项目 | AVA2 | 本实现 |
|
||||
| --- | --- | --- |
|
||||
| 窗口 | 新增 SWITCHBOT 物品窗口,5 个物品槽加 1 个道具槽 | 不新增窗口类型,物品留在背包,按物品 ID 绑定;每个角色同一时间只洗 1 件 |
|
||||
| 洗练执行 | 自己实现消耗和 ChangeAttribute,绕过手动检查和 ItemLog | 每次都调用原 `UseItem`,检查、概率、日志、扣道具都和手动洗练一样;71151/76023 仍只能洗等级上限 ≤40 的武器和衣服 |
|
||||
| 速度 | 0.1 秒一次 | 0.25 秒一次(约 4 次/秒) |
|
||||
| 物品被移动 | 拦截移动、交易、出售等路径 | 每次洗练前重新检查:物品不在背包、已装备、易主时停止(item_gone);交易、商店、仓库、合成界面打开时停止(busy) |
|
||||
| 换线 / 下线 | 通过 P2P 转移,继续洗 | 直接停止,不离线洗练 |
|
||||
- **C++**
|
||||
- `PythonSwitchbot.{h,cpp}`:`switchbot` 模块,接口和 AVA2 相同。
|
||||
- `PythonNetworkStreamPhaseGameSwitchbot.cpp`:收发代码照搬 AVA2。
|
||||
- `Packet.h`:CG/GC 171,subheader 和字段顺序同 AVA2。物品按本服结构:3 个孔、7 条属性。
|
||||
- `GameType.h`:`SWITCHBOT = 7` 窗口、`SLOT_TYPE_SWITCHBOT`。
|
||||
- `PythonPlayer`:`aSwitchbotItem`。
|
||||
- `RecvItemSetPacket`:收到 SWITCHBOT 窗口的物品时刷新洗练窗口。
|
||||
- 结构体都是 `pack(1)`,两端都用 `static_assert` 固定大小:220 / 15 / 9 / 40 / 7。
|
||||
- **脚本**:`mt_switchbot`(`src/platform/ScriptLib/SwitchbotScript.inc`)。
|
||||
- 主体是 AVA2 `root/uiswitchbot.py` 原文:SwitchbotItemTab、SwitchbotAttribute、SwitchbotWindow、SearchListWindow、ConfigurationWindow。方案用 pickle 存在 `switchbot.inf`。
|
||||
- 再补上 AVA2 放在别的文件里、用 `ENABLE_SWITCHBOT` 包起来的部分:
|
||||
- `ui.ThinBoardCircle`、`ListBoxEx.GetItems`;
|
||||
- `uitooltip.SetSwitchBotItem`;
|
||||
- mouseModule / uiinventory 的 `SLOT_TYPE_SWITCHBOT`(拖回背包时发 `SendItemMovePacket(SWITCHBOT → INVENTORY)`);
|
||||
- interfacemodule 的 Toggle / Refresh / HideAllWindows / `__HideWindows`;
|
||||
- game.py 的 `RefreshSwitchbotWindow` / `RefreshSwitchbotItem`。
|
||||
- **图片**:`d:/ymir work/ui/switchbot/` 和 `ui/pattern/thinboardcircle/`。`tools/server/ava2-items/make_items.py` 的 `SWITCHBOT_UI` 把它们打进 ava2items 包。
|
||||
|
||||
匹配规则和 AVA2 相同:最多 2 套方案,每套 1–5 条“属性 ≥ 阈值”;任意一套全部达标就停止,只看前 5 条普通属性。
|
||||
## 和 AVA2 不同的地方
|
||||
|
||||
## 客户端
|
||||
| 项目 | AVA2 | 本实现 | 原因 |
|
||||
| --- | --- | --- | --- |
|
||||
| 第 6 格(洗练道具格) | 显示,放 71084 | 隐藏(`attrTab.Hide()`) | 服务端从背包取道具,不用第 5 号格 |
|
||||
| 入口 | 扩展任务栏按钮 + F9 | 小地图旁“洗练”按钮(y+148,原 v1 按钮的位置) | 40250 没有扩展任务栏;F9/F8 已给自动狩猎,触屏也要能点 |
|
||||
| 结束 / 停止提示 | locale_string 864 / 865 | 服务端命令 `switchbot_end/stop/error`,脚本转成中文聊天提示 | 见服务端文档 |
|
||||
| “Alternativen:” | 德文写死 | `localeInfo.SWITCHBOT_ALTERNATIVES`(备选方案:) | 原文没走 locale |
|
||||
| 文字 | locale_game.txt | 脚本里补中文 `SWITCHBOT_*`(`player.AutoHuntLocalize` 转码) | 本服 locale 没有这些条目 |
|
||||
| 版本 | — | `CG_CLIENT_VERSION2` 的 timestamp 由 `1215955205` 改为 `1215955205 mt20261016` | 服务端只给新客户端发 GC_SWITCHBOT;服务端(欧洲区)的版本检查用 `atoi`,仍读到 1215955205 |
|
||||
|
||||
- 模块 `mt_switchbot`(`src/platform/ScriptLib/SwitchbotScript.inc`),在 `PythonBoot.cpp` 中安装。入口是小地图旁“百科”按钮下方的“洗练”按钮。
|
||||
- 物品:扫描背包里至少有一条属性的武器和防具,用 `<` `>` 切换。洗练道具:扫描子类型为 USE_CHANGE_ATTRIBUTE 的道具,显示数量。次数上限可选 10、50、100、200、500、1000。
|
||||
- 可选属性和最大值由服务端 `attrs` 下发,客户端不自己推算。添加属性时分页点选;阈值用 -/+ 调整,步长为最大值的 1/5,默认取最大值。
|
||||
- 运行时锁定所有设置,实时显示次数、剩余道具、停止原因和当前 5 条属性。停止时在聊天框提示;达标时如果窗口已关闭,会自动打开。
|
||||
- 命令间隔至少 0.3 秒,同一时间只有一个请求在等待回复。4 秒没有回复就显示“服务器尚未启用自动洗练”。`attrs` 只接受完整、连续的回复,不完整的整批丢弃。
|
||||
- 文字都用 GBK 可编码的字符(不用 ◀/▶/⚠)。
|
||||
没有移植 AVA2 的 `uiswitch.DopadorMenu/DopadorManual`(另一套手动洗练菜单)。
|
||||
|
||||
2026-10-18:50348/50349 已在 sbtest 补齐选择属性序号的 quest 流程,材料 socket 0 记录1~5,再拖到装备;自有装备提示按 AVA2 用黄色 <<属性>> 显示。独立表存储保留,详见 [属性锁定说明](../tools/server/ava2-attr-lock/README.md)。他人装备(沿用GM权限)、商店、交易和仓库提示已在 sbtest 验证;见 [视图提示](AVA2-ATTR-LOCK-VIEWS.md) 和 [链接/活动槽快照](AVA2-ATTR-LOCK-SNAPSHOTS.md)。
|
||||
|
||||
## 证据
|
||||
|
||||
- `tests/wiki/test_switchbot.py`(CTest:`port.switchbot`)共 6 项通过,覆盖:
|
||||
- 请求节流和合并;
|
||||
- 不完整的 attrs 回复被拒绝;
|
||||
- start 命令的拼装和校验;
|
||||
- state/error 解析和超时;
|
||||
- 和服务端的原因码、错误码、上限一致;
|
||||
- 窗口流程:扫描 → 读取属性 → 选属性 → 开始 → 达标提示。
|
||||
- 脚本能在 Python 2.7 下编译。`tests/wiki/test_service.py` 仍然通过。
|
||||
- 2026-10-15 联机测试(203 额外开的测试核心 channel5/first,端口 13040,使用隔离编译的 game;macOS 原生客户端,账号 admin,物品为背包 33 格的剑 279,道具 71084):
|
||||
- 上限 10 次:洗满 10 次后停止(limit),约 4 次/秒。
|
||||
- 两套方案、阈值 1:第 18 次达标(matched)。
|
||||
- 已经达标的物品:0 次就停止,不扣道具。
|
||||
- 洗练中把物品从 33 格移到 90 格:继续洗,窗口跟到 90 格;点停止后显示 stopped。
|
||||
- 洗练中退出客户端:服务端立即停止。
|
||||
- log.log 中 CHANGE_ATTRIBUTE 共 72 行,和总次数一致。
|
||||
- busy:洗练中摆摊(先给 50200 摊位包袱;没有它 `OpenMyShop` 会提前返回、摊位不会开,第一次测试就是这样误判的),摊位开出约 1 秒后停止(busy),共洗 6 次。
|
||||
- no_scroll:用 76014(共 6 张)、上限 10,洗 6 次后停止(no_scroll),道具剩 0。
|
||||
- rejected:对 90 级剑用 71151(原路径只允许等级 <= 40):0 次就停止(rejected),道具未扣。
|
||||
- 截图里窗口布局正常。仓库自带的 `Client` 是英文 cp1252 locale,所以中文显示为 `????`;需要 zh locale 客户端才能看到中文。
|
||||
- 联机测试发现并修复了两个窗口问题,`test_switchbot.py` 已加回归用例:
|
||||
- 洗练中移动物品后,选中项会跳到别的物品:现在按服务端报告的格子跟随。
|
||||
- 空闲时移动物品后选中项丢失:现在退而按相同 vnum 匹配。
|
||||
- 服务端 `tests/features/test_switchbot.py` 和 `test_queries.py` 通过。203 的隔离目录 `/root/metin2-features-dev` 完整编译通过。
|
||||
- `tests/wiki/test_switchbot.py`(CTest `port.switchbot`),5 项:
|
||||
- 窗口代码和 AVA2 原文逐字相同(只有上表两处替换);
|
||||
- ThinBoardCircle、文字、`USERDATA_DIRECTORY`、5 个标签页的宽度;
|
||||
- 服务端命令提示,其他命令照常传下去;
|
||||
- 从洗练窗口拖回背包;
|
||||
- interface / game 钩子。
|
||||
- `tests/wiki/test_item_actions.py` 已更新:50348/50349 走原来的使用流程。
|
||||
- 脚本能在 Python 2.7 下编译。macOS 构建(`build/switchbot-check`,关闭 MeshPort)通过,ctest 52 项全过(7 项跳过,和之前一样)。
|
||||
- 服务端 `tests/features/test_switchbot.py` 同时检查客户端 `Packet.h`、`PythonSwitchbot.h` 和版本字符串。
|
||||
- 联机测试(2026-10-16,Mac 客户端 + 203 的 channel5,脚本驱动):
|
||||
- 武器(channel5 连线上 db):放入、拖回、开始和停止、洗到目标自动结束、洗练中拖出被拒绝、放入无效物品被拒绝;约 12 次/秒,ItemLog 记录数和消耗数一致。
|
||||
- 戒指和护符(`tools/server/sbtest` 隔离环境,解锁后的 proto):戒指用戒指属性池(20 条),消耗 71084;护符用护符属性池,只消耗 71302。两边都能洗到目标。
|
||||
- 重新登录:物品和属性保留(从 db 缓存读和重启后从 MySQL 读都测过,`window=SWITCHBOT`);洗练停止,目标清空,和 AVA2 一样(下线时 `UnregisterItem`)。
|
||||
- 同核心换地图(1 → 21 → 1):传送后接着洗,目标保留,只在传送时暂停一下,和 AVA2 一样。
|
||||
|
||||
## 未完成
|
||||
|
||||
- Android 真机测试。
|
||||
- macOS 构建需要 `-DMT_40250_SOURCE=<含 EterPack/EterPack.cpp 的源码目录>` 来生成 pack 密钥,否则 system.py 读不出来(RunMain Error)。本机没有 40250 源码,这次用的是 AVA2 的 `TEST/3. Source BIN/Client`,两者密钥相同。
|
||||
- 服务端还没有部署到 203 正式环境。
|
||||
- 属性锁定(阶段 6 后半):需要单独的存储设计。
|
||||
- 跨核心换地图续洗已通过;跨频道换线仍需从当前退出重登流程改为原生服务端传送。
|
||||
- 正式服当前版本的实际开始/停止和跨核心续洗验收仍需补齐;2026-10-17 已确认现役 game 含 CSwitchbotManager / switchbot_end,player.item.window 也已有 SWITCHBOT,不能再写成正式服仅有 v1。
|
||||
- Android 构建和真机测试。
|
||||
- 属性锁定:他人装备、交易和商店提示同步;物理拖放与 Android 触控验收。
|
||||
|
||||
## 2026-10-17 当前客户端复测
|
||||
|
||||
真实 macOS 客户端连接 sbtest,普通 QA1017 把背包 32 格的 19 号武器移入 SWITCHBOT 第 0 格。
|
||||
设置两套目标后开始,约 1.5 秒内消耗 2 个 71151 和 17 个 71084,收到属性更新;手动停止后 active=0。
|
||||
将目标设为当前已有的 (13,5),再次开始后 finished=1、active=0,材料数量不变。验收后物品移回原背包格。
|
||||
客户端状态记录在 build/ordered-acceptance-20261017/switchbot-{roll-live,live}.json。
|
||||
|
||||
修正所有 ThinBoardCircle 的明黄色底色:原 AVA2 配置向 0~1 颜色接口传入 255,当前渲染下产生溢出色;
|
||||
按用户反馈改为归一化深灰 (0.08,0.08,0.08,0.96),保持白色文字和原状态色。
|
||||
真实客户端截图已确认主面板、属性列表和输入框可读。原始 uiswitchbot 主体逐字对照测试仍通过;
|
||||
颜色是明确的用户要求变更,不宣称该配置仍与 AVA2 原值相同。
|
||||
|
||||
### 同日验收脚本干扰说明
|
||||
|
||||
上述约 1.5 秒洗练是私有驱动主动发送 Stop,并非自然达到用户选择的释放速度。
|
||||
该驱动最初设置两套 (14,8),随后又把两套改为武器已有的 (13,5) 来验证立即完成;这些编号分别是缓慢和眩晕概率,不是释放速度/攻击速度。
|
||||
在同一可见客户端进行该操作会干扰人工观察,不能将其停止/完成提示解释成界面所选释放速度已命中。
|
||||
驱动已结束,客户端已重新启动,当前没有该定时器。后续人工验收期间不再插入修改配置或定时停止。
|
||||
新增回归直接编译执行服务端 CheckItem 函数,确认攻击速度 7 不能满足释放速度 9、数值门槛、同方案 AND 和备选方案 OR。
|
||||
客户端回归通过真实选择回调确认释放速度编号 9 保持为 9,未错误发送成 7。
|
||||
|
||||
## 2026-10-18 纯释放速度自然完成
|
||||
|
||||
macOS 真实客户端连接 sbtest,普通 QA1017 的测试武器(19)起初无释放速度。所有备选方案均只设类型9(释放速度)≥1,未混入攻击速度7。开始后不发送手动 Stop:71084 总数2082→2069,约1.315秒后 active=0、finished=1,最终五条属性含 (9,10)。属性匹配、消耗和自然停止同时成立;不是“已有目标立即完成”测试。证据:build/parity-acceptance-20261018/switchbot-cast-natural.json。验收后物品移回背包,测试轮询窗口隐藏。
|
||||
|
||||
Android APK 已构建并保留数据安装,用户于本轮明确选择“暂时不测手机”,因此手机联机/触控保留未验收。
|
||||
|
||||
## 2026-10-18 跨核心传送续洗
|
||||
|
||||
临时将 sbtest 主核心限制为地图1/62,增加同频道的独立测试核心:13040/P2P14040 与13041/P2P14041,后者只载入地图61。正式服配置和二进制未变。QA1017 通过原生追踪传送从地图1→61→62,服务端日志确认两次跨核心连接。
|
||||
|
||||
开始配置为释放速度20、暴击10、穿透10、动物系20、不死系20,填入两个实际备选;武器第4条 (4,6) 已锁定。两个目标核心进入后 active 均为1,目标表一致,锁定值始终不变;71084总数2069→1811→1595,确认是持续真实洗练。最后主动停止、武器退回159格并解锁,测试集群重启后恢复原 MAP_ALLOW,临时核心关闭,QA位置恢复主城。证据:crosscore-{before,outbound,return,summary,cleanup}.json,以及远端 crosscore/primary-syslog、aux-syslog。
|
||||
|
||||
这验证的是跨核心换地图。该次测试时换线窗口仍使用退出重登,因此其证据只证明跨核心换地图;后续原生换线验收见下节。
|
||||
|
||||
## 2026-10-18 原生跨频道续洗
|
||||
|
||||
已按 AVA2 启用的 do_cmd→MoveChannel 和 MoveChannelDialog 接入,203端口布局通过P2P实际地图归属适配。sbtest仅临时加载地图1:频道5端口13040、频道6端口13050;详见 [原生换线](AVA2-NATIVE-CHANNEL.md)。
|
||||
|
||||
最终无需人工补发频道查询的自动验收完成5→6→5:active全程为1,两套目标表一致,锁定第4条 (4,6) 不变,71084总数1034→976→919。此轮特意使用持续不命中的目标检查交接,在往返完成后主动停止;不能将其称为自然完成测试。已退回武器到159格并解锁,数据库锁记录为0。
|
||||
|
||||
同频道、未开放频道、重复命令取消倒计时、真实任务选择窗口中的换线拒绝均通过。另一次5→6后正常退出重登仍在6,auth保持11040,再回5;关闭辅助核心后列表只剩5,旧目标6请求被拒绝。上述结果仅为macOS/sbtest;用户暂停Android真机验收,正式服未部署本轮换线改动。
|
||||
|
||||
证据:本机 build/parity-acceptance-20261018/native-channel-{before,outbound,return,cleanup,reconnect,unavailable}.json、native-channel-proof-final.log、native-channel-reconnect.log、native-channel-live-unavailable.png。首轮联机曾发现频道元数据不刷新,最终验收使用服务端EnterGame主动下发列表和原版UpdateServerInfo更新后的版本。
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
# AVA2 原生首领与副本追踪
|
||||
|
||||
更新:2026-10-18;分支 `feature/ava2-unlock`。本轮仅部署 sbtest(203:11040/13040),正式服未更新。
|
||||
|
||||
## 实现与来源
|
||||
|
||||
`NativeTrackScript.inc` 载入 AVA2 `pack_maker/root/uitrack.py` 的双页窗口、卡片、滚动、门票提示与提醒选项,使用原 `uiscript/track/{window_old,item_old}.py`、ymirdesign 图片及头像。原 `mt_boss` / `mt_dungeons` 入口转入原生窗口。兼容层补齐 MultiTextLineNew、ListBoxNew、按钮裁剪和事件参数接口;不改变 40250 原始打包脚本。
|
||||
|
||||
服务端移植 AVA2 `CNewMobTimer` 日历、刷新、死亡与追踪查询,使用 `/track_window load/teleport`、`TrackBossInfo`、`TrackDungeonInfo`。当前开放原始列表的五个生肖首领,地图 `metin2_12zi_stage`(357)及相关 85 条怪物/NPC 数据只导入 sbtest。地图载入不代表整个生肖副本玩法已经移植。
|
||||
|
||||
跨核心刷新状态通过现有变长 P2P relay 传播,并增加存活心跳和超时失效;显示真实所属频道。地图不可用、未知首领和未同步状态单独显示,客户端倒计时结束不自行声称首领已刷新。65535 存活标记与同值倒计时作区分。原日历 `days_range` 按星期取模,不能当作固定 48 小时。
|
||||
|
||||
副本保留 AVA2 八组冷却/重返标记及优先级,三份新任务恢复 `d.track_update`。旧地下墓穴、火焰副本和蜘蛛巢穴另外读取当前已部署任务的实际截止时间;旧蓝龙从 `dragon_lair_access.get_settings()` 读取房间冷却。任务正在运行或配置缺失时不执行该 Lua 查询,显示状态暂不可用。冷却结束只描述计时状态,入场仍由 NPC 校验钥匙、队伍、房间归属等条件。
|
||||
|
||||
提醒选项通过 `systemSetting` 保存到 `metin2.cfg`。经典解析器遇空行停止,因此新字段必须写在结尾空行之前。断线、换图、关闭商店会清除本次道具价格,避免污染后续商店。
|
||||
|
||||
## 原生门票商店
|
||||
|
||||
从 AVA2 原始 MyISAM `player.shop` / `shop_item` 核实 shop 12(NPC 20381),快照见 `tools/server/ava2-track/shop12.tsv`。八种门票售价依次为:圆木 10、圆木 15、夹板 15、夹板 15、地基石 20、地基石 20、地基石 30、地基石 30。
|
||||
|
||||
沿用原生 ShopDialog、确认框、物品图标和悬浮价格。服务端独立持有商店,不覆盖现有 NPC 商店 ID;只允许打开 shop 12,禁止卖出。检查任务状态、交易/仓库/死亡/传送状态及道具余额,原 CShop 发奖成功后才扣兑换物,不扣金币。追加的 GC_SHOP 子包为 2044 字节载荷(含 40 格道具价格),接收端完整验证后再更新状态。旧商店流程保持兼容。
|
||||
|
||||
## 验证证据
|
||||
|
||||
本地证据目录 `build/parity-acceptance-20261018/`(私有登录资料不纳入版本库)。
|
||||
|
||||
- macOS 真实客户端显示两页窗口、卡片滚动、门票图片与中文界面;临时短周期首领刷新后显示 CH5,实际传送到地图 357 并发现 9842 实体。验收后恢复原始刷新日历并将 QA 角色返回主城。
|
||||
- 原生 shop 12 返回八项价格;通过原生确认回调购买第一张票:90011 数量 170→160、25163 数量 0→1,金币保持 1330870487;真实卖出封包被拒绝,余额不变。见 `ticket-*.json` / `ticket-shop.png`。
|
||||
- 服务端实际日历/查询/商店控制器隔离测试通过;另测八副本标记、旧任务截止时间、蓝龙共享冷却、配置失效与整数边界。FreeBSD 独立目录完整编译通过。
|
||||
- 配置回归测试编译真实 SaveConfig/LoadConfig,两项启用、关闭其中一项均能冷读;真实客户端冷启动读回 `[1,1]`,见 `track-preferences-cold-pass.json`。
|
||||
- 客户端解包器覆盖有效、截断、超长和异常价格封包,并验证失败时无部分状态写入;原生窗口回调、旧商店回退和关闭路径通过自动测试。
|
||||
|
||||
## 尚未闭合
|
||||
|
||||
八个副本的任务、门票和等级条件尚未全部换成 AVA2 原版;列表中的 AVA2 门票不代表旧 NPC 已接受这些票。提醒选项冷启动验收通过(两项保持 1;验收后恢复此前的 0)。物理鼠标/快捷键和 Android 触控尚未验收;测试代码调用 UI 回调不能替代物理输入验证。Android APK 已增量构建并安装,手机解锁后才能开始联机验收。
|
||||
|
||||
资源生成报告仍有 40 项源文件缺口(含此前九头蛇动作和生肖装饰模型),不能声称全量资源无缺失。当前实现也不代表战令、百科、属性锁定和其他 AVA2 系统已完成。
|
||||
@@ -0,0 +1,81 @@
|
||||
# Model preview
|
||||
|
||||
Ported from AVA2's render-target window (`EterLib/CRenderTarget*`, `GrpRenderTargetTexture.*`, `UserInterface/CPythonRenderTargetModule.cpp`, `root/uirendertarget.py`). The preview shows:
|
||||
- a wearable item on a character of every race that may wear it;
|
||||
- a monster, with its motions.
|
||||
|
||||
It is client only; the server is not involved.
|
||||
|
||||
## Entry points
|
||||
|
||||
| Where | How |
|
||||
|---|---|
|
||||
| Inventory | hold X and left-click the item |
|
||||
| NPC shop | hold X and left-click the item |
|
||||
| Wiki detail | the "模型预览" line, on weapon / armor / costume rows that have a model, and on every monster |
|
||||
|
||||
Without X the original click path runs unchanged. The inventory wrapper chains onto `mt_mobile_inventory`'s, because `mt_preview` is installed after it. There is no touch entry other than the wiki.
|
||||
|
||||
## Window (`ScriptLib/ModelPreviewScript.inc`, module `mt_preview`)
|
||||
|
||||
### Item mode
|
||||
- `ItemSpec(vnum)` accepts:
|
||||
- a weapon other than an arrow → `SetWeapon`;
|
||||
- a body armor or a body costume → `SetArmor`;
|
||||
- a hair costume → `SetHair`, which reads value3.
|
||||
- The races are those not excluded by `ITEM_ANTIFLAG_{MALE,FEMALE,WARRIOR,ASSASSIN,SURA,SHAMAN}`, ordered warrior, assassin, sura, shaman, with male first. The window starts on the player's own race if it is allowed.
|
||||
- `<` / `>` step through the allowed races.
|
||||
|
||||
### Mob mode
|
||||
- `SelectModel(vnum)`.
|
||||
- Motion buttons: 待机 1, 攻击 13, 受击 5, 死亡 11, 技能1–4 33–36 (`InterceptOnceMotion`).
|
||||
|
||||
### Controls
|
||||
- Dragging with the left button turns the camera: absolute yaw/pitch from the press point, pitch clamped to ±60°.
|
||||
- 放大 / 缩小 change the zoom in 5 % steps, clamped to −8..+12. Windows have no wheel event.
|
||||
- 自动旋转 spins the model.
|
||||
- 复位 rebuilds the model, which also resets the camera.
|
||||
|
||||
### Lifetime
|
||||
- Render target index 1 is created at 300×330 when the window opens.
|
||||
- It is removed on close or Esc, and on every re-open before it is created again. `GameWindow.Close` also calls `renderTarget.Destroy()`.
|
||||
- The host frees the GPU image 120 frames after its last use.
|
||||
|
||||
## Native side
|
||||
|
||||
- `renderTarget` Python module (`port/UserInterface/PythonRenderTargetModule.cpp`) → `CRenderTargetManager` → `CRenderTarget`, which owns a `CInstanceBase` and a `CGraphicRenderTargetTexture`.
|
||||
- `CPythonApplication` calls `DeformModels` / `UpdateModels` / `RenderModels` around the character manager.
|
||||
|
||||
### Port differences from AVA2
|
||||
- Player races (0..7) are created as `TYPE_PC`. 40250 reserves the armor/weapon/hair parts only for PCs, so AVA2's `TYPE_NPC` crashed on the first `ChangeArmor`.
|
||||
- The model sits at the world origin, where culling hides it. Instead of AVA2's `SetAlwaysRender`, it is shown again before `Deform` and `Render`. Its text tail is detached.
|
||||
- The background quad is drawn inside the render target, in `RenderModel`. `RenderBackgrounds` is a no-op.
|
||||
- Wiki affects are not ported.
|
||||
- The texture has 1 mip level.
|
||||
|
||||
### Host (Vulkan)
|
||||
- A colour render target is `D3DFMT_X8R8G8B8` / `A8R8G8B8` with `D3DUSAGE_RENDERTARGET`, named `rt:<id>:<w>x<h>:c`.
|
||||
- It gets its own RGBA8 offscreen pass (pipeline key bits 29–30: 0 none, 1 shadow, 2 colour) and is cleared to black.
|
||||
- Shadow targets keep the previous path.
|
||||
- Side effect: SnowEnvironment's blur targets now take the colour path. Snow blur is off by default.
|
||||
|
||||
## Verification
|
||||
|
||||
- `tests/wiki/test_model_preview.py` covers:
|
||||
- `ItemSpec` races and slots;
|
||||
- race stepping and fallback;
|
||||
- motions and zoom clamps;
|
||||
- drag;
|
||||
- reset;
|
||||
- the view drawing the target;
|
||||
- no live target after close, Esc, or 5 re-opens;
|
||||
- the inventory and shop wrappers;
|
||||
- wiki links and module order.
|
||||
- ctest 49/49.
|
||||
- Live, channel5 13040, macOS client, 2026-10-16:
|
||||
- armor 11299 on a warrior;
|
||||
- sword 19 after a 90°/20° turn;
|
||||
- wild dog 101 with the attack motion;
|
||||
- boss 691 zoomed in with spin.
|
||||
- The main scene was unchanged.
|
||||
- 120 open/close cycles (30 paced, plus 60 in one frame) did not grow RSS: 668 MB before, 593 MB after.
|
||||
@@ -0,0 +1,89 @@
|
||||
# 客户端内置 MeshPort:同网段直连,跨网段统一组网
|
||||
|
||||
SDK 源码在 `third_party/meshport/`;客户端的后台运行时在 `src/meshport/runtime/`,TCP/UDP 平台适配在 `src/meshport/transport.cpp`。不依赖相邻的 MeshPort 工程或另行安装的 MeshPort 应用。
|
||||
|
||||
## 统一路径
|
||||
|
||||
组网按每一个目标 IPv4 地址决定,位于原生网络层,不依赖登录窗口或按钮。首次跨网段请求(包括登录前频道查询、先注册、先发送 UDP、命令行自动登录)都可触发后台启动。
|
||||
|
||||
| 请求 | 接入点 |
|
||||
|---|---|
|
||||
| 登录前频道状态查询 | `CServerStateChecker` → `CNetworkStream`;当前实现是 TCP |
|
||||
| 账号认证、游戏连接 | `CAccountConnector`、`CPythonNetworkStream` → `CNetworkStream` |
|
||||
| 换地图、换线、断线后的新连接 | 每次 `CNetworkStream::Connect` 重新判断目标地址 |
|
||||
| 公会图标/标志上传和下载 | `CGuildMarkUploader`、`CGuildMarkDownloader` → `CNetworkStream` |
|
||||
| 注册账号 HTTP | `PythonAccountRegister.cpp` 的工作线程使用相同 TCP 连接与 SOCKS 协商 |
|
||||
| 通用 UDP | `CNetworkDatagram`、`CNetDatagramSender`、`CNetDatagramReceiver` → 统一 SOCKS5 UDP ASSOCIATE |
|
||||
|
||||
百科、洗练、拾取、战令等服务端命令复用游戏连接,自动跟随该连接的路径。域名沿用系统 IPv4 解析,解析后的地址进入相同判断;纯数字开头的域名不会再被误当成 IP。游戏现有封包、加密、原始数据内容保持不变。
|
||||
|
||||
## 路由与生命周期
|
||||
|
||||
- 使用本机已启用网卡的实际 IPv4 地址、子网掩码判断,不假定 `/24`。排除回环、点对点及 TUN/TAP 网卡;回环目标直接连接,便于本地测试。
|
||||
- 同网段直接使用系统 TCP/UDP,不为了本地请求启动 MeshPort。一个客户端可以同时访问同网段与跨网段目标。
|
||||
- 跨网段只使用 MeshPort;没有配置、引导连接失败、路由缺失或 SOCKS 被拒绝时返回失败,**不退回系统直连**。
|
||||
- 首次需要时才后台启动 SDK。复用保存配置中的网络身份、密钥、引导节点及传输选项,强制应用模式、`dhcp=true`、清空固定 IPv4 和监听端口。
|
||||
- 等待动态 IP 和 SDK 接受的公告子网就绪。引擎启动、发现节点或仅获取 IP 均不算连接成功;TCP 的远端 SOCKS 建连成功或收到有效 UDP 回包后才提示“组网成功”,约 6 秒。
|
||||
- 同一 SDK 由全部请求共享,多个请求不会重复启动,也不会因另一次登录停止现有连接。运行期间刷新健康状态和子网,后续新目标、重连均重新检查路由。
|
||||
- 地址/路由准备最多 60 秒,SOCKS 建连最多 10 秒;原生 TCP 给整个准备流程最多 75 秒。UDP 发送队列有数量、字节和时限上限,防止断网时无限积压。
|
||||
- UDP 保留原始来源 IP/端口、数据报边界及 `MSG_PEEK`,直连和组网回包可由同一接收 API 读取。TCP 控制连接、UDP relay 与原始 socket 一起回收。
|
||||
- 关闭注册窗口会取消路由等待和 HTTP I/O,已发送到服务器的请求无法撤回,不做自动重发。退出时先取消并等待注册线程,再停止 SDK;关闭普通连接会移除其待完成协商。登录窗口的取消/退出也只取消尚在准备的账号及游戏连接,不中断独立频道查询或已建立的连接。
|
||||
- 网卡变化后,新连接和每次发送都重新判断;排队的 UDP 若变为同网段,则改走直连。已经建立的 TCP 会话不能迁移到另一条路径:断线后沿原客户端流程返回登录/建立新连接,新连接重新判断;没有新增自动登录或自动重放业务请求。
|
||||
|
||||
使用应用内桥接,不创建系统 VPN、不安装 OS 路由。MeshPort 自己的引导/打洞连接仍使用系统网络,避免组网递归。
|
||||
|
||||
## SDK 的 DHCP 子网修复
|
||||
|
||||
原 SDK 的公告子网过滤器捕获 `TomlConfig.get_ipv4()`。DHCP 启动时它为空,动态地址分配后也不会更新,造成“有 IP、有节点,但无法接受服务器网段”。本地修复从运行中的节点快照更新过滤器,再投影接受的子网;变更记录在 `third_party/meshport/UPSTREAM.md`。
|
||||
|
||||
## 私有配置
|
||||
|
||||
当前开发机默认读取 `~/Library/Application Support/MeshPort/network-profile.toml`。其他电脑可将同一网络的配置放入忽略规则覆盖的 `config/meshport.private.toml`,或设置 CMake 参数:
|
||||
|
||||
```sh
|
||||
cmake -S . -B build/release -DMT_BUILD_NATIVE_RENDER=ON \
|
||||
-DMT_MESHPORT_CONFIG="/path/to/network-profile.toml"
|
||||
```
|
||||
|
||||
配置在构建时读入生成头文件;开发运行时可用环境变量 `MT_MESHPORT_CONFIG` 覆盖。私有配置不进入 Git;包含配置的 APK/可执行文件应按私有客户端分发。错误提示不输出密钥。
|
||||
|
||||
## 构建
|
||||
|
||||
需要 Rust 1.95+(`cargo` 在 PATH 内)和 protoc(在 PATH 内或通过 `PROTOC` 指定)。依赖固定在 Cargo.lock,首次构建需要下载注册表依赖。编译产物默认放在 `build/meshport-runtime`;运行时及其 SDK 作为一份静态库链接,不依赖动态 MeshPort 库。
|
||||
|
||||
```sh
|
||||
./scripts/build_meshport.sh macos
|
||||
cmake -S . -B build/release -DCMAKE_BUILD_TYPE=Release \
|
||||
-DMT_BUILD_NATIVE_RENDER=ON -DCMAKE_PREFIX_PATH=/opt/homebrew
|
||||
cmake --build build/release --target mt_native_render -j8
|
||||
```
|
||||
|
||||
Android arm64:`./android/build.sh Release --no-deploy` 会先编译运行时和 SDK,再构建客户端和 APK。独立构建可执行 `./scripts/build_meshport.sh android`;最低 API 24,链接对齐 16 KB 页面。
|
||||
|
||||
`MT_MESHPORT_LIBRARY` 可覆盖静态库路径,`MT_MESHPORT_ROOT` 可覆盖 CMake 中 SDK 头文件路径。组网关闭的专项测试可设置 `-DMT_ENABLE_MESHPORT=OFF`。
|
||||
|
||||
## 验证
|
||||
|
||||
本地真实 SDK 网关将公告网段映射到回环 TCP/UDP 测试服务,测试安装零条 OS 路由,无需管理员权限。构建测试网关时使用与运行时相同的 Cargo target 目录:
|
||||
|
||||
```sh
|
||||
CARGO_TARGET_DIR="$PWD/build/meshport-runtime" cargo build \
|
||||
--manifest-path src/meshport/runtime/Cargo.toml \
|
||||
--example gateway_fixture --release --locked
|
||||
cmake -S . -B build/native -DBUILD_TESTING=ON
|
||||
cmake --build build/native --target meshport_transport_test meshport_network_paths_test -j4
|
||||
ctest --test-dir build/native -R '^meshport\.' --output-on-failure
|
||||
python3 tests/meshport/test_network_paths.py \
|
||||
build/native/src/meshport/meshport_network_paths_test --client
|
||||
```
|
||||
|
||||
测试包括:实际子网掩码、同网段零组网启动、UDP 首次请求触发 DHCP、真实公告子网 TCP/UDP 转发、UDP 来源与 peek、并发账号/游戏类型连接、HTTP、缺失路由不直连、取消协商、SOCKS 分片/拒绝、失败提示与成功提示生命周期。`--client` 还启动真实 Python 2.7 原生客户端,调用实际注册接口验证取消后重新注册。
|
||||
|
||||
跨公网到正式服务器的完整游戏登录、Android 真机切换 Wi-Fi/移动网络需要相应网络与设备验收;本地回环网关测试不能代替这些现场验证。
|
||||
|
||||
本次本机验证记录(2026-10-16):
|
||||
|
||||
- macOS 原生客户端和 Android arm64 APK 构建成功。
|
||||
- `meshport.transport`、`meshport.login`、`meshport.network_paths`、`meshport.dhcp`、`port.net` 共 5 组通过:`build/meshport-final-tests.log`。
|
||||
- 真实 Python 2.7 客户端验证了登录前路由、取消待完成登录、实际 HTTP 注册、取消后重新注册:`build/meshport-path-client-tests.log`、`build/meshport-registration-runtime.log`。
|
||||
- 完整 `port.login_flow` 的账号/加密登录及前段网络检查通过,后段 NPC 商店/任务/仓库点击检查仍有 27 项失败。用关闭组网模块的对照程序复验,失败数量和源码行号完全相同;此项不记为整体通过。日志:`build/meshport-regression-tests.log`、`build/meshport-baseline/test.log`。
|
||||
@@ -271,3 +271,7 @@ Mac 和 Android 更新包在 dist/*AVA2Bio-20261014.zip,Android 包含 APK 与
|
||||
新增当前服务端已加载分组的只读查询、来源反查、NORMAL/PCT 宝箱模式、角色有效属性快照,以及客户端能力协商/请求匹配/分页/降级。接入百科、怪物目标和触控背包提示;保持原开箱及经济行为。FreeBSD 独立构建、协议及触控回归通过;没有替换 203 运行程序。未完成副本、洗练、日历/战令与模型预览,边界及证据见 `AVA2-READONLY-FEATURES.md`。
|
||||
|
||||
2026-10-15 再续:龙穴/周任务信息与提醒、共享真实掉落开关的活动日历已实现并在隔离环境验证。副本仅首批龙穴;活动仅月光宝箱/圣诞袜,生产未部署,无生产排期。自动洗练/锁定、战令、模型预览、批量开箱仍待实现。见 AVA2-DUNGEON-CALENDAR.md。
|
||||
|
||||
### 2026-10-18:AVA2原生战令/百科/掉落/活动日历
|
||||
|
||||
按用户授权替换三个原生系统,使用原AVA2脚本和独立平台适配;146项客户端回归、30组服务端功能测试、macOS/sbtest联机及Android离线构建通过。203正式服已于本地时间2026-10-19 08:31更新game a8d606ea,auth/13个核心/原db正常。没有生产活动排期;测试角色和临时排期已恢复。详见 `AVA2-NATIVE-SYSTEMS.md`;整体40250/AVA2结论保持PARTIAL。
|
||||
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build only MeshPort's application-mode SDK; no VPN or internet proxy engine.
|
||||
set -euo pipefail
|
||||
repo="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
mesh="${MT_MESHPORT_ROOT:-$repo/third_party/meshport}"
|
||||
platform="${1:-macos}"
|
||||
export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$repo/build/meshport-runtime}"
|
||||
if [ "$platform" = android ] && [ -f "$CARGO_TARGET_DIR/aarch64-linux-android/release/libmetin2_meshport.a" ] && ! command -v cargo >/dev/null; then
|
||||
echo "Using prebuilt meshport: $CARGO_TARGET_DIR/aarch64-linux-android/release/libmetin2_meshport.a"
|
||||
exit 0
|
||||
fi
|
||||
command -v cargo >/dev/null || { echo "Rust 1.95+ is required (cargo not found)" >&2; exit 1; }
|
||||
cd "$mesh"
|
||||
if [ "$platform" = android ]; then
|
||||
sdk="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-$HOME/Library/Android/sdk}}"
|
||||
ndk="${ANDROID_NDK_ROOT:-${ANDROID_NDK_HOME:-}}"
|
||||
if [ -z "$ndk" ]; then ndk="$sdk/ndk/$(ls "$sdk/ndk" | sort -V | tail -1)"; fi
|
||||
tools="$ndk/toolchains/llvm/prebuilt/darwin-x86_64/bin"
|
||||
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="$tools/aarch64-linux-android24-clang"
|
||||
export CC_aarch64_linux_android="$CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER"
|
||||
export AR_aarch64_linux_android="$tools/llvm-ar"
|
||||
export CARGO_TARGET_AARCH64_LINUX_ANDROID_RUSTFLAGS='-C link-arg=-Wl,-z,max-page-size=16384'
|
||||
exec cargo build --manifest-path "$repo/src/meshport/runtime/Cargo.toml" --target aarch64-linux-android --release --locked
|
||||
elif [ "$platform" = macos ]; then
|
||||
exec cargo build --manifest-path "$repo/src/meshport/runtime/Cargo.toml" --release --locked
|
||||
fi
|
||||
printf 'usage: %s [macos|android]\n' "$0" >&2
|
||||
exit 2
|
||||
+120
-10
@@ -23,7 +23,7 @@ REPO = Path(__file__).resolve().parents[1]
|
||||
DEFAULT_EN = REPO.parent / "40250/Server Client TMP4/Client/Eternexus/locale_en/locale/en"
|
||||
DEFAULT_ZH = REPO.parent / "server_extracted/client_locale/longju/locale/taiwan"
|
||||
DEFAULT_OUTPUT = REPO / "build/zh-locale/Client"
|
||||
BUILD_DIRS = ("build/release", "build/native")
|
||||
BUILD_DIRS = ("build/release", "build/native", "build/switchbot-check")
|
||||
LOCALE_CFG = "10002 936 zh\n"
|
||||
DEFAULT_NAMES = REPO / "data/zh_40250"
|
||||
FORMAT = re.compile(r"%(?:\([^)]*\))?[-+#0 ]*\d*(?:\.\d+)?[diouxXeEfFgGcrs%]")
|
||||
@@ -125,7 +125,7 @@ def wrap_description(text: str) -> str:
|
||||
return " |".join(lines)
|
||||
|
||||
|
||||
def translate_itemdesc(path: Path, table: Path):
|
||||
def translate_itemdesc(path: Path, table: Path, names: dict = None):
|
||||
"""itemdesc.txt with its description and summary columns replaced from the English→Chinese table (UTF-8,
|
||||
English<TAB>Chinese) and wrapped; untranslated cells keep the English text."""
|
||||
chinese = {}
|
||||
@@ -137,6 +137,9 @@ def translate_itemdesc(path: Path, table: Path):
|
||||
for line in path.read_bytes().decode("cp1252").split("\n"):
|
||||
parts = line.split("\t")
|
||||
if parts[0].strip().isdigit():
|
||||
vnum = parts[0].strip()
|
||||
if names and vnum in names and names[vnum]:
|
||||
parts[1] = names[vnum]
|
||||
left = False
|
||||
for column in ITEMDESC_COLUMNS:
|
||||
text = parts[column].strip() if column < len(parts) else ""
|
||||
@@ -154,6 +157,26 @@ def translate_itemdesc(path: Path, table: Path):
|
||||
return {"translated_cells": translated, "english_rows": english_rows}
|
||||
|
||||
|
||||
def translate_guildbuildinglist(path: Path, table: Path):
|
||||
"""Replace column 3 (name) in guildbuildinglist.txt using a VNUM<TAB>NAME table (UTF-8)."""
|
||||
names = {}
|
||||
for line in table.read_text(encoding="utf-8").splitlines():
|
||||
if line and not line.startswith("#"):
|
||||
vnum, name = line.split("\t", 1)
|
||||
names[vnum.strip()] = name.strip()
|
||||
lines = path.read_bytes().decode("cp1252").splitlines()
|
||||
out = []
|
||||
translated = 0
|
||||
for line in lines:
|
||||
parts = line.split("\t")
|
||||
if parts and parts[0] in names:
|
||||
parts[3] = names[parts[0]]
|
||||
translated += 1
|
||||
out.append("\t".join(parts))
|
||||
path.write_bytes(("\n".join(out) + "\n").encode("gbk"))
|
||||
return {"translated_rows": translated}
|
||||
|
||||
|
||||
def overlay_rows(path: Path, overlay: Path, wrap_columns=()):
|
||||
"""Replace the rows of a vnum-keyed file by the overlay's (UTF-8, whole rows, no header); other rows keep
|
||||
their bytes (the English files are cp1252). wrap_columns (0-based) are wrapped like translated text."""
|
||||
@@ -320,7 +343,16 @@ def build(en: Path, zh: Path, output: Path, client_base: Path,
|
||||
|
||||
table = names_dir / "itemdesc_translate_zh.tsv" if names_dir else None
|
||||
if table and table.is_file():
|
||||
report["files"]["itemdesc.txt translation"] = translate_itemdesc(locale_dir / "itemdesc.txt", table)
|
||||
item_names_map = name_rows(names_dir / "item_names_zh.txt") if names_dir else {}
|
||||
if names_dir:
|
||||
item_names_map.update(name_rows(names_dir / "item_names_zh_overlay.txt"))
|
||||
report["files"]["itemdesc.txt translation"] = translate_itemdesc(
|
||||
locale_dir / "itemdesc.txt", table, item_names_map)
|
||||
|
||||
building_table = names_dir / "guildbuildinglist_zh.tsv" if names_dir else None
|
||||
if building_table and building_table.is_file() and (locale_dir / "guildbuildinglist.txt").is_file():
|
||||
report["files"]["guildbuildinglist.txt"] = translate_guildbuildinglist(
|
||||
locale_dir / "guildbuildinglist.txt", building_table)
|
||||
|
||||
for filename in ROW_FILES:
|
||||
overlay = names_dir / (Path(filename).stem + "_zh_overlay.txt") if names_dir else None
|
||||
@@ -350,11 +382,15 @@ def build(en: Path, zh: Path, output: Path, client_base: Path,
|
||||
limits = names_dir / "item_limits_server.tsv"
|
||||
if (names_dir / "item_stones_server.tsv").is_file() and not limits.is_file():
|
||||
raise ValueError("stone overlay requires the item limits table argument")
|
||||
if (names_dir / "item_shapes_server.tsv").is_file() and not (names_dir / "item_stones_server.tsv").is_file():
|
||||
raise ValueError("item shapes require the stone overlay argument")
|
||||
result = subprocess.run(
|
||||
[str(proto_tool), str(en / "item_proto"), str(en / "mob_proto"),
|
||||
str(item_names), str(mob_names), str(locale_dir / "item_proto"),
|
||||
str(locale_dir / "mob_proto")] + ([str(limits)] if limits.is_file() else [])
|
||||
+ ([str(names_dir / "item_stones_server.tsv")] if (names_dir / "item_stones_server.tsv").is_file() else []),
|
||||
+ ([str(names_dir / "item_stones_server.tsv")] if (names_dir / "item_stones_server.tsv").is_file() else [])
|
||||
# item_shapes_server.tsv follows the stone overlay (positional): size and flags of new-use items.
|
||||
+ ([str(names_dir / "item_shapes_server.tsv")] if (names_dir / "item_shapes_server.tsv").is_file() else []),
|
||||
check=True, capture_output=True, text=True,
|
||||
)
|
||||
report["proto"] = {
|
||||
@@ -393,7 +429,10 @@ def build_biolog(output: Path, pack_tool: Path):
|
||||
root = REPO / "tools/server/biolog"
|
||||
ava = REPO.parent / "AVA2"
|
||||
archive = ava / "2. Backup SF+SRC and SQL/FILES+SRC.tgz"
|
||||
if not archive.is_file():
|
||||
extracted = ava / "TEST/2. Backup SF+SRC and SQL/home/srv1/db/item_proto.txt"
|
||||
if not archive.is_file() and extracted.is_file():
|
||||
ava = ava / "TEST" # the reference unpacked under AVA2/TEST
|
||||
elif not archive.is_file():
|
||||
raise ValueError("AVA2 biology requires the local FILES+SRC.tgz reference")
|
||||
proto_tool = tool("biolog_proto_patch")
|
||||
if not proto_tool.is_file():
|
||||
@@ -401,11 +440,14 @@ def build_biolog(output: Path, pack_tool: Path):
|
||||
stage = output.parent / "biolog"
|
||||
stage.mkdir(parents=True, exist_ok=True)
|
||||
proto = stage / "ava2-item-proto.txt"
|
||||
with tarfile.open(archive, "r:gz") as source:
|
||||
member = source.extractfile("home/srv1/db/item_proto.txt")
|
||||
if member is None:
|
||||
raise ValueError("AVA2 item table missing")
|
||||
proto.write_bytes(member.read())
|
||||
if not archive.is_file():
|
||||
shutil.copyfile(extracted, proto)
|
||||
else:
|
||||
with tarfile.open(archive, "r:gz") as source:
|
||||
member = source.extractfile("home/srv1/db/item_proto.txt")
|
||||
if member is None:
|
||||
raise ValueError("AVA2 item table missing")
|
||||
proto.write_bytes(member.read())
|
||||
spec = importlib.util.spec_from_file_location("biolog_assets", root / "make_assets.py")
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
@@ -421,6 +463,70 @@ def build_biolog(output: Path, pack_tool: Path):
|
||||
return {"stages": 13, "item_templates": 29, "pack": "biolog", "first_priority": True}
|
||||
|
||||
|
||||
def build_ava2_items(output: Path, pack_tool: Path):
|
||||
"""AVA2 drop items missing on the server, layered over the biolog item table (see tools/server/ava2-items)."""
|
||||
import importlib.util
|
||||
root = REPO / "tools/server/ava2-items"
|
||||
ava = REPO.parent / "AVA2"
|
||||
if not (ava / "1. Client DEV/pack_maker").is_dir():
|
||||
ava = ava / "TEST"
|
||||
reader = REPO.parent / "metin2-server/src/server/db/src/ProtoReader.cpp"
|
||||
if not (ava / "1. Client DEV/pack_maker").is_dir() or not reader.is_file():
|
||||
raise ValueError("AVA2 items need ../AVA2 (pack_maker + FILES+SRC.tgz or server db) and ../metin2-server")
|
||||
proto_tool = tool("item_proto_patch")
|
||||
if not proto_tool.is_file():
|
||||
raise ValueError("build item_proto_patch before generating the Chinese client")
|
||||
stage = output.parent / "ava2-items"
|
||||
spec = importlib.util.spec_from_file_location("ava2_items", root / "make_items.py")
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
# biolog's pack carries the current locale/zh item tables; this pack must replace them, so it goes first.
|
||||
report = module.prepare(ava, reader, output.parent / "biolog/assets/locale/zh", stage,
|
||||
proto_tool.resolve(), pack_tool.resolve(), wrap_description)
|
||||
for extension in ("eix", "epk"):
|
||||
shutil.copy2(stage / ("ava2items." + extension), output / "pack" / ("ava2items." + extension))
|
||||
index = output / "pack/Index"
|
||||
lines = index.read_bytes().replace(b"\r\n", b"\n").splitlines()
|
||||
if b"ava2items" in lines:
|
||||
del lines[lines.index(b"ava2items") - 1:lines.index(b"ava2items") + 1]
|
||||
at = lines.index(b"biolog") - 1
|
||||
lines[at:at] = [b"*", b"ava2items"]
|
||||
index.write_bytes(b"\r\n".join(lines) + b"\r\n")
|
||||
return {"items": len(report["kept"]) + len(report["locked"]), "kept": len(report["kept"]),
|
||||
"locked": len(report["locked"]), "assets": report["assets"], "pack": "ava2items"}
|
||||
|
||||
|
||||
def build_ava2_maps(output: Path, pack_tool: Path, ava_root: Path = None):
|
||||
"""AVA2 maps/dungeons + their monsters, layered over ava2items (see tools/server/ava2-maps)."""
|
||||
import importlib.util
|
||||
root = REPO / "tools/server/ava2-maps"
|
||||
ava = ava_root or REPO.parent / "AVA2"
|
||||
if ava_root is None and not (ava / "2. Backup SF+SRC and SQL/home/srv1").is_dir():
|
||||
ava = ava / "TEST"
|
||||
reader = REPO.parent / "metin2-server/src/server/db/src/ProtoReader.cpp"
|
||||
if not (ava / "1. Client DEV/pack_maker").is_dir() or not reader.is_file():
|
||||
raise ValueError("AVA2 maps need pack_maker + extracted server tree (use --ava2-maps-root) and ../metin2-server")
|
||||
tools = [tool(name) for name in ("mob_proto_patch", "gr2_textures")]
|
||||
if not all(path.is_file() for path in tools):
|
||||
raise ValueError("build mob_proto_patch and gr2_textures before generating the Chinese client")
|
||||
spec = importlib.util.spec_from_file_location("ava2_maps", root / "make_maps.py")
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
stage = output.parent / "ava2-maps"
|
||||
# Reads the effective pack chain (ava2items' locale/zh/mob_proto included), so it must run after build_ava2_items.
|
||||
report = module.prepare(ava, reader, output, stage, tools[0].resolve(), tools[1].resolve(), pack_tool.resolve())
|
||||
for extension in ("eix", "epk"):
|
||||
shutil.copy2(stage / ("ava2maps." + extension), output / "pack" / ("ava2maps." + extension))
|
||||
index = output / "pack/Index"
|
||||
lines = index.read_bytes().replace(b"\r\n", b"\n").splitlines()
|
||||
if b"ava2maps" in lines:
|
||||
del lines[lines.index(b"ava2maps") - 1:lines.index(b"ava2maps") + 1]
|
||||
at = lines.index(b"ava2items") - 1
|
||||
lines[at:at] = [b"*", b"ava2maps"]
|
||||
index.write_bytes(b"\r\n".join(lines) + b"\r\n")
|
||||
return {"mobs": report["mobs"], "races": report["races"], "files": report["files"],
|
||||
"misses": len(report["misses"]), "pack": "ava2maps"}
|
||||
|
||||
|
||||
def build_wiki(output: Path, pack_tool: Path):
|
||||
"""A versioned public server catalogue; original script and proto packs stay intact."""
|
||||
@@ -457,11 +563,15 @@ def main():
|
||||
parser.add_argument("--proto-tool", type=Path, default=tool("locale_proto_patch"))
|
||||
parser.add_argument("--pack-tool", type=Path, default=tool("eterpack_pack"))
|
||||
parser.add_argument("--name-tables", type=Path, default=DEFAULT_NAMES)
|
||||
parser.add_argument("--ava2-maps-root", type=Path,
|
||||
help="AVA2 reference root containing pack_maker and the extracted server tree")
|
||||
args = parser.parse_args()
|
||||
report_path = build(args.english, args.chinese, args.output, args.client_base,
|
||||
args.proto_tool, args.name_tables, args.pack_tool)
|
||||
report = json.loads(report_path.read_text())
|
||||
report["biolog"] = build_biolog(args.output, args.pack_tool)
|
||||
report["ava2_items"] = build_ava2_items(args.output, args.pack_tool)
|
||||
report["ava2_maps"] = build_ava2_maps(args.output, args.pack_tool, args.ava2_maps_root)
|
||||
report["wiki"] = build_wiki(args.output, args.pack_tool)
|
||||
report_path.write_text(json.dumps(report, ensure_ascii=False, indent=2)+"\n", encoding="utf-8")
|
||||
print(f"Built {args.output / 'pack/locale_zh.eix'} (.epk), registered in pack/Index")
|
||||
|
||||
@@ -187,3 +187,9 @@ The cache includes every specialization value, while alpha reference, fog and te
|
||||
`--generic-shaders` / `MT_GENERIC_SHADERS=1` disables specialization for rendering comparisons.
|
||||
Android Adreno 512 starts in 30 FPS saver mode when no frame-rate preference exists; saved preferences and test overrides take priority.
|
||||
See [Mi 8 Lite measurements](../../docs/XIAOMI8LITE-ADAPTATION-20260930.md).
|
||||
|
||||
### Local QA commands between frames
|
||||
|
||||
`--py-command-file /absolute/path/command.py` optionally consumes local Python commands between script frames, while the script fiber is parked. Publish a complete file with atomic rename. Commands are removed before execution, including on a Python error; files over 1 MiB are rejected. This is an explicit development hook like `--py-exec`, disabled when omitted. Do not execute login/focus/phase changes from a test window's `OnUpdate`: those callbacks run during the native window-list traversal.
|
||||
|
||||
When reopening login, the selected live endpoint is retained instead of the packed legacy login address. A later manual server selection or explicit channel change still selects its own target; the successful game entry becomes the saved endpoint. No credentials are stored by this adapter.
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
// and 2D UIRenderCommand stream + memory textures ("MTRA").
|
||||
// - Version 5: adds per-draw fog color, mode, range and distance/density state.
|
||||
// - Version 6: adds texture address and filtering state for both stages.
|
||||
// - Version 11: adds D3D8 UI stage-0 U/V addressing; older UI captures retain clamp.
|
||||
// - Version 7: adds two fixed-function lights and material color sources.
|
||||
// - Version 8: eight lights, back-buffer clear entries, viewport MinZ/MaxZ, border color,
|
||||
// TEXCOORDINDEX / TEXTURETRANSFORMFLAGS / D3DTS_TEXTUREn per stage, emissive
|
||||
@@ -28,7 +29,7 @@
|
||||
namespace native_draw_capture {
|
||||
|
||||
struct Capture {
|
||||
std::uint32_t version = 10;
|
||||
std::uint32_t version = 11;
|
||||
std::vector<Render3DDraw> draws;
|
||||
std::unordered_map<std::string, std::vector<std::uint8_t>> textures;
|
||||
std::uint32_t ui_width = 960;
|
||||
@@ -114,7 +115,7 @@ inline void write(
|
||||
std::ofstream file(path, std::ios::binary | std::ios::trunc);
|
||||
if (!file) throw std::runtime_error("cannot create native draw capture: " + path);
|
||||
const std::uint32_t magic = 0x4d544452; // MTDR
|
||||
const std::uint32_t version = 10;
|
||||
const std::uint32_t version = 11;
|
||||
const auto count = static_cast<std::uint32_t>(draws.size());
|
||||
write_scalar(file, magic); write_scalar(file, version); write_scalar(file, count);
|
||||
for (const auto& draw : draws) {
|
||||
@@ -233,6 +234,7 @@ inline void write(
|
||||
write_string(file, cmd.mask);
|
||||
file.write(reinterpret_cast<const char*>(cmd.mu), sizeof(cmd.mu));
|
||||
file.write(reinterpret_cast<const char*>(cmd.mv), sizeof(cmd.mv));
|
||||
write_scalar(file,cmd.address_u);write_scalar(file,cmd.address_v);
|
||||
}
|
||||
if (!file) throw std::runtime_error("failed to write native draw capture: " + path);
|
||||
}
|
||||
@@ -242,7 +244,7 @@ inline Capture read_capture(const std::string& path) {
|
||||
if (!file) throw std::runtime_error("cannot open native draw capture: " + path);
|
||||
std::uint32_t magic = 0, version = 0, count = 0;
|
||||
read_scalar(file, magic); read_scalar(file, version); read_scalar(file, count);
|
||||
if (magic != 0x4d544452 || (version < 1 || version > 10) || count > 10'000)
|
||||
if (magic != 0x4d544452 || (version < 1 || version > 11) || count > 10'000)
|
||||
throw std::runtime_error("unsupported native draw capture format");
|
||||
Capture capture;
|
||||
capture.version = version;
|
||||
@@ -404,6 +406,7 @@ inline Capture read_capture(const std::string& path) {
|
||||
read_string(file, cmd.mask);
|
||||
file.read(reinterpret_cast<char*>(cmd.mu), sizeof(cmd.mu));
|
||||
file.read(reinterpret_cast<char*>(cmd.mv), sizeof(cmd.mv));
|
||||
if(version>=11) {read_scalar(file,cmd.address_u);read_scalar(file,cmd.address_v);}
|
||||
if (!file) throw std::runtime_error("truncated native draw capture UI command");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "host_util.h"
|
||||
#include "native_audio.h"
|
||||
#include "perf_log.h"
|
||||
#include "python_command_file.h"
|
||||
#include "texture_decode.h"
|
||||
#include "ui_scale.h"
|
||||
#include "ui_quality.h"
|
||||
@@ -40,6 +41,7 @@ namespace mt_host {
|
||||
// --py-exec: a test hook run once the auto-login run reaches the GameWindow (or, with --login-screen,
|
||||
// once the LoginWindow is up).
|
||||
std::string g_py_exec_after_login;
|
||||
std::string g_py_command_file;
|
||||
// --perf-log / MT_PERF_LOG=1: src/host/perf_log.h.
|
||||
bool g_perf_log = false;
|
||||
|
||||
@@ -236,7 +238,7 @@ int run_live_client(
|
||||
std::snprintf(
|
||||
conn_cmd,
|
||||
sizeof(conn_cmd),
|
||||
"_stream.SetConnectInfo('%s', %d, '%s', %d)\n"
|
||||
"__import__('mt_live_endpoint').Configure(_stream, '%s', %d, '%s', %d)\n"
|
||||
"_w = _stream.curPhaseWindow\n"
|
||||
"_w._LoginWindow__OpenServerBoard()",
|
||||
server_host.c_str(),
|
||||
@@ -257,7 +259,7 @@ int run_live_client(
|
||||
std::snprintf(
|
||||
login_cmd,
|
||||
sizeof(login_cmd),
|
||||
"_stream.SetConnectInfo('%s', %d, '%s', %d)\n"
|
||||
"__import__('mt_live_endpoint').Configure(_stream, '%s', %d, '%s', %d)\n"
|
||||
"_w = _stream.curPhaseWindow\n"
|
||||
"_w._LoginWindow__OpenLoginBoard()\n"
|
||||
"_w.idEditLine.SetText('%s')\n"
|
||||
@@ -458,6 +460,13 @@ int run_live_client(
|
||||
}
|
||||
};
|
||||
while ((frames == 0 || completed < frames) && renderer.poll(true) && PythonBoot::IsAppLooping()) {
|
||||
// The script fiber is parked here. UI callbacks can change focus/order/phase safely before traversal.
|
||||
if (!g_py_command_file.empty()) {
|
||||
std::string command_error;
|
||||
if (!consume_python_command_file(g_py_command_file,py_exec,command_error) && !command_error.empty())
|
||||
std::cerr << command_error << '\n';
|
||||
if (!PythonBoot::IsAppLooping()) break;
|
||||
}
|
||||
apply_policy();
|
||||
save_ui_height_if_changed();
|
||||
double pace_ms = 0.0;
|
||||
|
||||
@@ -10,6 +10,8 @@ class VulkanWindow;
|
||||
// --py-exec: a test hook run once the auto-login run reaches the GameWindow (or, with --login-screen,
|
||||
// once the LoginWindow is up).
|
||||
extern std::string g_py_exec_after_login;
|
||||
// --py-command-file: optional local QA commands executed while the script fiber is parked.
|
||||
extern std::string g_py_command_file;
|
||||
// --perf-log / MT_PERF_LOG=1: src/host/perf_log.h.
|
||||
extern bool g_perf_log;
|
||||
|
||||
|
||||
@@ -137,6 +137,7 @@ int main(int argc, char** argv) {
|
||||
else if (arg == "--show-fps") show_fps = true;
|
||||
#ifdef MT_NATIVE_HAS_LIVE_CLIENT
|
||||
else if (arg == "--py-exec" && i+1 < argc) g_py_exec_after_login = argv[++i];
|
||||
else if (arg == "--py-command-file" && i+1 < argc) g_py_command_file = argv[++i];
|
||||
else if (arg == "--perf-log") g_perf_log = true;
|
||||
else if (arg == "--fps-cap" && i+1 < argc) g_fps_cap = std::max(0, std::stoi(argv[++i]));
|
||||
else if (arg == "--refresh-rate" && i+1 < argc) g_refresh_rate = std::max(0, std::stoi(argv[++i]));
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
// Optional local QA input, consumed between script frames, never from a window OnUpdate callback.
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
namespace mt_host {
|
||||
template<class Execute>
|
||||
bool consume_python_command_file(const std::string& path, Execute execute, std::string& error) {
|
||||
if (path.empty()) return true;
|
||||
std::error_code ec;
|
||||
const bool exists=std::filesystem::exists(path,ec);
|
||||
if (ec) { error="cannot inspect Python command file";return false; }
|
||||
if (!exists) return true;
|
||||
const auto size=std::filesystem::file_size(path,ec);
|
||||
if (ec) { error="cannot stat Python command file";return false; }
|
||||
if (size>1024*1024) {
|
||||
std::filesystem::remove(path,ec);
|
||||
error="Python command file exceeds 1 MiB";return false;
|
||||
}
|
||||
std::ifstream in(path,std::ios::binary);
|
||||
if (!in) { error="cannot read Python command file";return false; }
|
||||
std::string code(static_cast<std::size_t>(size),'\0');
|
||||
if (size && !in.read(&code[0],static_cast<std::streamsize>(size))) {
|
||||
error="incomplete Python command file";return false;
|
||||
}
|
||||
in.close();
|
||||
// A failed command must not execute again on the next frame. Producers publish with atomic rename.
|
||||
if (!std::filesystem::remove(path,ec) || ec) { error="cannot consume Python command file";return false; }
|
||||
return execute(code);
|
||||
}
|
||||
}
|
||||
+66
-35
@@ -423,12 +423,12 @@ public:
|
||||
|
||||
const uint32_t icon_col = 0xFFFFFFFF;
|
||||
const float r = btn.radius;
|
||||
|
||||
#ifdef MT_NATIVE_HAS_LIVE_CLIENT
|
||||
if (btn.id == kAutoHuntButton) {
|
||||
draw_auto_hunt_button(commands, btn);
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef MT_NATIVE_HAS_LIVE_CLIENT
|
||||
if (is_quick_slot_button(btn.id)) {
|
||||
std::string skill_icon;
|
||||
float uv[4];
|
||||
@@ -649,51 +649,82 @@ private:
|
||||
static bool is_quick_slot_button(int id) { return (id >= 2 && id <= 7) || id == 9 || id == 10; }
|
||||
static int quick_slot_index(int id) { return id >= 9 ? id - 3 : id - 2; }
|
||||
|
||||
// A circular arrow; green while the hunt runs.
|
||||
// Clear "AUTO" vector button; green glow while the hunt runs.
|
||||
static void draw_auto_hunt_button(std::vector<UIRenderCommand>& commands, const ButtonDef& btn) {
|
||||
bool on = false;
|
||||
#ifdef MT_NATIVE_HAS_LIVE_CLIENT
|
||||
on = PythonBoot::AutoHuntIsEnabled();
|
||||
#endif
|
||||
const uint32_t disc = btn.pressed ? btn.color_pressed : (on ? 0xC040C040 : btn.color_idle);
|
||||
draw_filled_disc(commands, btn.x, btn.y, btn.radius, disc);
|
||||
const uint32_t col = on ? 0xFFB0FFB0 : 0xDDFFFFFF;
|
||||
const float r = btn.radius * 0.45f;
|
||||
const float kPi = 3.14159265f;
|
||||
const int segments = 12;
|
||||
const float a0 = -kPi * 0.35f, a1 = a0 + kPi * 1.6f;
|
||||
for (int i = 0; i < segments; ++i) {
|
||||
const float t0 = a0 + (a1 - a0) * float(i) / float(segments);
|
||||
const float t1 = a0 + (a1 - a0) * float(i + 1) / float(segments);
|
||||
draw_line(commands, btn.x + std::cos(t0) * r, btn.y + std::sin(t0) * r,
|
||||
btn.x + std::cos(t1) * r, btn.y + std::sin(t1) * r, col);
|
||||
}
|
||||
// Arrowhead at the arc's end, pointing along the direction of travel.
|
||||
const float ex = btn.x + std::cos(a1) * r, ey = btn.y + std::sin(a1) * r;
|
||||
const float tx = -std::sin(a1), ty = std::cos(a1);
|
||||
const float nx = std::cos(a1), ny = std::sin(a1);
|
||||
const float h = r * 0.55f;
|
||||
draw_line(commands, ex, ey, ex - tx * h + nx * h * 0.6f, ey - ty * h + ny * h * 0.6f, col);
|
||||
draw_line(commands, ex, ey, ex - tx * h - nx * h * 0.6f, ey - ty * h - ny * h * 0.6f, col);
|
||||
const uint32_t disc = btn.pressed ? (on ? 0xEB257D32 : 0xEB16110C) : (on ? 0xDD1B5E20 : 0x8A16110C);
|
||||
draw_filled_disc(commands, btn.x, btn.y, btn.radius * 0.88f, disc);
|
||||
|
||||
const uint32_t ring_col = on ? 0xFF80FF90 : (btn.pressed ? 0xFFB89545 : 0x8A997847);
|
||||
draw_circle(commands, btn.x, btn.y, btn.radius * 0.90f, ring_col, 32);
|
||||
if (on) {
|
||||
// A play dot in the middle while running.
|
||||
draw_rect_bar(commands, btn.x - 2.0f, btn.y - 2.0f, btn.x + 2.0f, btn.y + 2.0f, col);
|
||||
draw_circle(commands, btn.x, btn.y, btn.radius * 0.72f, 0x6680FF90, 32);
|
||||
}
|
||||
|
||||
const uint32_t text_col = on ? 0xFFFFFFFF : (btn.pressed ? 0xFFFFFFFF : 0xFFD8C49A);
|
||||
const float h = std::round(btn.radius * 0.44f);
|
||||
const float w = std::round(h * 0.52f);
|
||||
const float gap = std::max(1.5f, std::round(h * 0.18f));
|
||||
const float total_w = 4.0f * w + 3.0f * gap;
|
||||
|
||||
const float top = btn.y - h * 0.5f;
|
||||
const float bot = top + h;
|
||||
const float mid = top + h * 0.5f;
|
||||
|
||||
float x = btn.x - total_w * 0.5f;
|
||||
|
||||
// 'A'
|
||||
draw_line(commands, x, bot, x + w * 0.5f, top, text_col);
|
||||
draw_line(commands, x + 0.6f, bot, x + w * 0.5f + 0.6f, top, text_col);
|
||||
draw_line(commands, x + w * 0.5f, top, x + w, bot, text_col);
|
||||
draw_line(commands, x + w * 0.5f - 0.6f, top, x + w - 0.6f, bot, text_col);
|
||||
draw_rect_bar(commands, x + w * 0.22f, mid + 0.3f, x + w * 0.78f, mid + 1.5f, text_col);
|
||||
|
||||
x += w + gap;
|
||||
|
||||
// 'U'
|
||||
draw_rect_bar(commands, x, top, x + 1.3f, bot - 1.0f, text_col);
|
||||
draw_rect_bar(commands, x + w - 1.3f, top, x + w, bot - 1.0f, text_col);
|
||||
draw_rect_bar(commands, x + 1.0f, bot - 1.3f, x + w - 1.0f, bot, text_col);
|
||||
draw_line(commands, x, bot - 1.0f, x + 1.0f, bot, text_col);
|
||||
draw_line(commands, x + w - 1.0f, bot, x + w, bot - 1.0f, text_col);
|
||||
|
||||
x += w + gap;
|
||||
|
||||
// 'T'
|
||||
draw_rect_bar(commands, x, top, x + w, top + 1.3f, text_col);
|
||||
const float t_stem = x + (w - 1.3f) * 0.5f;
|
||||
draw_rect_bar(commands, t_stem, top + 1.0f, t_stem + 1.3f, bot, text_col);
|
||||
|
||||
x += w + gap;
|
||||
|
||||
// 'O'
|
||||
draw_rect_bar(commands, x + 1.0f, top, x + w - 1.0f, top + 1.3f, text_col);
|
||||
draw_rect_bar(commands, x + 1.0f, bot - 1.3f, x + w - 1.0f, bot, text_col);
|
||||
draw_rect_bar(commands, x, top + 1.0f, x + 1.3f, bot - 1.0f, text_col);
|
||||
draw_rect_bar(commands, x + w - 1.3f, top + 1.0f, x + w, bot - 1.0f, text_col);
|
||||
draw_line(commands, x, top + 1.0f, x + 1.0f, top, text_col);
|
||||
draw_line(commands, x + w - 1.0f, top, x + w, top + 1.0f, text_col);
|
||||
draw_line(commands, x, bot - 1.0f, x + 1.0f, bot, text_col);
|
||||
draw_line(commands, x + w - 1.0f, bot, x + w, bot - 1.0f, text_col);
|
||||
}
|
||||
|
||||
void init_buttons() {
|
||||
buttons_.clear();
|
||||
// Lower-right combat controls. All menus and status UI remain the original 40250 UI.
|
||||
buttons_.push_back({1, 0x39, 0, 0, 42.0f, "ATK", 0xC04C2818, 0xE0A77832});
|
||||
buttons_.push_back({2, 0x02, 0, 0, 26.0f, "S1", 0x803060C0, 0xD05080FF});
|
||||
buttons_.push_back({3, 0x03, 0, 0, 26.0f, "S2", 0x80903090, 0xD0D050D0});
|
||||
buttons_.push_back({4, 0x04, 0, 0, 26.0f, "S3", 0x80309060, 0xD050D080});
|
||||
buttons_.push_back({5, 0x05, 0, 0, 26.0f, "S4", 0x80906030, 0xD0D08050});
|
||||
buttons_.push_back({6, 0x06, 0, 0, 26.0f, "S5", 0x80603090, 0xD08050D0});
|
||||
buttons_.push_back({7, 0x07, 0, 0, 26.0f, "S6", 0x80308090, 0xD050C0D0});
|
||||
buttons_.push_back({kAutoHuntButton, 0, 0, 0, 24.0f, "AUTO", 0x80707070, 0xD0FFFFFF});
|
||||
buttons_.push_back({9, 0x08, 0, 0, 28.0f, "7", 0xB032211B, 0xE0664B2D});
|
||||
buttons_.push_back({10, 0x09, 0, 0, 28.0f, "8", 0xB032211B, 0xE0664B2D});
|
||||
buttons_.push_back({2, 0x02, 0, 0, 22.0f, "S1", 0x803060C0, 0xD05080FF});
|
||||
buttons_.push_back({3, 0x03, 0, 0, 22.0f, "S2", 0x80903090, 0xD0D050D0});
|
||||
buttons_.push_back({4, 0x04, 0, 0, 22.0f, "S3", 0x80309060, 0xD050D080});
|
||||
buttons_.push_back({5, 0x05, 0, 0, 22.0f, "S4", 0x80906030, 0xD0D08050});
|
||||
buttons_.push_back({6, 0x06, 0, 0, 22.0f, "S5", 0x80603090, 0xD08050D0});
|
||||
buttons_.push_back({7, 0x07, 0, 0, 22.0f, "S6", 0x80308090, 0xD050C0D0});
|
||||
buttons_.push_back({kAutoHuntButton, 0, 0, 0, 22.0f, "AUTO", 0x80707070, 0xD0FFFFFF});
|
||||
buttons_.push_back({9, 0x08, 0, 0, 24.0f, "7", 0xB032211B, 0xE0664B2D});
|
||||
buttons_.push_back({10, 0x09, 0, 0, 24.0f, "8", 0xB032211B, 0xE0664B2D});
|
||||
for (auto& btn : buttons_) {
|
||||
if (is_quick_slot_button(btn.id)) {
|
||||
btn.color_idle = 0xA032211B;
|
||||
@@ -717,7 +748,7 @@ private:
|
||||
|
||||
int find_button(float x, float y) {
|
||||
int nearest = -1;
|
||||
float best = 1.25f;
|
||||
float best = 1.15f;
|
||||
for (size_t i = 0; i < buttons_.size(); ++i) {
|
||||
const auto& btn = buttons_[i];
|
||||
const float distance = std::hypot(x - btn.x, y - btn.y) / btn.radius;
|
||||
|
||||
+15
-14
@@ -16,25 +16,26 @@ struct TouchLayout {
|
||||
|
||||
inline TouchLayout make_touch_layout(float width, float height, float safe_inset, float minimum_target) {
|
||||
TouchLayout layout{};
|
||||
layout.scale = std::max(minimum_target / 52.0f,
|
||||
layout.scale = std::max(minimum_target / 44.0f,
|
||||
std::clamp(std::min(height / 600.0f, (width - 2 * safe_inset) / 800.0f), 0.65f, 1.35f));
|
||||
const float s = layout.scale;
|
||||
const float ax = width - safe_inset - 78 * s;
|
||||
// Leave the original status/menu strip clear below the lowest skill.
|
||||
const float ay = height - 136 * s;
|
||||
layout.buttons[0] = {ax, ay, 44 * s};
|
||||
// PORT: D2R Mobile's main-button + single skill arc arrangement, extended to six slots.
|
||||
// 24-degree spacing at radius 176 keeps even the expanded (1.25x) hit circles separate.
|
||||
const float ax = width - safe_inset - 74 * s;
|
||||
// Lowered attack button for thumb resting near the bottom edge.
|
||||
const float ay = height - 88 * s;
|
||||
layout.buttons[0] = {ax, ay, 42 * s};
|
||||
// Compact single-layer skill arc in the upper-left of attack button:
|
||||
// 20-degree spacing from 170 to 270 degrees at radius 140 keeps the skills tightly
|
||||
// wrapped around the attack button without encroaching on the minimap or screen center.
|
||||
for (int slot = 0; slot < 6; ++slot) {
|
||||
const float angle = (160.0f + 24.0f * slot) * 3.14159265f / 180.0f;
|
||||
layout.buttons[slot + 1] = {ax + std::cos(angle) * 176 * s,
|
||||
ay + std::sin(angle) * 176 * s, 28 * s};
|
||||
const float angle = (170.0f + 20.0f * slot) * 3.14159265f / 180.0f;
|
||||
layout.buttons[slot + 1] = {ax + std::cos(angle) * 140 * s,
|
||||
ay + std::sin(angle) * 140 * s, 22 * s};
|
||||
}
|
||||
// Keep the settings/toggle action outside the arc, away from repeated attack taps.
|
||||
layout.buttons[7] = {ax - 246 * s, ay - 84 * s, 26 * s};
|
||||
// Auto hunt button nestled compactly just outside the skill arc.
|
||||
layout.buttons[7] = {ax - 195 * s, ay - 50 * s, 22 * s};
|
||||
const float item_center = std::min(width / 2, layout.buttons[1].x - 114 * s);
|
||||
layout.buttons[8] = {item_center - 36 * s, height - 38 * s, 28 * s};
|
||||
layout.buttons[9] = {item_center + 36 * s, height - 38 * s, 28 * s};
|
||||
layout.buttons[8] = {item_center - 36 * s, height - 38 * s, 24 * s};
|
||||
layout.buttons[9] = {item_center + 36 * s, height - 38 * s, 24 * s};
|
||||
return layout;
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ void VulkanWindow::build_ui_batches(
|
||||
? ((cmd.blend == 1 || cmd.blend == 2) ? 0x2A : (cmd.blend == 3 ? 0x31 : 1))
|
||||
: 1;
|
||||
const VkPipeline pipeline = get_pipeline(0, 0, blend_mode);
|
||||
const VkDescriptorSet descriptor = get_ui_texture_descriptor(tex_name, mask_name, capture_textures, point);
|
||||
const VkDescriptorSet descriptor = get_ui_texture_descriptor(tex_name, mask_name, capture_textures, point, cmd.address_u, cmd.address_v);
|
||||
|
||||
for (int k = 0; k < 4; ++k) {
|
||||
Vertex& vert = vertices[v_count + k];
|
||||
|
||||
+10
-8
@@ -173,7 +173,7 @@ void VulkanWindow::prepare_draws(const std::vector<Render3DDraw>& draws, const T
|
||||
RenderTarget* target = nullptr;
|
||||
if (draw.render_target) {
|
||||
target = get_render_target(
|
||||
Render3DRenderTargetName(draw.render_target, draw.target_width, draw.target_height));
|
||||
Render3DRenderTargetName(draw.render_target, draw.target_width, draw.target_height, draw.target_color));
|
||||
if (!target) continue;
|
||||
}
|
||||
if (draw.clear_flags && target) {
|
||||
@@ -257,7 +257,8 @@ void VulkanWindow::prepare_draws(const std::vector<Render3DDraw>& draws, const T
|
||||
}
|
||||
}
|
||||
const auto pipeline = get_pipeline(cull, depth, blend, draw.lines,
|
||||
static_cast<std::uint8_t>(draw.z_func), target != nullptr, &draw);
|
||||
static_cast<std::uint8_t>(draw.z_func),
|
||||
std::uint8_t(target ? (target->color ? 2 : 1) : 0), &draw);
|
||||
// D3DTOP_DISABLE (1) on stage 0 or 1 ends the cascade before stage 1 samples.
|
||||
const bool bind_tex1 = !draw.texture1.empty() && draw.color_op[0] > 1 && draw.color_op[1] > 1;
|
||||
const auto descriptor = get_texture_descriptor(
|
||||
@@ -265,8 +266,9 @@ void VulkanWindow::prepare_draws(const std::vector<Render3DDraw>& draws, const T
|
||||
|
||||
auto constants = make_push_constants(draw, skin_offset_encoded);
|
||||
if (draw.pretransformed) {
|
||||
const float screen_width = float(logical_width());
|
||||
const float screen_height = float(logical_height());
|
||||
// PORT: a pretransformed draw into a render target is in the target's pixels.
|
||||
const float screen_width = target ? float(target->width) : float(logical_width());
|
||||
const float screen_height = target ? float(target->height) : float(logical_height());
|
||||
// Screen pixels (y down) to D3D NDC (y up); the shader's Y flip then maps to Vulkan.
|
||||
constants.mvp = {2.0f / screen_width, 0, 0, 0,
|
||||
0, -2.0f / screen_height, 0, 0,
|
||||
@@ -448,7 +450,7 @@ void VulkanWindow::record_passes(std::uint32_t image_index, const FrameDraws& fr
|
||||
for (std::size_t i = 0; i < frame.offscreen_draws.size();) {
|
||||
RenderTarget* target = frame.offscreen_draws[i].target;
|
||||
VkRenderPassBeginInfo offscreen_begin{VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO};
|
||||
offscreen_begin.renderPass = offscreen_pass_;
|
||||
offscreen_begin.renderPass = target->color ? offscreen_color_pass_ : offscreen_pass_;
|
||||
offscreen_begin.framebuffer = target->framebuffer;
|
||||
offscreen_begin.renderArea.extent = {target->width, target->height};
|
||||
vkCmdBeginRenderPass(f_->command, &offscreen_begin, VK_SUBPASS_CONTENTS_INLINE);
|
||||
@@ -559,10 +561,10 @@ VulkanWindow::Readback VulkanWindow::record_readbacks(std::uint32_t image_index)
|
||||
const char* dump_rt = std::getenv("MT_DUMP_RT");
|
||||
if (readback.bmp && dump_rt && *dump_rt) {
|
||||
readback.dump_rt = dump_rt;
|
||||
const std::uint32_t texel = offscreen_format_ == VK_FORMAT_R5G6B5_UNORM_PACK16 ? 2 : 4;
|
||||
for (auto& entry : render_targets_) {
|
||||
RenderTarget& rt = entry.second;
|
||||
Readback::RtDump dump{VK_NULL_HANDLE, VK_NULL_HANDLE, rt.width, rt.height};
|
||||
const std::uint32_t texel = !rt.color && offscreen_format_ == VK_FORMAT_R5G6B5_UNORM_PACK16 ? 2 : 4;
|
||||
Readback::RtDump dump{VK_NULL_HANDLE, VK_NULL_HANDLE, rt.width, rt.height, texel};
|
||||
VkBufferCreateInfo info{VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO};
|
||||
info.size = VkDeviceSize(rt.width) * rt.height * texel; info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT;
|
||||
check(vkCreateBuffer(device_, &info, nullptr, &dump.buffer), "vkCreateBuffer rt dump");
|
||||
@@ -615,9 +617,9 @@ void VulkanWindow::finish_readbacks(Readback& readback) {
|
||||
for (auto& sink : readback.sinks) sink(bgra.data(), w, h);
|
||||
}
|
||||
vkUnmapMemory(device_, readback.memory);
|
||||
const std::uint32_t texel = offscreen_format_ == VK_FORMAT_R5G6B5_UNORM_PACK16 ? 2 : 4;
|
||||
for (std::size_t n = 0; n < readback.rt_dumps.size(); ++n) {
|
||||
const auto& dump = readback.rt_dumps[n];
|
||||
const std::uint32_t texel = dump.texel;
|
||||
void* data = nullptr;
|
||||
check(vkMapMemory(device_, dump.memory, 0, VK_WHOLE_SIZE, 0, &data), "vkMapMemory rt dump");
|
||||
const auto* bytes = static_cast<const std::uint8_t*>(data);
|
||||
|
||||
@@ -104,8 +104,13 @@ void VulkanWindow::create_offscreen_pass() {
|
||||
VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
|
||||
offscreen_format_ = (properties.optimalTilingFeatures & wanted) == wanted
|
||||
? VK_FORMAT_R5G6B5_UNORM_PACK16 : VK_FORMAT_R8G8B8A8_UNORM;
|
||||
offscreen_pass_ = make_offscreen_pass(offscreen_format_);
|
||||
offscreen_color_pass_ = make_offscreen_pass(VK_FORMAT_R8G8B8A8_UNORM);
|
||||
}
|
||||
|
||||
VkRenderPass VulkanWindow::make_offscreen_pass(VkFormat format) {
|
||||
VkAttachmentDescription attachments[2]{};
|
||||
attachments[0].format = offscreen_format_; attachments[0].samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
attachments[0].format = format; attachments[0].samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
attachments[0].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; attachments[0].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||
attachments[0].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
attachments[0].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
@@ -146,15 +151,17 @@ void VulkanWindow::create_offscreen_pass() {
|
||||
pass_info.attachmentCount = 2; pass_info.pAttachments = attachments;
|
||||
pass_info.subpassCount = 1; pass_info.pSubpasses = &subpass;
|
||||
pass_info.dependencyCount = 2; pass_info.pDependencies = dependencies;
|
||||
check(vkCreateRenderPass(device_, &pass_info, nullptr, &offscreen_pass_), "vkCreateRenderPass offscreen");
|
||||
VkRenderPass pass = VK_NULL_HANDLE;
|
||||
check(vkCreateRenderPass(device_, &pass_info, nullptr, &pass), "vkCreateRenderPass offscreen");
|
||||
return pass;
|
||||
}
|
||||
|
||||
VkPipeline VulkanWindow::get_pipeline(std::uint8_t cull, std::uint8_t depth, std::uint8_t blend,
|
||||
bool lines, std::uint8_t z_func, bool offscreen, const Render3DDraw* draw) {
|
||||
bool lines, std::uint8_t z_func, std::uint8_t offscreen, const Render3DDraw* draw) {
|
||||
std::array<std::uint32_t, 17> key{};
|
||||
key[0] = std::uint32_t(cull) | (std::uint32_t(depth) << 8) |
|
||||
(std::uint32_t(blend) << 16) | (lines ? (1u << 24) : 0u) |
|
||||
(std::uint32_t(z_func & 0xfu) << 25) | (offscreen ? (1u << 29) : 0u);
|
||||
(std::uint32_t(z_func & 0xfu) << 25) | (std::uint32_t(offscreen & 3u) << 29);
|
||||
static const bool specialize = std::getenv("MT_GENERIC_SHADERS") == nullptr;
|
||||
key[1] = specialize ? 1u : 0u;
|
||||
if (specialize && draw) {
|
||||
@@ -296,7 +303,7 @@ VkPipeline VulkanWindow::get_pipeline(std::uint8_t cull, std::uint8_t depth, std
|
||||
pipeline_info.pMultisampleState = &multisample; pipeline_info.pDepthStencilState = &depth_stencil;
|
||||
pipeline_info.pColorBlendState = &blending;
|
||||
pipeline_info.pDynamicState = &dynamic_info;
|
||||
pipeline_info.layout = layout_; pipeline_info.renderPass = offscreen ? offscreen_pass_ : pass_;
|
||||
pipeline_info.layout = layout_; pipeline_info.renderPass = offscreen == 2 ? offscreen_color_pass_ : offscreen ? offscreen_pass_ : pass_;
|
||||
VkPipeline handle = VK_NULL_HANDLE;
|
||||
check(vkCreateGraphicsPipelines(device_, VK_NULL_HANDLE, 1, &pipeline_info, nullptr, &handle), "vkCreateGraphicsPipelines");
|
||||
pipelines_.emplace(key, handle);
|
||||
|
||||
@@ -270,15 +270,23 @@ void VulkanWindow::ensure_ui_capacity(std::size_t command_count) {
|
||||
}
|
||||
|
||||
VulkanWindow::RenderTarget* VulkanWindow::get_render_target(const std::string& name) {
|
||||
if (auto it = render_targets_.find(name); it != render_targets_.end()) return &it->second;
|
||||
if (auto it = render_targets_.find(name); it != render_targets_.end()) {
|
||||
it->second.last_used_frame = frame_number_;
|
||||
return &it->second;
|
||||
}
|
||||
unsigned id = 0, w = 0, h = 0;
|
||||
if (std::sscanf(name.c_str(), "rt:%u:%ux%u", &id, &w, &h) != 3 || !w || !h || w > 4096 || h > 4096)
|
||||
int end = 0;
|
||||
if (std::sscanf(name.c_str(), "rt:%u:%ux%u%n", &id, &w, &h, &end) != 3 || !w || !h || w > 4096 || h > 4096)
|
||||
return nullptr;
|
||||
const bool color = name.compare(std::size_t(end), std::string::npos, ":c") == 0;
|
||||
if (!color && name[std::size_t(end)] != '\0') return nullptr;
|
||||
RenderTarget& target = render_targets_[name];
|
||||
target.width = w;
|
||||
target.height = h;
|
||||
target.color = color;
|
||||
target.last_used_frame = frame_number_;
|
||||
auto make_image = [&](VkFormat format, VkImageUsageFlags usage, VkImageAspectFlags aspect,
|
||||
VkImage& image, VkDeviceMemory& memory, VkImageView& view) {
|
||||
VkImage& image, VkDeviceMemory& memory, VkImageView& view, bool opaque = false) {
|
||||
VkImageCreateInfo info{VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO};
|
||||
info.imageType = VK_IMAGE_TYPE_2D;
|
||||
info.format = format;
|
||||
@@ -299,18 +307,20 @@ VulkanWindow::RenderTarget* VulkanWindow::get_render_target(const std::string& n
|
||||
VkImageViewCreateInfo view_info{VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO};
|
||||
view_info.image = image; view_info.viewType = VK_IMAGE_VIEW_TYPE_2D; view_info.format = format;
|
||||
view_info.subresourceRange = {aspect, 0, 1, 0, 1};
|
||||
// A colour target is D3DFMT_X8R8G8B8: sampled alpha is always 1.
|
||||
if (opaque) view_info.components.a = VK_COMPONENT_SWIZZLE_ONE;
|
||||
check(vkCreateImageView(device_, &view_info, nullptr, &view), "vkCreateImageView render target");
|
||||
};
|
||||
make_image(offscreen_format_,
|
||||
make_image(color ? VK_FORMAT_R8G8B8A8_UNORM : offscreen_format_,
|
||||
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT |
|
||||
VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT, target.texture.image, target.texture.memory, target.texture.view);
|
||||
VK_IMAGE_ASPECT_COLOR_BIT, target.texture.image, target.texture.memory, target.texture.view, color);
|
||||
make_image(VK_FORMAT_D32_SFLOAT,
|
||||
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
|
||||
VK_IMAGE_ASPECT_DEPTH_BIT, target.depth_image, target.depth_memory, target.depth_view);
|
||||
const VkImageView views[2] = {target.texture.view, target.depth_view};
|
||||
VkFramebufferCreateInfo fb{VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO};
|
||||
fb.renderPass = offscreen_pass_;
|
||||
fb.renderPass = color ? offscreen_color_pass_ : offscreen_pass_;
|
||||
fb.attachmentCount = 2; fb.pAttachments = views;
|
||||
fb.width = w; fb.height = h; fb.layers = 1;
|
||||
check(vkCreateFramebuffer(device_, &fb, nullptr, &target.framebuffer), "vkCreateFramebuffer render target");
|
||||
@@ -343,7 +353,8 @@ void VulkanWindow::initialize_render_target(RenderTarget& target) {
|
||||
barriers[1].subresourceRange = {VK_IMAGE_ASPECT_DEPTH_BIT, 0, 1, 0, 1};
|
||||
vkCmdPipelineBarrier(f_->command, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
0, 0, nullptr, 0, nullptr, 2, barriers);
|
||||
const VkClearColorValue white{{1.0f, 1.0f, 1.0f, 1.0f}};
|
||||
const float shade = target.color ? 0.0f : 1.0f;
|
||||
const VkClearColorValue white{{shade, shade, shade, 1.0f}};
|
||||
const VkClearDepthStencilValue far{1.0f, 0};
|
||||
vkCmdClearColorImage(f_->command, target.texture.image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &white, 1,
|
||||
&barriers[0].subresourceRange);
|
||||
|
||||
@@ -181,7 +181,7 @@ VulkanWindow::PreparedDraw VulkanWindow::scene_composite_draw() {
|
||||
for (int i = 0; i < 16; ++i) m[i] = i % 5 == 0 ? 1.0f : 0.0f;
|
||||
PreparedDraw composite{};
|
||||
composite.geometry = &scene_quad_;
|
||||
composite.pipeline = get_pipeline(0, 0, 0, false, 4, false, &quad);
|
||||
composite.pipeline = get_pipeline(0, 0, 0, false, 4, 0, &quad);
|
||||
composite.descriptor = scene_texture_.descriptor;
|
||||
composite.constants = make_push_constants(quad, 0.0f);
|
||||
// Unit square (y down) to D3D NDC (y up), as the pretransformed draws map screen pixels.
|
||||
|
||||
@@ -195,7 +195,20 @@ VkDescriptorSet VulkanWindow::get_texture_descriptor(
|
||||
VkDescriptorSet VulkanWindow::get_ui_texture_descriptor(
|
||||
const std::string& texture0_name,
|
||||
const std::string& mask_name,
|
||||
const std::unordered_map<std::string, std::vector<std::uint8_t>>& capture_textures, bool point) {
|
||||
const std::unordered_map<std::string, std::vector<std::uint8_t>>& capture_textures, bool point,
|
||||
std::uint32_t address_u,std::uint32_t address_v) {
|
||||
if(address_u!=3 || address_v!=3) {
|
||||
// 40250 ExpandedImage uses the current D3D8 addressing state. Board backgrounds tile;
|
||||
// clamping them stretches the edge texels into stripes. Reuse the existing sampler cache.
|
||||
Render3DDraw state{};
|
||||
state.address_u[0]=address_u; state.address_v[0]=address_v;
|
||||
state.address_u[1]=state.address_v[1]=3;
|
||||
for(int i=0;i<2;++i) {
|
||||
state.min_filter[i]=state.mag_filter[i]=point?1:2;
|
||||
state.mip_filter[i]=0; // UI remains at mip zero, including the HD archive.
|
||||
}
|
||||
return get_texture_descriptor(texture0_name,mask_name,capture_textures,state);
|
||||
}
|
||||
auto& tex0 = get_gpu_texture(texture0_name, capture_textures);
|
||||
if (point && mask_name.empty() && tex0.view) {
|
||||
if (!tex0.ui_point_descriptor)
|
||||
@@ -430,6 +443,19 @@ void VulkanWindow::prune_textures() {
|
||||
it = textures_.erase(it);
|
||||
} else ++it;
|
||||
}
|
||||
// PORT: render targets too (a closed model preview); a later use recreates and clears one.
|
||||
for (auto it = render_targets_.begin(); it != render_targets_.end();) {
|
||||
if (frame_number_ - it->second.last_used_frame > static_retention_frames) {
|
||||
for (auto pair = paired_descriptors_.begin(); pair != paired_descriptors_.end();) {
|
||||
if (pair->first.find("\n" + it->first + "\n") != std::string::npos) {
|
||||
vkFreeDescriptorSets(device_, descriptor_pool_, 1, &pair->second.set);
|
||||
pair = paired_descriptors_.erase(pair);
|
||||
} else ++pair;
|
||||
}
|
||||
release_render_target(it->second);
|
||||
it = render_targets_.erase(it);
|
||||
} else ++it;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mt_host
|
||||
|
||||
@@ -125,6 +125,7 @@ VulkanWindow::~VulkanWindow() {
|
||||
for (auto& entry : textures_) release_texture(entry.second);
|
||||
for (auto& entry : render_targets_) release_render_target(entry.second);
|
||||
if (offscreen_pass_) vkDestroyRenderPass(device_, offscreen_pass_, nullptr);
|
||||
if (offscreen_color_pass_) vkDestroyRenderPass(device_, offscreen_color_pass_, nullptr);
|
||||
destroy_scene_target();
|
||||
release_geometry(scene_quad_);
|
||||
if (scene_pass_) vkDestroyRenderPass(device_, scene_pass_, nullptr);
|
||||
|
||||
@@ -56,8 +56,9 @@ class VulkanWindow {
|
||||
VkDescriptorSet set = VK_NULL_HANDLE;
|
||||
std::uint64_t last_used_frame = 0;
|
||||
};
|
||||
// An offscreen D3D render-target texture (the 40250 character shadow map, "rt:<id>:<w>x<h>"):
|
||||
// drawn by the frame's offscreen pass ahead of the back-buffer pass and sampled by that pass.
|
||||
// An offscreen D3D render-target texture (the 40250 character shadow map, "rt:<id>:<w>x<h>", or a
|
||||
// colour target such as the model preview, "rt:<id>:<w>x<h>:c"): drawn by the frame's offscreen pass
|
||||
// ahead of the back-buffer pass and sampled by that pass.
|
||||
// Between frames the colour image stays SHADER_READ_ONLY_OPTIMAL and the depth image
|
||||
// DEPTH_STENCIL_ATTACHMENT_OPTIMAL; the render pass keeps (LOAD/STORE) both, like a D3D surface.
|
||||
struct RenderTarget {
|
||||
@@ -67,7 +68,9 @@ class VulkanWindow {
|
||||
VkImageView depth_view = VK_NULL_HANDLE;
|
||||
VkFramebuffer framebuffer = VK_NULL_HANDLE;
|
||||
std::uint32_t width = 0, height = 0;
|
||||
bool initialized = false; // cleared to white / depth 1 by the first frame that uses it
|
||||
bool initialized = false; // cleared (shadow white, colour black) / depth 1 by the first frame that uses it
|
||||
bool color = false; // RGBA8 drawn with offscreen_color_pass_; otherwise offscreen_format_
|
||||
std::uint64_t last_used_frame = 0; // pruned with the textures once unused
|
||||
};
|
||||
struct PreparedDraw {
|
||||
Geometry* geometry = nullptr;
|
||||
@@ -223,7 +226,7 @@ private:
|
||||
};
|
||||
// Host copies of the swapchain image (--screenshot-out) and, with MT_DUMP_RT, of every render target.
|
||||
struct Readback {
|
||||
struct RtDump { VkBuffer buffer; VkDeviceMemory memory; std::uint32_t w, h; };
|
||||
struct RtDump { VkBuffer buffer; VkDeviceMemory memory; std::uint32_t w, h, texel; };
|
||||
bool screenshot = false; // the swapchain image is copied (a BMP or a frame sink wants it)
|
||||
bool bmp = false; // --screenshot-out
|
||||
std::vector<FrameSink> sinks;
|
||||
@@ -297,7 +300,9 @@ private:
|
||||
|
||||
// The render pass of offscreen render-target textures: colour (R5G6B5 like the D3D surface when
|
||||
// the device can render to it) + D32 depth, both loaded and stored, colour left shader-readable.
|
||||
// PORT: plus offscreen_color_pass_, the same pass over RGBA8 for colour targets.
|
||||
void create_offscreen_pass();
|
||||
VkRenderPass make_offscreen_pass(VkFormat format);
|
||||
|
||||
// The reduced-resolution scene pass: pass_'s attachments (so pass_ pipelines draw in it) at
|
||||
// scene_extent_, resolving into the sampled scene_texture_. Unsupported when the swapchain
|
||||
@@ -322,9 +327,10 @@ private:
|
||||
// the layouts offscreen_pass_ expects. Recorded outside any render pass.
|
||||
void initialize_render_target(RenderTarget& target);
|
||||
|
||||
// offscreen: for offscreen_pass_ (single-sampled render-target texture) instead of pass_.
|
||||
// offscreen: 1 for offscreen_pass_, 2 for offscreen_color_pass_ (single-sampled render-target
|
||||
// texture) instead of pass_.
|
||||
VkPipeline get_pipeline(std::uint8_t cull, std::uint8_t depth, std::uint8_t blend,
|
||||
bool lines = false, std::uint8_t z_func = 4, bool offscreen = false,
|
||||
bool lines = false, std::uint8_t z_func = 4, std::uint8_t offscreen = 0,
|
||||
const Render3DDraw* draw = nullptr);
|
||||
|
||||
VkDescriptorSet allocate_texture_descriptor_set(VkImageView view0, VkImageView view1,
|
||||
@@ -351,7 +357,7 @@ private:
|
||||
const std::string& texture0_name,
|
||||
const std::string& mask_name,
|
||||
const std::unordered_map<std::string, std::vector<std::uint8_t>>& capture_textures,
|
||||
bool point = false);
|
||||
bool point = false, std::uint32_t address_u = 3, std::uint32_t address_v = 3);
|
||||
|
||||
void upload_texture(
|
||||
std::uint32_t width,
|
||||
@@ -478,6 +484,7 @@ private:
|
||||
std::unordered_map<std::string, PairedDescriptor> paired_descriptors_;
|
||||
std::unordered_map<std::string, RenderTarget> render_targets_;
|
||||
VkRenderPass offscreen_pass_ = VK_NULL_HANDLE;
|
||||
VkRenderPass offscreen_color_pass_ = VK_NULL_HANDLE;
|
||||
float render_scale_ = 1.0f;
|
||||
bool scene_supported_ = false;
|
||||
VkRenderPass scene_pass_ = VK_NULL_HANDLE;
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
set(mt_mesh_default OFF)
|
||||
if(APPLE OR ANDROID)
|
||||
set(mt_mesh_default ON)
|
||||
endif()
|
||||
option(MT_ENABLE_MESHPORT "Embed MeshPort application networking" ${mt_mesh_default})
|
||||
if(NOT MT_ENABLE_MESHPORT)
|
||||
return()
|
||||
endif()
|
||||
set(MT_MESHPORT_ROOT "${PROJECT_SOURCE_DIR}/third_party/meshport" CACHE PATH "MeshPort source checkout")
|
||||
if(ANDROID)
|
||||
set(mt_mesh_library "${PROJECT_SOURCE_DIR}/build/meshport-runtime/aarch64-linux-android/release/libmetin2_meshport.a")
|
||||
else()
|
||||
set(mt_mesh_library "${PROJECT_SOURCE_DIR}/build/meshport-runtime/release/libmetin2_meshport.a")
|
||||
endif()
|
||||
set(MT_MESHPORT_LIBRARY "${mt_mesh_library}" CACHE FILEPATH "MeshPort static library for this target")
|
||||
if(NOT EXISTS "${MT_MESHPORT_LIBRARY}")
|
||||
message(FATAL_ERROR "Build MeshPort first: scripts/build_meshport.sh (or set MT_MESHPORT_LIBRARY)")
|
||||
endif()
|
||||
# A private build input, never copy network credentials into the source tree.
|
||||
set(mt_mesh_config "${PROJECT_SOURCE_DIR}/config/meshport.private.toml")
|
||||
if(EXISTS "$ENV{HOME}/Library/Application Support/MeshPort/network-profile.toml")
|
||||
set(mt_mesh_config "$ENV{HOME}/Library/Application Support/MeshPort/network-profile.toml")
|
||||
endif()
|
||||
set(MT_MESHPORT_CONFIG "${mt_mesh_config}"
|
||||
CACHE FILEPATH "Saved MeshPort network configuration to embed")
|
||||
set(MT_MESHPORT_TOML "")
|
||||
if(EXISTS "${MT_MESHPORT_CONFIG}")
|
||||
file(READ "${MT_MESHPORT_CONFIG}" MT_MESHPORT_TOML)
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${MT_MESHPORT_CONFIG}")
|
||||
else()
|
||||
message(WARNING "MeshPort network profile missing: LAN login works, remote login requires MT_MESHPORT_CONFIG")
|
||||
endif()
|
||||
configure_file(config.h.in "${CMAKE_CURRENT_BINARY_DIR}/MeshPortConfig.h" @ONLY)
|
||||
add_library(mt_meshport STATIC transport.cpp)
|
||||
target_include_directories(mt_meshport PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
PRIVATE "${MT_MESHPORT_ROOT}/crates/meshport-ffi/include")
|
||||
target_compile_definitions(mt_meshport PUBLIC MT_HAS_MESHPORT=1)
|
||||
target_link_libraries(mt_meshport PUBLIC "${MT_MESHPORT_LIBRARY}")
|
||||
if(APPLE)
|
||||
target_link_libraries(mt_meshport PUBLIC "-framework Security" "-framework SystemConfiguration"
|
||||
"-framework CoreFoundation" resolv iconv)
|
||||
elseif(ANDROID)
|
||||
target_link_libraries(mt_meshport PUBLIC log android dl m)
|
||||
endif()
|
||||
if(BUILD_TESTING AND NOT ANDROID)
|
||||
add_executable(meshport_transport_test "${PROJECT_SOURCE_DIR}/tests/meshport/transport_test.cpp")
|
||||
target_link_libraries(meshport_transport_test PRIVATE mt_meshport)
|
||||
add_test(NAME meshport.transport COMMAND meshport_transport_test)
|
||||
add_executable(meshport_network_paths_test "${PROJECT_SOURCE_DIR}/tests/meshport/network_paths_test.cpp")
|
||||
target_link_libraries(meshport_network_paths_test PRIVATE mt_meshport)
|
||||
find_package(Python3 COMPONENTS Interpreter)
|
||||
if(Python3_FOUND)
|
||||
add_test(NAME meshport.login COMMAND "${Python3_EXECUTABLE}" "${PROJECT_SOURCE_DIR}/tests/meshport/test_login.py")
|
||||
if(EXISTS "${PROJECT_SOURCE_DIR}/build/meshport-runtime/release/examples/gateway_fixture")
|
||||
add_test(NAME meshport.network_paths COMMAND "${Python3_EXECUTABLE}"
|
||||
"${PROJECT_SOURCE_DIR}/tests/meshport/test_network_paths.py" "$<TARGET_FILE:meshport_network_paths_test>")
|
||||
set_tests_properties(meshport.network_paths PROPERTIES TIMEOUT 120)
|
||||
endif()
|
||||
if(APPLE AND EXISTS "${PROJECT_SOURCE_DIR}/build/meshport-runtime/release/libmetin2_meshport.dylib")
|
||||
add_test(NAME meshport.dhcp COMMAND "${Python3_EXECUTABLE}"
|
||||
"${PROJECT_SOURCE_DIR}/tests/meshport/sdk_smoke.py")
|
||||
set_tests_properties(meshport.dhcp PROPERTIES TIMEOUT 55)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
// Generated private build input. Network credentials are intentionally not logged.
|
||||
static const char* const kMeshPortConfig = R"MESHCONFIG(@MT_MESHPORT_TOML@)MESHCONFIG";
|
||||
Generated
+4911
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,20 @@
|
||||
[package]
|
||||
name = "metin2-meshport"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
rust-version = "1.95"
|
||||
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
|
||||
[lib]
|
||||
crate-type = ["staticlib", "cdylib"]
|
||||
|
||||
[dependencies]
|
||||
meshport-ffi = { path = "../../../third_party/meshport/crates/meshport-ffi" }
|
||||
serde_json = "1"
|
||||
|
||||
[dev-dependencies]
|
||||
easytier = { path = "../../../third_party/meshport/vendor/easytier/easytier", default-features = false, features = ["aes-gcm", "ffi-dataplane", "proxy-cidr-monitor", "dhcp-ipv4", "tcp-hole-punch", "proxy-packet"] }
|
||||
easytier-core = { path = "../../../third_party/meshport/vendor/easytier/easytier-core", default-features = false, features = ["proxy-smoltcp-stack"] }
|
||||
tokio = { version = "1", features = ["rt-multi-thread", "macros", "net", "io-util", "sync", "time"] }
|
||||
@@ -0,0 +1,38 @@
|
||||
//! Isolated test gateway. Maps a private advertised subnet to loopback; no OS routes/TUN.
|
||||
use easytier::instance::factory::create_native_instance;
|
||||
use easytier_core::config::toml::{ConfigLoader, TomlConfig};
|
||||
use tokio::{net::{TcpListener,UdpSocket},io::{AsyncReadExt,AsyncWriteExt}};
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let tcp=TcpListener::bind("127.0.0.1:0").await.unwrap();
|
||||
let tcp_port=tcp.local_addr().unwrap().port();
|
||||
let udp=UdpSocket::bind("127.0.0.1:0").await.unwrap();
|
||||
let udp_port=udp.local_addr().unwrap().port();
|
||||
let reserve=std::net::TcpListener::bind("127.0.0.1:0").unwrap();
|
||||
let mesh_port=reserve.local_addr().unwrap().port();drop(reserve);
|
||||
let name=format!("metin2-gateway-test-{}",std::process::id());
|
||||
let config=format!("ipv4='10.253.85.1/24'\nlisteners=['tcp://127.0.0.1:{mesh_port}']\nstun_servers=[]\nstun_servers_v6=[]\n[[proxy_network]]\ncidr='127.0.0.0/24'\nmapped_cidr='10.253.79.0/24'\n[network_identity]\nnetwork_name='{name}'\nnetwork_secret='isolated-test-only'\n[flags]\nno_tun=true\nuse_smoltcp=true\nenable_encryption=true\n");
|
||||
let parsed=TomlConfig::new_from_str(&config).unwrap();
|
||||
eprintln!("fixture proxy networks: {:?}",parsed.get_proxy_cidrs());
|
||||
let server=create_native_instance(parsed).unwrap();
|
||||
server.start().await.unwrap();
|
||||
println!("{{\"mesh_port\":{mesh_port},\"tcp_port\":{tcp_port},\"udp_port\":{udp_port},\"network_name\":\"{name}\"}}");
|
||||
tokio::spawn(async move {
|
||||
while let Ok((mut stream,_))=tcp.accept().await {
|
||||
tokio::spawn(async move {
|
||||
let mut data=[0u8;16384];
|
||||
while let Ok(size)=stream.read(&mut data).await {
|
||||
if size==0 {break}
|
||||
if data[..size].starts_with(b"POST /register") {
|
||||
let _=stream.write_all(b"HTTP/1.0 200 OK\r\nContent-Length: 3\r\n\r\nOK\n").await;break
|
||||
}
|
||||
if stream.write_all(&data[..size]).await.is_err(){break}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
let mut data=[0u8;65536];
|
||||
loop {
|
||||
if let Ok((size,peer))=udp.recv_from(&mut data).await {let _=udp.send_to(&data[..size],peer).await;}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
//! Metin2 host policy around the vendored MeshPort SDK. No sockets or OS routes are intercepted.
|
||||
use serde_json::{json, Value};
|
||||
use std::{collections::HashMap, ffi::{c_char, CStr, CString}, net::Ipv4Addr,
|
||||
sync::{Arc, Condvar, Mutex, OnceLock}, thread::{self, JoinHandle}, time::{Duration, Instant}};
|
||||
|
||||
struct Target { since: Instant, touched: Instant }
|
||||
#[derive(Default)]
|
||||
struct State {
|
||||
config: String, targets: HashMap<u32, Target>, routes: Vec<String>, port: u16,
|
||||
stop: bool, failed: bool, retry: bool, event: i32, connected: bool,
|
||||
}
|
||||
#[derive(Default)]
|
||||
struct Runtime { state: Arc<(Mutex<State>, Condvar)>, worker: Option<JoinHandle<()>> }
|
||||
static RUNTIME: OnceLock<Mutex<Runtime>> = OnceLock::new();
|
||||
fn runtime() -> &'static Mutex<Runtime> { RUNTIME.get_or_init(|| Mutex::new(Runtime::default())) }
|
||||
|
||||
fn matches(cidr: &str, address: u32) -> bool {
|
||||
let Some((ip, bits)) = cidr.split_once('/') else { return false };
|
||||
let (Ok(ip), Ok(bits)) = (ip.parse::<Ipv4Addr>(), bits.parse::<u32>()) else { return false };
|
||||
if !(1..=32).contains(&bits) { return false }
|
||||
let mask = u32::MAX << (32 - bits);
|
||||
(u32::from(ip) & mask) == (address & mask)
|
||||
}
|
||||
fn call(context: u64, request: Value) -> Result<Value, ()> {
|
||||
let text = CString::new(request.to_string()).map_err(|_| ())?;
|
||||
let pointer = unsafe { meshport_ffi::meshport_call(context, text.as_ptr()) };
|
||||
if pointer.is_null() { return Err(()) }
|
||||
let decoded = unsafe { serde_json::from_slice::<Value>(CStr::from_ptr(pointer).to_bytes()) };
|
||||
unsafe { meshport_ffi::meshport_string_free(pointer) };
|
||||
let decoded = decoded.map_err(|_| ())?;
|
||||
if decoded["ok"] != true {
|
||||
if std::env::var_os("MT_MESHPORT_TRACE").is_some() { eprintln!("MeshPort SDK operation failed: {}",request["op"]); }
|
||||
return Err(())
|
||||
}
|
||||
Ok(decoded["data"].clone())
|
||||
}
|
||||
fn start(context: u64, config: &str) -> Result<u16, ()> {
|
||||
let info = call(context, json!({"op":"abi_info"}))?;
|
||||
if info["abi"] != 1 || info["revision"].as_u64().unwrap_or(0) < 2 { return Err(()) }
|
||||
let migrated = call(context, json!({"op":"migrate_config","toml":config}))?;
|
||||
let mut profile = call(context, json!({"op":"validate","toml":migrated["toml"],"include_profile":true}))?["profile"].clone();
|
||||
profile["runtime_mode"] = json!("application");
|
||||
profile["dhcp"] = json!(true); profile["ipv4"] = json!("");
|
||||
profile["hostname"] = json!("Metin2"); profile["listeners"] = json!([]);
|
||||
let built = call(context, json!({"op":"build_config","profile":profile}))?;
|
||||
let started = call(context, json!({"op":"start_bridged","toml":built["toml"],"check_local_overlap":true}))?;
|
||||
let listen = started["listen"].as_str().ok_or(())?;
|
||||
let port = listen.strip_prefix("127.0.0.1:").ok_or(())?.parse::<u16>().map_err(|_| ())?;
|
||||
if port == 0 { return Err(()) }
|
||||
Ok(port)
|
||||
}
|
||||
fn run(shared: Arc<(Mutex<State>, Condvar)>) {
|
||||
let (lock, wake) = &*shared;
|
||||
let mut context = 0;
|
||||
let mut last_projection = String::new();
|
||||
loop {
|
||||
let mut state = lock.lock().unwrap();
|
||||
if state.stop { break }
|
||||
if state.failed && !state.retry || context == 0 && state.targets.is_empty() {
|
||||
drop(wake.wait_timeout(state, Duration::from_secs(1)).unwrap());
|
||||
continue
|
||||
}
|
||||
if state.retry {
|
||||
state.retry = false; state.failed = false; state.routes.clear(); state.port = 0;
|
||||
state.connected = false; state.event = 1;
|
||||
drop(state);
|
||||
if context != 0 { meshport_ffi::meshport_context_free(context); context = 0; }
|
||||
continue
|
||||
}
|
||||
if context == 0 {
|
||||
state.event = 1; state.connected = false;
|
||||
let config = state.config.clone(); drop(state);
|
||||
context = meshport_ffi::meshport_context_new();
|
||||
let prepared = if context == 0 { Err(()) } else { start(context, &config) };
|
||||
state = lock.lock().unwrap();
|
||||
match prepared {
|
||||
Ok(port) => state.port = port,
|
||||
Err(_) => {
|
||||
state.failed = true; state.event = 3; state.port = 0;
|
||||
drop(state);
|
||||
if context != 0 { meshport_ffi::meshport_context_free(context); context = 0; }
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
drop(state);
|
||||
let snapshot = call(context, json!({"op":"status"}));
|
||||
state = lock.lock().unwrap();
|
||||
match snapshot {
|
||||
Ok(data) if data["health"]["engine_running"] == true && data["health"]["bridge_running"] == true => {
|
||||
let ready = data["health"]["mesh_routable"] == true && data["platform_network"]["overlay"]["address"].as_str().is_some_and(|ip| ip != "0.0.0.0");
|
||||
if std::env::var_os("MT_MESHPORT_TRACE").is_some() {
|
||||
let projection = format!("ready={ready} overlay={} routes={}",data["platform_network"]["overlay"]["address"],data["platform_network"]["mesh_cidrs"]);
|
||||
if projection != last_projection { eprintln!("MeshPort {projection}"); last_projection = projection; }
|
||||
}
|
||||
state.routes = if ready { data["platform_network"]["mesh_cidrs"].as_array()
|
||||
.map(|items| items.iter().filter_map(|v|v.as_str().map(String::from)).collect()).unwrap_or_default() } else { vec![] };
|
||||
}
|
||||
_ => { state.routes.clear(); state.port = 0; state.failed = true; state.event = 3; }
|
||||
}
|
||||
state.targets.retain(|_,target| target.touched.elapsed() < Duration::from_secs(120));
|
||||
let interval = if state.connected { 1000 } else { 250 };
|
||||
drop(wake.wait_timeout(state, Duration::from_millis(interval)).unwrap());
|
||||
}
|
||||
if context != 0 { meshport_ffi::meshport_context_free(context); }
|
||||
}
|
||||
|
||||
/// Store a private profile; no network starts until a remote socket asks for a route.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn mt_mesh_configure(config: *const c_char) {
|
||||
if config.is_null() { return }
|
||||
let Ok(config) = unsafe { CStr::from_ptr(config) }.to_str() else { return };
|
||||
let rt = runtime().lock().unwrap();
|
||||
rt.state.0.lock().unwrap().config = config.to_owned();
|
||||
}
|
||||
/// Host-order IPv4. Positive = healthy bridge port, zero = waiting, -1 = unavailable.
|
||||
/// fresh=true only on a new operation; polling must not restart its timeout or retry.
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn mt_mesh_route(address: u32, fresh: bool) -> i32 {
|
||||
let mut rt = runtime().lock().unwrap();
|
||||
let mut state = rt.state.0.lock().unwrap();
|
||||
if state.stop { return -1 }
|
||||
let now = Instant::now();
|
||||
if fresh && state.failed { state.retry = true; }
|
||||
let target = state.targets.entry(address).or_insert(Target { since: now, touched: now });
|
||||
if fresh { target.since = now; }
|
||||
target.touched = now;
|
||||
let expired = target.since.elapsed() > Duration::from_secs(60);
|
||||
let answer = if state.failed && !state.retry || expired { -1 }
|
||||
else if !state.retry && state.port != 0 && state.routes.iter().any(|cidr|matches(cidr,address)) { state.port as i32 }
|
||||
else { 0 };
|
||||
if expired && !state.connected { state.event = 3; }
|
||||
drop(state);
|
||||
if rt.worker.is_none() {
|
||||
let shared = rt.state.clone(); rt.worker = Some(thread::spawn(move ||run(shared)));
|
||||
}
|
||||
if fresh { rt.state.1.notify_one(); }
|
||||
answer
|
||||
}
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn mt_mesh_connected() {
|
||||
let rt = runtime().lock().unwrap(); let mut state = rt.state.0.lock().unwrap();
|
||||
if !state.connected { state.connected = true; state.event = 2; }
|
||||
}
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn mt_mesh_event() -> i32 {
|
||||
let rt = runtime().lock().unwrap(); let mut state = rt.state.0.lock().unwrap();
|
||||
let event = state.event; state.event = 0; event
|
||||
}
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn mt_mesh_shutdown() {
|
||||
let worker = {
|
||||
let mut rt = runtime().lock().unwrap();
|
||||
rt.state.0.lock().unwrap().stop = true; rt.state.1.notify_all(); rt.worker.take()
|
||||
};
|
||||
if let Some(worker) = worker { let _ = worker.join(); }
|
||||
let mut rt = runtime().lock().unwrap(); rt.state = Arc::new((Mutex::new(State::default()), Condvar::new()));
|
||||
}
|
||||
@@ -0,0 +1,359 @@
|
||||
#include "transport.h"
|
||||
#include <arpa/inet.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <net/if.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#include <atomic>
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <stdexcept>
|
||||
#include <chrono>
|
||||
#include <deque>
|
||||
#include <set>
|
||||
#include <array>
|
||||
#include <fcntl.h>
|
||||
#include <algorithm>
|
||||
|
||||
extern "C" {
|
||||
void mt_mesh_configure(const char*);
|
||||
int mt_mesh_route(uint32_t, bool);
|
||||
void mt_mesh_connected();
|
||||
int mt_mesh_event();
|
||||
void mt_mesh_shutdown();
|
||||
}
|
||||
|
||||
namespace mt::meshport {
|
||||
namespace {
|
||||
using Clock = std::chrono::steady_clock;
|
||||
struct Handshake {
|
||||
sockaddr_in target{};
|
||||
const void* owner = nullptr;
|
||||
int stage = -1;
|
||||
size_t offset = 0;
|
||||
unsigned char bytes[10] = {5, 1, 0};
|
||||
unsigned char command = 1;
|
||||
Clock::time_point deadline = Clock::now() + std::chrono::seconds(75);
|
||||
};
|
||||
struct Packet { sockaddr_in target{}; std::vector<unsigned char> bytes; Clock::time_point deadline; };
|
||||
struct Udp {
|
||||
int control = -1, relay = -1;
|
||||
uint16_t port = 0;
|
||||
Handshake handshake;
|
||||
bool ready = false;
|
||||
std::deque<Packet> outgoing, incoming;
|
||||
std::set<std::pair<uint32_t,uint16_t>> peers;
|
||||
size_t queued_bytes = 0;
|
||||
};
|
||||
std::mutex transport_mutex;
|
||||
std::map<int, Handshake> handshakes;
|
||||
std::map<int, Udp> datagrams;
|
||||
std::vector<std::string> routes;
|
||||
sockaddr_in proxy{};
|
||||
bool fixture = false;
|
||||
std::atomic<int> transport_event{0};
|
||||
bool ipv4(const std::string& text, uint32_t& result) {
|
||||
in_addr ip{};
|
||||
if (inet_pton(AF_INET, text.c_str(), &ip) != 1) return false;
|
||||
result = ip.s_addr;
|
||||
return true;
|
||||
}
|
||||
std::string address(uint32_t ip) {
|
||||
char buf[INET_ADDRSTRLEN];
|
||||
in_addr value{}; value.s_addr = ip;
|
||||
return inet_ntop(AF_INET, &value, buf, sizeof(buf)) ? buf : "";
|
||||
}
|
||||
}
|
||||
bool in_subnet(uint32_t ip, uint32_t local, uint32_t mask) {
|
||||
return mask != 0 && (ip & mask) == (local & mask);
|
||||
}
|
||||
bool contains(const std::string& cidr, const std::string& ip) {
|
||||
const auto slash = cidr.find('/');
|
||||
if (slash == std::string::npos) return false;
|
||||
uint32_t network, target;
|
||||
if (!ipv4(cidr.substr(0, slash), network) || !ipv4(ip, target)) return false;
|
||||
const auto suffix = cidr.substr(slash + 1);
|
||||
if (suffix.empty() || suffix.find_first_not_of("0123456789") != std::string::npos) return false;
|
||||
if (suffix.size() > 2) return false;
|
||||
const int prefix = std::stoi(suffix);
|
||||
if (prefix < 1 || prefix > 32) return false;
|
||||
return in_subnet(target, network, htonl(0xffffffffu << (32 - prefix)));
|
||||
}
|
||||
bool same_subnet(const std::string& ip) {
|
||||
uint32_t target;
|
||||
if (!ipv4(ip, target)) return false;
|
||||
if ((ntohl(target) >> 24) == 127) return true;
|
||||
ifaddrs* interfaces = nullptr;
|
||||
if (getifaddrs(&interfaces) != 0) return false;
|
||||
bool local = false;
|
||||
for (auto* i = interfaces; i; i = i->ifa_next) {
|
||||
if (!i->ifa_addr || !i->ifa_netmask || i->ifa_addr->sa_family != AF_INET) continue;
|
||||
if (!(i->ifa_flags & IFF_UP) || (i->ifa_flags & (IFF_LOOPBACK | IFF_POINTOPOINT))) continue;
|
||||
const std::string name = i->ifa_name;
|
||||
if (name.find("tun") == 0 || name.find("utun") == 0 || name.find("tap") == 0) continue;
|
||||
const auto* a = reinterpret_cast<sockaddr_in*>(i->ifa_addr);
|
||||
const auto* m = reinterpret_cast<sockaddr_in*>(i->ifa_netmask);
|
||||
if (in_subnet(target, a->sin_addr.s_addr, m->sin_addr.s_addr)) { local = true; break; }
|
||||
}
|
||||
freeifaddrs(interfaces);
|
||||
return local;
|
||||
}
|
||||
void set_routes(const std::string& listen, const std::vector<std::string>& cidrs) {
|
||||
sockaddr_in next{};
|
||||
if (!listen.empty()) {
|
||||
const auto colon = listen.find(':');
|
||||
if (colon == std::string::npos || listen.substr(0, colon) != "127.0.0.1")
|
||||
throw std::runtime_error("MeshPort bridge must listen on loopback");
|
||||
const auto port_text = listen.substr(colon + 1);
|
||||
if (port_text.empty() || port_text.size() > 5 || port_text.find_first_not_of("0123456789") != std::string::npos)
|
||||
throw std::runtime_error("Invalid MeshPort bridge port");
|
||||
int port = std::stoi(port_text);
|
||||
if (port < 1 || port > 65535) throw std::runtime_error("Invalid MeshPort bridge port");
|
||||
next.sin_family = AF_INET;
|
||||
next.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||
next.sin_port = htons(port);
|
||||
}
|
||||
std::lock_guard<std::mutex> guard(transport_mutex);
|
||||
proxy = next;
|
||||
routes = cidrs;
|
||||
fixture = !listen.empty();
|
||||
}
|
||||
void configure(const std::string& config) { mt_mesh_configure(config.c_str()); }
|
||||
namespace {
|
||||
int route(const sockaddr_in& target, bool fresh) {
|
||||
if (fixture) {
|
||||
for (const auto& cidr : routes)
|
||||
if (contains(cidr, address(target.sin_addr.s_addr))) return ntohs(proxy.sin_port);
|
||||
return -1; // Missing routes never fall back to the OS network.
|
||||
}
|
||||
return mt_mesh_route(ntohl(target.sin_addr.s_addr), fresh);
|
||||
}
|
||||
sockaddr_in loopback(int port) {
|
||||
sockaddr_in value{}; value.sin_family = AF_INET;
|
||||
value.sin_addr.s_addr = htonl(INADDR_LOOPBACK); value.sin_port = htons(port); return value;
|
||||
}
|
||||
int fail(int error) { errno = error; transport_event = 3; return -1; }
|
||||
int advance(int fd, Handshake& h, sockaddr_in* bound = nullptr) {
|
||||
if (Clock::now() > h.deadline) return fail(ETIMEDOUT);
|
||||
if (h.stage == -1) {
|
||||
int port = route(h.target, false);
|
||||
if (port < 0) return fail(EHOSTUNREACH);
|
||||
if (!port) return 0;
|
||||
auto endpoint = loopback(port);
|
||||
int status = ::connect(fd, reinterpret_cast<const sockaddr*>(&endpoint), sizeof(endpoint));
|
||||
if (status < 0 && errno != EINPROGRESS && errno != EWOULDBLOCK) return fail(errno);
|
||||
h.stage = 0;
|
||||
h.deadline = Clock::now() + std::chrono::seconds(10);
|
||||
}
|
||||
if (h.stage == 0) {
|
||||
int error = 0; socklen_t len = sizeof(error);
|
||||
if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) return fail(errno);
|
||||
if (error) return fail(error);
|
||||
sockaddr_in peer{}; len = sizeof(peer);
|
||||
if (getpeername(fd, reinterpret_cast<sockaddr*>(&peer), &len) < 0) return 0;
|
||||
h.stage = 1;
|
||||
}
|
||||
const bool sending = h.stage == 1 || h.stage == 3;
|
||||
const size_t length = h.stage == 1 ? 3 : h.stage == 2 ? 2 : 10;
|
||||
#ifdef MSG_NOSIGNAL
|
||||
constexpr int send_flags = MSG_NOSIGNAL;
|
||||
#else
|
||||
constexpr int send_flags = 0;
|
||||
#endif
|
||||
const auto count = sending ? ::send(fd, h.bytes + h.offset, length - h.offset, send_flags)
|
||||
: ::recv(fd, h.bytes + h.offset, length - h.offset, 0);
|
||||
if (count < 0) return (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) ? 0 : fail(errno);
|
||||
if (!count) return fail(ECONNRESET);
|
||||
h.offset += static_cast<size_t>(count);
|
||||
if (h.offset != length) return 0;
|
||||
h.offset = 0;
|
||||
if (h.stage == 2) {
|
||||
if (h.bytes[0] != 5 || h.bytes[1] != 0) return fail(EPROTO);
|
||||
h.bytes[0] = 5; h.bytes[1] = h.command; h.bytes[2] = 0; h.bytes[3] = 1;
|
||||
if (h.command == 1) {
|
||||
std::memcpy(h.bytes + 4, &h.target.sin_addr.s_addr, 4);
|
||||
std::memcpy(h.bytes + 8, &h.target.sin_port, 2);
|
||||
} else { std::memset(h.bytes + 4, 0, 6); }
|
||||
} else if (h.stage == 4) {
|
||||
if (h.bytes[0] != 5 || h.bytes[1] != 0 || h.bytes[2] != 0 || h.bytes[3] != 1) return fail(EPROTO);
|
||||
if (bound) {
|
||||
bound->sin_family = AF_INET;
|
||||
std::memcpy(&bound->sin_addr.s_addr, h.bytes + 4, 4);
|
||||
std::memcpy(&bound->sin_port, h.bytes + 8, 2);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
++h.stage; return 0;
|
||||
}
|
||||
void close_udp(Udp& udp) {
|
||||
if (udp.control >= 0) ::close(udp.control);
|
||||
if (udp.relay >= 0) ::close(udp.relay);
|
||||
udp.control = udp.relay = -1; udp.ready = false; udp.port = 0;
|
||||
}
|
||||
void pump_udp(int fd, Udp& udp) {
|
||||
const auto now = Clock::now();
|
||||
while (!udp.outgoing.empty() && udp.outgoing.front().deadline < now) {
|
||||
udp.queued_bytes -= udp.outgoing.front().bytes.size(); udp.outgoing.pop_front(); transport_event = 3;
|
||||
}
|
||||
// A queued request can become local while DHCP/peer discovery is pending.
|
||||
while (!udp.outgoing.empty() && same_subnet(address(udp.outgoing.front().target.sin_addr.s_addr))) {
|
||||
auto& packet = udp.outgoing.front();
|
||||
auto count = ::sendto(fd,packet.bytes.data(),packet.bytes.size(),MSG_DONTWAIT,
|
||||
reinterpret_cast<sockaddr*>(&packet.target),sizeof(packet.target));
|
||||
if (count < 0 && (errno == EWOULDBLOCK || errno == EAGAIN || errno == EINTR)) break;
|
||||
udp.queued_bytes -= packet.bytes.size(); udp.outgoing.pop_front();
|
||||
}
|
||||
if (udp.control >= 0 && udp.ready) {
|
||||
char probe;
|
||||
auto result = ::recv(udp.control, &probe, 1, MSG_PEEK | MSG_DONTWAIT);
|
||||
if (result == 0 || (result < 0 && errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR)) close_udp(udp);
|
||||
}
|
||||
if (udp.control < 0 && !udp.outgoing.empty()) {
|
||||
auto& packet = udp.outgoing.front();
|
||||
const int port = route(packet.target, false);
|
||||
if (port < 0) {
|
||||
udp.queued_bytes -= packet.bytes.size(); udp.outgoing.pop_front(); transport_event = 3; return;
|
||||
}
|
||||
if (!port) return;
|
||||
udp.control = ::socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (udp.control < 0) return;
|
||||
fcntl(udp.control, F_SETFL, O_NONBLOCK);
|
||||
#ifdef SO_NOSIGPIPE
|
||||
int one=1;setsockopt(udp.control,SOL_SOCKET,SO_NOSIGPIPE,&one,sizeof(one));
|
||||
#endif
|
||||
udp.port = port; udp.handshake = Handshake{};
|
||||
udp.handshake.target = packet.target; udp.handshake.command = 3;
|
||||
}
|
||||
if (udp.control < 0) return;
|
||||
if (!udp.ready) {
|
||||
sockaddr_in relay{};
|
||||
int result = advance(udp.control, udp.handshake, &relay);
|
||||
if (result < 0) { close_udp(udp); return; }
|
||||
if (!result) return;
|
||||
// The SDK bridge is IPv4 loopback-only. Do not accept a redirect to an external relay.
|
||||
if (relay.sin_addr.s_addr != htonl(INADDR_LOOPBACK) || !relay.sin_port) { close_udp(udp); transport_event=3;return; }
|
||||
udp.relay = ::socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (udp.relay < 0) { close_udp(udp);return; }
|
||||
fcntl(udp.relay,F_SETFL,O_NONBLOCK);
|
||||
if (::connect(udp.relay,reinterpret_cast<sockaddr*>(&relay),sizeof(relay)) < 0) {close_udp(udp);return;}
|
||||
udp.ready = true;
|
||||
}
|
||||
for (size_t sent=0; !udp.outgoing.empty() && sent<32; ++sent) {
|
||||
auto& packet = udp.outgoing.front();
|
||||
const int port = route(packet.target,false);
|
||||
if (port == 0) break;
|
||||
if (port < 0) {
|
||||
udp.queued_bytes -= packet.bytes.size(); udp.outgoing.pop_front(); transport_event=3;continue;
|
||||
}
|
||||
if (port != udp.port) {close_udp(udp);return;}
|
||||
std::vector<unsigned char> envelope(10+packet.bytes.size());
|
||||
envelope[3]=1;
|
||||
std::memcpy(envelope.data()+4,&packet.target.sin_addr.s_addr,4);
|
||||
std::memcpy(envelope.data()+8,&packet.target.sin_port,2);
|
||||
std::copy(packet.bytes.begin(),packet.bytes.end(),envelope.begin()+10);
|
||||
auto count = ::send(udp.relay,envelope.data(),envelope.size(),0);
|
||||
if (count < 0 && (errno == EWOULDBLOCK || errno == EAGAIN || errno == EINTR)) break;
|
||||
if (count < 0) {close_udp(udp);return;}
|
||||
if(udp.peers.size()<128)udp.peers.emplace(packet.target.sin_addr.s_addr,packet.target.sin_port);
|
||||
udp.queued_bytes -= packet.bytes.size(); udp.outgoing.pop_front();
|
||||
}
|
||||
for (int i=0;i<32;++i) {
|
||||
std::array<unsigned char,65536> envelope;
|
||||
auto count = ::recv(udp.relay,envelope.data(),envelope.size(),0);
|
||||
if (count < 0) break;
|
||||
if (count<10 || envelope[0] || envelope[1] || envelope[2] || envelope[3]!=1) continue;
|
||||
sockaddr_in source{};source.sin_family=AF_INET;
|
||||
std::memcpy(&source.sin_addr.s_addr,envelope.data()+4,4);
|
||||
std::memcpy(&source.sin_port,envelope.data()+8,2);
|
||||
if (!udp.peers.count({source.sin_addr.s_addr,source.sin_port})) continue;
|
||||
if (udp.incoming.size()>=64) continue;
|
||||
udp.incoming.push_back({source,{envelope.begin()+10,envelope.begin()+count},now});
|
||||
if (!fixture) mt_mesh_connected(); else transport_event=2;
|
||||
}
|
||||
}
|
||||
}
|
||||
int connect_socket(int fd, const sockaddr_in& target, const void* owner) {
|
||||
if (same_subnet(address(target.sin_addr.s_addr)))
|
||||
return ::connect(fd,reinterpret_cast<const sockaddr*>(&target),sizeof(target));
|
||||
std::lock_guard<std::mutex> guard(transport_mutex);
|
||||
if (route(target,true)<0) return fail(EHOSTUNREACH);
|
||||
Handshake h; h.target=target; h.owner=owner; handshakes[fd]=h;
|
||||
errno=EINPROGRESS;return -1;
|
||||
}
|
||||
bool pending_owner(const void* owner) {
|
||||
if(!owner)return false;
|
||||
std::lock_guard<std::mutex> guard(transport_mutex);
|
||||
for(const auto& [fd,h]:handshakes)if(h.owner==owner)return true;
|
||||
return false;
|
||||
}
|
||||
bool pending(int fd) { std::lock_guard<std::mutex> guard(transport_mutex);return handshakes.count(fd)!=0; }
|
||||
int poll_socket(int fd) {
|
||||
std::lock_guard<std::mutex> guard(transport_mutex);
|
||||
auto it=handshakes.find(fd);if(it==handshakes.end()) return 1;
|
||||
int result=advance(fd,it->second);
|
||||
if (result==1) {
|
||||
handshakes.erase(it);
|
||||
if(!fixture) mt_mesh_connected();else transport_event=2;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
void forget_socket(int fd) {
|
||||
std::lock_guard<std::mutex> guard(transport_mutex);handshakes.erase(fd);
|
||||
auto it=datagrams.find(fd);if(it!=datagrams.end()){close_udp(it->second);datagrams.erase(it);}
|
||||
}
|
||||
ssize_t send_datagram(int fd,const void* bytes,size_t size,int flags,const sockaddr_in& target) {
|
||||
if (same_subnet(address(target.sin_addr.s_addr)))
|
||||
return ::sendto(fd,bytes,size,flags,reinterpret_cast<const sockaddr*>(&target),sizeof(target));
|
||||
if (size>65497) {errno=EMSGSIZE;return -1;}
|
||||
std::lock_guard<std::mutex> guard(transport_mutex);
|
||||
if (route(target,true)<0) return fail(EHOSTUNREACH);
|
||||
if(fcntl(fd,F_GETFD)<0)return -1;
|
||||
auto& udp=datagrams[fd];
|
||||
if (udp.outgoing.size()>=64 || udp.queued_bytes+size>1024*1024) {errno=EWOULDBLOCK;return -1;}
|
||||
const auto* begin=static_cast<const unsigned char*>(bytes);
|
||||
udp.outgoing.push_back({target,{begin,begin+size},Clock::now()+std::chrono::seconds(60)});
|
||||
udp.queued_bytes+=size;pump_udp(fd,udp);return static_cast<ssize_t>(size);
|
||||
}
|
||||
bool datagram_ready(int fd) {
|
||||
std::lock_guard<std::mutex> guard(transport_mutex);
|
||||
auto it=datagrams.find(fd);if(it==datagrams.end())return false;
|
||||
pump_udp(fd,it->second);return !it->second.incoming.empty();
|
||||
}
|
||||
ssize_t recv_datagram(int fd,void* bytes,size_t size,int flags,sockaddr_in* source) {
|
||||
std::lock_guard<std::mutex> guard(transport_mutex);
|
||||
auto it=datagrams.find(fd);
|
||||
if(it!=datagrams.end()) {
|
||||
auto& udp=it->second;pump_udp(fd,udp);
|
||||
if(!udp.incoming.empty()) {
|
||||
auto& packet=udp.incoming.front();
|
||||
const size_t count=std::min(size,packet.bytes.size());
|
||||
std::memcpy(bytes,packet.bytes.data(),count);if(source)*source=packet.target;
|
||||
const auto result=(flags&MSG_TRUNC)?packet.bytes.size():count;
|
||||
if(!(flags&MSG_PEEK))udp.incoming.pop_front();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
socklen_t length=sizeof(sockaddr_in);
|
||||
return ::recvfrom(fd,bytes,size,flags,reinterpret_cast<sockaddr*>(source),source?&length:nullptr);
|
||||
}
|
||||
void pump() {
|
||||
std::lock_guard<std::mutex> guard(transport_mutex);
|
||||
for(auto& [fd,udp]:datagrams)pump_udp(fd,udp);
|
||||
}
|
||||
int take_event() { pump();int event=transport_event.exchange(0);int runtime=mt_mesh_event();return event?event:runtime; }
|
||||
|
||||
void shutdown() {
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(transport_mutex);
|
||||
for (auto& [fd, udp] : datagrams) {
|
||||
if (udp.control >= 0) ::close(udp.control);
|
||||
if (udp.relay >= 0) ::close(udp.relay);
|
||||
}
|
||||
datagrams.clear(); handshakes.clear(); routes.clear(); proxy = {}; fixture = false;
|
||||
}
|
||||
mt_mesh_shutdown(); transport_event = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
namespace mt::meshport {
|
||||
bool in_subnet(uint32_t address, uint32_t local, uint32_t mask);
|
||||
bool same_subnet(const std::string& address);
|
||||
bool contains(const std::string& cidr, const std::string& address);
|
||||
void configure(const std::string& private_profile);
|
||||
// Explicit fixture bridge. Production obtains its routes exclusively from the native runtime.
|
||||
void set_routes(const std::string& listen, const std::vector<std::string>& cidrs);
|
||||
int connect_socket(int fd, const sockaddr_in& target, const void* owner = nullptr);
|
||||
bool pending_owner(const void* owner);
|
||||
int poll_socket(int fd); // 0 waiting; 1 ready; -1 failed. Includes preparation and SOCKS handshake.
|
||||
bool pending(int fd);
|
||||
void forget_socket(int fd);
|
||||
ssize_t send_datagram(int fd, const void* bytes, size_t size, int flags, const sockaddr_in& target);
|
||||
ssize_t recv_datagram(int fd, void* bytes, size_t size, int flags, sockaddr_in* source);
|
||||
bool datagram_ready(int fd);
|
||||
void pump();
|
||||
int take_event(); // 1 preparing; 2 remote transport verified; 3 failed.
|
||||
void shutdown();
|
||||
}
|
||||
@@ -21,3 +21,7 @@ if(TARGET mtpython)
|
||||
set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/ScriptLib/PythonBoot.cpp
|
||||
PROPERTY COMPILE_DEFINITIONS ${MT_PORT_DEFINES_UserInterface})
|
||||
endif()
|
||||
|
||||
if(TARGET mt_meshport)
|
||||
target_include_directories(port_platform PRIVATE "${PROJECT_BINARY_DIR}/src/meshport")
|
||||
endif()
|
||||
|
||||
@@ -192,6 +192,13 @@ HRESULT CpuSurface::LockRect(D3DLOCKED_RECT* locked, const RECT* rect, DWORD fla
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// PORT: a 32-bit render-target texture (the AVA2 model preview's CGraphicRenderTargetTexture), drawn on the
|
||||
// GPU with full state; the R5G6B5 ones are the character shadow map.
|
||||
bool is_color_target(const D3DSURFACE_DESC& desc)
|
||||
{
|
||||
return (desc.Usage & D3DUSAGE_RENDERTARGET) && (desc.Format == D3DFMT_X8R8G8B8 || desc.Format == D3DFMT_A8R8G8B8);
|
||||
}
|
||||
|
||||
D3DSURFACE_DESC surface_desc(UINT width, UINT height, D3DFORMAT format, DWORD usage, D3DPOOL pool)
|
||||
{
|
||||
D3DSURFACE_DESC desc = {};
|
||||
@@ -454,7 +461,10 @@ public:
|
||||
return S_OK;
|
||||
}
|
||||
auto* surface = static_cast<CpuSurface*>(m_renderTarget);
|
||||
if (!surface->parent || surface->level != 0 || surface->desc.Format != D3DFMT_R5G6B5)
|
||||
const bool colorTarget = surface->parent && surface->level == 0 && is_color_target(surface->desc);
|
||||
if (colorTarget && !g_gpu_render_targets)
|
||||
return S_OK;
|
||||
if (!colorTarget && (!surface->parent || surface->level != 0 || surface->desc.Format != D3DFMT_R5G6B5))
|
||||
return S_OK;
|
||||
if (g_gpu_render_targets)
|
||||
{
|
||||
@@ -463,6 +473,7 @@ public:
|
||||
clear.render_target = surface->parent->id;
|
||||
clear.target_width = surface->desc.Width;
|
||||
clear.target_height = surface->desc.Height;
|
||||
clear.target_color = colorTarget;
|
||||
clear.clear_flags = flags & (D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER);
|
||||
clear.clear_color = color;
|
||||
clear.clear_z = depth;
|
||||
@@ -1140,11 +1151,30 @@ private:
|
||||
if (m_renderTarget == m_backBuffer)
|
||||
Render3DAdd(std::move(draw));
|
||||
else if (g_gpu_render_targets)
|
||||
record_shadow(std::move(draw));
|
||||
{
|
||||
auto* surface = static_cast<CpuSurface*>(m_renderTarget);
|
||||
if (surface->parent && surface->level == 0 && is_color_target(surface->desc))
|
||||
record_color(std::move(draw), *surface);
|
||||
else
|
||||
record_shadow(std::move(draw));
|
||||
}
|
||||
else
|
||||
rasterize_shadow(draw);
|
||||
}
|
||||
|
||||
// PORT: a draw into a colour render target keeps every state the back buffer would get.
|
||||
void record_color(Render3DDraw draw, const CpuSurface& surface)
|
||||
{
|
||||
if (!draw.shared_geometry && draw.indices.size() < (draw.lines ? 2u : 3u))
|
||||
return;
|
||||
draw.render_target = surface.parent->id;
|
||||
draw.target_width = surface.desc.Width;
|
||||
draw.target_height = surface.desc.Height;
|
||||
draw.target_color = true;
|
||||
draw.ui_offset_x = 0;
|
||||
Render3DAdd(std::move(draw));
|
||||
}
|
||||
|
||||
// GPU counterpart of rasterize_shadow: the draw goes to the renderer's offscreen pass with the
|
||||
// states rasterize_shadow implements -- a flat D3DRS_TEXTUREFACTOR fill, no culling, no texture,
|
||||
// light, fog or blending, depth test LESSEQUAL with depth writes -- so both paths draw the same map.
|
||||
@@ -1257,6 +1287,8 @@ std::string MtCpuTextureNameFromHandle(const IDirect3DBaseTexture8* handle)
|
||||
const D3DSURFACE_DESC& desc = entry.second->levels[0].desc;
|
||||
if (g_gpu_render_targets && (desc.Usage & D3DUSAGE_RENDERTARGET) && desc.Format == D3DFMT_R5G6B5)
|
||||
return Render3DRenderTargetName(entry.first, desc.Width, desc.Height);
|
||||
if (g_gpu_render_targets && is_color_target(desc))
|
||||
return Render3DRenderTargetName(entry.first, desc.Width, desc.Height, true);
|
||||
if (entry.second == handle && !entry.second->levels.empty())
|
||||
return "mem:cpu_" + std::to_string(entry.first) + "@" + std::to_string(entry.second->revision);
|
||||
}
|
||||
@@ -1406,9 +1438,9 @@ bool IsNativeTerrainRenderEnabled()
|
||||
void SetGpuRenderTargetsEnabled(bool enabled) { g_gpu_render_targets = enabled; }
|
||||
bool IsGpuRenderTargetsEnabled() { return g_gpu_render_targets; }
|
||||
|
||||
std::string Render3DRenderTargetName(std::uint32_t id, std::uint32_t width, std::uint32_t height)
|
||||
std::string Render3DRenderTargetName(std::uint32_t id, std::uint32_t width, std::uint32_t height, bool color)
|
||||
{
|
||||
return "rt:" + std::to_string(id) + ":" + std::to_string(width) + "x" + std::to_string(height);
|
||||
return "rt:" + std::to_string(id) + ":" + std::to_string(width) + "x" + std::to_string(height) + (color ? ":c" : "");
|
||||
}
|
||||
|
||||
void Render3DBeginFrame()
|
||||
|
||||
@@ -38,6 +38,9 @@ struct Render3DDraw {
|
||||
// viewport is then in the target's pixels. Only emitted while GPU render targets are enabled.
|
||||
std::uint32_t render_target = 0;
|
||||
std::uint32_t target_width = 0, target_height = 0;
|
||||
// PORT: an X8R8G8B8 / A8R8G8B8 colour target (the AVA2 model preview, CRenderTarget) drawn with the
|
||||
// draw's own states, named with Render3DRenderTargetName(..., true); otherwise the R5G6B5 shadow map.
|
||||
bool target_color = false;
|
||||
|
||||
// Stage 0/1 textures, named like UIRenderTextureName: the pack path of a file texture or
|
||||
// "mem:<id>@<revision>"; empty when the stage has no texture.
|
||||
@@ -143,7 +146,8 @@ bool LookupGpuSkinSubrange(const void* vertex_buffer_base, std::uint32_t stride,
|
||||
// default (the Godot consumer has no offscreen pass); the native Vulkan renderer turns it on.
|
||||
void SetGpuRenderTargetsEnabled(bool enabled);
|
||||
bool IsGpuRenderTargetsEnabled();
|
||||
std::string Render3DRenderTargetName(std::uint32_t id, std::uint32_t width, std::uint32_t height);
|
||||
// A colour target's name ends in ":c".
|
||||
std::string Render3DRenderTargetName(std::uint32_t id, std::uint32_t width, std::uint32_t height, bool color = false);
|
||||
|
||||
void Render3DBeginFrame();
|
||||
void Render3DAdd(Render3DDraw draw);
|
||||
|
||||
@@ -112,10 +112,13 @@ void UIRenderAddImageNamed(const std::string& texture_name, const float x[4], co
|
||||
// 40250 draws the image quad through the device: the UI pass's world transform places it
|
||||
// (identity except where a caller sets one, e.g. CPythonMiniMap::RenderAtlas's window offset) and a
|
||||
// stage-0 MODULATE with D3DTA_TFACTOR tints it (the atlas's NPC/warp/waypoint marks).
|
||||
DWORD address_u = D3DTADDRESS_WRAP, address_v = D3DTADDRESS_WRAP;
|
||||
D3DXMATRIX world;
|
||||
D3DXMatrixIdentity(&world);
|
||||
if (CStateManager* state = CStateManager::InstancePtr()) {
|
||||
state->GetTransform(D3DTS_WORLD, &world);
|
||||
state->GetTextureStageState(0,D3DTSS_ADDRESSU,&address_u);
|
||||
state->GetTextureStageState(0,D3DTSS_ADDRESSV,&address_v);
|
||||
DWORD op = 0, arg1 = 0, arg2 = 0;
|
||||
state->GetTextureStageState(0, D3DTSS_COLOROP, &op);
|
||||
state->GetTextureStageState(0, D3DTSS_COLORARG1, &arg1);
|
||||
@@ -148,5 +151,6 @@ void UIRenderAddImageNamed(const std::string& texture_name, const float x[4], co
|
||||
command.quad = true;
|
||||
command.su = su; command.sv = sv; command.eu = eu; command.ev = ev;
|
||||
command.blend = blend;
|
||||
command.address_u = address_u; command.address_v = address_v;
|
||||
UIRenderAdd(std::move(command));
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ struct UIRenderCommand {
|
||||
std::string mask;
|
||||
float mu[4] = {}, mv[4] = {};
|
||||
bool behind_3d = false;
|
||||
// D3D8 texture stage 0 addressing. Direct platform commands retain their clamp default.
|
||||
std::uint32_t address_u = 3, address_v = 3;
|
||||
};
|
||||
|
||||
// D3DXCOLOR (0..1 floats) -> the 0xAARRGGBB the commands carry.
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// PORT: item bonuses added after 40250 (AVA2 numbering, server common/length.h). The packed uitooltip.py
|
||||
// only knows 40250's applies; add the new ones to its AFFECT_DICT so item and socket tooltips show them.
|
||||
static const char c_szAppliesScript[] = R"PY(# -*- coding: utf-8 -*-
|
||||
import item
|
||||
import player
|
||||
import uiToolTip
|
||||
|
||||
L = player.AutoHuntLocalize
|
||||
TEXTS = (
|
||||
("APPLY_ATTBONUS_STONE", "对陨石伤害 +%d%%"),
|
||||
("APPLY_ATTBONUS_BOSS", "对 Boss 伤害 +%d%%"),
|
||||
("APPLY_ENCHANT_ELEC", "对雷属性怪物伤害 +%d%%"),
|
||||
("APPLY_ENCHANT_FIRE", "对火属性怪物伤害 +%d%%"),
|
||||
("APPLY_ENCHANT_ICE", "对冰属性怪物伤害 +%d%%"),
|
||||
("APPLY_ENCHANT_WIND", "对风属性怪物伤害 +%d%%"),
|
||||
("APPLY_ENCHANT_EARTH", "对土属性怪物伤害 +%d%%"),
|
||||
("APPLY_ENCHANT_DARK", "对暗属性怪物伤害 +%d%%"),
|
||||
)
|
||||
|
||||
|
||||
def Text(text):
|
||||
return lambda value: L(text % value)
|
||||
|
||||
|
||||
for name, text in TEXTS:
|
||||
if hasattr(item, name):
|
||||
uiToolTip.ItemToolTip.AFFECT_DICT[getattr(item, name)] = Text(text)
|
||||
)PY";
|
||||
@@ -0,0 +1,34 @@
|
||||
// PORT: armor shapes added after 40250 (AVA2's dragon armor 21210+, item value3 = 32). The race .msm files are
|
||||
// read by bare name, which CEterPackManager always serves from the root pack, so a patch pack cannot replace
|
||||
// them; register the extra shapes after each LoadLocalRaceData instead, as the AVA2 msm groups would. Models
|
||||
// ship in the ava2items pack (metin2-client tools/server/ava2-items, ARMOR_SHAPES / RACE_PATHS).
|
||||
static const char c_szArmorShapesScript[] = R"PY(# -*- coding: utf-8 -*-
|
||||
import chrmgr
|
||||
|
||||
SHAPES = {32: "%s_7_1"}
|
||||
# ShapeData PathName of each race msm (male, female).
|
||||
PATHS = {"warrior": ("pc", "pc2"), "assassin": ("pc2", "pc"), "sura": ("pc", "pc2"), "shaman": ("pc2", "pc")}
|
||||
|
||||
_load = chrmgr.LoadLocalRaceData
|
||||
|
||||
|
||||
def Register(name):
|
||||
stem = name.lower().split(".")[0]
|
||||
race, _, sex = stem.partition("_")
|
||||
if race not in PATHS or sex not in ("m", "w"):
|
||||
return
|
||||
path = "d:/ymir work/%s/%s/" % (PATHS[race][sex == "w"], race)
|
||||
for shape, model in SHAPES.items():
|
||||
model = path + model % race
|
||||
chrmgr.SetShapeModel(shape, model + ".gr2")
|
||||
chrmgr.AppendShapeSkin(shape, 0, model + ".dds", model + ".dds")
|
||||
|
||||
|
||||
def LoadLocalRaceData(name):
|
||||
result = _load(name)
|
||||
Register(name)
|
||||
return result
|
||||
|
||||
|
||||
chrmgr.LoadLocalRaceData = LoadLocalRaceData
|
||||
)PY";
|
||||
@@ -0,0 +1,125 @@
|
||||
// AVA2 lock material selection uses socket 0; lock highlights follow original uitooltip.py.
|
||||
// The existing port stores masks outside the seven-attribute packet, so own-item tooltips query them read-only.
|
||||
static const char c_szAttrLockScript[] = R"PY(# -*- coding: utf-8 -*-
|
||||
import app,chat,game,net,player,uiToolTip,weakref,mt_switchbot
|
||||
L=player.AutoHuntLocalize
|
||||
Tip=uiToolTip.ItemToolTip
|
||||
_clear=Tip.ClearToolTip
|
||||
_inventory=Tip.SetInventoryItem
|
||||
_append=Tip._ItemToolTip__AppendAttributeInformation
|
||||
_add=Tip.AddItemData
|
||||
_update=Tip.OnUpdate
|
||||
_command=game.GameWindow.BINARY_ServerCommand_Run
|
||||
_close=game.GameWindow.Close
|
||||
_pending={}
|
||||
_serial=0
|
||||
_views={}
|
||||
|
||||
def Snapshot(window,cell,tip=None):
|
||||
if window in _views:return _views[window][0](tip,cell) if tip else None
|
||||
return (player.GetItemIndex(window,cell),
|
||||
tuple(player.GetItemAttribute(window,cell,i) for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM)),
|
||||
tuple(player.GetItemMetinSocket(window,cell,i) for i in xrange(player.METIN_SOCKET_MAX_NUM)))
|
||||
|
||||
def Clear(self):
|
||||
if not getattr(self,'attrLockRendering',False):
|
||||
self.attrLockContext=None;self.attrLockMask=0
|
||||
_clear(self)
|
||||
|
||||
def Query(self):
|
||||
global _serial
|
||||
context=getattr(self,'attrLockContext',None)
|
||||
if not context:return
|
||||
window,cell,snapshot=context
|
||||
if Snapshot(window,cell,self)!=snapshot:
|
||||
self.attrLockContext=None;self.attrLockMask=0
|
||||
self.HideToolTip()
|
||||
return
|
||||
_serial=(_serial%2147483646)+1
|
||||
self.attrLockNext=app.GetTime()+1.25
|
||||
# A tooltip can be rebuilt frequently during rolling; retain no old requests or windows.
|
||||
_pending.clear();_pending[_serial]=(weakref.ref(self),context)
|
||||
command='/attr_lock_info %d %d %d'%(_serial,window,cell)
|
||||
if window in _views:command+=' %d'%getattr(self,'attrLockVid',0)
|
||||
net.SendChatPacket(command)
|
||||
|
||||
def Inventory(self,cell,window_type=player.INVENTORY):
|
||||
_inventory(self,cell,window_type)
|
||||
snapshot=Snapshot(window_type,cell)
|
||||
if not snapshot[0] or not any(a[0] for a in snapshot[1][:5]):return
|
||||
self.attrLockContext=(window_type,cell,snapshot)
|
||||
Query(self)
|
||||
|
||||
def Rebuild(self):
|
||||
context=getattr(self,'attrLockContext',None)
|
||||
if not context:return
|
||||
window,cell,snapshot=context
|
||||
if Snapshot(window,cell,self)!=snapshot:return
|
||||
self.attrLockRendering=True
|
||||
try:
|
||||
if window in _views:_views[window][1](self,cell)
|
||||
else:_inventory(self,cell,window)
|
||||
finally:self.attrLockRendering=False
|
||||
|
||||
def Update(self):
|
||||
_update(self)
|
||||
if self.IsShow() and getattr(self,'attrLockContext',None) and app.GetTime()>=getattr(self,'attrLockNext',0):Query(self)
|
||||
|
||||
def AppendAttributes(self,attrs):
|
||||
mask=getattr(self,'attrLockMask',0)
|
||||
if not mask or getattr(self,'mtSash',None):return _append(self,attrs)
|
||||
# Original AVA2: locked lines are enclosed in << >> and use SPECIAL_TITLE_COLOR.
|
||||
for index,(kind,value) in enumerate(attrs):
|
||||
if not value:continue
|
||||
text=self._ItemToolTip__GetAffectString(kind,value)
|
||||
if text:
|
||||
if index<5 and mask&(1<<index):self.AppendTextLine('<<'+text+'>>',self.SPECIAL_TITLE_COLOR)
|
||||
else:self.AppendTextLine(text,self._ItemToolTip__GetAttributeColor(index,value))
|
||||
|
||||
def AddItemData(self,vnum,metinSlot=0,attrSlot=0,*args,**kwargs):
|
||||
_add(self,vnum,metinSlot,attrSlot,*args,**kwargs)
|
||||
if vnum in (50348,50349):
|
||||
index=int(metinSlot[0]) if metinSlot else 0
|
||||
self.AppendSpace(5)
|
||||
self.AppendTextLine(L('已选择第%d条普通属性'%index if 1<=index<=5 else '先使用此符选择属性序号'),self.SPECIAL_TITLE_COLOR)
|
||||
self.ShowToolTip()
|
||||
|
||||
def Command(self,line):
|
||||
words=line.split()
|
||||
if words and words[0]=='AttrLockResult':
|
||||
messages={'ok':'属性锁定状态已更新','item':'请使用未穿戴且未被交易或占用的装备','material':'请使用对应的锁定符或解锁符','slot':'请先使用此符选择有效的属性序号','five_attr':'装备需要五条普通属性','max':'最多可锁定两组普通属性','db':'保存失败,本次未消耗材料'}
|
||||
if len(words)==2:chat.AppendChat(chat.CHAT_TYPE_INFO,L(messages.get(words[1],'属性锁定失败')))
|
||||
return 1
|
||||
if words and words[0]=='AttrLockInfo':
|
||||
if len(words)!=6:return 1
|
||||
try:token,window,cell,vnum,mask=map(int,words[1:])
|
||||
except (ValueError,OverflowError):return 1
|
||||
request=_pending.pop(token,None)
|
||||
if request and -1<=mask<=31:
|
||||
owner,context=request;tip=owner()
|
||||
if tip and tip.IsShow() and getattr(tip,'attrLockContext',None)==context:
|
||||
if (window,cell)==context[:2] and vnum==context[2][0] and Snapshot(window,cell,tip)==context[2]:
|
||||
if mask>=0 and mask!=getattr(tip,'attrLockMask',0):
|
||||
tip.attrLockMask=mask;Rebuild(tip)
|
||||
return 1
|
||||
return _command(self,line)
|
||||
|
||||
def Close(self):
|
||||
_pending.clear()
|
||||
return _close(self)
|
||||
|
||||
_switchOver=mt_switchbot.SwitchbotItemTab.OverInItem
|
||||
def SwitchOver(self,slot):
|
||||
if self.IsEmpty() or self.IsActive():return _switchOver(self,slot)
|
||||
self.itemSlot.SetUsableItem(True)
|
||||
if self.tooltipItem:self.tooltipItem.SetInventoryItem(self.slot_num,player.SWITCHBOT)
|
||||
|
||||
Tip.ClearToolTip=Clear
|
||||
Tip.SetInventoryItem=Inventory
|
||||
Tip._ItemToolTip__AppendAttributeInformation=AppendAttributes
|
||||
Tip.AddItemData=AddItemData
|
||||
Tip.OnUpdate=Update
|
||||
mt_switchbot.SwitchbotItemTab.OverInItem=SwitchOver
|
||||
game.GameWindow.BINARY_ServerCommand_Run=Command
|
||||
game.GameWindow.Close=Close
|
||||
)PY";
|
||||
@@ -0,0 +1,148 @@
|
||||
// AVA2 lock presentation with the port's separate mask; no classic packet layout changes.
|
||||
static const char c_szAttrLockSnapshotsScript[] = R"PY(# -*- coding: utf-8 -*-
|
||||
import app,player,chat,game,net,uiToolTip,mt_switchbot,mt_attr_lock as core,weakref
|
||||
_cache={}
|
||||
_link=player.GetItemLink
|
||||
_relay=chat.GetLinkFromHyperlink
|
||||
_hyper=uiToolTip.HyperlinkItemToolTip.SetHyperlinkItem
|
||||
_command=game.GameWindow.BINARY_ServerCommand_Run
|
||||
_close=game.GameWindow.Close
|
||||
_open=game.GameWindow.Open
|
||||
_gameUpdate=game.GameWindow.OnUpdate
|
||||
_over=mt_switchbot.SwitchbotItemTab.OverInItem
|
||||
_update=uiToolTip.ItemToolTip.OnUpdate
|
||||
_clear=uiToolTip.ItemToolTip.ClearToolTip
|
||||
|
||||
def Key(window,cell):
|
||||
return (player.INVENTORY if window==player.EQUIPMENT else window,cell)
|
||||
|
||||
def Cached(window,cell):
|
||||
window,cell=Key(window,cell)
|
||||
value=_cache.get((window,cell))
|
||||
return value if value and value[0]==core.Snapshot(window,cell) else None
|
||||
|
||||
def Command(self,line):
|
||||
words=line.split()
|
||||
if words==['AttrLockSync']:
|
||||
self.attrLockSynced=True
|
||||
return 1
|
||||
if words and words[0]=='AttrLockItem':
|
||||
if len(words)!=5:return 1
|
||||
try:window,cell,vnum,mask=map(int,words[1:])
|
||||
except (ValueError,OverflowError):return 1
|
||||
if window not in (player.INVENTORY,player.EQUIPMENT,player.SWITCHBOT) or not 0<=cell<65536 or not -1<=mask<=31:return 1
|
||||
key=Key(window,cell);_cache.pop(key,None)
|
||||
snapshot=core.Snapshot(*key)
|
||||
if vnum and snapshot[0]==vnum and mask>=0:_cache[key]=(snapshot,mask)
|
||||
return 1
|
||||
return _command(self,line)
|
||||
|
||||
def GetItemLink(*args):
|
||||
link=_link(*args)
|
||||
if len(args)==1:window,cell=player.INVENTORY,args[0]
|
||||
elif len(args)==2:window,cell=args
|
||||
else:return link
|
||||
cached=Cached(window,cell)
|
||||
if not link or not cached or not cached[1]:return link
|
||||
# Fixed seven slots preserve holes and therefore the lock's attribute index.
|
||||
start=link.find('|H');end=link.find('|h',start+2)
|
||||
if start<0 or end<0:return link
|
||||
head=link[start+2:end].split(':')[:6]
|
||||
if len(head)!=6 or head[0]!='item':return link
|
||||
for kind,value in cached[0][1]:head.extend(('%x'%kind,str(value)))
|
||||
head.extend(('mtlock1',str(cached[1])))
|
||||
return link[:start+2]+':'.join(head)+link[end:]
|
||||
|
||||
def Decode(tokens):
|
||||
if len(tokens)!=22 or tokens[0]!='item' or tokens[20]!='mtlock1':return None
|
||||
try:
|
||||
mask=int(tokens[21]);vnum=int(tokens[1],16);flags=int(tokens[2],16)
|
||||
sockets=[int(v,16) for v in tokens[3:6]]
|
||||
attrs=[(int(tokens[i],16),int(tokens[i+1])) for i in xrange(6,20,2)]
|
||||
if not 0<=mask<=31 or not 0<vnum<=0xffffffff or not 0<=flags<=0xffffffff:return None
|
||||
if any(not 0<=v<=0xffffffff for v in sockets):return None
|
||||
if any(not 0<=k<=255 or not -32768<=v<=32767 for k,v in attrs):return None
|
||||
return vnum,sockets,attrs,mask
|
||||
except (ValueError,OverflowError):return None
|
||||
|
||||
def Hyperlink(self,tokens):
|
||||
if 'mtlock1' not in tokens:return _hyper(self,tokens)
|
||||
data=Decode(tokens)
|
||||
self.ClearToolTip()
|
||||
if not data:self.HideToolTip();return
|
||||
vnum,sockets,attrs,mask=data
|
||||
self.attrLockMask=mask
|
||||
self.AddItemData(vnum,sockets,attrs)
|
||||
self.ShowToolTip()
|
||||
uiToolTip.ItemToolTip.OnUpdate(self)
|
||||
# A chat link is an immutable sender snapshot, never a live item lookup.
|
||||
|
||||
def Relay(payload):
|
||||
tokens=payload.split(':')
|
||||
if 'mtlock1' not in tokens:return _relay(payload)
|
||||
if Decode(tokens) is None:return ''
|
||||
ordinary=_relay(':'.join(tokens[:20]))
|
||||
start=ordinary.find('|H');end=ordinary.find('|h',start+2)
|
||||
return ordinary[:start+2]+payload+ordinary[end:] if start>=0 and end>=0 else ''
|
||||
|
||||
def Clear(self):
|
||||
self.attrLockActive=None
|
||||
return _clear(self)
|
||||
|
||||
def Active(self,tab):
|
||||
self.ClearToolTip()
|
||||
cached=Cached(player.SWITCHBOT,tab.slot_num)
|
||||
self.SetSwitchBotItem(player.GetItemIndex(player.SWITCHBOT,tab.slot_num))
|
||||
if cached and cached[1]:
|
||||
self.attrLockMask=cached[1]
|
||||
self.AppendSpace(5)
|
||||
core.AppendAttributes(self,[a if i<5 and cached[1]&(1<<i) else (0,0) for i,a in enumerate(cached[0][1])])
|
||||
# The EU word wrapper cannot split Chinese words. Use ToolTip's measured-width
|
||||
# convention (AutoAppendTextLine) so the localized active message fits its board.
|
||||
width=max([self.toolTipWidth]+[line.GetTextSize()[0]+40 for line in self.childrenList if hasattr(line,'GetTextSize')])
|
||||
if width>self.toolTipWidth:
|
||||
self.toolTipWidth=width;self.AlignHorizonalCenter()
|
||||
self.attrLockActive=(weakref.ref(tab),core.Snapshot(player.SWITCHBOT,tab.slot_num),cached)
|
||||
self.ShowToolTip()
|
||||
|
||||
def Over(self,slot):
|
||||
if self.IsEmpty() or not self.IsActive():return _over(self,slot)
|
||||
self.itemSlot.SetUsableItem(True)
|
||||
if self.tooltipItem:Active(self.tooltipItem,self)
|
||||
|
||||
def Update(self):
|
||||
_update(self)
|
||||
active=getattr(self,'attrLockActive',None)
|
||||
if not self.IsShow() or not active:return
|
||||
tab=active[0]()
|
||||
if not tab or tab.IsEmpty() or core.Snapshot(player.SWITCHBOT,tab.slot_num)!=active[1]:
|
||||
self.ClearToolTip();self.HideToolTip();return
|
||||
if not tab.IsActive():self.SetInventoryItem(tab.slot_num,player.SWITCHBOT)
|
||||
elif Cached(player.SWITCHBOT,tab.slot_num)!=active[2]:Active(self,tab)
|
||||
|
||||
def Close(self):
|
||||
_cache.clear()
|
||||
return _close(self)
|
||||
|
||||
def Open(self):
|
||||
result=_open(self)
|
||||
self.attrLockSynced=False;self.attrLockSyncTries=0;self.attrLockSyncNext=app.GetTime()+1
|
||||
return result
|
||||
|
||||
def GameUpdate(self):
|
||||
_gameUpdate(self)
|
||||
if not getattr(self,'attrLockSynced',True) and self.attrLockSyncTries<3 and app.GetTime()>=self.attrLockSyncNext:
|
||||
self.attrLockSyncTries+=1;self.attrLockSyncNext=app.GetTime()+2.25
|
||||
net.SendChatPacket('/attr_lock_sync')
|
||||
|
||||
player.GetItemLink=GetItemLink
|
||||
chat.GetLinkFromHyperlink=Relay
|
||||
uiToolTip.HyperlinkItemToolTip.SetHyperlinkItem=Hyperlink
|
||||
uiToolTip.ItemToolTip.ClearToolTip=Clear
|
||||
uiToolTip.ItemToolTip.OnUpdate=Update
|
||||
mt_switchbot.SwitchbotItemTab.OverInItem=Over
|
||||
game.GameWindow.BINARY_ServerCommand_Run=Command
|
||||
game.GameWindow.Close=Close
|
||||
game.GameWindow.Open=Open
|
||||
game.GameWindow.OnUpdate=GameUpdate
|
||||
)PY";
|
||||
@@ -0,0 +1,126 @@
|
||||
// AVA2 lock lines apply to every real item container; keep the seven-attribute base packet.
|
||||
static const char c_szAttrLockViewsScript[] = R"PY(# -*- coding: utf-8 -*-
|
||||
import exchange,shop,safebox,player,uiToolTip,uiEquipmentDialog,uiSafebox,game,weakref,mt_attr_lock as core
|
||||
Tip=uiToolTip.ItemToolTip
|
||||
_epochs={101:0,102:0,103:0,104:0,105:0,106:0}
|
||||
_visible={104:False,105:False}
|
||||
_tips=weakref.WeakKeyDictionary()
|
||||
|
||||
def Invalidate(kinds):
|
||||
for kind in kinds:_epochs[kind]+=1
|
||||
for tip in list(_tips.keys()):
|
||||
context=getattr(tip,'attrLockContext',None)
|
||||
if context and context[0] in kinds:
|
||||
tip.attrLockContext=None;tip.attrLockMask=0;tip.HideToolTip()
|
||||
|
||||
def Triple(vnum,attribute,socket,epoch):
|
||||
return (vnum,tuple(attribute(i) for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM)),
|
||||
tuple(socket(i) for i in xrange(player.METIN_SOCKET_MAX_NUM)),epoch)
|
||||
|
||||
def Read(tip,cell,kind):
|
||||
if not tip:return None
|
||||
epoch=_epochs[kind]
|
||||
if kind in (101,102):
|
||||
if not exchange.isTrading():return None
|
||||
side='Self' if kind==101 else 'Target'
|
||||
return Triple(getattr(exchange,'GetItemVnumFrom'+side)(cell),lambda i:getattr(exchange,'GetItemAttributeFrom'+side)(cell,i),lambda i:getattr(exchange,'GetItemMetinSocketFrom'+side)(cell,i),epoch)
|
||||
if kind==103:
|
||||
if not shop.IsOpen():return None
|
||||
return Triple(shop.GetItemID(cell),lambda i:shop.GetItemAttribute(cell,i),lambda i:shop.GetItemMetinSocket(cell,i),epoch)
|
||||
if kind in (104,105):
|
||||
if not _visible[kind]:return None
|
||||
prefix='Get' if kind==104 else 'GetMall'
|
||||
return Triple(getattr(safebox,prefix+'ItemID')(cell),lambda i:getattr(safebox,prefix+'ItemAttribute')(cell,i),lambda i:getattr(safebox,prefix+'ItemMetinSocket')(cell,i),epoch)
|
||||
if kind==106:
|
||||
dialog=tip.attrLockViewOwner()
|
||||
if not dialog or not dialog.IsShow() or dialog.vid!=tip.attrLockVid:return None
|
||||
data=dialog.itemDataDict.get(cell)
|
||||
if not data:return None
|
||||
return (data[0],tuple(data[3]),tuple(data[2]),epoch)
|
||||
|
||||
def Bind(tip,kind,cell,render,args,owner=None):
|
||||
# The original setter clears and draws the complete tooltip, including prices/flags.
|
||||
tip.attrLockRender=(render,args,weakref.ref(owner) if owner else None)
|
||||
tip.attrLockVid=owner.vid if owner else 0
|
||||
tip.attrLockViewOwner=weakref.ref(owner) if owner else None
|
||||
snapshot=Read(tip,cell,kind)
|
||||
if not snapshot or not snapshot[0] or not any(a[0] for a in snapshot[1][:5]):return
|
||||
tip.attrLockContext=(kind,cell,snapshot);tip.attrLockMask=0
|
||||
_tips[tip]=True;core.Query(tip)
|
||||
|
||||
def Render(tip,cell):
|
||||
render,args,owner=tip.attrLockRender
|
||||
target=owner() if owner else tip
|
||||
if target:render(target,*args)
|
||||
|
||||
for _kind in _epochs:
|
||||
core._views[_kind]=(lambda tip,cell,kind=_kind:Read(tip,cell,kind),Render)
|
||||
|
||||
def WrapTip(name,kind):
|
||||
original=getattr(Tip,name)
|
||||
def Wrapped(self,cell,*args):
|
||||
self.ClearToolTip();self.HideToolTip()
|
||||
original(self,cell,*args)
|
||||
Bind(self,kind,cell,original,(cell,)+args)
|
||||
setattr(Tip,name,Wrapped)
|
||||
for _name,_kind in (('SetExchangeOwnerItem',101),('SetExchangeTargetItem',102),('SetShopItem',103),('SetShopItemBySecondaryCoin',103),('SetSafeBoxItem',104),('SetMallItem',105)):
|
||||
if hasattr(Tip,_name):WrapTip(_name,_kind)
|
||||
|
||||
_builder=Tip.SetPrivateShopBuilderItem
|
||||
def Builder(self,window,cell,shopcell):
|
||||
self.ClearToolTip();self.HideToolTip()
|
||||
_builder(self,window,cell,shopcell)
|
||||
snapshot=core.Snapshot(window,cell)
|
||||
if snapshot[0] and any(a[0] for a in snapshot[1][:5]):
|
||||
# Register the original price-preserving renderer as a normal own-item context.
|
||||
self.attrLockContext=(window,cell,snapshot)
|
||||
self.attrLockBuilderRender=(_builder,(window,cell,shopcell))
|
||||
core.Query(self)
|
||||
Tip.SetPrivateShopBuilderItem=Builder
|
||||
# Own-item rebuilding normally uses SetInventoryItem; retain the builder's selling price.
|
||||
_rebuild=core.Rebuild
|
||||
def Rebuild(self):
|
||||
builder=getattr(self,'attrLockBuilderRender',None)
|
||||
context=getattr(self,'attrLockContext',None)
|
||||
if builder and context and core.Snapshot(context[0],context[1],self)==context[2]:
|
||||
self.attrLockRendering=True
|
||||
try:builder[0](self,*builder[1])
|
||||
finally:self.attrLockRendering=False
|
||||
else:_rebuild(self)
|
||||
core.Rebuild=Rebuild
|
||||
_clear=Tip.ClearToolTip
|
||||
def Clear(self):
|
||||
if not getattr(self,'attrLockRendering',False):self.attrLockBuilderRender=None
|
||||
return _clear(self)
|
||||
Tip.ClearToolTip=Clear
|
||||
|
||||
_equip=uiEquipmentDialog.EquipmentDialog.OverInItem
|
||||
def Equipment(self,cell):
|
||||
if self.tooltipItem:self.tooltipItem.ClearToolTip();self.tooltipItem.HideToolTip()
|
||||
_equip(self,cell)
|
||||
if self.tooltipItem:Bind(self.tooltipItem,106,cell,_equip,(cell,),self)
|
||||
uiEquipmentDialog.EquipmentDialog.OverInItem=Equipment
|
||||
|
||||
def Wrap(cls,name,kinds,visible=None):
|
||||
original=getattr(cls,name)
|
||||
def Wrapped(self,*args,**kwargs):
|
||||
Invalidate(kinds)
|
||||
result=original(self,*args,**kwargs)
|
||||
if visible is not None:
|
||||
for kind in kinds:_visible[kind]=visible
|
||||
return result
|
||||
setattr(cls,name,Wrapped)
|
||||
for _name in ('StartExchange','EndExchange','RefreshExchange'):Wrap(game.GameWindow,_name,(101,102))
|
||||
for _name in ('StartShop','EndShop','RefreshShop'):Wrap(game.GameWindow,_name,(103,))
|
||||
Wrap(uiSafebox.SafeboxWindow,'ShowWindow',(104,),True)
|
||||
Wrap(uiSafebox.SafeboxWindow,'CommandCloseSafebox',(104,),False)
|
||||
Wrap(uiSafebox.MallWindow,'ShowWindow',(105,),True)
|
||||
Wrap(uiSafebox.MallWindow,'CommandCloseMall',(105,),False)
|
||||
for _name in ('Open','Close','SetEquipmentDialogItem','SetEquipmentDialogSocket','SetEquipmentDialogAttr'):
|
||||
Wrap(uiEquipmentDialog.EquipmentDialog,_name,(106,))
|
||||
_close=game.GameWindow.Close
|
||||
def Close(self):
|
||||
Invalidate(tuple(_epochs));_visible[104]=False;_visible[105]=False
|
||||
return _close(self)
|
||||
game.GameWindow.Close=Close
|
||||
)PY";
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,458 @@
|
||||
// AVA2 original uidropitem.py; generated by tools/ava2-native/import_sources.py.
|
||||
static const char c_szAva2DropItemSource[] = R"PY(# -*- coding: utf-8 -*-
|
||||
import ui
|
||||
import wndMgr
|
||||
import grp
|
||||
import item
|
||||
import ime
|
||||
import drop_item
|
||||
import chat
|
||||
import renderTarget
|
||||
import nonplayer
|
||||
|
||||
ITEM_LIST=item.GetNames()
|
||||
|
||||
|
||||
class DropItemWindows(ui.ScriptWindow):
|
||||
|
||||
def __init__(self):
|
||||
ui.ScriptWindow.__init__(self)
|
||||
drop_item.SetDropItemHandler(self)
|
||||
|
||||
self.RENDER_TARGET_INDEX = 2
|
||||
|
||||
self.total_dates = -1
|
||||
self.pages_view = drop_item.GetPageView()
|
||||
drop_item.SetPageSelect(1)
|
||||
|
||||
self.select_button = []
|
||||
|
||||
self.get_vnum = -1
|
||||
|
||||
self.LoadWindow()
|
||||
|
||||
def __del__(self):
|
||||
drop_item.SetDropItemHandler(None)
|
||||
ui.ScriptWindow.__init__(self)
|
||||
|
||||
def LoadWindow(self):
|
||||
try:
|
||||
pyScrLoader = ui.PythonScriptLoader()
|
||||
pyScrLoader.LoadScriptFile(self, "d:/ymir work/worldard/dropitem.py")
|
||||
except:
|
||||
import exception
|
||||
exception.Abort("DropItemWindows.LoadWindow.LoadObject")
|
||||
|
||||
try:
|
||||
self.GetChild("TitleBar").SetCloseEvent(ui.__mem_func__(self.Close))
|
||||
|
||||
self.ItemNameValue = self.GetChild("ItemNameValue")
|
||||
self.ButtonSearch = self.GetChild("ButtonSearch")
|
||||
self.ButtonDelete = self.GetChild("ButtonDelete")
|
||||
self.ModelRender = self.GetChild("ModelRender")
|
||||
self.ModelName1 = self.GetChild("ModelName1")
|
||||
self.ModelName2 = self.GetChild("ModelName2")
|
||||
self.PrevButton = self.GetChild("PrevButton")
|
||||
self.FirstPrevButton = self.GetChild("FirstPrevButton")
|
||||
self.NextButton = self.GetChild("NextButton")
|
||||
self.LastNextButton = self.GetChild("LastNextButton")
|
||||
self.TotalPages = self.GetChild("TotalPages")
|
||||
self.TotalResultados = self.GetChild("TotalResultados")
|
||||
self.ImgSlotTotalPages = self.GetChild("ImgSlotTotalPages")
|
||||
|
||||
self.ModelName1 = self.GetChild("ModelName1")
|
||||
self.ModelName2 = self.GetChild("ModelName2")
|
||||
|
||||
self.ButtonsSelect = {}
|
||||
for i in xrange(0,5):
|
||||
self.ButtonsSelect["NameMob_%d"%i] = self.GetChild("NameMob_%d"%i)
|
||||
self.ButtonsSelect["Cantidad_Item_%d"%i] = self.GetChild("Cantidad_Item_%d"%i)
|
||||
self.ButtonsSelect["Porcentaje_Item_%d"%i] = self.GetChild("Porcentaje_Item_%d"%i)
|
||||
self.ButtonsSelect["Porcentaje_Item_%d"%i].Hide()
|
||||
|
||||
self.ButtonsSelect["Button_Select_%d"%i] = self.GetChild("SelectOption_%d"%i)
|
||||
self.ButtonsSelect["Button_Select_%d"%i].Hide()
|
||||
|
||||
except:
|
||||
import exception
|
||||
exception.Abort("DropItemWindows.Elements.LoadObject")
|
||||
|
||||
|
||||
self.DropDownList = DropDown(self)
|
||||
self.DropDownList.OnChange = self.SelectOption
|
||||
self.DropDownList.SetPosition(15,60)
|
||||
self.DropDownList.Hide()
|
||||
|
||||
self.ItemNameValue.OnIMEUpdate = ui.__mem_func__(self.__OnValueUpdate)
|
||||
self.ItemNameValue.SetReturnEvent(ui.__mem_func__(self.__OnHideList))
|
||||
self.ItemNameValue.SetEscapeEvent(ui.__mem_func__(self.Close))
|
||||
|
||||
|
||||
self.PrevButton.SetEvent(self.__OnClickPage, 'MOSTBOUGHT_RIGHT')
|
||||
self.FirstPrevButton.SetEvent(self.__OnClickPage, 'MOSTBOUGHT_RIGHT_LAST')
|
||||
self.NextButton.SetEvent(self.__OnClickPage, 'MOSTBOUGHT_LEFT')
|
||||
self.LastNextButton.SetEvent(self.__OnClickPage, 'MOSTBOUGHT_LEFT_LAST')
|
||||
|
||||
self.ButtonSearch.SetEvent(self.SearchItem)
|
||||
self.ButtonDelete.SetEvent(self.DeleteItem)
|
||||
|
||||
|
||||
self.PrevButton.Hide()
|
||||
self.FirstPrevButton.Hide()
|
||||
self.NextButton.Hide()
|
||||
self.LastNextButton.Hide()
|
||||
self.TotalResultados.Hide()
|
||||
self.ImgSlotTotalPages.Hide()
|
||||
|
||||
self.ModelRender.Hide()
|
||||
|
||||
def SearchItem(self):
|
||||
if self.get_vnum == -1:
|
||||
return
|
||||
|
||||
drop_item.SearchItem(self.get_vnum)
|
||||
|
||||
def DeleteItem(self):
|
||||
self.Clear()
|
||||
|
||||
def BINARY_DROP_ITEM_LOADING(self):
|
||||
self.select_button = []
|
||||
drop_item.SetPageSelect(1)
|
||||
self.LoadInfo()
|
||||
self.TotalResultados.SetText("Total: %d"%(self.total_dates))
|
||||
self.TotalResultados.Show()
|
||||
self.ImgSlotTotalPages.Show()
|
||||
|
||||
def LoadInfo(self):
|
||||
self.total_dates = drop_item.CountDates()
|
||||
self.page_actual = drop_item.GetPageActual()
|
||||
|
||||
for i in xrange(0,5):
|
||||
self.ButtonsSelect["NameMob_%d"%i].SetText("")
|
||||
self.ButtonsSelect["Cantidad_Item_%d"%i].SetText("")
|
||||
self.ButtonsSelect["Porcentaje_Item_%d"%i].SetText("")
|
||||
self.ButtonsSelect["Button_Select_%d"%i].Hide()
|
||||
self.ButtonsSelect["Button_Select_%d"%i].SetUp()
|
||||
|
||||
for i in xrange(min(self.pages_view, self.total_dates - self.page_actual * self.pages_view +self.pages_view)):
|
||||
index = i + (self.page_actual - 1)*self.pages_view
|
||||
self.ButtonsSelect["NameMob_%d"%i].SetText(nonplayer.GetMonsterName(self.FReturnInfo("vnum_mob",index)))
|
||||
|
||||
if self.FReturnInfo("count_item",index) == 0:
|
||||
self.ButtonsSelect["Cantidad_Item_%d"%i].SetText("Cantidad: +1")
|
||||
else:
|
||||
self.ButtonsSelect["Cantidad_Item_%d"%i].SetText("Cantidad: x%d"%(self.FReturnInfo("count_item",index)))
|
||||
|
||||
#self.ButtonsSelect["Porcentaje_Item_%d"%i].SetText("Porcentaje: %d"%(self.ConvertProb(index))+"%")
|
||||
self.ButtonsSelect["Button_Select_%d"%i].SetEvent(self.FuncSelect,index,i)
|
||||
self.ButtonsSelect["Button_Select_%d"%i].Show()
|
||||
|
||||
self.CheckRadioButton(index,i)
|
||||
|
||||
Left_Last = self.WFunction(float(self.total_dates)/float(self.pages_view))
|
||||
self.TotalPages.SetText("%d/%d"%(self.page_actual,Left_Last))
|
||||
|
||||
if self.page_actual * self.pages_view >= self.total_dates:
|
||||
self.NextButton.Hide()
|
||||
self.LastNextButton.Hide()
|
||||
else:
|
||||
self.NextButton.Show()
|
||||
self.LastNextButton.Show()
|
||||
|
||||
if self.page_actual > 1:
|
||||
self.PrevButton.Show()
|
||||
self.FirstPrevButton.Show()
|
||||
else:
|
||||
self.PrevButton.Hide()
|
||||
self.FirstPrevButton.Hide()
|
||||
|
||||
|
||||
def CheckRadioButton(self, index1, index2):
|
||||
if len(self.select_button) >0 :
|
||||
if self.select_button[0][0] == index1 and self.select_button[0][1] == index2:
|
||||
self.__ClickRadioButton(index2)
|
||||
|
||||
def FuncSelect(self, index1, index2):
|
||||
renderTarget.SetBackground(self.RENDER_TARGET_INDEX, "d:/ymir work/ui/game/myshop_deco/model_view_bg.sub")
|
||||
renderTarget.SetVisibility(self.RENDER_TARGET_INDEX, True)
|
||||
renderTarget.SelectModel(self.RENDER_TARGET_INDEX, self.FReturnInfo("vnum_mob",index1))
|
||||
renderTarget.SetZoom(self.RENDER_TARGET_INDEX, float(1900))
|
||||
self.ModelRender.Show()
|
||||
|
||||
|
||||
self.select_button = []
|
||||
|
||||
self.select_button.append([index1,index2])
|
||||
|
||||
self.ModelName1.SetText(nonplayer.GetMonsterName(self.FReturnInfo("vnum_mob",index1)))
|
||||
self.ModelName2.SetText(nonplayer.GetMonsterName(self.FReturnInfo("vnum_mob",index1)))
|
||||
|
||||
self.__ClickRadioButton(index2)
|
||||
|
||||
def __ClickRadioButton(self, buttonIndex):
|
||||
selButton=self.ButtonsSelect["Button_Select_%d"%buttonIndex]
|
||||
|
||||
for i in xrange(0,5):
|
||||
self.ButtonsSelect["Button_Select_%d"%i].SetUp()
|
||||
|
||||
selButton.Down()
|
||||
|
||||
|
||||
def __OnClickPage(self, func):
|
||||
Left_Last = self.WFunction(float(self.total_dates)/float(self.pages_view))
|
||||
|
||||
if func == 'MOSTBOUGHT_LEFT':
|
||||
drop_item.SetPageSelect(self.page_actual+1)
|
||||
self.LoadInfo()
|
||||
elif func == 'MOSTBOUGHT_LEFT_LAST':
|
||||
drop_item.SetPageSelect(Left_Last)
|
||||
self.LoadInfo()
|
||||
elif func == 'MOSTBOUGHT_RIGHT':
|
||||
drop_item.SetPageSelect(self.page_actual-1)
|
||||
self.LoadInfo()
|
||||
elif func == 'MOSTBOUGHT_RIGHT_LAST':
|
||||
drop_item.SetPageSelect(1)
|
||||
self.LoadInfo()
|
||||
|
||||
|
||||
def __OnValueUpdate(self):
|
||||
ui.EditLine.OnIMEUpdate(self.ItemNameValue)
|
||||
get_text=self.ItemNameValue.GetText()
|
||||
if len(get_text)>0:
|
||||
self.DropDownList.Clear()
|
||||
f=0
|
||||
n=[]
|
||||
for it in ITEM_LIST:
|
||||
vnum,name=it["vnum"],it["name"]
|
||||
if f==10:
|
||||
break
|
||||
if len(name)>=len(get_text) and name[:len(get_text)].lower() == get_text.lower():
|
||||
self.DropDownList.AppendItem(name,vnum)
|
||||
f+=1
|
||||
|
||||
|
||||
if f>0:
|
||||
if self.DropDownList.dropped==0:
|
||||
self.DropDownList.Clear()
|
||||
self.DropDownList.ExpandMe()
|
||||
self.DropDownList.Show()
|
||||
return
|
||||
|
||||
self.__OnHideList()
|
||||
|
||||
|
||||
def __OnHideList(self):
|
||||
self.DropDownList.dropped=0
|
||||
self.DropDownList.Clear()
|
||||
self.DropDownList.Hide()
|
||||
|
||||
def SelectOption(self):
|
||||
self.get_vnum=self.DropDownList.DropList.GetSelectedItem().value
|
||||
name= ""
|
||||
for it in ITEM_LIST:
|
||||
if int(it["vnum"]) == self.get_vnum:
|
||||
name=it["name"]
|
||||
break
|
||||
|
||||
self.ItemNameValue.SetText(str(name))
|
||||
self.DropDownList.Clear()
|
||||
self.DropDownList.Hide()
|
||||
ime.SetCursorPosition(len(name)+1)
|
||||
|
||||
def ConvertProb(self,index):
|
||||
if self.FReturnInfo("prob_item",index) <= 0:
|
||||
return 1
|
||||
|
||||
if self.FReturnInfo("prob_item",index) >= 100:
|
||||
return 100
|
||||
|
||||
return self.FReturnInfo("prob_item",index)
|
||||
|
||||
def FReturnInfo(self,func,index):
|
||||
(name_mob,vnum_mob,prob_item,count_item) = drop_item.GetDates(index)
|
||||
info = {
|
||||
"name_mob" : name_mob,
|
||||
"vnum_mob" : vnum_mob,
|
||||
"prob_item" : prob_item,
|
||||
"count_item": count_item
|
||||
}
|
||||
|
||||
return info[func]
|
||||
|
||||
|
||||
def WFunction(self, num):
|
||||
if (num + 1) != int(num+1):
|
||||
return int(num+1)
|
||||
else:
|
||||
return int(num)
|
||||
|
||||
def Clear(self):
|
||||
self.total_dates = -1
|
||||
self.pages_view = drop_item.GetPageView()
|
||||
drop_item.SetPageSelect(1)
|
||||
self.select_button = []
|
||||
self.get_vnum = -1
|
||||
|
||||
|
||||
self.PrevButton.Hide()
|
||||
self.FirstPrevButton.Hide()
|
||||
self.NextButton.Hide()
|
||||
self.LastNextButton.Hide()
|
||||
|
||||
self.TotalResultados.Hide()
|
||||
|
||||
self.ImgSlotTotalPages.Hide()
|
||||
|
||||
self.__OnHideList()
|
||||
|
||||
self.ItemNameValue.SetText("")
|
||||
|
||||
self.ModelName1.SetText("")
|
||||
self.ModelName2.SetText("")
|
||||
|
||||
for i in xrange(0,5):
|
||||
self.ButtonsSelect["NameMob_%d"%i].SetText("")
|
||||
self.ButtonsSelect["Cantidad_Item_%d"%i].SetText("")
|
||||
self.ButtonsSelect["Porcentaje_Item_%d"%i].SetText("")
|
||||
self.ButtonsSelect["Button_Select_%d"%i].Hide()
|
||||
self.ButtonsSelect["Button_Select_%d"%i].SetUp()
|
||||
|
||||
renderTarget.SetVisibility(self.RENDER_TARGET_INDEX, False)
|
||||
self.ModelRender.Hide()
|
||||
|
||||
def OnPressEscapeKey(self):
|
||||
self.Close()
|
||||
return True
|
||||
|
||||
def Close(self):
|
||||
self.Clear()
|
||||
wndMgr.Hide(self.hWnd)
|
||||
|
||||
|
||||
class DropDown(ui.Window):
|
||||
dropped = 0
|
||||
dropstat = 0
|
||||
width = 0
|
||||
height = 0
|
||||
maxh = 30
|
||||
OnChange = None
|
||||
class Item(ui.Window):
|
||||
TEMPORARY_PLACE = 0
|
||||
width = 0
|
||||
height = 0
|
||||
def __init__(self,parent, text,value=0,skill=0):
|
||||
ui.Window.__init__(self)
|
||||
self.textBox=ui.MakeTextLine(self)
|
||||
self.textBox.SetText(text)
|
||||
self.value = int(value)
|
||||
self.skill = int(skill)
|
||||
|
||||
def __del__(self):
|
||||
ui.Window.__del__(self)
|
||||
|
||||
def SetParent(self, parent):
|
||||
ui.Window.SetParent(self, parent)
|
||||
self.parent=parent
|
||||
|
||||
def OnMouseLeftButtonDown(self):
|
||||
self.parent.SelectItem(self)
|
||||
|
||||
def SetSize(self,w,h):
|
||||
w = w-110
|
||||
ui.Window.SetSize(self,w,h)
|
||||
self.width = w
|
||||
self.height = h
|
||||
def OnUpdate(self):
|
||||
if self.IsIn():
|
||||
self.isOver = True
|
||||
else:
|
||||
self.isOver = False
|
||||
def OnRender(self):
|
||||
xRender, yRender = self.GetGlobalPosition()
|
||||
yRender -= self.TEMPORARY_PLACE
|
||||
widthRender = self.width
|
||||
heightRender = self.height + self.TEMPORARY_PLACE*2
|
||||
grp.SetColor(ui.BACKGROUND_COLOR)
|
||||
grp.RenderBar(xRender, yRender, widthRender, heightRender)
|
||||
grp.SetColor(ui.DARK_COLOR)
|
||||
grp.RenderLine(xRender, yRender, widthRender, 0)
|
||||
grp.RenderLine(xRender, yRender, 0, heightRender)
|
||||
grp.SetColor(ui.BRIGHT_COLOR)
|
||||
grp.RenderLine(xRender, yRender+heightRender, widthRender, 0)
|
||||
grp.RenderLine(xRender+widthRender, yRender, 0, heightRender)
|
||||
|
||||
if self.isOver:
|
||||
grp.SetColor(ui.HALF_WHITE_COLOR)
|
||||
grp.RenderBar(xRender + 2, yRender + 3, self.width - 3, heightRender - 5)
|
||||
|
||||
|
||||
def __init__(self,parent):
|
||||
ui.Window.__init__(self,"TOP_MOST")
|
||||
self.down = 1
|
||||
self.parent=parent
|
||||
|
||||
|
||||
self.DropList = ui.ListBoxEx()
|
||||
self.DropList.SetParent(self)
|
||||
self.DropList.itemHeight = 20
|
||||
self.DropList.itemWidth = 220
|
||||
self.DropList.itemStep = 18
|
||||
self.DropList.SetPosition(0,0)
|
||||
self.DropList.SetSize(200,2)
|
||||
self.DropList.SetSelectEvent(self.SetTitle)
|
||||
self.DropList.SetViewItemCount(0)
|
||||
self.DropList.Show()
|
||||
self.selected = self.DropList.GetSelectedItem()
|
||||
|
||||
self.SetSize(220-110,95)
|
||||
|
||||
def __del__(self):
|
||||
ui.Window.__del__(self)
|
||||
|
||||
def AppendItem(self,text,value=0,skill=0):
|
||||
self.DropList.AppendItem(self.Item(self,text,value,skill))
|
||||
|
||||
def OnPressEscapeKey(self):
|
||||
self.Hide()
|
||||
self.Clear()
|
||||
|
||||
def SetTitle(self,item):
|
||||
self.dropped = 0
|
||||
self.selected = item
|
||||
if self.OnChange:
|
||||
self.OnChange()
|
||||
self.Clear()
|
||||
|
||||
def SetSize(self,w,h):
|
||||
ui.Window.SetSize(self,w,h+10)
|
||||
self.width = w
|
||||
self.height = h
|
||||
self.DropList.SetSize(w,h)
|
||||
|
||||
def Clear(self):
|
||||
for x in self.DropList.itemList:
|
||||
x.Hide()
|
||||
self.DropList.RemoveAllItems()
|
||||
|
||||
def ExpandMe(self):
|
||||
if self.dropped == 1:
|
||||
self.dropped = 0
|
||||
else:
|
||||
self.dropped = 1
|
||||
|
||||
def OnUpdate(self):
|
||||
(w,h) = self.parent.GetLocalPosition()
|
||||
self.maxh =self.DropList.itemStep*len(self.DropList.itemList)
|
||||
self.SetPosition(w+15,h+75)
|
||||
if self.dropped == 0 or not self.parent.IsShow() or len(self.DropList.itemList)==0:
|
||||
self.SetSize(self.GetWidth(),0)
|
||||
self.DropList.SetViewItemCount(0)
|
||||
self.Hide()
|
||||
elif self.dropped == 1:
|
||||
self.Show()
|
||||
self.SetTop()
|
||||
height = self.maxh+5 if int(self.maxh/self.DropList.itemStep) <2 else self.maxh
|
||||
self.SetSize(self.GetWidth(),height)
|
||||
self.DropList.SetViewItemCount(self.maxh/self.DropList.itemStep)
|
||||
|
||||
)PY";
|
||||
@@ -0,0 +1,622 @@
|
||||
// AVA2 original uieventcalendarnew.py; generated by tools/ava2-native/import_sources.py.
|
||||
static const char c_szAva2EventCalendarNewSource[] = R"PY(# -*- coding: utf-8 -*-
|
||||
import ui, app, net, constInfo, player
|
||||
import datetime
|
||||
import chat
|
||||
import dbg
|
||||
import wndMgr
|
||||
import localeInfo
|
||||
from uiToolTip import ItemToolTip
|
||||
IMG_DIR = "d:/ymir work/ui/game/event_calendar/"
|
||||
IMG_ICON_DIR = "d:/ymir work/ui/game/event_calendar/icons/"
|
||||
MINI_IMG_ICON_DIR = "d:/ymir work/ui/game/event_calendar/icons/mini_gui/"
|
||||
|
||||
|
||||
events_default_data = {
|
||||
# img , eventName
|
||||
player.BONUS_EVENT:["bonus_event",localeInfo.BONUS_EVENT],
|
||||
player.DOUBLE_BOSS_LOOT_EVENT:["double_boss_loot_event",localeInfo.DOUBLE_BOSS_LOOT_EVENT],
|
||||
player.DOUBLE_METIN_LOOT_EVENT:["double_metin_loot_event", localeInfo.DOUBLE_METIN_LOOT_EVENT],
|
||||
player.DOUBLE_MISSION_BOOK_EVENT:["double_mission_book_event",localeInfo.DOUBLE_MISSION_BOOK_EVENT],
|
||||
player.DUNGEON_COOLDOWN_EVENT:["dungeon_cooldown_event",localeInfo.DUNGEON_COOLDOWN_EVENT],
|
||||
player.DUNGEON_TICKET_LOOT_EVENT:["dungeon_ticket_loot_event",localeInfo.DUNGEON_TICKET_LOOT_EVENT],
|
||||
player.EMPIRE_WAR_EVENT:["empire_war_event",""],
|
||||
player.MOONLIGHT_EVENT:["moonlight_event",localeInfo.MOONLIGHT_EVENT],
|
||||
player.TOURNAMENT_EVENT:["tournament_event",""],
|
||||
player.WHELL_OF_FORTUNE_EVENT:["whell_of_fortune_event",localeInfo.WHELL_OF_FORTUNE_EVENT],
|
||||
player.HALLOWEEN_EVENT:["halloween_event",localeInfo.HALLOWEEN_EVENT],
|
||||
|
||||
player.NPC_SEARCH_EVENT:["npc_search",""],
|
||||
|
||||
player.ITEM_DROP_EVENT:["item_drop_event",localeInfo.ITEM_DROP_EVENT],
|
||||
player.YANG_DROP_EVENT:["money_drop_event",localeInfo.YANG_DROP_EVENT],
|
||||
player.EXP_EVENT:["exp_event",localeInfo.EXP_EVENT],
|
||||
|
||||
player.CARD_EVENT:["okey_event",localeInfo.CARD_EVENT],
|
||||
player.CATCH_KING_EVENT:["king_event",localeInfo.CATCH_KING_EVENT],
|
||||
player.TREASURE_KEY:["keys_event",localeInfo.TREASURE_KEY],
|
||||
|
||||
player.BEGGINER_EVENT:["begginer_event",localeInfo.BEGGINER_EVENT],
|
||||
}
|
||||
|
||||
#Dont touch!
|
||||
def CalculateDayCount(month, year):
|
||||
if month == 2:
|
||||
if ((year%400==0) or (year%4==0 and year%100!=0)):
|
||||
return 29
|
||||
else:
|
||||
return 28
|
||||
elif month == 1 or month == 3 or month == 5 or month == 7 or month == 8 or month == 10 or month==12:
|
||||
return 31
|
||||
else:
|
||||
return 30
|
||||
EVENT_DAY_INDEX = 0
|
||||
EVENT_ID = 1
|
||||
EVENT_INDEX = 2
|
||||
EVENT_START_TEXT = 3
|
||||
EVENT_END_TEXT = 4
|
||||
EVENT_EMPIRE_FLAG = 5
|
||||
EVENT_CHANNEL_FLAG = 6
|
||||
EVENT_VALUE0 = 7
|
||||
EVENT_VALUE1 = 8
|
||||
EVENT_VALUE2 = 9
|
||||
EVENT_VALUE3 = 10
|
||||
EVENT_START_TIME = 11
|
||||
EVENT_END_TIME = 12
|
||||
EVENT_IS_ACTIVE = 13
|
||||
server_event_data = {}
|
||||
def SetEventStatus(eventID, eventStatus, endTime, endTimeText):
|
||||
for dayIndex, eventList in server_event_data.items():
|
||||
if eventList.has_key(eventID):
|
||||
eventList[eventID][EVENT_IS_ACTIVE] = eventStatus
|
||||
eventList[eventID][EVENT_END_TIME] = endTime
|
||||
eventList[eventID][EVENT_END_TEXT] = endTimeText
|
||||
def SetServerData(dayIndex, eventID, eventIndex, startTime, endTime, empireFlag, channelFlag, value0, value1, value2, value3, startRealTime, endRealTime, isAlreadyStart):
|
||||
if server_event_data.has_key(dayIndex):
|
||||
server_event_data[dayIndex][eventID] = [dayIndex, eventID, eventIndex, startTime, endTime, empireFlag, channelFlag, value0, value1, value2, value3, startRealTime, endRealTime, isAlreadyStart]
|
||||
else:
|
||||
eventList = {}
|
||||
eventList[eventID] = [dayIndex, eventID, eventIndex, startTime, endTime, empireFlag, channelFlag, value0, value1, value2, value3, startRealTime, endRealTime, isAlreadyStart]
|
||||
server_event_data[dayIndex] = eventList
|
||||
def IsEventIDActive(eventID):
|
||||
for dayIndex, eventList in server_event_data.items():
|
||||
if eventList.has_key(eventID):
|
||||
return eventList[EVENT_IS_ACTIVE]
|
||||
return False
|
||||
def IsEventIndexActive(eventIndex):
|
||||
for dayIndex, eventList in server_event_data.items():
|
||||
for eventID, eventData in eventList.items():
|
||||
if eventList[EVENT_IS_ACTIVE]:
|
||||
return eventList[EVENT_INDEX] == eventIndex
|
||||
return False
|
||||
def GetEventIndexData(eventIndex):
|
||||
for dayIndex, eventList in server_event_data.items():
|
||||
for eventID, eventData in eventList.items():
|
||||
if eventList[EVENT_INDEX] == eventIndex:
|
||||
return eventData
|
||||
return None
|
||||
def GetEventIDData(eventID):
|
||||
for dayIndex, eventList in server_event_data.items():
|
||||
if eventList.has_key(eventID):
|
||||
return eventList[eventID]
|
||||
return None
|
||||
#Dont touch!
|
||||
|
||||
class ImageBoxSpecial(ui.ImageBox):
|
||||
def __del__(self):
|
||||
ui.ImageBox.__del__(self)
|
||||
def Destroy(self):
|
||||
self.miniIcon = None
|
||||
self.eventList=[]
|
||||
self.imageIndex = 0
|
||||
self.isMiniIcon = False
|
||||
|
||||
self.waitingTime = 0.0
|
||||
self.sleepTime = 0.0
|
||||
self.alphaValue = 0.0
|
||||
self.increaseValue = 0.0
|
||||
self.minAlpha = 0.0
|
||||
self.maxAlpha = 0.0
|
||||
self.alphaStatus = False
|
||||
|
||||
def __init__(self, isMiniIcon = False):
|
||||
ui.ImageBox.__init__(self)
|
||||
self.Destroy()
|
||||
self.isMiniIcon = isMiniIcon
|
||||
|
||||
self.waitingTime = 2.0
|
||||
self.alphaValue = 0.3
|
||||
self.increaseValue = 0.05
|
||||
self.minAlpha = 0.3
|
||||
self.maxAlpha = 1.0
|
||||
|
||||
if isMiniIcon:
|
||||
self.AddFlag("attach")
|
||||
self.AddFlag("movable")
|
||||
#self.SetSize(90, 90)
|
||||
(x,y) = (wndMgr.GetScreenWidth()-150, 200)
|
||||
self.SetPosition(x, y)
|
||||
self.SetEvent(ui.__mem_func__(self.OnClickEventIcon),"mouse_click")
|
||||
self.SetMouseLeftButtonDoubleClickEvent(ui.__mem_func__(self.OnClickDouble))
|
||||
self.SetMouseRightButtonDownEvent(ui.__mem_func__(self.NextEventWithKey))
|
||||
|
||||
def OnMoveWindow(self, x, y):
|
||||
(screenWidth, screenHeight) = (wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight())
|
||||
|
||||
if x < 0:
|
||||
x = 0
|
||||
elif x+self.GetWidth() >= screenWidth-70:
|
||||
x = screenWidth-80 - self.GetWidth()
|
||||
|
||||
if y < 0:
|
||||
y = 0
|
||||
elif y+self.GetHeight() >= screenHeight-100:
|
||||
y = screenHeight-100 - self.GetHeight()
|
||||
|
||||
self.SetPosition(x, y)
|
||||
|
||||
def NextEventWithKey(self):
|
||||
if len(self.eventList) > 1:
|
||||
self.sleepTime = 0
|
||||
self.alphaValue = self.maxAlpha
|
||||
self.alphaStatus = True
|
||||
|
||||
def SetBackgroundImage(self, image):
|
||||
self.LoadImage(image)
|
||||
self.SAFE_SetStringEvent("MOUSE_OVER_IN",self.OverInItem)
|
||||
self.SAFE_SetStringEvent("MOUSE_OVER_OUT",self.OverOutItem)
|
||||
self.SetEvent(ui.__mem_func__(self.OnClickEventIcon),"mouse_click")
|
||||
|
||||
def OnClickEventIcon(self):
|
||||
(_index, eventID) = self.GetNextImage(self.imageIndex)
|
||||
if GetEventIDData(eventID) != None:
|
||||
if GetEventIDData(eventID)[EVENT_IS_ACTIVE] == True:
|
||||
interface = constInfo.GetInterfaceInstance()
|
||||
if interface:
|
||||
if interface.wndEventManager:
|
||||
interface.wndEventManager.OnClick(GetEventIDData(eventID)[EVENT_INDEX])
|
||||
|
||||
def SetImage(self, folder):
|
||||
if self.miniIcon == None:
|
||||
miniIcon = ui.ImageBox()
|
||||
miniIcon.SetParent(self)
|
||||
miniIcon.AddFlag("not_pick")
|
||||
self.miniIcon = miniIcon
|
||||
|
||||
if self.isMiniIcon == True:
|
||||
self.miniIcon.LoadImage(MINI_IMG_ICON_DIR+folder+".tga")
|
||||
else:
|
||||
self.miniIcon.LoadImage(IMG_ICON_DIR+folder+".tga")
|
||||
self.miniIcon.SetPosition(6, 6)
|
||||
self.miniIcon.Show()
|
||||
|
||||
if self.isMiniIcon:
|
||||
self.SetSize(90,90)
|
||||
|
||||
self.alphaValue = self.minAlpha
|
||||
self.alphaStatus = False
|
||||
|
||||
def OnClickDouble(self):
|
||||
interface = constInfo.GetInterfaceInstance()
|
||||
if interface:
|
||||
interface.OpenEventCalendar()
|
||||
def OverOutItem(self):
|
||||
interface = constInfo.GetInterfaceInstance()
|
||||
if interface:
|
||||
if interface.tooltipItem:
|
||||
interface.tooltipItem.HideToolTip()
|
||||
def OverInItem(self):
|
||||
interface = constInfo.GetInterfaceInstance()
|
||||
if interface:
|
||||
if interface.wndEventManager:
|
||||
interface.wndEventManager.OverInItem(self.dayIndex)
|
||||
def Clear(self):
|
||||
self.miniIcon = None
|
||||
self.eventList = []
|
||||
if self.isMiniIcon:
|
||||
self.SetSize(0,0)
|
||||
|
||||
def DeleteImage(self, eventIndex):
|
||||
del self.eventList[eventIndex]
|
||||
if self.isMiniIcon and len(self.eventList) == 0:
|
||||
self.SetSize(0,0)
|
||||
|
||||
def AppendImage(self, eventID):
|
||||
if eventID in self.eventList:
|
||||
return
|
||||
self.eventList.append(eventID)
|
||||
if len(self.eventList) == 1:
|
||||
self.imageIndex = 0
|
||||
if GetEventIDData(eventID) != None:
|
||||
self.SetImage(events_default_data[GetEventIDData(eventID)[EVENT_INDEX]][0])
|
||||
|
||||
if self.isMiniIcon:
|
||||
self.SetSize(90,90)
|
||||
|
||||
def GetNextImage(self, listIndex):
|
||||
if listIndex >= len(self.eventList):
|
||||
if len(self.eventList) > 0:
|
||||
return (0,self.eventList[0])
|
||||
return (0,0)
|
||||
return (listIndex, self.eventList[listIndex])
|
||||
|
||||
def OnUpdate(self):
|
||||
if len(self.eventList) <= 1:
|
||||
self.imageIndex=0
|
||||
return
|
||||
elif self.sleepTime > app.GetTime():
|
||||
return
|
||||
if self.alphaStatus == True:
|
||||
self.alphaValue -= self.increaseValue
|
||||
if self.alphaValue < self.minAlpha:
|
||||
self.alphaValue = self.minAlpha
|
||||
self.alphaStatus = False
|
||||
(imageIndex, eventID) = self.GetNextImage(self.imageIndex+1)
|
||||
if GetEventIDData(eventID) != None:
|
||||
self.SetImage(events_default_data[GetEventIDData(eventID)[EVENT_INDEX]][0])
|
||||
self.imageIndex = imageIndex
|
||||
else:
|
||||
self.alphaValue += self.increaseValue
|
||||
if self.alphaValue > self.maxAlpha:
|
||||
self.alphaStatus = True
|
||||
self.sleepTime = app.GetTime()+self.waitingTime
|
||||
if self.miniIcon != None:
|
||||
self.miniIcon.SetAlpha(self.alphaValue)
|
||||
|
||||
class EventCalendarWindow(ui.BoardWithTitleBar):
|
||||
def __del__(self):
|
||||
ui.BoardWithTitleBar.__del__(self)
|
||||
def Destroy(self):
|
||||
self.children = {}
|
||||
self.currentMonth =0
|
||||
self.currentYear = 0
|
||||
def __init__(self):
|
||||
ui.BoardWithTitleBar.__init__(self)
|
||||
self.Destroy()
|
||||
self.__LoadWindow()
|
||||
|
||||
def __LoadWindow(self):
|
||||
dt = datetime.datetime.today()
|
||||
(self.currentMonth,self.currentYear) = (dt.month,dt.year)
|
||||
dayCount = CalculateDayCount(self.currentMonth, self.currentYear)
|
||||
|
||||
board = ui.ImageBox()
|
||||
board.SetParent(self)
|
||||
board.AddFlag("not_pick")
|
||||
board.LoadImage(IMG_DIR+"board.tga")
|
||||
board.SetPosition(8, 28)
|
||||
board.Show()
|
||||
self.children["board"] = board
|
||||
|
||||
self.SetSize(8+board.GetWidth()+8, 294)
|
||||
self.AddFlag("movable")
|
||||
self.AddFlag("attach")
|
||||
self.SetTitleName(localeInfo.EVENT_MANAGER_WINDOW_TITLE % (self.__GetMonthName(self.currentMonth),self.currentYear))
|
||||
self.SetCloseEvent(self.Close)
|
||||
self.SetCenterPosition()
|
||||
|
||||
for day in xrange(dayCount):
|
||||
yCalculate = day/8
|
||||
xCalculate = day-(yCalculate*8)
|
||||
|
||||
dayImages = ImageBoxSpecial(False)
|
||||
dayImages.SetParent(board)
|
||||
if dt.day == day+1:
|
||||
dayImages.SetBackgroundImage(IMG_DIR+"today_bg.tga")
|
||||
else:
|
||||
dayImages.SetBackgroundImage(IMG_DIR+"black_bg.tga")
|
||||
dayImages.SetPosition(8 + (xCalculate*66),8+(yCalculate*62))
|
||||
dayImages.dayIndex = day+1
|
||||
dayImages.Show()
|
||||
self.children["dayImages%d"%day] = dayImages
|
||||
|
||||
dayIndex = ui.NumberLine()
|
||||
dayIndex.SetParent(dayImages)
|
||||
dayIndex.SetNumber(str(day+1))
|
||||
dayIndex.SetPosition(8,8)
|
||||
dayIndex.Show()
|
||||
self.children["dayIndex%d"%day] = dayIndex
|
||||
self.Refresh()
|
||||
def Open(self):
|
||||
self.Show()
|
||||
self.Refresh()
|
||||
self.SetTop()
|
||||
def Close(self):
|
||||
self.Hide()
|
||||
def OnPressEscapeKey(self):
|
||||
self.Close()
|
||||
return True
|
||||
def OnUpdate(self):
|
||||
for dayIndex in xrange(31):
|
||||
if self.children.has_key("dayImages%d"%dayIndex):
|
||||
self.children["dayImages%d"%dayIndex].OnUpdate()
|
||||
|
||||
def Refresh(self):
|
||||
dt = datetime.datetime.today()
|
||||
for dayIndex in xrange(31):
|
||||
if self.children.has_key("dayImages%d"%dayIndex):
|
||||
dayEventImage = self.children["dayImages%d"%dayIndex]
|
||||
dayEventImage.Clear()
|
||||
if server_event_data.has_key(dayIndex+1):
|
||||
eventDict = server_event_data[dayIndex+1]
|
||||
if dt.day == dayIndex+1:
|
||||
dayEventImage.SetBackgroundImage(IMG_DIR+"today_bg.tga")
|
||||
else:
|
||||
dayEventImage.SetBackgroundImage(IMG_DIR+"blue_bg.tga")
|
||||
for eventID, _data in eventDict.items():
|
||||
dayEventImage.AppendImage(eventID)
|
||||
else:
|
||||
if dt.day == dayIndex+1:
|
||||
dayEventImage.SetBackgroundImage(IMG_DIR+"today_bg.tga")
|
||||
else:
|
||||
dayEventImage.SetBackgroundImage(IMG_DIR+"black_bg.tga")
|
||||
dayEventImage.Show()
|
||||
def OnClick(self, eventIndex):
|
||||
interface = constInfo.GetInterfaceInstance()
|
||||
if not interface:
|
||||
return
|
||||
if eventIndex == player.CARD_EVENT:
|
||||
if interface.wndCardsInfo.IsShow():
|
||||
interface.wndCardsInfo.Close()
|
||||
else:
|
||||
interface.wndCardsInfo.Open()
|
||||
elif eventIndex == player.CATCH_KING_EVENT:
|
||||
interface.ClickCatchKingEventButton()
|
||||
|
||||
def __textToColorFull(self, text):
|
||||
return localeInfo.EVENT_COLORFULL_TEXT % text
|
||||
def __GetBonusName(self, affect, value):
|
||||
return ItemToolTip.AFFECT_DICT[affect](value)
|
||||
def __CalculateTime(self, eventIndex, startTimeText, endTimeText, endTime):
|
||||
if endTimeText == "1970-01-01 03:00:00" or endTimeText == "1970-01-01 02:00:00" or endTimeText == "1970-01-01 01:00:00" or endTimeText == "1970-01-01 00:00:00" or endTimeText == "":
|
||||
startTimeSecond = startTimeText.split(" ")[1]
|
||||
return localeInfo.PVP_EVENT_TIME % self.__textToColorFull(startTimeSecond)
|
||||
startTimeFirst = startTimeText.split(" ")[0]
|
||||
startTimeSecond = startTimeText.split(" ")[1]
|
||||
endTimeFirst = endTimeText.split(" ")[0]
|
||||
endTimeSecond = endTimeText.split(" ")[1]
|
||||
beginTimeText = ""
|
||||
endTimeText = ""
|
||||
if startTimeFirst != endTimeFirst:
|
||||
beginTimeText += startTimeFirst.split("-")[2]+"/"+startTimeFirst.split("-")[1]
|
||||
beginTimeText+=" "
|
||||
endTimeText += endTimeFirst.split("-")[2]+"/"+endTimeFirst.split("-")[1]
|
||||
endTimeText+=" "
|
||||
beginTimeText+=startTimeSecond
|
||||
endTimeText+=endTimeSecond
|
||||
return localeInfo.NORMAL_EVENT_TIME % (self.__textToColorFull(beginTimeText),self.__textToColorFull(endTimeText))
|
||||
def __GetMonthName(self, monthIndex):
|
||||
monthName = {
|
||||
1:localeInfo.EVENT_MONTH_1,
|
||||
2:localeInfo.EVENT_MONTH_2,
|
||||
3:localeInfo.EVENT_MONTH_3,
|
||||
4:localeInfo.EVENT_MONTH_4,
|
||||
5:localeInfo.EVENT_MONTH_5,
|
||||
6:localeInfo.EVENT_MONTH_6,
|
||||
7:localeInfo.EVENT_MONTH_7,
|
||||
8:localeInfo.EVENT_MONTH_8,
|
||||
9:localeInfo.EVENT_MONTH_9,
|
||||
10:localeInfo.EVENT_MONTH_10,
|
||||
11:localeInfo.EVENT_MONTH_11,
|
||||
12:localeInfo.EVENT_MONTH_12
|
||||
}
|
||||
if monthName.has_key(monthIndex):
|
||||
return monthName[monthIndex]
|
||||
return "Unknown Month Name"
|
||||
def __GetMapName(self, mapIndex):
|
||||
mapNames = {
|
||||
61:localeInfo.MOUNT_SOHAN_MAP_NAME,
|
||||
62:localeInfo.MOUNT_DOYUMHWAN_MAP_NAME,
|
||||
63:localeInfo.MOUNT_YONGBI_MAP_NAME,
|
||||
}
|
||||
if mapNames.has_key(mapIndex):
|
||||
return mapNames[mapIndex]
|
||||
return "Unknown Map Name"
|
||||
def OverInItem(self, dayIndex):
|
||||
interface = constInfo.GetInterfaceInstance()
|
||||
if interface:
|
||||
tooltipItem = interface.tooltipItem
|
||||
if tooltipItem:
|
||||
tooltipItem.ClearToolTip()
|
||||
tooltipItem.ShowToolTip()
|
||||
tooltipItem.AppendTextLine(localeInfo.EVENT_TOOLTIP_TITLE % self.__textToColorFull("%04d-%02d-%02d" % (int(self.currentYear), int(self.currentMonth), int(dayIndex))))
|
||||
tooltipItem.AppendSpace(5)
|
||||
|
||||
if server_event_data.has_key(dayIndex):
|
||||
eventList = server_event_data[dayIndex]
|
||||
|
||||
for eventID, eventData in eventList.items():
|
||||
eventName=""
|
||||
topInfo=""
|
||||
|
||||
empireTexts = [localeInfo.ALL_KINGDOMS,localeInfo.RED_KINGDOM, localeInfo.YELLOW_KINGDOM, localeInfo.BLUE_KINGDOM]
|
||||
if eventData[EVENT_EMPIRE_FLAG] >= len(empireTexts):
|
||||
eventData[EVENT_EMPIRE_FLAG] = 0
|
||||
topInfo += empireTexts[eventData[EVENT_EMPIRE_FLAG]]+" "
|
||||
|
||||
if eventData[EVENT_CHANNEL_FLAG] == 0:
|
||||
topInfo += "|cFF97AE99"+localeInfo.ALL_CHANNEL+"|r"
|
||||
else:
|
||||
topInfo += ("|cFF97AE99"+localeInfo.ONLY_CHANNEL+"|r") % eventData[EVENT_CHANNEL_FLAG]
|
||||
|
||||
if eventData[EVENT_INDEX] == player.BONUS_EVENT:
|
||||
if eventData[EVENT_VALUE0] > 0 and eventData[EVENT_VALUE1] > 0:
|
||||
eventName+=self.__textToColorFull(events_default_data[eventData[EVENT_INDEX]][1])+" "+self.__GetBonusName(eventData[EVENT_VALUE0],eventData[EVENT_VALUE1])
|
||||
else:
|
||||
eventName+=self.__textToColorFull(events_default_data[eventData[EVENT_INDEX]][1])+" "+localeInfo.NONE_AFFECT
|
||||
|
||||
elif eventData[EVENT_INDEX] == player.EMPIRE_WAR_EVENT:
|
||||
eventName += self.__textToColorFull(localeInfo.EMPIRE_WAR_EVENT % (eventData[EVENT_VALUE0],eventData[EVENT_VALUE1]))
|
||||
|
||||
elif eventData[EVENT_INDEX] == player.TOURNAMENT_EVENT:
|
||||
warType = [localeInfo.TOURNAMENT_ALL_CHARACTER, localeInfo.CHARACTER_WARRIOR, localeInfo.CHARACTER_ASSASSIN,localeInfo.CHARACTER_SURA, localeInfo.CHARACTER_SHAMAN]
|
||||
if eventData[EVENT_VALUE0] >= len(warType):
|
||||
eventData[EVENT_VALUE0] = 0
|
||||
eventName += self.__textToColorFull(localeInfo.TOURNAMENT_EVENT % (warType[eventData[EVENT_VALUE0]], eventData[EVENT_VALUE1], eventData[EVENT_VALUE2]))
|
||||
|
||||
elif eventData[EVENT_INDEX] == player.ITEM_DROP_EVENT or eventData[EVENT_INDEX] == player.YANG_DROP_EVENT or eventData[EVENT_INDEX] == player.EXP_EVENT:
|
||||
eventName+= self.__textToColorFull(events_default_data[eventData[EVENT_INDEX]][1] % eventData[EVENT_VALUE0])
|
||||
|
||||
elif eventData[EVENT_INDEX] == player.NPC_SEARCH_EVENT:
|
||||
tooltipItem.AppendTextLine(self.__textToColorFull(localeInfo.NPC_SEARCH))
|
||||
tooltipItem.AppendTextLine(self.__textToColorFull(localeInfo.NPC_SEARCH_TEXT))
|
||||
for j in xrange(4):
|
||||
if eventData[EVENT_VALUE0+j] > 0:
|
||||
tooltipItem.AppendTextLine(self.__textToColorFull(self.__GetMapName(eventData[EVENT_VALUE0+j])))
|
||||
tooltipItem.AppendTextLine(self.__CalculateTime(eventData[EVENT_INDEX],eventData[EVENT_START_TEXT],eventData[EVENT_END_TEXT],eventData[EVENT_END_TIME]))
|
||||
tooltipItem.AppendSpace(5)
|
||||
continue
|
||||
else:
|
||||
eventName += self.__textToColorFull(events_default_data[eventData[EVENT_INDEX]][1])
|
||||
|
||||
tooltipItem.AppendTextLine(eventName)
|
||||
tooltipItem.AppendTextLine(topInfo)
|
||||
tooltipItem.AppendTextLine(self.__CalculateTime(eventData[EVENT_INDEX],eventData[EVENT_START_TEXT],eventData[EVENT_END_TEXT],eventData[EVENT_END_TIME]))
|
||||
tooltipItem.AppendSpace(10)
|
||||
else:
|
||||
tooltipItem.AppendTextLine(localeInfo.EVENT_TOOLTIP_DOESNT_HAVE_EVENT,interface.tooltipItem.NEGATIVE_COLOR)
|
||||
|
||||
class MovableImage(ImageBoxSpecial):
|
||||
def __del__(self):
|
||||
ImageBoxSpecial.__del__(self)
|
||||
|
||||
def Destroy(self):
|
||||
self.window = None
|
||||
self.eventCache = []
|
||||
self.timeList = []
|
||||
self.timeText = None
|
||||
ImageBoxSpecial.Destroy(self)
|
||||
|
||||
def __init__(self):
|
||||
self.Destroy()
|
||||
ImageBoxSpecial.__init__(self, True)
|
||||
|
||||
window = ui.Window()
|
||||
window.SetParent(self)
|
||||
window.AddFlag("not_pick")
|
||||
window.OnUpdate = ui.__mem_func__(self.OnUpdate)
|
||||
window.Show()
|
||||
self.window = window
|
||||
|
||||
timeText = ui.TextLine()
|
||||
timeText.SetParent(self)
|
||||
timeText.AddFlag("not_pick")
|
||||
timeText.SetHorizontalAlignCenter()
|
||||
timeText.SetPosition(55, 75)
|
||||
timeText.SetOutline()
|
||||
timeText.Show()
|
||||
self.timeText = timeText
|
||||
|
||||
timeTextEx = ui.TextLine()
|
||||
timeTextEx.SetParent(self)
|
||||
timeTextEx.AddFlag("not_pick")
|
||||
timeTextEx.SetHorizontalAlignCenter()
|
||||
timeTextEx.SetPosition(55, 93)
|
||||
timeTextEx.SetText(localeInfo.BONUS_NEXT_EVENT)
|
||||
timeTextEx.SetOutline()
|
||||
timeTextEx.Show()
|
||||
self.timeTextEx = timeTextEx
|
||||
|
||||
def Clear(self):
|
||||
self.eventCache = []
|
||||
self.timeList = []
|
||||
self.timeText.SetText("")
|
||||
self.timeTextEx.Hide()
|
||||
ImageBoxSpecial.Clear(self)
|
||||
self.Hide()
|
||||
|
||||
def Refresh(self):
|
||||
self.Clear()
|
||||
for dayIndex, eventList in server_event_data.items():
|
||||
for eventID, eventData in eventList.items():
|
||||
self.AppendEvent(eventData[EVENT_ID], eventData[EVENT_START_TIME], eventData[EVENT_END_TIME], eventData[EVENT_IS_ACTIVE])
|
||||
|
||||
def LoadTime(self, eventID, startTime, endTime, isAlreadyStart):
|
||||
self.AppendImage(eventID)
|
||||
self.timeList.append([startTime, endTime, isAlreadyStart])
|
||||
|
||||
if len(self.timeList) > 1:
|
||||
self.timeTextEx.Show()
|
||||
else:
|
||||
self.timeTextEx.Hide()
|
||||
self.Show()
|
||||
|
||||
def CheckCacheEvent(self):
|
||||
if len(self.eventCache) == 0:
|
||||
return
|
||||
clientGlobalTime = app.GetGlobalTimeStamp()
|
||||
for j in xrange(len(self.eventCache)):
|
||||
startTime = self.eventCache[j][1] - clientGlobalTime
|
||||
endTime = self.eventCache[j][2] - clientGlobalTime
|
||||
if startTime >= 0 and startTime <= (60*30):
|
||||
self.Refresh()
|
||||
return
|
||||
|
||||
def AppendEvent(self, eventID, startTime, endTime, isAlreadyStart):
|
||||
clientGlobalTime = app.GetGlobalTimeStamp()
|
||||
|
||||
newStartTime = startTime
|
||||
newEndTime = endTime
|
||||
if newStartTime != 0:
|
||||
newStartTime -= clientGlobalTime
|
||||
if newEndTime != 0:
|
||||
newEndTime -= clientGlobalTime
|
||||
|
||||
if (startTime != 0 and newStartTime <= 0 and endTime == startTime and isAlreadyStart == True) or (startTime != 0 and newStartTime <= 0 and endTime == 0 and isAlreadyStart == True):
|
||||
self.LoadTime(eventID, startTime, endTime, 2)
|
||||
elif newStartTime <= 0 and newEndTime <= 0:
|
||||
return
|
||||
elif newStartTime > 0 and newStartTime <= (60*30):#start-in
|
||||
self.LoadTime(eventID, startTime, endTime, 0)
|
||||
elif newEndTime > 0 and isAlreadyStart == True:#end-in
|
||||
self.LoadTime(eventID, startTime, endTime, 1)
|
||||
else:
|
||||
self.eventCache.append([eventID, startTime, endTime, isAlreadyStart])
|
||||
|
||||
if len(self.timeList) > 1:
|
||||
self.timeTextEx.Show()
|
||||
else:
|
||||
self.timeTextEx.Hide()
|
||||
|
||||
def DeleteEvent(self, index):
|
||||
self.DeleteImage(index)
|
||||
del self.timeList[index]
|
||||
|
||||
if len(self.timeList) <= 1:
|
||||
self.timeTextEx.Hide()
|
||||
|
||||
def FormatTime(self, seconds):
|
||||
if seconds == 0:
|
||||
return ""
|
||||
m, s = divmod(seconds, 60)
|
||||
h, m = divmod(m, 60)
|
||||
return "%02dh %02dm %02ds" % (h, m, s)
|
||||
|
||||
def OnUpdate(self):
|
||||
ImageBoxSpecial.OnUpdate(self)
|
||||
self.CheckCacheEvent()
|
||||
|
||||
if self.imageIndex < len(self.timeList):
|
||||
timeData = self.timeList[self.imageIndex]
|
||||
|
||||
if timeData[2] == 0:
|
||||
leftTime = timeData[0] - app.GetGlobalTimeStamp()
|
||||
if leftTime > 0:
|
||||
self.timeText.SetText(localeInfo.BONUS_START_IN%self.FormatTime(leftTime))
|
||||
|
||||
if not self.timeText.IsShow():
|
||||
self.timeText.Show()
|
||||
|
||||
elif timeData[2] == 1:
|
||||
leftTime = timeData[1] - app.GetGlobalTimeStamp()
|
||||
if leftTime > 0:
|
||||
self.timeText.SetText(localeInfo.BONUS_END_IN%self.FormatTime(leftTime))
|
||||
if not self.timeText.IsShow():
|
||||
self.timeText.Show()
|
||||
|
||||
elif timeData[2] == 2:
|
||||
if self.timeText.IsShow():
|
||||
self.timeText.Hide()
|
||||
|
||||
|
||||
)PY";
|
||||
@@ -0,0 +1,32 @@
|
||||
// PORT: AVA2 maps and dungeons (tools/server/ava2-maps), as module mt_ava2maps. npclist.txt is read from
|
||||
// the root pack only, so the ava2maps pack ships locale/zh/mt_ava2maps.txt (gbk) instead; this script feeds
|
||||
// it to RaceManager (race -> model folder, folder -> shared source folder), to the minimap zone names and
|
||||
// to mt_boss's server map index table. Models, maps and the mob_proto rows ship in the same pack.
|
||||
static const char c_szAva2MapsScript[] = R"PY(# -*- coding: utf-8 -*-
|
||||
import chrmgr
|
||||
import localeInfo
|
||||
import pack
|
||||
|
||||
PATH='locale/zh/mt_ava2maps.txt'
|
||||
|
||||
|
||||
def Load():
|
||||
if not pack.Exist(PATH):return 0
|
||||
zones=getattr(localeInfo,'MINIMAP_ZONE_NAME_DICT',None)
|
||||
try:
|
||||
import mt_boss
|
||||
maps=mt_boss.MAPS
|
||||
except (ImportError,AttributeError):
|
||||
maps=None
|
||||
count=0
|
||||
for line in pack.Get(PATH).splitlines():
|
||||
t=line.rstrip('\r').split('\t')
|
||||
if len(t)!=3:continue
|
||||
if t[0]=='race':chrmgr.RegisterRaceName(int(t[1]),t[2]);count+=1
|
||||
elif t[0]=='src':chrmgr.RegisterRaceSrcName(t[1],t[2])
|
||||
elif t[0]=='zone' and zones is not None:zones[t[1]]=t[2]
|
||||
elif t[0]=='map' and maps is not None:maps[int(t[1])]=t[2]
|
||||
return count
|
||||
|
||||
RACES=Load()
|
||||
)PY";
|
||||
@@ -0,0 +1,169 @@
|
||||
// Native AVA2 wiki/drop interfaces backed by the current server and loaded catalogue.
|
||||
static const char c_szAva2NativeDataScript[]=R"PY(# -*- coding: utf-8 -*-
|
||||
import app,item,net,nonplayer,pack,player,sys,types,weakref
|
||||
from mt_wiki_data import Catalogue
|
||||
from mt_biolog import L
|
||||
_built=False;_catalogue=None;_categories={};_costumes={};_chests={};_monsters={};_parents={};_cache={};_cacheTime={};_pending=[];_wire=None;_next=0;_rows=[];_handler=None;_page=1;_searchSerial=0;_data=[];_refresh=None
|
||||
|
||||
def Load():
|
||||
global _catalogue,_built
|
||||
if _catalogue is None:_catalogue=Catalogue(pack.Get('wiki/catalogue.txt'))
|
||||
if _built or not item.SelectItemWiki(19):return _catalogue
|
||||
_built=True
|
||||
jobs=(item.ITEM_ANTIFLAG_WARRIOR,item.ITEM_ANTIFLAG_ASSASSIN,item.ITEM_ANTIFLAG_SURA,item.ITEM_ANTIFLAG_SHAMAN)
|
||||
armor={'ARMOR_BODY':1,'ARMOR_HEAD':2,'ARMOR_SHIELD':3,'ARMOR_EAR':4,'ARMOR_WRIST':5,'ARMOR_NECK':6,'ARMOR_FOOTS':7,'ARMOR_FOOTS':7,'ARMOR_PENDANT':9}
|
||||
for v,r in sorted(_catalogue.items.items()):
|
||||
if r['refined']:_parents[r['refined']]=v
|
||||
if not item.SelectItemWiki(v):continue
|
||||
# AVA2 lists the last refine stage; the original UI expands its complete chain.
|
||||
category=0 if r['kind']=='ITEM_WEAPON' and r['subtype']!='WEAPON_ARROW' else armor.get(r['subtype']) if r['kind']=='ITEM_ARMOR' else 8 if r['kind']=='ITEM_BELT' else 10 if r['kind']=='ITEM_NEW_RINGS' else None
|
||||
if category is not None and not r['refined']:
|
||||
for job in xrange(4):
|
||||
if not item.IsAntiFlag(jobs[job]):_categories.setdefault((job,category),[]).append(v)
|
||||
if r['kind']=='ITEM_COSTUME':
|
||||
costume={'COSTUME_WEAPON':0,'COSTUME_BODY':1,'COSTUME_HAIR':2,'COSTUME_SASH':3,'COSTUME_MOUNT':5}.get(r['subtype'])
|
||||
if costume is not None:_costumes.setdefault(costume,[]).append(v)
|
||||
if r['kind'] in ('ITEM_GIFTBOX','ITEM_TREASURE_BOX'):_chests.setdefault(0,[]).append(v)
|
||||
for v,r in sorted(_catalogue.mobs.items()):
|
||||
kind='Stone' if r['kind']=='STONE' else 'Boss' if r['rank'] in ('BOSS','KING') else 'Monster'
|
||||
group=0 if r['level']<=75 else 1 if r['level']<=100 else 2
|
||||
_monsters.setdefault((kind,group),[]).append(v)
|
||||
return _catalogue
|
||||
|
||||
def Choose(rows,index,default=0):return rows[index] if 0<=index<len(rows) else default
|
||||
|
||||
def Categories(job,category):Load();return _categories.get((job,category),[])
|
||||
def Costumes(kind):Load();return _costumes.get(kind,[])
|
||||
def Chests(kind):Load();return _chests.get(kind,[])
|
||||
def Monsters(kind,group):Load();return _monsters.get((kind,group),[])
|
||||
|
||||
def RefineLevel(vnum):
|
||||
catalogue=Load();seen=set();count=0
|
||||
while vnum in _parents and vnum not in seen:seen.add(vnum);vnum=_parents[vnum]
|
||||
seen=set()
|
||||
while vnum and vnum not in seen:
|
||||
seen.add(vnum);r=catalogue.FindItem(vnum)
|
||||
if not r or not r['refined']:break
|
||||
vnum=r['refined'];count+=1
|
||||
return count
|
||||
|
||||
def RefineItems(index):
|
||||
r=Load().recipes.get(index)
|
||||
if not r:return 0
|
||||
materials=r['materials'][:5];values=[index]
|
||||
for v,c in materials+[(0,0)]*(5-len(materials)):values.extend((v,c))
|
||||
return tuple(values+[r['cost'],r['probability'],len(materials)])
|
||||
|
||||
def Matches(records,text):
|
||||
# Match the actual localized byte names, as native item/nonplayer searches do.
|
||||
return [v for v,r in sorted(records.items()) if text.lower() in L(r['name'].encode('utf-8')).lower() or text==str(v)]
|
||||
|
||||
def Query(kind,vnum,callback):
|
||||
key=(kind,int(vnum))
|
||||
if key in _cache and app.GetTime()-_cacheTime.get(key,0)<30:callback(_cache[key]);return
|
||||
for request in _pending+([_wire] if _wire else []):
|
||||
if request['key']==key:
|
||||
if request['failed']:callback(None)
|
||||
else:request['callbacks'].append(callback)
|
||||
return
|
||||
if len(_pending)>=16:callback(None);return
|
||||
_pending.append(dict(key=key,callbacks=[callback],deadline=0,failed=False))
|
||||
|
||||
def Tick():
|
||||
global _wire,_next
|
||||
now=app.GetTime()
|
||||
# An AVA2 response has no request ID. A timeout never advances the queue until
|
||||
# its terminal packet arrives, so late rows cannot become another item's drops.
|
||||
if _wire and now>=_wire['deadline'] and not _wire['failed']:
|
||||
_wire['failed']=True
|
||||
for cb in _wire['callbacks']:cb(None)
|
||||
_wire['callbacks']=[]
|
||||
if _wire or not _pending or now<_next:return
|
||||
request=_pending.pop(0)
|
||||
if not net.SendAva2DropQuery(*request['key']):
|
||||
_pending.insert(0,request);_next=now+1;return
|
||||
_wire=request;_wire['deadline']=now+5;_next=now+1.1
|
||||
|
||||
def Receive(sub,name,vnum,prob,count):
|
||||
global _rows,_wire
|
||||
if sub==2:
|
||||
if _handler:_handler.Open()
|
||||
return
|
||||
if not _wire:return
|
||||
if sub==4:_rows=[]
|
||||
elif sub==3 and len(_rows)<4096 and vnum>0 and count>0:_rows.append((name,vnum,prob,count))
|
||||
elif sub in (5,6):
|
||||
request=_wire;_wire=None;rows=_rows;_rows=[]
|
||||
if sub==6:
|
||||
for cb in request['callbacks']:cb(None)
|
||||
elif not request['failed']:
|
||||
_cache[request['key']]=rows;_cacheTime[request['key']]=app.GetTime()
|
||||
for cb in request['callbacks']:cb(rows)
|
||||
|
||||
def Read(kind,vnum):
|
||||
key=(kind,int(vnum))
|
||||
if key not in _cache or app.GetTime()-_cacheTime.get(key,0)>=30:
|
||||
def ready(rows):
|
||||
if rows is not None and _refresh:_refresh()
|
||||
Query(kind,vnum,ready)
|
||||
return _cache.get(key,[])
|
||||
|
||||
def Reverse(vnum,refined,chest):
|
||||
return sorted(set(r[1] for r in Read((10 if refined else 8) if chest else (9 if refined else 1),vnum)))
|
||||
|
||||
def SearchItem(vnum):
|
||||
global _data,_searchSerial
|
||||
_data=[];_searchSerial+=1;serial=_searchSerial
|
||||
def ready(rows):
|
||||
global _data
|
||||
if serial!=_searchSerial:return
|
||||
if rows is None:
|
||||
if _handler and hasattr(_handler,'NativeQueryFailed'):_handler.NativeQueryFailed()
|
||||
return
|
||||
_data=rows
|
||||
if _handler:_handler.BINARY_DROP_ITEM_LOADING()
|
||||
Query(1,vnum,ready)
|
||||
|
||||
def Handler(obj):
|
||||
global _handler
|
||||
_handler=weakref.proxy(obj) if obj else None
|
||||
|
||||
def Page(value):
|
||||
global _page
|
||||
_page=max(1,int(value))
|
||||
|
||||
def Clear():
|
||||
global _wire,_handler,_data,_rows,_refresh,_searchSerial
|
||||
_searchSerial+=1;_pending[:]=[];_wire=None;_handler=None;_data=[];_rows=[];_refresh=None;_cache.clear();_cacheTime.clear()
|
||||
|
||||
wiki=types.ModuleType('wiki');sys.modules['wiki']=wiki
|
||||
wiki.GetCategorySize=lambda j,k:len(Categories(j,k))
|
||||
wiki.GetCategoryData=lambda j,k,i:Choose(Categories(j,k),i)
|
||||
wiki.GetCostumeSize=lambda k:len(Costumes(k))
|
||||
wiki.GetCostumeData=lambda k,i:Choose(Costumes(k),i)
|
||||
wiki.GetChestSize=lambda k:len(Chests(k))
|
||||
wiki.GetChestData=lambda k,i:(Choose(Chests(k),i),0)
|
||||
for kind in ('Boss','Monster','Stone'):
|
||||
setattr(wiki,'Get'+kind+'Size',lambda g,k=kind:len(Monsters(k,g)))
|
||||
setattr(wiki,'Get'+kind+'Data',lambda g,i,k=kind:Choose(Monsters(k,g),i))
|
||||
wiki.GetRefineMaxLevel=RefineLevel
|
||||
wiki.GetRefineItems=RefineItems
|
||||
wiki.GetMobInfoSize=lambda v:len(Read(6,v))
|
||||
wiki.GetMobInfoData=lambda v,i:tuple(Choose(Read(6,v),i,('',0,0,0))[j] for j in (1,3))
|
||||
wiki.GetSpecialInfoSize=lambda v:len(Read(7,v))
|
||||
wiki.GetSpecialInfoData=lambda v,i:tuple(Choose(Read(7,v),i,('',0,0,0))[j] for j in (1,3))
|
||||
wiki.GetItemDropFromChest=lambda v,r=False:Reverse(v,r,True)
|
||||
wiki.GetItemDropFromMonster=lambda v,r=False:Reverse(v,r,False)
|
||||
item.GetNames=lambda:tuple({'vnum':v,'name':L(r['name'].encode('utf-8'))} for v,r in sorted(Load().items.items()))
|
||||
item.GetItemsByName=lambda text:Matches(Load().items,text)
|
||||
nonplayer.GetMobsByName=lambda text:Matches(Load().mobs,text)
|
||||
nonplayer.IsMonsterStone=lambda v:bool(Load().mobs.get(v,{}).get('kind')=='STONE')
|
||||
sys.modules.setdefault('uiWiki',types.ModuleType('uiWiki')) # WikiUI and uiWiki import each other in AVA2.
|
||||
drop=types.ModuleType('drop_item');sys.modules['drop_item']=drop
|
||||
drop.SetDropItemHandler=Handler;drop.SearchItem=SearchItem
|
||||
drop.Open=lambda:net.SendAva2DropQuery(0,0)
|
||||
drop.CountDates=lambda:len(_data)
|
||||
drop.GetDates=lambda i:Choose(_data,i,('None',0,0,0))
|
||||
drop.GetPageView=lambda:5;drop.SetPageSelect=Page;drop.GetPageActual=lambda:_page
|
||||
|
||||
)PY";
|
||||
@@ -0,0 +1,351 @@
|
||||
// Native AVA2 interface integration; real server state and session cleanup.
|
||||
static const char c_szAva2NativeInterfacesScript[]=R"PY(# -*- coding: utf-8 -*-
|
||||
import app,chat,chr,constInfo,datetime,game,item,localeInfo,net,pack,player,struct,ui,uiCommon,weakref
|
||||
import mt_battlepass,mt_calendar,mt_wiki,mt_ava2_native_data as data
|
||||
import uiBattlePassEx as battle,uiEventCalendarNew as calendar,uiWiki as encyclopedia,WikiUI
|
||||
from mt_biolog import L
|
||||
bp=None;cal=None;icon=None;book=None;finder=None;_selected=None;_calNext=0;_calWaiting=False;_calTime=0;_period=0;_bpNext=0;_bpTries=0;_bpReady=False;_calError=False
|
||||
|
||||
# Date labels follow the synchronized server period/UTC schedule, never the desktop clock.
|
||||
class BattleDate:
|
||||
@staticmethod
|
||||
def today():
|
||||
p=_period
|
||||
return datetime.datetime(p//100,p%100,1) if 200001<=p<=299912 and 1<=p%100<=12 else datetime.datetime.utcfromtimestamp(app.GetGlobalTimeStamp())
|
||||
class CalendarDate:
|
||||
@staticmethod
|
||||
def today():return datetime.datetime.utcfromtimestamp(app.GetGlobalTimeStamp())
|
||||
battle.datetime=type('NativeDate',(),{'datetime':BattleDate})
|
||||
calendar.datetime=type('NativeDate',(),{'datetime':CalendarDate})
|
||||
calendar.events_default_data[20]=['item_drop_event',L('圣诞袜掉落')]
|
||||
localeInfo.NumberToMoneyStringNEW=lambda n:format(int(n),',')
|
||||
for key,text in {'TARGET_INFO_RESIST_BELL':'铃铛抗性','TARGET_INFO_RESIST_BOW':'弓箭抗性','TARGET_INFO_RESIST_DAGGER':'匕首抗性','TARGET_INFO_RESIST_FAN':'扇子抗性','TARGET_INFO_RESIST_MAGIC':'魔法抗性','TARGET_INFO_RESIST_SWORD':'剑术抗性','TARGET_INFO_RESIST_TWOHAND':'双手武器抗性'}.items():setattr(localeInfo,key,L(text+':%d%%'))
|
||||
|
||||
# Keep the original finder interactions while localizing its literal Worldard labels.
|
||||
import uiDropItem
|
||||
_dropLoad=uiDropItem.DropItemWindows.LoadWindow
|
||||
_dropInfo=uiDropItem.DropItemWindows.LoadInfo
|
||||
_dropReady=uiDropItem.DropItemWindows.BINARY_DROP_ITEM_LOADING
|
||||
_dropSearch=uiDropItem.DropItemWindows.SearchItem
|
||||
def DropValue(self):
|
||||
ui.EditLine.OnIMEUpdate(self.ItemNameValue)
|
||||
text=self.ItemNameValue.GetText().strip();self.get_vnum=-1
|
||||
dropdown=self.DropDownList;dropdown.Clear()
|
||||
matches=[row for row in uiDropItem.ITEM_LIST if text and (row['name'].lower().startswith(text.lower()) or str(row['vnum'])==text)][:10]
|
||||
for row in matches:
|
||||
dropdown.AppendItem(row['name'],row['vnum'])
|
||||
if str(row['vnum'])==text or row['name'].lower()==text.lower():self.get_vnum=row['vnum']
|
||||
dropdown.DropList.SetViewItemCount(len(matches));dropdown.DropList.SetBasePos(0)
|
||||
dropdown.dropped=int(bool(matches))
|
||||
if matches:dropdown.Show()
|
||||
else:dropdown.Hide()
|
||||
def DropSearch(self):
|
||||
if self.get_vnum<=0:return
|
||||
import renderTarget
|
||||
renderTarget.SetVisibility(self.RENDER_TARGET_INDEX,False)
|
||||
self.ModelRender.Hide();self.ModelName1.SetText('');self.ModelName2.SetText('');data._data=[]
|
||||
self.LoadInfo();self.TotalResultados.SetText(L('查询中…'));self.TotalResultados.Show()
|
||||
_dropSearch(self)
|
||||
def DropReady(self):
|
||||
_dropReady(self);self.TotalResultados.SetText(L('共 %d 条')%max(0,self.total_dates))
|
||||
self.TotalPages.SetText('%d/%d'%(1 if not self.total_dates else self.page_actual,max(1,(self.total_dates+self.pages_view-1)//self.pages_view)))
|
||||
def DropFailed(self):self.TotalResultados.SetText(L('查询失败,请重试或重新连接'))
|
||||
uiDropItem.DropItemWindows._DropItemWindows__OnValueUpdate=DropValue
|
||||
uiDropItem.DropItemWindows.SearchItem=DropSearch
|
||||
uiDropItem.DropItemWindows.BINARY_DROP_ITEM_LOADING=DropReady
|
||||
uiDropItem.DropItemWindows.NativeQueryFailed=DropFailed
|
||||
def DropLoad(self):
|
||||
_dropLoad(self)
|
||||
self.GetChild('TitleName').SetText(L('掉落查询'))
|
||||
self.ButtonSearch.SetToolTipText(L('查询掉落来源'))
|
||||
self.ButtonDelete.SetToolTipText(L('清空查询'))
|
||||
def DropInfo(self):
|
||||
_dropInfo(self)
|
||||
for index in xrange(min(self.pages_view,max(0,self.total_dates-(self.page_actual-1)*self.pages_view))):
|
||||
row=index+(self.page_actual-1)*self.pages_view
|
||||
self.ButtonsSelect['Cantidad_Item_%d'%index].SetText(L('数量:%d')%self.FReturnInfo('count_item',row))
|
||||
self.TotalResultados.SetText(L('共 %d 条')%max(0,self.total_dates))
|
||||
uiDropItem.DropItemWindows.LoadWindow=DropLoad
|
||||
uiDropItem.DropItemWindows.LoadInfo=DropInfo
|
||||
|
||||
# The classic text renderer has no AVA2 inline-emoji markup. Preserve the list bullet
|
||||
# in the native wiki's two text builders rather than exposing markup to the player.
|
||||
def WikiTextBuilder(original):
|
||||
def append(self,box,text,x,y):return original(self,box,text.replace('|Eemoji/e_wiki|e',L('·')),x,y)
|
||||
return append
|
||||
encyclopedia.MonsterItemSpecial.AppendTextLine=WikiTextBuilder(encyclopedia.MonsterItemSpecial.AppendTextLine)
|
||||
encyclopedia.MonsterStatics.AppendTextLine=WikiTextBuilder(encyclopedia.MonsterStatics.AppendTextLine)
|
||||
for name,text in {'ANIMAL':'动物','DARK':'黑暗','DEVIL':'恶魔','EARTH':'大地','ELEC':'雷电','FIRE':'火焰','HUMAN':'半人','ICE':'冰霜','METIN':'陨石','MILGYO':'密教','ORC':'鬼族','UNDEAD':'亡灵','WIND':'风','ZODIAC':'黄道'}.items():setattr(localeInfo,'TARGET_INFO_RACE_'+name,L(text))
|
||||
|
||||
def ArticleOpen(name,mode='r'):
|
||||
import cStringIO
|
||||
return cStringIO.StringIO(pack.Get(name))
|
||||
encyclopedia.open=ArticleOpen
|
||||
# Preview only model types implemented by the current renderer; no empty fake model.
|
||||
import mt_preview
|
||||
WikiUI.IsCanModelPreview=lambda v:mt_preview.Previewable('item',v)
|
||||
|
||||
def RealVnum(vnum):
|
||||
catalogue=data.Load();base=vnum;seen=set()
|
||||
while base in data._parents and base not in seen:
|
||||
seen.add(base);base=data._parents[base]
|
||||
current=base;seen=set()
|
||||
while current and current not in seen:
|
||||
seen.add(current);record=catalogue.FindItem(current)
|
||||
if not record:return vnum,False
|
||||
following=record['refined']
|
||||
# Native EquipmentItem uses contiguous IDs; non-contiguous stones have no such recipe table.
|
||||
if following and following!=current+1:return vnum,False
|
||||
current=following
|
||||
return (base,True) if len(seen)>1 else (vnum,False)
|
||||
WikiUI.getRealVnum=RealVnum
|
||||
|
||||
class NativePass(battle.BattlePassWindow):
|
||||
def __init__(self):
|
||||
self.confirm=None;self.pendingTicket=None
|
||||
battle.BattlePassWindow.__init__(self)
|
||||
def Toggle(self):self.Close() if self.IsShow() else self.Open()
|
||||
def Open(self):
|
||||
self.isSendPacket=False
|
||||
battle.BattlePassWindow.Open(self)
|
||||
def Close(self):
|
||||
self.CloseConfirm();self.pendingTicket=None
|
||||
if self.IsShow():net.SendChatPacket('/battle_pass close')
|
||||
battle.BattlePassWindow.Close(self)
|
||||
def CloseConfirm(self):
|
||||
if self.confirm:
|
||||
self.confirm.Close();self.confirm.SetAcceptEvent(None);self.confirm.SetCancelEvent(None);self.confirm=None
|
||||
def OfferTicket(self,cell,vnum):
|
||||
self.pendingTicket=(cell,vnum);self.Open()
|
||||
def AskTicket(self,cell,vnum):
|
||||
if self.battlePassStatus!=0 or player.GetItemIndex(cell)!=vnum:return
|
||||
self.CloseConfirm();q=uiCommon.QuestionDialog();self.confirm=q
|
||||
q.SetText(L('消耗战令票并激活本月战令?'))
|
||||
def accept():
|
||||
self.CloseConfirm()
|
||||
if player.GetItemIndex(cell)==vnum:net.SendChatPacket('/battle_pass activate %d %d'%(cell,vnum))
|
||||
q.SetAcceptEvent(accept);q.SetCancelEvent(self.CloseConfirm);q.Open()
|
||||
def ClickShop(self):
|
||||
# The original button opens AVA2's cash shop 15; current tickets already use
|
||||
# the inventory confirmation flow, so it selects the actual current ticket.
|
||||
month=_period%100
|
||||
for cell in xrange(player.INVENTORY_PAGE_SIZE*player.INVENTORY_PAGE_COUNT):
|
||||
vnum=player.GetItemIndex(cell)
|
||||
if 25150<=vnum<=25161:
|
||||
item.SelectItem(vnum)
|
||||
if item.GetValue(0)==month:self.AskTicket(cell,vnum);return
|
||||
chat.AppendChat(chat.CHAT_TYPE_INFO,L('请先获得当月战令票,再使用它激活。'))
|
||||
|
||||
def Pass():
|
||||
global bp
|
||||
if bp is None:
|
||||
bp=NativePass();bp.Hide()
|
||||
interface=constInfo.GetInterfaceInstance()
|
||||
if interface:interface.wndBattlePassEx=bp
|
||||
return bp
|
||||
|
||||
class PassFacade:
|
||||
def Toggle(self):Pass().Toggle()
|
||||
def IsShow(self):return bool(bp and bp.IsShow())
|
||||
def Hide(self):
|
||||
if bp:bp.Close()
|
||||
def OfferTicket(self,cell,vnum):Pass().OfferTicket(cell,vnum)
|
||||
def Destroy(self):
|
||||
global bp
|
||||
if bp:bp.Close();bp.Destroy();bp=None
|
||||
|
||||
def CalendarWindow():
|
||||
global cal
|
||||
if cal is None:
|
||||
cal=calendar.EventCalendarWindow();cal.Hide()
|
||||
interface=constInfo.GetInterfaceInstance()
|
||||
if interface:interface.wndEventManager=cal
|
||||
if _calError:cal.SetTitleName(L('活动日历 · 排期暂不可用'))
|
||||
return cal
|
||||
|
||||
def CalendarToggle():
|
||||
global _calNext
|
||||
wnd=CalendarWindow()
|
||||
if wnd.IsShow():wnd.Close()
|
||||
else:wnd.Open();_calNext=0
|
||||
|
||||
def RefreshCalendar(now):
|
||||
global cal,icon
|
||||
date=datetime.datetime.utcfromtimestamp(now)
|
||||
if calendar.server_event_data:CalendarWindow()
|
||||
if cal:
|
||||
if (cal.currentYear,cal.currentMonth)!=(date.year,date.month):
|
||||
shown=cal.IsShow();cal.Close();cal.Destroy();cal=None;CalendarWindow()
|
||||
if shown:cal.Open()
|
||||
cal.SetTitleName(L('活动日历 · %d年%d月')%(date.year,date.month));cal.Refresh()
|
||||
if calendar.server_event_data and icon is None:
|
||||
icon=calendar.MovableImage()
|
||||
interface=constInfo.GetInterfaceInstance()
|
||||
if interface:interface.wndEventIcon=icon
|
||||
if icon:icon.Refresh()
|
||||
|
||||
|
||||
def Wiki():
|
||||
global book
|
||||
if book is None:
|
||||
book=encyclopedia.EncyclopediaofGame()
|
||||
def entry(x,label,callback):
|
||||
button=ui.MakeButton(book,x,7,L(label),'d:/ymir work/ui/public/','small_button_01.sub','small_button_02.sub','small_button_03.sub')
|
||||
button.SetText(L(label));button.SetEvent(callback);return button
|
||||
book.nativeCalendar=entry(book.GetWidth()-180,'活动日历',CalendarToggle)
|
||||
book.nativeDrops=entry(book.GetWidth()-110,'掉落查询',DropToggle)
|
||||
return book
|
||||
|
||||
def DropToggle():
|
||||
global finder
|
||||
if finder is None:
|
||||
import uiDropItem
|
||||
# The archived Worldard destructor re-registers its window. Use the normal
|
||||
# ScriptWindow destructor, and its actual native Show path instead.
|
||||
uiDropItem.DropItemWindows.__del__=ui.ScriptWindow.__del__
|
||||
uiDropItem.DropItemWindows.Open=lambda self:self.Show()
|
||||
finder=uiDropItem.DropItemWindows();finder.Hide()
|
||||
if finder.IsShow():finder.Close()
|
||||
else:finder.Show();finder.SetTop()
|
||||
|
||||
_showInfo=encyclopedia.EncyclopediaofGame.ShowItemInfo
|
||||
def WikiShowInfo(self,vnum,arg,isHistory=True):
|
||||
global _selected
|
||||
_selected=(vnum,arg) if arg in (0,1) else None
|
||||
return _showInfo(self,vnum,arg,isHistory)
|
||||
encyclopedia.EncyclopediaofGame.ShowItemInfo=WikiShowInfo
|
||||
|
||||
def RefreshBook():
|
||||
if book and _selected and book.IsShow() and not book.selectArg:
|
||||
scroll=book.children['resultpageListboxScrollbar'];position=scroll.GetPos()
|
||||
book.ShowItemInfo(_selected[0],_selected[1],False);scroll.SetPos(position)
|
||||
data._refresh=RefreshBook
|
||||
|
||||
def Show(vnum,arg):
|
||||
global _selected
|
||||
wnd=Wiki();wnd.Open();_selected=(vnum,arg);wnd.ShowItemInfo(vnum,arg)
|
||||
|
||||
class WikiFacade:
|
||||
def __init__(self):self.catalogue=None
|
||||
def Load(self):self.catalogue=data.Load()
|
||||
def IsShow(self):return bool(book and book.IsShow())
|
||||
def Hide(self):
|
||||
if book:book.Close()
|
||||
def Open(self,vnum=0):
|
||||
self.Load()
|
||||
if vnum:Show(vnum,0)
|
||||
else:Wiki().Open()
|
||||
def Select(self,mode,row):Show(row['id'],1 if mode=='mobs' else 0)
|
||||
def QueryRemote(self,kind,vnum,offset=0):
|
||||
if kind in ('mob','chest','sources'):Show(vnum,1 if kind=='mob' else 0)
|
||||
def Destroy(self):
|
||||
global book
|
||||
if book:book.Close();book.Destroy();book=None
|
||||
constInfo.SetMainParent(None);constInfo.SetListBox(None)
|
||||
|
||||
_event=struct.Struct('<HB I I BB 4I BB 25s25s')
|
||||
def Events(self,raw):
|
||||
global _calNext,_calWaiting,_calTime,cal,_calError
|
||||
# Parse atomically before replacing visible data, including byte counts and duplicate IDs.
|
||||
try:
|
||||
if not 6<=len(raw)<=32763:raise ValueError('length')
|
||||
sub,count,now=struct.unpack_from('<BBI',raw)
|
||||
if sub!=0 or count>31:raise ValueError('header')
|
||||
offset=6;nextData={};ids=set()
|
||||
for unused in xrange(count):
|
||||
day,size=struct.unpack_from('<BB',raw,offset);offset+=2
|
||||
if not 1<=day<=31 or day in nextData:raise ValueError('day')
|
||||
rows={};nextData[day]=rows
|
||||
for i in xrange(size):
|
||||
values=_event.unpack_from(raw,offset);offset+=_event.size
|
||||
eid,kind,start,end,empire,channel=values[:6]
|
||||
if not eid or eid in ids or kind not in calendar.events_default_data or not start<end or empire>3 or values[10] not in (0,1) or values[11] not in (0,1):raise ValueError('event')
|
||||
ids.add(eid)
|
||||
begin=values[12].split(b'\0',1)[0];finish=values[13].split(b'\0',1)[0]
|
||||
# Exact field order expected by native SetServerData / tooltip.
|
||||
rows[eid]=[day,eid,kind,begin,finish,empire,channel]+list(values[6:10])+[start,end,bool(values[10])]
|
||||
if offset!=len(raw):raise ValueError('trailing')
|
||||
except (ValueError,struct.error):
|
||||
chat.AppendChat(chat.CHAT_TYPE_INFO,L('活动排期数据无效,请重新打开日历。'));return
|
||||
calendar.server_event_data=nextData;_calTime=now;_calWaiting=False;_calNext=app.GetTime()+15
|
||||
_calError=False;RefreshCalendar(now)
|
||||
|
||||
_open=game.GameWindow.Open;_close=game.GameWindow.Close;_command=game.GameWindow.BINARY_ServerCommand_Run;_update=game.GameWindow.OnUpdate
|
||||
|
||||
def Open(self):
|
||||
global bp,_period,_calNext,_bpNext,_bpTries,_bpReady,_calError
|
||||
_open(self)
|
||||
if mt_battlepass.g_window:mt_battlepass.g_window.Destroy()
|
||||
bp=None;mt_battlepass.g_window=PassFacade();mt_battlepass.g_pass.listener=None
|
||||
if mt_wiki.g_window:mt_wiki.g_window.Destroy()
|
||||
mt_wiki.g_window=WikiFacade()
|
||||
_period=0;_calError=False;_calNext=app.GetTime()+1;_bpNext=app.GetTime()+1;_bpTries=0;_bpReady=False
|
||||
data._refresh=RefreshBook
|
||||
self.interface.wndBattlePassEx=bp
|
||||
self.interface.OpenBattlePass=lambda:Pass().Toggle()
|
||||
self.interface.OpenWikiWindow=lambda:mt_wiki.Toggle()
|
||||
self.interface.OpenEventCalendar=CalendarToggle
|
||||
# Both calendar and drop finder have native entry points, also accessible on desktop keys.
|
||||
keys=getattr(self,'onPressKeyDict',{})
|
||||
if app.DIK_F7 not in keys:keys[app.DIK_F7]=CalendarToggle
|
||||
|
||||
def Close(self):
|
||||
global bp,cal,icon,book,finder,_selected,_calWaiting
|
||||
if bp:bp.Close()
|
||||
if cal:cal.Close();cal.Destroy();cal=None
|
||||
if icon:icon.Clear();icon.Destroy();icon=None
|
||||
if finder:finder.Close();finder=None
|
||||
_selected=None;_calWaiting=False;calendar.server_event_data={};data.Clear()
|
||||
result=_close(self);bp=None;book=None
|
||||
return result
|
||||
|
||||
def Update(self):
|
||||
global _calNext,_calWaiting,_bpNext,_bpTries
|
||||
_update(self);data.Tick()
|
||||
if not _bpReady and _bpTries<3 and app.GetTime()>=_bpNext:
|
||||
net.SendChatPacket('/battle_pass info');_bpTries+=1;_bpNext=app.GetTime()+2.25
|
||||
if app.GetTime()>=_calNext:
|
||||
net.SendChatPacket('/event_manager info');_calWaiting=True;_calNext=app.GetTime()+15
|
||||
|
||||
def Command(self,line):
|
||||
global _period,_calWaiting,_calNext,_bpReady,_calError
|
||||
words=line.split()
|
||||
if not words:return _command(self,line)
|
||||
name=words[0]
|
||||
if name=='EventCalendarError':
|
||||
wasError=_calError;_calError=True
|
||||
calendar.server_event_data={};_calWaiting=False;_calNext=app.GetTime()+15
|
||||
if icon:icon.Clear()
|
||||
if cal:cal.Refresh();cal.SetTitleName(L('活动日历 · 排期暂不可用'))
|
||||
if not wasError and cal and cal.IsShow():chat.AppendChat(chat.CHAT_TYPE_INFO,L('服务器尚未发布有效活动排期。'))
|
||||
return 1
|
||||
if name=='BattlePassPeriod' and len(words)==2:
|
||||
try:_period=int(words[1])
|
||||
except ValueError:pass
|
||||
return 1
|
||||
if name.startswith('BattlePass'):
|
||||
Pass()
|
||||
try:
|
||||
if name=='BattlePassClear' and len(words)==1:bp.BattlePassClear()
|
||||
elif name=='BattlePassSetStatusEx' and len(words)==2:bp.SetBattlePassStatusEx(int(words[1]))
|
||||
elif name=='BattlePassSetStatus' and len(words)==4:
|
||||
_bpReady=True
|
||||
bp.SetBattlePassStatus(int(words[1]),int(words[2]),'' if words[3]=='Empty' else words[3])
|
||||
if bp.pendingTicket:
|
||||
ticket=bp.pendingTicket;bp.pendingTicket=None;bp.AskTicket(*ticket)
|
||||
elif name=='BattlePassSetMission' and len(words)==3:bp.SetMission(int(words[1]),int(words[2]))
|
||||
elif name=='BattlePassAppendMission' and len(words)==7:bp.AppendMission(int(words[1]),words[2],int(words[3]),int(words[4]),int(words[5]),int(words[6]))
|
||||
except (ValueError,IndexError):chat.AppendChat(chat.CHAT_TYPE_INFO,L('战令数据暂不可用,请重新打开。'))
|
||||
return 1
|
||||
if name=='MTBP1':
|
||||
if len(words)==3 and words[1]=='error':chat.AppendChat(chat.CHAT_TYPE_INFO,L(mt_battlepass.ERRORS.get(words[2],'战令操作失败')))
|
||||
return 1
|
||||
return _command(self,line)
|
||||
|
||||
mt_calendar.Toggle=CalendarToggle
|
||||
game.GameWindow.Open=Open;game.GameWindow.Close=Close;game.GameWindow.OnUpdate=Update
|
||||
game.GameWindow.BINARY_ServerCommand_Run=Command
|
||||
game.GameWindow.BINARY_Ava2Events=Events
|
||||
game.GameWindow.BINARY_Ava2Drop=lambda self,*args:data.Receive(*args)
|
||||
|
||||
)PY";
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,459 @@
|
||||
// PORT: AVA2 ui.py additions shared by native feature windows; keep base scripts unchanged.
|
||||
static const char c_szAva2UICompatScript[] = R"PY(# -*- coding: utf-8 -*-
|
||||
import ui
|
||||
|
||||
# AVA2 Button.SetListText / PythonScriptLoader.LoadElementButton text_x branch.
|
||||
def SetListText(self,text,x=8):
|
||||
if not self.ButtonText:
|
||||
textLine=ui.TextLine()
|
||||
textLine.SetParent(self)
|
||||
textLine.Show()
|
||||
self.ButtonText=textLine
|
||||
self.ButtonText.SetPosition(x,self.GetHeight()/2)
|
||||
self.ButtonText.SetVerticalAlignCenter()
|
||||
self.ButtonText.SetHorizontalAlignLeft()
|
||||
self.ButtonText.SetWindowHorizontalAlignLeft()
|
||||
self.ButtonText.SetText(text)
|
||||
ui.Button.SetListText=SetListText
|
||||
_loadButton=ui.PythonScriptLoader.LoadElementButton
|
||||
def LoadElementButton(self,window,value,parent):
|
||||
result=_loadButton(self,window,value,parent)
|
||||
if 'text' in value and 'text_x' in value and 'text_height' not in value:
|
||||
window.SetListText(value['text'],value['text_x'])
|
||||
return result
|
||||
ui.PythonScriptLoader.LoadElementButton=LoadElementButton
|
||||
|
||||
# AVA2 tracker list/text primitives and the two original loader branches.
|
||||
# The existing loader remains unchanged for all other element types.
|
||||
exec(r"""
|
||||
class ListBoxNew(Window):
|
||||
def __del__(self):
|
||||
Window.__del__(self)
|
||||
def Destroy(self):
|
||||
for item in self.itemList:
|
||||
item.Destroy()
|
||||
self.itemList=[]
|
||||
self.scrollBar=None
|
||||
self.basePos=0
|
||||
self.scrollLen=0
|
||||
self.scrollLenExtra=0
|
||||
self.isHorizontal= 0
|
||||
def __init__(self, isHorizontal = False):
|
||||
Window.__init__(self)
|
||||
self.itemList=[]
|
||||
self.Destroy()
|
||||
self.isHorizontal= isHorizontal
|
||||
def RemoveAllItems(self):
|
||||
for item in self.itemList:
|
||||
item.Destroy()
|
||||
self.itemList=[]
|
||||
if self.scrollBar:
|
||||
self.scrollBar.SetPos(0)
|
||||
self.RefreshAll()
|
||||
def SetExtraScrollLen(self, extraLen):
|
||||
self.scrollLenExtra=extraLen
|
||||
def GetItems(self):
|
||||
return self.itemList
|
||||
def AppendItem(self, newItem):
|
||||
self.itemList.append(newItem)
|
||||
self.RefreshAll()
|
||||
def SetScrollBar(self, scrollBar):
|
||||
scrollBar.SetScrollEvent(__mem_func__(self.__OnScroll))
|
||||
self.scrollBar=scrollBar
|
||||
def OnMouseWheel(self, nLen):
|
||||
if self.scrollBar:
|
||||
if self.scrollBar.IsShow():
|
||||
if nLen > 0:
|
||||
self.scrollBar.OnUp()
|
||||
else:
|
||||
self.scrollBar.OnDown()
|
||||
return True
|
||||
return False
|
||||
def __OnScroll(self):
|
||||
self.SetBasePos(int(self.scrollBar.GetPos()*self.scrollLen))
|
||||
def RefreshAll(self):
|
||||
windowHeight = self.GetHeight()
|
||||
scrollBar = self.scrollBar
|
||||
screenSize = 0
|
||||
for child in self.itemList:
|
||||
if child.exPos[1]+child.GetHeight() > screenSize:
|
||||
screenSize = child.exPos[1]+child.GetHeight()
|
||||
if screenSize > windowHeight:
|
||||
scrollLen = screenSize-windowHeight
|
||||
if scrollLen != 0:
|
||||
scrollLen += self.scrollLenExtra
|
||||
self.scrollLen = scrollLen
|
||||
scrollBar.SetMiddleBarSize(float(windowHeight-5)/float(screenSize))
|
||||
else:
|
||||
scrollBar.SetMiddleBarSize(1.0)
|
||||
def Render(self,basePos):
|
||||
for item in self.itemList:
|
||||
(ex,ey) = item.exPos
|
||||
if self.isHorizontal:
|
||||
item.SetPosition(ex-(basePos), ey)
|
||||
else:
|
||||
item.SetPosition(ex, ey-(basePos))
|
||||
item.OnRender()
|
||||
def SetBasePos(self, basePos):
|
||||
if self.basePos == basePos:
|
||||
return
|
||||
self.Render(basePos)
|
||||
self.basePos=basePos
|
||||
|
||||
class MultiTextLineNew(Window):
|
||||
def __del__(self):
|
||||
Window.__del__(self)
|
||||
def Destroy(self):
|
||||
self.textRules = {}
|
||||
def __init__(self):
|
||||
Window.__init__(self)
|
||||
self.Destroy()
|
||||
self.AddFlag("not_pick")
|
||||
self.textRules["textRange"] = 15
|
||||
self.textRules["text"] = ""
|
||||
self.textRules["textType"] = ""
|
||||
self.textRules["fontName"] = ""
|
||||
self.textRules["hexColor"] = 0
|
||||
self.textRules["fontColor"] = 0
|
||||
self.textRules["outline"] = 0
|
||||
def SetTextType(self, textType):
|
||||
self.textRules["textType"] = textType
|
||||
self.Refresh()
|
||||
def SetTextRange(self, textRange):
|
||||
self.textRules["textRange"] = textRange
|
||||
self.Refresh()
|
||||
def SetOutline(self, outline):
|
||||
self.textRules["outline"] = outline
|
||||
self.Refresh()
|
||||
def SetPackedFontColor(self, hexColor):
|
||||
self.textRules["hexColor"] = hexColor
|
||||
self.Refresh()
|
||||
def SetFontColor(self, r, g, b):
|
||||
self.textRules["fontColor"] =[r, g, b]
|
||||
self.Refresh()
|
||||
def SetFontName(self, fontName):
|
||||
self.textRules["fontName"] = fontName
|
||||
self.Refresh()
|
||||
def SetText(self, newText):
|
||||
self.textRules["text"] = newText
|
||||
self.Refresh()
|
||||
def Refresh(self):
|
||||
textRules = self.textRules
|
||||
self.children=[]
|
||||
|
||||
outline = textRules["outline"]
|
||||
fontColor = textRules["fontColor"]
|
||||
hexColor = textRules["hexColor"]
|
||||
yRange = textRules["textRange"]
|
||||
fontName = textRules["fontName"]
|
||||
textType = textRules["textType"].split("#")
|
||||
totalTextList = textRules["text"].split("#")
|
||||
|
||||
(xPosition, yPosition) = (0, 0)
|
||||
|
||||
for text in totalTextList:
|
||||
childText = TextLine()
|
||||
childText.SetParent(self)
|
||||
childText.AddFlag("not_pick")
|
||||
childText.SetPosition(xPosition, yPosition)
|
||||
if fontName != "":
|
||||
childText.SetFontName(fontName)
|
||||
if hexColor != 0:
|
||||
childText.SetPackedFontColor(hexColor)
|
||||
if fontColor != 0:
|
||||
childText.SetFontColor(*fontColor)
|
||||
if outline:
|
||||
childText.SetOutline()
|
||||
self.AddTextType(childText, textType)
|
||||
childText.SetText(str(text))
|
||||
childText.Show()
|
||||
self.children.append(childText)
|
||||
yPosition+=yRange
|
||||
self.CheckTexType(self.children, textType, yPosition)
|
||||
def AddTextType(self, text, typeArg):
|
||||
if len(typeArg) != 2:
|
||||
return
|
||||
_typeDict = {
|
||||
"vertical":{
|
||||
"top":text.SetVerticalAlignTop,
|
||||
"bottom":text.SetVerticalAlignBottom,
|
||||
"center":text.SetVerticalAlignCenter,
|
||||
},
|
||||
"horizontal":{
|
||||
"top":text.SetHorizontalAlignLeft,
|
||||
"bottom":text.SetHorizontalAlignRight,
|
||||
"center":text.SetHorizontalAlignCenter,
|
||||
},
|
||||
"all_align":{
|
||||
"1" : [text.SetHorizontalAlignCenter,text.SetVerticalAlignCenter,text.SetWindowHorizontalAlignCenter,text.SetWindowVerticalAlignCenter],
|
||||
},
|
||||
}
|
||||
(firstToken, secondToken) = tuple(typeArg)
|
||||
if _typeDict.has_key(firstToken):
|
||||
textType = _typeDict[firstToken][secondToken] if _typeDict[firstToken].has_key(secondToken) else None
|
||||
if textType != None:
|
||||
if isinstance(textType, list):
|
||||
for rule in textType:
|
||||
rule()
|
||||
else:
|
||||
textType()
|
||||
def CheckTexType(self, textList, typeArg, yMax):
|
||||
if len(typeArg) != 2:
|
||||
return
|
||||
elif typeArg[1] != "center":
|
||||
return
|
||||
width = 0
|
||||
for text in textList:
|
||||
if text.GetTextSize()[0] > width:
|
||||
width = text.GetTextSize()[0]
|
||||
centerWidth = width / 2
|
||||
#for text in textList:
|
||||
# text.SetPosition(centerWidth, text.GetLocalPosition()[1])
|
||||
|
||||
self.SetSize(width, yMax)
|
||||
def LoadChildren(self, parent, dicChildren):
|
||||
|
||||
if localeInfo.IsARABIC():
|
||||
parent.AddFlag( "rtl" )
|
||||
|
||||
if True == dicChildren.has_key("style"):
|
||||
for style in dicChildren["style"]:
|
||||
parent.AddFlag(style)
|
||||
|
||||
if False == dicChildren.has_key("children"):
|
||||
return False
|
||||
|
||||
Index = 0
|
||||
|
||||
ChildrenList = dicChildren["children"]
|
||||
parent.Children = range(len(ChildrenList))
|
||||
for ElementValue in ChildrenList:
|
||||
try:
|
||||
Name = ElementValue["name"]
|
||||
except KeyError:
|
||||
Name = ElementValue["name"] = "NONAME"
|
||||
|
||||
try:
|
||||
Type = ElementValue["type"]
|
||||
except KeyError:
|
||||
Type = ElementValue["type"] = "window"
|
||||
|
||||
if False == self.CheckKeyList(Name, ElementValue, self.DEFAULT_KEY_LIST):
|
||||
del parent.Children[Index]
|
||||
continue
|
||||
|
||||
if Type == "window":
|
||||
parent.Children[Index] = ScriptWindow()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementWindow(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "render_target":
|
||||
parent.Children[Index] = RenderTarget()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementWindow(parent.Children[Index], ElementValue, parent)
|
||||
parent.Children[Index].SetRenderTarget(int(ElementValue["index"]))
|
||||
|
||||
elif Type == "button":
|
||||
parent.Children[Index] = Button()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementButton(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "radio_button":
|
||||
parent.Children[Index] = RadioButton()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementButton(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "toggle_button":
|
||||
parent.Children[Index] = ToggleButton()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementButton(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "mark":
|
||||
parent.Children[Index] = MarkBox()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementMark(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "image":
|
||||
parent.Children[Index] = ImageBox()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementImage(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "expanded_image":
|
||||
parent.Children[Index] = ExpandedImageBox()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementExpandedImage(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "ani_image":
|
||||
parent.Children[Index] = AniImageBox()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementAniImage(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "slot":
|
||||
parent.Children[Index] = SlotWindow()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementSlot(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "candidate_list":
|
||||
parent.Children[Index] = CandidateListBox()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementCandidateList(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "grid_table":
|
||||
parent.Children[Index] = GridSlotWindow()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementGridTable(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "text":
|
||||
parent.Children[Index] = TextLine()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementText(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "multi_text":
|
||||
parent.Children[Index] = MultiTextLineNew()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementText(parent.Children[Index], ElementValue, parent)
|
||||
elif Type == "listbox_new":
|
||||
parent.Children[Index] = ListBoxNew()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementListBox(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "editline":
|
||||
parent.Children[Index] = EditLine()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementEditLine(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "titlebar":
|
||||
parent.Children[Index] = TitleBar()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementTitleBar(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "horizontalbar":
|
||||
parent.Children[Index] = HorizontalBar()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementHorizontalBar(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "board":
|
||||
parent.Children[Index] = Board()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementBoard(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "board_with_titlebar":
|
||||
parent.Children[Index] = BoardWithTitleBar()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementBoardWithTitleBar(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "thinboard":
|
||||
parent.Children[Index] = ThinBoard()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementThinBoard(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "thinboard_circle":
|
||||
parent.Children[Index] = ThinBoardCircle()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementThinBoard(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "box":
|
||||
parent.Children[Index] = Box()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementBox(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "bar":
|
||||
parent.Children[Index] = Bar()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementBar(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "line":
|
||||
parent.Children[Index] = Line()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementLine(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "slotbar":
|
||||
parent.Children[Index] = SlotBar()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementSlotBar(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "gauge":
|
||||
parent.Children[Index] = Gauge()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementGauge(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "scrollbar":
|
||||
parent.Children[Index] = ScrollBar()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "thin_scrollbar":
|
||||
parent.Children[Index] = ThinScrollBar()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "small_thin_scrollbar":
|
||||
parent.Children[Index] = SmallThinScrollBar()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementScrollBar(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "sliderbar":
|
||||
parent.Children[Index] = SliderBar()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementSliderBar(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "listbox":
|
||||
parent.Children[Index] = ListBox()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementListBox(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
elif Type == "listbox2":
|
||||
parent.Children[Index] = ListBox2()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementListBox2(parent.Children[Index], ElementValue, parent)
|
||||
elif Type == "listboxex":
|
||||
parent.Children[Index] = ListBoxEx()
|
||||
parent.Children[Index].SetParent(parent)
|
||||
self.LoadElementListBoxEx(parent.Children[Index], ElementValue, parent)
|
||||
|
||||
else:
|
||||
Index += 1
|
||||
continue
|
||||
|
||||
parent.Children[Index].SetWindowName(Name)
|
||||
if 0 != self.InsertFunction:
|
||||
self.InsertFunction(Name, parent.Children[Index])
|
||||
|
||||
self.LoadChildren(parent.Children[Index], ElementValue)
|
||||
Index += 1
|
||||
PythonScriptLoader.LoadChildren=LoadChildren
|
||||
del LoadChildren
|
||||
""",ui.__dict__)
|
||||
_position=ui.Window.SetPosition
|
||||
def SetPosition(self,x,y,flag=False):
|
||||
if flag:self.exPos=(x,y)
|
||||
_position(self,x,y)
|
||||
ui.Window.SetPosition=SetPosition
|
||||
if not hasattr(ui.Window,'GetBottom'):
|
||||
ui.Window.GetBottom=lambda self:self.GetLocalPosition()[1]+self.GetHeight()
|
||||
ui.Button.SetRenderingRect=lambda self,l,t,r,b:ui.wndMgr.SetRenderingRect(self.hWnd,l,t,r,b)
|
||||
_imageEvent=ui.ImageBox.SAFE_SetStringEvent
|
||||
def SetImageEvent(self,event,func,*args):
|
||||
if args:
|
||||
callback=ui.__mem_func__(func)
|
||||
self.eventDict[event]=lambda:callback(*args)
|
||||
return
|
||||
return _imageEvent(self,event,func)
|
||||
ui.ImageBox.SAFE_SetStringEvent=SetImageEvent
|
||||
_text=ui.PythonScriptLoader.LoadElementText
|
||||
def LoadText(self,window,value,parent):
|
||||
if isinstance(window,ui.MultiTextLineNew):
|
||||
if 'text_range' in value:window.SetTextRange(value['text_range'])
|
||||
if 'text_type' in value:window.SetTextType(value['text_type'])
|
||||
return _text(self,window,value,parent)
|
||||
ui.PythonScriptLoader.LoadElementText=LoadText
|
||||
# AVA2 toggle callbacks accept bound arguments, like Button.SAFE_SetEvent.
|
||||
_toggleUp=ui.ToggleButton.SetToggleUpEvent
|
||||
_toggleDown=ui.ToggleButton.SetToggleDownEvent
|
||||
def SetToggleUp(self,func,*args):
|
||||
return _toggleUp(self,(lambda:func(*args)) if args else func)
|
||||
def SetToggleDown(self,func,*args):
|
||||
return _toggleDown(self,(lambda:func(*args)) if args else func)
|
||||
ui.ToggleButton.SetToggleUpEvent=SetToggleUp
|
||||
ui.ToggleButton.SetToggleDownEvent=SetToggleDown
|
||||
)PY";
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,420 @@
|
||||
// PORT: battle pass (战令), from AVA2's uibattlepassex.py. The server runs monthly seasons of up to ten missions
|
||||
// counted from real events (kills, fishing, refines, levels, NPC trades, play time); each mission has a reward and
|
||||
// a final reward follows once all are done. This window asks with /mt_bp, shows progress live while open and
|
||||
// claims rewards. Entry points: F6 and a "战令" button by the minimap. Protocol: metin2-server
|
||||
// docs/FEATURE-BATTLEPASS.md.
|
||||
static const char c_szBattlePassScript[] = R"PY(# -*- coding: utf-8 -*-
|
||||
import app
|
||||
import chat
|
||||
import game
|
||||
import grp
|
||||
import item
|
||||
import net
|
||||
import nonplayer
|
||||
import player
|
||||
import ui
|
||||
import weakref
|
||||
from mt_biolog import Action, Text, L
|
||||
|
||||
g_window=None
|
||||
g_entry=None
|
||||
SEND_GAP=.4
|
||||
TIMEOUT=3.
|
||||
PAGE=5
|
||||
ROW=56
|
||||
WIDTH=620
|
||||
MAX_SLOT=10
|
||||
# type: (name without sub, name with a sub vnum: kind of the vnum)
|
||||
TYPES={1:('击杀怪物','击杀 ','mob'),2:('击杀 Boss','击杀 Boss ','mob'),3:('摧毁陨石','摧毁 ','mob'),4:('累计在线',None,None),
|
||||
5:('钓鱼','钓到 ','item'),6:('成功强化装备','强化出 ','item'),7:('提升等级',None,None),8:('在 NPC 商店消费金币',None,None),
|
||||
9:(None,'向 NPC 出售 ','item')}
|
||||
ERRORS={'loading':'数据加载中,请稍后再试','slot':'没有这个任务','claimed':'奖励已经领取过了','incomplete':'任务尚未完成',
|
||||
'space':'背包空间不足,请整理后再领取','config':'奖励配置有误,请联系管理员','db':'服务器繁忙,请稍后再试',
|
||||
'rate':'操作过快,请稍后再试','invalid':'参数无效','ticket':'请使用当月战令票激活','month':'这张战令票不属于当前月份',
|
||||
'activated':'本月战令已经激活过了','busy':'请先结束交易、商店、仓库或传送'}
|
||||
|
||||
|
||||
def Number(text,low=0,high=10**12):
|
||||
if not text.isdigit() or len(text)>13:raise ValueError(text)
|
||||
value=int(text)
|
||||
if not low<=value<=high:raise ValueError(text)
|
||||
return value
|
||||
|
||||
|
||||
def Rewards(words):
|
||||
if len(words)%2:raise ValueError(words)
|
||||
return [(Number(words[i],1,2**32-1),Number(words[i+1],1,10000)) for i in range(0,len(words),2)]
|
||||
|
||||
|
||||
def Grouped(value):
|
||||
text=str(int(value));parts=[]
|
||||
while len(text)>3:parts.insert(0,text[-3:]);text=text[:-3]
|
||||
return ','.join([text]+parts)
|
||||
|
||||
|
||||
def Amount(kind,value,target):
|
||||
# Play time is counted in seconds and shown in hours, or in minutes for a target under an hour.
|
||||
if kind==4:
|
||||
unit=3600. if target>=3600 else 60.
|
||||
amount=value/unit
|
||||
return ('%d'%amount) if amount==int(amount) else ('%.1f'%amount)
|
||||
return Grouped(value)
|
||||
|
||||
|
||||
def Unit(kind,target):
|
||||
if kind!=4:return ''
|
||||
return ' 小时' if target>=3600 else ' 分钟'
|
||||
|
||||
|
||||
def SeasonName(season):
|
||||
year,month=divmod(season,100)
|
||||
if 2000<=year<=2999 and 1<=month<=12:return '%d 年 %d 月'%(year,month)
|
||||
return '第 %d 期'%season
|
||||
|
||||
|
||||
def Left(seconds):
|
||||
seconds=int(seconds)
|
||||
if seconds<=0:return '已结束'
|
||||
days,rest=divmod(seconds,86400);hours,rest=divmod(rest,3600)
|
||||
if days:return '剩余 %d 天 %d 小时'%(days,hours)
|
||||
return '剩余 %d 小时 %d 分'%(hours,max(1,rest//60))
|
||||
|
||||
|
||||
class Pass(object):
|
||||
# Protocol state only. send(text) posts a chat command, now() is seconds.
|
||||
def __init__(self,send,now,listener=None):
|
||||
self.send=send;self.now=now;self.listener=listener
|
||||
self.waiting=None;self.nextSend=0;self.unsupported=False
|
||||
self.Clear()
|
||||
|
||||
def Clear(self):
|
||||
self.season=None;self.missions={};self.final=None;self.reading=None;self.none=False;self.error=None;self.claiming=None;self.access=None;self.month=None
|
||||
|
||||
def Ready(self):
|
||||
return self.waiting is None or self.now()>=self.waiting
|
||||
|
||||
def Post(self,text,expect=True):
|
||||
now=self.now()
|
||||
if now<self.nextSend:return False
|
||||
self.send(text);self.nextSend=now+SEND_GAP
|
||||
if expect:self.waiting=now+TIMEOUT
|
||||
return True
|
||||
|
||||
def Query(self):
|
||||
self.Tick()
|
||||
if self.waiting is not None:return False
|
||||
return self.Post('/mt_bp 1 info')
|
||||
|
||||
def Claim(self,slot):
|
||||
if self.claiming is not None or not self.season or self.access not in (None,1):return False
|
||||
if self.Post('/mt_bp 1 claim %d'%slot):self.claiming=slot;self.error=None;return True
|
||||
return False
|
||||
|
||||
def Activate(self,cell,vnum):
|
||||
if self.access!=0 or self.waiting is not None or not 25150<=vnum<=25161:return False
|
||||
if player.GetItemIndex(cell)!=vnum:return False
|
||||
return self.Post('/mt_bp 1 activate %d %d'%(cell,vnum))
|
||||
|
||||
def Close(self):
|
||||
self.send('/mt_bp 1 close')
|
||||
|
||||
def Tick(self):
|
||||
if self.waiting is not None and self.now()>=self.waiting:
|
||||
self.waiting=None;self.claiming=None
|
||||
if self.season is None:self.unsupported=True
|
||||
self.Notify('timeout')
|
||||
|
||||
def SecondsLeft(self):
|
||||
if not self.season:return 0
|
||||
_,_,end,now,at=self.season
|
||||
return end-(now+(self.now()-at))
|
||||
|
||||
def Notify(self,kind,value=None):
|
||||
if self.listener:self.listener(kind,value)
|
||||
|
||||
def Receive(self,line):
|
||||
if not line.startswith('MTBP1 '):return False
|
||||
words=line.split()
|
||||
try:self.Parse(words[1],words[2:])
|
||||
except (ValueError,IndexError):self.reading=None
|
||||
return True
|
||||
|
||||
def Parse(self,kind,args):
|
||||
if kind=='season' and len(args)==5:
|
||||
seasonId,start,end,now=[Number(w,0,2**32-1) for w in args[:4]];count=Number(args[4],1,MAX_SLOT)
|
||||
self.reading=dict(season=(seasonId,start,end,now,self.now()),count=count,missions={},final=None,access=None,month=None)
|
||||
elif kind=='access' and len(args) in (1,2) and self.reading is not None:
|
||||
self.reading['access']=Number(args[0],0,2)
|
||||
if len(args)==2:self.reading['month']=Number(args[1],1,12)
|
||||
elif kind=='mission' and self.reading is not None and len(args)>=6:
|
||||
slot=Number(args[0],1,MAX_SLOT);kind=Number(args[1],1,9)
|
||||
self.reading['missions'][slot]=dict(slot=slot,type=kind,sub=Number(args[2],0,2**32-1),target=Number(args[3],1),
|
||||
value=Number(args[4]),claimed=Number(args[5],0,1)==1,rewards=Rewards(args[6:]))
|
||||
elif kind=='final' and self.reading is not None and len(args)>=4:
|
||||
self.reading['final']=dict(claimed=Number(args[0],0,1)==1,all=Number(args[1],0,1)==1,rewards=Rewards(args[2:]))
|
||||
elif kind=='end' and not args and self.reading is not None:
|
||||
r=self.reading;self.reading=None
|
||||
if len(r['missions'])!=r['count'] or r['final'] is None:return
|
||||
self.season=r['season'];self.missions=r['missions'];self.final=r['final'];self.access=r['access'];self.month=r['month'];self.none=False
|
||||
self.Answered('info')
|
||||
elif kind=='none' and not args:
|
||||
self.Clear();self.none=True;self.Answered('none')
|
||||
elif kind=='progress' and len(args)==2:
|
||||
slot=Number(args[0],1,MAX_SLOT);m=self.missions.get(slot)
|
||||
if m:m['value']=min(m['target'],Number(args[1]));self.Notify('progress',slot)
|
||||
elif kind=='done' and len(args)==1:
|
||||
slot=Number(args[0],1,MAX_SLOT);m=self.missions.get(slot)
|
||||
if m:m['value']=m['target']
|
||||
self.Notify('done',slot)
|
||||
elif kind=='claimed' and len(args)==1:
|
||||
slot=Number(args[0],0,MAX_SLOT)
|
||||
if slot:
|
||||
if slot in self.missions:self.missions[slot]['claimed']=True
|
||||
elif self.final:self.final['claimed']=True
|
||||
self.claiming=None;self.Notify('claimed',slot) # a full info follows
|
||||
elif kind=='error' and len(args)==1 and args[0] in ERRORS:
|
||||
self.error=args[0];self.claiming=None;self.Answered('error')
|
||||
|
||||
def Answered(self,kind):
|
||||
self.waiting=None;self.unsupported=False;self.Notify(kind)
|
||||
|
||||
def AllDone(self):
|
||||
return bool(self.missions) and all(m['value']>=m['target'] for m in self.missions.values())
|
||||
|
||||
|
||||
def ItemName(vnum):
|
||||
try:
|
||||
item.SelectItem(vnum);name=item.GetItemName()
|
||||
except Exception:name=''
|
||||
return name if name else L('物品 %d'%vnum)
|
||||
|
||||
|
||||
def MobName(vnum):
|
||||
try:name=nonplayer.GetMonsterName(vnum)
|
||||
except Exception:name=''
|
||||
return name if name else L('怪物 %d'%vnum)
|
||||
|
||||
|
||||
def MissionName(m):
|
||||
# Locale text: the utf-8 parts go through L, game names are already in the locale's code page.
|
||||
plain,prefix,kind=TYPES.get(m['type'],('任务',None,None))
|
||||
if m['sub'] and prefix:return L(prefix)+(MobName(m['sub']) if kind=='mob' else ItemName(m['sub']))
|
||||
return L(plain or '任务')
|
||||
|
||||
|
||||
def RewardText(rewards):
|
||||
return L(',').join([ItemName(vnum)+(' x%d'%count) for vnum,count in rewards])
|
||||
|
||||
|
||||
class BattlePassWindow(ui.Window):
|
||||
def __init__(self,state):
|
||||
ui.Window.__init__(self);self.SetWindowName('BattlePassWindow');self.AddFlag('float');self.AddFlag('movable')
|
||||
self.state=state;self.page=0
|
||||
self.SetSize(WIDTH,74+PAGE*ROW+ROW+20+56)
|
||||
self.heading=Text(self,18,18,'战令',0xffffd68b)
|
||||
self.season=Text(self,80,18,'',0xffc3b7a1)
|
||||
self.closeButton=Action(self,WIDTH-76,6,64,'关闭',self.Hide)
|
||||
self.rows=[]
|
||||
for i in range(PAGE):
|
||||
y=64+i*ROW
|
||||
self.rows.append(dict(name=Text(self,18,y+4,''),value=Text(self,330,y+4,''),
|
||||
reward=Text(self,18,y+26,'',0xffb3aa98),button=Action(self,WIDTH-118,y,100,'领取',lambda i=i:self.ClaimRow(i))))
|
||||
y=64+PAGE*ROW+8
|
||||
self.finalName=Text(self,18,y+4,'最终奖励',0xffffd68b)
|
||||
self.finalState=Text(self,330,y+4,'')
|
||||
self.finalReward=Text(self,18,y+26,'',0xffb3aa98)
|
||||
self.finalButton=Action(self,WIDTH-118,y,100,'领取',lambda:self.state.Claim(0) and self.Refresh())
|
||||
self.activateButton=Action(self,WIDTH-218,y,200,'使用当月战令票激活',self.AskActivate)
|
||||
self.activateButton.Hide();self.confirm=None;self.pendingTicket=None
|
||||
y=self.GetHeight()-56
|
||||
self.prev=Action(self,18,y,80,'上一页',lambda:self.Turn(-1))
|
||||
self.pageText=Text(self,140,y+24,'');self.pageText.SetHorizontalAlignCenter()
|
||||
self.next=Action(self,182,y,80,'下一页',lambda:self.Turn(1))
|
||||
self.note=Text(self,280,y+16,'',0xffc3b7a1)
|
||||
self.second=-1
|
||||
self.Hide()
|
||||
|
||||
def Open(self):
|
||||
self.state.error=None;self.state.Query();self.Refresh();self.SetCenterPosition();ui.Window.Show(self);self.SetTop()
|
||||
|
||||
def Toggle(self):
|
||||
if self.IsShow():self.Hide()
|
||||
else:self.Open()
|
||||
|
||||
def Hide(self):
|
||||
state=self.__dict__.get('state') # ui.Window.__init__ hides the window before state is set
|
||||
if self.IsShow() and state and state.season:state.Close()
|
||||
self.pendingTicket=None
|
||||
self.CloseConfirm()
|
||||
ui.Window.Hide(self)
|
||||
|
||||
def CloseConfirm(self):
|
||||
confirm=self.__dict__.get('confirm')
|
||||
if confirm:
|
||||
confirm.Close();confirm.SetAcceptEvent(None);confirm.SetCancelEvent(None);self.confirm=None
|
||||
|
||||
def OfferTicket(self,cell,vnum):
|
||||
self.pendingTicket=(cell,vnum)
|
||||
self.Open()
|
||||
|
||||
def AskTicket(self,cell,vnum):
|
||||
if self.state.access!=0 or player.GetItemIndex(cell)!=vnum:return
|
||||
item.SelectItem(vnum)
|
||||
if item.GetValue(0)!=self.state.month:self.state.error='month';self.Refresh();return
|
||||
import uiCommon
|
||||
self.CloseConfirm();self.confirm=uiCommon.QuestionDialog()
|
||||
self.confirm.SetText(L('消耗战令票并激活本月战令?'))
|
||||
self.confirm.SetAcceptEvent(lambda:self.ConfirmActivate(cell,vnum))
|
||||
self.confirm.SetCancelEvent(self.CloseConfirm);self.confirm.Open()
|
||||
|
||||
def AskActivate(self):
|
||||
if self.state.access!=0:return
|
||||
for cell in range(player.INVENTORY_PAGE_SIZE*player.INVENTORY_PAGE_COUNT):
|
||||
vnum=player.GetItemIndex(cell)
|
||||
if not 25150<=vnum<=25161:continue
|
||||
item.SelectItem(vnum)
|
||||
# Display uses server time, not the phone's local month/time zone.
|
||||
if item.GetValue(0)!=self.state.month:continue
|
||||
self.AskTicket(cell,vnum);return
|
||||
self.state.error='ticket';self.Refresh()
|
||||
|
||||
def ConfirmActivate(self,cell,vnum):
|
||||
self.CloseConfirm();self.state.Activate(cell,vnum);self.Refresh()
|
||||
|
||||
def Slots(self):
|
||||
return sorted(self.state.missions)
|
||||
|
||||
def Pages(self):
|
||||
return max(1,(len(self.Slots())+PAGE-1)//PAGE)
|
||||
|
||||
def Turn(self,delta):
|
||||
self.page=max(0,min(self.Pages()-1,self.page+delta));self.Refresh()
|
||||
|
||||
def ClaimRow(self,i):
|
||||
slots=self.Slots()[self.page*PAGE:]
|
||||
if i<len(slots) and self.state.Claim(slots[i]):self.Refresh()
|
||||
|
||||
def Refresh(self):
|
||||
s=self.state;self.page=min(self.page,self.Pages()-1)
|
||||
slots=self.Slots()[self.page*PAGE:(self.page+1)*PAGE]
|
||||
for i,row in enumerate(self.rows):
|
||||
widgets=(row['name'],row['value'],row['reward'],row['button'])
|
||||
if i>=len(slots):
|
||||
for w in widgets:w.Hide()
|
||||
continue
|
||||
for w in widgets:w.Show()
|
||||
m=s.missions[slots[i]];done=m['value']>=m['target']
|
||||
row['name'].SetText(MissionName(m))
|
||||
row['value'].SetText(Amount(m['type'],m['value'],m['target'])+' / '+Amount(m['type'],m['target'],m['target'])+L(Unit(m['type'],m['target'])))
|
||||
row['value'].SetPackedFontColor(0xff9fe08b if done else 0xffe8dec8)
|
||||
row['reward'].SetText(L('奖励:')+RewardText(m['rewards']) if m['rewards'] else L('无奖励'))
|
||||
if m['claimed']:row['button'].SetText('已领取')
|
||||
elif s.claiming==m['slot']:row['button'].SetText('领取中')
|
||||
else:row['button'].SetText('领取' if done else '未完成')
|
||||
row['button'].SetEnabled(s.access in (None,1) and done and not m['claimed'] and bool(m['rewards']) and s.claiming is None)
|
||||
f=s.final
|
||||
for w in (self.finalName,self.finalState,self.finalReward,self.finalButton):
|
||||
if f:w.Show()
|
||||
else:w.Hide()
|
||||
if f:
|
||||
ready=s.AllDone()
|
||||
self.finalState.SetText(L('已领取' if f['claimed'] else '全部任务完成' if ready else '完成全部任务后可领取'))
|
||||
self.finalReward.SetText(L('奖励:')+RewardText(f['rewards']))
|
||||
self.finalButton.SetText('已领取' if f['claimed'] else '领取中' if s.claiming==0 else '领取')
|
||||
self.finalButton.SetEnabled(s.access in (None,1) and ready and not f['claimed'] and s.claiming is None)
|
||||
if s.access==0:
|
||||
self.finalButton.Hide();self.finalState.Hide();self.finalReward.Hide();self.activateButton.Show()
|
||||
self.activateButton.SetEnabled(s.waiting is None)
|
||||
else:self.activateButton.Hide()
|
||||
many=self.Pages()>1
|
||||
for w in (self.prev,self.next,self.pageText):
|
||||
if many and s.season:w.Show()
|
||||
else:w.Hide()
|
||||
self.prev.SetEnabled(self.page>0);self.next.SetEnabled(self.page<self.Pages()-1)
|
||||
self.pageText.SetText('%d / %d'%(self.page+1,self.Pages()))
|
||||
if s.season:self.season.SetText(L(SeasonName(s.season[0])+' '+Left(s.SecondsLeft())))
|
||||
else:self.season.SetText('')
|
||||
if s.unsupported:note='!服务器尚未启用战令'
|
||||
elif s.error:note='!'+ERRORS[s.error]
|
||||
elif s.none:note='当前没有进行中的战令赛季'
|
||||
elif not s.season:note='正在查询……'
|
||||
elif s.claiming is not None:note='正在领取……'
|
||||
elif s.access==0:note='激活后才开始累计进度'
|
||||
elif s.access==2:note='本月战令已完成'
|
||||
else:note='击杀、钓鱼、强化等都会自动计入进度'
|
||||
self.note.SetText(L(note))
|
||||
|
||||
def OnUpdate(self):
|
||||
self.state.Tick()
|
||||
second=int(app.GetTime())
|
||||
if second!=self.second:self.second=second;self.Refresh()
|
||||
|
||||
def OnRender(self):
|
||||
x,y=self.GetGlobalPosition();w=self.GetWidth()
|
||||
grp.SetColor(0xf51b1916);grp.RenderBar(x,y,w,self.GetHeight());grp.SetColor(0xff9b7b48);grp.RenderBox(x,y,w,self.GetHeight())
|
||||
grp.SetColor(0xff4a3d2a)
|
||||
for i in range(PAGE+1):grp.RenderLine(x+12,y+60+i*ROW,w-24,0)
|
||||
|
||||
def OnPressEscapeKey(self):self.Hide();return True
|
||||
|
||||
def Destroy(self):
|
||||
self.Hide();self.closeButton.event=self.finalButton.event=self.activateButton.event=self.prev.event=self.next.event=None
|
||||
for row in self.rows:row['button'].event=None
|
||||
self.state=None
|
||||
|
||||
|
||||
class Entry(Action):
|
||||
def __init__(self,window):
|
||||
Action.__init__(self,None,0,0,64,'战令',Toggle)
|
||||
self.minimap=weakref.proxy(window.interface.wndMiniMap);self.SetWindowName('BattlePassEntry');self.OnUpdate()
|
||||
|
||||
def OnUpdate(self):
|
||||
x,y=self.minimap.GetGlobalPosition();self.SetPosition(max(4,x-68),y+460)
|
||||
|
||||
|
||||
def OnPass(kind,value):
|
||||
s=g_pass
|
||||
if kind=='done':
|
||||
m=s.missions.get(value)
|
||||
name=MissionName(m) if m else L('一项任务')
|
||||
chat.AppendChat(chat.CHAT_TYPE_INFO,L('战令任务完成:')+name+L(',按 F6 领取奖励'))
|
||||
elif kind=='claimed':chat.AppendChat(chat.CHAT_TYPE_INFO,L('战令奖励已放入背包' if value else '战令最终奖励已放入背包'))
|
||||
elif kind=='error':chat.AppendChat(chat.CHAT_TYPE_INFO,L(ERRORS[s.error]))
|
||||
if g_window and g_window.IsShow():
|
||||
if kind=='info' and g_window.pendingTicket:
|
||||
ticket=g_window.pendingTicket;g_window.pendingTicket=None;g_window.AskTicket(*ticket)
|
||||
g_window.Refresh()
|
||||
|
||||
|
||||
g_pass=Pass(net.SendChatPacket,app.GetTime,OnPass)
|
||||
|
||||
|
||||
def Toggle():
|
||||
if g_window:g_window.Toggle()
|
||||
|
||||
|
||||
_open=game.GameWindow.Open
|
||||
_close=game.GameWindow.Close
|
||||
_command=game.GameWindow.BINARY_ServerCommand_Run
|
||||
|
||||
def Open(self):
|
||||
global g_window,g_entry
|
||||
_open(self);g_pass.waiting=None;g_pass.unsupported=False;g_pass.Clear()
|
||||
g_window=BattlePassWindow(g_pass);g_entry=None
|
||||
keys=getattr(self,'onPressKeyDict',None)
|
||||
if keys is not None and app.DIK_F6 not in keys:keys[app.DIK_F6]=lambda:Toggle()
|
||||
|
||||
def Close(self):
|
||||
global g_window,g_entry
|
||||
if g_entry:g_entry.Hide();g_entry.event=None;g_entry=None
|
||||
if g_window:g_window.Destroy();g_window=None
|
||||
_close(self)
|
||||
|
||||
def Command(self,line):
|
||||
if g_pass.Receive(line):return 1
|
||||
return _command(self,line)
|
||||
|
||||
game.GameWindow.Open=Open
|
||||
game.GameWindow.Close=Close
|
||||
game.GameWindow.BINARY_ServerCommand_Run=Command
|
||||
)PY";
|
||||
@@ -443,8 +443,7 @@ def Open(self):
|
||||
global g_window,g_entry
|
||||
_open(self)
|
||||
g_window=BiologWindow()
|
||||
g_entry=Entry(self)
|
||||
g_entry.nextTick=0
|
||||
g_entry=None
|
||||
|
||||
def Close(self):
|
||||
global g_window,g_entry
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// PORT: AVA2 uitrack world-boss tab, read-only. The server's boss regens (own channel plus the shared core) come
|
||||
// from the MTF1 'bosses' query; the original regen timers stay authoritative. AVA2's teleport button is left out.
|
||||
// PORT: AVA2 uitrack world-boss tab. The server's boss regens (own channel plus the shared core) come
|
||||
// from the MTF1 'bosses' query; the original regen timers stay authoritative. Direct travel is wired to PortTrackTravel.
|
||||
// See docs/AVA2-BOSS.md.
|
||||
static const char c_szBossScript[] = R"PY(# -*- coding: utf-8 -*-
|
||||
import app
|
||||
@@ -24,6 +24,20 @@ g_tick=None
|
||||
PAGE=8
|
||||
REFRESH=30.
|
||||
SHARED_CHANNEL=99
|
||||
TRAVEL_LEVELS={9844:(40,60),9836:(65,85),9838:(80,100),9840:(95,115),9842:(105,120),
|
||||
1093:(40,120),2092:(70,120),2493:(75,120),2598:(80,120),6091:(90,120),
|
||||
6191:(90,120),9018:(105,120),20442:(110,120)}
|
||||
|
||||
|
||||
def Travel(vnum,done=None):
|
||||
service=mt_feature_service.g_service
|
||||
if not service:return
|
||||
def received(data,error):
|
||||
errors={'unsupported':'服务器未启用此入口传送','level':'等级不符合入口要求',
|
||||
'busy':'当前状态不能传送,请稍后再试','unavailable':'服务器尚未开放该地图'}
|
||||
chat.AppendChat(chat.CHAT_TYPE_INFO,L(errors.get(error,'传送失败,请稍后重试') if error else '正在前往入口'))
|
||||
if done:done(data,error)
|
||||
service.Request('travel',vnum,0,received)
|
||||
# Server map index -> map directory (share/locale/<locale>/map/index), for localeInfo.MINIMAP_ZONE_NAME_DICT.
|
||||
MAPS={1:'metin2_map_a1',3:'metin2_map_a3',4:'metin2_map_guild_01',5:'metin2_map_monkey_dungeon_11',
|
||||
6:'metin2_guild_village_01',21:'metin2_map_b1',23:'metin2_map_b3',24:'metin2_map_guild_02',
|
||||
@@ -110,17 +124,24 @@ class BossWindow(ui.Window):
|
||||
self.tracker=tracker;self.pending=False;self.generation=0;self.nextQuery=0;self.page=0;self.dimensions=None
|
||||
self.heading=Text(self,18,18,'世界Boss',0xffffd68b)
|
||||
self.closeButton=Action(self,0,6,60,'关闭',self.Hide)
|
||||
self.refreshButton=Action(self,18,48,80,'刷新',self.Query)
|
||||
self.prevButton=Action(self,110,48,72,'上一页',lambda:self.Turn(-1))
|
||||
self.nextButton=Action(self,194,48,72,'下一页',lambda:self.Turn(1))
|
||||
self.status=Text(self,280,54,'',0xffc3b7a1)
|
||||
self.dungeonButton=Action(self,18,48,100,'副本信息',self.OpenDungeon)
|
||||
self.refreshButton=Action(self,124,48,70,'刷新',self.Query)
|
||||
self.prevButton=Action(self,200,48,70,'上一页',lambda:self.Turn(-1))
|
||||
self.nextButton=Action(self,276,48,70,'下一页',lambda:self.Turn(1))
|
||||
self.status=Text(self,354,54,'',0xffc3b7a1)
|
||||
self.lines=[Text(self,18,0,'',0xffefdfc3) for i in range(PAGE)]
|
||||
self.details=[Text(self,30,0,'',0xffb2aa9a) for i in range(PAGE)]
|
||||
self.remindButtons=[Action(self,0,0,92,'',lambda i=i:self.Remind(i)) for i in range(PAGE)]
|
||||
self.travelButtons=[Action(self,0,0,72,'传送',lambda i=i:self.Teleport(i)) for i in range(PAGE)]
|
||||
self.note=Text(self,18,0,'提醒:Boss 刷新后在聊天框提示;以服务器刷新为准。',0xffb2aa9a)
|
||||
self.Reflow();self.Hide()
|
||||
|
||||
def Buttons(self):return [self.closeButton,self.refreshButton,self.prevButton,self.nextButton]+self.remindButtons
|
||||
def OpenDungeon(self):
|
||||
import mt_dungeons
|
||||
self.Hide()
|
||||
mt_dungeons.Toggle()
|
||||
|
||||
def Buttons(self):return [self.closeButton,self.dungeonButton,self.refreshButton,self.prevButton,self.nextButton]+self.remindButtons+self.travelButtons
|
||||
|
||||
def Open(self):
|
||||
self.Reflow();self.SetCenterPosition();self.Show();self.SetTop();self.Query()
|
||||
@@ -147,6 +168,12 @@ class BossWindow(ui.Window):
|
||||
rows=self.tracker.rows or [];index=self.page*PAGE+i
|
||||
if index<len(rows):self.tracker.Toggle(rows[index]);self.Render()
|
||||
|
||||
def Teleport(self,i):
|
||||
rows=self.tracker.rows or [];index=self.page*PAGE+i
|
||||
if index>=len(rows) or rows[index]['vnum'] not in TRAVEL_LEVELS:return
|
||||
self.travelButtons[i].SetEnabled(False)
|
||||
Travel(rows[index]['vnum'],lambda data,error:self.Render())
|
||||
|
||||
def Render(self):
|
||||
t=self.tracker;rows=t.rows or [];self.page=min(self.page,self.Pages()-1)
|
||||
if t.error:self.status.SetText(L('服务端未启用 Boss 追踪' if t.error=='unsupported' else '未同步,请稍后刷新'))
|
||||
@@ -156,6 +183,7 @@ class BossWindow(ui.Window):
|
||||
self.prevButton.SetEnabled(self.page>0);self.nextButton.SetEnabled(self.page+1<self.Pages())
|
||||
for i in range(PAGE):
|
||||
index=self.page*PAGE+i;line=self.lines[i];detail=self.details[i];button=self.remindButtons[i]
|
||||
travel=self.travelButtons[i];travel.Hide()
|
||||
if index>=len(rows):line.Hide();detail.Hide();button.Hide();continue
|
||||
r=rows[index];left=t.Left(r)
|
||||
channel='共享' if r['channel']==SHARED_CHANNEL else 'CH%d'%r['channel']
|
||||
@@ -169,6 +197,9 @@ class BossWindow(ui.Window):
|
||||
button.SetText(L('提醒:'+('开' if Key(r) in t.reminders else '关')))
|
||||
button.SetEnabled(bool(r['alive']==0 and r['next']) or Key(r) in t.reminders)
|
||||
line.Show();detail.Show();button.Show()
|
||||
service=mt_feature_service.g_service
|
||||
if r['vnum'] in TRAVEL_LEVELS and service and service.mask is not None and service.mask&512:
|
||||
travel.Show();travel.SetEnabled(not service.pending and not service.queue)
|
||||
|
||||
def Reflow(self):
|
||||
dims=(wndMgr.GetScreenWidth(),wndMgr.GetScreenHeight())
|
||||
@@ -179,6 +210,7 @@ class BossWindow(ui.Window):
|
||||
for i in range(PAGE):
|
||||
y=88+i*spacing
|
||||
self.lines[i].SetPosition(18,y);self.details[i].SetPosition(30,y+18);self.remindButtons[i].SetPosition(width-110,y)
|
||||
self.travelButtons[i].SetPosition(width-190,y)
|
||||
self.note.SetPosition(18,height-22);self.SetCenterPosition()
|
||||
|
||||
def OnUpdate(self):
|
||||
@@ -207,7 +239,7 @@ class ReminderTick(ui.Window):
|
||||
class Entry(Action):
|
||||
def __init__(self,window):
|
||||
Action.__init__(self,None,0,0,64,'Boss',Toggle)
|
||||
self.minimap=weakref.proxy(window.interface.wndMiniMap);self.SetWindowName('BossEntry');self.OnUpdate()
|
||||
self.minimap=weakref.proxy(window.interface.wndMiniMap);self.SetWindowName('BossEntry');self.OnUpdate();self.Hide()
|
||||
|
||||
def OnUpdate(self):
|
||||
x,y=self.minimap.GetGlobalPosition();self.SetPosition(max(4,x-68),y+356)
|
||||
|
||||
@@ -171,7 +171,7 @@ class ChannelWindow(ui.Window):
|
||||
class Entry(Action):
|
||||
def __init__(self,window):
|
||||
Action.__init__(self,None,0,0,64,'换线',Toggle)
|
||||
self.minimap=weakref.proxy(window.interface.wndMiniMap);self.SetWindowName('ChannelEntry');self.OnUpdate()
|
||||
self.minimap=weakref.proxy(window.interface.wndMiniMap);self.SetWindowName('ChannelEntry');self.OnUpdate();self.Hide()
|
||||
|
||||
def OnUpdate(self):
|
||||
x,y=self.minimap.GetGlobalPosition();self.SetPosition(max(4,x-68),y+304)
|
||||
|
||||
@@ -0,0 +1,291 @@
|
||||
// PORT: AVA2 uichestdropinfo.py with stale-cell and slider bounds fixes; original UIScript packed in ava2items.
|
||||
static const char c_szChestScript[] = R"PY(# -*- coding: utf-8 -*-
|
||||
import app
|
||||
import chat
|
||||
from mt_wiki import B
|
||||
import game
|
||||
import uiInventory
|
||||
import uiScriptLocale
|
||||
import item
|
||||
import player
|
||||
import net
|
||||
import ui
|
||||
L=player.AutoHuntLocalize
|
||||
uiScriptLocale.CHEST_DROP_TITLE=L('宝箱奖励预览')
|
||||
uiScriptLocale.CHEST_DROP_OPEN=L('开启')
|
||||
|
||||
#blackdragonx61 (28.11.21)
|
||||
import ui
|
||||
import item
|
||||
import uiToolTip
|
||||
import player
|
||||
import net
|
||||
|
||||
class ChestDropInfoWindow(ui.ScriptWindow):
|
||||
DROP_SLOT_SIZE = 5 * 8
|
||||
ITEM = 0
|
||||
COUNT = 1
|
||||
|
||||
def __init__(self) :
|
||||
ui.ScriptWindow.__init__(self)
|
||||
self.isLoaded = False
|
||||
self.ItemVnum = -1
|
||||
self.PageCount = 0
|
||||
self.CurrentPage = 0
|
||||
self.DropDict = dict()
|
||||
self.MainItemSlot = None
|
||||
self.DropItemSlot = None
|
||||
self.prevButton = None
|
||||
self.nextButton = None
|
||||
self.currentPageText = None
|
||||
self.tooltipitem = None
|
||||
self.itemCell = [-1, -1]
|
||||
self.itemCount = 0
|
||||
|
||||
def __del__(self) :
|
||||
ui.ScriptWindow.__del__(self)
|
||||
self.DropDict = None
|
||||
self.MainItemSlot = None
|
||||
self.DropItemSlot = None
|
||||
self.prevButton = None
|
||||
self.nextButton = None
|
||||
self.currentPageText = None
|
||||
self.tooltipitem = None
|
||||
self.itemCell = 0
|
||||
self.itemCount = 0
|
||||
|
||||
def __LoadWindow(self):
|
||||
if self.isLoaded:
|
||||
return
|
||||
|
||||
self.isLoaded = True
|
||||
|
||||
# script
|
||||
try:
|
||||
self.__LoadScript("UIScript/ChestDropInfoWindow.py")
|
||||
except:
|
||||
import exception
|
||||
exception.Abort("ChestDropInfoWindow.__LoadWindow.__LoadScript")
|
||||
|
||||
# object
|
||||
try:
|
||||
self.__BindObject()
|
||||
except:
|
||||
import exception
|
||||
exception.Abort("ChestDropInfoWindow.__LoadWindow.__BindObject")
|
||||
|
||||
# event
|
||||
try:
|
||||
self.__BindEvent()
|
||||
except:
|
||||
import exception
|
||||
exception.Abort("ChestDropInfoWindow.__LoadWindow.__BindEvent")
|
||||
|
||||
def __LoadScript(self, fileName):
|
||||
pyScrLoader = ui.PythonScriptLoader()
|
||||
pyScrLoader.LoadScriptFile(self, fileName)
|
||||
|
||||
def __BindObject(self):
|
||||
self.MainItemSlot = self.GetChild("main_item_slot")
|
||||
self.DropItemSlot = self.GetChild("drop_item_slot")
|
||||
self.prevButton = self.GetChild("prev_button")
|
||||
self.nextButton = self.GetChild("next_button")
|
||||
self.currentPageText = self.GetChild("CurrentPage")
|
||||
|
||||
def __BindEvent(self):
|
||||
self.GetChild("board").SetCloseEvent(ui.__mem_func__(self.Close))
|
||||
|
||||
self.MainItemSlot.SetOverInItemEvent(ui.__mem_func__(self.OverInMainItemSlot))
|
||||
self.MainItemSlot.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
|
||||
|
||||
self.GetChild("open_btn").SetEvent(ui.__mem_func__(self.ClickOpenMultiChest))
|
||||
|
||||
self.GetChild("count_controller").SetEvent(ui.__mem_func__(self.OnChangeCount))
|
||||
|
||||
self.DropItemSlot.SetOverInItemEvent(ui.__mem_func__(self.OverInDropItemSlot))
|
||||
self.DropItemSlot.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
|
||||
|
||||
self.prevButton.SetEvent(ui.__mem_func__(self.SetPage), -1)
|
||||
self.nextButton.SetEvent(ui.__mem_func__(self.SetPage), +1)
|
||||
|
||||
def UpdateItems(self):
|
||||
for i in range(ChestDropInfoWindow.DROP_SLOT_SIZE):
|
||||
self.DropItemSlot.ClearSlot(i)
|
||||
|
||||
if self.CurrentPage in self.DropDict:
|
||||
for pos in self.DropDict[self.CurrentPage]:
|
||||
data = self.DropDict[self.CurrentPage][pos]
|
||||
self.DropItemSlot.SetItemSlot(pos, data[ChestDropInfoWindow.ITEM], data[ChestDropInfoWindow.COUNT])
|
||||
|
||||
self.DropItemSlot.RefreshSlot()
|
||||
|
||||
def ClickOpenMultiChest(self):
|
||||
if player.GetItemIndex(*self.itemCell) != self.ItemVnum:
|
||||
self.Close()
|
||||
return
|
||||
owned = min(player.GetItemCount(*self.itemCell), 1000)
|
||||
if owned <= 0:
|
||||
self.Close()
|
||||
return
|
||||
realpos = max(1, min(owned, int(self.GetChild("count_controller").GetSliderPos()*self.itemCount)))
|
||||
net.SendChatPacket("/chest_drop %d %d %d"%(self.itemCell[0], self.itemCell[1],realpos))
|
||||
self.Close()
|
||||
|
||||
def OnChangeCount(self):
|
||||
if self.itemCount <= 0: return
|
||||
realpos = max(1,min(self.itemCount,int(self.GetChild("count_controller").GetSliderPos()*self.itemCount)))
|
||||
self.GetChild("countSliderText").SetText("%d/%d"%(int(realpos),self.itemCount))
|
||||
|
||||
def UpdateCountSlider(self, itemWindow, itemCell):
|
||||
if itemCell == -1:
|
||||
return
|
||||
self.itemCell = [itemWindow, itemCell]
|
||||
self.itemCount = min(1000, player.GetItemCount(*self.itemCell))
|
||||
|
||||
slider = self.GetChild("count_controller")
|
||||
sliderText = self.GetChild("countSliderText")
|
||||
|
||||
if self.itemCount <= 0:
|
||||
slider.Hide()
|
||||
sliderText.Hide()
|
||||
self.GetChild("open_btn").Hide()
|
||||
return
|
||||
else:
|
||||
self.GetChild("open_btn").Show()
|
||||
slider.Show()
|
||||
sliderText.Show()
|
||||
|
||||
value =1.0/float(self.itemCount)
|
||||
pos = value*1.0
|
||||
slider.SetSliderPos(pos)
|
||||
sliderText.SetText("1/%d"%self.itemCount)
|
||||
|
||||
def SetTooltipItem(self, tooltipItem):
|
||||
self.tooltipitem = tooltipItem
|
||||
def SetPage(self, page):
|
||||
nextpage = page + self.CurrentPage
|
||||
if 0 <= nextpage <= self.PageCount:
|
||||
self.CurrentPage = nextpage
|
||||
self.currentPageText.SetText(str(self.CurrentPage + 1))
|
||||
self.UpdateItems()
|
||||
|
||||
def SetUp(self, itemVnum):
|
||||
self.ItemVnum = itemVnum
|
||||
self.MainItemSlot.SetItemSlot(0, self.ItemVnum, 0)
|
||||
self.MainItemSlot.RefreshSlot()
|
||||
|
||||
(self.PageCount, DropList) = item.GetDropInfo(self.ItemVnum)
|
||||
|
||||
self.DropDict.clear()
|
||||
for i in range(self.PageCount + 1):
|
||||
self.DropDict[i] = dict()
|
||||
|
||||
for page, pos, vnum, count in DropList:
|
||||
self.DropDict[page][pos] = (vnum, count)
|
||||
|
||||
self.CurrentPage = 0
|
||||
self.SetPage(0)
|
||||
|
||||
def Open(self, itemVnum, itemWindow, itemCell):
|
||||
#if self.IsShow():
|
||||
# return
|
||||
|
||||
self.__LoadWindow()
|
||||
self.SetUp(itemVnum)
|
||||
self.UpdateCountSlider(itemWindow, itemCell)
|
||||
self.SetCenterPosition()
|
||||
self.SetTop()
|
||||
self.Show()
|
||||
|
||||
def OverInMainItemSlot(self, slotIndex):
|
||||
if self.tooltipitem:
|
||||
self.tooltipitem.SetItemToolTip(self.ItemVnum)
|
||||
|
||||
def OverInDropItemSlot(self, slotIndex):
|
||||
if self.tooltipitem:
|
||||
if self.CurrentPage in self.DropDict:
|
||||
if slotIndex in self.DropDict[self.CurrentPage]:
|
||||
data = self.DropDict[self.CurrentPage][slotIndex]
|
||||
self.tooltipitem.SetItemToolTip(data[ChestDropInfoWindow.ITEM])
|
||||
|
||||
def OverOutItem(self):
|
||||
if self.tooltipitem:
|
||||
self.tooltipitem.HideToolTip()
|
||||
self.tooltipitem.ClearToolTip()
|
||||
|
||||
def Close(self):
|
||||
self.OverOutItem()
|
||||
self.Hide()
|
||||
|
||||
def OnPressEscapeKey(self):
|
||||
self.Close()
|
||||
return True
|
||||
|
||||
def Batchable(vnum):
|
||||
if not vnum: return False
|
||||
item.SelectItem(vnum)
|
||||
return item.GetItemType()==item.ITEM_TYPE_GIFTBOX
|
||||
|
||||
def Select(self,cell,vnum):
|
||||
self.Open(vnum,player.INVENTORY,cell)
|
||||
ChestDropInfoWindow.Select=Select
|
||||
|
||||
g_window=None
|
||||
_oldOpen=game.GameWindow.Open
|
||||
_oldClose=game.GameWindow.Close
|
||||
_oldCommand=game.GameWindow.BINARY_ServerCommand_Run
|
||||
_oldUse=uiInventory.InventoryWindow._InventoryWindow__UseItem
|
||||
|
||||
def GameOpen(self):
|
||||
global g_window
|
||||
_oldOpen(self)
|
||||
item.ClearDropInfo()
|
||||
g_window=ChestDropInfoWindow()
|
||||
g_window.SetTooltipItem(self.interface.tooltipItem)
|
||||
|
||||
def GameClose(self):
|
||||
global g_window
|
||||
if g_window:
|
||||
g_window.Close()
|
||||
g_window.ClearDictionary()
|
||||
g_window=None
|
||||
item.ClearDropInfo()
|
||||
_oldClose(self)
|
||||
|
||||
def UseItem(self,cell):
|
||||
vnum=player.GetItemIndex(player.INVENTORY,cell)
|
||||
item.SelectItem(vnum)
|
||||
if (g_window and item.GetItemType()==item.ITEM_TYPE_GIFTBOX and
|
||||
not item.IsFlag(item.ITEM_FLAG_CONFIRM_WHEN_USE) and
|
||||
(app.IsPressed(app.DIK_LCONTROL) or app.IsPressed(app.DIK_RCONTROL))):
|
||||
if app.IsPressed(app.DIK_Z):
|
||||
net.SendChatPacket('/chest_drop %d %d %d'%(player.INVENTORY,cell,min(1000,player.GetItemCount(player.INVENTORY,cell))))
|
||||
else:
|
||||
g_window.Open(vnum,player.INVENTORY,cell)
|
||||
return
|
||||
return _oldUse(self,cell)
|
||||
|
||||
def OpenChestDrop(self,vnum):
|
||||
# A late catalogue response must never replace another box or reopen a closed window.
|
||||
if g_window and g_window.IsShow() and g_window.ItemVnum==vnum:
|
||||
g_window.SetUp(vnum)
|
||||
|
||||
def Command(self,line):
|
||||
words=line.split()
|
||||
if words and words[0] in ('chest_reward','chest_opened','chest_error'):
|
||||
if words[0]=='chest_reward' and len(words)==3 and all(x.isdigit() for x in words[1:]):
|
||||
item.SelectItem(int(words[1]))
|
||||
chat.AppendChat(chat.CHAT_TYPE_INFO,L('获得:%s ×%s'%(B(item.GetItemName()),words[2])))
|
||||
elif words[0]=='chest_opened' and len(words)==2 and words[1].isdigit():
|
||||
chat.AppendChat(chat.CHAT_TYPE_INFO,L('背包空间不足,已开启 %s 个宝箱'%words[1]))
|
||||
elif words[0]=='chest_error':
|
||||
chat.AppendChat(chat.CHAT_TYPE_INFO,L('宝箱无法开启或背包空间不足。'))
|
||||
return 1
|
||||
return _oldCommand(self,line)
|
||||
game.GameWindow.BINARY_ServerCommand_Run=Command
|
||||
|
||||
game.GameWindow.Open=GameOpen
|
||||
game.GameWindow.Close=GameClose
|
||||
game.GameWindow.OpenChestDrop=OpenChestDrop
|
||||
uiInventory.InventoryWindow._InventoryWindow__UseItem=UseItem
|
||||
)PY";
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user