diff options
author | Simei Yin | 2018-05-31 23:04:14 +0200 |
---|---|---|
committer | Simei Yin | 2018-05-31 23:15:09 +0200 |
commit | 80478ee4704ea09c16c5728c957ea0096b923d05 (patch) | |
tree | 16e33ae6bef2b50cce1e55ed7ceaa86d005387ae /engines/sludge | |
parent | ca583ebfcfc420d0b303256a9a088bb2327ea907 (diff) | |
download | scummvm-rg350-80478ee4704ea09c16c5728c957ea0096b923d05.tar.gz scummvm-rg350-80478ee4704ea09c16c5728c957ea0096b923d05.tar.bz2 scummvm-rg350-80478ee4704ea09c16c5728c957ea0096b923d05.zip |
SLUDGE: Move copyStack() to struct Variable
Diffstat (limited to 'engines/sludge')
-rw-r--r-- | engines/sludge/builtin.cpp | 2 | ||||
-rw-r--r-- | engines/sludge/variable.cpp | 20 | ||||
-rw-r--r-- | engines/sludge/variable.h | 4 |
3 files changed, 14 insertions, 12 deletions
diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp index bf7c4228d3..c7b66d6dc6 100644 --- a/engines/sludge/builtin.cpp +++ b/engines/sludge/builtin.cpp @@ -551,7 +551,7 @@ builtIn(copyStack) { return BR_ERROR; } // Return value - if (!copyStack(fun->stack->thisVar, fun->reg)) + if (!fun->reg.copyStack(fun->stack->thisVar)) return BR_ERROR; trimStack(fun->stack); return BR_CONTINUE; diff --git a/engines/sludge/variable.cpp b/engines/sludge/variable.cpp index 5da52483e6..c1ff97e699 100644 --- a/engines/sludge/variable.cpp +++ b/engines/sludge/variable.cpp @@ -170,20 +170,20 @@ bool getSavedGamesStack(StackHandler *sH, const Common::String &ext) { return true; } -bool copyStack(const Variable &from, Variable &to) { - to.varType = SVT_STACK; - to.varData.theStack = new StackHandler; - if (!checkNew(to.varData.theStack)) +bool Variable::copyStack(const Variable &from) { + varType = SVT_STACK; + varData.theStack = new StackHandler; + if (!checkNew(varData.theStack)) return false; - to.varData.theStack->first = NULL; - to.varData.theStack->last = NULL; - to.varData.theStack->timesUsed = 1; + varData.theStack->first = NULL; + varData.theStack->last = NULL; + varData.theStack->timesUsed = 1; VariableStack *a = from.varData.theStack->first; while (a) { - addVarToStack(a->thisVar, to.varData.theStack->first); - if (to.varData.theStack->last == NULL) { - to.varData.theStack->last = to.varData.theStack->first; + addVarToStack(a->thisVar, varData.theStack->first); + if (varData.theStack->last == NULL) { + varData.theStack->last = varData.theStack->first; } a = a->next; } diff --git a/engines/sludge/variable.h b/engines/sludge/variable.h index 51fba77e85..4d756f5d67 100644 --- a/engines/sludge/variable.h +++ b/engines/sludge/variable.h @@ -103,6 +103,9 @@ struct Variable { bool makeFastArrayFromStack(const StackHandler *stacky); bool makeFastArraySize(int size); + // Stack variable + bool copyStack(const Variable &from); + // Add variables void addVariablesInSecond(const Variable &other); void compareVariablesInSecond(const Variable &other); @@ -132,7 +135,6 @@ bool addVarToStack(const Variable &va, VariableStack *&thisStack); bool addVarToStackQuick(Variable &va, VariableStack *&thisStack); void trimStack(VariableStack *&stack); int deleteVarFromStack(const Variable &va, VariableStack *&thisStack, bool allOfEm = false); -bool copyStack(const Variable &from, Variable &to); int stackSize(const StackHandler *me); bool getSavedGamesStack(StackHandler *sH, const Common::String &ext); |