]> git.mxchange.org Git - flightgear.git/blob - src/Main/globals.cxx
796b18cd8f66d1ef35085ca9f8b738efd2534056
[flightgear.git] / src / Main / globals.cxx
1 // globals.cxx -- Global state that needs to be shared among the sim modules
2 //
3 // Written by Curtis Olson, started July 2000.
4 //
5 // Copyright (C) 2000  Curtis L. Olson - http://www.flightgear.org/~curt
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software Foundation,
19 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23 #ifdef HAVE_CONFIG_H
24 #  include <config.h>
25 #endif
26
27 #include <boost/foreach.hpp>
28 #include <algorithm>
29
30 #include <osgViewer/Viewer>
31 #include <osgDB/Registry>
32
33 #include <simgear/structure/commands.hxx>
34 #include <simgear/misc/sg_path.hxx>
35 #include <simgear/misc/sg_dir.hxx>
36 #include <simgear/timing/sg_time.hxx>
37 #include <simgear/ephemeris/ephemeris.hxx>
38 #include <simgear/scene/material/matlib.hxx>
39 #include <simgear/structure/subsystem_mgr.hxx>
40 #include <simgear/structure/event_mgr.hxx>
41 #include <simgear/sound/soundmgr_openal.hxx>
42 #include <simgear/misc/ResourceManager.hxx>
43 #include <simgear/props/propertyObject.hxx>
44 #include <simgear/props/props_io.hxx>
45 #include <simgear/scene/model/modellib.hxx>
46 #include <simgear/package/Root.hxx>
47
48 #include <Aircraft/controls.hxx>
49 #include <Airports/runways.hxx>
50 #include <Autopilot/route_mgr.hxx>
51 #include <GUI/gui.h>
52 #include <Scenery/scenery.hxx>
53 #include <Scenery/tilemgr.hxx>
54 #include <Navaids/navlist.hxx>
55 #include <Viewer/renderer.hxx>
56 #include <Viewer/viewmgr.hxx>
57
58 #include "globals.hxx"
59 #include "locale.hxx"
60
61 #include "fg_props.hxx"
62 #include "fg_io.hxx"
63
64 class AircraftResourceProvider : public simgear::ResourceProvider
65 {
66 public:
67   AircraftResourceProvider() :
68     simgear::ResourceProvider(simgear::ResourceManager::PRIORITY_HIGH)
69   {
70   }
71
72   virtual SGPath resolve(const std::string& aResource, SGPath&) const
73   {
74     string_list pieces(sgPathBranchSplit(aResource));
75     if ((pieces.size() < 3) || (pieces.front() != "Aircraft")) {
76       return SGPath(); // not an Aircraft path
77     }
78
79   // test against the aircraft-dir property
80     const char* aircraftDir = fgGetString("/sim/aircraft-dir");
81     string_list aircraftDirPieces(sgPathBranchSplit(aircraftDir));
82     if (!aircraftDirPieces.empty() && (aircraftDirPieces.back() == pieces[1])) {
83         // disable this warning for release builds
84 #if defined(ENABLE_DEV_WARNINGS)
85         SGPath betterPath;
86         for (unsigned int i=2; i<pieces.size(); ++i) {
87             betterPath.append(pieces[i]);
88         }
89         SG_LOG(SG_AIRCRAFT, SG_WARN, "resolved path:" << aResource << " using /sim/aircraft-dir.\n"
90                "This is legacy behaviour, change to an aircraft relative path:" << betterPath);
91 #endif
92
93         // current aircraft-dir matches resource aircraft
94         SGPath r(aircraftDir);
95         for (unsigned int i=2; i<pieces.size(); ++i) {
96           r.append(pieces[i]);
97         }
98
99         if (r.exists()) {
100           return r;
101         } else {
102           // Stop here, otherwise we could end up returning a resource that
103           // belongs to an unrelated version of the same aircraft (from a
104           // different aircraft directory).
105           return SGPath();
106         }
107     }
108
109   // try each aircraft dir in turn
110     std::string res(aResource, 9); // resource path with 'Aircraft/' removed
111     const string_list& dirs(globals->get_aircraft_paths());
112     string_list::const_iterator it = dirs.begin();
113     for (; it != dirs.end(); ++it) {
114       SGPath p(*it, res);
115       if (p.exists()) {
116         return p;
117       }
118     } // of aircraft path iteration
119
120     return SGPath(); // not found
121   }
122 };
123
124 class CurrentAircraftDirProvider : public simgear::ResourceProvider
125 {
126 public:
127   CurrentAircraftDirProvider() :
128     simgear::ResourceProvider(simgear::ResourceManager::PRIORITY_HIGH)
129   {
130   }
131
132   virtual SGPath resolve(const std::string& aResource, SGPath&) const
133   {
134     const char* aircraftDir = fgGetString("/sim/aircraft-dir");
135     SGPath p(aircraftDir);
136     p.append(aResource);
137     return p.exists() ? p : SGPath();
138   }
139 };
140
141 ////////////////////////////////////////////////////////////////////////
142 // Implementation of FGGlobals.
143 ////////////////////////////////////////////////////////////////////////
144
145 // global global :-)
146 FGGlobals *globals = NULL;
147
148
149 // Constructor
150 FGGlobals::FGGlobals() :
151     renderer( new FGRenderer ),
152     subsystem_mgr( new SGSubsystemMgr ),
153     event_mgr( new SGEventMgr ),
154     sim_time_sec( 0.0 ),
155     fg_root( "" ),
156     fg_home( "" ),
157     time_params( NULL ),
158     commands( SGCommandMgr::instance() ),
159     channel_options_list( NULL ),
160     initial_waypoints( NULL ),
161     channellist( NULL ),
162     haveUserSettings(false)
163 {
164     SGPropertyNode* root = new SGPropertyNode;
165     props = SGPropertyNode_ptr(root);
166     locale = new FGLocale(props);
167
168     simgear::ResourceManager::instance()->addProvider(new AircraftResourceProvider);
169     simgear::ResourceManager::instance()->addProvider(new CurrentAircraftDirProvider);
170     initProperties();
171 }
172
173 void FGGlobals::initProperties()
174 {
175     simgear::PropertyObjectBase::setDefaultRoot(props);
176
177     positionLon = props->getNode("position/longitude-deg", true);
178     positionLat = props->getNode("position/latitude-deg", true);
179     positionAlt = props->getNode("position/altitude-ft", true);
180
181     viewLon = props->getNode("sim/current-view/viewer-lon-deg", true);
182     viewLat = props->getNode("sim/current-view/viewer-lat-deg", true);
183     viewAlt = props->getNode("sim/current-view/viewer-elev-ft", true);
184
185     orientPitch = props->getNode("orientation/pitch-deg", true);
186     orientHeading = props->getNode("orientation/heading-deg", true);
187     orientRoll = props->getNode("orientation/roll-deg", true);
188
189 }
190
191 // Destructor
192 FGGlobals::~FGGlobals()
193 {
194     // save user settings (unless already saved)
195     saveUserSettings();
196
197     // stop OSG threading first, to avoid thread races while we tear down
198     // scene-graph pieces
199
200     osg::ref_ptr<osgViewer::Viewer> vw(renderer->getViewer());
201     if (vw) {
202         // https://code.google.com/p/flightgear-bugs/issues/detail?id=1291
203         // explicitly stop trheading before we delete the renderer or
204         // viewMgr (which ultimately holds refs to the CameraGroup, and
205         // GraphicsContext)
206         vw->stopThreading();
207     }
208
209     subsystem_mgr->shutdown();
210     subsystem_mgr->unbind();
211
212     subsystem_mgr->remove(FGTileMgr::subsystemName());
213     // don't cancel the pager until after shutdown, since AIModels (and
214     // potentially others) can queue delete requests on the pager.
215     if (vw && vw->getDatabasePager()) {
216         vw->getDatabasePager()->cancel();
217         vw->getDatabasePager()->clear();
218     }
219
220     osgDB::Registry::instance()->clearObjectCache();
221     subsystem_mgr->remove(FGScenery::subsystemName());
222
223     // renderer touches subsystems during its destruction
224     set_renderer(NULL);
225
226     delete subsystem_mgr;
227     subsystem_mgr = NULL; // important so ::get_subsystem returns NULL
228     vw = 0; // don't delete the viewer until now
229
230     delete time_params;
231     set_matlib(NULL);
232
233     delete channel_options_list;
234     delete initial_waypoints;
235     delete channellist;
236
237     simgear::PropertyObjectBase::setDefaultRoot(NULL);
238     simgear::SGModelLib::resetPropertyRoot();
239
240     delete locale;
241     locale = NULL;
242
243     cleanupListeners();
244
245     props.clear();
246
247     delete commands;
248 }
249
250 // set the fg_root path
251 void FGGlobals::set_fg_root (const std::string &root) {
252     SGPath tmp(root);
253     fg_root = tmp.realpath();
254
255     // append /data to root if it exists
256     tmp.append( "data" );
257     tmp.append( "version" );
258     if ( tmp.exists() ) {
259         fgGetNode("BAD_FG_ROOT", true)->setStringValue(fg_root);
260         fg_root += "/data";
261         fgGetNode("GOOD_FG_ROOT", true)->setStringValue(fg_root);
262         SG_LOG(SG_GENERAL, SG_ALERT, "***\n***\n*** Warning: changing bad FG_ROOT/--fg-root to '"
263                 << fg_root << "'\n***\n***");
264     }
265
266     // deliberately not a tied property, for fgValidatePath security
267     // write-protect to avoid accidents
268     SGPropertyNode *n = fgGetNode("/sim", true);
269     n->removeChild("fg-root", 0);
270     n = n->getChild("fg-root", 0, true);
271     n->setStringValue(fg_root.c_str());
272     n->setAttribute(SGPropertyNode::WRITE, false);
273
274     simgear::ResourceManager::instance()->addBasePath(fg_root,
275       simgear::ResourceManager::PRIORITY_DEFAULT);
276 }
277
278 // set the fg_home path
279 void FGGlobals::set_fg_home (const std::string &home) {
280     SGPath tmp(home);
281     fg_home = tmp.realpath();
282 }
283
284 PathList FGGlobals::get_data_paths() const
285 {
286     PathList r(additional_data_paths);
287     r.push_back(SGPath(fg_root));
288     return r;
289 }
290
291 PathList FGGlobals::get_data_paths(const std::string& suffix) const
292 {
293     PathList r;
294     BOOST_FOREACH(SGPath p, get_data_paths()) {
295         p.append(suffix);
296         if (p.exists()) {
297             r.push_back(p);
298         }
299     }
300
301     return r;
302 }
303
304 void FGGlobals::append_data_path(const SGPath& path)
305 {
306     if (!path.exists()) {
307         SG_LOG(SG_GENERAL, SG_WARN, "adding non-existant data path:" << path);
308     }
309
310     additional_data_paths.push_back(path);
311 }
312
313 SGPath FGGlobals::find_data_dir(const std::string& pathSuffix) const
314 {
315     BOOST_FOREACH(SGPath p, additional_data_paths) {
316         p.append(pathSuffix);
317         if (p.exists()) {
318             return p;
319         }
320     }
321
322     SGPath rootPath(fg_root);
323     rootPath.append(pathSuffix);
324     if (rootPath.exists()) {
325         return rootPath;
326     }
327
328     SG_LOG(SG_GENERAL, SG_WARN, "dir not found in any data path:" << pathSuffix);
329     return SGPath();
330 }
331
332 void FGGlobals::append_fg_scenery (const std::string &paths, bool secure)
333 {
334     SGPropertyNode* sim = fgGetNode("/sim", true);
335
336   // find first unused fg-scenery property in /sim
337     int propIndex = 0;
338     while (sim->getChild("fg-scenery", propIndex) != NULL) {
339       ++propIndex;
340     }
341
342     BOOST_FOREACH(const SGPath& path, sgPathSplit( paths )) {
343         SGPath abspath(path.realpath());
344         if (!abspath.exists()) {
345           SG_LOG(SG_GENERAL, SG_WARN, "scenery path not found:" << abspath.str());
346           continue;
347         }
348
349       // check for duplicates
350       string_list::const_iterator ex = std::find(fg_scenery.begin(), fg_scenery.end(), abspath.str());
351       if (ex != fg_scenery.end()) {
352         SG_LOG(SG_GENERAL, SG_INFO, "skipping duplicate add of scenery path:" << abspath.str());
353         continue;
354       }
355
356       // tell the ResouceManager about the scenery path
357       // needed to load Models from this scenery path
358       simgear::ResourceManager::instance()->addBasePath(abspath.str(),
359         simgear::ResourceManager::PRIORITY_DEFAULT);
360
361         simgear::Dir dir(abspath);
362         SGPath terrainDir(dir.file("Terrain"));
363         SGPath objectsDir(dir.file("Objects"));
364
365       // this code used to add *either* the base dir, OR add the
366       // Terrain and Objects subdirs, but the conditional logic was commented
367       // out, such that all three dirs are added. Unfortunately there's
368       // no information as to why the change was made.
369         fg_scenery.push_back(abspath.str());
370         if (secure) {
371           secure_fg_scenery.push_back(abspath.str());
372         }
373
374         if (terrainDir.exists()) {
375           fg_scenery.push_back(terrainDir.str());
376         }
377
378         if (objectsDir.exists()) {
379           fg_scenery.push_back(objectsDir.str());
380         }
381
382         // insert a marker for FGTileEntry::load(), so that
383         // FG_SCENERY=A:B becomes list ["A/Terrain", "A/Objects", "",
384         // "B/Terrain", "B/Objects", ""]
385         fg_scenery.push_back("");
386
387       // make scenery dirs available to Nasal
388         SGPropertyNode* n = sim->getChild("fg-scenery", propIndex++, true);
389         n->setStringValue(abspath.str());
390         n->setAttribute(SGPropertyNode::WRITE, false);
391
392         // temporary fix so these values survive reset
393         n->setAttribute(SGPropertyNode::PRESERVE, true);
394     } // of path list iteration
395 }
396
397 void FGGlobals::clear_fg_scenery()
398 {
399   fg_scenery.clear();
400   secure_fg_scenery.clear();
401   fgGetNode("/sim", true)->removeChildren("fg-scenery");
402
403 }
404
405 void FGGlobals::set_catalog_aircraft_path(const SGPath& path)
406 {
407     catalog_aircraft_dir = path;
408 }
409
410 string_list FGGlobals::get_aircraft_paths() const
411 {
412     string_list r;
413     if (!catalog_aircraft_dir.isNull()) {
414         r.push_back(catalog_aircraft_dir.str());
415     }
416
417     r.insert(r.end(), fg_aircraft_dirs.begin(), fg_aircraft_dirs.end());
418     return r;
419 }
420
421 void FGGlobals::append_aircraft_path(const std::string& path)
422 {
423   SGPath dirPath(path);
424   if (!dirPath.exists()) {
425     SG_LOG(SG_GENERAL, SG_ALERT, "aircraft path not found:" << path);
426     return;
427   }
428
429   SGPath acSubdir(dirPath);
430   acSubdir.append("Aircraft");
431   if (acSubdir.exists()) {
432       SG_LOG(
433         SG_GENERAL,
434         SG_WARN,
435         "Specified an aircraft-dir with an 'Aircraft' subdirectory:" << dirPath
436         << ", will instead use child directory:" << acSubdir
437       );
438       dirPath = acSubdir;
439   }
440
441   std::string abspath = dirPath.realpath();
442   fg_aircraft_dirs.push_back(abspath);
443 }
444
445 void FGGlobals::append_aircraft_paths(const std::string& path)
446 {
447   string_list paths = sgPathSplit(path);
448   for (unsigned int p = 0; p<paths.size(); ++p) {
449     append_aircraft_path(paths[p]);
450   }
451 }
452
453 SGPath FGGlobals::resolve_aircraft_path(const std::string& branch) const
454 {
455   return simgear::ResourceManager::instance()->findPath(branch);
456 }
457
458 SGPath FGGlobals::resolve_maybe_aircraft_path(const std::string& branch) const
459 {
460   return simgear::ResourceManager::instance()->findPath(branch);
461 }
462
463 SGPath FGGlobals::resolve_resource_path(const std::string& branch) const
464 {
465   return simgear::ResourceManager::instance()
466     ->findPath(branch, SGPath(fgGetString("/sim/aircraft-dir")));
467 }
468
469 FGRenderer *
470 FGGlobals::get_renderer () const
471 {
472    return renderer;
473 }
474
475 void FGGlobals::set_renderer(FGRenderer *render)
476 {
477     if (render == renderer) {
478         return;
479     }
480
481     delete renderer;
482     renderer = render;
483 }
484
485 SGSubsystemMgr *
486 FGGlobals::get_subsystem_mgr () const
487 {
488     return subsystem_mgr;
489 }
490
491 SGSubsystem *
492 FGGlobals::get_subsystem (const char * name) const
493 {
494     if (!subsystem_mgr) {
495         return NULL;
496     }
497
498     return subsystem_mgr->get_subsystem(name);
499 }
500
501 void
502 FGGlobals::add_subsystem (const char * name,
503                           SGSubsystem * subsystem,
504                           SGSubsystemMgr::GroupType type,
505                           double min_time_sec)
506 {
507     subsystem_mgr->add(name, subsystem, type, min_time_sec);
508 }
509
510 SGEventMgr *
511 FGGlobals::get_event_mgr () const
512 {
513     return event_mgr;
514 }
515
516 SGGeod
517 FGGlobals::get_aircraft_position() const
518 {
519   return SGGeod::fromDegFt(positionLon->getDoubleValue(),
520                            positionLat->getDoubleValue(),
521                            positionAlt->getDoubleValue());
522 }
523
524 SGVec3d
525 FGGlobals::get_aircraft_position_cart() const
526 {
527     return SGVec3d::fromGeod(get_aircraft_position());
528 }
529
530 void FGGlobals::get_aircraft_orientation(double& heading, double& pitch, double& roll)
531 {
532   heading = orientHeading->getDoubleValue();
533   pitch = orientPitch->getDoubleValue();
534   roll = orientRoll->getDoubleValue();
535 }
536
537 SGGeod
538 FGGlobals::get_view_position() const
539 {
540   return SGGeod::fromDegFt(viewLon->getDoubleValue(),
541                            viewLat->getDoubleValue(),
542                            viewAlt->getDoubleValue());
543 }
544
545 SGVec3d
546 FGGlobals::get_view_position_cart() const
547 {
548   return SGVec3d::fromGeod(get_view_position());
549 }
550
551 static void treeDumpRefCounts(int depth, SGPropertyNode* nd)
552 {
553     for (int i=0; i<nd->nChildren(); ++i) {
554         SGPropertyNode* cp = nd->getChild(i);
555         if (SGReferenced::count(cp) > 1) {
556             SG_LOG(SG_GENERAL, SG_INFO, "\t" << cp->getPath() << " refcount:" << SGReferenced::count(cp));
557         }
558
559         treeDumpRefCounts(depth + 1, cp);
560     }
561 }
562
563 static void treeClearAliases(SGPropertyNode* nd)
564 {
565     if (nd->isAlias()) {
566         nd->unalias();
567     }
568
569     for (int i=0; i<nd->nChildren(); ++i) {
570         SGPropertyNode* cp = nd->getChild(i);
571         treeClearAliases(cp);
572     }
573 }
574
575 void
576 FGGlobals::resetPropertyRoot()
577 {
578     delete locale;
579
580     cleanupListeners();
581
582     // we don't strictly need to clear these (they will be reset when we
583     // initProperties again), but trying to reduce false-positives when dumping
584     // ref-counts.
585     positionLon.clear();
586     positionLat.clear();
587     positionAlt.clear();
588     viewLon.clear();
589     viewLat.clear();
590     viewAlt.clear();
591     orientPitch.clear();
592     orientHeading.clear();
593     orientRoll.clear();
594
595     // clear aliases so ref-counts are accurate when dumped
596     treeClearAliases(props);
597
598     SG_LOG(SG_GENERAL, SG_INFO, "root props refcount:" << props.getNumRefs());
599     treeDumpRefCounts(0, props);
600
601     //BaseStackSnapshot::dumpAll(std::cout);
602
603     props = new SGPropertyNode;
604     initProperties();
605     locale = new FGLocale(props);
606
607     // remove /sim/fg-root before writing to prevent hijacking
608     SGPropertyNode *n = props->getNode("/sim", true);
609     n->removeChild("fg-root", 0);
610     n = n->getChild("fg-root", 0, true);
611     n->setStringValue(fg_root.c_str());
612     n->setAttribute(SGPropertyNode::WRITE, false);
613 }
614
615 static std::string autosaveName()
616 {
617     std::ostringstream os;
618     string_list versionParts = simgear::strutils::split(VERSION, ".");
619     if (versionParts.size() < 2) {
620         return "autosave.xml";
621     }
622
623     os << "autosave_" << versionParts[0] << "_" << versionParts[1] << ".xml";
624     return os.str();
625 }
626
627 // Load user settings from autosave.xml
628 void
629 FGGlobals::loadUserSettings(const SGPath& dataPath)
630 {
631     // remember that we have (tried) to load any existing autsave.xml
632     haveUserSettings = true;
633
634     SGPath autosaveFile = simgear::Dir(dataPath).file(autosaveName());
635     SGPropertyNode autosave;
636     if (autosaveFile.exists()) {
637       SG_LOG(SG_INPUT, SG_INFO, "Reading user settings from " << autosaveFile.str());
638       try {
639           readProperties(autosaveFile.str(), &autosave, SGPropertyNode::USERARCHIVE);
640       } catch (sg_exception& e) {
641           SG_LOG(SG_INPUT, SG_WARN, "failed to read user settings:" << e.getMessage()
642             << "(from " << e.getOrigin() << ")");
643       }
644     }
645     copyProperties(&autosave, globals->get_props());
646 }
647
648 // Save user settings in autosave.xml
649 void
650 FGGlobals::saveUserSettings()
651 {
652     // only save settings when we have (tried) to load the previous
653     // settings (otherwise user data was lost)
654     if (!haveUserSettings)
655         return;
656
657     if (fgGetBool("/sim/startup/save-on-exit")) {
658       // don't save settings more than once on shutdown
659       haveUserSettings = false;
660
661       SGPath autosaveFile(globals->get_fg_home());
662       autosaveFile.append(autosaveName());
663       autosaveFile.create_dir( 0700 );
664       SG_LOG(SG_IO, SG_INFO, "Saving user settings to " << autosaveFile.str());
665       try {
666         writeProperties(autosaveFile.str(), globals->get_props(), false, SGPropertyNode::USERARCHIVE);
667       } catch (const sg_exception &e) {
668         guiErrorMessage("Error writing autosave:", e);
669       }
670       SG_LOG(SG_INPUT, SG_DEBUG, "Finished Saving user settings");
671     }
672 }
673
674 long int FGGlobals::get_warp() const
675 {
676   return fgGetInt("/sim/time/warp");
677 }
678
679 void FGGlobals::set_warp( long int w )
680 {
681   fgSetInt("/sim/time/warp", w);
682 }
683
684 long int FGGlobals::get_warp_delta() const
685 {
686   return fgGetInt("/sim/time/warp-delta");
687 }
688
689 void FGGlobals::set_warp_delta( long int d )
690 {
691   fgSetInt("/sim/time/warp-delta", d);
692 }
693
694 FGScenery* FGGlobals::get_scenery () const
695 {
696     return get_subsystem<FGScenery>();
697 }
698
699 FGTileMgr* FGGlobals::get_tile_mgr () const
700 {
701     return get_subsystem<FGTileMgr>();
702 }
703
704 FGViewMgr *FGGlobals::get_viewmgr() const
705 {
706     return get_subsystem<FGViewMgr>();
707 }
708
709 flightgear::View* FGGlobals::get_current_view () const
710 {
711     FGViewMgr* vm = get_viewmgr();
712     return vm ? vm->get_current_view() : 0;
713 }
714
715 void FGGlobals::set_matlib( SGMaterialLib *m )
716 {
717     matlib = m;
718 }
719
720 FGControls *FGGlobals::get_controls() const
721 {
722     return get_subsystem<FGControls>();
723 }
724
725 void FGGlobals::addListenerToCleanup(SGPropertyChangeListener* l)
726 {
727     _listeners_to_cleanup.push_back(l);
728 }
729
730 void FGGlobals::cleanupListeners()
731 {
732     SGPropertyChangeListenerVec::iterator i = _listeners_to_cleanup.begin();
733     for (; i != _listeners_to_cleanup.end(); ++i) {
734         delete *i;
735     }
736     _listeners_to_cleanup.clear();
737 }
738
739 simgear::pkg::Root* FGGlobals::packageRoot()
740 {
741   return _packageRoot.get();
742 }
743
744 void FGGlobals::setPackageRoot(const SGSharedPtr<simgear::pkg::Root>& p)
745 {
746   _packageRoot = p;
747 }
748
749 // end of globals.cxx