I think I understand what I'm looking at, I just don't know whether I'm missing something in the docs, looking at a bug, or seeing intentional behavior. In this module:
the time warp and thruster settings are not applied in that step, but the next one. I think this because if I get to interplanetary space, crank the timewarp to 100000x and tap KP+, the main tank empties and the timewarp is reset to 1.
So far as I can tell, there isn't any "earlier" step notification, no place where I can find out and modify what's going to happen next. That would certainly explain why my "warp safety officer" MFD hasn't already been written. I've tried doing it with every thruster-setting variant I can find. I don't see where this has been discussed before, sorry and linky-please? if I missed it, but if not I don't know whether what I want constitutes a bugfix or a new feature.
Code:
#define ORBITER_MODULE
#define WIN32_LEAN_AND_MEAN
#include "Orbitersdk.h"
struct WSO : oapi::Module
{
double warp; VESSEL *pV; double oldlevel;
void clbkPreStep(double simt, double simdt, double mjd) {
double ntv = pV->GetThrusterGroupLevel(THGROUP_MAIN);
if ( warp > 10.0 && oldlevel == 0.0 && ntv != 0.0 ) {
oapiSetTimeAcceleration(1.0);
pV->IncThrusterGroupLevel_SingleStep(THGROUP_MAIN,-ntv);
}
oldlevel=ntv;
}
void clbkFocusChanged (OBJHANDLE new_focus, OBJHANDLE old_focus) {
pV=oapiGetVesselInterface(new_focus);
}
void clbkTimeAccChanged (double new_warp, double old_warp) {
warp = new_warp;
}
WSO(HINSTANCE m) : oapi::Module(m), pV(0), warp(1.0), englevel(0) {}
};
DLLCLBK void InitModule(HINSTANCE m) { oapiRegisterModule(new WSO(m)); return;}
DLLCLBK void ExitModule(HINSTANCE m) { return; }
So far as I can tell, there isn't any "earlier" step notification, no place where I can find out and modify what's going to happen next. That would certainly explain why my "warp safety officer" MFD hasn't already been written. I've tried doing it with every thruster-setting variant I can find. I don't see where this has been discussed before, sorry and linky-please? if I missed it, but if not I don't know whether what I want constitutes a bugfix or a new feature.