Image Caching Hell, but Progress
Hey Folks! Been a bit of a rough day, as I wrestle with Asset caching in the engine in order to load assets.
Pretty much most of the day was spent trying and failing to get the game loading bitmaps into mod containers. In the PC version, the engine loads each mod into a separate data container, so when the game requests an asset by ID, it first checks which mod to get it from, then loads it from there.
However, the mobile version defers a lot of its asset loading until the last possible moment before an asset is displayed. As such, it loads things using different methods, and those bypass mod containers.
Also, they seem to use OpenFL/Haxe/Flixel's built-in Asset caching, which is intended to only keep stuff in memory when needed, and remove it when done. Again, great in a performance-limited environment like mobile. However, it plays havoc with trying to load bitmaps in advance, since they almost all get dumped immediately when the cache sees they're not used yet.
And annoyingly, no amount of my trying to turn caching off, or bypassing it, seems to help. I always get a hodge-podge of missing images when I try to load things my way. Even if I create byte-copies of bitmaps after loading them, storing the copies, they get wiped. I can't see to get direct access to a bitmap that the cache can't touch, and my loaded bitmaps all disappear.
Anyway, today's screenshot is what I see now that I'm back to using the built-in cache loading that ignores mod paths. Just about everything loads now, except hex maps. I did manage to fix the explosive memory leak, which turned out to be the hex map trying to load new copies of each hex art each frame. So that's good. But I'm still not sure why I have blank hexes.
And once that's fixed, I'll have to return to the modding path issue. How can I intercept asset loads to ensure the game looks at the right mod? We'll see.
So far, I still think this is doable. But there's a lot to be done!