aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimei Yin2018-05-29 22:10:09 +0200
committerSimei Yin2018-05-29 22:37:10 +0200
commitdc320b86bc0da7026bfd650be6a8450684b54fa9 (patch)
treee967e6b5817262fb87a1ed86876575408de947ff
parent1ec5ef3e4df9ee3606bb4b3092fcf0d6f515563e (diff)
downloadscummvm-rg350-dc320b86bc0da7026bfd650be6a8450684b54fa9.tar.gz
scummvm-rg350-dc320b86bc0da7026bfd650be6a8450684b54fa9.tar.bz2
scummvm-rg350-dc320b86bc0da7026bfd650be6a8450684b54fa9.zip
SLUDGE: Create constructor of Variable instead of initVarNew
-rw-r--r--engines/sludge/event.cpp2
-rw-r--r--engines/sludge/function.cpp4
-rw-r--r--engines/sludge/sludger.cpp3
-rw-r--r--engines/sludge/variable.cpp3
-rw-r--r--engines/sludge/variable.h10
5 files changed, 5 insertions, 17 deletions
diff --git a/engines/sludge/event.cpp b/engines/sludge/event.cpp
index d6afe2f5b9..acccd7ff84 100644
--- a/engines/sludge/event.cpp
+++ b/engines/sludge/event.cpp
@@ -182,7 +182,6 @@ bool EventManager::handleInput() {
if (!checkNew(tempStack))
return false;
- initVarNew(tempStack->thisVar);
ScreenRegion *overRegion = _vm->_regionMan->getOverRegion();
if (overRegion) {
setVariable(tempStack->thisVar, SVT_OBJTYPE, overRegion->thisType->objectNum);
@@ -321,7 +320,6 @@ bool EventManager::handleInput() {
VariableStack *tempStack = new VariableStack;
if (!checkNew(tempStack))
return false;
- initVarNew(tempStack->thisVar);
makeTextVar(tempStack->thisVar, tempString);
tempStack->next = nullptr;
if (!startNewFunctionNum(_currentEvents->func[kSpace], 1, nullptr, tempStack))
diff --git a/engines/sludge/function.cpp b/engines/sludge/function.cpp
index 8aa69f07c4..98f7bf79b1 100644
--- a/engines/sludge/function.cpp
+++ b/engines/sludge/function.cpp
@@ -661,9 +661,6 @@ bool loadFunctionCode(LoadedFunction *newFunc) {
newFunc->localVars = new Variable[newFunc->numLocals];
if (!checkNew(newFunc->localVars))
return false;
- for (int a = 0; a < newFunc->numLocals; a++) {
- initVarNew(newFunc->localVars[a]);
- }
return true;
}
@@ -700,7 +697,6 @@ int startNewFunctionNum(uint funcNum, uint numParamsExpected,
newFunc->freezerLevel = 0;
newFunc->runThisLine = 0;
newFunc->isSpeech = 0;
- initVarNew(newFunc->reg);
restartFunction(newFunc);
return 1;
diff --git a/engines/sludge/sludger.cpp b/engines/sludge/sludger.cpp
index f297ff12f5..f9dedf22fc 100644
--- a/engines/sludge/sludger.cpp
+++ b/engines/sludge/sludger.cpp
@@ -177,7 +177,6 @@ void killSludge() {
bool initSludge(const Common::String &filename) {
initSludge();
- int a = 0;
Common::File *fp = openAndVerify(filename, 'G', 'E', ERROR_BAD_HEADER, gameVersion);
if (!fp)
return false;
@@ -276,8 +275,6 @@ bool initSludge(const Common::String &filename) {
globalVars = new Variable[numGlobals];
if (!checkNew(globalVars))
return false;
- for (a = 0; a < numGlobals; a++)
- initVarNew(globalVars[a]);
// Get language selected by user
g_sludge->_resMan->setData(fp);
diff --git a/engines/sludge/variable.cpp b/engines/sludge/variable.cpp
index 8ed2297008..a663599d5a 100644
--- a/engines/sludge/variable.cpp
+++ b/engines/sludge/variable.cpp
@@ -408,9 +408,6 @@ bool makeFastArraySize(Variable &to, int size) {
to.varData.fastArray->fastVariables = new Variable[size];
if (!checkNew(to.varData.fastArray->fastVariables))
return false;
- for (int i = 0; i < size; i++) {
- initVarNew(to.varData.fastArray->fastVariables[i]);
- }
to.varData.fastArray->size = size;
to.varData.fastArray->timesUsed = 1;
return true;
diff --git a/engines/sludge/variable.h b/engines/sludge/variable.h
index a3cc57d911..27bf71a689 100644
--- a/engines/sludge/variable.h
+++ b/engines/sludge/variable.h
@@ -68,6 +68,11 @@ union VariableData {
struct Variable {
VariableType varType;
VariableData varData;
+
+ Variable() {
+ varType = SVT_NULL;
+ varData.intValue = 0;
+ }
};
struct VariableStack {
@@ -75,10 +80,6 @@ struct VariableStack {
VariableStack *next;
};
-// Initialisation
-
-#define initVarNew(thisVar) thisVar.varType = SVT_NULL
-
// Setting variables
void setVariable(Variable &thisVar, VariableType vT, int value);
@@ -94,7 +95,6 @@ char *createCString(const Common::String &s);
// Misc.
void unlinkVar(Variable &thisVar);
-Common::String getNumberedString(int value);
Common::String getTextFromAnyVar(const Variable &from);
struct Persona *getCostumeFromVar(Variable &thisVar);
struct PersonaAnimation *getAnimationFromVar(Variable &thisVar);