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

View file

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

View file

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

View file

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

View file

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