aboutsummaryrefslogtreecommitdiff
path: root/engines/hopkins
diff options
context:
space:
mode:
authorStrangerke2013-01-10 22:09:37 +0100
committerStrangerke2013-01-10 22:09:37 +0100
commit9f153a3cbd47da66da6e2f03b909e20fc993d4c0 (patch)
tree6488d55ca5ed5db7053a82d62d62627457eb485b /engines/hopkins
parentde93e44b16375a272618722745287fdefd2547de (diff)
downloadscummvm-rg350-9f153a3cbd47da66da6e2f03b909e20fc993d4c0.tar.gz
scummvm-rg350-9f153a3cbd47da66da6e2f03b909e20fc993d4c0.tar.bz2
scummvm-rg350-9f153a3cbd47da66da6e2f03b909e20fc993d4c0.zip
HOPKINS: Get rid of a magic value, rename a couple of pathfinding functions
Diffstat (limited to 'engines/hopkins')
-rw-r--r--engines/hopkins/globals.cpp2
-rw-r--r--engines/hopkins/hopkins.h2
-rw-r--r--engines/hopkins/lines.cpp24
-rw-r--r--engines/hopkins/lines.h4
-rw-r--r--engines/hopkins/objects.cpp8
-rw-r--r--engines/hopkins/talk.cpp4
6 files changed, 23 insertions, 21 deletions
diff --git a/engines/hopkins/globals.cpp b/engines/hopkins/globals.cpp
index 2392376a97..319516ada6 100644
--- a/engines/hopkins/globals.cpp
+++ b/engines/hopkins/globals.cpp
@@ -324,7 +324,7 @@ void Globals::clearAll() {
BufLig = (int16 *)g_PTRNUL;
chemin = (int16 *)g_PTRNUL;
- for (int idx = 0; idx < 400; ++idx) {
+ for (int idx = 0; idx < MAX_LINES; ++idx) {
_vm->_linesManager.Ligne[idx]._lineDataEndIdx = 0;
_vm->_linesManager.Ligne[idx].field2 = 0;
_vm->_linesManager.Ligne[idx].field4 = 0;
diff --git a/engines/hopkins/hopkins.h b/engines/hopkins/hopkins.h
index 18c7414827..9b1bce5509 100644
--- a/engines/hopkins/hopkins.h
+++ b/engines/hopkins/hopkins.h
@@ -73,6 +73,8 @@ enum {
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
+#define MAX_LINES 400
+
struct HopkinsGameDescription;
class HopkinsEngine : public Engine {
diff --git a/engines/hopkins/lines.cpp b/engines/hopkins/lines.cpp
index 44dc5b06f3..5ebc762fbc 100644
--- a/engines/hopkins/lines.cpp
+++ b/engines/hopkins/lines.cpp
@@ -29,7 +29,7 @@
namespace Hopkins {
LinesManager::LinesManager() {
- for (int i = 0; i < 400; ++i) {
+ for (int i = 0; i < MAX_LINES; ++i) {
Common::fill((byte *)&_zoneLine[i], (byte *)&_zoneLine[i] + sizeof(LigneZoneItem), 0);
Common::fill((byte *)&Ligne[i], (byte *)&Ligne[i] + sizeof(LigneItem), 0);
}
@@ -53,7 +53,7 @@ void LinesManager::setParent(HopkinsEngine *vm) {
}
void LinesManager::CLEAR_ZONE() {
- for (int idx = 0; idx < 400; ++idx)
+ for (int idx = 0; idx < MAX_LINES; ++idx)
removeZoneLine(idx);
next_ligne = 0;
@@ -120,7 +120,7 @@ int LinesManager::OPTI_ZONE(int posX, int minZoneNum, bool lastRow) {
* Remove Zone Line
*/
void LinesManager::removeZoneLine(int idx) {
- if (idx > 400)
+ if (idx > MAX_LINES)
error("Attempting to remove a line obstacle > MAX_LIGNE.");
_vm->_linesManager._zoneLine[idx].zoneData = (int16 *)_vm->_globals.freeMemory((byte *)_vm->_linesManager._zoneLine[idx].zoneData);
@@ -136,7 +136,7 @@ void LinesManager::addZoneLine(int idx, int a2, int a3, int a4, int a5, int bobZ
_vm->_globals.BOBZONE_FLAG[bobZoneIdx] = true;
_vm->_globals.BOBZONE[bobZoneIdx] = a3;
} else {
- if (idx > 400)
+ if (idx > MAX_LINES)
error("Attempting to add a line obstacle > MAX_LIGNE.");
_zoneLine[idx].zoneData = (int16 *)_vm->_globals.freeMemory((byte *)_zoneLine[idx].zoneData);
@@ -180,17 +180,17 @@ void LinesManager::addZoneLine(int idx, int a2, int a3, int a4, int a5, int bobZ
}
-void LinesManager::RESET_OBSTACLE() {
- for (int idx = 0; idx < 400; ++idx) {
- RETIRE_LIGNE(idx);
+void LinesManager::resetLines() {
+ for (int idx = 0; idx < MAX_LINES; ++idx) {
+ removeLine(idx);
Ligne[idx]._lineDataEndIdx = 0;
Ligne[idx]._lineData = (int16 *)g_PTRNUL;
}
}
// Remove Line
-void LinesManager::RETIRE_LIGNE(int idx) {
- if (idx > 400)
+void LinesManager::removeLine(int idx) {
+ if (idx > MAX_LINES)
error("Attempting to add a line obstacle > MAX_LIGNE.");
Ligne[idx]._lineData = (int16 *)_vm->_globals.freeMemory((byte *)Ligne[idx]._lineData);
}
@@ -219,7 +219,7 @@ void LinesManager::AJOUTE_LIGNE(int idx, int a2, int a3, int a4, int a5, int a6,
int v39;
int v40;
- if (idx > 400)
+ if (idx > MAX_LINES)
error("Attempting to add a line obstacle > MAX_LIGNE.");
if (_linesNumb < idx)
@@ -419,7 +419,7 @@ void LinesManager::initRoute() {
_vm->_graphicsManager.min_x == curLineX || _vm->_graphicsManager.min_y == curLineY ||
(lineX == curLineX && lineY == curLineY))
break;
- if (lineIdx == 400)
+ if (lineIdx == MAX_LINES)
error("ERROR - LAST LINE NOT FOUND");
int16 *nextLineData = Ligne[lineIdx + 1]._lineData;
@@ -429,7 +429,7 @@ void LinesManager::initRoute() {
}
_vm->_objectsManager._lastLine = lineIdx;
- for (int idx = 1; idx < 400; idx++) {
+ for (int idx = 1; idx < MAX_LINES; idx++) {
if ((Ligne[idx]._lineDataEndIdx < _vm->_globals._maxLineLength) && (idx != _vm->_objectsManager._lastLine + 1)) {
Ligne[idx].field6 = Ligne[idx - 1].field6;
Ligne[idx].field8 = Ligne[idx - 1].field8;
diff --git a/engines/hopkins/lines.h b/engines/hopkins/lines.h
index e6dcd2539f..67b5fa44a0 100644
--- a/engines/hopkins/lines.h
+++ b/engines/hopkins/lines.h
@@ -75,8 +75,8 @@ public:
int OPTI_ZONE(int posX, int minZoneNum, bool lastRow);
void removeZoneLine(int idx);
void addZoneLine(int idx, int a2, int a3, int a4, int a5, int bobZoneIdx);
- void RESET_OBSTACLE();
- void RETIRE_LIGNE(int idx);
+ void resetLines();
+ void removeLine(int idx);
void AJOUTE_LIGNE(int idx, int a2, int a3, int a4, int a5, int a6, int a7);
bool checkCollisionLine(int xp, int yp, int *foundDataIdx, int *foundLineIdx, int startLineIdx, int endLineIdx);
void initRoute();
diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp
index d78990431e..c01901d2fb 100644
--- a/engines/hopkins/objects.cpp
+++ b/engines/hopkins/objects.cpp
@@ -2049,7 +2049,7 @@ void ObjectsManager::GOHOME2() {
// Load Obstacle
void ObjectsManager::CHARGE_OBSTACLE(const Common::String &file) {
- _vm->_linesManager.RESET_OBSTACLE();
+ _vm->_linesManager.resetLines();
_vm->_linesManager._linesNumb = 0;
_lastLine = 0;
byte *ptr = _vm->_fileManager.loadFile(file);
@@ -2177,7 +2177,7 @@ void ObjectsManager::CARRE_ZONE() {
_vm->_globals.CarreZone[idx].fieldC = 0;
}
- for (int idx = 0; idx < 400; ++idx) {
+ for (int idx = 0; idx < MAX_LINES; ++idx) {
dataP = _vm->_linesManager._zoneLine[idx].zoneData;
if (dataP != (int16 *)g_PTRNUL) {
v4 = _vm->_linesManager._zoneLine[idx].field2;
@@ -2620,7 +2620,7 @@ void ObjectsManager::CLEAR_ECRAN() {
_vm->_globals.CLEAR_VBOB();
_vm->_animationManager.clearAnim();
_vm->_linesManager.CLEAR_ZONE();
- _vm->_linesManager.RESET_OBSTACLE();
+ _vm->_linesManager.resetLines();
_vm->_globals.resetCache();
for (int v1 = 0; v1 <= 48; v1++) {
@@ -4131,7 +4131,7 @@ void ObjectsManager::INILINK(const Common::String &file) {
}
}
- _vm->_linesManager.RESET_OBSTACLE();
+ _vm->_linesManager.resetLines();
for (size_t idx = 0; idx < nbytes; idx++) {
if (ptr[idx] == 'O' && ptr[idx + 1] == 'B' && ptr[idx + 2] == '2') {
v16 = ptr + idx + 4;
diff --git a/engines/hopkins/talk.cpp b/engines/hopkins/talk.cpp
index ff4642c18e..ae403d6d1f 100644
--- a/engines/hopkins/talk.cpp
+++ b/engines/hopkins/talk.cpp
@@ -1070,7 +1070,7 @@ void TalkManager::OBJET_VIVANT(const Common::String &a2) {
_vm->_eventsManager.VBL();
_vm->_graphicsManager.no_scroll = 1;
_vm->_linesManager.CLEAR_ZONE();
- _vm->_linesManager.RESET_OBSTACLE();
+ _vm->_linesManager.resetLines();
_vm->_globals.resetCache();
for (int i = 0; i <= 44; i++)
@@ -1146,7 +1146,7 @@ void TalkManager::OBJET_VIVANT(const Common::String &a2) {
_characterSprite = _vm->_globals.freeMemory(_characterSprite);
_vm->_graphicsManager.NB_SCREEN(false);
_vm->_linesManager.CLEAR_ZONE();
- _vm->_linesManager.RESET_OBSTACLE();
+ _vm->_linesManager.resetLines();
_vm->_globals.resetCache();
for (int i = 0; i <= 44; i++)
_vm->_globals.BOBZONE[i] = 0;