aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2017-11-15 01:49:50 +0200
committerFilippos Karapetis2017-11-15 01:49:50 +0200
commit64b57afe2c140359b04e77689af4ddb53f2b5c7d (patch)
tree164a968b2b8d5a1ef7f912be852fd2e01e41bfa5 /engines
parentb48d1b7b8eda7a5ee43cb5b578cc448eed1b9d39 (diff)
downloadscummvm-rg350-64b57afe2c140359b04e77689af4ddb53f2b5c7d.tar.gz
scummvm-rg350-64b57afe2c140359b04e77689af4ddb53f2b5c7d.tar.bz2
scummvm-rg350-64b57afe2c140359b04e77689af4ddb53f2b5c7d.zip
Revert "DRASCULA: Revert range 4dbed774..1f1d8607"
This reverts commit bf69b25e33189581848412e77624865aa55ba234. The original game had slight differences between the code for each chapter. Part of these changes was to simplify the code and unify some of these differences, particularly in the checks for clickable areas, where the code is using Common::Rects with contains() now. I have play tested the whole game with these changes, there are no visible regressions, and the game is still completable. Thus, I'm restoring the changes to the engine.
Diffstat (limited to 'engines')
-rw-r--r--engines/drascula/animation.cpp38
-rw-r--r--engines/drascula/drascula.cpp33
-rw-r--r--engines/drascula/drascula.h14
-rw-r--r--engines/drascula/interface.cpp4
-rw-r--r--engines/drascula/objects.cpp10
-rw-r--r--engines/drascula/rooms.cpp80
6 files changed, 87 insertions, 92 deletions
diff --git a/engines/drascula/animation.cpp b/engines/drascula/animation.cpp
index 741c145132..c89e5ff738 100644
--- a/engines/drascula/animation.cpp
+++ b/engines/drascula/animation.cpp
@@ -362,7 +362,7 @@ void DrasculaEngine::animation_2_1() {
int l;
- gotoObject(231, 91);
+ walkToPoint(Common::Point(231, 91));
_characterVisible = false;
term_int = 0;
@@ -439,7 +439,7 @@ void DrasculaEngine::animation_2_1() {
if (animate("lev.bin", 15))
break;
- gotoObject(100 + curWidth / 2, 99 + curHeight);
+ walkToPoint(Common::Point(100 + curWidth / 2, 99 + curHeight));
if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE) || shouldQuit())
break;
trackProtagonist = 1;
@@ -484,7 +484,7 @@ void DrasculaEngine::animation_2_1() {
pause(118);
if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE) || shouldQuit())
break;
- gotoObject(132, 97 + curHeight);
+ walkToPoint(Common::Point(132, 97 + curHeight));
pause(60);
if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE) || shouldQuit())
break;
@@ -492,7 +492,7 @@ void DrasculaEngine::animation_2_1() {
if ((term_int == 1) || (getScan() == Common::KEYCODE_ESCAPE) || shouldQuit())
break;
talk_bj(12);
- gotoObject(157, 98 + curHeight);
+ walkToPoint(Common::Point(157, 98 + curHeight));
if (animate("bes.bin", 16))
break;
playMusic(11);
@@ -880,8 +880,8 @@ void DrasculaEngine::animation_23_2() {
trackVonBraun = 1;
talk_vonBraun(16, kVonBraunNormal);
trackVonBraun = 2;
- gotoObject(157, 147);
- gotoObject(131, 149);
+ walkToPoint(Common::Point(157, 147));
+ walkToPoint(Common::Point(131, 149));
trackProtagonist = 0;
animation_14_2();
if (flags[25] == 0)
@@ -1024,7 +1024,7 @@ void DrasculaEngine::animation_31_2() {
talk_vonBraun(44, kVonBraunNormal);
placeVonBraun(-50);
pause(15);
- gotoObject(159, 140);
+ walkToPoint(Common::Point(159, 140));
loadPic(99, backSurface);
playTalkSequence(31); // sequence 31, chapter 2
@@ -1041,8 +1041,8 @@ void DrasculaEngine::animation_31_2() {
void DrasculaEngine::animation_35_2() {
debug(4, "animation_35_2()");
- gotoObject(96, 165);
- gotoObject(79, 165);
+ walkToPoint(Common::Point(96, 165));
+ walkToPoint(Common::Point(79, 165));
updateRoom();
updateScreen();
@@ -1130,7 +1130,7 @@ void DrasculaEngine::animation_2_3() {
loadPic(97, extraSurface);
loadPic(99, backSurface);
- gotoObject(332, 127);
+ walkToPoint(Common::Point(332, 127));
}
void DrasculaEngine::animation_6_3() {
@@ -1221,7 +1221,7 @@ void DrasculaEngine::animation_1_5() {
talk_bj(19);
talk(229);
pause(5);
- gotoObject(114, 170);
+ walkToPoint(Common::Point(114, 170));
trackProtagonist = 3;
talk(431);
talk_bj(20);
@@ -1265,7 +1265,7 @@ void DrasculaEngine::animation_5_5(){
selectVerb(kVerbNone);
removeObject(8);
- gotoObject(curX - 19, curY + curHeight);
+ walkToPoint(Common::Point(curX - 19, curY + curHeight));
trackProtagonist = 1;
updateRoom();
updateScreen();
@@ -1429,8 +1429,8 @@ void DrasculaEngine::animation_12_5() {
loadPic(99, backSurface);
- gotoObject(40, 169);
- gotoObject(-14, 175);
+ walkToPoint(Common::Point(40, 169));
+ walkToPoint(Common::Point(-14, 175));
doBreak = 1;
previousMusic = roomMusic;
@@ -1487,7 +1487,7 @@ void DrasculaEngine::animation_14_5() {
pause(17);
trackProtagonist = 3;
talk(246);
- gotoObject(89, 160);
+ walkToPoint(Common::Point(89, 160));
flags[10] = 1;
playSound(7);
updateRoom();
@@ -1659,7 +1659,7 @@ void DrasculaEngine::animation_9_6() {
updateScreen();
fadeFromBlack(0);
pause(96);
- gotoObject(116, 178);
+ walkToPoint(Common::Point(116, 178));
trackProtagonist = 2;
updateRoom();
updateScreen();
@@ -1844,7 +1844,7 @@ void DrasculaEngine::animation_24_2() {
debug(4, "animation_24_2()");
if (curX < 178)
- gotoObject(208, 136);
+ walkToPoint(Common::Point(208, 136));
trackProtagonist = 3;
updateRoom();
pause(3);
@@ -2139,8 +2139,8 @@ void DrasculaEngine::animation_5_4(){
trackProtagonist = 3;
loadPic("anh_dr.alg", backSurface);
- gotoObject(99, 160);
- gotoObject(38, 177);
+ walkToPoint(Common::Point(99, 160));
+ walkToPoint(Common::Point(38, 177));
_characterVisible = false;
updateRoom();
updateScreen();
diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp
index 1f3f0c654d..3f840b0901 100644
--- a/engines/drascula/drascula.cpp
+++ b/engines/drascula/drascula.cpp
@@ -94,10 +94,6 @@ DrasculaEngine::DrasculaEngine(OSystem *syst, const DrasculaGameDescription *gam
_talkSequencesSize = 0;
_numLangs = 0;
feetHeight = 0;
- floorX1 = 0;
- floorY1 = 0;
- floorX2 = 0;
- floorY2 = 0;
lowerLimit = 0;
upperLimit = 0;
trackFinal = 0;
@@ -444,7 +440,7 @@ bool DrasculaEngine::runCurrentChapter() {
enterRoom(62);
curX = -20;
curY = 56;
- gotoObject(65, 145);
+ walkToPoint(Common::Point(65, 145));
}
// REMINDER: This is a good place to debug animations
@@ -550,14 +546,14 @@ bool DrasculaEngine::runCurrentChapter() {
// made the character start walking off screen, as his actual position was
// different than the displayed one
if (_roomNumber == 3 && (curX == 279) && (curY + curHeight == 101)) {
- gotoObject(178, 121);
- gotoObject(169, 135);
+ walkToPoint(Common::Point(178, 121));
+ walkToPoint(Common::Point(169, 135));
} else if (_roomNumber == 14 && (curX == 214) && (curY + curHeight == 121)) {
_walkToObject = true;
- gotoObject(190, 130);
+ walkToPoint(Common::Point(190, 130));
} else if (_roomNumber == 14 && (curX == 246) && (curY + curHeight == 112)) {
_walkToObject = true;
- gotoObject(190, 130);
+ walkToPoint(Common::Point(190, 130));
}
}
@@ -744,8 +740,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 +753,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;
@@ -770,8 +764,8 @@ bool DrasculaEngine::verify1() {
}
if (doBreak == 0) {
- roomX = CLIP(_mouseX, floorX1, floorX2);
- roomY = CLIP(_mouseY, floorY1 + feetHeight, floorY2);
+ roomX = CLIP<int16>(_mouseX, _walkRect.left, _walkRect.right);
+ roomY = CLIP<int16>(_mouseY, _walkRect.top + feetHeight, _walkRect.bottom);
startWalking();
}
doBreak = 0;
@@ -792,11 +786,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]);
+ walkToPoint(_roomObject[l]);
if (checkAction(objectNum[l]))
return true;
if (currentChapter == 4)
diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h
index fbc29ed206..a7eadcd069 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;
@@ -441,7 +443,7 @@ public:
int doBreak;
int stepX, stepY;
int curHeight, curWidth, feetHeight;
- int floorX1, floorY1, floorX2, floorY2;
+ Common::Rect _walkRect;
int lowerLimit, upperLimit;
int trackFinal;
bool _walkToObject;
@@ -485,7 +487,7 @@ public:
void enterRoom(int);
void clearRoom();
- void gotoObject(int, int);
+ void walkToPoint(Common::Point pos);
void moveCursor();
void checkObjects();
void selectVerbFromBar();
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 cff26c93d5..65c042a9fe 100644
--- a/engines/drascula/objects.cpp
+++ b/engines/drascula/objects.cpp
@@ -57,7 +57,7 @@ void DrasculaEngine::chooseObject(int object) {
pickedObject = object;
}
-void DrasculaEngine::gotoObject(int pointX, int pointY) {
+void DrasculaEngine::walkToPoint(Common::Point pos) {
bool cursorVisible = isCursorVisible();
hideCursor();
@@ -70,8 +70,8 @@ void DrasculaEngine::gotoObject(int pointX, int pointY) {
return;
}
}
- roomX = pointX;
- roomY = pointY;
+ roomX = pos.x;
+ roomY = pos.y;
startWalking();
while (!shouldQuit()) {
@@ -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 75d2928f0f..f99f00c8e7 100644
--- a/engines/drascula/rooms.cpp
+++ b/engines/drascula/rooms.cpp
@@ -690,7 +690,7 @@ bool DrasculaEngine::room_26(int fl) {
else if (pickedObject == 16 && fl == 50 && flags[18] == 1 && flags[12] == 1)
animation_5_4();
else if (pickedObject == kVerbPick && fl == 143 && flags[18] == 1) {
- gotoObject(260, 180);
+ walkToPoint(Common::Point(260, 180));
pickObject(10);
visible[1] = 0;
flags[12] = 1;
@@ -699,14 +699,14 @@ bool DrasculaEngine::room_26(int fl) {
talk_igor(27, kIgorDoor);
flags[30] = 1;
talk_igor(28, kIgorDoor);
- gotoObject(153, 180);
+ walkToPoint(Common::Point(153, 180));
} else if (pickedObject == kVerbPick && fl == 143 && flags[18] == 0) {
- gotoObject(260, 180);
+ walkToPoint(Common::Point(260, 180));
copyBackground(80, 78, 199, 94, 38, 27, drawSurface3, screenSurface);
updateScreen(199, 94, 199, 94, 38, 27, screenSurface);
pause(3);
talk_igor(25, kIgorWig);
- gotoObject(153, 180);
+ walkToPoint(Common::Point(153, 180));
} else if (pickedObject == kVerbTalk && fl == 51)
animation_1_4();
else
@@ -927,7 +927,7 @@ bool DrasculaEngine::room_55(int fl) {
playSound(11);
animate("det.bin", 17);
finishSound();
- gotoObject(curX - 3, curY + curHeight + 6);
+ walkToPoint(Common::Point(curX - 3, curY + curHeight + 6));
} else
hasAnswer = 0;
@@ -972,7 +972,7 @@ bool DrasculaEngine::room_59(int fl) {
delay(40);
finishSound();
delay(10);
- gotoObject(174, 168);
+ walkToPoint(Common::Point(174, 168));
trackProtagonist = 2;
updateRoom();
updateScreen();
@@ -1705,32 +1705,38 @@ 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);
}
}
- p.parseInt(floorX1);
- p.parseInt(floorY1);
- p.parseInt(floorX2);
- p.parseInt(floorY2);
+ p.parseInt(x1);
+ p.parseInt(y1);
+ p.parseInt(x2);
+ p.parseInt(y2);
+ _walkRect = Common::Rect(x1, y1, x2, y2);
if (currentChapter != 2) {
p.parseInt(upperLimit);
@@ -1767,8 +1773,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;
}
@@ -1792,27 +1798,27 @@ void DrasculaEngine::enterRoom(int roomIndex) {
color_abc(kColorLightGreen);
if (currentChapter != 2) {
- for (l = 0; l <= floorY1; l++)
+ for (l = 0; l <= _walkRect.top; l++)
factor_red[l] = upperLimit;
- for (l = floorY1; l <= 201; l++)
+ for (l = _walkRect.top; l <= 201; l++)
factor_red[l] = lowerLimit;
- chiquez = (float)(lowerLimit - upperLimit) / (float)(floorY2 - floorY1);
- for (l = floorY1; l <= floorY2; l++) {
+ chiquez = (float)(lowerLimit - upperLimit) / (float)(_walkRect.bottom - _walkRect.top);
+ for (l = _walkRect.top; l <= _walkRect.bottom; l++) {
factor_red[l] = (int)(upperLimit + pequegnez);
pequegnez = pequegnez + chiquez;
}
}
if (_roomNumber == 24) {
- for (l = floorY1 - 1; l > 74; l--) {
+ for (l = _walkRect.top - 1; l > 74; l--) {
factor_red[l] = (int)(upperLimit - pequegnez);
pequegnez = pequegnez + chiquez;
}
}
if (currentChapter == 5 && _roomNumber == 54) {
- for (l = floorY1 - 1; l > 84; l--) {
+ for (l = _walkRect.top - 1; l > 84; l--) {
factor_red[l] = (int)(upperLimit - pequegnez);
pequegnez = pequegnez + chiquez;
}
@@ -1820,8 +1826,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 +1921,7 @@ bool DrasculaEngine::exitRoom(int doorNumber) {
((currentChapter != 3 && currentChapter != 5) || visible[doorNumber] == 1)) {
hideCursor();
- gotoObject(roomObjX[doorNumber], roomObjY[doorNumber]);
+ walkToPoint(_roomObject[doorNumber]);
if (currentChapter != 2) {
trackProtagonist = trackObj[doorNumber];
updateRoom();
@@ -1923,7 +1929,7 @@ bool DrasculaEngine::exitRoom(int doorNumber) {
}
_characterMoved = false;
trackProtagonist = trackCharacter_alkeva[doorNumber];
- objExit = roomExits[doorNumber];
+ objExit = _roomExitId[doorNumber];
doBreak = 1;
previousMusic = roomMusic;
@@ -1935,8 +1941,8 @@ bool DrasculaEngine::exitRoom(int doorNumber) {
if (objectNum[doorNumber] == 136)
animation_2_2();
if (objectNum[doorNumber] == 124) {
- gotoObject(163, 106);
- gotoObject(287, 101);
+ walkToPoint(Common::Point(163, 106));
+ walkToPoint(Common::Point(287, 101));
trackProtagonist = 0;
}
if (objectNum[doorNumber] == 173) {
@@ -1953,16 +1959,14 @@ bool DrasculaEngine::exitRoom(int doorNumber) {
addObject(kItemEarplugs);
}
} else if (currentChapter == 4 && objectNum[doorNumber] == 108) {
- gotoObject(171, 78);
+ walkToPoint(Common::Point(171, 78));
}
if (currentChapter == 5)
_characterVisible = true;
clearRoom();
- if (!sscanf(_targetSurface[doorNumber], "%d", &roomNum)) {
- error("Malformed roomNum in targetSurface (%s)", _targetSurface[doorNumber]);
- }
+ roomNum = _doorDestRoom[doorNumber];
curX = -1;
enterRoom(roomNum);