zer0Kerbal / Kaboom

Another way to not go to space today! What can be more Kerbal than more Explosions!* *Now with SuperKlue Implosions!* KaboOom! (BOOM) is an add-on for Kerbal Space Program.
https://forum.kerbalspaceprogram.com/index.php?/topic/192938-*/
GNU General Public License v2.0
2 stars 3 forks source link

[Bug 🐞]: No Booms :( 🧯 #74

Closed zer0Kerbal closed 2 years ago

zer0Kerbal commented 2 years ago

Brief description of your issue

from @caipi on KSP Forums

`in short/TLDR: I recently noticed that I cannot SuperKlue-Kaboom the inline drills from KPBS (Planetary Base Systems). Is that a known issue? Is there any way to get around it or fix it?

Long explanation: As I was building my Minmusbase, at some point I ran into an issue where I tried to get rid of the old, obsolete drills I no longer need. I wanted to Superklue-Kaboom them. It just created a NullRef Exception. At first I thought it could have something to do with struts or the mass and center of the base (previously added a huge fuel tank and filled it up and connected it via a KIS/KAS corridor). But it turned out that only the (K&K) Inline Drills (both, ore and metal ore) were affected. So I created a new clean install with some basic mods, KPBS and Kaboom. It doesn't appear to be a conflict with other mods. Other KPBS parts superklue-kaboom just fine.

My best guess would be that it is related to the fact that the inline drills are dynamic (shapeshifting :D ) in their form and change when you attach objects to both sides. But I wouldn't be surprised if it had something to do with the attachment nodes and how they are set up. Or it might be something else entirely since I don't really no s*tuff about it. ;-)

Here is a short log excerpt with the coressponding Nullrefs (two attempts for two parts, the inline drill attached slightly different ways):`

Steps to reproduce

  1. new clean install with some basic mods, KPBS and Kaboom.
  2. try to Kaboom (K&K) Inline Drills (both, ore and metal ore)

Expected behavior

parts to go Kaboom! (be destroyed)

Actual behavior

No Booms :(

    Kaboom.WeldingUtilities.DetachPart (Part thisPart) (at <468b15f52ea3465a98e8f0a0b20c22e6>:0)
    Kaboom.Welding.PerformWeld (Kaboom.WeldingData wData, System.Boolean compress) (at <468b15f52ea3465a98e8f0a0b20c22e6>:0)
    Kaboom.Welding.MergeParts (System.Boolean compress) (at <468b15f52ea3465a98e8f0a0b20c22e6>:0)
    Kaboom.ModuleKaboom.Proceed () (at <468b15f52ea3465a98e8f0a0b20c22e6>:0)
    Kaboom.ModuleKaboom.KaboomIt () (at <468b15f52ea3465a98e8f0a0b20c22e6>:0)
    Kaboom.ModuleKaboom.KaboomEvent () (at <468b15f52ea3465a98e8f0a0b20c22e6>:0)
    BaseEvent.Invoke () (at <39c0323fb6b449a4aaf3465c00ed3c8d>:0)
    UIPartActionButton.OnClick () (at <39c0323fb6b449a4aaf3465c00ed3c8d>:0)
    UnityEngine.Events.InvokableCall.Invoke () (at <12e76cd50cc64cf19e759e981cb725af>:0)
    UnityEngine.Events.UnityEvent.Invoke () (at <12e76cd50cc64cf19e759e981cb725af>:0)
    UnityEngine.UI.Button.Press () (at <5336a8686ff14f17888ce9a9f44f29bc>:0)
    UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at <5336a8686ff14f17888ce9a9f44f29bc>:0)
    UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at <5336a8686ff14f17888ce9a9f44f29bc>:0)
    UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at <5336a8686ff14f17888ce9a9f44f29bc>:0)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
    UnityEngine.EventSystems.EventSystem:Update()
[EXC 15:51:53.072] NullReferenceException: Object reference not set to an instance of an object
    Kaboom.WeldingUtilities.DetachPart (Part thisPart) (at <468b15f52ea3465a98e8f0a0b20c22e6>:0)
    Kaboom.Welding.PerformWeld (Kaboom.WeldingData wData, System.Boolean compress) (at <468b15f52ea3465a98e8f0a0b20c22e6>:0)
    Kaboom.Welding.MergeParts (System.Boolean compress) (at <468b15f52ea3465a98e8f0a0b20c22e6>:0)
    Kaboom.ModuleKaboom.Proceed () (at <468b15f52ea3465a98e8f0a0b20c22e6>:0)
    Kaboom.ModuleKaboom.KaboomIt () (at <468b15f52ea3465a98e8f0a0b20c22e6>:0)
    Kaboom.ModuleKaboom.KaboomEvent () (at <468b15f52ea3465a98e8f0a0b20c22e6>:0)
    BaseEvent.Invoke () (at <39c0323fb6b449a4aaf3465c00ed3c8d>:0)
    UIPartActionButton.OnClick () (at <39c0323fb6b449a4aaf3465c00ed3c8d>:0)
    UnityEngine.Events.InvokableCall.Invoke () (at <12e76cd50cc64cf19e759e981cb725af>:0)
    UnityEngine.Events.UnityEvent.Invoke () (at <12e76cd50cc64cf19e759e981cb725af>:0)
    UnityEngine.UI.Button.Press () (at <5336a8686ff14f17888ce9a9f44f29bc>:0)
    UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at <5336a8686ff14f17888ce9a9f44f29bc>:0)
    UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at <5336a8686ff14f17888ce9a9f44f29bc>:0)
    UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at <5336a8686ff14f17888ce9a9f44f29bc>:0)
    UnityEngine.DebugLogHandler:LogException(Exception, Object)
    ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
    UnityEngine.EventSystems.EventSystem:Update()```

### Environment

```shell
unknown

How did you download and install this?

Other (explain below)

zer0Kerbal commented 2 years ago

FYI @yalov

zer0Kerbal commented 2 years ago

caipi

Update Just a quick response before I go to bed - I'm gonna share more information and logs tomorrow.

First: What an awesome video clip!!! (I couldn't put enough exclamation marks on it to signify how much I like it - but I don't want to spam you :D )

And I hate to correct you, but it does actually go boom. It just doesn't go super boom. I mean superklue boom. I can make it explode, but I cannot make it explode and simultaneously attach the two parts, that were previously attached to the drill, to each other. It's just the superklue function that does not work as intended with the K&K inline drills. If I try, I get the NullRef error message and no boom (No boom today. Boom tomorrow. There's always a boom tomorrow.). The superklue boom function works properly with other K&K parts, even the appearance-changing K&K Cross-Way works fine. Just not the drills.

The normal boom function works with the K&K inline drills. If I have superklue disabled, it makes boom as it should. Sorry if I didn't make that clear enough in my initial post. More tomorrow (or when I find time ;.; silly alternate real life... we all know Kerbal is actually the real life, isn't it?).

zer0Kerbal commented 2 years ago

flart

(https://forum.kerbalspaceprogram.com/index.php?/topic/192938-1122-kaboom-v1401-implosions-de-superklue-detonate-and-weld-parts-from-eva-part-menu26-oct-2021/page/3/#elControls_4105742_menu) Posted 34 minutes ago (edited) 12 hours ago, zer0Kerbal said: Thank you for the bug report.

Both .sln doesn't load properly on my side, so no PR. Something about files path.

The problem most likely WeldingUtilities.cs#L32

thisPart.topNode.attachedPart = null; The kk drill probably doesn't have the top node, it is Drill_g.cfg#L20

node_stack_back = 0, -0.439, 0, 0, -1, 0, 1 node_stack_front = 0, 0.401, 0, 0, 1, 0, 1

zer0Kerbal commented 2 years ago

@yalov @flart thank you for looking at this.

Then how can one implode/superklue it if it doesn't have a top/bottom?

unless it has been surfaced attached and another part is on it node.

Later down in the Drill.cfg

MODULE
{
    name = ModuleKPBSCorridorNodes
    nodeNames = front
    transormNames = Base_Front
    showAllWithNoAttachment = false
}

Something about files path.

I have an environmental variable set (actually one for each major version of KSP) that points to the KSP directory of that version. Makes my life a whole lot less insane. You should just need to set %K112% to the path of your KSPDEV install (in my case K:\KSP\112\)

caipi- commented 2 years ago

Sounds like you guys already found the cause of the problem: The drill has no node_stack_top defined in its user part and your code requires such a top node. I guess that means all parts that don't have a top stack node should be affected.

Do you still need me to provide more detailed logs and stuff (given that you alread found the issue)? By the way: Drills undeployed, not drilling - but that didn't make a change. I could deploy them and start drilling, wouldn't change a thing Mods are all installed manually and in their latest version, along with KSP 1.12.3

Also, just to check and confirm if that is really the issue, I changed the drill config from

    // --- node definitions ---
    node_stack_back = 0, -0.439, 0, 0, -1, 0, 1
    node_stack_front = 0, 0.401, 0, 0, 1, 0, 1

to

    // --- node definitions ---
    node_stack_bottom = 0, -0.439, 0, 0, -1, 0, 1
    node_stack_top = 0, 0.401, 0, 0, 1, 0, 1

Since it didn't really change the nodes (orientation, size and position), but only the names, I thought I'd give it a try. It worked! Renaming the nodes is a quick, dirty workaround (just in case anybody else stumbles into it before it gets/got fixed). After renaming the nodes, I could superklue-kaboom (weld together) the drills. I don't know if that creates some other issues along the way, though. So it would probably be better to fix the code - if possible.

So very, very likely a silly question from somebody who never bothered to learn how to code: Wouldn't it be enough to put an if clause around the line that @flart mentioned, something like "if top stack node exist (code) else use front stack node for whatever it is you need it for (and potentially back node instead of bottom node, if it is also still mentioned somewhere)"? I'm probably oversimplifying the issue and solution here... Again, I have no coding skills! :D