[Scummvm-cvs-logs] SF.net SVN: scummvm: [29908] scummvm/trunk/engines/agos
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Thu Dec 20 10:43:47 CET 2007
Revision: 29908
http://scummvm.svn.sourceforge.net/scummvm/?rev=29908&view=rev
Author: fingolfin
Date: 2007-12-20 01:43:46 -0800 (Thu, 20 Dec 2007)
Log Message:
-----------
Moved all time() calls in AGOS to a single new method AGOSEngine::getTime(); also replaced an evil function-static variable by a member variable (lastMinute)
Modified Paths:
--------------
scummvm/trunk/engines/agos/agos.cpp
scummvm/trunk/engines/agos/agos.h
scummvm/trunk/engines/agos/event.cpp
scummvm/trunk/engines/agos/input.cpp
scummvm/trunk/engines/agos/saveload.cpp
scummvm/trunk/engines/agos/script_e1.cpp
scummvm/trunk/engines/agos/script_e2.cpp
scummvm/trunk/engines/agos/script_ff.cpp
scummvm/trunk/engines/agos/script_pp.cpp
scummvm/trunk/engines/agos/script_ww.cpp
Modified: scummvm/trunk/engines/agos/agos.cpp
===================================================================
--- scummvm/trunk/engines/agos/agos.cpp 2007-12-19 17:26:48 UTC (rev 29907)
+++ scummvm/trunk/engines/agos/agos.cpp 2007-12-20 09:43:46 UTC (rev 29908)
@@ -275,6 +275,7 @@
_gameStoppedClock = 0;
_gameTime = 0;
_lastTime = 0;
+ _lastMinute = 0;
_firstTimeStruct = 0;
_pendingDeleteTimeEvent = 0;
@@ -1051,4 +1052,9 @@
_system->quit();
}
+uint32 AGOSEngine::getTime() const {
+ // FIXME: calling time() is not portable, use OSystem::getMillis instead
+ return (uint32)time(NULL);
+}
+
} // End of namespace AGOS
Modified: scummvm/trunk/engines/agos/agos.h
===================================================================
--- scummvm/trunk/engines/agos/agos.h 2007-12-19 17:26:48 UTC (rev 29907)
+++ scummvm/trunk/engines/agos/agos.h 2007-12-20 09:43:46 UTC (rev 29908)
@@ -362,9 +362,12 @@
uint _numTextBoxes;
- uint _lastTime;
+ uint32 getTime() const;
+
+ uint32 _lastMinute; // Used in processSpecialKeys()
+ uint32 _lastTime;
uint32 _clockStopped, _gameStoppedClock, _gameTime;
- time_t _timeStore;
+ uint32 _timeStore;
TimeEvent *_firstTimeStruct, *_pendingDeleteTimeEvent;
Modified: scummvm/trunk/engines/agos/event.cpp
===================================================================
--- scummvm/trunk/engines/agos/event.cpp 2007-12-19 17:26:48 UTC (rev 29907)
+++ scummvm/trunk/engines/agos/event.cpp 2007-12-20 09:43:46 UTC (rev 29908)
@@ -42,17 +42,15 @@
void AGOSEngine::addTimeEvent(uint16 timeout, uint16 subroutine_id) {
TimeEvent *te = (TimeEvent *)malloc(sizeof(TimeEvent)), *first, *last = NULL;
- time_t cur_time;
+ uint32 cur_time = getTime();
- time(&cur_time);
-
if (getGameId() == GID_DIMP) {
timeout /= 2;
}
te->time = cur_time + timeout - _gameStoppedClock;
if (getGameType() == GType_FF && _clockStopped)
- te->time -= ((uint32)time(NULL) - _clockStopped);
+ te->time -= (getTime() - _clockStopped);
te->subroutine_id = subroutine_id;
first = _firstTimeStruct;
@@ -135,17 +133,16 @@
}
bool AGOSEngine::kickoffTimeEvents() {
- time_t cur_time;
+ uint32 cur_time;
TimeEvent *te;
bool result = false;
if (getGameType() == GType_FF && _clockStopped)
return result;
- time(&cur_time);
- cur_time -= _gameStoppedClock;
+ cur_time = getTime() - _gameStoppedClock;
- while ((te = _firstTimeStruct) != NULL && te->time <= (uint32)cur_time) {
+ while ((te = _firstTimeStruct) != NULL && te->time <= cur_time) {
result = true;
_pendingDeleteTimeEvent = te;
invokeTimeEvent(te);
Modified: scummvm/trunk/engines/agos/input.cpp
===================================================================
--- scummvm/trunk/engines/agos/input.cpp 2007-12-19 17:26:48 UTC (rev 29907)
+++ scummvm/trunk/engines/agos/input.cpp 2007-12-20 09:43:46 UTC (rev 29908)
@@ -362,8 +362,6 @@
}
void AGOSEngine::hitarea_stuff_helper() {
- time_t cur_time;
-
if (getGameType() == GType_SIMON2 || getGameType() == GType_FF ||
getGameType() == GType_PP) {
if (_variableArray[254] || _variableArray[249]) {
@@ -383,8 +381,8 @@
}
}
- time(&cur_time);
- if ((uint) cur_time != _lastTime) {
+ uint32 cur_time = getTime();
+ if (cur_time != _lastTime) {
_lastTime = cur_time;
if (kickoffTimeEvents())
permitInput();
@@ -459,16 +457,12 @@
bool verbCode = false;
if (getGameId() == GID_DIMP) {
- static time_t lastMinute = 0;
- time_t t;
- time_t t1;
- t = time(&t);
- t1 = t / 30;
- if (!lastMinute)
- lastMinute = t1;
- if (t1 - lastMinute) {
- _variableArray[120] += (t1 - lastMinute);
- lastMinute = t1;
+ uint32 t1 = getTime() / 30;
+ if (!_lastMinute)
+ _lastMinute = t1;
+ if (t1 - _lastMinute) {
+ _variableArray[120] += (t1 - _lastMinute);
+ _lastMinute = t1;
}
}
Modified: scummvm/trunk/engines/agos/saveload.cpp
===================================================================
--- scummvm/trunk/engines/agos/saveload.cpp 2007-12-19 17:26:48 UTC (rev 29907)
+++ scummvm/trunk/engines/agos/saveload.cpp 2007-12-20 09:43:46 UTC (rev 29908)
@@ -250,7 +250,7 @@
numSaveGames = countSaveGames();
- time_t saveTime = time(NULL);
+ uint32 saveTime = getTime();
haltAnimation();
restart:
@@ -331,7 +331,7 @@
}
restartAnimation();
- _gameStoppedClock = time(NULL) - saveTime + _gameStoppedClock;
+ _gameStoppedClock = getTime() - saveTime + _gameStoppedClock;
}
void AGOSEngine_Elvira2::listSaveGames(char *dst) {
@@ -415,7 +415,7 @@
}
void AGOSEngine_Elvira2::userGame(bool load) {
- time_t saveTime;
+ uint32 saveTime;
int i, numSaveGames;
char *name;
bool b;
@@ -423,7 +423,7 @@
_saveOrLoad = load;
- saveTime = time(NULL);
+ saveTime = getTime();
if (getGameType() == GType_ELVIRA2)
haltAnimation();
@@ -504,7 +504,7 @@
get_out:;
disableFileBoxes();
- _gameStoppedClock = time(NULL) - saveTime + _gameStoppedClock;
+ _gameStoppedClock = getTime() - saveTime + _gameStoppedClock;
if (getGameType() == GType_ELVIRA2)
restartAnimation();
@@ -624,7 +624,7 @@
};
void AGOSEngine_Simon1::userGame(bool load) {
- time_t saveTime;
+ uint32 saveTime;
int i, numSaveGames, result;
WindowBlock *window;
char *name;
@@ -634,7 +634,7 @@
_saveOrLoad = load;
- saveTime = time(NULL);
+ saveTime = getTime();
numSaveGames = countSaveGames();
if (!load)
@@ -772,7 +772,7 @@
get_out:;
disableFileBoxes();
- _gameStoppedClock = time(NULL) - saveTime + _gameStoppedClock;
+ _gameStoppedClock = getTime() - saveTime + _gameStoppedClock;
}
int AGOSEngine_Simon1::userGameGetKey(bool *b, char *buf, uint maxChar) {
@@ -1316,7 +1316,7 @@
uint32 curTime = 0;
if (getGameType() != GType_SIMON1 && getGameType() != GType_SIMON2)
- curTime = time(NULL);
+ curTime = getTime();
_lockWord |= 0x100;
@@ -1347,7 +1347,7 @@
f->writeUint32BE(i);
if (getGameType() == GType_FF && _clockStopped)
- gsc += ((uint32)time(NULL) - _clockStopped);
+ gsc += (getTime() - _clockStopped);
for (te = _firstTimeStruct; te; te = te->next) {
f->writeUint32BE(te->time - curTime + gsc);
f->writeUint16BE(te->subroutine_id);
Modified: scummvm/trunk/engines/agos/script_e1.cpp
===================================================================
--- scummvm/trunk/engines/agos/script_e1.cpp 2007-12-19 17:26:48 UTC (rev 29907)
+++ scummvm/trunk/engines/agos/script_e1.cpp 2007-12-20 09:43:46 UTC (rev 29908)
@@ -825,16 +825,13 @@
void AGOSEngine_Elvira1::oe1_setTime() {
// 259: set time
- time(&_timeStore);
+ _timeStore = getTime();
}
void AGOSEngine_Elvira1::oe1_ifTime() {
// 260: if time
- time_t t;
-
uint a = getVarOrWord();
- time(&t);
- t -= a;
+ uint32 t = getTime() - a;
if (t >= _timeStore)
setScriptCondition(true);
else
@@ -897,7 +894,7 @@
WindowBlock *window = _windowArray[4];
const char *message1, *message2;
- time_t pauseTime = time(NULL);
+ uint32 pauseTime = getTime();
haltAnimation();
restart:
@@ -970,7 +967,7 @@
}
restartAnimation();
- _gameStoppedClock = time(NULL) - pauseTime + _gameStoppedClock;
+ _gameStoppedClock = getTime() - pauseTime + _gameStoppedClock;
}
void AGOSEngine_Elvira1::oe1_printPlayerHit() {
Modified: scummvm/trunk/engines/agos/script_e2.cpp
===================================================================
--- scummvm/trunk/engines/agos/script_e2.cpp 2007-12-19 17:26:48 UTC (rev 29907)
+++ scummvm/trunk/engines/agos/script_e2.cpp 2007-12-20 09:43:46 UTC (rev 29908)
@@ -378,7 +378,7 @@
// 135: pause game
HitArea *ha;
- time_t pauseTime = time(NULL);
+ uint32 pauseTime = getTime();
haltAnimation();
for (;;) {
@@ -400,7 +400,7 @@
}
restartAnimation();
- _gameStoppedClock = time(NULL) - pauseTime + _gameStoppedClock;
+ _gameStoppedClock = getTime() - pauseTime + _gameStoppedClock;
}
void AGOSEngine_Elvira2::oe2_setDoorOpen() {
Modified: scummvm/trunk/engines/agos/script_ff.cpp
===================================================================
--- scummvm/trunk/engines/agos/script_ff.cpp 2007-12-19 17:26:48 UTC (rev 29907)
+++ scummvm/trunk/engines/agos/script_ff.cpp 2007-12-20 09:43:46 UTC (rev 29908)
@@ -397,12 +397,8 @@
void AGOSEngine_Feeble::off_ifTime() {
// 124: if time
- time_t t;
-
uint a = getVarOrWord();
- time(&t);
- t -= _gameStoppedClock;
- t -= a;
+ uint32 t = getTime() - _gameStoppedClock - a;
if (t >= _timeStore)
setScriptCondition(true);
else
@@ -411,8 +407,7 @@
void AGOSEngine_Feeble::off_setTime() {
// 131
- time(&_timeStore);
- _timeStore -= _gameStoppedClock;
+ _timeStore = getTime() - _gameStoppedClock;
}
void AGOSEngine_Feeble::off_saveUserGame() {
@@ -612,13 +607,13 @@
void AGOSEngine_Feeble::off_stopClock() {
// 193: pause clock
- _clockStopped = time(NULL);
+ _clockStopped = getTime();
}
void AGOSEngine_Feeble::off_restartClock() {
// 194: resume clock
if (_clockStopped != 0)
- _gameStoppedClock += time(NULL) - _clockStopped;
+ _gameStoppedClock += getTime() - _clockStopped;
_clockStopped = 0;
}
Modified: scummvm/trunk/engines/agos/script_pp.cpp
===================================================================
--- scummvm/trunk/engines/agos/script_pp.cpp 2007-12-19 17:26:48 UTC (rev 29907)
+++ scummvm/trunk/engines/agos/script_pp.cpp 2007-12-20 09:43:46 UTC (rev 29908)
@@ -299,7 +299,7 @@
// 30
getNextWord();
if (_clockStopped != 0)
- _gameTime += time(NULL) - _clockStopped;
+ _gameTime += getTime() - _clockStopped;
_clockStopped = 0;
_system->setFeatureState(OSystem::kFeatureIconifyWindow, true);
}
@@ -379,7 +379,7 @@
void AGOSEngine_PuzzlePack::opp_saveUserGame() {
// 132: save game
if (_clockStopped != 0)
- _gameTime += time(NULL) - _clockStopped;
+ _gameTime += getTime() - _clockStopped;
_clockStopped = 0;
if (getGameId() == GID_DIMP) {
@@ -452,7 +452,7 @@
void AGOSEngine_PuzzlePack::opp_restartClock() {
// 194: resume clock
if (_clockStopped != 0)
- _gameTime += time(NULL) - _clockStopped;
+ _gameTime += getTime() - _clockStopped;
_clockStopped = 0;
}
Modified: scummvm/trunk/engines/agos/script_ww.cpp
===================================================================
--- scummvm/trunk/engines/agos/script_ww.cpp 2007-12-19 17:26:48 UTC (rev 29907)
+++ scummvm/trunk/engines/agos/script_ww.cpp 2007-12-20 09:43:46 UTC (rev 29908)
@@ -365,7 +365,7 @@
// 135: pause game
HitArea *ha;
- time_t pauseTime = time(NULL);
+ uint32 pauseTime = getTime();
haltAnimation();
for (;;) {
@@ -389,7 +389,7 @@
}
restartAnimation();
- _gameStoppedClock = time(NULL) - pauseTime + _gameStoppedClock;
+ _gameStoppedClock = getTime() - pauseTime + _gameStoppedClock;
}
void AGOSEngine_Waxworks::oww_boxMessage() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list