Faark / KspLoadOnDemand

Makes KSP assets (atm only part textures) load once required instead of all on startup
14 stars 7 forks source link

KSP .25 incompatibility #1

Closed Gaalidas closed 9 years ago

Gaalidas commented 9 years ago

I suspect all we need is a recompile for the current KSP release. Since 0.25, people have been reporting a message about incompatibility and invalid operations and/or whatnot. I'd try to do it myself, but the project files refuse to load in "sharp develop" which is what I use to recompile other mods for my own preferences.

jgottula commented 9 years ago

I rebuilt the existing LoadOnDemand code against KSP 0.25 with VS2013 to generate LoadOnDemand.dll, NetWrapper.native, and NetWrapper64.native.

I tried it out in KSP 0.25 (32-bit, d3d9 mode) with essentially no other mods. At first it looked like it was going to work, but at the main menu screen, I got the message that something wasn't working right.

Going into the VAB and elsewhere, the game seemed to have reverted harmlessly to the normal way of loading textures (part entries were full res, not thumbnails; no texture pop-in; etc).

The relevant snippet from KSP.log:

[WRN 11:21:51.618] [HighLogic]: =========================== Scene Change : From LOADING to MAINMENU =====================
[LOG 11:21:52.420] AddonLoader: Instantiating addon 'LegacyInterface' from assembly 'LoadOnDemand'
[LOG 11:21:52.421] AddonLoader: Instantiating addon 'ActivityGUI' from assembly 'LoadOnDemand'
[LOG 11:21:52.422] AddonLoader: Instantiating addon 'DevStuff' from assembly 'LoadOnDemand'
[LOG 11:21:52.423] AddonLoader: Instantiating addon 'StartupDelayed' from assembly 'LoadOnDemand'
[LOG 11:21:52.429] LoadOnDemand: FinSetup: True
[LOG 11:21:52.430] LoadOnDemand: Sending Texture Info to net4
[EXC 11:21:52.436] InvalidOperationException: Operation is not valid due to the current state of the object
    System.Linq.Enumerable.Iterate[KeyValuePair`2,Int32] (IEnumerable`1 source, Int32 initValue, System.Func`3 selector)
    System.Linq.Enumerable.Max[KeyValuePair`2] (IEnumerable`1 source, System.Func`2 selector)
    LoadOnDemand.Managers.TextureManager.FinalizeSetup ()
    LoadOnDemand.Logic.StartupDelayed.Awake ()
    UnityEngine.GameObject:AddComponent(Type)
    AddonLoader:StartAddon(LoadedAssembly, Type, KSPAddon, Startup)
    AddonLoader:StartAddons(Startup)
    AddonLoader:OnLevelWasLoaded(Int32)
[LOG 11:21:52.439] AddonLoader: Instantiating addon 'WorkQueue' from assembly 'LoadOnDemand'
[LOG 11:23:13.169] Game State Created.
[LOG 11:23:13.179] ScenarioTypes: List Created 9 scenario types loaded from 4 loaded assemblies.
[LOG 11:23:13.188] Game State Saved as persistent
[WRN 11:23:13.189] [HighLogic]: =========================== Scene Change : From MAINMENU to SPACECENTER (Async) =====================

Here's a dropbox folder containing the recompiled DLL's and the full logs and such: https://www.dropbox.com/sh/zjxignll9fpzaej/AAArjh9nFcvkIGt0g1i1cEuxa?dl=0

Hope this helps.

Faark commented 9 years ago

Yes, seems like someone broke/changed the file type recognition of KSP's internal file listing. Textures are now "unknown" instead of "texture" when LOD tries to find them for models&co, making it ignore them and later crash because of "no textures". Easy to work around, but so far only lead to the next issue with .25 :(

Gaalidas commented 9 years ago

So are we unable to get this to work in .25 then? Fortunately, I've been able to launch without this successfully, but the loading times are very much increased.

Faark commented 9 years ago

It means we have to figure out a [new] solution for how to make the game not load textures LOD wants to take care of. Worst one would be to let the game load the texture, unload again, then do our stuff. Kinda like ATM did/does again. But that would be a stupid solution (and not save any loading time) and i hope we can find some better one.

Gaalidas commented 9 years ago

Well, if you can't find one soon, I'll take that stupid solution. I just had a crash that I believe would not have occurred with your mod running. Unfortunately when it comes to coding and finding solutions for complex stuff like this, I'm rather useless. I suppose even worse case scenario would be to literally cause the game not to see the textures (sorta like KerbPaint masks where removing the extension of the file causes it to become invisible) by hand or using a batch file, then start the whole texture management thing before the game freaks out about missing textures for its models and such. But that, I think, is even stupider than your stupid idea. See? I can be stupid too!

Gaalidas commented 9 years ago

Interesting little tidbit of info... So, it seems the KSP people added the ability to define alternate and/or custom asset loaders. sarbian has already made us a DDS loader as a result. Maybe that would be a good place to start for figuring out this problem we have.

Faark commented 9 years ago

Ive uploaded v3.3 that should work with .25. I'll mark this issue as resolved. Please reopen it there are any problems.

Those custom assert loader seem useless for this project. Its only allows modders to add custom file types (aka new file extensions). It kinda makes it worse, actually, since i'm not sure whether LOD could easily load DDS files. Hope mods wont exclusively rely on them.

Btw, DDS (aka DXT compression) is sth that was on the todo list for ages, just haven't found the time to actually choose and integrate some compression library. But others doing the same now should help.