diff options
author | Max Horn | 2003-10-17 11:11:01 +0000 |
---|---|---|
committer | Max Horn | 2003-10-17 11:11:01 +0000 |
commit | 7f5c5f0f8bff4e786c28da398589fb1fb5b386c0 (patch) | |
tree | 59fb340f5d23b957245414360118a6ee8fed30f0 | |
parent | e00848384a55f78c44c882b5fdb04526ef08cbaa (diff) | |
download | scummvm-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
-rw-r--r-- | common/timer.cpp | 20 |
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; |