diff options
author | Strangerke | 2012-10-14 10:28:03 +0200 |
---|---|---|
committer | Strangerke | 2012-10-14 10:28:03 +0200 |
commit | ad3c7febd7b5f03d72b30e6ff1d0e8cbd2114b8f (patch) | |
tree | 94c6a3fab7af4652ff9101982100af35a6468c78 | |
parent | d7a9cfb80fd574643130f8ea43ff2f206627614c (diff) | |
download | scummvm-rg350-ad3c7febd7b5f03d72b30e6ff1d0e8cbd2114b8f.tar.gz scummvm-rg350-ad3c7febd7b5f03d72b30e6ff1d0e8cbd2114b8f.tar.bz2 scummvm-rg350-ad3c7febd7b5f03d72b30e6ff1d0e8cbd2114b8f.zip |
MORTEVIELLE: Some more renaming
-rw-r--r-- | engines/mortevielle/actions.cpp | 159 | ||||
-rw-r--r-- | engines/mortevielle/menu.cpp | 5 | ||||
-rw-r--r-- | engines/mortevielle/mortevielle.cpp | 41 | ||||
-rw-r--r-- | engines/mortevielle/mortevielle.h | 5 | ||||
-rw-r--r-- | engines/mortevielle/mouse.cpp | 14 | ||||
-rw-r--r-- | engines/mortevielle/mouse.h | 2 | ||||
-rw-r--r-- | engines/mortevielle/saveload.cpp | 2 |
7 files changed, 122 insertions, 106 deletions
diff --git a/engines/mortevielle/actions.cpp b/engines/mortevielle/actions.cpp index 2f4af8538d..6d8e095a3a 100644 --- a/engines/mortevielle/actions.cpp +++ b/engines/mortevielle/actions.cpp @@ -298,19 +298,19 @@ void MortevielleEngine::fctTake() { * @remarks Originally called 'tsprendre' */ void MortevielleEngine::fctInventoryTake() { - int cx = 0; + int inventIndex = 0; do { - ++cx; - } while (_menu._inventoryMenu[cx] != _msg[4]); + ++inventIndex; + } while (_menu._inventoryMenu[inventIndex] != _msg[4]); int cz = 0; int cy = 0; do { ++cy; - if (ord(_coreVar._sjer[cy]) != 0) + if (_coreVar._inventory[cy] != 0) ++cz; - } while (cz != cx); - cz = ord(_coreVar._sjer[cy]); - _coreVar._sjer[cy] = chr(0); + } while (cz != inventIndex); + cz = _coreVar._inventory[cy]; + _coreVar._inventory[cy] = 0; _menu.setInventoryText(); putInHand(cz); _crep = 998; @@ -1342,15 +1342,18 @@ void MortevielleEngine::fctSound() { * @remarks Originally called 'tparler' */ void MortevielleEngine::fctDiscuss() { - bool te[47]; - int cy, cx, max, suj, co, lig, icm, i, choi, x, y, c; - char tou; + bool questionAsked[47]; + int cy, cx; + int x, y; +// int c; Common::String lib[47]; - bool f; + + int choice; + int displId; endSearch(); if (_col) - suj = 128; + displId = 128; else { cx = 0; do { @@ -1359,54 +1362,55 @@ void MortevielleEngine::fctDiscuss() { _caff = 69 + cx; drawPictureWithText(); handleDescriptionText(2, _caff); - suj = _caff + 60; + displId = _caff + 60; } testKey(false); mennor(); _mouse.hideMouse(); hirs(); premtet(); - startDialog(suj); + startDialog(displId); hirs(); for (int ix = 1; ix <= 46; ++ix) - te[ix] = false; + questionAsked[ix] = false; for (int ix = 1; ix <= 45; ++ix) { lib[ix] = getString(ix + kQuestionStringIndex); - for (i = lib[ix].size(); i <= 40; ++i) + for (int i = lib[ix].size(); i <= 40; ++i) lib[ix] = lib[ix] + ' '; } lib[46] = lib[45]; lib[45] = ' '; _mouse.showMouse(); do { - choi = 0; - icm = 0; - co = 0; - lig = 0; - do { - ++icm; - _screenSurface.putxy(co, lig); + choice = 0; + int posX = 0; + int posY = 0; + for (int icm = 1; icm < 43; icm++) { + _screenSurface.putxy(posX, posY); if (_coreVar._teauto[icm] == '*') { - if (te[icm]) + // If question already asked, write it in reverse video + if (questionAsked[icm]) writetp(lib[icm], 1); else writetp(lib[icm], 0); } if (icm == 23) { - lig = 0; - co = 320; + posY = 0; + posX = 320; } else - lig = lig + 8; - } while (icm != 42); + posY += 8; + } _screenSurface.putxy(320, 176); writetp(lib[46], 0); - tou = '\0'; + char retKey = '\0'; + bool click; do { - _mouse.moveMouse(f, tou); + bool dummyFl; + _mouse.moveMouse(dummyFl, retKey); CHECK_QUIT; - _mouse.getMousePosition(x, y, c); + _mouse.getMousePosition(x, y, click); x *= (3 - _res); if (x > 319) cx = 41; @@ -1414,95 +1418,98 @@ void MortevielleEngine::fctDiscuss() { cx = 1; cy = ((uint)y >> 3) + 1; // 0-199 => 1-25 if ((cy > 23) || ((cx == 41) && ((cy >= 20) && (cy <= 22)))) { - if (choi != 0) { - lig = ((choi - 1) % 23) << 3; - if (choi > 23) - co = 320; + if (choice != 0) { + posY = ((choice - 1) % 23) << 3; + if (choice > 23) + posX = 320; else - co = 0; - _screenSurface.putxy(co, lig); - if (te[choi]) - writetp(lib[choi], 0); + posX = 0; + _screenSurface.putxy(posX, posY); + if (questionAsked[choice]) + writetp(lib[choice], 0); else - writetp(lib[choi], 1); - te[choi] = !te[choi]; - choi = 0; + writetp(lib[choice], 1); + questionAsked[choice] = !questionAsked[choice]; + choice = 0; } } else { int ix = cy; if (cx == 41) ix += 23; - if (ix != choi) { - if (choi != 0) { - lig = ((choi - 1) % 23) << 3; - if (choi > 23) - co = 320; + if (ix != choice) { + if (choice != 0) { + posY = ((choice - 1) % 23) << 3; + if (choice > 23) + posX = 320; else - co = 0; - _screenSurface.putxy(co, lig); - if (te[choi]) - writetp(lib[choi], 0); + posX = 0; + _screenSurface.putxy(posX, posY); + if (questionAsked[choice]) + writetp(lib[choice], 0); else - writetp(lib[choi], 1); - te[choi] = ! te[choi]; + writetp(lib[choice], 1); + questionAsked[choice] = ! questionAsked[choice]; } if ((_coreVar._teauto[ix] == '*') || (ix == 46)) { - lig = ((ix - 1) % 23) << 3; + posY = ((ix - 1) % 23) << 3; if (ix > 23) - co = 320; + posX = 320; else - co = 0; - _screenSurface.putxy(co, lig); - if (te[ix]) + posX = 0; + _screenSurface.putxy(posX, posY); + if (questionAsked[ix]) writetp(lib[ix], 0); else writetp(lib[ix], 1); - te[ix] = ! te[ix]; - choi = ix; + questionAsked[ix] = ! questionAsked[ix]; + choice = ix; } else - choi = 0; + choice = 0; } } - } while (!((tou == '\15') || (((c != 0) || getMouseClick()) && (choi != 0)))); + } while (!((retKey == '\15') || (((click != 0) || getMouseClick()) && (choice != 0)))); setMouseClick(false); - if (choi != 46) { - int ix = choi - 1; + + // If choice is not "End of Conversation" + if (choice != 46) { + int ix = choice - 1; if (_col) { _col = false; _coreVar._currPlace = 15; + int maxRandVal; if (_openObjCount > 0) - max = 8; + maxRandVal = 8; else - max = 4; - if (getRandomNumber(1, max) == 2) - suj = 129; + maxRandVal = 4; + if (getRandomNumber(1, maxRandVal) == 2) + displId = 129; else { - suj = 138; + displId = 138; _coreVar._faithScore += (3 * (_coreVar._faithScore / 10)); } } else if (_nbrep[_caff - 69] < _nbrepm[_caff - 69]) { - suj = _tabdon[kArep + (ix << 3) + (_caff - 70)]; + displId = _tabdon[kArep + (ix << 3) + (_caff - 70)]; _coreVar._faithScore += _tabdon[kArcf + ix]; ++_nbrep[_caff - 69]; } else { _coreVar._faithScore += 3; - suj = 139; + displId = 139; } _mouse.hideMouse(); hirs(); premtet(); - startDialog(suj); + startDialog(displId); _mouse.showMouse(); - if ((suj == 84) || (suj == 86)) { + if ((displId == 84) || (displId == 86)) { _coreVar._pourc[5] = '*'; _coreVar._teauto[7] = '*'; } - if ((suj == 106) || (suj == 108) || (suj == 94)) { + if ((displId == 106) || (displId == 108) || (displId == 94)) { for (int indx = 29; indx <= 31; ++indx) _coreVar._teauto[indx] = '*'; _coreVar._pourc[7] = '*'; } - if (suj == 70) { + if (displId == 70) { _coreVar._pourc[8] = '*'; _coreVar._teauto[32] = '*'; } @@ -1510,7 +1517,7 @@ void MortevielleEngine::fctDiscuss() { hirs(); _mouse.showMouse(); } - } while ((choi != 46) && (suj != 138)); + } while ((choice != 46) && (displId != 138)); if (_col) { _coreVar._faithScore += (3 * (_coreVar._faithScore / 10)); _mouse.hideMouse(); diff --git a/engines/mortevielle/menu.cpp b/engines/mortevielle/menu.cpp index 99509f8490..f03d6661e4 100644 --- a/engines/mortevielle/menu.cpp +++ b/engines/mortevielle/menu.cpp @@ -576,14 +576,13 @@ void Menu::unsetSearchMenu() { * @remarks Originally called 'modinv' */ void Menu::setInventoryText() { - int r; Common::String nomp; int cy = 0; for (int i = 1; i <= 6; ++i) { - if (g_vm->_coreVar._sjer[i] != chr(0)) { + if (g_vm->_coreVar._inventory[i] != 0) { ++cy; - r = (ord(g_vm->_coreVar._sjer[i]) + 400); + int r = g_vm->_coreVar._inventory[i] + 400; nomp = g_vm->getString(r - 501 + kInventoryStringIndex); setText(_inventoryMenu[cy], nomp); enableMenuItem(_inventoryMenu[i]); diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp index 088c8809cd..782c811b1f 100644 --- a/engines/mortevielle/mortevielle.cpp +++ b/engines/mortevielle/mortevielle.cpp @@ -1702,7 +1702,7 @@ void MortevielleEngine::loseGame() { bool MortevielleEngine::checkInventory(int objectId) { bool retVal = false; for (int i = 1; i <= 6; ++i) - retVal = (retVal || (ord(_coreVar._sjer[i]) == objectId)); + retVal = (retVal || (_coreVar._inventory[i] == objectId)); if (_coreVar._selectedObjectId == objectId) retVal = true; @@ -2234,7 +2234,7 @@ Common::String MortevielleEngine::getString(int num) { Common::String wrkStr = ""; if (num < 0) { - warning("deline: num < 0! Skipping"); + warning("getString(%d): num < 0! Skipping", num); } else if (!_txxFileFl) { wrkStr = getGameString(num); } else { @@ -2285,9 +2285,11 @@ void MortevielleEngine::resetVariables() { _coreVar._currPlace = MANOR_FRONT; for (int i = 2; i <= 6; ++i) - _coreVar._sjer[i] = chr(0); + _coreVar._inventory[i] = 0; + + // Only object in inventory: a gun + _coreVar._inventory[1] = 113; - _coreVar._sjer[1] = chr(113); _coreVar._fullHour = chr(20); for (int i = 1; i <= 10; ++i) @@ -3361,7 +3363,8 @@ void MortevielleEngine::drawPictureWithText() { */ void MortevielleEngine::testKey(bool d) { bool quest = false; - int x, y, c; + int x, y; + bool click; _mouse.hideMouse(); fenat('K'); @@ -3371,18 +3374,18 @@ void MortevielleEngine::testKey(bool d) { _key = testou(); do { - _mouse.getMousePosition(x, y, c); + _mouse.getMousePosition(x, y, click); keyPressed(); - } while (c != 0); + } while (click); // Event loop do { if (d) prepareRoom(); quest = keyPressed(); - _mouse.getMousePosition(x, y, c); + _mouse.getMousePosition(x, y, click); CHECK_QUIT; - } while (!(quest || (c != 0) || (d && _anyone))); + } while (!(quest || (click) || (d && _anyone))); if (quest) testou(); setMouseClick(false); @@ -3506,16 +3509,21 @@ void MortevielleEngine::ajchai() { _crep = 192; } -void MortevielleEngine::ajjer(int ob) { - int cx = 0; +/** + * Check if inventory is full and, if not, add object in it. + * @remarks Originally called 'ajjer' + */ +void MortevielleEngine::addObjectToInventory(int objectId) { + int i = 0; do { - ++cx; - } while ((cx <= 5) && (ord(_coreVar._sjer[cx]) != 0)); + ++i; + } while ((i <= 5) && (_coreVar._inventory[i] != 0)); - if (ord(_coreVar._sjer[cx]) == 0) { - _coreVar._sjer[(cx)] = chr(ob); + if (_coreVar._inventory[i] == 0) { + _coreVar._inventory[i] = objectId; _menu.setInventoryText(); } else + // Inventory is full _crep = 139; } @@ -3715,8 +3723,9 @@ void MortevielleEngine::treg(int objId) { void MortevielleEngine::putInHand(int &objId) { _crep = 999; if (_coreVar._selectedObjectId != 0) - ajjer(_coreVar._selectedObjectId); + addObjectToInventory(_coreVar._selectedObjectId); + // If inventory wasn't full if (_crep != 139) { displayItemInHand(objId + 400); _coreVar._selectedObjectId = objId; diff --git a/engines/mortevielle/mortevielle.h b/engines/mortevielle/mortevielle.h index 7e0f717142..1141f70026 100644 --- a/engines/mortevielle/mortevielle.h +++ b/engines/mortevielle/mortevielle.h @@ -187,7 +187,7 @@ struct SaveStruct { int _faithScore; byte _pourc[11]; byte _teauto[43]; - byte _sjer[31]; + byte _inventory[31]; int _currPlace; int _atticBallHoleObjectId; int _atticRodHoleObjectId; @@ -441,7 +441,7 @@ private: void tlu(int af, int ob); void affrep(); void mennor(); - void ajjer(int ob); + void addObjectToInventory(int objectId); void tsuiv(); void treg(int objId); void putInHand(int &objId); @@ -469,7 +469,6 @@ public: int _res; int _caff; int _crep; -// byte _is; byte _v_lieu[7][25]; // TODO: Replace the following with proper implementations, or refactor out the code using them diff --git a/engines/mortevielle/mouse.cpp b/engines/mortevielle/mouse.cpp index 598677f762..96b40d8114 100644 --- a/engines/mortevielle/mouse.cpp +++ b/engines/mortevielle/mouse.cpp @@ -238,10 +238,10 @@ void MouseHandler::setMousePosition(Common::Point newPos) { * Get mouse poisition * @remarks Originally called 'read_pos_mouse' */ -void MouseHandler::getMousePosition(int &x, int &y, int &c) { +void MouseHandler::getMousePosition(int &x, int &y, bool &click) { x = g_vm->getMousePos().x; y = g_vm->getMousePos().y; - c = g_vm->getMouseClick() ? 1 : 0; + click = g_vm->getMouseClick(); } /** @@ -251,7 +251,8 @@ void MouseHandler::getMousePosition(int &x, int &y, int &c) { void MouseHandler::moveMouse(bool &funct, char &key) { bool p_key; char in1, in2; - int cx, cy, cd; + int cx, cy; + bool click; // Set defaults and check pending events funct = false; @@ -267,7 +268,7 @@ void MouseHandler::moveMouse(bool &funct, char &key) { CHECK_QUIT; in1 = g_vm->getChar(); - getMousePosition(cx, cy, cd); + getMousePosition(cx, cy, click); switch (toupper(in1)) { case '4': cx -= 8; @@ -408,9 +409,10 @@ void MouseHandler::moveMouse(bool &funct, char &key) { * @remarks Originally called 'dans_rect' */ bool MouseHandler::isMouseIn(Common::Rect r) { - int x, y, c; + int x, y; + bool click; - getMousePosition(x, y, c); + getMousePosition(x, y, click); if ((x > r.left) && (x < r.right) && (y > r.top) && (y < r.bottom)) return true; diff --git a/engines/mortevielle/mouse.h b/engines/mortevielle/mouse.h index abfc315677..58e3fc78d0 100644 --- a/engines/mortevielle/mouse.h +++ b/engines/mortevielle/mouse.h @@ -43,7 +43,7 @@ public: void hideMouse(); void showMouse(); void setMousePosition(Common::Point newPos); - void getMousePosition(int &x, int &y, int &c); + void getMousePosition(int &x, int &y, bool &click); void moveMouse(bool &funct, char &key); bool isMouseIn(Common::Rect r); }; diff --git a/engines/mortevielle/saveload.cpp b/engines/mortevielle/saveload.cpp index 48ae04678d..e4fb38c20a 100644 --- a/engines/mortevielle/saveload.cpp +++ b/engines/mortevielle/saveload.cpp @@ -50,7 +50,7 @@ void SavegameManager::sync_save(Common::Serializer &sz) { for (int i = 0; i < 43; ++i) sz.syncAsByte(g_vm->_saveStruct._teauto[i]); for (int i = 0; i < 31; ++i) - sz.syncAsByte(g_vm->_saveStruct._sjer[i]); + sz.syncAsByte(g_vm->_saveStruct._inventory[i]); sz.syncAsSint16LE(g_vm->_saveStruct._currPlace); sz.syncAsSint16LE(g_vm->_saveStruct._atticBallHoleObjectId); |