diff options
Diffstat (limited to 'engines/sword2')
-rw-r--r-- | engines/sword2/controls.cpp | 6 | ||||
-rw-r--r-- | engines/sword2/music.cpp | 13 | ||||
-rw-r--r-- | engines/sword2/protocol.cpp | 4 | ||||
-rw-r--r-- | engines/sword2/render.cpp | 4 | ||||
-rw-r--r-- | engines/sword2/resman.cpp | 4 |
5 files changed, 19 insertions, 12 deletions
diff --git a/engines/sword2/controls.cpp b/engines/sword2/controls.cpp index 7428cbb534..c55cc72493 100644 --- a/engines/sword2/controls.cpp +++ b/engines/sword2/controls.cpp @@ -180,12 +180,12 @@ void FontRendererGui::fetchText(uint32 textId, byte *buf) { byte *data = _vm->fetchTextLine(_vm->_resman->openResource(textId / SIZE), textId & 0xffff); int i; - for (i = 0; data[i + 2]; i++) { - if (buf) + if (buf) { + for (i = 0; data[i + 2]; i++) buf[i] = data[i + 2]; + buf[i] = 0; } - buf[i] = 0; _vm->_resman->closeResource(textId / SIZE); } diff --git a/engines/sword2/music.cpp b/engines/sword2/music.cpp index c052aa6b46..89073fef8e 100644 --- a/engines/sword2/music.cpp +++ b/engines/sword2/music.cpp @@ -496,9 +496,16 @@ int Sound::readBuffer(int16 *buffer, const int numSamples) { memset(buffer, 0, 2 * numSamples); if (!_mixBuffer || numSamples > _mixBufferLen) { - if (_mixBuffer) - _mixBuffer = (int16 *)realloc(_mixBuffer, 2 * numSamples); - else + if (_mixBuffer) { + int16 *newBuffer = (int16 *)realloc(_mixBuffer, 2 * numSamples); + if (newBuffer) { + _mixBuffer = newBuffer; + } else { + // We can't use the old buffer any more. It's too small. + free(_mixBuffer); + _mixBuffer = 0; + } + } else _mixBuffer = (int16 *)malloc(2 * numSamples); _mixBufferLen = numSamples; diff --git a/engines/sword2/protocol.cpp b/engines/sword2/protocol.cpp index 03b021f04c..6c47c07401 100644 --- a/engines/sword2/protocol.cpp +++ b/engines/sword2/protocol.cpp @@ -412,8 +412,8 @@ byte *Sword2Engine::fetchPsxParallax(uint32 location, uint8 level) { debug(2, "fetchPsxParallax() -> %s parallax, xRes: %u, yRes: %u", (level == 0) ? "Background" : "Foreground", plxXres, plxYres); // Calculate the number of tiles which compose the parallax grid. - horTiles = plxXres % 64 ? (plxXres / 64) + 1 : plxXres / 64; - verTiles = plxYres % 16 ? (plxYres / 16) + 1 : plxYres / 16; + horTiles = (plxXres % 64) ? (plxXres / 64) + 1 : plxXres / 64; + verTiles = (plxYres % 16) ? (plxYres / 16) + 1 : plxYres / 16; totSize = plxSize + horTiles * verTiles * 4 + 8; diff --git a/engines/sword2/render.cpp b/engines/sword2/render.cpp index 1a8dcdab16..99295be571 100644 --- a/engines/sword2/render.cpp +++ b/engines/sword2/render.cpp @@ -731,8 +731,8 @@ int32 Screen::initialisePsxParallaxLayer(byte *parallax) { data = parallax + xTiles * yTiles * 4; _xBlocks[_layer] = xTiles; - _yBlocks[_layer] = (yTiles / 2) + (yTiles % 2 ? 1 : 0); - bool oddTiles = (yTiles % 2 ? true : false); + _yBlocks[_layer] = (yTiles / 2) + ((yTiles % 2) ? 1 : 0); + bool oddTiles = ((yTiles % 2) ? true : false); _blockSurfaces[_layer] = (BlockSurface **)calloc(_xBlocks[_layer] * _yBlocks[_layer], sizeof(BlockSurface *)); if (!_blockSurfaces[_layer]) diff --git a/engines/sword2/resman.cpp b/engines/sword2/resman.cpp index 81d74f355b..1b2411a404 100644 --- a/engines/sword2/resman.cpp +++ b/engines/sword2/resman.cpp @@ -474,7 +474,7 @@ void ResourceManager::readCluIndex(uint16 fileNum, Common::File *file) { file->seek(table_offset); assert((tableSize % 8) == 0); - _resFiles[fileNum].entryTab = (uint32*)malloc(tableSize); + _resFiles[fileNum].entryTab = (uint32 *)malloc(tableSize); _resFiles[fileNum].numEntries = tableSize / 8; file->read(_resFiles[fileNum].entryTab, tableSize); if (file->eos() || file->err()) @@ -482,7 +482,7 @@ void ResourceManager::readCluIndex(uint16 fileNum, Common::File *file) { #ifdef SCUMM_BIG_ENDIAN for (int tabCnt = 0; tabCnt < _resFiles[fileNum].numEntries * 2; tabCnt++) - _resFiles[fileNum].entryTab[tabCnt] = FROM_LE_32(_resFiles[fileNum].entryTab[tabCnt]); + _resFiles[fileNum].entryTab[tabCnt] = FROM_LE_32(_resFiles[fileNum].entryTab[tabCnt]); #endif } |