diff --git a/ScStwLibraries/headers/scstwtimer.h b/ScStwLibraries/headers/scstwtimer.h index a8a94a0..af782b8 100644 --- a/ScStwLibraries/headers/scstwtimer.h +++ b/ScStwLibraries/headers/scstwtimer.h @@ -86,6 +86,7 @@ public: WON, /*!< Timer has won */ LOST, /*!< Timer has lost */ FAILED, /*!< A false start occured */ + WILDCARD, /*!< The opponent has done a false start */ CANCELLED, /*!< Timer was cancelled */ INCIDENT, /*!< There was a technical incident (most likely a disconnected extension) */ DISABLED /*!< Timer is disabled */ @@ -332,6 +333,15 @@ protected slots: */ void technicalIncident(); + /*! + * \brief Function to set the timer into WILDCARD state + * + * Only works when the timer is in STARTING state. + * + * \return false if not in STARTING state + */ + bool wildcard(); + signals: /*! diff --git a/ScStwLibraries/sources/scstwrace.cpp b/ScStwLibraries/sources/scstwrace.cpp index 2b13f53..a9adecc 100644 --- a/ScStwLibraries/sources/scstwrace.cpp +++ b/ScStwLibraries/sources/scstwrace.cpp @@ -248,10 +248,11 @@ int ScStwRace::handleFalseStart() { int returnCode = ScStw::Success; - // cancel all running timers + // set all running timers to wildcard foreach(ScStwTimer *timer, this->timers) { - if(timer->getState() != ScStwTimer::FAILED && !timer->cancel() && timer->getState() != ScStwTimer::DISABLED) - returnCode = ScStw::InternalErrorTimerOperationFailed; + if(timer->getState() != ScStwTimer::FAILED && timer->getState() != ScStwTimer::DISABLED) + if(!timer->wildcard()) + returnCode = ScStw::InternalErrorTimerOperationFailed; } this->setState(STOPPED); diff --git a/ScStwLibraries/sources/scstwtimer.cpp b/ScStwLibraries/sources/scstwtimer.cpp index efa429a..fdded29 100644 --- a/ScStwLibraries/sources/scstwtimer.cpp +++ b/ScStwLibraries/sources/scstwtimer.cpp @@ -71,6 +71,15 @@ void ScStwTimer::technicalIncident() { this->setState(INCIDENT); } +bool ScStwTimer::wildcard() { + if(this->state != STARTING) + return false; + + this->setState(WILDCARD); + + return true; +} + void ScStwTimer::handleClimberStart(double timeOfStart) { this->reactionTime = timeOfStart - this->startTime; qDebug() << "+ [INFO][TIMER] reaction time: " << this->reactionTime; @@ -109,7 +118,7 @@ bool ScStwTimer::stop(StopReason reason) { } bool ScStwTimer::stop(StopReason reason, double timeOfStop) { - if(this->state != STARTING && this->state != RUNNING && this->state != WAITING){ + if(this->state != STARTING && this->state != WILDCARD && this->state != RUNNING && this->state != WAITING){ return false; }