diff options
Diffstat (limited to 'engines/wintermute/base/base_sprite.cpp')
-rw-r--r-- | engines/wintermute/base/base_sprite.cpp | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 468af1bd75..3f809f7a46 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -32,6 +32,7 @@ #include "engines/wintermute/base/base_dynamic_buffer.h" #include "engines/wintermute/base/gfx/base_surface.h" #include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_frame.h" #include "engines/wintermute/base/sound/base_sound.h" #include "engines/wintermute/base/base_sub_frame.h" @@ -64,7 +65,7 @@ void BaseSprite::setDefaults() { _currentFrame = -1; _looping = false; _lastFrameTime = 0; - setFilename(NULL); + setFilename(nullptr); _finished = false; _changed = false; _paused = false; @@ -72,7 +73,7 @@ void BaseSprite::setDefaults() { _moveX = _moveY = 0; _editorMuted = false; - _editorBgFile = NULL; + _editorBgFile = nullptr; _editorBgOffsetX = _editorBgOffsetY = 0; _editorBgAlpha = 0xFF; _streamed = false; @@ -94,7 +95,7 @@ void BaseSprite::cleanup() { _frames.clear(); delete[] _editorBgFile; - _editorBgFile = NULL; + _editorBgFile = nullptr; setDefaults(); } @@ -133,7 +134,7 @@ bool BaseSprite::isFinished() { bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteCacheType cacheType) { Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(filename); if (!file) { - _gameRef->LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename.c_str()); + BaseEngine::LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename.c_str()); if (_gameRef->_debugDebugMode) { return loadFile("invalid_debug.bmp", lifeTime, cacheType); } else { @@ -141,7 +142,7 @@ bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteC } } else { BaseFileManager::getEngineInstance()->closeFile(file); - file = NULL; + file = nullptr; } bool ret = STATUS_FAILED; @@ -154,8 +155,8 @@ bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteC BaseFrame *frame = new BaseFrame(_gameRef); BaseSubFrame *subframe = new BaseSubFrame(_gameRef); subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true); - if (subframe->_surface == NULL) { - _gameRef->LOG(0, "Error loading simple sprite '%s'", filename.c_str()); + if (subframe->_surface == nullptr) { + BaseEngine::LOG(0, "Error loading simple sprite '%s'", filename.c_str()); ret = STATUS_FAILED; delete frame; delete subframe; @@ -170,7 +171,7 @@ bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteC byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer) { if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) { - _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename.c_str()); + BaseEngine::LOG(0, "Error parsing SPRITE file '%s'", filename.c_str()); } else { ret = STATUS_OK; } @@ -231,7 +232,7 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITE) { - _gameRef->LOG(0, "'SPRITE' keyword expected."); + BaseEngine::LOG(0, "'SPRITE' keyword expected."); return STATUS_FAILED; } buffer = params; @@ -311,7 +312,7 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa if (DID_FAIL(frame->loadBuffer(params, frameLifeTime, _streamedKeepLoaded))) { delete frame; - _gameRef->LOG(0, "Error parsing frame %d", frameCount); + BaseEngine::LOG(0, "Error parsing frame %d", frameCount); return STATUS_FAILED; } @@ -330,7 +331,7 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa } if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in SPRITE definition"); + BaseEngine::LOG(0, "Syntax error in SPRITE definition"); return STATUS_FAILED; } _canBreak = !_continuous; @@ -365,9 +366,9 @@ bool BaseSprite::getCurrentFrame(float zoomX, float zoomY) { uint32 timer; if (_owner && _owner->_freezable) { - timer = _gameRef->_timer; + timer = _gameRef->getTimer()->getTime(); } else { - timer = _gameRef->_liveTimer; + timer = _gameRef->getLiveTimer()->getTime(); } int lastFrame = _currentFrame; @@ -440,7 +441,7 @@ bool BaseSprite::display(int x, int y, BaseObject *registerVal, float zoomX, flo BaseSurface *BaseSprite::getSurface() { // only used for animated textures for 3D models if (_currentFrame < 0 || _currentFrame >= (int32)_frames.size()) { - return NULL; + return nullptr; } BaseFrame *frame = _frames[_currentFrame]; if (frame && frame->_subframes.size() > 0) { @@ -448,10 +449,10 @@ BaseSurface *BaseSprite::getSurface() { if (subframe) { return subframe->_surface; } else { - return NULL; + return nullptr; } } else { - return NULL; + return nullptr; } } @@ -611,13 +612,13 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "AddFrame") == 0) { stack->correctParams(1); ScValue *val = stack->pop(); - const char *filename = NULL; + const char *filename = nullptr; if (!val->isNULL()) { filename = val->getString(); } BaseFrame *frame = new BaseFrame(_gameRef); - if (filename != NULL) { + if (filename != nullptr) { BaseSubFrame *sub = new BaseSubFrame(_gameRef); if (DID_SUCCEED(sub->setSurface(filename))) { sub->setDefaultRect(); @@ -643,13 +644,13 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta } ScValue *val = stack->pop(); - const char *filename = NULL; + const char *filename = nullptr; if (!val->isNULL()) { filename = val->getString(); } BaseFrame *frame = new BaseFrame(_gameRef); - if (filename != NULL) { + if (filename != nullptr) { BaseSubFrame *sub = new BaseSubFrame(_gameRef); if (DID_SUCCEED(sub->setSurface(filename))) { frame->_subframes.add(sub); @@ -740,7 +741,7 @@ ScValue *BaseSprite::scGetProperty(const Common::String &name) { // Owner (RO) ////////////////////////////////////////////////////////////////////////// else if (name == "Owner") { - if (_owner == NULL) { + if (_owner == nullptr) { _scValue->setNULL(); } else { _scValue->setNative(_owner, true); |