Skip to content

Script aborting error when trying to set SASMODE to any value in KSP 1.10.1+ #3036

@1greywind

Description

@1greywind

I found a bug that has 100% reproduction rate and affect any script running from IVA or from flight screen with Navball hidden.
But is not reproducible in 1.8.1, so I is clearly related to added in post 1.8.1 patches ability to auto hide NavBall in Map view.

It breaks immersion when you try to do automated mission using IVA only view with RPM and stuff.

Steps to reproduce:

On KSP 1.10.1 with kOS 1.2.x or older (verified on v1.3.2.0) do the follwing:

  1. Enter flight scene
  2. Toggle SAS ON. Verify that SAS supports prograde or retrograde modes.
  3. Open kOS terminal
  4. With NavBall visible type in command: SET SASMODE TO "PROGRADE" - observe no issues
  5. Hide NavBall using "close" button on top of it or enter IVA by pressing C on keyboard.
  6. Type SET SASMODE TO "RETROGRADE" - observe error "Object reference not set to an instance of an object"
  7. While sas mode is set the error stops script execution.

Video with bug demonstration: on Youtube

KSP.log with error: on Dropbox

Example KSP.log output:

[LOG 23:09:55.676] kOS: At interpreter, line 6
set sasmode to "prograde".
               ^

[LOG 23:09:55.677] System.NullReferenceException: Object reference not set to an instance of an object
  at kOS.Module.kOSProcessor.SetAutopilotMode (System.Int32 mode) [0x00005] in <65f8e2840d484781b935eacbc49257d5>:0 
  at kOS.Binding.FlightControlManager.SelectAutopilotMode (VesselAutopilot+AutopilotMode autopilotMode) [0x00059] in <65f8e2840d484781b935eacbc49257d5>:0 
  at kOS.Binding.FlightControlManager.SelectAutopilotMode (System.String autopilotMode) [0x00186] in <65f8e2840d484781b935eacbc49257d5>:0 
  at kOS.Binding.FlightControlManager.SelectAutopilotMode (System.Object autopilotMode) [0x00017] in <65f8e2840d484781b935eacbc49257d5>:0 
  at kOS.Safe.Binding.BoundVariable.set_Value (System.Object value) [0x00015] in <34008363e530440ca32b385cd54c2cc0>:0 
  at kOS.Safe.Execution.CPU.SetValue (System.String identifier, System.Object value) [0x00007] in <34008363e530440ca32b385cd54c2cc0>:0 
  at kOS.Safe.Compilation.OpcodeStore.Execute (kOS.Safe.Execution.ICpu cpu) [0x00010] in <34008363e530440ca32b385cd54c2cc0>:0 
  at kOS.Safe.Execution.CPU.ExecuteInstruction (kOS.Safe.Execution.ProgramContext context, System.Boolean doProfiling) [0x001e5] in <34008363e530440ca32b385cd54c2cc0>:0 
  at kOS.Safe.Execution.CPU.ContinueExecution (System.Boolean doProfiling) [0x00030] in <34008363e530440ca32b385cd54c2cc0>:0 
  at kOS.Safe.Execution.CPU.KOSFixedUpdate (System.Double deltaTime) [0x000b0] in <34008363e530440ca32b385cd54c2cc0>:0 
[LOG 23:09:55.677] Code Fragment
File                 Line:Col IP   label   opcode operand
====                 ====:=== ==== ================================  
interpreter             6:16  0059 @0035   store $sasmode 
interpreter             6:0   0060 @0036   popscope 1 
interpreter             6:1   0061 @0037   pushscope 10 0 
interpreter             6:16  0062 @0038   push prograde 
interpreter             6:16  0063 @0039   store $sasmode 
interpreter             6:0   0064 @0040   popscope 1 
interpreter             6:1   0065 @0041   pushscope 11 0 
interpreter             6:16  0066 @0042   push prograde 
interpreter             6:16  0067 @0043   store $sasmode 
interpreter             6:0   0068 @0044   popscope 1 
interpreter             6:1   0069 @0045   pushscope 12 0 
interpreter             6:16  0070 @0046   push prograde 
interpreter             6:16  0071 @0047   store $sasmode 
interpreter             6:0   0072 @0048   popscope 1 
interpreter             6:1   0073 @0049   pushscope 13 0 
interpreter             6:16  0074 @0050   push prograde 
interpreter             6:16  0075 @0051   store $sasmode <<--INSTRUCTION POINTER--
interpreter             6:0   0076 @0052   popscope 1 
                        0:0   0077         EOF

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions