SLUDGE: Create constructor of Variable instead of initVarNew

This commit is contained in:
Simei Yin 2018-05-29 22:10:09 +02:00
parent 1ec5ef3e4d
commit dc320b86bc
5 changed files with 5 additions and 17 deletions

View File

@ -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))

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);