#if PLUGIN_SESSION_RECOVERY namespace XFEEDToolBox.Plugin; internal static unsafe partial class Navigation { internal struct RecoveryThrottlePulse { internal nuint node,binding,source; internal float before; internal bool applied; } internal static RecoveryThrottlePulse BeginRecoveryThrottleTrial(RecoveryFlightContextBinding proof) { if(!proof.reproduction)throw new InvalidOperationException("A fixed after-grant empty trial is required"); // This is an absolute .75 input. Original profile activation can // publish its finite .05 baseline before this mapper frame; requiring // it to still be zero would reject a valid reproduction. Admission // itself still starts from zero, and the bounded original frame, // ATC, ownership and eventual four-place zero gates are unchanged. CheckRecoveryFlightContextFrame(proof,false,seed:true); var node=proof.ship.node;var absolute=Pointer(node+0xB0);var source=proof.ship.source; if(Read(proof.active+0x24)!=1||!FixtureBindingName(absolute,"ForwardReverseThrust_Set") ||!BeginDockingFixturePulse(node,absolute,source,out var pulse))throw new InvalidOperationException("Original absolute command was not eligible"); return new(){node=node,binding=absolute,source=source,before=pulse.beforeAccumulator,applied=true}; } internal static bool EndRecoveryThrottleTrial(in RecoveryThrottlePulse pulse) { EndDockingFixturePulse(new(){node=pulse.node,binding=pulse.binding,source=pulse.source,beforeAccumulator=pulse.before,applied=pulse.applied}); return pulse.applied&&Pointer(pulse.node+0xB0)==pulse.binding&&Pointer(pulse.node+0x78)==pulse.source&&Read(pulse.binding+0x18)==0; } internal static float RecoveryThrottleTrialCommand(RecoveryFlightContextBinding proof)=>Read(Pointer(proof.ship.node+0xB0)+0x18); internal static bool CleanupRecoveryThrottleTrial(RecoveryFlightContextBinding proof) { var ship=proof.ship;var baseline=ship.baseline;var current=RecoveryPlayer(baseline.entity); if(current.life!=baseline.life||current.fsd!=baseline.fsd||current.physics!=baseline.physics||current.inputRoot!=baseline.inputRoot ||!Sample(current.physics,out var frame)||frame.life!=baseline.life||frame.entity!=baseline.entity||!BoundFsd(frame,frame.fsd))return false; var controller=Pointer(frame.inputRoot+0x2F8);var value=ReadRecoveryFlightContextThrottle(proof); if(Pointer(ship.node)!=image+0x512E330||Pointer(ship.node+0x40)!=ship.registry||Pointer(ship.node+0x78)!=ship.source ||LocalDockingComputer(frame)!=ship.computer||Pointer(ship.computer+0x240)!=controller||Pointer(ship.computer+0x260)!=ship.source ||!RecoverySubscriber(ship)||!FixtureBindingName(Pointer(ship.node+0xB0),"ForwardReverseThrust_Set") ||RecoveryThrottleTrialCommand(proof)!=0||Math.Abs(value[0]-.75f)>.001f||Math.Abs(value[1]-.75f)>.001f ||value[3]!=-100f&&Math.Abs(value[3])>.001f||Pointer(Pointer(controller)+0x158)!=image+ThrottleSetter ||!Platform.ReadBytes(image+0x8F5320,18).AsSpan().SequenceEqual(new byte[]{0xC6,0x81,0xC0,0,0,0,0,0xC7,0x81,0xB0,0,0,0,0,0,0,0,0xC3}))return false; // Undo only this trial's unchanged, retained command. These original // methods own the controller override and the source accumulator. Call(image+ThrottleSetter,(ulong)controller,F32(0)); Call(image+0x8F5320,(ulong)(ship.node+0x20));return true; } } #endif