aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/pet_control/pet_rooms.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2016-06-22 20:43:54 -0400
committerPaul Gilbert2016-07-15 19:24:04 -0400
commit452274dae027933b2199cd26236f1a5e908c4275 (patch)
treea5fe0f1e8ccc2b20cb00e33e24be8f7b302d4341 /engines/titanic/pet_control/pet_rooms.cpp
parent5aff1d01b4088979e207c434476fa7ca3f6a644f (diff)
downloadscummvm-rg350-452274dae027933b2199cd26236f1a5e908c4275.tar.gz
scummvm-rg350-452274dae027933b2199cd26236f1a5e908c4275.tar.bz2
scummvm-rg350-452274dae027933b2199cd26236f1a5e908c4275.zip
TITANIC: Flesh out PET Rooms adding glyphs
Diffstat (limited to 'engines/titanic/pet_control/pet_rooms.cpp')
-rw-r--r--engines/titanic/pet_control/pet_rooms.cpp45
1 files changed, 39 insertions, 6 deletions
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;