aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine/seg_manager.cpp
diff options
context:
space:
mode:
authorFilippos Karapetis2010-06-01 14:41:48 +0000
committerFilippos Karapetis2010-06-01 14:41:48 +0000
commite083c20da1aab0090a5fc3ea624c9810c63dad52 (patch)
tree8afe1c12bdba317e799049cdd49dec49281e728f /engines/sci/engine/seg_manager.cpp
parent400542a1fe688bb702a89333c833bc1d89dd1ed4 (diff)
downloadscummvm-rg350-e083c20da1aab0090a5fc3ea624c9810c63dad52.tar.gz
scummvm-rg350-e083c20da1aab0090a5fc3ea624c9810c63dad52.tar.bz2
scummvm-rg350-e083c20da1aab0090a5fc3ea624c9810c63dad52.zip
The system strings segment is a fixed segment of the segment manager, which doesn't change during the game, thus move all the system strings code and variables inside the segment manager
svn-id: r49372
Diffstat (limited to 'engines/sci/engine/seg_manager.cpp')
-rw-r--r--engines/sci/engine/seg_manager.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp
index 92eb1c4717..4d3e6f754e 100644
--- a/engines/sci/engine/seg_manager.cpp
+++ b/engines/sci/engine/seg_manager.cpp
@@ -54,7 +54,6 @@ SegManager::SegManager(ResourceManager *resMan) {
createClassTable();
}
-// Destroy the object, free the memorys if allocated before
SegManager::~SegManager() {
resetSegMan();
}
@@ -81,6 +80,25 @@ void SegManager::resetSegMan() {
createClassTable();
}
+void SegManager::initSysStrings() {
+ sysStrings = (SystemStrings *)allocSegment(new SystemStrings(), &sysStringsSegment);
+
+ // Allocate static buffer for savegame and CWD directories
+ SystemString *strSaveDir = &sysStrings->_strings[SYS_STRING_SAVEDIR];
+ strSaveDir->_name = "savedir";
+ strSaveDir->_maxSize = MAX_SAVE_DIR_SIZE;
+ strSaveDir->_value = (char *)calloc(MAX_SAVE_DIR_SIZE, sizeof(char));
+ // Set the savegame dir (actually, we set it to a fake value,
+ // since we cannot let the game control where saves are stored)
+ ::strcpy(strSaveDir->_value, "");
+
+ // Allocate static buffer for the parser base
+ SystemString *strParserBase = &sysStrings->_strings[SYS_STRING_PARSER_BASE];
+ strParserBase->_name = "parser-base";
+ strParserBase->_maxSize = MAX_PARSER_BASE;
+ strParserBase->_value = (char *)calloc(MAX_PARSER_BASE, sizeof(char));
+}
+
SegmentId SegManager::findFreeSegment() const {
// FIXME: This is a very crude approach: We find a free segment id by scanning
// from the start. This can be slow if the number of segments becomes large.
@@ -393,10 +411,6 @@ DataStack *SegManager::allocateStack(int size, SegmentId *segid) {
return retval;
}
-SystemStrings *SegManager::allocateSysStrings(SegmentId *segid) {
- return (SystemStrings *)allocSegment(new SystemStrings(), segid);
-}
-
void SegManager::freeHunkEntry(reg_t addr) {
if (addr.isNull()) {
warning("Attempt to free a Hunk from a null address");