From c27d6585df61efc8b1ff5917de2dc3ae8b5d4248 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 3 Jul 2012 05:08:59 +0200 Subject: WINTERMUTE: Rename FuncName->funcName in ScStack --- engines/wintermute/Base/scriptables/SXArray.cpp | 18 +- engines/wintermute/Base/scriptables/SXDate.cpp | 82 ++++---- engines/wintermute/Base/scriptables/SXFile.cpp | 182 ++++++++--------- engines/wintermute/Base/scriptables/SXMath.cpp | 88 ++++---- .../wintermute/Base/scriptables/SXMemBuffer.cpp | 164 +++++++-------- engines/wintermute/Base/scriptables/SXStore.cpp | 66 +++--- engines/wintermute/Base/scriptables/SXString.cpp | 58 +++--- engines/wintermute/Base/scriptables/ScEngine.cpp | 4 +- engines/wintermute/Base/scriptables/ScScript.cpp | 226 ++++++++++----------- engines/wintermute/Base/scriptables/ScStack.cpp | 38 ++-- engines/wintermute/Base/scriptables/ScStack.h | 24 +-- engines/wintermute/Base/scriptables/SxObject.cpp | 4 +- 12 files changed, 477 insertions(+), 477 deletions(-) (limited to 'engines/wintermute/Base/scriptables') diff --git a/engines/wintermute/Base/scriptables/SXArray.cpp b/engines/wintermute/Base/scriptables/SXArray.cpp index 1a8dfdba64..c22dd9e4b5 100644 --- a/engines/wintermute/Base/scriptables/SXArray.cpp +++ b/engines/wintermute/Base/scriptables/SXArray.cpp @@ -45,15 +45,15 @@ CSXArray::CSXArray(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { _length = 0; _values = new CScValue(Game); - int NumParams = stack->Pop()->GetInt(0); + int NumParams = stack->pop()->GetInt(0); - if (NumParams == 1) _length = stack->Pop()->GetInt(0); + if (NumParams == 1) _length = stack->pop()->GetInt(0); else if (NumParams > 1) { _length = NumParams; char ParamName[20]; for (int i = 0; i < NumParams; i++) { sprintf(ParamName, "%d", i); - _values->SetProp(ParamName, stack->Pop()); + _values->SetProp(ParamName, stack->pop()); } } } @@ -98,15 +98,15 @@ HRESULT CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // Push ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Push") == 0) { - int NumParams = stack->Pop()->GetInt(0); + int NumParams = stack->pop()->GetInt(0); char ParamName[20]; for (int i = 0; i < NumParams; i++) { _length++; sprintf(ParamName, "%d", _length - 1); - _values->SetProp(ParamName, stack->Pop(), true); + _values->SetProp(ParamName, stack->pop(), true); } - stack->PushInt(_length); + stack->pushInt(_length); return S_OK; } @@ -116,15 +116,15 @@ HRESULT CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Pop") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_length > 0) { char ParamName[20]; sprintf(ParamName, "%d", _length - 1); - stack->Push(_values->GetProp(ParamName)); + stack->push(_values->GetProp(ParamName)); _values->DeleteProp(ParamName); _length--; - } else stack->PushNULL(); + } else stack->pushNULL(); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXDate.cpp b/engines/wintermute/Base/scriptables/SXDate.cpp index 5026ebdd8e..61a646df43 100644 --- a/engines/wintermute/Base/scriptables/SXDate.cpp +++ b/engines/wintermute/Base/scriptables/SXDate.cpp @@ -40,17 +40,17 @@ CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack) { ////////////////////////////////////////////////////////////////////////// CSXDate::CSXDate(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - stack->CorrectParams(6); + stack->correctParams(6); memset(&_tm, 0, sizeof(_tm)); - CScValue *valYear = stack->Pop(); + CScValue *valYear = stack->pop(); _tm.tm_year = valYear->GetInt() - 1900; - _tm.tm_mon = stack->Pop()->GetInt() - 1; - _tm.tm_mday = stack->Pop()->GetInt(); - _tm.tm_hour = stack->Pop()->GetInt(); - _tm.tm_min = stack->Pop()->GetInt(); - _tm.tm_sec = stack->Pop()->GetInt(); + _tm.tm_mon = stack->pop()->GetInt() - 1; + _tm.tm_mday = stack->pop()->GetInt(); + _tm.tm_hour = stack->pop()->GetInt(); + _tm.tm_min = stack->pop()->GetInt(); + _tm.tm_sec = stack->pop()->GetInt(); if (valYear->IsNULL()) { g_system->getTimeAndDate(_tm); @@ -80,57 +80,57 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // GetYear ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GetYear") == 0) { - stack->CorrectParams(0); - stack->PushInt(_tm.tm_year + 1900); + stack->correctParams(0); + stack->pushInt(_tm.tm_year + 1900); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetMonth ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetMonth") == 0) { - stack->CorrectParams(0); - stack->PushInt(_tm.tm_mon + 1); + stack->correctParams(0); + stack->pushInt(_tm.tm_mon + 1); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetDate ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetDate") == 0) { - stack->CorrectParams(0); - stack->PushInt(_tm.tm_mday); + stack->correctParams(0); + stack->pushInt(_tm.tm_mday); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetHours ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetHours") == 0) { - stack->CorrectParams(0); - stack->PushInt(_tm.tm_hour); + stack->correctParams(0); + stack->pushInt(_tm.tm_hour); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetMinutes ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetMinutes") == 0) { - stack->CorrectParams(0); - stack->PushInt(_tm.tm_min); + stack->correctParams(0); + stack->pushInt(_tm.tm_min); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetSeconds ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetSeconds") == 0) { - stack->CorrectParams(0); - stack->PushInt(_tm.tm_sec); + stack->correctParams(0); + stack->pushInt(_tm.tm_sec); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetWeekday ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetWeekday") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); warning("GetWeekday returns a wrong value on purpose"); - stack->PushInt(_tm.tm_mday % 7); + stack->pushInt(_tm.tm_mday % 7); return S_OK; } @@ -139,54 +139,54 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // SetYear ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetYear") == 0) { - stack->CorrectParams(1); - _tm.tm_year = stack->Pop()->GetInt() - 1900; - stack->PushNULL(); + stack->correctParams(1); + _tm.tm_year = stack->pop()->GetInt() - 1900; + stack->pushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetMonth ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetMonth") == 0) { - stack->CorrectParams(1); - _tm.tm_mon = stack->Pop()->GetInt() - 1; - stack->PushNULL(); + stack->correctParams(1); + _tm.tm_mon = stack->pop()->GetInt() - 1; + stack->pushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetDate ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetDate") == 0) { - stack->CorrectParams(1); - _tm.tm_mday = stack->Pop()->GetInt(); - stack->PushNULL(); + stack->correctParams(1); + _tm.tm_mday = stack->pop()->GetInt(); + stack->pushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetHours ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetHours") == 0) { - stack->CorrectParams(1); - _tm.tm_hour = stack->Pop()->GetInt(); - stack->PushNULL(); + stack->correctParams(1); + _tm.tm_hour = stack->pop()->GetInt(); + stack->pushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetMinutes ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetMinutes") == 0) { - stack->CorrectParams(1); - _tm.tm_min = stack->Pop()->GetInt(); - stack->PushNULL(); + stack->correctParams(1); + _tm.tm_min = stack->pop()->GetInt(); + stack->pushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // SetSeconds ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetSeconds") == 0) { - stack->CorrectParams(1); - _tm.tm_sec = stack->Pop()->GetInt(); - stack->PushNULL(); + stack->correctParams(1); + _tm.tm_sec = stack->pop()->GetInt(); + stack->pushNULL(); return S_OK; } @@ -195,9 +195,9 @@ HRESULT CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // SetCurrentTime ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetCurrentTime") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); g_system->getTimeAndDate(_tm); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp index b897ca9701..fc2fca1991 100644 --- a/engines/wintermute/Base/scriptables/SXFile.cpp +++ b/engines/wintermute/Base/scriptables/SXFile.cpp @@ -56,8 +56,8 @@ CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack) { ////////////////////////////////////////////////////////////////////////// CSXFile::CSXFile(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); _filename = NULL; if (!Val->IsNULL()) CBUtils::SetString(&_filename, Val->GetString()); @@ -110,11 +110,11 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // SetFilename ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetFilename") == 0) { - stack->CorrectParams(1); - const char *Filename = stack->Pop()->GetString(); + stack->correctParams(1); + const char *Filename = stack->pop()->GetString(); cleanup(); CBUtils::SetString(&_filename, Filename); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -122,9 +122,9 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // OpenAsText / OpenAsBinary ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "OpenAsText") == 0 || strcmp(name, "OpenAsBinary") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); Close(); - _mode = stack->Pop()->GetInt(1); + _mode = stack->pop()->GetInt(1); if (_mode < 1 || _mode > 3) { script->RuntimeError("File.%s: invalid access mode. Setting read mode.", name); _mode = 1; @@ -150,8 +150,8 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this } else _textMode = strcmp(name, "OpenAsText") == 0; } - if (_readFile || _writeFile) stack->PushBool(true); - else stack->PushBool(false); + if (_readFile || _writeFile) stack->pushBool(true); + else stack->pushBool(false); return S_OK; } @@ -160,9 +160,9 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Close ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Close") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); Close(); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -170,13 +170,13 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // SetPosition ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetPosition") == 0) { - stack->CorrectParams(1); + stack->correctParams(1); if (_mode == 0) { script->RuntimeError("File.%s: File is not open", name); - stack->PushBool(false); + stack->pushBool(false); } else { - int Pos = stack->Pop()->GetInt(); - stack->PushBool(SetPos(Pos)); + int Pos = stack->pop()->GetInt(); + stack->pushBool(SetPos(Pos)); } return S_OK; } @@ -185,9 +185,9 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Delete ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Delete") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); Close(); - stack->PushBool(CBPlatform::DeleteFile(_filename) != false); + stack->pushBool(CBPlatform::DeleteFile(_filename) != false); return S_OK; } @@ -195,12 +195,12 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Copy ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Copy") == 0) { - stack->CorrectParams(2); - const char *Dest = stack->Pop()->GetString(); - bool Overwrite = stack->Pop()->GetBool(true); + stack->correctParams(2); + const char *Dest = stack->pop()->GetString(); + bool Overwrite = stack->pop()->GetBool(true); Close(); - stack->PushBool(CBPlatform::CopyFile(_filename, Dest, !Overwrite) != false); + stack->pushBool(CBPlatform::CopyFile(_filename, Dest, !Overwrite) != false); return S_OK; } @@ -208,10 +208,10 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ReadLine ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ReadLine") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (!_textMode || !_readFile) { script->RuntimeError("File.%s: File must be open in text mode.", name); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } uint32 BufSize = FILE_BUFFER_SIZE; @@ -245,8 +245,8 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this } Buf[Counter] = '\0'; - if (!FoundNewLine && Counter == 0) stack->PushNULL(); - else stack->PushString((char *)Buf); + if (!FoundNewLine && Counter == 0) stack->pushNULL(); + else stack->pushString((char *)Buf); free(Buf); @@ -257,12 +257,12 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ReadText ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ReadText") == 0) { - stack->CorrectParams(1); - int TextLen = stack->Pop()->GetInt(); + stack->correctParams(1); + int TextLen = stack->pop()->GetInt(); if (!_textMode || !_readFile) { script->RuntimeError("File.%s: File must be open in text mode.", name); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } uint32 BufSize = FILE_BUFFER_SIZE; @@ -292,8 +292,8 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this } Buf[Counter] = '\0'; - if (TextLen > 0 && Counter == 0) stack->PushNULL(); - else stack->PushString((char *)Buf); + if (TextLen > 0 && Counter == 0) stack->pushNULL(); + else stack->pushString((char *)Buf); free(Buf); @@ -304,11 +304,11 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // WriteLine / WriteText ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteLine") == 0 || strcmp(name, "WriteText") == 0) { - stack->CorrectParams(1); - const char *Line = stack->Pop()->GetString(); + stack->correctParams(1); + const char *Line = stack->pop()->GetString(); if (!_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in text mode.", name); - stack->PushBool(false); + stack->pushBool(false); return S_OK; } if (strcmp(name, "WriteLine") == 0) @@ -316,7 +316,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this else fprintf((FILE *)_writeFile, "%s", Line); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -326,15 +326,15 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ReadBool ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ReadBool") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_textMode || !_readFile) { script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } bool Val; - if (_readFile->read(&Val, sizeof(bool)) == sizeof(bool)) stack->PushBool(Val); - else stack->PushNULL(); + if (_readFile->read(&Val, sizeof(bool)) == sizeof(bool)) stack->pushBool(Val); + else stack->pushNULL(); return S_OK; } @@ -343,15 +343,15 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ReadByte ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ReadByte") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_textMode || !_readFile) { script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } byte Val; - if (_readFile->read(&Val, sizeof(byte)) == sizeof(byte)) stack->PushInt(Val); - else stack->PushNULL(); + if (_readFile->read(&Val, sizeof(byte)) == sizeof(byte)) stack->pushInt(Val); + else stack->pushNULL(); return S_OK; } @@ -360,15 +360,15 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ReadShort ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ReadShort") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_textMode || !_readFile) { script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } short Val; - if (_readFile->read(&Val, sizeof(short)) == sizeof(short)) stack->PushInt(65536 + Val); - else stack->PushNULL(); + if (_readFile->read(&Val, sizeof(short)) == sizeof(short)) stack->pushInt(65536 + Val); + else stack->pushNULL(); return S_OK; } @@ -377,15 +377,15 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ReadInt / ReadLong ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ReadInt") == 0 || strcmp(name, "ReadLong") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_textMode || !_readFile) { script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } int Val; - if (_readFile->read(&Val, sizeof(int)) == sizeof(int)) stack->PushInt(Val); - else stack->PushNULL(); + if (_readFile->read(&Val, sizeof(int)) == sizeof(int)) stack->pushInt(Val); + else stack->pushNULL(); return S_OK; } @@ -394,15 +394,15 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ReadFloat ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ReadFloat") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_textMode || !_readFile) { script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } float Val; - if (_readFile->read(&Val, sizeof(float)) == sizeof(float)) stack->PushFloat(Val); - else stack->PushNULL(); + if (_readFile->read(&Val, sizeof(float)) == sizeof(float)) stack->pushFloat(Val); + else stack->pushNULL(); return S_OK; } @@ -411,15 +411,15 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ReadDouble ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ReadDouble") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_textMode || !_readFile) { script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } double Val; - if (_readFile->read(&Val, sizeof(double)) == sizeof(double)) stack->PushFloat(Val); - else stack->PushNULL(); + if (_readFile->read(&Val, sizeof(double)) == sizeof(double)) stack->pushFloat(Val); + else stack->pushNULL(); return S_OK; } @@ -428,10 +428,10 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // ReadString ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ReadString") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_textMode || !_readFile) { script->RuntimeError("File.%s: File must be open for reading in binary mode.", name); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } uint32 Size; @@ -440,11 +440,11 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (Str) { if (_readFile->read(Str, Size) == Size) { Str[Size] = '\0'; - stack->PushString((char *)Str); + stack->pushString((char *)Str); } delete [] Str; - } else stack->PushNULL(); - } else stack->PushNULL(); + } else stack->pushNULL(); + } else stack->pushNULL(); return S_OK; } @@ -453,16 +453,16 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // WriteBool ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteBool") == 0) { - stack->CorrectParams(1); - bool Val = stack->Pop()->GetBool(); + stack->correctParams(1); + bool Val = stack->pop()->GetBool(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); - stack->PushBool(false); + stack->pushBool(false); return S_OK; } fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -471,16 +471,16 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // WriteByte ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteByte") == 0) { - stack->CorrectParams(1); - byte Val = stack->Pop()->GetInt(); + stack->correctParams(1); + byte Val = stack->pop()->GetInt(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); - stack->PushBool(false); + stack->pushBool(false); return S_OK; } fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -489,16 +489,16 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // WriteShort ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteShort") == 0) { - stack->CorrectParams(1); - short Val = stack->Pop()->GetInt(); + stack->correctParams(1); + short Val = stack->pop()->GetInt(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); - stack->PushBool(false); + stack->pushBool(false); return S_OK; } fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -507,16 +507,16 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // WriteInt / WriteLong ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteInt") == 0 || strcmp(name, "WriteLong") == 0) { - stack->CorrectParams(1); - int Val = stack->Pop()->GetInt(); + stack->correctParams(1); + int Val = stack->pop()->GetInt(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); - stack->PushBool(false); + stack->pushBool(false); return S_OK; } fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -525,16 +525,16 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // WriteFloat ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteFloat") == 0) { - stack->CorrectParams(1); - float Val = stack->Pop()->GetFloat(); + stack->correctParams(1); + float Val = stack->pop()->GetFloat(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); - stack->PushBool(false); + stack->pushBool(false); return S_OK; } fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -543,16 +543,16 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // WriteDouble ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteDouble") == 0) { - stack->CorrectParams(1); - double Val = stack->Pop()->GetFloat(); + stack->correctParams(1); + double Val = stack->pop()->GetFloat(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); - stack->PushBool(false); + stack->pushBool(false); return S_OK; } fwrite(&Val, sizeof(Val), 1, (FILE *)_writeFile); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -561,12 +561,12 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // WriteString ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WriteString") == 0) { - stack->CorrectParams(1); - const char *Val = stack->Pop()->GetString(); + stack->correctParams(1); + const char *Val = stack->pop()->GetString(); if (_textMode || !_writeFile) { script->RuntimeError("File.%s: File must be open for writing in binary mode.", name); - stack->PushBool(false); + stack->pushBool(false); return S_OK; } @@ -574,7 +574,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this fwrite(&Size, sizeof(Size), 1, (FILE *)_writeFile); fwrite(Val, Size, 1, (FILE *)_writeFile); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXMath.cpp b/engines/wintermute/Base/scriptables/SXMath.cpp index a9337af1a8..110330d4ef 100644 --- a/engines/wintermute/Base/scriptables/SXMath.cpp +++ b/engines/wintermute/Base/scriptables/SXMath.cpp @@ -63,8 +63,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Abs ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Abs") == 0) { - stack->CorrectParams(1); - stack->PushFloat(fabs(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(fabs(stack->pop()->GetFloat())); return S_OK; } @@ -72,8 +72,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Acos ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Acos") == 0) { - stack->CorrectParams(1); - stack->PushFloat(acos(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(acos(stack->pop()->GetFloat())); return S_OK; } @@ -81,8 +81,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Asin ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Asin") == 0) { - stack->CorrectParams(1); - stack->PushFloat(asin(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(asin(stack->pop()->GetFloat())); return S_OK; } @@ -90,8 +90,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Atan ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Atan") == 0) { - stack->CorrectParams(1); - stack->PushFloat(atan(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(atan(stack->pop()->GetFloat())); return S_OK; } @@ -99,10 +99,10 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Atan2 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Atan2") == 0) { - stack->CorrectParams(2); - double y = stack->Pop()->GetFloat(); - double x = stack->Pop()->GetFloat(); - stack->PushFloat(atan2(y, x)); + stack->correctParams(2); + double y = stack->pop()->GetFloat(); + double x = stack->pop()->GetFloat(); + stack->pushFloat(atan2(y, x)); return S_OK; } @@ -110,8 +110,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Ceil ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Ceil") == 0) { - stack->CorrectParams(1); - stack->PushFloat(ceil(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(ceil(stack->pop()->GetFloat())); return S_OK; } @@ -119,8 +119,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Cos ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Cos") == 0) { - stack->CorrectParams(1); - stack->PushFloat(cos(DegreeToRadian(stack->Pop()->GetFloat()))); + stack->correctParams(1); + stack->pushFloat(cos(DegreeToRadian(stack->pop()->GetFloat()))); return S_OK; } @@ -128,8 +128,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Cosh ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Cosh") == 0) { - stack->CorrectParams(1); - stack->PushFloat(cosh(DegreeToRadian(stack->Pop()->GetFloat()))); + stack->correctParams(1); + stack->pushFloat(cosh(DegreeToRadian(stack->pop()->GetFloat()))); return S_OK; } @@ -137,8 +137,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Exp ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Exp") == 0) { - stack->CorrectParams(1); - stack->PushFloat(exp(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(exp(stack->pop()->GetFloat())); return S_OK; } @@ -146,8 +146,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Floor ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Floor") == 0) { - stack->CorrectParams(1); - stack->PushFloat(floor(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(floor(stack->pop()->GetFloat())); return S_OK; } @@ -155,8 +155,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Log ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Log") == 0) { - stack->CorrectParams(1); - stack->PushFloat(log(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(log(stack->pop()->GetFloat())); return S_OK; } @@ -164,8 +164,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Log10 ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Log10") == 0) { - stack->CorrectParams(1); - stack->PushFloat(log10(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(log10(stack->pop()->GetFloat())); return S_OK; } @@ -173,11 +173,11 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Pow ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Pow") == 0) { - stack->CorrectParams(2); - double x = stack->Pop()->GetFloat(); - double y = stack->Pop()->GetFloat(); + stack->correctParams(2); + double x = stack->pop()->GetFloat(); + double y = stack->pop()->GetFloat(); - stack->PushFloat(pow(x, y)); + stack->pushFloat(pow(x, y)); return S_OK; } @@ -185,8 +185,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Sin ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Sin") == 0) { - stack->CorrectParams(1); - stack->PushFloat(sin(DegreeToRadian(stack->Pop()->GetFloat()))); + stack->correctParams(1); + stack->pushFloat(sin(DegreeToRadian(stack->pop()->GetFloat()))); return S_OK; } @@ -194,8 +194,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Sinh ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Sinh") == 0) { - stack->CorrectParams(1); - stack->PushFloat(sinh(DegreeToRadian(stack->Pop()->GetFloat()))); + stack->correctParams(1); + stack->pushFloat(sinh(DegreeToRadian(stack->pop()->GetFloat()))); return S_OK; } @@ -203,8 +203,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Tan ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Tan") == 0) { - stack->CorrectParams(1); - stack->PushFloat(tan(DegreeToRadian(stack->Pop()->GetFloat()))); + stack->correctParams(1); + stack->pushFloat(tan(DegreeToRadian(stack->pop()->GetFloat()))); return S_OK; } @@ -212,8 +212,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Tanh ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Tanh") == 0) { - stack->CorrectParams(1); - stack->PushFloat(tanh(DegreeToRadian(stack->Pop()->GetFloat()))); + stack->correctParams(1); + stack->pushFloat(tanh(DegreeToRadian(stack->pop()->GetFloat()))); return S_OK; } @@ -221,8 +221,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // Sqrt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Sqrt") == 0) { - stack->CorrectParams(1); - stack->PushFloat(sqrt(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(sqrt(stack->pop()->GetFloat())); return S_OK; } @@ -230,8 +230,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // DegToRad ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DegToRad") == 0) { - stack->CorrectParams(1); - stack->PushFloat(DegreeToRadian(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(DegreeToRadian(stack->pop()->GetFloat())); return S_OK; } @@ -239,8 +239,8 @@ HRESULT CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *this // RadToDeg ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RadToDeg") == 0) { - stack->CorrectParams(1); - stack->PushFloat(RadianToDegree(stack->Pop()->GetFloat())); + stack->correctParams(1); + stack->pushFloat(RadianToDegree(stack->pop()->GetFloat())); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp index 82a9a1f5e2..7dcb6ea1a7 100644 --- a/engines/wintermute/Base/scriptables/SXMemBuffer.cpp +++ b/engines/wintermute/Base/scriptables/SXMemBuffer.cpp @@ -43,11 +43,11 @@ CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack) { ////////////////////////////////////////////////////////////////////////// CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - stack->CorrectParams(1); + stack->correctParams(1); _buffer = NULL; _size = 0; - int NewSize = stack->Pop()->GetInt(); + int NewSize = stack->pop()->GetInt(); Resize(MAX(0, NewSize)); } @@ -127,11 +127,11 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetSize ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetSize") == 0) { - stack->CorrectParams(1); - int NewSize = stack->Pop()->GetInt(); + stack->correctParams(1); + int NewSize = stack->pop()->GetInt(); NewSize = MAX(0, NewSize); - if (SUCCEEDED(Resize(NewSize))) stack->PushBool(true); - else stack->PushBool(false); + if (SUCCEEDED(Resize(NewSize))) stack->pushBool(true); + else stack->pushBool(false); return S_OK; } @@ -140,10 +140,10 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // GetBool ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetBool") == 0) { - stack->CorrectParams(1); - int Start = stack->Pop()->GetInt(); - if (!CheckBounds(script, Start, sizeof(bool))) stack->PushNULL(); - else stack->PushBool(*(bool *)((byte *)_buffer + Start)); + stack->correctParams(1); + int Start = stack->pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(bool))) stack->pushNULL(); + else stack->pushBool(*(bool *)((byte *)_buffer + Start)); return S_OK; } @@ -152,10 +152,10 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // GetByte ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetByte") == 0) { - stack->CorrectParams(1); - int Start = stack->Pop()->GetInt(); - if (!CheckBounds(script, Start, sizeof(byte))) stack->PushNULL(); - else stack->PushInt(*(byte *)((byte *)_buffer + Start)); + stack->correctParams(1); + int Start = stack->pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(byte))) stack->pushNULL(); + else stack->pushInt(*(byte *)((byte *)_buffer + Start)); return S_OK; } @@ -164,10 +164,10 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // GetShort ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetShort") == 0) { - stack->CorrectParams(1); - int Start = stack->Pop()->GetInt(); - if (!CheckBounds(script, Start, sizeof(short))) stack->PushNULL(); - else stack->PushInt(65536 + * (short *)((byte *)_buffer + Start)); + stack->correctParams(1); + int Start = stack->pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(short))) stack->pushNULL(); + else stack->pushInt(65536 + * (short *)((byte *)_buffer + Start)); return S_OK; } @@ -176,10 +176,10 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // GetInt / GetLong ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetInt") == 0 || strcmp(name, "GetLong") == 0) { - stack->CorrectParams(1); - int Start = stack->Pop()->GetInt(); - if (!CheckBounds(script, Start, sizeof(int))) stack->PushNULL(); - else stack->PushInt(*(int *)((byte *)_buffer + Start)); + stack->correctParams(1); + int Start = stack->pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(int))) stack->pushNULL(); + else stack->pushInt(*(int *)((byte *)_buffer + Start)); return S_OK; } @@ -188,10 +188,10 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // GetFloat ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetFloat") == 0) { - stack->CorrectParams(1); - int Start = stack->Pop()->GetInt(); - if (!CheckBounds(script, Start, sizeof(float))) stack->PushNULL(); - else stack->PushFloat(*(float *)((byte *)_buffer + Start)); + stack->correctParams(1); + int Start = stack->pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(float))) stack->pushNULL(); + else stack->pushFloat(*(float *)((byte *)_buffer + Start)); return S_OK; } @@ -200,10 +200,10 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // GetDouble ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetDouble") == 0) { - stack->CorrectParams(1); - int Start = stack->Pop()->GetInt(); - if (!CheckBounds(script, Start, sizeof(double))) stack->PushNULL(); - else stack->PushFloat(*(double *)((byte *)_buffer + Start)); + stack->correctParams(1); + int Start = stack->pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(double))) stack->pushNULL(); + else stack->pushFloat(*(double *)((byte *)_buffer + Start)); return S_OK; } @@ -212,9 +212,9 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // GetString ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetString") == 0) { - stack->CorrectParams(2); - int Start = stack->Pop()->GetInt(); - int Length = stack->Pop()->GetInt(); + stack->correctParams(2); + int Start = stack->pop()->GetInt(); + int Length = stack->pop()->GetInt(); // find end of string if (Length == 0 && Start >= 0 && Start < _size) { @@ -226,12 +226,12 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack } } - if (!CheckBounds(script, Start, Length)) stack->PushNULL(); + if (!CheckBounds(script, Start, Length)) stack->pushNULL(); else { char *Str = new char[Length + 1]; strncpy(Str, (const char *)_buffer + Start, Length); Str[Length] = '\0'; - stack->PushString(Str); + stack->pushString(Str); delete [] Str; } return S_OK; @@ -241,13 +241,13 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // GetPointer ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetPointer") == 0) { - stack->CorrectParams(1); - int Start = stack->Pop()->GetInt(); - if (!CheckBounds(script, Start, sizeof(void *))) stack->PushNULL(); + stack->correctParams(1); + int Start = stack->pop()->GetInt(); + if (!CheckBounds(script, Start, sizeof(void *))) stack->pushNULL(); else { void *Pointer = *(void **)((byte *)_buffer + Start); CSXMemBuffer *Buf = new CSXMemBuffer(Game, Pointer); - stack->PushNative(Buf, false); + stack->pushNative(Buf, false); } return S_OK; } @@ -256,14 +256,14 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetBool ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetBool") == 0) { - stack->CorrectParams(2); - int Start = stack->Pop()->GetInt(); - bool Val = stack->Pop()->GetBool(); + stack->correctParams(2); + int Start = stack->pop()->GetInt(); + bool Val = stack->pop()->GetBool(); - if (!CheckBounds(script, Start, sizeof(bool))) stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(bool))) stack->pushBool(false); else { *(bool *)((byte *)_buffer + Start) = Val; - stack->PushBool(true); + stack->pushBool(true); } return S_OK; } @@ -272,14 +272,14 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetByte ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetByte") == 0) { - stack->CorrectParams(2); - int Start = stack->Pop()->GetInt(); - byte Val = (byte)stack->Pop()->GetInt(); + stack->correctParams(2); + int Start = stack->pop()->GetInt(); + byte Val = (byte)stack->pop()->GetInt(); - if (!CheckBounds(script, Start, sizeof(byte))) stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(byte))) stack->pushBool(false); else { *(byte *)((byte *)_buffer + Start) = Val; - stack->PushBool(true); + stack->pushBool(true); } return S_OK; } @@ -288,14 +288,14 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetShort ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetShort") == 0) { - stack->CorrectParams(2); - int Start = stack->Pop()->GetInt(); - short Val = (short)stack->Pop()->GetInt(); + stack->correctParams(2); + int Start = stack->pop()->GetInt(); + short Val = (short)stack->pop()->GetInt(); - if (!CheckBounds(script, Start, sizeof(short))) stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(short))) stack->pushBool(false); else { *(short *)((byte *)_buffer + Start) = Val; - stack->PushBool(true); + stack->pushBool(true); } return S_OK; } @@ -304,14 +304,14 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetInt / SetLong ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetInt") == 0 || strcmp(name, "SetLong") == 0) { - stack->CorrectParams(2); - int Start = stack->Pop()->GetInt(); - int Val = stack->Pop()->GetInt(); + stack->correctParams(2); + int Start = stack->pop()->GetInt(); + int Val = stack->pop()->GetInt(); - if (!CheckBounds(script, Start, sizeof(int))) stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(int))) stack->pushBool(false); else { *(int *)((byte *)_buffer + Start) = Val; - stack->PushBool(true); + stack->pushBool(true); } return S_OK; } @@ -320,14 +320,14 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetFloat ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetFloat") == 0) { - stack->CorrectParams(2); - int Start = stack->Pop()->GetInt(); - float Val = (float)stack->Pop()->GetFloat(); + stack->correctParams(2); + int Start = stack->pop()->GetInt(); + float Val = (float)stack->pop()->GetFloat(); - if (!CheckBounds(script, Start, sizeof(float))) stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(float))) stack->pushBool(false); else { *(float *)((byte *)_buffer + Start) = Val; - stack->PushBool(true); + stack->pushBool(true); } return S_OK; } @@ -336,14 +336,14 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetDouble ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetDouble") == 0) { - stack->CorrectParams(2); - int Start = stack->Pop()->GetInt(); - double Val = stack->Pop()->GetFloat(); + stack->correctParams(2); + int Start = stack->pop()->GetInt(); + double Val = stack->pop()->GetFloat(); - if (!CheckBounds(script, Start, sizeof(double))) stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(double))) stack->pushBool(false); else { *(double *)((byte *)_buffer + Start) = Val; - stack->PushBool(true); + stack->pushBool(true); } return S_OK; } @@ -352,14 +352,14 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetString ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetString") == 0) { - stack->CorrectParams(2); - int Start = stack->Pop()->GetInt(); - const char *Val = stack->Pop()->GetString(); + stack->correctParams(2); + int Start = stack->pop()->GetInt(); + const char *Val = stack->pop()->GetString(); - if (!CheckBounds(script, Start, strlen(Val) + 1)) stack->PushBool(false); + if (!CheckBounds(script, Start, strlen(Val) + 1)) stack->pushBool(false); else { memcpy((byte *)_buffer + Start, Val, strlen(Val) + 1); - stack->PushBool(true); + stack->pushBool(true); } return S_OK; } @@ -368,19 +368,19 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // SetPointer ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetPointer") == 0) { - stack->CorrectParams(2); - int Start = stack->Pop()->GetInt(); - /* CScValue *Val = */ stack->Pop(); + stack->correctParams(2); + int Start = stack->pop()->GetInt(); + /* CScValue *Val = */ stack->pop(); - if (!CheckBounds(script, Start, sizeof(void *))) stack->PushBool(false); + if (!CheckBounds(script, Start, sizeof(void *))) stack->pushBool(false); else { /* int Pointer = (int)Val->GetMemBuffer(); memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*)); - stack->PushBool(true); + stack->pushBool(true); */ // TODO fix - stack->PushBool(false); + stack->pushBool(false); } return S_OK; @@ -390,7 +390,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack // DEBUG_Dump ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DEBUG_Dump") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); if (_buffer && _size) { warning("SXMemBuffer::ScCallMethod - DEBUG_Dump"); Common::DumpFile f; @@ -398,7 +398,7 @@ HRESULT CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack f.write(_buffer, _size); f.close(); } - stack->PushNULL(); + stack->pushNULL(); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXStore.cpp b/engines/wintermute/Base/scriptables/SXStore.cpp index bfdbd212c7..a1d41c2db6 100644 --- a/engines/wintermute/Base/scriptables/SXStore.cpp +++ b/engines/wintermute/Base/scriptables/SXStore.cpp @@ -89,39 +89,39 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // EnableEvents ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "EnableEvents") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); SetEventsEnabled(script, true); - stack->PushBool(GetEventsEnabled() == true); + stack->pushBool(GetEventsEnabled() == true); return S_OK; } ////////////////////////////////////////////////////////////////////////// // DisableEvents ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DisableEvents") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); SetEventsEnabled(script, false); - stack->PushBool(GetEventsEnabled() == false); + stack->pushBool(GetEventsEnabled() == false); return S_OK; } ////////////////////////////////////////////////////////////////////////// // ValidateProducts ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ValidateProducts") == 0) { - stack->CorrectParams(1); - const char *prodIdList = stack->Pop()->GetString(); + stack->correctParams(1); + const char *prodIdList = stack->pop()->GetString(); _lastProductRequestOwner = script->_owner; ValidateProducts(prodIdList); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } ////////////////////////////////////////////////////////////////////////// // GetValidProduct ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetValidProduct") == 0) { - stack->CorrectParams(1); - int index = stack->Pop()->GetInt(); + stack->correctParams(1); + int index = stack->pop()->GetInt(); if (index >= 0 && index < _validProducts.GetSize()) { - CScValue *prod = stack->GetPushValue(); + CScValue *prod = stack->getPushValue(); if (prod) { prod->SetProperty("Id", _validProducts[index]->GetId()); prod->SetProperty("Name", _validProducts[index]->GetName()); @@ -129,7 +129,7 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi prod->SetProperty("Price", _validProducts[index]->GetPrice()); } } else - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -137,12 +137,12 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GetInvalidProduct ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetInvalidProduct") == 0) { - stack->CorrectParams(1); - int index = stack->Pop()->GetInt(); + stack->correctParams(1); + int index = stack->pop()->GetInt(); if (index >= 0 && index < _invalidProducts.size()) - stack->PushString(_invalidProducts[index].c_str()); + stack->pushString(_invalidProducts[index].c_str()); else - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -150,17 +150,17 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // GetTransaction ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetTransaction") == 0) { - stack->CorrectParams(1); - int index = stack->Pop()->GetInt(); + stack->correctParams(1); + int index = stack->pop()->GetInt(); if (index >= 0 && index < _transactions.GetSize()) { - CScValue *trans = stack->GetPushValue(); + CScValue *trans = stack->getPushValue(); if (trans) { trans->SetProperty("Id", _transactions[index]->GetId()); trans->SetProperty("ProductId", _transactions[index]->GetProductId()); trans->SetProperty("State", _transactions[index]->GetState()); } } else - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -168,9 +168,9 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // Purchase ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Purchase") == 0) { - stack->CorrectParams(1); - const char *prodId = stack->Pop()->GetString(); - stack->PushBool(Purchase(script, prodId)); + stack->correctParams(1); + const char *prodId = stack->pop()->GetString(); + stack->pushBool(Purchase(script, prodId)); return S_OK; } @@ -178,9 +178,9 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // FinishTransaction ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "FinishTransaction") == 0) { - stack->CorrectParams(1); - const char *transId = stack->Pop()->GetString(); - stack->PushBool(FinishTransaction(script, transId)); + stack->correctParams(1); + const char *transId = stack->pop()->GetString(); + stack->pushBool(FinishTransaction(script, transId)); return S_OK; } @@ -188,9 +188,9 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // RestoreTransactions ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "RestoreTransactions") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); RestoreTransactions(script); - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -199,13 +199,13 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // UnlockProduct ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "UnlockProduct") == 0) { - stack->CorrectParams(1); - const char *prodId = stack->Pop()->GetString(); + stack->correctParams(1); + const char *prodId = stack->pop()->GetString(); Game->_registry->WriteBool("Purchases", prodId, true); Game->_registry->SaveValues(); - stack->PushBool(true); + stack->pushBool(true); return S_OK; } @@ -214,10 +214,10 @@ HRESULT CSXStore::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi // IsProductUnlocked ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsProductUnlocked") == 0) { - stack->CorrectParams(1); - const char *prodId = stack->Pop()->GetString(); + stack->correctParams(1); + const char *prodId = stack->pop()->GetString(); - stack->PushBool(Game->_registry->ReadBool("Purchases", prodId, false)); + stack->pushBool(Game->_registry->ReadBool("Purchases", prodId, false)); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp index 4a912df5fe..36dc257229 100644 --- a/engines/wintermute/Base/scriptables/SXString.cpp +++ b/engines/wintermute/Base/scriptables/SXString.cpp @@ -48,8 +48,8 @@ CSXString::CSXString(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { _string = NULL; _capacity = 0; - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); if (Val->IsInt()) { _capacity = MAX(0, Val->GetInt()); @@ -104,9 +104,9 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // Substring ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Substring") == 0) { - stack->CorrectParams(2); - int start = stack->Pop()->GetInt(); - int end = stack->Pop()->GetInt(); + stack->correctParams(2); + int start = stack->pop()->GetInt(); + int end = stack->pop()->GetInt(); if (end < start) CBUtils::Swap(&start, &end); @@ -121,11 +121,11 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th WideString subStr(str.c_str() + start, end - start + 1); if (Game->_textEncoding == TEXT_UTF8) - stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); + stack->pushString(StringUtil::WideToUtf8(subStr).c_str()); else - stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); + stack->pushString(StringUtil::WideToAnsi(subStr).c_str()); // } catch (std::exception &) { - // stack->PushNULL(); + // stack->pushNULL(); // } return S_OK; @@ -135,14 +135,14 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // Substr ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Substr") == 0) { - stack->CorrectParams(2); - int start = stack->Pop()->GetInt(); + stack->correctParams(2); + int start = stack->pop()->GetInt(); - CScValue *val = stack->Pop(); + CScValue *val = stack->pop(); int len = val->GetInt(); if (!val->IsNULL() && len <= 0) { - stack->PushString(""); + stack->pushString(""); return S_OK; } @@ -159,11 +159,11 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th WideString subStr(str.c_str() + start, len); if (Game->_textEncoding == TEXT_UTF8) - stack->PushString(StringUtil::WideToUtf8(subStr).c_str()); + stack->pushString(StringUtil::WideToUtf8(subStr).c_str()); else - stack->PushString(StringUtil::WideToAnsi(subStr).c_str()); + stack->pushString(StringUtil::WideToAnsi(subStr).c_str()); // } catch (std::exception &) { -// stack->PushNULL(); +// stack->pushNULL(); // } return S_OK; @@ -173,7 +173,7 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // ToUpperCase ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ToUpperCase") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); WideString str; if (Game->_textEncoding == TEXT_UTF8) @@ -184,9 +184,9 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th StringUtil::ToUpperCase(str); if (Game->_textEncoding == TEXT_UTF8) - stack->PushString(StringUtil::WideToUtf8(str).c_str()); + stack->pushString(StringUtil::WideToUtf8(str).c_str()); else - stack->PushString(StringUtil::WideToAnsi(str).c_str()); + stack->pushString(StringUtil::WideToAnsi(str).c_str()); return S_OK; } @@ -195,7 +195,7 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // ToLowerCase ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ToLowerCase") == 0) { - stack->CorrectParams(0); + stack->correctParams(0); WideString str; if (Game->_textEncoding == TEXT_UTF8) @@ -206,9 +206,9 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th StringUtil::ToLowerCase(str); if (Game->_textEncoding == TEXT_UTF8) - stack->PushString(StringUtil::WideToUtf8(str).c_str()); + stack->pushString(StringUtil::WideToUtf8(str).c_str()); else - stack->PushString(StringUtil::WideToAnsi(str).c_str()); + stack->pushString(StringUtil::WideToAnsi(str).c_str()); return S_OK; } @@ -217,10 +217,10 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // IndexOf ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IndexOf") == 0) { - stack->CorrectParams(2); + stack->correctParams(2); - const char *strToFind = stack->Pop()->GetString(); - int index = stack->Pop()->GetInt(); + const char *strToFind = stack->pop()->GetString(); + int index = stack->pop()->GetInt(); WideString str; if (Game->_textEncoding == TEXT_UTF8) @@ -235,7 +235,7 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th toFind = StringUtil::AnsiToWide(strToFind); int indexOf = StringUtil::IndexOf(str, toFind, index); - stack->PushInt(indexOf); + stack->pushInt(indexOf); return S_OK; } @@ -244,14 +244,14 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th // Split ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Split") == 0) { - stack->CorrectParams(1); - CScValue *Val = stack->Pop(); + stack->correctParams(1); + CScValue *Val = stack->pop(); char Separators[MAX_PATH] = ","; if (!Val->IsNULL()) strcpy(Separators, Val->GetString()); CSXArray *Array = new CSXArray(Game); if (!Array) { - stack->PushNULL(); + stack->pushNULL(); return S_OK; } @@ -308,7 +308,7 @@ HRESULT CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *th Val = NULL; } - stack->PushNative(Array, false); + stack->pushNative(Array, false); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp index 9c443df509..e840d0cd78 100644 --- a/engines/wintermute/Base/scriptables/ScEngine.cpp +++ b/engines/wintermute/Base/scriptables/ScEngine.cpp @@ -407,13 +407,13 @@ HRESULT CScEngine::Tick() { case SCRIPT_WAITING_SCRIPT: { if (!IsValidScript(_scripts[i]->_waitScript) || _scripts[i]->_waitScript->_state == SCRIPT_ERROR) { // fake return value - _scripts[i]->_stack->PushNULL(); + _scripts[i]->_stack->pushNULL(); _scripts[i]->_waitScript = NULL; _scripts[i]->Run(); } else { if (_scripts[i]->_waitScript->_state == SCRIPT_THREAD_FINISHED) { // copy return value - _scripts[i]->_stack->Push(_scripts[i]->_waitScript->_stack->Pop()); + _scripts[i]->_stack->push(_scripts[i]->_waitScript->_stack->pop()); _scripts[i]->Run(); _scripts[i]->_waitScript->finish(); _scripts[i]->_waitScript = NULL; diff --git a/engines/wintermute/Base/scriptables/ScScript.cpp b/engines/wintermute/Base/scriptables/ScScript.cpp index 6e43ac6e0d..61e1e91282 100644 --- a/engines/wintermute/Base/scriptables/ScScript.cpp +++ b/engines/wintermute/Base/scriptables/ScScript.cpp @@ -493,9 +493,9 @@ HRESULT CScScript::ExecuteInstruction() { if (Game->GetDebugMgr()->_enabled) Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->GetProp(_symbols[dw]), _symbols[dw]); } else { - _scopeStack->GetTop()->SetProp(_symbols[dw], _operand); + _scopeStack->getTop()->SetProp(_symbols[dw], _operand); if (Game->GetDebugMgr()->_enabled) - Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->GetTop(), _scopeStack->GetTop()->GetProp(_symbols[dw]), _symbols[dw]); + Game->GetDebugMgr()->OnVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->GetProp(_symbols[dw]), _symbols[dw]); } break; @@ -517,13 +517,13 @@ HRESULT CScScript::ExecuteInstruction() { case II_RET: if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { - Game->GetDebugMgr()->OnScriptShutdownScope(this, _scopeStack->GetTop()); + Game->GetDebugMgr()->OnScriptShutdownScope(this, _scopeStack->getTop()); - _scopeStack->Pop(); - _iP = (uint32)_callStack->Pop()->GetInt(); + _scopeStack->pop(); + _iP = (uint32)_callStack->pop()->GetInt(); if (_scopeStack->_sP < 0) Game->GetDebugMgr()->OnScriptChangeScope(this, NULL); - else Game->GetDebugMgr()->OnScriptChangeScope(this, _scopeStack->GetTop()); + else Game->GetDebugMgr()->OnScriptChangeScope(this, _scopeStack->getTop()); } else { if (_thread) { _state = SCRIPT_THREAD_FINISHED; @@ -544,7 +544,7 @@ HRESULT CScScript::ExecuteInstruction() { dw = GetDWORD(); _operand->SetInt(_iP); - _callStack->Push(_operand); + _callStack->push(_operand); _iP = dw; @@ -553,11 +553,11 @@ HRESULT CScScript::ExecuteInstruction() { case II_CALL_BY_EXP: { // push var // push string - str = _stack->Pop()->GetString(); + str = _stack->pop()->GetString(); char *MethodName = new char[strlen(str) + 1]; strcpy(MethodName, str); - CScValue *var = _stack->Pop(); + CScValue *var = _stack->pop(); if (var->_type == VAL_VARIABLE_REF) var = var->_valRef; HRESULT res = E_FAIL; @@ -574,18 +574,18 @@ HRESULT CScScript::ExecuteInstruction() { if (!_unbreakable) { _waitScript = var->GetNative()->invokeMethodThread(MethodName); if (!_waitScript) { - _stack->CorrectParams(0); + _stack->correctParams(0); RuntimeError("Error invoking method '%s'.", MethodName); - _stack->PushNULL(); + _stack->pushNULL(); } else { _state = SCRIPT_WAITING_SCRIPT; _waitScript->CopyParameters(_stack); } } else { // can call methods in unbreakable mode - _stack->CorrectParams(0); + _stack->correctParams(0); RuntimeError("Cannot call method '%s'. Ignored.", MethodName); - _stack->PushNULL(); + _stack->pushNULL(); } delete [] MethodName; break; @@ -616,9 +616,9 @@ HRESULT CScScript::ExecuteInstruction() { if (var->_type == VAL_NATIVE && !TriedNative) res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); if (FAILED(res)) { - _stack->CorrectParams(0); + _stack->correctParams(0); RuntimeError("Call to undefined method '%s'. Ignored.", MethodName); - _stack->PushNULL(); + _stack->pushNULL(); } } } @@ -638,40 +638,40 @@ HRESULT CScScript::ExecuteInstruction() { } case II_SCOPE: _operand->SetNULL(); - _scopeStack->Push(_operand); + _scopeStack->push(_operand); if (_scopeStack->_sP < 0) Game->GetDebugMgr()->OnScriptChangeScope(this, NULL); - else Game->GetDebugMgr()->OnScriptChangeScope(this, _scopeStack->GetTop()); + else Game->GetDebugMgr()->OnScriptChangeScope(this, _scopeStack->getTop()); break; case II_CORRECT_STACK: dw = GetDWORD(); // params expected - _stack->CorrectParams(dw); + _stack->correctParams(dw); break; case II_CREATE_OBJECT: _operand->SetObject(); - _stack->Push(_operand); + _stack->push(_operand); break; case II_POP_EMPTY: - _stack->Pop(); + _stack->pop(); break; case II_PUSH_VAR: { CScValue *var = GetVar(_symbols[GetDWORD()]); if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) { _operand->SetReference(var); - _stack->Push(_operand); - } else _stack->Push(var); + _stack->push(_operand); + } else _stack->push(var); break; } case II_PUSH_VAR_REF: { CScValue *var = GetVar(_symbols[GetDWORD()]); _operand->SetReference(var); - _stack->Push(_operand); + _stack->push(_operand); break; } @@ -679,7 +679,7 @@ HRESULT CScScript::ExecuteInstruction() { char *VarName = _symbols[GetDWORD()]; CScValue *var = GetVar(VarName); if (var) { - CScValue *val = _stack->Pop(); + CScValue *val = _stack->pop(); if (!val) { RuntimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); var->SetNULL(); @@ -699,58 +699,58 @@ HRESULT CScScript::ExecuteInstruction() { } case II_PUSH_VAR_THIS: - _stack->Push(_thisStack->GetTop()); + _stack->push(_thisStack->getTop()); break; case II_PUSH_INT: - _stack->PushInt((int)GetDWORD()); + _stack->pushInt((int)GetDWORD()); break; case II_PUSH_FLOAT: - _stack->PushFloat(GetFloat()); + _stack->pushFloat(GetFloat()); break; case II_PUSH_BOOL: - _stack->PushBool(GetDWORD() != 0); + _stack->pushBool(GetDWORD() != 0); break; case II_PUSH_STRING: - _stack->PushString(GetString()); + _stack->pushString(GetString()); break; case II_PUSH_NULL: - _stack->PushNULL(); + _stack->pushNULL(); break; case II_PUSH_THIS_FROM_STACK: - _operand->SetReference(_stack->GetTop()); - _thisStack->Push(_operand); + _operand->SetReference(_stack->getTop()); + _thisStack->push(_operand); break; case II_PUSH_THIS: _operand->SetReference(GetVar(_symbols[GetDWORD()])); - _thisStack->Push(_operand); + _thisStack->push(_operand); break; case II_POP_THIS: - _thisStack->Pop(); + _thisStack->pop(); break; case II_PUSH_BY_EXP: { - str = _stack->Pop()->GetString(); - CScValue *val = _stack->Pop()->GetProp(str); - if (val) _stack->Push(val); - else _stack->PushNULL(); + str = _stack->pop()->GetString(); + CScValue *val = _stack->pop()->GetProp(str); + if (val) _stack->push(val); + else _stack->pushNULL(); break; } case II_POP_BY_EXP: { - str = _stack->Pop()->GetString(); - CScValue *var = _stack->Pop(); - CScValue *val = _stack->Pop(); + str = _stack->pop()->GetString(); + CScValue *var = _stack->pop(); + CScValue *val = _stack->pop(); if (val == NULL) { RuntimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); @@ -764,11 +764,11 @@ HRESULT CScScript::ExecuteInstruction() { } case II_PUSH_REG1: - _stack->Push(_reg1); + _stack->push(_reg1); break; case II_POP_REG1: - _reg1->Copy(_stack->Pop()); + _reg1->Copy(_stack->pop()); break; case II_JMP: @@ -777,8 +777,8 @@ HRESULT CScScript::ExecuteInstruction() { case II_JMP_FALSE: { dw = GetDWORD(); - //if(!_stack->Pop()->GetBool()) _iP = dw; - CScValue *Val = _stack->Pop(); + //if(!_stack->pop()->GetBool()) _iP = dw; + CScValue *Val = _stack->pop(); if (!Val) { RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); } else { @@ -788,8 +788,8 @@ HRESULT CScScript::ExecuteInstruction() { } case II_ADD: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); if (op1->IsNULL() || op2->IsNULL()) _operand->SetNULL(); else if (op1->GetType() == VAL_STRING || op2->GetType() == VAL_STRING) { @@ -802,98 +802,98 @@ HRESULT CScScript::ExecuteInstruction() { _operand->SetInt(op1->GetInt() + op2->GetInt()); else _operand->SetFloat(op1->GetFloat() + op2->GetFloat()); - _stack->Push(_operand); + _stack->push(_operand); break; case II_SUB: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); if (op1->IsNULL() || op2->IsNULL()) _operand->SetNULL(); else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) _operand->SetInt(op1->GetInt() - op2->GetInt()); else _operand->SetFloat(op1->GetFloat() - op2->GetFloat()); - _stack->Push(_operand); + _stack->push(_operand); break; case II_MUL: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); if (op1->IsNULL() || op2->IsNULL()) _operand->SetNULL(); else if (op1->GetType() == VAL_INT && op2->GetType() == VAL_INT) _operand->SetInt(op1->GetInt() * op2->GetInt()); else _operand->SetFloat(op1->GetFloat() * op2->GetFloat()); - _stack->Push(_operand); + _stack->push(_operand); break; case II_DIV: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); if (op2->GetFloat() == 0.0f) RuntimeError("Division by zero."); if (op1->IsNULL() || op2->IsNULL() || op2->GetFloat() == 0.0f) _operand->SetNULL(); else _operand->SetFloat(op1->GetFloat() / op2->GetFloat()); - _stack->Push(_operand); + _stack->push(_operand); break; case II_MODULO: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); if (op2->GetInt() == 0) RuntimeError("Division by zero."); if (op1->IsNULL() || op2->IsNULL() || op2->GetInt() == 0) _operand->SetNULL(); else _operand->SetInt(op1->GetInt() % op2->GetInt()); - _stack->Push(_operand); + _stack->push(_operand); break; case II_NOT: - op1 = _stack->Pop(); + op1 = _stack->pop(); //if(op1->IsNULL()) _operand->SetNULL(); if (op1->IsNULL()) _operand->SetBool(true); else _operand->SetBool(!op1->GetBool()); - _stack->Push(_operand); + _stack->push(_operand); break; case II_AND: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); if (op1 == NULL || op2 == NULL) { RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); _operand->SetBool(false); } else { _operand->SetBool(op1->GetBool() && op2->GetBool()); } - _stack->Push(_operand); + _stack->push(_operand); break; case II_OR: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); if (op1 == NULL || op2 == NULL) { RuntimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); _operand->SetBool(false); } else { _operand->SetBool(op1->GetBool() || op2->GetBool()); } - _stack->Push(_operand); + _stack->push(_operand); break; case II_CMP_EQ: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); /* if((op1->IsNULL() && !op2->IsNULL()) || (!op1->IsNULL() && op2->IsNULL())) _operand->SetBool(false); @@ -912,12 +912,12 @@ HRESULT CScScript::ExecuteInstruction() { */ _operand->SetBool(CScValue::Compare(op1, op2) == 0); - _stack->Push(_operand); + _stack->push(_operand); break; case II_CMP_NE: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); /* if((op1->IsNULL() && !op2->IsNULL()) || (!op1->IsNULL() && op2->IsNULL())) _operand->SetBool(true); @@ -936,12 +936,12 @@ HRESULT CScScript::ExecuteInstruction() { */ _operand->SetBool(CScValue::Compare(op1, op2) != 0); - _stack->Push(_operand); + _stack->push(_operand); break; case II_CMP_L: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); /* if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ @@ -951,12 +951,12 @@ HRESULT CScScript::ExecuteInstruction() { */ _operand->SetBool(CScValue::Compare(op1, op2) < 0); - _stack->Push(_operand); + _stack->push(_operand); break; case II_CMP_G: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); /* if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ @@ -966,12 +966,12 @@ HRESULT CScScript::ExecuteInstruction() { */ _operand->SetBool(CScValue::Compare(op1, op2) > 0); - _stack->Push(_operand); + _stack->push(_operand); break; case II_CMP_LE: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); /* if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ @@ -981,12 +981,12 @@ HRESULT CScScript::ExecuteInstruction() { */ _operand->SetBool(CScValue::Compare(op1, op2) <= 0); - _stack->Push(_operand); + _stack->push(_operand); break; case II_CMP_GE: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); /* if(op1->GetType()==VAL_FLOAT && op2->GetType()==VAL_FLOAT){ @@ -996,26 +996,26 @@ HRESULT CScScript::ExecuteInstruction() { */ _operand->SetBool(CScValue::Compare(op1, op2) >= 0); - _stack->Push(_operand); + _stack->push(_operand); break; case II_CMP_STRICT_EQ: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); //_operand->SetBool(op1->GetType()==op2->GetType() && op1->GetFloat()==op2->GetFloat()); _operand->SetBool(CScValue::CompareStrict(op1, op2) == 0); - _stack->Push(_operand); + _stack->push(_operand); break; case II_CMP_STRICT_NE: - op2 = _stack->Pop(); - op1 = _stack->Pop(); + op2 = _stack->pop(); + op1 = _stack->pop(); //_operand->SetBool(op1->GetType()!=op2->GetType() || op1->GetFloat()!=op2->GetFloat()); _operand->SetBool(CScValue::CompareStrict(op1, op2) != 0); - _stack->Push(_operand); + _stack->push(_operand); break; case II_DBG_LINE: { @@ -1077,7 +1077,7 @@ CScValue *CScScript::GetVar(char *name) { // scope locals if (_scopeStack->_sP >= 0) { - if (_scopeStack->GetTop()->PropExists(name)) ret = _scopeStack->GetTop()->GetProp(name); + if (_scopeStack->getTop()->PropExists(name)) ret = _scopeStack->getTop()->GetProp(name); } // script globals @@ -1094,10 +1094,10 @@ CScValue *CScScript::GetVar(char *name) { //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", name); Game->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", name, _filename, _currentLine); CScValue *Val = new CScValue(Game); - CScValue *Scope = _scopeStack->GetTop(); + CScValue *Scope = _scopeStack->getTop(); if (Scope) { Scope->SetProp(name, Val); - ret = _scopeStack->GetTop()->GetProp(name); + ret = _scopeStack->getTop()->GetProp(name); } else { _globals->SetProp(name, Val); ret = _globals->GetProp(name); @@ -1331,8 +1331,8 @@ HRESULT CScScript::ExternalCall(CScStack *stack, CScStack *thisStack, CScScript: #ifndef __WIN32__ Game->LOG(0, "External functions are not supported on this platform."); - stack->CorrectParams(0); - stack->PushNULL(); + stack->correctParams(0); + stack->pushNULL(); return E_FAIL; #else @@ -1345,11 +1345,11 @@ HRESULT CScScript::ExternalCall(CScStack *stack, CScStack *thisStack, CScScript: if (pFunc) { int i; Success = true; - stack->CorrectParams(Function->nu_params); + stack->correctParams(Function->nu_params); CBDynBuffer *Buffer = new CBDynBuffer(Game, 20 * sizeof(uint32)); for (i = 0; i < Function->nu_params; i++) { - CScValue *Val = stack->Pop(); + CScValue *Val = stack->pop(); switch (Function->params[i]) { case TYPE_BOOL: Buffer->PutDWORD((uint32)Val->GetBool()); @@ -1399,34 +1399,34 @@ HRESULT CScScript::ExternalCall(CScStack *stack, CScStack *thisStack, CScScript: // return switch (Function->returns) { case TYPE_BOOL: - stack->PushBool((byte)ret != 0); + stack->pushBool((byte)ret != 0); break; case TYPE_LONG: - stack->PushInt(ret); + stack->pushInt(ret); break; case TYPE_BYTE: - stack->PushInt((byte)ret); + stack->pushInt((byte)ret); break; break; case TYPE_STRING: - stack->PushString((char *)ret); + stack->pushString((char *)ret); break; case TYPE_MEMBUFFER: { CSXMemBuffer *Buf = new CSXMemBuffer(Game, (void *)ret); - stack->PushNative(Buf, false); + stack->pushNative(Buf, false); } break; case TYPE_FLOAT: { uint32 dw = GetST0(); - stack->PushFloat(*((float *)&dw)); + stack->pushFloat(*((float *)&dw)); break; } case TYPE_DOUBLE: - stack->PushFloat(GetST0Double()); + stack->pushFloat(GetST0Double()); break; default: - stack->PushNULL(); + stack->pushNULL(); } if (StackCorrupted) RuntimeError("Warning: Stack corrupted after calling '%s' in '%s'\n Check parameters and/or calling convention.", Function->name, Function->dll_name); @@ -1434,8 +1434,8 @@ HRESULT CScScript::ExternalCall(CScStack *stack, CScStack *thisStack, CScScript: } else RuntimeError("Error loading DLL '%s'", Function->dll_name); if (!Success) { - stack->CorrectParams(0); - stack->PushNULL(); + stack->correctParams(0); + stack->pushNULL(); } if (hDll) FreeLibrary(hDll); @@ -1527,13 +1527,13 @@ double CScScript::GetST0Double(void) { ////////////////////////////////////////////////////////////////////////// HRESULT CScScript::CopyParameters(CScStack *stack) { int i; - int NumParams = stack->Pop()->GetInt(); + int NumParams = stack->pop()->GetInt(); for (i = NumParams - 1; i >= 0; i--) { - _stack->Push(stack->GetAt(i)); + _stack->push(stack->getAt(i)); } - _stack->PushInt(NumParams); + _stack->pushInt(NumParams); - for (i = 0; i < NumParams; i++) stack->Pop(); + for (i = 0; i < NumParams; i++) stack->pop(); return S_OK; } diff --git a/engines/wintermute/Base/scriptables/ScStack.cpp b/engines/wintermute/Base/scriptables/ScStack.cpp index f10aa7085b..dc953ed8d0 100644 --- a/engines/wintermute/Base/scriptables/ScStack.cpp +++ b/engines/wintermute/Base/scriptables/ScStack.cpp @@ -55,7 +55,7 @@ CScStack::~CScStack() { ////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::Pop() { +CScValue *CScStack::pop() { if (_sP < 0) { Game->LOG(0, "Fatal: Stack underflow"); return NULL; @@ -66,7 +66,7 @@ CScValue *CScStack::Pop() { ////////////////////////////////////////////////////////////////////////// -void CScStack::Push(CScValue *val) { +void CScStack::push(CScValue *val) { _sP++; if (_sP < _values.GetSize()) { @@ -81,7 +81,7 @@ void CScStack::Push(CScValue *val) { ////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::GetPushValue() { +CScValue *CScStack::getPushValue() { _sP++; if (_sP >= _values.GetSize()) { @@ -95,14 +95,14 @@ CScValue *CScStack::GetPushValue() { ////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::GetTop() { +CScValue *CScStack::getTop() { if (_sP < 0 || _sP >= _values.GetSize()) return NULL; else return _values[_sP]; } ////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::GetAt(int index) { +CScValue *CScStack::getAt(int index) { index = _sP - index; if (index < 0 || index >= _values.GetSize()) return NULL; else return _values[index]; @@ -110,8 +110,8 @@ CScValue *CScStack::GetAt(int index) { ////////////////////////////////////////////////////////////////////////// -void CScStack::CorrectParams(uint32 expected_params) { - int nu_params = Pop()->GetInt(); +void CScStack::correctParams(uint32 expected_params) { + int nu_params = pop()->GetInt(); if (expected_params < nu_params) { // too many params while (expected_params < nu_params) { @@ -140,67 +140,67 @@ void CScStack::CorrectParams(uint32 expected_params) { ////////////////////////////////////////////////////////////////////////// -void CScStack::PushNULL() { +void CScStack::pushNULL() { /* CScValue* val = new CScValue(Game); val->SetNULL(); Push(val); delete val; */ - GetPushValue()->SetNULL(); + getPushValue()->SetNULL(); } ////////////////////////////////////////////////////////////////////////// -void CScStack::PushInt(int val) { +void CScStack::pushInt(int val) { /* CScValue* val = new CScValue(Game); val->SetInt(Val); Push(val); delete val; */ - GetPushValue()->SetInt(val); + getPushValue()->SetInt(val); } ////////////////////////////////////////////////////////////////////////// -void CScStack::PushFloat(double val) { +void CScStack::pushFloat(double val) { /* CScValue* val = new CScValue(Game); val->SetFloat(Val); Push(val); delete val; */ - GetPushValue()->SetFloat(val); + getPushValue()->SetFloat(val); } ////////////////////////////////////////////////////////////////////////// -void CScStack::PushBool(bool val) { +void CScStack::pushBool(bool val) { /* CScValue* val = new CScValue(Game); val->SetBool(Val); Push(val); delete val; */ - GetPushValue()->SetBool(val); + getPushValue()->SetBool(val); } ////////////////////////////////////////////////////////////////////////// -void CScStack::PushString(const char *val) { +void CScStack::pushString(const char *val) { /* CScValue* val = new CScValue(Game); val->SetString(Val); Push(val); delete val; */ - GetPushValue()->SetString(val); + getPushValue()->SetString(val); } ////////////////////////////////////////////////////////////////////////// -void CScStack::PushNative(CBScriptable *val, bool persistent) { +void CScStack::pushNative(CBScriptable *val, bool persistent) { /* CScValue* val = new CScValue(Game); val->SetNative(Val, Persistent); @@ -208,7 +208,7 @@ void CScStack::PushNative(CBScriptable *val, bool persistent) { delete val; */ - GetPushValue()->SetNative(val, persistent); + getPushValue()->SetNative(val, persistent); } diff --git a/engines/wintermute/Base/scriptables/ScStack.h b/engines/wintermute/Base/scriptables/ScStack.h index 3e7f557cdd..b2d5f15c1c 100644 --- a/engines/wintermute/Base/scriptables/ScStack.h +++ b/engines/wintermute/Base/scriptables/ScStack.h @@ -41,19 +41,19 @@ class CBScriptable; class CScStack : public CBBase { public: - CScValue *GetAt(int Index); - CScValue *GetPushValue(); + CScValue *getAt(int Index); + CScValue *getPushValue(); DECLARE_PERSISTENT(CScStack, CBBase) - void PushNative(CBScriptable *Val, bool Persistent); - void PushString(const char *Val); - void PushBool(bool Val); - void PushInt(int Val); - void PushFloat(double Val); - void PushNULL(); - void CorrectParams(uint32 expected_params); - CScValue *GetTop(); - void Push(CScValue *Val); - CScValue *Pop(); + void pushNative(CBScriptable *Val, bool Persistent); + void pushString(const char *Val); + void pushBool(bool Val); + void pushInt(int Val); + void pushFloat(double Val); + void pushNULL(); + void correctParams(uint32 expected_params); + CScValue *getTop(); + void push(CScValue *Val); + CScValue *pop(); CScStack(CBGame *inGame); virtual ~CScStack(); CBArray _values; diff --git a/engines/wintermute/Base/scriptables/SxObject.cpp b/engines/wintermute/Base/scriptables/SxObject.cpp index ff51134321..b4fd782f76 100644 --- a/engines/wintermute/Base/scriptables/SxObject.cpp +++ b/engines/wintermute/Base/scriptables/SxObject.cpp @@ -44,9 +44,9 @@ CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack) { ////////////////////////////////////////////////////////////////////////// CSXObject::CSXObject(CBGame *inGame, CScStack *stack): CBObject(inGame) { - int NumParams = stack->Pop()->GetInt(0); + int NumParams = stack->pop()->GetInt(0); for (int i = 0; i < NumParams; i++) { - addScript(stack->Pop()->GetString()); + addScript(stack->pop()->GetString()); } } -- cgit v1.2.3