diff options
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); |