aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/base/base_string_table.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/wintermute/base/base_string_table.cpp')
-rw-r--r--engines/wintermute/base/base_string_table.cpp40
1 files changed, 37 insertions, 3 deletions
diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp
index 8207c32244..4c750ebc93 100644
--- a/engines/wintermute/base/base_string_table.cpp
+++ b/engines/wintermute/base/base_string_table.cpp
@@ -8,12 +8,12 @@
* 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.
@@ -147,6 +147,15 @@ void BaseStringTable::expand(char **str) const {
}
}
+//////////////////////////////////////////////////////////////////////////
+void BaseStringTable::expand(Common::String &str) const {
+ char *tmp = new char[str.size()+1];
+ strcpy(tmp, str.c_str());
+ expand(&tmp);
+ str = tmp;
+ delete[] tmp;
+}
+
//////////////////////////////////////////////////////////////////////////
const char *BaseStringTable::expandStatic(const char *string) const {
@@ -189,8 +198,10 @@ bool BaseStringTable::loadFile(const char *filename, bool clearOld) {
BaseEngine::LOG(0, "Loading string table...");
if (clearOld) {
+ _filenames.clear();
_strings.clear();
}
+ _filenames.push_back(Common::String(filename));
uint32 size;
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename, &size);
@@ -253,4 +264,27 @@ bool BaseStringTable::loadFile(const char *filename, bool clearOld) {
return STATUS_OK;
}
-} // end of namespace Wintermute
+bool BaseStringTable::persist(BasePersistenceManager *persistMgr) {
+ // Do nothing if the save game is too old.
+ if (!persistMgr->checkVersion(1, 3, 1)) {
+ return true;
+ }
+ uint32 numFiles = _filenames.size();
+ persistMgr->transferUint32("NumFiles", &numFiles);
+ if (persistMgr->getIsSaving()) {
+ for (uint i = 0; i < numFiles; i++) {
+ persistMgr->transferString("Filename", &_filenames[i]);
+ }
+ } else {
+ _strings.clear();
+ _filenames.clear();
+ for (uint i = 0; i < numFiles; i++) {
+ Common::String filename = "";
+ persistMgr->transferString("Filename", &filename);
+ loadFile(filename.c_str(), false);
+ }
+ }
+ return true;
+}
+
+} // End of namespace Wintermute