diff options
author | Strangerke | 2013-01-12 15:19:46 +0100 |
---|---|---|
committer | Strangerke | 2013-01-12 15:19:46 +0100 |
commit | 558506af549f763f5743bad1359f7b16255c42f9 (patch) | |
tree | 9203f0a1287551e2345f3ea1306a5313459975c1 | |
parent | 212a2cb0f8e54f9fae171621e36119a9f80706e1 (diff) | |
download | scummvm-rg350-558506af549f763f5743bad1359f7b16255c42f9.tar.gz scummvm-rg350-558506af549f763f5743bad1359f7b16255c42f9.tar.bz2 scummvm-rg350-558506af549f763f5743bad1359f7b16255c42f9.zip |
HOPKINS: Some refactoring in DialogManager and AnimationManager
-rw-r--r-- | engines/hopkins/anim.cpp | 113 | ||||
-rw-r--r-- | engines/hopkins/dialogs.cpp | 54 | ||||
-rw-r--r-- | engines/hopkins/globals.cpp | 1 | ||||
-rw-r--r-- | engines/hopkins/globals.h | 1 |
4 files changed, 79 insertions, 90 deletions
diff --git a/engines/hopkins/anim.cpp b/engines/hopkins/anim.cpp index 780fdd9eca..25c6913a72 100644 --- a/engines/hopkins/anim.cpp +++ b/engines/hopkins/anim.cpp @@ -462,7 +462,7 @@ LABEL_114: * Load Animation */ void AnimationManager::loadAnim(const Common::String &animName) { - byte v20[15]; + char dummyBuf[15]; char header[10]; char filename1[15]; char filename2[15]; @@ -481,7 +481,7 @@ void AnimationManager::loadAnim(const Common::String &animName) { int filesize = f.size(); int nbytes = filesize - 115; f.read(header, 10); - f.read(v20, 15); + f.read(dummyBuf, 15); f.read(filename1, 15); f.read(filename2, 15); f.read(filename3, 15); @@ -490,7 +490,7 @@ void AnimationManager::loadAnim(const Common::String &animName) { f.read(filename6, 15); if (header[0] != 'A' || header[1] != 'N' || header[2] != 'I' || header[3] != 'S') - error("File incompatible with this soft."); + error("Invalid animation File: %s", filename.c_str()); const char *files[6] = { &filename1[0], &filename2[0], &filename3[0], &filename4[0], &filename5[0], &filename6[0] }; @@ -498,9 +498,9 @@ void AnimationManager::loadAnim(const Common::String &animName) { for (int idx = 0; idx <= 5; ++idx) { if (files[idx][0]) { if (!f.exists(files[idx])) - error("File not found"); + error("Missing file %s in animation File: %s", files[idx], filename.c_str()); if (loadSpriteBank(idx + 1, files[idx])) - error("File not compatible with this soft."); + error("Invalid sprite bank in animation File: %s", filename.c_str()); } } @@ -528,7 +528,6 @@ void AnimationManager::clearAnim() { _vm->_globals.Bank[idx]._loadedFl = false; _vm->_globals.Bank[idx]._filename = ""; _vm->_globals.Bank[idx]._fileHeader = 0; - _vm->_globals.Bank[idx].field1C = 0; } } @@ -539,7 +538,6 @@ int AnimationManager::loadSpriteBank(int idx, const Common::String &filename) { byte *v13; byte *v19; int result = 0; - _vm->_globals.Bank[idx].field1C = _vm->_fileManager.fileSize(filename); _vm->_globals.Bank[idx]._loadedFl = true; _vm->_globals.Bank[idx]._filename = filename; @@ -551,63 +549,60 @@ int AnimationManager::loadSpriteBank(int idx, const Common::String &filename) { else if (fileDataPtr[1] == 'O' && fileDataPtr[2] == 'R') _vm->_globals.Bank[idx]._fileHeader = 2; - if (_vm->_globals.Bank[idx]._fileHeader) { - _vm->_globals.Bank[idx]._data = fileDataPtr; - - bool loopCond = false; - int v8 = 0; - int width; - int height; - do { - width = _vm->_objectsManager.getWidth(fileDataPtr, v8); - height = _vm->_objectsManager.getHeight(fileDataPtr, v8); - if (!width && !height) - loopCond = true; - else - ++v8; - if (v8 > 249) - loopCond = true; - } while (!loopCond); + if (!_vm->_globals.Bank[idx]._fileHeader) { + _vm->_globals.freeMemory(fileDataPtr); + _vm->_globals.Bank[idx]._loadedFl = false; + result = -1; + } + + _vm->_globals.Bank[idx]._data = fileDataPtr; + + int v8 = 0; + int width; + int height; + for(;;) { + width = _vm->_objectsManager.getWidth(fileDataPtr, v8); + height = _vm->_objectsManager.getHeight(fileDataPtr, v8); + if (!width && !height) + break; - if (v8 <= 249) { - _vm->_globals.Bank[idx].field1A = v8; + ++v8; + if (v8 > 249) + break; + } - Common::String ofsFilename = _vm->_globals.Bank[idx]._filename; - char ch; - do { - ch = ofsFilename.lastChar(); - ofsFilename.deleteLastChar(); - } while (ch != '.'); - ofsFilename += ".OFS"; - - Common::File f; - if (f.exists(ofsFilename)) { - v19 = _vm->_fileManager.loadFile(ofsFilename); - v13 = v19; - 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.setOffsetXY(_vm->_globals.Bank[idx]._data, objIdx, x1, y1, 0); - if (_vm->_globals.Bank[idx]._fileHeader == 2) - _vm->_objectsManager.setOffsetXY(_vm->_globals.Bank[idx]._data, objIdx, x2, y2, 1); - } + if (v8 > 249) { + _vm->_globals.freeMemory(fileDataPtr); + _vm->_globals.Bank[idx]._loadedFl = false; + result = -2; + } + _vm->_globals.Bank[idx].field1A = v8; - _vm->_globals.freeMemory(v19); - } + Common::String ofsFilename = _vm->_globals.Bank[idx]._filename; + char ch; + do { + ch = ofsFilename.lastChar(); + ofsFilename.deleteLastChar(); + } while (ch != '.'); + ofsFilename += ".OFS"; - result = 0; - } else { - _vm->_globals.freeMemory(fileDataPtr); - _vm->_globals.Bank[idx]._loadedFl = false; - result = -2; + Common::File f; + if (f.exists(ofsFilename)) { + v19 = _vm->_fileManager.loadFile(ofsFilename); + v13 = v19; + 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.setOffsetXY(_vm->_globals.Bank[idx]._data, objIdx, x1, y1, 0); + if (_vm->_globals.Bank[idx]._fileHeader == 2) + _vm->_objectsManager.setOffsetXY(_vm->_globals.Bank[idx]._data, objIdx, x2, y2, 1); } - } else { - _vm->_globals.freeMemory(fileDataPtr); - _vm->_globals.Bank[idx]._loadedFl = false; - result = -1; + + _vm->_globals.freeMemory(v19); + result = 0; } return result; diff --git a/engines/hopkins/dialogs.cpp b/engines/hopkins/dialogs.cpp index 9c7347f5f7..489ce0f625 100644 --- a/engines/hopkins/dialogs.cpp +++ b/engines/hopkins/dialogs.cpp @@ -363,7 +363,6 @@ LABEL_7: } _vm->_graphicsManager.Capture_Mem(_vm->_graphicsManager._vesaBuffer, _vm->_dialogsManager._inventWin1, _inventX, _inventY, _inventWidth, _inventHeight); _vm->_eventsManager._curMouseButton = 0; - bool v20 = false; int newInventoryItem = 0; // Main loop to select an inventory item @@ -390,38 +389,35 @@ LABEL_7: break; _vm->_objectsManager.takeInventoryObject(_vm->_globals._inventory[newInventoryItem]); if (_vm->_eventsManager._mouseCursorId == 8) - v20 = true; - if (!v20) { - _vm->_scriptManager.TRAVAILOBJET = true; - _vm->_globals._saveData->data[svField3] = _vm->_globals._curObjectIndex; - _vm->_globals._saveData->data[svField8] = _vm->_globals._inventory[newInventoryItem]; - _vm->_globals._saveData->data[svField9] = _vm->_eventsManager._mouseCursorId; - _vm->_objectsManager.OPTI_OBJET(); - _vm->_scriptManager.TRAVAILOBJET = false; - - if (_vm->_soundManager._voiceOffFl) { - do - _vm->_eventsManager.VBL(); - while (!_vm->_globals._exitId && _vm->_eventsManager.getMouseButton() != 1); - _vm->_fontManager.hideText(9); - } - if (_vm->_globals._exitId) { - if (_vm->_globals._exitId == 2) - v20 = true; + break; + + _vm->_scriptManager.TRAVAILOBJET = true; + _vm->_globals._saveData->data[svField3] = _vm->_globals._curObjectIndex; + _vm->_globals._saveData->data[svField8] = _vm->_globals._inventory[newInventoryItem]; + _vm->_globals._saveData->data[svField9] = _vm->_eventsManager._mouseCursorId; + _vm->_objectsManager.OPTI_OBJET(); + _vm->_scriptManager.TRAVAILOBJET = false; + + if (_vm->_soundManager._voiceOffFl) { + do + _vm->_eventsManager.VBL(); + while (!_vm->_globals._exitId && _vm->_eventsManager.getMouseButton() != 1); + _vm->_fontManager.hideText(9); + } + if (_vm->_globals._exitId) { + if (_vm->_globals._exitId == 2) { _vm->_globals._exitId = 0; - if (!v20) { - _inventBuf2 = _vm->_globals.freeMemory(_inventBuf2); - _vm->_dialogsManager._inventWin1 = _vm->_globals.freeMemory(_vm->_dialogsManager._inventWin1); - goto LABEL_7; - } - } else if (!v20) { - _inventDisplayedFl = true; + break; } - } + + _vm->_globals._exitId = 0; + _inventBuf2 = _vm->_globals.freeMemory(_inventBuf2); + _vm->_dialogsManager._inventWin1 = _vm->_globals.freeMemory(_vm->_dialogsManager._inventWin1); + goto LABEL_7; + } else + _inventDisplayedFl = true; } if (_removeInventFl) - v20 = true; - if (v20) break; _vm->_eventsManager.VBL(); if (_vm->_globals._screenId >= 35 && _vm->_globals._screenId <= 40) diff --git a/engines/hopkins/globals.cpp b/engines/hopkins/globals.cpp index 1a339115e9..f16f54abbc 100644 --- a/engines/hopkins/globals.cpp +++ b/engines/hopkins/globals.cpp @@ -389,7 +389,6 @@ void Globals::INIT_ANIM() { Bank[idx]._loadedFl = false; Bank[idx]._filename = ""; Bank[idx]._fileHeader = 0; - Bank[idx].field1C = 0; } } diff --git a/engines/hopkins/globals.h b/engines/hopkins/globals.h index 7c9d16a951..44fedf2561 100644 --- a/engines/hopkins/globals.h +++ b/engines/hopkins/globals.h @@ -70,7 +70,6 @@ struct BankItem { Common::String _filename; int _fileHeader; int field1A; - uint32 field1C; }; struct ListeItem { |