Major property-manager rewrite, using const char * throughout
interface instead of string. This will result in a lot more efficiency later, once I add in a simple hash table for caching lookups, since it will avoid creating a lot of temporary string objects. The major considerations for users will be that they cannot use node->getName() == "foo"; any more, and will have to use c_str() when setting a string value from a C++ string.
This commit is contained in:
parent
47b2307356
commit
0cc3bed841
20 changed files with 269 additions and 238 deletions
src
|
@ -664,7 +664,7 @@ void TgtAptDialog_OK (puObject *)
|
||||||
|
|
||||||
void TgtAptDialog_Reset(puObject *)
|
void TgtAptDialog_Reset(puObject *)
|
||||||
{
|
{
|
||||||
sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
|
sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id") );
|
||||||
TgtAptDialogInput->setValue ( NewTgtAirportId );
|
TgtAptDialogInput->setValue ( NewTgtAirportId );
|
||||||
TgtAptDialogInput->setCursor( 0 ) ;
|
TgtAptDialogInput->setCursor( 0 ) ;
|
||||||
}
|
}
|
||||||
|
@ -705,7 +705,7 @@ void TgtAptDialog_HandleArrow( puObject *arrow )
|
||||||
|
|
||||||
void AddWayPoint(puObject *cb)
|
void AddWayPoint(puObject *cb)
|
||||||
{
|
{
|
||||||
sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
|
sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id") );
|
||||||
TgtAptDialogInput->setValue( NewTgtAirportId );
|
TgtAptDialogInput->setValue( NewTgtAirportId );
|
||||||
|
|
||||||
/* refresh waypoint list */
|
/* refresh waypoint list */
|
||||||
|
@ -776,8 +776,7 @@ void ClearRoute(puObject *cb)
|
||||||
void NewTgtAirportInit()
|
void NewTgtAirportInit()
|
||||||
{
|
{
|
||||||
SG_LOG( SG_AUTOPILOT, SG_INFO, " enter NewTgtAirportInit()" );
|
SG_LOG( SG_AUTOPILOT, SG_INFO, " enter NewTgtAirportInit()" );
|
||||||
sprintf( NewTgtAirportId, "%s",
|
sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id") );
|
||||||
fgGetString("/sim/startup/airport-id").c_str() );
|
|
||||||
SG_LOG( SG_AUTOPILOT, SG_INFO, " NewTgtAirportId " << NewTgtAirportId );
|
SG_LOG( SG_AUTOPILOT, SG_INFO, " NewTgtAirportId " << NewTgtAirportId );
|
||||||
int len = 150
|
int len = 150
|
||||||
- puGetDefaultLabelFont().getStringWidth( NewTgtAirportLabel ) / 2;
|
- puGetDefaultLabelFont().getStringWidth( NewTgtAirportLabel ) / 2;
|
||||||
|
|
|
@ -376,7 +376,7 @@ void FGAutopilot::reset() {
|
||||||
|
|
||||||
update_old_control_values();
|
update_old_control_values();
|
||||||
|
|
||||||
sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
|
sprintf( NewTgtAirportId, "%s", fgGetString("/sim/startup/airport-id") );
|
||||||
|
|
||||||
MakeTargetLatLonStr( get_TargetLatitude(), get_TargetLongitude() );
|
MakeTargetLatLonStr( get_TargetLatitude(), get_TargetLongitude() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,7 +183,7 @@ float get_altitude( void )
|
||||||
|
|
||||||
float altitude;
|
float altitude;
|
||||||
|
|
||||||
if ( startup_units_node->getStringValue() == "feet" ) {
|
if ( string(startup_units_node->getStringValue()) == "feet" ) {
|
||||||
altitude = current_aircraft.fdm_state->get_Altitude();
|
altitude = current_aircraft.fdm_state->get_Altitude();
|
||||||
} else {
|
} else {
|
||||||
altitude = (current_aircraft.fdm_state->get_Altitude()
|
altitude = (current_aircraft.fdm_state->get_Altitude()
|
||||||
|
|
|
@ -1102,7 +1102,7 @@ FGTextLayer::Chunk::getValue () const
|
||||||
sprintf(_buf, _fmt.c_str(), _text.c_str());
|
sprintf(_buf, _fmt.c_str(), _text.c_str());
|
||||||
return _buf;
|
return _buf;
|
||||||
case TEXT_VALUE:
|
case TEXT_VALUE:
|
||||||
sprintf(_buf, _fmt.c_str(), _node->getStringValue().c_str());
|
sprintf(_buf, _fmt.c_str(), _node->getStringValue());
|
||||||
break;
|
break;
|
||||||
case DOUBLE_VALUE:
|
case DOUBLE_VALUE:
|
||||||
sprintf(_buf, _fmt.c_str(), _node->getFloatValue() * _mult);
|
sprintf(_buf, _fmt.c_str(), _node->getFloatValue() * _mult);
|
||||||
|
|
|
@ -295,8 +295,8 @@ readTransformation (const SGPropertyNode * node, float w_scale, float h_scale)
|
||||||
type = "rotation";
|
type = "rotation";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (propName != (string)"") {
|
if (propName != "") {
|
||||||
target = fgGetNode(propName, true);
|
target = fgGetNode(propName.c_str(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
t->node = target;
|
t->node = target;
|
||||||
|
@ -313,7 +313,7 @@ readTransformation (const SGPropertyNode * node, float w_scale, float h_scale)
|
||||||
t->table = new SGInterpTable();
|
t->table = new SGInterpTable();
|
||||||
for(int i = 0; i < trans_table->nChildren(); i++) {
|
for(int i = 0; i < trans_table->nChildren(); i++) {
|
||||||
const SGPropertyNode * node = trans_table->getChild(i);
|
const SGPropertyNode * node = trans_table->getChild(i);
|
||||||
if (node->getName() == "entry") {
|
if (string(node->getName()) == "entry") {
|
||||||
double ind = node->getDoubleValue("ind", 0.0);
|
double ind = node->getDoubleValue("ind", 0.0);
|
||||||
double dep = node->getDoubleValue("dep", 0.0);
|
double dep = node->getDoubleValue("dep", 0.0);
|
||||||
SG_LOG( SG_COCKPIT, SG_INFO, "Adding interpolation entry "
|
SG_LOG( SG_COCKPIT, SG_INFO, "Adding interpolation entry "
|
||||||
|
@ -413,7 +413,7 @@ readTextChunk (const SGPropertyNode * node)
|
||||||
else if (type == "number-value") {
|
else if (type == "number-value") {
|
||||||
string propName = node->getStringValue("property");
|
string propName = node->getStringValue("property");
|
||||||
float scale = node->getFloatValue("scale", 1.0);
|
float scale = node->getFloatValue("scale", 1.0);
|
||||||
SGPropertyNode * target = fgGetNode(propName, true);
|
SGPropertyNode * target = fgGetNode(propName.c_str(), true);
|
||||||
chunk = new FGTextLayer::Chunk(FGTextLayer::DOUBLE_VALUE, target,
|
chunk = new FGTextLayer::Chunk(FGTextLayer::DOUBLE_VALUE, target,
|
||||||
format, scale);
|
format, scale);
|
||||||
}
|
}
|
||||||
|
@ -485,7 +485,7 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale)
|
||||||
for (int i = 0; i < node->nChildren(); i++) {
|
for (int i = 0; i < node->nChildren(); i++) {
|
||||||
const SGPropertyNode * child = node->getChild(i);
|
const SGPropertyNode * child = node->getChild(i);
|
||||||
cerr << "Trying child " << child->getName() << endl;
|
cerr << "Trying child " << child->getName() << endl;
|
||||||
if (child->getName() == "layer") {
|
if (string(child->getName()) == "layer") {
|
||||||
cerr << "succeeded!" << endl;
|
cerr << "succeeded!" << endl;
|
||||||
((FGGroupLayer *)layer)->addLayer(readLayer(child, w_scale, h_scale));
|
((FGGroupLayer *)layer)->addLayer(readLayer(child, w_scale, h_scale));
|
||||||
}
|
}
|
||||||
|
@ -516,7 +516,7 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale)
|
||||||
int nChunks = chunk_group->nChildren();
|
int nChunks = chunk_group->nChildren();
|
||||||
for (int i = 0; i < nChunks; i++) {
|
for (int i = 0; i < nChunks; i++) {
|
||||||
const SGPropertyNode * node = chunk_group->getChild(i);
|
const SGPropertyNode * node = chunk_group->getChild(i);
|
||||||
if (node->getName() == "chunk") {
|
if (string(node->getName()) == "chunk") {
|
||||||
FGTextLayer::Chunk * chunk = readTextChunk(node);
|
FGTextLayer::Chunk * chunk = readTextChunk(node);
|
||||||
if (chunk != 0)
|
if (chunk != 0)
|
||||||
tlayer->addChunk(chunk);
|
tlayer->addChunk(chunk);
|
||||||
|
@ -576,7 +576,7 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale)
|
||||||
int nTransformations = trans_group->nChildren();
|
int nTransformations = trans_group->nChildren();
|
||||||
for (int i = 0; i < nTransformations; i++) {
|
for (int i = 0; i < nTransformations; i++) {
|
||||||
const SGPropertyNode * node = trans_group->getChild(i);
|
const SGPropertyNode * node = trans_group->getChild(i);
|
||||||
if (node->getName() == "transformation") {
|
if (string(node->getName()) == "transformation") {
|
||||||
FGPanelTransformation * t = readTransformation(node, w_scale, h_scale);
|
FGPanelTransformation * t = readTransformation(node, w_scale, h_scale);
|
||||||
if (t != 0)
|
if (t != 0)
|
||||||
layer->addTransformation(t);
|
layer->addTransformation(t);
|
||||||
|
@ -645,7 +645,7 @@ readInstrument (const SGPropertyNode * node)
|
||||||
int nActions = action_group->nChildren();
|
int nActions = action_group->nChildren();
|
||||||
for (int i = 0; i < nActions; i++) {
|
for (int i = 0; i < nActions; i++) {
|
||||||
const SGPropertyNode * node = action_group->getChild(i);
|
const SGPropertyNode * node = action_group->getChild(i);
|
||||||
if (node->getName() == "action") {
|
if (string(node->getName()) == "action") {
|
||||||
FGPanelAction * action = readAction(node, w_scale, h_scale);
|
FGPanelAction * action = readAction(node, w_scale, h_scale);
|
||||||
if (action != 0)
|
if (action != 0)
|
||||||
instrument->addAction(action);
|
instrument->addAction(action);
|
||||||
|
@ -664,7 +664,7 @@ readInstrument (const SGPropertyNode * node)
|
||||||
int nLayers = layer_group->nChildren();
|
int nLayers = layer_group->nChildren();
|
||||||
for (int i = 0; i < nLayers; i++) {
|
for (int i = 0; i < nLayers; i++) {
|
||||||
const SGPropertyNode * node = layer_group->getChild(i);
|
const SGPropertyNode * node = layer_group->getChild(i);
|
||||||
if (node->getName() == "layer") {
|
if (string(node->getName()) == "layer") {
|
||||||
FGInstrumentLayer * layer = readLayer(node, w_scale, h_scale);
|
FGInstrumentLayer * layer = readLayer(node, w_scale, h_scale);
|
||||||
if (layer != 0)
|
if (layer != 0)
|
||||||
instrument->addLayer(layer);
|
instrument->addLayer(layer);
|
||||||
|
@ -783,7 +783,7 @@ readPanel (const SGPropertyNode * root)
|
||||||
int nInstruments = instrument_group->nChildren();
|
int nInstruments = instrument_group->nChildren();
|
||||||
for (int i = 0; i < nInstruments; i++) {
|
for (int i = 0; i < nInstruments; i++) {
|
||||||
const SGPropertyNode * node = instrument_group->getChild(i);
|
const SGPropertyNode * node = instrument_group->getChild(i);
|
||||||
if (node->getName() == "instrument") {
|
if (string(node->getName()) == "instrument") {
|
||||||
FGPanelInstrument * instrument = readInstrument(node);
|
FGPanelInstrument * instrument = readInstrument(node);
|
||||||
if (instrument != 0)
|
if (instrument != 0)
|
||||||
panel->addInstrument(instrument);
|
panel->addInstrument(instrument);
|
||||||
|
|
|
@ -45,10 +45,10 @@ FGLaRCsim::FGLaRCsim( double dt ) {
|
||||||
speed_up = fgGetNode("/sim/speed-up", true);
|
speed_up = fgGetNode("/sim/speed-up", true);
|
||||||
aero = fgGetNode("/sim/aero", true);
|
aero = fgGetNode("/sim/aero", true);
|
||||||
|
|
||||||
ls_toplevel_init( 0.0, (char *)(aero->getStringValue().c_str()) );
|
ls_toplevel_init( 0.0, (char *)(aero->getStringValue()) );
|
||||||
|
|
||||||
lsic=new LaRCsimIC; //this needs to be brought up after LaRCsim is
|
lsic=new LaRCsimIC; //this needs to be brought up after LaRCsim is
|
||||||
if ( aero->getStringValue() == "c172" ) {
|
if ( string(aero->getStringValue()) == "c172" ) {
|
||||||
copy_to_LaRCsim(); // initialize all of LaRCsim's vars
|
copy_to_LaRCsim(); // initialize all of LaRCsim's vars
|
||||||
|
|
||||||
//this should go away someday -- formerly done in fg_init.cxx
|
//this should go away someday -- formerly done in fg_init.cxx
|
||||||
|
@ -85,7 +85,7 @@ void FGLaRCsim::init() {
|
||||||
// Run an iteration of the EOM (equations of motion)
|
// Run an iteration of the EOM (equations of motion)
|
||||||
void FGLaRCsim::update( int multiloop ) {
|
void FGLaRCsim::update( int multiloop ) {
|
||||||
|
|
||||||
if ( aero->getStringValue() == "c172" ) {
|
if ( string(aero->getStringValue()) == "c172" ) {
|
||||||
// set control inputs
|
// set control inputs
|
||||||
// cout << "V_calibrated_kts = " << V_calibrated_kts << '\n';
|
// cout << "V_calibrated_kts = " << V_calibrated_kts << '\n';
|
||||||
eng.set_IAS( V_calibrated_kts );
|
eng.set_IAS( V_calibrated_kts );
|
||||||
|
@ -169,7 +169,7 @@ void FGLaRCsim::update( int multiloop ) {
|
||||||
speed_up->getIntValue();
|
speed_up->getIntValue();
|
||||||
Flap_handle = 30.0 * globals->get_controls()->get_flaps();
|
Flap_handle = 30.0 * globals->get_controls()->get_flaps();
|
||||||
|
|
||||||
if ( aero->getStringValue() == "c172" ) {
|
if ( string(aero->getStringValue()) == "c172" ) {
|
||||||
Use_External_Engine = 1;
|
Use_External_Engine = 1;
|
||||||
} else {
|
} else {
|
||||||
Use_External_Engine = 0;
|
Use_External_Engine = 0;
|
||||||
|
@ -539,7 +539,7 @@ bool FGLaRCsim::copy_from_LaRCsim() {
|
||||||
_set_Climb_Rate( -1 * V_down );
|
_set_Climb_Rate( -1 * V_down );
|
||||||
// cout << "climb rate = " << -V_down * 60 << endl;
|
// cout << "climb rate = " << -V_down * 60 << endl;
|
||||||
|
|
||||||
if ( aero->getStringValue() == "uiuc" ) {
|
if ( string(aero->getStringValue()) == "uiuc" ) {
|
||||||
if (pilot_elev_no) {
|
if (pilot_elev_no) {
|
||||||
globals->get_controls()->set_elevator(Long_control);
|
globals->get_controls()->set_elevator(Long_control);
|
||||||
globals->get_controls()->set_elevator_trim(Long_trim);
|
globals->get_controls()->set_elevator_trim(Long_trim);
|
||||||
|
|
|
@ -117,7 +117,7 @@ void AptDialog_OK (puObject *)
|
||||||
void AptDialog_Reset(puObject *)
|
void AptDialog_Reset(puObject *)
|
||||||
{
|
{
|
||||||
// strncpy( NewAirportId, fgGetString("/sim/startup/airport-id").c_str(), 16 );
|
// strncpy( NewAirportId, fgGetString("/sim/startup/airport-id").c_str(), 16 );
|
||||||
sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
|
sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id") );
|
||||||
AptDialogInput->setValue ( NewAirportId );
|
AptDialogInput->setValue ( NewAirportId );
|
||||||
AptDialogInput->setCursor( 0 ) ;
|
AptDialogInput->setCursor( 0 ) ;
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ void AptDialog_Reset(puObject *)
|
||||||
void NewAirport(puObject *cb)
|
void NewAirport(puObject *cb)
|
||||||
{
|
{
|
||||||
// strncpy( NewAirportId, fgGetString("/sim/startup/airport-id").c_str(), 16 );
|
// strncpy( NewAirportId, fgGetString("/sim/startup/airport-id").c_str(), 16 );
|
||||||
sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
|
sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id") );
|
||||||
// cout << "NewAirport " << NewAirportId << endl;
|
// cout << "NewAirport " << NewAirportId << endl;
|
||||||
AptDialogInput->setValue( NewAirportId );
|
AptDialogInput->setValue( NewAirportId );
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ void NewAirport(puObject *cb)
|
||||||
|
|
||||||
void NewAirportInit(void)
|
void NewAirportInit(void)
|
||||||
{
|
{
|
||||||
sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
|
sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id") );
|
||||||
int len = 150
|
int len = 150
|
||||||
- puGetDefaultLabelFont().getStringWidth( NewAirportLabel ) / 2;
|
- puGetDefaultLabelFont().getStringWidth( NewAirportLabel ) / 2;
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ void NetIdDialog_OK (puObject *)
|
||||||
|
|
||||||
void NewCallSign(puObject *cb)
|
void NewCallSign(puObject *cb)
|
||||||
{
|
{
|
||||||
sprintf( NewNetId, "%s", fgGetString("/sim/networking/call-sign").c_str() );
|
sprintf( NewNetId, "%s", fgGetString("/sim/networking/call-sign") );
|
||||||
// sprintf( NewNetId, "%s", fgd_callsign );
|
// sprintf( NewNetId, "%s", fgd_callsign );
|
||||||
NetIdDialogInput->setValue( NewNetId );
|
NetIdDialogInput->setValue( NewNetId );
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ void NewCallSign(puObject *cb)
|
||||||
|
|
||||||
void NewNetIdInit(void)
|
void NewNetIdInit(void)
|
||||||
{
|
{
|
||||||
sprintf( NewNetId, "%s", fgGetString("/sim/networking/call-sign").c_str() );
|
sprintf( NewNetId, "%s", fgGetString("/sim/networking/call-sign") );
|
||||||
// sprintf( NewNetId, "%s", fgd_callsign );
|
// sprintf( NewNetId, "%s", fgd_callsign );
|
||||||
int len = 150 - puGetDefaultLabelFont().getStringWidth( NewNetIdLabel ) / 2;
|
int len = 150 - puGetDefaultLabelFont().getStringWidth( NewNetIdLabel ) / 2;
|
||||||
|
|
||||||
|
|
|
@ -471,7 +471,7 @@ void fgPropPicker::find_props ()
|
||||||
for (i = 0; i < (int)node->nChildren(); i++) {
|
for (i = 0; i < (int)node->nChildren(); i++) {
|
||||||
SGPropertyNode * child = node->getChild(i);
|
SGPropertyNode * child = node->getChild(i);
|
||||||
name = child->getName();
|
name = child->getName();
|
||||||
if ( node->getChild(name, 1) != 0 ) {
|
if ( node->getChild(name.c_str(), 1) != 0 ) {
|
||||||
iindex = child->getIndex();
|
iindex = child->getIndex();
|
||||||
sprintf(sindex, "[%d]", iindex);
|
sprintf(sindex, "[%d]", iindex);
|
||||||
name += sindex;
|
name += sindex;
|
||||||
|
@ -487,11 +487,11 @@ void fgPropPicker::find_props ()
|
||||||
values[ pi ] = new char[ 2 ] ;
|
values[ pi ] = new char[ 2 ] ;
|
||||||
} else {
|
} else {
|
||||||
dflag[ pi ] = 0 ;
|
dflag[ pi ] = 0 ;
|
||||||
value = node->getStringValue ( name, "" );
|
value = node->getStringValue ( name.c_str(), "" );
|
||||||
values[ pi ] = new char[ strlen(value.c_str())+2 ] ;
|
values[ pi ] = new char[ strlen(value.c_str())+2 ] ;
|
||||||
strcpy ( values [pi], value.c_str() );
|
strcpy ( values [pi], value.c_str() );
|
||||||
line += " = '" + value + "' " + "(";
|
line += " = '" + value + "' " + "(";
|
||||||
line += getValueTypeString( node->getNode( name ) );
|
line += getValueTypeString( node->getNode( name.c_str() ) );
|
||||||
line += ")";
|
line += ")";
|
||||||
files[ pi ] = new char[ strlen(line.c_str())+2 ] ;
|
files[ pi ] = new char[ strlen(line.c_str())+2 ] ;
|
||||||
strcpy ( files [ pi ], line.c_str() ) ;
|
strcpy ( files [ pi ], line.c_str() ) ;
|
||||||
|
|
|
@ -517,7 +517,7 @@ do_property_swap (const SGPropertyNode * arg, SGCommandState ** state)
|
||||||
// FIXME: inefficient
|
// FIXME: inefficient
|
||||||
const string & tmp = prop1->getStringValue();
|
const string & tmp = prop1->getStringValue();
|
||||||
return (prop1->setUnspecifiedValue(prop2->getStringValue()) &&
|
return (prop1->setUnspecifiedValue(prop2->getStringValue()) &&
|
||||||
prop2->setUnspecifiedValue(tmp));
|
prop2->setUnspecifiedValue(tmp.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ LogClassMapping log_class_mappings [] = {
|
||||||
/**
|
/**
|
||||||
* Get the logging classes.
|
* Get the logging classes.
|
||||||
*/
|
*/
|
||||||
static string
|
static const char *
|
||||||
getLoggingClasses ()
|
getLoggingClasses ()
|
||||||
{
|
{
|
||||||
sgDebugClass classes = logbuf::get_log_classes();
|
sgDebugClass classes = logbuf::get_log_classes();
|
||||||
|
@ -110,11 +110,12 @@ getLoggingClasses ()
|
||||||
result += log_class_mappings[i].name;
|
result += log_class_mappings[i].name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void addLoggingClass (const string &name)
|
static void
|
||||||
|
addLoggingClass (const string &name)
|
||||||
{
|
{
|
||||||
sgDebugClass classes = logbuf::get_log_classes();
|
sgDebugClass classes = logbuf::get_log_classes();
|
||||||
for (int i = 0; log_class_mappings[i].c != SG_UNDEFD; i++) {
|
for (int i = 0; log_class_mappings[i].c != SG_UNDEFD; i++) {
|
||||||
|
@ -131,8 +132,9 @@ static void addLoggingClass (const string &name)
|
||||||
* Set the logging classes.
|
* Set the logging classes.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
setLoggingClasses (string classes)
|
setLoggingClasses (const char * c)
|
||||||
{
|
{
|
||||||
|
string classes = c;
|
||||||
logbuf::set_log_classes(SG_NONE);
|
logbuf::set_log_classes(SG_NONE);
|
||||||
|
|
||||||
if (classes == "none") {
|
if (classes == "none") {
|
||||||
|
@ -165,7 +167,7 @@ setLoggingClasses (string classes)
|
||||||
/**
|
/**
|
||||||
* Get the logging priority.
|
* Get the logging priority.
|
||||||
*/
|
*/
|
||||||
static string
|
static const char *
|
||||||
getLoggingPriority ()
|
getLoggingPriority ()
|
||||||
{
|
{
|
||||||
switch (logbuf::get_log_priority()) {
|
switch (logbuf::get_log_priority()) {
|
||||||
|
@ -191,8 +193,9 @@ getLoggingPriority ()
|
||||||
* Set the logging priority.
|
* Set the logging priority.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
setLoggingPriority (string priority)
|
setLoggingPriority (const char * p)
|
||||||
{
|
{
|
||||||
|
string priority = p;
|
||||||
if (priority == "bulk") {
|
if (priority == "bulk") {
|
||||||
logbuf::set_log_priority(SG_BULK);
|
logbuf::set_log_priority(SG_BULK);
|
||||||
} else if (priority == "debug") {
|
} else if (priority == "debug") {
|
||||||
|
@ -210,42 +213,13 @@ setLoggingPriority (string priority)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/**
|
|
||||||
* Get the pause state of the sim.
|
|
||||||
*/
|
|
||||||
static bool
|
|
||||||
getFreeze ()
|
|
||||||
{
|
|
||||||
return globals->get_freeze();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the pause state of the sim.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
setFreeze (bool freeze)
|
|
||||||
{
|
|
||||||
globals->set_freeze(freeze);
|
|
||||||
if ( freeze ) {
|
|
||||||
// BusyCursor( 0 );
|
|
||||||
current_atcdisplay->CancelRepeatingMessage();
|
|
||||||
current_atcdisplay->RegisterRepeatingMessage("**** SIM IS FROZEN **** SIM IS FROZEN ****");
|
|
||||||
} else {
|
|
||||||
// BusyCursor( 1 );
|
|
||||||
current_atcdisplay->CancelRepeatingMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the current aircraft directory (UIUC) as a string.
|
* Return the current aircraft directory (UIUC) as a string.
|
||||||
*/
|
*/
|
||||||
static string
|
static const char *
|
||||||
getAircraftDir ()
|
getAircraftDir ()
|
||||||
{
|
{
|
||||||
return aircraft_dir;
|
return aircraft_dir.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -253,12 +227,9 @@ getAircraftDir ()
|
||||||
* Set the current aircraft directory (UIUC).
|
* Set the current aircraft directory (UIUC).
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
setAircraftDir (string dir)
|
setAircraftDir (const char * dir)
|
||||||
{
|
{
|
||||||
if (getAircraftDir() != dir) {
|
aircraft_dir = dir;
|
||||||
aircraft_dir = dir;
|
|
||||||
// needReinit(); FIXME!!
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -275,7 +246,7 @@ getElapsedTime_ms ()
|
||||||
/**
|
/**
|
||||||
* Return the current Zulu time.
|
* Return the current Zulu time.
|
||||||
*/
|
*/
|
||||||
static string
|
static const char *
|
||||||
getDateString ()
|
getDateString ()
|
||||||
{
|
{
|
||||||
string out;
|
string out;
|
||||||
|
@ -285,7 +256,7 @@ getDateString ()
|
||||||
t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
|
t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
|
||||||
t->tm_hour, t->tm_min, t->tm_sec);
|
t->tm_hour, t->tm_min, t->tm_sec);
|
||||||
out = buf;
|
out = buf;
|
||||||
return out;
|
return out.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -293,7 +264,7 @@ getDateString ()
|
||||||
* Set the current Zulu time.
|
* Set the current Zulu time.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
setDateString (string date_string)
|
setDateString (const char * date_string)
|
||||||
{
|
{
|
||||||
static const SGPropertyNode *cur_time_override
|
static const SGPropertyNode *cur_time_override
|
||||||
= fgGetNode("/sim/time/cur-time-override", true);
|
= fgGetNode("/sim/time/cur-time-override", true);
|
||||||
|
@ -304,7 +275,7 @@ setDateString (string date_string)
|
||||||
|
|
||||||
// Scan for basic ISO format
|
// Scan for basic ISO format
|
||||||
// YYYY-MM-DDTHH:MM:SS
|
// YYYY-MM-DDTHH:MM:SS
|
||||||
int ret = sscanf(date_string.c_str(), "%d-%d-%dT%d:%d:%d",
|
int ret = sscanf(date_string, "%d-%d-%dT%d:%d:%d",
|
||||||
&(new_time.tm_year), &(new_time.tm_mon),
|
&(new_time.tm_year), &(new_time.tm_mon),
|
||||||
&(new_time.tm_mday), &(new_time.tm_hour),
|
&(new_time.tm_mday), &(new_time.tm_hour),
|
||||||
&(new_time.tm_min), &(new_time.tm_sec));
|
&(new_time.tm_min), &(new_time.tm_sec));
|
||||||
|
@ -339,7 +310,7 @@ setDateString (string date_string)
|
||||||
/**
|
/**
|
||||||
* Return the GMT as a string.
|
* Return the GMT as a string.
|
||||||
*/
|
*/
|
||||||
static string
|
static const char *
|
||||||
getGMTString ()
|
getGMTString ()
|
||||||
{
|
{
|
||||||
string out;
|
string out;
|
||||||
|
@ -349,7 +320,7 @@ getGMTString ()
|
||||||
t->tm_hour, t->tm_min, t->tm_sec);
|
t->tm_hour, t->tm_min, t->tm_sec);
|
||||||
// cout << t << " " << buf << endl;
|
// cout << t << " " << buf << endl;
|
||||||
out = buf;
|
out = buf;
|
||||||
return out;
|
return out.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -682,6 +653,146 @@ fgLoadFlight (istream &input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
// Property convenience functions.
|
||||||
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
SGPropertyNode *
|
||||||
|
fgGetNode (const char * path, bool create)
|
||||||
|
{
|
||||||
|
return globals->get_props()->getNode(path, create);
|
||||||
|
}
|
||||||
|
|
||||||
|
SGPropertyNode *
|
||||||
|
fgGetNode (const char * path, int index, bool create)
|
||||||
|
{
|
||||||
|
return globals->get_props()->getNode(path, index, create);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
fgHasNode (const char * path)
|
||||||
|
{
|
||||||
|
return (fgGetNode(path, false) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
fgGetBool (const char * name, bool defaultValue)
|
||||||
|
{
|
||||||
|
return globals->get_props()->getBoolValue(name, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
fgGetInt (const char * name, int defaultValue)
|
||||||
|
{
|
||||||
|
return globals->get_props()->getIntValue(name, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
fgGetLong (const char * name, long defaultValue)
|
||||||
|
{
|
||||||
|
return globals->get_props()->getLongValue(name, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
float
|
||||||
|
fgGetFloat (const char * name, float defaultValue)
|
||||||
|
{
|
||||||
|
return globals->get_props()->getFloatValue(name, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
double
|
||||||
|
fgGetDouble (const char * name, double defaultValue)
|
||||||
|
{
|
||||||
|
return globals->get_props()->getDoubleValue(name, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
fgGetString (const char * name, const char * defaultValue)
|
||||||
|
{
|
||||||
|
return globals->get_props()->getStringValue(name, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
fgSetBool (const char * name, bool val)
|
||||||
|
{
|
||||||
|
return globals->get_props()->setBoolValue(name, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
fgSetInt (const char * name, int val)
|
||||||
|
{
|
||||||
|
return globals->get_props()->setIntValue(name, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
fgSetLong (const char * name, long val)
|
||||||
|
{
|
||||||
|
return globals->get_props()->setLongValue(name, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
fgSetFloat (const char * name, float val)
|
||||||
|
{
|
||||||
|
return globals->get_props()->setFloatValue(name, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
fgSetDouble (const char * name, double val)
|
||||||
|
{
|
||||||
|
return globals->get_props()->setDoubleValue(name, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
fgSetString (const char * name, const char * val)
|
||||||
|
{
|
||||||
|
return globals->get_props()->setStringValue(name, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
fgSetArchivable (const char * name, bool state)
|
||||||
|
{
|
||||||
|
SGPropertyNode * node = globals->get_props()->getNode(name);
|
||||||
|
if (node == 0)
|
||||||
|
SG_LOG(SG_GENERAL, SG_ALERT,
|
||||||
|
"Attempt to set archive flag for non-existant property "
|
||||||
|
<< name);
|
||||||
|
else
|
||||||
|
node->setAttribute(SGPropertyNode::ARCHIVE, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
fgSetReadable (const char * name, bool state)
|
||||||
|
{
|
||||||
|
SGPropertyNode * node = globals->get_props()->getNode(name);
|
||||||
|
if (node == 0)
|
||||||
|
SG_LOG(SG_GENERAL, SG_ALERT,
|
||||||
|
"Attempt to set read flag for non-existant property "
|
||||||
|
<< name);
|
||||||
|
else
|
||||||
|
node->setAttribute(SGPropertyNode::READ, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
fgSetWritable (const char * name, bool state)
|
||||||
|
{
|
||||||
|
SGPropertyNode * node = globals->get_props()->getNode(name);
|
||||||
|
if (node == 0)
|
||||||
|
SG_LOG(SG_GENERAL, SG_ALERT,
|
||||||
|
"Attempt to set write flag for non-existant property "
|
||||||
|
<< name);
|
||||||
|
else
|
||||||
|
node->setAttribute(SGPropertyNode::WRITE, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
fgUntie (const char * name)
|
||||||
|
{
|
||||||
|
if (!globals->get_props()->untie(name))
|
||||||
|
SG_LOG(SG_GENERAL, SG_WARN, "Failed to untie property " << name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Implementation of FGCondition.
|
// Implementation of FGCondition.
|
||||||
|
@ -701,7 +812,7 @@ FGCondition::~FGCondition ()
|
||||||
// Implementation of FGPropertyCondition.
|
// Implementation of FGPropertyCondition.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FGPropertyCondition::FGPropertyCondition (const string &propname)
|
FGPropertyCondition::FGPropertyCondition (const char * propname)
|
||||||
: _node(fgGetNode(propname, true))
|
: _node(fgGetNode(propname, true))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -915,13 +1026,13 @@ FGComparisonCondition::test () const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGComparisonCondition::setLeftProperty (const string &propname)
|
FGComparisonCondition::setLeftProperty (const char * propname)
|
||||||
{
|
{
|
||||||
_left_property = fgGetNode(propname, true);
|
_left_property = fgGetNode(propname, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGComparisonCondition::setRightProperty (const string &propname)
|
FGComparisonCondition::setRightProperty (const char * propname)
|
||||||
{
|
{
|
||||||
delete _right_value;
|
delete _right_value;
|
||||||
_right_value = 0;
|
_right_value = 0;
|
||||||
|
|
|
@ -69,7 +69,6 @@ extern bool fgLoadFlight (istream &input);
|
||||||
// Convenience functions for getting property values.
|
// Convenience functions for getting property values.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a property node.
|
* Get a property node.
|
||||||
*
|
*
|
||||||
|
@ -77,11 +76,7 @@ extern bool fgLoadFlight (istream &input);
|
||||||
* @param create true to create the node if it doesn't exist.
|
* @param create true to create the node if it doesn't exist.
|
||||||
* @return The node, or 0 if none exists and none was created.
|
* @return The node, or 0 if none exists and none was created.
|
||||||
*/
|
*/
|
||||||
inline SGPropertyNode *
|
extern SGPropertyNode * fgGetNode (const char * path, bool create = false);
|
||||||
fgGetNode (const string &path, bool create = false)
|
|
||||||
{
|
|
||||||
return globals->get_props()->getNode(path, create);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,11 +93,8 @@ fgGetNode (const string &path, bool create = false)
|
||||||
* @param create true to create the node if it doesn't exist.
|
* @param create true to create the node if it doesn't exist.
|
||||||
* @return The node, or 0 if none exists and none was created.
|
* @return The node, or 0 if none exists and none was created.
|
||||||
*/
|
*/
|
||||||
inline SGPropertyNode *
|
extern SGPropertyNode * fgGetNode (const char * path,
|
||||||
fgGetNode (const string &path, int index, bool create = false)
|
int index, bool create = false);
|
||||||
{
|
|
||||||
return globals->get_props()->getNode(path, index, create);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,11 +103,7 @@ fgGetNode (const string &path, int index, bool create = false)
|
||||||
* @param path The path of the node, relative to root.
|
* @param path The path of the node, relative to root.
|
||||||
* @return true if the node exists, false otherwise.
|
* @return true if the node exists, false otherwise.
|
||||||
*/
|
*/
|
||||||
inline bool
|
extern bool fgHasNode (const char * path);
|
||||||
fgHasNode (const string &path)
|
|
||||||
{
|
|
||||||
return (fgGetNode(path, false) != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,10 +120,7 @@ fgHasNode (const string &path)
|
||||||
* does not exist.
|
* does not exist.
|
||||||
* @return The property's value as a bool, or the default value provided.
|
* @return The property's value as a bool, or the default value provided.
|
||||||
*/
|
*/
|
||||||
inline bool fgGetBool (const string &name, bool defaultValue = false)
|
extern bool fgGetBool (const char * name, bool defaultValue = false);
|
||||||
{
|
|
||||||
return globals->get_props()->getBoolValue(name, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,10 +137,7 @@ inline bool fgGetBool (const string &name, bool defaultValue = false)
|
||||||
* does not exist.
|
* does not exist.
|
||||||
* @return The property's value as an int, or the default value provided.
|
* @return The property's value as an int, or the default value provided.
|
||||||
*/
|
*/
|
||||||
inline int fgGetInt (const string &name, int defaultValue = 0)
|
extern int fgGetInt (const char * name, int defaultValue = 0);
|
||||||
{
|
|
||||||
return globals->get_props()->getIntValue(name, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -172,10 +154,7 @@ inline int fgGetInt (const string &name, int defaultValue = 0)
|
||||||
* does not exist.
|
* does not exist.
|
||||||
* @return The property's value as a long, or the default value provided.
|
* @return The property's value as a long, or the default value provided.
|
||||||
*/
|
*/
|
||||||
inline int fgGetLong (const string &name, long defaultValue = 0L)
|
extern int fgGetLong (const char * name, long defaultValue = 0L);
|
||||||
{
|
|
||||||
return globals->get_props()->getLongValue(name, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -192,10 +171,7 @@ inline int fgGetLong (const string &name, long defaultValue = 0L)
|
||||||
* does not exist.
|
* does not exist.
|
||||||
* @return The property's value as a float, or the default value provided.
|
* @return The property's value as a float, or the default value provided.
|
||||||
*/
|
*/
|
||||||
inline float fgGetFloat (const string &name, float defaultValue = 0.0)
|
extern float fgGetFloat (const char * name, float defaultValue = 0.0);
|
||||||
{
|
|
||||||
return globals->get_props()->getFloatValue(name, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -212,10 +188,7 @@ inline float fgGetFloat (const string &name, float defaultValue = 0.0)
|
||||||
* does not exist.
|
* does not exist.
|
||||||
* @return The property's value as a double, or the default value provided.
|
* @return The property's value as a double, or the default value provided.
|
||||||
*/
|
*/
|
||||||
inline double fgGetDouble (const string &name, double defaultValue = 0.0)
|
extern double fgGetDouble (const char * name, double defaultValue = 0.0);
|
||||||
{
|
|
||||||
return globals->get_props()->getDoubleValue(name, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -232,10 +205,8 @@ inline double fgGetDouble (const string &name, double defaultValue = 0.0)
|
||||||
* does not exist.
|
* does not exist.
|
||||||
* @return The property's value as a string, or the default value provided.
|
* @return The property's value as a string, or the default value provided.
|
||||||
*/
|
*/
|
||||||
inline string fgGetString (const string &name, string defaultValue = "")
|
extern const char * fgGetString (const char * name,
|
||||||
{
|
const char * defaultValue = "");
|
||||||
return globals->get_props()->getStringValue(name, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -251,10 +222,7 @@ inline string fgGetString (const string &name, string defaultValue = "")
|
||||||
* @param val The new value for the property.
|
* @param val The new value for the property.
|
||||||
* @return true if the assignment succeeded, false otherwise.
|
* @return true if the assignment succeeded, false otherwise.
|
||||||
*/
|
*/
|
||||||
inline bool fgSetBool (const string &name, bool val)
|
extern bool fgSetBool (const char * name, bool val);
|
||||||
{
|
|
||||||
return globals->get_props()->setBoolValue(name, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -270,10 +238,7 @@ inline bool fgSetBool (const string &name, bool val)
|
||||||
* @param val The new value for the property.
|
* @param val The new value for the property.
|
||||||
* @return true if the assignment succeeded, false otherwise.
|
* @return true if the assignment succeeded, false otherwise.
|
||||||
*/
|
*/
|
||||||
inline bool fgSetInt (const string &name, int val)
|
extern bool fgSetInt (const char * name, int val);
|
||||||
{
|
|
||||||
return globals->get_props()->setIntValue(name, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -289,10 +254,7 @@ inline bool fgSetInt (const string &name, int val)
|
||||||
* @param val The new value for the property.
|
* @param val The new value for the property.
|
||||||
* @return true if the assignment succeeded, false otherwise.
|
* @return true if the assignment succeeded, false otherwise.
|
||||||
*/
|
*/
|
||||||
inline bool fgSetLong (const string &name, long val)
|
extern bool fgSetLong (const char * name, long val);
|
||||||
{
|
|
||||||
return globals->get_props()->setLongValue(name, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -308,10 +270,7 @@ inline bool fgSetLong (const string &name, long val)
|
||||||
* @param val The new value for the property.
|
* @param val The new value for the property.
|
||||||
* @return true if the assignment succeeded, false otherwise.
|
* @return true if the assignment succeeded, false otherwise.
|
||||||
*/
|
*/
|
||||||
inline bool fgSetFloat (const string &name, float val)
|
extern bool fgSetFloat (const char * name, float val);
|
||||||
{
|
|
||||||
return globals->get_props()->setFloatValue(name, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -327,10 +286,7 @@ inline bool fgSetFloat (const string &name, float val)
|
||||||
* @param val The new value for the property.
|
* @param val The new value for the property.
|
||||||
* @return true if the assignment succeeded, false otherwise.
|
* @return true if the assignment succeeded, false otherwise.
|
||||||
*/
|
*/
|
||||||
inline bool fgSetDouble (const string &name, double val)
|
extern bool fgSetDouble (const char * name, double val);
|
||||||
{
|
|
||||||
return globals->get_props()->setDoubleValue(name, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -346,10 +302,7 @@ inline bool fgSetDouble (const string &name, double val)
|
||||||
* @param val The new value for the property.
|
* @param val The new value for the property.
|
||||||
* @return true if the assignment succeeded, false otherwise.
|
* @return true if the assignment succeeded, false otherwise.
|
||||||
*/
|
*/
|
||||||
inline bool fgSetString (const string &name, const string &val)
|
extern bool fgSetString (const char * name, const char * val);
|
||||||
{
|
|
||||||
return globals->get_props()->setStringValue(name, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -370,17 +323,7 @@ inline bool fgSetString (const string &name, const string &val)
|
||||||
* @param name The property name.
|
* @param name The property name.
|
||||||
* @param state The state of the archive attribute (defaults to true).
|
* @param state The state of the archive attribute (defaults to true).
|
||||||
*/
|
*/
|
||||||
inline void
|
extern void fgSetArchivable (const char * name, bool state = true);
|
||||||
fgSetArchivable (const string &name, bool state = true)
|
|
||||||
{
|
|
||||||
SGPropertyNode * node = globals->get_props()->getNode(name);
|
|
||||||
if (node == 0)
|
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT,
|
|
||||||
"Attempt to set archive flag for non-existant property "
|
|
||||||
<< name);
|
|
||||||
else
|
|
||||||
node->setAttribute(SGPropertyNode::ARCHIVE, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -395,17 +338,7 @@ fgSetArchivable (const string &name, bool state = true)
|
||||||
* @param name The property name.
|
* @param name The property name.
|
||||||
* @param state The state of the read attribute (defaults to true).
|
* @param state The state of the read attribute (defaults to true).
|
||||||
*/
|
*/
|
||||||
inline void
|
extern void fgSetReadable (const char * name, bool state = true);
|
||||||
fgSetReadable (const string &name, bool state = true)
|
|
||||||
{
|
|
||||||
SGPropertyNode * node = globals->get_props()->getNode(name);
|
|
||||||
if (node == 0)
|
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT,
|
|
||||||
"Attempt to set read flag for non-existant property "
|
|
||||||
<< name);
|
|
||||||
else
|
|
||||||
node->setAttribute(SGPropertyNode::READ, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -420,17 +353,7 @@ fgSetReadable (const string &name, bool state = true)
|
||||||
* @param name The property name.
|
* @param name The property name.
|
||||||
* @param state The state of the write attribute (defaults to true).
|
* @param state The state of the write attribute (defaults to true).
|
||||||
*/
|
*/
|
||||||
inline void
|
extern void fgSetWritable (const char * name, bool state = true);
|
||||||
fgSetWritable (const string &name, bool state = true)
|
|
||||||
{
|
|
||||||
SGPropertyNode * node = globals->get_props()->getNode(name);
|
|
||||||
if (node == 0)
|
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT,
|
|
||||||
"Attempt to set write flag for non-existant property "
|
|
||||||
<< name);
|
|
||||||
else
|
|
||||||
node->setAttribute(SGPropertyNode::WRITE, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -445,12 +368,7 @@ fgSetWritable (const string &name, bool state = true)
|
||||||
* Classes should use this function to release control of any
|
* Classes should use this function to release control of any
|
||||||
* properties they are managing.
|
* properties they are managing.
|
||||||
*/
|
*/
|
||||||
inline void
|
extern void fgUntie (const char * name);
|
||||||
fgUntie (const string &name)
|
|
||||||
{
|
|
||||||
if (!globals->get_props()->untie(name))
|
|
||||||
SG_LOG(SG_GENERAL, SG_WARN, "Failed to untie property " << name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -471,7 +389,7 @@ fgUntie (const string &name)
|
||||||
*/
|
*/
|
||||||
template <class V>
|
template <class V>
|
||||||
inline void
|
inline void
|
||||||
fgTie (const string &name, V (*getter)(), void (*setter)(V) = 0,
|
fgTie (const char * name, V (*getter)(), void (*setter)(V) = 0,
|
||||||
bool useDefault = true)
|
bool useDefault = true)
|
||||||
{
|
{
|
||||||
if (!globals->get_props()->tie(name, SGRawValueFunctions<V>(getter, setter),
|
if (!globals->get_props()->tie(name, SGRawValueFunctions<V>(getter, setter),
|
||||||
|
@ -501,7 +419,7 @@ fgTie (const string &name, V (*getter)(), void (*setter)(V) = 0,
|
||||||
*/
|
*/
|
||||||
template <class V>
|
template <class V>
|
||||||
inline void
|
inline void
|
||||||
fgTie (const string &name, int index, V (*getter)(int),
|
fgTie (const char * name, int index, V (*getter)(int),
|
||||||
void (*setter)(int, V) = 0, bool useDefault = true)
|
void (*setter)(int, V) = 0, bool useDefault = true)
|
||||||
{
|
{
|
||||||
if (!globals->get_props()->tie(name,
|
if (!globals->get_props()->tie(name,
|
||||||
|
@ -535,7 +453,7 @@ fgTie (const string &name, int index, V (*getter)(int),
|
||||||
*/
|
*/
|
||||||
template <class T, class V>
|
template <class T, class V>
|
||||||
inline void
|
inline void
|
||||||
fgTie (const string &name, T * obj, V (T::*getter)() const,
|
fgTie (const char * name, T * obj, V (T::*getter)() const,
|
||||||
void (T::*setter)(V) = 0, bool useDefault = true)
|
void (T::*setter)(V) = 0, bool useDefault = true)
|
||||||
{
|
{
|
||||||
if (!globals->get_props()->tie(name,
|
if (!globals->get_props()->tie(name,
|
||||||
|
@ -567,7 +485,7 @@ fgTie (const string &name, T * obj, V (T::*getter)() const,
|
||||||
*/
|
*/
|
||||||
template <class T, class V>
|
template <class T, class V>
|
||||||
inline void
|
inline void
|
||||||
fgTie (const string &name, T * obj, int index,
|
fgTie (const char * name, T * obj, int index,
|
||||||
V (T::*getter)(int) const, void (T::*setter)(int, V) = 0,
|
V (T::*getter)(int) const, void (T::*setter)(int, V) = 0,
|
||||||
bool useDefault = true)
|
bool useDefault = true)
|
||||||
{
|
{
|
||||||
|
@ -614,7 +532,7 @@ public:
|
||||||
class FGPropertyCondition : public FGCondition
|
class FGPropertyCondition : public FGCondition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FGPropertyCondition (const string &propname);
|
FGPropertyCondition (const char * propname);
|
||||||
virtual ~FGPropertyCondition ();
|
virtual ~FGPropertyCondition ();
|
||||||
virtual bool test () const { return _node->getBoolValue(); }
|
virtual bool test () const { return _node->getBoolValue(); }
|
||||||
private:
|
private:
|
||||||
|
@ -691,8 +609,8 @@ public:
|
||||||
FGComparisonCondition (Type type, bool reverse = false);
|
FGComparisonCondition (Type type, bool reverse = false);
|
||||||
virtual ~FGComparisonCondition ();
|
virtual ~FGComparisonCondition ();
|
||||||
virtual bool test () const;
|
virtual bool test () const;
|
||||||
virtual void setLeftProperty (const string &propname);
|
virtual void setLeftProperty (const char * propname);
|
||||||
virtual void setRightProperty (const string &propname);
|
virtual void setRightProperty (const char * propname);
|
||||||
// will make a local copy
|
// will make a local copy
|
||||||
virtual void setRightValue (const SGPropertyNode * value);
|
virtual void setRightValue (const SGPropertyNode * value);
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -1405,7 +1405,7 @@ int mainLoop( int argc, char **argv ) {
|
||||||
|
|
||||||
// set current_options lon/lat if an airport id is specified
|
// set current_options lon/lat if an airport id is specified
|
||||||
// cout << "3. airport_id = " << fgGetString("/sim/startup/airport-id") << endl;
|
// cout << "3. airport_id = " << fgGetString("/sim/startup/airport-id") << endl;
|
||||||
if ( fgGetString("/sim/startup/airport-id").length() ) {
|
if ( fgGetString("/sim/startup/airport-id")[0] != '\0' ) {
|
||||||
// fgSetPosFromAirportID( fgGetString("/sim/startup/airport-id") );
|
// fgSetPosFromAirportID( fgGetString("/sim/startup/airport-id") );
|
||||||
fgSetPosFromAirportIDandHdg( fgGetString("/sim/startup/airport-id"),
|
fgSetPosFromAirportIDandHdg( fgGetString("/sim/startup/airport-id"),
|
||||||
fgGetDouble("/orientation/heading-deg") );
|
fgGetDouble("/orientation/heading-deg") );
|
||||||
|
|
|
@ -574,13 +574,13 @@ parse_option (const string& arg)
|
||||||
} else if ( arg == "--enable-anti-alias-hud" ) {
|
} else if ( arg == "--enable-anti-alias-hud" ) {
|
||||||
fgSetBool("/sim/hud/antialiased", true);
|
fgSetBool("/sim/hud/antialiased", true);
|
||||||
} else if ( arg.find( "--control=") == 0 ) {
|
} else if ( arg.find( "--control=") == 0 ) {
|
||||||
fgSetString("/sim/control-mode", arg.substr(10));
|
fgSetString("/sim/control-mode", arg.substr(10).c_str());
|
||||||
} else if ( arg == "--disable-auto-coordination" ) {
|
} else if ( arg == "--disable-auto-coordination" ) {
|
||||||
fgSetBool("/sim/auto-coordination", false);
|
fgSetBool("/sim/auto-coordination", false);
|
||||||
} else if ( arg == "--enable-auto-coordination" ) {
|
} else if ( arg == "--enable-auto-coordination" ) {
|
||||||
fgSetBool("/sim/auto-coordination", true);
|
fgSetBool("/sim/auto-coordination", true);
|
||||||
} else if ( arg.find( "--browser-app=") == 0 ) {
|
} else if ( arg.find( "--browser-app=") == 0 ) {
|
||||||
fgSetString("/sim/startup/browser-app", arg.substr(14));
|
fgSetString("/sim/startup/browser-app", arg.substr(14).c_str());
|
||||||
} else if ( arg == "--disable-hud" ) {
|
} else if ( arg == "--disable-hud" ) {
|
||||||
fgSetBool("/sim/hud/visibility", false);
|
fgSetBool("/sim/hud/visibility", false);
|
||||||
} else if ( arg == "--enable-hud" ) {
|
} else if ( arg == "--enable-hud" ) {
|
||||||
|
@ -595,7 +595,7 @@ parse_option (const string& arg)
|
||||||
fgSetBool("/sim/sound/audible", true);
|
fgSetBool("/sim/sound/audible", true);
|
||||||
} else if ( arg.find( "--airport-id=") == 0 ) {
|
} else if ( arg.find( "--airport-id=") == 0 ) {
|
||||||
// NB: changed property name!!!
|
// NB: changed property name!!!
|
||||||
fgSetString("/sim/startup/airport-id", arg.substr(13));
|
fgSetString("/sim/startup/airport-id", arg.substr(13).c_str());
|
||||||
} else if ( arg.find( "--offset-distance=") == 0 ) {
|
} else if ( arg.find( "--offset-distance=") == 0 ) {
|
||||||
fgSetDouble("/sim/startup/offset-distance", atof(arg.substr(18)));
|
fgSetDouble("/sim/startup/offset-distance", atof(arg.substr(18)));
|
||||||
} else if ( arg.find( "--offset-azimuth=") == 0 ) {
|
} else if ( arg.find( "--offset-azimuth=") == 0 ) {
|
||||||
|
@ -679,11 +679,11 @@ parse_option (const string& arg)
|
||||||
} else if ( arg.find( "--fg-scenery=" ) == 0 ) {
|
} else if ( arg.find( "--fg-scenery=" ) == 0 ) {
|
||||||
globals->set_fg_scenery(arg.substr( 13 ));
|
globals->set_fg_scenery(arg.substr( 13 ));
|
||||||
} else if ( arg.find( "--fdm=" ) == 0 ) {
|
} else if ( arg.find( "--fdm=" ) == 0 ) {
|
||||||
fgSetString("/sim/flight-model", arg.substr(6));
|
fgSetString("/sim/flight-model", arg.substr(6).c_str());
|
||||||
} else if ( arg.find( "--aero=" ) == 0 ) {
|
} else if ( arg.find( "--aero=" ) == 0 ) {
|
||||||
fgSetString("/sim/aero", arg.substr(7));
|
fgSetString("/sim/aero", arg.substr(7).c_str());
|
||||||
} else if ( arg.find( "--aircraft-dir=" ) == 0 ) {
|
} else if ( arg.find( "--aircraft-dir=" ) == 0 ) {
|
||||||
fgSetString("/sim/aircraft-dir", arg.substr(15));
|
fgSetString("/sim/aircraft-dir", arg.substr(15).c_str());
|
||||||
} else if ( arg.find( "--model-hz=" ) == 0 ) {
|
} else if ( arg.find( "--model-hz=" ) == 0 ) {
|
||||||
fgSetInt("/sim/model-hz", atoi(arg.substr(11)));
|
fgSetInt("/sim/model-hz", atoi(arg.substr(11)));
|
||||||
} else if ( arg.find( "--speed=" ) == 0 ) {
|
} else if ( arg.find( "--speed=" ) == 0 ) {
|
||||||
|
@ -844,7 +844,7 @@ parse_option (const string& arg)
|
||||||
fgSetBool("/sim/hud/net-display", true);
|
fgSetBool("/sim/hud/net-display", true);
|
||||||
net_hud_display = 1; // FIXME
|
net_hud_display = 1; // FIXME
|
||||||
} else if ( arg.find( "--net-id=") == 0 ) {
|
} else if ( arg.find( "--net-id=") == 0 ) {
|
||||||
fgSetString("sim/networking/call-sign", arg.substr(9));
|
fgSetString("sim/networking/call-sign", arg.substr(9).c_str());
|
||||||
#endif
|
#endif
|
||||||
} else if ( arg.find( "--prop:" ) == 0 ) {
|
} else if ( arg.find( "--prop:" ) == 0 ) {
|
||||||
string assign = arg.substr(7);
|
string assign = arg.substr(7);
|
||||||
|
@ -855,17 +855,19 @@ parse_option (const string& arg)
|
||||||
}
|
}
|
||||||
string name = assign.substr(0, pos);
|
string name = assign.substr(0, pos);
|
||||||
string value = assign.substr(pos + 1);
|
string value = assign.substr(pos + 1);
|
||||||
fgSetString(name.c_str(), value);
|
fgSetString(name.c_str(), value.c_str());
|
||||||
// SG_LOG(SG_GENERAL, SG_INFO, "Setting default value of property "
|
// SG_LOG(SG_GENERAL, SG_INFO, "Setting default value of property "
|
||||||
// << name << " to \"" << value << '"');
|
// << name << " to \"" << value << '"');
|
||||||
} else if ( arg.find("--trace-read=") == 0) {
|
} else if ( arg.find("--trace-read=") == 0) {
|
||||||
string name = arg.substr(13);
|
string name = arg.substr(13);
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "Tracing reads for property " << name);
|
SG_LOG(SG_GENERAL, SG_INFO, "Tracing reads for property " << name);
|
||||||
fgGetNode(name, true)->setAttribute(SGPropertyNode::TRACE_READ, true);
|
fgGetNode(name.c_str(), true)
|
||||||
|
->setAttribute(SGPropertyNode::TRACE_READ, true);
|
||||||
} else if ( arg.find("--trace-write=") == 0) {
|
} else if ( arg.find("--trace-write=") == 0) {
|
||||||
string name = arg.substr(14);
|
string name = arg.substr(14);
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "Tracing writes for property " << name);
|
SG_LOG(SG_GENERAL, SG_INFO, "Tracing writes for property " << name);
|
||||||
fgGetNode(name, true)->setAttribute(SGPropertyNode::TRACE_WRITE, true);
|
fgGetNode(name.c_str(), true)
|
||||||
|
->setAttribute(SGPropertyNode::TRACE_WRITE, true);
|
||||||
} else if ( arg.find( "--view-offset=" ) == 0 ) {
|
} else if ( arg.find( "--view-offset=" ) == 0 ) {
|
||||||
// $$$ begin - added VS Renganathan, 14 Oct 2K
|
// $$$ begin - added VS Renganathan, 14 Oct 2K
|
||||||
// for multi-window outside window imagery
|
// for multi-window outside window imagery
|
||||||
|
|
|
@ -133,7 +133,7 @@ void HttpdChannel::foundTerminator (void) {
|
||||||
string b = arg.substr( apos + 1 );
|
string b = arg.substr( apos + 1 );
|
||||||
printf(" a = %s b = %s\n", a.c_str(), b.c_str() );
|
printf(" a = %s b = %s\n", a.c_str(), b.c_str() );
|
||||||
if ( a == "value" ) {
|
if ( a == "value" ) {
|
||||||
fgSetString( request, urlDecode(b) );
|
fgSetString( request.c_str(), urlDecode(b).c_str() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ void HttpdChannel::foundTerminator (void) {
|
||||||
request = urlDecode(request);
|
request = urlDecode(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
node = globals->get_props()->getNode(request);
|
node = globals->get_props()->getNode(request.c_str());
|
||||||
|
|
||||||
string response = "";
|
string response = "";
|
||||||
response += "<HTML LANG=\"en\">";
|
response += "<HTML LANG=\"en\">";
|
||||||
|
@ -179,7 +179,7 @@ void HttpdChannel::foundTerminator (void) {
|
||||||
for (int i = 0; i < node->nChildren(); i++) {
|
for (int i = 0; i < node->nChildren(); i++) {
|
||||||
SGPropertyNode *child = node->getChild(i);
|
SGPropertyNode *child = node->getChild(i);
|
||||||
string name = child->getName();
|
string name = child->getName();
|
||||||
if ( node->getChild(name, 1) ) {
|
if ( node->getChild(name.c_str(), 1) ) {
|
||||||
char buf[16];
|
char buf[16];
|
||||||
sprintf(buf, "[%d]", child->getIndex());
|
sprintf(buf, "[%d]", child->getIndex());
|
||||||
name += buf;
|
name += buf;
|
||||||
|
@ -197,7 +197,7 @@ void HttpdChannel::foundTerminator (void) {
|
||||||
line += "</A></B>";
|
line += "</A></B>";
|
||||||
line += "/<BR>";
|
line += "/<BR>";
|
||||||
} else {
|
} else {
|
||||||
string value = node->getStringValue ( name, "" );
|
string value = node->getStringValue ( name.c_str(), "" );
|
||||||
line += "<B>";
|
line += "<B>";
|
||||||
line += name;
|
line += name;
|
||||||
line += "</B> <A HREF=\"";
|
line += "</B> <A HREF=\"";
|
||||||
|
|
|
@ -130,15 +130,15 @@ bool FGProps::process_command( const char *cmd ) {
|
||||||
|
|
||||||
string command = tokens[0];
|
string command = tokens[0];
|
||||||
|
|
||||||
SGPropertyNode * node = globals->get_props()->getNode(path);
|
SGPropertyNode * node = globals->get_props()->getNode(path.c_str());
|
||||||
|
|
||||||
if ( command == "ls" ) {
|
if ( command == "ls" ) {
|
||||||
SGPropertyNode * dir = node;
|
SGPropertyNode * dir = node;
|
||||||
if ( tokens.size() > 2 ) {
|
if ( tokens.size() > 2 ) {
|
||||||
if ( tokens[1][0] == '/' ) {
|
if ( tokens[1][0] == '/' ) {
|
||||||
dir = globals->get_props()->getNode(tokens[1]);
|
dir = globals->get_props()->getNode(tokens[1].c_str());
|
||||||
} else {
|
} else {
|
||||||
dir = globals->get_props()->getNode(path + "/" + tokens[1]);
|
dir = globals->get_props()->getNode((path + "/" + tokens[1]).c_str());
|
||||||
}
|
}
|
||||||
if ( dir == 0 ) {
|
if ( dir == 0 ) {
|
||||||
tokens[1] = "ERR Node \"" + tokens[1] + "\" not found.\n";
|
tokens[1] = "ERR Node \"" + tokens[1] + "\" not found.\n";
|
||||||
|
@ -151,7 +151,7 @@ bool FGProps::process_command( const char *cmd ) {
|
||||||
SGPropertyNode * child = dir->getChild(i);
|
SGPropertyNode * child = dir->getChild(i);
|
||||||
string name = child->getName();
|
string name = child->getName();
|
||||||
string line = name;
|
string line = name;
|
||||||
if ( dir->getChild(name, 1) ) {
|
if ( dir->getChild(name.c_str(), 1) ) {
|
||||||
char buf[16];
|
char buf[16];
|
||||||
sprintf(buf, "[%d]", child->getIndex());
|
sprintf(buf, "[%d]", child->getIndex());
|
||||||
line += buf;
|
line += buf;
|
||||||
|
@ -160,9 +160,9 @@ bool FGProps::process_command( const char *cmd ) {
|
||||||
line += "/";
|
line += "/";
|
||||||
} else {
|
} else {
|
||||||
if ( mode == PROMPT ) {
|
if ( mode == PROMPT ) {
|
||||||
string value = dir->getStringValue ( name, "" );
|
string value = dir->getStringValue ( name.c_str(), "" );
|
||||||
line += " =\t'" + value + "'\t(";
|
line += " =\t'" + value + "'\t(";
|
||||||
line += getValueTypeString( dir->getNode( name ) );
|
line += getValueTypeString( dir->getNode( name.c_str() ) );
|
||||||
line += ")";
|
line += ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ bool FGProps::process_command( const char *cmd ) {
|
||||||
io->writestring( buf.str() );
|
io->writestring( buf.str() );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SGPropertyNode *child = node->getNode(tokens[1]);
|
SGPropertyNode *child = node->getNode(tokens[1].c_str());
|
||||||
if ( child ) {
|
if ( child ) {
|
||||||
writeProperties ( buf, child );
|
writeProperties ( buf, child );
|
||||||
io->writestring( buf.str() );
|
io->writestring( buf.str() );
|
||||||
|
@ -192,7 +192,7 @@ bool FGProps::process_command( const char *cmd ) {
|
||||||
if ( tokens.size() <= 1 ) {
|
if ( tokens.size() <= 1 ) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else {
|
} else {
|
||||||
SGPropertyNode *child = node->getNode(tokens[1]);
|
SGPropertyNode *child = node->getNode(tokens[1].c_str());
|
||||||
if ( child ) {
|
if ( child ) {
|
||||||
node = child;
|
node = child;
|
||||||
path = node->getPath();
|
path = node->getPath();
|
||||||
|
@ -213,13 +213,13 @@ bool FGProps::process_command( const char *cmd ) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else {
|
} else {
|
||||||
string tmp;
|
string tmp;
|
||||||
string value = node->getStringValue ( tokens[1], "" );
|
string value = node->getStringValue ( tokens[1].c_str(), "" );
|
||||||
if ( mode == PROMPT ) {
|
if ( mode == PROMPT ) {
|
||||||
//string ttt = "debug = '" + tokens[1] + "'\n";
|
//string ttt = "debug = '" + tokens[1] + "'\n";
|
||||||
//io->writestring( ttt.c_str() );
|
//io->writestring( ttt.c_str() );
|
||||||
|
|
||||||
tmp = tokens[1] + " = '" + value + "' (";
|
tmp = tokens[1] + " = '" + value + "' (";
|
||||||
tmp += getValueTypeString( node->getNode( tokens[1] ) );
|
tmp += getValueTypeString( node->getNode( tokens[1].c_str() ) );
|
||||||
tmp += ")\n";
|
tmp += ")\n";
|
||||||
} else {
|
} else {
|
||||||
tmp = value + "\n";
|
tmp = value + "\n";
|
||||||
|
@ -230,13 +230,13 @@ bool FGProps::process_command( const char *cmd ) {
|
||||||
if ( tokens.size() <= 2 ) {
|
if ( tokens.size() <= 2 ) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else {
|
} else {
|
||||||
node->getNode( tokens[1], true )->setStringValue(tokens[2]);
|
node->getNode( tokens[1].c_str(), true )->setStringValue(tokens[2].c_str());
|
||||||
|
|
||||||
// now fetch and write out the new value as confirmation
|
// now fetch and write out the new value as confirmation
|
||||||
// of the change
|
// of the change
|
||||||
string value = node->getStringValue ( tokens[1], "" );
|
string value = node->getStringValue ( tokens[1].c_str(), "" );
|
||||||
string tmp = tokens[1] + " = '" + value + "' (";
|
string tmp = tokens[1] + " = '" + value + "' (";
|
||||||
tmp += getValueTypeString( node->getNode( tokens[1] ) );
|
tmp += getValueTypeString( node->getNode( tokens[1].c_str() ) );
|
||||||
tmp += ")\n";
|
tmp += ")\n";
|
||||||
|
|
||||||
io->writestring( tmp.c_str() );
|
io->writestring( tmp.c_str() );
|
||||||
|
|
|
@ -82,7 +82,7 @@ char *fg_net_init( ssgRoot *orig_scene ){
|
||||||
// We enable display of netinfos only if user wishes it via cmd-line param
|
// We enable display of netinfos only if user wishes it via cmd-line param
|
||||||
net_hud_display = (net_hud_display == 0) ? 0 : 1;
|
net_hud_display = (net_hud_display == 0) ? 0 : 1;
|
||||||
// Get pilot's name from options, can be modified at runtime via menu
|
// Get pilot's name from options, can be modified at runtime via menu
|
||||||
net_callsign = (char *)(fgGetString("/sim/networking/call-sign").c_str());
|
net_callsign = (char *)(fgGetString("/sim/networking/call-sign"));
|
||||||
// Disable Blast Mode -1 = Disable, 0 = Enable
|
// Disable Blast Mode -1 = Disable, 0 = Enable
|
||||||
net_blast_toggle = -1;
|
net_blast_toggle = -1;
|
||||||
// We start unregistered, we reg. later via menu to fgd
|
// We start unregistered, we reg. later via menu to fgd
|
||||||
|
|
|
@ -82,13 +82,15 @@ bool FGMaterialLib::load( const string& mpath ) {
|
||||||
int nMaterials = materials.nChildren();
|
int nMaterials = materials.nChildren();
|
||||||
for (int i = 0; i < nMaterials; i++) {
|
for (int i = 0; i < nMaterials; i++) {
|
||||||
const SGPropertyNode * node = materials.getChild(i);
|
const SGPropertyNode * node = materials.getChild(i);
|
||||||
if (node->getName() == "material") {
|
if (string(node->getName()) == "material") {
|
||||||
FGNewMat * m = new FGNewMat(node);
|
FGNewMat * m = new FGNewMat(node);
|
||||||
|
|
||||||
vector<const SGPropertyNode *>names = node->getChildren("name");
|
vector<const SGPropertyNode *>names = node->getChildren("name");
|
||||||
for (unsigned int j = 0; j < names.size(); j++) {
|
for (unsigned int j = 0; j < names.size(); j++) {
|
||||||
|
string name = names[j]->getStringValue();
|
||||||
m->ref();
|
m->ref();
|
||||||
matlib[names[j]->getStringValue()] = m;
|
std::cerr << "Material " << name << endl;
|
||||||
|
matlib[name] = m;
|
||||||
SG_LOG( SG_TERRAIN, SG_INFO, " Loading material "
|
SG_LOG( SG_TERRAIN, SG_INFO, " Loading material "
|
||||||
<< names[j]->getStringValue());
|
<< names[j]->getStringValue());
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,15 +51,16 @@ FGFX::init()
|
||||||
const SGPropertyNode * node = fgGetNode("/sim/sound", true);
|
const SGPropertyNode * node = fgGetNode("/sim/sound", true);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
string path_str = node->getStringValue("path");
|
||||||
SGPath path( globals->get_fg_root() );
|
SGPath path( globals->get_fg_root() );
|
||||||
if (node->getStringValue("path") == "") {
|
if (path_str == "") {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "Incorect path in configuration file.");
|
SG_LOG(SG_GENERAL, SG_ALERT, "Incorrect path in configuration file.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
path.append(node->getStringValue("path"));
|
path.append(path_str.c_str());
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "Reading Instrument " << node->getName()
|
SG_LOG(SG_GENERAL, SG_INFO, "Reading Instrument " << node->getName()
|
||||||
<< " from " << path.str());
|
<< " from " << path.str());
|
||||||
|
|
||||||
SGPropertyNode root;
|
SGPropertyNode root;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -99,29 +99,27 @@ FGSound::init()
|
||||||
SG_LOG(SG_GENERAL, SG_INFO,
|
SG_LOG(SG_GENERAL, SG_INFO,
|
||||||
"Loading sound information for: " << _name );
|
"Loading sound information for: " << _name );
|
||||||
|
|
||||||
if (_node->getStringValue("mode") == "looped") {
|
string mode_str = _node->getStringValue("mode");
|
||||||
|
if (mode_str == "looped") {
|
||||||
_mode = FGSound::LOOPED;
|
_mode = FGSound::LOOPED;
|
||||||
} else {
|
} else {
|
||||||
_mode = FGSound::ONCE;
|
_mode = FGSound::ONCE;
|
||||||
if (_node->getStringValue("mode") != (string)"once")
|
if (mode_str != (string)"once")
|
||||||
SG_LOG( SG_GENERAL, SG_INFO, "Unknown sound mode, default to 'once'");
|
SG_LOG( SG_GENERAL, SG_INFO, "Unknown sound mode, default to 'once'");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_node->getStringValue("type") == "flipflop") {
|
string type_str = _node->getStringValue("type");
|
||||||
|
if (type_str == "flipflop") {
|
||||||
_type = FGSound::FLIPFLOP;
|
_type = FGSound::FLIPFLOP;
|
||||||
|
} else if (type_str== "inverted") {
|
||||||
} else if (_node->getStringValue("type") == "inverted") {
|
|
||||||
_type = FGSound::INVERTED;
|
_type = FGSound::INVERTED;
|
||||||
|
} else if (type_str == "raise") {
|
||||||
} else if (_node->getStringValue("type") == "raise") {
|
|
||||||
_type = FGSound::RAISE;
|
_type = FGSound::RAISE;
|
||||||
|
} else if (type_str == "fall") {
|
||||||
} else if (_node->getStringValue("type") == "fall") {
|
|
||||||
_type = FGSound::FALL;
|
_type = FGSound::FALL;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_type = FGSound::LEVEL;
|
_type = FGSound::LEVEL;
|
||||||
if (_node->getStringValue("type") != (string)"level")
|
if (type_str != (string)"level")
|
||||||
SG_LOG( SG_GENERAL, SG_INFO, "Unknown sound type, default to 'level'");
|
SG_LOG( SG_GENERAL, SG_INFO, "Unknown sound type, default to 'level'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue