aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/console.cpp2
-rw-r--r--engines/sci/engine/kmisc.cpp2
-rw-r--r--engines/sci/engine/kstring.cpp4
-rw-r--r--engines/sci/engine/memobj.h6
-rw-r--r--engines/sci/engine/savegame.cpp2
-rw-r--r--engines/sci/engine/seg_manager.cpp25
-rw-r--r--engines/sci/engine/seg_manager.h10
7 files changed, 18 insertions, 33 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index d0ac6e3134..8cdad3f6e1 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -1488,7 +1488,7 @@ bool Console::segmentInfo(int nr) {
case MEM_OBJ_DYNMEM: {
DebugPrintf("dynmem (%s): %d bytes\n",
- (*(DynMem *)mobj)._description ? (*(DynMem *)mobj)._description : "no description", (*(DynMem *)mobj)._size);
+ (*(DynMem *)mobj)._description.c_str(), (*(DynMem *)mobj)._size);
Common::hexdump((*(DynMem *)mobj)._buf, (*(DynMem *)mobj)._size, 16, 0);
}
diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp
index 48fca8056e..74f6c91257 100644
--- a/engines/sci/engine/kmisc.cpp
+++ b/engines/sci/engine/kmisc.cpp
@@ -175,7 +175,6 @@ reg_t kMemory(EngineState *s, int, int argc, reg_t *argv) {
if (!s->segMan->allocDynmem(argv[1].toUint16(), "kMemory() critical", &s->r_acc)) {
error("Critical heap allocation failed");
}
- return s->r_acc;
break;
case K_MEMORY_ALLOCATE_NONCRITICAL :
s->segMan->allocDynmem(argv[1].toUint16(), "kMemory() non-critical", &s->r_acc);
@@ -234,7 +233,6 @@ reg_t kMemory(EngineState *s, int, int argc, reg_t *argv) {
WRITE_LE_UINT16(ref, argv[2].offset); // ?
}
}
- return s->r_acc;
break;
}
}
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index d7735483ac..97742a0db7 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -367,12 +367,10 @@ reg_t kStrAt(EngineState *s, int, int argc, reg_t *argv) {
if (s->_gameName.equalsIgnoreCase("lsl5") && s->currentRoomNumber() == 155)
lsl5PasswordWorkaround = true;
- const char* dst = (const char *)dest; // used just for code beautification purposes
-
if ((argc == 2) &&
/* Our pathfinder already works around the issue we're trying to fix */
(strcmp(s->segMan->getDescription(argv[0]), AVOIDPATH_DYNMEM_STRING) != 0) &&
- ((strlen(dst) < 2) || (!lsl5PasswordWorkaround && !is_print_str(dst)))) {
+ ((strlen(dest) < 2) || (!lsl5PasswordWorkaround && !is_print_str(dest)))) {
// SQ4 array handling detected
#ifndef SCUMM_BIG_ENDIAN
int odd = argv[1].toUint16() & 1;
diff --git a/engines/sci/engine/memobj.h b/engines/sci/engine/memobj.h
index f8cbb53060..707773add2 100644
--- a/engines/sci/engine/memobj.h
+++ b/engines/sci/engine/memobj.h
@@ -557,14 +557,12 @@ struct HunkTable : public Table<Hunk> {
// Free-style memory
struct DynMem : public MemObject {
int _size;
- char *_description;
+ Common::String _description;
byte *_buf;
public:
- DynMem() : _size(0), _description(0), _buf(0) {}
+ DynMem() : _size(0), _buf(0) {}
~DynMem() {
- free(_description);
- _description = NULL;
free(_buf);
_buf = NULL;
}
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 139cc1c4f7..ade012226b 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -420,7 +420,7 @@ void SystemStrings::saveLoadWithSerializer(Common::Serializer &s) {
void DynMem::saveLoadWithSerializer(Common::Serializer &s) {
s.syncAsSint32LE(_size);
- syncCStr(s, &_description);
+ s.syncString(_description);
if (!_buf && _size) {
_buf = (byte *)calloc(_size, 1);
}
diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp
index 72c2dd25b0..cc43de2603 100644
--- a/engines/sci/engine/seg_manager.cpp
+++ b/engines/sci/engine/seg_manager.cpp
@@ -302,7 +302,7 @@ const char *SegManager::getObjectName(reg_t pos) {
if (nameReg.isNull())
return "<no name>";
- const char *name = (const char*)dereference(obj->_variables[SCRIPT_NAME_SELECTOR], NULL);
+ const char *name = derefString(obj->_variables[SCRIPT_NAME_SELECTOR]);
if (!name)
return "<invalid name>";
@@ -930,18 +930,13 @@ byte *SegManager::dereference(reg_t pointer, int *size) {
return mobj->dereference(pointer, size);
}
-static void *_kernel_dereference_pointer(SegManager *segMan, reg_t pointer, int entries, int align) {
+static void *_kernel_dereference_pointer(SegManager *segMan, reg_t pointer, int entries) {
int maxsize;
void *retval = segMan->dereference(pointer, &maxsize);
if (!retval)
return NULL;
- if (pointer.offset & (align - 1)) {
- warning("Unaligned pointer read: %04x:%04x expected with %d alignment", PRINT_REG(pointer), align);
- return NULL;
- }
-
if (entries > maxsize) {
warning("Trying to dereference pointer %04x:%04x beyond end of segment", PRINT_REG(pointer));
return NULL;
@@ -951,15 +946,21 @@ static void *_kernel_dereference_pointer(SegManager *segMan, reg_t pointer, int
}
byte *SegManager::derefBulkPtr(reg_t pointer, int entries) {
- return (byte *)_kernel_dereference_pointer(this, pointer, entries, 1);
+ return (byte *)_kernel_dereference_pointer(this, pointer, entries);
}
reg_t *SegManager::derefRegPtr(reg_t pointer, int entries) {
- return (reg_t *)_kernel_dereference_pointer(this, pointer, entries, sizeof(reg_t));
+ const int align = sizeof(reg_t);
+ if (pointer.offset & (align - 1)) {
+ warning("Unaligned pointer read: %04x:%04x expected with %d alignment", PRINT_REG(pointer), align);
+ return NULL;
+ }
+
+ return (reg_t *)_kernel_dereference_pointer(this, pointer, entries);
}
char *SegManager::derefString(reg_t pointer, int entries) {
- return (char *)_kernel_dereference_pointer(this, pointer, entries, 1);
+ return (char *)_kernel_dereference_pointer(this, pointer, entries);
}
@@ -977,7 +978,7 @@ byte *SegManager::allocDynmem(int size, const char *descr, reg_t *addr) {
else
d._buf = (byte *)malloc(size);
- d._description = strdup(descr);
+ d._description = descr;
return (byte *)(d._buf);
}
@@ -990,7 +991,7 @@ const char *SegManager::getDescription(reg_t addr) {
switch (mobj->getType()) {
case MEM_OBJ_DYNMEM:
- return (*(DynMem *)mobj)._description;
+ return (*(DynMem *)mobj)._description.c_str();
default:
return "";
}
diff --git a/engines/sci/engine/seg_manager.h b/engines/sci/engine/seg_manager.h
index c3d72d5e40..9b274890d5 100644
--- a/engines/sci/engine/seg_manager.h
+++ b/engines/sci/engine/seg_manager.h
@@ -312,16 +312,6 @@ public:
const char *getDescription(reg_t addr);
- // 10. Reserved segments
-
- // Reserves a special-purpose segment
- // Parameters: (char *) name: A string name identifying the segment (the string is cloned and retained)
- // Returns : A fresh segment ID for the segment in question
- // Reserved segments are never used by the segment manager. They can be used to tag special-purpose addresses.
- // Segment 0 is implicitly reserved for numbers.
- //SegmentId sm_allocate_reserved_segment(char *name);
-
-
// Generic Operations on Segments and Addresses
/**