aboutsummaryrefslogtreecommitdiff
path: root/engines/sludge/builtin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sludge/builtin.cpp')
-rw-r--r--engines/sludge/builtin.cpp706
1 files changed, 337 insertions, 369 deletions
diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp
index 7385d4d861..1030643788 100644
--- a/engines/sludge/builtin.cpp
+++ b/engines/sludge/builtin.cpp
@@ -32,6 +32,7 @@
#include "sludge/floor.h"
#include "sludge/fonttext.h"
#include "sludge/freeze.h"
+#include "sludge/function.h"
#include "sludge/graphics.h"
#include "sludge/language.h"
#include "sludge/loadsave.h"
@@ -54,51 +55,16 @@
namespace Sludge {
-int speechMode = 0;
-SpritePalette pastePalette;
-
Variable *launchResult = NULL;
-extern int lastFramesPerSecond, thumbWidth, thumbHeight;
extern bool allowAnyFilename;
-extern bool captureAllKeys;
extern VariableStack *noStack;
extern StatusStuff *nowStatus;
-extern ScreenRegion *overRegion;
extern int numBIFNames, numUserFunc;
extern Common::String *allUserFunc;
extern Common::String *allBIFNames;
-extern byte brightnessLevel;
-extern byte fadeMode;
-extern uint16 saveEncoding;
-
-int paramNum[] = { -1, 0, 1, 1, -1, -1, 1, 3, 4, 1, 0, 0, 8, -1, // SAY->MOVEMOUSE
- -1, 0, 0, -1, -1, 1, 1, 1, 1, 4, 1, 1, 2, 1,// FOCUS->REMOVEREGION
- 2, 2, 0, 0, 2, // ANIMATE->SETSCALE
- -1, 2, 1, 0, 0, 0, 1, 0, 3, // new/push/pop stack, status stuff
- 2, 0, 0, 3, 1, 0, 2, // delFromStack->completeTimers
- -1, -1, -1, 2, 2, 0, 3, 1, // anim, costume, pO, setC, wait, sS, substring, stringLength
- 0, 1, 1, 0, 2, // dark, save, load, quit, rename
- 1, 3, 3, 1, 2, 1, 1, 3, 1, 0, 0, 2, 1, // stackSize, pasteString, startMusic, defvol, vol, stopmus, stopsound, setfont, alignStatus, show x 2, pos'Status, setFloor
- -1, -1, 1, 1, 2, 1, 1, 1, -1, -1, -1, 1, 1, // force, jump, peekstart, peekend, enqueue, getSavedGames, inFont, loopSound, removeChar, stopCharacter
- 1, 0, 3, 3, 1, 2, 1, 2, 2, // launch, howFrozen, pastecol, litcol, checksaved, float, cancelfunc, walkspeed, delAll
- 2, 3, 1, 2, 2, 0, 0, 1, 2, 3, 1, -1, // extras, mixoverlay, pastebloke, getMScreenX/Y, setSound(Default/-)Volume, looppoints, speechMode, setLightMap
- -1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, // think, getCharacterDirection, is(char/region/moving), deleteGame, renameGame, hardScroll, stringWidth, speechSpeed, normalCharacter
- 2, 1, 2, 1, 3, 1, 1, 2, 1, // fetchEvent, setBrightness, spin, fontSpace, burnString, captureAll, cacheSound, setSpinSpeed, transitionMode
- 1, 0, 0, 1, 0, 2, 1, 1, 1, // movie(Start/Abort/Playing), updateDisplay, getSoundCache, savedata, loaddata, savemode, freeSound
- 3, 0, 3, 3, 2, 1, 1, // setParallax, clearParallax, setBlankColour, setBurnColour, getPixelColour, makeFastArray, getCharacterScale
- 0, 2, 0, // getLanguage, launchWith, getFramesPerSecond
- 3, 2, 2, 0, 0, 1, // readThumbnail, setThumbnailSize, hasFlag, snapshot, clearSnapshot, anyFilename
- 2, 1, // regGet, fatal
- 4, 3, -1, 0, // chr AA, max AA, setBackgroundEffect, doBackgroundEffect
- 2, // setCharacterAngleOffset
- 2, 5, // setCharacterTransparency, setCharacterColourise
- 1, // zoomCamera
- 1, 0, 0 // playMovie, stopMovie, pauseMovie
- };
-
bool failSecurityCheck(const Common::String &fn) {
if (fn.empty())
return true;
@@ -121,11 +87,12 @@ bool failSecurityCheck(const Common::String &fn) {
return false;
}
-LoadedFunction *saverFunc;
+extern LoadedFunction *saverFunc;
typedef BuiltReturn (*builtInSludgeFunc)(int numParams, LoadedFunction *fun);
struct builtInFunctionData {
builtInSludgeFunc func;
+ int paramNum;
};
#define builtIn(a) static BuiltReturn builtIn_ ## a (int numParams, LoadedFunction *fun)
@@ -140,15 +107,15 @@ static BuiltReturn sayCore(int numParams, LoadedFunction *fun, bool sayIt) {
switch (numParams) {
case 3:
- if (!getValueType(fileNum, SVT_FILE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(fileNum, SVT_FILE))
return BR_ERROR;
trimStack(fun->stack);
// fall through
case 2:
- newText = getTextFromAnyVar(fun->stack->thisVar);
+ newText = fun->stack->thisVar.getTextFromAnyVar();
trimStack(fun->stack);
- if (!getValueType(objT, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(objT, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
p = g_sludge->_speechMan->wrapSpeech(newText, objT, fileNum, sayIt);
@@ -192,13 +159,13 @@ 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;
}
builtIn(setCursor) {
UNUSEDALL
- PersonaAnimation *aa = getAnimationFromVar(fun->stack->thisVar);
+ PersonaAnimation *aa = fun->stack->thisVar.getAnimationFromVar();
g_sludge->_cursorMan->pickAnimCursor(aa);
trimStack(fun->stack);
return BR_CONTINUE;
@@ -206,39 +173,39 @@ 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;
}
builtIn(getStatusText) {
UNUSEDALL
- makeTextVar(fun->reg, statusBarText());
+ fun->reg.makeTextVar(statusBarText());
return BR_CONTINUE;
}
builtIn(getMatchingFiles) {
UNUSEDALL
- Common::String newText = getTextFromAnyVar(fun->stack->thisVar);
+ Common::String newText = fun->stack->thisVar.getTextFromAnyVar();
trimStack(fun->stack);
- unlinkVar(fun->reg);
+ fun->reg.unlinkVar();
// Return value
fun->reg.varType = SVT_STACK;
@@ -248,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;
}
@@ -260,7 +227,7 @@ builtIn(saveGame) {
fatal("Can't save game state while the engine is frozen");
}
- g_sludge->loadNow = getTextFromAnyVar(fun->stack->thisVar);
+ g_sludge->loadNow = fun->stack->thisVar.getTextFromAnyVar();
trimStack(fun->stack);
Common::String aaaaa = encodeFilename(g_sludge->loadNow);
@@ -270,14 +237,14 @@ 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;
}
builtIn(fileExists) {
UNUSEDALL
- g_sludge->loadNow = getTextFromAnyVar(fun->stack->thisVar);
+ g_sludge->loadNow = fun->stack->thisVar.getTextFromAnyVar();
trimStack(fun->stack);
Common::String aaaaa = encodeFilename(g_sludge->loadNow);
g_sludge->loadNow.clear();
@@ -300,13 +267,13 @@ builtIn(fileExists) {
}
// Return value
- setVariable(fun->reg, SVT_INT, exist);
+ fun->reg.setVariable(SVT_INT, exist);
return BR_CONTINUE;
}
builtIn(loadGame) {
UNUSEDALL
- Common::String aaaaa = getTextFromAnyVar(fun->stack->thisVar);
+ Common::String aaaaa = fun->stack->thisVar.getTextFromAnyVar();
trimStack(fun->stack);
g_sludge->loadNow.clear();
g_sludge->loadNow = encodeFilename(aaaaa);
@@ -340,16 +307,16 @@ builtIn(blankScreen) {
builtIn(blankArea) {
UNUSEDALL
int x1, y1, x2, y2;
- if (!getValueType(y2, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(y2, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(x2, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(x2, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(y1, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(y1, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(x1, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(x1, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
g_sludge->_gfxMan->blankScreen(x1, y1, x2, y2);
@@ -365,13 +332,13 @@ builtIn(darkBackground) {
builtIn(addOverlay) {
UNUSEDALL
int fileNumber, xPos, yPos;
- if (!getValueType(yPos, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(yPos, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(xPos, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(xPos, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(fileNumber, SVT_FILE))
return BR_ERROR;
trimStack(fun->stack);
g_sludge->_gfxMan->loadBackDrop(fileNumber, xPos, yPos);
@@ -381,13 +348,13 @@ builtIn(addOverlay) {
builtIn(mixOverlay) {
UNUSEDALL
int fileNumber, xPos, yPos;
- if (!getValueType(yPos, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(yPos, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(xPos, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(xPos, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(fileNumber, SVT_FILE))
return BR_ERROR;
trimStack(fun->stack);
g_sludge->_gfxMan->mixBackDrop(fileNumber, xPos, yPos);
@@ -397,13 +364,13 @@ builtIn(mixOverlay) {
builtIn(pasteImage) {
UNUSEDALL
int x, y;
- if (!getValueType(y, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(y, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(x, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(x, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- PersonaAnimation *pp = getAnimationFromVar(fun->stack->thisVar);
+ PersonaAnimation *pp = fun->stack->thisVar.getAnimationFromVar();
trimStack(fun->stack);
if (pp == NULL)
return BR_CONTINUE;
@@ -418,10 +385,10 @@ builtIn(pasteImage) {
builtIn(setSceneDimensions) {
UNUSEDALL
int x, y;
- if (!getValueType(y, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(y, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(x, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(x, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
if (g_sludge->_gfxMan->killResizeBackdrop(x, y)) {
@@ -435,10 +402,10 @@ builtIn(setSceneDimensions) {
builtIn(aimCamera) {
UNUSEDALL
int cameraX, cameraY;
- if (!getValueType(cameraY, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(cameraY, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(cameraX, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(cameraX, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
@@ -450,7 +417,7 @@ builtIn(aimCamera) {
builtIn(zoomCamera) {
UNUSEDALL
int z;
- if (!getValueType(z, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(z, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
@@ -476,7 +443,7 @@ builtIn(pickOne) {
// Return value
while (numParams--) {
if (i == numParams)
- copyVariable(fun->stack->thisVar, fun->reg);
+ fun->reg.copyFrom(fun->stack->thisVar);
trimStack(fun->stack);
}
return BR_CONTINUE;
@@ -489,13 +456,13 @@ builtIn(substring) {
//debugOut ("BUILTIN: substring\n");
- if (!getValueType(length, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(length, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(start, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(start, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- wholeString = getTextFromAnyVar(fun->stack->thisVar);
+ wholeString = fun->stack->thisVar.getTextFromAnyVar();
trimStack(fun->stack);
UTF8Converter convert;
@@ -517,21 +484,21 @@ builtIn(substring) {
Common::String newString(wholeString.begin() + startoffset, wholeString.begin() + endoffset);
- makeTextVar(fun->reg, newString);
+ fun->reg.makeTextVar(newString);
return BR_CONTINUE;
}
builtIn(stringLength) {
UNUSEDALL
- Common::String newText = getTextFromAnyVar(fun->stack->thisVar);
+ Common::String newText = fun->stack->thisVar.getTextFromAnyVar();
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;
}
builtIn(newStack) {
UNUSEDALL
- unlinkVar(fun->reg);
+ fun->reg.unlinkVar();
// Return value
fun->reg.varType = SVT_STACK;
@@ -560,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, fun->stack->thisVar.varData.theStack->getStackSize());
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;
@@ -584,7 +551,7 @@ builtIn(copyStack) {
return BR_ERROR;
}
// Return value
- if (!copyStack(fun->stack->thisVar, fun->reg))
+ if (!fun->reg.copyStack(fun->stack->thisVar))
return BR_ERROR;
trimStack(fun->stack);
return BR_CONTINUE;
@@ -639,10 +606,11 @@ 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);
+ VariableStack *nextFirstStack = fun->stack->next->thisVar.varData.theStack->first;
+ fun->stack->next->thisVar.varData.theStack->last = (nextFirstStack == NULL) ? NULL : nextFirstStack->stackFindLast();
trimStack(fun->stack);
trimStack(fun->stack);
@@ -657,10 +625,11 @@ 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);
+ VariableStack *nextFirstStack = fun->stack->next->thisVar.varData.theStack->first;
+ fun->stack->next->thisVar.varData.theStack->last = (nextFirstStack == NULL) ? NULL : nextFirstStack->stackFindLast();
trimStack(fun->stack);
trimStack(fun->stack);
@@ -679,7 +648,7 @@ builtIn(popFromStack) {
}
// Return value
- copyVariable(fun->stack->thisVar.varData.theStack->first->thisVar, fun->reg);
+ fun->reg.copyFrom(fun->stack->thisVar.varData.theStack->first->thisVar);
trimStack(fun->stack->thisVar.varData.theStack->first);
trimStack(fun->stack);
return BR_CONTINUE;
@@ -697,7 +666,7 @@ builtIn(peekStart) {
}
// Return value
- copyVariable(fun->stack->thisVar.varData.theStack->first->thisVar, fun->reg);
+ fun->reg.copyFrom(fun->stack->thisVar.varData.theStack->first->thisVar);
trimStack(fun->stack);
return BR_CONTINUE;
}
@@ -714,7 +683,7 @@ builtIn(peekEnd) {
}
// Return value
- copyVariable(fun->stack->thisVar.varData.theStack->last->thisVar, fun->reg);
+ fun->reg.copyFrom(fun->stack->thisVar.varData.theStack->last->thisVar);
trimStack(fun->stack);
return BR_CONTINUE;
}
@@ -723,24 +692,24 @@ builtIn(random) {
UNUSEDALL
int num;
- if (!getValueType(num, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(num, SVT_INT))
return BR_ERROR;
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;
}
static bool getRGBParams(int &red, int &green, int &blue, LoadedFunction *fun) {
- if (!getValueType(blue, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(blue, SVT_INT))
return false;
trimStack(fun->stack);
- if (!getValueType(green, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(green, SVT_INT))
return false;
trimStack(fun->stack);
- if (!getValueType(red, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(red, SVT_INT))
return false;
trimStack(fun->stack);
return true;
@@ -775,7 +744,7 @@ builtIn(setPasteColour) {
if (!getRGBParams(red, green, blue, fun))
return BR_ERROR;
- setFontColour(pastePalette, (byte)red, (byte)green, (byte)blue);
+ g_sludge->_txtMan->setPasterColor((byte)red, (byte)green, (byte)blue);
return BR_CONTINUE;
}
@@ -787,7 +756,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;
}
@@ -799,21 +768,21 @@ 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;
}
builtIn(setFont) {
UNUSEDALL
int fileNumber, newHeight;
- if (!getValueType(newHeight, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(newHeight, SVT_INT))
return BR_ERROR;
// newDebug (" Height:", newHeight);
trimStack(fun->stack);
- Common::String newText = getTextFromAnyVar(fun->stack->thisVar);
+ Common::String newText = fun->stack->thisVar.getTextFromAnyVar();
// newDebug (" Character supported:", newText);
trimStack(fun->stack);
- if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(fileNumber, SVT_FILE))
return BR_ERROR;
// newDebug (" File:", fileNumber);
trimStack(fun->stack);
@@ -825,28 +794,28 @@ builtIn(setFont) {
builtIn(inFont) {
UNUSEDALL
- Common::String newText = getTextFromAnyVar(fun->stack->thisVar);
+ Common::String newText = fun->stack->thisVar.getTextFromAnyVar();
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;
}
builtIn(pasteString) {
UNUSEDALL
- Common::String newText = getTextFromAnyVar(fun->stack->thisVar);
+ Common::String newText = fun->stack->thisVar.getTextFromAnyVar();
trimStack(fun->stack);
int y, x;
- if (!getValueType(y, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(y, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(x, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(x, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
if (x == IN_THE_CENTRE)
x = g_sludge->_gfxMan->getCenterX(g_sludge->_txtMan->stringWidth(newText));
- g_sludge->_txtMan->pasteStringToBackdrop(newText, x, y, pastePalette);
+ g_sludge->_txtMan->pasteStringToBackdrop(newText, x, y);
return BR_CONTINUE;
}
@@ -858,11 +827,11 @@ builtIn(anim) {
}
// First store the frame numbers and take 'em off the stack
- PersonaAnimation *ba = createPersonaAnim(numParams - 1, fun->stack);
+ PersonaAnimation *ba = new PersonaAnimation(numParams - 1, fun->stack);
// Only remaining paramter is the file number
int fileNumber;
- if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(fileNumber, SVT_FILE))
return BR_ERROR;
trimStack(fun->stack);
@@ -870,10 +839,10 @@ builtIn(anim) {
LoadedSpriteBank *sprBanky = g_sludge->_gfxMan->loadBankForAnim(fileNumber);
if (!sprBanky)
return BR_ERROR; // File not found, fatal done already
- setBankFile(ba, sprBanky);
+ ba->theSprites = sprBanky;
// Return value
- newAnimationVariable(fun->reg, ba);
+ fun->reg.makeAnimationVariable(ba);
return BR_CONTINUE;
}
@@ -893,18 +862,18 @@ builtIn(costume) {
if (!checkNew(newPersona->animation))
return BR_ERROR;
for (iii = numParams - 1; iii >= 0; iii--) {
- newPersona->animation[iii] = getAnimationFromVar(fun->stack->thisVar);
+ newPersona->animation[iii] = fun->stack->thisVar.getAnimationFromVar();
trimStack(fun->stack);
}
// Return value
- newCostumeVariable(fun->reg, newPersona);
+ fun->reg.makeCostumeVariable(newPersona);
return BR_CONTINUE;
}
builtIn(launch) {
UNUSEDALL
- Common::String newTextA = getTextFromAnyVar(fun->stack->thisVar);
+ Common::String newTextA = fun->stack->thisVar.getTextFromAnyVar();
Common::String newText = encodeFilename(newTextA);
@@ -922,7 +891,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;
@@ -931,7 +900,7 @@ builtIn(launch) {
builtIn(pause) {
UNUSEDALL
int theTime;
- if (!getValueType(theTime, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(theTime, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
if (theTime > 0) {
@@ -951,10 +920,10 @@ builtIn(completeTimers) {
builtIn(callEvent) {
UNUSEDALL
int obj1, obj2;
- if (!getValueType(obj2, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(obj2, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(obj1, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(obj1, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
@@ -962,10 +931,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;
}
@@ -987,13 +956,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;
}
@@ -1004,13 +973,13 @@ builtIn(playMovie) {
if (movieIsPlaying)
return BR_PAUSE;
- if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(fileNumber, SVT_FILE))
return BR_ERROR;
trimStack(fun->stack);
r = playMovie(fileNumber);
- setVariable(fun->reg, SVT_INT, r);
+ fun->reg.setVariable(SVT_INT, r);
if (r && (!fun->next)) {
restartFunction(fun);
@@ -1024,7 +993,7 @@ builtIn(stopMovie) {
stopMovie();
- setVariable(fun->reg, SVT_INT, 0);
+ fun->reg.setVariable(SVT_INT, 0);
return BR_CONTINUE;
}
@@ -1033,7 +1002,7 @@ builtIn(pauseMovie) {
pauseMovie();
- setVariable(fun->reg, SVT_INT, 0);
+ fun->reg.setVariable(SVT_INT, 0);
return BR_CONTINUE;
}
@@ -1043,13 +1012,13 @@ builtIn(pauseMovie) {
builtIn(startMusic) {
UNUSEDALL
int fromTrack, musChan, fileNumber;
- if (!getValueType(fromTrack, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(fromTrack, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(musChan, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(musChan, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(fileNumber, SVT_FILE))
return BR_ERROR;
trimStack(fun->stack);
if (!g_sludge->_soundMan->playMOD(fileNumber, musChan, fromTrack))
@@ -1060,7 +1029,7 @@ builtIn(startMusic) {
builtIn(stopMusic) {
UNUSEDALL
int v;
- if (!getValueType(v, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(v, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
g_sludge->_soundMan->stopMOD(v);
@@ -1070,10 +1039,10 @@ builtIn(stopMusic) {
builtIn(setMusicVolume) {
UNUSEDALL
int musChan, v;
- if (!getValueType(v, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(v, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(musChan, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(musChan, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
g_sludge->_soundMan->setMusicVolume(musChan, v);
@@ -1083,7 +1052,7 @@ builtIn(setMusicVolume) {
builtIn(setDefaultMusicVolume) {
UNUSEDALL
int v;
- if (!getValueType(v, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(v, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
g_sludge->_soundMan->setDefaultMusicVolume(v);
@@ -1093,7 +1062,7 @@ builtIn(setDefaultMusicVolume) {
builtIn(playSound) {
UNUSEDALL
int fileNumber;
- if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(fileNumber, SVT_FILE))
return BR_ERROR;
trimStack(fun->stack);
if (!g_sludge->_soundMan->startSound(fileNumber, false))
@@ -1109,7 +1078,7 @@ builtIn(loopSound) {
return BR_ERROR;
} else if (numParams < 2) {
- if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(fileNumber, SVT_FILE))
return BR_ERROR;
trimStack(fun->stack);
if (!g_sludge->_soundMan->startSound(fileNumber, true))
@@ -1124,12 +1093,12 @@ builtIn(loopSound) {
// Should we loop?
if (fun->stack->thisVar.varType != SVT_FILE) {
- getValueType(doLoop, SVT_INT, fun->stack->thisVar);
+ fun->stack->thisVar.getValueType(doLoop, SVT_INT);
trimStack(fun->stack);
numParams--;
}
while (numParams) {
- if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar)) {
+ if (!fun->stack->thisVar.getValueType(fileNumber, SVT_FILE)) {
fatal("Illegal parameter given built-in function loopSound().");
return BR_ERROR;
}
@@ -1162,7 +1131,7 @@ builtIn(loopSound) {
builtIn(stopSound) {
UNUSEDALL
int v;
- if (!getValueType(v, SVT_FILE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(v, SVT_FILE))
return BR_ERROR;
trimStack(fun->stack);
g_sludge->_soundMan->huntKillSound(v);
@@ -1172,7 +1141,7 @@ builtIn(stopSound) {
builtIn(setDefaultSoundVolume) {
UNUSEDALL
int v;
- if (!getValueType(v, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(v, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
g_sludge->_soundMan->setDefaultSoundVolume(v);
@@ -1182,10 +1151,10 @@ builtIn(setDefaultSoundVolume) {
builtIn(setSoundVolume) {
UNUSEDALL
int musChan, v;
- if (!getValueType(v, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(v, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(musChan, SVT_FILE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(musChan, SVT_FILE))
return BR_ERROR;
trimStack(fun->stack);
g_sludge->_soundMan->setSoundVolume(musChan, v);
@@ -1195,13 +1164,13 @@ builtIn(setSoundVolume) {
builtIn(setSoundLoopPoints) {
UNUSEDALL
int musChan, theEnd, theStart;
- if (!getValueType(theEnd, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(theEnd, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(theStart, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(theStart, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(musChan, SVT_FILE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(musChan, SVT_FILE))
return BR_ERROR;
trimStack(fun->stack);
g_sludge->_soundMan->setSoundLoop(musChan, theStart, theEnd);
@@ -1215,20 +1184,20 @@ builtIn(setFloor) {
UNUSEDALL
if (fun->stack->thisVar.varType == SVT_FILE) {
int v;
- getValueType(v, SVT_FILE, fun->stack->thisVar);
+ fun->stack->thisVar.getValueType(v, SVT_FILE);
trimStack(fun->stack);
- if (!setFloor(v))
+ if (!g_sludge->_floorMan->setFloor(v))
return BR_ERROR;
} else {
trimStack(fun->stack);
- setFloorNull();
+ g_sludge->_floorMan->setFloorNull();
}
return BR_CONTINUE;
}
builtIn(showFloor) {
UNUSEDALL
- drawFloor();
+ g_sludge->_floorMan->drawFloor();
return BR_CONTINUE;
}
@@ -1236,7 +1205,7 @@ builtIn(setZBuffer) {
UNUSEDALL
if (fun->stack->thisVar.varType == SVT_FILE) {
int v;
- getValueType(v, SVT_FILE, fun->stack->thisVar);
+ fun->stack->thisVar.getValueType(v, SVT_FILE);
trimStack(fun->stack);
if (!g_sludge->_gfxMan->setZBuffer(v))
return BR_ERROR;
@@ -1251,7 +1220,7 @@ builtIn(setLightMap) {
UNUSEDALL
switch (numParams) {
case 2:
- if (!getValueType(g_sludge->_gfxMan->_lightMapMode, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(g_sludge->_gfxMan->_lightMapMode, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
g_sludge->_gfxMan->_lightMapMode %= LIGHTMAPMODE_NUM;
@@ -1260,15 +1229,15 @@ builtIn(setLightMap) {
case 1:
if (fun->stack->thisVar.varType == SVT_FILE) {
int v;
- getValueType(v, SVT_FILE, fun->stack->thisVar);
+ fun->stack->thisVar.getValueType(v, SVT_FILE);
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;
@@ -1284,13 +1253,15 @@ builtIn(setLightMap) {
builtIn(setSpeechMode) {
UNUSEDALL
- if (!getValueType(speechMode, SVT_INT, fun->stack->thisVar))
+ int speechMode;
+ if (!fun->stack->thisVar.getValueType(speechMode, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
if (speechMode < 0 || speechMode > 2) {
fatal("Valid parameters are be SPEECHANDTEXT, SPEECHONLY or TEXTONLY");
return BR_ERROR;
}
+ g_sludge->_speechMan->setSpeechMode(speechMode);
return BR_CONTINUE;
}
@@ -1298,9 +1269,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;
}
@@ -1313,21 +1284,21 @@ builtIn(skipSpeech) {
builtIn(getOverObject) {
UNUSEDALL
- if (overRegion)
+ if (g_sludge->_regionMan->getOverRegion())
// Return value
- setVariable(fun->reg, SVT_OBJTYPE, overRegion->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;
}
builtIn(rename) {
UNUSEDALL
- Common::String newText = getTextFromAnyVar(fun->stack->thisVar);
+ Common::String newText = fun->stack->thisVar.getTextFromAnyVar();
int objT;
trimStack(fun->stack);
- if (!getValueType(objT, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(objT, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
ObjectType *o = g_sludge->_objMan->findObjectType(objT);
@@ -1339,19 +1310,19 @@ builtIn(rename) {
builtIn(getObjectX) {
UNUSEDALL
int objectNumber;
- if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(objectNumber, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- OnScreenPerson *pers = findPerson(objectNumber);
+ 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 = getRegionForObject(objectNumber);
+ 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;
@@ -1360,19 +1331,19 @@ builtIn(getObjectX) {
builtIn(getObjectY) {
UNUSEDALL
int objectNumber;
- if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(objectNumber, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- OnScreenPerson *pers = findPerson(objectNumber);
+ 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 = getRegionForObject(objectNumber);
+ 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;
@@ -1381,31 +1352,31 @@ builtIn(getObjectY) {
builtIn(addScreenRegion) {
UNUSEDALL
int sX, sY, x1, y1, x2, y2, di, objectNumber;
- if (!getValueType(di, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(di, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(sY, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(sY, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(sX, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(sX, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(y2, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(y2, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(x2, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(x2, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(y1, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(y1, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(x1, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(x1, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(objectNumber, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- if (addScreenRegion(x1, y1, x2, y2, sX, sY, di, objectNumber))
+ if (g_sludge->_regionMan->addScreenRegion(x1, y1, x2, y2, sX, sY, di, objectNumber))
return BR_CONTINUE;
return BR_ERROR;
@@ -1414,22 +1385,22 @@ builtIn(addScreenRegion) {
builtIn(removeScreenRegion) {
UNUSEDALL
int objectNumber;
- if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(objectNumber, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- removeScreenRegion(objectNumber);
+ g_sludge->_regionMan->removeScreenRegion(objectNumber);
return BR_CONTINUE;
}
builtIn(showBoxes) {
UNUSEDALL
- showBoxes();
+ g_sludge->_regionMan->showBoxes();
return BR_CONTINUE;
}
builtIn(removeAllScreenRegions) {
UNUSEDALL
- killAllRegions();
+ g_sludge->_regionMan->kill();
return BR_CONTINUE;
}
@@ -1438,21 +1409,21 @@ builtIn(addCharacter) {
Persona *p;
int x, y, objectNumber;
- p = getCostumeFromVar(fun->stack->thisVar);
+ p = fun->stack->thisVar.getCostumeFromVar();
if (p == NULL)
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(y, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(y, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(x, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(x, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(objectNumber, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- if (addPerson(x, y, objectNumber, p))
+ if (g_sludge->_peopleMan->addPerson(x, y, objectNumber, p))
return BR_CONTINUE;
return BR_ERROR;
}
@@ -1460,109 +1431,109 @@ builtIn(addCharacter) {
builtIn(hideCharacter) {
UNUSEDALL
int objectNumber;
- if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(objectNumber, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- setShown(false, objectNumber);
+ g_sludge->_peopleMan->setShown(false, objectNumber);
return BR_CONTINUE;
}
builtIn(showCharacter) {
UNUSEDALL
int objectNumber;
- if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(objectNumber, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- setShown(true, objectNumber);
+ g_sludge->_peopleMan->setShown(true, objectNumber);
return BR_CONTINUE;
}
builtIn(removeAllCharacters) {
UNUSEDALL
killSpeechTimers();
- killMostPeople();
+ g_sludge->_peopleMan->killMostPeople();
return BR_CONTINUE;
}
builtIn(setCharacterDrawMode) {
UNUSEDALL
int obj, di;
- if (!getValueType(di, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(di, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(obj, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- setDrawMode(di, obj);
+ g_sludge->_peopleMan->setDrawMode(di, obj);
return BR_CONTINUE;
}
builtIn(setCharacterTransparency) {
UNUSEDALL
int obj, x;
- if (!getValueType(x, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(x, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(obj, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- setPersonTransparency(obj, x);
+ g_sludge->_peopleMan->setPersonTransparency(obj, x);
return BR_CONTINUE;
}
builtIn(setCharacterColourise) {
UNUSEDALL
int obj, r, g, b, mix;
- if (!getValueType(mix, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(mix, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(b, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(b, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(g, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(g, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(r, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(r, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(obj, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- setPersonColourise(obj, r, g, b, mix);
+ g_sludge->_peopleMan->setPersonColourise(obj, r, g, b, mix);
return BR_CONTINUE;
}
builtIn(setScale) {
UNUSEDALL
int val1, val2;
- if (!getValueType(val2, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(val2, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(val1, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(val1, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- setScale((int16)val1, (int16)val2);
+ g_sludge->_peopleMan->setScale((int16)val1, (int16)val2);
return BR_CONTINUE;
}
builtIn(stopCharacter) {
UNUSEDALL
int obj;
- if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(obj, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
// Return value
- setVariable(fun->reg, SVT_INT, stopPerson(obj));
+ fun->reg.setVariable(SVT_INT, g_sludge->_peopleMan->stopPerson(obj));
return BR_CONTINUE;
}
builtIn(pasteCharacter) {
UNUSEDALL
int obj;
- if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(obj, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- OnScreenPerson *thisPerson = findPerson(obj);
+ OnScreenPerson *thisPerson = g_sludge->_peopleMan->findPerson(obj);
if (thisPerson) {
PersonaAnimation *myAnim;
myAnim = thisPerson->myAnim;
@@ -1574,9 +1545,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;
}
@@ -1584,91 +1555,91 @@ builtIn(pasteCharacter) {
builtIn(animate) {
UNUSEDALL
int obj;
- PersonaAnimation *pp = getAnimationFromVar(fun->stack->thisVar);
+ PersonaAnimation *pp = fun->stack->thisVar.getAnimationFromVar();
if (pp == NULL)
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(obj, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- animatePerson(obj, pp);
- setVariable(fun->reg, SVT_INT, timeForAnim(pp));
+ g_sludge->_peopleMan->animatePerson(obj, pp);
+ fun->reg.setVariable(SVT_INT, pp->getTotalTime());
return BR_CONTINUE;
}
builtIn(setCostume) {
UNUSEDALL
int obj;
- Persona *pp = getCostumeFromVar(fun->stack->thisVar);
+ Persona *pp = fun->stack->thisVar.getCostumeFromVar();
if (pp == NULL)
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(obj, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- animatePerson(obj, pp);
+ g_sludge->_peopleMan->animatePerson(obj, pp);
return BR_CONTINUE;
}
builtIn(floatCharacter) {
UNUSEDALL
int obj, di;
- if (!getValueType(di, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(di, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(obj, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- setVariable(fun->reg, SVT_INT, floatCharacter(di, obj));
+ fun->reg.setVariable(SVT_INT, g_sludge->_peopleMan->floatCharacter(di, obj));
return BR_CONTINUE;
}
builtIn(setCharacterWalkSpeed) {
UNUSEDALL
int obj, di;
- if (!getValueType(di, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(di, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(obj, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- setVariable(fun->reg, SVT_INT, setCharacterWalkSpeed(di, obj));
+ fun->reg.setVariable(SVT_INT, g_sludge->_peopleMan->setCharacterWalkSpeed(di, obj));
return BR_CONTINUE;
}
builtIn(turnCharacter) {
UNUSEDALL
int obj, di;
- if (!getValueType(di, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(di, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(obj, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- setVariable(fun->reg, SVT_INT, turnPersonToFace(obj, di));
+ fun->reg.setVariable(SVT_INT, g_sludge->_peopleMan->turnPersonToFace(obj, di));
return BR_CONTINUE;
}
builtIn(setCharacterExtra) {
UNUSEDALL
int obj, di;
- if (!getValueType(di, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(di, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(obj, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(obj, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- setVariable(fun->reg, SVT_INT, setPersonExtra(obj, di));
+ fun->reg.setVariable(SVT_INT, g_sludge->_peopleMan->setPersonExtra(obj, di));
return BR_CONTINUE;
}
builtIn(removeCharacter) {
UNUSEDALL
int objectNumber;
- if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(objectNumber, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- removeOneCharacter(objectNumber);
+ g_sludge->_peopleMan->removeOneCharacter(objectNumber);
return BR_CONTINUE;
}
@@ -1677,23 +1648,23 @@ static BuiltReturn moveChr(int numParams, LoadedFunction *fun, bool force, bool
case 3: {
int x, y, objectNumber;
- if (!getValueType(y, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(y, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(x, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(x, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(objectNumber, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
if (force) {
- if (forceWalkingPerson(x, y, objectNumber, fun, -1))
+ if (g_sludge->_peopleMan->forceWalkingPerson(x, y, objectNumber, fun, -1))
return BR_PAUSE;
} else if (immediate) {
- jumpPerson(x, y, objectNumber);
+ g_sludge->_peopleMan->jumpPerson(x, y, objectNumber);
} else {
- if (makeWalkingPerson(x, y, objectNumber, fun, -1))
+ if (g_sludge->_peopleMan->makeWalkingPerson(x, y, objectNumber, fun, -1))
return BR_PAUSE;
}
return BR_CONTINUE;
@@ -1703,23 +1674,23 @@ static BuiltReturn moveChr(int numParams, LoadedFunction *fun, bool force, bool
int toObj, objectNumber;
ScreenRegion*reggie;
- if (!getValueType(toObj, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(toObj, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(objectNumber, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- reggie = getRegionForObject(toObj);
+ reggie = g_sludge->_regionMan->getRegionForObject(toObj);
if (reggie == NULL)
return BR_CONTINUE;
if (force) {
- if (forceWalkingPerson(reggie->sX, reggie->sY, objectNumber, fun, reggie->di))
+ if (g_sludge->_peopleMan->forceWalkingPerson(reggie->sX, reggie->sY, objectNumber, fun, reggie->di))
return BR_PAUSE;
} else if (immediate) {
- jumpPerson(reggie->sX, reggie->sY, objectNumber);
+ g_sludge->_peopleMan->jumpPerson(reggie->sX, reggie->sY, objectNumber);
} else {
- if (makeWalkingPerson(reggie->sX, reggie->sY, objectNumber, fun, reggie->di))
+ if (g_sludge->_peopleMan->makeWalkingPerson(reggie->sX, reggie->sY, objectNumber, fun, reggie->di))
return BR_PAUSE;
}
return BR_CONTINUE;
@@ -1766,7 +1737,7 @@ builtIn(addStatus) {
builtIn(statusText) {
UNUSEDALL
- Common::String newText = getTextFromAnyVar(fun->stack->thisVar);
+ Common::String newText = fun->stack->thisVar.getTextFromAnyVar();
trimStack(fun->stack);
setStatusBar(newText);
return BR_CONTINUE;
@@ -1775,7 +1746,7 @@ builtIn(statusText) {
builtIn(lightStatus) {
UNUSEDALL
int val;
- if (!getValueType(val, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(val, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
setLitStatus(val);
@@ -1785,10 +1756,10 @@ builtIn(lightStatus) {
builtIn(positionStatus) {
UNUSEDALL
int x, y;
- if (!getValueType(y, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(y, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(x, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(x, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
positionStatus(x, y);
@@ -1798,7 +1769,7 @@ builtIn(positionStatus) {
builtIn(alignStatus) {
UNUSEDALL
int val;
- if (!getValueType(val, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(val, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
nowStatus->alignStatus = (int16)val;
@@ -1812,7 +1783,7 @@ static bool getFuncNumForCallback(int numParams, LoadedFunction *fun, int &funct
break;
case 1:
- if (!getValueType(functionNum, SVT_FUNC, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(functionNum, SVT_FUNC))
return false;
trimStack(fun->stack);
break;
@@ -1922,18 +1893,18 @@ builtIn(cancelSub) {
builtIn(stringWidth) {
UNUSEDALL
- Common::String theText = getTextFromAnyVar(fun->stack->thisVar);
+ Common::String theText = fun->stack->thisVar.getTextFromAnyVar();
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;
}
builtIn(hardScroll) {
UNUSEDALL
int v;
- if (!getValueType(v, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(v, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
g_sludge->_gfxMan->hardScroll(v);
@@ -1943,80 +1914,76 @@ builtIn(hardScroll) {
builtIn(isScreenRegion) {
UNUSEDALL
int objectNumber;
- if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(objectNumber, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- setVariable(fun->reg, SVT_INT, getRegionForObject(objectNumber) != NULL);
+ fun->reg.setVariable(SVT_INT, g_sludge->_regionMan->getRegionForObject(objectNumber) != NULL);
return BR_CONTINUE;
}
builtIn(setSpeechSpeed) {
UNUSEDALL
int number;
- if (!getValueType(number, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(number, SVT_INT))
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;
}
builtIn(setFontSpacing) {
UNUSEDALL
int fontSpaceI;
- if (!getValueType(fontSpaceI, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(fontSpaceI, SVT_INT))
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;
}
builtIn(transitionLevel) {
UNUSEDALL
- int number;
- if (!getValueType(number, SVT_INT, fun->stack->thisVar))
+ int brightnessLevel;
+ if (!fun->stack->thisVar.getValueType(brightnessLevel, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (number < 0)
- brightnessLevel = 0;
- else if (number > 255)
- brightnessLevel = 255;
- else
- brightnessLevel = number;
+ g_sludge->_gfxMan->setBrightnessLevel(brightnessLevel);
- setVariable(fun->reg, SVT_INT, 1);
+ fun->reg.setVariable(SVT_INT, 1);
return BR_CONTINUE;
}
builtIn(captureAllKeys) {
UNUSEDALL
- captureAllKeys = getBoolean(fun->stack->thisVar);
+ // This built-in function doesn't have any effect any more, we capture all keys by default
+ bool captureAllKeysDeprecated = fun->stack->thisVar.getBoolean();
trimStack(fun->stack);
- setVariable(fun->reg, SVT_INT, captureAllKeys);
+ fun->reg.setVariable(SVT_INT, captureAllKeysDeprecated);
return BR_CONTINUE;
}
builtIn(spinCharacter) {
UNUSEDALL
int number, objectNumber;
- if (!getValueType(number, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(number, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(objectNumber, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- OnScreenPerson *thisPerson = findPerson(objectNumber);
+ OnScreenPerson *thisPerson = g_sludge->_peopleMan->findPerson(objectNumber);
if (thisPerson) {
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;
}
}
@@ -2024,14 +1991,14 @@ builtIn(spinCharacter) {
builtIn(getCharacterDirection) {
UNUSEDALL
int objectNumber;
- if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(objectNumber, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- OnScreenPerson *thisPerson = findPerson(objectNumber);
+ 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;
}
@@ -2039,26 +2006,26 @@ builtIn(getCharacterDirection) {
builtIn(isCharacter) {
UNUSEDALL
int objectNumber;
- if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(objectNumber, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- OnScreenPerson *thisPerson = findPerson(objectNumber);
- setVariable(fun->reg, SVT_INT, thisPerson != NULL);
+ OnScreenPerson *thisPerson = g_sludge->_peopleMan->findPerson(objectNumber);
+ fun->reg.setVariable(SVT_INT, thisPerson != NULL);
return BR_CONTINUE;
}
builtIn(normalCharacter) {
UNUSEDALL
int objectNumber;
- if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(objectNumber, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- OnScreenPerson *thisPerson = findPerson(objectNumber);
+ 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;
}
@@ -2066,14 +2033,14 @@ builtIn(normalCharacter) {
builtIn(isMoving) {
UNUSEDALL
int objectNumber;
- if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(objectNumber, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- OnScreenPerson *thisPerson = findPerson(objectNumber);
+ 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;
}
@@ -2081,10 +2048,10 @@ builtIn(isMoving) {
builtIn(fetchEvent) {
UNUSEDALL
int obj1, obj2;
- if (!getValueType(obj2, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(obj2, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(obj1, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(obj1, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
@@ -2092,9 +2059,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;
}
@@ -2102,13 +2069,13 @@ builtIn(fetchEvent) {
builtIn(deleteFile) {
UNUSEDALL
- Common::String namNormal = getTextFromAnyVar(fun->stack->thisVar);
+ Common::String namNormal = fun->stack->thisVar.getTextFromAnyVar();
trimStack(fun->stack);
Common::String nam = encodeFilename(namNormal);
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;
}
@@ -2118,20 +2085,20 @@ builtIn(renameFile) {
Common::String temp;
temp.clear();
- temp = getTextFromAnyVar(fun->stack->thisVar);
+ temp = fun->stack->thisVar.getTextFromAnyVar();
Common::String newnam = encodeFilename(temp);
trimStack(fun->stack);
if (failSecurityCheck(newnam))
return BR_ERROR;
temp.clear();
- temp = getTextFromAnyVar(fun->stack->thisVar);
+ temp = fun->stack->thisVar.getTextFromAnyVar();
Common::String nam = encodeFilename(temp);
trimStack(fun->stack);
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;
}
@@ -2139,7 +2106,7 @@ builtIn(renameFile) {
builtIn(cacheSound) {
UNUSEDALL
int fileNumber;
- if (!getValueType(fileNumber, SVT_FILE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(fileNumber, SVT_FILE))
return BR_ERROR;
trimStack(fun->stack);
if (g_sludge->_soundMan->cacheSound(fileNumber) == -1)
@@ -2149,38 +2116,38 @@ builtIn(cacheSound) {
builtIn(burnString) {
UNUSEDALL
- Common::String newText = getTextFromAnyVar(fun->stack->thisVar);
+ Common::String newText = fun->stack->thisVar.getTextFromAnyVar();
trimStack(fun->stack);
int y, x;
- if (!getValueType(y, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(y, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(x, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(x, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
if (x == IN_THE_CENTRE)
x = g_sludge->_gfxMan->getCenterX(g_sludge->_txtMan->stringWidth(newText));
- g_sludge->_txtMan->burnStringToBackdrop(newText, x, y, pastePalette);
+ g_sludge->_txtMan->burnStringToBackdrop(newText, x, y);
return BR_CONTINUE;
}
builtIn(setCharacterSpinSpeed) {
UNUSEDALL
int speed, who;
- if (!getValueType(speed, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(speed, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(who, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(who, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- OnScreenPerson *thisPerson = findPerson(who);
+ OnScreenPerson *thisPerson = g_sludge->_peopleMan->findPerson(who);
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;
}
@@ -2188,20 +2155,20 @@ builtIn(setCharacterSpinSpeed) {
builtIn(setCharacterAngleOffset) {
UNUSEDALL
int angle, who;
- if (!getValueType(angle, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(angle, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(who, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(who, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- OnScreenPerson *thisPerson = findPerson(who);
+ OnScreenPerson *thisPerson = g_sludge->_peopleMan->findPerson(who);
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;
}
@@ -2209,11 +2176,11 @@ builtIn(setCharacterAngleOffset) {
builtIn(transitionMode) {
UNUSEDALL
int n;
- if (!getValueType(n, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(n, SVT_INT))
return BR_ERROR;
- fadeMode = n;
+ g_sludge->_gfxMan->setFadeMode(n);
trimStack(fun->stack);
- setVariable(fun->reg, SVT_INT, 1);
+ fun->reg.setVariable(SVT_INT, 1);
return BR_CONTINUE;
}
@@ -2221,7 +2188,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;
}
@@ -2242,7 +2209,7 @@ builtIn(getSoundCache) {
builtIn(saveCustomData) {
UNUSEDALL
// saveCustomData (thisStack, fileName);
- Common::String fileNameB = getTextFromAnyVar(fun->stack->thisVar);
+ Common::String fileNameB = fun->stack->thisVar.getTextFromAnyVar();
Common::String fileName = encodeFilename(fileNameB);
@@ -2254,7 +2221,7 @@ builtIn(saveCustomData) {
fatal("First parameter isn't a stack");
return BR_ERROR;
}
- if (!stackToFile(fileName, fun->stack->thisVar))
+ if (!CustomSaveHelper::stackToFile(fileName, fun->stack->thisVar))
return BR_ERROR;
trimStack(fun->stack);
return BR_CONTINUE;
@@ -2263,7 +2230,7 @@ builtIn(saveCustomData) {
builtIn(loadCustomData) {
UNUSEDALL
- Common::String newTextA = getTextFromAnyVar(fun->stack->thisVar);
+ Common::String newTextA = fun->stack->thisVar.getTextFromAnyVar();
Common::String newText = encodeFilename(newTextA);
@@ -2271,7 +2238,7 @@ builtIn(loadCustomData) {
return BR_ERROR;
trimStack(fun->stack);
- unlinkVar(fun->reg);
+ fun->reg.unlinkVar();
fun->reg.varType = SVT_STACK;
fun->reg.varData.theStack = new StackHandler;
if (!checkNew(fun->reg.varData.theStack))
@@ -2279,7 +2246,7 @@ builtIn(loadCustomData) {
fun->reg.varData.theStack->first = NULL;
fun->reg.varData.theStack->last = NULL;
fun->reg.varData.theStack->timesUsed = 1;
- if (!fileToStack(newText, fun->reg.varData.theStack))
+ if (!CustomSaveHelper::fileToStack(newText, fun->reg.varData.theStack))
return BR_ERROR;
return BR_CONTINUE;
}
@@ -2287,18 +2254,18 @@ builtIn(loadCustomData) {
builtIn(setCustomEncoding) {
UNUSEDALL
int n;
- if (!getValueType(n, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(n, SVT_INT))
return BR_ERROR;
- saveEncoding = n;
+ CustomSaveHelper::_saveEncoding = n;
trimStack(fun->stack);
- setVariable(fun->reg, SVT_INT, 1);
+ fun->reg.setVariable(SVT_INT, 1);
return BR_CONTINUE;
}
builtIn(freeSound) {
UNUSEDALL
int v;
- if (!getValueType(v, SVT_FILE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(v, SVT_FILE))
return BR_ERROR;
trimStack(fun->stack);
g_sludge->_soundMan->huntKillFreeSound(v);
@@ -2312,19 +2279,19 @@ builtIn(parallaxAdd) {
return BR_ERROR;
} else {
int wrapX, wrapY, v;
- if (!getValueType(wrapY, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(wrapY, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(wrapX, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(wrapX, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(v, SVT_FILE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(v, SVT_FILE))
return BR_ERROR;
trimStack(fun->stack);
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;
}
@@ -2332,21 +2299,21 @@ builtIn(parallaxAdd) {
builtIn(parallaxClear) {
UNUSEDALL
g_sludge->_gfxMan->killParallax();
- setVariable(fun->reg, SVT_INT, 1);
+ fun->reg.setVariable(SVT_INT, 1);
return BR_CONTINUE;
}
builtIn(getPixelColour) {
UNUSEDALL
int x, y;
- if (!getValueType(y, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(y, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(x, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(x, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- unlinkVar(fun->reg);
+ fun->reg.unlinkVar();
fun->reg.varType = SVT_STACK;
fun->reg.varData.theStack = new StackHandler;
if (!checkNew(fun->reg.varData.theStack))
@@ -2364,7 +2331,7 @@ builtIn(makeFastArray) {
UNUSEDALL
switch (fun->stack->thisVar.varType) {
case SVT_STACK: {
- bool success = makeFastArrayFromStack(fun->reg, fun->stack->thisVar.varData.theStack);
+ bool success = fun->reg.makeFastArrayFromStack(fun->stack->thisVar.varData.theStack);
trimStack(fun->stack);
return success ? BR_CONTINUE : BR_ERROR;
}
@@ -2373,7 +2340,7 @@ builtIn(makeFastArray) {
case SVT_INT: {
int i = fun->stack->thisVar.varData.intValue;
trimStack(fun->stack);
- return makeFastArraySize(fun->reg, i) ? BR_CONTINUE : BR_ERROR;
+ return fun->reg.makeFastArraySize(i) ? BR_CONTINUE : BR_ERROR;
}
break;
@@ -2387,22 +2354,22 @@ builtIn(makeFastArray) {
builtIn(getCharacterScale) {
UNUSEDALL
int objectNumber;
- if (!getValueType(objectNumber, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(objectNumber, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
- OnScreenPerson *pers = findPerson(objectNumber);
+ 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;
}
@@ -2413,7 +2380,7 @@ builtIn(_rem_launchWith) {
trimStack(fun->stack);
// To support some windows only games
- Common::String filename = getTextFromAnyVar(fun->stack->thisVar);
+ Common::String filename = fun->stack->thisVar.getTextFromAnyVar();
trimStack(fun->stack);
if (filename.hasSuffix(".exe")) {
@@ -2432,28 +2399,28 @@ 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, lastFramesPerSecond);
+ fun->reg.setVariable(SVT_INT, g_sludge->_timer.getLastFps());
return BR_CONTINUE;
}
builtIn(showThumbnail) {
UNUSEDALL
int x, y;
- if (!getValueType(y, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(y, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(x, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(x, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
// Encode the name!Encode the name!
- Common::String aaaaa = getTextFromAnyVar(fun->stack->thisVar);
+ Common::String aaaaa = fun->stack->thisVar.getTextFromAnyVar();
trimStack(fun->stack);
Common::String file = encodeFilename(aaaaa);
g_sludge->_gfxMan->showThumbnail(file, x, y);
@@ -2462,13 +2429,14 @@ builtIn(showThumbnail) {
builtIn(setThumbnailSize) {
UNUSEDALL
- if (!getValueType(thumbHeight, SVT_INT, fun->stack->thisVar))
+ int thumbHeight, thumbWidth;
+ if (!fun->stack->thisVar.getValueType(thumbHeight, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(thumbWidth, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(thumbWidth, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!g_sludge->_gfxMan->checkSizeValide(thumbWidth, thumbHeight)) {
+ if (!g_sludge->_gfxMan->setThumbnailSize(thumbWidth, thumbHeight)) {
Common::String buff = Common::String::format("%i x %i", thumbWidth, thumbWidth);
fatal("Invalid thumbnail size", buff);
return BR_ERROR;
@@ -2479,16 +2447,16 @@ builtIn(setThumbnailSize) {
builtIn(hasFlag) {
UNUSEDALL
int objNum, flagIndex;
- if (!getValueType(flagIndex, SVT_INT, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(flagIndex, SVT_INT))
return BR_ERROR;
trimStack(fun->stack);
- if (!getValueType(objNum, SVT_OBJTYPE, fun->stack->thisVar))
+ if (!fun->stack->thisVar.getValueType(objNum, SVT_OBJTYPE))
return BR_ERROR;
trimStack(fun->stack);
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;
}
@@ -2506,9 +2474,9 @@ builtIn(snapshotClear) {
builtIn(bodgeFilenames) {
UNUSEDALL
bool lastValue = allowAnyFilename;
- allowAnyFilename = getBoolean(fun->stack->thisVar);
+ allowAnyFilename = fun->stack->thisVar.getBoolean();
trimStack(fun->stack);
- setVariable(fun->reg, SVT_INT, lastValue);
+ fun->reg.setVariable(SVT_INT, lastValue);
return BR_CONTINUE;
}
@@ -2517,14 +2485,14 @@ 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;
}
builtIn(quitWithFatalError) {
UNUSEDALL
- Common::String mess = getTextFromAnyVar(fun->stack->thisVar);
+ Common::String mess = fun->stack->thisVar.getTextFromAnyVar();
trimStack(fun->stack);
fatal(mess);
return BR_ERROR;
@@ -2555,14 +2523,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;
}
@@ -2584,9 +2552,9 @@ BuiltReturn callBuiltIn(int whichFunc, int numParams, LoadedFunction *fun) {
}
if (whichFunc < NUM_FUNCS) {
- if (paramNum[whichFunc] != -1) {
- if (paramNum[whichFunc] != numParams) {
- Common::String buff = Common::String::format("Built in function must have %i parameter%s", paramNum[whichFunc], (paramNum[whichFunc] == 1) ? "" : "s");
+ if (builtInFunctionArray[whichFunc].paramNum != -1) {
+ if (builtInFunctionArray[whichFunc].paramNum != numParams) {
+ Common::String buff = Common::String::format("Built in function must have %i parameter%s", builtInFunctionArray[whichFunc].paramNum, (builtInFunctionArray[whichFunc].paramNum == 1) ? "" : "s");
Common::String msg = buff;
fatal(msg);
return BR_ERROR;