diff options
author | Strangerke | 2013-03-28 10:25:42 +0100 |
---|---|---|
committer | Strangerke | 2013-03-28 10:26:35 +0100 |
commit | 6c9458617e1b1dcf81417bcf0015b9abbe223f72 (patch) | |
tree | ed5f176f231678827cdbd1de1ec1df631abcb256 | |
parent | b4df7868a1c6c846014159b31fc846c7426f1b9c (diff) | |
download | scummvm-rg350-6c9458617e1b1dcf81417bcf0015b9abbe223f72.tar.gz scummvm-rg350-6c9458617e1b1dcf81417bcf0015b9abbe223f72.tar.bz2 scummvm-rg350-6c9458617e1b1dcf81417bcf0015b9abbe223f72.zip |
HOPKINS: Some renaming in LinesManager
-rw-r--r-- | engines/hopkins/lines.cpp | 59 | ||||
-rw-r--r-- | engines/hopkins/lines.h | 11 | ||||
-rw-r--r-- | engines/hopkins/objects.cpp | 14 | ||||
-rw-r--r-- | engines/hopkins/script.cpp | 22 |
4 files changed, 52 insertions, 54 deletions
diff --git a/engines/hopkins/lines.cpp b/engines/hopkins/lines.cpp index d6ed23bdc0..e50a1129b0 100644 --- a/engines/hopkins/lines.cpp +++ b/engines/hopkins/lines.cpp @@ -1068,8 +1068,8 @@ int LinesManager::GENIAL(int lineIdx, int dataIdx, int fromX, int fromY, int des return result; } -// Avoid 2 -RouteItem *LinesManager::PARCOURS2(int fromX, int fromY, int destX, int destY) { +// Find Route from a point to the other +RouteItem *LinesManager::findRoute(int fromX, int fromY, int destX, int destY) { int foundLineIdx; int foundDataIdx; int curLineY = 0; @@ -1496,7 +1496,7 @@ RouteItem *LinesManager::PARCOURS2(int fromX, int fromY, int destX, int destY) { return &_bestRoute[0]; } -void LinesManager::_useRoute0(int idx, int curRouteIdx) { +void LinesManager::useRoute0(int idx, int curRouteIdx) { if (idx) { int i = 0; do { @@ -1590,7 +1590,7 @@ int LinesManager::characterRoute(int fromX, int fromY, int destX, int destY, int int newY = curY; if (destX >= curX - 2 && destX <= curX + 2 && destY >= curY - 2 && destY <= curY + 2) { _testRoute0[idxRoute0].invalidate(); - _useRoute0(idxRoute0, curRouteIdx); + useRoute0(idxRoute0, curRouteIdx); return 1; } distX = abs(curX - destX) + 1; @@ -1655,7 +1655,7 @@ int LinesManager::characterRoute(int fromX, int fromY, int destX, int destY, int newMaxDist = newDistX; if (newMaxDist <= 10) { _testRoute0[idxRoute0].invalidate(); - _useRoute0(idxRoute0, curRouteIdx); + useRoute0(idxRoute0, curRouteIdx); return 1; } int newStepX = 1000 * newDistX / (newMaxDist - 1); @@ -1733,7 +1733,7 @@ int LinesManager::characterRoute(int fromX, int fromY, int destX, int destY, int } if (newMaxDist + 1 <= 0) { _testRoute0[idxRoute0].invalidate(); - _useRoute0(idxRoute0, curRouteIdx); + useRoute0(idxRoute0, curRouteIdx); return 1; } int curDist = 0; @@ -1747,7 +1747,7 @@ int LinesManager::characterRoute(int fromX, int fromY, int destX, int destY, int ++curDist; if (curDist >= newMaxDist + 1) { _testRoute0[idxRoute0].invalidate(); - _useRoute0(idxRoute0, curRouteIdx); + useRoute0(idxRoute0, curRouteIdx); return 1; } } @@ -1755,7 +1755,7 @@ int LinesManager::characterRoute(int fromX, int fromY, int destX, int destY, int break; int tmpRouteIdx = GENIAL(collLineIdxRoute0, collDataIdxRoute0, curPosX, curPosY, destX, destY, idxRoute0, _testRoute0); if (tmpRouteIdx == -1) { - _useRoute0(idxRoute0, curRouteIdx); + useRoute0(idxRoute0, curRouteIdx); return 1; } idxRoute0 = tmpRouteIdx; @@ -2466,40 +2466,41 @@ int LinesManager::testLine(int paramX, int paramY, int *a3, int *foundLineIdx, i return -1; } -int LinesManager::CALC_PROPRE(int idx) { - int size = _vm->_globals->_spriteSize[idx]; +int LinesManager::computeYSteps(int idx) { + int zoomPct = _vm->_globals->_spriteSize[idx]; if (_vm->_globals->_characterType == 1) { - if (size < 0) - size = -size; - size = 20 * (5 * size - 100) / -80; + if (zoomPct < 0) + zoomPct = -zoomPct; + zoomPct = 20 * (5 * zoomPct - 100) / -80; } else if (_vm->_globals->_characterType == 2) { - if (size < 0) - size = -size; - size = 20 * (5 * size - 165) / -67; + if (zoomPct < 0) + zoomPct = -zoomPct; + zoomPct = 20 * (5 * zoomPct - 165) / -67; } int retVal = 25; - if (size < 0) - retVal = _vm->_graphicsManager->zoomOut(25, -size); - else if (size > 0) - retVal = _vm->_graphicsManager->zoomIn(25, size); + if (zoomPct < 0) + retVal = _vm->_graphicsManager->zoomOut(25, -zoomPct); + else if (zoomPct > 0) + retVal = _vm->_graphicsManager->zoomIn(25, zoomPct); return retVal; } -void LinesManager::PACOURS_PROPRE(RouteItem *route) { +void LinesManager::optimizeRoute(RouteItem *route) { + if (route[0]._x == -1 && route[0]._y == -1) + return; + int routeIdx = 0; Directions oldDir = DIR_NONE; int route0Y = route[0]._y; Directions curDir = route[0]._dir; - if (route[0]._x == -1 && route0Y == -1) - return; for (;;) { if (oldDir != DIR_NONE && curDir != oldDir) { int oldRouteIdx = routeIdx; int routeCount = 0; - int routeNum = CALC_PROPRE(route0Y); + int yStep = computeYSteps(route0Y); int curRouteX = route[routeIdx]._x; int curRouteY = route[routeIdx]._y; while (curRouteX != -1 || curRouteY != -1) { @@ -2511,7 +2512,7 @@ void LinesManager::PACOURS_PROPRE(RouteItem *route) { curRouteX = route[routeIdx]._x; curRouteY = route[routeIdx]._y; } - if (routeCount < routeNum) { + if (routeCount < yStep) { int idx = oldRouteIdx; for (int i = 0; i < routeCount; i++) { route[idx]._dir = oldDir; @@ -2669,7 +2670,7 @@ int LinesManager::checkCollision(int xp, int yp) { } // Square Zone -void LinesManager::CARRE_ZONE() { +void LinesManager::initSquareZones() { for (int idx = 0; idx < 100; ++idx) { SquareZoneItem *curZone = &_squareZone[idx]; curZone->_enabledFl = false; @@ -2689,10 +2690,8 @@ void LinesManager::CARRE_ZONE() { SquareZoneItem *curZone = &_squareZone[_zoneLine[idx]._bobZoneIdx]; curZone->_enabledFl = true; - if (curZone->_maxZoneLineIdx < idx) - curZone->_maxZoneLineIdx = idx; - if (curZone->_minZoneLineIdx > idx) - curZone->_minZoneLineIdx = idx; + curZone->_maxZoneLineIdx = MAX(curZone->_maxZoneLineIdx, idx); + curZone->_minZoneLineIdx = MIN(curZone->_minZoneLineIdx, idx); for (int i = 0; i < _zoneLine[idx]._count; i++) { int zoneX = *dataP++; diff --git a/engines/hopkins/lines.h b/engines/hopkins/lines.h index 8a5cb7ae2a..4d84808238 100644 --- a/engines/hopkins/lines.h +++ b/engines/hopkins/lines.h @@ -148,11 +148,11 @@ private: bool makeSmoothMove(int fromX, int fromY, int destX, int destY); int characterRoute(int fromX, int fromY, int destX, int destY, int startLineIdx, int endLineIdx, int routeIdx); int testLine(int paramX, int paramY, int *a3, int *foundLineIdx, int *foundDataIdx); - void _useRoute0(int idx, int curRouteIdx); + void useRoute0(int idx, int curRouteIdx); void useRoute1(int idx, int curRouteIdx); void useRoute2(int idx, int curRouteIdx); + int computeYSteps(int idx); - int CALC_PROPRE(int idx); int CONTOURNE(int lineIdx, int lineDataIdx, int routeIdx, int destLineIdx, int destLineDataIdx, RouteItem *route); int CONTOURNE1(int lineIdx, int lineDataIdx, int routeIdx, int destLineIdx, int destLineDataIdx, RouteItem *route, int a8, int a9); bool MIRACLE(int fromX, int fromY, int lineIdx, int destLineIdx, int routeIdx); @@ -177,8 +177,10 @@ public: void loadLines(const Common::String &file); void addLine(int lineIdx, Directions direction, int fromX, int fromY, int destX, int destY); void initRoute(); + RouteItem *findRoute(int fromX, int fromY, int destX, int destY); RouteItem *cityMapCarRoute(int x1, int y1, int x2, int y2); void clearAllZones(); + void initSquareZones(); void resetLines(); void resetLinesNumb(); void resetLastLine(); @@ -186,10 +188,7 @@ public: void disableZone(int idx); void checkZone(); int getMouseZone(); - - void CARRE_ZONE(); - RouteItem *PARCOURS2(int fromX, int fromY, int destX, int destY); - void PACOURS_PROPRE(RouteItem *route); + void optimizeRoute(RouteItem *route); }; } // End of namespace Hopkins diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp index 6cb2ca17ed..982678ba80 100644 --- a/engines/hopkins/objects.cpp +++ b/engines/hopkins/objects.cpp @@ -1796,7 +1796,7 @@ void ObjectsManager::loadZone(const Common::String &file) { _vm->_linesManager->ZONEP[i + 1]._messageId = READ_LE_UINT16(verbData + 2 * i); _vm->_globals->freeMemory(ptr); - _vm->_linesManager->CARRE_ZONE(); + _vm->_linesManager->initSquareZones(); } void ObjectsManager::handleCityMap() { @@ -1984,9 +1984,9 @@ void ObjectsManager::handleLeftButton() { _homeRateCounter = 0; _oldDirection = DIR_NONE; } else { - _vm->_linesManager->_route = _vm->_linesManager->PARCOURS2(getSpriteX(0), getSpriteY(0), getSpriteX(0), 390); + _vm->_linesManager->_route = _vm->_linesManager->findRoute(getSpriteX(0), getSpriteY(0), getSpriteX(0), 390); if (_vm->_linesManager->_route != (RouteItem *)g_PTRNUL) - _vm->_linesManager->PACOURS_PROPRE(_vm->_linesManager->_route); + _vm->_linesManager->optimizeRoute(_vm->_linesManager->_route); _oldCharacterPosX = getSpriteX(0); _oldCharacterPosY = getSpriteY(0); _homeRateCounter = 0; @@ -1998,9 +1998,9 @@ void ObjectsManager::handleLeftButton() { } } else { if (!_vm->_globals->_freezeCharacterFl && !_vm->_globals->_cityMapEnabledFl) { - _vm->_linesManager->_route = _vm->_linesManager->PARCOURS2(getSpriteX(0), getSpriteY(0), destX, destY); + _vm->_linesManager->_route = _vm->_linesManager->findRoute(getSpriteX(0), getSpriteY(0), destX, destY); if (_vm->_linesManager->_route != (RouteItem *)g_PTRNUL) - _vm->_linesManager->PACOURS_PROPRE(_vm->_linesManager->_route); + _vm->_linesManager->optimizeRoute(_vm->_linesManager->_route); _oldCharacterPosX = getSpriteX(0); _oldCharacterPosY = getSpriteY(0); _homeRateCounter = 0; @@ -3272,7 +3272,7 @@ void ObjectsManager::loadLinkFile(const Common::String &file) { _vm->_linesManager->ZONEP[i]._messageId = READ_LE_INT16(verbData + dep); dep += 2; } - _vm->_linesManager->CARRE_ZONE(); + _vm->_linesManager->initSquareZones(); } } } @@ -3788,7 +3788,7 @@ void ObjectsManager::PERSONAGE(const Common::String &backgroundFile, const Commo _oldDirection = DIR_NONE; _homeRateCounter = 0; _vm->_linesManager->_route = (RouteItem *)g_PTRNUL; - _vm->_linesManager->_route = _vm->_linesManager->PARCOURS2(getSpriteX(0), getSpriteY(0), 330, 345); + _vm->_linesManager->_route = _vm->_linesManager->findRoute(getSpriteX(0), getSpriteY(0), 330, 345); _vm->_globals->_checkDistanceFl = true; do { GOHOME(); diff --git a/engines/hopkins/script.cpp b/engines/hopkins/script.cpp index 61f6ea5638..e34b690434 100644 --- a/engines/hopkins/script.cpp +++ b/engines/hopkins/script.cpp @@ -760,7 +760,7 @@ int ScriptManager::handleOpcode(byte *dataP) { case 46: { _vm->_globals->_checkDistanceFl = true; _vm->_linesManager->_route = (RouteItem *)g_PTRNUL; - _vm->_linesManager->_route = _vm->_linesManager->PARCOURS2(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 564, 420); + _vm->_linesManager->_route = _vm->_linesManager->findRoute(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 564, 420); _vm->_objectsManager->_zoneNum = -1; do { if (_vm->shouldQuit()) @@ -987,7 +987,7 @@ int ScriptManager::handleOpcode(byte *dataP) { _vm->_objectsManager->resetOldDirection(); _vm->_objectsManager->resetHomeRateCounter(); _vm->_linesManager->_route = (RouteItem *)g_PTRNUL; - _vm->_linesManager->_route = _vm->_linesManager->PARCOURS2(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 445, 332); + _vm->_linesManager->_route = _vm->_linesManager->findRoute(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 445, 332); _vm->_globals->_checkDistanceFl = true; do { if (_vm->shouldQuit()) @@ -1105,7 +1105,7 @@ int ScriptManager::handleOpcode(byte *dataP) { _vm->_objectsManager->resetOldDirection(); _vm->_objectsManager->resetHomeRateCounter(); _vm->_linesManager->_route = (RouteItem *)g_PTRNUL; - _vm->_linesManager->_route = _vm->_linesManager->PARCOURS2(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 119, 268); + _vm->_linesManager->_route = _vm->_linesManager->findRoute(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 119, 268); _vm->_globals->_checkDistanceFl = true; do { if (_vm->shouldQuit()) @@ -1424,14 +1424,14 @@ int ScriptManager::handleOpcode(byte *dataP) { _vm->_linesManager->_route = (RouteItem *)g_PTRNUL; switch (_vm->_globals->_saveData->_data[svField253]) { case 1: - _vm->_linesManager->_route = _vm->_linesManager->PARCOURS2(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 201, 294); + _vm->_linesManager->_route = _vm->_linesManager->findRoute(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 201, 294); break; case 2: - _vm->_linesManager->_route = _vm->_linesManager->PARCOURS2(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 158, 338); + _vm->_linesManager->_route = _vm->_linesManager->findRoute(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 158, 338); break; default: if (_vm->_globals->_saveData->_data[svField253] > 2) - _vm->_linesManager->_route = _vm->_linesManager->PARCOURS2(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 211, 393); + _vm->_linesManager->_route = _vm->_linesManager->findRoute(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 211, 393); break; } _vm->_globals->_checkDistanceFl = true; @@ -1670,7 +1670,7 @@ int ScriptManager::handleOpcode(byte *dataP) { _vm->_objectsManager->resetHomeRateCounter(); _vm->_globals->_checkDistanceFl = true; _vm->_linesManager->_route = (RouteItem *)g_PTRNUL; - _vm->_linesManager->_route = _vm->_linesManager->PARCOURS2(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 361, 325); + _vm->_linesManager->_route = _vm->_linesManager->findRoute(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 361, 325); _vm->_globals->_checkDistanceFl = true; _vm->_objectsManager->_zoneNum = -1; do { @@ -1698,7 +1698,7 @@ int ScriptManager::handleOpcode(byte *dataP) { _vm->_objectsManager->resetHomeRateCounter(); _vm->_globals->_checkDistanceFl = true; _vm->_linesManager->_route = (RouteItem *)g_PTRNUL; - _vm->_linesManager->_route = _vm->_linesManager->PARCOURS2(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 361, 325); + _vm->_linesManager->_route = _vm->_linesManager->findRoute(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 361, 325); _vm->_globals->_checkDistanceFl = true; _vm->_objectsManager->_zoneNum = -1; do { @@ -1885,7 +1885,7 @@ int ScriptManager::handleOpcode(byte *dataP) { } _vm->_globals->_checkDistanceFl = true; _vm->_linesManager->_route = (RouteItem *)g_PTRNUL; - _vm->_linesManager->_route = _vm->_linesManager->PARCOURS2(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 330, 418); + _vm->_linesManager->_route = _vm->_linesManager->findRoute(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 330, 418); _vm->_globals->_checkDistanceFl = true; _vm->_objectsManager->_zoneNum = 0; do { @@ -1916,7 +1916,7 @@ int ScriptManager::handleOpcode(byte *dataP) { _vm->_objectsManager->stopBobAnimation(1); _vm->_linesManager->_route = (RouteItem *)g_PTRNUL; _vm->_globals->_checkDistanceFl = true; - _vm->_linesManager->_route = _vm->_linesManager->PARCOURS2(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 330, 314); + _vm->_linesManager->_route = _vm->_linesManager->findRoute(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 330, 314); _vm->_objectsManager->_zoneNum = 0; _vm->_globals->_checkDistanceFl = true; do { @@ -2010,7 +2010,7 @@ int ScriptManager::handleOpcode(byte *dataP) { _vm->_objectsManager->resetHomeRateCounter(); _vm->_globals->_checkDistanceFl = true; _vm->_linesManager->_route = (RouteItem *)g_PTRNUL; - _vm->_linesManager->_route = _vm->_linesManager->PARCOURS2(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 488, 280); + _vm->_linesManager->_route = _vm->_linesManager->findRoute(_vm->_objectsManager->getSpriteX(0), _vm->_objectsManager->getSpriteY(0), 488, 280); _vm->_globals->_checkDistanceFl = true; do { if (_vm->shouldQuit()) |