aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/base
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-07-26 15:59:26 +0200
committerEinar Johan Trøan Sømåen2012-07-26 15:59:26 +0200
commitef11f9d0c53cbdd9d88a99143de6f43f34d7e24d (patch)
tree8dfaee0ba16e18a8e3772dd5afc9123d5c4e78d2 /engines/wintermute/base
parent38507fa9895620639d8733dbb4e085dfb2282a33 (diff)
downloadscummvm-rg350-ef11f9d0c53cbdd9d88a99143de6f43f34d7e24d.tar.gz
scummvm-rg350-ef11f9d0c53cbdd9d88a99143de6f43f34d7e24d.tar.bz2
scummvm-rg350-ef11f9d0c53cbdd9d88a99143de6f43f34d7e24d.zip
WINTERMUTE: Run Astyle with add-braces to break one-line statements into easier-to-read-code.
Diffstat (limited to 'engines/wintermute/base')
-rw-r--r--engines/wintermute/base/base.cpp28
-rw-r--r--engines/wintermute/base/base_active_rect.cpp8
-rw-r--r--engines/wintermute/base/base_dynamic_buffer.cpp28
-rw-r--r--engines/wintermute/base/base_fader.cpp45
-rw-r--r--engines/wintermute/base/base_file_manager.cpp52
-rw-r--r--engines/wintermute/base/base_frame.cpp124
-rw-r--r--engines/wintermute/base/base_game.cpp859
-rw-r--r--engines/wintermute/base/base_keyboard_state.cpp24
-rw-r--r--engines/wintermute/base/base_named_object.cpp7
-rw-r--r--engines/wintermute/base/base_object.cpp291
-rw-r--r--engines/wintermute/base/base_parser.cpp76
-rw-r--r--engines/wintermute/base/base_persistence_manager.cpp97
-rw-r--r--engines/wintermute/base/base_quick_msg.cpp8
-rw-r--r--engines/wintermute/base/base_region.cpp87
-rw-r--r--engines/wintermute/base/base_registry.cpp43
-rw-r--r--engines/wintermute/base/base_save_thumb_helper.cpp4
-rw-r--r--engines/wintermute/base/base_script_holder.cpp55
-rw-r--r--engines/wintermute/base/base_scriptable.cpp39
-rw-r--r--engines/wintermute/base/base_sprite.cpp162
-rw-r--r--engines/wintermute/base/base_string_table.cpp49
-rw-r--r--engines/wintermute/base/base_sub_frame.cpp137
-rw-r--r--engines/wintermute/base/base_surface_storage.cpp45
-rw-r--r--engines/wintermute/base/base_transition_manager.cpp17
-rw-r--r--engines/wintermute/base/file/base_disk_file.cpp11
-rw-r--r--engines/wintermute/base/file/base_file_entry.cpp4
-rw-r--r--engines/wintermute/base/file/base_package.cpp18
-rw-r--r--engines/wintermute/base/file/base_save_thumb_file.cpp27
-rw-r--r--engines/wintermute/base/font/base_font.cpp7
-rw-r--r--engines/wintermute/base/font/base_font_bitmap.cpp115
-rw-r--r--engines/wintermute/base/font/base_font_storage.cpp16
-rw-r--r--engines/wintermute/base/font/base_font_truetype.cpp119
-rw-r--r--engines/wintermute/base/font/base_font_truetype.h4
-rw-r--r--engines/wintermute/base/gfx/base_image.cpp76
-rw-r--r--engines/wintermute/base/gfx/base_renderer.cpp28
-rw-r--r--engines/wintermute/base/gfx/base_surface.cpp8
-rw-r--r--engines/wintermute/base/gfx/osystem/base_render_osystem.cpp55
-rw-r--r--engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp41
-rw-r--r--engines/wintermute/base/particles/part_emitter.cpp140
-rw-r--r--engines/wintermute/base/particles/part_particle.cpp36
-rw-r--r--engines/wintermute/base/scriptables/script.cpp292
-rw-r--r--engines/wintermute/base/scriptables/script_engine.cpp167
-rw-r--r--engines/wintermute/base/scriptables/script_engine.h8
-rw-r--r--engines/wintermute/base/scriptables/script_ext_array.cpp35
-rw-r--r--engines/wintermute/base/scriptables/script_ext_array.h2
-rw-r--r--engines/wintermute/base/scriptables/script_ext_date.cpp9
-rw-r--r--engines/wintermute/base/scriptables/script_ext_file.cpp166
-rw-r--r--engines/wintermute/base/scriptables/script_ext_math.cpp8
-rw-r--r--engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp118
-rw-r--r--engines/wintermute/base/scriptables/script_ext_string.cpp120
-rw-r--r--engines/wintermute/base/scriptables/script_stack.cpp14
-rw-r--r--engines/wintermute/base/scriptables/script_value.cpp197
-rw-r--r--engines/wintermute/base/sound/base_sound.cpp113
-rw-r--r--engines/wintermute/base/sound/base_sound_manager.cpp19
53 files changed, 2941 insertions, 1317 deletions
diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp
index b81261cdaf..687d2d52e6 100644
--- a/engines/wintermute/base/base.cpp
+++ b/engines/wintermute/base/base.cpp
@@ -56,16 +56,19 @@ BaseClass::~BaseClass() {
//////////////////////////////////////////////////////////////////////////
const char *BaseClass::getEditorProp(const char *propName, const char *initVal) {
_editorPropsIter = _editorProps.find(propName);
- if (_editorPropsIter != _editorProps.end())
+ if (_editorPropsIter != _editorProps.end()) {
return _editorPropsIter->_value.c_str();
- //return _editorPropsIter->second.c_str(); // <- TODO Clean
- else return initVal;
+ } else {
+ return initVal;
+ }
}
//////////////////////////////////////////////////////////////////////////
bool BaseClass::setEditorProp(const char *propName, const char *propValue) {
- if (propName == NULL) return STATUS_FAILED;
+ if (propName == NULL) {
+ return STATUS_FAILED;
+ }
if (propValue == NULL) {
_editorProps.erase(propName);
@@ -91,8 +94,9 @@ bool BaseClass::parseEditorProperty(byte *buffer, bool complete) {
TOKEN_TABLE_END
- if (!_gameRef->_editorMode)
+ if (!_gameRef->_editorMode) {
return STATUS_OK;
+ }
byte *params;
@@ -115,15 +119,21 @@ bool BaseClass::parseEditorProperty(byte *buffer, bool complete) {
case TOKEN_NAME:
delete[] propName;
propName = new char[strlen((char *)params) + 1];
- if (propName) strcpy(propName, (char *)params);
- else cmd = PARSERR_GENERIC;
+ if (propName) {
+ strcpy(propName, (char *)params);
+ } else {
+ cmd = PARSERR_GENERIC;
+ }
break;
case TOKEN_VALUE:
delete[] propValue;
propValue = new char[strlen((char *)params) + 1];
- if (propValue) strcpy(propValue, (char *)params);
- else cmd = PARSERR_GENERIC;
+ if (propValue) {
+ strcpy(propValue, (char *)params);
+ } else {
+ cmd = PARSERR_GENERIC;
+ }
break;
}
diff --git a/engines/wintermute/base/base_active_rect.cpp b/engines/wintermute/base/base_active_rect.cpp
index 0283ee274e..0756d10698 100644
--- a/engines/wintermute/base/base_active_rect.cpp
+++ b/engines/wintermute/base/base_active_rect.cpp
@@ -97,8 +97,12 @@ void BaseActiveRect::clipRect() {
rc.bottom -= Rend->_drawOffsetY;
}
- if (rc.left > _rect.left) _offsetX = rc.left - _rect.left;
- if (rc.top > _rect.top) _offsetY = rc.top - _rect.top;
+ if (rc.left > _rect.left) {
+ _offsetX = rc.left - _rect.left;
+ }
+ if (rc.top > _rect.top) {
+ _offsetY = rc.top - _rect.top;
+ }
BasePlatform::intersectRect(&_rect, &_rect, &rc);
}
diff --git a/engines/wintermute/base/base_dynamic_buffer.cpp b/engines/wintermute/base/base_dynamic_buffer.cpp
index 8d6f88c9fe..a61227b0dc 100644
--- a/engines/wintermute/base/base_dynamic_buffer.cpp
+++ b/engines/wintermute/base/base_dynamic_buffer.cpp
@@ -53,7 +53,9 @@ BaseDynamicBuffer::~BaseDynamicBuffer() {
//////////////////////////////////////////////////////////////////////////
void BaseDynamicBuffer::cleanup() {
- if (_buffer) free(_buffer);
+ if (_buffer) {
+ free(_buffer);
+ }
_buffer = NULL;
_size = 0;
_realSize = 0;
@@ -72,7 +74,9 @@ uint32 BaseDynamicBuffer::getSize() {
bool BaseDynamicBuffer::init(uint32 initSize) {
cleanup();
- if (initSize == 0) initSize = _initSize;
+ if (initSize == 0) {
+ initSize = _initSize;
+ }
_buffer = (byte *)malloc(initSize);
if (!_buffer) {
@@ -89,7 +93,9 @@ bool BaseDynamicBuffer::init(uint32 initSize) {
//////////////////////////////////////////////////////////////////////////
bool BaseDynamicBuffer::putBytes(byte *buffer, uint32 size) {
- if (!_initialized) init();
+ if (!_initialized) {
+ init();
+ }
while (_offset + size > _realSize) {
_realSize += _growBy;
@@ -110,7 +116,9 @@ bool BaseDynamicBuffer::putBytes(byte *buffer, uint32 size) {
//////////////////////////////////////////////////////////////////////////
bool BaseDynamicBuffer::getBytes(byte *buffer, uint32 size) {
- if (!_initialized) init();
+ if (!_initialized) {
+ init();
+ }
if (_offset + size > _size) {
_gameRef->LOG(0, "BaseDynamicBuffer::GetBytes - Buffer underflow");
@@ -140,8 +148,9 @@ uint32 BaseDynamicBuffer::getDWORD() {
//////////////////////////////////////////////////////////////////////////
void BaseDynamicBuffer::putString(const char *val) {
- if (!val) putString("(null)");
- else {
+ if (!val) {
+ putString("(null)");
+ } else {
putDWORD(strlen(val) + 1);
putBytes((byte *)val, strlen(val) + 1);
}
@@ -154,8 +163,11 @@ char *BaseDynamicBuffer::getString() {
char *ret = (char *)(_buffer + _offset);
_offset += len;
- if (!strcmp(ret, "(null)")) return NULL;
- else return ret;
+ if (!strcmp(ret, "(null)")) {
+ return NULL;
+ } else {
+ return ret;
+ }
}
diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp
index 10818abfb9..04fde5457c 100644
--- a/engines/wintermute/base/base_fader.cpp
+++ b/engines/wintermute/base/base_fader.cpp
@@ -59,23 +59,31 @@ BaseFader::~BaseFader() {
//////////////////////////////////////////////////////////////////////////
bool BaseFader::update() {
- if (!_active) return STATUS_OK;
+ if (!_active) {
+ return STATUS_OK;
+ }
int alphaDelta = _targetAlpha - _sourceAlpha;
uint32 time;
- if (_system) time = g_system->getMillis() - _startTime;
- else time = _gameRef->_timer - _startTime;
+ if (_system) {
+ time = g_system->getMillis() - _startTime;
+ } else {
+ time = _gameRef->_timer - _startTime;
+ }
- if (time >= _duration) _currentAlpha = _targetAlpha;
- else {
+ if (time >= _duration) {
+ _currentAlpha = _targetAlpha;
+ } else {
_currentAlpha = (byte)(_sourceAlpha + (float)time / (float)_duration * alphaDelta);
}
_currentAlpha = MIN((unsigned char)255, MAX(_currentAlpha, (byte)0)); // TODO: clean
_ready = time >= _duration;
- if (_ready && _currentAlpha == 0x00) _active = false;
+ if (_ready && _currentAlpha == 0x00) {
+ _active = false;
+ }
return STATUS_OK;
}
@@ -83,10 +91,13 @@ bool BaseFader::update() {
//////////////////////////////////////////////////////////////////////////
bool BaseFader::display() {
- if (!_active) return STATUS_OK;
+ if (!_active) {
+ return STATUS_OK;
+ }
- if (_currentAlpha > 0x00)
+ if (_currentAlpha > 0x00) {
_gameRef->_renderer->fadeToColor(_red, _green, _blue, _currentAlpha);
+ }
return STATUS_OK;
}
@@ -114,8 +125,11 @@ bool BaseFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) {
_duration = duration;
_system = system;
- if (_system) _startTime = g_system->getMillis();
- else _startTime = _gameRef->_timer;
+ if (_system) {
+ _startTime = g_system->getMillis();
+ } else {
+ _startTime = _gameRef->_timer;
+ }
return STATUS_OK;
}
@@ -137,8 +151,11 @@ bool BaseFader::fadeOut(uint32 targetColor, uint32 duration, bool system) {
_duration = duration;
_system = system;
- if (_system) _startTime = g_system->getMillis();
- else _startTime = _gameRef->_timer;
+ if (_system) {
+ _startTime = g_system->getMillis();
+ } else {
+ _startTime = _gameRef->_timer;
+ }
return STATUS_OK;
@@ -167,7 +184,9 @@ bool BaseFader::persist(BasePersistenceManager *persistMgr) {
persistMgr->transfer(TMEMBER(_targetAlpha));
persistMgr->transfer(TMEMBER(_system));
- if (_system && !persistMgr->getIsSaving()) _startTime = 0;
+ if (_system && !persistMgr->getIsSaving()) {
+ _startTime = 0;
+ }
return STATUS_OK;
}
diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp
index c296f88699..ff693e055c 100644
--- a/engines/wintermute/base/base_file_manager.cpp
+++ b/engines/wintermute/base/base_file_manager.cpp
@@ -86,8 +86,9 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz
Common::SeekableReadStream *file = openFile(filename);
if (!file) {
- if (mustExist)
+ if (mustExist) {
debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Error opening file '%s'", filename.c_str());
+ }
return NULL;
}
@@ -106,7 +107,9 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz
};
buffer[file->size()] = '\0';
- if (size != NULL) *size = file->size();
+ if (size != NULL) {
+ *size = file->size();
+ }
closeFile(file);
return buffer;
@@ -114,8 +117,9 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz
//////////////////////////////////////////////////////////////////////////
bool BaseFileManager::addPath(TPathType type, const Common::FSNode &path) {
- if (!path.exists())
+ if (!path.exists()) {
return STATUS_FAILED;
+ }
switch (type) {
case PATH_SINGLE:
@@ -141,8 +145,9 @@ bool BaseFileManager::reloadPaths() {
//////////////////////////////////////////////////////////////////////////
bool BaseFileManager::initPaths() {
- if (!_gameRef) // This function only works when the game-registry is loaded
+ if (!_gameRef) { // This function only works when the game-registry is loaded
return STATUS_FAILED;
+ }
AnsiString pathList;
@@ -210,15 +215,17 @@ bool BaseFileManager::registerPackages() {
warning("Should register %s %s", (*it).getPath().c_str(), (*it).getName().c_str());
(*it).getChildren(files, Common::FSNode::kListFilesOnly);
for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) {
- if (!fileIt->getName().hasSuffix(".dcp"))
+ if (!fileIt->getName().hasSuffix(".dcp")) {
continue;
+ }
// Avoid registering all the language files
// TODO: Select based on the gameDesc.
if (fileIt->getParent().getName() == "language") {
Common::String parentName = fileIt->getParent().getName();
Common::String dcpName = fileIt->getName();
- if (fileIt->getName() != "english.dcp")
+ if (fileIt->getName() != "english.dcp") {
continue;
+ }
}
warning("Registering %s %s", (*fileIt).getPath().c_str(), (*fileIt).getName().c_str());
registerPackage((*fileIt));
@@ -247,8 +254,9 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f
// correct slashes
for (int32 i = 0; i < upcName.size(); i++) {
- if (upcName[i] == '/')
+ if (upcName[i] == '/') {
upcName.setChar('\\', (uint32)i);
+ }
}
Common::ArchiveMemberPtr entry = _packages.getMember(upcName);
file = entry->createReadStream();
@@ -256,23 +264,29 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f
}
bool BaseFileManager::hasFile(const Common::String &filename) {
- if (diskFileExists(filename))
+ if (diskFileExists(filename)) {
return true;
- if (_packages.hasFile(filename))
- return true; // We don't bother checking if the file can actually be opened, something bigger is wrong if that is the case.
- if (BaseResources::hasFile(filename))
+ }
+ if (_packages.hasFile(filename)) {
+ return true; // We don't bother checking if the file can actually be opened, something bigger is wrong if that is the case.
+ }
+ if (BaseResources::hasFile(filename)) {
return true;
+ }
return false;
}
//////////////////////////////////////////////////////////////////////////
Common::SeekableReadStream *BaseFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) {
- if (strcmp(filename.c_str(), "") == 0)
+ if (strcmp(filename.c_str(), "") == 0) {
return NULL;
+ }
debugC(kWinterMuteDebugFileAccess, "Open file %s", filename.c_str());
Common::SeekableReadStream *file = openFileRaw(filename);
- if (file && keepTrackOf) _openFiles.push_back(file);
+ if (file && keepTrackOf) {
+ _openFiles.push_back(file);
+ }
return file;
}
@@ -295,8 +309,9 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f
Common::SeekableReadStream *ret = NULL;
if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) {
- if (!_gameRef)
+ if (!_gameRef) {
error("Attempt to load filename: %s without BaseGame-object, this is unsupported", filename.c_str());
+ }
BaseSaveThumbFile *SaveThumbFile = new BaseSaveThumbFile(_gameRef);
if (DID_SUCCEED(SaveThumbFile->open(filename))) {
ret = SaveThumbFile->getMemStream();
@@ -306,16 +321,19 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f
}
ret = openDiskFile(filename);
- if (ret)
+ if (ret) {
return ret;
+ }
ret = openPkgFile(filename);
- if (ret)
+ if (ret) {
return ret;
+ }
ret = BaseResources::getFile(filename);
- if (ret)
+ if (ret) {
return ret;
+ }
warning("BFileManager::OpenFileRaw - Failed to open %s", filename.c_str());
return NULL;
diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp
index 67edccd041..68b866bbf5 100644
--- a/engines/wintermute/base/base_frame.cpp
+++ b/engines/wintermute/base/base_frame.cpp
@@ -61,8 +61,9 @@ BaseFrame::~BaseFrame() {
delete _sound;
_sound = NULL;
- for (int i = 0; i < _subframes.getSize(); i++)
+ for (int i = 0; i < _subframes.getSize(); i++) {
delete _subframes[i];
+ }
_subframes.removeAll();
for (int i = 0; i < _applyEvent.getSize(); i++) {
@@ -79,7 +80,9 @@ bool BaseFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float
for (int i = 0; i < _subframes.getSize(); i++) {
res = _subframes[i]->draw(x, y, registerOwner, zoomX, zoomY, precise, alpha, rotate, blendMode);
- if (DID_FAIL(res)) return res;
+ if (DID_FAIL(res)) {
+ return res;
+ }
}
return STATUS_OK;
}
@@ -88,7 +91,9 @@ bool BaseFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float
//////////////////////////////////////////////////////////////////////////
bool BaseFrame::oneTimeDisplay(BaseObject *owner, bool muted) {
if (_sound && !muted) {
- if (owner) owner->updateOneSound(_sound);
+ if (owner) {
+ owner->updateOneSound(_sound);
+ }
_sound->play();
/*
if (_gameRef->_state == GAME_FROZEN) {
@@ -240,7 +245,9 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) {
if (!subframe || DID_FAIL(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) {
delete subframe;
cmd = PARSERR_GENERIC;
- } else _subframes.add(subframe);
+ } else {
+ _subframes.add(subframe);
+ }
}
break;
@@ -251,7 +258,9 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) {
}
_sound = new BaseSound(_gameRef);
if (!_sound || DID_FAIL(_sound->setSound(params, Audio::Mixer::kSFXSoundType, false))) {
- if (_gameRef->_soundMgr->_soundAvailable) _gameRef->LOG(0, "Error loading sound '%s'.", params);
+ if (_gameRef->_soundMgr->_soundAvailable) {
+ _gameRef->LOG(0, "Error loading sound '%s'.", params);
+ }
delete _sound;
_sound = NULL;
}
@@ -291,8 +300,11 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) {
BaseSubFrame *sub = new BaseSubFrame(_gameRef);
if (surface_file != NULL) {
- if (custoTrans) sub->setSurface(surface_file, false, r, g, b, lifeTime, keepLoaded);
- else sub->setSurface(surface_file, true, 0, 0, 0, lifeTime, keepLoaded);
+ if (custoTrans) {
+ sub->setSurface(surface_file, false, r, g, b, lifeTime, keepLoaded);
+ } else {
+ sub->setSurface(surface_file, true, 0, 0, 0, lifeTime, keepLoaded);
+ }
if (!sub->_surface) {
delete sub;
@@ -301,11 +313,16 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) {
}
sub->_alpha = BYTETORGBA(ar, ag, ab, alpha);
- if (custoTrans) sub->_transparent = BYTETORGBA(r, g, b, 0xFF);
+ if (custoTrans) {
+ sub->_transparent = BYTETORGBA(r, g, b, 0xFF);
+ }
}
- if (BasePlatform::isRectEmpty(&rect)) sub->setDefaultRect();
- else sub->_rect = rect;
+ if (BasePlatform::isRectEmpty(&rect)) {
+ sub->setDefaultRect();
+ } else {
+ sub->_rect = rect;
+ }
sub->_hotspotX = hotspotX;
sub->_hotspotY = hotspotY;
@@ -325,7 +342,9 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) {
//////////////////////////////////////////////////////////////////////////
bool BaseFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) {
- if (!rect) return false;
+ if (!rect) {
+ return false;
+ }
BasePlatform::setRectEmpty(rect);
Rect32 subRect;
@@ -344,21 +363,27 @@ bool BaseFrame::saveAsText(BaseDynamicBuffer *buffer, int indent) {
buffer->putTextIndent(indent, "FRAME {\n");
buffer->putTextIndent(indent + 2, "DELAY = %d\n", _delay);
- if (_moveX != 0 || _moveY != 0)
+ if (_moveX != 0 || _moveY != 0) {
buffer->putTextIndent(indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY);
+ }
- if (_sound && _sound->_soundFilename)
+ if (_sound && _sound->_soundFilename) {
buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->_soundFilename);
+ }
buffer->putTextIndent(indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE");
- if (_killSound)
+ if (_killSound) {
buffer->putTextIndent(indent + 2, "KILL_SOUND=%s\n", _killSound ? "TRUE" : "FALSE");
+ }
- if (_editorExpanded)
+ if (_editorExpanded) {
buffer->putTextIndent(indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE");
+ }
- if (_subframes.getSize() > 0) _subframes[0]->saveAsText(buffer, indent, false);
+ if (_subframes.getSize() > 0) {
+ _subframes[0]->saveAsText(buffer, indent, false);
+ }
for (int i = 1; i < _subframes.getSize(); i++) {
_subframes[i]->saveAsText(buffer, indent + 2);
@@ -406,8 +431,11 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac
if (strcmp(name, "GetSound") == 0) {
stack->correctParams(0);
- if (_sound && _sound->_soundFilename) stack->pushString(_sound->_soundFilename);
- else stack->pushNULL();
+ if (_sound && _sound->_soundFilename) {
+ stack->pushString(_sound->_soundFilename);
+ } else {
+ stack->pushNULL();
+ }
return STATUS_OK;
}
@@ -426,8 +454,12 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac
stack->pushBool(false);
delete _sound;
_sound = NULL;
- } else stack->pushBool(true);
- } else stack->pushBool(true);
+ } else {
+ stack->pushBool(true);
+ }
+ } else {
+ stack->pushBool(true);
+ }
return STATUS_OK;
}
@@ -440,7 +472,9 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac
if (index < 0 || index >= _subframes.getSize()) {
script->runtimeError("Frame.GetSubframe: Subframe index %d is out of range.", index);
stack->pushNULL();
- } else stack->pushNative(_subframes[index], true);
+ } else {
+ stack->pushNative(_subframes[index], true);
+ }
return STATUS_OK;
}
@@ -477,7 +511,9 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac
stack->correctParams(1);
ScValue *val = stack->pop();
const char *filename = NULL;
- if (!val->isNULL()) filename = val->getString();
+ if (!val->isNULL()) {
+ filename = val->getString();
+ }
BaseSubFrame *sub = new BaseSubFrame(_gameRef);
if (filename != NULL) {
@@ -496,19 +532,26 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac
else if (strcmp(name, "InsertSubframe") == 0) {
stack->correctParams(2);
int index = stack->pop()->getInt();
- if (index < 0) index = 0;
+ if (index < 0) {
+ index = 0;
+ }
ScValue *val = stack->pop();
const char *filename = NULL;
- if (!val->isNULL()) filename = val->getString();
+ if (!val->isNULL()) {
+ filename = val->getString();
+ }
BaseSubFrame *sub = new BaseSubFrame(_gameRef);
if (filename != NULL) {
sub->setSurface(filename);
}
- if (index >= _subframes.getSize()) _subframes.add(sub);
- else _subframes.insertAt(index, sub);
+ if (index >= _subframes.getSize()) {
+ _subframes.add(sub);
+ } else {
+ _subframes.insertAt(index, sub);
+ }
stack->pushNative(sub, true);
return STATUS_OK;
@@ -523,7 +566,9 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac
if (index < 0 || index >= _applyEvent.getSize()) {
script->runtimeError("Frame.GetEvent: Event index %d is out of range.", index);
stack->pushNULL();
- } else stack->pushString(_applyEvent[index]);
+ } else {
+ stack->pushString(_applyEvent[index]);
+ }
return STATUS_OK;
}
@@ -563,15 +608,20 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac
//////////////////////////////////////////////////////////////////////////
else {
- if (_subframes.getSize() == 1) return _subframes[0]->scCallMethod(script, stack, thisStack, name);
- else return BaseScriptable::scCallMethod(script, stack, thisStack, name);
+ if (_subframes.getSize() == 1) {
+ return _subframes[0]->scCallMethod(script, stack, thisStack, name);
+ } else {
+ return BaseScriptable::scCallMethod(script, stack, thisStack, name);
+ }
}
}
//////////////////////////////////////////////////////////////////////////
ScValue *BaseFrame::scGetProperty(const char *name) {
- if (!_scValue) _scValue = new ScValue(_gameRef);
+ if (!_scValue) {
+ _scValue = new ScValue(_gameRef);
+ }
_scValue->setNULL();
//////////////////////////////////////////////////////////////////////////
@@ -640,8 +690,11 @@ ScValue *BaseFrame::scGetProperty(const char *name) {
//////////////////////////////////////////////////////////////////////////
else {
- if (_subframes.getSize() == 1) return _subframes[0]->scGetProperty(name);
- else return BaseScriptable::scGetProperty(name);
+ if (_subframes.getSize() == 1) {
+ return _subframes[0]->scGetProperty(name);
+ } else {
+ return BaseScriptable::scGetProperty(name);
+ }
}
}
@@ -690,8 +743,11 @@ bool BaseFrame::scSetProperty(const char *name, ScValue *value) {
//////////////////////////////////////////////////////////////////////////
else {
- if (_subframes.getSize() == 1) return _subframes[0]->scSetProperty(name, value);
- else return BaseScriptable::scSetProperty(name, value);
+ if (_subframes.getSize() == 1) {
+ return _subframes[0]->scSetProperty(name, value);
+ } else {
+ return BaseScriptable::scSetProperty(name, value);
+ }
}
}
diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp
index b2b92d6de4..9de183660e 100644
--- a/engines/wintermute/base/base_game.cpp
+++ b/engines/wintermute/base/base_game.cpp
@@ -390,7 +390,9 @@ bool BaseGame::cleanup() {
_fontStorage->removeFont(_videoFont);
_videoFont = NULL;
- for (int i = 0; i < _quickMessages.getSize(); i++) delete _quickMessages[i];
+ for (int i = 0; i < _quickMessages.getSize(); i++) {
+ delete _quickMessages[i];
+ }
_quickMessages.removeAll();
_viewportStack.removeAll();
@@ -417,48 +419,59 @@ bool BaseGame::initialize1() {
bool loaded = false; // Not really a loop, but a goto-replacement.
while (!loaded) {
_surfaceStorage = new BaseSurfaceStorage(this);
- if (_surfaceStorage == NULL)
+ if (_surfaceStorage == NULL) {
break;
+ }
_fontStorage = new BaseFontStorage(this);
- if (_fontStorage == NULL)
+ if (_fontStorage == NULL) {
break;
+ }
_fileManager = new BaseFileManager(this);
- if (_fileManager == NULL)
+ if (_fileManager == NULL) {
break;
+ }
_soundMgr = new BaseSoundMgr(this);
- if (_soundMgr == NULL)
+ if (_soundMgr == NULL) {
break;
+ }
_debugMgr = new BaseDebugger(this);
- if (_debugMgr == NULL)
+ if (_debugMgr == NULL) {
break;
+ }
_mathClass = new SXMath(this);
- if (_mathClass == NULL)
+ if (_mathClass == NULL) {
break;
+ }
_scEngine = new ScEngine(this);
- if (_scEngine == NULL)
+ if (_scEngine == NULL) {
break;
+ }
_videoPlayer = new VideoPlayer(this);
- if (_videoPlayer == NULL)
+ if (_videoPlayer == NULL) {
break;
+ }
_transMgr = new BaseTransitionMgr(this);
- if (_transMgr == NULL)
+ if (_transMgr == NULL) {
break;
+ }
_keyboardState = new BaseKeyboardState(this);
- if (_keyboardState == NULL)
+ if (_keyboardState == NULL) {
break;
+ }
_fader = new BaseFader(this);
- if (_fader == NULL)
+ if (_fader == NULL) {
break;
+ }
registerObject(_fader);
loaded = true;
@@ -484,7 +497,9 @@ bool BaseGame::initialize1() {
//////////////////////////////////////////////////////////////////////
bool BaseGame::initialize2() { // we know whether we are going to be accelerated
_renderer = makeOSystemRenderer(this);
- if (_renderer == NULL) return STATUS_FAILED;
+ if (_renderer == NULL) {
+ return STATUS_FAILED;
+ }
return STATUS_OK;
}
@@ -495,9 +510,15 @@ bool BaseGame::initialize3() { // renderer is initialized
_posX = _renderer->_width / 2;
_posY = _renderer->_height / 2;
- if (_indicatorY == -1) _indicatorY = _renderer->_height - _indicatorHeight;
- if (_indicatorX == -1) _indicatorX = 0;
- if (_indicatorWidth == -1) _indicatorWidth = _renderer->_width;
+ if (_indicatorY == -1) {
+ _indicatorY = _renderer->_height - _indicatorHeight;
+ }
+ if (_indicatorX == -1) {
+ _indicatorX = 0;
+ }
+ if (_indicatorWidth == -1) {
+ _indicatorWidth = _renderer->_width;
+ }
return STATUS_OK;
}
@@ -567,7 +588,9 @@ void BaseGame::LOG(bool res, const char *fmt, ...) {
if (_engineLogCallback) {
_engineLogCallback(buff, res, _engineLogCallbackData);
}
- if (_debugMgr) _debugMgr->onLog(res, buff);
+ if (_debugMgr) {
+ _debugMgr->onLog(res, buff);
+ }
debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff);
@@ -615,7 +638,9 @@ bool BaseGame::initLoop() {
_timerDelta = _timer - _timerLast;
_timerLast = _timer;
_timer += MIN((uint32)1000, _deltaTime);
- } else _timerDelta = 0;
+ } else {
+ _timerDelta = 0;
+ }
_framesRendered++;
if (_fpsTime > 1000) {
@@ -637,7 +662,9 @@ bool BaseGame::initLoop() {
updateSounds();
- if (_fader) _fader->update();
+ if (_fader) {
+ _fader->update();
+ }
return STATUS_OK;
}
@@ -663,8 +690,12 @@ void BaseGame::setOffset(int offsetX, int offsetY) {
//////////////////////////////////////////////////////////////////////////
void BaseGame::getOffset(int *offsetX, int *offsetY) {
- if (offsetX != NULL) *offsetX = _offsetX;
- if (offsetY != NULL) *offsetY = _offsetY;
+ if (offsetX != NULL) {
+ *offsetX = _offsetX;
+ }
+ if (offsetY != NULL) {
+ *offsetY = _offsetY;
+ }
}
@@ -680,7 +711,9 @@ bool BaseGame::loadFile(const char *filename) {
setFilename(filename);
- if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) {
+ _gameRef->LOG(0, "Error parsing GAME file '%s'", filename);
+ }
delete[] buffer;
@@ -789,7 +822,9 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) {
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)&params)) > 0) {
switch (cmd) {
case TOKEN_TEMPLATE:
- if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC;
+ if (DID_FAIL(loadFile((char *)params))) {
+ cmd = PARSERR_GENERIC;
+ }
break;
case TOKEN_NAME:
@@ -801,14 +836,18 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) {
break;
case TOKEN_SYSTEM_FONT:
- if (_systemFont) _fontStorage->removeFont(_systemFont);
+ if (_systemFont) {
+ _fontStorage->removeFont(_systemFont);
+ }
_systemFont = NULL;
_systemFont = _gameRef->_fontStorage->addFont((char *)params);
break;
case TOKEN_VIDEO_FONT:
- if (_videoFont) _fontStorage->removeFont(_videoFont);
+ if (_videoFont) {
+ _fontStorage->removeFont(_videoFont);
+ }
_videoFont = NULL;
_videoFont = _gameRef->_fontStorage->addFont((char *)params);
@@ -939,7 +978,9 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) {
}
}
- if (!_systemFont) _systemFont = _gameRef->_fontStorage->addFont("system_font.fnt");
+ if (!_systemFont) {
+ _systemFont = _gameRef->_fontStorage->addFont("system_font.fnt");
+ }
if (cmd == PARSERR_TOKENNOTFOUND) {
@@ -994,10 +1035,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
else if (strcmp(name, "RunScript") == 0) {
_gameRef->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)");
stack->correctParams(1);
- if (DID_FAIL(addScript(stack->pop()->getString())))
+ if (DID_FAIL(addScript(stack->pop()->getString()))) {
stack->pushBool(false);
- else
+ } else {
stack->pushBool(true);
+ }
return STATUS_OK;
}
@@ -1008,16 +1050,20 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
else if (strcmp(name, "LoadStringTable") == 0) {
stack->correctParams(2);
const char *filename = stack->pop()->getString();
- ScValue *Val = stack->pop();
+ ScValue *val = stack->pop();
bool ClearOld;
- if (Val->isNULL()) ClearOld = true;
- else ClearOld = Val->getBool();
+ if (val->isNULL()) {
+ ClearOld = true;
+ } else {
+ ClearOld = val->getBool();
+ }
- if (DID_FAIL(_stringTable->loadFile(filename, ClearOld)))
+ if (DID_FAIL(_stringTable->loadFile(filename, ClearOld))) {
stack->pushBool(false);
- else
+ } else {
stack->pushBool(true);
+ }
return STATUS_OK;
}
@@ -1028,8 +1074,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
else if (strcmp(name, "ValidObject") == 0) {
stack->correctParams(1);
BaseScriptable *obj = stack->pop()->getNative();
- if (validObject((BaseObject *) obj)) stack->pushBool(true);
- else stack->pushBool(false);
+ if (validObject((BaseObject *) obj)) {
+ stack->pushBool(true);
+ } else {
+ stack->pushBool(false);
+ }
return STATUS_OK;
}
@@ -1054,7 +1103,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
ScValue *val = stack->pop();
BaseObject *obj = (BaseObject *)val->getNative();
unregisterObject(obj);
- if (val->getType() == VAL_VARIABLE_REF) val->setNULL();
+ if (val->getType() == VAL_VARIABLE_REF) {
+ val->setNULL();
+ }
stack->pushNULL();
return STATUS_OK;
@@ -1097,8 +1148,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "PlayMusic") == 0 || strcmp(name, "PlayMusicChannel") == 0) {
int channel = 0;
- if (strcmp(name, "PlayMusic") == 0) stack->correctParams(3);
- else {
+ if (strcmp(name, "PlayMusic") == 0) {
+ stack->correctParams(3);
+ } else {
stack->correctParams(4);
channel = stack->pop()->getInt();
}
@@ -1111,8 +1163,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
uint32 loopStart = (uint32)(valLoopStart->isNULL() ? 0 : valLoopStart->getInt());
- if (DID_FAIL(playMusic(channel, filename, looping, loopStart))) stack->pushBool(false);
- else stack->pushBool(true);
+ if (DID_FAIL(playMusic(channel, filename, looping, loopStart))) {
+ stack->pushBool(false);
+ } else {
+ stack->pushBool(true);
+ }
return STATUS_OK;
}
@@ -1122,14 +1177,18 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
else if (strcmp(name, "StopMusic") == 0 || strcmp(name, "StopMusicChannel") == 0) {
int channel = 0;
- if (strcmp(name, "StopMusic") == 0) stack->correctParams(0);
- else {
+ if (strcmp(name, "StopMusic") == 0) {
+ stack->correctParams(0);
+ } else {
stack->correctParams(1);
channel = stack->pop()->getInt();
}
- if (DID_FAIL(stopMusic(channel))) stack->pushBool(false);
- else stack->pushBool(true);
+ if (DID_FAIL(stopMusic(channel))) {
+ stack->pushBool(false);
+ } else {
+ stack->pushBool(true);
+ }
return STATUS_OK;
}
@@ -1139,14 +1198,18 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
else if (strcmp(name, "PauseMusic") == 0 || strcmp(name, "PauseMusicChannel") == 0) {
int channel = 0;
- if (strcmp(name, "PauseMusic") == 0) stack->correctParams(0);
- else {
+ if (strcmp(name, "PauseMusic") == 0) {
+ stack->correctParams(0);
+ } else {
stack->correctParams(1);
channel = stack->pop()->getInt();
}
- if (DID_FAIL(pauseMusic(channel))) stack->pushBool(false);
- else stack->pushBool(true);
+ if (DID_FAIL(pauseMusic(channel))) {
+ stack->pushBool(false);
+ } else {
+ stack->pushBool(true);
+ }
return STATUS_OK;
}
@@ -1155,14 +1218,18 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "ResumeMusic") == 0 || strcmp(name, "ResumeMusicChannel") == 0) {
int channel = 0;
- if (strcmp(name, "ResumeMusic") == 0) stack->correctParams(0);
- else {
+ if (strcmp(name, "ResumeMusic") == 0) {
+ stack->correctParams(0);
+ } else {
stack->correctParams(1);
channel = stack->pop()->getInt();
}
- if (DID_FAIL(resumeMusic(channel))) stack->pushBool(false);
- else stack->pushBool(true);
+ if (DID_FAIL(resumeMusic(channel))) {
+ stack->pushBool(false);
+ } else {
+ stack->pushBool(true);
+ }
return STATUS_OK;
}
@@ -1171,15 +1238,20 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetMusic") == 0 || strcmp(name, "GetMusicChannel") == 0) {
int channel = 0;
- if (strcmp(name, "GetMusic") == 0) stack->correctParams(0);
- else {
+ if (strcmp(name, "GetMusic") == 0) {
+ stack->correctParams(0);
+ } else {
stack->correctParams(1);
channel = stack->pop()->getInt();
}
- if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) stack->pushNULL();
- else {
- if (!_music[channel] || !_music[channel]->_soundFilename) stack->pushNULL();
- else stack->pushString(_music[channel]->_soundFilename);
+ if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) {
+ stack->pushNULL();
+ } else {
+ if (!_music[channel] || !_music[channel]->_soundFilename) {
+ stack->pushNULL();
+ } else {
+ stack->pushString(_music[channel]->_soundFilename);
+ }
}
return STATUS_OK;
}
@@ -1189,16 +1261,20 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetMusicPosition") == 0 || strcmp(name, "SetMusicChannelPosition") == 0 || strcmp(name, "SetMusicPositionChannel") == 0) {
int channel = 0;
- if (strcmp(name, "SetMusicPosition") == 0) stack->correctParams(1);
- else {
+ if (strcmp(name, "SetMusicPosition") == 0) {
+ stack->correctParams(1);
+ } else {
stack->correctParams(2);
channel = stack->pop()->getInt();
}
uint32 time = stack->pop()->getInt();
- if (DID_FAIL(setMusicStartTime(channel, time))) stack->pushBool(false);
- else stack->pushBool(true);
+ if (DID_FAIL(setMusicStartTime(channel, time))) {
+ stack->pushBool(false);
+ } else {
+ stack->pushBool(true);
+ }
return STATUS_OK;
}
@@ -1208,14 +1284,18 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetMusicPosition") == 0 || strcmp(name, "GetMusicChannelPosition") == 0) {
int channel = 0;
- if (strcmp(name, "GetMusicPosition") == 0) stack->correctParams(0);
- else {
+ if (strcmp(name, "GetMusicPosition") == 0) {
+ stack->correctParams(0);
+ } else {
stack->correctParams(1);
channel = stack->pop()->getInt();
}
- if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0);
- else stack->pushInt(_music[channel]->getPositionTime());
+ if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) {
+ stack->pushInt(0);
+ } else {
+ stack->pushInt(_music[channel]->getPositionTime());
+ }
return STATUS_OK;
}
@@ -1224,14 +1304,18 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "IsMusicPlaying") == 0 || strcmp(name, "IsMusicChannelPlaying") == 0) {
int channel = 0;
- if (strcmp(name, "IsMusicPlaying") == 0) stack->correctParams(0);
- else {
+ if (strcmp(name, "IsMusicPlaying") == 0) {
+ stack->correctParams(0);
+ } else {
stack->correctParams(1);
channel = stack->pop()->getInt();
}
- if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false);
- else stack->pushBool(_music[channel]->isPlaying());
+ if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) {
+ stack->pushBool(false);
+ } else {
+ stack->pushBool(_music[channel]->isPlaying());
+ }
return STATUS_OK;
}
@@ -1240,17 +1324,22 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetMusicVolume") == 0 || strcmp(name, "SetMusicChannelVolume") == 0) {
int channel = 0;
- if (strcmp(name, "SetMusicVolume") == 0) stack->correctParams(1);
- else {
+ if (strcmp(name, "SetMusicVolume") == 0) {
+ stack->correctParams(1);
+ } else {
stack->correctParams(2);
channel = stack->pop()->getInt();
}
int volume = stack->pop()->getInt();
- if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false);
- else {
- if (DID_FAIL(_music[channel]->setVolumePercent(volume))) stack->pushBool(false);
- else stack->pushBool(true);
+ if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) {
+ stack->pushBool(false);
+ } else {
+ if (DID_FAIL(_music[channel]->setVolumePercent(volume))) {
+ stack->pushBool(false);
+ } else {
+ stack->pushBool(true);
+ }
}
return STATUS_OK;
}
@@ -1260,14 +1349,18 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetMusicVolume") == 0 || strcmp(name, "GetMusicChannelVolume") == 0) {
int channel = 0;
- if (strcmp(name, "GetMusicVolume") == 0) stack->correctParams(0);
- else {
+ if (strcmp(name, "GetMusicVolume") == 0) {
+ stack->correctParams(0);
+ } else {
stack->correctParams(1);
channel = stack->pop()->getInt();
}
- if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0);
- else stack->pushInt(_music[channel]->getVolumePercent());
+ if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) {
+ stack->pushInt(0);
+ } else {
+ stack->pushInt(_music[channel]->getVolumePercent());
+ }
return STATUS_OK;
}
@@ -1350,8 +1443,12 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
int right = stack->pop()->getInt();
int bottom = stack->pop()->getInt();
- if (right < left) BaseUtils::swap(&left, &right);
- if (bottom < top) BaseUtils::swap(&top, &bottom);
+ if (right < left) {
+ BaseUtils::swap(&left, &right);
+ }
+ if (bottom < top) {
+ BaseUtils::swap(&top, &bottom);
+ }
BasePlatform::setRect(&_mouseLockRect, left, top, right, bottom);
@@ -1376,26 +1473,34 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
const char *filename = stack->pop()->getString();
warning("PlayVideo: %s - not implemented yet", filename);
ScValue *valType = stack->pop();
- int Type;
- if (valType->isNULL()) Type = (int)VID_PLAY_STRETCH;
- else Type = valType->getInt();
+ int type;
+ if (valType->isNULL()) {
+ type = (int)VID_PLAY_STRETCH;
+ } else {
+ type = valType->getInt();
+ }
int xVal = stack->pop()->getInt();
int yVal = stack->pop()->getInt();
- bool FreezeMusic = stack->pop()->getBool(true);
+ bool freezeMusic = stack->pop()->getBool(true);
ScValue *valSub = stack->pop();
- const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString();
+ const char *subtitleFile = valSub->isNULL() ? NULL : valSub->getString();
- if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER)
- Type = (int)VID_PLAY_STRETCH;
+ if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) {
+ type = (int)VID_PLAY_STRETCH;
+ }
- if (DID_SUCCEED(_gameRef->_videoPlayer->initialize(filename, SubtitleFile))) {
- if (DID_SUCCEED(_gameRef->_videoPlayer->play((TVideoPlayback)Type, xVal, yVal, FreezeMusic))) {
+ if (DID_SUCCEED(_gameRef->_videoPlayer->initialize(filename, subtitleFile))) {
+ if (DID_SUCCEED(_gameRef->_videoPlayer->play((TVideoPlayback)type, xVal, yVal, freezeMusic))) {
stack->pushBool(true);
script->sleep(0);
- } else stack->pushBool(false);
- } else stack->pushBool(false);
+ } else {
+ stack->pushBool(false);
+ }
+ } else {
+ stack->pushBool(false);
+ }
return STATUS_OK;
}
@@ -1414,9 +1519,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
const char *filename = stack->pop()->getString();
ScValue *valType = stack->pop();
int type;
- if (valType->isNULL())
+ if (valType->isNULL()) {
type = (int)VID_PLAY_STRETCH;
- else type = valType->getInt();
+ } else {
+ type = valType->getInt();
+ }
int xVal = stack->pop()->getInt();
int yVal = stack->pop()->getInt();
@@ -1426,7 +1533,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
ScValue *valSub = stack->pop();
const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString();
- if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) type = (int)VID_PLAY_STRETCH;
+ if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) {
+ type = (int)VID_PLAY_STRETCH;
+ }
delete _theoraPlayer;
_theoraPlayer = new VideoTheoraPlayer(this);
@@ -1435,7 +1544,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
if (DID_SUCCEED(_theoraPlayer->play((TVideoPlayback)type, xVal, yVal, true, freezeMusic))) {
stack->pushBool(true);
script->sleep(0);
- } else stack->pushBool(false);
+ } else {
+ stack->pushBool(false);
+ }
} else {
stack->pushBool(false);
delete _theoraPlayer;
@@ -1649,8 +1760,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetActiveCursor") == 0) {
stack->correctParams(1);
- if (DID_SUCCEED(setActiveCursor(stack->pop()->getString()))) stack->pushBool(true);
- else stack->pushBool(false);
+ if (DID_SUCCEED(setActiveCursor(stack->pop()->getString()))) {
+ stack->pushBool(true);
+ } else {
+ stack->pushBool(false);
+ }
return STATUS_OK;
}
@@ -1660,8 +1774,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetActiveCursor") == 0) {
stack->correctParams(0);
- if (!_activeCursor || !_activeCursor->getFilename()) stack->pushNULL();
- else stack->pushString(_activeCursor->getFilename());
+ if (!_activeCursor || !_activeCursor->getFilename()) {
+ stack->pushNULL();
+ } else {
+ stack->pushString(_activeCursor->getFilename());
+ }
return STATUS_OK;
}
@@ -1671,8 +1788,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetActiveCursorObject") == 0) {
stack->correctParams(0);
- if (!_activeCursor) stack->pushNULL();
- else stack->pushNative(_activeCursor, true);
+ if (!_activeCursor) {
+ stack->pushNULL();
+ } else {
+ stack->pushNative(_activeCursor, true);
+ }
return STATUS_OK;
}
@@ -1695,8 +1815,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
else if (strcmp(name, "HasActiveCursor") == 0) {
stack->correctParams(0);
- if (_activeCursor) stack->pushBool(true);
- else stack->pushBool(false);
+ if (_activeCursor) {
+ stack->pushBool(true);
+ } else {
+ stack->pushBool(false);
+ }
return STATUS_OK;
}
@@ -1710,8 +1833,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
// TODO: Replace with fileExists
Common::SeekableReadStream *file = _fileManager->openFile(filename, false);
- if (!file) stack->pushBool(false);
- else {
+ if (!file) {
+ stack->pushBool(false);
+ } else {
_fileManager->closeFile(file);
stack->pushBool(true);
}
@@ -1732,7 +1856,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
bool system = (strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0);
_fader->fadeOut(BYTETORGBA(red, green, blue, alpha), duration, system);
- if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) script->waitFor(_fader);
+ if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) {
+ script->waitFor(_fader);
+ }
stack->pushNULL();
return STATUS_OK;
@@ -1752,7 +1878,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
bool system = (strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0);
_fader->fadeIn(BYTETORGBA(red, green, blue, alpha), duration, system);
- if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) script->waitFor(_fader);
+ if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) {
+ script->waitFor(_fader);
+ }
stack->pushNULL();
return STATUS_OK;
@@ -1774,15 +1902,16 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
stack->correctParams(1);
char filename[MAX_PATH_LENGTH];
- ScValue *Val = stack->pop();
+ ScValue *val = stack->pop();
warning("BGame::ScCallMethod - Screenshot not reimplemented"); //TODO
int fileNum = 0;
while (true) {
- sprintf(filename, "%s%03d.bmp", Val->isNULL() ? getName() : Val->getString(), fileNum);
- if (!Common::File::exists(filename))
+ sprintf(filename, "%s%03d.bmp", val->isNULL() ? getName() : val->getString(), fileNum);
+ if (!Common::File::exists(filename)) {
break;
+ }
fileNum++;
}
@@ -1791,7 +1920,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
if (image) {
ret = DID_SUCCEED(image->saveBMPFile(filename));
delete image;
- } else ret = false;
+ } else {
+ ret = false;
+ }
stack->pushBool(ret);
return STATUS_OK;
@@ -1810,9 +1941,13 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
BaseImage *image = _gameRef->_renderer->takeScreenshot();
if (image) {
ret = DID_SUCCEED(image->resize(sizeX, sizeY));
- if (ret) ret = DID_SUCCEED(image->saveBMPFile(filename));
+ if (ret) {
+ ret = DID_SUCCEED(image->saveBMPFile(filename));
+ }
delete image;
- } else ret = false;
+ } else {
+ ret = false;
+ }
stack->pushBool(ret);
return STATUS_OK;
@@ -1828,7 +1963,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
UIWindow *win = new UIWindow(_gameRef);
_windows.add(win);
registerObject(win);
- if (!val->isNULL()) win->setName(val->getString());
+ if (!val->isNULL()) {
+ win->setName(val->getString());
+ }
stack->pushNative(win, true);
return STATUS_OK;
}
@@ -1912,8 +2049,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetWaitCursor") == 0) {
stack->correctParams(1);
- if (DID_SUCCEED(setWaitCursor(stack->pop()->getString()))) stack->pushBool(true);
- else stack->pushBool(false);
+ if (DID_SUCCEED(setWaitCursor(stack->pop()->getString()))) {
+ stack->pushBool(true);
+ } else {
+ stack->pushBool(false);
+ }
return STATUS_OK;
}
@@ -1936,8 +2076,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetWaitCursor") == 0) {
stack->correctParams(0);
- if (!_cursorNoninteractive || !_cursorNoninteractive->getFilename()) stack->pushNULL();
- else stack->pushString(_cursorNoninteractive->getFilename());
+ if (!_cursorNoninteractive || !_cursorNoninteractive->getFilename()) {
+ stack->pushNULL();
+ } else {
+ stack->pushString(_cursorNoninteractive->getFilename());
+ }
return STATUS_OK;
}
@@ -1947,8 +2090,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetWaitCursorObject") == 0) {
stack->correctParams(0);
- if (!_cursorNoninteractive) stack->pushNULL();
- else stack->pushNative(_cursorNoninteractive, true);
+ if (!_cursorNoninteractive) {
+ stack->pushNULL();
+ } else {
+ stack->pushNative(_cursorNoninteractive, true);
+ }
return STATUS_OK;
}
@@ -2017,10 +2163,8 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "AccOutputText") == 0) {
stack->correctParams(2);
- /* const char *Str = */
- stack->pop()->getString();
- /* int Type = */
- stack->pop()->getInt();
+ /* const char *Str = */ stack->pop()->getString();
+ /* int type = */ stack->pop()->getInt();
// do nothing
stack->pushNULL();
@@ -2038,7 +2182,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
delete _cachedThumbnail;
_cachedThumbnail = NULL;
stack->pushBool(false);
- } else stack->pushBool(true);
+ } else {
+ stack->pushBool(true);
+ }
return STATUS_OK;
}
@@ -2083,12 +2229,15 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
char Hex[100];
sprintf(Hex, "%x", checksum);
stack->pushString(Hex);
- } else
+ } else {
stack->pushInt(checksum);
+ }
_fileManager->closeFile(file);
file = NULL;
- } else stack->pushNULL();
+ } else {
+ stack->pushNULL();
+ }
return STATUS_OK;
}
@@ -2139,9 +2288,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
stack->pushNULL();
return STATUS_OK;
+ } else {
+ return BaseObject::scCallMethod(script, stack, thisStack, name);
}
-
- else return BaseObject::scCallMethod(script, stack, thisStack, name);
}
@@ -2307,8 +2456,11 @@ ScValue *BaseGame::scGetProperty(const char *name) {
// Keyboard (RO)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Keyboard") == 0) {
- if (_keyboardState) _scValue->setNative(_keyboardState, true);
- else _scValue->setNULL();
+ if (_keyboardState) {
+ _scValue->setNative(_keyboardState, true);
+ } else {
+ _scValue->setNULL();
+ }
return _scValue;
}
@@ -2530,9 +2682,9 @@ ScValue *BaseGame::scGetProperty(const char *name) {
error("Request for a SXStore-object, which is not supported by ScummVM");
return _scValue;
+ } else {
+ return BaseObject::scGetProperty(name);
}
-
- else return BaseObject::scGetProperty(name);
}
@@ -2579,7 +2731,9 @@ bool BaseGame::scSetProperty(const char *name, ScValue *value) {
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "MainObject") == 0) {
BaseScriptable *obj = value->getNative();
- if (obj == NULL || validObject((BaseObject *)obj)) _mainObject = (BaseObject *)obj;
+ if (obj == NULL || validObject((BaseObject *)obj)) {
+ _mainObject = (BaseObject *)obj;
+ }
return STATUS_OK;
}
@@ -2655,10 +2809,14 @@ bool BaseGame::scSetProperty(const char *name, ScValue *value) {
// TextEncoding
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "TextEncoding") == 0) {
- int Enc = value->getInt();
- if (Enc < 0) Enc = 0;
- if (Enc >= NUM_TEXT_ENCODINGS) Enc = NUM_TEXT_ENCODINGS - 1;
- _textEncoding = (TTextEncoding)Enc;
+ int enc = value->getInt();
+ if (enc < 0) {
+ enc = 0;
+ }
+ if (enc >= NUM_TEXT_ENCODINGS) {
+ enc = NUM_TEXT_ENCODINGS - 1;
+ }
+ _textEncoding = (TTextEncoding)enc;
return STATUS_OK;
}
@@ -2725,9 +2883,9 @@ bool BaseGame::scSetProperty(const char *name, ScValue *value) {
else if (strcmp(name, "CursorHidden") == 0) {
_cursorHidden = value->getBool();
return STATUS_OK;
+ } else {
+ return BaseObject::scSetProperty(name, value);
}
-
- else return BaseObject::scSetProperty(name, value);
}
@@ -2741,7 +2899,9 @@ const char *BaseGame::scToString() {
#define QUICK_MSG_DURATION 3000
//////////////////////////////////////////////////////////////////////////
bool BaseGame::displayQuickMsg() {
- if (_quickMessages.getSize() == 0 || !_systemFont) return STATUS_OK;
+ if (_quickMessages.getSize() == 0 || !_systemFont) {
+ return STATUS_OK;
+ }
// update
for (int i = 0; i < _quickMessages.getSize(); i++) {
@@ -2796,7 +2956,9 @@ bool BaseGame::registerObject(BaseObject *object) {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::unregisterObject(BaseObject *object) {
- if (!object) return STATUS_OK;
+ if (!object) {
+ return STATUS_OK;
+ }
// is it a window?
for (int i = 0; i < _windows.getSize(); i++) {
@@ -2804,23 +2966,31 @@ bool BaseGame::unregisterObject(BaseObject *object) {
_windows.removeAt(i);
// get new focused window
- if (_focusedWindow == object) _focusedWindow = NULL;
+ if (_focusedWindow == object) {
+ _focusedWindow = NULL;
+ }
break;
}
}
// is it active object?
- if (_activeObject == object) _activeObject = NULL;
+ if (_activeObject == object) {
+ _activeObject = NULL;
+ }
// is it main object?
- if (_mainObject == object) _mainObject = NULL;
+ if (_mainObject == object) {
+ _mainObject = NULL;
+ }
// destroy object
for (int i = 0; i < _regObjects.getSize(); i++) {
if (_regObjects[i] == object) {
_regObjects.removeAt(i);
- if (!_loadInProgress) SystemClassRegistry::getInstance()->enumInstances(invalidateValues, "ScValue", (void *)object);
+ if (!_loadInProgress) {
+ SystemClassRegistry::getInstance()->enumInstances(invalidateValues, "ScValue", (void *)object);
+ }
delete object;
return STATUS_OK;
}
@@ -2846,11 +3016,17 @@ void BaseGame::invalidateValues(void *value, void *data) {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::validObject(BaseObject *object) {
- if (!object) return false;
- if (object == this) return true;
+ if (!object) {
+ return false;
+ }
+ if (object == this) {
+ return true;
+ }
for (int i = 0; i < _regObjects.getSize(); i++) {
- if (_regObjects[i] == object) return true;
+ if (_regObjects[i] == object) {
+ return true;
+ }
}
return false;
}
@@ -2946,7 +3122,9 @@ bool BaseGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack
stack->correctParams(1);
BaseScriptable *obj = stack->pop()->getNative();
- if (validObject((BaseObject *)obj)) script->waitForExclusive((BaseObject *)obj);
+ if (validObject((BaseObject *)obj)) {
+ script->waitForExclusive((BaseObject *)obj);
+ }
stack->pushNULL();
}
@@ -2982,8 +3160,11 @@ bool BaseGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack
int b = stack->pop()->getInt();
int a;
ScValue *val = stack->pop();
- if (val->isNULL()) a = 255;
- else a = val->getInt();
+ if (val->isNULL()) {
+ a = 255;
+ } else {
+ a = val->getInt();
+ }
stack->pushInt(BYTETORGBA(r, g, b, a));
}
@@ -3142,15 +3323,23 @@ bool BaseGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack
//////////////////////////////////////////////////////////////////////////
bool BaseGame::showCursor() {
- if (_cursorHidden) return STATUS_OK;
+ if (_cursorHidden) {
+ return STATUS_OK;
+ }
if (!_interactive && _gameRef->_state == GAME_RUNNING) {
- if (_cursorNoninteractive) return drawCursor(_cursorNoninteractive);
+ if (_cursorNoninteractive) {
+ return drawCursor(_cursorNoninteractive);
+ }
} else {
- if (_activeObject && !DID_FAIL(_activeObject->showCursor())) return STATUS_OK;
- else {
- if (_activeObject && _activeCursor && _activeObject->getExtendedFlag("usable")) return drawCursor(_activeCursor);
- else if (_cursor) return drawCursor(_cursor);
+ if (_activeObject && !DID_FAIL(_activeObject->showCursor())) {
+ return STATUS_OK;
+ } else {
+ if (_activeObject && _activeCursor && _activeObject->getExtendedFlag("usable")) {
+ return drawCursor(_activeCursor);
+ } else if (_cursor) {
+ return drawCursor(_cursor);
+ }
}
}
return STATUS_FAILED;
@@ -3171,7 +3360,9 @@ bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) {
_indicatorDisplay = true;
_indicatorProgress = 0;
BasePersistenceManager *pm = new BasePersistenceManager(_gameRef);
- if (DID_FAIL(ret = pm->initSave(desc))) goto save_finish;
+ if (DID_FAIL(ret = pm->initSave(desc))) {
+ goto save_finish;
+ }
if (!quickSave) {
delete _saveLoadImage;
@@ -3186,9 +3377,15 @@ bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) {
}
}
- if (DID_FAIL(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) goto save_finish;
- if (DID_FAIL(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) goto save_finish;
- if (DID_FAIL(ret = pm->saveFile(filename))) goto save_finish;
+ if (DID_FAIL(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) {
+ goto save_finish;
+ }
+ if (DID_FAIL(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) {
+ goto save_finish;
+ }
+ if (DID_FAIL(ret = pm->saveFile(filename))) {
+ goto save_finish;
+ }
_registry->writeInt("System", "MostRecentSaveSlot", slot);
@@ -3240,11 +3437,17 @@ bool BaseGame::loadGame(const char *filename) {
_indicatorDisplay = true;
_indicatorProgress = 0;
BasePersistenceManager *pm = new BasePersistenceManager(_gameRef);
- if (DID_FAIL(ret = pm->initLoad(filename))) goto load_finish;
+ if (DID_FAIL(ret = pm->initLoad(filename))) {
+ goto load_finish;
+ }
//if (DID_FAIL(ret = cleanup())) goto load_finish;
- if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadTable(_gameRef, pm))) goto load_finish;
- if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadInstances(_gameRef, pm))) goto load_finish;
+ if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadTable(_gameRef, pm))) {
+ goto load_finish;
+ }
+ if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadInstances(_gameRef, pm))) {
+ goto load_finish;
+ }
// data initialization after load
initAfterLoad();
@@ -3332,7 +3535,9 @@ bool BaseGame::displayWindows(bool inGame) {
if (_windows[i]->_visible && _windows[i]->_inGame == inGame) {
res = _windows[i]->display();
- if (DID_FAIL(res)) return res;
+ if (DID_FAIL(res)) {
+ return res;
+ }
}
}
@@ -3356,7 +3561,9 @@ bool BaseGame::playMusic(int channel, const char *filename, bool looping, uint32
_music[channel]->setPositionTime(_musicStartTime[channel]);
_musicStartTime[channel] = 0;
}
- if (loopStart) _music[channel]->setLoopStart(loopStart);
+ if (loopStart) {
+ _music[channel]->setLoopStart(loopStart);
+ }
return _music[channel]->play(looping);
} else {
delete _music[channel];
@@ -3378,7 +3585,9 @@ bool BaseGame::stopMusic(int channel) {
delete _music[channel];
_music[channel] = NULL;
return STATUS_OK;
- } else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
}
@@ -3389,8 +3598,11 @@ bool BaseGame::pauseMusic(int channel) {
return STATUS_FAILED;
}
- if (_music[channel]) return _music[channel]->pause();
- else return STATUS_FAILED;
+ if (_music[channel]) {
+ return _music[channel]->pause();
+ } else {
+ return STATUS_FAILED;
+ }
}
@@ -3401,8 +3613,11 @@ bool BaseGame::resumeMusic(int channel) {
return STATUS_FAILED;
}
- if (_music[channel]) return _music[channel]->resume();
- else return STATUS_FAILED;
+ if (_music[channel]) {
+ return _music[channel]->resume();
+ } else {
+ return STATUS_FAILED;
+ }
}
@@ -3414,8 +3629,11 @@ bool BaseGame::setMusicStartTime(int channel, uint32 time) {
}
_musicStartTime[channel] = time;
- if (_music[channel] && _music[channel]->isPlaying()) return _music[channel]->setPositionTime(time);
- else return STATUS_OK;
+ if (_music[channel] && _music[channel]->isPlaying()) {
+ return _music[channel]->setPositionTime(time);
+ } else {
+ return STATUS_OK;
+ }
}
@@ -3464,11 +3682,15 @@ bool BaseGame::loadSettings(const char *filename) {
case TOKEN_GAME:
delete[] _settingsGameFile;
_settingsGameFile = new char[strlen((char *)params) + 1];
- if (_settingsGameFile) strcpy(_settingsGameFile, (char *)params);
+ if (_settingsGameFile) {
+ strcpy(_settingsGameFile, (char *)params);
+ }
break;
case TOKEN_STRING_TABLE:
- if (DID_FAIL(_stringTable->loadFile((char *)params))) cmd = PARSERR_GENERIC;
+ if (DID_FAIL(_stringTable->loadFile((char *)params))) {
+ cmd = PARSERR_GENERIC;
+ }
break;
case TOKEN_RESOLUTION:
@@ -3544,8 +3766,9 @@ bool BaseGame::loadSettings(const char *filename) {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::persist(BasePersistenceManager *persistMgr) {
- if (!persistMgr->getIsSaving())
+ if (!persistMgr->getIsSaving()) {
cleanup();
+ }
BaseObject::persist(persistMgr);
@@ -3627,29 +3850,32 @@ bool BaseGame::persist(BasePersistenceManager *persistMgr) {
persistMgr->transfer(TMEMBER(_autoSaveSlot));
persistMgr->transfer(TMEMBER(_cursorHidden));
- if (!persistMgr->getIsSaving())
+ if (!persistMgr->getIsSaving()) {
_quitting = false;
+ }
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
-bool BaseGame::focusWindow(UIWindow *Window) {
- UIWindow *Prev = _focusedWindow;
+bool BaseGame::focusWindow(UIWindow *window) {
+ UIWindow *prev = _focusedWindow;
for (int i = 0; i < _windows.getSize(); i++) {
- if (_windows[i] == Window) {
+ if (_windows[i] == window) {
if (i < _windows.getSize() - 1) {
_windows.removeAt(i);
- _windows.add(Window);
+ _windows.add(window);
- _gameRef->_focusedWindow = Window;
+ _gameRef->_focusedWindow = window;
}
- if (Window->_mode == WINDOW_NORMAL && Prev != Window && _gameRef->validObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE))
- return focusWindow(Prev);
- else return STATUS_OK;
+ if (window->_mode == WINDOW_NORMAL && prev != window && _gameRef->validObject(prev) && (prev->_mode == WINDOW_EXCLUSIVE || prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) {
+ return focusWindow(prev);
+ } else {
+ return STATUS_OK;
+ }
}
}
return STATUS_FAILED;
@@ -3674,7 +3900,9 @@ bool BaseGame::freeze(bool includingMusic) {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::unfreeze() {
- if (_freezeLevel == 0) return STATUS_OK;
+ if (_freezeLevel == 0) {
+ return STATUS_OK;
+ }
_freezeLevel--;
if (_freezeLevel == 0) {
@@ -3691,8 +3919,9 @@ bool BaseGame::unfreeze() {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::handleKeypress(Common::Event *event, bool printable) {
if (isVideoPlaying()) {
- if (event->kbd.keycode == Common::KEYCODE_ESCAPE)
+ if (event->kbd.keycode == Common::KEYCODE_ESCAPE) {
stopVideo();
+ }
return true;
}
@@ -3708,10 +3937,11 @@ bool BaseGame::handleKeypress(Common::Event *event, bool printable) {
if (_focusedWindow) {
if (!_gameRef->_focusedWindow->handleKeypress(event, _keyboardState->_currentPrintable)) {
/*if (event->type != SDL_TEXTINPUT) {*/
- if (_gameRef->_focusedWindow->canHandleEvent("Keypress"))
+ if (_gameRef->_focusedWindow->canHandleEvent("Keypress")) {
_gameRef->_focusedWindow->applyEvent("Keypress");
- else
+ } else {
applyEvent("Keypress");
+ }
/*}*/
}
return true;
@@ -3760,11 +3990,19 @@ bool BaseGame::handleMouseWheel(int Delta) {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) {
- if (verMajor) *verMajor = DCGF_VER_MAJOR;
- if (verMinor) *verMinor = DCGF_VER_MINOR;
+ if (verMajor) {
+ *verMajor = DCGF_VER_MAJOR;
+ }
+ if (verMinor) {
+ *verMinor = DCGF_VER_MINOR;
+ }
- if (extMajor) *extMajor = 0;
- if (extMinor) *extMinor = 0;
+ if (extMajor) {
+ *extMajor = 0;
+ }
+ if (extMinor) {
+ *extMinor = 0;
+ }
return STATUS_OK;
}
@@ -3775,7 +4013,9 @@ void BaseGame::setWindowTitle() {
if (_renderer) {
char title[512];
strcpy(title, _caption[0]);
- if (title[0] != '\0') strcat(title, " - ");
+ if (title[0] != '\0') {
+ strcat(title, " - ");
+ }
strcat(title, "WME Lite");
@@ -3825,7 +4065,9 @@ bool BaseGame::getSaveSlotDescription(int slot, char *buffer) {
char filename[MAX_PATH_LENGTH + 1];
getSaveSlotFilename(slot, filename);
BasePersistenceManager *pm = new BasePersistenceManager(_gameRef);
- if (!pm) return STATUS_FAILED;
+ if (!pm) {
+ return STATUS_FAILED;
+ }
if (DID_FAIL(pm->initLoad(filename))) {
delete pm;
@@ -3845,9 +4087,11 @@ bool BaseGame::isSaveSlotUsed(int slot) {
getSaveSlotFilename(slot, filename);
warning("BaseGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", slot);
- Common::SeekableReadStream *File = g_wintermute->getSaveFileMan()->openForLoading(filename);
- if (!File) return false;
- delete File;
+ Common::SeekableReadStream *file = g_wintermute->getSaveFileMan()->openForLoading(filename);
+ if (!file) {
+ return false;
+ }
+ delete file;
return true;
}
@@ -3870,9 +4114,13 @@ bool BaseGame::setActiveObject(BaseObject *obj) {
obj = NULL;
}
- if (obj == _activeObject) return STATUS_OK;
+ if (obj == _activeObject) {
+ return STATUS_OK;
+ }
- if (_activeObject) _activeObject->applyEvent("MouseLeave");
+ if (_activeObject) {
+ _activeObject->applyEvent("MouseLeave");
+ }
//if (ValidObject(_activeObject)) _activeObject->applyEvent("MouseLeave");
_activeObject = obj;
if (_activeObject) {
@@ -3886,8 +4134,11 @@ bool BaseGame::setActiveObject(BaseObject *obj) {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::pushViewport(BaseViewport *viewport) {
_viewportSP++;
- if (_viewportSP >= _viewportStack.getSize()) _viewportStack.add(viewport);
- else _viewportStack[_viewportSP] = viewport;
+ if (_viewportSP >= _viewportStack.getSize()) {
+ _viewportStack.add(viewport);
+ } else {
+ _viewportStack[_viewportSP] = viewport;
+ }
_renderer->setViewport(viewport->getRect());
@@ -3898,13 +4149,16 @@ bool BaseGame::pushViewport(BaseViewport *viewport) {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::popViewport() {
_viewportSP--;
- if (_viewportSP < -1) _gameRef->LOG(0, "Fatal: Viewport stack underflow!");
+ if (_viewportSP < -1) {
+ _gameRef->LOG(0, "Fatal: Viewport stack underflow!");
+ }
- if (_viewportSP >= 0 && _viewportSP < _viewportStack.getSize()) _renderer->setViewport(_viewportStack[_viewportSP]->getRect());
- else _renderer->setViewport(_renderer->_drawOffsetX,
- _renderer->_drawOffsetY,
- _renderer->_width + _renderer->_drawOffsetX,
- _renderer->_height + _renderer->_drawOffsetY);
+ if (_viewportSP >= 0 && _viewportSP < _viewportStack.getSize()) {
+ _renderer->setViewport(_viewportStack[_viewportSP]->getRect());
+ } else _renderer->setViewport(_renderer->_drawOffsetX,
+ _renderer->_drawOffsetY,
+ _renderer->_width + _renderer->_drawOffsetX,
+ _renderer->_height + _renderer->_drawOffsetY);
return STATUS_OK;
}
@@ -3912,17 +4166,22 @@ bool BaseGame::popViewport() {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::getCurrentViewportRect(Rect32 *rect, bool *custom) {
- if (rect == NULL) return STATUS_FAILED;
- else {
+ if (rect == NULL) {
+ return STATUS_FAILED;
+ } else {
if (_viewportSP >= 0) {
BasePlatform::copyRect(rect, _viewportStack[_viewportSP]->getRect());
- if (custom) *custom = true;
+ if (custom) {
+ *custom = true;
+ }
} else {
BasePlatform::setRect(rect, _renderer->_drawOffsetX,
_renderer->_drawOffsetY,
_renderer->_width + _renderer->_drawOffsetX,
_renderer->_height + _renderer->_drawOffsetY);
- if (custom) *custom = false;
+ if (custom) {
+ *custom = false;
+ }
}
return STATUS_OK;
@@ -3933,11 +4192,19 @@ bool BaseGame::getCurrentViewportRect(Rect32 *rect, bool *custom) {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::getCurrentViewportOffset(int *offsetX, int *offsetY) {
if (_viewportSP >= 0) {
- if (offsetX) *offsetX = _viewportStack[_viewportSP]->_offsetX;
- if (offsetY) *offsetY = _viewportStack[_viewportSP]->_offsetY;
+ if (offsetX) {
+ *offsetX = _viewportStack[_viewportSP]->_offsetX;
+ }
+ if (offsetY) {
+ *offsetY = _viewportStack[_viewportSP]->_offsetY;
+ }
} else {
- if (offsetX) *offsetX = 0;
- if (offsetY) *offsetY = 0;
+ if (offsetX) {
+ *offsetX = 0;
+ }
+ if (offsetY) {
+ *offsetY = 0;
+ }
}
return STATUS_OK;
@@ -3959,7 +4226,9 @@ bool BaseGame::windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack *
//////////////////////////////////////////////////////////////////////////
void BaseGame::setInteractive(bool state) {
_interactive = state;
- if (_transMgr) _transMgr->_origInteractive = state;
+ if (_transMgr) {
+ _transMgr->_origInteractive = state;
+ }
}
@@ -3983,7 +4252,9 @@ bool BaseGame::displayContent(bool doUpdate, bool displayAll) {
bool BaseGame::displayContentSimple() {
// fill black
_renderer->fill(0, 0, 0);
- if (_indicatorDisplay) displayIndicator();
+ if (_indicatorDisplay) {
+ displayIndicator();
+ }
return STATUS_OK;
}
@@ -3994,14 +4265,20 @@ bool BaseGame::displayIndicator() {
if (_saveLoadImage) {
Rect32 rc;
BasePlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight());
- if (_loadInProgress) _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc);
- else _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc);
+ if (_loadInProgress) {
+ _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc);
+ } else {
+ _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc);
+ }
}
- if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) return STATUS_OK;
+ if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) {
+ return STATUS_OK;
+ }
_renderer->setupLines();
- for (int i = 0; i < _indicatorHeight; i++)
+ for (int i = 0; i < _indicatorHeight; i++) {
_renderer->drawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor);
+ }
_renderer->setup2D();
return STATUS_OK;
@@ -4011,8 +4288,12 @@ bool BaseGame::displayIndicator() {
bool BaseGame::updateMusicCrossfade() {
/* byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */
- if (!_musicCrossfadeRunning) return STATUS_OK;
- if (_state == GAME_FROZEN) return STATUS_OK;
+ if (!_musicCrossfadeRunning) {
+ return STATUS_OK;
+ }
+ if (_state == GAME_FROZEN) {
+ return STATUS_OK;
+ }
if (_musicCrossfadeChannel1 < 0 || _musicCrossfadeChannel1 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel1]) {
_musicCrossfadeRunning = false;
@@ -4023,8 +4304,12 @@ bool BaseGame::updateMusicCrossfade() {
return STATUS_OK;
}
- if (!_music[_musicCrossfadeChannel1]->isPlaying()) _music[_musicCrossfadeChannel1]->play();
- if (!_music[_musicCrossfadeChannel2]->isPlaying()) _music[_musicCrossfadeChannel2]->play();
+ if (!_music[_musicCrossfadeChannel1]->isPlaying()) {
+ _music[_musicCrossfadeChannel1]->play();
+ }
+ if (!_music[_musicCrossfadeChannel2]->isPlaying()) {
+ _music[_musicCrossfadeChannel2]->play();
+ }
uint32 currentTime = _gameRef->_liveTimer - _musicCrossfadeStartTime;
@@ -4112,19 +4397,27 @@ bool BaseGame::setWaitCursor(const char *filename) {
delete _cursorNoninteractive;
_cursorNoninteractive = NULL;
return STATUS_FAILED;
- } else return STATUS_OK;
+ } else {
+ return STATUS_OK;
+ }
}
//////////////////////////////////////////////////////////////////////////
bool BaseGame::isVideoPlaying() {
- if (_videoPlayer->isPlaying()) return true;
- if (_theoraPlayer && _theoraPlayer->isPlaying()) return true;
+ if (_videoPlayer->isPlaying()) {
+ return true;
+ }
+ if (_theoraPlayer && _theoraPlayer->isPlaying()) {
+ return true;
+ }
return false;
}
//////////////////////////////////////////////////////////////////////////
bool BaseGame::stopVideo() {
- if (_videoPlayer->isPlaying()) _videoPlayer->stop();
+ if (_videoPlayer->isPlaying()) {
+ _videoPlayer->stop();
+ }
if (_theoraPlayer && _theoraPlayer->isPlaying()) {
_theoraPlayer->stop();
delete _theoraPlayer;
@@ -4136,7 +4429,9 @@ bool BaseGame::stopVideo() {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::drawCursor(BaseSprite *cursor) {
- if (!cursor) return STATUS_FAILED;
+ if (!cursor) {
+ return STATUS_FAILED;
+ }
if (cursor != _lastCursor) {
cursor->reset();
_lastCursor = cursor;
@@ -4148,7 +4443,9 @@ bool BaseGame::drawCursor(BaseSprite *cursor) {
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
bool BaseGame::onActivate(bool activate, bool refreshMouse) {
- if (_shuttingDown || !_renderer) return STATUS_OK;
+ if (_shuttingDown || !_renderer) {
+ return STATUS_OK;
+ }
_renderer->_active = activate;
@@ -4158,15 +4455,20 @@ bool BaseGame::onActivate(bool activate, bool refreshMouse) {
setActiveObject(_renderer->getObjectAt(p.x, p.y));
}
- if (activate) _soundMgr->resumeAll();
- else _soundMgr->pauseAll();
+ if (activate) {
+ _soundMgr->resumeAll();
+ } else {
+ _soundMgr->pauseAll();
+ }
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
bool BaseGame::onMouseLeftDown() {
- if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT);
+ if (_activeObject) {
+ _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT);
+ }
bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick"));
if (!handled) {
@@ -4175,7 +4477,9 @@ bool BaseGame::onMouseLeftDown() {
}
}
- if (_activeObject != NULL) _capturedObject = _activeObject;
+ if (_activeObject != NULL) {
+ _capturedObject = _activeObject;
+ }
_mouseLeftDown = true;
BasePlatform::setCapture(/*_renderer->_window*/);
@@ -4184,7 +4488,9 @@ bool BaseGame::onMouseLeftDown() {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::onMouseLeftUp() {
- if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT);
+ if (_activeObject) {
+ _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT);
+ }
BasePlatform::releaseCapture();
_capturedObject = NULL;
@@ -4201,9 +4507,13 @@ bool BaseGame::onMouseLeftUp() {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::onMouseLeftDblClick() {
- if (_state == GAME_RUNNING && !_interactive) return STATUS_OK;
+ if (_state == GAME_RUNNING && !_interactive) {
+ return STATUS_OK;
+ }
- if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT);
+ if (_activeObject) {
+ _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT);
+ }
bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftDoubleClick"));
if (!handled) {
@@ -4216,9 +4526,13 @@ bool BaseGame::onMouseLeftDblClick() {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::onMouseRightDblClick() {
- if (_state == GAME_RUNNING && !_interactive) return STATUS_OK;
+ if (_state == GAME_RUNNING && !_interactive) {
+ return STATUS_OK;
+ }
- if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT);
+ if (_activeObject) {
+ _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT);
+ }
bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightDoubleClick"));
if (!handled) {
@@ -4231,7 +4545,9 @@ bool BaseGame::onMouseRightDblClick() {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::onMouseRightDown() {
- if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT);
+ if (_activeObject) {
+ _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT);
+ }
bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick"));
if (!handled) {
@@ -4244,7 +4560,9 @@ bool BaseGame::onMouseRightDown() {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::onMouseRightUp() {
- if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT);
+ if (_activeObject) {
+ _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT);
+ }
bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease"));
if (!handled) {
@@ -4257,9 +4575,13 @@ bool BaseGame::onMouseRightUp() {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::onMouseMiddleDown() {
- if (_state == GAME_RUNNING && !_interactive) return STATUS_OK;
+ if (_state == GAME_RUNNING && !_interactive) {
+ return STATUS_OK;
+ }
- if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE);
+ if (_activeObject) {
+ _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE);
+ }
bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleClick"));
if (!handled) {
@@ -4272,7 +4594,9 @@ bool BaseGame::onMouseMiddleDown() {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::onMouseMiddleUp() {
- if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE);
+ if (_activeObject) {
+ _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE);
+ }
bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleRelease"));
if (!handled) {
@@ -4297,9 +4621,13 @@ bool BaseGame::onPaint() {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::onWindowClose() {
if (canHandleEvent("QuitGame")) {
- if (_state != GAME_FROZEN) _gameRef->applyEvent("QuitGame");
+ if (_state != GAME_FROZEN) {
+ _gameRef->applyEvent("QuitGame");
+ }
return STATUS_OK;
- } else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -4312,10 +4640,11 @@ bool BaseGame::displayDebugInfo() {
}
if (_gameRef->_debugDebugMode) {
- if (!_gameRef->_renderer->_windowed)
+ if (!_gameRef->_renderer->_windowed) {
sprintf(str, "Mode: %dx%dx%d", _renderer->_width, _renderer->_height, _renderer->_bPP);
- else
+ } else {
sprintf(str, "Mode: %dx%d windowed", _renderer->_width, _renderer->_height);
+ }
strcat(str, " (");
strcat(str, _renderer->getName().c_str());
@@ -4333,7 +4662,9 @@ bool BaseGame::displayDebugInfo() {
sprintf(str, "Timer: %d", _timer);
_gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT);
- if (_activeObject != NULL) _systemFont->drawText((byte *)_activeObject->getName(), 0, 150, _renderer->_width, TAL_RIGHT);
+ if (_activeObject != NULL) {
+ _systemFont->drawText((byte *)_activeObject->getName(), 0, 150, _renderer->_width, TAL_RIGHT);
+ }
sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024));
_systemFont->drawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT);
@@ -4345,7 +4676,9 @@ bool BaseGame::displayDebugInfo() {
//////////////////////////////////////////////////////////////////////////
BaseDebugger *BaseGame::getDebugMgr() {
- if (!_debugMgr) _debugMgr = new BaseDebugger(this);
+ if (!_debugMgr) {
+ _debugMgr = new BaseDebugger(this);
+ }
return _debugMgr;
}
@@ -4390,10 +4723,14 @@ void BaseGame::getMousePos(Point32 *pos) {
//////////////////////////////////////////////////////////////////////////
bool BaseGame::miniUpdate() {
- if (!_miniUpdateEnabled) return STATUS_OK;
+ if (!_miniUpdateEnabled) {
+ return STATUS_OK;
+ }
if (g_system->getMillis() - _lastMiniUpdate > 200) {
- if (_soundMgr) _soundMgr->initLoop();
+ if (_soundMgr) {
+ _soundMgr->initLoop();
+ }
_lastMiniUpdate = g_system->getMillis();
}
return STATUS_OK;
@@ -4443,8 +4780,12 @@ void BaseGame::autoSaveOnExit() {
_soundMgr->saveSettings();
_registry->saveValues();
- if (!_autoSaveOnExit) return;
- if (_state == GAME_FROZEN) return;
+ if (!_autoSaveOnExit) {
+ return;
+ }
+ if (_state == GAME_FROZEN) {
+ return;
+ }
saveGame(_autoSaveSlot, "autosave", true);
}
diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp
index 03f9929eee..3bad8f6012 100644
--- a/engines/wintermute/base/base_keyboard_state.cpp
+++ b/engines/wintermute/base/base_keyboard_state.cpp
@@ -84,9 +84,13 @@ bool BaseKeyboardState::scCallMethod(ScScript *script, ScStack *stack, ScStack *
if (val->_type == VAL_STRING && strlen(val->getString()) > 0) {
const char *str = val->getString();
char temp = str[0];
- if (temp >= 'A' && temp <= 'Z') temp += ('a' - 'A');
+ if (temp >= 'A' && temp <= 'Z') {
+ temp += ('a' - 'A');
+ }
vKey = (int)temp;
- } else vKey = val->getInt();
+ } else {
+ vKey = val->getInt();
+ }
warning("BKeyboardState doesnt yet have state-support %d", vKey); //TODO;
// Uint8 *state = SDL_GetKeyboardState(NULL);
@@ -95,9 +99,9 @@ bool BaseKeyboardState::scCallMethod(ScScript *script, ScStack *stack, ScStack *
stack->pushBool(isDown);
return STATUS_OK;
+ } else {
+ return BaseScriptable::scCallMethod(script, stack, thisStack, name);
}
-
- else return BaseScriptable::scCallMethod(script, stack, thisStack, name);
}
@@ -122,7 +126,9 @@ ScValue *BaseKeyboardState::scGetProperty(const char *name) {
key[0] = (char)_currentCharCode;
key[1] = '\0';
_scValue->setString(key);
- } else _scValue->setString("");
+ } else {
+ _scValue->setString("");
+ }
return _scValue;
}
@@ -165,9 +171,9 @@ ScValue *BaseKeyboardState::scGetProperty(const char *name) {
else if (strcmp(name, "IsControl") == 0) {
_scValue->setBool(_currentControl);
return _scValue;
+ } else {
+ return BaseScriptable::scGetProperty(name);
}
-
- else return BaseScriptable::scGetProperty(name);
}
@@ -255,7 +261,9 @@ bool BaseKeyboardState::isAltDown() {
//////////////////////////////////////////////////////////////////////////
uint32 BaseKeyboardState::keyCodeToVKey(Common::Event *event) {
- if (event->type != Common::EVENT_KEYDOWN) return 0;
+ if (event->type != Common::EVENT_KEYDOWN) {
+ return 0;
+ }
switch (event->kbd.keycode) {
case Common::KEYCODE_KP_ENTER:
diff --git a/engines/wintermute/base/base_named_object.cpp b/engines/wintermute/base/base_named_object.cpp
index 0821c9325b..0873f090d0 100644
--- a/engines/wintermute/base/base_named_object.cpp
+++ b/engines/wintermute/base/base_named_object.cpp
@@ -58,11 +58,14 @@ void BaseNamedObject::setName(const char *name) {
delete[] _name;
_name = NULL;
- if (name == NULL)
+ if (name == NULL) {
return;
+ }
_name = new char [strlen(name) + 1];
- if (_name != NULL) strcpy(_name, name);
+ if (_name != NULL) {
+ strcpy(_name, name);
+ }
}
} // end of namespace WinterMute
diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp
index 44823acf1a..18619616fe 100644
--- a/engines/wintermute/base/base_object.cpp
+++ b/engines/wintermute/base/base_object.cpp
@@ -85,8 +85,9 @@ BaseObject::BaseObject(BaseGame *inGame): BaseScriptHolder(inGame) {
_rotateValid = false;
_relativeRotate = 0.0f;
- for (int i = 0; i < 7; i++)
+ for (int i = 0; i < 7; i++) {
_caption[i] = NULL;
+ }
_saveState = true;
_nonIntMouseEvents = false;
@@ -107,8 +108,9 @@ BaseObject::~BaseObject() {
//////////////////////////////////////////////////////////////////////////
bool BaseObject::cleanup() {
- if (_gameRef && _gameRef->_activeObject == this)
+ if (_gameRef && _gameRef->_activeObject == this) {
_gameRef->_activeObject = NULL;
+ }
BaseScriptHolder::cleanup();
delete[] _soundEvent;
@@ -137,9 +139,12 @@ bool BaseObject::cleanup() {
//////////////////////////////////////////////////////////////////////////
void BaseObject::setCaption(const char *caption, int caseVal) { // TODO: rename Case to something usefull
- if (caseVal == 0) caseVal = 1;
- if (caseVal < 1 || caseVal > 7)
+ if (caseVal == 0) {
+ caseVal = 1;
+ }
+ if (caseVal < 1 || caseVal > 7) {
return;
+ }
delete[] _caption[caseVal - 1];
_caption[caseVal - 1] = new char[strlen(caption) + 1];
@@ -152,10 +157,14 @@ void BaseObject::setCaption(const char *caption, int caseVal) { // TODO: rename
//////////////////////////////////////////////////////////////////////////
const char *BaseObject::getCaption(int caseVal) {
- if (caseVal == 0) caseVal = 1;
- if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL)
+ if (caseVal == 0) {
+ caseVal = 1;
+ }
+ if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) {
return "";
- else return _caption[caseVal - 1];
+ } else {
+ return _caption[caseVal - 1];
+ }
}
@@ -198,8 +207,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetCursor") == 0) {
stack->correctParams(1);
- if (DID_SUCCEED(setCursor(stack->pop()->getString()))) stack->pushBool(true);
- else stack->pushBool(false);
+ if (DID_SUCCEED(setCursor(stack->pop()->getString()))) {
+ stack->pushBool(true);
+ } else {
+ stack->pushBool(false);
+ }
return STATUS_OK;
}
@@ -226,8 +238,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetCursor") == 0) {
stack->correctParams(0);
- if (!_cursor || !_cursor->getFilename()) stack->pushNULL();
- else stack->pushString(_cursor->getFilename());
+ if (!_cursor || !_cursor->getFilename()) {
+ stack->pushNULL();
+ } else {
+ stack->pushString(_cursor->getFilename());
+ }
return STATUS_OK;
}
@@ -237,8 +252,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetCursorObject") == 0) {
stack->correctParams(0);
- if (!_cursor) stack->pushNULL();
- else stack->pushNative(_cursor, true);
+ if (!_cursor) {
+ stack->pushNULL();
+ } else {
+ stack->pushNative(_cursor, true);
+ }
return STATUS_OK;
}
@@ -249,8 +267,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
else if (strcmp(name, "HasCursor") == 0) {
stack->correctParams(0);
- if (_cursor) stack->pushBool(true);
- else stack->pushBool(false);
+ if (_cursor) {
+ stack->pushBool(true);
+ } else {
+ stack->pushBool(false);
+ }
return STATUS_OK;
}
@@ -272,10 +293,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
else if (strcmp(name, "LoadSound") == 0) {
stack->correctParams(1);
const char *filename = stack->pop()->getString();
- if (DID_SUCCEED(playSFX(filename, false, false)))
+ if (DID_SUCCEED(playSFX(filename, false, false))) {
stack->pushBool(true);
- else
+ } else {
stack->pushBool(false);
+ }
return STATUS_OK;
}
@@ -299,15 +321,20 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
looping = val1->getBool();
loopStart = val2->getInt();
} else {
- if (val1->isNULL()) filename = NULL;
- else filename = val1->getString();
+ if (val1->isNULL()) {
+ filename = NULL;
+ } else {
+ filename = val1->getString();
+ }
looping = val2->isNULL() ? false : val2->getBool();
loopStart = val3->getInt();
}
- if (DID_FAIL(playSFX(filename, looping, true, NULL, loopStart)))
+ if (DID_FAIL(playSFX(filename, looping, true, NULL, loopStart))) {
stack->pushBool(false);
- else stack->pushBool(true);
+ } else {
+ stack->pushBool(true);
+ }
return STATUS_OK;
}
@@ -331,8 +358,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
eventName = val2->getString();
}
- if (DID_FAIL(playSFX(filename, false, true, eventName))) stack->pushBool(false);
- else stack->pushBool(true);
+ if (DID_FAIL(playSFX(filename, false, true, eventName))) {
+ stack->pushBool(false);
+ } else {
+ stack->pushBool(true);
+ }
return STATUS_OK;
}
@@ -342,8 +372,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
else if (strcmp(name, "StopSound") == 0) {
stack->correctParams(0);
- if (DID_FAIL(stopSFX())) stack->pushBool(false);
- else stack->pushBool(true);
+ if (DID_FAIL(stopSFX())) {
+ stack->pushBool(false);
+ } else {
+ stack->pushBool(true);
+ }
return STATUS_OK;
}
@@ -353,8 +386,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
else if (strcmp(name, "PauseSound") == 0) {
stack->correctParams(0);
- if (DID_FAIL(pauseSFX())) stack->pushBool(false);
- else stack->pushBool(true);
+ if (DID_FAIL(pauseSFX())) {
+ stack->pushBool(false);
+ } else {
+ stack->pushBool(true);
+ }
return STATUS_OK;
}
@@ -364,8 +400,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
else if (strcmp(name, "ResumeSound") == 0) {
stack->correctParams(0);
- if (DID_FAIL(resumeSFX())) stack->pushBool(false);
- else stack->pushBool(true);
+ if (DID_FAIL(resumeSFX())) {
+ stack->pushBool(false);
+ } else {
+ stack->pushBool(true);
+ }
return STATUS_OK;
}
@@ -375,8 +414,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
else if (strcmp(name, "IsSoundPlaying") == 0) {
stack->correctParams(0);
- if (_sFX && _sFX->isPlaying()) stack->pushBool(true);
- else stack->pushBool(false);
+ if (_sFX && _sFX->isPlaying()) {
+ stack->pushBool(true);
+ } else {
+ stack->pushBool(false);
+ }
return STATUS_OK;
}
@@ -387,8 +429,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
stack->correctParams(1);
uint32 Time = stack->pop()->getInt();
- if (DID_FAIL(setSFXTime(Time))) stack->pushBool(false);
- else stack->pushBool(true);
+ if (DID_FAIL(setSFXTime(Time))) {
+ stack->pushBool(false);
+ } else {
+ stack->pushBool(true);
+ }
return STATUS_OK;
}
@@ -398,8 +443,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
else if (strcmp(name, "GetSoundPosition") == 0) {
stack->correctParams(0);
- if (!_sFX) stack->pushInt(0);
- else stack->pushInt(_sFX->getPositionTime());
+ if (!_sFX) {
+ stack->pushInt(0);
+ } else {
+ stack->pushInt(_sFX->getPositionTime());
+ }
return STATUS_OK;
}
@@ -410,8 +458,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
stack->correctParams(1);
int volume = stack->pop()->getInt();
- if (DID_FAIL(setSFXVolume(volume))) stack->pushBool(false);
- else stack->pushBool(true);
+ if (DID_FAIL(setSFXVolume(volume))) {
+ stack->pushBool(false);
+ } else {
+ stack->pushBool(true);
+ }
return STATUS_OK;
}
@@ -421,8 +472,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
else if (strcmp(name, "GetSoundVolume") == 0) {
stack->correctParams(0);
- if (!_sFX) stack->pushInt(_sFXVolume);
- else stack->pushInt(_sFX->getVolumePercent());
+ if (!_sFX) {
+ stack->pushInt(_sFXVolume);
+ } else {
+ stack->pushInt(_sFX->getVolumePercent());
+ }
return STATUS_OK;
}
@@ -470,9 +524,9 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
stack->pushNULL();
return STATUS_OK;
+ } else {
+ return BaseScriptHolder::scCallMethod(script, stack, thisStack, name);
}
-
- else return BaseScriptHolder::scCallMethod(script, stack, thisStack, name);
}
@@ -578,8 +632,11 @@ ScValue *BaseObject::scGetProperty(const char *name) {
// Scale
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Scale") == 0) {
- if (_scale < 0) _scValue->setNULL();
- else _scValue->setFloat((double)_scale);
+ if (_scale < 0) {
+ _scValue->setNULL();
+ } else {
+ _scValue->setFloat((double)_scale);
+ }
return _scValue;
}
@@ -587,8 +644,11 @@ ScValue *BaseObject::scGetProperty(const char *name) {
// ScaleX
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "ScaleX") == 0) {
- if (_scaleX < 0) _scValue->setNULL();
- else _scValue->setFloat((double)_scaleX);
+ if (_scaleX < 0) {
+ _scValue->setNULL();
+ } else {
+ _scValue->setFloat((double)_scaleX);
+ }
return _scValue;
}
@@ -596,8 +656,11 @@ ScValue *BaseObject::scGetProperty(const char *name) {
// ScaleY
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "ScaleY") == 0) {
- if (_scaleY < 0) _scValue->setNULL();
- else _scValue->setFloat((double)_scaleY);
+ if (_scaleY < 0) {
+ _scValue->setNULL();
+ } else {
+ _scValue->setFloat((double)_scaleY);
+ }
return _scValue;
}
@@ -613,8 +676,11 @@ ScValue *BaseObject::scGetProperty(const char *name) {
// Rotate
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Rotate") == 0) {
- if (!_rotateValid) _scValue->setNULL();
- else _scValue->setFloat((double)_rotate);
+ if (!_rotateValid) {
+ _scValue->setNULL();
+ } else {
+ _scValue->setFloat((double)_rotate);
+ }
return _scValue;
}
@@ -663,9 +729,9 @@ ScValue *BaseObject::scGetProperty(const char *name) {
else if (strcmp(name, "AccCaption") == 0) {
_scValue->setNULL();
return _scValue;
+ } else {
+ return BaseScriptHolder::scGetProperty(name);
}
-
- else return BaseScriptHolder::scGetProperty(name);
}
@@ -742,7 +808,9 @@ bool BaseObject::scSetProperty(const char *name, ScValue *value) {
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "BlendMode") == 0) {
int i = value->getInt();
- if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) i = BLEND_NORMAL;
+ if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) {
+ i = BLEND_NORMAL;
+ }
_blendMode = (TSpriteBlendMode)i;
return STATUS_OK;
}
@@ -751,8 +819,11 @@ bool BaseObject::scSetProperty(const char *name, ScValue *value) {
// Scale
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Scale") == 0) {
- if (value->isNULL()) _scale = -1;
- else _scale = (float)value->getFloat();
+ if (value->isNULL()) {
+ _scale = -1;
+ } else {
+ _scale = (float)value->getFloat();
+ }
return STATUS_OK;
}
@@ -760,8 +831,11 @@ bool BaseObject::scSetProperty(const char *name, ScValue *value) {
// ScaleX
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "ScaleX") == 0) {
- if (value->isNULL()) _scaleX = -1;
- else _scaleX = (float)value->getFloat();
+ if (value->isNULL()) {
+ _scaleX = -1;
+ } else {
+ _scaleX = (float)value->getFloat();
+ }
return STATUS_OK;
}
@@ -769,8 +843,11 @@ bool BaseObject::scSetProperty(const char *name, ScValue *value) {
// ScaleY
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "ScaleY") == 0) {
- if (value->isNULL()) _scaleY = -1;
- else _scaleY = (float)value->getFloat();
+ if (value->isNULL()) {
+ _scaleY = -1;
+ } else {
+ _scaleY = (float)value->getFloat();
+ }
return STATUS_OK;
}
@@ -817,7 +894,9 @@ bool BaseObject::scSetProperty(const char *name, ScValue *value) {
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SoundPanning") == 0) {
_autoSoundPanning = value->getBool();
- if (!_autoSoundPanning) resetSoundPan();
+ if (!_autoSoundPanning) {
+ resetSoundPan();
+ }
return STATUS_OK;
}
@@ -842,9 +921,9 @@ bool BaseObject::scSetProperty(const char *name, ScValue *value) {
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "AccCaption") == 0) {
return STATUS_OK;
+ } else {
+ return BaseScriptHolder::scSetProperty(name, value);
}
-
- else return BaseScriptHolder::scSetProperty(name, value);
}
@@ -856,8 +935,11 @@ const char *BaseObject::scToString() {
//////////////////////////////////////////////////////////////////////////
bool BaseObject::showCursor() {
- if (_cursor) return _gameRef->drawCursor(_cursor);
- else return STATUS_FAILED;
+ if (_cursor) {
+ return _gameRef->drawCursor(_cursor);
+ } else {
+ return STATUS_FAILED;
+ }
}
@@ -871,8 +953,9 @@ bool BaseObject::saveAsText(BaseDynamicBuffer *buffer, int indent) {
bool BaseObject::persist(BasePersistenceManager *persistMgr) {
BaseScriptHolder::persist(persistMgr);
- for (int i = 0; i < 7; i++)
+ for (int i = 0; i < 7; i++) {
persistMgr->transfer(TMEMBER(_caption[i]));
+ }
persistMgr->transfer(TMEMBER(_activeCursor));
persistMgr->transfer(TMEMBER(_alphaColor));
persistMgr->transfer(TMEMBER(_autoSoundPanning));
@@ -936,7 +1019,9 @@ bool BaseObject::setCursor(const char *filename) {
delete _cursor;
_cursor = NULL;
return STATUS_FAILED;
- } else return STATUS_OK;
+ } else {
+ return STATUS_OK;
+ }
}
@@ -948,7 +1033,9 @@ bool BaseObject::setActiveCursor(const char *filename) {
delete _activeCursor;
_activeCursor = NULL;
return STATUS_FAILED;
- } else return STATUS_OK;
+ } else {
+ return STATUS_OK;
+ }
}
@@ -983,16 +1070,24 @@ bool BaseObject::playSFX(const char *filename, bool looping, bool playNow, const
if (_gameRef->_editorMode || _sFXStart) {
_sFX->setVolumePercent(_sFXVolume);
_sFX->setPositionTime(_sFXStart);
- if (!_gameRef->_editorMode) _sFXStart = 0;
+ if (!_gameRef->_editorMode) {
+ _sFXStart = 0;
+ }
}
if (playNow) {
setSoundEvent(eventName);
- if (loopStart) _sFX->setLoopStart(loopStart);
+ if (loopStart) {
+ _sFX->setLoopStart(loopStart);
+ }
return _sFX->play(looping);
- } else return STATUS_OK;
+ } else {
+ return STATUS_OK;
+ }
}
- if (filename == NULL) return STATUS_FAILED;
+ if (filename == NULL) {
+ return STATUS_FAILED;
+ }
// create new sound
delete _sFX;
@@ -1007,9 +1102,13 @@ bool BaseObject::playSFX(const char *filename, bool looping, bool playNow, const
_sFX->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4);
if (playNow) {
setSoundEvent(eventName);
- if (loopStart) _sFX->setLoopStart(loopStart);
+ if (loopStart) {
+ _sFX->setLoopStart(loopStart);
+ }
return _sFX->play(looping);
- } else return STATUS_OK;
+ } else {
+ return STATUS_OK;
+ }
} else {
delete _sFX;
_sFX = NULL;
@@ -1027,37 +1126,51 @@ bool BaseObject::stopSFX(bool deleteSound) {
_sFX = NULL;
}
return STATUS_OK;
- } else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
}
//////////////////////////////////////////////////////////////////////////
bool BaseObject::pauseSFX() {
- if (_sFX) return _sFX->pause();
- else return STATUS_FAILED;
+ if (_sFX) {
+ return _sFX->pause();
+ } else {
+ return STATUS_FAILED;
+ }
}
//////////////////////////////////////////////////////////////////////////
bool BaseObject::resumeSFX() {
- if (_sFX) return _sFX->resume();
- else return STATUS_FAILED;
+ if (_sFX) {
+ return _sFX->resume();
+ } else {
+ return STATUS_FAILED;
+ }
}
//////////////////////////////////////////////////////////////////////////
bool BaseObject::setSFXTime(uint32 time) {
_sFXStart = time;
- if (_sFX && _sFX->isPlaying()) return _sFX->setPositionTime(time);
- else return STATUS_OK;
+ if (_sFX && _sFX->isPlaying()) {
+ return _sFX->setPositionTime(time);
+ } else {
+ return STATUS_OK;
+ }
}
//////////////////////////////////////////////////////////////////////////
bool BaseObject::setSFXVolume(int volume) {
_sFXVolume = volume;
- if (_sFX) return _sFX->setVolumePercent(volume);
- else return STATUS_OK;
+ if (_sFX) {
+ return _sFX->setVolumePercent(volume);
+ } else {
+ return STATUS_OK;
+ }
}
@@ -1070,7 +1183,9 @@ bool BaseObject::updateSounds() {
}
}
- if (_sFX) updateOneSound(_sFX);
+ if (_sFX) {
+ updateOneSound(_sFX);
+ }
return STATUS_OK;
}
@@ -1080,8 +1195,9 @@ bool BaseObject::updateOneSound(BaseSound *sound) {
bool Ret = STATUS_OK;
if (sound) {
- if (_autoSoundPanning)
+ if (_autoSoundPanning) {
Ret = sound->setPan(_gameRef->_soundMgr->posToPan(_posX - _gameRef->_offsetX, _posY - _gameRef->_offsetY));
+ }
Ret = sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4);
}
@@ -1090,8 +1206,9 @@ bool BaseObject::updateOneSound(BaseSound *sound) {
//////////////////////////////////////////////////////////////////////////
bool BaseObject::resetSoundPan() {
- if (!_sFX) return STATUS_OK;
- else {
+ if (!_sFX) {
+ return STATUS_OK;
+ } else {
return _sFX->setPan(0.0f);
}
}
@@ -1115,7 +1232,9 @@ void BaseObject::setSoundEvent(const char *eventName) {
_soundEvent = NULL;
if (eventName) {
_soundEvent = new char[strlen(eventName) + 1];
- if (_soundEvent) strcpy(_soundEvent, eventName);
+ if (_soundEvent) {
+ strcpy(_soundEvent, eventName);
+ }
}
}
diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp
index 12ed67ba2a..98d77f4ed5 100644
--- a/engines/wintermute/base/base_parser.cpp
+++ b/engines/wintermute/base/base_parser.cpp
@@ -50,7 +50,9 @@ BaseParser::BaseParser(BaseGame *inGame): BaseClass(inGame) {
//////////////////////////////////////////////////////////////////////
BaseParser::~BaseParser() {
- if (_whiteSpace != NULL) delete[] _whiteSpace;
+ if (_whiteSpace != NULL) {
+ delete[] _whiteSpace;
+ }
}
@@ -71,8 +73,9 @@ int32 BaseParser::getObject(char **buf, TokenDesc *tokens, char **name, char **d
skipCharacters(buf, _whiteSpace);
}
- if (! **buf) // at end of file
+ if (! **buf) { // at end of file
return PARSERR_EOF;
+ }
// find the token.
// for now just use brute force. Improve later.
@@ -89,7 +92,9 @@ int32 BaseParser::getObject(char **buf, TokenDesc *tokens, char **name, char **d
char *p = strchr(*buf, '\n');
if (p && p > *buf) {
strncpy(_lastOffender, *buf, MIN((uint32)255, (uint32)(p - *buf))); // TODO, clean
- } else strcpy(_lastOffender, "");
+ } else {
+ strcpy(_lastOffender, "");
+ }
return PARSERR_TOKENNOTFOUND;
}
@@ -102,10 +107,11 @@ int32 BaseParser::getObject(char **buf, TokenDesc *tokens, char **name, char **d
skipCharacters(buf, _whiteSpace);
// get optional data
- if (**buf == '=') // An assignment rather than a command/object.
+ if (**buf == '=') { // An assignment rather than a command/object.
*data = getAssignmentText(buf);
- else
+ } else {
*data = getSubText(buf, '{', '}');
+ }
return tokens->id;
}
@@ -113,7 +119,9 @@ int32 BaseParser::getObject(char **buf, TokenDesc *tokens, char **name, char **d
//////////////////////////////////////////////////////////////////////
int32 BaseParser::getCommand(char **buf, TokenDesc *tokens, char **params) {
- if (!*buf) return PARSERR_TOKENNOTFOUND;
+ if (!*buf) {
+ return PARSERR_TOKENNOTFOUND;
+ }
_gameRef->miniUpdate();
char *name;
return getObject(buf, tokens, &name, params);
@@ -124,9 +132,12 @@ int32 BaseParser::getCommand(char **buf, TokenDesc *tokens, char **params) {
void BaseParser::skipCharacters(char **buf, const char *toSkip) {
char ch;
while ((ch = **buf) != 0) {
- if (ch == '\n') _parserLine++;
- if (strchr(toSkip, ch) == NULL)
+ if (ch == '\n') {
+ _parserLine++;
+ }
+ if (strchr(toSkip, ch) == NULL) {
return;
+ }
++*buf; // skip this character
}
// we must be at the end of the buffer if we get here
@@ -135,8 +146,9 @@ void BaseParser::skipCharacters(char **buf, const char *toSkip) {
//////////////////////////////////////////////////////////////////////
char *BaseParser::getSubText(char **buf, char open, char close) {
- if (**buf == 0 || **buf != open)
+ if (**buf == 0 || **buf != open) {
return 0;
+ }
++*buf; // skip opening delimiter
char *result = *buf;
@@ -144,11 +156,13 @@ char *BaseParser::getSubText(char **buf, char open, char close) {
char theChar;
long skip = 1;
- if (open == close) // we cant nest identical delimiters
+ if (open == close) { // we cant nest identical delimiters
open = 0;
+ }
while ((theChar = **buf) != 0) {
- if (theChar == open)
+ if (theChar == open) {
++skip;
+ }
if (theChar == close) {
if (--skip == 0) {
**buf = 0; // null terminate the result string
@@ -176,13 +190,15 @@ char *BaseParser::getAssignmentText(char **buf) {
char theChar;
while ((theChar = **buf) != 0) {
- if (theChar <= 0x20) // space and control chars
+ if (theChar <= 0x20) { // space and control chars
break;
+ }
++*buf;
}
- **buf = 0; // null terminate it
- if (theChar) // skip the terminator
+ **buf = 0; // null terminate it
+ if (theChar) { // skip the terminator
++*buf;
+ }
}
return result;
@@ -195,10 +211,16 @@ char *BaseParser::getToken(char **buf) {
static char token[100];
char *b = *buf, * t = token;
while (true) {
- while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) b++;
+ while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) {
+ b++;
+ }
if (*b == ';')
- while (*b && *b != '\n' && *b != 13 && *b != 10) b++;
- else break;
+ while (*b && *b != '\n' && *b != 13 && *b != 10) {
+ b++;
+ }
+ else {
+ break;
+ }
}
if (*b == '\'') {
@@ -207,7 +229,9 @@ char *BaseParser::getToken(char **buf) {
*t++ = *b++;
}
*t++ = 0;
- if (*b == '\'') b++;
+ if (*b == '\'') {
+ b++;
+ }
} else if (*b == '(' || *b == ')' || *b == '=' || *b == ',' || *b == '[' || *b == ']' ||
*b == '%' || *b == ':' || *b == '{' || *b == '}') {
*t++ = *b++;
@@ -265,7 +289,9 @@ int BaseParser::getTokenInt(char **buf) {
//////////////////////////////////////////////////////////////////////
void BaseParser::skipToken(char **buf, char *tok, char * /*msg*/) {
char *t = getToken(buf);
- if (strcmp(t, tok)) return; // Error
+ if (strcmp(t, tok)) {
+ return; // Error
+ }
}
@@ -299,7 +325,9 @@ int BaseParser::scanStr(const char *in, const char *format, ...) {
list[i++] = atoi(in);
in += strspn(in, "0123456789+-");
in += strspn(in, " \t\n\f");
- if (*in != ',') break;
+ if (*in != ',') {
+ break;
+ }
in++;
in += strspn(in, " \t\n\f");
}
@@ -339,7 +367,9 @@ int BaseParser::scanStr(const char *in, const char *format, ...) {
list[i++] = (float)atof(in);
in += strspn(in, "0123456789.eE+-");
in += strspn(in, " \t\n\f");
- if (*in != ',') break;
+ if (*in != ',') {
+ break;
+ }
in++;
in += strspn(in, " \t\n\f");
}
@@ -414,7 +444,9 @@ int BaseParser::scanStr(const char *in, const char *format, ...) {
break;
}
}
- if (*format) format++;
+ if (*format) {
+ format++;
+ }
} else if (*format == ' ') {
format++;
in += strspn(in, " \t\n\f");
diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp
index cf7deb2970..d8f928b683 100644
--- a/engines/wintermute/base/base_persistence_manager.cpp
+++ b/engines/wintermute/base/base_persistence_manager.cpp
@@ -181,7 +181,9 @@ bool BasePersistenceManager::getSaveExists(int slot) {
//////////////////////////////////////////////////////////////////////////
bool BasePersistenceManager::initSave(const char *desc) {
- if (!desc) return STATUS_FAILED;
+ if (!desc) {
+ return STATUS_FAILED;
+ }
cleanup();
_saving = true;
@@ -232,7 +234,9 @@ bool BasePersistenceManager::initSave(const char *desc) {
thumbnailOK = true;
}
}
- if (!thumbnailOK) putDWORD(0);
+ if (!thumbnailOK) {
+ putDWORD(0);
+ }
// in any case, destroy the cached thumbnail once used
delete _gameRef->_cachedThumbnail;
@@ -288,9 +292,13 @@ bool BasePersistenceManager::readHeader(const Common::String &filename) {
_thumbnailData = new byte[_thumbnailDataSize];
if (_thumbnailData) {
getBytes(_thumbnailData, _thumbnailDataSize);
- } else _thumbnailDataSize = 0;
+ } else {
+ _thumbnailDataSize = 0;
+ }
}
- } else _savedVerBuild = 35; // last build with ver1 savegames
+ } else {
+ _savedVerBuild = 35; // last build with ver1 savegames
+ }
uint32 dataOffset = getDWORD();
@@ -379,16 +387,18 @@ bool BasePersistenceManager::saveFile(const Common::String &filename) {
//////////////////////////////////////////////////////////////////////////
bool BasePersistenceManager::putBytes(byte *buffer, uint32 size) {
_saveStream->write(buffer, size);
- if (_saveStream->err())
+ if (_saveStream->err()) {
return STATUS_FAILED;
+ }
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
bool BasePersistenceManager::getBytes(byte *buffer, uint32 size) {
_loadStream->read(buffer, size);
- if (_loadStream->err())
+ if (_loadStream->err()) {
return STATUS_FAILED;
+ }
return STATUS_OK;
}
@@ -407,8 +417,9 @@ uint32 BasePersistenceManager::getDWORD() {
//////////////////////////////////////////////////////////////////////////
void BasePersistenceManager::putString(const Common::String &val) {
- if (!val.size()) putString("(null)");
- else {
+ if (!val.size()) {
+ putString("(null)");
+ } else {
_saveStream->writeUint32LE(val.size());
_saveStream->writeString(val);
}
@@ -440,7 +451,9 @@ char *BasePersistenceManager::getString() {
if (!strcmp(ret, "(null)")) {
delete[] ret;
return NULL;
- } else return ret;
+ } else {
+ return ret;
+ }
}
bool BasePersistenceManager::putTimeDate(const TimeDate &t) {
@@ -510,13 +523,15 @@ double BasePersistenceManager::getDouble() {
bool BasePersistenceManager::transfer(const char *name, bool *val) {
if (_saving) {
_saveStream->writeByte(*val);
- if (_saveStream->err())
+ if (_saveStream->err()) {
return STATUS_FAILED;
+ }
return STATUS_OK;
} else {
*val = _loadStream->readByte();
- if (_loadStream->err())
+ if (_loadStream->err()) {
return STATUS_FAILED;
+ }
return STATUS_OK;
}
}
@@ -527,13 +542,15 @@ bool BasePersistenceManager::transfer(const char *name, bool *val) {
bool BasePersistenceManager::transfer(const char *name, int *val) {
if (_saving) {
_saveStream->writeSint32LE(*val);
- if (_saveStream->err())
+ if (_saveStream->err()) {
return STATUS_FAILED;
+ }
return STATUS_OK;
} else {
*val = _loadStream->readSint32LE();
- if (_loadStream->err())
+ if (_loadStream->err()) {
return STATUS_FAILED;
+ }
return STATUS_OK;
}
}
@@ -544,13 +561,15 @@ bool BasePersistenceManager::transfer(const char *name, int *val) {
bool BasePersistenceManager::transfer(const char *name, uint32 *val) {
if (_saving) {
_saveStream->writeUint32LE(*val);
- if (_saveStream->err())
+ if (_saveStream->err()) {
return STATUS_FAILED;
+ }
return STATUS_OK;
} else {
*val = _loadStream->readUint32LE();
- if (_loadStream->err())
+ if (_loadStream->err()) {
return STATUS_FAILED;
+ }
return STATUS_OK;
}
}
@@ -561,13 +580,15 @@ bool BasePersistenceManager::transfer(const char *name, uint32 *val) {
bool BasePersistenceManager::transfer(const char *name, float *val) {
if (_saving) {
putFloat(*val);
- if (_saveStream->err())
+ if (_saveStream->err()) {
return STATUS_FAILED;
+ }
return STATUS_OK;
} else {
*val = getFloat();
- if (_loadStream->err())
+ if (_loadStream->err()) {
return STATUS_FAILED;
+ }
return STATUS_OK;
}
}
@@ -578,13 +599,15 @@ bool BasePersistenceManager::transfer(const char *name, float *val) {
bool BasePersistenceManager::transfer(const char *name, double *val) {
if (_saving) {
putDouble(*val);
- if (_saveStream->err())
+ if (_saveStream->err()) {
return STATUS_FAILED;
+ }
return STATUS_OK;
} else {
*val = getDouble();
- if (_loadStream->err())
+ if (_loadStream->err()) {
return STATUS_FAILED;
+ }
return STATUS_OK;
}
}
@@ -667,7 +690,9 @@ bool BasePersistenceManager::transfer(const char *name, AnsiStringArray &val) {
delete[] str;
return STATUS_FAILED;
}
- if (str) val.push_back(str);
+ if (str) {
+ val.push_back(str);
+ }
delete[] str;
}
}
@@ -680,13 +705,15 @@ bool BasePersistenceManager::transfer(const char *name, AnsiStringArray &val) {
bool BasePersistenceManager::transfer(const char *name, byte *val) {
if (_saving) {
_saveStream->writeByte(*val);
- if (_saveStream->err())
+ if (_saveStream->err()) {
return STATUS_FAILED;
+ }
return STATUS_OK;
} else {
*val = _loadStream->readByte();
- if (_loadStream->err())
+ if (_loadStream->err()) {
return STATUS_FAILED;
+ }
return STATUS_OK;
}
}
@@ -700,16 +727,18 @@ bool BasePersistenceManager::transfer(const char *name, Rect32 *val) {
_saveStream->writeSint32LE(val->top);
_saveStream->writeSint32LE(val->right);
_saveStream->writeSint32LE(val->bottom);
- if (_saveStream->err())
+ if (_saveStream->err()) {
return STATUS_FAILED;
+ }
return STATUS_OK;
} else {
val->left = _loadStream->readSint32LE();
val->top = _loadStream->readSint32LE();
val->right = _loadStream->readSint32LE();
val->bottom = _loadStream->readSint32LE();
- if (_loadStream->err())
+ if (_loadStream->err()) {
return STATUS_FAILED;
+ }
return STATUS_OK;
}
}
@@ -721,14 +750,16 @@ bool BasePersistenceManager::transfer(const char *name, Point32 *val) {
if (_saving) {
_saveStream->writeSint32LE(val->x);
_saveStream->writeSint32LE(val->y);
- if (_saveStream->err())
+ if (_saveStream->err()) {
return STATUS_FAILED;
+ }
return STATUS_OK;
} else {
val->x = _loadStream->readSint32LE();
val->y = _loadStream->readSint32LE();
- if (_loadStream->err())
+ if (_loadStream->err()) {
return STATUS_FAILED;
+ }
return STATUS_OK;
}
}
@@ -740,14 +771,16 @@ bool BasePersistenceManager::transfer(const char *name, Vector2 *val) {
if (_saving) {
putFloat(val->x);
putFloat(val->y);
- if (_saveStream->err())
+ if (_saveStream->err()) {
return STATUS_FAILED;
+ }
return STATUS_OK;
} else {
val->x = getFloat();
val->y = getFloat();
- if (_loadStream->err())
+ if (_loadStream->err()) {
return STATUS_FAILED;
+ }
return STATUS_OK;
}
}
@@ -779,13 +812,17 @@ bool BasePersistenceManager::transfer(const char *name, void *val) {
//////////////////////////////////////////////////////////////////////////
bool BasePersistenceManager::checkVersion(byte verMajor, byte verMinor, byte verBuild) {
- if (_saving) return true;
+ if (_saving) {
+ return true;
+ }
// it's ok if we are same or newer than the saved game
if (verMajor > _savedVerMajor ||
(verMajor == _savedVerMajor && verMinor > _savedVerMinor) ||
(verMajor == _savedVerMajor && verMinor == _savedVerMinor && verBuild > _savedVerBuild)
- ) return false;
+ ) {
+ return false;
+ }
return true;
}
diff --git a/engines/wintermute/base/base_quick_msg.cpp b/engines/wintermute/base/base_quick_msg.cpp
index d672e39c6b..bf38adb578 100644
--- a/engines/wintermute/base/base_quick_msg.cpp
+++ b/engines/wintermute/base/base_quick_msg.cpp
@@ -34,14 +34,18 @@ namespace WinterMute {
//////////////////////////////////////////////////////////////////////////
BaseQuickMsg::BaseQuickMsg(BaseGame *inGame, const char *text): BaseClass(inGame) {
_text = new char [strlen(text) + 1];
- if (_text) strcpy(_text, text);
+ if (_text) {
+ strcpy(_text, text);
+ }
_startTime = _gameRef->_currentTime;
}
//////////////////////////////////////////////////////////////////////////
BaseQuickMsg::~BaseQuickMsg() {
- if (_text) delete[] _text;
+ if (_text) {
+ delete[] _text;
+ }
}
diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp
index f88de2ab91..67cda44ece 100644
--- a/engines/wintermute/base/base_region.cpp
+++ b/engines/wintermute/base/base_region.cpp
@@ -60,7 +60,9 @@ BaseRegion::~BaseRegion() {
//////////////////////////////////////////////////////////////////////////
void BaseRegion::cleanup() {
- for (int i = 0; i < _points.getSize(); i++) delete _points[i];
+ for (int i = 0; i < _points.getSize(); i++) {
+ delete _points[i];
+ }
_points.removeAll();
BasePlatform::setRectEmpty(&_rect);
@@ -76,7 +78,9 @@ bool BaseRegion::createRegion() {
//////////////////////////////////////////////////////////////////////////
bool BaseRegion::pointInRegion(int x, int y) {
- if (_points.getSize() < 3) return false;
+ if (_points.getSize() < 3) {
+ return false;
+ }
Point32 pt;
pt.x = x;
@@ -88,8 +92,11 @@ bool BaseRegion::pointInRegion(int x, int y) {
rect.top = y - 1;
rect.bottom = y + 2;
- if (BasePlatform::ptInRect(&_rect, pt)) return ptInPolygon(x, y);
- else return false;
+ if (BasePlatform::ptInRect(&_rect, pt)) {
+ return ptInPolygon(x, y);
+ } else {
+ return false;
+ }
}
@@ -105,7 +112,9 @@ bool BaseRegion::loadFile(const char *filename) {
setFilename(filename);
- if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true))) {
+ _gameRef->LOG(0, "Error parsing REGION file '%s'", filename);
+ }
delete[] buffer;
@@ -153,13 +162,17 @@ bool BaseRegion::loadBuffer(byte *buffer, bool complete) {
int i;
- for (i = 0; i < _points.getSize(); i++) delete _points[i];
+ for (i = 0; i < _points.getSize(); i++) {
+ delete _points[i];
+ }
_points.removeAll();
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)&params)) > 0) {
switch (cmd) {
case TOKEN_TEMPLATE:
- if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC;
+ if (DID_FAIL(loadFile((char *)params))) {
+ cmd = PARSERR_GENERIC;
+ }
break;
case TOKEN_NAME:
@@ -240,7 +253,9 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
createRegion();
stack->pushBool(true);
- } else stack->pushBool(false);
+ } else {
+ stack->pushBool(false);
+ }
return STATUS_OK;
}
@@ -260,7 +275,9 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
createRegion();
stack->pushBool(true);
- } else stack->pushBool(false);
+ } else {
+ stack->pushBool(false);
+ }
return STATUS_OK;
}
@@ -280,7 +297,9 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
createRegion();
stack->pushBool(true);
- } else stack->pushBool(false);
+ } else {
+ stack->pushBool(false);
+ }
return STATUS_OK;
}
@@ -298,12 +317,14 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
val->setProperty("X", _points[index]->x);
val->setProperty("Y", _points[index]->y);
}
- } else stack->pushNULL();
+ } else {
+ stack->pushNULL();
+ }
return STATUS_OK;
+ } else {
+ return BaseObject::scCallMethod(script, stack, thisStack, name);
}
-
- else return BaseObject::scCallMethod(script, stack, thisStack, name);
}
@@ -341,9 +362,9 @@ ScValue *BaseRegion::scGetProperty(const char *name) {
else if (strcmp(name, "NumPoints") == 0) {
_scValue->setInt(_points.getSize());
return _scValue;
+ } else {
+ return BaseObject::scGetProperty(name);
}
-
- else return BaseObject::scGetProperty(name);
}
@@ -363,9 +384,9 @@ bool BaseRegion::scSetProperty(const char *name, ScValue *value) {
else if (strcmp(name, "Active") == 0) {
_active = value->getBool();
return STATUS_OK;
+ } else {
+ return BaseObject::scSetProperty(name, value);
}
-
- else return BaseObject::scSetProperty(name, value);
}
@@ -377,8 +398,11 @@ const char *BaseRegion::scToString() {
//////////////////////////////////////////////////////////////////////////
bool BaseRegion::saveAsText(BaseDynamicBuffer *buffer, int indent, const char *nameOverride) {
- if (!nameOverride) buffer->putTextIndent(indent, "REGION {\n");
- else buffer->putTextIndent(indent, "%s {\n", nameOverride);
+ if (!nameOverride) {
+ buffer->putTextIndent(indent, "REGION {\n");
+ } else {
+ buffer->putTextIndent(indent, "%s {\n", nameOverride);
+ }
buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName());
buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption());
@@ -395,7 +419,9 @@ bool BaseRegion::saveAsText(BaseDynamicBuffer *buffer, int indent, const char *n
buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y);
}
- if (_scProp) _scProp->saveAsText(buffer, indent + 2);
+ if (_scProp) {
+ _scProp->saveAsText(buffer, indent + 2);
+ }
buffer->putTextIndent(indent, "}\n\n");
@@ -425,7 +451,9 @@ typedef struct {
//////////////////////////////////////////////////////////////////////////
bool BaseRegion::ptInPolygon(int x, int y) {
- if (_points.getSize() < 3) return false;
+ if (_points.getSize() < 3) {
+ return false;
+ }
int counter = 0;
double xinters;
@@ -446,8 +474,9 @@ bool BaseRegion::ptInPolygon(int x, int y) {
if (p.x <= MAX(p1.x, p2.x)) {
if (p1.y != p2.y) {
xinters = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x;
- if (p1.x == p2.x || p.x <= xinters)
+ if (p1.x == p2.x || p.x <= xinters) {
counter++;
+ }
}
}
}
@@ -455,17 +484,19 @@ bool BaseRegion::ptInPolygon(int x, int y) {
p1 = p2;
}
- if (counter % 2 == 0)
+ if (counter % 2 == 0) {
return false;
- else
+ } else {
return true;
+ }
}
//////////////////////////////////////////////////////////////////////////
bool BaseRegion::getBoundingRect(Rect32 *rect) {
- if (_points.getSize() == 0) BasePlatform::setRectEmpty(rect);
- else {
+ if (_points.getSize() == 0) {
+ BasePlatform::setRectEmpty(rect);
+ } else {
int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN;
for (int i = 0; i < _points.getSize(); i++) {
@@ -483,7 +514,9 @@ bool BaseRegion::getBoundingRect(Rect32 *rect) {
//////////////////////////////////////////////////////////////////////////
bool BaseRegion::mimic(BaseRegion *region, float scale, int x, int y) {
- if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) return STATUS_OK;
+ if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) {
+ return STATUS_OK;
+ }
cleanup();
diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp
index 7eb2685746..441d00c05b 100644
--- a/engines/wintermute/base/base_registry.cpp
+++ b/engines/wintermute/base/base_registry.cpp
@@ -61,8 +61,12 @@ AnsiString BaseRegistry::readString(const AnsiString &subKey, const AnsiString &
bool found = false;
ret = getValue(_localValues, subKey, key, found);
- if (!found) ret = getValue(_values, subKey, key, found);
- if (!found) ret = init;
+ if (!found) {
+ ret = getValue(_values, subKey, key, found);
+ }
+ if (!found) {
+ ret = init;
+ }
return ret;
}
@@ -105,8 +109,11 @@ int BaseRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int i
}
}
AnsiString val = readString(subKey, key, "");
- if (val.empty()) return init;
- else return atoi(val.c_str());
+ if (val.empty()) {
+ return init;
+ } else {
+ return atoi(val.c_str());
+ }
}
@@ -166,8 +173,11 @@ char *BaseRegistry::getIniName() {
//////////////////////////////////////////////////////////////////////////
void BaseRegistry::loadValues(bool local) {
- if (local) loadXml("settings.xml", _localValues);
- else loadXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values);
+ if (local) {
+ loadXml("settings.xml", _localValues);
+ } else {
+ loadXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values);
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -186,12 +196,15 @@ void BaseRegistry::setBasePath(const char *basePath) {
AnsiString BaseRegistry::getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) {
found = false;
PathValueMap::iterator it = values.find(path);
- if (it == values.end()) return "";
+ if (it == values.end()) {
+ return "";
+ }
KeyValuePair pairs = (*it)._value;
KeyValuePair::iterator keyIt = pairs.find(key);
- if (keyIt == pairs.end()) return "";
- else {
+ if (keyIt == pairs.end()) {
+ return "";
+ } else {
found = true;
return (*keyIt)._value;
}
@@ -200,11 +213,14 @@ AnsiString BaseRegistry::getValue(PathValueMap &values, const AnsiString path, c
//////////////////////////////////////////////////////////////////////////
void BaseRegistry::loadXml(const AnsiString fileName, PathValueMap &values) {
TiXmlDocument doc(fileName.c_str());
- if (!doc.LoadFile()) return;
+ if (!doc.LoadFile()) {
+ return;
+ }
TiXmlElement *rootElem = doc.RootElement();
- if (!rootElem || Common::String(rootElem->Value()) != "Settings") // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together)
+ if (!rootElem || Common::String(rootElem->Value()) != "Settings") { // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together)
return;
+ }
for (TiXmlElement *pathElem = rootElem->FirstChildElement(); pathElem != NULL; pathElem = pathElem->NextSiblingElement()) {
for (TiXmlElement *keyElem = pathElem->FirstChildElement(); keyElem != NULL; keyElem = keyElem->NextSiblingElement()) {
@@ -247,8 +263,9 @@ void BaseRegistry::saveXml(const AnsiString fileName, PathValueMap &values) {
Common::DumpFile stream;
stream.open(fileName.c_str());
- if (!stream.isOpen()) return;
- else {
+ if (!stream.isOpen()) {
+ return;
+ } else {
stream.write(printer.CStr(), printer.Size());
stream.close();
}
diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp
index b63f280f05..5007b65422 100644
--- a/engines/wintermute/base/base_save_thumb_helper.cpp
+++ b/engines/wintermute/base/base_save_thumb_helper.cpp
@@ -60,7 +60,9 @@ bool BaseSaveThumbHelper::storeThumbnail(bool doFlip) {
}
BaseImage *screenshot = _gameRef->_renderer->takeScreenshot();
- if (!screenshot) return STATUS_FAILED;
+ if (!screenshot) {
+ return STATUS_FAILED;
+ }
// normal thumbnail
if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) {
diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp
index d274f9df73..b90b4dc60a 100644
--- a/engines/wintermute/base/base_script_holder.cpp
+++ b/engines/wintermute/base/base_script_holder.cpp
@@ -75,10 +75,13 @@ void BaseScriptHolder::setFilename(const char *filename) {
delete[] _filename;
_filename = NULL;
}
- if (filename == NULL)
+ if (filename == NULL) {
return;
+ }
_filename = new char [strlen(filename) + 1];
- if (_filename != NULL) strcpy(_filename, filename);
+ if (_filename != NULL) {
+ strcpy(_filename, filename);
+ }
}
@@ -97,7 +100,9 @@ bool BaseScriptHolder::applyEvent(const char *eventName, bool unbreakable) {
}
}
}
- if (numHandlers > 0 && unbreakable) _gameRef->_scEngine->tickUnbreakable();
+ if (numHandlers > 0 && unbreakable) {
+ _gameRef->_scEngine->tickUnbreakable();
+ }
return ret;
}
@@ -134,8 +139,11 @@ bool BaseScriptHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *t
bool ret;
ret = applyEvent(val->getString());
- if (DID_SUCCEED(ret)) stack->pushBool(true);
- else stack->pushBool(false);
+ if (DID_SUCCEED(ret)) {
+ stack->pushBool(true);
+ } else {
+ stack->pushBool(false);
+ }
return STATUS_OK;
}
@@ -206,7 +214,9 @@ bool BaseScriptHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *t
stack->pushBool(ret);
return STATUS_OK;
- } else return BaseScriptable::scCallMethod(script, stack, thisStack, name);
+ } else {
+ return BaseScriptable::scCallMethod(script, stack, thisStack, name);
+ }
}
@@ -236,9 +246,9 @@ ScValue *BaseScriptHolder::scGetProperty(const char *name) {
else if (strcmp(name, "Filename") == 0) {
_scValue->setString(_filename);
return _scValue;
+ } else {
+ return BaseScriptable::scGetProperty(name);
}
-
- else return BaseScriptable::scGetProperty(name);
}
@@ -250,7 +260,9 @@ bool BaseScriptHolder::scSetProperty(const char *name, ScValue *value) {
if (strcmp(name, "Name") == 0) {
setName(value->getString());
return STATUS_OK;
- } else return BaseScriptable::scSetProperty(name, value);
+ } else {
+ return BaseScriptable::scSetProperty(name, value);
+ }
}
@@ -334,7 +346,9 @@ bool BaseScriptHolder::removeScript(ScScript *script) {
//////////////////////////////////////////////////////////////////////////
bool BaseScriptHolder::canHandleEvent(const char *EventName) {
for (int i = 0; i < _scripts.getSize(); i++) {
- if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) return true;
+ if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) {
+ return true;
+ }
}
return false;
}
@@ -343,7 +357,9 @@ bool BaseScriptHolder::canHandleEvent(const char *EventName) {
//////////////////////////////////////////////////////////////////////////
bool BaseScriptHolder::canHandleMethod(const char *MethodName) {
for (int i = 0; i < _scripts.getSize(); i++) {
- if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) return true;
+ if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) {
+ return true;
+ }
}
return false;
}
@@ -382,15 +398,21 @@ bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) {
case TOKEN_NAME:
delete[] propName;
propName = new char[strlen((char *)params) + 1];
- if (propName) strcpy(propName, (char *)params);
- else cmd = PARSERR_GENERIC;
+ if (propName) {
+ strcpy(propName, (char *)params);
+ } else {
+ cmd = PARSERR_GENERIC;
+ }
break;
case TOKEN_VALUE:
delete[] propValue;
propValue = new char[strlen((char *)params) + 1];
- if (propValue) strcpy(propValue, (char *)params);
- else cmd = PARSERR_GENERIC;
+ if (propValue) {
+ strcpy(propValue, (char *)params);
+ } else {
+ cmd = PARSERR_GENERIC;
+ }
break;
}
@@ -430,8 +452,9 @@ bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) {
//////////////////////////////////////////////////////////////////////////
void BaseScriptHolder::makeFreezable(bool freezable) {
_freezable = freezable;
- for (int i = 0; i < _scripts.getSize(); i++)
+ for (int i = 0; i < _scripts.getSize(); i++) {
_scripts[i]->_freezable = freezable;
+ }
}
diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp
index 4059abde3d..ad89b63d65 100644
--- a/engines/wintermute/base/base_scriptable.cpp
+++ b/engines/wintermute/base/base_scriptable.cpp
@@ -38,8 +38,11 @@ IMPLEMENT_PERSISTENT(BaseScriptable, false)
BaseScriptable::BaseScriptable(BaseGame *inGame, bool noValue, bool persistable): BaseNamedObject(inGame) {
_refCount = 0;
- if (noValue) _scValue = NULL;
- else _scValue = new ScValue(_gameRef);
+ if (noValue) {
+ _scValue = NULL;
+ } else {
+ _scValue = new ScValue(_gameRef);
+ }
_persistable = persistable;
@@ -74,17 +77,27 @@ bool BaseScriptable::scCallMethod(ScScript *script, ScStack *stack, ScStack *thi
//////////////////////////////////////////////////////////////////////////
ScValue *BaseScriptable::scGetProperty(const char *name) {
- if (!_scProp) _scProp = new ScValue(_gameRef);
- if (_scProp) return _scProp->getProp(name);
- else return NULL;
+ if (!_scProp) {
+ _scProp = new ScValue(_gameRef);
+ }
+ if (_scProp) {
+ return _scProp->getProp(name);
+ } else {
+ return NULL;
+ }
}
//////////////////////////////////////////////////////////////////////////
bool BaseScriptable::scSetProperty(const char *name, ScValue *value) {
- if (!_scProp) _scProp = new ScValue(_gameRef);
- if (_scProp) return _scProp->setProp(name, value);
- else return STATUS_FAILED;
+ if (!_scProp) {
+ _scProp = new ScValue(_gameRef);
+ }
+ if (_scProp) {
+ return _scProp->setProp(name, value);
+ } else {
+ return STATUS_FAILED;
+ }
}
@@ -150,9 +163,13 @@ bool BaseScriptable::persist(BasePersistenceManager *persistMgr) {
//////////////////////////////////////////////////////////////////////////
int BaseScriptable::scCompare(BaseScriptable *val) {
- if (this < val) return -1;
- else if (this > val) return 1;
- else return 0;
+ if (this < val) {
+ return -1;
+ } else if (this > val) {
+ return 1;
+ } else {
+ return 0;
+ }
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp
index c2e57f9fd6..2fda638665 100644
--- a/engines/wintermute/base/base_sprite.cpp
+++ b/engines/wintermute/base/base_sprite.cpp
@@ -89,8 +89,9 @@ void BaseSprite::setDefaults() {
void BaseSprite::cleanup() {
BaseScriptHolder::cleanup();
- for (int i = 0; i < _frames.getSize(); i++)
+ for (int i = 0; i < _frames.getSize(); i++) {
delete _frames[i];
+ }
_frames.removeAll();
delete[] _editorBgFile;
@@ -103,7 +104,9 @@ void BaseSprite::cleanup() {
//////////////////////////////////////////////////////////////////////////
bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, uint32 alpha) {
GetCurrentFrame(zoomX, zoomY);
- if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK;
+ if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) {
+ return STATUS_OK;
+ }
// move owner if allowed to
if (_changed && _owner && _owner->_movable) {
@@ -125,8 +128,11 @@ bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType c
Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename);
if (!file) {
_gameRef->LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename);
- if (_gameRef->_debugDebugMode) return loadFile("invalid_debug.bmp", lifeTime, cacheType);
- else return loadFile("invalid.bmp", lifeTime, cacheType);
+ if (_gameRef->_debugDebugMode) {
+ return loadFile("invalid_debug.bmp", lifeTime, cacheType);
+ } else {
+ return loadFile("invalid.bmp", lifeTime, cacheType);
+ }
} else {
_gameRef->_fileManager->closeFile(file);
file = NULL;
@@ -154,7 +160,9 @@ bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType c
} else {
byte *buffer = _gameRef->_fileManager->readWholeFile(filename);
if (buffer) {
- if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) {
+ _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename);
+ }
delete[] buffer;
}
}
@@ -262,7 +270,9 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa
if (_gameRef->_editorMode) {
delete[] _editorBgFile;
_editorBgFile = new char[strlen((char *)params) + 1];
- if (_editorBgFile) strcpy(_editorBgFile, (char *)params);
+ if (_editorBgFile) {
+ strcpy(_editorBgFile, (char *)params);
+ }
}
break;
@@ -282,7 +292,9 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa
case TOKEN_FRAME: {
int FrameLifeTime = lifeTime;
- if (cacheType == CACHE_HALF && frameCount % 2 != 1) FrameLifeTime = -1;
+ if (cacheType == CACHE_HALF && frameCount % 2 != 1) {
+ FrameLifeTime = -1;
+ }
frame = new BaseFrame(_gameRef);
@@ -294,7 +306,9 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa
_frames.add(frame);
frameCount++;
- if (_currentFrame == -1) _currentFrame = 0;
+ if (_currentFrame == -1) {
+ _currentFrame = 0;
+ }
}
break;
@@ -316,8 +330,11 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa
//////////////////////////////////////////////////////////////////////
void BaseSprite::reset() {
- if (_frames.getSize() > 0) _currentFrame = 0;
- else _currentFrame = -1;
+ if (_frames.getSize() > 0) {
+ _currentFrame = 0;
+ } else {
+ _currentFrame = -1;
+ }
killAllSounds();
@@ -331,11 +348,16 @@ void BaseSprite::reset() {
bool BaseSprite::GetCurrentFrame(float zoomX, float zoomY) {
//if (_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true;
- if (_currentFrame == -1) return false;
+ if (_currentFrame == -1) {
+ return false;
+ }
uint32 timer;
- if (_owner && _owner->_freezable) timer = _gameRef->_timer;
- else timer = _gameRef->_liveTimer;
+ if (_owner && _owner->_freezable) {
+ timer = _gameRef->_timer;
+ } else {
+ timer = _gameRef->_liveTimer;
+ }
int lastFrame = _currentFrame;
@@ -343,7 +365,9 @@ bool BaseSprite::GetCurrentFrame(float zoomX, float zoomY) {
if (!_paused && !_finished && timer >= _lastFrameTime + _frames[_currentFrame]->_delay && _lastFrameTime != 0) {
if (_currentFrame < _frames.getSize() - 1) {
_currentFrame++;
- if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1);
+ if (_continuous) {
+ _canBreak = (_currentFrame == _frames.getSize() - 1);
+ }
} else {
if (_looping) {
_currentFrame = 0;
@@ -362,7 +386,9 @@ bool BaseSprite::GetCurrentFrame(float zoomX, float zoomY) {
if (_lastFrameTime == 0) {
_lastFrameTime = timer;
_changed = true;
- if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1);
+ if (_continuous) {
+ _canBreak = (_currentFrame == _frames.getSize() - 1);
+ }
}
if (_changed) {
@@ -381,7 +407,9 @@ bool BaseSprite::GetCurrentFrame(float zoomX, float zoomY) {
//////////////////////////////////////////////////////////////////////
bool BaseSprite::display(int X, int Y, BaseObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) {
- if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK;
+ if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) {
+ return STATUS_OK;
+ }
// on change...
if (_changed) {
@@ -400,18 +428,27 @@ bool BaseSprite::display(int X, int Y, BaseObject *Register, float ZoomX, float
//////////////////////////////////////////////////////////////////////////
BaseSurface *BaseSprite::getSurface() {
// only used for animated textures for 3D models
- if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return NULL;
- BaseFrame *Frame = _frames[_currentFrame];
- if (Frame && Frame->_subframes.getSize() > 0) {
- BaseSubFrame *Subframe = Frame->_subframes[0];
- if (Subframe) return Subframe->_surface;
- else return NULL;
- } else return NULL;
+ if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) {
+ return NULL;
+ }
+ BaseFrame *frame = _frames[_currentFrame];
+ if (frame && frame->_subframes.getSize() > 0) {
+ BaseSubFrame *subframe = frame->_subframes[0];
+ if (subframe) {
+ return subframe->_surface;
+ } else {
+ return NULL;
+ }
+ } else {
+ return NULL;
+ }
}
//////////////////////////////////////////////////////////////////////////
bool BaseSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) {
- if (!rect) return false;
+ if (!rect) {
+ return false;
+ }
BasePlatform::setRectEmpty(rect);
for (int i = 0; i < _frames.getSize(); i++) {
@@ -434,12 +471,14 @@ bool BaseSprite::saveAsText(BaseDynamicBuffer *buffer, int indent) {
if (_streamed) {
buffer->putTextIndent(indent + 2, "STREAMED=%s\n", _streamed ? "TRUE" : "FALSE");
- if (_streamedKeepLoaded)
+ if (_streamedKeepLoaded) {
buffer->putTextIndent(indent + 2, "STREAMED_KEEP_LOADED=%s\n", _streamedKeepLoaded ? "TRUE" : "FALSE");
+ }
}
- if (_editorMuted)
+ if (_editorMuted) {
buffer->putTextIndent(indent + 2, "EDITOR_MUTED=%s\n", _editorMuted ? "TRUE" : "FALSE");
+ }
if (_editorBgFile) {
buffer->putTextIndent(indent + 2, "EDITOR_BG_FILE=\"%s\"\n", _editorBgFile);
@@ -514,7 +553,9 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
if (Index < 0 || Index >= _frames.getSize()) {
script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", Index);
stack->pushNULL();
- } else stack->pushNative(_frames[Index], true);
+ } else {
+ stack->pushNative(_frames[Index], true);
+ }
return STATUS_OK;
}
@@ -523,17 +564,19 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "DeleteFrame") == 0) {
stack->correctParams(1);
- ScValue *Val = stack->pop();
- if (Val->isInt()) {
- int Index = Val->getInt(-1);
- if (Index < 0 || Index >= _frames.getSize()) {
- script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index);
+ ScValue *val = stack->pop();
+ if (val->isInt()) {
+ int index = val->getInt(-1);
+ if (index < 0 || index >= _frames.getSize()) {
+ script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", index);
}
} else {
- BaseFrame *Frame = (BaseFrame *)Val->getNative();
+ BaseFrame *frame = (BaseFrame *)val->getNative();
for (int i = 0; i < _frames.getSize(); i++) {
- if (_frames[i] == Frame) {
- if (i == _currentFrame) _lastFrameTime = 0;
+ if (_frames[i] == frame) {
+ if (i == _currentFrame) {
+ _lastFrameTime = 0;
+ }
delete _frames[i];
_frames.removeAt(i);
break;
@@ -561,7 +604,9 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
stack->correctParams(1);
ScValue *val = stack->pop();
const char *filename = NULL;
- if (!val->isNULL()) filename = val->getString();
+ if (!val->isNULL()) {
+ filename = val->getString();
+ }
BaseFrame *frame = new BaseFrame(_gameRef);
if (filename != NULL) {
@@ -569,7 +614,9 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
if (DID_SUCCEED(sub->setSurface(filename))) {
sub->setDefaultRect();
frame->_subframes.add(sub);
- } else delete sub;
+ } else {
+ delete sub;
+ }
}
_frames.add(frame);
@@ -583,24 +630,31 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
else if (strcmp(name, "InsertFrame") == 0) {
stack->correctParams(2);
int index = stack->pop()->getInt();
- if (index < 0)
+ if (index < 0) {
index = 0;
+ }
ScValue *val = stack->pop();
const char *filename = NULL;
- if (!val->isNULL())
+ if (!val->isNULL()) {
filename = val->getString();
+ }
BaseFrame *frame = new BaseFrame(_gameRef);
if (filename != NULL) {
BaseSubFrame *sub = new BaseSubFrame(_gameRef);
- if (DID_SUCCEED(sub->setSurface(filename))) frame->_subframes.add(sub);
- else delete sub;
+ if (DID_SUCCEED(sub->setSurface(filename))) {
+ frame->_subframes.add(sub);
+ } else {
+ delete sub;
+ }
}
- if (index >= _frames.getSize())
+ if (index >= _frames.getSize()) {
_frames.add(frame);
- else _frames.insertAt(index, frame);
+ } else {
+ _frames.insertAt(index, frame);
+ }
stack->pushNative(frame, true);
return STATUS_OK;
@@ -624,9 +678,9 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta
_paused = false;
stack->pushNULL();
return STATUS_OK;
+ } else {
+ return BaseScriptHolder::scCallMethod(script, stack, thisStack, name);
}
-
- else return BaseScriptHolder::scCallMethod(script, stack, thisStack, name);
}
@@ -678,8 +732,11 @@ ScValue *BaseSprite::scGetProperty(const char *name) {
// Owner (RO)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Owner") == 0) {
- if (_owner == NULL) _scValue->setNULL();
- else _scValue->setNative(_owner, true);
+ if (_owner == NULL) {
+ _scValue->setNULL();
+ } else {
+ _scValue->setNative(_owner, true);
+ }
return _scValue;
}
@@ -697,9 +754,9 @@ ScValue *BaseSprite::scGetProperty(const char *name) {
else if (strcmp(name, "Paused") == 0) {
_scValue->setBool(_paused);
return _scValue;
+ } else {
+ return BaseScriptHolder::scGetProperty(name);
}
-
- else return BaseScriptHolder::scGetProperty(name);
}
@@ -731,9 +788,9 @@ bool BaseSprite::scSetProperty(const char *name, ScValue *value) {
else if (strcmp(name, "Looping") == 0) {
_looping = value->getBool();
return STATUS_OK;
+ } else {
+ return BaseScriptHolder::scSetProperty(name, value);
}
-
- else return BaseScriptHolder::scSetProperty(name, value);
}
@@ -746,8 +803,9 @@ const char *BaseSprite::scToString() {
//////////////////////////////////////////////////////////////////////////
bool BaseSprite::killAllSounds() {
for (int i = 0; i < _frames.getSize(); i++) {
- if (_frames[i]->_sound)
+ if (_frames[i]->_sound) {
_frames[i]->_sound->stop();
+ }
}
return STATUS_OK;
}
diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp
index 58cf046436..18a18fe0ba 100644
--- a/engines/wintermute/base/base_string_table.cpp
+++ b/engines/wintermute/base/base_string_table.cpp
@@ -51,8 +51,9 @@ BaseStringTable::~BaseStringTable() {
//////////////////////////////////////////////////////////////////////////
bool BaseStringTable::addString(const char *key, const char *val, bool reportDuplicities) {
- if (key == NULL || val == NULL)
+ if (key == NULL || val == NULL) {
return STATUS_FAILED;
+ }
if (scumm_stricmp(key, "@right-to-left") == 0) {
_gameRef->_textRTL = true;
@@ -63,8 +64,9 @@ bool BaseStringTable::addString(const char *key, const char *val, bool reportDup
finalKey.toLowercase();
StringsIter it = _strings.find(finalKey);
- if (it != _strings.end() && reportDuplicities)
+ if (it != _strings.end() && reportDuplicities) {
_gameRef->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str());
+ }
_strings[finalKey] = val;
@@ -73,12 +75,14 @@ bool BaseStringTable::addString(const char *key, const char *val, bool reportDup
//////////////////////////////////////////////////////////////////////////
char *BaseStringTable::getKey(const char *str) const {
- if (str == NULL || str[0] != '/')
+ if (str == NULL || str[0] != '/') {
return NULL;
+ }
const char *value = strchr(str + 1, '/');
- if (value == NULL)
+ if (value == NULL) {
return NULL;
+ }
char *key = new char[value - str];
Common::strlcpy(key, str + 1, (size_t)(value - str));
@@ -107,12 +111,14 @@ char *BaseStringTable::getKey(const char *str) const {
//////////////////////////////////////////////////////////////////////////
void BaseStringTable::expand(char **str) const {
- if (str == NULL || *str == NULL || *str[0] != '/')
+ if (str == NULL || *str == NULL || *str[0] != '/') {
return;
+ }
char *value = strchr(*str + 1, '/');
- if (value == NULL)
+ if (value == NULL) {
return;
+ }
char *key = new char[value - *str];
Common::strlcpy(key, *str + 1, (size_t)(value - *str));
@@ -136,19 +142,22 @@ void BaseStringTable::expand(char **str) const {
delete[] *str;
*str = newStr;
- if (strlen(*str) > 0 && *str[0] == '/')
+ if (strlen(*str) > 0 && *str[0] == '/') {
expand(str);
+ }
}
//////////////////////////////////////////////////////////////////////////
const char *BaseStringTable::expandStatic(const char *string) const {
- if (string == NULL || string[0] == '\0' || string[0] != '/')
+ if (string == NULL || string[0] == '\0' || string[0] != '/') {
return string;
+ }
const char *value = strchr(string + 1, '/');
- if (value == NULL)
+ if (value == NULL) {
return string;
+ }
char *key = new char[value - string];
Common::strlcpy(key, string + 1, (size_t)(value - string - 1));
@@ -167,10 +176,11 @@ const char *BaseStringTable::expandStatic(const char *string) const {
delete[] key;
- if (strlen(newStr) > 0 && newStr[0] == '/')
+ if (strlen(newStr) > 0 && newStr[0] == '/') {
return expandStatic(newStr);
- else
+ } else {
return newStr;
+ }
}
@@ -178,8 +188,9 @@ const char *BaseStringTable::expandStatic(const char *string) const {
bool BaseStringTable::loadFile(const char *filename, bool clearOld) {
_gameRef->LOG(0, "Loading string table...");
- if (clearOld)
+ if (clearOld) {
_strings.clear();
+ }
uint32 size;
byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size);
@@ -197,27 +208,33 @@ bool BaseStringTable::loadFile(const char *filename, bool clearOld) {
//_gameRef->_textEncoding = TEXT_ANSI;
_gameRef->LOG(0, " UTF8 file detected, switching to UTF8 text encoding");
}
- } else _gameRef->_textEncoding = TEXT_ANSI;
+ } else {
+ _gameRef->_textEncoding = TEXT_ANSI;
+ }
uint32 lineLength = 0;
while (pos < size) {
lineLength = 0;
- while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0')
+ while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') {
lineLength++;
+ }
uint32 realLength = lineLength - (pos + lineLength >= size ? 0 : 1);
char *line = new char[realLength + 1];
Common::strlcpy(line, (char *)&buffer[pos], realLength + 1);
char *value = strchr(line, '\t');
- if (value == NULL) value = strchr(line, ' ');
+ if (value == NULL) {
+ value = strchr(line, ' ');
+ }
if (line[0] != ';') {
if (value != NULL) {
value[0] = '\0';
value++;
for (uint32 i = 0; i < strlen(value); i++) {
- if (value[i] == '|')
+ if (value[i] == '|') {
value[i] = '\n';
+ }
}
addString(line, value, clearOld);
} else if (line[0] != '\0') {
diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp
index 523bbed866..e8290ee659 100644
--- a/engines/wintermute/base/base_sub_frame.cpp
+++ b/engines/wintermute/base/base_sub_frame.cpp
@@ -67,7 +67,9 @@ BaseSubFrame::BaseSubFrame(BaseGame *inGame): BaseScriptable(inGame, true) {
//////////////////////////////////////////////////////////////////////////
BaseSubFrame::~BaseSubFrame() {
- if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface);
+ if (_surface) {
+ _gameRef->_surfaceStorage->removeSurface(_surface);
+ }
delete[] _surfaceFilename;
_surfaceFilename = NULL;
}
@@ -181,12 +183,17 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) {
}
if (surfaceFile != NULL) {
- if (custoTrans) setSurface(surfaceFile, false, r, g, b, lifeTime, keepLoaded);
- else setSurface(surfaceFile, true, 0, 0, 0, lifeTime, keepLoaded);
+ if (custoTrans) {
+ setSurface(surfaceFile, false, r, g, b, lifeTime, keepLoaded);
+ } else {
+ setSurface(surfaceFile, true, 0, 0, 0, lifeTime, keepLoaded);
+ }
}
_alpha = BYTETORGBA(ar, ag, ab, alpha);
- if (custoTrans) _transparent = BYTETORGBA(r, g, b, 0xFF);
+ if (custoTrans) {
+ _transparent = BYTETORGBA(r, g, b, 0xFF);
+ }
/*
if (_surface == NULL)
@@ -195,8 +202,11 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) {
return STATUS_FAILED;
}
*/
- if (BasePlatform::isRectEmpty(&rect)) setDefaultRect();
- else _rect = rect;
+ if (BasePlatform::isRectEmpty(&rect)) {
+ setDefaultRect();
+ } else {
+ _rect = rect;
+ }
return STATUS_OK;
}
@@ -204,7 +214,9 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) {
//////////////////////////////////////////////////////////////////////
bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) {
- if (!_surface) return STATUS_OK;
+ if (!_surface) {
+ return STATUS_OK;
+ }
if (registerOwner != NULL && !_decoration) {
if (zoomX == 100 && zoomY == 100) {
@@ -213,18 +225,25 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl
_gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise));
}
}
- if (_gameRef->_suspendedRendering) return STATUS_OK;
+ if (_gameRef->_suspendedRendering) {
+ return STATUS_OK;
+ }
bool res;
//if (Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha)
- if (_alpha != 0xFFFFFFFF) alpha = _alpha;
+ if (_alpha != 0xFFFFFFFF) {
+ alpha = _alpha;
+ }
if (rotate != 0.0f) {
res = _surface->displayTransform((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _hotspotX, _hotspotY, _rect, zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY);
} else {
- if (zoomX == 100 && zoomY == 100) res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, _rect, alpha, blendMode, _mirrorX, _mirrorY);
- else res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _rect, zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY);
+ if (zoomX == 100 && zoomY == 100) {
+ res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, _rect, alpha, blendMode, _mirrorX, _mirrorY);
+ } else {
+ res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _rect, zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY);
+ }
}
return res;
@@ -233,7 +252,9 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl
//////////////////////////////////////////////////////////////////////////
bool BaseSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) {
- if (!rect) return false;
+ if (!rect) {
+ return false;
+ }
float ratioX = scaleX / 100.0f;
float ratioY = scaleY / 100.0f;
@@ -249,52 +270,66 @@ bool BaseSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, flo
//////////////////////////////////////////////////////////////////////////
bool BaseSubFrame::saveAsText(BaseDynamicBuffer *buffer, int indent, bool complete) {
- if (complete)
+ if (complete) {
buffer->putTextIndent(indent, "SUBFRAME {\n");
+ }
- if (_surface && _surface->getFileNameStr() != "")
+ if (_surface && _surface->getFileNameStr() != "") {
buffer->putTextIndent(indent + 2, "IMAGE = \"%s\"\n", _surface->getFileName());
+ }
- if (_transparent != 0xFFFF00FF)
+ if (_transparent != 0xFFFF00FF) {
buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", RGBCOLGetR(_transparent), RGBCOLGetG(_transparent), RGBCOLGetB(_transparent));
+ }
Rect32 rect;
BasePlatform::setRectEmpty(&rect);
- if (_surface) BasePlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight());
- if (!(rect == _rect))
+ if (_surface) {
+ BasePlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight());
+ }
+ if (!(rect == _rect)) {
buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom);
+ }
- if (_hotspotX != 0 || _hotspotY != 0)
+ if (_hotspotX != 0 || _hotspotY != 0) {
buffer->putTextIndent(indent + 2, "HOTSPOT {%d, %d}\n", _hotspotX, _hotspotY);
+ }
if (_alpha != 0xFFFFFFFF) {
buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alpha), RGBCOLGetG(_alpha), RGBCOLGetB(_alpha));
buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alpha));
}
- if (_mirrorX)
+ if (_mirrorX) {
buffer->putTextIndent(indent + 2, "MIRROR_X=%s\n", _mirrorX ? "TRUE" : "FALSE");
+ }
- if (_mirrorY)
+ if (_mirrorY) {
buffer->putTextIndent(indent + 2, "MIRROR_Y=%s\n", _mirrorY ? "TRUE" : "FALSE");
+ }
- if (_2DOnly)
+ if (_2DOnly) {
buffer->putTextIndent(indent + 2, "2D_ONLY=%s\n", _2DOnly ? "TRUE" : "FALSE");
+ }
- if (_3DOnly)
+ if (_3DOnly) {
buffer->putTextIndent(indent + 2, "3D_ONLY=%s\n", _3DOnly ? "TRUE" : "FALSE");
+ }
- if (_decoration)
+ if (_decoration) {
buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE");
+ }
- if (_editorSelected)
+ if (_editorSelected) {
buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE");
+ }
BaseClass::saveAsText(buffer, indent + 2);
- if (complete)
+ if (complete) {
buffer->putTextIndent(indent, "}\n\n");
+ }
return STATUS_OK;
}
@@ -304,7 +339,9 @@ bool BaseSubFrame::saveAsText(BaseDynamicBuffer *buffer, int indent, bool comple
void BaseSubFrame::setDefaultRect() {
if (_surface) {
BasePlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight());
- } else BasePlatform::setRectEmpty(&_rect);
+ } else {
+ BasePlatform::setRectEmpty(&_rect);
+ }
}
@@ -349,8 +386,11 @@ bool BaseSubFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS
if (strcmp(name, "GetImage") == 0) {
stack->correctParams(0);
- if (!_surfaceFilename) stack->pushNULL();
- else stack->pushString(_surfaceFilename);
+ if (!_surfaceFilename) {
+ stack->pushNULL();
+ } else {
+ stack->pushString(_surfaceFilename);
+ }
return STATUS_OK;
}
@@ -359,31 +399,37 @@ bool BaseSubFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetImage") == 0) {
stack->correctParams(1);
- ScValue *Val = stack->pop();
+ ScValue *val = stack->pop();
- if (Val->isNULL()) {
- if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface);
+ if (val->isNULL()) {
+ if (_surface) {
+ _gameRef->_surfaceStorage->removeSurface(_surface);
+ }
delete[] _surfaceFilename;
_surfaceFilename = NULL;
stack->pushBool(true);
} else {
- const char *filename = Val->getString();
+ const char *filename = val->getString();
if (DID_SUCCEED(setSurface(filename))) {
setDefaultRect();
stack->pushBool(true);
- } else stack->pushBool(false);
+ } else {
+ stack->pushBool(false);
+ }
}
return STATUS_OK;
+ } else {
+ return BaseScriptable::scCallMethod(script, stack, thisStack, name);
}
-
- else return BaseScriptable::scCallMethod(script, stack, thisStack, name);
}
//////////////////////////////////////////////////////////////////////////
ScValue *BaseSubFrame::scGetProperty(const char *name) {
- if (!_scValue) _scValue = new ScValue(_gameRef);
+ if (!_scValue) {
+ _scValue = new ScValue(_gameRef);
+ }
_scValue->setNULL();
//////////////////////////////////////////////////////////////////////////
@@ -465,9 +511,9 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) {
else if (strcmp(name, "HotspotY") == 0) {
_scValue->setInt(_hotspotY);
return _scValue;
+ } else {
+ return BaseScriptable::scGetProperty(name);
}
-
- else return BaseScriptable::scGetProperty(name);
}
@@ -535,9 +581,9 @@ bool BaseSubFrame::scSetProperty(const char *name, ScValue *value) {
else if (strcmp(name, "HotspotY") == 0) {
_hotspotY = value->getInt();
return STATUS_OK;
+ } else {
+ return BaseScriptable::scSetProperty(name, value);
}
-
- else return BaseScriptable::scSetProperty(name, value);
}
@@ -570,7 +616,9 @@ bool BaseSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed,
_keepLoaded = keepLoaded;
return STATUS_OK;
- } else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
}
@@ -581,8 +629,11 @@ bool BaseSubFrame::setSurfaceSimple() {
return STATUS_OK;
}
_surface = _gameRef->_surfaceStorage->addSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded);
- if (_surface) return STATUS_OK;
- else return STATUS_FAILED;
+ if (_surface) {
+ return STATUS_OK;
+ } else {
+ return STATUS_FAILED;
+ }
}
} // end of namespace WinterMute
diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp
index d8ba0cbbce..3d878b1346 100644
--- a/engines/wintermute/base/base_surface_storage.cpp
+++ b/engines/wintermute/base/base_surface_storage.cpp
@@ -52,7 +52,9 @@ BaseSurfaceStorage::~BaseSurfaceStorage() {
//////////////////////////////////////////////////////////////////////////
bool BaseSurfaceStorage::cleanup(bool warn) {
for (uint32 i = 0; i < _surfaces.size(); i++) {
- if (warn) _gameRef->LOG(0, "BaseSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount);
+ if (warn) {
+ _gameRef->LOG(0, "BaseSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount);
+ }
delete _surfaces[i];
}
_surfaces.clear();
@@ -67,7 +69,9 @@ bool BaseSurfaceStorage::initLoop() {
_lastCleanupTime = _gameRef->_liveTimer;
sortSurfaces();
for (uint32 i = 0; i < _surfaces.size(); i++) {
- if (_surfaces[i]->_lifeTime <= 0) break;
+ if (_surfaces[i]->_lifeTime <= 0) {
+ break;
+ }
if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) {
//_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename);
@@ -105,17 +109,22 @@ BaseSurface *BaseSurfaceStorage::addSurface(const char *filename, bool defaultCK
}
if (!_gameRef->_fileManager->hasFile(filename)) {
- if (filename) _gameRef->LOG(0, "Missing image: '%s'", filename);
- if (_gameRef->_debugDebugMode)
+ if (filename) {
+ _gameRef->LOG(0, "Missing image: '%s'", filename);
+ }
+ if (_gameRef->_debugDebugMode) {
return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded);
- else
+ } else {
return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded);
+ }
}
BaseSurface *surface;
surface = _gameRef->_renderer->createSurface();
- if (!surface) return NULL;
+ if (!surface) {
+ return NULL;
+ }
if (DID_FAIL(surface->create(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded))) {
delete surface;
@@ -171,18 +180,28 @@ int BaseSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) {
BaseSurface *s2 = *((BaseSurface **)arg2);
// sort by life time
- if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) return 1;
- else if (s1->_lifeTime > 0 && s2->_lifeTime <= 0) return -1;
+ if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) {
+ return 1;
+ } else if (s1->_lifeTime > 0 && s2->_lifeTime <= 0) {
+ return -1;
+ }
// sort by validity
- if (s1->_valid && !s2->_valid) return -1;
- else if (!s1->_valid && s2->_valid) return 1;
+ if (s1->_valid && !s2->_valid) {
+ return -1;
+ } else if (!s1->_valid && s2->_valid) {
+ return 1;
+ }
// sort by time
- else if (s1->_lastUsedTime > s2->_lastUsedTime) return 1;
- else if (s1->_lastUsedTime < s2->_lastUsedTime) return -1;
- else return 0;
+ else if (s1->_lastUsedTime > s2->_lastUsedTime) {
+ return 1;
+ } else if (s1->_lastUsedTime < s2->_lastUsedTime) {
+ return -1;
+ } else {
+ return 0;
+ }
}
} // end of namespace WinterMute
diff --git a/engines/wintermute/base/base_transition_manager.cpp b/engines/wintermute/base/base_transition_manager.cpp
index eeaacd2063..7a78865552 100644
--- a/engines/wintermute/base/base_transition_manager.cpp
+++ b/engines/wintermute/base/base_transition_manager.cpp
@@ -57,7 +57,9 @@ bool BaseTransitionMgr::isReady() {
//////////////////////////////////////////////////////////////////////////
bool BaseTransitionMgr::start(TTransitionType type, bool nonInteractive) {
- if (_state != TRANS_MGR_READY) return STATUS_OK;
+ if (_state != TRANS_MGR_READY) {
+ return STATUS_OK;
+ }
if (type == TRANSITION_NONE || type >= NUM_TRANSITION_TYPES) {
_state = TRANS_MGR_READY;
@@ -82,7 +84,9 @@ bool BaseTransitionMgr::start(TTransitionType type, bool nonInteractive) {
//////////////////////////////////////////////////////////////////////////
bool BaseTransitionMgr::update() {
- if (isReady()) return STATUS_OK;
+ if (isReady()) {
+ return STATUS_OK;
+ }
if (!_started) {
_started = true;
@@ -100,8 +104,9 @@ bool BaseTransitionMgr::update() {
alpha = MIN(255, MAX(alpha, 0));
_gameRef->_renderer->fade((uint16)alpha);
- if (time > FADE_DURATION)
+ if (time > FADE_DURATION) {
_state = TRANS_MGR_READY;
+ }
}
break;
@@ -111,8 +116,9 @@ bool BaseTransitionMgr::update() {
alpha = MIN(255, MAX(alpha, 0));
_gameRef->_renderer->fade((uint16)alpha);
- if (time > FADE_DURATION)
+ if (time > FADE_DURATION) {
_state = TRANS_MGR_READY;
+ }
}
break;
default:
@@ -120,8 +126,9 @@ bool BaseTransitionMgr::update() {
}
if (isReady()) {
- if (_preserveInteractive)
+ if (_preserveInteractive) {
_gameRef->_interactive = _origInteractive;
+ }
}
return STATUS_OK;
}
diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp
index bb8504d2f4..7d805aedb5 100644
--- a/engines/wintermute/base/file/base_disk_file.cpp
+++ b/engines/wintermute/base/file/base_disk_file.cpp
@@ -41,7 +41,9 @@ namespace WinterMute {
void correctSlashes(char *fileName) {
for (size_t i = 0; i < strlen(fileName); i++) {
- if (fileName[i] == '\\') fileName[i] = '/';
+ if (fileName[i] == '\\') {
+ fileName[i] = '/';
+ }
}
}
@@ -51,8 +53,9 @@ static Common::FSNode getNodeForRelativePath(const Common::String &filename) {
// specifies to follow the Windows-convention of folder\subfolder\file (absolute paths should not happen)
// Absolute path: TODO: Add specific fallbacks here.
- if (filename.contains(':'))
+ if (filename.contains(':')) {
error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str());
+ }
// Relative path:
if (filename.contains('\\')) {
@@ -132,7 +135,9 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) {
magic2 = file->readUint32LE();
bool compressed = false;
- if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) compressed = true;
+ if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) {
+ compressed = true;
+ }
if (compressed) {
uint32 dataOffset, compSize, uncompSize;
diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp
index 8282079c86..7bf635b858 100644
--- a/engines/wintermute/base/file/base_file_entry.cpp
+++ b/engines/wintermute/base/file/base_file_entry.cpp
@@ -61,7 +61,9 @@ public:
Common::SeekableReadStream *BaseFileEntry::createReadStream() const {
Common::SeekableReadStream *file = _package->getFilePointer();
- if (!file) return NULL;
+ if (!file) {
+ return NULL;
+ }
// TODO: Cleanup
bool compressed = (_compressedLength != 0);
diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp
index f2d2378c6a..b41ae3c1bd 100644
--- a/engines/wintermute/base/file/base_package.cpp
+++ b/engines/wintermute/base/file/base_package.cpp
@@ -64,7 +64,9 @@ static bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset)
uint32 toRead = MIN((unsigned int)32768, fileSize - bytesRead);
f->seek((int32)startPos, SEEK_SET);
uint32 actuallyRead = f->read(buf, toRead);
- if (actuallyRead != toRead) return false;
+ if (actuallyRead != toRead) {
+ return false;
+ }
for (uint32 i = 0; i < toRead - 8; i++)
if (!memcmp(buf + i, signature, 8)) {
@@ -85,8 +87,9 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool
_priority = 0;
bool boundToExe = false;
Common::SeekableReadStream *stream = file.createReadStream();
- if (!stream)
+ if (!stream) {
return;
+ }
if (searchSignature) {
uint32 offset;
if (!findPackageSignature(stream, &offset)) {
@@ -121,7 +124,9 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool
assert(hdr._numDirs == 1);
for (uint32 i = 0; i < hdr._numDirs; i++) {
BasePackage *pkg = new BasePackage();
- if (!pkg) return;
+ if (!pkg) {
+ return;
+ }
pkg->_fsnode = file;
pkg->_boundToExe = boundToExe;
@@ -136,7 +141,9 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool
delete[] pkgName;
pkgName = NULL;
- if (!hdr._masterIndex) pkg->_cd = 0; // override CD to fixed disk
+ if (!hdr._masterIndex) {
+ pkg->_cd = 0; // override CD to fixed disk
+ }
_packages.push_back(pkg);
// read file entries
@@ -242,8 +249,9 @@ Common::SeekableReadStream *PackageSet::createReadStreamForMember(const Common::
upcName.toUppercase();
Common::HashMap<Common::String, Common::ArchiveMemberPtr>::const_iterator it;
it = _files.find(upcName.c_str());
- if (it != _files.end())
+ if (it != _files.end()) {
return it->_value->createReadStream();
+ }
return NULL;
}
diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp
index 0a0d0cac09..e067241589 100644
--- a/engines/wintermute/base/file/base_save_thumb_file.cpp
+++ b/engines/wintermute/base/file/base_save_thumb_file.cpp
@@ -53,7 +53,9 @@ BaseSaveThumbFile::~BaseSaveThumbFile() {
bool BaseSaveThumbFile::open(const Common::String &filename) {
close();
- if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) return STATUS_FAILED;
+ if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) {
+ return STATUS_FAILED;
+ }
char *tempFilename = new char[strlen(filename.c_str()) - 8];
strcpy(tempFilename, filename.c_str() + 9);
@@ -70,7 +72,9 @@ bool BaseSaveThumbFile::open(const Common::String &filename) {
BasePersistenceManager *pm = new BasePersistenceManager(_gameRef);
Common::String slotFilename = pm->getFilenameForSlot(slot);
- if (!pm) return STATUS_FAILED;
+ if (!pm) {
+ return STATUS_FAILED;
+ }
if (DID_FAIL(pm->initLoad(slotFilename))) {
delete pm;
@@ -84,7 +88,9 @@ bool BaseSaveThumbFile::open(const Common::String &filename) {
memcpy(_data, pm->_thumbnailData, pm->_thumbnailDataSize);
_size = pm->_thumbnailDataSize;
res = STATUS_OK;
- } else res = STATUS_FAILED;
+ } else {
+ res = STATUS_FAILED;
+ }
delete pm;
return res;
@@ -105,7 +111,9 @@ bool BaseSaveThumbFile::close() {
//////////////////////////////////////////////////////////////////////////
bool BaseSaveThumbFile::read(void *buffer, uint32 size) {
- if (!_data || _pos + size > _size) return STATUS_FAILED;
+ if (!_data || _pos + size > _size) {
+ return STATUS_FAILED;
+ }
memcpy(buffer, (byte *)_data + _pos, size);
_pos += size;
@@ -116,7 +124,9 @@ bool BaseSaveThumbFile::read(void *buffer, uint32 size) {
//////////////////////////////////////////////////////////////////////////
bool BaseSaveThumbFile::seek(uint32 pos, int whence) {
- if (!_data) return STATUS_FAILED;
+ if (!_data) {
+ return STATUS_FAILED;
+ }
uint32 newPos = 0;
@@ -132,8 +142,11 @@ bool BaseSaveThumbFile::seek(uint32 pos, int whence) {
break;
}
- if (newPos > _size) return STATUS_FAILED;
- else _pos = newPos;
+ if (newPos > _size) {
+ return STATUS_FAILED;
+ } else {
+ _pos = newPos;
+ }
return STATUS_OK;
}
diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp
index d576b834a2..937557f4d7 100644
--- a/engines/wintermute/base/font/base_font.cpp
+++ b/engines/wintermute/base/font/base_font.cpp
@@ -187,7 +187,9 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const char *filename) {
byte *buffer = gameRef->_fileManager->readWholeFile(filename);
- if (buffer == NULL) return false;
+ if (buffer == NULL) {
+ return false;
+ }
byte *WorkBuffer = buffer;
@@ -195,8 +197,9 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const char *filename) {
BaseParser parser(gameRef);
bool ret = false;
- if (parser.getCommand((char **)&WorkBuffer, commands, (char **)&params) == TOKEN_TTFONT)
+ if (parser.getCommand((char **)&WorkBuffer, commands, (char **)&params) == TOKEN_TTFONT) {
ret = true;
+ }
delete[] buffer;
return ret;
diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp
index dd6c6da327..9cce8ca9ee 100644
--- a/engines/wintermute/base/font/base_font_bitmap.cpp
+++ b/engines/wintermute/base/font/base_font_bitmap.cpp
@@ -91,8 +91,9 @@ int BaseFontBitmap::getTextWidth(byte *text, int maxLength) {
str = AnsiString((char *)text);
}
- if (maxLength >= 0 && str.size() > (uint32)maxLength)
+ if (maxLength >= 0 && str.size() > (uint32)maxLength) {
str = Common::String(str.c_str(), (uint32)maxLength);
+ }
//str.substr(0, maxLength); // TODO: Remove
int textWidth = 0;
@@ -106,9 +107,13 @@ int BaseFontBitmap::getTextWidth(byte *text, int maxLength) {
//////////////////////////////////////////////////////////////////////
int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) {
- if (maxLength == 0) return 0;
+ if (maxLength == 0) {
+ return 0;
+ }
- if (text == NULL || text[0] == '\0') return _tileHeight;
+ if (text == NULL || text[0] == '\0') {
+ return _tileHeight;
+ }
AnsiString str;
@@ -118,7 +123,9 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli
} else {
str = AnsiString((char *)text);
}
- if (str.empty()) return 0;
+ if (str.empty()) {
+ return 0;
+ }
int LineLength = 0;
int RealLength = 0;
@@ -135,11 +142,15 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli
bool new_line = false;
bool long_line = false;
- if (draw) _gameRef->_renderer->startSpriteBatch();
+ if (draw) {
+ _gameRef->_renderer->startSpriteBatch();
+ }
while (!done) {
if (maxHeight > 0 && (NumLines + 1)*_tileHeight > maxHeight) {
- if (draw) _gameRef->_renderer->endSpriteBatch();
+ if (draw) {
+ _gameRef->_renderer->endSpriteBatch();
+ }
return NumLines * _tileHeight;
}
@@ -170,10 +181,14 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli
LineLength += getCharWidth(str[index]);
RealLength = LineLength;
}
- } else LineLength += getCharWidth(str[index]);
+ } else {
+ LineLength += getCharWidth(str[index]);
+ }
if ((LineLength > width) || done || new_line) {
- if (end < 0) done = true;
+ if (end < 0) {
+ done = true;
+ }
int StartX;
switch (align) {
case TAL_CENTER:
@@ -190,12 +205,16 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli
break;
}
for (i = start; i < end + 1; i++) {
- if (draw) drawChar(str[i], StartX, y);
+ if (draw) {
+ drawChar(str[i], StartX, y);
+ }
StartX += getCharWidth(str[i]);
}
y += _tileHeight;
last_end = end;
- if (long_line) end--;
+ if (long_line) {
+ end--;
+ }
start = end + 2;
index = end + 1;
LineLength = 0;
@@ -205,7 +224,9 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli
}
}
- if (draw) _gameRef->_renderer->endSpriteBatch();
+ if (draw) {
+ _gameRef->_renderer->endSpriteBatch();
+ }
return NumLines * _tileHeight;
}
@@ -213,7 +234,9 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli
//////////////////////////////////////////////////////////////////////
void BaseFontBitmap::drawChar(byte c, int x, int y) {
- if (_fontextFix) c--;
+ if (_fontextFix) {
+ c--;
+ }
int row, col;
@@ -223,8 +246,11 @@ void BaseFontBitmap::drawChar(byte c, int x, int y) {
Rect32 rect;
/* l t r b */
int tileWidth;
- if (_wholeCell) tileWidth = _tileWidth;
- else tileWidth = _widths[c];
+ if (_wholeCell) {
+ tileWidth = _tileWidth;
+ } else {
+ tileWidth = _widths[c];
+ }
BasePlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight);
bool handled = false;
@@ -237,7 +263,9 @@ void BaseFontBitmap::drawChar(byte c, int x, int y) {
handled = true;
}
}
- if (!handled && _subframe) _subframe->_surface->displayTrans(x, y, rect);
+ if (!handled && _subframe) {
+ _subframe->_surface->displayTrans(x, y, rect);
+ }
}
@@ -253,7 +281,9 @@ bool BaseFontBitmap::loadFile(const char *filename) {
setFilename(filename);
- if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer))) {
+ _gameRef->LOG(0, "Error parsing FONT file '%s'", filename);
+ }
delete[] buffer;
@@ -408,8 +438,11 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) {
if (surfaceFile != NULL && !_sprite) {
_subframe = new BaseSubFrame(_gameRef);
- if (custoTrans) _subframe->setSurface(surfaceFile, false, r, g, b);
- else _subframe->setSurface(surfaceFile);
+ if (custoTrans) {
+ _subframe->setSurface(surfaceFile, false, r, g, b);
+ } else {
+ _subframe->setSurface(surfaceFile);
+ }
}
@@ -425,25 +458,32 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) {
// do we need to modify widths?
if (expandWidth != 0) {
for (i = 0; i < NUM_CHARACTERS; i++) {
- int NewWidth = (int)_widths[i] + expandWidth;
- if (NewWidth < 0) NewWidth = 0;
+ int newWidth = (int)_widths[i] + expandWidth;
+ if (newWidth < 0) {
+ newWidth = 0;
+ }
- _widths[i] = (byte)NewWidth;
+ _widths[i] = (byte)newWidth;
}
}
// handle space character
uint32 spaceChar = ' ';
- if (_fontextFix) spaceChar--;
+ if (_fontextFix) {
+ spaceChar--;
+ }
- if (spaceWidth != 0) _widths[spaceChar] = spaceWidth;
- else {
+ if (spaceWidth != 0) {
+ _widths[spaceChar] = spaceWidth;
+ } else {
if (_widths[spaceChar] == expandWidth || _widths[spaceChar] == 0) {
_widths[spaceChar] = (_widths['m'] + _widths['i']) / 2;
}
}
} else {
- for (i = lastWidth; i < NUM_CHARACTERS; i++) _widths[i] = default_width;
+ for (i = lastWidth; i < NUM_CHARACTERS; i++) {
+ _widths[i] = default_width;
+ }
}
@@ -463,10 +503,11 @@ bool BaseFontBitmap::persist(BasePersistenceManager *persistMgr) {
persistMgr->transfer(TMEMBER(_sprite));
persistMgr->transfer(TMEMBER(_widthsFrame));
- if (persistMgr->getIsSaving())
+ if (persistMgr->getIsSaving()) {
persistMgr->putBytes(_widths, sizeof(_widths));
- else
+ } else {
persistMgr->getBytes(_widths, sizeof(_widths));
+ }
persistMgr->transfer(TMEMBER(_fontextFix));
@@ -479,7 +520,9 @@ bool BaseFontBitmap::persist(BasePersistenceManager *persistMgr) {
//////////////////////////////////////////////////////////////////////////
int BaseFontBitmap::getCharWidth(byte index) {
- if (_fontextFix) index--;
+ if (_fontextFix) {
+ index--;
+ }
return _widths[index];
}
@@ -495,8 +538,12 @@ bool BaseFontBitmap::getWidths() {
}
}
}
- if (surf == NULL && _subframe) surf = _subframe->_surface;
- if (!surf || DID_FAIL(surf->startPixelOp())) return STATUS_FAILED;
+ if (surf == NULL && _subframe) {
+ surf = _subframe->_surface;
+ }
+ if (!surf || DID_FAIL(surf->startPixelOp())) {
+ return STATUS_FAILED;
+ }
for (int i = 0; i < NUM_CHARACTERS; i++) {
@@ -507,14 +554,18 @@ bool BaseFontBitmap::getWidths() {
int minCol = -1;
for (int row = 0; row < _tileHeight; row++) {
for (int col = _tileWidth - 1; col >= minCol + 1; col--) {
- if (xxx + col < 0 || xxx + col >= surf->getWidth() || yyy + row < 0 || yyy + row >= surf->getHeight()) continue;
+ if (xxx + col < 0 || xxx + col >= surf->getWidth() || yyy + row < 0 || yyy + row >= surf->getHeight()) {
+ continue;
+ }
if (!surf->isTransparentAtLite(xxx + col, yyy + row)) {
//min_col = col;
minCol = MAX(col, minCol);
break;
}
}
- if (minCol == _tileWidth - 1) break;
+ if (minCol == _tileWidth - 1) {
+ break;
+ }
}
_widths[i] = minCol + 1;
diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp
index 84c80c73cb..8b4fa74181 100644
--- a/engines/wintermute/base/font/base_font_storage.cpp
+++ b/engines/wintermute/base/font/base_font_storage.cpp
@@ -52,7 +52,9 @@ BaseFontStorage::~BaseFontStorage() {
//////////////////////////////////////////////////////////////////////////
bool BaseFontStorage::cleanup(bool warn) {
for (int i = 0; i < _fonts.getSize(); i++) {
- if (warn) _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->getFilename());
+ if (warn) {
+ _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->getFilename());
+ }
delete _fonts[i];
}
_fonts.removeAll();
@@ -70,7 +72,9 @@ bool BaseFontStorage::initLoop() {
//////////////////////////////////////////////////////////////////////////
BaseFont *BaseFontStorage::addFont(const char *filename) {
- if (!filename) return NULL;
+ if (!filename) {
+ return NULL;
+ }
for (int i = 0; i < _fonts.getSize(); i++) {
if (scumm_stricmp(_fonts[i]->getFilename(), filename) == 0) {
@@ -104,7 +108,9 @@ BaseFont *BaseFontStorage::addFont(const char *filename) {
//////////////////////////////////////////////////////////////////////////
bool BaseFontStorage::removeFont(BaseFont *font) {
- if (!font) return STATUS_FAILED;
+ if (!font) {
+ return STATUS_FAILED;
+ }
for (int i = 0; i < _fonts.getSize(); i++) {
if (_fonts[i] == font) {
@@ -123,7 +129,9 @@ bool BaseFontStorage::removeFont(BaseFont *font) {
//////////////////////////////////////////////////////////////////////////
bool BaseFontStorage::persist(BasePersistenceManager *persistMgr) {
- if (!persistMgr->getIsSaving()) cleanup(false);
+ if (!persistMgr->getIsSaving()) {
+ cleanup(false);
+ }
persistMgr->transfer(TMEMBER(_gameRef));
_fonts.persist(persistMgr);
diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp
index 0a97370cb7..420df58b74 100644
--- a/engines/wintermute/base/font/base_font_truetype.cpp
+++ b/engines/wintermute/base/font/base_font_truetype.cpp
@@ -57,7 +57,9 @@ BaseFontTT::BaseFontTT(BaseGame *inGame): BaseFont(inGame) {
_fallbackFont = NULL;
_deletableFont = NULL;
- for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL;
+ for (int i = 0; i < NUM_CACHED_TEXTS; i++) {
+ _cachedTexts[i] = NULL;
+ }
#if 0
_fTFace = NULL;
@@ -98,7 +100,9 @@ BaseFontTT::~BaseFontTT(void) {
//////////////////////////////////////////////////////////////////////////
void BaseFontTT::clearCache() {
for (int i = 0; i < NUM_CACHED_TEXTS; i++) {
- if (_cachedTexts[i]) delete _cachedTexts[i];
+ if (_cachedTexts[i]) {
+ delete _cachedTexts[i];
+ }
_cachedTexts[i] = NULL;
}
}
@@ -109,12 +113,16 @@ void BaseFontTT::initLoop() {
if (_gameRef->_constrainedMemory) {
// purge all cached images not used in the last frame
for (int i = 0; i < NUM_CACHED_TEXTS; i++) {
- if (_cachedTexts[i] == NULL) continue;
+ if (_cachedTexts[i] == NULL) {
+ continue;
+ }
if (!_cachedTexts[i]->_marked) {
delete _cachedTexts[i];
_cachedTexts[i] = NULL;
- } else _cachedTexts[i]->_marked = false;
+ } else {
+ _cachedTexts[i]->_marked = false;
+ }
}
}
}
@@ -123,11 +131,15 @@ void BaseFontTT::initLoop() {
int BaseFontTT::getTextWidth(byte *text, int maxLength) {
WideString textStr;
- if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text);
- else textStr = StringUtil::ansiToWide((char *)text);
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
+ textStr = StringUtil::utf8ToWide((char *)text);
+ } else {
+ textStr = StringUtil::ansiToWide((char *)text);
+ }
- if (maxLength >= 0 && textStr.size() > (uint32)maxLength)
+ if (maxLength >= 0 && textStr.size() > (uint32)maxLength) {
textStr = Common::String(textStr.c_str(), (uint32)maxLength);
+ }
//text = text.substr(0, MaxLength); // TODO: Remove
int textWidth, textHeight;
@@ -140,8 +152,11 @@ int BaseFontTT::getTextWidth(byte *text, int maxLength) {
int BaseFontTT::getTextHeight(byte *text, int width) {
WideString textStr;
- if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text);
- else textStr = StringUtil::ansiToWide((char *)text);
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
+ textStr = StringUtil::utf8ToWide((char *)text);
+ } else {
+ textStr = StringUtil::ansiToWide((char *)text);
+ }
int textWidth, textHeight;
@@ -153,7 +168,9 @@ int BaseFontTT::getTextHeight(byte *text, int width) {
//////////////////////////////////////////////////////////////////////////
void BaseFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) {
- if (text == NULL || strcmp((char *)text, "") == 0) return;
+ if (text == NULL || strcmp((char *)text, "") == 0) {
+ return;
+ }
WideString textStr = (char *)text;
@@ -161,8 +178,9 @@ void BaseFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align,
/* if (_gameRef->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text);
else text = StringUtil::AnsiToWide((char *)Text);*/
- if (maxLength >= 0 && textStr.size() > (uint32)maxLength)
+ if (maxLength >= 0 && textStr.size() > (uint32)maxLength) {
textStr = Common::String(textStr.c_str(), (uint32)maxLength);
+ }
//text = text.substr(0, MaxLength); // TODO: Remove
BaseRenderer *renderer = _gameRef->_renderer;
@@ -199,7 +217,9 @@ void BaseFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align,
surface = renderTextToTexture(textStr, width, align, maxHeight, textOffset);
if (surface) {
// write surface to cache
- if (_cachedTexts[minIndex] != NULL) delete _cachedTexts[minIndex];
+ if (_cachedTexts[minIndex] != NULL) {
+ delete _cachedTexts[minIndex];
+ }
_cachedTexts[minIndex] = new BaseCachedTTFontText;
_cachedTexts[minIndex]->_surface = surface;
@@ -261,10 +281,11 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width,
debugC(kWinterMuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color));
// void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const;
Graphics::Surface *surface = new Graphics::Surface();
- if (_deletableFont) // We actually have a TTF
+ if (_deletableFont) { // We actually have a TTF
surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0));
- else // We are using a fallback, they can't do 32bpp
+ } else { // We are using a fallback, they can't do 32bpp
surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0));
+ }
uint32 useColor = 0xffffffff;
Common::Array<Common::String>::iterator it;
int heightOffset = 0;
@@ -309,7 +330,9 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width,
wchar_t ch = line->GetText()[i];
GlyphInfo *glyph = _glyphCache->GetGlyph(ch);
- if (!glyph) continue;
+ if (!glyph) {
+ continue;
+ }
textOffset = MAX(textOffset, glyph->GetBearingY());
}
@@ -322,10 +345,14 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width,
wchar_t ch = line->GetText()[i];
GlyphInfo *glyph = _glyphCache->GetGlyph(ch);
- if (!glyph) continue;
+ if (!glyph) {
+ continue;
+ }
float kerning = 0;
- if (prevChar != L'\0') kerning = GetKerning(prevChar, ch);
+ if (prevChar != L'\0') {
+ kerning = GetKerning(prevChar, ch);
+ }
posX += (int)kerning;
@@ -381,7 +408,9 @@ void BaseFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target,
warning("BaseFontTT::BlitSurface - not ported yet");
#if 0
for (int y = 0; y < src->h; y++) {
- if (targetRect->y + y < 0 || targetRect->y + y >= target->h) continue;
+ if (targetRect->y + y < 0 || targetRect->y + y >= target->h) {
+ continue;
+ }
uint8 *srcBuf = (uint8 *)src->pixels + y * src->pitch;
@@ -391,7 +420,9 @@ void BaseFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target,
uint32 *tgtBuf32 = (uint32 *)tgtBuf;
for (int x = 0; x < src->w; x++) {
- if (targetRect->x + x < 0 || targetRect->x + x >= target->w) continue;
+ if (targetRect->x + x < 0 || targetRect->x + x >= target->w) {
+ continue;
+ }
tgtBuf32[x + targetRect->x] = srcBuf32[x];
}
@@ -417,7 +448,9 @@ bool BaseFontTT::loadFile(const char *filename) {
setFilename(filename);
- if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename);
+ if (DID_FAIL(ret = loadBuffer(buffer))) {
+ _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename);
+ }
delete[] buffer;
@@ -468,7 +501,7 @@ bool BaseFontTT::loadBuffer(byte *buffer) {
}
buffer = (byte *)params;
- uint32 BaseColor = 0x00000000;
+ uint32 baseColor = 0x00000000;
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)&params)) > 0) {
switch (cmd) {
@@ -507,23 +540,24 @@ bool BaseFontTT::loadBuffer(byte *buffer) {
case TOKEN_COLOR: {
int r, g, b;
parser.scanStr(params, "%d,%d,%d", &r, &g, &b);
- BaseColor = BYTETORGBA(r, g, b, RGBCOLGetA(BaseColor));
+ baseColor = BYTETORGBA(r, g, b, RGBCOLGetA(baseColor));
}
break;
case TOKEN_ALPHA: {
int a;
parser.scanStr(params, "%d", &a);
- BaseColor = BYTETORGBA(RGBCOLGetR(BaseColor), RGBCOLGetG(BaseColor), RGBCOLGetB(BaseColor), a);
+ baseColor = BYTETORGBA(RGBCOLGetR(baseColor), RGBCOLGetG(baseColor), RGBCOLGetB(baseColor), a);
}
break;
case TOKEN_LAYER: {
- BaseTTFontLayer *Layer = new BaseTTFontLayer;
- if (Layer && DID_SUCCEED(parseLayer(Layer, (byte *)params))) _layers.add(Layer);
- else {
- delete Layer;
- Layer = NULL;
+ BaseTTFontLayer *layer = new BaseTTFontLayer;
+ if (layer && DID_SUCCEED(parseLayer(layer, (byte *)params))) {
+ _layers.add(layer);
+ } else {
+ delete layer;
+ layer = NULL;
cmd = PARSERR_TOKENNOTFOUND;
}
}
@@ -538,12 +572,14 @@ bool BaseFontTT::loadBuffer(byte *buffer) {
// create at least one layer
if (_layers.getSize() == 0) {
- BaseTTFontLayer *Layer = new BaseTTFontLayer;
- Layer->_color = BaseColor;
- _layers.add(Layer);
+ BaseTTFontLayer *layer = new BaseTTFontLayer;
+ layer->_color = baseColor;
+ _layers.add(layer);
}
- if (!_fontFile) BaseUtils::setString(&_fontFile, "arial.ttf");
+ if (!_fontFile) {
+ BaseUtils::setString(&_fontFile, "arial.ttf");
+ }
return initFont();
}
@@ -587,8 +623,11 @@ bool BaseFontTT::parseLayer(BaseTTFontLayer *layer, byte *buffer) {
break;
}
}
- if (cmd != PARSERR_EOF) return STATUS_FAILED;
- else return STATUS_OK;
+ if (cmd != PARSERR_EOF) {
+ return STATUS_FAILED;
+ } else {
+ return STATUS_OK;
+ }
}
@@ -609,7 +648,9 @@ bool BaseFontTT::persist(BasePersistenceManager *persistMgr) {
if (persistMgr->getIsSaving()) {
numLayers = _layers.getSize();
persistMgr->transfer(TMEMBER(numLayers));
- for (int i = 0; i < numLayers; i++) _layers[i]->persist(persistMgr);
+ for (int i = 0; i < numLayers; i++) {
+ _layers[i]->persist(persistMgr);
+ }
} else {
numLayers = _layers.getSize();
persistMgr->transfer(TMEMBER(numLayers));
@@ -621,7 +662,9 @@ bool BaseFontTT::persist(BasePersistenceManager *persistMgr) {
}
if (!persistMgr->getIsSaving()) {
- for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL;
+ for (int i = 0; i < NUM_CACHED_TEXTS; i++) {
+ _cachedTexts[i] = NULL;
+ }
_fallbackFont = _font = _deletableFont = NULL;
}
@@ -636,7 +679,9 @@ void BaseFontTT::afterLoad() {
//////////////////////////////////////////////////////////////////////////
bool BaseFontTT::initFont() {
- if (!_fontFile) return STATUS_FAILED;
+ if (!_fontFile) {
+ return STATUS_FAILED;
+ }
Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile);
if (!file) {
diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h
index 8a8459b070..f8c5eee74d 100644
--- a/engines/wintermute/base/font/base_font_truetype.h
+++ b/engines/wintermute/base/font/base_font_truetype.h
@@ -67,7 +67,9 @@ private:
}
virtual ~BaseCachedTTFontText() {
- if (_surface) delete _surface;
+ if (_surface) {
+ delete _surface;
+ }
}
};
diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp
index 09a78a748b..571deed793 100644
--- a/engines/wintermute/base/gfx/base_image.cpp
+++ b/engines/wintermute/base/gfx/base_image.cpp
@@ -53,15 +53,11 @@ BaseImage::BaseImage(BaseFileManager *fileManager) {
//////////////////////////////////////////////////////////////////////
BaseImage::~BaseImage() {
- /* delete _bitmap; */
delete _decoder;
if (_deletableSurface) {
_deletableSurface->free();
}
delete _deletableSurface;
-#if 0
- if (_bitmap) FreeImage_Unload(_bitmap);
-#endif
}
bool BaseImage::loadFile(const Common::String &filename) {
@@ -82,7 +78,9 @@ bool BaseImage::loadFile(const Common::String &filename) {
}
_filename = filename;
Common::SeekableReadStream *file = _fileManager->openFile(filename.c_str());
- if (!file) return false;
+ if (!file) {
+ return false;
+ }
_decoder->loadStream(*file);
_surface = _decoder->getSurface();
@@ -93,7 +91,9 @@ bool BaseImage::loadFile(const Common::String &filename) {
}
byte BaseImage::getAlphaAt(int x, int y) const {
- if (!_surface) return 0xFF;
+ if (!_surface) {
+ return 0xFF;
+ }
uint32 color = *(uint32 *)_surface->getBasePtr(x, y);
byte r, g, b, a;
_surface->format.colorToARGB(color, a, r, g, b);
@@ -107,12 +107,6 @@ void BaseImage::copyFrom(const Graphics::Surface *surface) {
//////////////////////////////////////////////////////////////////////////
bool BaseImage::saveBMPFile(const char *filename) const {
-#if 0
- if (!_bitmap) return STATUS_FAILED;
-
- if (FreeImage_Save(FIF_BMP, _bitmap, filename)) return STATUS_OK;
- else return STATUS_FAILED;
-#endif
warning("BaseImage::saveBMPFile - stubbed"); // TODO
return false;
}
@@ -121,10 +115,16 @@ bool BaseImage::saveBMPFile(const char *filename) const {
//////////////////////////////////////////////////////////////////////////
bool BaseImage::resize(int newWidth, int newHeight) {
#if 0
- if (!_bitmap) return STATUS_FAILED;
+ if (!_bitmap) {
+ return STATUS_FAILED;
+ }
- if (newWidth == 0) NewWidth = FreeImage_GetWidth(_bitmap);
- if (newHeight == 0) NewHeight = FreeImage_GetHeight(_bitmap);
+ if (newWidth == 0) {
+ NewWidth = FreeImage_GetWidth(_bitmap);
+ }
+ if (newHeight == 0) {
+ NewHeight = FreeImage_GetHeight(_bitmap);
+ }
FIBITMAP *newImg = FreeImage_Rescale(_bitmap, NewWidth, NewHeight, FILTER_BILINEAR);
@@ -132,7 +132,9 @@ bool BaseImage::resize(int newWidth, int newHeight) {
FreeImage_Unload(_bitmap);
_bitmap = newImg;
return STATUS_OK;
- } else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
#endif
return false;
}
@@ -140,7 +142,9 @@ bool BaseImage::resize(int newWidth, int newHeight) {
//////////////////////////////////////////////////////////////////////////
bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const {
- if (!_surface) return false;
+ if (!_surface) {
+ return false;
+ }
/* The following is just copied over and inverted to write-ops from the BMP-decoder */
stream->writeByte('B');
@@ -164,8 +168,9 @@ bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const {
stream->writeUint32LE(width);
stream->writeUint32LE((uint32)height);
- if (width == 0 || height == 0)
+ if (width == 0 || height == 0) {
return false;
+ }
if (height < 0) {
warning("Right-side up bitmaps not supported");
@@ -194,8 +199,9 @@ bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const {
Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8();
// BGRA for 24bpp
- if (bitsPerPixel == 24)
+ if (bitsPerPixel == 24) {
format = Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0);
+ }
Graphics::Surface *surface = _surface->convertTo(format);
@@ -219,36 +225,22 @@ bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const {
surface->free();
delete surface;
return true;
-
- //*BufferSize = 0;
-#if 0
- FIMEMORY *fiMem = FreeImage_OpenMemory();
- FreeImage_SaveToMemory(FIF_PNG, _bitmap, fiMem);
- uint32 size;
- byte *data;
- FreeImage_AcquireMemory(fiMem, &data, &size);
-
-
- byte *Buffer = new byte[size];
- memcpy(Buffer, data, size);
-
- FreeImage_CloseMemory(fiMem);
-
- if (BufferSize) *BufferSize = size;
-
- return Buffer;
-#endif
- return false;
}
//////////////////////////////////////////////////////////////////////////
bool BaseImage::copyFrom(BaseImage *origImage, int newWidth, int newHeight) {
#if 0
- if (_bitmap) FreeImage_Unload(_bitmap);
+ if (_bitmap) {
+ FreeImage_Unload(_bitmap);
+ }
- if (NewWidth == 0) NewWidth = FreeImage_GetWidth(OrigImage->GetBitmap());
- if (NewHeight == 0) NewHeight = FreeImage_GetHeight(OrigImage->GetBitmap());
+ if (NewWidth == 0) {
+ NewWidth = FreeImage_GetWidth(OrigImage->GetBitmap());
+ }
+ if (NewHeight == 0) {
+ NewHeight = FreeImage_GetHeight(OrigImage->GetBitmap());
+ }
_bitmap = FreeImage_Rescale(OrigImage->GetBitmap(), NewWidth, NewHeight, FILTER_BILINEAR);
#endif
diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp
index 66b7f513bf..168aa75d91 100644
--- a/engines/wintermute/base/gfx/base_renderer.cpp
+++ b/engines/wintermute/base/gfx/base_renderer.cpp
@@ -89,13 +89,19 @@ BaseObject *BaseRenderer::getObjectAt(int x, int y) {
yy = height - yy;
}
- if (!_rectList[i]->_frame->_surface->isTransparentAt(xx, yy)) return _rectList[i]->_owner;
+ if (!_rectList[i]->_frame->_surface->isTransparentAt(xx, yy)) {
+ return _rectList[i]->_owner;
+ }
}
// region
else if (_rectList[i]->_region) {
- if (_rectList[i]->_region->pointInRegion(x + _rectList[i]->_offsetX, y + _rectList[i]->_offsetY)) return _rectList[i]->_owner;
+ if (_rectList[i]->_region->pointInRegion(x + _rectList[i]->_offsetX, y + _rectList[i]->_offsetY)) {
+ return _rectList[i]->_owner;
+ }
}
- } else return _rectList[i]->_owner;
+ } else {
+ return _rectList[i]->_owner;
+ }
}
}
@@ -208,10 +214,18 @@ bool BaseRenderer::unclipCursor() {
//////////////////////////////////////////////////////////////////////////
bool BaseRenderer::pointInViewport(Point32 *p) {
- if (p->x < _drawOffsetX) return false;
- if (p->y < _drawOffsetY) return false;
- if (p->x > _drawOffsetX + _width) return false;
- if (p->y > _drawOffsetY + _height) return false;
+ if (p->x < _drawOffsetX) {
+ return false;
+ }
+ if (p->y < _drawOffsetY) {
+ return false;
+ }
+ if (p->x > _drawOffsetX + _width) {
+ return false;
+ }
+ if (p->y > _drawOffsetY + _height) {
+ return false;
+ }
return true;
}
diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp
index 684236ac7f..68e3e3d26c 100644
--- a/engines/wintermute/base/gfx/base_surface.cpp
+++ b/engines/wintermute/base/gfx/base_surface.cpp
@@ -54,7 +54,9 @@ BaseSurface::BaseSurface(BaseGame *inGame): BaseClass(inGame) {
//////////////////////////////////////////////////////////////////////
BaseSurface::~BaseSurface() {
- if (_pixelOpReady) endPixelOp();
+ if (_pixelOpReady) {
+ endPixelOp();
+ }
}
@@ -139,7 +141,9 @@ bool BaseSurface::prepareToDraw() {
if (!_valid) {
//_gameRef->LOG(0, "Reviving: %s", _filename);
return create(_filename.c_str(), _ckDefault, _ckRed, _ckGreen, _ckBlue, _lifeTime, _keepLoaded);
- } else return STATUS_OK;
+ } else {
+ return STATUS_OK;
+ }
}
diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
index 43cf66d053..e465194e58 100644
--- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
@@ -44,10 +44,12 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s
_srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(true) {
_colorMod = 0;
_mirror = TransparentSurface::FLIP_NONE;
- if (mirrorX)
+ if (mirrorX) {
_mirror |= TransparentSurface::FLIP_V;
- if (mirrorY)
+ }
+ if (mirrorY) {
_mirror |= TransparentSurface::FLIP_H;
+ }
if (surf) {
_surface = new Graphics::Surface();
_surface->create((uint16)srcRect->width(), (uint16)srcRect->height(), surf->format);
@@ -113,8 +115,12 @@ BaseRenderOSystem::~BaseRenderOSystem() {
_renderSurface->free();
delete _renderSurface;
#if 0
- if (_renderer) SDL_DestroyRenderer(_renderer);
- if (_win) SDL_DestroyWindow(_win);
+ if (_renderer) {
+ SDL_DestroyRenderer(_renderer);
+ }
+ if (_win) {
+ SDL_DestroyWindow(_win);
+ }
SDL_Quit();
#endif
}
@@ -212,7 +218,9 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) {
_realWidth, _realHeight,
flags);
- if (!_win) return STATUS_FAILED;
+ if (!_win) {
+ return STATUS_FAILED;
+ }
#endif
g_system->showMouse(false);
@@ -226,7 +234,9 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) {
#if 0
_renderer = SDL_CreateRenderer(_win, -1, 0);
- if (!_renderer) return STATUS_FAILED;
+ if (!_renderer) {
+ return STATUS_FAILED;
+ }
#endif
_renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat());
_active = true;
@@ -273,8 +283,9 @@ bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) {
//SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF);
//SDL_RenderClear(_renderer);
_clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b);
- if (!_disableDirtyRects)
+ if (!_disableDirtyRects) {
return STATUS_OK;
+ }
if (!rect) {
rect = &_renderRect;
}
@@ -320,9 +331,9 @@ void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect
//TODO: This is only here until I'm sure about the final pixelformat
uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b);
- if (_disableDirtyRects)
+ if (_disableDirtyRects) {
_renderSurface->fillRect(fillRect, col);
- else {
+ } else {
setAlphaMod(a);
setColorMod(r, g, b);
Graphics::Surface surf;
@@ -468,8 +479,9 @@ void BaseRenderOSystem::drawTickets() {
it++;
}
}
- if (!_dirtyRect || _dirtyRect->width() == 0 || _dirtyRect->height() == 0)
+ if (!_dirtyRect || _dirtyRect->width() == 0 || _dirtyRect->height() == 0) {
return;
+ }
// The color-mods are stored in the RenderTickets on add, since we set that state again during
// draw, we need to keep track of what it was prior to draw.
uint32 oldColorMod = _colorMod;
@@ -518,8 +530,9 @@ void BaseRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::R
}
src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, clipRect, _colorMod, clipRect->width(), clipRect->height());
- if (doDelete)
+ if (doDelete) {
delete clipRect;
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -566,9 +579,13 @@ BaseImage *BaseRenderOSystem::takeScreenshot() {
SDL_RenderGetViewport(_renderer, &viewport);
SDL_Surface *surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, 0x00000000);
- if (!surface) return NULL;
+ if (!surface) {
+ return NULL;
+ }
- if (SDL_RenderReadPixels(_renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) return NULL;
+ if (SDL_RenderReadPixels(_renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) {
+ return NULL;
+ }
FIBITMAP *dib = FreeImage_Allocate(viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK);
@@ -643,7 +660,9 @@ void BaseRenderOSystem::dumpData(const char *filename) {
warning("BaseRenderOSystem::DumpData(%s) - not reimplemented yet", filename); // TODO
#if 0
FILE *f = fopen(filename, "wt");
- if (!f) return;
+ if (!f) {
+ return;
+ }
BaseSurfaceStorage *Mgr = _gameRef->_surfaceStorage;
@@ -652,8 +671,12 @@ void BaseRenderOSystem::dumpData(const char *filename) {
fprintf(f, "Filename;Usage;Size;KBytes\n");
for (int i = 0; i < Mgr->_surfaces.getSize(); i++) {
BaseSurfaceOSystem *Surf = (BaseSurfaceOSystem *)Mgr->_surfaces[i];
- if (!Surf->_filename) continue;
- if (!Surf->_valid) continue;
+ if (!Surf->_filename) {
+ continue;
+ }
+ if (!Surf->_valid) {
+ continue;
+ }
fprintf(f, "%s;%d;", Surf->_filename, Surf->_referenceCount);
fprintf(f, "%dx%d;", Surf->getWidth(), Surf->getHeight());
diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
index 36213dfde1..4b680e2793 100644
--- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
+++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
@@ -107,11 +107,14 @@ bool BaseSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed
_ckGreen = ckGreen;
_ckBlue = ckBlue;
- if (_lifeTime == 0 || lifeTime == -1 || lifeTime > _lifeTime)
+ if (_lifeTime == 0 || lifeTime == -1 || lifeTime > _lifeTime) {
_lifeTime = lifeTime;
+ }
_keepLoaded = keepLoaded;
- if (_keepLoaded) _lifeTime = -1;
+ if (_keepLoaded) {
+ _lifeTime = -1;
+ }
return STATUS_OK;
}
@@ -201,7 +204,9 @@ void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) {
delete[] _alphaMask;
_alphaMask = NULL;
- if (!surface) return;
+ if (!surface) {
+ return;
+ }
#if 0
SDL_LockSurface(surface);
#endif
@@ -224,11 +229,14 @@ void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) {
surface->format.colorToARGB(pixel, a, r, g, b);
//SDL_GetRGBA(pixel, surface->format, &r, &g, &b, &a);
- if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue)
+ if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue) {
a = 0;
+ }
_alphaMask[y * surface->w + x] = a;
- if (a < 255) hasTransparency = true;
+ if (a < 255) {
+ hasTransparency = true;
+ }
}
}
#if 0
@@ -331,7 +339,9 @@ bool BaseSurfaceOSystem::isTransparentAt(int x, int y) {
int width, height;
//SDL_QueryTexture(_texture, NULL, &access, &width, &height); //TODO
//if (access != SDL_TEXTUREACCESS_STREAMING) return false;
- if (X < 0 || X >= width || Y < 0 || Y >= height) return true;
+ if (X < 0 || X >= width || Y < 0 || Y >= height) {
+ return true;
+ }
StartPixelOp();
@@ -371,10 +381,15 @@ bool BaseSurfaceOSystem::isTransparentAtLite(int x, int y) {
//SDL_QueryTexture(_texture, &format, &access, &width, &height);
//if (access != SDL_TEXTUREACCESS_STREAMING) return false;
- if (X < 0 || X >= width || Y < 0 || Y >= height) return true;
+ if (X < 0 || X >= width || Y < 0 || Y >= height) {
+ return true;
+ }
- if (!_alphaMask) return false;
- else return _alphaMask[Y * width + X] <= 128;
+ if (!_alphaMask) {
+ return false;
+ } else {
+ return _alphaMask[Y * width + X] <= 128;
+ }
#endif
return false;
/*
@@ -447,8 +462,9 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo
finishLoad();
}
- if (renderer->_forceAlphaColor != 0)
+ if (renderer->_forceAlphaColor != 0) {
alpha = renderer->_forceAlphaColor;
+ }
// This particular warning is rather messy, as this function is called a ton,
// thus we avoid printing it more than once.
@@ -469,10 +485,11 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo
SDL_SetTextureColorMod(_texture, r, g, b);
SDL_SetTextureAlphaMod(_texture, a);
- if (AlphaDisable)
+ if (alphaDisable) {
SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE);
- else
+ } else {
SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_BLEND);
+ }
#endif
// TODO: This _might_ miss the intended behaviour by 1 in each direction
// But I think it fits the model used in Wintermute.
diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp
index 1ddefec610..b16fb83abf 100644
--- a/engines/wintermute/base/particles/part_emitter.cpp
+++ b/engines/wintermute/base/particles/part_emitter.cpp
@@ -116,11 +116,15 @@ PartEmitter::~PartEmitter(void) {
//////////////////////////////////////////////////////////////////////////
bool PartEmitter::addSprite(const char *filename) {
- if (!filename) return STATUS_FAILED;
+ if (!filename) {
+ return STATUS_FAILED;
+ }
// do we already have the file?
for (int i = 0; i < _sprites.getSize(); i++) {
- if (scumm_stricmp(filename, _sprites[i]) == 0) return STATUS_OK;
+ if (scumm_stricmp(filename, _sprites[i]) == 0) {
+ return STATUS_OK;
+ }
}
// check if file exists
@@ -128,7 +132,9 @@ bool PartEmitter::addSprite(const char *filename) {
if (!File) {
_gameRef->LOG(0, "Sprite '%s' not found", filename);
return STATUS_FAILED;
- } else _gameRef->_fileManager->closeFile(File);
+ } else {
+ _gameRef->_fileManager->closeFile(File);
+ }
char *Str = new char[strlen(filename) + 1];
strcpy(Str, filename);
@@ -151,24 +157,37 @@ bool PartEmitter::removeSprite(const char *filename) {
//////////////////////////////////////////////////////////////////////////
bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint32 timerDelta) {
- if (!particle) return STATUS_FAILED;
- if (_sprites.getSize() == 0) return STATUS_FAILED;
+ if (!particle) {
+ return STATUS_FAILED;
+ }
+ if (_sprites.getSize() == 0) {
+ return STATUS_FAILED;
+ }
int posX = BaseUtils::randomInt(_posX, _posX + _width);
int posY = BaseUtils::randomInt(_posY, _posY + _height);
float posZ = BaseUtils::randomFloat(0.0f, 100.0f);
float velocity;
- if (_velocityZBased) velocity = _velocity1 + posZ * (_velocity2 - _velocity1) / 100;
- else velocity = BaseUtils::randomFloat(_velocity1, _velocity2);
+ if (_velocityZBased) {
+ velocity = _velocity1 + posZ * (_velocity2 - _velocity1) / 100;
+ } else {
+ velocity = BaseUtils::randomFloat(_velocity1, _velocity2);
+ }
float scale;
- if (_scaleZBased) scale = _scale1 + posZ * (_scale2 - _scale1) / 100;
- else scale = BaseUtils::randomFloat(_scale1, _scale2);
+ if (_scaleZBased) {
+ scale = _scale1 + posZ * (_scale2 - _scale1) / 100;
+ } else {
+ scale = BaseUtils::randomFloat(_scale1, _scale2);
+ }
int lifeTime;
- if (_lifeTimeZBased) lifeTime = (int)(_lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100);
- else lifeTime = BaseUtils::randomInt(_lifeTime1, _lifeTime2);
+ if (_lifeTimeZBased) {
+ lifeTime = (int)(_lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100);
+ } else {
+ lifeTime = BaseUtils::randomInt(_lifeTime1, _lifeTime2);
+ }
float angle = BaseUtils::randomAngle(_angle1, _angle2);
int spriteIndex = BaseUtils::randomInt(0, _sprites.getSize() - 1);
@@ -220,14 +239,20 @@ bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint3
particle->fadeIn(currentTime, _fadeInTime);
- if (particle->_isDead) return STATUS_FAILED;
- else return STATUS_OK;
+ if (particle->_isDead) {
+ return STATUS_FAILED;
+ } else {
+ return STATUS_OK;
+ }
}
//////////////////////////////////////////////////////////////////////////
bool PartEmitter::update() {
- if (!_running) return STATUS_OK;
- else return updateInternal(_gameRef->_timer, _gameRef->_timerDelta);
+ if (!_running) {
+ return STATUS_OK;
+ } else {
+ return updateInternal(_gameRef->_timer, _gameRef->_timerDelta);
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -237,7 +262,9 @@ bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) {
for (int i = 0; i < _particles.getSize(); i++) {
_particles[i]->update(this, currentTime, timerDelta);
- if (!_particles[i]->_isDead) numLive++;
+ if (!_particles[i]->_isDead) {
+ numLive++;
+ }
}
@@ -263,8 +290,9 @@ bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) {
}
PartParticle *particle;
- if (firstDeadIndex >= 0) particle = _particles[firstDeadIndex];
- else {
+ if (firstDeadIndex >= 0) {
+ particle = _particles[firstDeadIndex];
+ } else {
particle = new PartParticle(_gameRef);
_particles.add(particle);
}
@@ -274,12 +302,15 @@ bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) {
toGen--;
}
}
- if (needsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased))
+ if (needsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) {
sortParticlesByZ();
+ }
// we actually generated some particles and we're not in fast-forward mode
if (needsSort && _overheadTime == 0) {
- if (_owner && _emitEvent) _owner->applyEvent(_emitEvent);
+ if (_owner && _emitEvent) {
+ _owner->applyEvent(_emitEvent);
+ }
}
}
@@ -288,17 +319,23 @@ bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) {
//////////////////////////////////////////////////////////////////////////
bool PartEmitter::display(BaseRegion *region) {
- if (_sprites.getSize() <= 1) _gameRef->_renderer->startSpriteBatch();
+ if (_sprites.getSize() <= 1) {
+ _gameRef->_renderer->startSpriteBatch();
+ }
for (int i = 0; i < _particles.getSize(); i++) {
if (region != NULL && _useRegion) {
- if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) continue;
+ if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) {
+ continue;
+ }
}
_particles[i]->display(this);
}
- if (_sprites.getSize() <= 1) _gameRef->_renderer->endSpriteBatch();
+ if (_sprites.getSize() <= 1) {
+ _gameRef->_renderer->endSpriteBatch();
+ }
return STATUS_OK;
}
@@ -339,9 +376,13 @@ int PartEmitter::compareZ(const void *obj1, const void *obj2) {
PartParticle *p1 = *(PartParticle **)obj1;
PartParticle *p2 = *(PartParticle **)obj2;
- if (p1->_posZ < p2->_posZ) return -1;
- else if (p1->_posZ > p2->_posZ) return 1;
- else return 0;
+ if (p1->_posZ < p2->_posZ) {
+ return -1;
+ } else if (p1->_posZ > p2->_posZ) {
+ return 1;
+ } else {
+ return 0;
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -385,7 +426,9 @@ PartForce *PartEmitter::addForceByName(const char *name) {
//////////////////////////////////////////////////////////////////////////
bool PartEmitter::addForce(const char *name, PartForce::TForceType type, int posX, int posY, float angle, float strength) {
PartForce *force = addForceByName(name);
- if (!force) return STATUS_FAILED;
+ if (!force) {
+ return STATUS_FAILED;
+ }
force->_type = type;
force->_pos = Vector2(posX, posY);
@@ -554,9 +597,9 @@ bool PartEmitter::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
stack->pushBool(DID_SUCCEED(removeForce(forceName)));
return STATUS_OK;
+ } else {
+ return BaseObject::scCallMethod(script, stack, thisStack, name);
}
-
- else return BaseObject::scCallMethod(script, stack, thisStack, name);
}
//////////////////////////////////////////////////////////////////////////
@@ -745,7 +788,9 @@ ScValue *PartEmitter::scGetProperty(const char *name) {
else if (strcmp(name, "NumLiveParticles") == 0) {
int numAlive = 0;
for (int i = 0; i < _particles.getSize(); i++) {
- if (_particles[i] && !_particles[i]->_isDead) numAlive++;
+ if (_particles[i] && !_particles[i]->_isDead) {
+ numAlive++;
+ }
}
_scValue->setInt(numAlive);
return _scValue;
@@ -822,12 +867,15 @@ ScValue *PartEmitter::scGetProperty(const char *name) {
// EmitEvent
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "EmitEvent") == 0) {
- if (!_emitEvent) _scValue->setNULL();
- else _scValue->setString(_emitEvent);
+ if (!_emitEvent) {
+ _scValue->setNULL();
+ } else {
+ _scValue->setString(_emitEvent);
+ }
return _scValue;
+ } else {
+ return BaseObject::scGetProperty(name);
}
-
- else return BaseObject::scGetProperty(name);
}
@@ -978,8 +1026,12 @@ bool PartEmitter::scSetProperty(const char *name, ScValue *value) {
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Alpha1") == 0) {
_alpha1 = value->getInt();
- if (_alpha1 < 0) _alpha1 = 0;
- if (_alpha1 > 255) _alpha1 = 255;
+ if (_alpha1 < 0) {
+ _alpha1 = 0;
+ }
+ if (_alpha1 > 255) {
+ _alpha1 = 255;
+ }
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
@@ -987,8 +1039,12 @@ bool PartEmitter::scSetProperty(const char *name, ScValue *value) {
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Alpha2") == 0) {
_alpha2 = value->getInt();
- if (_alpha2 < 0) _alpha2 = 0;
- if (_alpha2 > 255) _alpha2 = 255;
+ if (_alpha2 < 0) {
+ _alpha2 = 0;
+ }
+ if (_alpha2 > 255) {
+ _alpha2 = 255;
+ }
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
@@ -1080,11 +1136,13 @@ bool PartEmitter::scSetProperty(const char *name, ScValue *value) {
else if (strcmp(name, "EmitEvent") == 0) {
delete[] _emitEvent;
_emitEvent = NULL;
- if (!value->isNULL()) BaseUtils::setString(&_emitEvent, value->getString());
+ if (!value->isNULL()) {
+ BaseUtils::setString(&_emitEvent, value->getString());
+ }
return STATUS_OK;
+ } else {
+ return BaseObject::scSetProperty(name, value);
}
-
- else return BaseObject::scSetProperty(name, value);
}
diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp
index b63a82f926..4a5239edfe 100644
--- a/engines/wintermute/base/particles/part_particle.cpp
+++ b/engines/wintermute/base/particles/part_particle.cpp
@@ -99,24 +99,29 @@ bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timer
if (currentTime - _fadeStart >= (uint32)_fadeTime) {
_state = PARTICLE_NORMAL;
_currentAlpha = _alpha1;
- } else _currentAlpha = (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1);
+ } else {
+ _currentAlpha = (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1);
+ }
return STATUS_OK;
} else if (_state == PARTICLE_FADEOUT) {
if (currentTime - _fadeStart >= (uint32)_fadeTime) {
_isDead = true;
return STATUS_OK;
- } else _currentAlpha = _fadeStartAlpha - (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha);
+ } else {
+ _currentAlpha = _fadeStartAlpha - (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha);
+ }
return STATUS_OK;
} else {
// time is up
if (_lifeTime > 0) {
if (currentTime - _creationTime >= (uint32)_lifeTime) {
- if (emitter->_fadeOutTime > 0)
+ if (emitter->_fadeOutTime > 0) {
fadeOut(currentTime, emitter->_fadeOutTime);
- else
+ } else {
_isDead = true;
+ }
}
}
@@ -125,10 +130,13 @@ bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timer
Point32 p;
p.x = (int32)_pos.x;
p.y = (int32)_pos.y;
- if (!BasePlatform::ptInRect(&_border, p))
+ if (!BasePlatform::ptInRect(&_border, p)) {
fadeOut(currentTime, emitter->_fadeOutTime);
+ }
+ }
+ if (_state != PARTICLE_NORMAL) {
+ return STATUS_OK;
}
- if (_state != PARTICLE_NORMAL) return STATUS_OK;
// update alpha
if (_lifeTime > 0) {
@@ -166,13 +174,15 @@ bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timer
_rotation = BaseUtils::normalizeAngle(_rotation);
// update scale
- if (_exponentialGrowth)
+ if (_exponentialGrowth) {
_scale += _scale / 100.0f * _growthRate * elapsedTime;
- else
+ } else {
_scale += _growthRate * elapsedTime;
+ }
- if (_scale <= 0.0f)
+ if (_scale <= 0.0f) {
_isDead = true;
+ }
return STATUS_OK;
@@ -181,8 +191,12 @@ bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timer
//////////////////////////////////////////////////////////////////////////
bool PartParticle::display(PartEmitter *emitter) {
- if (!_sprite) return STATUS_FAILED;
- if (_isDead) return STATUS_OK;
+ if (!_sprite) {
+ return STATUS_FAILED;
+ }
+ if (_isDead) {
+ return STATUS_OK;
+ }
_sprite->GetCurrentFrame();
return _sprite->display(_pos.x, _pos.y,
diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp
index a519da5832..4deeb0bf39 100644
--- a/engines/wintermute/base/scriptables/script.cpp
+++ b/engines/wintermute/base/scriptables/script.cpp
@@ -249,17 +249,23 @@ bool ScScript::create(const char *filename, byte *buffer, uint32 size, BaseScrip
_threadEvent = NULL;
_filename = new char[strlen(filename) + 1];
- if (_filename) strcpy(_filename, filename);
+ if (_filename) {
+ strcpy(_filename, filename);
+ }
_buffer = new byte [size];
- if (!_buffer) return STATUS_FAILED;
+ if (!_buffer) {
+ return STATUS_FAILED;
+ }
memcpy(_buffer, buffer, size);
_bufferSize = size;
bool res = initScript();
- if (DID_FAIL(res)) return res;
+ if (DID_FAIL(res)) {
+ return res;
+ }
// establish global variables table
_globals = new ScValue(_gameRef);
@@ -277,22 +283,30 @@ bool ScScript::createThread(ScScript *original, uint32 initIP, const char *event
_thread = true;
_methodThread = false;
_threadEvent = new char[strlen(eventName) + 1];
- if (_threadEvent) strcpy(_threadEvent, eventName);
+ if (_threadEvent) {
+ strcpy(_threadEvent, eventName);
+ }
// copy filename
_filename = new char[strlen(original->_filename) + 1];
- if (_filename) strcpy(_filename, original->_filename);
+ if (_filename) {
+ strcpy(_filename, original->_filename);
+ }
// copy buffer
_buffer = new byte [original->_bufferSize];
- if (!_buffer) return STATUS_FAILED;
+ if (!_buffer) {
+ return STATUS_FAILED;
+ }
memcpy(_buffer, original->_buffer, original->_bufferSize);
_bufferSize = original->_bufferSize;
// initialize
bool res = initScript();
- if (DID_FAIL(res)) return res;
+ if (DID_FAIL(res)) {
+ return res;
+ }
// copy globals
_globals = original->_globals;
@@ -317,29 +331,39 @@ bool ScScript::createThread(ScScript *original, uint32 initIP, const char *event
//////////////////////////////////////////////////////////////////////////
bool ScScript::createMethodThread(ScScript *original, const char *methodName) {
uint32 ip = original->getMethodPos(methodName);
- if (ip == 0) return STATUS_FAILED;
+ if (ip == 0) {
+ return STATUS_FAILED;
+ }
cleanup();
_thread = true;
_methodThread = true;
_threadEvent = new char[strlen(methodName) + 1];
- if (_threadEvent) strcpy(_threadEvent, methodName);
+ if (_threadEvent) {
+ strcpy(_threadEvent, methodName);
+ }
// copy filename
_filename = new char[strlen(original->_filename) + 1];
- if (_filename) strcpy(_filename, original->_filename);
+ if (_filename) {
+ strcpy(_filename, original->_filename);
+ }
// copy buffer
_buffer = new byte [original->_bufferSize];
- if (!_buffer) return STATUS_FAILED;
+ if (!_buffer) {
+ return STATUS_FAILED;
+ }
memcpy(_buffer, original->_buffer, original->_bufferSize);
_bufferSize = original->_bufferSize;
// initialize
bool res = initScript();
- if (DID_FAIL(res)) return res;
+ if (DID_FAIL(res)) {
+ return res;
+ }
// copy globals
_globals = original->_globals;
@@ -360,17 +384,25 @@ bool ScScript::createMethodThread(ScScript *original, const char *methodName) {
//////////////////////////////////////////////////////////////////////////
void ScScript::cleanup() {
- if (_buffer) delete[] _buffer;
+ if (_buffer) {
+ delete[] _buffer;
+ }
_buffer = NULL;
- if (_filename) delete[] _filename;
+ if (_filename) {
+ delete[] _filename;
+ }
_filename = NULL;
- if (_symbols) delete[] _symbols;
+ if (_symbols) {
+ delete[] _symbols;
+ }
_symbols = NULL;
_numSymbols = 0;
- if (_globals && !_thread) delete _globals;
+ if (_globals && !_thread) {
+ delete _globals;
+ }
_globals = NULL;
delete _scopeStack;
@@ -385,22 +417,30 @@ void ScScript::cleanup() {
delete _stack;
_stack = NULL;
- if (_functions) delete[] _functions;
+ if (_functions) {
+ delete[] _functions;
+ }
_functions = NULL;
_numFunctions = 0;
- if (_methods) delete[] _methods;
+ if (_methods) {
+ delete[] _methods;
+ }
_methods = NULL;
_numMethods = 0;
- if (_events) delete[] _events;
+ if (_events) {
+ delete[] _events;
+ }
_events = NULL;
_numEvents = 0;
if (_externals) {
for (uint32 i = 0; i < _numExternals; i++) {
- if (_externals[i].nu_params > 0) delete[] _externals[i].params;
+ if (_externals[i].nu_params > 0) {
+ delete[] _externals[i].params;
+ }
}
delete[] _externals;
}
@@ -423,7 +463,7 @@ void ScScript::cleanup() {
_waitScript = NULL;
_parentScript = NULL; // ref only
-
+
delete _scriptStream;
}
@@ -460,7 +500,9 @@ double ScScript::getFloat() {
//////////////////////////////////////////////////////////////////////////
char *ScScript::getString() {
char *ret = (char *)(_buffer + _iP);
- while (*(char *)(_buffer + _iP) != '\0') _iP++;
+ while (*(char *)(_buffer + _iP) != '\0') {
+ _iP++;
+ }
_iP++; // string terminator
_scriptStream->seek(_iP);
@@ -489,12 +531,14 @@ bool ScScript::executeInstruction() {
dw = getDWORD();
if (_scopeStack->_sP < 0) {
_globals->setProp(_symbols[dw], _operand);
- if (_gameRef->getDebugMgr()->_enabled)
+ if (_gameRef->getDebugMgr()->_enabled) {
_gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]);
+ }
} else {
_scopeStack->getTop()->setProp(_symbols[dw], _operand);
- if (_gameRef->getDebugMgr()->_enabled)
+ if (_gameRef->getDebugMgr()->_enabled) {
_gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]);
+ }
}
break;
@@ -508,8 +552,9 @@ bool ScScript::executeInstruction() {
_operand->setNULL();
_engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR);
- if (_gameRef->getDebugMgr()->_enabled)
+ if (_gameRef->getDebugMgr()->_enabled) {
_gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]);
+ }
}
break;
}
@@ -521,14 +566,20 @@ bool ScScript::executeInstruction() {
_scopeStack->pop();
_iP = (uint32)_callStack->pop()->getInt();
- if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL);
- else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop());
+ if (_scopeStack->_sP < 0) {
+ _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL);
+ } else {
+ _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop());
+ }
} else {
if (_thread) {
_state = SCRIPT_THREAD_FINISHED;
} else {
- if (_numEvents == 0 && _numMethods == 0) _state = SCRIPT_FINISHED;
- else _state = SCRIPT_PERSISTENT;
+ if (_numEvents == 0 && _numMethods == 0) {
+ _state = SCRIPT_FINISHED;
+ } else {
+ _state = SCRIPT_PERSISTENT;
+ }
}
}
@@ -557,7 +608,9 @@ bool ScScript::executeInstruction() {
strcpy(MethodName, str);
ScValue *var = _stack->pop();
- if (var->_type == VAL_VARIABLE_REF) var = var->_valRef;
+ if (var->_type == VAL_VARIABLE_REF) {
+ var = var->_valRef;
+ }
bool res = STATUS_FAILED;
bool TriedNative = false;
@@ -612,7 +665,9 @@ bool ScScript::executeInstruction() {
*/
else {
res = STATUS_FAILED;
- if (var->_type == VAL_NATIVE && !TriedNative) res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName);
+ if (var->_type == VAL_NATIVE && !TriedNative) {
+ res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName);
+ }
if (DID_FAIL(res)) {
_stack->correctParams(0);
@@ -631,7 +686,9 @@ bool ScScript::executeInstruction() {
TExternalFunction *f = getExternal(_symbols[SymbolIndex]);
if (f) {
externalCall(_stack, _thisStack, f);
- } else _gameRef->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]);
+ } else {
+ _gameRef->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]);
+ }
break;
}
@@ -639,8 +696,11 @@ bool ScScript::executeInstruction() {
_operand->setNULL();
_scopeStack->push(_operand);
- if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL);
- else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop());
+ if (_scopeStack->_sP < 0) {
+ _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL);
+ } else {
+ _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop());
+ }
break;
@@ -663,7 +723,9 @@ bool ScScript::executeInstruction() {
if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) {
_operand->setReference(var);
_stack->push(_operand);
- } else _stack->push(var);
+ } else {
+ _stack->push(var);
+ }
break;
}
@@ -683,15 +745,19 @@ bool ScScript::executeInstruction() {
runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum.");
var->setNULL();
} else {
- if (val->getType() == VAL_VARIABLE_REF) val = val->_valRef;
- if (val->_type == VAL_NATIVE) var->setValue(val);
- else {
+ if (val->getType() == VAL_VARIABLE_REF) {
+ val = val->_valRef;
+ }
+ if (val->_type == VAL_NATIVE) {
+ var->setValue(val);
+ } else {
var->copy(val);
}
}
- if (_gameRef->getDebugMgr()->_enabled)
+ if (_gameRef->getDebugMgr()->_enabled) {
_gameRef->getDebugMgr()->onVariableChangeValue(var, val);
+ }
}
break;
@@ -740,8 +806,11 @@ bool ScScript::executeInstruction() {
case II_PUSH_BY_EXP: {
str = _stack->pop()->getString();
ScValue *val = _stack->pop()->getProp(str);
- if (val) _stack->push(val);
- else _stack->pushNULL();
+ if (val) {
+ _stack->push(val);
+ } else {
+ _stack->pushNULL();
+ }
break;
}
@@ -754,10 +823,13 @@ bool ScScript::executeInstruction() {
if (val == NULL) {
runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum.");
var->setNULL();
- } else var->setProp(str, val);
+ } else {
+ var->setProp(str, val);
+ }
- if (_gameRef->getDebugMgr()->_enabled)
+ if (_gameRef->getDebugMgr()->_enabled) {
_gameRef->getDebugMgr()->onVariableChangeValue(var, NULL);
+ }
break;
}
@@ -781,7 +853,9 @@ bool ScScript::executeInstruction() {
if (!val) {
runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?");
} else {
- if (!val->getBool()) _iP = dw;
+ if (!val->getBool()) {
+ _iP = dw;
+ }
}
break;
}
@@ -790,17 +864,19 @@ bool ScScript::executeInstruction() {
op2 = _stack->pop();
op1 = _stack->pop();
- if (op1->isNULL() || op2->isNULL())
+ if (op1->isNULL() || op2->isNULL()) {
_operand->setNULL();
- else if (op1->getType() == VAL_STRING || op2->getType() == VAL_STRING) {
+ } else if (op1->getType() == VAL_STRING || op2->getType() == VAL_STRING) {
char *tempStr = new char [strlen(op1->getString()) + strlen(op2->getString()) + 1];
strcpy(tempStr, op1->getString());
strcat(tempStr, op2->getString());
_operand->setString(tempStr);
delete[] tempStr;
- } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT)
+ } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) {
_operand->setInt(op1->getInt() + op2->getInt());
- else _operand->setFloat(op1->getFloat() + op2->getFloat());
+ } else {
+ _operand->setFloat(op1->getFloat() + op2->getFloat());
+ }
_stack->push(_operand);
@@ -810,11 +886,13 @@ bool ScScript::executeInstruction() {
op2 = _stack->pop();
op1 = _stack->pop();
- if (op1->isNULL() || op2->isNULL())
+ if (op1->isNULL() || op2->isNULL()) {
_operand->setNULL();
- else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT)
+ } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) {
_operand->setInt(op1->getInt() - op2->getInt());
- else _operand->setFloat(op1->getFloat() - op2->getFloat());
+ } else {
+ _operand->setFloat(op1->getFloat() - op2->getFloat());
+ }
_stack->push(_operand);
@@ -824,10 +902,13 @@ bool ScScript::executeInstruction() {
op2 = _stack->pop();
op1 = _stack->pop();
- if (op1->isNULL() || op2->isNULL()) _operand->setNULL();
- else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT)
+ if (op1->isNULL() || op2->isNULL()) {
+ _operand->setNULL();
+ } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) {
_operand->setInt(op1->getInt() * op2->getInt());
- else _operand->setFloat(op1->getFloat() * op2->getFloat());
+ } else {
+ _operand->setFloat(op1->getFloat() * op2->getFloat());
+ }
_stack->push(_operand);
@@ -837,11 +918,15 @@ bool ScScript::executeInstruction() {
op2 = _stack->pop();
op1 = _stack->pop();
- if (op2->getFloat() == 0.0f)
+ if (op2->getFloat() == 0.0f) {
runtimeError("Division by zero.");
+ }
- if (op1->isNULL() || op2->isNULL() || op2->getFloat() == 0.0f) _operand->setNULL();
- else _operand->setFloat(op1->getFloat() / op2->getFloat());
+ if (op1->isNULL() || op2->isNULL() || op2->getFloat() == 0.0f) {
+ _operand->setNULL();
+ } else {
+ _operand->setFloat(op1->getFloat() / op2->getFloat());
+ }
_stack->push(_operand);
@@ -851,12 +936,15 @@ bool ScScript::executeInstruction() {
op2 = _stack->pop();
op1 = _stack->pop();
- if (op2->getInt() == 0)
+ if (op2->getInt() == 0) {
runtimeError("Division by zero.");
+ }
- if (op1->isNULL() || op2->isNULL() || op2->getInt() == 0)
+ if (op1->isNULL() || op2->isNULL() || op2->getInt() == 0) {
_operand->setNULL();
- else _operand->setInt(op1->getInt() % op2->getInt());
+ } else {
+ _operand->setInt(op1->getInt() % op2->getInt());
+ }
_stack->push(_operand);
@@ -865,8 +953,11 @@ bool ScScript::executeInstruction() {
case II_NOT:
op1 = _stack->pop();
//if (op1->isNULL()) _operand->setNULL();
- if (op1->isNULL()) _operand->setBool(true);
- else _operand->setBool(!op1->getBool());
+ if (op1->isNULL()) {
+ _operand->setBool(true);
+ } else {
+ _operand->setBool(!op1->getBool());
+ }
_stack->push(_operand);
break;
@@ -1060,8 +1151,9 @@ bool ScScript::executeInstruction() {
//////////////////////////////////////////////////////////////////////////
uint32 ScScript::getFuncPos(const char *name) {
for (uint32 i = 0; i < _numFunctions; i++) {
- if (strcmp(name, _functions[i].name) == 0)
+ if (strcmp(name, _functions[i].name) == 0) {
return _functions[i].pos;
+ }
}
return 0;
}
@@ -1070,8 +1162,9 @@ uint32 ScScript::getFuncPos(const char *name) {
//////////////////////////////////////////////////////////////////////////
uint32 ScScript::getMethodPos(const char *name) {
for (uint32 i = 0; i < _numMethods; i++) {
- if (strcmp(name, _methods[i].name) == 0)
+ if (strcmp(name, _methods[i].name) == 0) {
return _methods[i].pos;
+ }
}
return 0;
}
@@ -1083,20 +1176,23 @@ ScValue *ScScript::getVar(char *name) {
// scope locals
if (_scopeStack->_sP >= 0) {
- if (_scopeStack->getTop()->propExists(name))
+ if (_scopeStack->getTop()->propExists(name)) {
ret = _scopeStack->getTop()->getProp(name);
+ }
}
// script globals
if (ret == NULL) {
- if (_globals->propExists(name))
+ if (_globals->propExists(name)) {
ret = _globals->getProp(name);
+ }
}
// engine globals
if (ret == NULL) {
- if (_engine->_globals->propExists(name))
+ if (_engine->_globals->propExists(name)) {
ret = _engine->_globals->getProp(name);
+ }
}
if (ret == NULL) {
@@ -1162,7 +1258,9 @@ bool ScScript::finish(bool includingThreads) {
if (_state != SCRIPT_FINISHED && includingThreads) {
_state = SCRIPT_FINISHED;
finishThreads();
- } else _state = SCRIPT_FINISHED;
+ } else {
+ _state = SCRIPT_FINISHED;
+ }
return STATUS_OK;
@@ -1188,8 +1286,9 @@ void ScScript::runtimeError(const char *fmt, ...) {
_gameRef->LOG(0, "Runtime error. Script '%s', line %d", _filename, _currentLine);
_gameRef->LOG(0, " %s", buff);
- if (!_gameRef->_suppressScriptErrors)
+ if (!_gameRef->_suppressScriptErrors) {
_gameRef->quickMessage("Script runtime error. View log for details.");
+ }
}
@@ -1217,8 +1316,8 @@ bool ScScript::persist(BasePersistenceManager *persistMgr) {
initTables();
} else {
_buffer = NULL;
- _scriptStream = NULL;
- }
+ _scriptStream = NULL;
+ }
}
persistMgr->transfer(TMEMBER(_callStack));
@@ -1249,7 +1348,9 @@ bool ScScript::persist(BasePersistenceManager *persistMgr) {
persistMgr->transfer(TMEMBER(_unbreakable));
persistMgr->transfer(TMEMBER(_parentScript));
- if (!persistMgr->getIsSaving()) _tracingMode = false;
+ if (!persistMgr->getIsSaving()) {
+ _tracingMode = false;
+ }
return STATUS_OK;
}
@@ -1260,7 +1361,9 @@ ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable)
//if (_state!=SCRIPT_PERSISTENT) return NULL;
uint32 pos = getEventPos(eventName);
- if (!pos) return NULL;
+ if (!pos) {
+ return NULL;
+ }
ScScript *thread = new ScScript(_gameRef, _engine);
if (thread) {
@@ -1274,7 +1377,9 @@ ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable)
delete thread;
return NULL;
}
- } else return NULL;
+ } else {
+ return NULL;
+ }
}
@@ -1282,7 +1387,9 @@ ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable)
//////////////////////////////////////////////////////////////////////////
uint32 ScScript::getEventPos(const char *name) {
for (int i = _numEvents - 1; i >= 0; i--) {
- if (scumm_stricmp(name, _events[i].name) == 0) return _events[i].pos;
+ if (scumm_stricmp(name, _events[i].name) == 0) {
+ return _events[i].pos;
+ }
}
return 0;
}
@@ -1307,7 +1414,9 @@ bool ScScript::pause() {
return STATUS_FAILED;
}
- if (!_freezable || _state == SCRIPT_PERSISTENT) return STATUS_OK;
+ if (!_freezable || _state == SCRIPT_PERSISTENT) {
+ return STATUS_OK;
+ }
_origState = _state;
_state = SCRIPT_PAUSED;
@@ -1318,7 +1427,9 @@ bool ScScript::pause() {
//////////////////////////////////////////////////////////////////////////
bool ScScript::resume() {
- if (_state != SCRIPT_PAUSED) return STATUS_OK;
+ if (_state != SCRIPT_PAUSED) {
+ return STATUS_OK;
+ }
_state = _origState;
return STATUS_OK;
@@ -1328,8 +1439,9 @@ bool ScScript::resume() {
//////////////////////////////////////////////////////////////////////////
ScScript::TExternalFunction *ScScript::getExternal(char *name) {
for (uint32 i = 0; i < _numExternals; i++) {
- if (strcmp(name, _externals[i].name) == 0)
+ if (strcmp(name, _externals[i].name) == 0) {
return &_externals[i];
+ }
}
return NULL;
}
@@ -1354,7 +1466,9 @@ bool ScScript::copyParameters(ScStack *stack) {
}
_stack->pushInt(NumParams);
- for (i = 0; i < NumParams; i++) stack->pop();
+ for (i = 0; i < NumParams; i++) {
+ stack->pop();
+ }
return STATUS_OK;
}
@@ -1364,8 +1478,9 @@ bool ScScript::copyParameters(ScStack *stack) {
bool ScScript::finishThreads() {
for (int i = 0; i < _engine->_scripts.getSize(); i++) {
ScScript *scr = _engine->_scripts[i];
- if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0)
+ if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) {
scr->finish(true);
+ }
}
return STATUS_OK;
}
@@ -1385,9 +1500,13 @@ const char *ScScript::dbgGetFilename() {
//////////////////////////////////////////////////////////////////////////
bool ScScript::dbgSendScript(IWmeDebugClient *client) {
- if (_methodThread) client->onScriptMethodThreadInit(this, _parentScript, _threadEvent);
- else if (_thread) client->onScriptEventThreadInit(this, _parentScript, _threadEvent);
- else client->onScriptInit(this);
+ if (_methodThread) {
+ client->onScriptMethodThreadInit(this, _parentScript, _threadEvent);
+ } else if (_thread) {
+ client->onScriptEventThreadInit(this, _parentScript, _threadEvent);
+ } else {
+ client->onScriptInit(this);
+ }
return dbgSendVariables(client);
return STATUS_OK;
@@ -1421,8 +1540,11 @@ int ScScript::dbgGetNumBreakpoints() {
//////////////////////////////////////////////////////////////////////////
int ScScript::dbgGetBreakpoint(int index) {
- if (index >= 0 && index < _breakpoints.getSize()) return _breakpoints[index];
- else return -1;
+ if (index >= 0 && index < _breakpoints.getSize()) {
+ return _breakpoints[index];
+ } else {
+ return -1;
+ }
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp
index 792dfd4589..356617094d 100644
--- a/engines/wintermute/base/scriptables/script_engine.cpp
+++ b/engines/wintermute/base/scriptables/script_engine.cpp
@@ -47,8 +47,11 @@ IMPLEMENT_PERSISTENT(ScEngine, true)
ScEngine::ScEngine(BaseGame *inGame): BaseClass(inGame) {
_gameRef->LOG(0, "Initializing scripting engine...");
- if (_compilerAvailable) _gameRef->LOG(0, " Script compiler bound successfuly");
- else _gameRef->LOG(0, " Script compiler is NOT available");
+ if (_compilerAvailable) {
+ _gameRef->LOG(0, " Script compiler bound successfuly");
+ } else {
+ _gameRef->LOG(0, " Script compiler is NOT available");
+ }
_globals = new ScValue(_gameRef);
@@ -68,7 +71,9 @@ ScEngine::ScEngine(BaseGame *inGame): BaseClass(inGame) {
}
// prepare script cache
- for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) _cachedScripts[i] = NULL;
+ for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) {
+ _cachedScripts[i] = NULL;
+ }
_currentScript = NULL;
@@ -99,7 +104,9 @@ ScEngine::~ScEngine() {
//////////////////////////////////////////////////////////////////////////
bool ScEngine::cleanup() {
for (int i = 0; i < _scripts.getSize(); i++) {
- if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]);
+ if (!_scripts[i]->_thread && _scripts[i]->_owner) {
+ _scripts[i]->_owner->removeScript(_scripts[i]);
+ }
delete _scripts[i];
_scripts.removeAt(i);
i--;
@@ -143,7 +150,9 @@ ScScript *ScEngine::runScript(const char *filename, BaseScriptHolder *owner) {
// get script from cache
compBuffer = getCompiledScript(filename, &compSize);
- if (!compBuffer) return NULL;
+ if (!compBuffer) {
+ return NULL;
+ }
// add new script
ScScript *script = new ScScript(_gameRef, this);
@@ -155,8 +164,11 @@ ScScript *ScEngine::runScript(const char *filename, BaseScriptHolder *owner) {
} else {
// publish the "self" pseudo-variable
ScValue val(_gameRef);
- if (owner)val.setNative(owner, true);
- else val.setNULL();
+ if (owner) {
+ val.setNative(owner, true);
+ } else {
+ val.setNULL();
+ }
script->_globals->setProp("self", &val);
script->_globals->setProp("this", &val);
@@ -226,7 +238,9 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig
}
}
- if (_cachedScripts[index] != NULL) delete _cachedScripts[index];
+ if (_cachedScripts[index] != NULL) {
+ delete _cachedScripts[index];
+ }
_cachedScripts[index] = cachedScript;
ret = cachedScript->_buffer;
@@ -244,8 +258,9 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig
//////////////////////////////////////////////////////////////////////////
bool ScEngine::tick() {
- if (_scripts.getSize() == 0)
+ if (_scripts.getSize() == 0) {
return STATUS_OK;
+ }
// resolve waiting scripts
@@ -267,16 +282,24 @@ bool ScEngine::tick() {
if (!obj_found) _scripts[i]->finish(); // _waitObject no longer exists
*/
if (_gameRef->validObject(_scripts[i]->_waitObject)) {
- if (_scripts[i]->_waitObject->isReady()) _scripts[i]->run();
- } else _scripts[i]->finish();
+ if (_scripts[i]->_waitObject->isReady()) {
+ _scripts[i]->run();
+ }
+ } else {
+ _scripts[i]->finish();
+ }
break;
}
case SCRIPT_SLEEPING: {
if (_scripts[i]->_waitFrozen) {
- if (_scripts[i]->_waitTime <= g_system->getMillis()) _scripts[i]->run();
+ if (_scripts[i]->_waitTime <= g_system->getMillis()) {
+ _scripts[i]->run();
+ }
} else {
- if (_scripts[i]->_waitTime <= _gameRef->_timer) _scripts[i]->run();
+ if (_scripts[i]->_waitTime <= _gameRef->_timer) {
+ _scripts[i]->run();
+ }
}
break;
}
@@ -309,7 +332,9 @@ bool ScEngine::tick() {
for (int i = 0; i < _scripts.getSize(); i++) {
// skip paused scripts
- if (_scripts[i]->_state == SCRIPT_PAUSED) continue;
+ if (_scripts[i]->_state == SCRIPT_PAUSED) {
+ continue;
+ }
// time sliced script
if (_scripts[i]->_timeSlice > 0) {
@@ -318,20 +343,26 @@ bool ScEngine::tick() {
_currentScript = _scripts[i];
_scripts[i]->executeInstruction();
}
- if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, g_system->getMillis() - StartTime);
+ if (_isProfiling && _scripts[i]->_filename) {
+ addScriptTime(_scripts[i]->_filename, g_system->getMillis() - StartTime);
+ }
}
// normal script
else {
uint32 startTime = 0;
bool isProfiling = _isProfiling;
- if (isProfiling) startTime = g_system->getMillis();
+ if (isProfiling) {
+ startTime = g_system->getMillis();
+ }
while (_scripts[i]->_state == SCRIPT_RUNNING) {
_currentScript = _scripts[i];
_scripts[i]->executeInstruction();
}
- if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, g_system->getMillis() - startTime);
+ if (isProfiling && _scripts[i]->_filename) {
+ addScriptTime(_scripts[i]->_filename, g_system->getMillis() - startTime);
+ }
}
_currentScript = NULL;
}
@@ -346,7 +377,9 @@ bool ScEngine::tick() {
bool ScEngine::tickUnbreakable() {
// execute unbreakable scripts
for (int i = 0; i < _scripts.getSize(); i++) {
- if (!_scripts[i]->_unbreakable) continue;
+ if (!_scripts[i]->_unbreakable) {
+ continue;
+ }
while (_scripts[i]->_state == SCRIPT_RUNNING) {
_currentScript = _scripts[i];
@@ -366,7 +399,9 @@ bool ScEngine::removeFinishedScripts() {
// remove finished scripts
for (int i = 0; i < _scripts.getSize(); i++) {
if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) {
- if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]);
+ if (!_scripts[i]->_thread && _scripts[i]->_owner) {
+ _scripts[i]->_owner->removeScript(_scripts[i]);
+ }
_gameRef->getDebugMgr()->onScriptShutdown(_scripts[i]);
delete _scripts[i];
_scripts.removeAt(i);
@@ -382,7 +417,9 @@ int ScEngine::getNumScripts(int *running, int *waiting, int *persistent) {
int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0;
for (int i = 0; i < _scripts.getSize(); i++) {
- if (_scripts[i]->_state == SCRIPT_FINISHED) continue;
+ if (_scripts[i]->_state == SCRIPT_FINISHED) {
+ continue;
+ }
switch (_scripts[i]->_state) {
case SCRIPT_RUNNING:
case SCRIPT_SLEEPING:
@@ -401,9 +438,15 @@ int ScEngine::getNumScripts(int *running, int *waiting, int *persistent) {
}
numTotal++;
}
- if (running) *running = numRunning;
- if (waiting) *waiting = numWaiting;
- if (persistent) *persistent = numPersistent;
+ if (running) {
+ *running = numRunning;
+ }
+ if (waiting) {
+ *waiting = numWaiting;
+ }
+ if (persistent) {
+ *persistent = numPersistent;
+ }
return numTotal;
}
@@ -426,7 +469,9 @@ bool ScEngine::resetObject(BaseObject *Object) {
// terminate all scripts waiting for this object
for (int i = 0; i < _scripts.getSize(); i++) {
if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) {
- if (!_gameRef->_compatKillMethodThreads) resetScript(_scripts[i]);
+ if (!_gameRef->_compatKillMethodThreads) {
+ resetScript(_scripts[i]);
+ }
bool IsThread = _scripts[i]->_methodThread || _scripts[i]->_thread;
_scripts[i]->finish(!IsThread); // 1.9b1 - top-level script kills its threads as well
@@ -448,7 +493,9 @@ bool ScEngine::resetScript(ScScript *script) {
//////////////////////////////////////////////////////////////////////////
bool ScEngine::persist(BasePersistenceManager *persistMgr) {
- if (!persistMgr->getIsSaving()) cleanup();
+ if (!persistMgr->getIsSaving()) {
+ cleanup();
+ }
persistMgr->transfer(TMEMBER(_gameRef));
persistMgr->transfer(TMEMBER(_currentScript));
@@ -474,7 +521,9 @@ void ScEngine::editorCleanup() {
//////////////////////////////////////////////////////////////////////////
bool ScEngine::pauseAll() {
for (int i = 0; i < _scripts.getSize(); i++) {
- if (_scripts[i] != _currentScript) _scripts[i]->pause();
+ if (_scripts[i] != _currentScript) {
+ _scripts[i]->pause();
+ }
}
return STATUS_OK;
@@ -483,8 +532,9 @@ bool ScEngine::pauseAll() {
//////////////////////////////////////////////////////////////////////////
bool ScEngine::resumeAll() {
- for (int i = 0; i < _scripts.getSize(); i++)
+ for (int i = 0; i < _scripts.getSize(); i++) {
_scripts[i]->resume();
+ }
return STATUS_OK;
}
@@ -493,7 +543,9 @@ bool ScEngine::resumeAll() {
//////////////////////////////////////////////////////////////////////////
bool ScEngine::isValidScript(ScScript *script) {
for (int i = 0; i < _scripts.getSize(); i++) {
- if (_scripts[i] == script) return true;
+ if (_scripts[i] == script) {
+ return true;
+ }
}
return false;
}
@@ -511,14 +563,17 @@ bool ScEngine::dbgSendScripts(IWmeDebugClient *client) {
// process normal scripts first
for (int i = 0; i < _scripts.getSize(); i++) {
- if (_scripts[i]->_thread || _scripts[i]->_methodThread) continue;
+ if (_scripts[i]->_thread || _scripts[i]->_methodThread) {
+ continue;
+ }
_scripts[i]->dbgSendScript(client);
}
// and threads later
for (int i = 0; i < _scripts.getSize(); i++) {
- if (_scripts[i]->_thread || _scripts[i]->_methodThread)
+ if (_scripts[i]->_thread || _scripts[i]->_methodThread) {
_scripts[i]->dbgSendScript(client);
+ }
}
return STATUS_OK;
@@ -526,7 +581,9 @@ bool ScEngine::dbgSendScripts(IWmeDebugClient *client) {
//////////////////////////////////////////////////////////////////////////
bool ScEngine::addBreakpoint(const char *scriptFilename, int line) {
- if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK;
+ if (!_gameRef->getDebugMgr()->_enabled) {
+ return STATUS_OK;
+ }
CScBreakpoint *bp = NULL;
for (int i = 0; i < _breakpoints.getSize(); i++) {
@@ -541,7 +598,9 @@ bool ScEngine::addBreakpoint(const char *scriptFilename, int line) {
}
for (int i = 0; i < bp->_lines.getSize(); i++) {
- if (bp->_lines[i] == line) return STATUS_OK;
+ if (bp->_lines[i] == line) {
+ return STATUS_OK;
+ }
}
bp->_lines.add(line);
@@ -553,7 +612,9 @@ bool ScEngine::addBreakpoint(const char *scriptFilename, int line) {
//////////////////////////////////////////////////////////////////////////
bool ScEngine::removeBreakpoint(const char *scriptFilename, int line) {
- if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK;
+ if (!_gameRef->getDebugMgr()->_enabled) {
+ return STATUS_OK;
+ }
for (int i = 0; i < _breakpoints.getSize(); i++) {
if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) {
@@ -578,7 +639,9 @@ bool ScEngine::removeBreakpoint(const char *scriptFilename, int line) {
//////////////////////////////////////////////////////////////////////////
bool ScEngine::refreshScriptBreakpoints() {
- if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK;
+ if (!_gameRef->getDebugMgr()->_enabled) {
+ return STATUS_OK;
+ }
for (int i = 0; i < _scripts.getSize(); i++) {
refreshScriptBreakpoints(_scripts[i]);
@@ -588,9 +651,13 @@ bool ScEngine::refreshScriptBreakpoints() {
//////////////////////////////////////////////////////////////////////////
bool ScEngine::refreshScriptBreakpoints(ScScript *script) {
- if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK;
+ if (!_gameRef->getDebugMgr()->_enabled) {
+ return STATUS_OK;
+ }
- if (!script || !script->_filename) return STATUS_FAILED;
+ if (!script || !script->_filename) {
+ return STATUS_FAILED;
+ }
for (int i = 0; i < _breakpoints.getSize(); i++) {
if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), script->_filename) == 0) {
@@ -598,14 +665,18 @@ bool ScEngine::refreshScriptBreakpoints(ScScript *script) {
return STATUS_OK;
}
}
- if (script->_breakpoints.getSize() > 0) script->_breakpoints.removeAll();
+ if (script->_breakpoints.getSize() > 0) {
+ script->_breakpoints.removeAll();
+ }
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
bool ScEngine::saveBreakpoints() {
- if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK;
+ if (!_gameRef->getDebugMgr()->_enabled) {
+ return STATUS_OK;
+ }
char text[512];
@@ -628,7 +699,9 @@ bool ScEngine::saveBreakpoints() {
//////////////////////////////////////////////////////////////////////////
bool ScEngine::loadBreakpoints() {
- if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK;
+ if (!_gameRef->getDebugMgr()->_enabled) {
+ return STATUS_OK;
+ }
char key[100];
@@ -641,7 +714,9 @@ bool ScEngine::loadBreakpoints() {
char *path = BaseUtils::strEntry(0, breakpoint.c_str(), ':');
char *line = BaseUtils::strEntry(1, breakpoint.c_str(), ':');
- if (path != NULL && line != NULL) addBreakpoint(path, atoi(line));
+ if (path != NULL && line != NULL) {
+ addBreakpoint(path, atoi(line));
+ }
delete[] path;
delete[] line;
path = NULL;
@@ -654,7 +729,9 @@ bool ScEngine::loadBreakpoints() {
//////////////////////////////////////////////////////////////////////////
void ScEngine::addScriptTime(const char *filename, uint32 time) {
- if (!_isProfiling) return;
+ if (!_isProfiling) {
+ return;
+ }
AnsiString fileName = filename;
fileName.toLowercase();
@@ -664,7 +741,9 @@ void ScEngine::addScriptTime(const char *filename, uint32 time) {
//////////////////////////////////////////////////////////////////////////
void ScEngine::enableProfiling() {
- if (_isProfiling) return;
+ if (_isProfiling) {
+ return;
+ }
// destroy old data, if any
_scriptTimes.clear();
@@ -676,7 +755,9 @@ void ScEngine::enableProfiling() {
//////////////////////////////////////////////////////////////////////////
void ScEngine::disableProfiling() {
- if (!_isProfiling) return;
+ if (!_isProfiling) {
+ return;
+ }
dumpStats();
_isProfiling = false;
diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h
index e443ec5832..fc441347df 100644
--- a/engines/wintermute/base/scriptables/script_engine.h
+++ b/engines/wintermute/base/scriptables/script_engine.h
@@ -48,13 +48,17 @@ public:
CScCachedScript(const char *filename, byte *buffer, uint32 size) {
_timestamp = g_system->getMillis();
_buffer = new byte[size];
- if (_buffer) memcpy(_buffer, buffer, size);
+ if (_buffer) {
+ memcpy(_buffer, buffer, size);
+ }
_size = size;
_filename = filename;
};
~CScCachedScript() {
- if (_buffer) delete[] _buffer;
+ if (_buffer) {
+ delete[] _buffer;
+ }
};
uint32 _timestamp;
diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp
index 41059b2d80..0380103cd4 100644
--- a/engines/wintermute/base/scriptables/script_ext_array.cpp
+++ b/engines/wintermute/base/scriptables/script_ext_array.cpp
@@ -47,8 +47,9 @@ SXArray::SXArray(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) {
int numParams = stack->pop()->getInt(0);
- if (numParams == 1) _length = stack->pop()->getInt(0);
- else if (numParams > 1) {
+ if (numParams == 1) {
+ _length = stack->pop()->getInt(0);
+ } else if (numParams > 1) {
_length = numParams;
char paramName[20];
for (int i = 0; i < numParams; i++) {
@@ -86,7 +87,9 @@ const char *SXArray::scToString() {
}
}
- if (i < _length - 1 && strlen(dummy) + 1 < 32768) strcat(dummy, ",");
+ if (i < _length - 1 && strlen(dummy) + 1 < 32768) {
+ strcat(dummy, ",");
+ }
}
return dummy;
}
@@ -124,12 +127,14 @@ bool SXArray::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
stack->push(_values->getProp(paramName));
_values->deleteProp(paramName);
_length--;
- } else stack->pushNULL();
+ } else {
+ stack->pushNULL();
+ }
return STATUS_OK;
+ } else {
+ return STATUS_FAILED;
}
-
- else return STATUS_FAILED;
}
@@ -160,7 +165,9 @@ ScValue *SXArray::scGetProperty(const char *name) {
char ParamName[20];
if (validNumber(name, ParamName)) {
return _values->getProp(ParamName);
- } else return _scValue;
+ } else {
+ return _scValue;
+ }
}
}
@@ -190,10 +197,14 @@ bool SXArray::scSetProperty(const char *name, ScValue *value) {
else {
char paramName[20];
if (validNumber(name, paramName)) {
- int Index = atoi(paramName);
- if (Index >= _length) _length = Index + 1;
+ int index = atoi(paramName);
+ if (index >= _length) {
+ _length = index + 1;
+ }
return _values->setProp(paramName, value);
- } else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
}
}
@@ -223,7 +234,9 @@ bool SXArray::validNumber(const char *origStr, char *outStr) {
int index = atoi(origStr);
sprintf(outStr, "%d", index);
return true;
- } else return false;
+ } else {
+ return false;
+ }
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/wintermute/base/scriptables/script_ext_array.h b/engines/wintermute/base/scriptables/script_ext_array.h
index 8eb86c4e69..67a1104b46 100644
--- a/engines/wintermute/base/scriptables/script_ext_array.h
+++ b/engines/wintermute/base/scriptables/script_ext_array.h
@@ -35,7 +35,7 @@ namespace WinterMute {
class SXArray : public BaseScriptable {
public:
- bool push(ScValue *Val);
+ bool push(ScValue *val);
bool validNumber(const char *origStr, char *outStr);
DECLARE_PERSISTENT(SXArray, BaseScriptable)
SXArray(BaseGame *inGame, ScStack *stack);
diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp
index d2fd3663c7..a3bb7e2183 100644
--- a/engines/wintermute/base/scriptables/script_ext_date.cpp
+++ b/engines/wintermute/base/scriptables/script_ext_date.cpp
@@ -199,10 +199,9 @@ bool SXDate::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
g_system->getTimeAndDate(_tm);
stack->pushNULL();
return STATUS_OK;
- }
-
- else
+ } else {
return STATUS_FAILED;
+ }
}
@@ -216,9 +215,9 @@ ScValue *SXDate::scGetProperty(const char *name) {
if (strcmp(name, "Type") == 0) {
_scValue->setString("date");
return _scValue;
+ } else {
+ return _scValue;
}
-
- else return _scValue;
}
diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp
index 7da1601bdc..437fbb64a2 100644
--- a/engines/wintermute/base/scriptables/script_ext_file.cpp
+++ b/engines/wintermute/base/scriptables/script_ext_file.cpp
@@ -51,10 +51,12 @@ BaseScriptable *makeSXFile(BaseGame *inGame, ScStack *stack) {
//////////////////////////////////////////////////////////////////////////
SXFile::SXFile(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) {
stack->correctParams(1);
- ScValue *Val = stack->pop();
+ ScValue *val = stack->pop();
_filename = NULL;
- if (!Val->isNULL()) BaseUtils::setString(&_filename, Val->getString());
+ if (!val->isNULL()) {
+ BaseUtils::setString(&_filename, val->getString());
+ }
_readFile = NULL;
_writeFile = NULL;
@@ -94,8 +96,11 @@ void SXFile::close() {
//////////////////////////////////////////////////////////////////////////
const char *SXFile::scToString() {
- if (_filename) return _filename;
- else return "[file object]";
+ if (_filename) {
+ return _filename;
+ } else {
+ return "[file object]";
+ }
}
#define FILE_BUFFER_SIZE 32768
@@ -129,24 +134,37 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
if (!_readFile) {
//script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename);
close();
- } else _textMode = strcmp(name, "OpenAsText") == 0;
+ } else {
+ _textMode = strcmp(name, "OpenAsText") == 0;
+ }
} else {
if (strcmp(name, "OpenAsText") == 0) {
- if (_mode == 2) _writeFile = openForWrite(_filename, false);
- else _writeFile = openForAppend(_filename, false);
+ if (_mode == 2) {
+ _writeFile = openForWrite(_filename, false);
+ } else {
+ _writeFile = openForAppend(_filename, false);
+ }
} else {
- if (_mode == 2) _writeFile = openForWrite(_filename, true);
- else _writeFile = openForAppend(_filename, true);
+ if (_mode == 2) {
+ _writeFile = openForWrite(_filename, true);
+ } else {
+ _writeFile = openForAppend(_filename, true);
+ }
}
if (!_writeFile) {
//script->runtimeError("File.%s: Error opening file '%s' for writing.", Name, _filename);
close();
- } else _textMode = strcmp(name, "OpenAsText") == 0;
+ } else {
+ _textMode = strcmp(name, "OpenAsText") == 0;
+ }
}
- if (_readFile || _writeFile) stack->pushBool(true);
- else stack->pushBool(false);
+ if (_readFile || _writeFile) {
+ stack->pushBool(true);
+ } else {
+ stack->pushBool(false);
+ }
return STATUS_OK;
}
@@ -221,7 +239,9 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
bool ret = STATUS_FAILED;
do {
ret = _readFile->read(&b, 1);
- if (ret != 1) break;
+ if (ret != 1) {
+ break;
+ }
if (counter > bufSize) {
buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE);
@@ -231,8 +251,9 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
buf[counter] = '\0';
foundNewLine = true;
break;
- } else if (b == 0x0D) continue;
- else {
+ } else if (b == 0x0D) {
+ continue;
+ } else {
buf[counter] = b;
counter++;
}
@@ -244,8 +265,11 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
}
buf[counter] = '\0';
- if (!foundNewLine && counter == 0) stack->pushNULL();
- else stack->pushString((char *)buf);
+ if (!foundNewLine && counter == 0) {
+ stack->pushNULL();
+ } else {
+ stack->pushString((char *)buf);
+ }
free(buf);
@@ -272,14 +296,17 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
bool ret = STATUS_FAILED;
while (counter < (uint32)textLen) {
ret = _readFile->read(&b, 1);
- if (ret != 1) break;
+ if (ret != 1) {
+ break;
+ }
if (counter > bufSize) {
buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE);
bufSize += FILE_BUFFER_SIZE;
}
- if (b == 0x0D) continue;
- else {
+ if (b == 0x0D) {
+ continue;
+ } else {
buf[counter] = b;
counter++;
}
@@ -291,8 +318,11 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
}
buf[counter] = '\0';
- if (textLen > 0 && counter == 0) stack->pushNULL();
- else stack->pushString((char *)buf);
+ if (textLen > 0 && counter == 0) {
+ stack->pushNULL();
+ } else {
+ stack->pushString((char *)buf);
+ }
free(buf);
@@ -335,8 +365,11 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
return STATUS_OK;
}
bool val;
- if (_readFile->read(&val, sizeof(bool)) == sizeof(bool)) stack->pushBool(val);
- else stack->pushNULL();
+ if (_readFile->read(&val, sizeof(bool)) == sizeof(bool)) {
+ stack->pushBool(val);
+ } else {
+ stack->pushNULL();
+ }
return STATUS_OK;
}
@@ -355,8 +388,8 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
if (!_readFile->err()) {
stack->pushInt(val);
} else {
- stack->pushNULL();
- }
+ stack->pushNULL();
+ }
return STATUS_OK;
}
@@ -375,7 +408,7 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
if (!_readFile->err()) {
stack->pushInt(65536 + val);
} else {
- stack->pushNULL();
+ stack->pushNULL();
}
return STATUS_OK;
}
@@ -411,7 +444,7 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
return STATUS_OK;
}
float val;
- (*(uint32*)&val) = _readFile->readUint32LE();
+ (*(uint32 *)&val) = _readFile->readUint32LE();
if (!_readFile->err()) {
stack->pushFloat(val);
} else {
@@ -433,8 +466,11 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
return STATUS_OK;
}
double val;
- if (_readFile->read(&val, sizeof(double)) == sizeof(double)) stack->pushFloat(val);
- else stack->pushNULL();
+ if (_readFile->read(&val, sizeof(double)) == sizeof(double)) {
+ stack->pushFloat(val);
+ } else {
+ stack->pushNULL();
+ }
return STATUS_OK;
}
@@ -458,8 +494,12 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
stack->pushString((char *)str);
}
delete[] str;
- } else stack->pushNULL();
- } else stack->pushNULL();
+ } else {
+ stack->pushNULL();
+ }
+ } else {
+ stack->pushNULL();
+ }
return STATUS_OK;
}
@@ -548,7 +588,7 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
stack->pushBool(false);
return STATUS_OK;
}
- uint32 *ptr = (uint32*)&val;
+ uint32 *ptr = (uint32 *)&val;
_writeFile->writeUint32LE(*ptr);
stack->pushBool(true);
@@ -594,10 +634,9 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
stack->pushBool(true);
return STATUS_OK;
+ } else {
+ return BaseScriptable::scCallMethod(script, stack, thisStack, name);
}
-
-
- else return BaseScriptable::scCallMethod(script, stack, thisStack, name);
}
@@ -651,9 +690,9 @@ ScValue *SXFile::scGetProperty(const char *name) {
else if (strcmp(name, "AccessMode") == 0) {
_scValue->setInt(_mode);
return _scValue;
+ } else {
+ return BaseScriptable::scGetProperty(name);
}
-
- else return BaseScriptable::scGetProperty(name);
}
@@ -681,43 +720,46 @@ bool SXFile::scSetProperty(const char *name, ScValue *value) {
//////////////////////////////////////////////////////////////////////////
uint32 SXFile::getPos() {
- if (_mode == 1 && _readFile)
+ if (_mode == 1 && _readFile) {
return _readFile->pos();
- else if ((_mode == 2 || _mode == 3) && _writeFile) {
+ } else if ((_mode == 2 || _mode == 3) && _writeFile) {
error("SXFile - getPos for WriteFile not supported");
return 0;
// return ftell((FILE *)_writeFile);
- } else {
+ } else {
return 0;
}
}
//////////////////////////////////////////////////////////////////////////
bool SXFile::setPos(uint32 pos, int whence) {
- if (_mode == 1 && _readFile)
+ if (_mode == 1 && _readFile) {
return _readFile->seek(pos, whence);
- else if ((_mode == 2 || _mode == 3) && _writeFile) {
+ } else if ((_mode == 2 || _mode == 3) && _writeFile) {
error("SXFile - seeking in WriteFile not supported");
return false;
// return fseek((FILE *)_writeFile, pos, (int)origin) == 0;
+ } else {
+ return false;
}
- else return false;
}
//////////////////////////////////////////////////////////////////////////
uint32 SXFile::getLength() {
- if (_mode == 1 && _readFile)
+ if (_mode == 1 && _readFile) {
return _readFile->size();
- else if ((_mode == 2 || _mode == 3) && _writeFile) {
+ } else if ((_mode == 2 || _mode == 3) && _writeFile) {
error("SXFile - reading length for WriteFile not supported");
return 0;
-/*
- uint32 currentPos = ftell((FILE *)_writeFile);
- fseek((FILE *)_writeFile, 0, SEEK_END);
- int ret = ftell((FILE *)_writeFile);
- fseek((FILE *)_writeFile, CurrentPos, SEEK_SET);
- return Ret;*/
- } else return 0;
+ /*
+ uint32 currentPos = ftell((FILE *)_writeFile);
+ fseek((FILE *)_writeFile, 0, SEEK_END);
+ int ret = ftell((FILE *)_writeFile);
+ fseek((FILE *)_writeFile, CurrentPos, SEEK_SET);
+ return Ret;*/
+ } else {
+ return 0;
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -744,24 +786,28 @@ bool SXFile::persist(BasePersistenceManager *persistMgr) {
// open for reading
if (_mode == 1) {
_readFile = _gameRef->_fileManager->openFile(_filename);
- if (!_readFile)
+ if (!_readFile) {
close();
+ }
}
// open for writing / appending
else {
if (_textMode) {
- if (_mode == 2)
+ if (_mode == 2) {
_writeFile = openForWrite(_filename, false);
- else
+ } else {
_writeFile = openForAppend(_filename, false);
+ }
} else {
- if (_mode == 2)
+ if (_mode == 2) {
_writeFile = openForWrite(_filename, true);
- else
+ } else {
_writeFile = openForAppend(_filename, true);
+ }
}
- if (_writeFile)
+ if (_writeFile) {
close();
+ }
}
setPos(pos);
}
@@ -777,7 +823,7 @@ Common::WriteStream *SXFile::openForWrite(const Common::String &filename, bool b
// Should replace fopen(..., "ab+") and fopen(..., "a+")
Common::WriteStream *SXFile::openForAppend(const Common::String &filename, bool binary) {
- error("SXFile::openForAppend - WriteFiles not supported");
+ error("SXFile::openForAppend - WriteFiles not supported");
}
} // end of namespace WinterMute
diff --git a/engines/wintermute/base/scriptables/script_ext_math.cpp b/engines/wintermute/base/scriptables/script_ext_math.cpp
index 1c37a15aa9..525b43434f 100644
--- a/engines/wintermute/base/scriptables/script_ext_math.cpp
+++ b/engines/wintermute/base/scriptables/script_ext_math.cpp
@@ -243,9 +243,9 @@ bool SXMath::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
stack->correctParams(1);
stack->pushFloat(radianToDegree(stack->pop()->getFloat()));
return STATUS_OK;
+ } else {
+ return STATUS_FAILED;
}
-
- else return STATUS_FAILED;
}
@@ -267,9 +267,9 @@ ScValue *SXMath::scGetProperty(const char *name) {
else if (strcmp(name, "PI") == 0) {
_scValue->setFloat(M_PI);
return _scValue;
+ } else {
+ return _scValue;
}
-
- else return _scValue;
}
diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp
index 3d3f0b218b..e15af3446e 100644
--- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp
+++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp
@@ -70,7 +70,9 @@ void *SXMemBuffer::scToMemBuffer() {
//////////////////////////////////////////////////////////////////////////
void SXMemBuffer::cleanup() {
- if (_size) free(_buffer);
+ if (_size) {
+ free(_buffer);
+ }
_buffer = NULL;
_size = 0;
}
@@ -81,14 +83,18 @@ bool SXMemBuffer::resize(int newSize) {
if (_size == 0) {
_buffer = malloc(newSize);
- if (_buffer) _size = newSize;
+ if (_buffer) {
+ _size = newSize;
+ }
} else {
void *newBuf = realloc(_buffer, newSize);
if (!newBuf) {
if (newSize == 0) {
_buffer = newBuf;
_size = newSize;
- } else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
} else {
_buffer = newBuf;
_size = newSize;
@@ -107,14 +113,16 @@ bool SXMemBuffer::checkBounds(ScScript *script, int start, int length) {
script->runtimeError("Cannot use Set/Get methods on an uninitialized memory buffer");
return false;
}
- if (_size == 0)
+ if (_size == 0) {
return true;
+ }
if (start < 0 || length == 0 || start + length > _size) {
script->runtimeError("Set/Get method call is out of bounds");
return false;
- } else
+ } else {
return true;
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -132,10 +140,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
stack->correctParams(1);
int newSize = stack->pop()->getInt();
newSize = MAX(0, newSize);
- if (DID_SUCCEED(resize(newSize)))
+ if (DID_SUCCEED(resize(newSize))) {
stack->pushBool(true);
- else
+ } else {
stack->pushBool(false);
+ }
return STATUS_OK;
}
@@ -146,10 +155,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
else if (strcmp(name, "GetBool") == 0) {
stack->correctParams(1);
int start = stack->pop()->getInt();
- if (!checkBounds(script, start, sizeof(bool)))
+ if (!checkBounds(script, start, sizeof(bool))) {
stack->pushNULL();
- else
+ } else {
stack->pushBool(*(bool *)((byte *)_buffer + start));
+ }
return STATUS_OK;
}
@@ -160,10 +170,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
else if (strcmp(name, "GetByte") == 0) {
stack->correctParams(1);
int start = stack->pop()->getInt();
- if (!checkBounds(script, start, sizeof(byte)))
+ if (!checkBounds(script, start, sizeof(byte))) {
stack->pushNULL();
- else
+ } else {
stack->pushInt(*(byte *)((byte *)_buffer + start));
+ }
return STATUS_OK;
}
@@ -174,10 +185,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
else if (strcmp(name, "GetShort") == 0) {
stack->correctParams(1);
int Start = stack->pop()->getInt();
- if (!checkBounds(script, Start, sizeof(short)))
+ if (!checkBounds(script, Start, sizeof(short))) {
stack->pushNULL();
- else
+ } else {
stack->pushInt(65536 + * (short *)((byte *)_buffer + Start));
+ }
return STATUS_OK;
}
@@ -188,10 +200,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
else if (strcmp(name, "GetInt") == 0 || strcmp(name, "GetLong") == 0) {
stack->correctParams(1);
int start = stack->pop()->getInt();
- if (!checkBounds(script, start, sizeof(int)))
+ if (!checkBounds(script, start, sizeof(int))) {
stack->pushNULL();
- else
+ } else {
stack->pushInt(*(int *)((byte *)_buffer + start));
+ }
return STATUS_OK;
}
@@ -202,10 +215,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
else if (strcmp(name, "GetFloat") == 0) {
stack->correctParams(1);
int start = stack->pop()->getInt();
- if (!checkBounds(script, start, sizeof(float)))
+ if (!checkBounds(script, start, sizeof(float))) {
stack->pushNULL();
- else
+ } else {
stack->pushFloat(*(float *)((byte *)_buffer + start));
+ }
return STATUS_OK;
}
@@ -216,10 +230,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
else if (strcmp(name, "GetDouble") == 0) {
stack->correctParams(1);
int start = stack->pop()->getInt();
- if (!checkBounds(script, start, sizeof(double)))
+ if (!checkBounds(script, start, sizeof(double))) {
stack->pushNULL();
- else
+ } else {
stack->pushFloat(*(double *)((byte *)_buffer + start));
+ }
return STATUS_OK;
}
@@ -242,9 +257,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
}
}
- if (!checkBounds(script, start, length))
+ if (!checkBounds(script, start, length)) {
stack->pushNULL();
- else {
+ } else {
char *str = new char[length + 1];
strncpy(str, (const char *)_buffer + start, length);
str[length] = '\0';
@@ -260,9 +275,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
else if (strcmp(name, "GetPointer") == 0) {
stack->correctParams(1);
int start = stack->pop()->getInt();
- if (!checkBounds(script, start, sizeof(void *)))
+ if (!checkBounds(script, start, sizeof(void *))) {
stack->pushNULL();
- else {
+ } else {
void *pointer = *(void **)((byte *)_buffer + start);
SXMemBuffer *buf = new SXMemBuffer(_gameRef, pointer);
stack->pushNative(buf, false);
@@ -278,9 +293,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
int start = stack->pop()->getInt();
bool val = stack->pop()->getBool();
- if (!checkBounds(script, start, sizeof(bool)))
+ if (!checkBounds(script, start, sizeof(bool))) {
stack->pushBool(false);
- else {
+ } else {
*(bool *)((byte *)_buffer + start) = val;
stack->pushBool(true);
}
@@ -295,9 +310,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
int start = stack->pop()->getInt();
byte val = (byte)stack->pop()->getInt();
- if (!checkBounds(script, start, sizeof(byte)))
+ if (!checkBounds(script, start, sizeof(byte))) {
stack->pushBool(false);
- else {
+ } else {
*(byte *)((byte *)_buffer + start) = val;
stack->pushBool(true);
}
@@ -312,9 +327,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
int start = stack->pop()->getInt();
short val = (short)stack->pop()->getInt();
- if (!checkBounds(script, start, sizeof(short)))
+ if (!checkBounds(script, start, sizeof(short))) {
stack->pushBool(false);
- else {
+ } else {
*(short *)((byte *)_buffer + start) = val;
stack->pushBool(true);
}
@@ -329,9 +344,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
int start = stack->pop()->getInt();
int val = stack->pop()->getInt();
- if (!checkBounds(script, start, sizeof(int)))
+ if (!checkBounds(script, start, sizeof(int))) {
stack->pushBool(false);
- else {
+ } else {
*(int *)((byte *)_buffer + start) = val;
stack->pushBool(true);
}
@@ -346,9 +361,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
int start = stack->pop()->getInt();
float val = (float)stack->pop()->getFloat();
- if (!checkBounds(script, start, sizeof(float)))
+ if (!checkBounds(script, start, sizeof(float))) {
stack->pushBool(false);
- else {
+ } else {
*(float *)((byte *)_buffer + start) = val;
stack->pushBool(true);
}
@@ -363,9 +378,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
int start = stack->pop()->getInt();
double val = stack->pop()->getFloat();
- if (!checkBounds(script, start, sizeof(double)))
+ if (!checkBounds(script, start, sizeof(double))) {
stack->pushBool(false);
- else {
+ } else {
*(double *)((byte *)_buffer + start) = val;
stack->pushBool(true);
}
@@ -380,9 +395,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
int start = stack->pop()->getInt();
const char *val = stack->pop()->getString();
- if (!checkBounds(script, start, strlen(val) + 1))
+ if (!checkBounds(script, start, strlen(val) + 1)) {
stack->pushBool(false);
- else {
+ } else {
memcpy((byte *)_buffer + start, val, strlen(val) + 1);
stack->pushBool(true);
}
@@ -395,11 +410,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
else if (strcmp(name, "SetPointer") == 0) {
stack->correctParams(2);
int start = stack->pop()->getInt();
- /* ScValue *Val = */ stack->pop();
+ /* ScValue *val = */ stack->pop();
- if (!checkBounds(script, start, sizeof(void *)))
+ if (!checkBounds(script, start, sizeof(void *))) {
stack->pushBool(false);
- else {
+ } else {
/*
int Pointer = (int)Val->getMemBuffer();
memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*));
@@ -426,9 +441,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
}
stack->pushNULL();
return STATUS_OK;
+ } else {
+ return STATUS_FAILED;
}
-
- else return STATUS_FAILED;
}
@@ -450,9 +465,9 @@ ScValue *SXMemBuffer::scGetProperty(const char *name) {
if (strcmp(name, "Size") == 0) {
_scValue->setInt(_size);
return _scValue;
+ } else {
+ return BaseScriptable::scGetProperty(name);
}
-
- else return BaseScriptable::scGetProperty(name);
}
@@ -487,12 +502,16 @@ bool SXMemBuffer::persist(BasePersistenceManager *persistMgr) {
persistMgr->transfer(TMEMBER(_size));
if (persistMgr->getIsSaving()) {
- if (_size > 0) persistMgr->putBytes((byte *)_buffer, _size);
+ if (_size > 0) {
+ persistMgr->putBytes((byte *)_buffer, _size);
+ }
} else {
if (_size > 0) {
_buffer = malloc(_size);
persistMgr->getBytes((byte *)_buffer, _size);
- } else _buffer = NULL;
+ } else {
+ _buffer = NULL;
+ }
}
return STATUS_OK;
@@ -501,8 +520,11 @@ bool SXMemBuffer::persist(BasePersistenceManager *persistMgr) {
//////////////////////////////////////////////////////////////////////////
int SXMemBuffer::scCompare(BaseScriptable *val) {
- if (_buffer == val->scToMemBuffer()) return 0;
- else return 1;
+ if (_buffer == val->scToMemBuffer()) {
+ return 0;
+ } else {
+ return 1;
+ }
}
} // end of namespace WinterMute
diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp
index 385d7ca746..1c7349bd8d 100644
--- a/engines/wintermute/base/scriptables/script_ext_string.cpp
+++ b/engines/wintermute/base/scriptables/script_ext_string.cpp
@@ -61,13 +61,17 @@ SXString::SXString(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) {
setStringVal(val->getString());
}
- if (_capacity == 0) setStringVal("");
+ if (_capacity == 0) {
+ setStringVal("");
+ }
}
//////////////////////////////////////////////////////////////////////////
SXString::~SXString() {
- if (_string) delete[] _string;
+ if (_string) {
+ delete[] _string;
+ }
}
@@ -87,8 +91,11 @@ void SXString::setStringVal(const char *val) {
//////////////////////////////////////////////////////////////////////////
const char *SXString::scToString() {
- if (_string) return _string;
- else return "[null string]";
+ if (_string) {
+ return _string;
+ } else {
+ return "[null string]";
+ }
}
@@ -108,22 +115,26 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
int start = stack->pop()->getInt();
int end = stack->pop()->getInt();
- if (end < start) BaseUtils::swap(&start, &end);
+ if (end < start) {
+ BaseUtils::swap(&start, &end);
+ }
//try {
WideString str;
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
str = StringUtil::utf8ToWide(_string);
- else
+ } else {
str = StringUtil::ansiToWide(_string);
+ }
//WideString subStr = str.substr(start, end - start + 1);
WideString subStr(str.c_str() + start, end - start + 1);
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
stack->pushString(StringUtil::wideToUtf8(subStr).c_str());
- else
+ } else {
stack->pushString(StringUtil::wideToAnsi(subStr).c_str());
+ }
// } catch (std::exception &) {
// stack->pushNULL();
// }
@@ -146,22 +157,26 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
return STATUS_OK;
}
- if (val->isNULL()) len = strlen(_string) - start;
+ if (val->isNULL()) {
+ len = strlen(_string) - start;
+ }
// try {
WideString str;
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
str = StringUtil::utf8ToWide(_string);
- else
+ } else {
str = StringUtil::ansiToWide(_string);
+ }
// WideString subStr = str.substr(start, len);
WideString subStr(str.c_str() + start, len);
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
stack->pushString(StringUtil::wideToUtf8(subStr).c_str());
- else
+ } else {
stack->pushString(StringUtil::wideToAnsi(subStr).c_str());
+ }
// } catch (std::exception &) {
// stack->pushNULL();
// }
@@ -176,17 +191,19 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
stack->correctParams(0);
WideString str;
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
str = StringUtil::utf8ToWide(_string);
- else
+ } else {
str = StringUtil::ansiToWide(_string);
+ }
str.toUppercase();
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
stack->pushString(StringUtil::wideToUtf8(str).c_str());
- else
+ } else {
stack->pushString(StringUtil::wideToAnsi(str).c_str());
+ }
return STATUS_OK;
}
@@ -198,17 +215,19 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
stack->correctParams(0);
WideString str;
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
str = StringUtil::utf8ToWide(_string);
- else
+ } else {
str = StringUtil::ansiToWide(_string);
+ }
str.toLowercase();
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
stack->pushString(StringUtil::wideToUtf8(str).c_str());
- else
+ } else {
stack->pushString(StringUtil::wideToAnsi(str).c_str());
+ }
return STATUS_OK;
}
@@ -223,16 +242,18 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
int index = stack->pop()->getInt();
WideString str;
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
str = StringUtil::utf8ToWide(_string);
- else
+ } else {
str = StringUtil::ansiToWide(_string);
+ }
WideString toFind;
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
toFind = StringUtil::utf8ToWide(strToFind);
- else
+ } else {
toFind = StringUtil::ansiToWide(strToFind);
+ }
int indexOf = StringUtil::indexOf(str, toFind, index);
stack->pushInt(indexOf);
@@ -247,7 +268,9 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
stack->correctParams(1);
ScValue *val = stack->pop();
char separators[MAX_PATH_LENGTH] = ",";
- if (!val->isNULL()) strcpy(separators, val->getString());
+ if (!val->isNULL()) {
+ strcpy(separators, val->getString());
+ }
SXArray *array = new SXArray(_gameRef);
if (!array) {
@@ -257,16 +280,18 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
WideString str;
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
str = StringUtil::utf8ToWide(_string);
- else
+ } else {
str = StringUtil::ansiToWide(_string);
+ }
WideString delims;
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
delims = StringUtil::utf8ToWide(separators);
- else
+ } else {
delims = StringUtil::ansiToWide(separators);
+ }
Common::Array<WideString> parts;
@@ -298,10 +323,11 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
for (Common::Array<WideString>::iterator it = parts.begin(); it != parts.end(); ++it) {
WideString &part = (*it);
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
val = new ScValue(_gameRef, StringUtil::wideToUtf8(part).c_str());
- else
+ } else {
val = new ScValue(_gameRef, StringUtil::wideToAnsi(part).c_str());
+ }
array->push(val);
delete val;
@@ -310,9 +336,9 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
stack->pushNative(array, false);
return STATUS_OK;
+ } else {
+ return STATUS_FAILED;
}
-
- else return STATUS_FAILED;
}
@@ -334,8 +360,9 @@ ScValue *SXString::scGetProperty(const char *name) {
if (_gameRef->_textEncoding == TEXT_UTF8) {
WideString wstr = StringUtil::utf8ToWide(_string);
_scValue->setInt(wstr.size());
- } else
+ } else {
_scValue->setInt(strlen(_string));
+ }
return _scValue;
}
@@ -345,9 +372,9 @@ ScValue *SXString::scGetProperty(const char *name) {
else if (strcmp(name, "Capacity") == 0) {
_scValue->setInt(_capacity);
return _scValue;
+ } else {
+ return _scValue;
}
-
- else return _scValue;
}
@@ -358,8 +385,9 @@ bool SXString::scSetProperty(const char *name, ScValue *value) {
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "Capacity") == 0) {
int32 newCap = (uint32)value->getInt();
- if (newCap < (int32)(strlen(_string) + 1)) _gameRef->LOG(0, "Warning: cannot lower string capacity");
- else if (newCap != _capacity) {
+ if (newCap < (int32)(strlen(_string) + 1)) {
+ _gameRef->LOG(0, "Warning: cannot lower string capacity");
+ } else if (newCap != _capacity) {
char *newStr = new char[newCap];
if (newStr) {
memset(newStr, 0, newCap);
@@ -370,9 +398,9 @@ bool SXString::scSetProperty(const char *name, ScValue *value) {
}
}
return STATUS_OK;
+ } else {
+ return STATUS_FAILED;
}
-
- else return STATUS_FAILED;
}
@@ -384,12 +412,16 @@ bool SXString::persist(BasePersistenceManager *persistMgr) {
persistMgr->transfer(TMEMBER(_capacity));
if (persistMgr->getIsSaving()) {
- if (_capacity > 0) persistMgr->putBytes((byte *)_string, _capacity);
+ if (_capacity > 0) {
+ persistMgr->putBytes((byte *)_string, _capacity);
+ }
} else {
if (_capacity > 0) {
_string = new char[_capacity];
persistMgr->getBytes((byte *)_string, _capacity);
- } else _string = NULL;
+ } else {
+ _string = NULL;
+ }
}
return STATUS_OK;
diff --git a/engines/wintermute/base/scriptables/script_stack.cpp b/engines/wintermute/base/scriptables/script_stack.cpp
index 74cc7a57ee..0d4ea54b8c 100644
--- a/engines/wintermute/base/scriptables/script_stack.cpp
+++ b/engines/wintermute/base/scriptables/script_stack.cpp
@@ -96,16 +96,22 @@ ScValue *ScStack::getPushValue() {
//////////////////////////////////////////////////////////////////////////
ScValue *ScStack::getTop() {
- if (_sP < 0 || _sP >= _values.getSize()) return NULL;
- else return _values[_sP];
+ if (_sP < 0 || _sP >= _values.getSize()) {
+ return NULL;
+ } else {
+ return _values[_sP];
+ }
}
//////////////////////////////////////////////////////////////////////////
ScValue *ScStack::getAt(int index) {
index = _sP - index;
- if (index < 0 || index >= _values.getSize()) return NULL;
- else return _values[index];
+ if (index < 0 || index >= _values.getSize()) {
+ return NULL;
+ } else {
+ return _values[index];
+ }
}
diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp
index 5e824cd10c..01cb4044ff 100644
--- a/engines/wintermute/base/scriptables/script_value.cpp
+++ b/engines/wintermute/base/scriptables/script_value.cpp
@@ -122,7 +122,9 @@ ScValue::ScValue(BaseGame *inGame, const char *val): BaseClass(inGame) {
void ScValue::cleanup(bool ignoreNatives) {
deleteProps();
- if (_valString) delete[] _valString;
+ if (_valString) {
+ delete[] _valString;
+ }
if (!ignoreNatives) {
if (_valNative && !_persistent) {
@@ -157,7 +159,9 @@ ScValue::~ScValue() {
//////////////////////////////////////////////////////////////////////////
ScValue *ScValue::getProp(const char *name) {
- if (_type == VAL_VARIABLE_REF) return _valRef->getProp(name);
+ if (_type == VAL_VARIABLE_REF) {
+ return _valRef->getProp(name);
+ }
if (_type == VAL_STRING && strcmp(name, "Length") == 0) {
_gameRef->_scValue->_type = VAL_INT;
@@ -178,18 +182,24 @@ ScValue *ScValue::getProp(const char *name) {
ScValue *ret = NULL;
- if (_type == VAL_NATIVE && _valNative) ret = _valNative->scGetProperty(name);
+ if (_type == VAL_NATIVE && _valNative) {
+ ret = _valNative->scGetProperty(name);
+ }
if (ret == NULL) {
_valIter = _valObject.find(name);
- if (_valIter != _valObject.end()) ret = _valIter->_value;
+ if (_valIter != _valObject.end()) {
+ ret = _valIter->_value;
+ }
}
return ret;
}
//////////////////////////////////////////////////////////////////////////
bool ScValue::deleteProp(const char *name) {
- if (_type == VAL_VARIABLE_REF) return _valRef->deleteProp(name);
+ if (_type == VAL_VARIABLE_REF) {
+ return _valRef->deleteProp(name);
+ }
_valIter = _valObject.find(name);
if (_valIter != _valObject.end()) {
@@ -204,8 +214,9 @@ bool ScValue::deleteProp(const char *name) {
//////////////////////////////////////////////////////////////////////////
bool ScValue::setProp(const char *name, ScValue *val, bool copyWhole, bool setAsConst) {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->setProp(name, val);
+ }
bool ret = STATUS_FAILED;
if (_type == VAL_NATIVE && _valNative) {
@@ -219,15 +230,19 @@ bool ScValue::setProp(const char *name, ScValue *val, bool copyWhole, bool setAs
if (_valIter != _valObject.end()) {
newVal = _valIter->_value;
}
- if (!newVal)
+ if (!newVal) {
newVal = new ScValue(_gameRef);
- else newVal->cleanup();
+ } else {
+ newVal->cleanup();
+ }
newVal->copy(val, copyWhole);
newVal->_isConstVar = setAsConst;
_valObject[name] = newVal;
- if (_type != VAL_NATIVE) _type = VAL_OBJECT;
+ if (_type != VAL_NATIVE) {
+ _type = VAL_OBJECT;
+ }
/*
_valIter = _valObject.find(Name);
@@ -250,8 +265,9 @@ bool ScValue::setProp(const char *name, ScValue *val, bool copyWhole, bool setAs
//////////////////////////////////////////////////////////////////////////
bool ScValue::propExists(const char *name) {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->propExists(name);
+ }
_valIter = _valObject.find(name);
return (_valIter != _valObject.end());
@@ -273,15 +289,18 @@ void ScValue::deleteProps() {
void ScValue::CleanProps(bool includingNatives) {
_valIter = _valObject.begin();
while (_valIter != _valObject.end()) {
- if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) _valIter->_value->setNULL();
+ if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) {
+ _valIter->_value->setNULL();
+ }
_valIter++;
}
}
//////////////////////////////////////////////////////////////////////////
bool ScValue::isNULL() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->isNULL();
+ }
return (_type == VAL_NULL);
}
@@ -289,8 +308,9 @@ bool ScValue::isNULL() {
//////////////////////////////////////////////////////////////////////////
bool ScValue::isNative() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->isNative();
+ }
return (_type == VAL_NATIVE);
}
@@ -298,8 +318,9 @@ bool ScValue::isNative() {
//////////////////////////////////////////////////////////////////////////
bool ScValue::isString() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->isString();
+ }
return (_type == VAL_STRING);
}
@@ -307,8 +328,9 @@ bool ScValue::isString() {
//////////////////////////////////////////////////////////////////////////
bool ScValue::isFloat() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->isFloat();
+ }
return (_type == VAL_FLOAT);
}
@@ -316,8 +338,9 @@ bool ScValue::isFloat() {
//////////////////////////////////////////////////////////////////////////
bool ScValue::isInt() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->isInt();
+ }
return (_type == VAL_INT);
}
@@ -325,8 +348,9 @@ bool ScValue::isInt() {
//////////////////////////////////////////////////////////////////////////
bool ScValue::isBool() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->isBool();
+ }
return (_type == VAL_BOOL);
}
@@ -334,8 +358,9 @@ bool ScValue::isBool() {
//////////////////////////////////////////////////////////////////////////
bool ScValue::isObject() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->isObject();
+ }
return (_type == VAL_OBJECT);
}
@@ -343,8 +368,9 @@ bool ScValue::isObject() {
//////////////////////////////////////////////////////////////////////////
TValType ScValue::getTypeTolerant() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->getType();
+ }
return _type;
}
@@ -414,8 +440,11 @@ void ScValue::setString(const char *val) {
}
setStringVal(val);
- if (_valString) _type = VAL_STRING;
- else _type = VAL_NULL;
+ if (_valString) {
+ _type = VAL_STRING;
+ } else {
+ _type = VAL_NULL;
+ }
}
void ScValue::setString(const Common::String &val) {
@@ -450,7 +479,9 @@ void ScValue::setNULL() {
if (_valNative && !_persistent) {
_valNative->_refCount--;
- if (_valNative->_refCount <= 0) delete _valNative;
+ if (_valNative->_refCount <= 0) {
+ delete _valNative;
+ }
}
_valNative = NULL;
deleteProps();
@@ -472,7 +503,9 @@ void ScValue::setNative(BaseScriptable *val, bool persistent) {
if (_valNative && !_persistent) {
_valNative->_refCount--;
if (_valNative->_refCount <= 0) {
- if (_valNative != val) delete _valNative;
+ if (_valNative != val) {
+ delete _valNative;
+ }
_valNative = NULL;
}
}
@@ -481,7 +514,9 @@ void ScValue::setNative(BaseScriptable *val, bool persistent) {
_persistent = persistent;
_valNative = val;
- if (_valNative && !_persistent) _valNative->_refCount++;
+ if (_valNative && !_persistent) {
+ _valNative->_refCount++;
+ }
}
}
@@ -507,8 +542,9 @@ void ScValue::setReference(ScValue *val) {
//////////////////////////////////////////////////////////////////////////
bool ScValue::getBool(bool defaultVal) {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->getBool();
+ }
switch (_type) {
case VAL_BOOL:
@@ -534,7 +570,9 @@ bool ScValue::getBool(bool defaultVal) {
//////////////////////////////////////////////////////////////////////////
int ScValue::getInt(int defaultVal) {
- if (_type == VAL_VARIABLE_REF) return _valRef->getInt();
+ if (_type == VAL_VARIABLE_REF) {
+ return _valRef->getInt();
+ }
switch (_type) {
case VAL_BOOL:
@@ -560,8 +598,9 @@ int ScValue::getInt(int defaultVal) {
//////////////////////////////////////////////////////////////////////////
double ScValue::getFloat(double defaultVal) {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->getFloat();
+ }
switch (_type) {
case VAL_BOOL:
@@ -586,19 +625,23 @@ double ScValue::getFloat(double defaultVal) {
//////////////////////////////////////////////////////////////////////////
void *ScValue::getMemBuffer() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->getMemBuffer();
+ }
- if (_type == VAL_NATIVE)
+ if (_type == VAL_NATIVE) {
return _valNative->scToMemBuffer();
- else return (void *)NULL;
+ } else {
+ return (void *)NULL;
+ }
}
//////////////////////////////////////////////////////////////////////////
const char *ScValue::getString() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->getString();
+ }
switch (_type) {
case VAL_OBJECT:
@@ -647,11 +690,15 @@ const char *ScValue::getString() {
//////////////////////////////////////////////////////////////////////////
BaseScriptable *ScValue::getNative() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->getNative();
+ }
- if (_type == VAL_NATIVE) return _valNative;
- else return NULL;
+ if (_type == VAL_NATIVE) {
+ return _valNative;
+ } else {
+ return NULL;
+ }
}
@@ -668,12 +715,16 @@ void ScValue::copy(ScValue *orig, bool copyWhole) {
if (_valNative && !_persistent) {
_valNative->_refCount--;
if (_valNative->_refCount <= 0) {
- if (_valNative != orig->_valNative) delete _valNative;
+ if (_valNative != orig->_valNative) {
+ delete _valNative;
+ }
_valNative = NULL;
}
}
- if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && copyWhole) orig = orig->_valRef;
+ if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && copyWhole) {
+ orig = orig->_valRef;
+ }
cleanup(true);
@@ -687,7 +738,9 @@ void ScValue::copy(ScValue *orig, bool copyWhole) {
_persistent = orig->_persistent;
_valNative = orig->_valNative;
- if (_valNative && !_persistent) _valNative->_refCount++;
+ if (_valNative && !_persistent) {
+ _valNative->_refCount++;
+ }
//!!!! ref->native++
// copy properties
@@ -698,7 +751,9 @@ void ScValue::copy(ScValue *orig, bool copyWhole) {
_valObject[orig->_valIter->_key]->copy(orig->_valIter->_value);
orig->_valIter++;
}
- } else _valObject.clear();
+ } else {
+ _valObject.clear();
+ }
}
@@ -730,7 +785,9 @@ void ScValue::setValue(ScValue *val) {
}
}
// otherwise just copy everything
- else copy(val);
+ else {
+ copy(val);
+ }
}
@@ -841,39 +898,60 @@ int ScValue::compare(ScValue *val1, ScValue *val2) {
// same class?
if (strcmp(val1->getNative()->getClassName(), val2->getNative()->getClassName()) == 0) {
return val1->getNative()->scCompare(val2->getNative());
- } else return strcmp(val1->getString(), val2->getString());
+ } else {
+ return strcmp(val1->getString(), val2->getString());
+ }
}
// both objects?
- if (val1->isObject() && val2->isObject()) return -1;
+ if (val1->isObject() && val2->isObject()) {
+ return -1;
+ }
// null states
- if (val1->isNULL() && !val2->isNULL()) return -1;
- else if (!val1->isNULL() && val2->isNULL()) return 1;
- else if (val1->isNULL() && val2->isNULL()) return 0;
+ if (val1->isNULL() && !val2->isNULL()) {
+ return -1;
+ } else if (!val1->isNULL() && val2->isNULL()) {
+ return 1;
+ } else if (val1->isNULL() && val2->isNULL()) {
+ return 0;
+ }
// one of them is string? convert both to string
- if (val1->isString() || val2->isString()) return strcmp(val1->getString(), val2->getString());
+ if (val1->isString() || val2->isString()) {
+ return strcmp(val1->getString(), val2->getString());
+ }
// one of them is float?
if (val1->isFloat() || val2->isFloat()) {
- if (val1->getFloat() < val2->getFloat()) return -1;
- else if (val1->getFloat() > val2->getFloat()) return 1;
- else return 0;
+ if (val1->getFloat() < val2->getFloat()) {
+ return -1;
+ } else if (val1->getFloat() > val2->getFloat()) {
+ return 1;
+ } else {
+ return 0;
+ }
}
// otherwise compare as int's
- if (val1->getInt() < val2->getInt()) return -1;
- else if (val1->getInt() > val2->getInt()) return 1;
- else return 0;
+ if (val1->getInt() < val2->getInt()) {
+ return -1;
+ } else if (val1->getInt() > val2->getInt()) {
+ return 1;
+ } else {
+ return 0;
+ }
}
//////////////////////////////////////////////////////////////////////////
int ScValue::compareStrict(ScValue *val1, ScValue *val2) {
- if (val1->getTypeTolerant() != val2->getTypeTolerant()) return -1;
- else return ScValue::compare(val1, val2);
+ if (val1->getTypeTolerant() != val2->getTypeTolerant()) {
+ return -1;
+ } else {
+ return ScValue::compare(val1, val2);
+ }
}
@@ -1013,16 +1091,18 @@ bool ScValue::dbgSetVal() {
//////////////////////////////////////////////////////////////////////////
int ScValue::dbgGetNumProperties() {
- if (_valNative && _valNative->_scProp)
+ if (_valNative && _valNative->_scProp) {
return _valNative->_scProp->dbgGetNumProperties();
- else return _valObject.size();
+ } else {
+ return _valObject.size();
+ }
}
//////////////////////////////////////////////////////////////////////////
bool ScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value) {
- if (_valNative && _valNative->_scProp)
+ if (_valNative && _valNative->_scProp) {
return _valNative->_scProp->dbgGetProperty(index, name, value);
- else {
+ } else {
int count = 0;
_valIter = _valObject.begin();
while (_valIter != _valObject.end()) {
@@ -1040,8 +1120,9 @@ bool ScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value
//////////////////////////////////////////////////////////////////////////
bool ScValue::dbgGetDescription(char *buf, int bufSize) {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->dbgGetDescription(buf, bufSize);
+ }
if (_type == VAL_NATIVE) {
_valNative->scDebuggerDesc(buf, bufSize);
diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp
index 8cc8c21948..9cd9e4cc75 100644
--- a/engines/wintermute/base/sound/base_sound.cpp
+++ b/engines/wintermute/base/sound/base_sound.cpp
@@ -57,7 +57,9 @@ BaseSound::BaseSound(BaseGame *inGame): BaseClass(inGame) {
//////////////////////////////////////////////////////////////////////////
BaseSound::~BaseSound() {
- if (_sound) _gameRef->_soundMgr->removeSound(_sound);
+ if (_sound) {
+ _gameRef->_soundMgr->removeSound(_sound);
+ }
_sound = NULL;
delete[] _soundFilename;
@@ -83,7 +85,9 @@ bool BaseSound::setSound(const char *filename, Audio::Mixer::SoundType type, boo
_soundStreamed = streamed;
return STATUS_OK;
- } else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
}
@@ -91,22 +95,32 @@ bool BaseSound::setSound(const char *filename, Audio::Mixer::SoundType type, boo
bool BaseSound::setSoundSimple() {
_sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed);
if (_sound) {
- if (_soundPosition) _sound->setPosition(_soundPosition);
+ if (_soundPosition) {
+ _sound->setPosition(_soundPosition);
+ }
_sound->setLooping(_soundLooping);
_sound->setPrivateVolume(_soundPrivateVolume);
_sound->setLoopStart(_soundLoopStart);
_sound->_freezePaused = _soundFreezePaused;
- if (_soundPlaying) return _sound->resume();
- else return STATUS_OK;
- } else return STATUS_FAILED;
+ if (_soundPlaying) {
+ return _sound->resume();
+ } else {
+ return STATUS_OK;
+ }
+ } else {
+ return STATUS_FAILED;
+ }
}
//////////////////////////////////////////////////////////////////////////
uint32 BaseSound::getLength() {
- if (_sound) return _sound->getLength();
- else return 0;
+ if (_sound) {
+ return _sound->getLength();
+ } else {
+ return 0;
+ }
}
@@ -115,7 +129,9 @@ bool BaseSound::play(bool looping) {
if (_sound) {
_soundPaused = false;
return _sound->play(looping, _soundPosition);
- } else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
}
@@ -124,7 +140,9 @@ bool BaseSound::stop() {
if (_sound) {
_soundPaused = false;
return _sound->stop();
- } else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
}
@@ -132,9 +150,13 @@ bool BaseSound::stop() {
bool BaseSound::pause(bool freezePaused) {
if (_sound) {
_soundPaused = true;
- if (freezePaused) _sound->_freezePaused = true;
+ if (freezePaused) {
+ _sound->_freezePaused = true;
+ }
return _sound->pause();
- } else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
}
@@ -143,7 +165,9 @@ bool BaseSound::resume() {
if (_sound && _soundPaused) {
_soundPaused = false;
return _sound->resume();
- } else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
}
@@ -153,8 +177,9 @@ bool BaseSound::persist(BasePersistenceManager *persistMgr) {
_soundPlaying = _sound->isPlaying();
_soundLooping = _sound->_looping;
_soundPrivateVolume = _sound->_privateVolume;
- if (_soundPlaying)
+ if (_soundPlaying) {
_soundPosition = _sound->getPosition();
+ }
_soundLoopStart = _sound->_loopStart;
_soundFreezePaused = _sound->_freezePaused;
}
@@ -195,64 +220,81 @@ bool BaseSound::isPaused() {
//////////////////////////////////////////////////////////////////////////
bool BaseSound::setPositionTime(uint32 time) {
- if (!_sound) return STATUS_FAILED;
+ if (!_sound) {
+ return STATUS_FAILED;
+ }
_soundPosition = time;
bool ret = _sound->setPosition(_soundPosition);
- if (_sound->isPlaying())
+ if (_sound->isPlaying()) {
_soundPosition = 0;
+ }
return ret;
}
//////////////////////////////////////////////////////////////////////////
uint32 BaseSound::getPositionTime() {
- if (!_sound) return 0;
+ if (!_sound) {
+ return 0;
+ }
- if (!_sound->isPlaying())
+ if (!_sound->isPlaying()) {
return 0;
- else return _sound->getPosition();
+ } else {
+ return _sound->getPosition();
+ }
}
//////////////////////////////////////////////////////////////////////////
bool BaseSound::setVolumePercent(int percent) {
- if (!_sound)
+ if (!_sound) {
return STATUS_FAILED;
- else return _sound->setPrivateVolume(percent * 255 / 100);
+ } else {
+ return _sound->setPrivateVolume(percent * 255 / 100);
+ }
}
//////////////////////////////////////////////////////////////////////////
bool BaseSound::setVolume(int volume) {
- if (!_sound)
+ if (!_sound) {
return STATUS_FAILED;
- else return _sound->setPrivateVolume(volume);
+ } else {
+ return _sound->setPrivateVolume(volume);
+ }
}
//////////////////////////////////////////////////////////////////////////
bool BaseSound::setPrivateVolume(int volume) {
- if (!_sound)
+ if (!_sound) {
return STATUS_FAILED;
- else return _sound->_privateVolume = volume;
+ } else {
+ return _sound->_privateVolume = volume;
+ }
}
//////////////////////////////////////////////////////////////////////////
int BaseSound::getVolumePercent() {
- if (!_sound)
+ if (!_sound) {
return 0;
- else return _sound->_privateVolume * 100 / 255;
+ } else {
+ return _sound->_privateVolume * 100 / 255;
+ }
}
//////////////////////////////////////////////////////////////////////////
int BaseSound::getVolume() {
- if (!_sound)
+ if (!_sound) {
return 0;
- else return _sound->_privateVolume;
+ } else {
+ return _sound->_privateVolume;
+ }
}
//////////////////////////////////////////////////////////////////////////
bool BaseSound::setLoopStart(uint32 pos) {
- if (!_sound)
+ if (!_sound) {
return STATUS_FAILED;
- else {
+ } else {
_sound->setLoopStart(pos);
return STATUS_OK;
}
@@ -260,16 +302,19 @@ bool BaseSound::setLoopStart(uint32 pos) {
//////////////////////////////////////////////////////////////////////////
bool BaseSound::setPan(float pan) {
- if (_sound)
+ if (_sound) {
return _sound->setPan(pan);
- else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
}
//////////////////////////////////////////////////////////////////////////
bool BaseSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) {
- if (!_sound)
+ if (!_sound) {
return STATUS_OK;
+ }
if (type != _sFXType || param1 != _sFXParam1 || param2 != _sFXParam2 || param3 != _sFXParam3 || param4 != _sFXParam4) {
bool ret = _sound->applyFX(type, param1, param2, param3, param4);
diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp
index cebc3a3765..74aae59e3d 100644
--- a/engines/wintermute/base/sound/base_sound_manager.cpp
+++ b/engines/wintermute/base/sound/base_sound_manager.cpp
@@ -61,8 +61,9 @@ BaseSoundMgr::~BaseSoundMgr() {
//////////////////////////////////////////////////////////////////////////
bool BaseSoundMgr::cleanup() {
- for (uint32 i = 0; i < _sounds.size(); i++)
+ for (uint32 i = 0; i < _sounds.size(); i++) {
delete _sounds[i];
+ }
_sounds.clear();
#if 0
BASS_Free();
@@ -93,8 +94,9 @@ bool BaseSoundMgr::initialize() {
//////////////////////////////////////////////////////////////////////////
bool BaseSoundMgr::initLoop() {
- if (!_soundAvailable)
+ if (!_soundAvailable) {
return STATUS_OK;
+ }
#if 0
BASS_Update(500);
@@ -105,8 +107,9 @@ bool BaseSoundMgr::initLoop() {
//////////////////////////////////////////////////////////////////////////
BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) {
- if (!_soundAvailable)
+ if (!_soundAvailable) {
return NULL;
+ }
BaseSoundBuffer *sound;
@@ -123,7 +126,9 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::Soun
}
sound = new BaseSoundBuffer(_gameRef);
- if (!sound) return NULL;
+ if (!sound) {
+ return NULL;
+ }
sound->setStreaming(streamed);
sound->setType(type);
@@ -149,8 +154,9 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::Soun
//////////////////////////////////////////////////////////////////////////
bool BaseSoundMgr::addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type) {
- if (!sound)
+ if (!sound) {
return STATUS_FAILED;
+ }
// Make sure the master-volume is applied to the sound.
sound->updateVolume();
@@ -177,8 +183,9 @@ bool BaseSoundMgr::removeSound(BaseSoundBuffer *sound) {
//////////////////////////////////////////////////////////////////////////
bool BaseSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) {
- if (!_soundAvailable)
+ if (!_soundAvailable) {
return STATUS_OK;
+ }
switch (type) {
case Audio::Mixer::kSFXSoundType: