AIManager scenario tweaking.
This commit is contained in:
parent
d70e26d87b
commit
4a84ea0bc4
2 changed files with 17 additions and 44 deletions
|
@ -69,14 +69,8 @@ FGAIManager::init() {
|
||||||
wind_from_east_node = fgGetNode("/environment/wind-from-east-fps",true);
|
wind_from_east_node = fgGetNode("/environment/wind-from-east-fps",true);
|
||||||
wind_from_north_node = fgGetNode("/environment/wind-from-north-fps",true);
|
wind_from_north_node = fgGetNode("/environment/wind-from-north-fps",true);
|
||||||
|
|
||||||
user_latitude_node = fgGetNode("/position/latitude-deg", true);
|
|
||||||
user_longitude_node = fgGetNode("/position/longitude-deg", true);
|
|
||||||
user_altitude_node = fgGetNode("/position/altitude-ft", true);
|
|
||||||
user_altitude_agl_node = fgGetNode("/position/altitude-agl-ft", true);
|
user_altitude_agl_node = fgGetNode("/position/altitude-agl-ft", true);
|
||||||
user_heading_node = fgGetNode("/orientation/heading-deg", true);
|
|
||||||
user_pitch_node = fgGetNode("/orientation/pitch-deg", true);
|
|
||||||
user_yaw_node = fgGetNode("/orientation/side-slip-deg", true);
|
user_yaw_node = fgGetNode("/orientation/side-slip-deg", true);
|
||||||
user_roll_node = fgGetNode("/orientation/roll-deg", true);
|
|
||||||
user_speed_node = fgGetNode("/velocities/uBody-fps", true);
|
user_speed_node = fgGetNode("/velocities/uBody-fps", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,24 +86,20 @@ FGAIManager::postinit() {
|
||||||
enabled->setBoolValue(true);
|
enabled->setBoolValue(true);
|
||||||
|
|
||||||
// process all scenarios
|
// process all scenarios
|
||||||
std::map<string, bool> scenarios;
|
std::set<std::string> loadedScenarios;
|
||||||
for (int i = 0 ; i < root->nChildren() ; i++) {
|
BOOST_FOREACH(SGPropertyNode* n, root->getChildren("scenario")) {
|
||||||
SGPropertyNode *n = root->getChild(i);
|
|
||||||
if (strcmp(n->getName(), "scenario"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const string& name = n->getStringValue();
|
const string& name = n->getStringValue();
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (scenarios.find(name) != scenarios.end()) {
|
if (loadedScenarios.find(name) != loadedScenarios.end()) {
|
||||||
SG_LOG(SG_AI, SG_DEBUG, "won't load scenario '" << name << "' twice");
|
SG_LOG(SG_AI, SG_WARN, "won't load scenario '" << name << "' twice");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SG_LOG(SG_AI, SG_ALERT, "loading scenario '" << name << '\'');
|
SG_LOG(SG_AI, SG_INFO, "loading scenario '" << name << '\'');
|
||||||
processScenario(name);
|
loadScenario(name);
|
||||||
scenarios[name] = true;
|
loadedScenarios.insert(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,14 +220,10 @@ FGAIManager::getNumAiObjects(void) const
|
||||||
void
|
void
|
||||||
FGAIManager::fetchUserState( void ) {
|
FGAIManager::fetchUserState( void ) {
|
||||||
|
|
||||||
user_latitude = user_latitude_node->getDoubleValue();
|
|
||||||
user_longitude = user_longitude_node->getDoubleValue();
|
|
||||||
user_altitude = user_altitude_node->getDoubleValue();
|
|
||||||
user_heading = user_heading_node->getDoubleValue();
|
|
||||||
user_pitch = user_pitch_node->getDoubleValue();
|
|
||||||
user_yaw = user_yaw_node->getDoubleValue();
|
user_yaw = user_yaw_node->getDoubleValue();
|
||||||
|
globals->get_aircraft_orientation(user_heading, user_pitch, user_roll);
|
||||||
|
|
||||||
user_speed = user_speed_node->getDoubleValue() * 0.592484;
|
user_speed = user_speed_node->getDoubleValue() * 0.592484;
|
||||||
user_roll = user_roll_node->getDoubleValue();
|
|
||||||
wind_from_east = wind_from_east_node->getDoubleValue();
|
wind_from_east = wind_from_east_node->getDoubleValue();
|
||||||
wind_from_north = wind_from_north_node->getDoubleValue();
|
wind_from_north = wind_from_north_node->getDoubleValue();
|
||||||
user_altitude_agl = user_altitude_agl_node->getDoubleValue();
|
user_altitude_agl = user_altitude_agl_node->getDoubleValue();
|
||||||
|
@ -259,7 +245,7 @@ FGAIManager::processThermal( double dt, FGAIThermal* thermal ) {
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FGAIManager::processScenario( const string &filename ) {
|
FGAIManager::loadScenario( const string &filename ) {
|
||||||
|
|
||||||
SGPropertyNode_ptr scenarioTop = loadScenarioFile(filename);
|
SGPropertyNode_ptr scenarioTop = loadScenarioFile(filename);
|
||||||
|
|
||||||
|
@ -271,11 +257,7 @@ FGAIManager::processScenario( const string &filename ) {
|
||||||
if (!scenarios)
|
if (!scenarios)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < scenarios->nChildren(); i++) {
|
BOOST_FOREACH(SGPropertyNode* scEntry, scenarios->getChildren("entry")) {
|
||||||
SGPropertyNode* scEntry = scenarios->getChild(i);
|
|
||||||
|
|
||||||
if (strcmp(scEntry->getName(), "entry"))
|
|
||||||
continue;
|
|
||||||
const std::string& type = scEntry->getStringValue("type", "aircraft");
|
const std::string& type = scEntry->getStringValue("type", "aircraft");
|
||||||
|
|
||||||
if (type == "tanker") { // refueling scenarios
|
if (type == "tanker") { // refueling scenarios
|
||||||
|
@ -334,8 +316,7 @@ FGAIManager::processScenario( const string &filename ) {
|
||||||
attach(aistatic);
|
attach(aistatic);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // of scenario entry iteration
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SGPropertyNode_ptr
|
SGPropertyNode_ptr
|
||||||
|
|
|
@ -72,9 +72,9 @@ public:
|
||||||
|
|
||||||
const FGAIBase *calcCollision(double alt, double lat, double lon, double fuse_range);
|
const FGAIBase *calcCollision(double alt, double lat, double lon, double fuse_range);
|
||||||
|
|
||||||
inline double get_user_latitude() const { return user_latitude; }
|
// inline double get_user_latitude() const { return user_latitude; }
|
||||||
inline double get_user_longitude() const { return user_longitude; }
|
// inline double get_user_longitude() const { return user_longitude; }
|
||||||
inline double get_user_altitude() const { return user_altitude; }
|
// inline double get_user_altitude() const { return user_altitude; }
|
||||||
inline double get_user_heading() const { return user_heading; }
|
inline double get_user_heading() const { return user_heading; }
|
||||||
inline double get_user_pitch() const { return user_pitch; }
|
inline double get_user_pitch() const { return user_pitch; }
|
||||||
inline double get_user_yaw() const { return user_yaw; }
|
inline double get_user_yaw() const { return user_yaw; }
|
||||||
|
@ -86,7 +86,7 @@ public:
|
||||||
|
|
||||||
int getNumAiObjects(void) const;
|
int getNumAiObjects(void) const;
|
||||||
|
|
||||||
void processScenario( const string &filename );
|
void loadScenario( const string &filename );
|
||||||
|
|
||||||
static SGPropertyNode_ptr loadScenarioFile(const std::string& filename);
|
static SGPropertyNode_ptr loadScenarioFile(const std::string& filename);
|
||||||
|
|
||||||
|
@ -101,21 +101,13 @@ private:
|
||||||
SGPropertyNode_ptr root;
|
SGPropertyNode_ptr root;
|
||||||
SGPropertyNode_ptr enabled;
|
SGPropertyNode_ptr enabled;
|
||||||
SGPropertyNode_ptr thermal_lift_node;
|
SGPropertyNode_ptr thermal_lift_node;
|
||||||
SGPropertyNode_ptr user_latitude_node;
|
|
||||||
SGPropertyNode_ptr user_longitude_node;
|
|
||||||
SGPropertyNode_ptr user_altitude_node;
|
|
||||||
SGPropertyNode_ptr user_altitude_agl_node;
|
SGPropertyNode_ptr user_altitude_agl_node;
|
||||||
SGPropertyNode_ptr user_heading_node;
|
|
||||||
SGPropertyNode_ptr user_pitch_node;
|
|
||||||
SGPropertyNode_ptr user_yaw_node;
|
SGPropertyNode_ptr user_yaw_node;
|
||||||
SGPropertyNode_ptr user_roll_node;
|
|
||||||
SGPropertyNode_ptr user_speed_node;
|
SGPropertyNode_ptr user_speed_node;
|
||||||
SGPropertyNode_ptr wind_from_east_node;
|
SGPropertyNode_ptr wind_from_east_node;
|
||||||
SGPropertyNode_ptr wind_from_north_node;
|
SGPropertyNode_ptr wind_from_north_node;
|
||||||
|
|
||||||
double user_latitude;
|
|
||||||
double user_longitude;
|
|
||||||
double user_altitude;
|
|
||||||
double user_altitude_agl;
|
double user_altitude_agl;
|
||||||
double user_heading;
|
double user_heading;
|
||||||
double user_pitch;
|
double user_pitch;
|
||||||
|
|
Loading…
Reference in a new issue