aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2016-06-19 21:50:06 -0400
committerPaul Gilbert2016-07-15 19:23:47 -0400
commit701caa956ca652256504a1dd6a82e24a853323ac (patch)
tree646107cf813a1040f323ba2032e9478dbc0600a5 /engines/titanic
parentf0889c17a46019b8b294a74d054d0c60e445190b (diff)
downloadscummvm-rg350-701caa956ca652256504a1dd6a82e24a853323ac.tar.gz
scummvm-rg350-701caa956ca652256504a1dd6a82e24a853323ac.tar.bz2
scummvm-rg350-701caa956ca652256504a1dd6a82e24a853323ac.zip
TITANIC: Implemented mail manager methods
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/core/game_object.cpp28
-rw-r--r--engines/titanic/core/game_object.h27
-rw-r--r--engines/titanic/core/mail_man.cpp24
-rw-r--r--engines/titanic/core/mail_man.h18
-rw-r--r--engines/titanic/pet_control/pet_drag_chev.cpp2
5 files changed, 78 insertions, 21 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index 4a5dd9b065..466fb443da 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -61,8 +61,8 @@ CGameObject::CGameObject(): CNamedItem() {
_field44 = 0xF0;
_field48 = 0xF0;
_field4C = 0xFF;
- _field50 = 0;
- _field54 = 0;
+ _isMail = false;
+ _id = 0;
_field58 = 0;
_visible = true;
_field60 = 0;
@@ -124,8 +124,8 @@ void CGameObject::load(SimpleFile *file) {
_field4C = file->readNumber();
_fieldB8 = file->readNumber();
_visible = file->readNumber() != 0;
- _field50 = file->readNumber();
- _field54 = file->readNumber();
+ _isMail = file->readNumber();
+ _id = file->readNumber();
_field58 = file->readNumber();
resourceKey.load(file);
@@ -1008,19 +1008,19 @@ void CGameObject::setState1C(bool flag) {
getGameManager()->_gameState._field1C = flag;
}
-void CGameObject::mailFn10(int v) {
+void CGameObject::addMail(int mailId) {
CMailMan *mailMan = getMailMan();
if (mailMan) {
makeDirty();
- mailMan->fn10(this, v);
+ mailMan->addMail(this, mailId);
}
}
-void CGameObject::mailFn11(int v) {
+void CGameObject::setMailId(int mailId) {
CMailMan *mailMan = getMailMan();
if (mailMan) {
makeDirty();
- mailMan->fn11(this, v);
+ mailMan->setMailId(this, mailId);
}
}
@@ -1033,4 +1033,16 @@ CGameObject *CGameObject::findMail(int id) const {
return mailMan ? mailMan->findMail(id) : nullptr;
}
+void CGameObject::removeMail(int id, int v) {
+ CMailMan *mailMan = getMailMan();
+ if (mailMan)
+ mailMan->removeMail(id, v);
+}
+
+void CGameObject::resetMail() {
+ CMailMan *mailMan = getMailMan();
+ if (mailMan)
+ mailMan->resetValue();
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 01f15ceb85..ad0d93948e 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -82,9 +82,6 @@ protected:
int _field44;
int _field48;
int _field4C;
- int _field50;
- int _field54;
- int _field58;
CMovieClipList _clipList1;
int _initialFrame;
CMovieClipList _clipList2;
@@ -382,8 +379,15 @@ protected:
void setState1C(bool flag);
- void mailFn10(int v);
- void mailFn11(int v);
+ /**
+ * Adds an object to the mail list
+ */
+ void addMail(int mailId);
+
+ /**
+ * Sets the mail identifier for an object
+ */
+ void setMailId(int mailId);
/**
* Returns true if a mail with a specified Id exists
@@ -394,7 +398,20 @@ protected:
* Returns a specified mail, if one exists
*/
CGameObject *findMail(int id) const;
+
+ /**
+ * Remove an object from the mail list
+ */
+ void removeMail(int id, int v);
+
+ /**
+ * Resets the Mail Man value
+ */
+ void resetMail();
public:
+ bool _isMail;
+ int _id;
+ int _field58;
int _field60;
CursorId _cursorId;
bool _visible;
diff --git a/engines/titanic/core/mail_man.cpp b/engines/titanic/core/mail_man.cpp
index e96b697dff..8ac50e9767 100644
--- a/engines/titanic/core/mail_man.cpp
+++ b/engines/titanic/core/mail_man.cpp
@@ -47,21 +47,35 @@ CGameObject *CMailMan::getNextObject(CGameObject *prior) const {
return static_cast<CGameObject *>(prior->getNextSibling());
}
-void CMailMan::fn10(CGameObject *obj, int v) {
- warning("TODO: CMailMan::fn10");
+void CMailMan::addMail(CGameObject *obj, int id) {
+ obj->detach();
+ obj->addUnder(this);
+ setMailId(obj, id);
}
-void CMailMan::fn11(CGameObject *obj, int v) {
- warning("TODO: CMailMan::fn11");
+void CMailMan::setMailId(CGameObject *obj, int id) {
+ obj->_id = id;
+ obj->_field58 = 0;
+ obj->_isMail = true;
}
CGameObject *CMailMan::findMail(int id) const {
for (CGameObject *obj = getFirstObject(); obj; obj = getNextObject(obj)) {
- if (_field50 && _field54 == id)
+ if (obj->_isMail && obj->_id == id)
return obj;
}
return nullptr;
}
+void CMailMan::removeMail(int id, int v) {
+ for (CGameObject *obj = getFirstObject(); obj; obj = getNextObject(obj)) {
+ if (obj->_isMail && obj->_id == id) {
+ obj->_isMail = false;
+ obj->_field58 = v;
+ break;
+ }
+ }
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/mail_man.h b/engines/titanic/core/mail_man.h
index 1a95729ff1..982aae4cc0 100644
--- a/engines/titanic/core/mail_man.h
+++ b/engines/titanic/core/mail_man.h
@@ -55,13 +55,27 @@ public:
*/
CGameObject *getNextObject(CGameObject *prior) const;
- void fn10(CGameObject *obj, int v);
- void fn11(CGameObject *obj, int v);
+ /**
+ * Add an object to the mail list
+ */
+ void addMail(CGameObject *obj, int id);
+
+ /**
+ * Sets the mail identifier for an object
+ */
+ static void setMailId(CGameObject *obj, int id);
/**
* Scan the mail list for a specified item
*/
CGameObject *findMail(int id) const;
+
+ /**
+ * Remove a mail item
+ */
+ void removeMail(int id, int v);
+
+ void resetValue() { _value = 0; }
};
diff --git a/engines/titanic/pet_control/pet_drag_chev.cpp b/engines/titanic/pet_control/pet_drag_chev.cpp
index 645804118d..3143cde0ea 100644
--- a/engines/titanic/pet_control/pet_drag_chev.cpp
+++ b/engines/titanic/pet_control/pet_drag_chev.cpp
@@ -56,7 +56,7 @@ bool CPetDragChev::MouseDragEndMsg(CMouseDragEndMsg *msg) {
CSuccUBus *succubus = static_cast<CSuccUBus *>(msg->_dropTarget);
if (succubus) {
- CSetChevRoomBits chevMsg(_field54);
+ CSetChevRoomBits chevMsg(_id);
chevMsg.execute(succubus);
} else {
CPetControl *petControl = getPetControl();