aboutsummaryrefslogtreecommitdiff
path: root/common/timer.cpp
diff options
context:
space:
mode:
authorMax Horn2003-10-17 11:11:01 +0000
committerMax Horn2003-10-17 11:11:01 +0000
commit7f5c5f0f8bff4e786c28da398589fb1fb5b386c0 (patch)
tree59fb340f5d23b957245414360118a6ee8fed30f0 /common/timer.cpp
parente00848384a55f78c44c882b5fdb04526ef08cbaa (diff)
downloadscummvm-rg350-7f5c5f0f8bff4e786c28da398589fb1fb5b386c0.tar.gz
scummvm-rg350-7f5c5f0f8bff4e786c28da398589fb1fb5b386c0.tar.bz2
scummvm-rg350-7f5c5f0f8bff4e786c28da398589fb1fb5b386c0.zip
COMI crashes because for some reasons we get a 0 timer interval. not sure how that is possible, but adding some asserts for now
svn-id: r10852
Diffstat (limited to 'common/timer.cpp')
-rw-r--r--common/timer.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/common/timer.cpp b/common/timer.cpp
index f7d7151c4f..ba5c82ef92 100644
--- a/common/timer.cpp
+++ b/common/timer.cpp
@@ -92,6 +92,7 @@ int Timer::handler(int t) {
if ((_timerSlots[l].procedure) && (_timerSlots[l].interval > 0)) {
_timerSlots[l].counter -= interval;
while (_timerSlots[l].counter <= 0) {
+ assert(_timerSlots[l].interval > 0);
_timerSlots[l].counter += _timerSlots[l].interval;
_timerSlots[l].procedure(_timerSlots[l].refCon);
}
@@ -102,32 +103,27 @@ int Timer::handler(int t) {
}
bool Timer::installProcedure(TimerProc procedure, int32 interval, void *refCon) {
+ assert(interval > 0);
Common::StackLock lock(_mutex);
- int32 l;
- bool found = false;
- for (l = 0; l < MAX_TIMERS; l++) {
+ for (int l = 0; l < MAX_TIMERS; l++) {
if (!_timerSlots[l].procedure) {
- _timerSlots[l].procedure = procedure;
_timerSlots[l].interval = interval;
_timerSlots[l].counter = interval;
_timerSlots[l].refCon = refCon;
- found = true;
- break;
+ _timerSlots[l].procedure = procedure;
+ return true;
}
}
- if (!found)
- warning("Couldn't find free timer slot!");
-
- return found;
+ warning("Couldn't find free timer slot!");
+ return false;
}
void Timer::releaseProcedure(TimerProc procedure) {
Common::StackLock lock(_mutex);
- int32 l;
- for (l = 0; l < MAX_TIMERS; l++) {
+ for (int l = 0; l < MAX_TIMERS; l++) {
if (_timerSlots[l].procedure == procedure) {
_timerSlots[l].procedure = 0;
_timerSlots[l].interval = 0;