From e5cf0332f2d08c7f6bc45c1f1fd8edaf276ea76d Mon Sep 17 00:00:00 2001 From: Borja Lorente Date: Tue, 16 Aug 2016 12:45:08 +0200 Subject: MACVENTURE: Break up one-line ifs and fix braces --- engines/macventure/container.cpp | 33 +++++++------ engines/macventure/datafiles.cpp | 3 +- engines/macventure/dialog.cpp | 4 +- engines/macventure/gui.cpp | 97 +++++++++++++++++++++++++++++---------- engines/macventure/gui.h | 8 +++- engines/macventure/image.cpp | 60 ++++++++++++++++-------- engines/macventure/macventure.cpp | 49 ++++++++++++++------ engines/macventure/script.cpp | 65 ++++++++++++++++++-------- engines/macventure/sound.cpp | 47 +++++++++++++------ engines/macventure/text.cpp | 4 +- engines/macventure/world.cpp | 42 ++++++++++++----- 11 files changed, 293 insertions(+), 119 deletions(-) diff --git a/engines/macventure/container.cpp b/engines/macventure/container.cpp index 1781f96a07..ff98d6961f 100644 --- a/engines/macventure/container.cpp +++ b/engines/macventure/container.cpp @@ -27,18 +27,21 @@ namespace MacVenture { Container::Container(Common::String filename) { _filename = filename; - if (!_file.open(_filename)) + if (!_file.open(_filename)) { error("CONTAINER: Could not open %s", _filename.c_str()); + } _res = _file.readStream(_file.size()); _header = _res->readUint32BE(); _simplified = false; - for (uint i = 0; i < 16; ++i) + for (uint i = 0; i < 16; ++i) { _huff.push_back(0); + } - for (uint i = 0; i < 16; ++i) + for (uint i = 0; i < 16; ++i) { _lens.push_back(0); + } if (!(_header & 0x80000000)) { // Is simplified container @@ -51,16 +54,19 @@ Container::Container(Common::String filename) { _res->seek(_header, SEEK_SET); _numObjs = _res->readUint16BE(); - for (uint i = 0; i < 15; ++i) + for (uint i = 0; i < 15; ++i) { _huff[i] = _res->readUint16BE(); + } - for (uint i = 0; i < 16; ++i) + for (uint i = 0; i < 16; ++i) { _lens[i] = _res->readByte(); + } // Read groups uint numGroups = _numObjs / 64; - if ((_numObjs % 64) > 0) + if ((_numObjs % 64) > 0) { numGroups++; + } for (uint i = 0; i < numGroups; ++i) { ItemGroup group; @@ -94,7 +100,9 @@ Container::Container(Common::String filename) { // Look in the Huffman table int x = 0; for (x = 0; x < 16; x++) { - if (_huff[x] > mask) break; + if (_huff[x] > mask) { + break; + } } // I will opt to copy the code from webventure, @@ -116,8 +124,11 @@ Container::Container(Common::String filename) { length = _res->readUint32BE(); _res->seek(-4, SEEK_CUR); bitSize--; - if (bitSize == 0) length = 0; - else length >>= (32 - bitSize) - bits; + if (bitSize == 0) { + length = 0; + } else { + length >>= (32 - bitSize) - bits; + } length &= (1 << bitSize) - 1; length |= 1 << bitSize; bits += bitSize; @@ -126,11 +137,9 @@ Container::Container(Common::String filename) { _res->seek(2, SEEK_CUR); } } - group.lengths[j] = length; debugC(4, kMVDebugContainer, "Load legth of object %d:%d is %d", i, j, length); } - _groups.push_back(group); } } @@ -166,9 +175,7 @@ Common::SeekableReadStream *Container::getItem(uint32 id) { for (uint i = 0; i < objectIndex; i++) { offset += _groups[groupID].lengths[i]; } - _res->seek(_groups[groupID].offset + offset + sizeof(_header), SEEK_SET); - } // HACK Should Limit the size of the stream returned diff --git a/engines/macventure/datafiles.cpp b/engines/macventure/datafiles.cpp index 9532434f03..aa47869bcd 100644 --- a/engines/macventure/datafiles.cpp +++ b/engines/macventure/datafiles.cpp @@ -66,8 +66,9 @@ Common::String windowTypeName(MVWindowType windowType) { void MacVentureEngine::loadDataBundle() { _dataBundle = Common::makeZipArchive(MACVENTURE_DATA_BUNDLE); - if (!_dataBundle) + if (!_dataBundle) { error("ENGINE: Couldn't load data bundle '%s'.", MACVENTURE_DATA_BUNDLE.c_str()); + } } Common::SeekableReadStream *MacVentureEngine::getBorderFile(MVWindowType windowType, bool isActive) { diff --git a/engines/macventure/dialog.cpp b/engines/macventure/dialog.cpp index 27ef224712..7c375d425c 100644 --- a/engines/macventure/dialog.cpp +++ b/engines/macventure/dialog.cpp @@ -80,7 +80,9 @@ const Graphics::Font& Dialog::getFont() { bool Dialog::processEvent(Common::Event event) { for (Common::Array::iterator it = _elements.begin(); it != _elements.end(); it++) { - if ((*it)->processEvent(this, event)) return true; + if ((*it)->processEvent(this, event)) { + return true; + } } return false; } diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp index ac429d03d9..f4cb8eeb6f 100644 --- a/engines/macventure/gui.cpp +++ b/engines/macventure/gui.cpp @@ -267,7 +267,9 @@ void Gui::setWindowTitle(WindowReference winID, Common::String string) { } void Gui::updateWindowInfo(WindowReference ref, ObjID objID, const Common::Array &children) { - if (ref == kNoWindow) return; + if (ref == kNoWindow) { + return; + } WindowData &data = findWindowData(ref); data.children.clear(); data.objRef = objID; @@ -284,9 +286,15 @@ void Gui::updateWindowInfo(WindowReference ref, ObjID objID, const Common::Array data.children.push_back(DrawableObject(child, kBlitBIC)); } } - if (originx != 0x7fff) data.bounds.left = originx; - if (originy != 0x7fff) data.bounds.top = originy; - if (ref != kMainGameWindow) data.updateScroll = true; + if (originx != 0x7fff) { + data.bounds.left = originx; + } + if (originy != 0x7fff) { + data.bounds.top = originy; + } + if (ref != kMainGameWindow) { + data.updateScroll = true; + } } void Gui::addChild(WindowReference target, ObjID child) { @@ -297,7 +305,9 @@ void Gui::removeChild(WindowReference target, ObjID child) { WindowData &data = findWindowData(target); uint index = 0; for (;index < data.children.size(); index++) { - if (data.children[index].obj == child) break; + if (data.children[index].obj == child) { + break; + } } if (index < data.children.size()) @@ -602,7 +612,9 @@ void Gui::drawMainGameWindow() { void Gui::drawSelfWindow() { drawObjectsInWindow(getWindowData(kSelfWindow), _selfWindow->getSurface()); - if (_engine->isObjSelected(1)) invertWindowColors(kSelfWindow); + if (_engine->isObjSelected(1)) { + invertWindowColors(kSelfWindow); + } findWindow(kSelfWindow)->setDirty(true); } @@ -667,7 +679,9 @@ void Gui::drawObjectsInWindow(const WindowData &targetData, Graphics::ManagedSur ObjID child; BlitMode mode; - if (targetData.children.size() == 0) return; + if (targetData.children.size() == 0) { + return; + } Graphics::ManagedSurface composeSurface; createInnerSurface(&composeSurface, surface, border); @@ -736,12 +750,20 @@ void Gui::drawDraggedObject() { uint h = asset->getHeight() + MIN((int16)0, _draggedObj.pos.y); // In case of overflow from the bottom/left - if (_draggedObj.pos.x > 0 && _draggedObj.pos.x + w > kScreenWidth) { w = kScreenWidth - _draggedObj.pos.x; } - if (_draggedObj.pos.y > 0 && _draggedObj.pos.y + h > kScreenHeight) { h = kScreenHeight - _draggedObj.pos.y; } + if (_draggedObj.pos.x > 0 && _draggedObj.pos.x + w > kScreenWidth) { + w = kScreenWidth - _draggedObj.pos.x; + } + if (_draggedObj.pos.y > 0 && _draggedObj.pos.y + h > kScreenHeight) { + h = kScreenHeight - _draggedObj.pos.y; + } Common::Point target = _draggedObj.pos; - if (target.x < 0) { target.x = 0; } - if (target.y < 0) { target.y = 0; } + if (target.x < 0) { + target.x = 0; + } + if (target.y < 0) { + target.y = 0; + } _draggedSurface.create(w, h, _screen.format); _draggedSurface.blitFrom( @@ -766,11 +788,15 @@ void Gui::drawDraggedObject() { } void Gui::drawDialog() { - if (_dialog) _dialog->draw(); + if (_dialog) { + _dialog->draw(); + } } void Gui::updateWindow(WindowReference winID, bool containerOpen) { - if (winID == kNoWindow) return; + if (winID == kNoWindow) { + return; + } if (winID == kSelfWindow || containerOpen) { WindowData &data = findWindowData(winID); if (winID == kCommandsWindow) { @@ -822,8 +848,9 @@ void Gui::unselectExits() { } void Gui::updateExit(ObjID obj) { - if (!_engine->isObjExit(obj)) return; - + if (!_engine->isObjExit(obj)) { + return; + } BorderBounds border = borderBounds(getWindowData(kExitsWindow).type); int ctl = -1; @@ -943,7 +970,9 @@ Common::Point Gui::getGlobalScrolledSurfacePosition(WindowReference reference) { const WindowData &data = getWindowData(reference); BorderBounds border = borderBounds(data.type); Graphics::MacWindow *win = findWindow(reference); - if (!win) return Common::Point(0, 0); + if (!win) { + return Common::Point(0, 0); + } return Common::Point( win->getDimensions().left + border.leftOffset - data.scrollPos.x, win->getDimensions().top + border.topOffset - data.scrollPos.y); @@ -1010,12 +1039,16 @@ WindowReference Gui::findObjWindow(ObjID objID) { // This is a bit of a HACK, we take advantage of the consecutive nature of references for (uint i = kCommandsWindow; i <= kDiplomaWindow; i++) { const WindowData &data = getWindowData((WindowReference)i); - if (data.objRef == objID) { return data.refcon; } + if (data.objRef == objID) { + return data.refcon; + } } for (uint i = kInventoryStart; i < _inventoryWindows.size() + kInventoryStart; i++) { const WindowData &data = getWindowData((WindowReference)i); - if (data.objRef == objID) { return data.refcon; } + if (data.objRef == objID) { + return data.refcon; + } } return kNoWindow; @@ -1068,7 +1101,9 @@ void Gui::selectDraggable(ObjID child, WindowReference origin, Common::Point cli void Gui::handleDragRelease(bool shiftPressed, bool isDoubleClick) { if (_draggedObj.id != 0) { WindowReference destinationWindow = findWindowAtPoint(_draggedObj.pos); - if (destinationWindow == kNoWindow) return; + if (destinationWindow == kNoWindow) { + return; + } if (_draggedObj.hasMoved) { const WindowData &destinationWindowData = getWindowData(destinationWindow); ObjID destObject = destinationWindowData.objRef; @@ -1246,7 +1281,9 @@ bool Gui::processEvent(Common::Event &event) { processed |= _cursor->processEvent(event); - if (_dialog && _dialog->processEvent(event)) return true; + if (_dialog && _dialog->processEvent(event)) { + return true; + } if (event.type == Common::EVENT_MOUSEMOVE) { if (_draggedObj.id != 0) { @@ -1370,7 +1407,9 @@ bool MacVenture::Gui::processDiplomaEvents(WindowClick click, Common::Event & ev bool Gui::processInventoryEvents(WindowClick click, Common::Event & event) { if (event.type == Common::EVENT_LBUTTONDOWN && click == kBorderCloseButton) { WindowReference ref = findWindowAtPoint(event.mouse); - if (ref == kNoWindow) return false; + if (ref == kNoWindow) { + return false; + } if (click == kBorderCloseButton) { removeInventoryWindow(ref); @@ -1384,7 +1423,9 @@ bool Gui::processInventoryEvents(WindowClick click, Common::Event & event) { if (event.type == Common::EVENT_LBUTTONDOWN) { // Find the appropriate window WindowReference ref = findWindowAtPoint(event.mouse); - if (ref == kNoWindow) return false; + if (ref == kNoWindow) { + return false; + } WindowData &data = findWindowData((WindowReference) ref); @@ -1406,7 +1447,9 @@ bool Gui::processInventoryEvents(WindowClick click, Common::Event & event) { void Gui::selectForDrag(Common::Point cursorPosition) { WindowReference ref = findWindowAtPoint(cursorPosition); - if (ref == kNoWindow) return; + if (ref == kNoWindow) { + return; + } Graphics::MacWindow *win = findWindow(ref); WindowData &data = findWindowData((WindowReference) ref); @@ -1418,13 +1461,17 @@ void Gui::selectForDrag(Common::Point cursorPosition) { void Gui::handleSingleClick() { debugC(2, kMVDebugGUI, "Registered Single Click"); // HACK THERE HAS TO BE A MORE ELEGANT WAY - if (_dialog) return; + if (_dialog) { + return; + } handleDragRelease(false, false); } void Gui::handleDoubleClick() { debugC(2, kMVDebugGUI, "Registered Double Click"); - if (_dialog) return; + if (_dialog) { + return; + } handleDragRelease(false, true); } diff --git a/engines/macventure/gui.h b/engines/macventure/gui.h index 28ee85ddae..4ad1709e25 100644 --- a/engines/macventure/gui.h +++ b/engines/macventure/gui.h @@ -344,11 +344,15 @@ public: } void scrollDown() { - if (_scrollPos < (int)(_lines.size() - 1)) _scrollPos++; + if (_scrollPos < (int)(_lines.size() - 1)) { + _scrollPos++; + } } void scrollUp() { - if (_scrollPos > 0) _scrollPos--; + if (_scrollPos > 0) { + _scrollPos--; + } } diff --git a/engines/macventure/image.cpp b/engines/macventure/image.cpp index f4d46b039f..c1bfd75158 100644 --- a/engines/macventure/image.cpp +++ b/engines/macventure/image.cpp @@ -109,11 +109,17 @@ void ImageAsset::decodePPIC(ObjID id, Common::Array &data, uint &bitHeight uint8 mode = stream.getBits(3); int w, h; - if (stream.getBit()) h = stream.getBits(10); - else h = stream.getBits(6); + if (stream.getBit()) { + h = stream.getBits(10); + } else { + h = stream.getBits(6); + } - if (stream.getBit()) w = stream.getBits(10); - else w = stream.getBits(6); + if (stream.getBit()) { + w = stream.getBits(10); + } else { + w = stream.getBits(6); + } rowBytes = ((w + 0xF) >> 3) & 0xFFFE; bitWidth = w; @@ -284,8 +290,7 @@ void ImageAsset::decodeHuffGraphic(const PPICHuff & huff, Common::BitStream & st v = data[pos]; pos++; } - } - else { + } else { for (uint x = 0; x < rowBytes; x++) { uint16 val = data[pos] ^ v; val ^= (val >> 4) & 0xf; @@ -298,7 +303,9 @@ void ImageAsset::decodeHuffGraphic(const PPICHuff & huff, Common::BitStream & st } if (flags & 4) { uint16 delta = rowBytes * 4; - if (flags & 2) delta *= 2; + if (flags & 2) { + delta *= 2; + } pos = 0; uint q = delta; for (uint i = 0; i < bitHeight * rowBytes - delta; i++) { @@ -318,8 +325,9 @@ byte ImageAsset::walkHuff(const PPICHuff & huff, Common::BitStream & stream) { uint16 dw = stream.peekBits(16); uint16 i = 0; for (;i < 16; i++) { - if (huff.masks[i + 1] > dw) + if (huff.masks[i + 1] > dw) { break; + } } stream.skip(huff.lens[i]); uint8 val = huff.symbols[i]; @@ -351,7 +359,7 @@ byte ImageAsset::walkHuff(const PPICHuff & huff, Common::BitStream & stream) { void ImageAsset::blitInto(Graphics::ManagedSurface *target, int x, int y, BlitMode mode) { if (mode == kBlitDirect) { blitDirect(target, x, y, _imgData, _imgBitHeight, _imgBitWidth, _imgRowBytes); - } else if (mode < kBlitXOR){ + } else if (mode < kBlitXOR) { if (_container->getItemByteSize(_mask)) { // Has mask switch (mode) { case MacVenture::kBlitBIC: @@ -383,35 +391,46 @@ void ImageAsset::blitInto(Graphics::ManagedSurface *target, int x, int y, BlitMo } bool ImageAsset::isPointInside(Common::Point point) { - if (point.x >= _maskBitWidth || point.y >= _maskBitHeight) return false; - if (_maskData.empty()) return false; + if (point.x >= _maskBitWidth || point.y >= _maskBitHeight) { + return false; + } + if (_maskData.empty()) { + return false; + } // We see if the point lands on the mask. uint pix = _maskData[(point.y * _maskRowBytes) + (point.x >> 3)] & (1 << (7 - (point.x & 7))); return pix != 0; } bool ImageAsset::isRectInside(Common::Rect rect) { - // HACK is it &&, or ||? - if (_maskData.empty()) return (rect.width() > 0 && rect.height() > 0); + if (_maskData.empty()) { + return (rect.width() > 0 && rect.height() > 0); + } for (int y = rect.top; y < rect.top + rect.height(); y++) { uint bmpofs = y * _maskRowBytes; byte pix; for (int x = rect.left; x < rect.left + rect.width(); x++) { pix = _maskData[bmpofs + (x >> 3)] & (1 << (7 - (x & 7))); - if (pix) return true; + if (pix) { + return true; + } } } return false; } int ImageAsset::getWidth() { - if (_imgData.size() == 0) return 0; + if (_imgData.size() == 0) { + return 0; + } return MAX(0, (int)_imgBitWidth); } int ImageAsset::getHeight() { - if (_imgData.size() == 0) return 0; + if (_imgData.size() == 0) { + return 0; + } return MAX(0, (int)_imgBitHeight); } @@ -443,7 +462,9 @@ void ImageAsset::blitBIC(Graphics::ManagedSurface * target, int ox, int oy, cons assert(ox + x <= target->w); assert(oy + y <= target->h); pix = data[bmpofs + ((x + sx) >> 3)] & (1 << (7 - ((x + sx) & 7))); - if (pix) *((byte *)target->getBasePtr(ox + x, oy + y)) = kColorWhite; + if (pix) { + *((byte *)target->getBasePtr(ox + x, oy + y)) = kColorWhite; + } } } } @@ -459,7 +480,9 @@ void ImageAsset::blitOR(Graphics::ManagedSurface * target, int ox, int oy, const assert(ox + x <= target->w); assert(oy + y <= target->h); pix = data[bmpofs + ((x + sx) >> 3)] & (1 << (7 - ((x + sx) & 7))); - if (pix) *((byte *)target->getBasePtr(ox + x, oy + y)) = kColorBlack; + if (pix) { + *((byte *)target->getBasePtr(ox + x, oy + y)) = kColorBlack; + } } } } @@ -505,7 +528,6 @@ void ImageAsset::calculateSectionInDirection(uint targetWhole, uint originWhole, } else { blittedWhole = (blittedWhole) - ((blittedWhole + originPosition) - targetWhole); } - } if (originPosition < 0) { if (ABS(originPosition) > (int)blittedWhole) { diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp index 2c91680926..7f754c470d 100644 --- a/engines/macventure/macventure.cpp +++ b/engines/macventure/macventure.cpp @@ -39,8 +39,12 @@ void toASCII(Common::String &str) { debugC(3, kMVDebugMain, "toASCII: %s", str.c_str()); Common::String::iterator it = str.begin(); for (; it != str.end(); it++) { - if (*it == '\216') { str.replace(it, it + 1, "e"); } - if (*it == '\210') { str.replace(it, it + 1, "a"); } + if (*it == '\216') { + str.replace(it, it + 1, "e"); + } + if (*it == '\210') { + str.replace(it, it + 1, "a"); + } } } @@ -687,7 +691,7 @@ void MacVentureEngine::selectObject(ObjID objID) { void MacVentureEngine::unselectObject(ObjID objID) { int idxCur = findObjectInArray(objID, _currentSelection); - if (idxCur != -1){ + if (idxCur != -1) { _currentSelection.remove_at(idxCur); highlightExit(objID); } @@ -709,8 +713,11 @@ int MacVentureEngine::findObjectInArray(ObjID objID, const Common::Array bool found = false; uint i = 0; while (i < list.size() && !found) { - if (list[i] == objID) found = true; - else i++; + if (list[i] == objID) { + found = true; + } else { + i++; + } } // HACK, should use iterator return found ? i : -1; @@ -752,7 +759,9 @@ void MacVentureEngine::highlightExit(ObjID objID) { } void MacVentureEngine::selectPrimaryObject(ObjID objID) { - if (objID == _destObject) return; + if (objID == _destObject) { + return; + } int idx; debugC(4, kMVDebugMain, "Select primary object (%d)", objID); if (_destObject > 0 && @@ -782,7 +791,9 @@ void MacVentureEngine::openObject(ObjID objID) { _world->getObjAttr(objID, kAttrPosX), _world->getObjAttr(objID, kAttrPosY)); - if (getObjWindow(objID)) return; + if (getObjWindow(objID)) { + return; + } if (objID == _world->getObjAttr(1, kAttrParentObject)) { _gui->updateWindowInfo(kMainGameWindow, objID, _world->getChildren(objID, true)); _gui->updateWindow(kMainGameWindow, _world->getObjAttr(objID, kAttrContainerOpen)); @@ -850,14 +861,20 @@ void MacVentureEngine::checkObject(QueuedObject old) { ObjID cur = id; ObjID root = _world->getObjAttr(1, kAttrParentObject); while (cur != root) { - if (cur == 0 || !_world->getObjAttr(cur, kAttrContainerOpen)) break; + if (cur == 0 || !_world->getObjAttr(cur, kAttrContainerOpen)) { + break; + } cur = _world->getObjAttr(cur, kAttrParentObject); } if (cur == root) { - if (win) return; + if (win) { + return; + } enqueueObject(kOpenWindow, id); //open } else { - if (!win) return; + if (!win) { + return; + } enqueueObject(kCloseWindow, id); //close } @@ -904,7 +921,9 @@ void MacVentureEngine::zoomObject(ObjID objID) { bool MacVentureEngine::isObjEnqueued(ObjID objID) { Common::Array::const_iterator it; for (it = _objQueue.begin(); it != _objQueue.end(); it++) { - if ((*it).object == objID) return true; + if ((*it).object == objID) { + return true; + } } return false; } @@ -1049,9 +1068,13 @@ WindowReference MacVentureEngine::getObjWindow(ObjID objID) { } WindowReference MacVentureEngine::findParentWindow(ObjID objID) { - if (objID == 1) return kSelfWindow; + if (objID == 1) { + return kSelfWindow; + } ObjID parent = _world->getObjAttr(objID, kAttrParentObject); - if (parent == 0) return kNoWindow; + if (parent == 0) { + return kNoWindow; + } return getObjWindow(parent); } diff --git a/engines/macventure/script.cpp b/engines/macventure/script.cpp index c88ac0bf3e..f7e49c68e3 100644 --- a/engines/macventure/script.cpp +++ b/engines/macventure/script.cpp @@ -61,7 +61,9 @@ bool ScriptEngine::resume(bool execAll) { debugC(3, kMVDebugScript, "Resume Script"); while (_frames.size()) { bool fail = execFrame(execAll); - if (fail) return true; + if (fail) { + return true; + } } return false; } @@ -80,8 +82,11 @@ bool ScriptEngine::execFrame(bool execAll) { // Do first dispatch script (script 0) if (frame->haltedInFirst || doFirst) { // We were stuck or it's the first time frame->haltedInFirst = false; - if (doFirst) { fail = loadScript(frame, 0); } - else { fail = resumeFunc(frame); } + if (doFirst) { + fail = loadScript(frame, 0); + } else { + fail = resumeFunc(frame); + } if (fail) { frame->haltedInFirst = true; _engine->preparedToRun(); @@ -97,7 +102,9 @@ bool ScriptEngine::execFrame(bool execAll) { Common::Array family = _world->getFamily(_world->getObjAttr(1, kAttrParentObject), false); uint32 i = frame->familyIdx; for (; i < family.size(); i++) { - if (doFamily) { fail = loadScript(frame, family[i]); } + if (doFamily) { + fail = loadScript(frame, family[i]); + } else { fail = resumeFunc(frame); } if (fail) { // We are stuck, so we don't shift the frame frame->haltedInFamily = true; @@ -123,8 +130,7 @@ bool ScriptEngine::execFrame(bool execAll) { uint localHigh = 0; do { // Saved function calls highest = 0; - for (uint i = 0; i saves.size(); i++) - { + for (uint i = 0; i saves.size(); i++) { if (highest < frame->saves[i].rank) { highest = frame->saves[i].rank; localHigh = i; @@ -156,7 +162,9 @@ bool ScriptEngine::loadScript(EngineFrame * frame, uint32 scriptID) { bool ScriptEngine::resumeFunc(EngineFrame * frame) { bool fail = runFunc(frame); - if (fail) return fail; + if (fail) { + return fail; + } frame->scripts.pop_front(); if (frame->scripts.size()) return resumeFunc(frame); @@ -645,12 +653,16 @@ void ScriptEngine::op95SORT(EngineState * state, EngineFrame * frame) { word step = neg16(state->pop()); word num = neg16(state->pop()); step %= num; - if (step<0) step += num; + if (step < 0) { + step += num; + } word end = 0; word start = 0; for (word i = 1;i= num) start -= num; + if (start >= num) { + start -= num; + } if (start == end) { end++; start = end; @@ -710,7 +722,9 @@ void ScriptEngine::op9dDMOD(EngineState * state, EngineFrame * frame) { void ScriptEngine::op9eABS(EngineState * state, EngineFrame * frame) { word val = neg16(state->pop()); - if (val<0) val = -val; + if (val < 0) { + val = -val; + } state->push(val); } @@ -837,14 +851,18 @@ void ScriptEngine::opb2BEQ(EngineState * state, EngineFrame * frame, ScriptAsset val = val | script->fetch(); val = neg16(val); word b = state->pop(); - if (b != 0) script->branch(val); + if (b != 0) { + script->branch(val); + } } void ScriptEngine::opb3BEQB(EngineState * state, EngineFrame * frame, ScriptAsset *script) { word val = script->fetch(); val = neg8(val); word b = state->pop(); - if (b != 0) script->branch(val); + if (b != 0) { + script->branch(val); + } } void ScriptEngine::opb4BNE(EngineState * state, EngineFrame * frame, ScriptAsset *script) { @@ -853,14 +871,18 @@ void ScriptEngine::opb4BNE(EngineState * state, EngineFrame * frame, ScriptAsset val = val | script->fetch(); val = neg16(val); word b = state->pop(); - if (b == 0) script->branch(val); + if (b == 0) { + script->branch(val); + } } void ScriptEngine::opb5BNEB(EngineState * state, EngineFrame * frame, ScriptAsset *script) { word val = script->fetch(); val = neg8(val); word b = state->pop(); - if (b == 0) script->branch(val); + if (b == 0) { + script->branch(val); + } } void ScriptEngine::opb6CLAT(EngineState * state, EngineFrame * frame) { @@ -886,18 +908,22 @@ void ScriptEngine::opb8CLOW(EngineState * state, EngineFrame * frame) { void ScriptEngine::opb9CHI(EngineState * state, EngineFrame * frame) { word lo = state->pop(); - for (uint i = 0;isaves.size();i++) - if (frame->saves[i].rank >= lo) + for (uint i = 0;isaves.size();i++) { + if (frame->saves[i].rank >= lo) { frame->saves[i].rank = 0; + } + } } void ScriptEngine::opbaCRAN(EngineState * state, EngineFrame * frame) { word hi = state->pop(); word lo = state->pop(); - for (uint i = 0;isaves.size();i++) + for (uint i = 0;isaves.size();i++) { if (frame->saves[i].rank >= lo && - frame->saves[i].rank <= hi) + frame->saves[i].rank <= hi) { frame->saves[i].rank = 0; + } + } } bool ScriptEngine::opbbFORK(EngineState * state, EngineFrame * frame) { @@ -942,8 +968,9 @@ void ScriptEngine::opbeSWOB(EngineState * state, EngineFrame * frame) { _world->setObjAttr(to, kAttrContainerOpen, _world->getObjAttr(from, 6)); _world->setObjAttr(from, kAttrContainerOpen, 0); Common::Array children = _world->getChildren(from, true); - for (uint i = 0; i < children.size(); i++) + for (uint i = 0; i < children.size(); i++) { _world->setObjAttr(children[i], 0, to); + } } void ScriptEngine::opbfSNOB(EngineState * state, EngineFrame * frame) { diff --git a/engines/macventure/sound.cpp b/engines/macventure/sound.cpp index 590da2eef3..492bf55b43 100644 --- a/engines/macventure/sound.cpp +++ b/engines/macventure/sound.cpp @@ -104,7 +104,9 @@ SoundAsset::~SoundAsset() { } void SoundAsset::play(Audio::Mixer *mixer, Audio::SoundHandle *soundHandle) { - if (_data.size() == 0) return; + if (_data.size() == 0) { + return; + } Audio::AudioStream *sound = Audio::makeRawStream(&_data.front(), _length, _frequency, Audio::FLAG_UNSIGNED, DisposeAfterUse::NO); mixer->playStream(Audio::Mixer::kPlainSoundType, soundHandle, sound); } @@ -127,8 +129,11 @@ void SoundAsset::decode10(Common::SeekableReadStream *stream) { _frequency = (stream->readUint32BE() * 22100 / 0x10000) | 0; byte ch = 0; for (uint i = 0; i < _length; i++) { - if (i & 1) ch >>= 4; - else ch = stream->readByte(); + if (i & 1) { + ch >>= 4; + } else { + ch = stream->readByte(); + } _data.push_back(wavtable[ch & 0xf]); } } @@ -156,14 +161,18 @@ void SoundAsset::decode12(Common::SeekableReadStream *stream) { ch -= 0x80; uint32 env= ch * scale; ch = (env >> 8) & 0xff; - if (ch & 0x80) ch = 0x7f; + if (ch & 0x80) { + ch = 0x7f; + } ch += 0x80; } else { ch = (ch ^ 0xff) + 1; ch -= 0x80; uint32 env = ch * scale; ch = (env >> 8) & 0xff; - if (ch & 0x80) ch = 0x7f; + if (ch & 0x80) { + ch = 0x7f; + } ch += 0x80; ch = (ch ^ 0xff) + 1; } @@ -185,8 +194,11 @@ void SoundAsset::decode18(Common::SeekableReadStream *stream) { _frequency = (stream->readUint32BE() * 22100 / 0x10000) | 0; byte ch = 0; for (uint i = 0; i < _length; i++) { - if (i & 1) ch >>= 4; - else ch = stream->readByte(); + if (i & 1) { + ch >>= 4; + } else { + ch = stream->readByte(); + } _data.push_back(wavtable[ch & 0xf]); } } @@ -204,8 +216,11 @@ void SoundAsset::decode1a(Common::SeekableReadStream *stream) { _frequency = (stream->readUint32BE() * 22100 / 0x10000) | 0; byte ch = 0; for (uint i = 0; i < _length; i++) { - if (i & 1) ch >>= 4; - else ch = stream->readByte(); + if (i & 1) { + ch >>= 4; + } else { + ch = stream->readByte(); + } _data.push_back(wavtable[ch & 0xf]); } } @@ -231,8 +246,11 @@ void SoundAsset::decode78(Common::SeekableReadStream *stream) { _frequency = (stream->readUint32BE() * 22100 / 0x10000) | 0; byte ch = 0; for (uint i = 0; i < _length; i++) { - if (i & 1) ch <<= 4; - else ch = stream->readByte(); + if (i & 1) { + ch <<= 4; + } else { + ch = stream->readByte(); + } _data.push_back(wavtable[(ch >> 4) & 0xf]); } } @@ -250,8 +268,11 @@ void SoundAsset::decode7e(Common::SeekableReadStream *stream) { uint32 last=0x80; byte ch = 0; for (uint i = 0; i < _length; i++) { - if (i & 1) ch <<= 4; - else ch = stream->readByte(); + if (i & 1) { + ch <<= 4; + } else { + ch = stream->readByte(); + } last += wavtable[(ch >> 4) & 0xf]; _data.push_back(last & 0xff); } diff --git a/engines/macventure/text.cpp b/engines/macventure/text.cpp index 5a2d029714..7981692c0a 100644 --- a/engines/macventure/text.cpp +++ b/engines/macventure/text.cpp @@ -123,7 +123,9 @@ void TextAsset::decodeHuffman() { uint32 entry; // Find the length index for (entry = 0; entry < _huffman->getNumEntries(); entry++) { - if (mask < _huffman->getMask(entry)) break; + if (mask < _huffman->getMask(entry)) { + break; + } } stream.skip(_huffman->getLength(entry)); diff --git a/engines/macventure/world.cpp b/engines/macventure/world.cpp index c514ebd535..fc563cb639 100644 --- a/engines/macventure/world.cpp +++ b/engines/macventure/world.cpp @@ -63,7 +63,9 @@ uint32 World::getObjAttr(ObjID objID, uint32 attrID) { res = _saveGame->getAttr(objID, index); } else { index &= 0x7F; - if (objStream->size() == 0) return 0; + if (objStream->size() == 0) { + return 0; + } // Look for the right attribute inside the object objStream->skip(index * 2); res = objStream->readByte() << 8; @@ -79,8 +81,10 @@ uint32 World::getObjAttr(ObjID objID, uint32 attrID) { } void World::setObjAttr(ObjID objID, uint32 attrID, Attribute value) { - if (attrID == kAttrPosX || attrID == kAttrPosY) {} + if (attrID == kAttrPosX || attrID == kAttrPosY) { // Round to scale + // Intentionally empty, we don't seem to require this functionality + } if (attrID == kAttrParentObject) setParent(objID, value); @@ -101,15 +105,24 @@ bool MacVenture::World::isObjActive(ObjID obj) { ObjID destObj = _engine->getDestObject(); Common::Point p = _engine->getDeltaPoint(); ControlAction selectedControl = _engine->getSelectedControl(); - if (!getAncestor(obj)) return false; // If our ancestor is the garbage (obj 0), we're inactive + if (!getAncestor(obj)) { + return false; // If our ancestor is the garbage (obj 0), we're inactive + } if (_engine->getInvolvedObjects() >= 2 && // If (we need > 1 objs for the command) && destObj > 0 && // we have a destination object && - !getAncestor(destObj)) // but that destination object is in the garbage + !getAncestor(destObj)) { // but that destination object is in the garbage return false; - if (selectedControl != kMoveObject) return true; // We only need one + } + if (selectedControl != kMoveObject) { + return true; // We only need one + } // Handle move object - if (!isObjDraggable(obj)) return false; // We can't move it - if (getObjAttr(1, kAttrParentObject) != destObj) return true; // if the target is not the player's parent, we can go + if (!isObjDraggable(obj)) { + return false; // We can't move it + } + if (getObjAttr(1, kAttrParentObject) != destObj) { + return true; // if the target is not the player's parent, we can go + } Common::Rect rect(kScreenWidth, kScreenHeight); rect.top -= getObjAttr(obj, kAttrPosY) + p.y; rect.left -= getObjAttr(obj, kAttrPosX) + p.x; @@ -173,7 +186,7 @@ void World::releaseChildren(ObjID objID) { } Common::String World::getText(ObjID objID, ObjID source, ObjID target) { - if (objID & 0x8000){ + if (objID & 0x8000) { return _engine->getUserInput(); } TextAsset text = TextAsset(_engine, objID, source, target, _gameText, _engine->isOldText(), _engine->getDecodingHuffman()); @@ -203,7 +216,9 @@ void World::calculateObjectRelations() { for (uint i = numObjs - 1; i > 0; i--) { val = parents[i]; next = _relations[val * 2]; - if (next) { _relations[i * 2 + 1] = next; } + if (next) { + _relations[i * 2 + 1] = next; + } _relations[val * 2] = i; } } @@ -231,7 +246,9 @@ void World::setParent(ObjID child, ObjID newParent) { } void World::loadGameFrom(Common::InSaveFile *file) { - if (_saveGame) delete _saveGame; + if (_saveGame) { + delete _saveGame; + } _saveGame = new SaveGame(_engine, file); calculateObjectRelations(); } @@ -287,7 +304,7 @@ void SaveGame::saveInto(Common::OutSaveFile *file) { warning("Saving the game not yet tested!"); // Save attibutes Common::Array::const_iterator itg; - for(itg = _groups.begin(); itg != _groups.end(); itg++) { + for (itg = _groups.begin(); itg != _groups.end(); itg++) { Common::Array::const_iterator ita; for (ita = itg->begin(); ita != itg->end(); ita++) { file->writeUint16BE((*ita)); @@ -307,8 +324,9 @@ void SaveGame::loadGroups(MacVentureEngine *engine, Common::SeekableReadStream * GlobalSettings settings = engine->getGlobalSettings(); for (int i = 0; i < settings._numGroups; ++i) { AttributeGroup g; - for (int j = 0; j < settings._numObjects; ++j) + for (int j = 0; j < settings._numObjects; ++j) { g.push_back(res->readUint16BE()); + } _groups.push_back(g); } -- cgit v1.2.3