aboutsummaryrefslogtreecommitdiff
path: root/engines/drascula
diff options
context:
space:
mode:
Diffstat (limited to 'engines/drascula')
-rw-r--r--engines/drascula/drascula.cpp15
-rw-r--r--engines/drascula/drascula.h10
-rw-r--r--engines/drascula/interface.cpp4
-rw-r--r--engines/drascula/objects.cpp4
-rw-r--r--engines/drascula/rooms.cpp41
5 files changed, 36 insertions, 38 deletions
diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp
index 1f3f0c654d..bf333d6575 100644
--- a/engines/drascula/drascula.cpp
+++ b/engines/drascula/drascula.cpp
@@ -744,8 +744,7 @@ bool DrasculaEngine::verify1() {
removeObject();
else {
for (l = 0; l < numRoomObjs; l++) {
- if (_mouseX >= _objectX1[l] && _mouseY >= _objectY1[l]
- && _mouseX <= _objectX2[l] && _mouseY <= _objectY2[l] && doBreak == 0) {
+ if (_objectRect[l].contains(Common::Point(_mouseX, _mouseY)) && doBreak == 0) {
if (exitRoom(l))
return true;
if (doBreak == 1)
@@ -758,10 +757,9 @@ bool DrasculaEngine::verify1() {
doBreak = 1;
for (l = 0; l < numRoomObjs; l++) {
- if (_mouseX > _objectX1[l] && _mouseY > _objectY1[l]
- && _mouseX < _objectX2[l] && _mouseY < _objectY2[l] && doBreak == 0) {
- roomX = roomObjX[l];
- roomY = roomObjY[l];
+ if (_objectRect[l].contains(Common::Point(_mouseX, _mouseY)) && doBreak == 0) {
+ roomX = _roomObject[l].x;
+ roomY = _roomObject[l].y;
trackFinal = trackObj[l];
doBreak = 1;
_walkToObject = true;
@@ -792,11 +790,10 @@ bool DrasculaEngine::verify2() {
return true;
} else {
for (l = 0; l < numRoomObjs; l++) {
- if (_mouseX > _objectX1[l] && _mouseY > _objectY1[l]
- && _mouseX < _objectX2[l] && _mouseY < _objectY2[l] && visible[l] == 1) {
+ if (_objectRect[l].contains(Common::Point(_mouseX, _mouseY)) && visible[l] == 1) {
trackFinal = trackObj[l];
_walkToObject = true;
- gotoObject(roomObjX[l], roomObjY[l]);
+ gotoObject(_roomObject[l].x, _roomObject[l].y);
if (checkAction(objectNum[l]))
return true;
if (currentChapter == 4)
diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h
index d493a9dc73..848b807282 100644
--- a/engines/drascula/drascula.h
+++ b/engines/drascula/drascula.h
@@ -420,11 +420,13 @@ public:
char iconName[44][13];
int objectNum[40], visible[40], isDoor[40];
- int roomObjX[40], roomObjY[40], trackObj[40];
+ int trackObj[40];
+ Common::Point _roomObject[40];
int inventoryObjects[43];
- char _targetSurface[40][20];
- int _destX[40], _destY[40], trackCharacter_alkeva[40], roomExits[40];
- int _objectX1[40], _objectY1[40], _objectX2[40], _objectY2[40];
+ int _doorDestRoom[40];
+ Common::Point _doorDestPoint[40];
+ int trackCharacter_alkeva[40], _roomExitId[40];
+ Common::Rect _objectRect[40];
int takeObject, pickedObject;
bool _subtitlesDisabled;
bool _menuBar, _menuScreen, _hasName;
diff --git a/engines/drascula/interface.cpp b/engines/drascula/interface.cpp
index 07f192cd4c..a0656e1f41 100644
--- a/engines/drascula/interface.cpp
+++ b/engines/drascula/interface.cpp
@@ -165,9 +165,7 @@ void DrasculaEngine::showMap() {
_hasName = false;
for (int l = 0; l < numRoomObjs; l++) {
- if (_mouseX > _objectX1[l] && _mouseY > _objectY1[l]
- && _mouseX < _objectX2[l] && _mouseY < _objectY2[l]
- && visible[l] == 1) {
+ if (_objectRect[l].contains(Common::Point(_mouseX, _mouseY)) && visible[l] == 1) {
strcpy(textName, objName[l]);
_hasName = true;
}
diff --git a/engines/drascula/objects.cpp b/engines/drascula/objects.cpp
index 300d477347..1a87a55a36 100644
--- a/engines/drascula/objects.cpp
+++ b/engines/drascula/objects.cpp
@@ -102,9 +102,7 @@ void DrasculaEngine::checkObjects() {
_hasName = false;
for (l = 0; l < numRoomObjs; l++) {
- if (_mouseX > _objectX1[l] && _mouseY > _objectY1[l]
- && _mouseX < _objectX2[l] && _mouseY < _objectY2[l]
- && visible[l] == 1 && isDoor[l] == 0) {
+ if (_objectRect[l].contains(Common::Point(_mouseX, _mouseY)) && visible[l] == 1 && isDoor[l] == 0) {
strcpy(textName, objName[l]);
_hasName = true;
}
diff --git a/engines/drascula/rooms.cpp b/engines/drascula/rooms.cpp
index 8418135b37..b4de3c51be 100644
--- a/engines/drascula/rooms.cpp
+++ b/engines/drascula/rooms.cpp
@@ -1705,24 +1705,29 @@ void DrasculaEngine::enterRoom(int roomIndex) {
p.parseInt(numRoomObjs);
+ int x1, y1, x2, y2;
+
for (l = 0; l < numRoomObjs; l++) {
p.parseInt(objectNum[l]);
p.parseString(objName[l]);
- p.parseInt(_objectX1[l]);
- p.parseInt(_objectY1[l]);
- p.parseInt(_objectX2[l]);
- p.parseInt(_objectY2[l]);
- p.parseInt(roomObjX[l]);
- p.parseInt(roomObjY[l]);
+ p.parseInt(x1);
+ p.parseInt(y1);
+ p.parseInt(x2);
+ p.parseInt(y2);
+ _objectRect[l] = Common::Rect(x1, y1, x2, y2);
+ p.parseInt(x1);
+ p.parseInt(y1);
+ _roomObject[l] = Common::Point(x1, y1);
p.parseInt(trackObj[l]);
p.parseInt(visible[l]);
p.parseInt(isDoor[l]);
if (isDoor[l] != 0) {
- p.parseString(_targetSurface[l]);
- p.parseInt(_destX[l]);
- p.parseInt(_destY[l]);
+ p.parseInt(_doorDestRoom[l]);
+ p.parseInt(x1);
+ p.parseInt(y1);
+ _doorDestPoint[l] = Common::Point(x1, y1);
p.parseInt(trackCharacter_alkeva[l]);
- p.parseInt(roomExits[l]);
+ p.parseInt(_roomExitId[l]);
updateDoor(l);
}
}
@@ -1767,8 +1772,8 @@ void DrasculaEngine::enterRoom(int roomIndex) {
if (currentChapter == 2) {
if (curX == -1) {
- curX = _destX[objIsExit];
- curY = _destY[objIsExit] - curHeight;
+ curX = _doorDestPoint[objIsExit].x;
+ curY = _doorDestPoint[objIsExit].y - curHeight;
}
_characterMoved = false;
}
@@ -1820,8 +1825,8 @@ void DrasculaEngine::enterRoom(int roomIndex) {
if (currentChapter != 2) {
if (curX == -1) {
- curX = _destX[objIsExit];
- curY = _destY[objIsExit];
+ curX = _doorDestPoint[objIsExit].x;
+ curY = _doorDestPoint[objIsExit].y;
curHeight = (CHARACTER_HEIGHT * factor_red[curY]) / 100;
curWidth = (CHARACTER_WIDTH * factor_red[curY]) / 100;
curY = curY - curHeight;
@@ -1915,7 +1920,7 @@ bool DrasculaEngine::exitRoom(int doorNumber) {
((currentChapter != 3 && currentChapter != 5) || visible[doorNumber] == 1)) {
hideCursor();
- gotoObject(roomObjX[doorNumber], roomObjY[doorNumber]);
+ gotoObject(_roomObject[doorNumber].x, _roomObject[doorNumber].y);
if (currentChapter != 2) {
trackProtagonist = trackObj[doorNumber];
updateRoom();
@@ -1923,7 +1928,7 @@ bool DrasculaEngine::exitRoom(int doorNumber) {
}
_characterMoved = false;
trackProtagonist = trackCharacter_alkeva[doorNumber];
- objExit = roomExits[doorNumber];
+ objExit = _roomExitId[doorNumber];
doBreak = 1;
previousMusic = roomMusic;
@@ -1960,9 +1965,7 @@ bool DrasculaEngine::exitRoom(int doorNumber) {
_characterVisible = true;
clearRoom();
- if (!sscanf(_targetSurface[doorNumber], "%d", &roomNum)) {
- error("Malformed roomNum in targetSurface (%s)", _targetSurface[doorNumber]);
- }
+ roomNum = _doorDestRoom[doorNumber];
curX = -1;
enterRoom(roomNum);