WINTERMUTE: Split the timers from BaseGame into a separate class.

This commit is contained in:
Einar Johan Trøan Sømåen 2013-04-18 12:10:40 +02:00
parent 7ee757366b
commit 8f25b651e8
23 changed files with 196 additions and 62 deletions

View file

@ -752,7 +752,7 @@ bool AdActor::update() {
_tempSprite2 = _sentence->_currentSprite; _tempSprite2 = _sentence->_currentSprite;
} }
bool timeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); bool timeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->getTimer()->getTime() - _sentence->_startTime);
if (_tempSprite2 == nullptr || _tempSprite2->isFinished() || (/*_tempSprite2->_looping &&*/ timeIsUp)) { if (_tempSprite2 == nullptr || _tempSprite2->isFinished() || (/*_tempSprite2->_looping &&*/ timeIsUp)) {
if (timeIsUp) { if (timeIsUp) {
_sentence->finish(); _sentence->finish();

View file

@ -627,7 +627,7 @@ bool AdEntity::update() {
_tempSprite2 = _sentence->_currentSprite; _tempSprite2 = _sentence->_currentSprite;
} }
bool timeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); bool timeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->getTimer()->getTime() - _sentence->_startTime);
if (_tempSprite2 == nullptr || _tempSprite2->isFinished() || (/*_tempSprite2->_looping &&*/ timeIsUp)) { if (_tempSprite2 == nullptr || _tempSprite2->isFinished() || (/*_tempSprite2->_looping &&*/ timeIsUp)) {
if (timeIsUp) { if (timeIsUp) {
_sentence->finish(); _sentence->finish();

View file

@ -378,7 +378,7 @@ bool AdItem::update() {
_tempSprite2 = _sentence->_currentSprite; _tempSprite2 = _sentence->_currentSprite;
} }
bool timeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); bool timeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->getTimer()->getTime() - _sentence->_startTime);
if (_tempSprite2 == nullptr || _tempSprite2->isFinished() || (/*_tempSprite2->_looping &&*/ timeIsUp)) { if (_tempSprite2 == nullptr || _tempSprite2->isFinished() || (/*_tempSprite2->_looping &&*/ timeIsUp)) {
if (timeIsUp) { if (timeIsUp) {
_sentence->finish(); _sentence->finish();

View file

@ -904,7 +904,7 @@ void AdObject::talk(const char *text, const char *sound, uint32 duration, const
_sentence->setStances(stances); _sentence->setStances(stances);
_sentence->_duration = duration; _sentence->_duration = duration;
_sentence->_align = Align; _sentence->_align = Align;
_sentence->_startTime = _gameRef->_timer; _sentence->_startTime = _gameRef->getTimer()->getTime();
_sentence->_currentStance = -1; _sentence->_currentStance = -1;
_sentence->_font = _font == nullptr ? _gameRef->getSystemFont() : _font; _sentence->_font = _font == nullptr ? _gameRef->getSystemFont() : _font;
_sentence->_freezable = _freezable; _sentence->_freezable = _freezable;

View file

@ -931,13 +931,13 @@ bool AdScene::traverseNodes(bool doUpdate) {
if (_autoScroll) { if (_autoScroll) {
// adjust horizontal scroll // adjust horizontal scroll
if (_gameRef->_timer - _lastTimeH >= _scrollTimeH) { if (_gameRef->getTimer()->getTime() - _lastTimeH >= _scrollTimeH) {
int timesMissed = (_gameRef->_timer - _lastTimeH) / _scrollTimeH; int timesMissed = (_gameRef->getTimer()->getTime() - _lastTimeH) / _scrollTimeH;
// Cap the amount of catch-up to avoid jittery characters. // Cap the amount of catch-up to avoid jittery characters.
if (timesMissed > 2) { if (timesMissed > 2) {
timesMissed = 2; timesMissed = 2;
} }
_lastTimeH = _gameRef->_timer; _lastTimeH = _gameRef->getTimer()->getTime();
if (_offsetLeft < _targetOffsetLeft) { if (_offsetLeft < _targetOffsetLeft) {
_offsetLeft += _scrollPixelsH * timesMissed; _offsetLeft += _scrollPixelsH * timesMissed;
_offsetLeft = MIN(_offsetLeft, _targetOffsetLeft); _offsetLeft = MIN(_offsetLeft, _targetOffsetLeft);
@ -948,13 +948,13 @@ bool AdScene::traverseNodes(bool doUpdate) {
} }
// adjust vertical scroll // adjust vertical scroll
if (_gameRef->_timer - _lastTimeV >= _scrollTimeV) { if (_gameRef->getTimer()->getTime() - _lastTimeV >= _scrollTimeV) {
int timesMissed = (_gameRef->_timer - _lastTimeV) / _scrollTimeV; int timesMissed = (_gameRef->getTimer()->getTime() - _lastTimeV) / _scrollTimeV;
// Cap the amount of catch-up to avoid jittery characters. // Cap the amount of catch-up to avoid jittery characters.
if (timesMissed > 2) { if (timesMissed > 2) {
timesMissed = 2; timesMissed = 2;
} }
_lastTimeV = _gameRef->_timer; _lastTimeV = _gameRef->getTimer()->getTime();
if (_offsetTop < _targetOffsetTop) { if (_offsetTop < _targetOffsetTop) {
_offsetTop += _scrollPixelsV * timesMissed; _offsetTop += _scrollPixelsV * timesMissed;
_offsetTop = MIN(_offsetTop, _targetOffsetTop); _offsetTop = MIN(_offsetTop, _targetOffsetTop);

View file

@ -314,9 +314,9 @@ bool AdSentence::update(TDirection dir) {
/* /*
if (_sound) CurrentTime = _sound->GetPositionTime(); if (_sound) CurrentTime = _sound->GetPositionTime();
else CurrentTime = _gameRef->_timer - _startTime; else CurrentTime = _gameRef->getTimer()->getTime() - _startTime;
*/ */
currentTime = _gameRef->_timer - _startTime; currentTime = _gameRef->getTimer()->getTime() - _startTime;
bool talkNodeFound = false; bool talkNodeFound = false;
for (uint32 i = 0; i < _talkDef->_nodes.size(); i++) { for (uint32 i = 0; i < _talkDef->_nodes.size(); i++) {
@ -355,7 +355,7 @@ bool AdSentence::update(TDirection dir) {
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
bool AdSentence::canSkip() { bool AdSentence::canSkip() {
// prevent accidental sentence skipping (TODO make configurable) // prevent accidental sentence skipping (TODO make configurable)
return (_gameRef->_timer - _startTime) > 300; return (_gameRef->getTimer()->getTime() - _startTime) > 300;
} }
} // end of namespace Wintermute } // end of namespace Wintermute

View file

@ -106,4 +106,20 @@ BaseRenderer *BaseEngine::getRenderer() {
} }
} }
const Timer *BaseEngine::getTimer() {
if (instance()._gameRef) {
return instance()._gameRef->getTimer();
} else {
return nullptr;
}
}
const Timer *BaseEngine::getLiveTimer() {
if (instance()._gameRef) {
return instance()._gameRef->getLiveTimer();
} else {
return nullptr;
}
}
} // end of namespace Wintermute } // end of namespace Wintermute

View file

@ -42,6 +42,7 @@ class BaseGame;
class BaseSoundMgr; class BaseSoundMgr;
class BaseRenderer; class BaseRenderer;
class SystemClassRegistry; class SystemClassRegistry;
class Timer;
class BaseEngine : public Common::Singleton<Wintermute::BaseEngine> { class BaseEngine : public Common::Singleton<Wintermute::BaseEngine> {
void init(Common::Language lang); void init(Common::Language lang);
BaseFileManager *_fileManager; BaseFileManager *_fileManager;
@ -64,6 +65,8 @@ public:
BaseFileManager *getFileManager() { return _fileManager; } BaseFileManager *getFileManager() { return _fileManager; }
BaseSoundMgr *getSoundMgr(); BaseSoundMgr *getSoundMgr();
BaseRenderer *getRenderer(); BaseRenderer *getRenderer();
static const Timer *getTimer();
static const Timer *getLiveTimer();
static void LOG(bool res, const char *fmt, ...); static void LOG(bool res, const char *fmt, ...);
const char *getGameId() { return _gameId.c_str(); } const char *getGameId() { return _gameId.c_str(); }
}; };

View file

@ -71,7 +71,7 @@ bool BaseFader::update() {
if (_system) { if (_system) {
time = g_system->getMillis() - _startTime; time = g_system->getMillis() - _startTime;
} else { } else {
time = _gameRef->_timer - _startTime; time = _gameRef->getTimer()->getTime() - _startTime;
} }
if (time >= _duration) { if (time >= _duration) {
@ -129,7 +129,7 @@ bool BaseFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) {
if (_system) { if (_system) {
_startTime = g_system->getMillis(); _startTime = g_system->getMillis();
} else { } else {
_startTime = _gameRef->_timer; _startTime = _gameRef->getTimer()->getTime();
} }
return STATUS_OK; return STATUS_OK;
@ -155,7 +155,7 @@ bool BaseFader::fadeOut(uint32 targetColor, uint32 duration, bool system) {
if (_system) { if (_system) {
_startTime = g_system->getMillis(); _startTime = g_system->getMillis();
} else { } else {
_startTime = _gameRef->_timer; _startTime = _gameRef->getTimer()->getTime();
} }

View file

@ -81,7 +81,7 @@ IMPLEMENT_PERSISTENT(BaseGame, true)
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gameId) { BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gameId), _timerNormal(), _timerLive() {
_shuttingDown = false; _shuttingDown = false;
_state = GAME_RUNNING; _state = GAME_RUNNING;
@ -122,14 +122,6 @@ BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gam
_subtitles = true; _subtitles = true;
_videoSubtitles = true; _videoSubtitles = true;
_timer = 0;
_timerDelta = 0;
_timerLast = 0;
_liveTimer = 0;
_liveTimerDelta = 0;
_liveTimerLast = 0;
_sequence = 0; _sequence = 0;
_mousePos.x = _mousePos.y = 0; _mousePos.x = _mousePos.y = 0;
@ -561,16 +553,12 @@ bool BaseGame::initLoop() {
_lastTime = _currentTime; _lastTime = _currentTime;
_fpsTime += _deltaTime; _fpsTime += _deltaTime;
_liveTimerDelta = _liveTimer - _liveTimerLast; _timerLive.updateTime(_deltaTime, 1000);
_liveTimerLast = _liveTimer;
_liveTimer += MIN((uint32)1000, _deltaTime);
if (_state != GAME_FROZEN) { if (_state != GAME_FROZEN) {
_timerDelta = _timer - _timerLast; _timerNormal.updateTime(_deltaTime, 1000);
_timerLast = _timer;
_timer += MIN((uint32)1000, _deltaTime);
} else { } else {
_timerDelta = 0; _timerNormal.setTimeDelta(0);
} }
_framesRendered++; _framesRendered++;
@ -1985,7 +1973,7 @@ ScValue *BaseGame::scGetProperty(const Common::String &name) {
// CurrentTime (RO) // CurrentTime (RO)
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
else if (name == "CurrentTime") { else if (name == "CurrentTime") {
_scValue->setInt((int)_timer); _scValue->setInt((int)getTimer()->getTime());
return _scValue; return _scValue;
} }
@ -3104,13 +3092,8 @@ bool BaseGame::persist(BasePersistenceManager *persistMgr) {
persistMgr->transfer(TMEMBER(_videoFont)); persistMgr->transfer(TMEMBER(_videoFont));
persistMgr->transfer(TMEMBER(_videoSubtitles)); persistMgr->transfer(TMEMBER(_videoSubtitles));
persistMgr->transfer(TMEMBER(_timer)); _timerNormal.persist(persistMgr);
persistMgr->transfer(TMEMBER(_timerDelta)); _timerLive.persist(persistMgr);
persistMgr->transfer(TMEMBER(_timerLast));
persistMgr->transfer(TMEMBER(_liveTimer));
persistMgr->transfer(TMEMBER(_liveTimerDelta));
persistMgr->transfer(TMEMBER(_liveTimerLast));
_renderer->persistSaveLoadImages(persistMgr); _renderer->persistSaveLoadImages(persistMgr);
@ -3777,7 +3760,7 @@ bool BaseGame::displayDebugInfo() {
_systemFont->drawText((byte *)str, 0, 70, _renderer->getWidth(), TAL_RIGHT); _systemFont->drawText((byte *)str, 0, 70, _renderer->getWidth(), TAL_RIGHT);
sprintf(str, "Timer: %d", _timer); sprintf(str, "Timer: %d", getTimer()->getTime());
_gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->getWidth(), TAL_RIGHT); _gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->getWidth(), TAL_RIGHT);
if (_activeObject != nullptr) { if (_activeObject != nullptr) {

View file

@ -30,6 +30,7 @@
#define WINTERMUTE_BASE_GAME_H #define WINTERMUTE_BASE_GAME_H
#include "engines/wintermute/base/base_object.h" #include "engines/wintermute/base/base_object.h"
#include "engines/wintermute/base/timer.h"
#include "engines/wintermute/persistent.h" #include "engines/wintermute/persistent.h"
#include "engines/wintermute/coll_templ.h" #include "engines/wintermute/coll_templ.h"
#include "engines/wintermute/math/rect32.h" #include "engines/wintermute/math/rect32.h"
@ -214,14 +215,13 @@ public:
TGameState _state; TGameState _state;
TGameState _origState; TGameState _origState;
bool _origInteractive; bool _origInteractive;
uint32 _timer;
uint32 _timerDelta;
uint32 _timerLast;
uint32 _liveTimer;
uint32 _liveTimerDelta;
uint32 _liveTimerLast;
const Timer *getTimer() const { return &_timerNormal; }
const Timer *getLiveTimer() const { return &_timerLive; }
private:
Timer _timerNormal;
Timer _timerLive;
public:
BaseObject *_capturedObject; BaseObject *_capturedObject;
Point32 _mousePos; Point32 _mousePos;
bool validObject(BaseObject *object); bool validObject(BaseObject *object);

View file

@ -177,7 +177,7 @@ bool BaseGameMusic::updateMusicCrossfade() {
_music[_musicCrossfadeChannel2]->play(); _music[_musicCrossfadeChannel2]->play();
} }
uint32 currentTime = _gameRef->_liveTimer - _musicCrossfadeStartTime; uint32 currentTime = _gameRef->getLiveTimer()->getTime() - _musicCrossfadeStartTime;
if (currentTime >= _musicCrossfadeLength) { if (currentTime >= _musicCrossfadeLength) {
_musicCrossfadeRunning = false; _musicCrossfadeRunning = false;
@ -469,7 +469,7 @@ bool BaseGameMusic::scCallMethod(ScScript *script, ScStack *stack, ScStack *this
return STATUS_OK; return STATUS_OK;
} }
_musicCrossfadeStartTime = _gameRef->_liveTimer; _musicCrossfadeStartTime = _gameRef->getLiveTimer()->getTime();
_musicCrossfadeChannel1 = channel1; _musicCrossfadeChannel1 = channel1;
_musicCrossfadeChannel2 = channel2; _musicCrossfadeChannel2 = channel2;
_musicCrossfadeLength = fadeLength; _musicCrossfadeLength = fadeLength;

View file

@ -27,8 +27,8 @@
*/ */
#include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_parser.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/base/base_game.h"
#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/platform_osystem.h"
#include "common/str.h" #include "common/str.h"
#include "common/util.h" #include "common/util.h"

View file

@ -365,9 +365,9 @@ bool BaseSprite::getCurrentFrame(float zoomX, float zoomY) {
uint32 timer; uint32 timer;
if (_owner && _owner->_freezable) { if (_owner && _owner->_freezable) {
timer = _gameRef->_timer; timer = _gameRef->getTimer()->getTime();
} else { } else {
timer = _gameRef->_liveTimer; timer = _gameRef->getLiveTimer()->getTime();
} }
int lastFrame = _currentFrame; int lastFrame = _currentFrame;

View file

@ -66,15 +66,15 @@ bool BaseSurfaceStorage::cleanup(bool warn) {
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
bool BaseSurfaceStorage::initLoop() { bool BaseSurfaceStorage::initLoop() {
if (_gameRef->_smartCache && _gameRef->_liveTimer - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) { if (_gameRef->_smartCache && _gameRef->getLiveTimer()->getTime() - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) {
_lastCleanupTime = _gameRef->_liveTimer; _lastCleanupTime = _gameRef->getLiveTimer()->getTime();
sortSurfaces(); sortSurfaces();
for (uint32 i = 0; i < _surfaces.size(); i++) { for (uint32 i = 0; i < _surfaces.size(); i++) {
if (_surfaces[i]->_lifeTime <= 0) { if (_surfaces[i]->_lifeTime <= 0) {
break; break;
} }
if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && (int)(_gameRef->_liveTimer - _surfaces[i]->_lastUsedTime) >= _surfaces[i]->_lifeTime) { if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && (int)(_gameRef->getLiveTimer()->getTime() - _surfaces[i]->_lastUsedTime) >= _surfaces[i]->_lifeTime) {
//_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename);
_surfaces[i]->invalidate(); _surfaces[i]->invalidate();
} }

View file

@ -129,7 +129,7 @@ bool BaseSurface::invalidate() {
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
bool BaseSurface::prepareToDraw() { bool BaseSurface::prepareToDraw() {
_lastUsedTime = _gameRef->_liveTimer; _lastUsedTime = _gameRef->getLiveTimer()->getTime();
if (!_valid) { if (!_valid) {
//_gameRef->LOG(0, "Reviving: %s", _filename); //_gameRef->LOG(0, "Reviving: %s", _filename);

View file

@ -252,7 +252,7 @@ bool PartEmitter::update() {
if (!_running) { if (!_running) {
return STATUS_OK; return STATUS_OK;
} else { } else {
return updateInternal(_gameRef->_timer, _gameRef->_timerDelta); return updateInternal(_gameRef->getTimer()->getTime(), _gameRef->getTimer()->getTimeDelta());
} }
} }
@ -353,7 +353,7 @@ bool PartEmitter::start() {
if (_overheadTime > 0) { if (_overheadTime > 0) {
uint32 delta = 500; uint32 delta = 500;
int steps = _overheadTime / delta; int steps = _overheadTime / delta;
uint32 currentTime = _gameRef->_timer - _overheadTime; uint32 currentTime = _gameRef->getTimer()->getTime() - _overheadTime;
for (int i = 0; i < steps; i++) { for (int i = 0; i < steps; i++) {
updateInternal(currentTime, delta); updateInternal(currentTime, delta);

View file

@ -1194,7 +1194,7 @@ bool ScScript::sleep(uint32 duration) {
_waitTime = g_system->getMillis() + duration; _waitTime = g_system->getMillis() + duration;
_waitFrozen = true; _waitFrozen = true;
} else { } else {
_waitTime = _gameRef->_timer + duration; _waitTime = _gameRef->getTimer()->getTime() + duration;
_waitFrozen = false; _waitFrozen = false;
} }
return STATUS_OK; return STATUS_OK;

View file

@ -285,7 +285,7 @@ bool ScEngine::tick() {
_scripts[i]->run(); _scripts[i]->run();
} }
} else { } else {
if (_scripts[i]->_waitTime <= _gameRef->_timer) { if (_scripts[i]->_waitTime <= _gameRef->getTimer()->getTime()) {
_scripts[i]->run(); _scripts[i]->run();
} }
} }

View file

@ -0,0 +1,74 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#include "engines/wintermute/base/timer.h"
#include "engines/wintermute/base/base_persistence_manager.h"
#include "engines/wintermute/persistent.h"
namespace Wintermute {
Timer::Timer() : _timer(0), _timerDelta(0), _timerLast(0) {
}
void Timer::setTime(uint32 time) {
_timer = time;
}
void Timer::setTimeDelta(uint32 timeDelta) {
_timerDelta = timeDelta;
}
void Timer::setTimeLast(uint32 timeLast) {
_timerLast = timeLast;
}
void Timer::updateTime(uint32 delta, uint32 max) {
_timerDelta = _timer - _timerLast;
_timerLast = _timer;
_timer += MIN((uint32)max, delta);
}
uint32 Timer::getTime() const {
return _timer;
}
uint32 Timer::getTimeDelta() const {
return _timerDelta;
}
uint32 Timer::getTimeLast() const {
return _timerLast;
}
void Timer::persist(BasePersistenceManager *persistMgr) {
persistMgr->transfer(TMEMBER(_timer));
persistMgr->transfer(TMEMBER(_timerDelta));
persistMgr->transfer(TMEMBER(_timerLast));
}
} // End of namespace Wintermute

View file

@ -0,0 +1,57 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* This file is based on WME Lite.
* http://dead-code.org/redir.php?target=wmelite
* Copyright (c) 2011 Jan Nedoma
*/
#ifndef WINTERMUTE_TIMER_H
#define WINTERMUTE_TIMER_H
#include "common/scummsys.h"
namespace Wintermute {
class BasePersistenceManager;
class Timer {
uint32 _timer;
uint32 _timerDelta;
uint32 _timerLast;
public:
Timer();
void setTime(uint32 time);
void setTimeDelta(uint32 timeDelta);
void setTimeLast(uint32 timeLast);
void updateTime(uint32 delta, uint32 max);
uint32 getTime() const;
uint32 getTimeDelta() const;
uint32 getTimeLast() const;
void persist(BasePersistenceManager *persistMgr);
};
} // End of namespace Wintermute
#endif

View file

@ -87,6 +87,7 @@ MODULE_OBJS := \
base/base_viewport.o \ base/base_viewport.o \
base/saveload.o \ base/saveload.o \
base/save_thumb_helper.o \ base/save_thumb_helper.o \
base/timer.o \
detection.o \ detection.o \
graphics/transparent_surface.o \ graphics/transparent_surface.o \
math/math_util.o \ math/math_util.o \

View file

@ -274,7 +274,7 @@ bool VideoTheoraPlayer::stop() {
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
bool VideoTheoraPlayer::update() { bool VideoTheoraPlayer::update() {
_currentTime = _freezeGame ? _gameRef->_liveTimer : _gameRef->_timer; _currentTime = _freezeGame ? _gameRef->getLiveTimer()->getTime() : _gameRef->getTimer()->getTime();
if (!isPlaying()) { if (!isPlaying()) {
return STATUS_OK; return STATUS_OK;