X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMain%2Ffg_props.cxx;h=b98f3280570ac6a622644676d06adf8197bd0a4c;hb=38226af24ec01e8f0a20d7fd73ef838a69f6ef25;hp=31f4ae0dac7f5403c1d706349c7ba24d51ff7293;hpb=3e0489bd910620e5d34e33d231c55135daeb2543;p=flightgear.git diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx index 31f4ae0da..b98f32805 100644 --- a/src/Main/fg_props.cxx +++ b/src/Main/fg_props.cxx @@ -31,10 +31,9 @@ #include #include #include +#include #include -#include -#include #include #include "globals.hxx" @@ -43,8 +42,6 @@ static bool winding_ccw = true; // FIXME: temporary -static bool fdm_data_logging = false; // FIXME: temporary - static bool frozen = false; // FIXME: temporary using std::string; @@ -236,6 +233,9 @@ setFreeze (bool f) smgr->resume(); } } + + // Pause the particle system + simgear::Particles::setFrozen(f); } @@ -256,7 +256,14 @@ static const char * getDateString () { static char buf[64]; // FIXME - struct tm * t = globals->get_time_params()->getGmt(); + + SGTime * st = globals->get_time_params(); + if (!st) { + buf[0] = 0; + return buf; + } + + struct tm * t = st->getGmt(); sprintf(buf, "%.4d-%.2d-%.2dT%.2d:%.2d:%.2d", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); @@ -270,9 +277,6 @@ getDateString () static void setDateString (const char * date_string) { - static const SGPropertyNode *cur_time_override - = fgGetNode("/sim/time/cur-time-override", true); - SGTime * st = globals->get_time_params(); struct tm * current_time = st->getGmt(); struct tm new_time; @@ -298,16 +302,13 @@ setDateString (const char * date_string) // values, one way or another. new_time.tm_year -= 1900; new_time.tm_mon -= 1; - // Now, tell flight gear to use // the new time. This was far // too difficult, by the way. long int warp = mktime(&new_time) - mktime(current_time) + globals->get_warp(); - double lon = current_aircraft.fdm_state->get_Longitude(); - double lat = current_aircraft.fdm_state->get_Latitude(); - globals->set_warp(warp); - st->update(lon, lat, cur_time_override->getLongValue(), warp); + + fgSetInt("/sim/time/warp", warp); } /** @@ -317,7 +318,13 @@ static const char * getGMTString () { static char buf[16]; - struct tm *t = globals->get_time_params()->getGmt(); + SGTime * st = globals->get_time_params(); + if (!st) { + buf[0] = 0; + return buf; + } + + struct tm *t = st->getGmt(); snprintf(buf, 16, "%.2d:%.2d:%.2d", t->tm_hour, t->tm_min, t->tm_sec); return buf; @@ -350,33 +357,21 @@ static double getHeadingMag () { double magheading; - magheading = current_aircraft.fdm_state->get_Psi() * SGD_RADIANS_TO_DEGREES - getMagVar(); + magheading = fgGetDouble("/orientation/heading-deg") - getMagVar(); if (magheading < 0) magheading += 360; return magheading; } -static long -getWarp () -{ - return globals->get_warp(); -} - -static void -setWarp (long warp) -{ - globals->set_warp(warp); -} - -static long -getWarpDelta () -{ - return globals->get_warp_delta(); -} - -static void -setWarpDelta (long delta) +/** + * Return the current track in degrees. + */ +static double +getTrackMag () { - globals->set_warp_delta(delta); + double magtrack; + magtrack = fgGetDouble("/orientation/track-deg") - getMagVar(); + if (magtrack < 0) magtrack += 360; + return magtrack; } static bool @@ -395,22 +390,6 @@ setWindingCCW (bool state) glFrontFace ( GL_CW ); } -static bool -getFDMDataLogging () -{ - return fdm_data_logging; -} - -static void -setFDMDataLogging (bool state) -{ - // kludge; no getter or setter available - if (state != fdm_data_logging) { - fgToggleFDMdataLogging(); - fdm_data_logging = state; - } -} - static const char * getLongitudeString () { @@ -514,16 +493,13 @@ FGProperties::bind () // Orientation fgTie("/orientation/heading-magnetic-deg", getHeadingMag); + fgTie("/orientation/track-magnetic-deg", getTrackMag); fgTie("/environment/magnetic-variation-deg", getMagVar); fgTie("/environment/magnetic-dip-deg", getMagDip); - fgTie("/sim/time/warp", getWarp, setWarp, false); - fgTie("/sim/time/warp-delta", getWarpDelta, setWarpDelta); - // Misc. Temporary junk. fgTie("/sim/temp/winding-ccw", getWindingCCW, setWindingCCW, false); - fgTie("/sim/temp/fdm-data-logging", getFDMDataLogging, setFDMDataLogging); } void @@ -543,18 +519,16 @@ FGProperties::unbind () // Orientation fgUntie("/orientation/heading-magnetic-deg"); + fgUntie("/orientation/track-magnetic-deg"); // Environment fgUntie("/environment/magnetic-variation-deg"); fgUntie("/environment/magnetic-dip-deg"); - fgUntie("/sim/time/warp"); - fgUntie("/sim/time/warp-delta"); - // Misc. Temporary junk. fgUntie("/sim/temp/winding-ccw"); - fgUntie("/sim/temp/full-screen"); - fgUntie("/sim/temp/fdm-data-logging"); +// fgUntie("/sim/temp/full-screen"); +// fgUntie("/sim/temp/fdm-data-logging"); } void @@ -830,10 +804,21 @@ fgSetWritable (const char * name, bool state) } void -fgUntie (const char * name) +fgUntie(const char * name) { - if (!globals->get_props()->untie(name)) + SGPropertyNode* node = globals->get_props()->getNode(name); + if (!node) { + SG_LOG(SG_GENERAL, SG_WARN, "fgUntie: unknown property " << name); + return; + } + + if (!node->isTied()) { + return; + } + + if (!node->untie()) { SG_LOG(SG_GENERAL, SG_WARN, "Failed to untie property " << name); + } }