
Map Close Crash Bugfix - Direct ApseMap.gfx Edit
This mod resolves a bug Warhorse probably introduced in a recent patch that makes the map crash the game when you close it.
查看大图[size=4][b]Installation instructions[/b][/size]
[color=#D4D4D8]Install in your \KingdomcomeDeliverance2\Mods\ folder like any other mod[/color]
Without this mod installed, open your windows resource monitor and leave it open on the screen that shows your memory usage. Go in game and open/close the map 100 times and look at your memory usage just slowly climbing up. This doesnt happen anymore after this fix. Neither should the crashing[b][size=4] related to the map closing [/size][size=5][u]specifically[/u][/size][/b]. I've tested on 800+ open/closes with no crash and its good enough for me. I can live with those odds.
[b][size=4]Compatibility[/size]:[/b]
Not compatible with mods that ship their own ApseMap.gfx except for [url=https://www.nexusmods.com/kingdomcomedeliverance2/mods/3338]Elfi's UI Tweaks[/url] who gave me permission to publish a patch between our two ApseMap.gfx files. Credits for the map tweaks his mod provides go to him. Just follow the load order in the optional file download.
[size=5][b]Crash On Map Close Fix — technical summary[/b][/size]
The bug (vanilla ApseMap.gfx)
The world map is a streaming tile engine. GlobalMap.Load and LocalMap.Load pull each map tile in asynchronously via MovieClipLoader.loadClip("img://Libs/UI/Textures/Maps/…dds", tileClip); the engine signals completion by calling back into cry_onStreamed. On close (fc_clear), the teardown paths — GlobalMap.Unload, LocalMap.Unload, and LocalMap.Clear — dispose the tiles with removeMovieClip() only. Crucially, removeMovieClip() tears down the display object but does not cancel a pending img:// load or release the streamed DDS texture, and there is no unloadClip/unloadMovie call anywhere in the file.
That single omission produces two failures, one root cause:
Crash on close. With deferred UI unload (wh_ui_ApseUnloadMode ≥ 1), the map movie is freed after the close. If a tile stream is still in flight, its completion lands on a freed/removed target → native crash. It's a race — random (roughly 1-in-many closes), worse the more aggressively the engine frees (mode 1 = crashiest), and absent at mode 0 only because the synchronous unload cancels streams atomically.
Memory leak. Tiles that finished streaming are never released on close either, so every map open allocates a fresh tile-set on top of ones never reclaimed → monotonic memory growth → eventual out-of-memory crash.
The fix
Cancel each tile's stream before removing its clip. Added tileClip.unloadMovie() immediately before every teardown removeMovieClip() in the three sites (a loop over m_TilesA in GlobalMap.Unload, LocalMap.Unload, and LocalMap.Clear). unloadMovie() both cancels a pending img:// load (kills the race) and releases a finished texture (kills the leak). It runs only during map teardown, so normal map use is unaffected.
Method
Decompiled ApseMap.gfx with FFDec, edited the two ActionScript classes (__Packages/GlobalMap.as, __Packages/LocalMap.as), recompiled just those with FFDec's assembler (all other scripts left byte-untouched), and re-wrapped the CFX container. Verified the result parses end-to-end and contains the change; the crash fix is validated in-game (800+ open/close cycles at apseunloadmode = 1 with flat memory and no crash). Shipped as a whole-file ApseMap.gfx override built from vanilla.
还没有人评论,去客户端里说两句吧。
评论在新手盒子客户端中发表,这里同步展示。