Jump to content

Temporary fix for docking port drift bug?


RealKerbal3x

Recommended Posts

With 1.12.2 potentially being the last patch for KSP, it's possible that we'll never see an official fix for the docking port drift bug, which has the potential to really mess with a lot of craft. So I've been wondering if disabling the rotation functionality in some way would be enough to avoid the bug for the time being.

Just spitballing here, but there are 3 ways I can think of to go about this:

  1. Directly editing the docking ports' config files to change 'canRotate' to 'False': From my limited testing, this did disable rotation functionality (as expected), but I'm not sure if it's actually eliminating drift, and obviously editing the game files to fix things isn't a great practice.
  2. Same as above, but doing it with a Module Manager patch instead: Theoretically this is a better solution than direct file editing, but I wasn't able to get it to work (I'm probably just inexperienced with MM syntax). And, same as above, I'm not sure if flipping a 'true/false' switch in the config file is enough to eliminate the bug.
  3. Writing a plugin to completely disable the docking port rotation code: This is probably the most likely to work, and while it's way out of my skillset at the moment I'm open to learning how to do it.

I'm open to suggestions, as everyone in this subforum is definitely smarter than me. Hopefully we do get a 1.12.3 or something at some point that fixes this bug, and this temporary fix doesn't end up becoming permanent.

Link to comment
Share on other sites

If it's 2 or 3 I'm sure one or more heros will step up:wink:

However (and I'm saying this as a total layman), are we sure that the problem is only caused by the rotation functionality )? I mean, what we see is: 'new rotation option =>drift' so it seems a logical conclusion, but maybe there are more/other changes in the code that cause the drifting problem?

Link to comment
Share on other sites

7 minutes ago, modus said:

If it's 2 or 3 I'm sure one or more heros will step up:wink:

However (and I'm saying this as a total layman), are we sure that the problem is only caused by the rotation functionality )? I mean, what we see is: 'new rotation option =>drift' so it seems a logical conclusion, but maybe there are more/other changes in the code that cause the drifting problem?

Yeah, being mostly uniformed about most of this stuff I have no idea where the problem is really coming from. However, given that drift is also a problem with the robotic parts, I assumed that they share at least some code and that's what's causing the drifting.

If that's the case then I hope that it's possible to actually modify it using a plugin.

Link to comment
Share on other sites

On 8/5/2021 at 6:41 PM, RealKerbal3x said:

the docking port drift bug

You might have to explain what the bug is, exactly, because not every modder will have run into this problem.

I do notice that in version 1.12, if I put stress on the craft (I used 'hack gravity') so that all the joints give a little, then quicksave and quickload,
most of the joints are initially back at their unstressed position upon quickload (which has been true in earlier versions of KSP)
but the joint between the docking ports loads back at its stressed position, and then the load on the craft moves them further 
(which is new, though similar behaviour was reported with the motorised joints in the new robotic parts).

Repeated quicksaves and quickloads make the docking ports move further and further from their original positions.

A module-manager patch to remove all the new options

@PART[*]:HAS[@MODULE[ModuleDockingNode]] {
    @MODULE[ModuleDockingNode] {
        @canRotate = false
        -rotationTransformName = delete
        -maxMotorOutput = delete
        -rotationTransformName = delete
        -maxMotorOutput = delete
        -RESOURCE {}
        -rotationAxis = delete
}}

does not solve the problem with the docking-ports moving after repeated quickload/quicksave.

So something changed the rules about how these particular joints are saved in the savefile.  I suspect the trigger for the new rule might be 'IJointLockState' because ModuleDockingNode now inherits from IJointLockState.   I do not know any way to change that inheritance.

Of course, we could all just use KSP 1.7.3 or maybe 1.9.1.
Older versions of KSP had the ability to align docking ports, having the docking ports joint only when aligned, if we enabled the option with a module-manager patch

@PART[*]:HAS[@MODULE[ModuleDockingNode*]:HAS[~snapOffset[]]]:FINAL {
    @MODULE[ModuleDockingNode*] {
        snapRotation = true
        snapOffset = 90
        captureMinRollDot = 0.9998 // cosine 2°, adjust for different tolerance
        acquireForce = 0.5 // per user preference, default is 2.0
}}

 

Edited by OHara
Make the fixed-angle docking patch from Community Patches compatible with the mod below (which renames ModuleDockingNode to ModuleDockingNodeFixed)
Link to comment
Share on other sites

 

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEngine;

namespace FixDockingNodes
{
    public class ModuleDockingNodeFixed : ModuleDockingNode
    {
        protected override void ApplyCoordsUpdate()
        {
            if (HighLogic.LoadedSceneIsFlight && canRotate && !nodeIsLocked && otherNode != null && vessel != null && part.vessel != null)
            {
                RecurseCoordUpdate(part.vessel.rootPart, part.vessel.rootPart);
            }
        }
    }
}

That's the code if you were wondering how it was fixed.

 

Link to comment
Share on other sites

4 hours ago, Anth12 said:

That's the code if you were wondering how it was fixed.

That's interesting.  Very short mod.  Now I see the new function ApplyCoordUpdate was added to ModuleDockingNode and there is a function of the same name in ServoBase from Breaking Ground. 

So the mod restores the original positions of all parts on a branch of the craft involving an unlocked docking port, before any quicksave or upon reload.  So if we did rotate any docking ports to straighten out a space station, that straightening will be un-done upon reload, which seems fine given the request..  I am confused what might happen on something like a Canadarm with docking ports and robotic parts working together.  We can AdvTweakable::Rotation:unlocked on those docking ports where we do not want the effects of this mod.

Ideally, given how the original KSP saved craft, we would restore the unstressed position rather than the original position.  That is, save the positions of the craft including effect of motorised joints but not the effects of stress on the craft.  In hindsight, maybe KSP should have saved the current flex on each joint, in addition to part-positions, so it could later distinguish flex from motorised motion.

The Klaw was the first part that would pivot and flex, so it has has for a long time showed this drift upon save/reload.  That is why I though the root of the problem might be in JointLockState, which is common to all the affected parts, but JointLockState doesn't seem to keeping track of the rotation of the joint, at least not publicly.

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.

×
×
  • Create New...