David Culp:
First, preferences.xml will define the scenario filename. For now, the other way of defining ai objects still works, so the sailboat stays in preferences.xml. Later, I'll move the sailboat into the demo scenario. If no scenario filename is given, then no scenario will be processed. I changed the demo scenario to create two 737's, one takes off on runway 01L, and the other takes off on runway 01R. This will make a good demo for the ai system. One problem, if you takeoff on 28L/R right away, you might run into the taking-off 737's, or be scared.
This commit is contained in:
parent
4c2f5ce59e
commit
0fd9f0a704
4 changed files with 23 additions and 9 deletions
|
@ -39,6 +39,7 @@ FGAIManager::FGAIManager() {
|
|||
numObjects = 0;
|
||||
_dt = 0.0;
|
||||
dt_count = 9;
|
||||
scenario_filename = "";
|
||||
}
|
||||
|
||||
FGAIManager::~FGAIManager() {
|
||||
|
@ -60,6 +61,10 @@ void FGAIManager::init() {
|
|||
for (int i = 0; i < root->nChildren(); i++) {
|
||||
const SGPropertyNode * entry = root->getChild(i);
|
||||
|
||||
if (!strcmp(entry->getName(), "scenario")){
|
||||
scenario_filename = entry->getStringValue();
|
||||
}
|
||||
|
||||
if (!strcmp(entry->getName(), "entry")) {
|
||||
if (!strcmp(entry->getStringValue("type", ""), "aircraft")) {
|
||||
|
||||
|
@ -113,10 +118,7 @@ void FGAIManager::init() {
|
|||
}
|
||||
}
|
||||
|
||||
//********** Flight Plan test code !!!! ****************
|
||||
processScenario( "default_scenario" );
|
||||
//*******************************************************
|
||||
|
||||
if (scenario_filename != "") processScenario( scenario_filename );
|
||||
initDone = true;
|
||||
}
|
||||
|
||||
|
@ -373,10 +375,12 @@ void FGAIManager::processThermal( FGAIThermal* thermal ) {
|
|||
void FGAIManager::processScenario( string filename ) {
|
||||
//cout << "AIManager: creating a scenario." << endl;
|
||||
FGAIScenario* s = new FGAIScenario( filename );
|
||||
FGAIScenario::entry* en = s->getNextEntry();
|
||||
if (en) {
|
||||
FGAIFlightPlan* f = new FGAIFlightPlan( en->flightplan );
|
||||
createAircraft("jet_transport", "Aircraft/737/Models/boeing733.xml", f);
|
||||
for (int i=0;i<s->nEntries();i++) {
|
||||
FGAIScenario::entry* en = s->getNextEntry();
|
||||
if (en) {
|
||||
FGAIFlightPlan* f = new FGAIFlightPlan( en->flightplan );
|
||||
createAircraft("jet_transport", "Aircraft/737/Models/boeing733.xml", f);
|
||||
}
|
||||
}
|
||||
delete s;
|
||||
}
|
||||
|
|
|
@ -128,6 +128,7 @@ private:
|
|||
int numObjects;
|
||||
SGPropertyNode* root;
|
||||
SGPropertyNode* wind_from_down;
|
||||
string scenario_filename;
|
||||
|
||||
double user_latitude;
|
||||
double user_longitude;
|
||||
|
|
|
@ -53,9 +53,11 @@ FGAIScenario::FGAIScenario(string filename)
|
|||
entries.push_back( en );
|
||||
SGPropertyNode * entry_node = node->getChild(i);
|
||||
en->callsign = entry_node->getStringValue("callsign", "none");
|
||||
en->aitype = entry_node->getStringValue("type", "aircraft");
|
||||
en->aircraft_class = entry_node->getStringValue("class", "jet_transport");
|
||||
en->model_path = entry_node->getStringValue("model", "Models/Geometry/glider.ac");
|
||||
en->flightplan = entry_node->getStringValue("flightplan", "");
|
||||
en->repeat = entry_node->getDoubleValue("repeat", 0.0);
|
||||
}
|
||||
|
||||
entry_iterator = entries.begin();
|
||||
|
@ -72,7 +74,12 @@ FGAIScenario::~FGAIScenario()
|
|||
FGAIScenario::entry*
|
||||
FGAIScenario::getNextEntry( void )
|
||||
{
|
||||
return *entry_iterator;
|
||||
if (entries.size() == 0) return 0;
|
||||
if (entry_iterator != entries.end()) {
|
||||
return *entry_iterator++;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int FGAIScenario::nEntries( void )
|
||||
|
|
|
@ -32,9 +32,11 @@ public:
|
|||
|
||||
typedef struct {
|
||||
string callsign;
|
||||
string aitype; // can be aircraft, ship, storm, thermal
|
||||
string aircraft_class;
|
||||
string model_path;
|
||||
string flightplan;
|
||||
double repeat; // in seconds
|
||||
} entry;
|
||||
|
||||
FGAIScenario(string filename);
|
||||
|
|
Loading…
Add table
Reference in a new issue