aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-06-22 20:43:54 -0400
committerPaul Gilbert2016-07-15 19:24:04 -0400
commit452274dae027933b2199cd26236f1a5e908c4275 (patch)
treea5fe0f1e8ccc2b20cb00e33e24be8f7b302d4341
parent5aff1d01b4088979e207c434476fa7ca3f6a644f (diff)
downloadscummvm-rg350-452274dae027933b2199cd26236f1a5e908c4275.tar.gz
scummvm-rg350-452274dae027933b2199cd26236f1a5e908c4275.tar.bz2
scummvm-rg350-452274dae027933b2199cd26236f1a5e908c4275.zip
TITANIC: Flesh out PET Rooms adding glyphs
-rw-r--r--engines/titanic/core/game_object.cpp4
-rw-r--r--engines/titanic/core/game_object.h2
-rw-r--r--engines/titanic/npcs/deskbot.cpp6
-rw-r--r--engines/titanic/pet_control/pet_control.cpp4
-rw-r--r--engines/titanic/pet_control/pet_control.h5
-rw-r--r--engines/titanic/pet_control/pet_rooms.cpp45
-rw-r--r--engines/titanic/pet_control/pet_rooms.h11
-rw-r--r--engines/titanic/pet_control/pet_rooms_glyphs.cpp10
-rw-r--r--engines/titanic/pet_control/pet_rooms_glyphs.h54
9 files changed, 101 insertions, 40 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index aa0de49174..695a6d66a5 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -790,10 +790,10 @@ void CGameObject::dec54() {
getGameManager()->dec54();
}
-void CGameObject::petAddRoom(int roomNum) {
+void CGameObject::petAddRandomRoom(int passClassNum) {
CPetControl *petControl = getPetControl();
if (petControl)
- petControl->addRoom(roomNum);
+ petControl->addRandomRoom(passClassNum);
}
void CGameObject::lockMouse() {
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 20729d586a..bb6b161a48 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -149,7 +149,7 @@ protected:
/**
* Adds a room to the room list
*/
- void petAddRoom(int roomNum);
+ void petAddRandomRoom(int passClassNum);
/**
* Locks/hides the mouse
diff --git a/engines/titanic/npcs/deskbot.cpp b/engines/titanic/npcs/deskbot.cpp
index 18c1e2a137..a52d7c7e4d 100644
--- a/engines/titanic/npcs/deskbot.cpp
+++ b/engines/titanic/npcs/deskbot.cpp
@@ -178,16 +178,16 @@ bool CDeskbot::TrueTalkTriggerActionMsg(CTrueTalkTriggerActionMsg *msg) {
case 1:
petDisplayMsg("You have been upgraded to 1st Class status. Enjoy hugely.");
setPassengerClass(_classNum);
- petAddRoom(_classNum);
+ petAddRandomRoom(_classNum);
break;
case 2:
petDisplayMsg("You have been upgraded to 2nd Class status. Enjoy.");
setPassengerClass(_classNum);
- petAddRoom(_classNum);
+ petAddRandomRoom(_classNum);
break;
case 3:
setPassengerClass(3);
- petAddRoom(_classNum);
+ petAddRandomRoom(_classNum);
break;
default:
break;
diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp
index f7973e008b..e7bf1eeb7a 100644
--- a/engines/titanic/pet_control/pet_control.cpp
+++ b/engines/titanic/pet_control/pet_control.cpp
@@ -520,8 +520,8 @@ CString CPetControl::getFullViewName() {
return gameManager ? gameManager->getFullViewName() : CString();
}
-void CPetControl::addRoom(int roomNum) {
- _rooms.addRoom(roomNum);
+void CPetControl::addRandomRoom(int passClassNum) {
+ _rooms.addRandomRoom(passClassNum);
}
int CPetControl::roomFn2(int val) {
diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h
index 758069e5f1..652a6e8c83 100644
--- a/engines/titanic/pet_control/pet_control.h
+++ b/engines/titanic/pet_control/pet_control.h
@@ -307,9 +307,10 @@ public:
CString getFullViewName();
/**
- * Adds a room to the room list
+ * Adds a random room to the room list
*/
- void addRoom(int roomNum);
+ void addRandomRoom(int passClassNum);
+
int roomFn2(int val);
/**
diff --git a/engines/titanic/pet_control/pet_rooms.cpp b/engines/titanic/pet_control/pet_rooms.cpp
index 29a46880e0..b98c68c174 100644
--- a/engines/titanic/pet_control/pet_rooms.cpp
+++ b/engines/titanic/pet_control/pet_rooms.cpp
@@ -212,8 +212,45 @@ void CPetRooms::areaChanged(PetArea area) {
_petControl->makeDirty();
}
-CPetRoomsGlyph *CPetRooms::addGlyph(int val, bool highlight) {
- CPetRoomsGlyph *glyph = new CPetRoomsGlyph(val);
+void CPetRooms::addRandomRoom(int passClassNum) {
+ CPetRoomsGlyph *glyph = _glyphs.findMode1();
+ if (glyph)
+ glyph->setMode(RGM_2);
+
+ CRoomFlags roomFlags;
+ roomFlags.setRandomLocation(passClassNum, _field1D4);
+ if (addRoom(roomFlags, true)) {
+
+ }
+
+ warning("TODO: CPetRooms::addRoom");
+}
+
+CPetRoomsGlyph *CPetRooms::addRoom(uint roomFlags, bool highlight) {
+ // Ensure that we don't add room if the room is already present
+ if (_glyphs.hasFlags(roomFlags))
+ return nullptr;
+
+ if (_glyphs.size() >= 32)
+ // Too many rooms already
+ return nullptr;
+
+ // Do a preliminary scan of the glyph list for any glyph that is
+ // no longer valid, and thus can be removed
+ for (CPetRoomsGlyphs::iterator i = _glyphs.begin(); i != _glyphs.end(); ++i) {
+ CPetRoomsGlyph *glyph = static_cast<CPetRoomsGlyph *>(*i);
+ if (!glyph->isModeValid()) {
+ _glyphs.erase(i);
+ break;
+ }
+ }
+
+ // Add the glyph
+ return addGlyph(roomFlags, highlight);
+}
+
+CPetRoomsGlyph *CPetRooms::addGlyph(uint roomFlags, bool highlight) {
+ CPetRoomsGlyph *glyph = new CPetRoomsGlyph(roomFlags);
if (!glyph->setup(_petControl, &_glyphs)) {
delete glyph;
return nullptr;
@@ -226,10 +263,6 @@ CPetRoomsGlyph *CPetRooms::addGlyph(int val, bool highlight) {
}
}
-void CPetRooms::addRoom(int roomNum) {
- warning("TODO: CPetRooms::addRoom");
-}
-
uint CPetRooms::mode1Flags() const {
CPetRoomsGlyph *glyph = _glyphs.findMode1();
return glyph ? glyph->getRoomFlags() : 0;
diff --git a/engines/titanic/pet_control/pet_rooms.h b/engines/titanic/pet_control/pet_rooms.h
index 608940fec6..a8a83af753 100644
--- a/engines/titanic/pet_control/pet_rooms.h
+++ b/engines/titanic/pet_control/pet_rooms.h
@@ -72,7 +72,12 @@ private:
/**
* Adds a glyph to the list
*/
- CPetRoomsGlyph *addGlyph(int val, bool highlight);
+ CPetRoomsGlyph *addRoom(uint roomFlags, bool highlight);
+
+ /**
+ * Adds a glyph to the list
+ */
+ CPetRoomsGlyph *addGlyph(uint roomFlags, bool highlight);
uint mode1Flags() const;
public:
@@ -151,9 +156,9 @@ public:
virtual CGameObject *getBackground(int index);
/**
- * Adds a room to the room list
+ * Adds a random room to the glyph list
*/
- void addRoom(int roomNum);
+ void addRandomRoom(int passClassNum);
int fn2(int val);
};
diff --git a/engines/titanic/pet_control/pet_rooms_glyphs.cpp b/engines/titanic/pet_control/pet_rooms_glyphs.cpp
index 71fdc5662d..1048180369 100644
--- a/engines/titanic/pet_control/pet_rooms_glyphs.cpp
+++ b/engines/titanic/pet_control/pet_rooms_glyphs.cpp
@@ -102,4 +102,14 @@ CPetRoomsGlyph *CPetRoomsGlyphs::findMode1() const {
return nullptr;
}
+CPetRoomsGlyph *CPetRoomsGlyphs::findGlyphByFlags(uint flags) const {
+ for (const_iterator i = begin(); i != end(); ++i) {
+ CPetRoomsGlyph *glyph = static_cast<CPetRoomsGlyph *>(*i);
+ if (glyph->getRoomFlags() == flags)
+ return glyph;
+ }
+
+ return nullptr;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_rooms_glyphs.h b/engines/titanic/pet_control/pet_rooms_glyphs.h
index c48011f347..1d6ded7af9 100644
--- a/engines/titanic/pet_control/pet_rooms_glyphs.h
+++ b/engines/titanic/pet_control/pet_rooms_glyphs.h
@@ -47,27 +47,6 @@ public:
CPetRoomsGlyph(uint flags);
/**
- * Set the room flags for the glyph
- */
- void setFoomFlags(uint flags) { _roomFlags = flags; }
-
- /**
- * Get the room flags for the glyph
- */
- uint getRoomFlags() const { return _roomFlags; }
-
- void set38(int val) { _field38 = val; }
-
- /**
- * Sets the mode of the glyph
- */
- void setMode(RoomGlyphMode mode) { _mode = mode; }
-
- bool isModeValid() const { return _mode != RGM_0; }
- bool isMode1() const { return _mode == RGM_1; }
- bool isMode2() const { return _mode == RGM_2; }
-
- /**
* Setup the glyph
*/
virtual bool setup(CPetControl *petControl, CPetGlyphs *owner);
@@ -94,6 +73,28 @@ public:
virtual int proc33();
virtual void proc39();
+
+
+ /**
+ * Set the room flags for the glyph
+ */
+ void setFoomFlags(uint flags) { _roomFlags = flags; }
+
+ /**
+ * Get the room flags for the glyph
+ */
+ uint getRoomFlags() const { return _roomFlags; }
+
+ void set38(int val) { _field38 = val; }
+
+ /**
+ * Sets the mode of the glyph
+ */
+ void setMode(RoomGlyphMode mode) { _mode = mode; }
+
+ bool isModeValid() const { return _mode != RGM_0; }
+ bool isMode1() const { return _mode == RGM_1; }
+ bool isMode2() const { return _mode == RGM_2; }
};
class CPetRoomsGlyphs : public CPetGlyphs {
@@ -105,6 +106,17 @@ public:
void save2(SimpleFile *file, int indent) const;
CPetRoomsGlyph *findMode1() const;
+
+
+ /**
+ * Finds a glyph in the list by it's room flags
+ */
+ CPetRoomsGlyph *findGlyphByFlags(uint flags) const;
+
+ /**
+ * Returns true if there's a glyph in the list with a given room flags
+ */
+ bool hasFlags(uint flags) const { return findGlyphByFlags(flags) != nullptr; }
};
} // End of namespace Titanic