]> git.mxchange.org Git - flightgear.git/blob - src/Main/fg_commands.cxx
Nasal security: document that symlinks are no longer followed
[flightgear.git] / src / Main / fg_commands.cxx
1 // fg_commands.cxx - internal FGFS commands.
2
3 #ifdef HAVE_CONFIG_H
4 #  include "config.h"
5 #endif
6
7 #include <string.h>             // strcmp()
8
9 #include <simgear/compiler.h>
10
11 #include <string>
12 #include <fstream>
13
14 #include <simgear/sg_inlines.h>
15 #include <simgear/debug/logstream.hxx>
16 #include <simgear/math/sg_random.h>
17 #include <simgear/scene/material/mat.hxx>
18 #include <simgear/scene/material/matlib.hxx>
19 #include <simgear/structure/exception.hxx>
20 #include <simgear/structure/commands.hxx>
21 #include <simgear/props/props.hxx>
22 #include <simgear/props/props_io.hxx>
23 #include <simgear/structure/event_mgr.hxx>
24 #include <simgear/sound/soundmgr_openal.hxx>
25 #include <simgear/timing/sg_time.hxx>
26 #include <Network/RemoteXMLRequest.hxx>
27
28 #include <FDM/flight.hxx>
29 #include <GUI/gui.h>
30 #include <GUI/new_gui.hxx>
31 #include <GUI/dialog.hxx>
32 #include <Aircraft/replay.hxx>
33 #include <Scenery/scenery.hxx>
34 #include <Scenery/tilemgr.hxx>
35 #include <Scripting/NasalSys.hxx>
36 #include <Sound/sample_queue.hxx>
37 #include <Airports/xmlloader.hxx>
38 #include <Network/HTTPClient.hxx>
39 #include <Viewer/viewmgr.hxx>
40 #include <Viewer/viewer.hxx>
41 #include <Environment/presets.hxx>
42 #include <Navaids/NavDataCache.hxx>
43
44 #include "fg_init.hxx"
45 #include "fg_io.hxx"
46 #include "fg_os.hxx"
47 #include "fg_commands.hxx"
48 #include "fg_props.hxx"
49 #include "globals.hxx"
50 #include "logger.hxx"
51 #include "util.hxx"
52 #include "main.hxx"
53 #include "positioninit.hxx"
54
55 #include <boost/scoped_array.hpp>
56
57 #if FG_HAVE_GPERFTOOLS
58 # include <google/profiler.h>
59 #endif
60
61 using std::string;
62 using std::ifstream;
63 using std::ofstream;
64
65
66 ////////////////////////////////////////////////////////////////////////
67 // Static helper functions.
68 ////////////////////////////////////////////////////////////////////////
69
70
71 static inline SGPropertyNode *
72 get_prop (const SGPropertyNode * arg)
73 {
74     return fgGetNode(arg->getStringValue("property[0]", "/null"), true);
75 }
76
77 static inline SGPropertyNode *
78 get_prop2 (const SGPropertyNode * arg)
79 {
80     return fgGetNode(arg->getStringValue("property[1]", "/null"), true);
81 }
82
83
84 /**
85  * Get a double value and split it as required.
86  */
87 static void
88 split_value (double full_value, const char * mask,
89              double * unmodifiable, double * modifiable)
90 {
91     if (!strcmp("integer", mask)) {
92         *modifiable = (full_value < 0 ? ceil(full_value) : floor (full_value));
93         *unmodifiable = full_value - *modifiable;
94     } else if (!strcmp("decimal", mask)) {
95         *unmodifiable = (full_value < 0 ? ceil(full_value) : floor(full_value));
96         *modifiable = full_value - *unmodifiable;
97     } else {
98         if (strcmp("all", mask))
99             SG_LOG(SG_GENERAL, SG_ALERT, "Bad value " << mask << " for mask;"
100                    << " assuming 'all'");
101         *unmodifiable = 0;
102         *modifiable = full_value;
103     }
104 }
105
106
107 /**
108  * Clamp or wrap a value as specified.
109  */
110 static void
111 limit_value (double * value, const SGPropertyNode * arg)
112 {
113     const SGPropertyNode * min_node = arg->getChild("min");
114     const SGPropertyNode * max_node = arg->getChild("max");
115
116     bool wrap = arg->getBoolValue("wrap");
117
118     if (min_node == 0 || max_node == 0)
119         wrap = false;
120   
121     if (wrap) {                 // wrap such that min <= x < max
122         double min_val = min_node->getDoubleValue();
123         double max_val = max_node->getDoubleValue();
124         double resolution = arg->getDoubleValue("resolution");
125         if (resolution > 0.0) {
126             // snap to (min + N*resolution), taking special care to handle imprecision
127             int n = (int)floor((*value - min_val) / resolution + 0.5);
128             int steps = (int)floor((max_val - min_val) / resolution + 0.5);
129             SG_NORMALIZE_RANGE(n, 0, steps);
130             *value = min_val + resolution * n;
131         } else {
132             // plain circular wrapping
133             SG_NORMALIZE_RANGE(*value, min_val, max_val);
134         }
135     } else {                    // clamp such that min <= x <= max
136         if ((min_node != 0) && (*value < min_node->getDoubleValue()))
137             *value = min_node->getDoubleValue();
138         else if ((max_node != 0) && (*value > max_node->getDoubleValue()))
139             *value = max_node->getDoubleValue();
140     }
141 }
142
143 static bool
144 compare_values (SGPropertyNode * value1, SGPropertyNode * value2)
145 {
146     switch (value1->getType()) {
147     case simgear::props::BOOL:
148         return (value1->getBoolValue() == value2->getBoolValue());
149     case simgear::props::INT:
150         return (value1->getIntValue() == value2->getIntValue());
151     case simgear::props::LONG:
152         return (value1->getLongValue() == value2->getLongValue());
153     case simgear::props::FLOAT:
154         return (value1->getFloatValue() == value2->getFloatValue());
155     case simgear::props::DOUBLE:
156         return (value1->getDoubleValue() == value2->getDoubleValue());
157     default:
158         return !strcmp(value1->getStringValue(), value2->getStringValue());
159     }
160 }
161
162
163
164 ////////////////////////////////////////////////////////////////////////
165 // Command implementations.
166 ////////////////////////////////////////////////////////////////////////
167
168
169 /**
170  * Built-in command: do nothing.
171  */
172 static bool
173 do_null (const SGPropertyNode * arg)
174 {
175   return true;
176 }
177
178 /**
179  * Built-in command: run a Nasal script.
180  */
181 static bool
182 do_nasal (const SGPropertyNode * arg)
183 {
184     return ((FGNasalSys*)globals->get_subsystem("nasal"))->handleCommand(arg);
185 }
186
187 /**
188  * Built-in command: exit FlightGear.
189  *
190  * status: the exit status to return to the operating system (defaults to 0)
191  */
192 static bool
193 do_exit (const SGPropertyNode * arg)
194 {
195     SG_LOG(SG_INPUT, SG_INFO, "Program exit requested.");
196     fgSetBool("/sim/signals/exit", true);
197     globals->saveUserSettings();
198     fgOSExit(arg->getIntValue("status", 0));
199     return true;
200 }
201
202
203 /**
204  * Reset FlightGear (Shift-Escape or Menu->File->Reset)
205  */
206 static bool
207 do_reset (const SGPropertyNode * arg)
208 {
209     fgResetIdleState();
210     return true;
211 }
212
213
214 /**
215  * Change aircraft
216  */
217 static bool
218 do_switch_aircraft (const SGPropertyNode * arg)
219 {
220     fgSetString("/sim/aircraft", arg->getStringValue("aircraft"));
221     // start a reset
222     fgResetIdleState();
223     return true;
224 }
225
226 /**
227  */
228 static bool
229 do_reposition (const SGPropertyNode * arg)
230 {
231   fgStartReposition();
232   return true;
233 }
234
235 /**
236  * Built-in command: replay the FDR buffer
237  */
238 static bool
239 do_replay (const SGPropertyNode * arg)
240 {
241     FGReplay *r = (FGReplay *)(globals->get_subsystem( "replay" ));
242     return r->start();
243 }
244
245 /**
246  * Built-in command: pause/unpause the sim
247  */
248 static bool
249 do_pause (const SGPropertyNode * arg)
250 {
251     bool forcePause = arg->getBoolValue("force-pause", false );
252     bool forcePlay = arg->getBoolValue("force-play", false );
253
254     bool paused = fgGetBool("/sim/freeze/master",true) || fgGetBool("/sim/freeze/clock",true);
255
256     if(forcePause) paused = false;
257     if(forcePlay) paused = true;
258
259     if (paused && (fgGetInt("/sim/freeze/replay-state",0)>0))
260     {
261         do_replay(NULL);
262     }
263     else
264     {
265         fgSetBool("/sim/freeze/master",!paused);
266         fgSetBool("/sim/freeze/clock",!paused);
267     }
268   
269     SGPropertyNode_ptr args(new SGPropertyNode);
270     args->setStringValue("id", "sim-pause");
271     if (!paused && fgGetBool("/sim/view-name-popup")) {
272       args->setStringValue("label", "Simulation is paused");
273       globals->get_commands()->execute("show-message", args);
274     } else {
275       globals->get_commands()->execute("clear-message", args);
276     }
277   
278     return true;
279 }
280
281 /**
282  * Built-in command: load flight.
283  *
284  * file (optional): the name of the file to load (relative to current
285  *   directory).  Defaults to "fgfs.sav"
286  */
287 static bool
288 do_load (const SGPropertyNode * arg)
289 {
290     SGPath file(arg->getStringValue("file", "fgfs.sav"));
291
292     if (file.extension() != "sav")
293         file.concat(".sav");
294
295     if (fgValidatePath(file, false).empty()) {
296         SG_LOG(SG_IO, SG_ALERT, "load: reading '" << file << "' denied "
297                 "(unauthorized access)");
298         return false;
299     }
300
301     ifstream input(file.c_str());
302     if (input.good() && fgLoadFlight(input)) {
303         input.close();
304         SG_LOG(SG_INPUT, SG_INFO, "Restored flight from " << file);
305         return true;
306     } else {
307         SG_LOG(SG_INPUT, SG_WARN, "Cannot load flight from " << file);
308         return false;
309     }
310 }
311
312
313 /**
314  * Built-in command: save flight.
315  *
316  * file (optional): the name of the file to save (relative to the
317  * current directory).  Defaults to "fgfs.sav".
318  */
319 static bool
320 do_save (const SGPropertyNode * arg)
321 {
322     SGPath file(arg->getStringValue("file", "fgfs.sav"));
323
324     if (file.extension() != "sav")
325         file.concat(".sav");
326
327     if (fgValidatePath(file, false).empty()) {
328         SG_LOG(SG_IO, SG_ALERT, "save: writing '" << file << "' denied "
329                 "(unauthorized access)");
330         return false;
331     }
332
333     bool write_all = arg->getBoolValue("write-all", false);
334     SG_LOG(SG_INPUT, SG_INFO, "Saving flight");
335     ofstream output(file.c_str());
336     if (output.good() && fgSaveFlight(output, write_all)) {
337         output.close();
338         SG_LOG(SG_INPUT, SG_INFO, "Saved flight to " << file);
339         return true;
340     } else {
341         SG_LOG(SG_INPUT, SG_ALERT, "Cannot save flight to " << file);
342         return false;
343     }
344 }
345
346 /**
347  * Built-in command: save flight recorder tape.
348  *
349  */
350 static bool
351 do_save_tape (const SGPropertyNode * arg)
352 {
353     FGReplay* replay = (FGReplay*) globals->get_subsystem("replay");
354     replay->saveTape(arg);
355
356     return true;
357 }
358 /**
359  * Built-in command: load flight recorder tape.
360  *
361  */
362 static bool
363 do_load_tape (const SGPropertyNode * arg)
364 {
365     FGReplay* replay = (FGReplay*) globals->get_subsystem("replay");
366     replay->loadTape(arg);
367
368     return true;
369 }
370
371 /**
372  * Built-in command: (re)load the panel.
373  *
374  * path (optional): the file name to load the panel from 
375  * (relative to FG_ROOT).  Defaults to the value of /sim/panel/path,
376  * and if that's unspecified, to "Panels/Default/default.xml".
377  */
378 static bool
379 do_panel_load (const SGPropertyNode * arg)
380 {
381   string panel_path = arg->getStringValue("path");
382   if (!panel_path.empty()) {
383     // write to the standard property, which will force a load
384     fgSetString("/sim/panel/path", panel_path.c_str());
385   }
386   
387   return true;
388 }
389
390 /**
391  * Built-in command: (re)load preferences.
392  *
393  * path (optional): the file name to load the panel from (relative
394  * to FG_ROOT). Defaults to "preferences.xml".
395  */
396 static bool
397 do_preferences_load (const SGPropertyNode * arg)
398 {
399   try {
400     fgLoadProps(arg->getStringValue("path", "preferences.xml"),
401                 globals->get_props());
402   } catch (const sg_exception &e) {
403     guiErrorMessage("Error reading global preferences: ", e);
404     return false;
405   }
406   SG_LOG(SG_INPUT, SG_INFO, "Successfully read global preferences.");
407   return true;
408 }
409
410 static void
411 do_view_next(bool do_it)
412 {
413   // Only switch view if really requested to do so (and not for example while
414   // reset/reposition where /command/view/next is set to false)
415   if( do_it )
416   {
417     globals->get_current_view()->setHeadingOffset_deg(0.0);
418     globals->get_viewmgr()->next_view();
419   }
420 }
421
422 static void
423 do_view_prev(bool do_it)
424 {
425   if( do_it )
426   {
427     globals->get_current_view()->setHeadingOffset_deg(0.0);
428     globals->get_viewmgr()->prev_view();
429   }
430 }
431
432 /**
433  * An fgcommand to toggle fullscreen mode.
434  * No parameters.
435  */
436 static bool
437 do_toggle_fullscreen(const SGPropertyNode *arg)
438 {
439     fgOSFullScreen();
440     return true;
441 }
442
443 /**
444  * Built-in command: cycle view.
445  */
446 static bool
447 do_view_cycle (const SGPropertyNode * arg)
448 {
449   globals->get_current_view()->setHeadingOffset_deg(0.0);
450   globals->get_viewmgr()->next_view();
451   return true;
452 }
453
454 /**
455  * Built-in command: capture screen.
456  */
457 static bool
458 do_screen_capture (const SGPropertyNode * arg)
459 {
460   return fgDumpSnapShot();
461 }
462
463 static bool
464 do_reload_shaders (const SGPropertyNode*)
465 {
466     simgear::reload_shaders();
467     return true;
468 }
469
470 static bool
471 do_dump_scene_graph (const SGPropertyNode*)
472 {
473     fgDumpSceneGraph();
474     return true;
475 }
476
477 static bool
478 do_dump_terrain_branch (const SGPropertyNode*)
479 {
480     fgDumpTerrainBranch();
481
482     double lon_deg = fgGetDouble("/position/longitude-deg");
483     double lat_deg = fgGetDouble("/position/latitude-deg");
484     SGGeod geodPos = SGGeod::fromDegFt(lon_deg, lat_deg, 0.0);
485     SGVec3d zero = SGVec3d::fromGeod(geodPos);
486
487     SG_LOG(SG_INPUT, SG_INFO, "Model parameters:");
488     SG_LOG(SG_INPUT, SG_INFO, "Center: " << zero.x() << ", " << zero.y() << ", " << zero.z() );
489     SG_LOG(SG_INPUT, SG_INFO, "Rotation: " << lat_deg << ", " << lon_deg );
490
491     return true;
492 }
493
494 static bool
495 do_print_visible_scene_info(const SGPropertyNode*)
496 {
497     fgPrintVisibleSceneInfoCommand();
498     return true;
499 }
500
501 /**
502  * Built-in command: hires capture screen.
503  */
504 static bool
505 do_hires_screen_capture (const SGPropertyNode * arg)
506 {
507   fgHiResDump();
508   return true;
509 }
510
511
512 /**
513  * Reload the tile cache.
514  */
515 static bool
516 do_tile_cache_reload (const SGPropertyNode * arg)
517 {
518     SGPropertyNode *master_freeze = fgGetNode("/sim/freeze/master");
519     bool freeze = master_freeze->getBoolValue();
520     SG_LOG(SG_INPUT, SG_INFO, "ReIniting TileCache");
521     if ( !freeze ) {
522         master_freeze->setBoolValue(true);
523     }
524
525     globals->get_subsystem("tile-manager")->reinit();
526
527     if ( !freeze ) {
528         master_freeze->setBoolValue(false);
529     }
530     return true;
531 }
532
533 /**
534  * Reload the materials definition
535  */
536 static bool
537 do_materials_reload (const SGPropertyNode * arg)
538 {
539     SG_LOG(SG_INPUT, SG_INFO, "Reloading Materials");
540     SGMaterialLib* new_matlib =  new SGMaterialLib;
541     SGPath mpath( globals->get_fg_root() );
542     mpath.append( fgGetString("/sim/rendering/materials-file") );
543     bool loaded = new_matlib->load(globals->get_fg_root(), 
544                                   mpath.str(), 
545                                   globals->get_props());
546
547     if ( ! loaded ) {
548        SG_LOG( SG_GENERAL, SG_ALERT,
549                "Error loading materials file " << mpath.str() );
550        return false;
551     }  
552
553     globals->set_matlib(new_matlib);    
554     FGTileMgr* tileManager = static_cast<FGTileMgr*>(globals->get_subsystem("tile-manager"));
555     tileManager->materialLibChanged();
556     
557     return true;
558 }
559
560 /**
561  * Built-in command: toggle a bool property value.
562  *
563  * property: The name of the property to toggle.
564  */
565 static bool
566 do_property_toggle (const SGPropertyNode * arg)
567 {
568   SGPropertyNode * prop = get_prop(arg);
569   return prop->setBoolValue(!prop->getBoolValue());
570 }
571
572
573 /**
574  * Built-in command: assign a value to a property.
575  *
576  * property: the name of the property to assign.
577  * value: the value to assign; or
578  * property[1]: the property to copy from.
579  */
580 static bool
581 do_property_assign (const SGPropertyNode * arg)
582 {
583   SGPropertyNode * prop = get_prop(arg);
584   const SGPropertyNode * value = arg->getNode("value");
585
586   if (value != 0)
587       return prop->setUnspecifiedValue(value->getStringValue());
588   else
589   {
590       const SGPropertyNode * prop2 = get_prop2(arg);
591       if (prop2)
592           return prop->setUnspecifiedValue(prop2->getStringValue());
593       else
594           return false;
595   }
596 }
597
598
599 /**
600  * Built-in command: increment or decrement a property value.
601  *
602  * If the 'step' argument is present, it will be used; otherwise,
603  * the command uses 'offset' and 'factor', usually from the mouse.
604  *
605  * property: the name of the property to increment or decrement.
606  * step: the amount of the increment or decrement (default: 0).
607  * offset: offset from the current setting (used for the mouse; multiplied 
608  *         by factor)
609  * factor: scaling amount for the offset (defaults to 1).
610  * min: the minimum allowed value (default: no minimum).
611  * max: the maximum allowed value (default: no maximum).
612  * mask: 'integer' to apply only to the left of the decimal point, 
613  *       'decimal' to apply only to the right of the decimal point,
614  *       or 'all' to apply to the whole number (the default).
615  * wrap: true if the value should be wrapped when it passes min or max;
616  *       both min and max must be present for this to work (default:
617  *       false).
618  */
619 static bool
620 do_property_adjust (const SGPropertyNode * arg)
621 {
622   SGPropertyNode * prop = get_prop(arg);
623
624   double amount = 0;
625   if (arg->hasValue("step"))
626       amount = arg->getDoubleValue("step");
627   else
628       amount = (arg->getDoubleValue("factor", 1)
629                 * arg->getDoubleValue("offset"));
630           
631   double unmodifiable, modifiable;
632   split_value(prop->getDoubleValue(), arg->getStringValue("mask", "all"),
633               &unmodifiable, &modifiable);
634   modifiable += amount;
635   limit_value(&modifiable, arg);
636
637   prop->setDoubleValue(unmodifiable + modifiable);
638
639   return true;
640 }
641
642
643 /**
644  * Built-in command: multiply a property value.
645  *
646  * property: the name of the property to multiply.
647  * factor: the amount by which to multiply.
648  * min: the minimum allowed value (default: no minimum).
649  * max: the maximum allowed value (default: no maximum).
650  * mask: 'integer' to apply only to the left of the decimal point, 
651  *       'decimal' to apply only to the right of the decimal point,
652  *       or 'all' to apply to the whole number (the default).
653  * wrap: true if the value should be wrapped when it passes min or max;
654  *       both min and max must be present for this to work (default:
655  *       false).
656  */
657 static bool
658 do_property_multiply (const SGPropertyNode * arg)
659 {
660   SGPropertyNode * prop = get_prop(arg);
661   double factor = arg->getDoubleValue("factor", 1);
662
663   double unmodifiable, modifiable;
664   split_value(prop->getDoubleValue(), arg->getStringValue("mask", "all"),
665               &unmodifiable, &modifiable);
666   modifiable *= factor;
667   limit_value(&modifiable, arg);
668
669   prop->setDoubleValue(unmodifiable + modifiable);
670
671   return true;
672 }
673
674
675 /**
676  * Built-in command: swap two property values.
677  *
678  * property[0]: the name of the first property.
679  * property[1]: the name of the second property.
680  */
681 static bool
682 do_property_swap (const SGPropertyNode * arg)
683 {
684   SGPropertyNode * prop1 = get_prop(arg);
685   SGPropertyNode * prop2 = get_prop2(arg);
686
687                                 // FIXME: inefficient
688   const string & tmp = prop1->getStringValue();
689   return (prop1->setUnspecifiedValue(prop2->getStringValue()) &&
690           prop2->setUnspecifiedValue(tmp.c_str()));
691 }
692
693
694 /**
695  * Built-in command: Set a property to an axis or other moving input.
696  *
697  * property: the name of the property to set.
698  * setting: the current input setting, usually between -1.0 and 1.0.
699  * offset: the offset to shift by, before applying the factor.
700  * factor: the factor to multiply by (use negative to reverse).
701  */
702 static bool
703 do_property_scale (const SGPropertyNode * arg)
704 {
705   SGPropertyNode * prop = get_prop(arg);
706   double setting = arg->getDoubleValue("setting");
707   double offset = arg->getDoubleValue("offset", 0.0);
708   double factor = arg->getDoubleValue("factor", 1.0);
709   bool squared = arg->getBoolValue("squared", false);
710   int power = arg->getIntValue("power", (squared ? 2 : 1));
711
712   int sign = (setting < 0 ? -1 : 1);
713
714   switch (power) {
715   case 1:
716       break;
717   case 2:
718       setting = setting * setting * sign;
719       break;
720   case 3:
721       setting = setting * setting * setting;
722       break;
723   case 4:
724       setting = setting * setting * setting * setting * sign;
725       break;
726   default:
727       setting =  pow(setting, power);
728       if ((power % 2) == 0)
729           setting *= sign;
730       break;
731   }
732
733   return prop->setDoubleValue((setting + offset) * factor);
734 }
735
736
737 /**
738  * Built-in command: cycle a property through a set of values.
739  *
740  * If the current value isn't in the list, the cycle will
741  * (re)start from the beginning.
742  *
743  * property: the name of the property to cycle.
744  * value[*]: the list of values to cycle through.
745  */
746 static bool
747 do_property_cycle (const SGPropertyNode * arg)
748 {
749     SGPropertyNode * prop = get_prop(arg);
750     std::vector<SGPropertyNode_ptr> values = arg->getChildren("value");
751     
752     bool wrap = arg->getBoolValue("wrap", true);
753     // compatible with knob/pick animations
754     int offset = arg->getIntValue("offset", 1);
755     
756     int selection = -1;
757     int nSelections = values.size();
758
759     if (nSelections < 1) {
760         SG_LOG(SG_GENERAL, SG_ALERT, "No values for property-cycle");
761         return false;
762     }
763
764                                 // Try to find the current selection
765     for (int i = 0; i < nSelections; i++) {
766         if (compare_values(prop, values[i])) {
767             selection = i;
768             break;
769         }
770     }
771
772     if (selection < 0) { // default to first selection
773         selection = 0;
774     } else {
775         selection += offset;
776         if (wrap) {
777             selection = (selection + nSelections) % nSelections;
778         } else {
779             SG_CLAMP_RANGE(selection, 0, nSelections - 1);
780         }
781     }
782     
783     prop->setUnspecifiedValue(values[selection]->getStringValue());
784     return true;
785 }
786
787
788 /**
789  * Built-in command: randomize a numeric property value.
790  *
791  * property: the name of the property value to randomize.
792  * min: the minimum allowed value.
793  * max: the maximum allowed value.
794  */
795 static bool
796 do_property_randomize (const SGPropertyNode * arg)
797 {
798     SGPropertyNode * prop = get_prop(arg);
799     double min = arg->getDoubleValue("min", DBL_MIN);
800     double max = arg->getDoubleValue("max", DBL_MAX);
801     prop->setDoubleValue(sg_random() * (max - min) + min);
802     return true;
803 }
804
805 /**
806  * Built-in command: interpolate a property value over time
807  *
808  * property:        the name of the property value to interpolate.
809  * type:            the interpolation type ("numeric", "color", etc.)
810  * easing:          name of easing function (see http://easings.net/)
811  * value[0..n]      any number of constant values to interpolate
812  * time/rate[0..n]  time between each value, number of time elements must
813  *                  match those of value elements. Instead of time also rate can
814  *                  be used which automatically calculates the time to change
815  *                  the property value at the given speed.
816  * -or-
817  * property[1..n+1] any number of target values taken from named properties
818  * time/rate[0..n]  time between each value, number of time elements must
819  *                  match those of value elements. Instead of time also rate can
820  *                  be used which automatically calculates the time to change
821  *                  the property value at the given speed.
822  */
823 static bool
824 do_property_interpolate (const SGPropertyNode * arg)
825 {
826   SGPropertyNode * prop = get_prop(arg);
827   if( !prop )
828     return false;
829
830   simgear::PropertyList time_nodes = arg->getChildren("time");
831   simgear::PropertyList rate_nodes = arg->getChildren("rate");
832
833   if( !time_nodes.empty() && !rate_nodes.empty() )
834     // mustn't specify time and rate
835     return false;
836
837   simgear::PropertyList::size_type num_times = time_nodes.empty()
838                                              ? rate_nodes.size()
839                                              : time_nodes.size();
840
841   simgear::PropertyList value_nodes = arg->getChildren("value");
842   if( value_nodes.empty() )
843   {
844     simgear::PropertyList prop_nodes = arg->getChildren("property");
845
846     // must have one more property node
847     if( prop_nodes.size() != num_times + 1 )
848       return false;
849
850     value_nodes.reserve(num_times);
851     for( size_t i = 1; i < prop_nodes.size(); ++i )
852       value_nodes.push_back( fgGetNode(prop_nodes[i]->getStringValue()) );
853   }
854
855   // must match
856   if( value_nodes.size() != num_times )
857     return false;
858
859   double_list deltas;
860   deltas.reserve(num_times);
861
862   if( !time_nodes.empty() )
863   {
864     for( size_t i = 0; i < num_times; ++i )
865       deltas.push_back( time_nodes[i]->getDoubleValue() );
866   }
867   else
868   {
869     for( size_t i = 0; i < num_times; ++i )
870     {
871       // TODO calculate delta based on property type
872       double delta = value_nodes[i]->getDoubleValue()
873                    - ( i > 0
874                      ? value_nodes[i - 1]->getDoubleValue()
875                      : prop->getDoubleValue()
876                      );
877       deltas.push_back( fabs(delta / rate_nodes[i]->getDoubleValue()) );
878     }
879   }
880
881   return prop->interpolate
882   (
883     arg->getStringValue("type", "numeric"),
884     value_nodes,
885     deltas,
886     arg->getStringValue("easing", "linear")
887   );
888 }
889
890 /**
891  * Built-in command: reinit the data logging system based on the
892  * current contents of the /logger tree.
893  */
894 static bool
895 do_data_logging_commit (const SGPropertyNode * arg)
896 {
897     FGLogger *log = (FGLogger *)globals->get_subsystem("logger");
898     log->reinit();
899     return true;
900 }
901
902 /**
903  * Built-in command: Add a dialog to the GUI system.  Does *not*
904  * display the dialog.  The property node should have the same format
905  * as a dialog XML configuration.  It must include:
906  *
907  * name: the name of the GUI dialog for future reference.
908  */
909 static bool
910 do_dialog_new (const SGPropertyNode * arg)
911 {
912     NewGUI * gui = (NewGUI *)globals->get_subsystem("gui");
913     if (!gui) {
914       return false;
915     }
916   
917     // Note the casting away of const: this is *real*.  Doing a
918     // "dialog-apply" command later on will mutate this property node.
919     // I'm not convinced that this isn't the Right Thing though; it
920     // allows client to create a node, pass it to dialog-new, and get
921     // the values back from the dialog by reading the same node.
922     // Perhaps command arguments are not as "const" as they would
923     // seem?
924     gui->newDialog((SGPropertyNode*)arg);
925     return true;
926 }
927
928 /**
929  * Built-in command: Show an XML-configured dialog.
930  *
931  * dialog-name: the name of the GUI dialog to display.
932  */
933 static bool
934 do_dialog_show (const SGPropertyNode * arg)
935 {
936     NewGUI * gui = (NewGUI *)globals->get_subsystem("gui");
937     gui->showDialog(arg->getStringValue("dialog-name"));
938     return true;
939 }
940
941
942 /**
943  * Built-in Command: Hide the active XML-configured dialog.
944  */
945 static bool
946 do_dialog_close (const SGPropertyNode * arg)
947 {
948     NewGUI * gui = (NewGUI *)globals->get_subsystem("gui");
949     if(arg->hasValue("dialog-name"))
950         return gui->closeDialog(arg->getStringValue("dialog-name"));
951     return gui->closeActiveDialog();
952 }
953
954
955 /**
956  * Update a value in the active XML-configured dialog.
957  *
958  * object-name: The name of the GUI object(s) (all GUI objects if omitted).
959  */
960 static bool
961 do_dialog_update (const SGPropertyNode * arg)
962 {
963     NewGUI * gui = (NewGUI *)globals->get_subsystem("gui");
964     FGDialog * dialog;
965     if (arg->hasValue("dialog-name"))
966         dialog = gui->getDialog(arg->getStringValue("dialog-name"));
967     else
968         dialog = gui->getActiveDialog();
969
970     if (dialog != 0) {
971         dialog->updateValues(arg->getStringValue("object-name"));
972         return true;
973     } else {
974         return false;
975     }
976 }
977
978 static bool
979 do_open_browser (const SGPropertyNode * arg)
980 {
981     string path;
982     if (arg->hasValue("path"))
983         path = arg->getStringValue("path");
984     else
985     if (arg->hasValue("url"))
986         path = arg->getStringValue("url");
987     else
988         return false;
989
990     return openBrowser(path);
991 }
992
993 /**
994  * Apply a value in the active XML-configured dialog.
995  *
996  * object-name: The name of the GUI object(s) (all GUI objects if omitted).
997  */
998 static bool
999 do_dialog_apply (const SGPropertyNode * arg)
1000 {
1001     NewGUI * gui = (NewGUI *)globals->get_subsystem("gui");
1002     FGDialog * dialog;
1003     if (arg->hasValue("dialog-name"))
1004         dialog = gui->getDialog(arg->getStringValue("dialog-name"));
1005     else
1006         dialog = gui->getActiveDialog();
1007
1008     if (dialog != 0) {
1009         dialog->applyValues(arg->getStringValue("object-name"));
1010         return true;
1011     } else {
1012         return false;
1013     }
1014 }
1015
1016
1017 /**
1018  * Redraw GUI (applying new widget colors). Doesn't reload the dialogs,
1019  * unlike reinit().
1020  */
1021 static bool
1022 do_gui_redraw (const SGPropertyNode * arg)
1023 {
1024     NewGUI * gui = (NewGUI *)globals->get_subsystem("gui");
1025     gui->redraw();
1026     return true;
1027 }
1028
1029
1030 /**
1031  * Adds model to the scenery. The path to the added branch (/models/model[*])
1032  * is returned in property "property".
1033  */
1034 static bool
1035 do_add_model (const SGPropertyNode * arg)
1036 {
1037     SGPropertyNode * model = fgGetNode("models", true);
1038     int i;
1039     for (i = 0; model->hasChild("model",i); i++);
1040     model = model->getChild("model", i, true);
1041     copyProperties(arg, model);
1042     if (model->hasValue("elevation-m"))
1043         model->setDoubleValue("elevation-ft", model->getDoubleValue("elevation-m")
1044                 * SG_METER_TO_FEET);
1045     model->getNode("load", true);
1046     model->removeChildren("load");
1047     const_cast<SGPropertyNode *>(arg)->setStringValue("property", model->getPath());
1048     return true;
1049 }
1050
1051 /**
1052  * Built-in command: play an audio message (i.e. a wav file) This is
1053  * fire and forget.  Call this once per message and it will get dumped
1054  * into a queue.  Messages are played sequentially so they do not
1055  * overlap.
1056  */
1057 static bool
1058 do_play_audio_sample (const SGPropertyNode * arg)
1059 {
1060     SGSoundMgr *smgr = globals->get_soundmgr();
1061     if (!smgr) {
1062         SG_LOG(SG_GENERAL, SG_WARN, "play-audio-sample: sound-manager not running");
1063         return false;
1064     }
1065   
1066     string path = arg->getStringValue("path");
1067     string file = arg->getStringValue("file");
1068     float volume = arg->getFloatValue("volume");
1069     // cout << "playing " << path << " / " << file << endl;
1070     try {
1071         FGSampleQueue *queue = globals->get_chatter_queue();
1072         if ( !queue ) {
1073             queue = new FGSampleQueue(smgr, "chatter");
1074             queue->tie_to_listener();
1075             globals->set_chatter_queue(queue);
1076         }
1077
1078         SGSoundSample *msg = new SGSoundSample(file.c_str(), path);
1079         msg->set_volume( volume );
1080         queue->add( msg );
1081
1082         return true;
1083
1084     } catch (const sg_io_exception&) {
1085         SG_LOG(SG_GENERAL, SG_ALERT, "play-audio-sample: "
1086                 "failed to load" << path << '/' << file);
1087         return false;
1088     }
1089 }
1090
1091 /**
1092  * Built-in command: commit presets (read from in /sim/presets/)
1093  */
1094 static bool
1095 do_presets_commit (const SGPropertyNode * arg)
1096 {
1097     if (fgGetBool("/sim/initialized", false)) {
1098       fgResetIdleState();
1099     } else {
1100       // Nasal can trigger this during initial init, which confuses
1101       // the logic in ReInitSubsystems, since initial state has not been
1102       // saved at that time. Short-circuit everything here.
1103       flightgear::initPosition();
1104     }
1105     
1106     return true;
1107 }
1108
1109 /**
1110  * Built-in command: set log level (0 ... 7)
1111  */
1112 static bool
1113 do_log_level (const SGPropertyNode * arg)
1114 {
1115    sglog().setLogLevels( SG_ALL, (sgDebugPriority)arg->getIntValue() );
1116
1117    return true;
1118 }
1119
1120 /*
1121 static bool
1122 do_decrease_visibility (const SGPropertyNode * arg)
1123 {
1124     Environment::Presets::VisibilitySingleton::instance()->adjust( 0.9 );
1125     return true;
1126 }
1127  
1128 static bool
1129 do_increase_visibility (const SGPropertyNode * arg)
1130 {
1131     Environment::Presets::VisibilitySingleton::instance()->adjust( 1.1 );
1132     return true;
1133 }
1134 */
1135 /**
1136  * An fgcommand to allow loading of xml files via nasal,
1137  * the xml file's structure will be made available within
1138  * a property tree node defined under argument "targetnode",
1139  * or in the given argument tree under "data" otherwise.
1140  *
1141  * @param filename a string to hold the complete path & filename of an XML file
1142  * @param targetnode a string pointing to a location within the property tree
1143  * where to store the parsed XML file. If <targetnode> is undefined, then the
1144  * file contents are stored under a node <data> in the argument tree.
1145  */
1146
1147 static bool
1148 do_load_xml_to_proptree(const SGPropertyNode * arg)
1149 {
1150     SGPath file(arg->getStringValue("filename"));
1151     if (file.str().empty())
1152         return false;
1153
1154     if (file.extension() != "xml")
1155         file.concat(".xml");
1156     
1157     std::string icao = arg->getStringValue("icao");
1158     if (icao.empty()) {
1159         if (file.isRelative()) {
1160           SGPath absPath = globals->resolve_maybe_aircraft_path(file.str());
1161           if (!absPath.isNull())
1162               file = absPath;
1163           else
1164           {
1165               SG_LOG(SG_IO, SG_ALERT, "loadxml: Cannot find XML property file '"  
1166                           << file.str() << "'.");
1167               return false;
1168           }
1169         }
1170     } else {
1171         if (!XMLLoader::findAirportData(icao, file.str(), file)) {
1172           SG_LOG(SG_IO, SG_INFO, "loadxml: failed to find airport data for "
1173             << file.str() << " at ICAO:" << icao);
1174           return false;
1175         }
1176     }
1177     
1178     if (fgValidatePath(file, false).empty()) {
1179         SG_LOG(SG_IO, SG_ALERT, "loadxml: reading '" << file.str() << "' denied "
1180                 "(unauthorized directory - authorization no longer follows symlinks; to authorize reading additional directories, add them to --fg-aircraft)");
1181         return false;
1182     }
1183
1184     SGPropertyNode *targetnode;
1185     if (arg->hasValue("targetnode"))
1186         targetnode = fgGetNode(arg->getStringValue("targetnode"), true);
1187     else
1188         targetnode = const_cast<SGPropertyNode *>(arg)->getNode("data", true);
1189
1190     try {
1191         readProperties(file.c_str(), targetnode, true);
1192     } catch (const sg_exception &e) {
1193         SG_LOG(SG_IO, SG_WARN, "loadxml: " << e.getFormattedMessage());
1194         return false;
1195     }
1196
1197     return true;
1198 }
1199
1200 static bool
1201 do_load_xml_from_url(const SGPropertyNode * arg)
1202 {
1203     FGHTTPClient* http = static_cast<FGHTTPClient*>(globals->get_subsystem("http"));
1204     if (!http) {
1205         SG_LOG(SG_IO, SG_ALERT, "xmlhttprequest: HTTP client not running");
1206         return false;
1207     }
1208   
1209     std::string url(arg->getStringValue("url"));
1210     if (url.empty())
1211         return false;
1212         
1213     SGPropertyNode *targetnode;
1214     if (arg->hasValue("targetnode"))
1215         targetnode = fgGetNode(arg->getStringValue("targetnode"), true);
1216     else
1217         targetnode = const_cast<SGPropertyNode *>(arg)->getNode("data", true);
1218     
1219     RemoteXMLRequest* req = new RemoteXMLRequest(url, targetnode);
1220     
1221     if (arg->hasChild("body"))
1222         req->setBodyData(arg->getChild("body"));
1223     
1224 // connect up optional reporting properties
1225     if (arg->hasValue("complete")) 
1226         req->setCompletionProp(fgGetNode(arg->getStringValue("complete"), true));
1227     if (arg->hasValue("failure")) 
1228         req->setFailedProp(fgGetNode(arg->getStringValue("failure"), true));
1229     if (arg->hasValue("status")) 
1230         req->setStatusProp(fgGetNode(arg->getStringValue("status"), true));
1231         
1232     http->makeRequest(req);
1233     return true;
1234 }
1235
1236
1237 /**
1238  * An fgcommand to allow saving of xml files via nasal,
1239  * the file's structure will be determined based on what's
1240  * encountered in the passed (source) property tree node
1241  *
1242  * @param filename a string to hold the complete path & filename of the (new)
1243  * XML file
1244  * @param sourcenode a string pointing to a location within the property tree
1245  * where to find the nodes that should be written recursively into an XML file
1246  * @param data if no sourcenode is given, then the file contents are taken from
1247  * the argument tree's "data" node.
1248  */
1249
1250 static bool
1251 do_save_xml_from_proptree(const SGPropertyNode * arg)
1252 {
1253     SGPath file(arg->getStringValue("filename"));
1254     if (file.str().empty())
1255         return false;
1256
1257     if (file.extension() != "xml")
1258         file.concat(".xml");
1259
1260     if (fgValidatePath(file, true).empty()) {
1261         SG_LOG(SG_IO, SG_ALERT, "savexml: writing to '" << file.str() << "' denied "
1262                 "(unauthorized directory - authorization no longer follows symlinks)");
1263         return false;
1264     }
1265
1266     SGPropertyNode *sourcenode;
1267     if (arg->hasValue("sourcenode"))
1268         sourcenode = fgGetNode(arg->getStringValue("sourcenode"), true);
1269     else if (arg->getNode("data", false))
1270         sourcenode = const_cast<SGPropertyNode *>(arg)->getNode("data");
1271     else
1272         return false;
1273
1274     try {
1275         writeProperties (file.c_str(), sourcenode, true);
1276     } catch (const sg_exception &e) {
1277         SG_LOG(SG_IO, SG_WARN, "savexml: " << e.getFormattedMessage());
1278         return false;
1279     }
1280
1281     return true;
1282 }
1283
1284 static bool
1285 do_press_cockpit_button (const SGPropertyNode *arg)
1286 {
1287   const char *prefix = arg->getStringValue("prefix");
1288
1289   if (arg->getBoolValue("guarded") && fgGetDouble((string(prefix) + "-guard").c_str()) < 1)
1290     return true;
1291
1292   string prop = string(prefix) + "-button";
1293   double value;
1294
1295   if (arg->getBoolValue("latching"))
1296     value = fgGetDouble(prop.c_str()) > 0 ? 0 : 1;
1297   else
1298     value = 1;
1299
1300   fgSetDouble(prop.c_str(), value);
1301   fgSetBool(arg->getStringValue("discrete"), value > 0);
1302
1303   return true;
1304 }
1305
1306 static bool
1307 do_release_cockpit_button (const SGPropertyNode *arg)
1308 {
1309   const char *prefix = arg->getStringValue("prefix");
1310
1311   if (arg->getBoolValue("guarded")) {
1312     string prop = string(prefix) + "-guard";
1313     if (fgGetDouble(prop.c_str()) < 1) {
1314       fgSetDouble(prop.c_str(), 1);
1315       return true;
1316     }
1317   }
1318
1319   if (! arg->getBoolValue("latching")) {
1320     fgSetDouble((string(prefix) + "-button").c_str(), 0);
1321     fgSetBool(arg->getStringValue("discrete"), false);
1322   }
1323
1324   return true;
1325 }
1326
1327 // Optional profiling commands using gperftools:
1328 // http://code.google.com/p/gperftools/
1329
1330 #if !FG_HAVE_GPERFTOOLS
1331 static void
1332 no_profiling_support()
1333 {
1334   SG_LOG
1335   (
1336     SG_GENERAL,
1337     SG_WARN,
1338     "No profiling support! Install gperftools and reconfigure/rebuild fgfs."
1339   );
1340 }
1341 #endif
1342
1343 static bool
1344 do_profiler_start(const SGPropertyNode *arg)
1345 {
1346 #if FG_HAVE_GPERFTOOLS
1347   const char *filename = arg->getStringValue("filename", "fgfs.profile");
1348   ProfilerStart(filename);
1349   return true;
1350 #else
1351   no_profiling_support();
1352   return false;
1353 #endif
1354 }
1355
1356 static bool
1357 do_profiler_stop(const SGPropertyNode *arg)
1358 {
1359 #if FG_HAVE_GPERFTOOLS
1360   ProfilerStop();
1361   return true;
1362 #else
1363   no_profiling_support();
1364   return false;
1365 #endif
1366 }
1367
1368
1369 static bool
1370 do_set_scenery_paths(const SGPropertyNode* arg)
1371 {
1372   SGPropertyNode* sim = fgGetNode("/sim", true);
1373   sim->removeChildren("fg-scenery");
1374   
1375   globals->clear_fg_scenery();
1376   
1377   std::string terrasyncPath(fgGetString("/sim/terrasync/scenery-dir"));
1378   bool seenTerrasyncPath = false;
1379   
1380   simgear::PropertyList paths = arg->getChildren("path");
1381   for (size_t i = 0; i < paths.size(); ++i) {
1382     std::string s = paths[i]->getStringValue();
1383     if (s == terrasyncPath) {
1384       seenTerrasyncPath = true;
1385     }
1386     
1387     globals->append_fg_scenery(s);
1388   }
1389   
1390   if (fgGetBool("/sim/terrasync/enabled") && !seenTerrasyncPath) {
1391     globals->append_fg_scenery(terrasyncPath);
1392   }
1393   
1394   if (paths.empty()) {
1395     // no scenery paths set *at all*, use the data in FG_ROOT
1396     SGPath root(globals->get_fg_root());
1397     root.append("Scenery");
1398     globals->append_fg_scenery(root.str());
1399   }
1400
1401     // might need to drop ground-nets from the DB. Also need to drop
1402     // them from memory, but this is tricky since FGAirportDynamics holds
1403     // an instance directly, and AI code may have pointers to ground-net
1404     // nodes. For now we'll leave-in memory versions untouched.
1405     flightgear::NavDataCache::instance()->dropGroundnetsIfRequired();
1406   
1407   return true;
1408 }
1409
1410 ////////////////////////////////////////////////////////////////////////
1411 // Command setup.
1412 ////////////////////////////////////////////////////////////////////////
1413
1414
1415 /**
1416  * Table of built-in commands.
1417  *
1418  * New commands do not have to be added here; any module in the application
1419  * can add a new command using globals->get_commands()->addCommand(...).
1420  */
1421 static struct {
1422   const char * name;
1423   SGCommandMgr::command_t command;
1424 } built_ins [] = {
1425     { "null", do_null },
1426     { "nasal", do_nasal },
1427     { "exit", do_exit },
1428     { "reset", do_reset },
1429     { "reposition", do_reposition },
1430     { "switch-aircraft", do_switch_aircraft },
1431     { "pause", do_pause },
1432     { "load", do_load },
1433     { "save", do_save },
1434     { "save-tape", do_save_tape },
1435     { "load-tape", do_load_tape },
1436     { "panel-load", do_panel_load },
1437     { "preferences-load", do_preferences_load },
1438     { "toggle-fullscreen", do_toggle_fullscreen },
1439     { "view-cycle", do_view_cycle },
1440     { "screen-capture", do_screen_capture },
1441     { "hires-screen-capture", do_hires_screen_capture },
1442     { "tile-cache-reload", do_tile_cache_reload },
1443     /*
1444     { "set-sea-level-air-temp-degc", do_set_sea_level_degc },
1445     { "set-outside-air-temp-degc", do_set_oat_degc },
1446     { "set-dewpoint-sea-level-air-temp-degc", do_set_dewpoint_sea_level_degc },
1447     { "set-dewpoint-temp-degc", do_set_dewpoint_degc },
1448     */
1449     { "property-toggle", do_property_toggle },
1450     { "property-assign", do_property_assign },
1451     { "property-adjust", do_property_adjust },
1452     { "property-multiply", do_property_multiply },
1453     { "property-swap", do_property_swap },
1454     { "property-scale", do_property_scale },
1455     { "property-cycle", do_property_cycle },
1456     { "property-randomize", do_property_randomize },
1457     { "property-interpolate", do_property_interpolate },
1458     { "data-logging-commit", do_data_logging_commit },
1459     { "dialog-new", do_dialog_new },
1460     { "dialog-show", do_dialog_show },
1461     { "dialog-close", do_dialog_close },
1462     { "dialog-update", do_dialog_update },
1463     { "dialog-apply", do_dialog_apply },
1464     { "open-browser", do_open_browser },
1465     { "gui-redraw", do_gui_redraw },
1466     { "add-model", do_add_model },
1467     { "play-audio-sample", do_play_audio_sample },
1468     { "presets-commit", do_presets_commit },
1469     { "log-level", do_log_level },
1470     { "replay", do_replay },
1471     /*
1472     { "decrease-visibility", do_decrease_visibility },
1473     { "increase-visibility", do_increase_visibility },
1474     */
1475     { "loadxml", do_load_xml_to_proptree},
1476     { "savexml", do_save_xml_from_proptree },
1477     { "xmlhttprequest", do_load_xml_from_url },
1478     { "press-cockpit-button", do_press_cockpit_button },
1479     { "release-cockpit-button", do_release_cockpit_button },
1480     { "dump-scenegraph", do_dump_scene_graph },
1481     { "dump-terrainbranch", do_dump_terrain_branch },
1482     { "print-visible-scene", do_print_visible_scene_info },
1483     { "reload-shaders", do_reload_shaders },
1484     { "reload-materials", do_materials_reload },
1485     { "set-scenery-paths", do_set_scenery_paths },
1486   
1487     { "profiler-start", do_profiler_start },
1488     { "profiler-stop",  do_profiler_stop },
1489
1490     { 0, 0 }                    // zero-terminated
1491 };
1492
1493
1494 /**
1495  * Initialize the default built-in commands.
1496  *
1497  * Other commands may be added by other parts of the application.
1498  */
1499 void
1500 fgInitCommands ()
1501 {
1502   SG_LOG(SG_GENERAL, SG_BULK, "Initializing basic built-in commands:");
1503   for (int i = 0; built_ins[i].name != 0; i++) {
1504     SG_LOG(SG_GENERAL, SG_BULK, "  " << built_ins[i].name);
1505     globals->get_commands()->addCommand(built_ins[i].name,
1506                                         built_ins[i].command);
1507   }
1508
1509   typedef bool (*dummy)();
1510   fgTie( "/command/view/next", dummy(0), do_view_next );
1511   fgTie( "/command/view/prev", dummy(0), do_view_prev );
1512
1513   globals->get_props()->setValueReadOnly( "/sim/debug/profiler-available",
1514                                           bool(FG_HAVE_GPERFTOOLS) );
1515 }
1516
1517 // end of fg_commands.cxx