Jump to content

[1.9.x] OSE Workshop Reworked - KIS Addon


linuxgurugamer
 Share

Recommended Posts

On 6/10/2020 at 11:08 AM, MoonstreamInSpace said:

This is the log: (More exactly, the part that was repeating again and again)

  Reveal hidden contents

[EXC 11:04:50.304] InvalidCastException: Specified cast is not valid.
    Workshop.W_KIS.KISWrapper.GetInventories (Vessel vessel) (at <476ea10d65914767a3468907f8f1d0d0>:0)
    Workshop.OseModuleWorkshop.AddToContainer (Workshop.WorkshopItem item) (at <476ea10d65914767a3468907f8f1d0d0>:0)
    Workshop.OseModuleWorkshop.FinishManufacturing () (at <476ea10d65914767a3468907f8f1d0d0>:0)
    Workshop.OseModuleWorkshop.ProcessItem (System.Double deltaTime) (at <476ea10d65914767a3468907f8f1d0d0>:0)
    Workshop.OseModuleWorkshop.FixedUpdate () (at <476ea10d65914767a3468907f8f1d0d0>:0)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
    UnityEngine.Debug:LogException(Exception)
    Workshop.WorkshopUtils:LogError(String, Exception)
    Workshop.OseModuleWorkshop:FixedUpdate()
[ERR 11:04:50.307] [OSE] - OseModuleWorkshop_OnUpdate

[EXC 11:04:50.314] InvalidCastException: Specified cast is not valid.
    Workshop.W_KIS.KISWrapper.GetInventories (Vessel vessel) (at <476ea10d65914767a3468907f8f1d0d0>:0)
    Workshop.OseModuleWorkshop.AddToContainer (Workshop.WorkshopItem item) (at <476ea10d65914767a3468907f8f1d0d0>:0)
    Workshop.OseModuleWorkshop.FinishManufacturing () (at <476ea10d65914767a3468907f8f1d0d0>:0)
    Workshop.OseModuleWorkshop.ProcessItem (System.Double deltaTime) (at <476ea10d65914767a3468907f8f1d0d0>:0)
    Workshop.OseModuleWorkshop.FixedUpdate () (at <476ea10d65914767a3468907f8f1d0d0>:0)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
    UnityEngine.Debug:LogException(Exception)
    Workshop.WorkshopUtils:LogError(String, Exception)
    Workshop.OseModuleWorkshop:FixedUpdate()
[LOG 11:04:50.321] 6/10/2020 11:04:50 AM,HLAirships,DEBUG: OnShowGUI Fired

Basically, it seems that OSE Workshop doesn't actually recognize Pathfinder-configured inventories.

I can work around this by using Kontainers or other inventories, but if you could fix this when you have the chance, that would be great.

Has anyone found a fix for this?

Link to comment
Share on other sites

2 hours ago, MoonstreamInSpace said:

Could you PLEASE fix this to work with Pathfinder?

How is that the job of this mod?  It seems if Pathfinder wanted to use THIS mod's functionality it is pathfinders job to make this work with pathfinder parts.

Link to comment
Share on other sites

On 6/16/2020 at 1:03 PM, goldenpsp said:

How is that the job of this mod?  It seems if Pathfinder wanted to use THIS mod's functionality it is pathfinders job to make this work with pathfinder parts.

It's broken with Kontainers and MKS as well. I don't think it works with anything but the built-in workshops, so it's not just Pathfinder.

What does "specified cast is not valid" even mean?

Edited by MoonstreamInSpace
Link to comment
Share on other sites

25 minutes ago, MoonstreamInSpace said:

What does "specified cast is not valid" even mean?

It's an error thrown in programming when you try to assign an object to a variable defined as a class that the object cannot be resolved into. For example:

String bob = "Bob"

Long boom = bob

In the above pseudocode, the variable 'bob' has been defined as a String. The next line tries to assign the value of the 'bob' variable to the 'boom' variable - however, the 'boom' variable is defined as a Long (a type of number) and the String class is not valid to assign to it. Hence, it will throw the 'specified cast is not valid' error.

Edited by Bombaatu
Link to comment
Share on other sites

2 hours ago, MoonstreamInSpace said:

It's broken with Kontainers and MKS as well. I don't think it works with anything but the built-in workshops, so it's not just Pathfinder.

What does "specified cast is not valid" even mean?

Ok,  and the configs for MKS and kontainers are part of MKS.  @linuxgurugamer is in charge of making sure this mod works with this mods parts.  It isn't his job to make sure it works with all the parts of other mods.  If MKS wants to integrate with this mod its the job of MKS etc.

Link to comment
Share on other sites

17 hours ago, goldenpsp said:

Ok,  and the configs for MKS and kontainers are part of MKS.  @linuxgurugamer is in charge of making sure this mod works with this mods parts.  It isn't his job to make sure it works with all the parts of other mods.  If MKS wants to integrate with this mod its the job of MKS etc.

Well, I'm getting the same error no matter what I print from, so I thought maybe the people who made the mod that's throwing the same exception for 2 different mods might know at least something. I think it has something to do with the fact that both MKS and Pathfinder use configurable modules for OSE Workshops (the same part can be changed from Workshop to non-workshop and back in the same flight). I will talk to the developers of the other mods.

Link to comment
Share on other sites

42 minutes ago, MoonstreamInSpace said:

Well, I'm getting the same error no matter what I print from, so I thought maybe the people who made the mod that's throwing the same exception for 2 different mods might know at least something. I think it has something to do with the fact that both MKS and Pathfinder use configurable modules for OSE Workshops (the same part can be changed from Workshop to non-workshop and back in the same flight). I will talk to the developers of the other mods.

Except you didn't as @linuxgurugamer knew anything.  You asked.

 

On 6/16/2020 at 10:51 AM, MoonstreamInSpace said:

Could you PLEASE fix this to work with Pathfinder?

 

Now maybe if you said hey @linuxgurugamer I'm trying to track down and issue so maybe I can help everyone figure it out.  It seems that other mods with configurable containers  are not being properly seen as proper KIS storage for OSE print output.  Do you have any insight on what I can look at, or a specific parameter in the config that might be causing this?

Hey that wasn't a half bad question if I say so myself :)  Maybe he has an answer so we can actually help fix the problem.

Some modders can get very busy.  I mean Linuxgurugamer has taken over maintenance of more mods than I can count.  This one IIRC he didn't really want to  as he is already swamped but he did anyway.  These guys are volunteering their time to create the mods we enjoy.

Link to comment
Share on other sites

6 hours ago, goldenpsp said:

Some modders can get very busy.  I mean Linuxgurugamer has taken over maintenance of more mods than I can count.  This one IIRC he didn't really want to  as he is already swamped but he did anyway.  These guys are volunteering their time to create the mods we enjoy.

Right, sorry.

Edited by MoonstreamInSpace
Link to comment
Share on other sites

I have a problem with the actual Workshop included in the mod (Workshop Chemical,to be exact). It just doesn't recognize inventories. It has a KIS Kontainer attached radially, and one of the containers that came with KIS, but it says "volume-0 liters" (attached to the bottom node). I would love it if someone would help. One of the weird things about this was that the "Casa" (from Pathfinder) and the "Ranger Portable Workshop" from MKS, when configured as OSE Workshops, recognized the storage (they said volume-16000, which was what I had available, but still threw "specified cast is not valid" errors).

Edit: The workshop actually works, it was probably just set up in the wrong place. The "specified cast" errors still exist, but at least there are workarounds.

I have literally no understanding for how OSE works in the code, and would appreciate some help to understand what I'm doing wrong.

Edited by MoonstreamInSpace
Link to comment
Share on other sites

@linuxgurugamer  I've encountered the same "InvalidCastException: Specified cast is not valid." issue with OSE and Pathfinder and it was bugging me a lot, so I did a bit of debugging and the reason seems to be the following.

KISWrapper.GetInventories (both overloads) checks moduleName (module.moduleName == "ModuleKISInventory") and pushes the module into ModuleKISInventory constructor that performs the casting (KIS.ModuleKISInventory)obj. Apparently, @Angel-125 inventories are something else, probably due to being a configurable parts/modules. I've added some logging into OSE code from Github and got these results:

[OSE] - Module is not KIS.ModuleKISInventory - WBI.Ponderosa2 class WBIOSEWorkshop
[OSE] - Module is not KIS.ModuleKISInventory - WBI.Hacienda class WBIOSEWorkshop

Overall, the "root problem" seems to be on Pathfinder side, i.e. having (moduleName == "ModuleKISInventory") while not being derived from (KIS.ModuleKISInventory).

Nevertheless, it's probably reasonable to do a defensive check in KISWrapper.GetInventories before passing the module to Workshop.W_KIS.ModuleKISInventory wrapper. I added the simple sanity check and it fixed the casting exception.

if (module.moduleName == "ModuleKISInventory")
{
    if (module is KIS.ModuleKISInventory) {
        inventories.Add(new ModuleKISInventory(module));
    } else {
        WorkshopUtils.LogError("Module is not KIS.ModuleKISInventory - " + module.name + " class " + module.ClassName);
    }
}

Moreover, as I can see, Pathfinder's parts also have actual KIS.ModuleKISInventory, because the workshop production, favoring etc - it's all working okay with this adjustment.

(I'll try to look into @Angel-125 code and his WBIOSEWorkshop and WBIInflatablePartModule to see why those moduleName's are "ModuleKISInventory" too, but I suspect there was a reason for that).

Link to comment
Share on other sites

@linuxgurugamer Thank you!

It seems that I've stumbled upon a non-critical, but performance-affecting issue. Not sure if it's specific for 1.10 or it's something affecting 1.9 too.

So far, I was able to reproduce it reliably if I quickload a game with kerbal in focus near the ship with OSE workshop. OseModuleHighlighter object ends up with highlightID=-1 and this leads to the following endless spam in the log:

KSP_PartHighlighter: CheckInit, id not found: -1
 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)

KSP_PartHighlighter: Stack:   at System.Environment.get_StackTrace () [0x00000] in <ad04dee02e7e4a85a1299c7ee81c79f6>:0 
  at KSP_PartHighlighter.PartHighlighter.CheckInit (System.Int32 id) [0x00000] in <1ed612a5ff2247e48ae3b8c639ba4f98>:0 
  at KSP_PartHighlighter.PartHighlighter.SetHighlighting (System.Int32 id, System.Boolean active) [0x00000] in <1ed612a5ff2247e48ae3b8c639ba4f98>:0 
  at Workshop.OseModuleHighlighter.LateUpdate () [0x00000] in <6860bce87fea4157971fd6d131e9f48d>:0 
 
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)

As it's inside update method, this can quickly inflate log file to hundreds of MB and affects framerate significantly.

I was able to locate the following in the log before the first CheckInit error and I believe it's the main reason for -1

KSP_PartHighlighter: CreateHighlightList: An item with the same key has already been added. Key: 0
KSP_PartHighlighter: CreateHighlightList: An item with the same key has already been added. Key: 1

As I understand, this comes from https://github.com/linuxgurugamer/SpaceTuxLibrary/blob/master/KSP_PartHighlighter/PartHighlighter.cs and is probably because of highlightCnt not being static, while the Dictionary is. Not totally sure if this is the root cause or there is something more to the story, but I think it should be enough for debug.

int highlightCnt = 0;
...
private static Dictionary<int, HighlightParts> hPartsLists = null;

 

Link to comment
Share on other sites

4 hours ago, Sibiro said:

As I understand, this comes from https://github.com/linuxgurugamer/SpaceTuxLibrary/blob/master/KSP_PartHighlighter/PartHighlighter.cs and is probably because of highlightCnt not being static, while the Dictionary is. Not totally sure if this is the root cause or there is something more to the story, but I think it should be enough for debug.

Update to the latest release of the SpaceTuxLibrary, this was recently fixed

Link to comment
Share on other sites

9 hours ago, linuxgurugamer said:

Update to the latest release of the SpaceTuxLibrary, this was recently fixed

@linuxgurugamer I've checked it today on a latest version 0.0.3.6 on a (mostly) clean install of KSP. The issue is still there, unfortunately.

Moreover, this time I've got it right when the ship was spawned on runway from SPH, and it was the first ship spawned in the new game.

Relevant messages in the log:

------------------- initializing editor mode... ------------------
editor started
...
KSP_PartHighlighter: UpdateHighlightColors, id: 0
OSE.Workshop added to ship - part count: 2
...
[HighLogic]: =========================== Scene Change : From EDITOR to FLIGHT (Async) =====================
...
------------------- initializing flight mode... ------------------
Loading ship from file: D:/SteamGames/ksp/sandbox_1/KSP_x64_Data/../saves/ose_test/Ships/SPH/Auto-Saved Ship.craft
OSE Test loaded!
[OSE Test]: Ready to Launch - waiting to start physics...
...
[FLIGHT GLOBALS]: Switching To Vessel OSE Test ---------------------- 
...
KSP_PartHighlighter: CreateHighlightList: An item with the same key has already been added. Key: 0

KSP_PartHighlighter: CheckInit, id not found: -1
... 
KSP_PartHighlighter: Stack:   at System.Environment.get_StackTrace () [0x00000] in <ad04dee02e7e4a85a1299c7ee81c79f6>:0 
  at KSP_PartHighlighter.PartHighlighter.CheckInit (System.Int32 id) [0x00000] in <1ed612a5ff2247e48ae3b8c639ba4f98>:0 
  at KSP_PartHighlighter.PartHighlighter.SetHighlighting (System.Int32 id, System.Boolean active) [0x00000] in <1ed612a5ff2247e48ae3b8c639ba4f98>:0 
  at Workshop.OseModuleHighlighter.LateUpdate () [0x00000] in <d31ffa410ef0460a8ebc3e4a1ab78d84>:0 

KSP_PartHighlighter: CheckInit, id not found: -1
(repeating)

Here is the full log  https://www.dropbox.com/s/6a014jo92zjv9bm/log_ose_parthighlighter_test.zip?dl=0

As I can see, the Source code linked along with the release here https://github.com/linuxgurugamer/SpaceTuxLibrary/releases/tag/0.0.3.6 still have static Dictionary and non-static highlightCnt. Maybe something didn't get into the main branch at some point?

Link to comment
Share on other sites

3 hours ago, Sibiro said:

@linuxgurugamer I've checked it today on a latest version 0.0.3.6 on a (mostly) clean install of KSP. The issue is still there, unfortunately.

Moreover, this time I've got it right when the ship was spawned on runway from SPH, and it was the first ship spawned in the new game.

Relevant messages in the log:

You are correct, it was a different bug which I fixed with the same symptoms.

I'll be releasing an update to the library in a few minutes

Link to comment
Share on other sites

  • 1 month later...

Hi all,

Is there a way to print items that are not in the standard categories? In specific I would like to print out some mks mini packs. If I try to enter the part name in search as shown in the VAB but no joy (actually I do not think search field is working).

Is the above supposed to work and should I look for mod conflicts or did I miss a thing to install (got all the dependencies as listed in the op).

Thanks

Seems that I am a bit of a numpty, in the settings I can enable the "misc category" which will allow me to access these other parts.

Edited by invultri
Link to comment
Share on other sites

Hi @linuxgurugamer

It seems there is a minor issue when a workshop completes a job and there is no space available the game will start stalling (actually locked up the pc once). I guess the inventories are checked a bit to aggressively in this case. This is easily preventable, but might be something that you could check up on whenever you have to update this mod.

Edit: Pausing the workshop job will remove the stall and return the game to normal performance.

Thanks for keeping these mods alive.

 

Edited by invultri
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

Hey, @linuxgurugamer

I have run into a hiccup here. While loading the PartRecipe for USI Otter components, it gives a NullReferenceException: Object reference not set to an instance of an object. Was working fine a day back as in I was playing alright but today, ( even when far as I know I dint do any major change to the wildfire, that is my mod list).

Log

Edited by rlq
Tagged OP
Link to comment
Share on other sites

4 hours ago, rlq said:

Hey, @linuxgurugamer

I have run into a hiccup here. While loading the PartRecipe for USI Otter components, it gives a NullReferenceException: Object reference not set to an instance of an object. Was working fine a day back as in I was playing alright but today, ( even when far as I know I dint do any major change to the wildfire, that is my mod list).

Log

I need the Player.log, as well as knowing what you were trying to do

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...