aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-03-29 22:21:55 -0400
committerPaul Gilbert2016-03-29 22:21:55 -0400
commita1e959b4986914bd42bdbd4587cdfc2bd57ca3a0 (patch)
tree1a4b8e18b8164140bd458a5179993167121c3e47
parente0602c4851ab42763cc66858fed8d05496040498 (diff)
downloadscummvm-rg350-a1e959b4986914bd42bdbd4587cdfc2bd57ca3a0.tar.gz
scummvm-rg350-a1e959b4986914bd42bdbd4587cdfc2bd57ca3a0.tar.bz2
scummvm-rg350-a1e959b4986914bd42bdbd4587cdfc2bd57ca3a0.zip
TITANIC: Fix PET post-loading
-rw-r--r--engines/titanic/core/tree_item.cpp2
-rw-r--r--engines/titanic/pet_control/pet_control.cpp33
-rw-r--r--engines/titanic/pet_control/pet_control.h19
-rw-r--r--engines/titanic/pet_control/pet_section.h5
4 files changed, 47 insertions, 12 deletions
diff --git a/engines/titanic/core/tree_item.cpp b/engines/titanic/core/tree_item.cpp
index 081c5806b6..61fcf97183 100644
--- a/engines/titanic/core/tree_item.cpp
+++ b/engines/titanic/core/tree_item.cpp
@@ -188,7 +188,7 @@ void CTreeItem::setParent(CTreeItem *newParent) {
}
void CTreeItem::addSibling(CTreeItem *item) {
- _priorSibling = item->_nextSibling;
+ _priorSibling = item;
_nextSibling = item->_nextSibling;
_parent = item->_parent;
diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp
index 63a1da450b..db053ca517 100644
--- a/engines/titanic/pet_control/pet_control.cpp
+++ b/engines/titanic/pet_control/pet_control.cpp
@@ -21,6 +21,7 @@
*/
#include "titanic/pet_control/pet_control.h"
+#include "titanic/core/project_item.h"
#include "titanic/game_manager.h"
#include "titanic/game_state.h"
@@ -32,7 +33,7 @@ void CPetControl::save(SimpleFile *file, int indent) const {
file->writeQuotedLine(_string1, indent);
file->writeQuotedLine(_string2, indent);
- saveSubObjects(file, indent);
+ saveAreas(file, indent);
CGameObject::save(file, indent);
}
@@ -45,7 +46,7 @@ void CPetControl::load(SimpleFile *file) {
_string1 = file->readString();
_string2 = file->readString();
- loadSubObjects(file, 0);
+ loadAreas(file, 0);
}
CGameObject::load(file);
@@ -58,7 +59,7 @@ bool CPetControl::isValid() const {
&& _sub7.isValid() && _sub8.isValid();
}
-void CPetControl::loadSubObjects(SimpleFile *file, int param) {
+void CPetControl::loadAreas(SimpleFile *file, int param) {
_convSection.load(file, param);
_roomsSection.load(file, param);
_remoteSection.load(file, param);
@@ -69,7 +70,7 @@ void CPetControl::loadSubObjects(SimpleFile *file, int param) {
_sub8.load(file, param);
}
-void CPetControl::saveSubObjects(SimpleFile *file, int indent) const {
+void CPetControl::saveAreas(SimpleFile *file, int indent) const {
_convSection.save(file, indent);
_roomsSection.save(file, indent);
_remoteSection.save(file, indent);
@@ -85,7 +86,26 @@ void CPetControl::proc26() {
}
void CPetControl::postLoad() {
- warning("TODO: CPetControl::postLoad");
+ CProjectItem *root = getRoot();
+
+ if (!_string1.empty() && root)
+ _treeItem1 = root->findByName(_string1);
+ if (!_string2.empty() && root)
+ _treeItem2 = root->findByName(_string2);
+
+ setArea(_currentArea);
+ loaded();
+}
+
+void CPetControl::loaded() {
+ _convSection.postLoad();
+ _roomsSection.postLoad();
+ _remoteSection.postLoad();
+ _invSection.postLoad();
+ _sub5.postLoad();
+ _saveSection.postLoad();
+ _sub7.postLoad();
+ _sub8.postLoad();
}
void CPetControl::enterNode(CNodeItem *node) {
@@ -98,7 +118,7 @@ void CPetControl::enterRoom(CRoomItem *room) {
}
void CPetControl::clear() {
- _field1394 = 0;
+ _treeItem2 = nullptr;
_string2.clear();
}
@@ -184,6 +204,7 @@ PetArea CPetControl::setArea(PetArea newArea) {
}
makeDirty();
+ return newArea;
}
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h
index ce40eba177..02a59fdd3a 100644
--- a/engines/titanic/pet_control/pet_control.h
+++ b/engines/titanic/pet_control/pet_control.h
@@ -51,9 +51,9 @@ private:
CPetControlSub5 _sub5;
CPetControlSub7 _sub7;
CPetControlSub8 _sub8;
- int _field1384;
+ CTreeItem *_treeItem1;
CString _string1;
- int _field1394;
+ CTreeItem *_treeItem2;
CString _string2;
int _field13A4;
private:
@@ -62,9 +62,20 @@ private:
*/
bool isValid() const;
- void loadSubObjects(SimpleFile *file, int param);
+ /**
+ * Loads data for the individual areas
+ */
+ void loadAreas(SimpleFile *file, int param);
- void saveSubObjects(SimpleFile *file, int indent) const;
+ /**
+ * Saves data for the individual areas
+ */
+ void saveAreas(SimpleFile *file, int indent) const;
+
+ /**
+ * Called at the end of the post game-load handling
+ */
+ void loaded();
public:
CLASSDEF
diff --git a/engines/titanic/pet_control/pet_section.h b/engines/titanic/pet_control/pet_section.h
index ceada29709..4a1335281b 100644
--- a/engines/titanic/pet_control/pet_section.h
+++ b/engines/titanic/pet_control/pet_section.h
@@ -77,7 +77,10 @@ public:
*/
virtual void load(SimpleFile *file, int param) {}
- virtual void proc19() {}
+ /**
+ * Called after a game has been loaded
+ */
+ virtual void postLoad() {}
/**
* Save the data for the class to file