aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-02-22 22:39:37 -0500
committerPaul Gilbert2016-02-22 22:39:37 -0500
commit938316b7dfdbbdf00b2b6e50ea2f05d856e15593 (patch)
tree0827c1e0256acc1d7c1d79c3593e6d487469d88f
parent063f8a97c842fa6745746180daffb513bda79658 (diff)
downloadscummvm-rg350-938316b7dfdbbdf00b2b6e50ea2f05d856e15593.tar.gz
scummvm-rg350-938316b7dfdbbdf00b2b6e50ea2f05d856e15593.tar.bz2
scummvm-rg350-938316b7dfdbbdf00b2b6e50ea2f05d856e15593.zip
TITANIC: Implementing CProjectItem loading
-rw-r--r--engines/titanic/objects/file_item.h1
-rw-r--r--engines/titanic/objects/list.cpp9
-rw-r--r--engines/titanic/objects/list.h5
-rw-r--r--engines/titanic/objects/project_item.cpp49
-rw-r--r--engines/titanic/objects/project_item.h11
5 files changed, 74 insertions, 1 deletions
diff --git a/engines/titanic/objects/file_item.h b/engines/titanic/objects/file_item.h
index 133421ae1c..2261598ea8 100644
--- a/engines/titanic/objects/file_item.h
+++ b/engines/titanic/objects/file_item.h
@@ -23,6 +23,7 @@
#ifndef TITANIC_FILE_ITEM_H
#define TITANIC_FILE_ITEM_H
+#include "titanic/objects/list.h"
#include "titanic/objects/tree_item.h"
namespace Titanic {
diff --git a/engines/titanic/objects/list.cpp b/engines/titanic/objects/list.cpp
index ddcddb04dd..1ebffac51b 100644
--- a/engines/titanic/objects/list.cpp
+++ b/engines/titanic/objects/list.cpp
@@ -85,4 +85,13 @@ void List::loadItems(SimpleFile *file) {
}
}
+void List::destroyContents() {
+ for (iterator i = begin(); i != end(); ++i) {
+ CSaveableObject *obj = *i;
+ delete obj;
+ }
+
+ clear();
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/objects/list.h b/engines/titanic/objects/list.h
index f98912795d..ceb471534d 100644
--- a/engines/titanic/objects/list.h
+++ b/engines/titanic/objects/list.h
@@ -75,6 +75,11 @@ public:
* Load the data for the class from file
*/
virtual void load(SimpleFile *file);
+
+ /**
+ * Clear the list and destroy any items in it
+ */
+ void destroyContents();
};
} // End of namespace Titanic
diff --git a/engines/titanic/objects/project_item.cpp b/engines/titanic/objects/project_item.cpp
index ee3cb3f28d..8211854407 100644
--- a/engines/titanic/objects/project_item.cpp
+++ b/engines/titanic/objects/project_item.cpp
@@ -27,15 +27,62 @@
namespace Titanic {
+CProjectItem::CProjectItem() : _field34(0), _field38(0), _field3C(0) {
+}
+
void CProjectItem::save(SimpleFile *file, int indent) const {
file->writeNumberLine(6, indent);
}
void CProjectItem::load(SimpleFile *file) {
- file->readNumber();
+ int val = file->readNumber();
+ load2(file, val);
+}
+
+void CProjectItem::load2(SimpleFile *file, int val) {
+ int count;
+ _items.destroyContents();
+ switch (val) {
+ case 1:
+ file->readBuffer();
+ _field34 = file->readNumber();
+ // Deliberate fall-through
+
+ case 0:
+ count = file->readNumber();
+ for (int idx = 0; idx < count; ++idx) {
+
+ }
+ break;
+
+ case 6:
+ file->readBuffer();
+ _field3C = file->readNumber();
+ // Deliberate fall-through
+
+ case 5:
+ file->readBuffer();
+ _field38 = file->readNumber();
+ // Deliberate fall-through
+
+ case 4:
+ file->readBuffer();
+ // Deliberate fall-through
+
+ case 2:
+ case 3:
+ _items.load(file);
+ file->readBuffer();
+ _field34 = file->readNumber();
+ break;
+
+ default:
+ break;
+ }
+ CTreeItem::load(file);
}
void CProjectItem::loadGame(int slotId) {
diff --git a/engines/titanic/objects/project_item.h b/engines/titanic/objects/project_item.h
index b313387a74..d769f3dd0f 100644
--- a/engines/titanic/objects/project_item.h
+++ b/engines/titanic/objects/project_item.h
@@ -32,6 +32,15 @@ namespace Titanic {
class CProjectItem : public CFileItem {
private:
CString _filename;
+ List _items;
+ int _field34;
+ int _field38;
+ int _field3C;
+
+ /**
+ * Load data for the project
+ */
+ void load2(SimpleFile *file, int val);
private:
/**
* Load project data from the passed file
@@ -43,6 +52,8 @@ private:
*/
void saveData(SimpleFile *file, CTreeItem *item) const;
public:
+ CProjectItem();
+
/**
* Return the class name
*/