SLUDGE: Move save game getter to StackHandler

This commit is contained in:
Simei Yin 2018-05-31 23:13:20 +02:00
parent fa72209845
commit 8ead8de284
3 changed files with 6 additions and 7 deletions

View File

@ -215,7 +215,7 @@ builtIn(getMatchingFiles) {
fun->reg.varData.theStack->first = NULL;
fun->reg.varData.theStack->last = NULL;
fun->reg.varData.theStack->timesUsed = 1;
if (!getSavedGamesStack(fun->reg.varData.theStack, newText))
if (!fun->reg.varData.theStack->getSavedGamesStack(newText))
return BR_ERROR;
return BR_CONTINUE;
}

View File

@ -144,8 +144,7 @@ int StackHandler::getStackSize() const {
return r;
}
bool getSavedGamesStack(StackHandler *sH, const Common::String &ext) {
bool StackHandler::getSavedGamesStack(const Common::String &ext) {
// Make pattern
uint len = ext.size();
Common::String pattern = "*";
@ -161,10 +160,10 @@ bool getSavedGamesStack(StackHandler *sH, const Common::String &ext) {
for (it = sa.begin(); it != sa.end(); ++it) {
(*it).erase((*it).size() - len, len);
newName.makeTextVar((*it));
if (!addVarToStack(newName, sH->first))
if (!addVarToStack(newName, first))
return false;
if (sH->last == NULL)
sH->last = sH->first;
if (last == NULL)
last = first;
}
return true;

View File

@ -58,6 +58,7 @@ struct StackHandler {
int timesUsed;
int getStackSize() const;
bool getSavedGamesStack(const Common::String &ext);
};
union VariableData {
@ -137,7 +138,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 getSavedGamesStack(StackHandler *sH, const Common::String &ext);
// load & save
void saveStack(VariableStack *vs, Common::WriteStream *stream);