Skip to content

Commit

Permalink
HOPKINS: Reduce the scope of some more variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Feb 9, 2014
1 parent 4ae6d57 commit 56664d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
15 changes: 6 additions & 9 deletions engines/hopkins/lines.cpp
Expand Up @@ -548,8 +548,6 @@ int LinesManager::avoidObstacleOnSegment(int lineIdx, int lineDataIdx, int route

bool LinesManager::MIRACLE(int fromX, int fromY, int lineIdx, int destLineIdx, int routeIdx) {
debugC(5, kDebugPath, "MIRACLE(%d, %d, %d, %d, %d)", fromX, fromY, lineIdx, destLineIdx, routeIdx);
int newLinesDataIdx = 0;
int newLinesIdx = 0;
int lineIdxLeft = 0;
int lineDataIdxLeft = 0;
int lineIdxRight = 0;
Expand Down Expand Up @@ -700,6 +698,8 @@ bool LinesManager::MIRACLE(int fromX, int fromY, int lineIdx, int destLineIdx, i
newDir = DIR_LEFT;
}

int newLinesDataIdx = 0;
int newLinesIdx = 0;
switch(newDir) {
case DIR_UP:
newLinesIdx = linesIdxUp;
Expand Down Expand Up @@ -1552,7 +1552,6 @@ void LinesManager::useRoute2(int idx, int curRouteIdx) {
int LinesManager::characterRoute(int fromX, int fromY, int destX, int destY, int startLineIdx, int endLineIdx, int routeIdx) {
debugC(5, kDebugPath, "characterRoute(%d, %d, %d, %d, %d, %d, %d)", fromX, fromY, destX, destY, startLineIdx, endLineIdx, routeIdx);
int collDataIdxRoute2 = 0;
bool colResult = false;

int curX = fromX;
int curY = fromY;
Expand Down Expand Up @@ -1603,7 +1602,6 @@ int LinesManager::characterRoute(int fromX, int fromY, int destX, int destY, int
int collLineIdxRoute1 = -1;
int collLineIdxRoute2 = -1;

int distX, distY;
int repeatFlag = 0;
int collDataIdxRoute0 = 0;
int collDataIdxRoute1 = 0;
Expand All @@ -1615,8 +1613,8 @@ int LinesManager::characterRoute(int fromX, int fromY, int destX, int destY, int
useRoute0(idxRoute0, curRouteIdx);
return 1;
}
distX = abs(curX - destX) + 1;
distY = abs(curY - destY) + 1;
int distX = abs(curX - destX) + 1;
int distY = abs(curY - destY) + 1;
int maxDist;
if (distX > distY)
maxDist = distX;
Expand Down Expand Up @@ -1912,7 +1910,7 @@ int LinesManager::characterRoute(int fromX, int fromY, int destX, int destY, int

posXRoute2 = _newPosX;
posYRoute2 = _newPosY;
colResult = checkCollisionLine(_newPosX, _newPosY, &collDataIdxRoute2, &collLineIdxRoute2, 0, _lastLine);
bool colResult = checkCollisionLine(_newPosX, _newPosY, &collDataIdxRoute2, &collLineIdxRoute2, 0, _lastLine);
if (colResult && collLineIdxRoute2 <= _lastLine)
break;
}
Expand Down Expand Up @@ -2456,13 +2454,12 @@ bool LinesManager::PLAN_TEST(int paramX, int paramY, int superRouteIdx, int para
int LinesManager::testLine(int paramX, int paramY, int *testValue, int *foundLineIdx, int *foundDataIdx) {
debugC(5, kDebugPath, "testLine(%d, %d, testValue, foundLineIdx, foundDataIdx)", paramX, paramY);
int16 *lineData;
int lineDataEndIdx;
int collLineIdx;
int collDataIdx;

for (int idx = _lastLine + 1; idx < _linesNumb + 1; idx++) {
lineData = _lineItem[idx]._lineData;
lineDataEndIdx = _lineItem[idx]._lineDataEndIdx;
int lineDataEndIdx = _lineItem[idx]._lineDataEndIdx;
if (!lineData)
continue;

Expand Down
8 changes: 3 additions & 5 deletions engines/hopkins/objects.cpp
Expand Up @@ -376,7 +376,6 @@ void ObjectsManager::addObject(int objIndex) {
void ObjectsManager::displaySprite() {
int clipX;
int clipY;
bool loopCondFl;
uint16 arr[50];

// Handle copying any background areas that text are going to be drawn on
Expand Down Expand Up @@ -441,6 +440,7 @@ void ObjectsManager::displaySprite() {
for (int i = 1; i <= 48; i++)
arr[i] = i;

bool loopCondFl;
do {
loopCondFl = false;
for (int sortIdx = 1; sortIdx < _sortedDisplayCount; sortIdx++) {
Expand Down Expand Up @@ -3613,12 +3613,10 @@ void ObjectsManager::showSpecialActionAnimation(const byte *spriteData, const Co
realSpeed = speed / 3;

int spriteIndex = 0;
bool completeTokenFl;
char nextChar;

for (int idx = 0; ; idx++) {
completeTokenFl = false;
nextChar = animString[idx];
bool completeTokenFl = false;
char nextChar = animString[idx];
if (nextChar == ',') {
spriteIndex = atoi(tmpStr.c_str());
tmpStr = "";
Expand Down

0 comments on commit 56664d0

Please sign in to comment.