1
0
Fork 0

A few fixes from David Culp.

This commit is contained in:
ehofman 2005-06-11 08:19:16 +00:00
parent c3037e3891
commit 34a4fb72b5
3 changed files with 33 additions and 5 deletions

View file

@ -133,8 +133,12 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root)
modelLoaded = false;
IsSlave = false;
// Multiple FDM's are stopped for now. We need to ensure that
// the "user" instance always gets the zeroeth instance number,
// because there may be instruments or scripts tied to properties
// in the jsbsim[0] node.
IdFDM = FDMctr;
FDMctr++;
//FDMctr++;
try {
char* num = getenv("JSBSIM_DEBUG");

View file

@ -142,6 +142,10 @@ FGJSBsim::FGJSBsim( double dt )
}
}
reset_on_crash = fgGetBool("/sim/reset-on-crash", false);
crashed = false;
fgSetBool("/sim/crashed", false);
fdmex = new FGFDMExec( (FGPropertyManager*)globals->get_props() );
// Register ground callback.
@ -813,11 +817,10 @@ bool FGJSBsim::copy_from_JSBsim()
speedbrake_pos_pct->setDoubleValue( FCS->GetDsbPos(ofNorm) );
spoilers_pos_pct->setDoubleValue( FCS->GetDspPos(ofNorm) );
// force a sim reset if crashed (altitude AGL < 0)
// crashed (altitude AGL < 0)
if (get_Altitude_AGL() < 0.0) {
fgSetBool("/sim/crashed", true);
SGPropertyNode* node = fgGetNode("/sim/presets", true);
globals->get_commands()->execute("old-reinit-dialog", node);
crash_message = "Attempted to fly under ground.";
crash_handler();
}
return true;
@ -1093,3 +1096,17 @@ void FGJSBsim::update_ic(void)
}
}
void FGJSBsim::crash_handler(void)
{
if (crashed) return; // we already crashed
crashed = true;
fgSetBool("/sim/crashed", true);
SG_LOG( SG_FLIGHT, SG_WARN, " Crash: " << crash_message );
if (reset_on_crash) {
SGPropertyNode* node = fgGetNode("/sim/presets", true);
globals->get_commands()->execute("old-reinit-dialog", node);
} else {
fgSetBool("/sim/freeze/master", true);
fgSetBool("/sim/freeze/clock", true);
}
}

View file

@ -205,6 +205,9 @@ public:
void do_trim(void);
void update_ic(void);
//** Handle a crash of the user aircraft. */
void crash_handler();
private:
FGFDMExec *fdmex;
FGInitialCondition *fgic;
@ -263,6 +266,10 @@ private:
void init_gear(void);
void update_gear(void);
bool reset_on_crash;
bool crashed;
string crash_message;
};