aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/script.cpp
diff options
context:
space:
mode:
authorTorbjörn Andersson2013-04-30 22:26:51 +0200
committerTorbjörn Andersson2013-04-30 22:26:51 +0200
commit2284aba71979192d18bf147a18bee807a9f31ea2 (patch)
treeb6d6ee60bf37fc89fe21cda3844b2dd880d58088 /engines/scumm/script.cpp
parent6936f830ea397bb29ca6ef58e983e33c9467af2d (diff)
downloadscummvm-rg350-2284aba71979192d18bf147a18bee807a9f31ea2.tar.gz
scummvm-rg350-2284aba71979192d18bf147a18bee807a9f31ea2.tar.bz2
scummvm-rg350-2284aba71979192d18bf147a18bee807a9f31ea2.zip
SCUMM: Use correct array size when calling initializeLocals()
The initializeLocals() function assumes that it can copy 25 elements when being provided an array of values. But this array was frequently a lot smaller than that. I've introduced a constant for the number of locals (though VirtualMachineState has one more for some reason), and fixed the array sizes in a number of places. CID 1003951, 1003952, 1003953, 1003955, 1003956, 1003959, 1003960, 1003961, 1003963, 100394, 1003965
Diffstat (limited to 'engines/scumm/script.cpp')
-rw-r--r--engines/scumm/script.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp
index 8587fb8092..59dfc229f2 100644
--- a/engines/scumm/script.cpp
+++ b/engines/scumm/script.cpp
@@ -138,10 +138,10 @@ void ScummEngine::runObjectScript(int object, int entry, bool freezeResistant, b
void ScummEngine::initializeLocals(int slot, int *vars) {
int i;
if (!vars) {
- for (i = 0; i < 25; i++)
+ for (i = 0; i < NUM_SCRIPT_LOCALS; i++)
vm.localvar[slot][i] = 0;
} else {
- for (i = 0; i < 25; i++)
+ for (i = 0; i < NUM_SCRIPT_LOCALS; i++)
vm.localvar[slot][i] = vars[i];
}
}
@@ -755,7 +755,7 @@ void ScummEngine::stopObjectCode() {
}
void ScummEngine::runInventoryScript(int i) {
- int args[24];
+ int args[NUM_SCRIPT_LOCALS];
memset(args, 0, sizeof(args));
args[0] = i;
if (VAR(VAR_INVENTORY_SCRIPT)) {
@@ -1060,7 +1060,7 @@ void ScummEngine::doSentence(int verb, int objectA, int objectB) {
void ScummEngine::checkAndRunSentenceScript() {
int i;
- int localParamList[24];
+ int localParamList[NUM_SCRIPT_LOCALS];
const ScriptSlot *ss;
int sentenceScript;
@@ -1308,7 +1308,7 @@ void ScummEngine_v0::runSentenceScript() {
}
void ScummEngine_v2::runInputScript(int clickArea, int val, int mode) {
- int args[24];
+ int args[NUM_SCRIPT_LOCALS];
int verbScript;
verbScript = 4;
@@ -1332,7 +1332,7 @@ void ScummEngine_v2::runInputScript(int clickArea, int val, int mode) {
}
void ScummEngine::runInputScript(int clickArea, int val, int mode) {
- int args[24];
+ int args[NUM_SCRIPT_LOCALS];
int verbScript;
verbScript = VAR(VAR_VERB_SCRIPT);
@@ -1490,7 +1490,7 @@ void ScummEngine::beginCutscene(int *args) {
void ScummEngine::endCutscene() {
ScriptSlot *ss = &vm.slot[_currentScript];
- int args[16];
+ int args[NUM_SCRIPT_LOCALS];
if (ss->cutsceneOverride > 0) // Only terminate if active
ss->cutsceneOverride--;