1
0
Fork 0

Clean-up, part III.

Consistent white-spacing only. Also move all dead code to bottom section
(to be removed later).
This commit is contained in:
ThorstenB 2012-05-13 00:11:20 +02:00
parent a2922e2e23
commit 91198ebc8e

View file

@ -41,8 +41,10 @@ FGATC::FGATC() :
_voice(true),
_playing(false),
_sgr(NULL),
_type(INVALID),
_display(false)
#ifdef OLD_ATC_MGR
freqClear(true),
,freqClear(true),
receiving(false),
respond(false),
responseID(""),
@ -51,11 +53,7 @@ FGATC::FGATC() :
responseReqd(false),
// Transmission timing stuff
pending_transmission(""),
#endif
_type(INVALID),
_display(false)
#ifdef OLD_ATC_MGR
,_timeout(0),
_timeout(0),
_pending(false),
_transmit(false),
_transmitting(false),
@ -76,6 +74,7 @@ FGATC::FGATC() :
FGATC::~FGATC() {
}
#ifndef OLD_ATC_MGR
// Derived classes wishing to use the response counter should
// call this from their own Update(...).
void FGATC::Update(double dt) {
@ -91,105 +90,6 @@ void FGATC::Update(double dt) {
_sgr->suspend();
}
#endif
#ifdef OLD_ATC_MGR
if(runResponseCounter) {
//cout << responseCounter << '\t' << responseTime << '\n';
if(responseCounter >= responseTime) {
runResponseCounter = false;
respond = true;
//cout << "RESPOND\n";
} else {
responseCounter += dt;
}
}
if(_runReleaseCounter) {
if(_releaseCounter >= _releaseTime) {
freqClear = true;
_runReleaseCounter = false;
} else {
_releaseCounter += dt;
}
}
// Transmission stuff cribbed from AIPlane.cxx
if(_pending) {
if(GetFreqClear()) {
//cout << "TUNED STATION FREQ CLEAR\n";
SetFreqInUse();
_pending = false;
_transmit = true;
_transmitting = false;
} else {
if(_timeout > 0.0) { // allows count down to be avoided by initially setting it to zero
_timeout -= dt;
if(_timeout <= 0.0) {
_timeout = 0.0;
_pending = false;
// timed out - don't render.
}
}
}
}
if(_transmit) {
_counter = 0.0;
_max_count = 5.0; // FIXME - hardwired length of message - need to calculate it!
//cout << "Transmission = " << pending_transmission << '\n';
if(_display) {
//Render(pending_transmission, ident, false);
Render(pending_transmission);
}
_transmit = false;
_transmitting = true;
} else if(_transmitting) {
if(_counter >= _max_count) {
//NoRender(plane.callsign); commented out since at the moment NoRender is designed just to stop repeating messages,
// and this will be primarily used on single messages.
_transmitting = false;
//if(tuned_station) tuned_station->NotifyTransmissionFinished(plane.callsign);
// TODO - need to let the plane the transmission is aimed at that it's finished.
// However, for now we'll just release the frequency since if we don't it all goes pear-shaped
_releaseCounter = 0.0;
_releaseTime = 0.9;
_runReleaseCounter = true;
}
_counter += dt;
}
#endif
}
#ifdef OLD_ATC_MGR
void FGATC::ReceiveUserCallback(int code) {
SG_LOG(SG_ATC, SG_WARN, "WARNING - whichever ATC class was intended to receive callback code " << code << " didn't get it!!!");
}
void FGATC::SetResponseReqd(const string& rid) {
receiving = false;
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;
runResponseCounter = true;
responseCounter = 0.0;
responseTime = 1.8; // TODO - randomize this slightly.
}
void FGATC::NotifyTransmissionFinished(const string& rid) {
//cout << "Transmission finished, callsign = " << rid << '\n';
receiving = false;
responseID = rid;
if(responseReqd) {
runResponseCounter = true;
responseCounter = 0.0;
responseTime = 1.2; // TODO - randomize this slightly, and allow it to be dependent on the transmission and how busy the ATC is.
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??
} else {
freqClear = true;
}
}
#endif
@ -316,6 +216,119 @@ void FGATC::NoRender(const string& refname) {
}
#ifdef OLD_ATC_MGR
// Derived classes wishing to use the response counter should
// call this from their own Update(...).
void FGATC::Update(double dt) {
#ifdef ENABLE_AUDIO_SUPPORT
bool active = _atc_external->getBoolValue() ||
_internal->getBoolValue();
if ( active && _enabled->getBoolValue() ) {
_sgr->set_volume( _masterVolume->getFloatValue() );
_sgr->resume(); // no-op if already in resumed state
} else {
_sgr->suspend();
}
#endif
if(runResponseCounter) {
//cout << responseCounter << '\t' << responseTime << '\n';
if(responseCounter >= responseTime) {
runResponseCounter = false;
respond = true;
//cout << "RESPOND\n";
} else {
responseCounter += dt;
}
}
if(_runReleaseCounter) {
if(_releaseCounter >= _releaseTime) {
freqClear = true;
_runReleaseCounter = false;
} else {
_releaseCounter += dt;
}
}
// Transmission stuff cribbed from AIPlane.cxx
if(_pending) {
if(GetFreqClear()) {
//cout << "TUNED STATION FREQ CLEAR\n";
SetFreqInUse();
_pending = false;
_transmit = true;
_transmitting = false;
} else {
if(_timeout > 0.0) { // allows count down to be avoided by initially setting it to zero
_timeout -= dt;
if(_timeout <= 0.0) {
_timeout = 0.0;
_pending = false;
// timed out - don't render.
}
}
}
}
if(_transmit) {
_counter = 0.0;
_max_count = 5.0; // FIXME - hardwired length of message - need to calculate it!
//cout << "Transmission = " << pending_transmission << '\n';
if(_display) {
//Render(pending_transmission, ident, false);
Render(pending_transmission);
}
_transmit = false;
_transmitting = true;
} else if(_transmitting) {
if(_counter >= _max_count) {
//NoRender(plane.callsign); commented out since at the moment NoRender is designed just to stop repeating messages,
// and this will be primarily used on single messages.
_transmitting = false;
//if(tuned_station) tuned_station->NotifyTransmissionFinished(plane.callsign);
// TODO - need to let the plane the transmission is aimed at that it's finished.
// However, for now we'll just release the frequency since if we don't it all goes pear-shaped
_releaseCounter = 0.0;
_releaseTime = 0.9;
_runReleaseCounter = true;
}
_counter += dt;
}
}
void FGATC::ReceiveUserCallback(int code) {
SG_LOG(SG_ATC, SG_WARN, "WARNING - whichever ATC class was intended to receive callback code " << code << " didn't get it!!!");
}
void FGATC::SetResponseReqd(const string& rid) {
receiving = false;
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;
runResponseCounter = true;
responseCounter = 0.0;
responseTime = 1.8; // TODO - randomize this slightly.
}
void FGATC::NotifyTransmissionFinished(const string& rid) {
//cout << "Transmission finished, callsign = " << rid << '\n';
receiving = false;
responseID = rid;
if(responseReqd) {
runResponseCounter = true;
responseCounter = 0.0;
responseTime = 1.2; // TODO - randomize this slightly, and allow it to be dependent on the transmission and how busy the ATC is.
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??
} else {
freqClear = true;
}
}
// Generate the text of a message from its parameters and the current context.
string FGATC::GenText(const string& m, int c) {
return("");