diff options
Diffstat (limited to 'engines/wintermute/base/base_script_holder.cpp')
-rw-r--r-- | engines/wintermute/base/base_script_holder.cpp | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index c5d5e82f76..036bac1dd8 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -29,6 +29,7 @@ #include "engines/wintermute/ad/ad_game.h" #include "engines/wintermute/base/base_script_holder.h" #include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script_engine.h" #include "engines/wintermute/base/scriptables/script.h" @@ -43,7 +44,7 @@ BaseScriptHolder::BaseScriptHolder(BaseGame *inGame) : BaseScriptable(inGame) { setName("<unnamed>"); _freezable = true; - _filename = NULL; + _filename = nullptr; } @@ -56,11 +57,11 @@ BaseScriptHolder::~BaseScriptHolder() { ////////////////////////////////////////////////////////////////////////// bool BaseScriptHolder::cleanup() { delete[] _filename; - _filename = NULL; + _filename = nullptr; for (uint32 i = 0; i < _scripts.size(); i++) { _scripts[i]->finish(true); - _scripts[i]->_owner = NULL; + _scripts[i]->_owner = nullptr; } _scripts.clear(); @@ -69,15 +70,15 @@ bool BaseScriptHolder::cleanup() { ////////////////////////////////////////////////////////////////////// void BaseScriptHolder::setFilename(const char *filename) { - if (_filename != NULL) { + if (_filename != nullptr) { delete[] _filename; - _filename = NULL; + _filename = nullptr; } - if (filename == NULL) { + if (filename == nullptr) { return; } _filename = new char [strlen(filename) + 1]; - if (_filename != NULL) { + if (_filename != nullptr) { strcpy(_filename, filename); } } @@ -301,7 +302,7 @@ bool BaseScriptHolder::addScript(const char *filename) { for (uint32 i = 0; i < _scripts.size(); i++) { if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { if (_scripts[i]->_state != SCRIPT_FINISHED) { - _gameRef->LOG(0, "BaseScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, getName()); + BaseEngine::LOG(0, "BaseScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, getName()); return STATUS_OK; } } @@ -342,7 +343,7 @@ bool BaseScriptHolder::removeScript(ScScript *script) { } ////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::canHandleEvent(const char *EventName) { +bool BaseScriptHolder::canHandleEvent(const char *EventName) const { for (uint32 i = 0; i < _scripts.size(); i++) { if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) { return true; @@ -353,7 +354,7 @@ bool BaseScriptHolder::canHandleEvent(const char *EventName) { ////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::canHandleMethod(const char *MethodName) { +bool BaseScriptHolder::canHandleMethod(const char *MethodName) const { for (uint32 i = 0; i < _scripts.size(); i++) { if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) { return true; @@ -382,14 +383,14 @@ bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) { if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { - _gameRef->LOG(0, "'PROPERTY' keyword expected."); + BaseEngine::LOG(0, "'PROPERTY' keyword expected."); return STATUS_FAILED; } buffer = params; } - char *propName = NULL; - char *propValue = NULL; + char *propName = nullptr; + char *propValue = nullptr; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -418,17 +419,17 @@ bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) { if (cmd == PARSERR_TOKENNOTFOUND) { delete[] propName; delete[] propValue; - propName = NULL; - propValue = NULL; - _gameRef->LOG(0, "Syntax error in PROPERTY definition"); + propName = nullptr; + propValue = nullptr; + BaseEngine::LOG(0, "Syntax error in PROPERTY definition"); return STATUS_FAILED; } - if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { + if (cmd == PARSERR_GENERIC || propName == nullptr || propValue == nullptr) { delete[] propName; delete[] propValue; - propName = NULL; - propValue = NULL; - _gameRef->LOG(0, "Error loading PROPERTY definition"); + propName = nullptr; + propValue = nullptr; + BaseEngine::LOG(0, "Error loading PROPERTY definition"); return STATUS_FAILED; } @@ -440,8 +441,8 @@ bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) { delete val; delete[] propName; delete[] propValue; - propName = NULL; - propValue = NULL; + propName = nullptr; + propValue = nullptr; return STATUS_OK; } @@ -474,7 +475,7 @@ ScScript *BaseScriptHolder::invokeMethodThread(const char *methodName) { } } } - return NULL; + return nullptr; } |