AIEscort: Maintenance
default dtor ensure all members are initialized _max_speed was hiding parent member double constants with double types
This commit is contained in:
parent
a9cb94fdbd
commit
a177aa76bc
2 changed files with 40 additions and 54 deletions
|
@ -41,28 +41,11 @@
|
|||
|
||||
using std::string;
|
||||
|
||||
FGAIEscort::FGAIEscort() :
|
||||
FGAIShip(otEscort),
|
||||
|
||||
_relbrg (0),
|
||||
_parent_speed(0),
|
||||
_interval(0),
|
||||
_stn_truebrg(0),
|
||||
_stn_height(0),
|
||||
_stn_speed(0),
|
||||
_stn_angle_limit(0),
|
||||
_stn_limit(0),
|
||||
_max_speed(0),
|
||||
_MPControl(false),
|
||||
_patrol(false),
|
||||
_stn_deg_true(false)
|
||||
|
||||
FGAIEscort::FGAIEscort() : FGAIShip(object_type::otEscort)
|
||||
{
|
||||
invisible = false;
|
||||
}
|
||||
|
||||
FGAIEscort::~FGAIEscort() {}
|
||||
|
||||
void FGAIEscort::readFromScenario(SGPropertyNode* scFileNode) {
|
||||
if (!scFileNode)
|
||||
return;
|
||||
|
@ -306,35 +289,35 @@ void FGAIEscort::setStationSpeed(){
|
|||
|
||||
// these are the AI rules for the manoeuvring of escorts
|
||||
|
||||
if (_MPControl && _tgtrange > 4 * _stn_limit) {
|
||||
if (_MPControl && _tgtrange > 4.0 * _stn_limit) {
|
||||
SG_LOG(SG_AI, SG_ALERT, "AIEscort: " << _name
|
||||
<< " re-aligning to MP pos");
|
||||
pos = _tgtpos;
|
||||
speed = 0;
|
||||
angle = 0;
|
||||
} else if ((_relbrg < -90 || _relbrg > 90) && _tgtrange > _stn_limit) {
|
||||
speed = 0.0;
|
||||
angle = 0.0;
|
||||
} else if ((_relbrg < -90.0 || _relbrg > 90.0) && _tgtrange > _stn_limit) {
|
||||
angle =_relbrg;
|
||||
|
||||
if(_tgtrange > 4 * _stn_limit)
|
||||
speed = 4 * -_stn_speed;
|
||||
if(_tgtrange > 4.0 * _stn_limit)
|
||||
speed = 4.0 * -_stn_speed;
|
||||
else
|
||||
speed = -_stn_speed;
|
||||
|
||||
} else if ((_relbrg >= -90 && _relbrg <= 90) && _tgtrange > _stn_limit) {
|
||||
} else if ((_relbrg >= -90.0 && _relbrg <= 90.0) && _tgtrange > _stn_limit) {
|
||||
angle = _relbrg;
|
||||
|
||||
if(_tgtrange > 4 * _stn_limit)
|
||||
speed = 4 * _stn_speed;
|
||||
if(_tgtrange > 4.0 * _stn_limit)
|
||||
speed = 4.0 * _stn_speed;
|
||||
else
|
||||
speed = _stn_speed;
|
||||
|
||||
} else {
|
||||
if (_patrol){
|
||||
angle = 15 * sg_random();
|
||||
speed = 5 * sg_random();
|
||||
angle = 15.0 * sg_random();
|
||||
speed = 5.0 * sg_random();
|
||||
} else {
|
||||
angle = 0;
|
||||
speed = 0;
|
||||
angle = 0.0;
|
||||
speed = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,10 @@
|
|||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
#ifndef _FG_AIESCORT_HXX
|
||||
#define _FG_AIESCORT_HXX
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
|
@ -30,14 +29,16 @@
|
|||
|
||||
#include "AIShip.hxx"
|
||||
|
||||
#include "AIManager.hxx"
|
||||
#include "AIBase.hxx"
|
||||
#include "AIManager.hxx"
|
||||
|
||||
class FGAIEscort : public FGAIShip {
|
||||
class FGAIEscort : public FGAIShip
|
||||
{
|
||||
public:
|
||||
FGAIEscort();
|
||||
virtual ~FGAIEscort();
|
||||
virtual ~FGAIEscort() = default;
|
||||
|
||||
const char* getTypeString(void) const override { return "escort"; }
|
||||
void readFromScenario(SGPropertyNode* scFileNode) override;
|
||||
|
||||
bool init(ModelSearchOrder searchOrder) override;
|
||||
|
@ -45,8 +46,6 @@ public:
|
|||
void reinit() override;
|
||||
void update(double dt) override;
|
||||
|
||||
const char* getTypeString(void) const override { return "escort"; }
|
||||
|
||||
private:
|
||||
void setStnRange(double r);
|
||||
void setStnBrg(double y);
|
||||
|
@ -75,22 +74,26 @@ private:
|
|||
SGGeod _selectedpos;
|
||||
SGGeod _tgtpos;
|
||||
|
||||
bool _solid; // if true ground is solid for FDMs
|
||||
double _tgtrange, _tgtbrg;
|
||||
double _ht_agl_ft;
|
||||
double _relbrg;
|
||||
double _parent_speed, _parent_hdg;
|
||||
double _interval;
|
||||
bool _solid = true; // if true ground is solid for FDMs
|
||||
double _tgtrange = 0.0;
|
||||
double _tgtbrg = 0.0;
|
||||
double _ht_agl_ft = 0.0;
|
||||
double _relbrg = 0.0;
|
||||
double _parent_speed = 0.0;
|
||||
double _parent_hdg = 0.0;
|
||||
double _interval = 0.0;
|
||||
|
||||
double _stn_relbrg, _stn_truebrg, _stn_brg, _stn_range, _stn_height;
|
||||
double _stn_speed, _stn_angle_limit, _stn_limit;
|
||||
|
||||
double _max_speed;
|
||||
|
||||
bool _MPControl, _patrol, _stn_deg_true;
|
||||
|
||||
// std::string _parent;
|
||||
double _stn_relbrg = 0.0;
|
||||
double _stn_truebrg = 0.0;
|
||||
double _stn_brg = 0.0;
|
||||
double _stn_range = 0.0;
|
||||
double _stn_height = 0.0;
|
||||
double _stn_speed = 0.0;
|
||||
double _stn_angle_limit = 0.0;
|
||||
double _stn_limit = 0.0;
|
||||
|
||||
bool _MPControl = false;
|
||||
bool _patrol = false;
|
||||
bool _stn_deg_true = false;
|
||||
};
|
||||
|
||||
#endif // FG_AIGROUNDVEHICLE_HXX
|
||||
|
|
Loading…
Reference in a new issue