From 81d8ec5a74c784b4cd6c9cf9d9ffdefc6d6f8db4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 27 Nov 2012 22:33:51 +0100 Subject: HOPKINS: Rework SCBOB(), silent some CppCheck warnings --- engines/hopkins/font.cpp | 30 ++++----- engines/hopkins/objects.cpp | 148 +++++++++++++++++--------------------------- engines/hopkins/script.cpp | 40 +++++------- engines/hopkins/talk.cpp | 10 ++- 4 files changed, 86 insertions(+), 142 deletions(-) (limited to 'engines') diff --git a/engines/hopkins/font.cpp b/engines/hopkins/font.cpp index df9aa94458..414d88e399 100644 --- a/engines/hopkins/font.cpp +++ b/engines/hopkins/font.cpp @@ -111,7 +111,6 @@ void FontManager::BOITE(int idx, int messageId, const Common::String &filename, byte *v9; byte *ptre; Common::String s; - byte *v59; Common::String file; Common::File f; @@ -122,7 +121,6 @@ void FontManager::BOITE(int idx, int messageId, const Common::String &filename, _vm->_globals.police_l = 11; _vm->_globals.largeur_boite = 11 * Txt[idx].field3FE; - int lineCount = 0; if (Txt[idx].textLoaded) { int v34 = Txt[idx].field3FC; if (v34 != 6 && v34 != 1 && v34 != 3 && v34 != 5) { @@ -146,6 +144,7 @@ void FontManager::BOITE(int idx, int messageId, const Common::String &filename, _vm->_graphicsManager.Ajoute_Segment_Vesa(xp, yp, xp + v37, yp + v36); } } else { + int lineCount = 0; int v62 = 0; do { TRIER_TEXT[v62++] = 0; @@ -195,13 +194,11 @@ void FontManager::BOITE(int idx, int messageId, const Common::String &filename, v11 = 0; WRITE_LE_UINT16((uint16 *)v9 + 48, (int16)READ_LE_UINT16(v10 + 96)); } - v59 = texte_tmp; - int v63 = 0; - int v64 = 0; + byte *v59 = texte_tmp; byte *v60; if (!v69) goto LABEL_43; - do { + for (int v63 = 0; v63 < v69; v63++) { byte v13 = *v59; if ((byte)(*v59 + 46) > 0x1Bu) { if ((byte)(v13 + 80) > 0x1Bu) { @@ -214,12 +211,12 @@ void FontManager::BOITE(int idx, int messageId, const Common::String &filename, v13 += 111; } *v59 = v13; - v59 = v59 + 1; - ++v63; - } while (v63 < v69); + v59++; + }; v60 = texte_tmp; if (v69) { + int v64 = 0; while (1) { byte v14 = *(v60 + v64); if (v14 == '\r' || v14 == '\n') { @@ -234,16 +231,13 @@ void FontManager::BOITE(int idx, int messageId, const Common::String &filename, Txt[idx].field3FE = v64; _vm->_globals.largeur_boite = 0; - int v15 = 0; - byte v16; if (v64 + 1 > 0) { - do { - v16 = *(v60 + v15); + for (int v15 = 0; v15 < v64 + 1; v15++) { + byte v16 = *(v60 + v15); if ((byte)v16 <= 0x1Fu) v16 = 32; _vm->_globals.largeur_boite += _vm->_objectsManager.Get_Largeur(_vm->_globals.police, (byte)v16 - 32); - ++v15; - } while (v15 < v64 + 1); + } } _vm->_globals.largeur_boite += 2; int v17 = _vm->_globals.largeur_boite / 2; @@ -309,16 +303,14 @@ LABEL_57: TRIER_TEXT[i] = 0; } else { int ptrc = 0; - int v23 = 0; if (v22 - 1 > 0) { - do { + for (int v23 = 0; v23 < TRIER_TEXT[i] - 1; v23++) { Common::String &line = Txt[idx].lines[i]; byte v24 = (v23 >= (int)line.size()) ? '\0' : line.c_str()[v23]; if ((byte)v24 <= 0x1Fu) v24 = 32; ptrc += _vm->_objectsManager.Get_Largeur(_vm->_globals.police, (byte)v24 - 32); - ++v23; - } while (v23 < TRIER_TEXT[i] - 1); + } } TRIER_TEXT[i] = ptrc; } diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp index dcb3a40b27..767decdded 100644 --- a/engines/hopkins/objects.cpp +++ b/engines/hopkins/objects.cpp @@ -719,106 +719,75 @@ void ObjectsManager::BOB_OFFSETY(int idx, int v) { } void ObjectsManager::SCBOB(int idx) { + if (_vm->_globals.Cache[idx].fieldA <= 0) + return; + int v1 = idx; - if (_vm->_globals.Cache[idx].fieldA > 0) { - int v8 = 0; - do { - v1 = v8; - if (_vm->_globals.Bob[v1].field0) { - if (!_vm->_globals.Bob[v8].field16) { - if (!_vm->_globals.Bob[v8].field34) { - if ( _vm->_globals.Bob[v8].frameIndex != 250) { - int v2 = _vm->_globals.Bob[v8].oldWidth; - int v9 = _vm->_globals.Bob[v8].oldX + _vm->_globals.Bob[v8].oldWidth; - int v6 = _vm->_globals.Bob[v8].oldY + _vm->_globals.Bob[v8].oldHeight; - int v3 =_vm->_globals.Cache[idx].field0; - int v4 =_vm->_globals.Cache[idx].field4; - int v7 =_vm->_globals.Cache[idx].field6 + v3; - int v1 =_vm->_globals.Cache[idx].field14 +_vm->_globals.Cache[idx].field8 + v4; - - if (v6 > v4) { - if (v6 < v1) { - v1 = 0; - if (v9 >= v3 && v9 <= (_vm->_globals.Cache[idx].field6 + v3)) { - ++_vm->_globals.Cache[idx].fieldA; - v1 = 1; - } - - if (!(uint16)v1) { - if (v2 >= v3 && v7 >= v2) { - ++_vm->_globals.Cache[idx].fieldA; - v1 = 1; - } - if (!(uint16)v1) { - if ( v7 >= v2 && v2 >= v3 ) { - ++_vm->_globals.Cache[idx].fieldA; - v1 = 1; - } - if (!(uint16)v1) { - if (v2 >= v3 && v9 <= v7) { - ++_vm->_globals.Cache[idx].fieldA; - v1 = 1; - } - if (!(uint16)v1 && v2 <= v3 && v9 >= v7) - ++_vm->_globals.Cache[idx].fieldA; - } - } - } - } - } - } + for (int v8 = 0; v8 <= 20; v8++) { + v1 = v8; + if ((_vm->_globals.Bob[v1].field0) && (!_vm->_globals.Bob[v8].field16) && (!_vm->_globals.Bob[v8].field34) && (_vm->_globals.Bob[v8].frameIndex != 250)) { + int v2 = _vm->_globals.Bob[v8].oldWidth; + int v9 = _vm->_globals.Bob[v8].oldX + _vm->_globals.Bob[v8].oldWidth; + int v6 = _vm->_globals.Bob[v8].oldY + _vm->_globals.Bob[v8].oldHeight; + int v3 =_vm->_globals.Cache[idx].field0; + int v4 =_vm->_globals.Cache[idx].field4; + int v7 =_vm->_globals.Cache[idx].field6 + v3; + int v1 =_vm->_globals.Cache[idx].field14 +_vm->_globals.Cache[idx].field8 + v4; + + if ((v6 > v4) && (v6 < v1)) { + v1 = 0; + if (v9 >= v3 && v9 <= (_vm->_globals.Cache[idx].field6 + v3)) { + ++_vm->_globals.Cache[idx].fieldA; + v1 = 1; + } + if (!(uint16)v1) { + if (v2 >= v3 && v7 >= v2) { + ++_vm->_globals.Cache[idx].fieldA; + v1 = 1; } } + if (!(uint16)v1) { + if ( v7 >= v2 && v2 >= v3 ) { + ++_vm->_globals.Cache[idx].fieldA; + v1 = 1; + } + } + if (!(uint16)v1) { + if (v2 >= v3 && v9 <= v7) { + ++_vm->_globals.Cache[idx].fieldA; + v1 = 1; + } + } + if (!(uint16)v1 && v2 <= v3 && v9 >= v7) + ++_vm->_globals.Cache[idx].fieldA; } - ++v8; - } while (v8 <= 20); + } } } void ObjectsManager::CALCUL_BOB(int idx) { - int result; - int v3; - int v4; - int v5; - int v6; - int v7; - int v8; - int v9; - int v10; - int v11; - int v13; - int v14; - int v15; - int v17; - int v20; - int v21; - int v22; - _vm->_globals.Bob[idx].isActive = false; if (_vm->_globals.Bob[idx].isSprite) { _vm->_globals.Bob[idx].field38 = 0; _vm->_globals.Bob[idx].field36 = 0; } - result = _vm->_globals.Bob[idx].frameIndex; + int result = _vm->_globals.Bob[idx].frameIndex; if (result != 250) { + int v5, v15, v22; if (_vm->_globals.Bob[idx].field38) { - v4 = get_offsetx(_vm->_globals.Bob[idx].spriteData, result, 1); - v22 = v4; - v15 = v4; + v22 = v15 = get_offsetx(_vm->_globals.Bob[idx].spriteData, result, 1); v5 = get_offsety(_vm->_globals.Bob[idx].spriteData, _vm->_globals.Bob[idx].frameIndex, 1); } else { - v3 = get_offsetx(_vm->_globals.Bob[idx].spriteData, result, 0); - v22 = v3; - v15 = v3; + v22 = v15 = get_offsetx(_vm->_globals.Bob[idx].spriteData, result, 0); v5 = get_offsety(_vm->_globals.Bob[idx].spriteData, _vm->_globals.Bob[idx].frameIndex, 0); } - v17 = v5; - v6 = v5; - v21 = 0; - v20 = 0; - v7 = _vm->_globals.Bob[idx].field36; + int v17 = v5; + int v6 = v5; + int v21 = 0; + int v20 = 0; + int v7 = _vm->_globals.Bob[idx].field36; if (v7 < 0) { v7 = -v7; @@ -832,16 +801,14 @@ void ObjectsManager::CALCUL_BOB(int idx) { if (v15 >= 0) { v22 = _vm->_graphicsManager.Reel_Zoom(v15, v21); } else { - v8 = v15; if (v15 < 0) - v8 = -v15; - v15 = v8; - v22 = -_vm->_graphicsManager.Reel_Zoom(v8, v21); + v15 = -v15; + v22 = -_vm->_graphicsManager.Reel_Zoom(v15, v21); } if (v6 >= 0) { v17 = _vm->_graphicsManager.Reel_Zoom(v6, v21); } else { - v9 = v15; + int v9 = v15; if (v15 < 0) v9 = -v15; v6 = v9; @@ -853,24 +820,21 @@ void ObjectsManager::CALCUL_BOB(int idx) { if (v15 >= 0) { v22 = _vm->_graphicsManager.Reel_Reduc(v15, v20); } else { - v10 = v15; - if (v15 < 0) - v10 = -v15; - v15 = v10; - v22 = -_vm->_graphicsManager.Reel_Reduc(v10, v20); + v15 = -v15; + v22 = -_vm->_graphicsManager.Reel_Reduc(v15, v20); } if (v6 >= 0) { v17 = _vm->_graphicsManager.Reel_Reduc(v6, v20); } else { - v11 = v15; + int v11 = v15; if (v15 < 0) v11 = -v15; v17 = -_vm->_graphicsManager.Reel_Reduc(v11, v20); } } - v13 = _vm->_globals.Bob[idx].xp - v22; - v14 = _vm->_globals.Bob[idx].yp - v17; + int v13 = _vm->_globals.Bob[idx].xp - v22; + int v14 = _vm->_globals.Bob[idx].yp - v17; _vm->_globals.Bob[idx].isActive = true; _vm->_globals.Bob[idx].oldX = v13; _vm->_globals.Bob[idx].oldY = v14; diff --git a/engines/hopkins/script.cpp b/engines/hopkins/script.cpp index a0b17c13ed..9955b77aca 100644 --- a/engines/hopkins/script.cpp +++ b/engines/hopkins/script.cpp @@ -43,14 +43,6 @@ void ScriptManager::setParent(HopkinsEngine *vm) { } int ScriptManager::Traduction(byte *a1) { - char v47; - char v48; - char v49; - int v50; - CharacterLocation *v51; - CharacterLocation *v53; - Common::String file; - int v1 = 0; int v70 = 0; if (*a1 != 'F' || *(a1 + 1) != 'C') @@ -494,15 +486,13 @@ LABEL_1141: int v74 = (int16)READ_LE_UINT16(a1 + 5) / _vm->_globals.vitesse; if (!v74) v74 = 1; - int v10 = 0; if (v74 + 1 > 0) { - do { + for (int v10 = 0; v10 < v74 + 1; v10++) { if (_vm->shouldQuit()) return -1; // Exiting game _vm->_eventsManager.VBL(); - ++v10; - } while (v10 < v74 + 1); + } } v1 = 1; } @@ -1812,7 +1802,7 @@ LABEL_1141: if (v76 == 40) _vm->_talkManager.PARLER_PERSO("MAGE.pe2"); if (v76 == 236) { - v47 = _vm->_globals.SAUVEGARDE->data[svField341]; + char v47 = _vm->_globals.SAUVEGARDE->data[svField341]; if (v47) { if (v47 == 2) v70 = 5; @@ -1840,7 +1830,7 @@ LABEL_1141: _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 27, 117, 1); } if (v76 == 237) { - v48 = _vm->_globals.SAUVEGARDE->data[svField341]; + char v48 = _vm->_globals.SAUVEGARDE->data[svField341]; if (v48) { if (v48 == 2) v70 = 5; @@ -1868,7 +1858,7 @@ LABEL_1141: _vm->_graphicsManager.AFFICHE_SPEED(_vm->_globals.SPRITE_ECRAN, 145, 166, 3); } if (v76 == 238) { - v49 = _vm->_globals.SAUVEGARDE->data[svField341]; + char v49 = _vm->_globals.SAUVEGARDE->data[svField341]; if (v49) { if (v49 == 2) v70 = 5; @@ -1902,24 +1892,24 @@ LABEL_1141: } if (v76 == 240) { _vm->_objectsManager.BOBANIM_ON(1); - v50 = 0; + bool soundFlag = false; do { if (_vm->shouldQuit()) return -1; // Exiting game _vm->_eventsManager.VBL(); - if (_vm->_objectsManager.BOBPOSI(1) == 12 && !v50) { + if (_vm->_objectsManager.BOBPOSI(1) == 12 && !soundFlag) { _vm->_soundManager.PLAY_SOUND("SOUND86.WAV"); - v50 = 1; + soundFlag = true; } if (_vm->_objectsManager.BOBPOSI(1) == 13) - v50 = 0; - if (_vm->_objectsManager.BOBPOSI(1) == 25 && !v50) { + soundFlag = false; + if (_vm->_objectsManager.BOBPOSI(1) == 25 && !soundFlag) { _vm->_soundManager.PLAY_SOUND("SOUND85.WAV"); - v50 = 1; + soundFlag = true; } if (_vm->_objectsManager.BOBPOSI(1) == 25) - v50 = 0; + soundFlag = false; } while (_vm->_objectsManager.BOBPOSI(1) != 32); _vm->_objectsManager.BOBANIM_OFF(1); _vm->_objectsManager.BOBANIM_ON(2); @@ -1936,7 +1926,7 @@ LABEL_1141: _vm->_eventsManager.VBL(); } - v51 = &_vm->_globals.SAUVEGARDE->realHopkins; + CharacterLocation *v51 = &_vm->_globals.SAUVEGARDE->realHopkins; v51->xp = _vm->_objectsManager.XSPR(0); v51->yp = _vm->_objectsManager.YSPR(0); v51->field2 = 57; @@ -2164,7 +2154,7 @@ LABEL_1141: _vm->_animationManager.NO_SEQ = true; _vm->_animationManager.PLAY_SEQ("RESUF.SEQ", 1, 24, 1); _vm->_animationManager.NO_SEQ = false; - v53 = &_vm->_globals.SAUVEGARDE->samantha; + CharacterLocation *v53 = &_vm->_globals.SAUVEGARDE->samantha; v53->xp = 404; v53->yp = 395; v53->field2 = 64; @@ -2303,7 +2293,7 @@ LABEL_1141: if (*(a1 + 2) == 'S' && *(a1 + 3) == 'O' && *(a1 + 4) == 'U') { int v60 = (int16)READ_LE_UINT16(a1 + 5); - file = Common::String::format("SOUND%d.WAV", v60); + Common::String file = Common::String::format("SOUND%d.WAV", v60); _vm->_soundManager.PLAY_SOUND(file); v1 = 1; } diff --git a/engines/hopkins/talk.cpp b/engines/hopkins/talk.cpp index 20bf11b13c..9642ed1ec1 100644 --- a/engines/hopkins/talk.cpp +++ b/engines/hopkins/talk.cpp @@ -196,7 +196,6 @@ void TalkManager::PARLER_PERSO(const Common::String &filename) { } void TalkManager::PARLER_PERSO2(const Common::String &filename) { - int v9 = 0; _vm->_objectsManager.DESACTIVE_CURSOR = 1; STATI = 1; byte v7 = _vm->_dialogsManager.DESACTIVE_INVENT; @@ -244,11 +243,10 @@ void TalkManager::PARLER_PERSO2(const Common::String &filename) { int v3; do { v3 = DIALOGUE(); - if (v3 != v2) - v9 = DIALOGUE_REP(v3); - - if (v9 == -1) - v3 = v1 + 3; + if (v3 != v2) { + if (DIALOGUE_REP(v3) == -1) + v3 = v1 + 3; + } } while (v3 != v2); } -- cgit v1.2.3