diff options
| -rw-r--r-- | engines/tony/custom.cpp | 18 | ||||
| -rw-r--r-- | engines/tony/game.cpp | 22 | ||||
| -rw-r--r-- | engines/tony/gfxcore.cpp | 17 | ||||
| -rw-r--r-- | engines/tony/inventory.cpp | 3 | ||||
| -rw-r--r-- | engines/tony/loc.cpp | 24 | ||||
| -rw-r--r-- | engines/tony/mpal/loadmpc.cpp | 3 | ||||
| -rw-r--r-- | engines/tony/mpal/mpal.cpp | 70 | ||||
| -rw-r--r-- | engines/tony/sound.cpp | 17 | ||||
| -rw-r--r-- | engines/tony/tony.cpp | 3 | 
9 files changed, 119 insertions, 58 deletions
diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 27de5cf717..9aef809826 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -237,9 +237,10 @@ VoiceHeader *SearchVoiceHeader(uint32 codehi, uint32 codelo) {  	if (g_vm->_voices.size() == 0)  		return NULL; -	for (uint i = 0; i < g_vm->_voices.size(); i++) +	for (uint i = 0; i < g_vm->_voices.size(); i++) {  		if (g_vm->_voices[i]._code == code)  			return &g_vm->_voices[i]; +	}  	return NULL;  } @@ -1208,21 +1209,25 @@ DECLARE_CUSTOM_FUNCTION(ScrollLocation)(CORO_PARAM, uint32 nX, uint32 nY, uint32  	while ((_ctx->lx != 0 || _ctx->ly != 0) && !GLOBALS._bSkipIdle) {  		if (_ctx->lx > 0) {  			_ctx->lx -= (int32)sX; -			if (_ctx->lx < 0) _ctx->lx = 0; +			if (_ctx->lx < 0) +				_ctx->lx = 0;  			_ctx->pt.offset((int32)sX, 0);  		} else if (_ctx->lx < 0) {  			_ctx->lx += (int32)sX; -			if (_ctx->lx > 0) _ctx->lx = 0; +			if (_ctx->lx > 0) +				_ctx->lx = 0;  			_ctx->pt.offset(-(int32)sX, 0);  		}  		if (_ctx->ly > 0) {  			_ctx->ly -= sY; -			if (_ctx->ly < 0) _ctx->ly = 0; +			if (_ctx->ly < 0) +				_ctx->ly = 0;  			_ctx->pt.offset(0, sY);  		} else if (_ctx->ly < 0) {  			_ctx->ly += sY; -			if (_ctx->ly > 0) _ctx->ly = 0; +			if (_ctx->ly > 0) +				_ctx->ly = 0;  			_ctx->pt.offset(0, -(int32)sY);  		} @@ -1493,7 +1498,8 @@ DECLARE_CUSTOM_FUNCTION(CharSendMessage)(CORO_PARAM, uint32 nChar, uint32 dwMess  			g_vm->_vdbFP.seek(_ctx->curOffset);  			_ctx->voice->loadVoiceFromVDB(g_vm->_vdbFP);  			_ctx->voice->setLoop(false); -			if (bIsBack) _ctx->voice->setVolume(55); +			if (bIsBack) +				_ctx->voice->setVolume(55);  			_ctx->voice->play();  			_ctx->text->setCustomSkipHandle2(_ctx->voice->_hEndOfBuffer);  			_ctx->curOffset = g_vm->_vdbFP.pos(); diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index 00c0a1ad7a..c17b611b0c 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -476,11 +476,16 @@ void RMOptionScreen::refreshAll(CORO_PARAM) {  	CORO_INVOKE_0(drawOT);  	if (_nState == MENULOAD || _nState == MENUSAVE) { -		if (_ctx->thumb) delete _ctx->thumb; -		if (_ctx->title) delete _ctx->title; +		if (_ctx->thumb) +			delete _ctx->thumb; -		for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) -			if (_ctx->num[_ctx->i]) delete _ctx->num[_ctx->i]; +		if (_ctx->title) +			delete _ctx->title; + +		for (_ctx->i = 0; _ctx->i < 6; _ctx->i++) { +			if (_ctx->num[_ctx->i]) +				delete _ctx->num[_ctx->i]; +		}  	}  	CORO_END_CODE; @@ -1049,13 +1054,14 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) {  			}  		} -		for (_ctx->i = 0; _ctx->i < 26 && strlen(_editName) < 12; _ctx->i++) +		for (_ctx->i = 0; _ctx->i < 26 && strlen(_editName) < 12; _ctx->i++) {  			if (KEYPRESS(Common::KEYCODE_LSHIFT) ||  			        KEYPRESS(Common::KEYCODE_RSHIFT)) {  				PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'A');  			} else {  				PROCESS_CHAR((Common::KeyCode)((int)'a' + _ctx->i), _ctx->i + 'a');  			} +		}  		for (_ctx->i = 0; _ctx->i < 10 && strlen(_editName) < 12; _ctx->i++)  			PROCESS_CHAR((Common::KeyCode)((int)'0' + _ctx->i), _ctx->i + '0'); @@ -1203,9 +1209,10 @@ void RMOptionScreen::doFrame(CORO_PARAM, RMInput *input) {  		}  	} -	if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) +	if (_nState == MENUGAME || _nState == MENUGFX || _nState == MENUSOUND) {  		if (!_bQuitConfirm && KEYPRESS(Common::KEYCODE_ESCAPE))  			close(); +	}  	if (_ctx->bRefresh)  		CORO_INVOKE_0(refreshAll); @@ -1475,7 +1482,8 @@ void RMPointer::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim  	// Check the pointer  	_ctx->n = _nCurPointer; -	if (_ctx->n == TA_COMBINE) _ctx->n = TA_USE; +	if (_ctx->n == TA_COMBINE) +		_ctx->n = TA_USE;  	// WORKAROUND: updateCursor gets called too early sometimes (for example, when  	// the cursor is released over the TA_PERORATE option), via setAction. diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 44befa3755..2e368bbc64 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -648,9 +648,14 @@ int RMGfxSourceBuffer8AB::calcTrasp(int fore, int back) {  	g = (GETGREEN(fore) >> 2) + (GETGREEN(back) >> 1);  	b = (GETBLUE(fore) >> 2) + (GETBLUE(back) >> 1); -	if (r > 0x1F) r = 0x1F; -	if (g > 0x1F) g = 0x1F; -	if (b > 0x1F) b = 0x1F; +	if (r > 0x1F) +		r = 0x1F; + +	if (g > 0x1F) +		g = 0x1F; + +	if (b > 0x1F) +		b = 0x1F;  	return (r << 10) | (g << 5) | b;  } @@ -1717,7 +1722,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri  		*/  		mybuf = &buf[x1]; -		for (x = 0; x < width; x++, mybuf += step) +		for (x = 0; x < width; x++, mybuf += step) {  			if (_aabuf[(y + v) * _dimx + x + u] == 2 && x != 0 && x != width - 1) {  				r = GETRED(mybuf[1]) + GETRED(mybuf[-1]) + GETRED(mybuf[-bigBuf.getDimx()]) + GETRED(mybuf[bigBuf.getDimx()]);  				g = GETGREEN(mybuf[1]) + GETGREEN(mybuf[-1]) + GETGREEN(mybuf[-bigBuf.getDimx()]) + GETGREEN(mybuf[bigBuf.getDimx()]); @@ -1737,6 +1742,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri  				mybuf[0] = (r << 10) | (g << 5) | b;  			} +		}  		// Skip to the next line  		buf += bigBuf.getDimx(); @@ -1756,7 +1762,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri  		*/  		mybuf = &buf[x1]; -		for (x = 0; x < width; x++, mybuf += step) +		for (x = 0; x < width; x++, mybuf += step) {  			if (_aabuf[(y + v) * _dimx + x + u] == 1 && x != 0 && x != width - 1) {  				r = GETRED(mybuf[1]) + GETRED(mybuf[-1]) + GETRED(mybuf[-bigBuf.getDimx()]) + GETRED(mybuf[bigBuf.getDimx()]);  				g = GETGREEN(mybuf[1]) + GETGREEN(mybuf[-1]) + GETGREEN(mybuf[-bigBuf.getDimx()]) + GETGREEN(mybuf[bigBuf.getDimx()]); @@ -1776,6 +1782,7 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri  				mybuf[0] = (r << 10) | (g << 5) | b;  			} +		}  		// Skip to the next line  		buf += bigBuf.getDimx(); diff --git a/engines/tony/inventory.cpp b/engines/tony/inventory.cpp index dbd3ad6840..647e4264c7 100644 --- a/engines/tony/inventory.cpp +++ b/engines/tony/inventory.cpp @@ -763,9 +763,10 @@ int RMInterface::onWhichBox(RMPoint pt) {  		max = 5;  	// Find the verb -	for (i = 0; i < max; i++) +	for (i = 0; i < max; i++) {  		if (_hotbbox[i].ptInRect(pt))  			return i; +	}  	// Found no verb  	return -1; diff --git a/engines/tony/loc.cpp b/engines/tony/loc.cpp index d8548cc570..6401e1337f 100644 --- a/engines/tony/loc.cpp +++ b/engines/tony/loc.cpp @@ -141,7 +141,7 @@ int RMPattern::init(RMSfx *sfx, bool bPlayP0, byte *bFlag) {  	// Check for sound:  	//  If the slot is 0, play -	//  If speed = 0, must playing unless it goes into loop '_', or if specified by the parameter +	//  If speed == 0, must play unless it goes into loop '_', or if specified by the parameter  	//  If speed != 0, play only the loop  	for (i = 0; i < _nSlots; i++) {  		if (_slots[i]._type == SOUND) { @@ -1108,7 +1108,9 @@ RMPoint RMCharacter::searching(char UP, char DOWN, char RIGHT, char LEFT, RMPoin  		}  	} -	if (minimo == 32000) trovato = punto; +	if (minimo == 32000) +		trovato = punto; +  	return trovato;  } @@ -1137,11 +1139,13 @@ short RMCharacter::scanLine(const RMPoint &punto) {  	if (Ldx > Ldy) {  		Lslope = Lfy / Lfx; -		if (Lend._x < Lstart._x) Lspeed = -Lspeed; +		if (Lend._x < Lstart._x) +			Lspeed = -Lspeed;  		Lstatus = 1;  	} else {  		Lslope = Lfx / Lfy; -		if (Lend._y < Lstart._y) Lspeed = - Lspeed; +		if (Lend._y < Lstart._y) +			Lspeed = - Lspeed;  		Lstatus = 0;  	} @@ -1777,11 +1781,13 @@ int RMGameBoxes::whichBox(int nLoc, const RMPoint &punto) {  	if (!cur)  		return -1; -	for (i = 0; i < cur->_numbBox; i++) -		if (cur->_boxes[i]._bActive) +	for (i = 0; i < cur->_numbBox; i++) { +		if (cur->_boxes[i]._bActive) {  			if ((punto._x >= cur->_boxes[i]._left) && (punto._x <= cur->_boxes[i]._right) &&  			        (punto._y >= cur->_boxes[i]._top)  && (punto._y <= cur->_boxes[i]._bottom))  				return i; +		} +	}  	return -1;  } @@ -2053,9 +2059,10 @@ void RMLocation::doFrame(RMGfxTargetBuffer *bigBuf) {  RMItem *RMLocation::getItemFromCode(uint32 dwCode) {  	int i; -	for (i = 0; i < _nItems; i++) +	for (i = 0; i < _nItems; i++) {  		if (_items[i].mpalCode() == (int)dwCode)  			return &_items[i]; +	}  	return NULL;  } @@ -2133,9 +2140,10 @@ void RMLocation::updateScrolling(const RMPoint &ptShowThis) {  	if (_curScroll._y + RM_SY > _buf->getDimy())  		_curScroll._y = _buf->getDimy() - RM_SY; -	if (oldScroll != _curScroll) +	if (oldScroll != _curScroll) {  		for (int i = 0; i < _nItems; i++)  			_items[i].setScrollPosition(_curScroll); +	}  }  void RMLocation::setFixedScroll(const RMPoint &scroll) { diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index ed4ad9d228..2d2f8ecd00 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -628,9 +628,10 @@ bool ParseMpc(const byte *lpBuf) {  		GLOBALS._lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); -		for (i = 0;i < GLOBALS._nDialogs; i++) +		for (i = 0;i < GLOBALS._nDialogs; i++) {  			if ((lpBuf = parseDialog(lpBuf + 7, &GLOBALS._lpmdDialogs[i])) == NULL)  				return false; +		}  		globalUnlock(GLOBALS._hDialogs);  	} diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 16d8a3213b..721552b80c 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -224,9 +224,10 @@ static int msgGetOrderFromNum(uint32 nMsg) {  	int i;  	LPMPALMSG msg = GLOBALS._lpmmMsgs; -	for (i = 0; i < GLOBALS._nMsgs; i++, msg++) +	for (i = 0; i < GLOBALS._nMsgs; i++, msg++) {  		if (msg->_wNum == nMsg)  			return i; +	}  	return -1;  } @@ -242,9 +243,10 @@ static int itemGetOrderFromNum(uint32 nItem) {  	int i;  	LPMPALITEM item = GLOBALS._lpmiItems; -	for (i = 0; i < GLOBALS._nItems; i++, item++) +	for (i = 0; i < GLOBALS._nItems; i++, item++) {  		if (item->nObj == nItem)  			return i; +	}  	return -1;  } @@ -261,9 +263,10 @@ static int scriptGetOrderFromNum(uint32 nScript) {  	int i;  	LPMPALSCRIPT script = GLOBALS._lpmsScripts; -	for (i = 0; i < GLOBALS._nScripts; i++, script++) +	for (i = 0; i < GLOBALS._nScripts; i++, script++) {  		if (script->nObj == nScript)  			return i; +	}  	return -1;  } @@ -280,9 +283,10 @@ static int dialogGetOrderFromNum(uint32 nDialog) {  	int i;  	LPMPALDIALOG dialog = GLOBALS._lpmdDialogs; -	for (i = 0; i < GLOBALS._nDialogs; i++, dialog++) +	for (i = 0; i < GLOBALS._nDialogs; i++, dialog++) {  		if (dialog->nObj == nDialog)  			return i; +	}  	return -1;  } @@ -333,14 +337,15 @@ static char *duplicateDialogPeriod(uint32 nPeriod) {  	LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog;  	int i, j; -	for (j = 0; dialog->_periods[j] != NULL; j++) +	for (j = 0; dialog->_periods[j] != NULL; j++) {  		if (dialog->_periodNums[j] == nPeriod) {  			/* Found the phrase, it should be duplicated */  			origmsg = (const char *)globalLock(dialog->_periods[j]);  			/* Calculate the length and allocate memory */  			i = 0; -			while (origmsg[i] != '\0') i++; +			while (origmsg[i] != '\0') +				i++;  			clonemsg = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, i + 1);  			if (clonemsg == NULL) @@ -352,7 +357,8 @@ static char *duplicateDialogPeriod(uint32 nPeriod) {  			return clonemsg;  		} - +	} +	  	return NULL;  } @@ -415,9 +421,10 @@ static uint32 *getSelectList(uint32 i) {  	/* Count how many are active selects */  	num = 0; -	for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) +	for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) {  		if (dialog->_choice[i]._select[j].curActive)  			num++; +	}  	/* If there are 0, it's a mistake */  	if (num == 0) @@ -429,9 +436,10 @@ static uint32 *getSelectList(uint32 i) {  	/* Copy all the data inside the active select list */  	k = 0; -	for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) +	for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) {  		if (dialog->_choice[i]._select[j].curActive)  			sl[k++] = dialog->_choice[i]._select[j].dwData; +	}  	sl[k] = (uint32)NULL;  	return sl; @@ -690,7 +698,8 @@ void ActionThread(CORO_PARAM, const void *param) {  		LPMPALITEM item;  		~CoroContextTag() { -			if (item) globalDestroy(item); +			if (item) +				globalDestroy(item);  		}  	CORO_END_CONTEXT(_ctx); @@ -844,14 +853,16 @@ void LocationPollThread(CORO_PARAM, const void *param) {  	for (_ctx->i = 0; _ctx->i < _ctx->numitems; _ctx->i++) {  		_ctx->ord = itemGetOrderFromNum(_ctx->il[_ctx->i]); -		if (_ctx->ord == -1) continue; +		if (_ctx->ord == -1) +			continue;  		_ctx->curItem = GLOBALS._lpmiItems + _ctx->ord;  		_ctx->k = 0; -		for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) +		for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) {  			if (_ctx->curItem->Action[_ctx->j].num == 0xFF)  				_ctx->k++; +		}  		_ctx->nIdleActions += _ctx->k; @@ -928,12 +939,13 @@ void LocationPollThread(CORO_PARAM, const void *param) {  		_ctx->curTime = g_vm->getTime();  		_ctx->dwSleepTime = (uint32)-1L; -		for (_ctx->k = 0;_ctx->k<_ctx->nIdleActions;_ctx->k++) +		for (_ctx->k = 0;_ctx->k<_ctx->nIdleActions;_ctx->k++) {  			if (_ctx->curTime >= _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime) {  				_ctx->dwSleepTime = 0;  				break; -		     } else +			} else  				_ctx->dwSleepTime = MIN(_ctx->dwSleepTime, _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime - _ctx->curTime); +		}  		/* We fall alseep, but always checking that the event is set when prompted for closure */  		CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS._hEndPollingLocations[id], _ctx->dwSleepTime, &_ctx->expired); @@ -942,7 +954,7 @@ void LocationPollThread(CORO_PARAM, const void *param) {  		if (!_ctx->expired)  			break; -		for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) +		for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) {  			if (_ctx->MyThreads[_ctx->i].nItem != 0) {  				CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 0, &_ctx->delayExpired); @@ -950,11 +962,12 @@ void LocationPollThread(CORO_PARAM, const void *param) {  				if (!_ctx->delayExpired)  					_ctx->MyThreads[_ctx->i].nItem = 0;  			} +		}  		_ctx->curTime = g_vm->getTime();  		/* Loop through all the necessary idle actions */ -		for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) +		for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) {  			if (_ctx->curTime >= _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime) {  				_ctx->MyActions[_ctx->k].dwLastTime += _ctx->MyActions[_ctx->k].wTime; @@ -966,9 +979,10 @@ void LocationPollThread(CORO_PARAM, const void *param) {  						continue;  					/* Check to see if there already another idle funning running on the item */ -					for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) +					for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) {  						if (_ctx->MyThreads[_ctx->i].nItem == _ctx->MyActions[_ctx->k].nItem)  							break; +					}  					if (_ctx->i < _ctx->nRealItems)  						continue; @@ -979,11 +993,12 @@ void LocationPollThread(CORO_PARAM, const void *param) {  					/* Check if there is a WhenExecute expression */  					_ctx->j=_ctx->MyActions[_ctx->k].nAction; -					if (_ctx->curItem->Action[_ctx->j].when != NULL) +					if (_ctx->curItem->Action[_ctx->j].when != NULL) {  						if (!evaluateExpression(_ctx->curItem->Action[_ctx->j].when)) {  							unlockItems();  							continue;  						} +					}  					/* Ok, we can perform the action. For convenience, we do it in a new process */  					_ctx->newItem = (LPMPALITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); @@ -1004,9 +1019,10 @@ void LocationPollThread(CORO_PARAM, const void *param) {  					_ctx->newItem->dwRes=_ctx->j;  					/* We will create an action, and will provide the necessary details */ -					for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) +					for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) {  						if (_ctx->MyThreads[_ctx->i].nItem == 0)  							break; +					}  					_ctx->MyThreads[_ctx->i].nItem = _ctx->MyActions[_ctx->k].nItem; @@ -1024,13 +1040,14 @@ void LocationPollThread(CORO_PARAM, const void *param) {  					/* Skip all idle actions of the same item */  				}  			} +		}  	}  	// Set idle skip on  	CORO_INVOKE_4(GLOBALS._lplpFunctions[200], 0, 0, 0, 0); -	for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) +	for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) {  		if (_ctx->MyThreads[_ctx->i].nItem != 0) {  			CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 5000, &_ctx->delayExpired); @@ -1041,6 +1058,7 @@ void LocationPollThread(CORO_PARAM, const void *param) {  */  			CoroScheduler.killMatchingProcess(_ctx->MyThreads[_ctx->i].hThread);  		} +	}  	// Set idle skip off  	CORO_INVOKE_4(GLOBALS._lplpFunctions[201], 0, 0, 0, 0); @@ -1178,9 +1196,10 @@ void doChoice(CORO_PARAM, uint32 nChoice) {  	_ctx->dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog;  	/* Search the choice between those required in the dialog */ -	for (_ctx->i = 0; _ctx->dialog->_choice[_ctx->i].nChoice != 0; _ctx->i++) +	for (_ctx->i = 0; _ctx->dialog->_choice[_ctx->i].nChoice != 0; _ctx->i++) {  		if (_ctx->dialog->_choice[_ctx->i].nChoice == nChoice)  			break; +	}  	/* If nothing has been found, exit with an error */  	if (_ctx->dialog->_choice[_ctx->i].nChoice == 0) { @@ -1200,7 +1219,7 @@ void doChoice(CORO_PARAM, uint32 nChoice) {  		_ctx->k = 0;  		/* Calculate the expression of each selection, to see if they're active or inactive */ -		for (_ctx->j = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].dwData != 0; _ctx->j++) +		for (_ctx->j = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].dwData != 0; _ctx->j++) {  			if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].when == NULL) {  				_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 1;  				_ctx->k++; @@ -1209,6 +1228,7 @@ void doChoice(CORO_PARAM, uint32 nChoice) {  				_ctx->k++;  			} else  				_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 0; +		}  		/* If there are no choices activated, then the dialog is finished. */  		if (_ctx->k == 0) { @@ -1373,9 +1393,10 @@ bool doSelection(uint32 i, uint32 dwData) {  	LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog;  	int j; -	for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) +	for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) {  		if (dialog->_choice[i]._select[j].dwData == dwData && dialog->_choice[i]._select[j].curActive != 0)  			break; +	}  	if (dialog->_choice[i]._select[j].dwData == 0)  		return false; @@ -2020,9 +2041,10 @@ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) {  bool mpalStartIdlePoll(int nLoc) {  	uint32 i; -	for (i = 0; i < MAXPOLLINGLOCATIONS; i++) +	for (i = 0; i < MAXPOLLINGLOCATIONS; i++) {  		if (GLOBALS._nPollingLocations[i] == (uint32)nLoc)  			return false; +	}  	for (i = 0; i < MAXPOLLINGLOCATIONS; i++) {  		if (GLOBALS._nPollingLocations[i] == 0) { diff --git a/engines/tony/sound.cpp b/engines/tony/sound.cpp index 8ea7aa03c3..3a1c6746c8 100644 --- a/engines/tony/sound.cpp +++ b/engines/tony/sound.cpp @@ -339,6 +339,7 @@ void FPSfx::pause(bool bPause) {  void FPSfx::setVolume(int dwVolume) {  	if (dwVolume > 63)  		dwVolume = 63; +  	if (dwVolume < 0)  		dwVolume = 0; @@ -349,7 +350,8 @@ void FPSfx::setVolume(int dwVolume) {  			dwVolume = 0;  		else {  			dwVolume -= (10 - GLOBALS._nCfgDubbingVolume) * 2; -			if (dwVolume < 0) dwVolume = 0; +			if (dwVolume < 0) +				dwVolume = 0;  		}  	} else {  		if (!GLOBALS._bCfgSFX) @@ -655,15 +657,20 @@ void FPStream::pause(bool bPause) {   */  void FPStream::setVolume(int dwVolume) { -	if (dwVolume > 63) dwVolume = 63; -	if (dwVolume < 0) dwVolume = 0; +	if (dwVolume > 63) +		dwVolume = 63; + +	if (dwVolume < 0) +		dwVolume = 0;  	_lastVolume = dwVolume; -	if (!GLOBALS._bCfgMusic) dwVolume = 0; +	if (!GLOBALS._bCfgMusic) +		dwVolume = 0;  	else {  		dwVolume -= (10 - GLOBALS._nCfgMusicVolume) * 2; -		if (dwVolume < 0) dwVolume = 0; +		if (dwVolume < 0) +			dwVolume = 0;  	}  	if (g_system->getMixer()->isSoundHandleActive(_handle)) diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index bb28848362..79300ca1ee 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -281,9 +281,10 @@ void TonyEngine::GUIError(const Common::String &msg) {  }  void TonyEngine::playMusic(int nChannel, const Common::String &fname, int nFX, bool bLoop, int nSync) { -	if (nChannel < 4) +	if (nChannel < 4) {  		if (GLOBALS._flipflop)  			nChannel = nChannel + 1; +	}  	switch (nFX) {  	case 0:  | 
