diff options
author | Strangerke | 2012-12-22 01:28:31 +0100 |
---|---|---|
committer | Strangerke | 2012-12-22 01:28:31 +0100 |
commit | e44df7732925e42d52e5567185a16839e9ba2cfb (patch) | |
tree | 3300bf5a594c48121df16dcaa044da2ac966a559 /engines | |
parent | fcbcca45b1a3f5abd1961a2e68b41cd2d78c899c (diff) | |
download | scummvm-rg350-e44df7732925e42d52e5567185a16839e9ba2cfb.tar.gz scummvm-rg350-e44df7732925e42d52e5567185a16839e9ba2cfb.tar.bz2 scummvm-rg350-e44df7732925e42d52e5567185a16839e9ba2cfb.zip |
HOPKINS: Remove useless IF statements
Diffstat (limited to 'engines')
-rw-r--r-- | engines/hopkins/anim.cpp | 33 | ||||
-rw-r--r-- | engines/hopkins/events.cpp | 10 | ||||
-rw-r--r-- | engines/hopkins/font.cpp | 54 | ||||
-rw-r--r-- | engines/hopkins/graphics.cpp | 22 | ||||
-rw-r--r-- | engines/hopkins/hopkins.cpp | 6 | ||||
-rw-r--r-- | engines/hopkins/lines.cpp | 263 | ||||
-rw-r--r-- | engines/hopkins/objects.cpp | 294 | ||||
-rw-r--r-- | engines/hopkins/script.cpp | 10 |
8 files changed, 313 insertions, 379 deletions
diff --git a/engines/hopkins/anim.cpp b/engines/hopkins/anim.cpp index d278f15a8d..2f9d44a614 100644 --- a/engines/hopkins/anim.cpp +++ b/engines/hopkins/anim.cpp @@ -576,13 +576,13 @@ void AnimationManager::loadAnim(const Common::String &animName) { const char *files[6] = { &filename1[0], &filename2[0], &filename3[0], &filename4[0], &filename5[0], &filename6[0] }; - for (int idx = 1; idx <= 6; ++idx) { - if (files[idx - 1][0]) { - _vm->_fileManager.constructFilename(_vm->_globals.HOPANIM, files[idx - 1]); + for (int idx = 0; idx <= 5; ++idx) { + if (files[idx][0]) { + _vm->_fileManager.constructFilename(_vm->_globals.HOPANIM, files[idx]); if (!f.exists(_vm->_globals.NFICHIER)) error("File not found"); - if (loadSpriteBank(idx, files[idx - 1])) + if (loadSpriteBank(idx + 1, files[idx])) error("File not compatible with this soft."); } } @@ -591,9 +591,8 @@ void AnimationManager::loadAnim(const Common::String &animName) { f.read(data, nbytes); f.close(); - for (int idx = 1; idx <= 20; ++idx) { + for (int idx = 1; idx <= 20; ++idx) searchAnim(data, idx, nbytes); - } _vm->_globals.freeMemory(data); } @@ -676,19 +675,15 @@ int AnimationManager::loadSpriteBank(int idx, const Common::String &filename) { if (f.exists(_vm->_globals.NFICHIER)) { v19 = _vm->_fileManager.loadFile(_vm->_globals.NFICHIER); v13 = v19; - - if (_vm->_globals.Bank[idx].field1A > 0) { - for (int objIdx = 0; objIdx < _vm->_globals.Bank[idx].field1A; ++objIdx) { - int x1 = (int16)READ_LE_UINT16(v13); - int y1 = (int16)READ_LE_UINT16(v13 + 2); - int x2 = (int16)READ_LE_UINT16(v13 + 4); - int y2 = (int16)READ_LE_UINT16(v13 + 6); - v13 += 8; - - _vm->_objectsManager.set_offsetxy(_vm->_globals.Bank[idx]._data, objIdx, x1, y1, 0); - if (_vm->_globals.Bank[idx]._fileHeader == 2) - _vm->_objectsManager.set_offsetxy(_vm->_globals.Bank[idx]._data, objIdx, x2, y2, 1); - } + for (int objIdx = 0; objIdx < _vm->_globals.Bank[idx].field1A; ++objIdx, v13 += 8) { + int x1 = (int16)READ_LE_UINT16(v13); + int y1 = (int16)READ_LE_UINT16(v13 + 2); + int x2 = (int16)READ_LE_UINT16(v13 + 4); + int y2 = (int16)READ_LE_UINT16(v13 + 6); + + _vm->_objectsManager.set_offsetxy(_vm->_globals.Bank[idx]._data, objIdx, x1, y1, 0); + if (_vm->_globals.Bank[idx]._fileHeader == 2) + _vm->_objectsManager.set_offsetxy(_vm->_globals.Bank[idx]._data, objIdx, x2, y2, 1); } _vm->_globals.freeMemory(v19); diff --git a/engines/hopkins/events.cpp b/engines/hopkins/events.cpp index 4667577237..418f4de28e 100644 --- a/engines/hopkins/events.cpp +++ b/engines/hopkins/events.cpp @@ -446,13 +446,11 @@ LABEL_65: _vm->_graphicsManager.unlockScreen(); _vm->_graphicsManager.dstrect[0] = Common::Rect(0, 20, SCREEN_WIDTH, 460); - if (_vm->_globals.NBBLOC) { - int v10 = _vm->_globals.NBBLOC + 1; - for (int i = 1; i != v10; i++) { - if (_vm->_globals.BLOC[i]._activeFl) - _vm->_globals.BLOC[i]._activeFl = false; - } + for (int i = 1; i < _vm->_globals.NBBLOC + 1; i++) { + if (_vm->_globals.BLOC[i]._activeFl) + _vm->_globals.BLOC[i]._activeFl = false; } + _vm->_globals.NBBLOC = 0; _startPos.x = _vm->_graphicsManager.SCROLL; _vm->_graphicsManager.ofscroll = _vm->_graphicsManager.SCROLL; diff --git a/engines/hopkins/font.cpp b/engines/hopkins/font.cpp index d4d6e8d770..28b13490f7 100644 --- a/engines/hopkins/font.cpp +++ b/engines/hopkins/font.cpp @@ -146,11 +146,9 @@ void FontManager::box(int idx, int messageId, const Common::String &filename, in int textType = _text[idx]._textType; if (textType != 6 && textType != 1 && textType != 3 && textType != 5) { int yCurrent = yp + 5; - if (_text[idx]._lineCount > 0) { - for (int lineNum = 0; lineNum < _text[idx]._lineCount; ++lineNum) { - displayText(xp + 5, yCurrent, _text[idx]._lines[lineNum], _text[idx]._color); - yCurrent += _vm->_globals.police_h + 1; - } + for (int lineNum = 0; lineNum < _text[idx]._lineCount; ++lineNum) { + displayText(xp + 5, yCurrent, _text[idx]._lines[lineNum], _text[idx]._color); + yCurrent += _vm->_globals.police_h + 1; } } else { int height = _text[idx]._height; @@ -251,14 +249,13 @@ void FontManager::box(int idx, int messageId, const Common::String &filename, in _text[idx]._field3FE = v64; _vm->_globals.largeur_boite = 0; - if (v64 + 1 > 0) { - for (int v15 = 0; v15 < v64 + 1; v15++) { - byte v16 = *(v60 + v15); - if (v16 <= 31) - v16 = 32; - _vm->_globals.largeur_boite += _vm->_objectsManager.getWidth(_vm->_globals.police, v16 - 32); - } + for (int v15 = 0; v15 < v64 + 1; v15++) { + byte v16 = *(v60 + v15); + if (v16 <= 31) + v16 = 32; + _vm->_globals.largeur_boite += _vm->_objectsManager.getWidth(_vm->_globals.police, v16 - 32); } + _vm->_globals.largeur_boite += 2; int v17 = _vm->_globals.largeur_boite / 2; if (v17 < 0) @@ -318,32 +315,25 @@ LABEL_57: } while (v21 != '%'); for (int i = 0; i <= 19; i++) { - int v22 = _textSortArray[i]; - if (v22 <= 0) { + if (_textSortArray[i] <= 0) { _textSortArray[i] = 0; } else { int ptrc = 0; - if (v22 - 1 > 0) { - for (int v23 = 0; v23 < _textSortArray[i] - 1; v23++) { - Common::String &line = _text[idx]._lines[i]; - byte v24 = (v23 >= (int)line.size()) ? '\0' : line.c_str()[v23]; - if (v24 <= 32) - v24 = ' '; - ptrc += _vm->_objectsManager.getWidth(_vm->_globals.police, (byte)v24 - 32); - } + for (int v23 = 0; v23 < _textSortArray[i] - 1; v23++) { + Common::String &line = _text[idx]._lines[i]; + byte v24 = (v23 >= (int)line.size()) ? '\0' : line.c_str()[v23]; + if (v24 <= 32) + v24 = ' '; + ptrc += _vm->_objectsManager.getWidth(_vm->_globals.police, (byte)v24 - 32); } _textSortArray[i] = ptrc; } } for (int i = 0; i <= 19; i++) { - int v25 = i; - do { - ++v25; - if (v25 == 20) - v25 = 0; + for (int v25 = i + 1; v25 != i; v25 = (v25 + 1) % 20) { if (_textSortArray[i] < _textSortArray[v25]) _textSortArray[i] = 0; - } while (v25 != i); + } }; for (int i = 0; i <= 19; i++) { @@ -407,11 +397,9 @@ LABEL_57: int v75 = v73 + 5; int v71 = v70 + 5; - if (lineCount > 0) { - for (int lineNum = 0; lineNum < lineCount; ++lineNum) { - displayText(v75, v71, _text[idx]._lines[lineNum], _text[idx]._color); - v71 += _vm->_globals.police_h + 1; - } + for (int lineNum = 0; lineNum < lineCount; ++lineNum) { + displayText(v75, v71, _text[idx]._lines[lineNum], _text[idx]._color); + v71 += _vm->_globals.police_h + 1; } int blockWidth = v53 + 1; diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 793d2fe96c..8ed4c03bc6 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -662,19 +662,17 @@ void GraphicsManager::fade_out(const byte *palette, int step, const byte *surfac m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); DD_VBL(); - if (palMax > 0) { - for (int palCtr3 = 0; palCtr3 < palMax; palCtr3++) { - for (int palCtr4 = 0; palCtr4 < PALETTE_BLOCK_SIZE; palCtr4++) { - int palCtr5 = palCtr4; - int palValue = tempPalette[palCtr4] - (palette[palCtr4] << 8) / palMax; - tempPalette[palCtr5] = palValue; - palData[palCtr5] = (palValue >> 8) & 0xff; - } - - setpal_vga256(palData); - m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - DD_VBL(); + for (int palCtr3 = 0; palCtr3 < palMax; palCtr3++) { + for (int palCtr4 = 0; palCtr4 < PALETTE_BLOCK_SIZE; palCtr4++) { + int palCtr5 = palCtr4; + int palValue = tempPalette[palCtr4] - (palette[palCtr4] << 8) / palMax; + tempPalette[palCtr5] = palValue; + palData[palCtr5] = (palValue >> 8) & 0xff; } + + setpal_vga256(palData); + m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + DD_VBL(); } for (int i = 0; i < PALETTE_BLOCK_SIZE; i++) diff --git a/engines/hopkins/hopkins.cpp b/engines/hopkins/hopkins.cpp index 56b98ab950..d5faff1f91 100644 --- a/engines/hopkins/hopkins.cpp +++ b/engines/hopkins/hopkins.cpp @@ -4386,15 +4386,13 @@ void HopkinsEngine::Charge_Credits() { _globals.Credit[idxLines]._colour = curPtr[1]; _globals.Credit[idxLines]._actvFl = true; _globals.Credit[idxLines]._linePosY = _globals.Credit_y + idxLines * _globals.Credit_step; + int idxBuf = 0; - for (;;) { + for(; idxBuf < 49; idxBuf++) { byte curChar = curPtr[idxBuf + 3]; if (curChar == '%' || curChar == 10) break; _globals.Credit[idxLines]._line[idxBuf] = curChar; - idxBuf++; - if (idxBuf >= 49) - break; } _globals.Credit[idxLines]._line[idxBuf] = 0; _globals.Credit[idxLines]._lineSize = idxBuf - 1; diff --git a/engines/hopkins/lines.cpp b/engines/hopkins/lines.cpp index 5b8c930ed2..8637a90449 100644 --- a/engines/hopkins/lines.cpp +++ b/engines/hopkins/lines.cpp @@ -177,16 +177,14 @@ void LinesManager::AJOUTE_LIGNE_ZONE(int idx, int a2, int a3, int a4, int a5, in int v16 = 1000 * a3; int v17 = 1000 * a2 / 1000; int v21 = 1000 * a3 / 1000; - if (v20 > 0) { - for (int i = 0; i < v20; i++) { - *dataP++ = v17; - *dataP++ = v21; - - v13 += v23; - v16 += v22; - v17 = v13 / 1000; - v21 = v16 / 1000; - } + for (int i = 0; i < v20; i++) { + *dataP++ = v17; + *dataP++ = v21; + + v13 += v23; + v16 += v22; + v17 = v13 / 1000; + v21 = v16 / 1000; } *dataP++ = -1; *dataP++ = -1; @@ -201,7 +199,7 @@ void LinesManager::AJOUTE_LIGNE_ZONE(int idx, int a2, int a3, int a4, int a5, in void LinesManager::RESET_OBSTACLE() { - for (int idx =0; idx < 400; ++idx) { + for (int idx = 0; idx < 400; ++idx) { RETIRE_LIGNE(idx); Ligne[idx].field0 = 0; Ligne[idx].lineData = (int16 *)g_PTRNUL; @@ -341,17 +339,15 @@ void LinesManager::AJOUTE_LIGNE(int idx, int a2, int a3, int a4, int a5, int a6, v31 = 1000 * a3 / 1000; v30 = 1000 * a4 / 1000; v35 = v34 - 1; - if (v35 > 0) { - for (int v26 = 0; v26 < v35; v26++) { - v32[0] = v31; - v32[1] = v30; - v32 += 2; + for (int v26 = 0; v26 < v35; v26++) { + v32[0] = v31; + v32[1] = v30; + v32 += 2; - v24 += v40; - v25 += v38; - v31 = v24 / 1000; - v30 = v25 / 1000; - } + v24 += v40; + v25 += v38; + v31 = v24 / 1000; + v30 = v25 / 1000; } v32[0] = a5; v32[1] = a6; @@ -623,23 +619,20 @@ int LinesManager::CONTOURNE(int a1, int a2, int a3, int a4, int a5, int16 *a6, i v8 += a7; } - if ((int)(a1 + 1) < a4) { - for (int v34 = a1 + 1; v34 < a4; v34++) { - if (Ligne[v34].field0 > 0) { - for (int i = 0; i < Ligne[v34].field0; i++) { - int16 *v14 = Ligne[v34].lineData; - int v15 = v14[2 * i]; - v50 = v14[2 * i + 1]; - int v16 = v8; + for (int v34 = a1 + 1; v34 < a4; v34++) { + for (int i = 0; i < Ligne[v34].field0; i++) { + int16 *v14 = Ligne[v34].lineData; + int v15 = v14[2 * i]; + v50 = v14[2 * i + 1]; + int v16 = v8; - a6[v16] = v15; - a6[v16 + 1] = v50; - a6[v16 + 2] = Ligne[v34].field6; - v8 += a7; - } - } + a6[v16] = v15; + a6[v16 + 1] = v50; + a6[v16 + 2] = Ligne[v34].field6; + v8 += a7; } } + v7 = 0; v36 = a4; } @@ -676,18 +669,16 @@ int LinesManager::CONTOURNE(int a1, int a2, int a3, int a4, int a5, int16 *a6, i } if (v36 == a4) { if (a5 >= v7) { - if (a5 > v7) { - for (int i = v7; i > a5; i++) { - int16 *v30 = Ligne[a4].lineData; - int v31 = v30[2 * i]; - v50 = v30[2 * i + 1]; - - int v32 = v8; - a6[v32] = v31; - a6[v32 + 1] = v50; - a6[v32 + 2] = Ligne[a4].field6; - v8 += a7; - } + for (int i = v7; i > a5; i++) { + int16 *v30 = Ligne[a4].lineData; + int v31 = v30[2 * i]; + v50 = v30[2 * i + 1]; + + int v32 = v8; + a6[v32] = v31; + a6[v32 + 1] = v50; + a6[v32 + 2] = Ligne[a4].field6; + v8 += a7; } } else { for (int i = v7; i > a5; --i) { @@ -728,19 +719,17 @@ int LinesManager::CONTOURNE1(int a1, int a2, int a3, int a4, int a5, int16 *a6, if (a1 + 1 == a9 + 1) v15 = a8; while (a4 != v15) { - if (Ligne[v15].field0 > 0) { - for (int v16 = 0; v16 < Ligne[v15].field0; v16++) { - int16 *v17 = Ligne[v15].lineData; - int v18 = v17[2 * v16]; - v50 = v17[2 * v16 + 1]; - - int v19 = v40; - a6[v19] = v18; - a6[v19 + 1] = v50; - a6[v19 + 2] = Ligne[v15].field6; - v40 += a7; + for (int v16 = 0; v16 < Ligne[v15].field0; v16++) { + int16 *v17 = Ligne[v15].lineData; + int v18 = v17[2 * v16]; + v50 = v17[2 * v16 + 1]; + + int v19 = v40; + a6[v19] = v18; + a6[v19 + 1] = v50; + a6[v19 + 2] = Ligne[v15].field6; + v40 += a7; - } } ++v15; if (a9 + 1 == v15) @@ -1021,24 +1010,22 @@ int LinesManager::MIRACLE(int a1, int a2, int a3, int a4, int a5) { v35 = v43; } if (v21 == 1) { - if (v39 > 0) { - for (int v22 = 0; v22 < v39; v22++) { - if (colision2_ligne(v41, v40 - v22, &v47, &v46, _vm->_objectsManager.DERLIGNE + 1, TOTAL_LIGNES) == 1 - && _vm->_objectsManager.DERLIGNE < v46) { - v23 = GENIAL(v46, v47, v41, v40 - v22, v41, v40 - v39, v7, &_vm->_globals.super_parcours[0], 4); - if (v23 == -1) - return 0; - v7 = v23; - if (NVPY != -1) - v22 = NVPY - v40; - } - v24 = v7; - _vm->_globals.super_parcours[v24] = v41; - _vm->_globals.super_parcours[v24 + 1] = v40 - v22; - _vm->_globals.super_parcours[v24 + 2] = 1; - _vm->_globals.super_parcours[v24 + 3] = 0; - v7 += 4; + for (int v22 = 0; v22 < v39; v22++) { + if (colision2_ligne(v41, v40 - v22, &v47, &v46, _vm->_objectsManager.DERLIGNE + 1, TOTAL_LIGNES) == 1 + && _vm->_objectsManager.DERLIGNE < v46) { + v23 = GENIAL(v46, v47, v41, v40 - v22, v41, v40 - v39, v7, &_vm->_globals.super_parcours[0], 4); + if (v23 == -1) + return 0; + v7 = v23; + if (NVPY != -1) + v22 = NVPY - v40; } + v24 = v7; + _vm->_globals.super_parcours[v24] = v41; + _vm->_globals.super_parcours[v24 + 1] = v40 - v22; + _vm->_globals.super_parcours[v24 + 2] = 1; + _vm->_globals.super_parcours[v24 + 3] = 0; + v7 += 4; } LABEL_186: NV_LIGNEDEP = v36; @@ -1047,68 +1034,62 @@ LABEL_186: return 1; } if (v21 == 5) { - if (v37 > 0) { - for (int v25 = 0; v25 < v37; v25++) { - if (colision2_ligne(v41, v25 + v40, &v47, &v46, _vm->_objectsManager.DERLIGNE + 1, TOTAL_LIGNES) == 1 - && _vm->_objectsManager.DERLIGNE < v46) { - v26 = GENIAL(v46, v47, v41, v25 + v40, v41, v37 + v40, v7, &_vm->_globals.super_parcours[0], 4); - if (v26 == -1) - return 0; - v7 = v26; - if (NVPY != -1) - v25 = v40 - NVPY; - } - v27 = v7; - _vm->_globals.super_parcours[v27] = v41; - _vm->_globals.super_parcours[v27 + 1] = v25 + v40; - _vm->_globals.super_parcours[v27 + 2] = 5; - _vm->_globals.super_parcours[v27 + 3] = 0; - v7 += 4; + for (int v25 = 0; v25 < v37; v25++) { + if (colision2_ligne(v41, v25 + v40, &v47, &v46, _vm->_objectsManager.DERLIGNE + 1, TOTAL_LIGNES) == 1 + && _vm->_objectsManager.DERLIGNE < v46) { + v26 = GENIAL(v46, v47, v41, v25 + v40, v41, v37 + v40, v7, &_vm->_globals.super_parcours[0], 4); + if (v26 == -1) + return 0; + v7 = v26; + if (NVPY != -1) + v25 = v40 - NVPY; } + v27 = v7; + _vm->_globals.super_parcours[v27] = v41; + _vm->_globals.super_parcours[v27 + 1] = v25 + v40; + _vm->_globals.super_parcours[v27 + 2] = 5; + _vm->_globals.super_parcours[v27 + 3] = 0; + v7 += 4; } goto LABEL_186; } if (v21 == 7) { - if (v18 > 0) { - for (int v28 = 0; v28 < v18; v28++) { - if (colision2_ligne(v41 - v28, v40, &v47, &v46, _vm->_objectsManager.DERLIGNE + 1, TOTAL_LIGNES) == 1 - && _vm->_objectsManager.DERLIGNE < v46) { - v29 = GENIAL(v46, v47, v41 - v28, v40, v41 - v18, v40, v7, &_vm->_globals.super_parcours[0], 4); - if (v29 == -1) - return 0; - v7 = v29; - if (NVPX != -1) - v28 = v41 - NVPX; - } - v30 = v7; - _vm->_globals.super_parcours[v30] = v41 - v28; - _vm->_globals.super_parcours[v30 + 1] = v40; - _vm->_globals.super_parcours[v30 + 2] = 7; - _vm->_globals.super_parcours[v30 + 3] = 0; - v7 += 4; + for (int v28 = 0; v28 < v18; v28++) { + if (colision2_ligne(v41 - v28, v40, &v47, &v46, _vm->_objectsManager.DERLIGNE + 1, TOTAL_LIGNES) == 1 + && _vm->_objectsManager.DERLIGNE < v46) { + v29 = GENIAL(v46, v47, v41 - v28, v40, v41 - v18, v40, v7, &_vm->_globals.super_parcours[0], 4); + if (v29 == -1) + return 0; + v7 = v29; + if (NVPX != -1) + v28 = v41 - NVPX; } + v30 = v7; + _vm->_globals.super_parcours[v30] = v41 - v28; + _vm->_globals.super_parcours[v30 + 1] = v40; + _vm->_globals.super_parcours[v30 + 2] = 7; + _vm->_globals.super_parcours[v30 + 3] = 0; + v7 += 4; } goto LABEL_186; } if (v21 == 3) { - if (v38 > 0) { - for (int v31 = 0; v31 < v38; v31++) { - if (colision2_ligne(v31 + v41, v40, &v47, &v46, _vm->_objectsManager.DERLIGNE + 1, TOTAL_LIGNES) == 1 - && _vm->_objectsManager.DERLIGNE < v46) { - v32 = GENIAL(v46, v47, v31 + v41, v40, v38 + v41, v40, v7, &_vm->_globals.super_parcours[0], 4); - if (v32 == -1) - return 0; - v7 = v32; - if (NVPX != -1) - v31 = NVPX - v41; - } - v33 = v7; - _vm->_globals.super_parcours[v33] = v31 + v41; - _vm->_globals.super_parcours[v33 + 1] = v40; - _vm->_globals.super_parcours[v33 + 2] = 3; - _vm->_globals.super_parcours[v33 + 3] = 0; - v7 += 4; + for (int v31 = 0; v31 < v38; v31++) { + if (colision2_ligne(v31 + v41, v40, &v47, &v46, _vm->_objectsManager.DERLIGNE + 1, TOTAL_LIGNES) == 1 + && _vm->_objectsManager.DERLIGNE < v46) { + v32 = GENIAL(v46, v47, v31 + v41, v40, v38 + v41, v40, v7, &_vm->_globals.super_parcours[0], 4); + if (v32 == -1) + return 0; + v7 = v32; + if (NVPX != -1) + v31 = NVPX - v41; } + v33 = v7; + _vm->_globals.super_parcours[v33] = v31 + v41; + _vm->_globals.super_parcours[v33 + 1] = v40; + _vm->_globals.super_parcours[v33 + 2] = 3; + _vm->_globals.super_parcours[v33 + 3] = 0; + v7 += 4; } goto LABEL_186; } @@ -1237,21 +1218,19 @@ LABEL_17: int v77 = 0; int v78 = 0; int v79 = 0; - if (v85 + 1 > 0) { - for (int v89 = v85 + 1; v89 > 0; v89--) { - int v96 = _vm->_globals.BufLig[v25]; - int v94 = _vm->_globals.BufLig[v25 + 1]; - if (colision2_ligne(v96, v94, &v101, &v100, v92, v91) == 1 && _vm->_objectsManager.DERLIGNE < v100) { - v80 = v100; - v77 = v101; - v78 = v96; - v79 = v94; - loopCond = true; - } - if (loopCond) - break; - v25 -= 2; - } + for (int v89 = v85 + 1; v89 > 0; v89--) { + int v96 = _vm->_globals.BufLig[v25]; + int v94 = _vm->_globals.BufLig[v25 + 1]; + if (colision2_ligne(v96, v94, &v101, &v100, v92, v91) == 1 && _vm->_objectsManager.DERLIGNE < v100) { + v80 = v100; + v77 = v101; + v78 = v96; + v79 = v94; + loopCond = true; + } + if (loopCond) + break; + v25 -= 2; } int v66 = 0; int v68 = 0; diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp index e3066f5e62..a960796d86 100644 --- a/engines/hopkins/objects.cpp +++ b/engines/hopkins/objects.cpp @@ -323,7 +323,6 @@ void ObjectsManager::displaySprite() { int y1_1; int y1_2; int v25; - int v26; int v27; int x1_1; int x1_2; @@ -410,9 +409,7 @@ void ObjectsManager::displaySprite() { do { v27 = 0; if (v25 > 1) { - v26 = _vm->_globals.NBTRI; - - for (int v34 = 1; v34 < v26; v34++) { + for (int v34 = 1; v34 < _vm->_globals.NBTRI; v34++) { v11 = arr[v34]; v12 = &arr[v34 + 1]; if (_vm->_globals.Tri[arr[v34]]._priority > _vm->_globals.Tri[*v12]._priority) { @@ -424,43 +421,39 @@ void ObjectsManager::displaySprite() { } } while (v27); - if (_vm->_globals.NBTRI + 1 > 1) { - for (int v35 = 1; v35 < _vm->_globals.NBTRI + 1; v35++) { - v13 = arr[v35]; - switch (_vm->_globals.Tri[v13]._triMode) { - case TRI_BOB: - DEF_BOB(_vm->_globals.Tri[v13]._index); - break; - case TRI_SPRITE: - DEF_SPRITE(_vm->_globals.Tri[v13]._index); - break; - case TRI_CACHE: - DEF_CACHE(_vm->_globals.Tri[v13]._index); - break; - default: - break; - } - _vm->_globals.Tri[v13]._triMode = TRI_NONE; + for (int v35 = 1; v35 < _vm->_globals.NBTRI + 1; v35++) { + v13 = arr[v35]; + switch (_vm->_globals.Tri[v13]._triMode) { + case TRI_BOB: + DEF_BOB(_vm->_globals.Tri[v13]._index); + break; + case TRI_SPRITE: + DEF_SPRITE(_vm->_globals.Tri[v13]._index); + break; + case TRI_CACHE: + DEF_CACHE(_vm->_globals.Tri[v13]._index); + break; + default: + break; } + _vm->_globals.Tri[v13]._triMode = TRI_NONE; } } else { - if (_vm->_globals.NBTRI + 1 > 1) { - for (int idx = 1; idx < (_vm->_globals.NBTRI + 1); ++idx) { - switch (_vm->_globals.Tri[idx]._triMode) { - case TRI_BOB: - DEF_BOB(_vm->_globals.Tri[idx]._index); - break; - case TRI_SPRITE: - DEF_SPRITE(_vm->_globals.Tri[idx]._index); - break; - case TRI_CACHE: - DEF_CACHE(_vm->_globals.Tri[idx]._index); - break; - default: - break; - } - _vm->_globals.Tri[idx]._triMode = TRI_NONE; + for (int idx = 1; idx < (_vm->_globals.NBTRI + 1); ++idx) { + switch (_vm->_globals.Tri[idx]._triMode) { + case TRI_BOB: + DEF_BOB(_vm->_globals.Tri[idx]._index); + break; + case TRI_SPRITE: + DEF_SPRITE(_vm->_globals.Tri[idx]._index); + break; + case TRI_CACHE: + DEF_CACHE(_vm->_globals.Tri[idx]._index); + break; + default: + break; } + _vm->_globals.Tri[idx]._triMode = TRI_NONE; } } @@ -3090,11 +3083,9 @@ void ObjectsManager::PACOURS_PROPRE(int16 *a1) { } if (v12 < v10) { v7 = v11; - if (v12 > 0) { - for (int v8 = 0; v8 < v12; v8++) { - a1[v7 + 2] = v14; - v7 += 4; - } + for (int v8 = 0; v8 < v12; v8++) { + a1[v7 + 2] = v14; + v7 += 4; } v15 = v14; } @@ -3413,16 +3404,14 @@ LABEL_88: 0) == 1) goto LABEL_88; - if ((_vm->_linesManager.Ligne[v48].field0 - 2) > 0) { - for (int v49 = _vm->_linesManager.Ligne[v48].field0 - 2; v49 > 0; v49 --) { - v50 = _vm->_linesManager.Ligne[l].lineData; - v52 = v67; - _vm->_globals.super_parcours[v52] = v50[2 * v49]; - _vm->_globals.super_parcours[v52 + 1] = v50[2 * v49 + 1]; - _vm->_globals.super_parcours[v52 + 2] = _vm->_linesManager.Ligne[l].field8; - _vm->_globals.super_parcours[v52 + 3] = 0; - v67 += 4; - } + for (int v49 = _vm->_linesManager.Ligne[v48].field0 - 2; v49 > 0; v49 --) { + v50 = _vm->_linesManager.Ligne[l].lineData; + v52 = v67; + _vm->_globals.super_parcours[v52] = v50[2 * v49]; + _vm->_globals.super_parcours[v52 + 1] = v50[2 * v49 + 1]; + _vm->_globals.super_parcours[v52 + 2] = _vm->_linesManager.Ligne[l].field8; + _vm->_globals.super_parcours[v52 + 3] = 0; + v67 += 4; } } v68 = _vm->_linesManager.Ligne[v73].field0 - 1; @@ -3430,15 +3419,13 @@ LABEL_88: } if (v69 == v73) { if (v68 <= v72) { - if (v68 < v72) { - for (int v57 = v68; v57 < v72; v57++) { - v58 = _vm->_linesManager.Ligne[v73].lineData; - _vm->_globals.super_parcours[v67] = v58[2 * v57]; - _vm->_globals.super_parcours[v67 + 1] = v58[2 * v57 + 1]; - _vm->_globals.super_parcours[v67 + 2] = _vm->_linesManager.Ligne[v73].field6; - _vm->_globals.super_parcours[v67 + 3] = 0; - v67 += 4; - } + for (int v57 = v68; v57 < v72; v57++) { + v58 = _vm->_linesManager.Ligne[v73].lineData; + _vm->_globals.super_parcours[v67] = v58[2 * v57]; + _vm->_globals.super_parcours[v67 + 1] = v58[2 * v57 + 1]; + _vm->_globals.super_parcours[v67 + 2] = _vm->_linesManager.Ligne[v73].field6; + _vm->_globals.super_parcours[v67 + 3] = 0; + v67 += 4; } } else { for (int v53 = v68; v53 > v72; v53--) { @@ -4544,101 +4531,98 @@ void ObjectsManager::INILINK(const Common::String &file) { } _vm->_linesManager.RESET_OBSTACLE(); - if (nbytes) { - for (size_t v41 = 0; v41 < nbytes; v41++) { - if (*(ptr + v41) == 'O' && *(ptr + v41 + 1) == 'B' && *(ptr + v41 + 2) == '2') { - v16 = ptr + v41 + 4; - v32 = 0; - v34 = 0; - _vm->_linesManager.TOTAL_LIGNES = 0; - do { - v27 = (int16)READ_LE_UINT16(v16 + 2 * v32); - if (v27 != -1) { - _vm->_linesManager.AJOUTE_LIGNE( - v34, - v27, - (int16)READ_LE_UINT16(v16 + 2 * v32 + 2), - (int16)READ_LE_UINT16(v16 + 2 * v32 + 4), - (int16)READ_LE_UINT16(v16 + 2 * v32 + 6), - (int16)READ_LE_UINT16(v16 + 2 * v32 + 8), - 1); - ++_vm->_linesManager.TOTAL_LIGNES; - } - v32 += 5; - ++v34; - } while (v27 != -1); - _vm->_linesManager.INIPARCOURS(); - } + for (size_t v41 = 0; v41 < nbytes; v41++) { + if (*(ptr + v41) == 'O' && *(ptr + v41 + 1) == 'B' && *(ptr + v41 + 2) == '2') { + v16 = ptr + v41 + 4; + v32 = 0; + v34 = 0; + _vm->_linesManager.TOTAL_LIGNES = 0; + do { + v27 = (int16)READ_LE_UINT16(v16 + 2 * v32); + if (v27 != -1) { + _vm->_linesManager.AJOUTE_LIGNE( + v34, + v27, + (int16)READ_LE_UINT16(v16 + 2 * v32 + 2), + (int16)READ_LE_UINT16(v16 + 2 * v32 + 4), + (int16)READ_LE_UINT16(v16 + 2 * v32 + 6), + (int16)READ_LE_UINT16(v16 + 2 * v32 + 8), + 1); + ++_vm->_linesManager.TOTAL_LIGNES; + } + v32 += 5; + ++v34; + } while (v27 != -1); + _vm->_linesManager.INIPARCOURS(); } } + if (!OBSSEUL) { - if (nbytes) { - for (size_t v42 = 0; v42 < nbytes; v42++) { - if (*(ptr + v42) == 'Z' && *(ptr + v42 + 1) == 'O' && *(ptr + v42 + 2) == '2') { - v17 = ptr + v42 + 4; - v33 = 0; - v35 = 0; - for (int v18 = 1; v18 <= 100; v18++) { - _vm->_globals.ZONEP[v18]._destX = 0; - _vm->_globals.ZONEP[v18]._destY = 0; - _vm->_globals.ZONEP[v18].field4 = 0; - _vm->_globals.ZONEP[v18].field6 = 0; - _vm->_globals.ZONEP[v18].field7 = 0; - _vm->_globals.ZONEP[v18].field8 = 0; - _vm->_globals.ZONEP[v18].field9 = 0; - _vm->_globals.ZONEP[v18].fieldA = 0; - _vm->_globals.ZONEP[v18].fieldB = 0; - _vm->_globals.ZONEP[v18].fieldC = 0; - _vm->_globals.ZONEP[v18].fieldD = 0; - _vm->_globals.ZONEP[v18].fieldE = 0; - _vm->_globals.ZONEP[v18].fieldF = 0; - _vm->_globals.ZONEP[v18].field12 = 0; - } + for (size_t v42 = 0; v42 < nbytes; v42++) { + if (*(ptr + v42) == 'Z' && *(ptr + v42 + 1) == 'O' && *(ptr + v42 + 2) == '2') { + v17 = ptr + v42 + 4; + v33 = 0; + v35 = 0; + for (int v18 = 1; v18 <= 100; v18++) { + _vm->_globals.ZONEP[v18]._destX = 0; + _vm->_globals.ZONEP[v18]._destY = 0; + _vm->_globals.ZONEP[v18].field4 = 0; + _vm->_globals.ZONEP[v18].field6 = 0; + _vm->_globals.ZONEP[v18].field7 = 0; + _vm->_globals.ZONEP[v18].field8 = 0; + _vm->_globals.ZONEP[v18].field9 = 0; + _vm->_globals.ZONEP[v18].fieldA = 0; + _vm->_globals.ZONEP[v18].fieldB = 0; + _vm->_globals.ZONEP[v18].fieldC = 0; + _vm->_globals.ZONEP[v18].fieldD = 0; + _vm->_globals.ZONEP[v18].fieldE = 0; + _vm->_globals.ZONEP[v18].fieldF = 0; + _vm->_globals.ZONEP[v18].field12 = 0; + } - v31 = 0; - do { - v28 = (int16)READ_LE_UINT16(v17 + 2 * v33); - if (v28 != -1) { - _vm->_linesManager.AJOUTE_LIGNE_ZONE( - v35, - (int16)READ_LE_UINT16(v17 + 2 * v33 + 2), - (int16)READ_LE_UINT16(v17 + 2 * v33 + 4), - (int16)READ_LE_UINT16(v17 + 2 * v33 + 6), - (int16)READ_LE_UINT16(v17 + 2 * v33 + 8), - v28); - _vm->_globals.ZONEP[v28].field10 = 1; - } - v33 += 5; - ++v35; - ++v31; - } while (v28 != -1); - for (int v21 = 1; v21 <= 100; v21++) { - _vm->_globals.ZONEP[v21]._destX = (int16)READ_LE_UINT16(v17 + 2 * v33); - _vm->_globals.ZONEP[v21]._destY = (int16)READ_LE_UINT16(v17 + 2 * v33 + 2); - _vm->_globals.ZONEP[v21].field4 = (int16)READ_LE_UINT16(v17 + 2 * v33 + 4); - v33 += 3; + v31 = 0; + do { + v28 = (int16)READ_LE_UINT16(v17 + 2 * v33); + if (v28 != -1) { + _vm->_linesManager.AJOUTE_LIGNE_ZONE( + v35, + (int16)READ_LE_UINT16(v17 + 2 * v33 + 2), + (int16)READ_LE_UINT16(v17 + 2 * v33 + 4), + (int16)READ_LE_UINT16(v17 + 2 * v33 + 6), + (int16)READ_LE_UINT16(v17 + 2 * v33 + 8), + v28); + _vm->_globals.ZONEP[v28].field10 = 1; } + v33 += 5; + ++v35; + ++v31; + } while (v28 != -1); + for (int v21 = 1; v21 <= 100; v21++) { + _vm->_globals.ZONEP[v21]._destX = (int16)READ_LE_UINT16(v17 + 2 * v33); + _vm->_globals.ZONEP[v21]._destY = (int16)READ_LE_UINT16(v17 + 2 * v33 + 2); + _vm->_globals.ZONEP[v21].field4 = (int16)READ_LE_UINT16(v17 + 2 * v33 + 4); + v33 += 3; + } - v22 = ptr + v42 + (10 * v31 + 606) + 4; - v29 = 0; - for (int v24 = 1; v24 <= 100; v24++) { - _vm->_globals.ZONEP[v24].field6 = *(v29 + v22); - _vm->_globals.ZONEP[v24].field7 = *(v22 + v29 + 1); - _vm->_globals.ZONEP[v24].field8 = *(v22 + v29 + 2); - _vm->_globals.ZONEP[v24].field9 = *(v22 + v29 + 3); - _vm->_globals.ZONEP[v24].fieldA = *(v22 + v29 + 4); - _vm->_globals.ZONEP[v24].fieldB = *(v22 + v29 + 5); - _vm->_globals.ZONEP[v24].fieldC = *(v22 + v29 + 6); - _vm->_globals.ZONEP[v24].fieldD = *(v22 + v29 + 7); - _vm->_globals.ZONEP[v24].fieldE = *(v22 + v29 + 8); - _vm->_globals.ZONEP[v24].fieldF = *(v22 + v29 + 9); - v29 += 10; - } - v30 = 0; - for (int v25 = 1; v25 <= 100; v25++) - _vm->_globals.ZONEP[v25].field12 = (int16)READ_LE_UINT16(v22 + 1010 + 2 * v30++); - CARRE_ZONE(); + v22 = ptr + v42 + (10 * v31 + 606) + 4; + v29 = 0; + for (int v24 = 1; v24 <= 100; v24++) { + _vm->_globals.ZONEP[v24].field6 = *(v29 + v22); + _vm->_globals.ZONEP[v24].field7 = *(v22 + v29 + 1); + _vm->_globals.ZONEP[v24].field8 = *(v22 + v29 + 2); + _vm->_globals.ZONEP[v24].field9 = *(v22 + v29 + 3); + _vm->_globals.ZONEP[v24].fieldA = *(v22 + v29 + 4); + _vm->_globals.ZONEP[v24].fieldB = *(v22 + v29 + 5); + _vm->_globals.ZONEP[v24].fieldC = *(v22 + v29 + 6); + _vm->_globals.ZONEP[v24].fieldD = *(v22 + v29 + 7); + _vm->_globals.ZONEP[v24].fieldE = *(v22 + v29 + 8); + _vm->_globals.ZONEP[v24].fieldF = *(v22 + v29 + 9); + v29 += 10; } + v30 = 0; + for (int v25 = 1; v25 <= 100; v25++) + _vm->_globals.ZONEP[v25].field12 = (int16)READ_LE_UINT16(v22 + 1010 + 2 * v30++); + CARRE_ZONE(); } } } @@ -5022,10 +5006,8 @@ void ObjectsManager::ACTION(const byte *spriteData, const Common::String &a2, in _sprite[0]._spriteData = spriteData; _sprite[0]._spriteIndex = v13; } - if (v15 > 0) { - for (int v10 = 0; v10 < v15; v10++) - _vm->_eventsManager.VBL(); - } + for (int v10 = 0; v10 < v15; v10++) + _vm->_eventsManager.VBL(); if (v13 == -1) break; } @@ -5080,10 +5062,8 @@ void ObjectsManager::SPACTION(byte *a1, const Common::String &animationSeq, int _sprite[0]._spriteData = a1; _sprite[0]._spriteIndex = spriteIndex; } - if (v14 > 0) { - for (int v10 = 0; v10 < v14; v10++) - _vm->_eventsManager.VBL(); - } + for (int v10 = 0; v10 < v14; v10++) + _vm->_eventsManager.VBL(); } while (spriteIndex != -1); } diff --git a/engines/hopkins/script.cpp b/engines/hopkins/script.cpp index e3fc59a990..818610c892 100644 --- a/engines/hopkins/script.cpp +++ b/engines/hopkins/script.cpp @@ -480,13 +480,11 @@ LABEL_1141: uint v74 = READ_LE_UINT16(a1 + 5) / _vm->_globals._speed; if (!v74) v74 = 1; - if (v74 + 1 > 0) { - for (uint v10 = 0; v10 < v74 + 1; v10++) { - if (_vm->shouldQuit()) - return -1; // Exiting game + for (uint v10 = 0; v10 < v74 + 1; v10++) { + if (_vm->shouldQuit()) + return -1; // Exiting game - _vm->_eventsManager.VBL(); - } + _vm->_eventsManager.VBL(); } v1 = 1; } |