1
0
Fork 0

Added better AI handling of replay - part of the new carrier handling in replays.

This commit is contained in:
Richard Harrison 2018-08-07 17:56:22 +02:00
parent 402a71100e
commit 6513dc1137
5 changed files with 63 additions and 41 deletions

View file

@ -125,6 +125,7 @@ FGAIBase::FGAIBase(object_type ot, bool enableHot) :
_parent(""), _parent(""),
props( NULL ), props( NULL ),
model_removed( fgGetNode("/ai/models/model-removed", true) ), model_removed( fgGetNode("/ai/models/model-removed", true) ),
replay_time(fgGetNode("sim/replay/time", true)),
manager( NULL ), manager( NULL ),
_installed(false), _installed(false),
_impact_lat(0), _impact_lat(0),
@ -264,6 +265,8 @@ void FGAIBase::readFromScenario(SGPropertyNode* scFileNode)
void FGAIBase::update(double dt) { void FGAIBase::update(double dt) {
if (replay_time->getDoubleValue() > 0)
return;
if (_otype == otStatic) if (_otype == otStatic)
return; return;

View file

@ -168,6 +168,7 @@ protected:
SGPropertyNode_ptr _selected_ac; SGPropertyNode_ptr _selected_ac;
SGPropertyNode_ptr props; SGPropertyNode_ptr props;
SGPropertyNode_ptr trigger_node; SGPropertyNode_ptr trigger_node;
SGPropertyNode_ptr replay_time;
SGPropertyNode_ptr model_removed; // where to report model removal SGPropertyNode_ptr model_removed; // where to report model removal
FGAIManager* manager; FGAIManager* manager;

View file

@ -35,7 +35,7 @@
#include "AICarrier.hxx" #include "AICarrier.hxx"
FGAICarrier::FGAICarrier() : FGAIShip(otCarrier) { FGAICarrier::FGAICarrier() : FGAIShip(otCarrier), deck_altitude(65.0065) {
} }
FGAICarrier::~FGAICarrier() { FGAICarrier::~FGAICarrier() {
@ -49,6 +49,7 @@ void FGAICarrier::readFromScenario(SGPropertyNode* scFileNode) {
setRadius(scFileNode->getDoubleValue("turn-radius-ft", 2000)); setRadius(scFileNode->getDoubleValue("turn-radius-ft", 2000));
setSign(scFileNode->getStringValue("pennant-number")); setSign(scFileNode->getStringValue("pennant-number"));
setDeckAltitude(scFileNode->getDoubleValue("deck-altitude"));
setWind_from_east(scFileNode->getDoubleValue("wind_from_east", 0)); setWind_from_east(scFileNode->getDoubleValue("wind_from_east", 0));
setWind_from_north(scFileNode->getDoubleValue("wind_from_north", 0)); setWind_from_north(scFileNode->getDoubleValue("wind_from_north", 0));
setTACANChannelID(scFileNode->getStringValue("TACAN-channel-ID", "029Y")); setTACANChannelID(scFileNode->getStringValue("TACAN-channel-ID", "029Y"));
@ -112,6 +113,11 @@ void FGAICarrier::setMinLong(double deg) {
min_long = fabs(deg); min_long = fabs(deg);
} }
void FGAICarrier::setDeckAltitude(const double altitude_feet) {
deck_altitude = altitude_feet;
}
void FGAICarrier::setSign(const string& s) { void FGAICarrier::setSign(const string& s) {
sign = s; sign = s;
} }
@ -247,6 +253,8 @@ void FGAICarrier::bind() {
props->untie("velocities/true-airspeed-kt"); props->untie("velocities/true-airspeed-kt");
props->getNode("position/deck-altitude-feet", true)->setDoubleValue(deck_altitude);
tie("controls/flols/source-lights", tie("controls/flols/source-lights",
SGRawValuePointer<int>(&source)); SGRawValuePointer<int>(&source));
tie("controls/flols/distance-m", tie("controls/flols/distance-m",

View file

@ -46,6 +46,7 @@ public:
virtual void readFromScenario(SGPropertyNode* scFileNode); virtual void readFromScenario(SGPropertyNode* scFileNode);
void setSign(const string& ); void setSign(const string& );
void setDeckAltitude(const double altitude_feet);
void setTACANChannelID(const string &); void setTACANChannelID(const string &);
virtual void bind(); virtual void bind();
@ -109,6 +110,7 @@ private:
double dist; // the distance of the eyepoint from the flols double dist; // the distance of the eyepoint from the flols
double angle; double angle;
double deck_altitude;
int source; // the flols light which is visible at the moment int source; // the flols light which is visible at the moment
bool in_to_wind; bool in_to_wind;

View file

@ -212,6 +212,9 @@ void FGAIShip::bind() {
} }
void FGAIShip::update(double dt) { void FGAIShip::update(double dt) {
if (replay_time->getDoubleValue() <= 0)
{
//SG_LOG(SG_AI, SG_ALERT, "updating Ship: " << _name <<hdg<<pitch<<roll); //SG_LOG(SG_AI, SG_ALERT, "updating Ship: " << _name <<hdg<<pitch<<roll);
// For computation of rotation speeds we just use finite differences here. // For computation of rotation speeds we just use finite differences here.
// That is perfectly valid since this thing is not driven by accelerations // That is perfectly valid since this thing is not driven by accelerations
@ -236,6 +239,7 @@ void FGAIShip::update(double dt) {
FGAIBase::update(dt); FGAIBase::update(dt);
Run(dt); Run(dt);
Transform(); Transform();
if (fp) if (fp)
setXTrackError(); setXTrackError();
@ -256,6 +260,10 @@ void FGAIShip::update(double dt) {
aip.setBodyAngularVelocity(dOrAngleAxis); aip.setBodyAngularVelocity(dOrAngleAxis);
} }
}
else
Transform();
} }
void FGAIShip::Run(double dt) { void FGAIShip::Run(double dt) {