diff options
author | Simei Yin | 2018-05-31 18:51:42 +0200 |
---|---|---|
committer | Simei Yin | 2018-05-31 23:15:09 +0200 |
commit | 2ab7665e56b303e7d5311b4d88945cd2007bee3e (patch) | |
tree | bc300b4a4871f95eb3118051266b7c8cc6d3b78b | |
parent | 04444b70f97c40fe3893e80d73042b4f11dbfa46 (diff) | |
download | scummvm-rg350-2ab7665e56b303e7d5311b4d88945cd2007bee3e.tar.gz scummvm-rg350-2ab7665e56b303e7d5311b4d88945cd2007bee3e.tar.bz2 scummvm-rg350-2ab7665e56b303e7d5311b4d88945cd2007bee3e.zip |
SLUDGE: Move SetVariable() into struct Variable
-rw-r--r-- | engines/sludge/backdrop.cpp | 6 | ||||
-rw-r--r-- | engines/sludge/builtin.cpp | 164 | ||||
-rw-r--r-- | engines/sludge/event.cpp | 6 | ||||
-rw-r--r-- | engines/sludge/function.cpp | 62 | ||||
-rw-r--r-- | engines/sludge/loadsave.cpp | 2 | ||||
-rw-r--r-- | engines/sludge/savedata.cpp | 4 | ||||
-rw-r--r-- | engines/sludge/sound.cpp | 2 | ||||
-rw-r--r-- | engines/sludge/variable.cpp | 10 | ||||
-rw-r--r-- | engines/sludge/variable.h | 2 |
9 files changed, 129 insertions, 129 deletions
diff --git a/engines/sludge/backdrop.cpp b/engines/sludge/backdrop.cpp index 04f484715a..0e41230f36 100644 --- a/engines/sludge/backdrop.cpp +++ b/engines/sludge/backdrop.cpp @@ -540,14 +540,14 @@ bool GraphicsManager::getRGBIntoStack(uint x, uint y, StackHandler *sH) { byte *target = (byte *)_renderSurface.getBasePtr(x, y); - setVariable(newValue, SVT_INT, target[1]); + newValue.setVariable(SVT_INT, target[1]); if (!addVarToStackQuick(newValue, sH->first)) return false; sH->last = sH->first; - setVariable(newValue, SVT_INT, target[2]); + newValue.setVariable(SVT_INT, target[2]); if (!addVarToStackQuick(newValue, sH->first)) return false; - setVariable(newValue, SVT_INT, target[3]); + newValue.setVariable(SVT_INT, target[3]); if (!addVarToStackQuick(newValue, sH->first)) return false; return true; diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp index 0ebcea1001..e8990144ab 100644 --- a/engines/sludge/builtin.cpp +++ b/engines/sludge/builtin.cpp @@ -159,7 +159,7 @@ builtIn(unfreeze) { builtIn(howFrozen) { UNUSEDALL - setVariable(fun->reg, SVT_INT, g_sludge->_gfxMan->howFrozen()); + fun->reg.setVariable(SVT_INT, g_sludge->_gfxMan->howFrozen()); return BR_CONTINUE; } @@ -173,25 +173,25 @@ builtIn(setCursor) { builtIn(getMouseX) { UNUSEDALL - setVariable(fun->reg, SVT_INT, g_sludge->_evtMan->mouseX() + g_sludge->_gfxMan->getCamX()); + fun->reg.setVariable(SVT_INT, g_sludge->_evtMan->mouseX() + g_sludge->_gfxMan->getCamX()); return BR_CONTINUE; } builtIn(getMouseY) { UNUSEDALL - setVariable(fun->reg, SVT_INT, g_sludge->_evtMan->mouseY() + g_sludge->_gfxMan->getCamY()); + fun->reg.setVariable(SVT_INT, g_sludge->_evtMan->mouseY() + g_sludge->_gfxMan->getCamY()); return BR_CONTINUE; } builtIn(getMouseScreenX) { UNUSEDALL - setVariable(fun->reg, SVT_INT, g_sludge->_evtMan->mouseX() * g_sludge->_gfxMan->getCamZoom()); + fun->reg.setVariable(SVT_INT, g_sludge->_evtMan->mouseX() * g_sludge->_gfxMan->getCamZoom()); return BR_CONTINUE; } builtIn(getMouseScreenY) { UNUSEDALL - setVariable(fun->reg, SVT_INT, g_sludge->_evtMan->mouseY() * g_sludge->_gfxMan->getCamZoom()); + fun->reg.setVariable(SVT_INT, g_sludge->_evtMan->mouseY() * g_sludge->_gfxMan->getCamZoom()); return BR_CONTINUE; } @@ -237,7 +237,7 @@ builtIn(saveGame) { g_sludge->loadNow = ":" + aaaaa; - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); saverFunc = fun; return BR_KEEP_AND_PAUSE; } @@ -267,7 +267,7 @@ builtIn(fileExists) { } // Return value - setVariable(fun->reg, SVT_INT, exist); + fun->reg.setVariable(SVT_INT, exist); return BR_CONTINUE; } @@ -492,7 +492,7 @@ builtIn(stringLength) { UNUSEDALL Common::String newText = getTextFromAnyVar(fun->stack->thisVar); trimStack(fun->stack); - setVariable(fun->reg, SVT_INT, g_sludge->_txtMan->stringLength(newText)); + fun->reg.setVariable(SVT_INT, g_sludge->_txtMan->stringLength(newText)); return BR_CONTINUE; } @@ -527,13 +527,13 @@ builtIn(stackSize) { switch (fun->stack->thisVar.varType) { case SVT_STACK: // Return value - setVariable(fun->reg, SVT_INT, stackSize(fun->stack->thisVar.varData.theStack)); + fun->reg.setVariable(SVT_INT, stackSize(fun->stack->thisVar.varData.theStack)); trimStack(fun->stack); return BR_CONTINUE; case SVT_FASTARRAY: // Return value - setVariable(fun->reg, SVT_INT, fun->stack->thisVar.varData.fastArray->size); + fun->reg.setVariable(SVT_INT, fun->stack->thisVar.varData.fastArray->size); trimStack(fun->stack); return BR_CONTINUE; @@ -606,7 +606,7 @@ builtIn(deleteFromStack) { } // Return value - setVariable(fun->reg, SVT_INT, deleteVarFromStack(fun->stack->thisVar, fun->stack->next->thisVar.varData.theStack->first, false)); + fun->reg.setVariable(SVT_INT, deleteVarFromStack(fun->stack->thisVar, fun->stack->next->thisVar.varData.theStack->first, false)); // Horrible hacking because 'last' value might now be wrong! fun->stack->next->thisVar.varData.theStack->last = stackFindLast(fun->stack->next->thisVar.varData.theStack->first); @@ -624,7 +624,7 @@ builtIn(deleteAllFromStack) { } // Return value - setVariable(fun->reg, SVT_INT, deleteVarFromStack(fun->stack->thisVar, fun->stack->next->thisVar.varData.theStack->first, true)); + fun->reg.setVariable(SVT_INT, deleteVarFromStack(fun->stack->thisVar, fun->stack->next->thisVar.varData.theStack->first, true)); // Horrible hacking because 'last' value might now be wrong! fun->stack->next->thisVar.varData.theStack->last = stackFindLast(fun->stack->next->thisVar.varData.theStack->first); @@ -696,7 +696,7 @@ builtIn(random) { trimStack(fun->stack); if (num <= 0) num = 1; - setVariable(fun->reg, SVT_INT, 0 /*rand() % num*/); //TODO:false value + fun->reg.setVariable(SVT_INT, 0 /*rand() % num*/); //TODO:false value return BR_CONTINUE; } @@ -754,7 +754,7 @@ builtIn(setBlankColour) { return BR_ERROR; g_sludge->_gfxMan->setBlankColor(red, green, blue); - setVariable(fun->reg, SVT_INT, 1); + fun->reg.setVariable(SVT_INT, 1); return BR_CONTINUE; } @@ -766,7 +766,7 @@ builtIn(setBurnColour) { return BR_ERROR; g_sludge->_gfxMan->setBurnColor(red, green, blue); - setVariable(fun->reg, SVT_INT, 1); + fun->reg.setVariable(SVT_INT, 1); return BR_CONTINUE; } @@ -796,7 +796,7 @@ builtIn(inFont) { trimStack(fun->stack); // Return value - setVariable(fun->reg, SVT_INT, g_sludge->_txtMan->isInFont(newText)); + fun->reg.setVariable(SVT_INT, g_sludge->_txtMan->isInFont(newText)); return BR_CONTINUE; } @@ -889,7 +889,7 @@ builtIn(launch) { if (g_sludge->launchMe.empty()) return BR_ERROR; } - setVariable(fun->reg, SVT_INT, 1); + fun->reg.setVariable(SVT_INT, 1); launchResult = &fun->reg; return BR_KEEP_AND_PAUSE; @@ -929,10 +929,10 @@ builtIn(callEvent) { // Return value if (fNum) { - setVariable(fun->reg, SVT_FUNC, fNum); + fun->reg.setVariable(SVT_FUNC, fNum); return BR_CALLAFUNC; } - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); return BR_CONTINUE; } @@ -954,13 +954,13 @@ builtIn(_rem_movieStart) { builtIn(_rem_movieAbort) { UNUSEDALL - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); return BR_CONTINUE; } builtIn(_rem_moviePlaying) { UNUSEDALL - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); return BR_CONTINUE; } @@ -977,7 +977,7 @@ builtIn(playMovie) { r = playMovie(fileNumber); - setVariable(fun->reg, SVT_INT, r); + fun->reg.setVariable(SVT_INT, r); if (r && (!fun->next)) { restartFunction(fun); @@ -991,7 +991,7 @@ builtIn(stopMovie) { stopMovie(); - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); return BR_CONTINUE; } @@ -1000,7 +1000,7 @@ builtIn(pauseMovie) { pauseMovie(); - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); return BR_CONTINUE; } @@ -1231,11 +1231,11 @@ builtIn(setLightMap) { trimStack(fun->stack); if (!g_sludge->_gfxMan->loadLightMap(v)) return BR_ERROR; - setVariable(fun->reg, SVT_INT, 1); + fun->reg.setVariable(SVT_INT, 1); } else { trimStack(fun->stack); g_sludge->_gfxMan->killLightMap(); - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); } break; @@ -1267,9 +1267,9 @@ builtIn(somethingSpeaking) { UNUSEDALL int i = g_sludge->_speechMan->isThereAnySpeechGoingOn(); if (i == -1) { - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); } else { - setVariable(fun->reg, SVT_OBJTYPE, i); + fun->reg.setVariable(SVT_OBJTYPE, i); } return BR_CONTINUE; } @@ -1284,10 +1284,10 @@ builtIn(getOverObject) { UNUSEDALL if (g_sludge->_regionMan->getOverRegion()) // Return value - setVariable(fun->reg, SVT_OBJTYPE, g_sludge->_regionMan->getOverRegion()->thisType->objectNum); + fun->reg.setVariable(SVT_OBJTYPE, g_sludge->_regionMan->getOverRegion()->thisType->objectNum); else // Return value - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); return BR_CONTINUE; } @@ -1314,13 +1314,13 @@ builtIn(getObjectX) { OnScreenPerson *pers = g_sludge->_peopleMan->findPerson(objectNumber); if (pers) { - setVariable(fun->reg, SVT_INT, pers->x); + fun->reg.setVariable(SVT_INT, pers->x); } else { ScreenRegion *la = g_sludge->_regionMan->getRegionForObject(objectNumber); if (la) { - setVariable(fun->reg, SVT_INT, la->sX); + fun->reg.setVariable(SVT_INT, la->sX); } else { - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); } } return BR_CONTINUE; @@ -1335,13 +1335,13 @@ builtIn(getObjectY) { OnScreenPerson *pers = g_sludge->_peopleMan->findPerson(objectNumber); if (pers) { - setVariable(fun->reg, SVT_INT, pers->y); + fun->reg.setVariable(SVT_INT, pers->y); } else { ScreenRegion *la = g_sludge->_regionMan->getRegionForObject(objectNumber); if (la) { - setVariable(fun->reg, SVT_INT, la->sY); + fun->reg.setVariable(SVT_INT, la->sY); } else { - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); } } return BR_CONTINUE; @@ -1520,7 +1520,7 @@ builtIn(stopCharacter) { trimStack(fun->stack); // Return value - setVariable(fun->reg, SVT_INT, g_sludge->_peopleMan->stopPerson(obj)); + fun->reg.setVariable(SVT_INT, g_sludge->_peopleMan->stopPerson(obj)); return BR_CONTINUE; } @@ -1543,9 +1543,9 @@ builtIn(pasteCharacter) { int fNum = myAnim->frames[thisPerson->frameNum].frameNum; g_sludge->_gfxMan->fixScaleSprite(thisPerson->x, thisPerson->y, myAnim->theSprites->bank.sprites[ABS(fNum)], myAnim->theSprites->bank.myPalette, thisPerson, 0, 0, fNum < 0); - setVariable(fun->reg, SVT_INT, 1); + fun->reg.setVariable(SVT_INT, 1); } else { - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); } return BR_CONTINUE; } @@ -1561,7 +1561,7 @@ builtIn(animate) { return BR_ERROR; trimStack(fun->stack); g_sludge->_peopleMan->animatePerson(obj, pp); - setVariable(fun->reg, SVT_INT, pp->getTotalTime()); + fun->reg.setVariable(SVT_INT, pp->getTotalTime()); return BR_CONTINUE; } @@ -1588,7 +1588,7 @@ builtIn(floatCharacter) { if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; trimStack(fun->stack); - setVariable(fun->reg, SVT_INT, g_sludge->_peopleMan->floatCharacter(di, obj)); + fun->reg.setVariable(SVT_INT, g_sludge->_peopleMan->floatCharacter(di, obj)); return BR_CONTINUE; } @@ -1601,7 +1601,7 @@ builtIn(setCharacterWalkSpeed) { if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; trimStack(fun->stack); - setVariable(fun->reg, SVT_INT, g_sludge->_peopleMan->setCharacterWalkSpeed(di, obj)); + fun->reg.setVariable(SVT_INT, g_sludge->_peopleMan->setCharacterWalkSpeed(di, obj)); return BR_CONTINUE; } @@ -1614,7 +1614,7 @@ builtIn(turnCharacter) { if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; trimStack(fun->stack); - setVariable(fun->reg, SVT_INT, g_sludge->_peopleMan->turnPersonToFace(obj, di)); + fun->reg.setVariable(SVT_INT, g_sludge->_peopleMan->turnPersonToFace(obj, di)); return BR_CONTINUE; } @@ -1627,7 +1627,7 @@ builtIn(setCharacterExtra) { if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; trimStack(fun->stack); - setVariable(fun->reg, SVT_INT, g_sludge->_peopleMan->setPersonExtra(obj, di)); + fun->reg.setVariable(SVT_INT, g_sludge->_peopleMan->setPersonExtra(obj, di)); return BR_CONTINUE; } @@ -1895,7 +1895,7 @@ builtIn(stringWidth) { trimStack(fun->stack); // Return value - setVariable(fun->reg, SVT_INT, g_sludge->_txtMan->stringWidth(theText)); + fun->reg.setVariable(SVT_INT, g_sludge->_txtMan->stringWidth(theText)); return BR_CONTINUE; } @@ -1915,7 +1915,7 @@ builtIn(isScreenRegion) { if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar)) return BR_ERROR; trimStack(fun->stack); - setVariable(fun->reg, SVT_INT, g_sludge->_regionMan->getRegionForObject(objectNumber) != NULL); + fun->reg.setVariable(SVT_INT, g_sludge->_regionMan->getRegionForObject(objectNumber) != NULL); return BR_CONTINUE; } @@ -1926,7 +1926,7 @@ builtIn(setSpeechSpeed) { return BR_ERROR; trimStack(fun->stack); g_sludge->_speechMan->setSpeechSpeed(number * 0.01); - setVariable(fun->reg, SVT_INT, 1); + fun->reg.setVariable(SVT_INT, 1); return BR_CONTINUE; } @@ -1937,7 +1937,7 @@ builtIn(setFontSpacing) { return BR_ERROR; g_sludge->_txtMan->setFontSpace(fontSpaceI); trimStack(fun->stack); - setVariable(fun->reg, SVT_INT, 1); + fun->reg.setVariable(SVT_INT, 1); return BR_CONTINUE; } @@ -1950,7 +1950,7 @@ builtIn(transitionLevel) { g_sludge->_gfxMan->setBrightnessLevel(brightnessLevel); - setVariable(fun->reg, SVT_INT, 1); + fun->reg.setVariable(SVT_INT, 1); return BR_CONTINUE; } @@ -1959,7 +1959,7 @@ builtIn(captureAllKeys) { // This built-in function doesn't have any effect any more, we capture all keys by default bool captureAllKeysDeprecated = getBoolean(fun->stack->thisVar); trimStack(fun->stack); - setVariable(fun->reg, SVT_INT, captureAllKeysDeprecated); + fun->reg.setVariable(SVT_INT, captureAllKeysDeprecated); return BR_CONTINUE; } @@ -1978,10 +1978,10 @@ builtIn(spinCharacter) { thisPerson->wantAngle = number; thisPerson->spinning = true; thisPerson->continueAfterWalking = fun; - setVariable(fun->reg, SVT_INT, 1); + fun->reg.setVariable(SVT_INT, 1); return BR_PAUSE; } else { - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); return BR_CONTINUE; } } @@ -1994,9 +1994,9 @@ builtIn(getCharacterDirection) { trimStack(fun->stack); OnScreenPerson *thisPerson = g_sludge->_peopleMan->findPerson(objectNumber); if (thisPerson) { - setVariable(fun->reg, SVT_INT, thisPerson->direction); + fun->reg.setVariable(SVT_INT, thisPerson->direction); } else { - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); } return BR_CONTINUE; } @@ -2008,7 +2008,7 @@ builtIn(isCharacter) { return BR_ERROR; trimStack(fun->stack); OnScreenPerson *thisPerson = g_sludge->_peopleMan->findPerson(objectNumber); - setVariable(fun->reg, SVT_INT, thisPerson != NULL); + fun->reg.setVariable(SVT_INT, thisPerson != NULL); return BR_CONTINUE; } @@ -2021,9 +2021,9 @@ builtIn(normalCharacter) { OnScreenPerson *thisPerson = g_sludge->_peopleMan->findPerson(objectNumber); if (thisPerson) { thisPerson->myAnim = thisPerson->myPersona->animation[thisPerson->direction]; - setVariable(fun->reg, SVT_INT, 1); + fun->reg.setVariable(SVT_INT, 1); } else { - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); } return BR_CONTINUE; } @@ -2036,9 +2036,9 @@ builtIn(isMoving) { trimStack(fun->stack); OnScreenPerson *thisPerson = g_sludge->_peopleMan->findPerson(objectNumber); if (thisPerson) { - setVariable(fun->reg, SVT_INT, thisPerson->walking); + fun->reg.setVariable(SVT_INT, thisPerson->walking); } else { - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); } return BR_CONTINUE; } @@ -2057,9 +2057,9 @@ builtIn(fetchEvent) { // Return value if (fNum) { - setVariable(fun->reg, SVT_FUNC, fNum); + fun->reg.setVariable(SVT_FUNC, fNum); } else { - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); } return BR_CONTINUE; } @@ -2073,7 +2073,7 @@ builtIn(deleteFile) { namNormal.clear(); if (failSecurityCheck(nam)) return BR_ERROR; - setVariable(fun->reg, SVT_INT, remove(nam.c_str())); + fun->reg.setVariable(SVT_INT, remove(nam.c_str())); return BR_CONTINUE; } @@ -2096,7 +2096,7 @@ builtIn(renameFile) { if (failSecurityCheck(nam)) return BR_ERROR; - setVariable(fun->reg, SVT_INT, rename(nam.c_str(), newnam.c_str())); + fun->reg.setVariable(SVT_INT, rename(nam.c_str(), newnam.c_str())); return BR_CONTINUE; } @@ -2143,9 +2143,9 @@ builtIn(setCharacterSpinSpeed) { if (thisPerson) { thisPerson->spinSpeed = speed; - setVariable(fun->reg, SVT_INT, 1); + fun->reg.setVariable(SVT_INT, 1); } else { - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); } return BR_CONTINUE; } @@ -2164,9 +2164,9 @@ builtIn(setCharacterAngleOffset) { if (thisPerson) { thisPerson->angleOffset = angle; - setVariable(fun->reg, SVT_INT, 1); + fun->reg.setVariable(SVT_INT, 1); } else { - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); } return BR_CONTINUE; } @@ -2178,7 +2178,7 @@ builtIn(transitionMode) { return BR_ERROR; g_sludge->_gfxMan->setFadeMode(n); trimStack(fun->stack); - setVariable(fun->reg, SVT_INT, 1); + fun->reg.setVariable(SVT_INT, 1); return BR_CONTINUE; } @@ -2186,7 +2186,7 @@ builtIn(transitionMode) { builtIn(_rem_updateDisplay) { UNUSEDALL trimStack(fun->stack); - setVariable(fun->reg, SVT_INT, true); + fun->reg.setVariable(SVT_INT, true); return BR_CONTINUE; } @@ -2256,7 +2256,7 @@ builtIn(setCustomEncoding) { return BR_ERROR; CustomSaveHelper::_saveEncoding = n; trimStack(fun->stack); - setVariable(fun->reg, SVT_INT, 1); + fun->reg.setVariable(SVT_INT, 1); return BR_CONTINUE; } @@ -2289,7 +2289,7 @@ builtIn(parallaxAdd) { if (!g_sludge->_gfxMan->loadParallax(v, wrapX, wrapY)) return BR_ERROR; - setVariable(fun->reg, SVT_INT, 1); + fun->reg.setVariable(SVT_INT, 1); } return BR_CONTINUE; } @@ -2297,7 +2297,7 @@ builtIn(parallaxAdd) { builtIn(parallaxClear) { UNUSEDALL g_sludge->_gfxMan->killParallax(); - setVariable(fun->reg, SVT_INT, 1); + fun->reg.setVariable(SVT_INT, 1); return BR_CONTINUE; } @@ -2358,16 +2358,16 @@ builtIn(getCharacterScale) { OnScreenPerson *pers = g_sludge->_peopleMan->findPerson(objectNumber); if (pers) { - setVariable(fun->reg, SVT_INT, pers->scale * 100); + fun->reg.setVariable(SVT_INT, pers->scale * 100); } else { - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); } return BR_CONTINUE; } builtIn(getLanguageID) { UNUSEDALL - setVariable(fun->reg, SVT_INT, g_sludge->getLanguageID()); + fun->reg.setVariable(SVT_INT, g_sludge->getLanguageID()); return BR_CONTINUE; } @@ -2397,13 +2397,13 @@ builtIn(_rem_launchWith) { } g_sludge->launchNext.clear(); - setVariable(fun->reg, SVT_INT, false); + fun->reg.setVariable(SVT_INT, false); return BR_CONTINUE; } builtIn(getFramesPerSecond) { UNUSEDALL - setVariable(fun->reg, SVT_INT, g_sludge->_timer.getLastFps()); + fun->reg.setVariable(SVT_INT, g_sludge->_timer.getLastFps()); return BR_CONTINUE; } @@ -2454,7 +2454,7 @@ builtIn(hasFlag) { ObjectType *objT = g_sludge->_objMan->findObjectType(objNum); if (!objT) return BR_ERROR; - setVariable(fun->reg, SVT_INT, objT->flags & (1 << flagIndex)); + fun->reg.setVariable(SVT_INT, objT->flags & (1 << flagIndex)); return BR_CONTINUE; } @@ -2474,7 +2474,7 @@ builtIn(bodgeFilenames) { bool lastValue = allowAnyFilename; allowAnyFilename = getBoolean(fun->stack->thisVar); trimStack(fun->stack); - setVariable(fun->reg, SVT_INT, lastValue); + fun->reg.setVariable(SVT_INT, lastValue); return BR_CONTINUE; } @@ -2483,7 +2483,7 @@ builtIn(_rem_registryGetString) { UNUSEDALL trimStack(fun->stack); trimStack(fun->stack); - setVariable(fun->reg, SVT_INT, 0); + fun->reg.setVariable(SVT_INT, 0); return BR_CONTINUE; } @@ -2521,14 +2521,14 @@ builtIn(_rem_setMaximumAA) { builtIn(setBackgroundEffect) { UNUSEDALL bool done = blur_createSettings(numParams, fun->stack); - setVariable(fun->reg, SVT_INT, done ? 1 : 0); + fun->reg.setVariable(SVT_INT, done ? 1 : 0); return BR_CONTINUE; } builtIn(doBackgroundEffect) { UNUSEDALL bool done = blurScreen(); - setVariable(fun->reg, SVT_INT, done ? 1 : 0); + fun->reg.setVariable(SVT_INT, done ? 1 : 0); return BR_CONTINUE; } diff --git a/engines/sludge/event.cpp b/engines/sludge/event.cpp index acccd7ff84..16e02e54b7 100644 --- a/engines/sludge/event.cpp +++ b/engines/sludge/event.cpp @@ -157,7 +157,7 @@ bool EventManager::handleInput() { } else { l = 1; - setVariable(*launchResult, SVT_INT, 0/*launch(launchMe) > 31*/); //TODO:false value + launchResult->setVariable(SVT_INT, 0/*launch(launchMe) > 31*/); //TODO:false value _vm->launchMe.clear(); launchResult = nullptr; } @@ -184,9 +184,9 @@ bool EventManager::handleInput() { ScreenRegion *overRegion = _vm->_regionMan->getOverRegion(); if (overRegion) { - setVariable(tempStack->thisVar, SVT_OBJTYPE, overRegion->thisType->objectNum); + tempStack->thisVar.setVariable(SVT_OBJTYPE, overRegion->thisType->objectNum); } else { - setVariable(tempStack->thisVar, SVT_INT, 0); + tempStack->thisVar.setVariable(SVT_INT, 0); } tempStack->next = nullptr; if (!startNewFunctionNum(_currentEvents->func[kFocus], 1, nullptr, tempStack)) diff --git a/engines/sludge/function.cpp b/engines/sludge/function.cpp index 97c51307ab..7ed6207526 100644 --- a/engines/sludge/function.cpp +++ b/engines/sludge/function.cpp @@ -247,7 +247,7 @@ bool continueFunction(LoadedFunction *fun) { case BR_CALLAFUNC: { int i = fun->reg.varData.intValue; - setVariable(fun->reg, SVT_INT, 1); + fun->reg.setVariable(SVT_INT, 1); pauseFunction(fun); if (numBIFNames) setFatalInfo( @@ -278,15 +278,15 @@ bool continueFunction(LoadedFunction *fun) { // These all grab things and shove 'em into the register case SLU_LOAD_NULL: - setVariable(fun->reg, SVT_NULL, 0); + fun->reg.setVariable(SVT_NULL, 0); break; case SLU_LOAD_FILE: - setVariable(fun->reg, SVT_FILE, param); + fun->reg.setVariable(SVT_FILE, param); break; case SLU_LOAD_VALUE: - setVariable(fun->reg, SVT_INT, param); + fun->reg.setVariable(SVT_INT, param); break; case SLU_LOAD_LOCAL: @@ -295,27 +295,27 @@ bool continueFunction(LoadedFunction *fun) { break; case SLU_AND: - setVariable(fun->reg, SVT_INT, + fun->reg.setVariable(SVT_INT, getBoolean(fun->reg) && getBoolean(fun->stack->thisVar)); trimStack(fun->stack); break; case SLU_OR: - setVariable(fun->reg, SVT_INT, + fun->reg.setVariable(SVT_INT, getBoolean(fun->reg) || getBoolean(fun->stack->thisVar)); trimStack(fun->stack); break; case SLU_LOAD_FUNC: - setVariable(fun->reg, SVT_FUNC, param); + fun->reg.setVariable(SVT_FUNC, param); break; case SLU_LOAD_BUILT: - setVariable(fun->reg, SVT_BUILT, param); + fun->reg.setVariable(SVT_BUILT, param); break; case SLU_LOAD_OBJTYPE: - setVariable(fun->reg, SVT_OBJTYPE, param); + fun->reg.setVariable(SVT_OBJTYPE, param); break; case SLU_UNREG: @@ -333,7 +333,7 @@ bool continueFunction(LoadedFunction *fun) { switch (fun->stack->thisVar.varType) { case SVT_NULL: if (com == SLU_INDEXGET) { - setVariable(fun->reg, SVT_NULL, 0); + fun->reg.setVariable(SVT_NULL, 0); trimStack(fun->stack); } else { return fatal(ERROR_INCDEC_UNKNOWN); @@ -360,21 +360,21 @@ bool continueFunction(LoadedFunction *fun) { trimStack(fun->stack); if (!grab) { - setVariable(fun->reg, SVT_NULL, 0); + fun->reg.setVariable(SVT_NULL, 0); } else { int kk; switch (com) { case SLU_INCREMENT_INDEX: if (!getValueType(kk, SVT_INT, *grab)) return false; - setVariable(fun->reg, SVT_INT, kk); + fun->reg.setVariable(SVT_INT, kk); grab->varData.intValue = kk + 1; break; case SLU_DECREMENT_INDEX: if (!getValueType(kk, SVT_INT, *grab)) return false; - setVariable(fun->reg, SVT_INT, kk); + fun->reg.setVariable(SVT_INT, kk); grab->varData.intValue = kk - 1; break; @@ -437,8 +437,8 @@ bool continueFunction(LoadedFunction *fun) { int ii; if (!getValueType(ii, SVT_INT, fun->localVars[param])) return false; - setVariable(fun->reg, SVT_INT, ii); - setVariable(fun->localVars[param], SVT_INT, ii + 1); + fun->reg.setVariable(SVT_INT, ii); + fun->localVars[param].setVariable(SVT_INT, ii + 1); } break; @@ -446,8 +446,8 @@ bool continueFunction(LoadedFunction *fun) { int ii; if (!getValueType(ii, SVT_INT, globalVars[param])) return false; - setVariable(fun->reg, SVT_INT, ii); - setVariable(globalVars[param], SVT_INT, ii + 1); + fun->reg.setVariable(SVT_INT, ii); + globalVars[param].setVariable(SVT_INT, ii + 1); } break; @@ -455,8 +455,8 @@ bool continueFunction(LoadedFunction *fun) { int ii; if (!getValueType(ii, SVT_INT, fun->localVars[param])) return false; - setVariable(fun->reg, SVT_INT, ii); - setVariable(fun->localVars[param], SVT_INT, ii - 1); + fun->reg.setVariable(SVT_INT, ii); + fun->localVars[param].setVariable(SVT_INT, ii - 1); } break; @@ -464,8 +464,8 @@ bool continueFunction(LoadedFunction *fun) { int ii; if (!getValueType(ii, SVT_INT, globalVars[param])) return false; - setVariable(fun->reg, SVT_INT, ii); - setVariable(globalVars[param], SVT_INT, ii - 1); + fun->reg.setVariable(SVT_INT, ii); + globalVars[param].setVariable(SVT_INT, ii - 1); } break; @@ -500,7 +500,7 @@ bool continueFunction(LoadedFunction *fun) { break; case SLU_NOT: - setVariable(fun->reg, SVT_INT, !getBoolean(fun->reg)); + fun->reg.setVariable(SVT_INT, !getBoolean(fun->reg)); break; case SLU_BR_ZERO: @@ -519,7 +519,7 @@ bool continueFunction(LoadedFunction *fun) { int i; if (!getValueType(i, SVT_INT, fun->reg)) return false; - setVariable(fun->reg, SVT_INT, -i); + fun->reg.setVariable(SVT_INT, -i); } break; @@ -565,42 +565,42 @@ bool continueFunction(LoadedFunction *fun) { switch (com) { case SLU_MULT: - setVariable(fun->reg, SVT_INT, + fun->reg.setVariable(SVT_INT, firstValue * secondValue); break; case SLU_MINUS: - setVariable(fun->reg, SVT_INT, + fun->reg.setVariable(SVT_INT, firstValue - secondValue); break; case SLU_MODULUS: - setVariable(fun->reg, SVT_INT, + fun->reg.setVariable(SVT_INT, firstValue % secondValue); break; case SLU_DIVIDE: - setVariable(fun->reg, SVT_INT, + fun->reg.setVariable(SVT_INT, firstValue / secondValue); break; case SLU_LESSTHAN: - setVariable(fun->reg, SVT_INT, + fun->reg.setVariable(SVT_INT, firstValue < secondValue); break; case SLU_MORETHAN: - setVariable(fun->reg, SVT_INT, + fun->reg.setVariable(SVT_INT, firstValue > secondValue); break; case SLU_LESS_EQUAL: - setVariable(fun->reg, SVT_INT, + fun->reg.setVariable(SVT_INT, firstValue <= secondValue); break; case SLU_MORE_EQUAL: - setVariable(fun->reg, SVT_INT, + fun->reg.setVariable(SVT_INT, firstValue >= secondValue); break; diff --git a/engines/sludge/loadsave.cpp b/engines/sludge/loadsave.cpp index 22781eaba9..bb41d0a36e 100644 --- a/engines/sludge/loadsave.cpp +++ b/engines/sludge/loadsave.cpp @@ -71,7 +71,7 @@ bool handleSaveLoad() { if (!g_sludge->loadNow.empty()) { if (g_sludge->loadNow[0] == ':') { saveGame(g_sludge->loadNow.c_str() + 1); - setVariable(saverFunc->reg, SVT_INT, 1); + saverFunc->reg.setVariable(SVT_INT, 1); } else { if (!loadGame(g_sludge->loadNow)) return false; diff --git a/engines/sludge/savedata.cpp b/engines/sludge/savedata.cpp index 687c913999..f8b07a5362 100644 --- a/engines/sludge/savedata.cpp +++ b/engines/sludge/savedata.cpp @@ -138,11 +138,11 @@ bool CustomSaveHelper::fileToStack(const Common::String &filename, StackHandler break; case 1: - setVariable(stringVar, SVT_INT, fp->readUint32LE()); + stringVar.setVariable(SVT_INT, fp->readUint32LE()); break; case 2: - setVariable(stringVar, SVT_INT, fp->readByte()); + stringVar.setVariable(SVT_INT, fp->readByte()); break; default: diff --git a/engines/sludge/sound.cpp b/engines/sludge/sound.cpp index 306fd49b4e..25b239c191 100644 --- a/engines/sludge/sound.cpp +++ b/engines/sludge/sound.cpp @@ -402,7 +402,7 @@ bool SoundManager::getSoundCacheStack(StackHandler *sH) { for (int a = 0; a < MAX_SAMPLES; a++) { if (_soundCache[a].fileLoaded != -1) { - setVariable(newFileHandle, SVT_FILE, _soundCache[a].fileLoaded); + newFileHandle.setVariable(SVT_FILE, _soundCache[a].fileLoaded); if (!addVarToStackQuick(newFileHandle, sH->first)) return false; if (sH->last == NULL) diff --git a/engines/sludge/variable.cpp b/engines/sludge/variable.cpp index dc5604f31b..faaf9bd363 100644 --- a/engines/sludge/variable.cpp +++ b/engines/sludge/variable.cpp @@ -76,10 +76,10 @@ void Variable::unlinkVar() { } } -void setVariable(Variable &thisVar, VariableType vT, int value) { - thisVar.unlinkVar(); - thisVar.varType = vT; - thisVar.varData.intValue = value; +void Variable::setVariable(VariableType vT, int value) { + unlinkVar(); + varType = vT; + varData.intValue = value; } void newAnimationVariable(Variable &thisVar, PersonaAnimation *i) { @@ -236,7 +236,7 @@ int compareVars(const Variable &var1, const Variable &var2) { } void compareVariablesInSecond(const Variable &var1, Variable &var2) { - setVariable(var2, SVT_INT, compareVars(var1, var2)); + var2.setVariable(SVT_INT, compareVars(var1, var2)); } void makeTextVar(Variable &thisVar, const Common::String &txt) { diff --git a/engines/sludge/variable.h b/engines/sludge/variable.h index 5a750b5a6a..33810514d6 100644 --- a/engines/sludge/variable.h +++ b/engines/sludge/variable.h @@ -75,6 +75,7 @@ struct Variable { } void unlinkVar(); + void setVariable(VariableType vT, int value); }; struct VariableStack { @@ -84,7 +85,6 @@ struct VariableStack { // Setting variables -void setVariable(Variable &thisVar, VariableType vT, int value); bool copyVariable(const Variable &from, Variable &to); bool loadStringToVar(Variable &thisVar, int value); void newAnimationVariable(Variable &thisVar, struct PersonaAnimation *i); |