Jump to content

[KSP >= 1.3.0] TweakScale - Under Lisias' Management - 2.4.7.5 - 2024-0213


Lisias

Recommended Posts

Already on it.

Stock, TweakScale, ModuleManager: No issues

Stock, TweakScale, ModuleManager & HullcamVDS:

[ERR 10:49:06.662] [TweakScale] Exception on kerbalEVA.prefab.Modules.Contains: System.NullReferenceException: Object reference not set to an instance of an object
  at PartModuleList.Contains (Int32 classID) [0x00000] in <filename unknown>:0 
  at PartModuleList.Contains (System.String className) [0x00000] in <filename unknown>:0 
  at TweakScale.PrefabDryCostWriter+<WriteDryCost>d__4.MoveNext () [0x00000] in <filename unknown>:0 

[WRN 10:49:06.662] PartModuleList
[ERR 10:49:06.662] [TweakScale] Exception on kerbalEVAfemale.prefab.Modules.Contains: System.NullReferenceException: Object reference not set to an instance of an object
  at PartModuleList.Contains (Int32 classID) [0x00000] in <filename unknown>:0 
  at PartModuleList.Contains (System.String className) [0x00000] in <filename unknown>:0 
  at TweakScale.PrefabDryCostWriter+<WriteDryCost>d__4.MoveNext () [0x00000] in <filename unknown>:0 

Link to comment
Share on other sites

So, I did another run with base+DeadlyReentry and get these 180x:

[ERR 10:57:16.331] [TweakScale] part=0625.Heatshield (0.625m Heatshield) Exception on writeDryCost: System.NullReferenceException: Object reference not set to an instance of an object
  at PartModuleList.Contains (Int32 classID) [0x00000] in <filename unknown>:0 
  at PartModuleList.Contains (System.String className) [0x00000] in <filename unknown>:0 
  at TweakScale.PrefabDryCostWriter+<WriteDryCost>d__4.MoveNext () [0x00000] in <filename unknown>:0 


There are 318 parts in stock KSP.  With DE, 329 (4 heatshiels + 4 decouplers + 3 others (I'm guessing kerbalEVA, kerbalEVAFemale, kerbalEVAVinatage)

With only DE (no TS) everything is fine.

Again, with HcVDS (no TS), fine.

With HcVDS, the kerbalEVA exceptions ONLY.

Link to comment
Share on other sites

So here is something I was investigating that I find interesting.  You'll notice in all the DRE errors you have 'TweakScale.PrefabDryCostWriter+<WriteDryCost>d__4.MoveNext ()'.

I found this explanation for the MoveNext prefix: 

The d__4 portion is a prefix that is generated by the C# compiler to keep the construct unique from other generated members / types. In this case the d prefix means that it is an iterator or async method generated class (d is used for both). The number is just incremented for every name that is generated.

Is this a thing since the d__# never increments?

(Note: I have ZERO experience with C#.)

Link to comment
Share on other sites

3 hours ago, TranceaddicT said:

So, I did another run with base+DeadlyReentry and get these 180x:

[ERR 10:57:16.331] [TweakScale] part=0625.Heatshield (0.625m Heatshield) Exception on writeDryCost: System.NullReferenceException: Object reference not set to an instance of an object
[CUT by me]

Oh, delight. :D  I tried KSP 1.4.5 + TweakScale + TweakableEverything + Deadly Reentry + "MM /L Experimental" and the test KSP capsized before even finishing the load! :D 

By deleting TweakableEverything, KSP managed to finish loading and I could confirm the behaviour. But, and I want to make this absolutely clear, TweakableEverything was working absolutely fine on the previous testings (Impossible Innovations + B9 + AirplanePlus).

"My" /L Experimental fork for MM has a kind of a weakness that I'm exploiting to check the DLLs health: due being fired up early on KSP load chain, and due relying on KSPe services (that constantly probe all the loaded DLLs by Reflection), anything, absolutely anything wrong on any, absolutely any DLL blows up everything. So, I have an early and screaming notice of something that would silently fail later.

(this weakness is so useful at the moment that I didn't bothered to fix it yet! :sticktongue:)

By coincidence, or not, this Exception are repeated ad nauseam until the bitter end:

[EXC 20:52:09.573] ReflectionTypeLoadException: The classes in the module cannot be loaded.
        System.Reflection.Assembly.GetTypes ()
        KSPe.IO.File`1+<>c[ModuleManager.ModuleManager].<FullPathName>b__6_0 (System.Reflection.Assembly assembly)
        System.Linq.Enumerable+<CreateSelectManyIterator>c__Iterator14`3[System.Reflection.Assembly,System.Type<>f__AnonymousType0`2[System.Reflection.Assembly,System.Type]].MoveNext ()
        System.Linq.Enumerable+<CreateWhereIterator>c__Iterator1D`1[<>f__AnonymousType0`2[System.Reflection.Assembly,System.Type]].MoveNext ()
        System.Linq.Enumerable+<CreateSelectIterator>c__Iterator10`2[<>f__AnonymousType0`2[System.Reflection.Assembly,System.Type],System.Type].MoveNext ()
        System.Linq.Enumerable.FirstOrDefault[Type] (IEnumerable`1 source)
        KSPe.IO.File`1[ModuleManager.ModuleManager].FullPathName (System.String partialPathname, System.String hierarchy, Boolean createDirs)
        KSPe.PluginConfig.ForType[ModuleManager] (System.String name, System.String filename)
        ModuleManager.MMPatchLoader..cctor ()
        Rethrow as TypeInitializationException: An exception was thrown by the type initializer for ModuleManager.MMPatchLoader
        ModuleManager.ModuleManager.Update ()

Did you noticed the "MoveNext()" on the StackDump? Me too. :) 

All of this hint me that perhaps I'm chasing ghosts on trying to find an add-on (or set of add-ons) badly incompatible with TweakScale. The problem appears to be not on the Add-On, but on something on the environment where some add-ons bork by stumbling on the very same thing "my" MM stumble (but, being in the critical path of the load process, blows up everything on the act).

I know for sure that the absence of a DLL that it's a dependency of another one causes this critical failure on MM /L (frankly, it's a failure on the Mono's VM by leaving its internal data structures in a inconsistent state, but whatever - it's me the one that have to workaround it).

So, I'm guessing that, in reality, we are facing some kind of dynamic linking problem. And such linking problem is tampering the add ons that relies on Reflection.

 

Edited by Lisias
hit "Save" too soon.
Link to comment
Share on other sites

@Lisias

One part which could defiantly use a tweakscale fix is the RoveMax Model XL3. The problem is that whenever you try to scale it up, it no longer can properly turn.  My first guess is that a tweakscaleconfig should be added for ModuleWheelMotorSteering and scale steeringTorque with exponent 2

Edited by FreeThinker
Link to comment
Share on other sites

23 hours ago, TranceaddicT said:

So here is something I was investigating that I find interesting.  You'll notice in all the DRE errors you have 'TweakScale.PrefabDryCostWriter+<WriteDryCost>d__4.MoveNext ()'.

[…]

(Note: I have ZERO experience with C#.)

Dude… I should had paid more attention to your post. :) 

Imagine the following scenario: TweakScale V-1 generated a code. Then some revisions later, the synthetic methods are generated in a different order or whatever. As long such synthetic methods are used only by the current DLL, no problem - but if by some reason such methods are not "internal" to the DLL, and other DLLs manage to link against them, then we have chaos - clients calling one thing thinking it's other completely different.

It's a looong shot to imagine that such mishap would had been allowed to leak - but… I already saw some problems being solved by merely recompiling the thing, so…. I think I'm going to start another recompile fest tonight.

On 10/31/2018 at 6:35 PM, Nicky21 said:

What do i need to change in what files so that when i scale up the Extraplanetary Launchapds workshops using tweakscale its productivity scales appropriately?

You will need to ask the Launchpad's maintainer for that info, as I don't know (at least, yet) this module's guts in order to help you. Sorry.

But once that info is available, building the patch would be relatively straightforward..

Link to comment
Share on other sites

The kerbalEVA* issue that happens with HulcamVDS , doesn't happen on a identically installment on KSP 1.4.1 - I literally copied the MODs from 1.4.5/GameData to 1.4.1/GameData - being the only difference the Squad's folder (of course) and the absence of the SquadExpansion folder.

DeaflyReentry, however, blew up on millions of colours - but I put that on the "no supported version" basket. Not an issue.

So I decided to test KSP 1.4.5 with and without SquadExpansion, and got the very same results: NREs on kerbalEVA.

But at least, I know have a hint: it's a problem between KSP itself and some mods (not TweakScake).
 

— POST — EDIT —

Test done. No news. Same behaviour.

```
[ERR 20:52:15.960] [TweakScale] Exception on kerbalEVAfemale.prefab.Modules.Contains: System.NullReferenceException: Object reference not
 set to an instance of an object
  at PartModuleList.Contains (Int32 classID) [0x00000] in <filename unknown>:0
  at PartModuleList.Contains (System.String className) [0x00000] in <filename unknown>:0
  at TweakScale.PrefabDryCostWriter+<WriteDryCost>d__4.MoveNext () [0x00000] in <filename unknown>:0
```

This happens on KSP 1.4.3, but not on KSP 1.4.1. Compiling the DLLs against newer KSP libraries doesn't changed the behaviour.

Edited by Lisias
NEW INFORMATION
Link to comment
Share on other sites

On 10/31/2018 at 3:52 PM, TranceaddicT said:

Already on it.

Stock, TweakScale, ModuleManager: No issues

Stock, TweakScale, ModuleManager & HullcamVDS:

I logged the exception on that code of HullcamVDS:

try
{
	PartLoader.getPartInfoByName("kerbalEVA").partPrefab.AddModule(EVA);
}
catch (Exception e)
{
	Debug.LogException(e);
}

And got this:

Spoiler

[EXC 21:05:08.963] NullReferenceException: Object reference not set to an instance of an object
        PartModule.Load (.ConfigNode node)
        Part.AddModule (.ConfigNode node, Boolean forceAwake)
        HullcamVDS.initKerbalEVA.Awake ()
        UnityEngine.Debug:LogException(Exception)
        HullcamVDS.initKerbalEVA:Awake()
        UnityEngine.GameObject:AddComponent(Type)
        AddonLoader:StartAddon(LoadedAssembly, Type, KSPAddon, Startup)
        AddonLoader:StartAddons(Startup)
        AddonLoader:OnLevelLoaded(GameScenes)
        AddonLoader:OnSceneLoaded(Scene, LoadSceneMode)
        UnityEngine.SceneManagement.SceneManager:Internal_SceneLoaded(Scene, LoadSceneMode)

 

I didn't had the time to test it properly, so I don't know (yet) if the NRE is coming from the getPartInfoByName or from the .prefab. But this is something for the weekend. :)

In a way or another, it's a change that happened after KSP 1.4.1, and the empty try-catch prevented us to see the problem. Since the nasty collateral effects are being echoed by all the game, the getPartInfoByName appears to be working, and so the real problem is that kerbalEVAs doesn't have a prefab anymore, or perhaps we have a race condition where tow modules (and I include Squad's on the basket) are concurrently changing that part.

 

— POST — EDIT --

I killed some day job and did MOAR TESTS on the subject.

I changed the code to this:

Spoiler

//Add EVA camera to all Kerbals on EVA
[KSPAddon(KSPAddon.Startup.MainMenu, true)]
public class initKerbalEVA : UnityEngine.MonoBehaviour {
	private static readonly String[] KERBALS_TO_MANGLE = {"kerbalEVAthatDoenstExists", "kerbalEVA", "kerbalEVAfemale", "kerbalEVAVintage", "kerbalEVAfemaleVintage"};
	public void Awake() {
           
		ConfigNode EVA = new ConfigNode("MODULE");
		EVA.AddValue("name", "EVACamera");
		EVA.AddValue("cameraName", "EVACam");

		foreach (String pn in KERBALS_TO_MANGLE) try
		{
			Debug.Log(String.Format("Instrumenting {0}.", pn));
			AvailablePart p = PartLoader.getPartInfoByName(pn);
			if (null != p) p.partPrefab.AddModule(EVA);
		}
		catch (Exception e)
		{
			Debug.LogException(e);
		}
	}
}

 

And got this:

Spoiler

[LOG 08:47:24.296] Instrumenting kerbalEVAthatDoenstExists.
[LOG 08:47:24.296] Instrumenting kerbalEVA.
[EXC 08:47:24.303] NullReferenceException: Object reference not set to an instance of an object
        PartModule.Load (.ConfigNode node)
        Part.AddModule (.ConfigNode node, Boolean forceAwake)
        HullcamVDS.initKerbalEVA.Awake ()
        UnityEngine.Debug:LogException(Exception)
        HullcamVDS.initKerbalEVA:Awake()
        UnityEngine.GameObject:AddComponent(Type)
        AddonLoader:StartAddon(LoadedAssembly, Type, KSPAddon, Startup)
        AddonLoader:StartAddons(Startup)
        AddonLoader:OnLevelLoaded(GameScenes)
        AddonLoader:OnSceneLoaded(Scene, LoadSceneMode)
        UnityEngine.SceneManagement.SceneManager:Internal_SceneLoaded(Scene, LoadSceneMode)
[LOG 08:47:24.304] Instrumenting kerbalEVAfemale.
[EXC 08:47:24.305] NullReferenceException: Object reference not set to an instance of an object
        PartModule.Load (.ConfigNode node)
        Part.AddModule (.ConfigNode node, Boolean forceAwake)
        HullcamVDS.initKerbalEVA.Awake ()
        UnityEngine.Debug:LogException(Exception)
        HullcamVDS.initKerbalEVA:Awake()
        UnityEngine.GameObject:AddComponent(Type)
        AddonLoader:StartAddon(LoadedAssembly, Type, KSPAddon, Startup)
        AddonLoader:StartAddons(Startup)
        AddonLoader:OnLevelLoaded(GameScenes)
        AddonLoader:OnSceneLoaded(Scene, LoadSceneMode)
        UnityEngine.SceneManagement.SceneManager:Internal_SceneLoaded(Scene, LoadSceneMode)
[LOG 08:47:24.305] Instrumenting kerbalEVAVintage.
[EXC 08:47:24.306] NullReferenceException: Object reference not set to an instance of an object
        PartModuleList.Add (.PartModule module)
        Part.AddModule (System.String moduleName, Boolean forceAwake)
        Part.AddModule (.ConfigNode node, Boolean forceAwake)
        HullcamVDS.initKerbalEVA.Awake ()
        UnityEngine.Debug:LogException(Exception)
        HullcamVDS.initKerbalEVA:Awake()
        UnityEngine.GameObject:AddComponent(Type)
        AddonLoader:StartAddon(LoadedAssembly, Type, KSPAddon, Startup)
        AddonLoader:StartAddons(Startup)
        AddonLoader:OnLevelLoaded(GameScenes)
        AddonLoader:OnSceneLoaded(Scene, LoadSceneMode)
        UnityEngine.SceneManagement.SceneManager:Internal_SceneLoaded(Scene, LoadSceneMode)
[LOG 08:47:24.306] Instrumenting kerbalEVAfemaleVintage.
[EXC 08:47:24.307] NullReferenceException: Object reference not set to an instance of an object
        PartModuleList.Add (.PartModule module)
        Part.AddModule (System.String moduleName, Boolean forceAwake)
        Part.AddModule (.ConfigNode node, Boolean forceAwake)
        HullcamVDS.initKerbalEVA.Awake ()
        UnityEngine.Debug:LogException(Exception)
        HullcamVDS.initKerbalEVA:Awake()
        UnityEngine.GameObject:AddComponent(Type)
        AddonLoader:StartAddon(LoadedAssembly, Type, KSPAddon, Startup)
        AddonLoader:StartAddons(Startup)
        AddonLoader:OnLevelLoaded(GameScenes)
        AddonLoader:OnSceneLoaded(Scene, LoadSceneMode)
        UnityEngine.SceneManagement.SceneManager:Internal_SceneLoaded(Scene, LoadSceneMode)

 

I intentionally added a non existent part ("kerbalEVAthatDoesntExists") to see what happens.

That inexistent part works "fine", getPartInfoByname returns null for it, and then the if suppress the command,

The other four "kerbalEVA" do exist, but they don't have a prefab atribute[It's the Modules atribute that it's nulled!]. At least, yet - perhaps we are facing a race condition, in the same way I was on TweakScale.

Edited by Lisias
MOAR TESTS
Link to comment
Share on other sites

On 10/31/2018 at 6:48 PM, TranceaddicT said:

So here is something I was investigating that I find interesting.  You'll notice in all the DRE errors you have 'TweakScale.PrefabDryCostWriter+<WriteDryCost>d__4.MoveNext ()'

 

On 10/31/2018 at 9:03 PM, Lisias said:

So, I'm guessing that, in reality, we are facing some kind of dynamic linking problem. And such linking problem is tampering the add ons that relies on Reflection.

That was a very good call. it wasn't the cause for this problem, but it could be and if it was, I would be chasing my tail for days.

By testing it, I was leaded to what appears to be the real cause, so it totally worth the effort. Thx!

 

Link to comment
Share on other sites

Ladies and Gentlemen, we have a race condition. :)

[LOG 12:00:22.131] HullcamVDS::InstrumentKerbals: Started  <--- HERE!!! -->
[LOG 12:00:22.131] [AddonLoader]: Instantiating addon 'PrefabDryCostWriter' from assembly 'Scale'
[LOG 12:00:22.134] [UIMasterController]: ShowUI
[LOG 12:00:22.408] [GameParameters]: Loaded custom parameter class MissionParamsGeneral.
[LOG 12:00:22.408] [GameParameters]: Loaded custom parameter class MissionParamsFacilities.
[LOG 12:00:22.408] [GameParameters]: Loaded custom parameter class MissionParamsExtras.
[LOG 12:00:22.408] [GameParameters]: Loaded custom parameter class CommNetParams.
[LOG 12:00:22.408] [GameParameters]: Loaded custom parameter class AdvancedParams.
[LOG 12:00:22.427] TweakScale::WriteDryCost: Started       <--- HERE!!! -->

— POST— EDIIT --

And I'm a freaking dumb-SAS. :D 

The answer was there, all the time! :sticktongue:

This is the new stackdump:

[EXC 12:29:07.256] NullReferenceException: Object reference not set to an instance of an object
        PartModule.Load (.ConfigNode node)
        Part.AddModule (.ConfigNode node, Boolean forceAwake)
        HullcamVDS.initKerbalEVA+<InstrumentKerbals>d__4.MoveNext ()
        UnityEngine.Debug:LogException(Exception)
        HullcamVDS.<InstrumentKerbals>d__4:MoveNext()
        UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

This is what's happening, in verbose mode (from bottom to up)

  1. UnityEngine executes my call to start a Coroutine.
  2. A loop was entered somewhere up in the foodchain (see the MoveNext).
  3. Unity' Debug.LogException is invoked due an Exception. ok, but here? It's the next instruction the culprit, but whatever.
  4. HullcamVDS.InstrumentKerbals (inside the coroutine) entered a loop (since the MoveNext, called implicitly by foreach) - it's the Loop where I pick up a part name one by one (kerbalEVA, kerbalEVAfemale, etc)
  5. I call the p.partPrefab.AddModule(EVA); implicitly does:
    1. a Call to Part.AddModule (ok, not so implicit)
    2. a Call to PartModule.Load

On the step 5.2, the Exception aborts anything that AddModule should do in order to keep the GameDatabase's integrity, and that's the reason TweakScale borks later. While searching for the parts I want to instrument, I ask for the Modules from that part, and the (borked) process above leaves the kerbalEVAs with a null on the modules list!

Now I have to figure out by why by Kraken's sake PartModule.Load is failing. :)  

Edited by Lisias
MOAR INFO
Link to comment
Share on other sites

3 hours ago, Lisias said:

Ladies and Gentlemen, we have a race condition. :)

Now I have to figure out by why by Kraken's sake PartModule.Load is failing. :)  

Now, you've OFFICIALLY gone well beyond my understanding.

I suggest calling in @linuxgurugamer @sarbian or @NathanKell (to name a few) for another set of eyes.

Link to comment
Share on other sites

Also, you might what to look at what TACLS is doing with kerbalEVA.

                try
                {
                    IEnumerable<AvailablePart> evaParts = PartLoader.LoadedPartsList.Where(p => p.name.Contains("kerbalEVA"));
                    foreach (AvailablePart evaPart in evaParts)
                    {
                        if (evaPart.partPrefab != null && evaPart.partPrefab.Resources != null)
                        {
                            EvaAddLifeSupport(evaPart);
                        }
                    }
                }
                catch (Exception ex)
                {
                    this.LogError("Failed to add Life Support to the EVA.\n" + ex.Message + "\n" + ex.StackTrace);
                }

 

Link to comment
Share on other sites

4 hours ago, Lisias said:

Ladies and Gentlemen, we have a race condition. :)


[LOG 12:00:22.131] HullcamVDS::InstrumentKerbals: Started  <--- HERE!!! -->
[LOG 12:00:22.131] [AddonLoader]: Instantiating addon 'PrefabDryCostWriter' from assembly 'Scale'
[LOG 12:00:22.134] [UIMasterController]: ShowUI
[LOG 12:00:22.408] [GameParameters]: Loaded custom parameter class MissionParamsGeneral.
[LOG 12:00:22.408] [GameParameters]: Loaded custom parameter class MissionParamsFacilities.
[LOG 12:00:22.408] [GameParameters]: Loaded custom parameter class MissionParamsExtras.
[LOG 12:00:22.408] [GameParameters]: Loaded custom parameter class CommNetParams.
[LOG 12:00:22.408] [GameParameters]: Loaded custom parameter class AdvancedParams.
[LOG 12:00:22.427] TweakScale::WriteDryCost: Started       <--- HERE!!! -->

— POST— EDIIT --

And I'm a freaking dumb-SAS. :D 

The answer was there, all the time! :sticktongue:

This is the new stackdump:


[EXC 12:29:07.256] NullReferenceException: Object reference not set to an instance of an object
        PartModule.Load (.ConfigNode node)
        Part.AddModule (.ConfigNode node, Boolean forceAwake)
        HullcamVDS.initKerbalEVA+<InstrumentKerbals>d__4.MoveNext ()
        UnityEngine.Debug:LogException(Exception)
        HullcamVDS.<InstrumentKerbals>d__4:MoveNext()
        UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

This is what's happening, in verbose mode (from bottom to up)

  1. UnityEngine executes my call to start a Coroutine.
  2. A loop was entered somewhere up in the foodchain (see the MoveNext).
  3. Unity' Debug.LogException is invoked due an Exception. ok, but here? It's the next instruction the culprit, but whatever.
  4. HullcamVDS.InstrumentKerbals (inside the coroutine) entered a loop (since the MoveNext, called implicitly by foreach) - it's the Loop where I pick up a part name one by one (kerbalEVA, kerbalEVAfemale, etc)
  5. I call the p.partPrefab.AddModule(EVA); implicitly does:
    1. a Call to Part.AddModule (ok, not so implicit)
    2. a Call to PartModule.Load

On the step 5.2, the Exception aborts anything that AddModule should do in order to keep the GameDatabase's integrity, and that's the reason TweakScale borks later. While searching for the parts I want to instrument, I ask for the Modules from that part, and the (borked) process above leaves the kerbalEVAs with a null on the modules list!

Now I have to figure out by why by Kraken's sake PartModule.Load is failing. :)  

I know what's happening.  It's in this code:


		try {
						
			PartLoader.getPartInfoByName("kerbalEVA").partPrefab.AddModule(EVA);
		}
		catch{}
		try { PartLoader.getPartInfoByName("kerbalEVAfemale").partPrefab.AddModule(EVA); 
		}
		catch {}

There are two new kerbal parts, I need to add them.  Wait for the next version, either in a few minutes or tomorrow

@Lisias

New release out, 0.1.9.7, should fix this.  Link follows, should also be in CKAN soon

https://github.com/linuxgurugamer/HullcamVDSContinued/releases/download/0.1.9.7/HullcamVDSContinued-0.1.9.7.zip

Edited by linuxgurugamer
Link to comment
Share on other sites

Just now, linuxgurugamer said:

I know what's happening.  It's in this code:



		try {
						
			PartLoader.getPartInfoByName("kerbalEVA").partPrefab.AddModule(EVA);
		}
		catch{}
		try { PartLoader.getPartInfoByName("kerbalEVAfemale").partPrefab.AddModule(EVA); 
		}
		catch {}

There are two new kerbal parts, I need to add them.  Wait for the next version, either in a few minutes or tomorrow

It's somewhat further than that. I'm mangling with HullcamVDS (as I always do! :P ) and the problem is that PartModule.Load is throwing a NRE on 1.4.3 and later (perhaps 1.4.2, but I don't test on it), besides working fine on 1.4.1 .

Let me say again: this code works fine on 1.4.1, but borks on 1.4.3 and later. I don't know why it borks, but it leaves the Module list on the prefab in a inconsistent state (this happens on KSP code, it's not on you neither). And then, later, anyone trying to list the Modules from the kerbal's prefab blows up too - it's what's happening with TweakScale.

Adding support for more kerbals (the vintage ones) only expand the mess, as now more parts are messed due a NULL on the Module's list.

Edited by Lisias
hit "Save" too soon.
Link to comment
Share on other sites

14 minutes ago, TranceaddicT said:

Also, you might what to look at what TACLS is doing with kerbalEVA.


                try
                {
                    IEnumerable<AvailablePart> evaParts = PartLoader.LoadedPartsList.Where(p => p.name.Contains("kerbalEVA"));
                    foreach (AvailablePart evaPart in evaParts)
                    {
                        if (evaPart.partPrefab != null && evaPart.partPrefab.Resources != null)
                        {
                            EvaAddLifeSupport(evaPart);
                        }
                    }
                }
                catch (Exception ex)
                {
                    this.LogError("Failed to add Life Support to the EVA.\n" + ex.Message + "\n" + ex.StackTrace);
                }

 

Actually, TACLS has the same issue, missing the kerbalEVAVintage and kerbalEVAfemaleVintage parts.  I just opened an issue for him

2 minutes ago, Lisias said:

It's somewhat further than that. I'm mangling with HullcamVDS (as I always do! :P ) and the problem is that PartModule.Load is throwing a NRE on 1.4.3 and later (perhaps 1.4.2, but I don't test on it), besides working fine on 1.4.1 .

Let me say again: this code works fine on 1.4.1, but borks on 1.4.3 and later. I don't know why it borks, but it leaves the Module list on the prefab in a inconsistent state (this happens on KSP code, it's not on you neither). And then, later, anyone trying to list the Modules from the kerbal's prefab blows up too - it's what's happening with TweakScale.

Adding support for more kerbals (the vintage ones) only expand the mess, as now more parts are messed due a NULL on the Module's list.

I'll bet that they changed something in the API, from a simple variable to a get/set.  This happened before as well.

I can't help you for anything earlier, but at this link:

https://github.com/linuxgurugamer/HullcamVDSContinued/releases/tag/0.1.9.7

is new new release, and there is a file there for 1.4.5 as well.  I don't support any earlier version of 1.4, and I would suggest that you not do that either.  They seemed to have made too many changes

Link to comment
Share on other sites

Just now, TranceaddicT said:

Now, you've OFFICIALLY gone well beyond my understanding.

A "race condition" is when two somethings try to access the same something else, and nobody knows what happens because no one knows who will hit that something else first - being the reason we call it "race condition".

If A hits the thing first, you have a result. If B hits it first, you have another result. But only one of that results are the right one, and there's nothing ensuring that the right one hits that thing first.

It's a concurrency problem. Interesting enough, one of the technics we use to solve this is called "Semaphore", where we can assure that only one will have the green light to hit the disputed thing and, so, we can ensure the right result.

Link to comment
Share on other sites

2 minutes ago, TranceaddicT said:

From what I've seen *Vintage only exist in KSP_Data/sharedasset0.assets.

Nope.  It's the name of the kerbal parts in the expansion

1 minute ago, TranceaddicT said:

sharedassets0.assets references:

 

kbEVAVintage

kbEVAFemaleVintage

kerbalEVAVintage

kerbalEVAFemaleVintage

Look in GameData\SquadExpansion\MakingHistory\Parts\Prebuilt

Link to comment
Share on other sites

Just now, TranceaddicT said:

From what I've seen *Vintage only exist in KSP_Data/sharedasset0.assets.

Yep. But it appears to be irrelevant to the problem, as it's happening with or without the vintage kerbals. The problem is happening when trying to add a new Module to the kerbalEVA. Something changed somewhere, and the loading of the Module is raising an exception that it's borking the PartModule.Load method - and this method leaves the GameDatabase''s entry for that kerbal part in a inconsistent state (being more specific, with a nice NULL on the atribute that should have a list of ConfigNodes, each one pointing to a module).

Then, later, some other code (as TweakScale) will bork marvelously because there are never a NULL on the module's list of a part, at the worst, an empty list. And since there're never a NULL there, we never check. And since it's a list of something (modules in this case), it's usually used on a foreach - being the reason that it's usual to see a MoveNext call on the stack dump.

Edited by Lisias
Hit "Save" too soon
Link to comment
Share on other sites

6 minutes ago, Lisias said:

Yep. But it appears to be irrelevant to the problem, as it's happening with or without the vintage kerbals. The problem is happening when trying to add a new Module to the kerbalEVA. Something changed somewhere, and the loading of the Module is raising an exception that it's borking the PartModule.Load method - and this method leaves the GameDatabase''s entry for that kerbal part in a inconsistent state (being more specific, with a nice NULL on the atribute that should have a list of ConfigNodes, each one pointing to a module).

Then, later, some other code (as TweakScale) will bork marvelously because there are never a NULL on the module's list of a part, at the worst, an empty list. And since there're never a NULL there, we never check. And since it's a list of something (modules in this case), it's usually used on a foreach - being the reason that it's usual to see a MoveNext call on the stack dump.

 Couple of things. 

First, don't use the for each unless it's in a Start or Awake. Use a for loop with integer using the length of the list, it's faster.

Second, I always check for nulls in parts list these days because for whatever reason I am occasionaly seeing a nolle in the parts list and it's safer to check and be able to ignore it then not check and have an exception.

Link to comment
Share on other sites

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.

×
×
  • Create New...