aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorJoseph-Eugene Winzer2017-08-28 13:40:32 +0200
committerThierry Crozat2018-01-23 01:52:59 +0000
commitedef2792da5ca6f039a6d9ff7618cd9ad217f444 (patch)
tree60a9bd3b6c9c6a6c09b773fc1dde90bb2b6186c0 /engines
parentbc43ff820e309ce1f6d7b5748bf8d43647433c67 (diff)
downloadscummvm-rg350-edef2792da5ca6f039a6d9ff7618cd9ad217f444.tar.gz
scummvm-rg350-edef2792da5ca6f039a6d9ff7618cd9ad217f444.tar.bz2
scummvm-rg350-edef2792da5ca6f039a6d9ff7618cd9ad217f444.zip
SUPERNOVA: Adds RoomID to Rooms
GameManager::airless() determined if the space suit could be taken off by comparing the current room pointer to the allocated room objects. This led to indeterministic behavior as sometimes airless() would falsely return true as the dynamic allocation of the Room objects cannot be expected to be in a certain order. Implementing the corresponing RoomID to a Room objects solves this problem.
Diffstat (limited to 'engines')
-rw-r--r--engines/supernova/rooms.cpp18
-rw-r--r--engines/supernova/rooms.h59
-rw-r--r--engines/supernova/state.cpp52
-rw-r--r--engines/supernova/state.h3
-rw-r--r--engines/supernova/supernova.cpp4
5 files changed, 95 insertions, 41 deletions
diff --git a/engines/supernova/rooms.cpp b/engines/supernova/rooms.cpp
index 2e2dd5a377..cfccd11b58 100644
--- a/engines/supernova/rooms.cpp
+++ b/engines/supernova/rooms.cpp
@@ -27,12 +27,11 @@
namespace Supernova {
-void StartingItems::onEntrance() {
- for (int i = 0; i < 3; ++i)
- _gm->_inventory.add(*getObject(i));
+void Intro::onEntrance() {
+}
+
+bool Intro::interact(Action verb, Object &obj1, Object &obj2) {
- setRoomSeen(true);
- _gm->changeRoom(CABIN_R3);
}
bool ShipCorridor::interact(Action verb, Object &obj1, Object &obj2) {
@@ -566,6 +565,13 @@ bool ShipCabinR3::interact(Action verb, Object &obj1, Object &obj2) {
return true;
}
+void ShipCabinR3::onEntrance() {
+ for (int i = 0; i < 3; ++i)
+ _gm->_inventory.add(*_gm->_rooms[INTRO]->getObject(i));
+
+ setRoomSeen(true);
+}
+
bool ShipAirlock::interact(Action verb, Object &obj1, Object &obj2) {
Room *r;
@@ -2367,7 +2373,7 @@ bool AxacussBcorridor::interact(Action verb, Object &obj1, Object &obj2) {
}
} else if ((verb == ACTION_LOOK) &&
(obj1._id >= DOOR1) && (obj1._id <= DOOR4)) {
- _gm->_state._nameSeen |= 1 << (obj1._id - DOOR1);
+ _nameSeen |= 1 << (obj1._id - DOOR1);
return false;
} else if ((verb == ACTION_WALK) &&
((obj1._id == PILLAR1) || (obj1._id == PILLAR2))) {
diff --git a/engines/supernova/rooms.h b/engines/supernova/rooms.h
index 650fac9367..ae92f84c9d 100644
--- a/engines/supernova/rooms.h
+++ b/engines/supernova/rooms.h
@@ -50,6 +50,9 @@ public:
int getFileNumber() const {
return _fileNumber;
}
+ RoomID getId() const {
+ return _id;
+ }
void setSectionVisible(uint section, bool visible) {
_shown[section] = visible;
@@ -72,6 +75,7 @@ protected:
int _fileNumber;
bool _shown[kMaxSection];
Object _objectState[kMaxObject];
+ RoomID _id;
SupernovaEngine *_vm;
GameManager *_gm;
@@ -80,14 +84,14 @@ private:
};
// Room 0
-class StartingItems : public Room {
+class Intro : public Room {
public:
- StartingItems(SupernovaEngine *vm, GameManager *gm) {
+ Intro(SupernovaEngine *vm, GameManager *gm) {
_vm = vm;
_gm = gm;
_fileNumber = -1;
-
+ _id = INTRO;
_shown[0] = false;
_objectState[0] =
@@ -105,6 +109,7 @@ public:
}
virtual void onEntrance();
+ virtual bool interact(Action verb, Object &obj1, Object &obj2);
};
// Spaceship
@@ -115,6 +120,7 @@ public:
_gm = gm;
_fileNumber = 17;
+ _id = CORRIDOR;
_shown[0] = true;
_shown[1] = false;
_shown[2] = false;
@@ -143,6 +149,7 @@ public:
_gm = gm;
_fileNumber = 15;
+ _id = HALL;
_shown[0] = true;
_objectState[0] = Object("Luke", "Sie f\204hrt ins Cockpit.", NULLOBJECT, OPENABLE | EXIT, 4, 5, 1, COCKPIT, 10);
@@ -163,6 +170,7 @@ public:
_gm = gm;
_fileNumber = 33;
+ _id = SLEEP;
_shown[0] = true;
_objectState[0] = Object("Luke", "Dies ist eine der Tiefschlafkammern.", CABINS, NULLTYPE, 0, 0, 0, NULLROOM, 0);
@@ -191,6 +199,7 @@ public:
_gm = gm;
_fileNumber = 9;
+ _id = COCKPIT;
_shown[0] = true;
_objectState[0] = Object("Instrumente", "Hmm, sieht ziemlich kompliziert aus.", INSTRUMENTS, NULLTYPE, 2, 2, 0, NULLROOM, 0);
@@ -214,6 +223,7 @@ public:
_gm = gm;
_fileNumber = 21;
+ _id = CABIN_L1;
_shown[0] = true;
_shown[1] = true;
_shown[2] = true;
@@ -243,6 +253,7 @@ public:
_gm = gm;
_fileNumber = 21;
+ _id = CABIN_L2;
_shown[0] = true;
_shown[1] = false;
_shown[2] = false;
@@ -298,6 +309,7 @@ public:
_gm = gm;
_fileNumber = 21;
+ _id = CABIN_L3;
_shown[0] = true;
_shown[1] = false;
_shown[2] = false;
@@ -341,6 +353,7 @@ public:
_gm = gm;
_fileNumber = 22;
+ _id = CABIN_R1;
_shown[0] = true;
_shown[1] = true;
_shown[2] = true;
@@ -364,6 +377,7 @@ public:
_gm = gm;
_fileNumber = 22;
+ _id = CABIN_R2;
_shown[0] = true;
_shown[1] = false;
_shown[2] = false;
@@ -390,6 +404,7 @@ public:
_gm = gm;
_fileNumber = 22;
+ _id = CABIN_R3;
_shown[0] = true;
_shown[1] = false;
_shown[2] = false;
@@ -434,6 +449,7 @@ public:
}
virtual bool interact(Action verb, Object &obj1, Object &obj2);
+ virtual void onEntrance();
};
class ShipCabinBathroom : public Room {
@@ -443,6 +459,7 @@ public:
_gm = gm;
_fileNumber = 23;
+ _id = BATHROOM;
_shown[0] = true;
_objectState[0] = Object("Klo","Ein Klo mit Saugmechanismus.",TOILET,NULLTYPE,0,0,0);
@@ -458,6 +475,7 @@ public:
_gm = gm;
_fileNumber = 34;
+ _id = AIRLOCK;
_shown[0] = true;
_shown[1] = false;
_shown[2] = false;
@@ -486,6 +504,7 @@ public:
_gm = gm;
_fileNumber = 24;
+ _id = HOLD;
_shown[0] = true;
_objectState[0] = Object("",Object::defaultDescription,HOLD_WIRE,COMBINABLE,255,255,0);
@@ -518,6 +537,7 @@ public:
_gm = gm;
_fileNumber = 25;
+ _id = LANDINGMODULE;
_shown[0] = true;
_objectState[0] = Object("Steckdose",Object::defaultDescription,LANDINGMOD_SOCKET,COMBINABLE,1,1,0);
@@ -538,6 +558,7 @@ public:
_gm = gm;
_fileNumber = 18;
+ _id = GENERATOR;
_shown[0] = true;
_shown[1] = false;
_shown[2] = false;
@@ -570,6 +591,7 @@ public:
_gm = gm;
_fileNumber = 4;
+ _id = OUTSIDE;
_shown[0] = true;
_objectState[0] = Object("Luke",Object::defaultDescription,NULLOBJECT,EXIT,0,0,0,GENERATOR,3);
@@ -603,6 +625,7 @@ public:
_gm = gm;
_fileNumber = 12;
+ _id = CAVE;
_shown[0] = false;
_objectState[0] = Object("Ausgang","Hier bist du gerade hergekommen.",NULLOBJECT,EXIT,255,255,0,ROCKS,22);
@@ -616,6 +639,7 @@ public:
_gm = gm;
_fileNumber = 37;
+ _id = MEETUP;
_shown[0] = true;
_objectState[0] = Object("H\224hle",Object::defaultDescription,NULLOBJECT,EXIT,255,255,0,CAVE,22);
@@ -641,6 +665,7 @@ public:
_gm = gm;
_fileNumber = 10;
+ _id = ENTRANCE;
_shown[0] = true;
_objectState[0] = Object("Portier","Du siehst doch selbst, wie er aussieht.",PORTER,TALK,0,0,0);
@@ -696,6 +721,7 @@ public:
_gm = gm;
_fileNumber = 28;
+ _id = REST;
_shown[0] = true;
_objectState[0] = Object("Treppe",Object::defaultDescription,NULLOBJECT,EXIT,0,0,0,ENTRANCE,17);
@@ -718,6 +744,7 @@ public:
_gm = gm;
_fileNumber = 29;
+ _id = ROGER;
_shown[0] = true;
_objectState[0] = Object("Ausgang",Object::defaultDescription,NULLOBJECT,EXIT,255,255,0,REST,19);
@@ -754,6 +781,7 @@ public:
_gm = gm;
_fileNumber = 19;
+ _id = GLIDER;
_shown[0] = true;
_objectState[0] = Object("Ausgang",Object::defaultDescription,NULLOBJECT,EXIT,255,255,0,MEETUP,15);
@@ -782,6 +810,7 @@ public:
_gm = gm;
_fileNumber = 38;
+ _id = MEETUP2;
_shown[0] = true;
_objectState[0] = Object("Roger W.",Object::defaultDescription,ROGER_W,TALK,255,255,0);
@@ -819,6 +848,7 @@ public:
_gm = gm;
_fileNumber = 39;
+ _id = MEETUP3;
_shown[0] = true;
_objectState[0] = Object("Ufo","Der Eingang scheint offen zu sein.",UFO,EXIT,0,0,0,NULLROOM,3);
@@ -848,6 +878,7 @@ public:
_gm = gm;
_fileNumber = 43;
+ _id = CELL;
_shown[0] = true;
_shown[1] = true;
_shown[2] = false;
@@ -904,6 +935,7 @@ public:
_gm = gm;
_fileNumber = 16;
+ _id = CORRIDOR1;
_shown[0] = true;
_shown[1] = false;
_shown[2] = false;
@@ -944,6 +976,7 @@ public:
_gm = gm;
_fileNumber = 16;
+ _id = CORRIDOR2;
_shown[0] = true;
_shown[1] = false;
_shown[2] = true;
@@ -984,7 +1017,7 @@ public:
_gm = gm;
_fileNumber = 16;
-
+ _id = CORRIDOR3;
_shown[0] = true;
_shown[1] = false;
_shown[2] = false;
@@ -1022,6 +1055,7 @@ public:
_gm = gm;
_fileNumber = 16;
+ _id = CORRIDOR4;
_shown[0] = true;
_shown[1] = true;
_shown[2] = true;
@@ -1069,6 +1103,7 @@ public:
_gm = gm;
_fileNumber = 16;
+ _id = CORRIDOR5;
_shown[0] = true;
_shown[1] = false;
_shown[2] = false;
@@ -1123,6 +1158,7 @@ public:
_gm = gm;
_fileNumber = 16;
+ _id = CORRIDOR6;
_shown[0] = true;
_shown[1] = false;
_shown[2] = false;
@@ -1165,6 +1201,7 @@ public:
_gm = gm;
_fileNumber = 16;
+ _id = CORRIDOR7;
_shown[0] = true;
_shown[1] = false;
_shown[2] = false;
@@ -1205,6 +1242,7 @@ public:
_gm = gm;
_fileNumber = 16;
+ _id = CORRIDOR8;
_shown[0] = true;
_shown[1] = true;
_shown[2] = false;
@@ -1249,6 +1287,7 @@ public:
_gm = gm;
_fileNumber = 16;
+ _id = CORRIDOR9;
_shown[0] = true;
_shown[1] = true;
_shown[2] = false;
@@ -1293,6 +1332,7 @@ public:
_gm = gm;
_fileNumber = 6;
+ _id = BCORRIDOR;
_shown[0] = true;
_shown[1] = false;
_shown[2] = false;
@@ -1315,6 +1355,7 @@ public:
private:
Common::String _dontEnter;
+ byte _nameSeen;
};
class AxacussIntersection : public Room {
public:
@@ -1323,6 +1364,7 @@ public:
_gm = gm;
_fileNumber = 40;
+ _id = GUARD;
_shown[0] = true;
_objectState[0] = Object("Ausgang",Object::defaultDescription,NULLOBJECT,EXIT,255,255,0,CORRIDOR4,21);
@@ -1343,6 +1385,7 @@ public:
_gm = gm;
_fileNumber = 42;
+ _id = GUARD3;
_shown[0] = true;
_objectState[0] = Object("Ausgang",Object::defaultDescription,NULLOBJECT,EXIT,255,255,0,CORRIDOR1,22);
@@ -1364,6 +1407,7 @@ public:
_gm = gm;
_fileNumber = 7;
+ _id = OFFICE_L1;
_shown[0] = true;
_shown[1] = false;
_shown[2] = true;
@@ -1398,6 +1442,7 @@ public:
_gm = gm;
_fileNumber = 7;
+ _id = OFFICE_L2;
_shown[0] = true;
_shown[1] = true;
_shown[2] = false;
@@ -1432,6 +1477,7 @@ public:
_gm = gm;
_fileNumber = 8;
+ _id = OFFICE_R1;
_shown[0] = true;
_shown[1] = true;
_shown[2] = false;
@@ -1454,6 +1500,7 @@ public:
_gm = gm;
_fileNumber = 8;
+ _id = OFFICE_R2;
_shown[0] = true;
_shown[1] = false;
_shown[2] = true;
@@ -1474,6 +1521,7 @@ public:
_gm = gm;
_fileNumber = 7;
+ _id = OFFICE_L;
_shown[0] = true;
_shown[1] = false;
_shown[2] = false;
@@ -1509,6 +1557,7 @@ public:
_gm = gm;
_fileNumber = 3;
+ _id = ELEVATOR;
_shown[0] = true;
_objectState[0] = Object("Knopf",Object::defaultDescription,BUTTON1,PRESS,0,0,0);
@@ -1526,6 +1575,7 @@ public:
_gm = gm;
_fileNumber = 5;
+ _id = STATION;
_shown[0] = true;
_objectState[0] = Object("Schild",Object::defaultDescription,STATION_SIGN,NULLTYPE,0,0,0);
_objectState[1] = Object("T\201r",Object::defaultDescription,DOOR,EXIT|OPENABLE|CLOSED,1,1,0,NULLROOM,7);
@@ -1540,6 +1590,7 @@ public:
_gm = gm;
_fileNumber = 32;
+ _id = SIGN;
_shown[0] = true;
_shown[1] = true;
diff --git a/engines/supernova/state.cpp b/engines/supernova/state.cpp
index 84f040d98a..5b5af20e12 100644
--- a/engines/supernova/state.cpp
+++ b/engines/supernova/state.cpp
@@ -236,7 +236,6 @@ void GameManager::initState() {
_state._money = 0;
_state._coins = 0;
_state._shoes = 0;
- _state._nameSeen = 0;
_state._destination = 255;
_state._benOverlay = 0;
_state._language = 0;
@@ -246,14 +245,11 @@ void GameManager::initState() {
_state._terminalStripWire = false;
_state._cableConnected = false;
_state._powerOff = false;
- _state._cockpitSeen = false;
- _state._airlockSeen = false;
- _state._holdSeen = false;
_state._dream = false;
}
void GameManager::initRooms() {
- _rooms[INTRO] = new StartingItems(_vm, this);
+ _rooms[INTRO] = new Intro(_vm, this);
_rooms[CORRIDOR] = new ShipCorridor(_vm, this);
_rooms[HALL] = new ShipHall(_vm, this);
_rooms[SLEEP] = new ShipSleepCabin(_vm, this);
@@ -534,7 +530,7 @@ void GameManager::telomat(int number) {
}
void GameManager::startSearch() {
- if ((_currentRoom >= _rooms[CORRIDOR1]) && (_currentRoom <= _rooms[BCORRIDOR]))
+ if ((_currentRoom->getId() >= CORRIDOR1) && (_currentRoom->getId() <= BCORRIDOR))
busted(0);
_state._corridorSearch = true;
@@ -553,8 +549,8 @@ void GameManager::busted(int i) {
if (i > 0)
drawImage(i);
if (i == 0) {
- if ((_currentRoom >= _rooms[OFFICE_L1]) && (_currentRoom <= _rooms[OFFICE_R2])) {
- if (_currentRoom < _rooms[OFFICE_R1])
+ if ((_currentRoom->getId() >= OFFICE_L1) && (_currentRoom->getId() <= OFFICE_R2)) {
+ if (_currentRoom->getId() < OFFICE_R1)
i = 10;
else
i = 5;
@@ -569,13 +565,13 @@ void GameManager::busted(int i) {
_vm->playSound(kAudioVoiceHalt);
drawImage(i);
wait2(5);
- if (_currentRoom == _rooms[OFFICE_L2])
+ if (_currentRoom->getId() == OFFICE_L2)
i = 13;
drawImage(i + 1);
wait2(3);
drawImage(i + 2);
shot(0, 0);
- } else if (_currentRoom == _rooms[BCORRIDOR]) {
+ } else if (_currentRoom->getId() == BCORRIDOR) {
drawImage(21);
} else {
if (_currentRoom->isSectionVisible(4))
@@ -594,9 +590,9 @@ void GameManager::busted(int i) {
}
void GameManager::guardReturned() {
- if (_currentRoom == _rooms[GUARD])
+ if (_currentRoom->getId() == GUARD)
busted(-1);
- else if ((_currentRoom == _rooms[CORRIDOR9]) && (_currentRoom->isSectionVisible(27)))
+ else if ((_currentRoom->getId() == CORRIDOR9) && (_currentRoom->isSectionVisible(27)))
busted(0);
_rooms[GUARD]->setSectionVisible(1, false);
@@ -611,7 +607,7 @@ void GameManager::guardReturned() {
}
void GameManager::taxi() {
- if (_currentRoom == _rooms[SIGN]) {
+ if (_currentRoom->getId() == SIGN) {
changeRoom(STATION);
}
@@ -658,12 +654,16 @@ void GameManager::great(uint number) {
}
bool GameManager::airless() {
- return (
- ((_currentRoom > _rooms[AIRLOCK]) && (_currentRoom < _rooms[CABIN_R1])) ||
- ((_currentRoom > _rooms[BATHROOM])&& (_currentRoom < _rooms[ENTRANCE])) ||
- ((_currentRoom == _rooms[AIRLOCK]) && (_currentRoom->getObject(1)->hasProperty(OPENED))) ||
- (_currentRoom >= _rooms[MEETUP2])
- );
+ return (_currentRoom->getId() == HOLD ||
+ _currentRoom->getId() == LANDINGMODULE ||
+ _currentRoom->getId() == GENERATOR ||
+ _currentRoom->getId() == OUTSIDE ||
+ _currentRoom->getId() == ROCKS ||
+ _currentRoom->getId() == CAVE ||
+ _currentRoom->getId() == MEETUP ||
+ _currentRoom->getId() == MEETUP2 ||
+ _currentRoom->getId() == MEETUP3 ||
+ (_currentRoom->getId() == AIRLOCK && _rooms[AIRLOCK]->getObject(1)->hasProperty(OPENED)));
}
void GameManager::shipStart() {
@@ -813,12 +813,12 @@ void GameManager::mouseWait(int delay) {
}
void GameManager::roomBrightness() {
- if ((_currentRoom != _rooms[OUTSIDE]) && (_currentRoom < _rooms[ROCKS]) ) {
+ if ((_currentRoom->getId() != OUTSIDE) && (_currentRoom->getId() < ROCKS) ) {
if (_state._powerOff)
_vm->_brightness = 153;
- } else if ((_currentRoom == _rooms[CAVE])) {
+ } else if ((_currentRoom->getId() == CAVE)) {
_vm->_brightness = 0;
- } else if ((_currentRoom == _rooms[GUARD3])) {
+ } else if ((_currentRoom->getId() == GUARD3)) {
if (_state._powerOff)
_vm->_brightness = 0;
}
@@ -1083,7 +1083,7 @@ void GameManager::death(const char *message) {
initState();
initGui();
_inventory.clear();
- changeRoom(INTRO);
+ changeRoom(CABIN_R3);
g_system->fillScreen(kColorBlack);
_vm->paletteFadeIn();
@@ -1293,7 +1293,7 @@ bool GameManager::genericInteract(Action verb, Object &obj1, Object &obj2) {
}
} else if ((verb == ACTION_USE) && (obj1._id == SUIT)) {
takeObject(obj1);
- if ((_currentRoom >= _rooms[ENTRANCE]) && (_currentRoom <= _rooms[ROGER])) {
+ if ((_currentRoom->getId() >= ENTRANCE) && (_currentRoom->getId() <= ROGER)) {
if (obj1.hasProperty(WORN)) {
_vm->renderMessage("Die Luft hier ist atembar,|du ziehst den Anzug aus.");
_rooms[AIRLOCK]->getObject(4)->disableProperty(WORN);
@@ -1319,7 +1319,7 @@ bool GameManager::genericInteract(Action verb, Object &obj1, Object &obj2) {
}
} else if ((verb == ACTION_USE) && (obj1._id == HELMET)) {
takeObject(obj1);
- if ((_currentRoom >= _rooms[ENTRANCE]) && (_currentRoom <= _rooms[ROGER])) {
+ if ((_currentRoom->getId() >= ENTRANCE) && (_currentRoom->getId() <= ROGER)) {
if (obj1.hasProperty(WORN)) {
_vm->renderMessage("Die Luft hier ist atembar,|du ziehst den Anzug aus.");
_rooms[AIRLOCK]->getObject(4)->disableProperty(WORN);
@@ -1347,7 +1347,7 @@ bool GameManager::genericInteract(Action verb, Object &obj1, Object &obj2) {
}
} else if ((verb == ACTION_USE) && (obj1._id == LIFESUPPORT)) {
takeObject(obj1);
- if ((_currentRoom >= _rooms[ENTRANCE]) && (_currentRoom <= _rooms[ROGER])) {
+ if ((_currentRoom->getId() >= ENTRANCE) && (_currentRoom->getId() <= ROGER)) {
if (obj1.hasProperty(WORN)) {
_vm->renderMessage("Die Luft hier ist atembar,|du ziehst den Anzug aus.");
_rooms[AIRLOCK]->getObject(4)->disableProperty(WORN);
diff --git a/engines/supernova/state.h b/engines/supernova/state.h
index affd9b69f5..079e12641f 100644
--- a/engines/supernova/state.h
+++ b/engines/supernova/state.h
@@ -53,9 +53,6 @@ struct GameState {
bool _terminalStripWire;
bool _cableConnected;
bool _powerOff;
- bool _cockpitSeen;
- bool _airlockSeen;
- bool _holdSeen;
bool _dream;
};
diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp
index 941bfc8c40..ed40af99e3 100644
--- a/engines/supernova/supernova.cpp
+++ b/engines/supernova/supernova.cpp
@@ -185,11 +185,11 @@ void SupernovaEngine::updateEvents() {
case Common::EVENT_LBUTTONUP:
// fallthrough
case Common::EVENT_RBUTTONUP:
- // fallthrough
if (_mixer->isSoundHandleActive(_soundHandle) &&
- (_gm->_currentRoom != _gm->_rooms[INTRO]))
+ (_gm->_currentRoom->getId() == INTRO))
return;
_gm->_mouseClicked = true;
+ // fallthrough
case Common::EVENT_MOUSEMOVE:
_gm->_mouseClickType = _event.type;
_gm->_mouseX = _event.mouse.x;