aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra/timer_eob.cpp
diff options
context:
space:
mode:
authorathrxx2011-07-21 00:28:57 +0200
committerJohannes Schickel2011-12-26 16:18:13 +0100
commitc302b3e43b1d8cfe1eae669e01d3a0775d1f7b51 (patch)
tree0d718255a0cddb81f6bd0803f6f9479d6bc9722c /engines/kyra/timer_eob.cpp
parent9140fd8e91882250e23e2e4b44bf3088f3da827a (diff)
downloadscummvm-rg350-c302b3e43b1d8cfe1eae669e01d3a0775d1f7b51.tar.gz
scummvm-rg350-c302b3e43b1d8cfe1eae669e01d3a0775d1f7b51.tar.bz2
scummvm-rg350-c302b3e43b1d8cfe1eae669e01d3a0775d1f7b51.zip
KYRA: (EOB) - fix various bugs and implement some spells
Diffstat (limited to 'engines/kyra/timer_eob.cpp')
-rw-r--r--engines/kyra/timer_eob.cpp43
1 files changed, 26 insertions, 17 deletions
diff --git a/engines/kyra/timer_eob.cpp b/engines/kyra/timer_eob.cpp
index 00dc758a27..903dec2102 100644
--- a/engines/kyra/timer_eob.cpp
+++ b/engines/kyra/timer_eob.cpp
@@ -133,19 +133,21 @@ void EobCoreEngine::setCharEventTimer(int charIndex, uint32 countdown, int evnt,
_timer->setNextRun(timerId, ntime);
if (updateExistingTimer) {
- bool br = false;
+ bool updated = false;
int d = -1;
- for (int i = 0; i < 10 && br == false; i++) {
+ for (int i = 0; i < 10 && updated == false; i++) {
if (d == -1 && !c->timers[i])
d = i;
- if (!br && c->events[i] == evnt) {
+ if (!updated && c->events[i] == evnt) {
d = i;
- br = true;
+ updated = true;
}
}
+ assert(d != -1);
+
c->timers[d] = ntime;
c->events[d] = evnt;
} else {
@@ -179,7 +181,7 @@ void EobCoreEngine::setupCharacterTimers() {
uint32 nextTimer = 0xffffffff;
for (int ii = 0; ii < 10; ii++) {
- if (c->timers[ii] < nextTimer)
+ if (c->timers[ii] && c->timers[ii] < nextTimer)
nextTimer = c->timers[ii];
}
uint32 ctime = _system->getMillis();
@@ -193,21 +195,28 @@ void EobCoreEngine::setupCharacterTimers() {
}
}
-void EobCoreEngine::manualAdvanceTimer(int sysTimer, uint32 millis) {
- if (sysTimer != 2)
- return;
-
+void EobCoreEngine::advanceTimers(uint32 millis) {
uint32 ct = _system->getMillis();
for (int i = 0; i < 6; i++) {
+ EobCharacter *c = &_characters[i];
for (int ii = 0; ii < 10; ii++) {
- if (_characters[i].timers[ii]) {
- uint32 chrt = _characters[i].timers[ii] - ct;
- _characters[i].timers[ii] = chrt > millis ? chrt - millis : 1;
+ if (c->timers[ii] > ct) {
+ uint32 chrt = c->timers[ii] - ct;
+ c->timers[ii] = chrt > millis ? chrt - millis : ct;
}
}
}
- _timer->manualAdvance(millis);
+ setupCharacterTimers();
+
+ if (_scriptTimersMode & 2) {
+ for (int i = 0; i < _scriptTimersCount; i++) {
+ if (_scriptTimers[i].next > ct) {
+ uint32 chrt = _scriptTimers[i].next - ct;
+ _scriptTimers[i].next = chrt > millis ? chrt - millis : ct;
+ }
+ }
+ }
}
void EobCoreEngine::timerProcessCharacterExchange(int timerNum) {
@@ -314,7 +323,7 @@ void EobCoreEngine::timerSpecialCharacterUpdate(int timerNum) {
calcAndInflictCharacterDamage(charIndex, 0, 0, 5, 0x400, 5, 3);
setCharEventTimer(charIndex, 546, 8, 1);
} else {
- c->flags &= 0xfd;
+ c->flags &= ~2;
gui_drawCharPortraitWithStats(charIndex);
}
break;
@@ -329,7 +338,7 @@ void EobCoreEngine::timerSpecialCharacterUpdate(int timerNum) {
case 11:
if (c->disabledSlots & 4) {
- c->disabledSlots &= 0xfb;
+ c->disabledSlots &= ~4;
if (_openBookChar == charIndex && _updateFlags)
gui_drawSpellbook();
}
@@ -345,13 +354,13 @@ void EobCoreEngine::timerSpecialCharacterUpdate(int timerNum) {
}
}
- uint32 nextTimer = (uint32)(-1);
+ uint32 nextTimer = 0xffffffff;
for (int i = 0; i < 10; i++) {
if (c->timers[i] && c->timers[i] < nextTimer)
nextTimer = c->timers[i];
}
- if (nextTimer == (uint32)(-1))
+ if (nextTimer == 0xffffffff)
_timer->disable(timerNum);
else
_timer->setCountdown(timerNum, (nextTimer - ctime) / _tickLength);