aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/titanic/core/game_object.cpp4
-rw-r--r--engines/titanic/core/game_object.h1
-rw-r--r--engines/titanic/movie.cpp12
-rw-r--r--engines/titanic/movie.h7
-rw-r--r--engines/titanic/pet_control/pet_control.cpp32
-rw-r--r--engines/titanic/pet_control/pet_control.h19
-rw-r--r--engines/titanic/pet_control/pet_element.h11
-rw-r--r--engines/titanic/pet_control/pet_val.cpp43
-rw-r--r--engines/titanic/pet_control/pet_val.h26
-rw-r--r--engines/titanic/simple_file.cpp1
-rw-r--r--engines/titanic/true_talk/true_talk_manager.cpp1
-rw-r--r--engines/titanic/video_surface.cpp11
-rw-r--r--engines/titanic/video_surface.h2
13 files changed, 150 insertions, 20 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index 759c853759..bb1541c275 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -375,4 +375,8 @@ int CGameObject::getMovie19() const {
return _field78;
}
+int CGameObject::getSurface45() const {
+ return _surface ? _surface->proc45() : 0;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 68ddf9745d..bacb73074d 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -166,6 +166,7 @@ public:
bool hasActiveMovie() const;
int getMovie19() const;
+ int getSurface45() const;
/**
* Loads a frame
diff --git a/engines/titanic/movie.cpp b/engines/titanic/movie.cpp
index 28284f9a78..193b2cad33 100644
--- a/engines/titanic/movie.cpp
+++ b/engines/titanic/movie.cpp
@@ -25,10 +25,22 @@
namespace Titanic {
+CMovie::CMovie() : ListItem(), _state(0), _field10(0) {
+}
+
bool CMovie::isActive() const {
return g_vm->_movieList.contains(this);
}
+bool CMovie::get10() {
+ if (_field10) {
+ _field10 = 0;
+ return true;
+ } else {
+ return false;
+ }
+}
+
/*------------------------------------------------------------------------*/
OSMovie::OSMovie(const CResourceKey &name, CVideoSurface *surface) : _videoSurface(surface) {
diff --git a/engines/titanic/movie.h b/engines/titanic/movie.h
index ea0b1ea5e0..3529409fa5 100644
--- a/engines/titanic/movie.h
+++ b/engines/titanic/movie.h
@@ -32,7 +32,12 @@ namespace Titanic {
class CVideoSurface;
class CMovie : public ListItem {
+protected:
+ int _state;
+ int _field10;
public:
+ CMovie();
+
virtual void proc8(int v1, CVideoSurface *surface) = 0;
virtual void proc9() = 0;
virtual void proc10() = 0;
@@ -49,6 +54,8 @@ public:
virtual void *proc21() = 0;
bool isActive() const;
+
+ bool get10();
};
class OSMovie : public CMovie {
diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp
index 9f24b4b040..ad1d0b6d2b 100644
--- a/engines/titanic/pet_control/pet_control.cpp
+++ b/engines/titanic/pet_control/pet_control.cpp
@@ -27,6 +27,11 @@
namespace Titanic {
+CPetControl::CPetControl() : CGameObject(),
+ _currentArea(PET_CONVERSATION), _fieldC0(0), _locked(0), _fieldC8(0),
+ _treeItem1(nullptr), _treeItem2(nullptr), _hiddenRoom(nullptr) {
+}
+
void CPetControl::save(SimpleFile *file, int indent) const {
file->writeNumberLine(0, indent);
file->writeNumberLine(_currentArea, indent);
@@ -273,4 +278,31 @@ void CPetControl::fn3(CTreeItem *item) {
_string2.clear();
}
+CRoomItem *CPetControl::getHiddenRoom() {
+ if (!_hiddenRoom)
+ _hiddenRoom = getHiddenRoom();
+
+ return _hiddenRoom;
+}
+
+CGameObject *CPetControl::findItemInRoom(CRoomItem *room,
+ const CString &name) const {
+ if (!room)
+ return nullptr;
+
+ for (CTreeItem *treeItem = room->getFirstChild(); treeItem;
+ treeItem = treeItem->scan(room)) {
+ if (!treeItem->getName().compareTo(name)) {
+ return dynamic_cast<CGameObject *>(treeItem);
+ }
+ }
+
+ return nullptr;
+}
+
+CGameObject *CPetControl::getHiddenObject(const CString &name) {
+ CRoomItem *room = getHiddenRoom();
+ return room ? findItemInRoom(room, name) : nullptr;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h
index fa21d4bf01..1bb2088e27 100644
--- a/engines/titanic/pet_control/pet_control.h
+++ b/engines/titanic/pet_control/pet_control.h
@@ -55,7 +55,7 @@ private:
CString _string1;
CTreeItem *_treeItem2;
CString _string2;
- int _field13A4;
+ CRoomItem *_hiddenRoom;
Rect _oldBounds;
private:
/**
@@ -77,8 +77,19 @@ private:
* Called at the end of the post game-load handling
*/
void loaded();
+
+ /**
+ * Scan the specified room for an item by name
+ */
+ CGameObject *findItemInRoom(CRoomItem *room, const CString &name) const;
+
+ /**
+ * Returns a reference to the special hidden room container
+ */
+ CRoomItem *getHiddenRoom();
public:
CLASSDEF
+ CPetControl();
/**
* Save the data for the class to file
@@ -132,6 +143,12 @@ public:
* Returns true if the current area can be changed
*/
bool canChangeArea() const { return _locked == 0; }
+
+ /**
+ * Returns a game object used by the PET by name from within the
+ * special hidden room container
+ */
+ CGameObject *getHiddenObject(const CString &name);
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_element.h b/engines/titanic/pet_control/pet_element.h
index 66f57c44b4..19a94c2e2f 100644
--- a/engines/titanic/pet_control/pet_element.h
+++ b/engines/titanic/pet_control/pet_element.h
@@ -24,6 +24,7 @@
#define TITANIC_PET_ELEMENT_H
#include "titanic/simple_file.h"
+#include "titanic/string.h"
#include "titanic/core/link_item.h"
namespace Titanic {
@@ -31,16 +32,22 @@ namespace Titanic {
enum PetElementMode { MODE_0 = 0, MODE_1 = 1, MODE_2 = 2 };
class CGameObject;
+class CPetControl;
class CPetElement {
protected:
- Common::Rect _bounds;
+ Rect _bounds;
PetElementMode _mode;
public:
CPetElement();
virtual ~CPetElement() {}
- virtual void proc1() {}
+ /**
+ * Load an object into the element
+ */
+ virtual void loadObject(PetElementMode mode, const CString &name,
+ CPetControl *petControl) {}
+
virtual void proc2() {}
/**
diff --git a/engines/titanic/pet_control/pet_val.cpp b/engines/titanic/pet_control/pet_val.cpp
index 754bda5b7d..cc48dc3e3a 100644
--- a/engines/titanic/pet_control/pet_val.cpp
+++ b/engines/titanic/pet_control/pet_val.cpp
@@ -21,12 +21,27 @@
*/
#include "common/textconsole.h"
+#include "titanic/core/game_object.h"
#include "titanic/pet_control/pet_val.h"
+#include "titanic/pet_control/pet_control.h"
namespace Titanic {
-void CPetVal::proc1() {
- error("TODO");
+void CPetVal::loadObject(PetElementMode mode, const CString &name,
+ CPetControl *petControl) {
+ switch (mode) {
+ case MODE_0:
+ _object0 = petControl->getHiddenObject(name);
+ break;
+ case MODE_1:
+ _object1 = petControl->getHiddenObject(name);
+ break;
+ case MODE_2:
+ _object2 = petControl->getHiddenObject(name);
+ break;
+ default:
+ break;
+ }
}
void CPetVal::proc2() {
@@ -41,20 +56,30 @@ void CPetVal::proc4() {
error("TODO");
}
-void CPetVal::proc5(Rect *rect) {
- error("TODO");
+
+void CPetVal::getBounds(Rect *rect) {
+ if (rect) {
+ CGameObject *obj = getObject();
+ if (!obj)
+ obj = _object0;
+
+ if (obj && obj->getSurface45())
+ *rect = _bounds;
+ else
+ rect->clear();
+ }
}
-int CPetVal::proc16() {
+CGameObject *CPetVal::getObject() const {
switch (_mode) {
case MODE_0:
- return _field18;
+ return _object0;
case MODE_1:
- return _field1C;
+ return _object1;
case MODE_2:
- return _field20;
+ return _object2;
default:
- return 0;
+ return nullptr;
}
}
diff --git a/engines/titanic/pet_control/pet_val.h b/engines/titanic/pet_control/pet_val.h
index 6d19ddb961..90e8cfa88a 100644
--- a/engines/titanic/pet_control/pet_val.h
+++ b/engines/titanic/pet_control/pet_val.h
@@ -29,20 +29,32 @@ namespace Titanic {
class CPetVal: public CPetElement {
protected:
- int _field18;
- int _field1C;
- int _field20;
+ CGameObject *_object0;
+ CGameObject *_object1;
+ CGameObject *_object2;
public:
- CPetVal() : CPetElement(), _field18(0), _field1C(0), _field20(0) {}
+ CPetVal() : CPetElement(), _object0(nullptr), _object1(nullptr),
+ _object2(nullptr) {}
+
+ /**
+ * Load an object into the element
+ */
+ virtual void loadObject(PetElementMode mode, const CString &name,
+ CPetControl *petControl);
- virtual void proc1();
virtual void proc2();
virtual void proc3();
virtual void proc4();
- virtual void proc5(Rect *linkItem);
+ /**
+ * Get the bounds for the element
+ */
+ virtual void getBounds(Rect *rect);
- virtual int proc16();
+ /**
+ * Get the game object associated with this item
+ */
+ virtual CGameObject *getObject() const;
};
} // End of namespace Titanic
diff --git a/engines/titanic/simple_file.cpp b/engines/titanic/simple_file.cpp
index 3cd0ef7ecc..acf02e8df1 100644
--- a/engines/titanic/simple_file.cpp
+++ b/engines/titanic/simple_file.cpp
@@ -28,6 +28,7 @@ namespace Titanic {
bool File::open(const Common::String &name) {
if (!Common::File::open(name))
error("Could not open file - %s", name.c_str());
+ return true;
}
/*------------------------------------------------------------------------*/
diff --git a/engines/titanic/true_talk/true_talk_manager.cpp b/engines/titanic/true_talk/true_talk_manager.cpp
index d13356b42c..6f42346e3f 100644
--- a/engines/titanic/true_talk/true_talk_manager.cpp
+++ b/engines/titanic/true_talk/true_talk_manager.cpp
@@ -66,7 +66,6 @@ void CTrueTalkManager::load(SimpleFile *file) {
int ident1 = file->readNumber();
int ident2 = file->readNumber();
- int v = 0;
if (ident1 != MKTAG_BE('U', 'R', 'A', 'H')) {
while (ident2 != MKTAG_BE('A', 'K', 'E', 'R')) {
diff --git a/engines/titanic/video_surface.cpp b/engines/titanic/video_surface.cpp
index 6cbea17c40..520193f376 100644
--- a/engines/titanic/video_surface.cpp
+++ b/engines/titanic/video_surface.cpp
@@ -151,6 +151,17 @@ uint CVideoSurface::getTransparencyColor() {
return val;
}
+bool CVideoSurface::proc45() {
+ if (_field50) {
+ _field50 = 0;
+ return true;
+ } else if (_movie) {
+ return _movie->get10();
+ } else {
+ return false;
+ }
+}
+
/*------------------------------------------------------------------------*/
OSVideoSurface::OSVideoSurface(CScreenManager *screenManager, DirectDrawSurface *surface) :
diff --git a/engines/titanic/video_surface.h b/engines/titanic/video_surface.h
index 5a5ee5d48a..de181581eb 100644
--- a/engines/titanic/video_surface.h
+++ b/engines/titanic/video_surface.h
@@ -169,6 +169,8 @@ public:
*/
virtual bool load() = 0;
+ virtual bool proc45();
+
/**
* Frees the underlying surface
*/