Skip to content

Commit

Permalink
SLUDGE: Move stack size getter to struct StackHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
yinsimei committed May 31, 2018
1 parent 80478ee commit fa72209
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion engines/sludge/bg_effects.cpp
Expand Up @@ -166,7 +166,7 @@ bool blur_createSettings(int numParams, VariableStack *&stack) {
error = "Third and subsequent parameters in setBackgroundEffect should be arrays";
break;
} else {
int w = stackSize(justToCheckSizes->thisVar.varData.theStack);
int w = justToCheckSizes->thisVar.varData.theStack->getStackSize();
if (a) {
if (w != width) {
error = "Arrays in setBackgroundEffect must be the same size";
Expand Down
2 changes: 1 addition & 1 deletion engines/sludge/builtin.cpp
Expand Up @@ -527,7 +527,7 @@ builtIn(stackSize) {
switch (fun->stack->thisVar.varType) {
case SVT_STACK:
// Return value
fun->reg.setVariable(SVT_INT, stackSize(fun->stack->thisVar.varData.theStack));
fun->reg.setVariable(SVT_INT, fun->stack->thisVar.varData.theStack->getStackSize());
trimStack(fun->stack);
return BR_CONTINUE;

Expand Down
6 changes: 3 additions & 3 deletions engines/sludge/variable.cpp
Expand Up @@ -134,9 +134,9 @@ Persona *Variable::getCostumeFromVar() {
return p;
}

int stackSize(const StackHandler *me) {
int StackHandler::getStackSize() const {
int r = 0;
VariableStack *a = me->first;
VariableStack *a = first;
while (a) {
r++;
a = a->next;
Expand Down Expand Up @@ -403,7 +403,7 @@ bool Variable::makeFastArraySize(int size) {
}

bool Variable::makeFastArrayFromStack(const StackHandler *stacky) {
int size = stackSize(stacky);
int size = stacky->getStackSize();
if (!makeFastArraySize(size))
return false;

Expand Down
3 changes: 2 additions & 1 deletion engines/sludge/variable.h
Expand Up @@ -56,6 +56,8 @@ struct StackHandler {
struct VariableStack *first;
struct VariableStack *last;
int timesUsed;

int getStackSize() const;
};

union VariableData {
Expand Down Expand Up @@ -135,7 +137,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);
int stackSize(const StackHandler *me);
bool getSavedGamesStack(StackHandler *sH, const Common::String &ext);

// load & save
Expand Down

0 comments on commit fa72209

Please sign in to comment.