X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Fclock.cxx;h=86343cb47ebf0775cd52194365f8db62c88a3de2;hb=caf0138ab35b03bbe7bf367ff2222d0a31be3157;hp=6a584bb5812dcac3099d7b2e0121c68932747eb0;hpb=ae5cf05827d6122f9cec7bbe279ecf671b5fcf41;p=flightgear.git diff --git a/src/Instrumentation/clock.cxx b/src/Instrumentation/clock.cxx index 6a584bb58..86343cb47 100644 --- a/src/Instrumentation/clock.cxx +++ b/src/Instrumentation/clock.cxx @@ -5,6 +5,9 @@ // // $Id$ +#ifdef HAVE_CONFIG_H +# include +#endif #include "clock.hxx" #include @@ -12,47 +15,19 @@ #include
-Clock::Clock ( SGPropertyNode *node ) - : _is_serviceable(true), - _gmt_time_sec(0), - _offset_sec(0), - _indicated_sec(0), - _indicated_min(0), - _indicated_hour(0), - _local_hour(0), - _standstill_offset(0), - name("clock"), - num(0) +Clock::Clock(SGPropertyNode *node) : + _name(node->getStringValue("name", "clock")), + _num(node->getIntValue("number", 0)), + _is_serviceable(true), + _gmt_time_sec(0), + _offset_sec(0), + _indicated_sec(0), + _indicated_min(0), + _indicated_hour(0), + _local_hour(0), + _standstill_offset(0) { _indicated_string[0] = '\0'; - - int i; - for ( i = 0; i < node->nChildren(); ++i ) { - SGPropertyNode *child = node->getChild(i); - string cname = child->getName(); - string cval = child->getStringValue(); - if ( cname == "name" ) { - name = cval; - } else if ( cname == "number" ) { - num = child->getIntValue(); - } else { - SG_LOG( SG_INSTR, SG_WARN, "Error in clock config logic" ); - if ( name.length() ) { - SG_LOG( SG_INSTR, SG_WARN, "Section = " << name ); - } - } - } -} - -Clock::Clock () - : _is_serviceable(true), - _gmt_time_sec(0), - _offset_sec(0), - _indicated_sec(0), - _standstill_offset(0) -{ - _indicated_string[0] = '\0'; - _indicated_short_string[0] = '\0'; } Clock::~Clock () @@ -62,10 +37,10 @@ Clock::~Clock () void Clock::init () { - string branch; - branch = "/instrumentation/" + name; + std::string branch; + branch = "/instrumentation/" + _name; - SGPropertyNode *node = fgGetNode(branch.c_str(), num, true ); + SGPropertyNode *node = fgGetNode(branch.c_str(), _num, true ); _serviceable_node = node->getChild("serviceable", 0, true); _offset_node = node->getChild("offset-sec", 0, true); _sec_node = node->getChild("indicated-sec", 0, true); @@ -96,8 +71,10 @@ Clock::update (double delta_time_sec) // compute local time zone hour int tzoffset_hours = globals->get_time_params()->get_local_offset() / 3600; int lhour = hour + tzoffset_hours; - if ( lhour < 0 ) { lhour += 24; } - if ( lhour >= 24 ) { lhour -= 24; } + if (lhour < 0) + lhour += 24; + if (lhour >= 24) + lhour -= 24; long gmt = (hour * 60 + min) * 60 + sec; int offset = _offset_node->getLongValue(); @@ -149,8 +126,6 @@ Clock::update (double delta_time_sec) _hour_node->setLongValue(_indicated_hour); _local_hour = lhour; _lhour_node->setLongValue(_local_hour); - - }