aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMatthew Hoops2010-06-24 17:48:15 +0000
committerMatthew Hoops2010-06-24 17:48:15 +0000
commit7edbcc26f75e9953d3ed8225e351d398cf9099fc (patch)
tree4fcc7d48470c51dc2ed5199ac4005f019eaf3cef /engines
parentb8e2e8e5ddf21a9b27bbc74e6658b637b092de9f (diff)
downloadscummvm-rg350-7edbcc26f75e9953d3ed8225e351d398cf9099fc.tar.gz
scummvm-rg350-7edbcc26f75e9953d3ed8225e351d398cf9099fc.tar.bz2
scummvm-rg350-7edbcc26f75e9953d3ed8225e351d398cf9099fc.zip
Cleanup uninitialized read workaround(s).
svn-id: r50225
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/vm.cpp60
-rw-r--r--engines/sci/engine/vm.h9
2 files changed, 30 insertions, 39 deletions
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index d870eb96a6..0b4482e16f 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -183,13 +183,20 @@ static bool validate_variable(reg_t *r, reg_t *stack_base, int type, int max, in
return true;
}
-static const UninitializedReadWorkaround uninitializedReadWorkarounds[] = {
- { "laurabow2", 24, "gcWin", "open", 5, 0xf }, // is used as priority for game menu
- { "freddypharkas", 24, "gcWin", "open", 5, 0xf }, // is used as priority for game menu
- { "freddypharkas", 31, "quitWin", "open", 5, 0xf }, // is used as priority for game menu
- { "lsl1sci", 720, "rm720", "init", 0, 0 }, // age check room
- { "islandbrain", 140, "piece", "init", 3, 1 }, // some initialization variable. bnt is done on it, and it should be non-0
- { NULL, -1, NULL, NULL, 0, 0 }
+struct UninitializedReadWorkaround {
+ const char *gameId;
+ int scriptNr;
+ const char *objectName;
+ const char *methodName;
+ int index;
+ uint16 newValue;
+} static const uninitializedReadWorkarounds[] = {
+ { "laurabow2", 24, "gcWin", "open", 5, 0xf }, // is used as priority for game menu
+ { "freddypharkas", 24, "gcWin", "open", 5, 0xf }, // is used as priority for game menu
+ { "freddypharkas", 31, "quitWin", "open", 5, 0xf }, // is used as priority for game menu
+ { "lsl1sci", 720, "rm720", "init", 0, 0 }, // age check room
+ { "islandbrain", 140, "piece", "init", 3, 1 }, // some initialization variable. bnt is done on it, and it should be non-0
+ { NULL, -1, NULL, NULL, 0, 0 }
};
static reg_t validate_read_var(reg_t *r, reg_t *stack_base, int type, int max, int index, int line, reg_t default_value) {
@@ -197,43 +204,36 @@ static reg_t validate_read_var(reg_t *r, reg_t *stack_base, int type, int max, i
if (type == VAR_TEMP && r[index].segment == 0xffff) {
// Uninitialized read on a temp
// We need to find correct replacements for each situation manually
- EngineState *engine = g_sci->getEngineState();
- Script *local_script = engine->_segMan->getScriptIfLoaded(engine->xs->local_segment);
+ EngineState *state = g_sci->getEngineState();
+ Script *local_script = state->_segMan->getScriptIfLoaded(state->xs->local_segment);
int curScriptNr = local_script->_nr;
- Common::List<ExecStack>::iterator callIterator = engine->_executionStack.begin();
+ Common::List<ExecStack>::iterator callIterator = state->_executionStack.begin();
ExecStack call = *callIterator;
- while (callIterator != engine->_executionStack.end()) {
+ while (callIterator != state->_executionStack.end()) {
call = *callIterator;
callIterator++;
}
- const char *curObjectName = engine->_segMan->getObjectName(call.sendp);
- const char *curMethodName = "";
- if (call.type == EXEC_STACK_TYPE_CALL) {
- curMethodName = g_sci->getKernel()->getSelectorName(call.selector).c_str();
- }
- const char *gameId = g_sci->getGameId().c_str();
+ Common::String curObjectName = state->_segMan->getObjectName(call.sendp);
+ Common::String curMethodName;
+ Common::String gameId = g_sci->getGameId();
+
+ if (call.type == EXEC_STACK_TYPE_CALL)
+ curMethodName = g_sci->getKernel()->getSelectorName(call.selector);
// Search if this is a known uninitialized read
const UninitializedReadWorkaround *workaround = uninitializedReadWorkarounds;
while (workaround->gameId) {
- if (strcmp(workaround->gameId, gameId) == 0) {
- if (workaround->scriptNr == curScriptNr) {
- if (strcmp(workaround->objectName, curObjectName) == 0) {
- if (strcmp(workaround->methodName, curMethodName) == 0) {
- if (workaround->index == index) {
- // Workaround found
- r[index] = make_reg(0, workaround->newValue);
- return r[index];
- }
- }
- }
- }
+ if (workaround->gameId == gameId && workaround->scriptNr == curScriptNr && workaround->objectName == curObjectName
+ && workaround->methodName == curMethodName && workaround->index == index) {
+ // Workaround found
+ r[index] = make_reg(0, workaround->newValue);
+ return r[index];
}
workaround++;
}
- error("uninitialized read for temp %d from method %s::%s (script %d)", index, curObjectName, curMethodName, curScriptNr);
+ error("Uninitialized read for temp %d from method %s::%s (script %d)", index, curObjectName.c_str(), curMethodName.c_str(), curScriptNr);
}
return r[index];
} else
diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h
index 006bed4126..88898cdbba 100644
--- a/engines/sci/engine/vm.h
+++ b/engines/sci/engine/vm.h
@@ -109,15 +109,6 @@ struct ExecStack {
reg_t* getVarPointer(SegManager *segMan) const;
};
-struct UninitializedReadWorkaround {
- const char *gameId;
- int scriptNr;
- const char *objectName;
- const char *methodName;
- int index;
- uint16 newValue;
-};
-
enum {
VAR_GLOBAL = 0,
VAR_LOCAL = 1,