Use AIBase method setParentNode() vice the local method.
Signed-off-by: Vivian Meazza <vivian.meazza@lineone.net>
This commit is contained in:
parent
afbc360eed
commit
2758f07df0
5 changed files with 18 additions and 103 deletions
|
@ -44,7 +44,6 @@ using std::string;
|
||||||
FGAIEscort::FGAIEscort() :
|
FGAIEscort::FGAIEscort() :
|
||||||
FGAIShip(otEscort),
|
FGAIShip(otEscort),
|
||||||
|
|
||||||
_selected_ac(0),
|
|
||||||
_relbrg (0),
|
_relbrg (0),
|
||||||
_stn_truebrg(0),
|
_stn_truebrg(0),
|
||||||
_parent_speed(0),
|
_parent_speed(0),
|
||||||
|
@ -56,8 +55,7 @@ _max_speed(0),
|
||||||
_interval(0),
|
_interval(0),
|
||||||
_MPControl(false),
|
_MPControl(false),
|
||||||
_patrol(false),
|
_patrol(false),
|
||||||
_stn_deg_true(false),
|
_stn_deg_true(false)
|
||||||
_parent("")
|
|
||||||
|
|
||||||
{
|
{
|
||||||
invisible = false;
|
invisible = false;
|
||||||
|
@ -143,6 +141,8 @@ bool FGAIEscort::init(bool search_in_AI_path) {
|
||||||
|
|
||||||
props->setStringValue("controls/parent-name", _parent.c_str());
|
props->setStringValue("controls/parent-name", _parent.c_str());
|
||||||
setParentNode();
|
setParentNode();
|
||||||
|
setParent();
|
||||||
|
|
||||||
pos = _tgtpos;
|
pos = _tgtpos;
|
||||||
speed = _parent_speed;
|
speed = _parent_speed;
|
||||||
hdg = _parent_hdg;
|
hdg = _parent_hdg;
|
||||||
|
@ -196,10 +196,6 @@ void FGAIEscort::setStnPatrol(bool p) {
|
||||||
_patrol = p;
|
_patrol = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGAIEscort::setParentName(const string& p) {
|
|
||||||
_parent = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FGAIEscort::getGroundElev(SGGeod inpos) {
|
bool FGAIEscort::getGroundElev(SGGeod inpos) {
|
||||||
|
|
||||||
double height_m ;
|
double height_m ;
|
||||||
|
@ -233,79 +229,6 @@ bool FGAIEscort::getGroundElev(SGGeod inpos) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGAIEscort::setParentNode() {
|
|
||||||
|
|
||||||
const SGPropertyNode_ptr ai = fgGetNode("/ai/models", true);
|
|
||||||
|
|
||||||
for (int i = ai->nChildren() - 1; i >= -1; i--) {
|
|
||||||
SGPropertyNode_ptr model;
|
|
||||||
|
|
||||||
if (i < 0) { // last iteration: selected model
|
|
||||||
model = _selected_ac;
|
|
||||||
} else {
|
|
||||||
model = ai->getChild(i);
|
|
||||||
string path = ai->getPath();
|
|
||||||
const string name = model->getStringValue("name");
|
|
||||||
|
|
||||||
if (!model->nChildren()){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (name == _parent) {
|
|
||||||
_selected_ac = model; // save selected model for last iteration
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if (!model)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
}// end for loop
|
|
||||||
|
|
||||||
if (_selected_ac != 0){
|
|
||||||
const string name = _selected_ac->getStringValue("name");
|
|
||||||
setParent();
|
|
||||||
|
|
||||||
//double lat = _selected_ac->getDoubleValue("position/latitude-deg");
|
|
||||||
//double lon = _selected_ac->getDoubleValue("position/longitude-deg");
|
|
||||||
//double elevation = _selected_ac->getDoubleValue("position/altitude-ft");
|
|
||||||
//_MPControl = _selected_ac->getBoolValue("controls/mp-control");
|
|
||||||
|
|
||||||
//_selectedpos.setLatitudeDeg(lat);
|
|
||||||
//_selectedpos.setLongitudeDeg(lon);
|
|
||||||
//_selectedpos.setElevationFt(elevation);
|
|
||||||
|
|
||||||
//_parent_speed = _selected_ac->getDoubleValue("velocities/speed-kts");
|
|
||||||
//_parent_hdg = _selected_ac->getDoubleValue("orientation/true-heading-deg");
|
|
||||||
|
|
||||||
//if(!_stn_deg_true){
|
|
||||||
// _stn_truebrg = calcTrueBearingDeg(_stn_brg, _parent_hdg);
|
|
||||||
// _stn_relbrg = _stn_brg;
|
|
||||||
// //cout << _name <<" set rel"<<endl;
|
|
||||||
//} else {
|
|
||||||
// _stn_truebrg = _stn_brg;
|
|
||||||
// _stn_relbrg = calcRelBearingDeg(_stn_brg, _parent_hdg);
|
|
||||||
// //cout << _name << " set true"<<endl;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//double course2;
|
|
||||||
|
|
||||||
//SGGeodesy::direct( _selectedpos, _stn_truebrg, _stn_range * SG_NM_TO_METER,
|
|
||||||
// _tgtpos, course2);
|
|
||||||
|
|
||||||
//_tgtpos.setElevationFt(_stn_height);
|
|
||||||
|
|
||||||
//calcRangeBearing(pos.getLatitudeDeg(), pos.getLongitudeDeg(),
|
|
||||||
// _tgtpos.getLatitudeDeg(), _tgtpos.getLongitudeDeg(), _tgtrange, _tgtbrg);
|
|
||||||
|
|
||||||
//_relbrg = calcRelBearingDeg(_tgtbrg, hdg);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "AIEscort: " << _name
|
|
||||||
<< " parent not found: dying ");
|
|
||||||
setDie(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void FGAIEscort::setParent()
|
void FGAIEscort::setParent()
|
||||||
{
|
{
|
||||||
|
@ -474,10 +397,9 @@ void FGAIEscort::RunEscort(double dt){
|
||||||
|
|
||||||
setParent();
|
setParent();
|
||||||
setStationSpeed();
|
setStationSpeed();
|
||||||
//getGroundElev(pos);
|
|
||||||
|
|
||||||
_dt_count = 0;
|
_dt_count = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// end AIGroundvehicle
|
// end AIEscort
|
||||||
|
|
|
@ -50,8 +50,6 @@ private:
|
||||||
virtual void reinit() { init(); }
|
virtual void reinit() { init(); }
|
||||||
virtual void update (double dt);
|
virtual void update (double dt);
|
||||||
|
|
||||||
void setParentName(const std::string& p);
|
|
||||||
void setParentNode();
|
|
||||||
void setStnRange(double r);
|
void setStnRange(double r);
|
||||||
void setStnBrg(double y);
|
void setStnBrg(double y);
|
||||||
void setStationSpeed();
|
void setStationSpeed();
|
||||||
|
@ -96,12 +94,12 @@ private:
|
||||||
double _max_speed;
|
double _max_speed;
|
||||||
|
|
||||||
const SGMaterial* _material;
|
const SGMaterial* _material;
|
||||||
SGPropertyNode_ptr _selected_ac;
|
|
||||||
|
|
||||||
bool _MPControl, _patrol, _stn_deg_true;
|
bool _MPControl, _patrol, _stn_deg_true;
|
||||||
|
|
||||||
std::string _parent;
|
// std::string _parent;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FG_AIGROUNDVEHICLE_HXX
|
#endif // FG_AIGROUNDVEHICLE_HXX
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,6 @@ _next_run(0),
|
||||||
_parent_x_offset(0),
|
_parent_x_offset(0),
|
||||||
_parent_y_offset(0),
|
_parent_y_offset(0),
|
||||||
_parent_z_offset(0),
|
_parent_z_offset(0),
|
||||||
_parent(""),
|
|
||||||
_break_count(0)
|
_break_count(0)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -212,10 +211,6 @@ void FGAIGroundVehicle::setPitch(double p, double dt, double coeff){
|
||||||
_pitch_deg = (p * c) + (_pitch_deg * (1 - c));
|
_pitch_deg = (p * c) + (_pitch_deg * (1 - c));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGAIGroundVehicle::setParentName(const string& p) {
|
|
||||||
_parent = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FGAIGroundVehicle::setTowAngle(double ta, double dt, double coeff){
|
void FGAIGroundVehicle::setTowAngle(double ta, double dt, double coeff){
|
||||||
ta *= _tow_angle_gain;
|
ta *= _tow_angle_gain;
|
||||||
double factor = -0.0045 * speed + 1;
|
double factor = -0.0045 * speed + 1;
|
||||||
|
|
|
@ -62,7 +62,7 @@ private:
|
||||||
void setElevation(double _elevation, double dt, double _elevation_coeff);
|
void setElevation(double _elevation, double dt, double _elevation_coeff);
|
||||||
void setPitch(double _pitch, double dt, double _pitch_coeff);
|
void setPitch(double _pitch, double dt, double _pitch_coeff);
|
||||||
void setTowAngle(double _relbrg, double dt, double _towangle_coeff);
|
void setTowAngle(double _relbrg, double dt, double _towangle_coeff);
|
||||||
void setParentName(const string& p);
|
// void setParentName(const string& p);
|
||||||
void setTrainSpeed(double s, double dt, double coeff);
|
void setTrainSpeed(double s, double dt, double coeff);
|
||||||
void setParent();
|
void setParent();
|
||||||
void setParentNode();
|
void setParentNode();
|
||||||
|
@ -100,7 +100,7 @@ private:
|
||||||
const SGMaterial* _material;
|
const SGMaterial* _material;
|
||||||
SGPropertyNode_ptr _selected_ac;
|
SGPropertyNode_ptr _selected_ac;
|
||||||
|
|
||||||
string _parent;
|
// string _parent;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ void FGAIWingman::readFromScenario(SGPropertyNode* scFileNode) {
|
||||||
setLife(scFileNode->getDoubleValue("life", -1));
|
setLife(scFileNode->getDoubleValue("life", -1));
|
||||||
setNoRoll(scFileNode->getBoolValue("no-roll", false));
|
setNoRoll(scFileNode->getBoolValue("no-roll", false));
|
||||||
setName(scFileNode->getStringValue("name", "Wingman"));
|
setName(scFileNode->getStringValue("name", "Wingman"));
|
||||||
|
setParentName(scFileNode->getStringValue("parent", ""));
|
||||||
//setSMPath(scFileNode->getStringValue("submodel-path", ""));
|
//setSMPath(scFileNode->getStringValue("submodel-path", ""));
|
||||||
setSubID(scFileNode->getIntValue("SubID", 0));
|
setSubID(scFileNode->getIntValue("SubID", 0));
|
||||||
setXoffset(scFileNode->getDoubleValue("x-offset", 0.0));
|
setXoffset(scFileNode->getDoubleValue("x-offset", 0.0));
|
||||||
|
@ -171,7 +172,6 @@ bool FGAIWingman::init(bool search_in_AI_path) {
|
||||||
|
|
||||||
void FGAIWingman::update(double dt) {
|
void FGAIWingman::update(double dt) {
|
||||||
FGAIBallistic::update(dt);
|
FGAIBallistic::update(dt);
|
||||||
// cout << FGAIBase::_getName() << " update speed " << FGAIBase::_getSpeed() << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// end AIWingman
|
// end AIWingman
|
||||||
|
|
Loading…
Add table
Reference in a new issue