Fixing issues with very small timeouts in network games.
This commit is contained in:
@@ -31,37 +31,40 @@ MyTimeoutLabel::~MyTimeoutLabel()
|
|||||||
|
|
||||||
void MyTimeoutLabel::startTimeOutAnimation(int secs, bool beep) {
|
void MyTimeoutLabel::startTimeOutAnimation(int secs, bool beep) {
|
||||||
|
|
||||||
isBeepPlayed = FALSE;
|
if (secs >= 4) // smaller timeouts may lead to errors/endless loops below
|
||||||
isBeep = beep;
|
{
|
||||||
|
isBeepPlayed = FALSE;
|
||||||
|
isBeep = beep;
|
||||||
|
|
||||||
timeOutValue = secs;
|
timeOutValue = secs;
|
||||||
timeOutFrame = 1;
|
timeOutFrame = 1;
|
||||||
timeOutAnimationWidth = 52;
|
timeOutAnimationWidth = 52;
|
||||||
|
|
||||||
int preTimerIntervall = ((timeOutValue-3) * 1000)/timeOutAnimationWidth;
|
|
||||||
|
|
||||||
timerIntervall = preTimerIntervall;
|
|
||||||
|
|
||||||
//save gfx ressources and never play more the 10 pps
|
int preTimerIntervall = ((timeOutValue-3) * 1000)/timeOutAnimationWidth;
|
||||||
while(timerIntervall < 100) {
|
|
||||||
if(secs <= 9 && secs >= 6) {
|
timerIntervall = preTimerIntervall;
|
||||||
//fix inaccuracies caused by integer division
|
|
||||||
timerIntervall = timerIntervall + preTimerIntervall + 5;
|
//save gfx ressources and never play more the 10 pps
|
||||||
}
|
while(timerIntervall < 100) {
|
||||||
else {
|
if(secs <= 9 && secs >= 6) {
|
||||||
timerIntervall = timerIntervall + preTimerIntervall;
|
//fix inaccuracies caused by integer division
|
||||||
|
timerIntervall = timerIntervall + preTimerIntervall + 5;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
timerIntervall = timerIntervall + preTimerIntervall;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
waitFrames = 3000/timerIntervall;
|
||||||
|
|
||||||
|
//start the real timer
|
||||||
|
realTimer.reset();
|
||||||
|
realTimer.start();
|
||||||
|
|
||||||
|
// std::cout << timerIntervall << endl;
|
||||||
|
timeOutAnimation = TRUE;
|
||||||
|
timeOutAnimationTimer->start(timerIntervall);
|
||||||
}
|
}
|
||||||
|
|
||||||
waitFrames = 3000/timerIntervall;
|
|
||||||
|
|
||||||
//start the real timer
|
|
||||||
realTimer.reset();
|
|
||||||
realTimer.start();
|
|
||||||
|
|
||||||
// std::cout << timerIntervall << endl;
|
|
||||||
timeOutAnimation = TRUE;
|
|
||||||
timeOutAnimationTimer->start(timerIntervall);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyTimeoutLabel::startTimeOutAnimationNow() {
|
void MyTimeoutLabel::startTimeOutAnimationNow() {
|
||||||
|
|||||||
Reference in New Issue
Block a user