From 452274dae027933b2199cd26236f1a5e908c4275 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 22 Jun 2016 20:43:54 -0400 Subject: TITANIC: Flesh out PET Rooms adding glyphs --- engines/titanic/pet_control/pet_rooms.cpp | 45 ++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) (limited to 'engines/titanic/pet_control/pet_rooms.cpp') 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(*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; -- cgit v1.2.3