1
0
Fork 0

Further progress towards AI/ATC dialog

This commit is contained in:
daveluff 2003-10-06 22:40:37 +00:00
parent 939b9b65f3
commit c89ea44131
4 changed files with 39 additions and 7 deletions

View file

@ -52,7 +52,7 @@ FGAIPlane::~FGAIPlane() {
void FGAIPlane::Update(double dt) {
if(_pending) {
if(tuned_station) {
if(tuned_station->FreqClear()) {
if(tuned_station->GetFreqClear()) {
_pending = false;
_transmit = true;
_transmitting = false;

View file

@ -36,7 +36,25 @@ FGATC::FGATC() {
FGATC::~FGATC() {
}
// Derived classes wishing to use the response counter should call this from their own Update(...).
void FGATC::Update(double dt) {
if(responseReqd) {
if(responseCounter >= responseTime) {
responseReqd = false;
respond = true;
} else {
responseCounter += dt;
}
}
}
void FGATC::SetResponseReqd(string rid) {
responseReqd = true;
respond = false; // TODO - this ignores the fact that more than one plane could call this before response
// Shouldn't happen with AI only, but user could confuse things??
responseID = rid;
responseCounter = 0.0;
responseTime = 2.5; // TODO - randomize this slightly.
}
void FGATC::AddPlane(string pid) {

View file

@ -99,13 +99,15 @@ ostream& operator << (ostream& os, atc_type atc);
class FGATC {
public:
public:
FGATC();
virtual ~FGATC();
// Run the internal calculations
virtual void Update(double dt);
// Derived classes should call this method from their own Update methods if they
// wish to use the response timer functionality.
void Update(double dt);
// Add plane to a stack
virtual void AddPlane(string pid);
@ -120,10 +122,12 @@ class FGATC {
virtual void SetNoDisplay();
// Returns true if OK to transmit on this frequency
inline bool FreqClear() { return freqClear; }
inline bool GetFreqClear() { return freqClear; }
// Indicate that the frequency is in use
inline void FreqInUse() { freqClear = false; }
// Under development!!
inline void SetFreqInUse() { freqClear = false; }
// Transmission to the ATC is finished and a response is required
void SetResponseReqd(string rid);
// The above 3 funcs under development!!
// The idea is that AI traffic or the user ATC dialog box calls FreqInUse() when they begin transmitting,
// and that the tower control sets freqClear back to true following a reply.
// AI traffic should check FreqClear() is true prior to transmitting.
@ -156,7 +160,7 @@ class FGATC {
inline const char* get_name() {return name.c_str();}
inline void set_name(const string nm) {name = nm;}
protected:
protected:
// Render a transmission
// Outputs the transmission either on screen or as audio depending on user preference
@ -182,6 +186,13 @@ class FGATC {
FGATCVoice* vPtr;
bool freqClear; // Flag to indicate if the frequency is clear of ongoing dialog
bool responseReqd; // Flag to indicate we should be responding to a request/report
double responseTime; // Time to take from end of request transmission to beginning of response
// The idea is that this will be slightly random.
double responseCounter; // counter to implement the above
string responseID; // ID of the plane to respond to
bool respond; // Flag to indicate now is the time to respond - ie set following the count down of the response timer.
// Derived classes only need monitor this flag, and use the response ID, as long as they call FGATC::Update(...)
};
inline istream&

View file

@ -736,6 +736,9 @@ void FGTower::Update(double dt) {
if(update_count >= update_count_max) {
update_count = 0;
}
// Call the base class update for the response time handling.
FGATC::Update(dt);
if(ident == "KEMT") {
// For AI debugging convienience - may be removed