diff options
author | Simei Yin | 2018-05-31 22:48:20 +0200 |
---|---|---|
committer | Simei Yin | 2018-05-31 23:15:09 +0200 |
commit | 9fb57f944d1105c084b4cf54e037a66b9eb34740 (patch) | |
tree | 983643719c306692c05aec4888f54823d542a886 | |
parent | dc18ec2fd08ad10e022dc442228b5914701a3d2f (diff) | |
download | scummvm-rg350-9fb57f944d1105c084b4cf54e037a66b9eb34740.tar.gz scummvm-rg350-9fb57f944d1105c084b4cf54e037a66b9eb34740.tar.bz2 scummvm-rg350-9fb57f944d1105c084b4cf54e037a66b9eb34740.zip |
SLUDGE: Move stack variable getter/setter to VariableStack
-rw-r--r-- | engines/sludge/function.cpp | 6 | ||||
-rw-r--r-- | engines/sludge/variable.cpp | 6 | ||||
-rw-r--r-- | engines/sludge/variable.h | 6 |
3 files changed, 10 insertions, 8 deletions
diff --git a/engines/sludge/function.cpp b/engines/sludge/function.cpp index 400bf80bc1..553e59d76c 100644 --- a/engines/sludge/function.cpp +++ b/engines/sludge/function.cpp @@ -351,7 +351,7 @@ bool continueFunction(LoadedFunction *fun) { Variable *grab = (fun->stack->thisVar.varType == SVT_FASTARRAY) ? fun->stack->thisVar.varData.fastArray->fastArrayGetByIndex(ii) : - stackGetByIndex(fun->stack->thisVar.varData.theStack->first, ii); + fun->stack->thisVar.varData.theStack->first->stackGetByIndex(ii); trimStack(fun->stack); @@ -396,9 +396,7 @@ bool continueFunction(LoadedFunction *fun) { int ii; if (!fun->reg.getValueType(ii, SVT_INT)) return false; - if (!stackSetByIndex( - fun->stack->thisVar.varData.theStack->first, ii, - fun->stack->next->thisVar)) { + if (!fun->stack->thisVar.varData.theStack->first->stackSetByIndex(ii, fun->stack->next->thisVar)) { return false; } trimStack(fun->stack); diff --git a/engines/sludge/variable.cpp b/engines/sludge/variable.cpp index f822015c6a..9b72185cb8 100644 --- a/engines/sludge/variable.cpp +++ b/engines/sludge/variable.cpp @@ -448,7 +448,8 @@ bool addVarToStackQuick(Variable &va, VariableStack *&thisStack) { return true; } -bool stackSetByIndex(VariableStack *vS, uint theIndex, const Variable &va) { +bool VariableStack::stackSetByIndex(uint theIndex, const Variable &va) { + VariableStack *vS = this; while (theIndex--) { vS = vS->next; if (!vS) @@ -457,7 +458,8 @@ bool stackSetByIndex(VariableStack *vS, uint theIndex, const Variable &va) { return vS->thisVar.copyFrom(va); } -Variable *stackGetByIndex(VariableStack *vS, uint theIndex) { +Variable *VariableStack::stackGetByIndex(uint theIndex) { + VariableStack *vS = this; while (theIndex--) { vS = vS->next; if (!vS) { diff --git a/engines/sludge/variable.h b/engines/sludge/variable.h index 0519893ccd..dafc761019 100644 --- a/engines/sludge/variable.h +++ b/engines/sludge/variable.h @@ -117,6 +117,10 @@ struct Variable { struct VariableStack { Variable thisVar; VariableStack *next; + + // Variable getter & setter + bool stackSetByIndex(uint, const Variable &); + Variable *stackGetByIndex(uint); }; // Stacky stuff @@ -129,8 +133,6 @@ int deleteVarFromStack(const Variable &va, VariableStack *&thisStack, VariableStack *stackFindLast(VariableStack *hunt); bool copyStack(const Variable &from, Variable &to); int stackSize(const StackHandler *me); -bool stackSetByIndex(VariableStack *, uint, const Variable &); -Variable *stackGetByIndex(VariableStack *, uint); bool getSavedGamesStack(StackHandler *sH, const Common::String &ext); // load & save |