SLUDGE: Move FastArray getter to struct FastArrayHandler

This commit is contained in:
Simei Yin 2018-05-31 22:42:36 +02:00
parent 399ff4788c
commit dc18ec2fd0
3 changed files with 8 additions and 13 deletions

View File

@ -350,12 +350,8 @@ bool continueFunction(LoadedFunction *fun) {
return false;
Variable *grab =
(fun->stack->thisVar.varType == SVT_FASTARRAY) ?
fastArrayGetByIndex(
fun->stack->thisVar.varData.fastArray,
ii) :
stackGetByIndex(
fun->stack->thisVar.varData.theStack->first,
ii);
fun->stack->thisVar.varData.fastArray->fastArrayGetByIndex(ii) :
stackGetByIndex(fun->stack->thisVar.varData.theStack->first, ii);
trimStack(fun->stack);
@ -414,8 +410,7 @@ bool continueFunction(LoadedFunction *fun) {
int ii;
if (!fun->reg.getValueType(ii, SVT_INT))
return false;
Variable *v = fastArrayGetByIndex(
fun->stack->thisVar.varData.fastArray, ii);
Variable *v = fun->stack->thisVar.varData.fastArray->fastArrayGetByIndex(ii);
if (v == NULL)
return fatal("Not within bounds of fast array.");
if (!v->copyFrom(fun->stack->next->thisVar))

View File

@ -380,10 +380,10 @@ bool Variable::copyFrom(const Variable &from) {
return copyMain(from);
}
Variable *fastArrayGetByIndex(FastArrayHandler *vS, uint theIndex) {
if ((int)theIndex >= vS->size)
Variable *FastArrayHandler::fastArrayGetByIndex(uint theIndex) {
if ((int)theIndex >= size)
return NULL;
return &vS->fastVariables[theIndex];
return &fastVariables[theIndex];
}
bool Variable::makeFastArraySize(int size) {

View File

@ -48,6 +48,8 @@ struct FastArrayHandler {
struct Variable *fastVariables;
int size;
int timesUsed;
Variable *fastArrayGetByIndex(uint theIndex);
};
struct StackHandler {
@ -131,8 +133,6 @@ bool stackSetByIndex(VariableStack *, uint, const Variable &);
Variable *stackGetByIndex(VariableStack *, uint);
bool getSavedGamesStack(StackHandler *sH, const Common::String &ext);
Variable *fastArrayGetByIndex(FastArrayHandler *vS, uint theIndex);
// load & save
void saveStack(VariableStack *vs, Common::WriteStream *stream);
VariableStack *loadStack(Common::SeekableReadStream *stream, VariableStack **last);