fix(client): drain flying objects before effect shutdown

This commit is contained in:
shen
2026-10-16 23:12:13 -07:00
parent 569afb1378
commit b9f5d737cb
4 changed files with 22 additions and 1 deletions
+1
View File
@@ -651,3 +651,4 @@
{"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"]}
@@ -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"
}
}
}
+9
View File
@@ -1244,6 +1244,15 @@ void Stop()
mt::meshport::shutdown(); // PORT: join SDK worker and stop mesh before Python/platform teardown.
#endif
g_launcher->Clear();
// CPythonApplication::Destroy clears flying objects before characters and
// effects. A live missile's ClearAttachInstance still calls CEffectManager;
// leaving it for g_flying_manager's destructor used a destroyed singleton.
if (g_flying_manager)
g_flying_manager->Destroy();
// GameSingletons members are destroyed in reverse declaration order. Drain
// characters while pyTextTail, pyItem and pyBackground are still alive.
if (g_game_singletons)
g_game_singletons->kChrMgr.Destroy();
g_game_singletons.reset();
g_game_application.reset();
g_effect_manager.reset();
+10
View File
@@ -26,6 +26,8 @@
#include "EterLib/StateManager.h"
#include "EterLib/Util.h"
#include "EterPythonLib/PythonGraphic.h"
#include "GameLib/FlyingObjectManager.h"
#include "GameLib/FlyingInstance.h"
#include <dinput.h> // DIK_ESCAPE
#include <cmath>
@@ -425,9 +427,17 @@ int main(int argc, char** argv)
frames(1);
CHECK(!PythonBoot::IsAppLooping());
CHECK(py("assert _stream.curPhaseWindow == 0 and _stream.popupWindow == 0"));
// A missile may still be travelling when the window closes. Its attachments
// must be destroyed before the effect singleton, as in CPythonApplication::Destroy.
const char* flying = "d:/ymir work/effect/etc/gathering/ga_piece_yellow_small2.msf";
DWORD flying_crc = 0;
CFlyingManager::Instance().RegisterFlyingData(flying, flying_crc);
CHECK(CFlyingManager::Instance().CreateFlyingInstanceFlyTarget(flying_crc,
D3DXVECTOR3(0, 0, 0), CFlyTarget(D3DXVECTOR3(1000, 0, 0)), false));
PythonBoot::Stop();
CHECK(!PythonBoot::IsRunning());
PythonBoot::Stop(); // teardown remains idempotent
if (g_failures)
std::fprintf(stderr, "%d check(s) failed\n", g_failures);