SLUDGE: Move stack size getter to struct StackHandler

This commit is contained in:
Simei Yin 2018-05-31 23:09:15 +02:00
parent 80478ee470
commit fa72209845
4 changed files with 7 additions and 6 deletions

View File

@ -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";

View File

@ -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;

View File

@ -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;
@ -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;

View File

@ -56,6 +56,8 @@ struct StackHandler {
struct VariableStack *first;
struct VariableStack *last;
int timesUsed;
int getStackSize() const;
};
union VariableData {
@ -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