aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMax Horn2009-09-22 00:36:05 +0000
committerMax Horn2009-09-22 00:36:05 +0000
commit97d1f79e2d0c23dc337e85888ffa67aca98f7358 (patch)
treec5712062e885c780f4e8fca2035ccdffba18e462 /engines/sci
parent5fc2428c99b6ea05f45e3c3cd655ce3010ee6aa8 (diff)
downloadscummvm-rg350-97d1f79e2d0c23dc337e85888ffa67aca98f7358.tar.gz
scummvm-rg350-97d1f79e2d0c23dc337e85888ffa67aca98f7358.tar.bz2
scummvm-rg350-97d1f79e2d0c23dc337e85888ffa67aca98f7358.zip
SCI: Change SystemString::name from char* to Common::String
svn-id: r44243
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/game.cpp4
-rw-r--r--engines/sci/engine/savegame.cpp2
-rw-r--r--engines/sci/engine/segment.cpp4
-rw-r--r--engines/sci/engine/segment.h12
4 files changed, 11 insertions, 11 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp
index 1c94b540a0..f77cff4b95 100644
--- a/engines/sci/engine/game.cpp
+++ b/engines/sci/engine/game.cpp
@@ -335,7 +335,7 @@ int script_init_engine(EngineState *s) {
// Allocate static buffer for savegame and CWD directories
SystemString *str = &s->sys_strings->strings[SYS_STRING_SAVEDIR];
- str->name = strdup("savedir");
+ str->_name = "savedir";
str->max_size = MAX_SAVE_DIR_SIZE;
str->value = (reg_t *)calloc(MAX_SAVE_DIR_SIZE, sizeof(reg_t)); // FIXME -- sizeof(char) or sizeof(reg_t) ??
str->value[0].segment = s->string_frag_segment; // Set to empty string
@@ -439,7 +439,7 @@ int game_init(EngineState *s) {
s->status_bar_background = !s->resMan->isVGA() ? 15 : 255;
SystemString *str = &s->sys_strings->strings[SYS_STRING_PARSER_BASE];
- str->name = strdup("parser-base");
+ str->_name = "parser-base";
str->max_size = MAX_PARSER_BASE;
str->value = (reg_t *)calloc(MAX_PARSER_BASE + 1, sizeof(char)); // FIXME -- sizeof(char) or sizeof(reg_t) ??
str->value[0].segment = s->string_frag_segment; // Set to empty string
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 03f249c20a..c779e32fa9 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -437,7 +437,7 @@ void Script::saveLoadWithSerializer(Common::Serializer &s) {
}
static void sync_SystemString(Common::Serializer &s, SystemString &obj) {
- syncCStr(s, &obj.name);
+ s.syncString(obj._name);
s.syncAsSint32LE(obj.max_size);
// FIXME: This is a *WEIRD* hack: We sync a reg_t* as if it was a string.
diff --git a/engines/sci/engine/segment.cpp b/engines/sci/engine/segment.cpp
index 036d0f6979..80027dbb39 100644
--- a/engines/sci/engine/segment.cpp
+++ b/engines/sci/engine/segment.cpp
@@ -275,13 +275,13 @@ byte *DynMem::dereference(reg_t pointer, int *size) {
}
bool SystemStrings::isValidOffset(uint16 offset) const {
- return offset < SYS_STRINGS_MAX && strings[offset].name;
+ return offset < SYS_STRINGS_MAX && !strings[offset]._name.empty();
}
byte *SystemStrings::dereference(reg_t pointer, int *size) {
if (size)
*size = strings[pointer.offset].max_size;
- if (pointer.offset < SYS_STRINGS_MAX && strings[pointer.offset].name)
+ if (isValidOffset(pointer.offset))
return (byte *)(strings[pointer.offset].value);
// This occurs in KQ5CD when interacting with certain objects
diff --git a/engines/sci/engine/segment.h b/engines/sci/engine/segment.h
index 9e6e27dd85..81da9c2488 100644
--- a/engines/sci/engine/segment.h
+++ b/engines/sci/engine/segment.h
@@ -133,7 +133,7 @@ enum {
};
struct SystemString {
- char *name;
+ Common::String _name;
int max_size;
reg_t *value;
};
@@ -143,15 +143,15 @@ struct SystemStrings : public SegmentObj {
public:
SystemStrings() : SegmentObj(SEG_TYPE_SYS_STRINGS) {
- memset(strings, 0, sizeof(strings));
+ for (int i = 0; i < SYS_STRINGS_MAX; i++) {
+ strings[i].max_size = 0;
+ strings[i].value = 0;
+ }
}
~SystemStrings() {
for (int i = 0; i < SYS_STRINGS_MAX; i++) {
SystemString *str = &strings[i];
- if (str->name) {
- free(str->name);
- str->name = NULL;
-
+ if (!str->_name.empty()) {
free(str->value);
str->value = NULL;