Issue #631, reset scenarios on sim-reset
This commit is contained in:
parent
145148944f
commit
081240c4da
2 changed files with 29 additions and 0 deletions
|
@ -162,8 +162,20 @@ FGAIManager::postinit()
|
|||
void
|
||||
FGAIManager::reinit()
|
||||
{
|
||||
// shutdown scenarios
|
||||
unloadAllScenarios();
|
||||
|
||||
update(0.0);
|
||||
std::for_each(ai_list.begin(), ai_list.end(), boost::mem_fn(&FGAIBase::reinit));
|
||||
|
||||
// (re-)load scenarios
|
||||
postinit();
|
||||
}
|
||||
|
||||
void
|
||||
FGAIManager::shutdown()
|
||||
{
|
||||
unloadAllScenarios();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -429,6 +441,21 @@ FGAIManager::unloadScenario( const string &filename)
|
|||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
FGAIManager::unloadAllScenarios()
|
||||
{
|
||||
ScenarioDict::iterator it = _scenarios.begin();
|
||||
for (; it != _scenarios.end(); ++it) {
|
||||
delete it->second;
|
||||
} // of scenarios iteration
|
||||
|
||||
|
||||
// remove /sim/ai node
|
||||
root->removeChildren("scenario");
|
||||
_scenarios.clear();
|
||||
}
|
||||
|
||||
|
||||
SGPropertyNode_ptr
|
||||
FGAIManager::loadScenarioFile(const std::string& filename)
|
||||
{
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
virtual ~FGAIManager();
|
||||
|
||||
void init();
|
||||
virtual void shutdown();
|
||||
void postinit();
|
||||
void reinit();
|
||||
void bind();
|
||||
|
@ -101,6 +102,7 @@ private:
|
|||
|
||||
bool removeObject(const SGPropertyNode* args);
|
||||
bool unloadScenario( const std::string &filename );
|
||||
void unloadAllScenarios();
|
||||
|
||||
SGPropertyNode_ptr root;
|
||||
SGPropertyNode_ptr enabled;
|
||||
|
|
Loading…
Add table
Reference in a new issue