From f77a8a63cde7b40dd6fb4dfc23f11cc654c7e9a5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 14 Apr 2016 20:02:52 -0400 Subject: TITANIC: Implemented CGameObject::find --- engines/titanic/core/mail_man.cpp | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 engines/titanic/core/mail_man.cpp (limited to 'engines/titanic/core/mail_man.cpp') diff --git a/engines/titanic/core/mail_man.cpp b/engines/titanic/core/mail_man.cpp new file mode 100644 index 0000000000..cb959245b5 --- /dev/null +++ b/engines/titanic/core/mail_man.cpp @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/mail_man.h" + +namespace Titanic { + +void CMailMan::save(SimpleFile *file, int indent) const { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CGameObject::save(file, indent); +} + +void CMailMan::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CGameObject::load(file); +} + +CGameObject *CMailMan::getFirstObject() const { + return static_cast(getFirstChild()); +} + +CGameObject *CMailMan::getNextObject(CGameObject *prior) const { + if (!prior || prior->getParent() != this) + return nullptr; + + return static_cast(prior->getNextSibling()); +} + +} // End of namespace Titanic -- cgit v1.2.3 From f0889c17a46019b8b294a74d054d0c60e445190b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 19 Jun 2016 20:58:37 -0400 Subject: TITANIC: Implementing lots of cGameObject methods --- engines/titanic/core/mail_man.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'engines/titanic/core/mail_man.cpp') diff --git a/engines/titanic/core/mail_man.cpp b/engines/titanic/core/mail_man.cpp index cb959245b5..e96b697dff 100644 --- a/engines/titanic/core/mail_man.cpp +++ b/engines/titanic/core/mail_man.cpp @@ -47,4 +47,21 @@ CGameObject *CMailMan::getNextObject(CGameObject *prior) const { return static_cast(prior->getNextSibling()); } +void CMailMan::fn10(CGameObject *obj, int v) { + warning("TODO: CMailMan::fn10"); +} + +void CMailMan::fn11(CGameObject *obj, int v) { + warning("TODO: CMailMan::fn11"); +} + +CGameObject *CMailMan::findMail(int id) const { + for (CGameObject *obj = getFirstObject(); obj; obj = getNextObject(obj)) { + if (_field50 && _field54 == id) + return obj; + } + + return nullptr; +} + } // End of namespace Titanic -- cgit v1.2.3 From 701caa956ca652256504a1dd6a82e24a853323ac Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 19 Jun 2016 21:50:06 -0400 Subject: TITANIC: Implemented mail manager methods --- engines/titanic/core/mail_man.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'engines/titanic/core/mail_man.cpp') 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(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 -- cgit v1.2.3 From ef1d10e926fcf31ffeb5c594a305ec0cd8bf7064 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 26 Jun 2016 23:00:00 -0400 Subject: TITANIC: Implemented remaining CGameManager methods and others --- engines/titanic/core/mail_man.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/titanic/core/mail_man.cpp') diff --git a/engines/titanic/core/mail_man.cpp b/engines/titanic/core/mail_man.cpp index 8ac50e9767..8226ebfc80 100644 --- a/engines/titanic/core/mail_man.cpp +++ b/engines/titanic/core/mail_man.cpp @@ -55,7 +55,7 @@ void CMailMan::addMail(CGameObject *obj, int id) { void CMailMan::setMailId(CGameObject *obj, int id) { obj->_id = id; - obj->_field58 = 0; + obj->_roomFlags = 0; obj->_isMail = true; } @@ -68,11 +68,11 @@ CGameObject *CMailMan::findMail(int id) const { return nullptr; } -void CMailMan::removeMail(int id, int v) { +void CMailMan::removeMail(int id, int roomFlags) { for (CGameObject *obj = getFirstObject(); obj; obj = getNextObject(obj)) { if (obj->_isMail && obj->_id == id) { obj->_isMail = false; - obj->_field58 = v; + obj->_roomFlags = roomFlags; break; } } -- cgit v1.2.3 From 5ccc0a66da38d23520234e7060efaf966d3345b9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 29 Jun 2016 19:53:16 -0400 Subject: TITANIC: Removed const modifier from all saveable objects Turns out that CGameObject::save regenerates the _movieRangeInfo list. So the const suffix can no longer be used for the entire hierarchy --- engines/titanic/core/mail_man.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/titanic/core/mail_man.cpp') diff --git a/engines/titanic/core/mail_man.cpp b/engines/titanic/core/mail_man.cpp index 8226ebfc80..afe13bebad 100644 --- a/engines/titanic/core/mail_man.cpp +++ b/engines/titanic/core/mail_man.cpp @@ -24,7 +24,7 @@ namespace Titanic { -void CMailMan::save(SimpleFile *file, int indent) const { +void CMailMan::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_value, indent); CGameObject::save(file, indent); -- cgit v1.2.3