aboutsummaryrefslogtreecommitdiff
path: root/engines/sludge
diff options
context:
space:
mode:
authorSimei Yin2018-05-31 22:42:36 +0200
committerSimei Yin2018-05-31 23:15:09 +0200
commitdc18ec2fd08ad10e022dc442228b5914701a3d2f (patch)
tree58e28b77d515c4654acce57240629d61bba0b643 /engines/sludge
parent399ff4788cd5a03d37ac1945ed76bc47bc8d4218 (diff)
downloadscummvm-rg350-dc18ec2fd08ad10e022dc442228b5914701a3d2f.tar.gz
scummvm-rg350-dc18ec2fd08ad10e022dc442228b5914701a3d2f.tar.bz2
scummvm-rg350-dc18ec2fd08ad10e022dc442228b5914701a3d2f.zip
SLUDGE: Move FastArray getter to struct FastArrayHandler
Diffstat (limited to 'engines/sludge')
-rw-r--r--engines/sludge/function.cpp11
-rw-r--r--engines/sludge/variable.cpp6
-rw-r--r--engines/sludge/variable.h4
3 files changed, 8 insertions, 13 deletions
diff --git a/engines/sludge/function.cpp b/engines/sludge/function.cpp
index 88171a5103..400bf80bc1 100644
--- a/engines/sludge/function.cpp
+++ b/engines/sludge/function.cpp
@@ -350,12 +350,8 @@ bool continueFunction(LoadedFunction *fun) {
return false;
Variable *grab =
(fun->stack->thisVar.varType == SVT_FASTARRAY) ?
- fastArrayGetByIndex(
- fun->stack->thisVar.varData.fastArray,
- ii) :
- stackGetByIndex(
- fun->stack->thisVar.varData.theStack->first,
- ii);
+ fun->stack->thisVar.varData.fastArray->fastArrayGetByIndex(ii) :
+ stackGetByIndex(fun->stack->thisVar.varData.theStack->first, ii);
trimStack(fun->stack);
@@ -414,8 +410,7 @@ bool continueFunction(LoadedFunction *fun) {
int ii;
if (!fun->reg.getValueType(ii, SVT_INT))
return false;
- Variable *v = fastArrayGetByIndex(
- fun->stack->thisVar.varData.fastArray, ii);
+ Variable *v = fun->stack->thisVar.varData.fastArray->fastArrayGetByIndex(ii);
if (v == NULL)
return fatal("Not within bounds of fast array.");
if (!v->copyFrom(fun->stack->next->thisVar))
diff --git a/engines/sludge/variable.cpp b/engines/sludge/variable.cpp
index 50bd52e93c..f822015c6a 100644
--- a/engines/sludge/variable.cpp
+++ b/engines/sludge/variable.cpp
@@ -380,10 +380,10 @@ bool Variable::copyFrom(const Variable &from) {
return copyMain(from);
}
-Variable *fastArrayGetByIndex(FastArrayHandler *vS, uint theIndex) {
- if ((int)theIndex >= vS->size)
+Variable *FastArrayHandler::fastArrayGetByIndex(uint theIndex) {
+ if ((int)theIndex >= size)
return NULL;
- return &vS->fastVariables[theIndex];
+ return &fastVariables[theIndex];
}
bool Variable::makeFastArraySize(int size) {
diff --git a/engines/sludge/variable.h b/engines/sludge/variable.h
index de7d2efc34..0519893ccd 100644
--- a/engines/sludge/variable.h
+++ b/engines/sludge/variable.h
@@ -48,6 +48,8 @@ struct FastArrayHandler {
struct Variable *fastVariables;
int size;
int timesUsed;
+
+ Variable *fastArrayGetByIndex(uint theIndex);
};
struct StackHandler {
@@ -131,8 +133,6 @@ bool stackSetByIndex(VariableStack *, uint, const Variable &);
Variable *stackGetByIndex(VariableStack *, uint);
bool getSavedGamesStack(StackHandler *sH, const Common::String &ext);
-Variable *fastArrayGetByIndex(FastArrayHandler *vS, uint theIndex);
-
// load & save
void saveStack(VariableStack *vs, Common::WriteStream *stream);
VariableStack *loadStack(Common::SeekableReadStream *stream, VariableStack **last);