aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2016-04-14 20:02:52 -0400
committerPaul Gilbert2016-07-10 16:11:07 -0400
commitf77a8a63cde7b40dd6fb4dfc23f11cc654c7e9a5 (patch)
treea6eeca5e8990c29b635e3190dbf416e8ddbaf76e /engines
parent1babcc10cfce1458ac07c8e1027c321962cf8f09 (diff)
downloadscummvm-rg350-f77a8a63cde7b40dd6fb4dfc23f11cc654c7e9a5.tar.gz
scummvm-rg350-f77a8a63cde7b40dd6fb4dfc23f11cc654c7e9a5.tar.bz2
scummvm-rg350-f77a8a63cde7b40dd6fb4dfc23f11cc654c7e9a5.zip
TITANIC: Implemented CGameObject::find
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/core/game_object.cpp58
-rw-r--r--engines/titanic/core/game_object.h23
-rw-r--r--engines/titanic/core/mail_man.cpp (renamed from engines/titanic/game/mail_man.cpp)13
-rw-r--r--engines/titanic/core/mail_man.h (renamed from engines/titanic/game/mail_man.h)11
-rw-r--r--engines/titanic/core/saveable_object.cpp6
-rw-r--r--engines/titanic/core/tree_item.cpp5
-rw-r--r--engines/titanic/core/tree_item.h6
-rw-r--r--engines/titanic/module.mk2
8 files changed, 119 insertions, 5 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index 0a541bfb4d..ba8ab42c68 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -21,7 +21,9 @@
*/
#include "titanic/core/game_object.h"
+#include "titanic/core/mail_man.h"
#include "titanic/core/resource_key.h"
+#include "titanic/core/room_item.h"
#include "titanic/pet_control/pet_control.h"
#include "titanic/support/files_manager.h"
#include "titanic/support/screen_manager.h"
@@ -568,4 +570,60 @@ void CGameObject::petDisplayMsg(const CString &msg) const {
pet->displayMessage(msg);
}
+CGameObject *CGameObject::getMailManFirstObject() const {
+ CMailMan *mailMan = getMailMan();
+ return mailMan ? mailMan->getFirstObject() : nullptr;
+}
+
+CGameObject *CGameObject::getMailManNextObject(CGameObject *prior) const {
+ CMailMan *mailMan = getMailMan();
+ return mailMan ? mailMan->getNextObject(prior) : nullptr;
+}
+
+CGameObject *CGameObject::findRoomObject(const CString &name) const {
+ return static_cast<CGameObject *>(findRoom()->findByName(name));
+}
+
+Found CGameObject::find(const CString &name, CGameObject **item, int findAreas) {
+ CGameObject *go;
+ *item = nullptr;
+
+ // Scan under PET if flagged
+ if (findAreas & FIND_PET) {
+ for (go = getPetControl()->getFirstObject(); go; go = getPetControl()->getNextObject(go)) {
+ if (go->getName() == name) {
+ *item = go;
+ return FOUND_PET;
+ }
+ }
+ }
+
+ if (findAreas & FIND_MAILMAN) {
+ for (go = getMailManFirstObject(); go; go = getMailManNextObject(go)) {
+ if (go->getName() == name) {
+ *item = go;
+ return FOUND_MAILMAN;
+ }
+ }
+ }
+
+ if (findAreas & FIND_GLOBAL) {
+ go = static_cast<CGameObject *>(getRoot()->findByName(name));
+ if (go) {
+ *item = go;
+ return FOUND_GLOBAL;
+ }
+ }
+
+ if (findAreas & FIND_ROOM) {
+ go = findRoomObject(name);
+ if (go) {
+ *item = go;
+ return FOUND_ROOM;
+ }
+ }
+
+ return FOUND_NONE;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 09a00e30bb..86687309e7 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -32,6 +32,9 @@
namespace Titanic {
+enum Find { FIND_GLOBAL = 1, FIND_ROOM = 2, FIND_PET = 4, FIND_MAILMAN = 8 };
+enum Found { FOUND_NONE = 0, FOUND_GLOBAL = 1, FOUND_ROOM = 2, FOUND_PET = 3, FOUND_MAILMAN = 4 };
+
class CVideoSurface;
class CMouseDragStartMsg;
class OSMovie;
@@ -165,6 +168,26 @@ protected:
* Display a message in the PET
*/
void petDisplayMsg(const CString &msg) const;
+
+ /**
+ * Gets the first object under the system MailMan
+ */
+ CGameObject *getMailManFirstObject() const;
+
+ /**
+ * Gets the next object under the system MailMan
+ */
+ CGameObject *getMailManNextObject(CGameObject *prior) const;
+
+ /**
+ * Finds an object by name within the object's room
+ */
+ CGameObject *findRoomObject(const CString &name) const;
+
+ /**
+ * Finds an item in various system areas
+ */
+ Found find(const CString &name, CGameObject **item, int findAreas);
public:
int _field60;
CursorId _cursorId;
diff --git a/engines/titanic/game/mail_man.cpp b/engines/titanic/core/mail_man.cpp
index 9096fc55d1..cb959245b5 100644
--- a/engines/titanic/game/mail_man.cpp
+++ b/engines/titanic/core/mail_man.cpp
@@ -20,7 +20,7 @@
*
*/
-#include "titanic/game/mail_man.h"
+#include "titanic/core/mail_man.h"
namespace Titanic {
@@ -36,4 +36,15 @@ void CMailMan::load(SimpleFile *file) {
CGameObject::load(file);
}
+CGameObject *CMailMan::getFirstObject() const {
+ return static_cast<CGameObject *>(getFirstChild());
+}
+
+CGameObject *CMailMan::getNextObject(CGameObject *prior) const {
+ if (!prior || prior->getParent() != this)
+ return nullptr;
+
+ return static_cast<CGameObject *>(prior->getNextSibling());
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/game/mail_man.h b/engines/titanic/core/mail_man.h
index a75d75a865..d1c84e2264 100644
--- a/engines/titanic/game/mail_man.h
+++ b/engines/titanic/core/mail_man.h
@@ -43,6 +43,17 @@ public:
* Load the data for the class from file
*/
virtual void load(SimpleFile *file);
+
+ /**
+ * Get the first game object stored in the PET
+ */
+ CGameObject *getFirstObject() const;
+
+ /**
+ * Get the next game object stored in the PET following
+ * the passed game object
+ */
+ CGameObject *getNextObject(CGameObject *prior) const;
};
} // End of namespace Titanic
diff --git a/engines/titanic/core/saveable_object.cpp b/engines/titanic/core/saveable_object.cpp
index 2eacbba4a0..4a57959b57 100644
--- a/engines/titanic/core/saveable_object.cpp
+++ b/engines/titanic/core/saveable_object.cpp
@@ -68,6 +68,7 @@
#include "titanic/core/game_object_desc_item.h"
#include "titanic/core/link_item.h"
#include "titanic/core/list.h"
+#include "titanic/core/mail_man.h"
#include "titanic/core/message_target.h"
#include "titanic/core/movie_clip.h"
#include "titanic/core/multi_drop_target.h"
@@ -156,7 +157,6 @@
#include "titanic/game/light_switch.h"
#include "titanic/game/little_lift_button.h"
#include "titanic/game/long_stick_dispenser.h"
-#include "titanic/game/mail_man.h"
#include "titanic/game/missiveomat.h"
#include "titanic/game/missiveomat_button.h"
#include "titanic/game/movie_tester.h"
@@ -475,6 +475,7 @@ DEFFN(CGameObject)
DEFFN(CGameObjectDescItem)
DEFFN(CLinkItem)
DEFFN(ListItem)
+DEFFN(CMailMan)
DEFFN(CMessageTarget)
DEFFN(CMovieClip)
DEFFN(CMultiDropTarget)
@@ -565,7 +566,6 @@ DEFFN(CLight)
DEFFN(CLightSwitch)
DEFFN(CLittleLiftButton)
DEFFN(CLongStickDispenser)
-DEFFN(CMailMan)
DEFFN(CMissiveOMat)
DEFFN(CMissiveOMatButton)
DEFFN(CMovieTester)
@@ -1061,6 +1061,7 @@ void CSaveableObject::initClassList() {
ADDFN(CLinkItem, CNamedItem);
ADDFN(ListItem, CSaveableObject);
ADDFN(CMessageTarget, CSaveableObject);
+ ADDFN(CMailMan, CGameObject);
ADDFN(CMovieClip, ListItem);
ADDFN(CMultiDropTarget, CDropTarget);
ADDFN(CNamedItem, CTreeItem);
@@ -1151,7 +1152,6 @@ void CSaveableObject::initClassList() {
ADDFN(CLightSwitch, CBackground);
ADDFN(CLittleLiftButton, CBackground);
ADDFN(CLongStickDispenser, CGameObject);
- ADDFN(CMailMan, CGameObject);
ADDFN(CMissiveOMat, CGameObject);
ADDFN(CMissiveOMatButton, CEditControl);
ADDFN(CMovieTester, CGameObject);
diff --git a/engines/titanic/core/tree_item.cpp b/engines/titanic/core/tree_item.cpp
index d86e9b2f58..03bf0e764e 100644
--- a/engines/titanic/core/tree_item.cpp
+++ b/engines/titanic/core/tree_item.cpp
@@ -26,6 +26,7 @@
#include "titanic/core/game_object.h"
#include "titanic/core/game_object_desc_item.h"
#include "titanic/core/link_item.h"
+#include "titanic/core/mail_man.h"
#include "titanic/core/named_item.h"
#include "titanic/core/node_item.h"
#include "titanic/core/project_item.h"
@@ -275,6 +276,10 @@ CPetControl *CTreeItem::getPetControl() const {
return dynamic_cast<CPetControl *>(getDontSaveChild(CPetControl::_type));
}
+CMailMan *CTreeItem::getMailMan() const {
+ return dynamic_cast<CMailMan *>(getDontSaveChild(CMailMan::_type));
+}
+
CTreeItem *CTreeItem::getDontSaveChild(ClassDef *classDef) const {
CProjectItem *root = getRoot();
if (!root)
diff --git a/engines/titanic/core/tree_item.h b/engines/titanic/core/tree_item.h
index c44825f566..2f4ebc39f1 100644
--- a/engines/titanic/core/tree_item.h
+++ b/engines/titanic/core/tree_item.h
@@ -29,6 +29,7 @@ namespace Titanic {
class CGameManager;
class CDontSaveFileItem;
+class CMailMan;
class CMessage;
class CMusicRoom;
class CNamedItem;
@@ -249,6 +250,11 @@ public:
CPetControl *getPetControl() const;
/**
+ * Returns the MailMan
+ */
+ CMailMan *getMailMan() const;
+
+ /**
* Returns a child of the Dont Save area of the project of the given class
*/
CTreeItem *getDontSaveChild(ClassDef *classDef) const;
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index be9a46784c..8f3126b052 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -60,6 +60,7 @@ MODULE_OBJS := \
core/game_object_desc_item.o \
core/link_item.o \
core/list.o \
+ core/mail_man.o \
core/message_target.o \
core/movie_clip.o \
core/multi_drop_target.o \
@@ -150,7 +151,6 @@ MODULE_OBJS := \
game/light_switch.o \
game/little_lift_button.o \
game/long_stick_dispenser.o \
- game/mail_man.o \
game/missiveomat.o \
game/missiveomat_button.o \
game/movie_tester.o \