aboutsummaryrefslogtreecommitdiff
path: root/engines/hopkins/lines.cpp
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2013-02-18 23:52:55 +0100
committerWillem Jan Palenstijn2013-02-18 23:54:18 +0100
commit81bb4d43743c538c0e37e484e1f6f05e97222c9c (patch)
tree3824cbddbdc3d5d4d41c1802f8be032be5f9f1d7 /engines/hopkins/lines.cpp
parent6df59334b8998e25abdc46a2dfc718635f5a24df (diff)
parent7428af9a4c612b59cee7f55d867a00464b3dae64 (diff)
downloadscummvm-rg350-81bb4d43743c538c0e37e484e1f6f05e97222c9c.tar.gz
scummvm-rg350-81bb4d43743c538c0e37e484e1f6f05e97222c9c.tar.bz2
scummvm-rg350-81bb4d43743c538c0e37e484e1f6f05e97222c9c.zip
HOPKINS: Merge 'remotes/dreammaster/hopkins' into hopkins
Conflicts: engines/hopkins/lines.cpp engines/hopkins/lines.h engines/hopkins/objects.cpp
Diffstat (limited to 'engines/hopkins/lines.cpp')
-rw-r--r--engines/hopkins/lines.cpp588
1 files changed, 275 insertions, 313 deletions
diff --git a/engines/hopkins/lines.cpp b/engines/hopkins/lines.cpp
index 3334a76757..6870d1a0c1 100644
--- a/engines/hopkins/lines.cpp
+++ b/engines/hopkins/lines.cpp
@@ -59,7 +59,7 @@ LinesManager::LinesManager() {
Common::fill((byte *)&_smoothRoute[i], (byte *)&_smoothRoute[i] + sizeof(SmoothItem), 0);
for (int i = 0; i < 8001; ++i)
- super_parcours[i].set(0, 0, 0);
+ super_parcours[i].set(0, 0, DIR_NONE);
for (int i = 0; i < 101; ++i) {
Common::fill((byte *)&_segment[i], (byte *)&_segment[i] + sizeof(SegmentItem), 0);
@@ -80,7 +80,7 @@ LinesManager::LinesManager() {
NV_POSI = 0;
NVPX = 0;
NVPY = 0;
- _smoothMoveDirection = 0;
+ _smoothMoveDirection = DIR_NONE;
_lastLine = 0;
_maxLineIdx = 0;
_pathFindingMaxDepth = 0;
@@ -109,13 +109,13 @@ void LinesManager::loadLines(const Common::String &file) {
_linesNumb = 0;
_lastLine = 0;
byte *ptr = _vm->_fileManager.loadFile(file);
- for (int idx = 0; (int16)READ_LE_UINT16((uint16 *)ptr + (idx * 5)) != -1; idx++) {
+ for (int idx = 0; READ_LE_INT16((uint16 *)ptr + (idx * 5)) != -1; idx++) {
addLine(idx,
- (int16)READ_LE_UINT16((uint16 *)ptr + (idx * 5)),
- (int16)READ_LE_UINT16((uint16 *)ptr + (idx * 5) + 1),
- (int16)READ_LE_UINT16((uint16 *)ptr + (idx * 5) + 2),
- (int16)READ_LE_UINT16((uint16 *)ptr + (idx * 5) + 3),
- (int16)READ_LE_UINT16((uint16 *)ptr + (idx * 5) + 4));
+ (Directions)READ_LE_INT16((uint16 *)ptr + (idx * 5)),
+ READ_LE_INT16((uint16 *)ptr + (idx * 5) + 1),
+ READ_LE_INT16((uint16 *)ptr + (idx * 5) + 2),
+ READ_LE_INT16((uint16 *)ptr + (idx * 5) + 3),
+ READ_LE_INT16((uint16 *)ptr + (idx * 5) + 4));
}
initRoute();
_vm->_globals.freeMemory(ptr);
@@ -237,18 +237,16 @@ void LinesManager::addZoneLine(int idx, int a2, int a3, int a4, int a5, int bobZ
/**
* Add Line
*/
-void LinesManager::addLine(int idx, int direction, int a3, int a4, int a5, int a6) {
+void LinesManager::addLine(int idx, Directions direction, int a3, int a4, int a5, int a6) {
assert (idx <= MAX_LINES);
if (_linesNumb < idx)
_linesNumb = idx;
Ligne[idx]._lineData = (int16 *)_vm->_globals.freeMemory((byte *)Ligne[idx]._lineData);
- int v7 = abs(a3 - a5);
- int v8 = v7 + 1;
- int v9 = abs(a4 - a6);
- int v34 = v9 + 1;
- int v33 = v9 + 1;
+ int v8 = abs(a3 - a5) + 1;
+ int v34 = abs(a4 - a6) + 1;
+ int v33 = v34;
if (v8 > v34)
v34 = v8;
@@ -270,60 +268,60 @@ void LinesManager::addLine(int idx, int direction, int a3, int a4, int a5, int a
int v12 = (int)v37 / 1000;
if (!v11) {
if (v12 == -1) {
- Ligne[idx].field6 = 1;
- Ligne[idx].field8 = 5;
+ Ligne[idx].field6 = DIR_UP;
+ Ligne[idx].field8 = DIR_DOWN;
}
if (v12 == 1) {
- Ligne[idx].field6 = 5;
- Ligne[idx].field8 = 1;
+ Ligne[idx].field6 = DIR_DOWN;
+ Ligne[idx].field8 = DIR_UP;
}
}
if (v11 == 1) {
if (v12 == -1) {
- Ligne[idx].field6 = 2;
- Ligne[idx].field8 = 6;
+ Ligne[idx].field6 = DIR_UP_RIGHT;
+ Ligne[idx].field8 = DIR_DOWN_LEFT;
}
if (!v12) {
- Ligne[idx].field6 = 3;
- Ligne[idx].field8 = 7;
+ Ligne[idx].field6 = DIR_RIGHT;
+ Ligne[idx].field8 = DIR_LEFT;
}
if (v12 == 1) {
- Ligne[idx].field6 = 4;
- Ligne[idx].field8 = 8;
+ Ligne[idx].field6 = DIR_DOWN_RIGHT;
+ Ligne[idx].field8 = DIR_UP_LEFT;
}
}
if (v11 == -1) {
if (v12 == 1) {
- Ligne[idx].field6 = 6;
- Ligne[idx].field8 = 2;
+ Ligne[idx].field6 = DIR_DOWN_LEFT;
+ Ligne[idx].field8 = DIR_UP_RIGHT;
}
if (!v12) {
- Ligne[idx].field6 = 7;
- Ligne[idx].field8 = 3;
+ Ligne[idx].field6 = DIR_LEFT;
+ Ligne[idx].field8 = DIR_RIGHT;
}
if (v12 == -1) {
- Ligne[idx].field6 = 8;
- Ligne[idx].field8 = 4;
+ Ligne[idx].field6 = DIR_UP_LEFT;
+ Ligne[idx].field8 = DIR_DOWN_RIGHT;
}
}
if (v11 == 1 && v37 > 250 && v37 <= 999) {
- Ligne[idx].field6 = 4;
- Ligne[idx].field8 = 8;
+ Ligne[idx].field6 = DIR_DOWN_RIGHT;
+ Ligne[idx].field8 = DIR_UP_LEFT;
}
if (v11 == -1 && v37 > 250 && v37 <= 999) {
- Ligne[idx].field6 = 6;
- Ligne[idx].field8 = 2;
+ Ligne[idx].field6 = DIR_DOWN_LEFT;
+ Ligne[idx].field8 = DIR_UP_RIGHT;
}
if (v11 == 1 && v37 < -250 && v37 > -1000) {
- Ligne[idx].field6 = 2;
- Ligne[idx].field8 = 6;
+ Ligne[idx].field6 = DIR_UP_RIGHT;
+ Ligne[idx].field8 = DIR_DOWN_LEFT;
}
// This condition is impossible to meet!
// Code present in the Linux and BeOS executables
// CHECKME: maybe it should be checking negative values?
if (v11 == -1 && v37 <= 249 && v37 > 1000) {
- Ligne[idx].field6 = 8;
- Ligne[idx].field8 = 4;
+ Ligne[idx].field6 = DIR_UP_LEFT;
+ Ligne[idx].field8 = DIR_DOWN_RIGHT;
}
int v40 = v36 / v34;
int v38 = 1000 * v33 / v34;
@@ -528,34 +526,9 @@ int LinesManager::CONTOURNE1(int a1, int a2, int a3, int a4, int a5, RouteItem *
return v40;
}
-bool LinesManager::MIRACLE(int a1, int a2, int a3, int a4, int a5) {
- int v5;
- int v6;
- int v7;
- int v9;
- int v10;
- int i;
- int v12;
- int v13;
- int j;
- int v15;
- int v16;
- int k;
- int v18;
- int v19;
- int l;
- int v21;
- int v23;
- int v26;
- int v29;
- int v32;
+bool LinesManager::MIRACLE(int fromX, int fromY, int a3, int a4, int a5) {
int v35 = 0;
int v36 = 0;
- int v37;
- int v38;
- int v39;
- int v40;
- int v41;
int v42 = 0;
int v43 = 0;
int v44 = 0;
@@ -564,50 +537,49 @@ bool LinesManager::MIRACLE(int a1, int a2, int a3, int a4, int a5) {
int v47 = 0;
int v48 = 0;
int v49 = 0;
- int v50;
- int v51;
- v5 = a1;
- v6 = a2;
- v50 = a3;
- v7 = a5;
- if (checkCollisionLine(a1, a2, &v51, &v50, 0, _linesNumb)) {
+ int curX = fromX;
+ int curY = fromY;
+ int v50 = a3;
+ int v7 = a5;
+ int v51;
+ if (checkCollisionLine(fromX, fromY, &v51, &v50, 0, _linesNumb)) {
switch (Ligne[v50]._direction) {
- case 1:
- v6 = a2 - 2;
+ case DIR_UP:
+ curY -= 2;
break;
- case 2:
- v6 -= 2;
- v5 = a1 + 2;
+ case DIR_UP_RIGHT:
+ curY -= 2;
+ curX += 2;
break;
- case 3:
- v5 += 2;
+ case DIR_RIGHT:
+ curX += 2;
break;
- case 4:
- v6 += 2;
- v5 += 2;
+ case DIR_DOWN_RIGHT:
+ curY += 2;
+ curX += 2;
break;
- case 5:
- v6 += 2;
+ case DIR_DOWN:
+ curY += 2;
break;
- case 6:
- v6 += 2;
- v5 -= 2;
+ case DIR_DOWN_LEFT:
+ curY += 2;
+ curX -= 2;
break;
- case 7:
- v5 -= 2;
+ case DIR_LEFT:
+ curX -= 2;
break;
- case 8:
- v6 -= 2;
- v5 -= 2;
+ case DIR_UP_LEFT:
+ curY -= 2;
+ curX -= 2;
break;
}
}
- v41 = v5;
- v40 = v6;
- v9 = 0;
- v10 = v40;
- for (i = v40; v40 + 200 > v10; i = v10) {
+ int v41 = curX;
+ int v40 = curY;
+ int v9 = 0;
+ int v10 = v40;
+ for (int i = v40; v40 + 200 > v10; i = v10) {
if (checkCollisionLine(v41, i, &v49, &v48, 0, _lastLine) == 1 && v48 <= _lastLine)
break;
v49 = 0;
@@ -615,10 +587,10 @@ bool LinesManager::MIRACLE(int a1, int a2, int a3, int a4, int a5) {
++v9;
++v10;
}
- v37 = v9;
- v12 = 0;
- v13 = v40;
- for (j = v40; v40 - 200 < v13; j = v13) {
+ int v37 = v9;
+ int v12 = 0;
+ int v13 = v40;
+ for (int j = v40; v40 - 200 < v13; j = v13) {
if (checkCollisionLine(v41, j, &v47, &v46, 0, _lastLine) == 1 && v46 <= _lastLine)
break;
v47 = 0;
@@ -626,10 +598,10 @@ bool LinesManager::MIRACLE(int a1, int a2, int a3, int a4, int a5) {
++v12;
--v13;
}
- v39 = v12;
- v15 = 0;
- v16 = v41;
- for (k = v41; v41 + 200 > v16; k = v16) {
+ int v39 = v12;
+ int v15 = 0;
+ int v16 = v41;
+ for (int k = v41; v41 + 200 > v16; k = v16) {
if (checkCollisionLine(k, v40, &v45, &v44, 0, _lastLine) == 1 && v44 <= _lastLine)
break;
v45 = 0;
@@ -637,10 +609,10 @@ bool LinesManager::MIRACLE(int a1, int a2, int a3, int a4, int a5) {
++v15;
++v16;
}
- v38 = v15;
- v18 = 0;
- v19 = v41;
- for (l = v41; v41 - 200 < v19; l = v19) {
+ int v38 = v15;
+ int v18 = 0;
+ int v19 = v41;
+ for (int l = v41; v41 - 200 < v19; l = v19) {
if (checkCollisionLine(l, v40, &v43, &v42, 0, _lastLine) == 1 && v42 <= _lastLine)
break;
v43 = 0;
@@ -665,8 +637,7 @@ bool LinesManager::MIRACLE(int a1, int a2, int a3, int a4, int a5) {
v48 = -1;
if (v42 != -1 && a4 < v42)
v42 = -1;
- }
- if (a4 < v50) {
+ } else if (a4 < v50) {
if (v46 != -1 && v46 >= v50)
v46 = -1;
if (v44 != -1 && v50 <= v44)
@@ -685,18 +656,17 @@ bool LinesManager::MIRACLE(int a1, int a2, int a3, int a4, int a5) {
v42 = -1;
}
if (v46 != -1 || v44 != -1 || v48 != -1 || v42 != -1) {
- v21 = 0;
+ Directions newDir = DIR_NONE;
if (a4 > v50) {
if (v48 <= v46 && v44 <= v46 && v42 <= v46 && v46 > v50)
- v21 = 1;
+ newDir = DIR_UP;
if (v48 <= v44 && v46 <= v44 && v42 <= v44 && v50 < v44)
- v21 = 3;
+ newDir = DIR_RIGHT;
if (v46 <= v48 && v44 <= v48 && v42 <= v48 && v50 < v48)
- v21 = 5;
+ newDir = DIR_DOWN;
if (v48 <= v42 && v44 <= v42 && v46 <= v42 && v50 < v42)
- v21 = 7;
- }
- if (a4 < v50) {
+ newDir = DIR_LEFT;
+ } else if (a4 < v50) {
if (v46 == -1)
v46 = 1300;
if (v44 == -1)
@@ -706,103 +676,96 @@ bool LinesManager::MIRACLE(int a1, int a2, int a3, int a4, int a5) {
if (v42 == -1)
v42 = 1300;
if (v46 != 1300 && v48 >= v46 && v44 >= v46 && v42 >= v46 && v46 < v50)
- v21 = 1;
+ newDir = DIR_UP;
if (v44 != 1300 && v48 >= v44 && v46 >= v44 && v42 >= v44 && v50 > v44)
- v21 = 3;
+ newDir = DIR_RIGHT;
if (v48 != 1300 && v46 >= v48 && v44 >= v48 && v42 >= v48 && v50 > v48)
- v21 = 5;
+ newDir = DIR_DOWN;
if (v42 != 1300 && v48 >= v42 && v44 >= v42 && v46 >= v42 && v50 > v42)
- v21 = 7;
- }
- if (v21) {
- if (v21 == 1) {
- v36 = v46;
- v35 = v47;
- }
- if (v21 == 3) {
- v36 = v44;
- v35 = v45;
- }
- if (v21 == 5) {
- v36 = v48;
- v35 = v49;
- }
- if (v21 == 7) {
- v36 = v42;
- v35 = v43;
- }
- if (v21 == 1) {
- for (int v22 = 0; v22 < v39; v22++) {
- if (checkCollisionLine(v41, v40 - v22, &v47, &v46, _lastLine + 1, _linesNumb) && _lastLine < v46) {
- v23 = GENIAL(v46, v47, v41, v40 - v22, v41, v40 - v39, v7, &super_parcours[0]);
- if (v23 == -1)
- return false;
- v7 = v23;
- if (NVPY != -1)
- v22 = NVPY - v40;
- }
- super_parcours[v7].set(v41, v40 - v22, 1);
- v7++;
+ newDir = DIR_LEFT;
+ }
+
+ switch(newDir) {
+ case DIR_UP:
+ v36 = v46;
+ v35 = v47;
+ for (int v22 = 0; v22 < v39; v22++) {
+ if (checkCollisionLine(v41, v40 - v22, &v47, &v46, _lastLine + 1, _linesNumb) && _lastLine < v46) {
+ int v23 = GENIAL(v46, v47, v41, v40 - v22, v41, v40 - v39, v7, &super_parcours[0]);
+ if (v23 == -1)
+ return false;
+ v7 = v23;
+ if (NVPY != -1)
+ v22 = NVPY - v40;
}
- NV_LIGNEDEP = v36;
- NV_LIGNEOFS = v35;
- NV_POSI = v7;
- return true;
+ super_parcours[v7].set(v41, v40 - v22, DIR_UP);
+ v7++;
}
- if (v21 == 5) {
- for (int v25 = 0; v25 < v37; v25++) {
- if (checkCollisionLine(v41, v25 + v40, &v47, &v46, _lastLine + 1, _linesNumb) && _lastLine < v46) {
- v26 = GENIAL(v46, v47, v41, v25 + v40, v41, v37 + v40, v7, &super_parcours[0]);
- if (v26 == -1)
- return false;
- v7 = v26;
- if (NVPY != -1)
- v25 = v40 - NVPY;
- }
- super_parcours[v7].set(v41, v25 + v40, 5);
- v7++;
+ NV_LIGNEDEP = v36;
+ NV_LIGNEOFS = v35;
+ NV_POSI = v7;
+ return true;
+ break;
+ case DIR_RIGHT:
+ v36 = v44;
+ v35 = v45;
+ for (int v31 = 0; v31 < v38; v31++) {
+ if (checkCollisionLine(v31 + v41, v40, &v47, &v46, _lastLine + 1, _linesNumb) && _lastLine < v46) {
+ int v32 = GENIAL(v46, v47, v31 + v41, v40, v38 + v41, v40, v7, &super_parcours[0]);
+ if (v32 == -1)
+ return false;
+ v7 = v32;
+ if (NVPX != -1)
+ v31 = NVPX - v41;
}
- NV_LIGNEDEP = v36;
- NV_LIGNEOFS = v35;
- NV_POSI = v7;
- return true;
+ super_parcours[v7].set(v31 + v41, v40, DIR_RIGHT);
+ v7++;
}
- if (v21 == 7) {
- for (int v28 = 0; v28 < v18; v28++) {
- if (checkCollisionLine(v41 - v28, v40, &v47, &v46, _lastLine + 1, _linesNumb) && _lastLine < v46) {
- v29 = GENIAL(v46, v47, v41 - v28, v40, v41 - v18, v40, v7, &super_parcours[0]);
- if (v29 == -1)
- return false;
- v7 = v29;
- if (NVPX != -1)
- v28 = v41 - NVPX;
- }
- super_parcours[v7].set(v41 - v28, v40, 7);
- v7++;
+ NV_LIGNEDEP = v36;
+ NV_LIGNEOFS = v35;
+ NV_POSI = v7;
+ return true;
+ break;
+ case DIR_DOWN:
+ v36 = v48;
+ v35 = v49;
+ for (int v25 = 0; v25 < v37; v25++) {
+ if (checkCollisionLine(v41, v25 + v40, &v47, &v46, _lastLine + 1, _linesNumb) && _lastLine < v46) {
+ int v26 = GENIAL(v46, v47, v41, v25 + v40, v41, v37 + v40, v7, &super_parcours[0]);
+ if (v26 == -1)
+ return false;
+ v7 = v26;
+ if (NVPY != -1)
+ v25 = v40 - NVPY;
}
- NV_LIGNEDEP = v36;
- NV_LIGNEOFS = v35;
- NV_POSI = v7;
- return true;
+ super_parcours[v7].set(v41, v25 + v40, DIR_DOWN);
+ v7++;
}
- if (v21 == 3) {
- for (int v31 = 0; v31 < v38; v31++) {
- if (checkCollisionLine(v31 + v41, v40, &v47, &v46, _lastLine + 1, _linesNumb) && _lastLine < v46) {
- v32 = GENIAL(v46, v47, v31 + v41, v40, v38 + v41, v40, v7, &super_parcours[0]);
- if (v32 == -1)
- return false;
- v7 = v32;
- if (NVPX != -1)
- v31 = NVPX - v41;
- }
- super_parcours[v7].set(v31 + v41, v40, 3);
- v7++;
+ NV_LIGNEDEP = v36;
+ NV_LIGNEOFS = v35;
+ NV_POSI = v7;
+ return true;
+ break;
+ case DIR_LEFT:
+ v36 = v42;
+ v35 = v43;
+ for (int v28 = 0; v28 < v18; v28++) {
+ if (checkCollisionLine(v41 - v28, v40, &v47, &v46, _lastLine + 1, _linesNumb) && _lastLine < v46) {
+ int v29 = GENIAL(v46, v47, v41 - v28, v40, v41 - v18, v40, v7, &super_parcours[0]);
+ if (v29 == -1)
+ return false;
+ v7 = v29;
+ if (NVPX != -1)
+ v28 = v41 - NVPX;
}
- NV_LIGNEDEP = v36;
- NV_LIGNEOFS = v35;
- NV_POSI = v7;
- return true;
+ super_parcours[v7].set(v41 - v28, v40, DIR_LEFT);
+ v7++;
}
+ NV_LIGNEDEP = v36;
+ NV_LIGNEOFS = v35;
+ NV_POSI = v7;
+ return true;
+ break;
}
}
return false;
@@ -1081,31 +1044,31 @@ int LinesManager::GENIAL(int lineIdx, int dataIdx, int a3, int a4, int a5, int a
break;
switch (Ligne[foundLineIdx]._direction) {
- case 1:
+ case DIR_UP:
--NVPY;
break;
- case 2:
+ case DIR_UP_RIGHT:
--NVPY;
++NVPX;
break;
- case 3:
+ case DIR_RIGHT:
++NVPX;
break;
- case 4:
+ case DIR_DOWN_RIGHT:
++NVPY;
++NVPX;
break;
- case 5:
+ case DIR_DOWN:
++NVPY;
break;
- case 6:
+ case DIR_DOWN_LEFT:
++NVPY;
--NVPX;
break;
- case 7:
+ case DIR_LEFT:
--NVPX;
break;
- case 8:
+ case DIR_UP_LEFT:
--NVPY;
--NVPX;
break;
@@ -1135,7 +1098,7 @@ RouteItem *LinesManager::PARCOURS2(int fromX, int fromY, int destX, int destY) {
int v120 = 0;
int v115 = 0;
int v114 = 0;
- int v113 = 0;
+ Directions newDir = DIR_NONE;
int v111 = 0;
if (destY <= 24)
clipDestY = 25;
@@ -1333,22 +1296,22 @@ RouteItem *LinesManager::PARCOURS2(int fromX, int fromY, int destX, int destY) {
if (v141[1] != -1 && v126[3] >= v126[1] && v126[5] >= v126[1] && v126[7] >= v126[1]) {
v115 = v141[1];
v111 = v131[1];
- v113 = 1;
+ newDir = DIR_UP;
v114 = v136[1];
} else if (v141[5] != -1 && v126[3] >= v126[5] && v126[1] >= v126[5] && v126[7] >= v126[5]) {
v115 = v141[5];
v111 = v131[5];
- v113 = 5;
+ newDir = DIR_DOWN;
v114 = v136[5];
} else if (v141[3] != -1 && v126[1] >= v126[3] && v126[5] >= v126[3] && v126[7] >= v126[3]) {
v115 = v141[3];
v111 = v131[3];
- v113 = 3;
+ newDir = DIR_RIGHT;
v114 = v136[3];
} else if (v141[7] != -1 && v126[1] >= v126[7] && v126[5] >= v126[7] && v126[3] >= v126[7]) {
v115 = v141[7];
v111 = v131[7];
- v113 = 7;
+ newDir = DIR_LEFT;
v114 = v136[7];
}
@@ -1362,7 +1325,7 @@ RouteItem *LinesManager::PARCOURS2(int fromX, int fromY, int destX, int destY) {
v114 = NV_LIGNEOFS;
v112 = NV_POSI;
} else {
- if (v113 == 1) {
+ if (newDir == DIR_UP) {
for (int deltaY = 0; deltaY < v111; deltaY++) {
if (checkCollisionLine(fromX, fromY - deltaY, &foundDataIdx, &foundLineIdx, _lastLine + 1, _linesNumb) && _lastLine < foundLineIdx) {
int v58 = GENIAL(foundLineIdx, foundDataIdx, fromX, fromY - deltaY, fromX, fromY - v111, v112, super_parcours);
@@ -1374,11 +1337,11 @@ RouteItem *LinesManager::PARCOURS2(int fromX, int fromY, int destX, int destY) {
if (NVPY != -1)
deltaY = fromY - NVPY;
}
- super_parcours[v112].set(fromX, fromY - deltaY, 1);
+ super_parcours[v112].set(fromX, fromY - deltaY, DIR_UP);
v112++;
}
}
- if (v113 == 5) {
+ if (newDir == DIR_DOWN) {
for (int deltaY = 0; deltaY < v111; deltaY++) {
if (checkCollisionLine(fromX, deltaY + fromY, &foundDataIdx, &foundLineIdx, _lastLine + 1, _linesNumb)
&& _lastLine < foundLineIdx) {
@@ -1391,11 +1354,11 @@ RouteItem *LinesManager::PARCOURS2(int fromX, int fromY, int destX, int destY) {
if (NVPY != -1)
deltaY = NVPY - fromY;
}
- super_parcours[v112].set(fromX, fromY + deltaY, 5);
+ super_parcours[v112].set(fromX, fromY + deltaY, DIR_DOWN);
v112++;
}
}
- if (v113 == 7) {
+ if (newDir == DIR_LEFT) {
for (int deltaX = 0; deltaX < v111; deltaX++) {
if (checkCollisionLine(fromX - deltaX, fromY, &foundDataIdx, &foundLineIdx, _lastLine + 1, _linesNumb) && _lastLine < foundLineIdx) {
int v64 = GENIAL(foundLineIdx, foundDataIdx, fromX - deltaX, fromY, fromX - v111, fromY, v112, &super_parcours[0]);
@@ -1407,11 +1370,11 @@ RouteItem *LinesManager::PARCOURS2(int fromX, int fromY, int destX, int destY) {
if (NVPX != -1)
deltaX = fromX - NVPX;
}
- super_parcours[v112].set(fromX - deltaX, fromY, 7);
+ super_parcours[v112].set(fromX - deltaX, fromY, DIR_LEFT);
v112++;
}
}
- if (v113 == 3) {
+ if (newDir == DIR_RIGHT) {
for (int deltaX = 0; deltaX < v111; deltaX++) {
if (checkCollisionLine(deltaX + fromX, fromY, &foundDataIdx, &foundLineIdx, _lastLine + 1, _linesNumb) && _lastLine < foundLineIdx) {
int v67 = GENIAL(foundLineIdx, foundDataIdx, deltaX + fromX, fromY, v111 + fromX, fromY, v112, &super_parcours[0]);
@@ -1423,7 +1386,7 @@ RouteItem *LinesManager::PARCOURS2(int fromX, int fromY, int destX, int destY) {
if (NVPX != -1)
deltaX = NVPX - fromX;
}
- super_parcours[v112].set(fromX + deltaX, fromY, 3);
+ super_parcours[v112].set(fromX + deltaX, fromY, DIR_RIGHT);
v112++;
}
}
@@ -1558,7 +1521,7 @@ int LinesManager::PARC_PERS(int fromX, int fromY, int destX, int destY, int a5,
bool v45;
int v54;
int v55;
- int newDirection;
+ Directions newDirection;
int v92;
int v93;
int v94;
@@ -1599,30 +1562,30 @@ int LinesManager::PARC_PERS(int fromX, int fromY, int destX, int destY, int a5,
int foundLineIdx = a5;
if (checkCollisionLine(fromX, fromY, &foundDataIdx, &foundLineIdx, 0, _linesNumb)) {
switch (Ligne[foundLineIdx]._direction) {
- case 1:
+ case DIR_UP:
curY -= 2;
break;
- case 2:
+ case DIR_UP_RIGHT:
curY -= 2;
curX += 2;
break;
- case 3:
+ case DIR_RIGHT:
curX += 2;
break;
- case 4:
+ case DIR_DOWN_RIGHT:
curY += 2;
curX += 2;
- case 5:
+ case DIR_DOWN:
curY += 2;
break;
- case 6:
+ case DIR_DOWN_LEFT:
curY += 2;
curX -= 2;
break;
- case 7:
+ case DIR_LEFT:
curX -= 2;
break;
- case 8:
+ case DIR_UP_LEFT:
curY -= 2;
curX -= 2;
break;
@@ -1660,19 +1623,19 @@ int LinesManager::PARC_PERS(int fromX, int fromY, int destX, int destY, int a5,
v99 = -v99;
v13 = (int16)v101 / 1000;
v94 = (int16)v99 / 1000;
- newDirection = -1;
+ newDirection = DIR_NONE;
if (v94 == -1 && (v101 >= 0 && v101 <= 150))
- newDirection = 1;
+ newDirection = DIR_UP;
if (v13 == 1 && (v99 >= -1 && v99 <= 150))
- newDirection = 3;
+ newDirection = DIR_RIGHT;
if (v94 == 1 && (v101 >= -150 && v101 <= 150))
- newDirection = 5;
+ newDirection = DIR_DOWN;
if (v13 == -1 && (v99 >= -150 && v99 <= 150))
- newDirection = 7;
+ newDirection = DIR_LEFT;
if (v94 == -1 && (v101 >= -150 && v101 <= 0))
- newDirection = 1;
+ newDirection = DIR_UP;
- if (newDirection == -1 && !checkSmoothMove(curX, v109, destX, destY) && !makeSmoothMove(curX, v109, destX, destY)) {
+ if (newDirection == DIR_NONE && !checkSmoothMove(curX, v109, destX, destY) && !makeSmoothMove(curX, v109, destX, destY)) {
newDirection = _smoothMoveDirection;
v14 = 0;
for (v14 = 0; _smoothRoute[v14]._posX != -1 && _smoothRoute[v14]._posY != -1; ++v14) {
@@ -1723,71 +1686,71 @@ int LinesManager::PARC_PERS(int fromX, int fromY, int destX, int destY, int a5,
v104 = 1000 * v111 / 1000;
v103 = v105 / 1000;
if (!(v102 / 1000) && v96 == -1)
- newDirection = 1;
+ newDirection = DIR_UP;
if (v22 == 1) {
if (v96 == -1)
- newDirection = 2;
+ newDirection = DIR_UP_RIGHT;
if (!v96)
- newDirection = 3;
+ newDirection = DIR_RIGHT;
if (v96 == 1)
- newDirection = 4;
+ newDirection = DIR_DOWN_RIGHT;
}
if (!v22 && v96 == 1)
- newDirection = 5;
+ newDirection = DIR_DOWN;
if ((v22 != -1) && (v96 == -1)) {
if (v102 >= 0 && v102 < 510)
- newDirection = 1;
+ newDirection = DIR_UP;
else if (v102 >= 510 && v102 <= 1000)
- newDirection = 2;
+ newDirection = DIR_UP_RIGHT;
} else {
if (v96 == 1)
- newDirection = 6;
+ newDirection = DIR_DOWN_LEFT;
else if (!v96)
- newDirection = 7;
+ newDirection = DIR_LEFT;
else if (v96 == -1) {
if (v102 >= 0 && v102 < 510)
- newDirection = 1;
+ newDirection = DIR_UP;
else if (v102 >= 510 && v102 <= 1000)
- newDirection = 2;
+ newDirection = DIR_UP_RIGHT;
else
- newDirection = 8;
+ newDirection = DIR_UP_LEFT;
}
}
if (v22 == 1) {
if (v100 >= -1000 && v100 <= -510)
- newDirection = 2;
+ newDirection = DIR_UP_RIGHT;
if (v100 >= -510 && v100 <= 0)
- newDirection = 3;
+ newDirection = DIR_RIGHT;
if (v100 >= 0 && v100 <= 510)
- newDirection = 3;
+ newDirection = DIR_RIGHT;
if (v100 >= 510 && v100 <= 1000)
- newDirection = 4;
+ newDirection = DIR_DOWN_RIGHT;
}
if (v96 == 1) {
if (v102 >= 510 && v102 <= 1000)
- newDirection = 4;
+ newDirection = DIR_DOWN_RIGHT;
if (v102 >= 0 && v102 <= 510)
- newDirection = 5;
+ newDirection = DIR_DOWN;
if (v102 >= -510 && v102 <= 0)
- newDirection = 5;
+ newDirection = DIR_DOWN;
if (v102 >= -1000 && v102 <= -510)
- newDirection = 6;
+ newDirection = DIR_DOWN_LEFT;
}
if (v22 == -1) {
if (v100 >= 510 && v100 <= 1000)
- newDirection = 6;
+ newDirection = DIR_DOWN_LEFT;
if (v100 >= 0 && v100 <= 510)
- newDirection = 7;
+ newDirection = DIR_LEFT;
if (v100 >= -510 && v100 <= 0)
- newDirection = 7;
+ newDirection = DIR_LEFT;
if (v100 >= -1000 && v100 <= -510)
- newDirection = 8;
+ newDirection = DIR_UP_LEFT;
}
if (v96 == -1) {
if (v102 >= -1000 && v102 <= -510)
- newDirection = 8;
+ newDirection = DIR_UP_LEFT;
if (v102 >= -510 && v102 <= 0)
- newDirection = 1;
+ newDirection = DIR_UP;
}
v23 = 0;
if (v108 + 1 <= 0) {
@@ -1841,9 +1804,9 @@ int LinesManager::PARC_PERS(int fromX, int fromY, int destX, int destY, int a5,
}
if (v33 < destX)
- essai1[v117++].set(v33++, v92, 3);
+ essai1[v117++].set(v33++, v92, DIR_RIGHT);
else
- essai1[v117++].set(v33--, v92, 7);
+ essai1[v117++].set(v33--, v92, DIR_LEFT);
}
if (v33 != destX)
break;
@@ -1863,9 +1826,9 @@ int LinesManager::PARC_PERS(int fromX, int fromY, int destX, int destY, int a5,
}
if (v43 < destY)
- essai1[v117++].set(destX, v43++, 5);
+ essai1[v117++].set(destX, v43++, DIR_DOWN);
else
- essai1[v117++].set(destX, v43--, 1);
+ essai1[v117++].set(destX, v43--, DIR_UP);
}
if (v43 == destY) {
essai1[v117].invalidate();
@@ -1901,9 +1864,9 @@ int LinesManager::PARC_PERS(int fromX, int fromY, int destX, int destY, int a5,
}
if (v55 < destY)
- essai2[v117++].set(v114, v55++, 5);
+ essai2[v117++].set(v114, v55++, DIR_DOWN);
else
- essai2[v117++].set(v114, v55--, 1);
+ essai2[v117++].set(v114, v55--, DIR_UP);
}
if (v55 != destY)
break;
@@ -1925,9 +1888,9 @@ int LinesManager::PARC_PERS(int fromX, int fromY, int destX, int destY, int a5,
}
if (v61 < destX)
- essai2[v117++].set(v61++, destY, 3);
+ essai2[v117++].set(v61++, destY, DIR_RIGHT);
else
- essai2[v117++].set(v61--, destY, 7);
+ essai2[v117++].set(v61--, destY, DIR_LEFT);
}
if (v61 == destX) {
collLineIdx = -1;
@@ -2168,7 +2131,7 @@ RouteItem *LinesManager::cityMapCarRoute(int x1, int y1, int x2, int y2) {
for (;;) {
v28 = essai2[v27]._X;
int v29 = essai2[v27]._Y;
- int v66 = essai2[v27]._dir;
+ Directions v66 = essai2[v27]._dir;
v27++;
if (checkCollisionLine(v28, v29, &arrDataIdx[1], &arrLineIdx[1], 0, _lastLine))
@@ -2323,7 +2286,7 @@ bool LinesManager::makeSmoothMove(int fromX, int fromY, int destX, int destY) {
if (stepCount > 5) {
_smoothRoute[smoothIdx]._posX = -1;
_smoothRoute[smoothIdx]._posY = -1;
- _smoothMoveDirection = 6;
+ _smoothMoveDirection = DIR_DOWN_LEFT;
return false;
}
} else if (fromX < destX && destY > fromY) {
@@ -2357,7 +2320,7 @@ bool LinesManager::makeSmoothMove(int fromX, int fromY, int destX, int destY) {
if (stepCount > 5) {
_smoothRoute[smoothIdx]._posX = -1;
_smoothRoute[smoothIdx]._posY = -1;
- _smoothMoveDirection = 4;
+ _smoothMoveDirection = DIR_DOWN_RIGHT;
return false;
}
} else if (fromX > destX && destY < fromY) {
@@ -2384,7 +2347,7 @@ bool LinesManager::makeSmoothMove(int fromX, int fromY, int destX, int destY) {
if (stepCount > 5) {
_smoothRoute[smoothIdx]._posX = -1;
_smoothRoute[smoothIdx]._posY = -1;
- _smoothMoveDirection = 8;
+ _smoothMoveDirection = DIR_UP_LEFT;
return false;
}
} else if (fromX < destX && destY < fromY) {
@@ -2412,7 +2375,7 @@ bool LinesManager::makeSmoothMove(int fromX, int fromY, int destX, int destY) {
if (stepCount > 5) {
_smoothRoute[smoothIdx]._posX = -1;
_smoothRoute[smoothIdx]._posY = -1;
- _smoothMoveDirection = 2;
+ _smoothMoveDirection = DIR_UP_RIGHT;
return false;
}
}
@@ -2531,9 +2494,9 @@ int LinesManager::TEST_LIGNE(int paramX, int paramY, int *a3, int *foundLineIdx,
*a3 = 1;
int posX = lineData[2 * (lineDataEndIdx - 1)];
int posY = lineData[2 * (lineDataEndIdx - 1) + 1];
- if (Ligne[idx].field6 == 5 || Ligne[idx].field6 == 1)
+ if (Ligne[idx].field6 == DIR_DOWN || Ligne[idx].field6 == DIR_UP)
posY += 2;
- if (Ligne[idx].field6 == 3 || Ligne[idx].field8 == 7)
+ if (Ligne[idx].field6 == DIR_RIGHT || Ligne[idx].field8 == 7)
posX += 2;
if (!checkCollisionLine(posX, posY, &collDataIdx, &collLineIdx, 0, _lastLine))
error("Error in test line");
@@ -2545,9 +2508,9 @@ int LinesManager::TEST_LIGNE(int paramX, int paramY, int *a3, int *foundLineIdx,
*a3 = 2;
int posX = lineData[0];
int posY = lineData[1];
- if (Ligne[idx].field6 == 5 || Ligne[idx].field6 == 1)
+ if (Ligne[idx].field6 == DIR_DOWN || Ligne[idx].field6 == DIR_UP)
posY -= 2;
- if (Ligne[idx].field6 == 3 || Ligne[idx].field8 == 7)
+ if (Ligne[idx].field6 == DIR_RIGHT || Ligne[idx].field8 == 7)
posX -= 2;
if (!checkCollisionLine(posX, posY, &collDataIdx, &collLineIdx, 0, _lastLine))
error("Error in test line");
@@ -2589,9 +2552,9 @@ void LinesManager::PACOURS_PROPRE(RouteItem *route) {
int v12;
int v1 = 0;
- int v14 = -1;
+ Directions v14 = DIR_NONE;
int v2 = route[0]._Y;
- int v15 = route[0]._dir;
+ Directions v15 = route[0]._dir;
if (route[0]._X == -1 && v2 == -1)
return;
@@ -2738,9 +2701,9 @@ int LinesManager::colision(int xp, int yp) {
int yMin = yp - 4;
do {
- int16 *dataP = _vm->_linesManager._zoneLine[curZoneLineIdx]._zoneData;
+ int16 *dataP = _zoneLine[curZoneLineIdx]._zoneData;
if (dataP != (int16 *)g_PTRNUL) {
- int count = _vm->_linesManager._zoneLine[curZoneLineIdx]._count;
+ int count = _zoneLine[curZoneLineIdx]._count;
int v1 = dataP[0];
int v2 = dataP[1];
int v3 = dataP[count * 2 - 2];
@@ -2756,13 +2719,13 @@ int LinesManager::colision(int xp, int yp) {
if (v2 >= v4 && (yMin > v2 || yMax < v4))
flag = false;
- if (flag && _vm->_linesManager._zoneLine[curZoneLineIdx]._count > 0) {
+ if (flag && _zoneLine[curZoneLineIdx]._count > 0) {
for (int i = 0; i < count; ++i) {
int xCheck = *dataP++;
int yCheck = *dataP++;
if ((xp == xCheck || (xp + 1) == xCheck) && (yp == yCheck))
- return _vm->_linesManager._zoneLine[curZoneLineIdx]._bobZoneIdx;
+ return _zoneLine[curZoneLineIdx]._bobZoneIdx;
}
}
}
@@ -2786,18 +2749,18 @@ void LinesManager::CARRE_ZONE() {
}
for (int idx = 0; idx < MAX_LINES; ++idx) {
- int16 *dataP = _vm->_linesManager._zoneLine[idx]._zoneData;
+ int16 *dataP = _zoneLine[idx]._zoneData;
if (dataP == (int16 *)g_PTRNUL)
continue;
- int carreZoneId = _vm->_linesManager._zoneLine[idx]._bobZoneIdx;
+ int carreZoneId = _zoneLine[idx]._bobZoneIdx;
_squareZone[carreZoneId]._enabledFl = 1;
if (_squareZone[carreZoneId]._maxZoneLineIdx < idx)
_squareZone[carreZoneId]._maxZoneLineIdx = idx;
if (_squareZone[carreZoneId]._minZoneLineIdx > idx)
_squareZone[carreZoneId]._minZoneLineIdx = idx;
- for (int i = 0; i < _vm->_linesManager._zoneLine[idx]._count; i++) {
+ for (int i = 0; i < _zoneLine[idx]._count; i++) {
int zoneX = *dataP++;
int zoneY = *dataP++;
@@ -2822,32 +2785,31 @@ void LinesManager::CARRE_ZONE() {
void LinesManager::clearAll() {
for (int idx = 0; idx < 105; ++idx) {
- _vm->_linesManager.ZONEP[idx]._destX = 0;
- _vm->_linesManager.ZONEP[idx]._destY = 0;
- _vm->_linesManager.ZONEP[idx]._spriteIndex = 0;
+ ZONEP[idx]._destX = 0;
+ ZONEP[idx]._destY = 0;
+ ZONEP[idx]._spriteIndex = 0;
}
- _vm->_linesManager.essai0 = (RouteItem *)g_PTRNUL;
- _vm->_linesManager.essai1 = (RouteItem *)g_PTRNUL;
- _vm->_linesManager.essai2 = (RouteItem *)g_PTRNUL;
- _vm->_linesManager.BufLig = (int16 *)g_PTRNUL;
- _vm->_linesManager._route = (RouteItem *)g_PTRNUL;
+ essai0 = (RouteItem *)g_PTRNUL;
+ essai1 = (RouteItem *)g_PTRNUL;
+ essai2 = (RouteItem *)g_PTRNUL;
+ BufLig = (int16 *)g_PTRNUL;
+ _route = (RouteItem *)g_PTRNUL;
for (int idx = 0; idx < MAX_LINES; ++idx) {
- _vm->_linesManager.Ligne[idx]._lineDataEndIdx = 0;
- _vm->_linesManager.Ligne[idx]._direction = 0;
- _vm->_linesManager.Ligne[idx].field6 = 0;
- _vm->_linesManager.Ligne[idx].field8 = 0;
- _vm->_linesManager.Ligne[idx]._lineData = (int16 *)g_PTRNUL;
+ Ligne[idx]._lineDataEndIdx = 0;
+ Ligne[idx]._direction = DIR_NONE;
+ Ligne[idx].field6 = DIR_NONE;
+ Ligne[idx].field8 = DIR_NONE;
+ Ligne[idx]._lineData = (int16 *)g_PTRNUL;
- _vm->_linesManager._zoneLine[idx]._count = 0;
- _vm->_linesManager._zoneLine[idx]._bobZoneIdx = 0;
- _vm->_linesManager._zoneLine[idx]._zoneData = (int16 *)g_PTRNUL;
+ _zoneLine[idx]._count = 0;
+ _zoneLine[idx]._bobZoneIdx = 0;
+ _zoneLine[idx]._zoneData = (int16 *)g_PTRNUL;
}
- for (int idx = 0; idx < 100; ++idx) {
- _vm->_linesManager._squareZone[idx]._enabledFl = 0;
- }
+ for (int idx = 0; idx < 100; ++idx)
+ _squareZone[idx]._enabledFl = 0;
// FIXME: Delete these somewhere
_vm->_linesManager.essai0 = new RouteItem[8334];
@@ -2949,11 +2911,11 @@ void LinesManager::checkZone() {
if (_vm->_globals.compteur_71 <= 1)
return;
- if (_vm->_globals.NOMARCHE || (_vm->_linesManager._route == (RouteItem *)g_PTRNUL) || _vm->_globals.compteur_71 > 4) {
+ if (_vm->_globals.NOMARCHE || (_route == (RouteItem *)g_PTRNUL) || _vm->_globals.compteur_71 > 4) {
_vm->_globals.compteur_71 = 0;
int zoneId;
if (_vm->_globals._oldMouseX != mouseX || _vm->_globals._oldMouseY != oldMouseY) {
- zoneId = _vm->_linesManager.MZONE();
+ zoneId = MZONE();
} else {
zoneId = _vm->_globals._oldMouseZoneId;
}