I have a pair of space craft that start out their life docked. One of them has a Flight Program added to a Block using the tinker panel. The Flight Program reports the craft's position every 8 seconds. After undocking it continued to report the original craft's position instead of it's own. Once it gets beyond 10 km the nav position expression stops working entirely (just reports the same position repeatedly).

Bug Done Found in 0.9.307.0 Fixed in 0.9.404.0
Sandbox View

5 Comments

  • Log in to leave a comment
  • Profile image

    @sflanker I missed your comments. Yep, our markdown processor still needs some work! Nice workaround.

    4.0 years ago
  • Profile image
    Mod sflanker

    Here's my temporary workaround doing hacky things with reflection:

        protected override void OnInitialized() {
            base.OnInitialized();
    
            this.PartScript.MovedToNewCraft += this.OnMovedToNewCraft;
        }
    
        private static readonly FieldInfo FlightProgramScriptCraftServiceField =
            typeof(FlightProgramScript).GetField("_craftService", BindingFlags.Instance | BindingFlags.NonPublic);
    
        private static readonly FieldInfo CraftServiceCommandPodField =
            typeof(CraftService).GetField("_commandPod", BindingFlags.Instance | BindingFlags.NonPublic);
    
        private void OnMovedToNewCraft(ICraftScript oldCraft, ICraftScript newCraft) {
            if (this._flightProgramScript != null && oldCraft != null && newCraft != null) {
                Debug.Log(
                    $"Part '{this.PartScript.Data.Name}' Moved From Craft {oldCraft.CraftNode.NodeId} to {newCraft.CraftNode.NodeId}"
                );
    
                var craftService = (CraftService)FlightProgramScriptCraftServiceField.GetValue(this._flightProgramScript);
                CraftServiceCommandPodField.SetValue(
                    craftService,
                    this.PartScript.GetModifier<CommandPodScript>() ?? this.PartScript.CommandPod
                );
    
                craftService.OnCraftChanged();
            }
        }
    

    Sorry for the HTML escape sequences. Somebody needs to work on their markdown processor 😅

    4.0 years ago
  • Profile image
    Mod sflanker

    Happy to help. I thought I was just breaking things because I was pushing the envelope of what is supported.

    4.0 years ago
  • Profile image

    Thanks for bringing this to our attention. It is actually a pretty serious issue.

    4.0 years ago
  • Profile image
    Mod sflanker

    This issue does not affect Flight Programs on non-primary Command Chips, only on random parts like Blocks. So I think the priority on fixing this is really low.

    4.0 years ago

4 Upvotes

Log in in to upvote this post.