fixed technical incident not working in some cases
This commit is contained in:
parent
80aae3b22a
commit
94e5bc8e6f
2 changed files with 44 additions and 40 deletions
|
@ -153,33 +153,6 @@ ScStw::StatusCode ScStwRace::cancel() {
|
|||
return returnCode;
|
||||
}
|
||||
|
||||
void ScStwRace::technicalIncident() {
|
||||
|
||||
bool raceIsRunning = this->state == RUNNING;
|
||||
|
||||
qDebug() << "[ERROR][RACE] Got a technical incident, state is: " << this->state;
|
||||
|
||||
foreach(ScStwTimer *timer, this->timers){
|
||||
if(raceIsRunning && timer->getReadyState() == ScStwTimer::ExtensionBatteryNotFine)
|
||||
continue;
|
||||
else if(timer->getReadyState() == ScStwTimer::ExtensionIsNotConnected || timer->getReadyState() == ScStwTimer::ExtensionBatteryNotFine)
|
||||
timer->technicalIncident();
|
||||
else if(!raceIsRunning)
|
||||
timer->setState(ScStwTimer::CANCELLED);
|
||||
}
|
||||
|
||||
if(!raceIsRunning) {
|
||||
this->startWaitLoop->exit(LoopCancelExit);
|
||||
|
||||
if(this->state == STARTING) {
|
||||
this->soundPlayer->cancel();
|
||||
this->soundPlayer->play(ScStwSoundPlayer::FalseStart, this->getSoundVolume());
|
||||
}
|
||||
|
||||
this->setState(INCIDENT);
|
||||
}
|
||||
}
|
||||
|
||||
void ScStwRace::handleTimerReadyStateChange(ScStwTimer::ReadyState readyState) {
|
||||
|
||||
if(!this->competitionMode || this->state == IDLE || this->state == STOPPED || this->state == INCIDENT )
|
||||
|
@ -410,7 +383,8 @@ void ScStwRace::handleTimerStateChange(ScStwTimer::TimerState newState) {
|
|||
newState == ScStwTimer::WON ||
|
||||
newState == ScStwTimer::LOST ||
|
||||
newState == ScStwTimer::WILDCARD ||
|
||||
newState == ScStwTimer::FAILED
|
||||
newState == ScStwTimer::FAILED ||
|
||||
this->state == INCIDENT
|
||||
)
|
||||
return;
|
||||
|
||||
|
@ -418,6 +392,7 @@ void ScStwRace::handleTimerStateChange(ScStwTimer::TimerState newState) {
|
|||
|
||||
// check if the race is over
|
||||
bool raceIsOver = true;
|
||||
int incidentCount = 0;
|
||||
|
||||
foreach(ScStwTimer * timer, this->timers){
|
||||
if(timer->getState() < ScStwTimer::WAITING){
|
||||
|
@ -429,10 +404,14 @@ void ScStwRace::handleTimerStateChange(ScStwTimer::TimerState newState) {
|
|||
else if (timer->getState() == ScStwTimer::FAILING)
|
||||
this->handleFalseStart();
|
||||
else if (timer->getState() == ScStwTimer::INCIDENT)
|
||||
return;
|
||||
incidentCount ++;
|
||||
}
|
||||
|
||||
if(raceIsOver)
|
||||
if(incidentCount == this->timers.length()) {
|
||||
this->setState(INCIDENT);
|
||||
this->soundPlayer->play(ScStwSoundPlayer::FalseStart, this->getSoundVolume());
|
||||
}
|
||||
else if(raceIsOver)
|
||||
this->setState(STOPPED);
|
||||
}
|
||||
|
||||
|
@ -495,11 +474,11 @@ void ScStwRace::handleFalseStart() {
|
|||
|
||||
// find out which timer(s) have lost and which get a wildcard
|
||||
foreach(ScStwTimer * timer, this->timers) {
|
||||
qDebug() << "THIS TIMERS reaction time is: " << lowestReactionTime;
|
||||
qDebug() << "THIS TIMERS reaction time is: " << timer->getReactionTime();
|
||||
if(
|
||||
timer->getState() >= ScStwTimer::FAILING &&
|
||||
timer->getState() <= ScStwTimer::FAILED &&
|
||||
timer->getReactionTime() == lowestReactionTime
|
||||
timer->getReactionTime() <= lowestReactionTime
|
||||
) {
|
||||
// this is the timer with the lowest stopped time
|
||||
timer->setResult(ScStwTimer::FAILED);
|
||||
|
@ -510,9 +489,38 @@ void ScStwRace::handleFalseStart() {
|
|||
}
|
||||
}
|
||||
|
||||
this->setState(STOPPED);
|
||||
this->soundPlayer->cancel();
|
||||
this->soundPlayer->play(ScStwSoundPlayer::FalseStart, this->getSoundVolume());
|
||||
if(this->state != STOPPED) {
|
||||
this->setState(STOPPED);
|
||||
this->soundPlayer->cancel();
|
||||
this->soundPlayer->play(ScStwSoundPlayer::FalseStart, this->getSoundVolume());
|
||||
}
|
||||
}
|
||||
|
||||
void ScStwRace::technicalIncident() {
|
||||
|
||||
bool raceIsRunning = this->state == RUNNING;
|
||||
|
||||
qDebug() << "[ERROR][RACE] Got a technical incident, state is: " << this->state;
|
||||
|
||||
if(!raceIsRunning) {
|
||||
this->startWaitLoop->exit(LoopCancelExit);
|
||||
|
||||
if(this->state == STARTING) {
|
||||
this->soundPlayer->cancel();
|
||||
this->soundPlayer->play(ScStwSoundPlayer::FalseStart, this->getSoundVolume());
|
||||
}
|
||||
|
||||
this->setState(INCIDENT);
|
||||
}
|
||||
|
||||
foreach(ScStwTimer *timer, this->timers){
|
||||
if(raceIsRunning && timer->getReadyState() == ScStwTimer::ExtensionBatteryNotFine)
|
||||
continue;
|
||||
else if(timer->getReadyState() == ScStwTimer::ExtensionIsNotConnected || timer->getReadyState() == ScStwTimer::ExtensionBatteryNotFine)
|
||||
timer->technicalIncident();
|
||||
else if(!raceIsRunning)
|
||||
timer->setState(ScStwTimer::CANCELLED);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
|
|
|
@ -155,11 +155,7 @@ bool ScStwTimer::setResult(TimerState result) {
|
|||
break;
|
||||
case WILDCARD:
|
||||
case FAILED:
|
||||
if(this->state == STARTING || this->state == RUNNING || this->state == FAILED) {
|
||||
this->setState(WILDCARD);
|
||||
return true;
|
||||
}
|
||||
if(this->state == FAILING) {
|
||||
if(this->state == STARTING || this->state == RUNNING || this->state == FAILED || this->state == FAILING) {
|
||||
this->setState(result);
|
||||
return true;
|
||||
}
|
||||
|
|
Reference in a new issue