aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/base/scriptables
diff options
context:
space:
mode:
Diffstat (limited to 'engines/wintermute/base/scriptables')
-rw-r--r--engines/wintermute/base/scriptables/script.cpp292
-rw-r--r--engines/wintermute/base/scriptables/script_engine.cpp167
-rw-r--r--engines/wintermute/base/scriptables/script_engine.h8
-rw-r--r--engines/wintermute/base/scriptables/script_ext_array.cpp35
-rw-r--r--engines/wintermute/base/scriptables/script_ext_array.h2
-rw-r--r--engines/wintermute/base/scriptables/script_ext_date.cpp9
-rw-r--r--engines/wintermute/base/scriptables/script_ext_file.cpp166
-rw-r--r--engines/wintermute/base/scriptables/script_ext_math.cpp8
-rw-r--r--engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp118
-rw-r--r--engines/wintermute/base/scriptables/script_ext_string.cpp120
-rw-r--r--engines/wintermute/base/scriptables/script_stack.cpp14
-rw-r--r--engines/wintermute/base/scriptables/script_value.cpp197
12 files changed, 771 insertions, 365 deletions
diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp
index a519da5832..4deeb0bf39 100644
--- a/engines/wintermute/base/scriptables/script.cpp
+++ b/engines/wintermute/base/scriptables/script.cpp
@@ -249,17 +249,23 @@ bool ScScript::create(const char *filename, byte *buffer, uint32 size, BaseScrip
_threadEvent = NULL;
_filename = new char[strlen(filename) + 1];
- if (_filename) strcpy(_filename, filename);
+ if (_filename) {
+ strcpy(_filename, filename);
+ }
_buffer = new byte [size];
- if (!_buffer) return STATUS_FAILED;
+ if (!_buffer) {
+ return STATUS_FAILED;
+ }
memcpy(_buffer, buffer, size);
_bufferSize = size;
bool res = initScript();
- if (DID_FAIL(res)) return res;
+ if (DID_FAIL(res)) {
+ return res;
+ }
// establish global variables table
_globals = new ScValue(_gameRef);
@@ -277,22 +283,30 @@ bool ScScript::createThread(ScScript *original, uint32 initIP, const char *event
_thread = true;
_methodThread = false;
_threadEvent = new char[strlen(eventName) + 1];
- if (_threadEvent) strcpy(_threadEvent, eventName);
+ if (_threadEvent) {
+ strcpy(_threadEvent, eventName);
+ }
// copy filename
_filename = new char[strlen(original->_filename) + 1];
- if (_filename) strcpy(_filename, original->_filename);
+ if (_filename) {
+ strcpy(_filename, original->_filename);
+ }
// copy buffer
_buffer = new byte [original->_bufferSize];
- if (!_buffer) return STATUS_FAILED;
+ if (!_buffer) {
+ return STATUS_FAILED;
+ }
memcpy(_buffer, original->_buffer, original->_bufferSize);
_bufferSize = original->_bufferSize;
// initialize
bool res = initScript();
- if (DID_FAIL(res)) return res;
+ if (DID_FAIL(res)) {
+ return res;
+ }
// copy globals
_globals = original->_globals;
@@ -317,29 +331,39 @@ bool ScScript::createThread(ScScript *original, uint32 initIP, const char *event
//////////////////////////////////////////////////////////////////////////
bool ScScript::createMethodThread(ScScript *original, const char *methodName) {
uint32 ip = original->getMethodPos(methodName);
- if (ip == 0) return STATUS_FAILED;
+ if (ip == 0) {
+ return STATUS_FAILED;
+ }
cleanup();
_thread = true;
_methodThread = true;
_threadEvent = new char[strlen(methodName) + 1];
- if (_threadEvent) strcpy(_threadEvent, methodName);
+ if (_threadEvent) {
+ strcpy(_threadEvent, methodName);
+ }
// copy filename
_filename = new char[strlen(original->_filename) + 1];
- if (_filename) strcpy(_filename, original->_filename);
+ if (_filename) {
+ strcpy(_filename, original->_filename);
+ }
// copy buffer
_buffer = new byte [original->_bufferSize];
- if (!_buffer) return STATUS_FAILED;
+ if (!_buffer) {
+ return STATUS_FAILED;
+ }
memcpy(_buffer, original->_buffer, original->_bufferSize);
_bufferSize = original->_bufferSize;
// initialize
bool res = initScript();
- if (DID_FAIL(res)) return res;
+ if (DID_FAIL(res)) {
+ return res;
+ }
// copy globals
_globals = original->_globals;
@@ -360,17 +384,25 @@ bool ScScript::createMethodThread(ScScript *original, const char *methodName) {
//////////////////////////////////////////////////////////////////////////
void ScScript::cleanup() {
- if (_buffer) delete[] _buffer;
+ if (_buffer) {
+ delete[] _buffer;
+ }
_buffer = NULL;
- if (_filename) delete[] _filename;
+ if (_filename) {
+ delete[] _filename;
+ }
_filename = NULL;
- if (_symbols) delete[] _symbols;
+ if (_symbols) {
+ delete[] _symbols;
+ }
_symbols = NULL;
_numSymbols = 0;
- if (_globals && !_thread) delete _globals;
+ if (_globals && !_thread) {
+ delete _globals;
+ }
_globals = NULL;
delete _scopeStack;
@@ -385,22 +417,30 @@ void ScScript::cleanup() {
delete _stack;
_stack = NULL;
- if (_functions) delete[] _functions;
+ if (_functions) {
+ delete[] _functions;
+ }
_functions = NULL;
_numFunctions = 0;
- if (_methods) delete[] _methods;
+ if (_methods) {
+ delete[] _methods;
+ }
_methods = NULL;
_numMethods = 0;
- if (_events) delete[] _events;
+ if (_events) {
+ delete[] _events;
+ }
_events = NULL;
_numEvents = 0;
if (_externals) {
for (uint32 i = 0; i < _numExternals; i++) {
- if (_externals[i].nu_params > 0) delete[] _externals[i].params;
+ if (_externals[i].nu_params > 0) {
+ delete[] _externals[i].params;
+ }
}
delete[] _externals;
}
@@ -423,7 +463,7 @@ void ScScript::cleanup() {
_waitScript = NULL;
_parentScript = NULL; // ref only
-
+
delete _scriptStream;
}
@@ -460,7 +500,9 @@ double ScScript::getFloat() {
//////////////////////////////////////////////////////////////////////////
char *ScScript::getString() {
char *ret = (char *)(_buffer + _iP);
- while (*(char *)(_buffer + _iP) != '\0') _iP++;
+ while (*(char *)(_buffer + _iP) != '\0') {
+ _iP++;
+ }
_iP++; // string terminator
_scriptStream->seek(_iP);
@@ -489,12 +531,14 @@ bool ScScript::executeInstruction() {
dw = getDWORD();
if (_scopeStack->_sP < 0) {
_globals->setProp(_symbols[dw], _operand);
- if (_gameRef->getDebugMgr()->_enabled)
+ if (_gameRef->getDebugMgr()->_enabled) {
_gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]);
+ }
} else {
_scopeStack->getTop()->setProp(_symbols[dw], _operand);
- if (_gameRef->getDebugMgr()->_enabled)
+ if (_gameRef->getDebugMgr()->_enabled) {
_gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]);
+ }
}
break;
@@ -508,8 +552,9 @@ bool ScScript::executeInstruction() {
_operand->setNULL();
_engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR);
- if (_gameRef->getDebugMgr()->_enabled)
+ if (_gameRef->getDebugMgr()->_enabled) {
_gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]);
+ }
}
break;
}
@@ -521,14 +566,20 @@ bool ScScript::executeInstruction() {
_scopeStack->pop();
_iP = (uint32)_callStack->pop()->getInt();
- if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL);
- else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop());
+ if (_scopeStack->_sP < 0) {
+ _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL);
+ } else {
+ _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop());
+ }
} else {
if (_thread) {
_state = SCRIPT_THREAD_FINISHED;
} else {
- if (_numEvents == 0 && _numMethods == 0) _state = SCRIPT_FINISHED;
- else _state = SCRIPT_PERSISTENT;
+ if (_numEvents == 0 && _numMethods == 0) {
+ _state = SCRIPT_FINISHED;
+ } else {
+ _state = SCRIPT_PERSISTENT;
+ }
}
}
@@ -557,7 +608,9 @@ bool ScScript::executeInstruction() {
strcpy(MethodName, str);
ScValue *var = _stack->pop();
- if (var->_type == VAL_VARIABLE_REF) var = var->_valRef;
+ if (var->_type == VAL_VARIABLE_REF) {
+ var = var->_valRef;
+ }
bool res = STATUS_FAILED;
bool TriedNative = false;
@@ -612,7 +665,9 @@ bool ScScript::executeInstruction() {
*/
else {
res = STATUS_FAILED;
- if (var->_type == VAL_NATIVE && !TriedNative) res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName);
+ if (var->_type == VAL_NATIVE && !TriedNative) {
+ res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName);
+ }
if (DID_FAIL(res)) {
_stack->correctParams(0);
@@ -631,7 +686,9 @@ bool ScScript::executeInstruction() {
TExternalFunction *f = getExternal(_symbols[SymbolIndex]);
if (f) {
externalCall(_stack, _thisStack, f);
- } else _gameRef->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]);
+ } else {
+ _gameRef->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]);
+ }
break;
}
@@ -639,8 +696,11 @@ bool ScScript::executeInstruction() {
_operand->setNULL();
_scopeStack->push(_operand);
- if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL);
- else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop());
+ if (_scopeStack->_sP < 0) {
+ _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL);
+ } else {
+ _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop());
+ }
break;
@@ -663,7 +723,9 @@ bool ScScript::executeInstruction() {
if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) {
_operand->setReference(var);
_stack->push(_operand);
- } else _stack->push(var);
+ } else {
+ _stack->push(var);
+ }
break;
}
@@ -683,15 +745,19 @@ bool ScScript::executeInstruction() {
runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum.");
var->setNULL();
} else {
- if (val->getType() == VAL_VARIABLE_REF) val = val->_valRef;
- if (val->_type == VAL_NATIVE) var->setValue(val);
- else {
+ if (val->getType() == VAL_VARIABLE_REF) {
+ val = val->_valRef;
+ }
+ if (val->_type == VAL_NATIVE) {
+ var->setValue(val);
+ } else {
var->copy(val);
}
}
- if (_gameRef->getDebugMgr()->_enabled)
+ if (_gameRef->getDebugMgr()->_enabled) {
_gameRef->getDebugMgr()->onVariableChangeValue(var, val);
+ }
}
break;
@@ -740,8 +806,11 @@ bool ScScript::executeInstruction() {
case II_PUSH_BY_EXP: {
str = _stack->pop()->getString();
ScValue *val = _stack->pop()->getProp(str);
- if (val) _stack->push(val);
- else _stack->pushNULL();
+ if (val) {
+ _stack->push(val);
+ } else {
+ _stack->pushNULL();
+ }
break;
}
@@ -754,10 +823,13 @@ bool ScScript::executeInstruction() {
if (val == NULL) {
runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum.");
var->setNULL();
- } else var->setProp(str, val);
+ } else {
+ var->setProp(str, val);
+ }
- if (_gameRef->getDebugMgr()->_enabled)
+ if (_gameRef->getDebugMgr()->_enabled) {
_gameRef->getDebugMgr()->onVariableChangeValue(var, NULL);
+ }
break;
}
@@ -781,7 +853,9 @@ bool ScScript::executeInstruction() {
if (!val) {
runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?");
} else {
- if (!val->getBool()) _iP = dw;
+ if (!val->getBool()) {
+ _iP = dw;
+ }
}
break;
}
@@ -790,17 +864,19 @@ bool ScScript::executeInstruction() {
op2 = _stack->pop();
op1 = _stack->pop();
- if (op1->isNULL() || op2->isNULL())
+ if (op1->isNULL() || op2->isNULL()) {
_operand->setNULL();
- else if (op1->getType() == VAL_STRING || op2->getType() == VAL_STRING) {
+ } else if (op1->getType() == VAL_STRING || op2->getType() == VAL_STRING) {
char *tempStr = new char [strlen(op1->getString()) + strlen(op2->getString()) + 1];
strcpy(tempStr, op1->getString());
strcat(tempStr, op2->getString());
_operand->setString(tempStr);
delete[] tempStr;
- } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT)
+ } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) {
_operand->setInt(op1->getInt() + op2->getInt());
- else _operand->setFloat(op1->getFloat() + op2->getFloat());
+ } else {
+ _operand->setFloat(op1->getFloat() + op2->getFloat());
+ }
_stack->push(_operand);
@@ -810,11 +886,13 @@ bool ScScript::executeInstruction() {
op2 = _stack->pop();
op1 = _stack->pop();
- if (op1->isNULL() || op2->isNULL())
+ if (op1->isNULL() || op2->isNULL()) {
_operand->setNULL();
- else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT)
+ } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) {
_operand->setInt(op1->getInt() - op2->getInt());
- else _operand->setFloat(op1->getFloat() - op2->getFloat());
+ } else {
+ _operand->setFloat(op1->getFloat() - op2->getFloat());
+ }
_stack->push(_operand);
@@ -824,10 +902,13 @@ bool ScScript::executeInstruction() {
op2 = _stack->pop();
op1 = _stack->pop();
- if (op1->isNULL() || op2->isNULL()) _operand->setNULL();
- else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT)
+ 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());
+ } else {
+ _operand->setFloat(op1->getFloat() * op2->getFloat());
+ }
_stack->push(_operand);
@@ -837,11 +918,15 @@ bool ScScript::executeInstruction() {
op2 = _stack->pop();
op1 = _stack->pop();
- if (op2->getFloat() == 0.0f)
+ 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());
+ if (op1->isNULL() || op2->isNULL() || op2->getFloat() == 0.0f) {
+ _operand->setNULL();
+ } else {
+ _operand->setFloat(op1->getFloat() / op2->getFloat());
+ }
_stack->push(_operand);
@@ -851,12 +936,15 @@ bool ScScript::executeInstruction() {
op2 = _stack->pop();
op1 = _stack->pop();
- if (op2->getInt() == 0)
+ if (op2->getInt() == 0) {
runtimeError("Division by zero.");
+ }
- if (op1->isNULL() || op2->isNULL() || op2->getInt() == 0)
+ if (op1->isNULL() || op2->isNULL() || op2->getInt() == 0) {
_operand->setNULL();
- else _operand->setInt(op1->getInt() % op2->getInt());
+ } else {
+ _operand->setInt(op1->getInt() % op2->getInt());
+ }
_stack->push(_operand);
@@ -865,8 +953,11 @@ bool ScScript::executeInstruction() {
case II_NOT:
op1 = _stack->pop();
//if (op1->isNULL()) _operand->setNULL();
- if (op1->isNULL()) _operand->setBool(true);
- else _operand->setBool(!op1->getBool());
+ if (op1->isNULL()) {
+ _operand->setBool(true);
+ } else {
+ _operand->setBool(!op1->getBool());
+ }
_stack->push(_operand);
break;
@@ -1060,8 +1151,9 @@ bool ScScript::executeInstruction() {
//////////////////////////////////////////////////////////////////////////
uint32 ScScript::getFuncPos(const char *name) {
for (uint32 i = 0; i < _numFunctions; i++) {
- if (strcmp(name, _functions[i].name) == 0)
+ if (strcmp(name, _functions[i].name) == 0) {
return _functions[i].pos;
+ }
}
return 0;
}
@@ -1070,8 +1162,9 @@ uint32 ScScript::getFuncPos(const char *name) {
//////////////////////////////////////////////////////////////////////////
uint32 ScScript::getMethodPos(const char *name) {
for (uint32 i = 0; i < _numMethods; i++) {
- if (strcmp(name, _methods[i].name) == 0)
+ if (strcmp(name, _methods[i].name) == 0) {
return _methods[i].pos;
+ }
}
return 0;
}
@@ -1083,20 +1176,23 @@ ScValue *ScScript::getVar(char *name) {
// scope locals
if (_scopeStack->_sP >= 0) {
- if (_scopeStack->getTop()->propExists(name))
+ if (_scopeStack->getTop()->propExists(name)) {
ret = _scopeStack->getTop()->getProp(name);
+ }
}
// script globals
if (ret == NULL) {
- if (_globals->propExists(name))
+ if (_globals->propExists(name)) {
ret = _globals->getProp(name);
+ }
}
// engine globals
if (ret == NULL) {
- if (_engine->_globals->propExists(name))
+ if (_engine->_globals->propExists(name)) {
ret = _engine->_globals->getProp(name);
+ }
}
if (ret == NULL) {
@@ -1162,7 +1258,9 @@ bool ScScript::finish(bool includingThreads) {
if (_state != SCRIPT_FINISHED && includingThreads) {
_state = SCRIPT_FINISHED;
finishThreads();
- } else _state = SCRIPT_FINISHED;
+ } else {
+ _state = SCRIPT_FINISHED;
+ }
return STATUS_OK;
@@ -1188,8 +1286,9 @@ void ScScript::runtimeError(const char *fmt, ...) {
_gameRef->LOG(0, "Runtime error. Script '%s', line %d", _filename, _currentLine);
_gameRef->LOG(0, " %s", buff);
- if (!_gameRef->_suppressScriptErrors)
+ if (!_gameRef->_suppressScriptErrors) {
_gameRef->quickMessage("Script runtime error. View log for details.");
+ }
}
@@ -1217,8 +1316,8 @@ bool ScScript::persist(BasePersistenceManager *persistMgr) {
initTables();
} else {
_buffer = NULL;
- _scriptStream = NULL;
- }
+ _scriptStream = NULL;
+ }
}
persistMgr->transfer(TMEMBER(_callStack));
@@ -1249,7 +1348,9 @@ bool ScScript::persist(BasePersistenceManager *persistMgr) {
persistMgr->transfer(TMEMBER(_unbreakable));
persistMgr->transfer(TMEMBER(_parentScript));
- if (!persistMgr->getIsSaving()) _tracingMode = false;
+ if (!persistMgr->getIsSaving()) {
+ _tracingMode = false;
+ }
return STATUS_OK;
}
@@ -1260,7 +1361,9 @@ ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable)
//if (_state!=SCRIPT_PERSISTENT) return NULL;
uint32 pos = getEventPos(eventName);
- if (!pos) return NULL;
+ if (!pos) {
+ return NULL;
+ }
ScScript *thread = new ScScript(_gameRef, _engine);
if (thread) {
@@ -1274,7 +1377,9 @@ ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable)
delete thread;
return NULL;
}
- } else return NULL;
+ } else {
+ return NULL;
+ }
}
@@ -1282,7 +1387,9 @@ ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable)
//////////////////////////////////////////////////////////////////////////
uint32 ScScript::getEventPos(const char *name) {
for (int i = _numEvents - 1; i >= 0; i--) {
- if (scumm_stricmp(name, _events[i].name) == 0) return _events[i].pos;
+ if (scumm_stricmp(name, _events[i].name) == 0) {
+ return _events[i].pos;
+ }
}
return 0;
}
@@ -1307,7 +1414,9 @@ bool ScScript::pause() {
return STATUS_FAILED;
}
- if (!_freezable || _state == SCRIPT_PERSISTENT) return STATUS_OK;
+ if (!_freezable || _state == SCRIPT_PERSISTENT) {
+ return STATUS_OK;
+ }
_origState = _state;
_state = SCRIPT_PAUSED;
@@ -1318,7 +1427,9 @@ bool ScScript::pause() {
//////////////////////////////////////////////////////////////////////////
bool ScScript::resume() {
- if (_state != SCRIPT_PAUSED) return STATUS_OK;
+ if (_state != SCRIPT_PAUSED) {
+ return STATUS_OK;
+ }
_state = _origState;
return STATUS_OK;
@@ -1328,8 +1439,9 @@ bool ScScript::resume() {
//////////////////////////////////////////////////////////////////////////
ScScript::TExternalFunction *ScScript::getExternal(char *name) {
for (uint32 i = 0; i < _numExternals; i++) {
- if (strcmp(name, _externals[i].name) == 0)
+ if (strcmp(name, _externals[i].name) == 0) {
return &_externals[i];
+ }
}
return NULL;
}
@@ -1354,7 +1466,9 @@ bool ScScript::copyParameters(ScStack *stack) {
}
_stack->pushInt(NumParams);
- for (i = 0; i < NumParams; i++) stack->pop();
+ for (i = 0; i < NumParams; i++) {
+ stack->pop();
+ }
return STATUS_OK;
}
@@ -1364,8 +1478,9 @@ bool ScScript::copyParameters(ScStack *stack) {
bool ScScript::finishThreads() {
for (int i = 0; i < _engine->_scripts.getSize(); i++) {
ScScript *scr = _engine->_scripts[i];
- if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0)
+ if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) {
scr->finish(true);
+ }
}
return STATUS_OK;
}
@@ -1385,9 +1500,13 @@ const char *ScScript::dbgGetFilename() {
//////////////////////////////////////////////////////////////////////////
bool ScScript::dbgSendScript(IWmeDebugClient *client) {
- if (_methodThread) client->onScriptMethodThreadInit(this, _parentScript, _threadEvent);
- else if (_thread) client->onScriptEventThreadInit(this, _parentScript, _threadEvent);
- else client->onScriptInit(this);
+ if (_methodThread) {
+ client->onScriptMethodThreadInit(this, _parentScript, _threadEvent);
+ } else if (_thread) {
+ client->onScriptEventThreadInit(this, _parentScript, _threadEvent);
+ } else {
+ client->onScriptInit(this);
+ }
return dbgSendVariables(client);
return STATUS_OK;
@@ -1421,8 +1540,11 @@ int ScScript::dbgGetNumBreakpoints() {
//////////////////////////////////////////////////////////////////////////
int ScScript::dbgGetBreakpoint(int index) {
- if (index >= 0 && index < _breakpoints.getSize()) return _breakpoints[index];
- else return -1;
+ if (index >= 0 && index < _breakpoints.getSize()) {
+ return _breakpoints[index];
+ } else {
+ return -1;
+ }
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp
index 792dfd4589..356617094d 100644
--- a/engines/wintermute/base/scriptables/script_engine.cpp
+++ b/engines/wintermute/base/scriptables/script_engine.cpp
@@ -47,8 +47,11 @@ IMPLEMENT_PERSISTENT(ScEngine, true)
ScEngine::ScEngine(BaseGame *inGame): BaseClass(inGame) {
_gameRef->LOG(0, "Initializing scripting engine...");
- if (_compilerAvailable) _gameRef->LOG(0, " Script compiler bound successfuly");
- else _gameRef->LOG(0, " Script compiler is NOT available");
+ if (_compilerAvailable) {
+ _gameRef->LOG(0, " Script compiler bound successfuly");
+ } else {
+ _gameRef->LOG(0, " Script compiler is NOT available");
+ }
_globals = new ScValue(_gameRef);
@@ -68,7 +71,9 @@ ScEngine::ScEngine(BaseGame *inGame): BaseClass(inGame) {
}
// prepare script cache
- for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) _cachedScripts[i] = NULL;
+ for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) {
+ _cachedScripts[i] = NULL;
+ }
_currentScript = NULL;
@@ -99,7 +104,9 @@ ScEngine::~ScEngine() {
//////////////////////////////////////////////////////////////////////////
bool ScEngine::cleanup() {
for (int i = 0; i < _scripts.getSize(); i++) {
- if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]);
+ if (!_scripts[i]->_thread && _scripts[i]->_owner) {
+ _scripts[i]->_owner->removeScript(_scripts[i]);
+ }
delete _scripts[i];
_scripts.removeAt(i);
i--;
@@ -143,7 +150,9 @@ ScScript *ScEngine::runScript(const char *filename, BaseScriptHolder *owner) {
// get script from cache
compBuffer = getCompiledScript(filename, &compSize);
- if (!compBuffer) return NULL;
+ if (!compBuffer) {
+ return NULL;
+ }
// add new script
ScScript *script = new ScScript(_gameRef, this);
@@ -155,8 +164,11 @@ ScScript *ScEngine::runScript(const char *filename, BaseScriptHolder *owner) {
} else {
// publish the "self" pseudo-variable
ScValue val(_gameRef);
- if (owner)val.setNative(owner, true);
- else val.setNULL();
+ if (owner) {
+ val.setNative(owner, true);
+ } else {
+ val.setNULL();
+ }
script->_globals->setProp("self", &val);
script->_globals->setProp("this", &val);
@@ -226,7 +238,9 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig
}
}
- if (_cachedScripts[index] != NULL) delete _cachedScripts[index];
+ if (_cachedScripts[index] != NULL) {
+ delete _cachedScripts[index];
+ }
_cachedScripts[index] = cachedScript;
ret = cachedScript->_buffer;
@@ -244,8 +258,9 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig
//////////////////////////////////////////////////////////////////////////
bool ScEngine::tick() {
- if (_scripts.getSize() == 0)
+ if (_scripts.getSize() == 0) {
return STATUS_OK;
+ }
// resolve waiting scripts
@@ -267,16 +282,24 @@ bool ScEngine::tick() {
if (!obj_found) _scripts[i]->finish(); // _waitObject no longer exists
*/
if (_gameRef->validObject(_scripts[i]->_waitObject)) {
- if (_scripts[i]->_waitObject->isReady()) _scripts[i]->run();
- } else _scripts[i]->finish();
+ if (_scripts[i]->_waitObject->isReady()) {
+ _scripts[i]->run();
+ }
+ } else {
+ _scripts[i]->finish();
+ }
break;
}
case SCRIPT_SLEEPING: {
if (_scripts[i]->_waitFrozen) {
- if (_scripts[i]->_waitTime <= g_system->getMillis()) _scripts[i]->run();
+ if (_scripts[i]->_waitTime <= g_system->getMillis()) {
+ _scripts[i]->run();
+ }
} else {
- if (_scripts[i]->_waitTime <= _gameRef->_timer) _scripts[i]->run();
+ if (_scripts[i]->_waitTime <= _gameRef->_timer) {
+ _scripts[i]->run();
+ }
}
break;
}
@@ -309,7 +332,9 @@ bool ScEngine::tick() {
for (int i = 0; i < _scripts.getSize(); i++) {
// skip paused scripts
- if (_scripts[i]->_state == SCRIPT_PAUSED) continue;
+ if (_scripts[i]->_state == SCRIPT_PAUSED) {
+ continue;
+ }
// time sliced script
if (_scripts[i]->_timeSlice > 0) {
@@ -318,20 +343,26 @@ bool ScEngine::tick() {
_currentScript = _scripts[i];
_scripts[i]->executeInstruction();
}
- if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, g_system->getMillis() - StartTime);
+ if (_isProfiling && _scripts[i]->_filename) {
+ addScriptTime(_scripts[i]->_filename, g_system->getMillis() - StartTime);
+ }
}
// normal script
else {
uint32 startTime = 0;
bool isProfiling = _isProfiling;
- if (isProfiling) startTime = g_system->getMillis();
+ if (isProfiling) {
+ startTime = g_system->getMillis();
+ }
while (_scripts[i]->_state == SCRIPT_RUNNING) {
_currentScript = _scripts[i];
_scripts[i]->executeInstruction();
}
- if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, g_system->getMillis() - startTime);
+ if (isProfiling && _scripts[i]->_filename) {
+ addScriptTime(_scripts[i]->_filename, g_system->getMillis() - startTime);
+ }
}
_currentScript = NULL;
}
@@ -346,7 +377,9 @@ bool ScEngine::tick() {
bool ScEngine::tickUnbreakable() {
// execute unbreakable scripts
for (int i = 0; i < _scripts.getSize(); i++) {
- if (!_scripts[i]->_unbreakable) continue;
+ if (!_scripts[i]->_unbreakable) {
+ continue;
+ }
while (_scripts[i]->_state == SCRIPT_RUNNING) {
_currentScript = _scripts[i];
@@ -366,7 +399,9 @@ bool ScEngine::removeFinishedScripts() {
// remove finished scripts
for (int i = 0; i < _scripts.getSize(); i++) {
if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) {
- if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]);
+ if (!_scripts[i]->_thread && _scripts[i]->_owner) {
+ _scripts[i]->_owner->removeScript(_scripts[i]);
+ }
_gameRef->getDebugMgr()->onScriptShutdown(_scripts[i]);
delete _scripts[i];
_scripts.removeAt(i);
@@ -382,7 +417,9 @@ int ScEngine::getNumScripts(int *running, int *waiting, int *persistent) {
int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0;
for (int i = 0; i < _scripts.getSize(); i++) {
- if (_scripts[i]->_state == SCRIPT_FINISHED) continue;
+ if (_scripts[i]->_state == SCRIPT_FINISHED) {
+ continue;
+ }
switch (_scripts[i]->_state) {
case SCRIPT_RUNNING:
case SCRIPT_SLEEPING:
@@ -401,9 +438,15 @@ int ScEngine::getNumScripts(int *running, int *waiting, int *persistent) {
}
numTotal++;
}
- if (running) *running = numRunning;
- if (waiting) *waiting = numWaiting;
- if (persistent) *persistent = numPersistent;
+ if (running) {
+ *running = numRunning;
+ }
+ if (waiting) {
+ *waiting = numWaiting;
+ }
+ if (persistent) {
+ *persistent = numPersistent;
+ }
return numTotal;
}
@@ -426,7 +469,9 @@ bool ScEngine::resetObject(BaseObject *Object) {
// terminate all scripts waiting for this object
for (int i = 0; i < _scripts.getSize(); i++) {
if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) {
- if (!_gameRef->_compatKillMethodThreads) resetScript(_scripts[i]);
+ if (!_gameRef->_compatKillMethodThreads) {
+ resetScript(_scripts[i]);
+ }
bool IsThread = _scripts[i]->_methodThread || _scripts[i]->_thread;
_scripts[i]->finish(!IsThread); // 1.9b1 - top-level script kills its threads as well
@@ -448,7 +493,9 @@ bool ScEngine::resetScript(ScScript *script) {
//////////////////////////////////////////////////////////////////////////
bool ScEngine::persist(BasePersistenceManager *persistMgr) {
- if (!persistMgr->getIsSaving()) cleanup();
+ if (!persistMgr->getIsSaving()) {
+ cleanup();
+ }
persistMgr->transfer(TMEMBER(_gameRef));
persistMgr->transfer(TMEMBER(_currentScript));
@@ -474,7 +521,9 @@ void ScEngine::editorCleanup() {
//////////////////////////////////////////////////////////////////////////
bool ScEngine::pauseAll() {
for (int i = 0; i < _scripts.getSize(); i++) {
- if (_scripts[i] != _currentScript) _scripts[i]->pause();
+ if (_scripts[i] != _currentScript) {
+ _scripts[i]->pause();
+ }
}
return STATUS_OK;
@@ -483,8 +532,9 @@ bool ScEngine::pauseAll() {
//////////////////////////////////////////////////////////////////////////
bool ScEngine::resumeAll() {
- for (int i = 0; i < _scripts.getSize(); i++)
+ for (int i = 0; i < _scripts.getSize(); i++) {
_scripts[i]->resume();
+ }
return STATUS_OK;
}
@@ -493,7 +543,9 @@ bool ScEngine::resumeAll() {
//////////////////////////////////////////////////////////////////////////
bool ScEngine::isValidScript(ScScript *script) {
for (int i = 0; i < _scripts.getSize(); i++) {
- if (_scripts[i] == script) return true;
+ if (_scripts[i] == script) {
+ return true;
+ }
}
return false;
}
@@ -511,14 +563,17 @@ bool ScEngine::dbgSendScripts(IWmeDebugClient *client) {
// process normal scripts first
for (int i = 0; i < _scripts.getSize(); i++) {
- if (_scripts[i]->_thread || _scripts[i]->_methodThread) continue;
+ if (_scripts[i]->_thread || _scripts[i]->_methodThread) {
+ continue;
+ }
_scripts[i]->dbgSendScript(client);
}
// and threads later
for (int i = 0; i < _scripts.getSize(); i++) {
- if (_scripts[i]->_thread || _scripts[i]->_methodThread)
+ if (_scripts[i]->_thread || _scripts[i]->_methodThread) {
_scripts[i]->dbgSendScript(client);
+ }
}
return STATUS_OK;
@@ -526,7 +581,9 @@ bool ScEngine::dbgSendScripts(IWmeDebugClient *client) {
//////////////////////////////////////////////////////////////////////////
bool ScEngine::addBreakpoint(const char *scriptFilename, int line) {
- if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK;
+ if (!_gameRef->getDebugMgr()->_enabled) {
+ return STATUS_OK;
+ }
CScBreakpoint *bp = NULL;
for (int i = 0; i < _breakpoints.getSize(); i++) {
@@ -541,7 +598,9 @@ bool ScEngine::addBreakpoint(const char *scriptFilename, int line) {
}
for (int i = 0; i < bp->_lines.getSize(); i++) {
- if (bp->_lines[i] == line) return STATUS_OK;
+ if (bp->_lines[i] == line) {
+ return STATUS_OK;
+ }
}
bp->_lines.add(line);
@@ -553,7 +612,9 @@ bool ScEngine::addBreakpoint(const char *scriptFilename, int line) {
//////////////////////////////////////////////////////////////////////////
bool ScEngine::removeBreakpoint(const char *scriptFilename, int line) {
- if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK;
+ if (!_gameRef->getDebugMgr()->_enabled) {
+ return STATUS_OK;
+ }
for (int i = 0; i < _breakpoints.getSize(); i++) {
if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) {
@@ -578,7 +639,9 @@ bool ScEngine::removeBreakpoint(const char *scriptFilename, int line) {
//////////////////////////////////////////////////////////////////////////
bool ScEngine::refreshScriptBreakpoints() {
- if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK;
+ if (!_gameRef->getDebugMgr()->_enabled) {
+ return STATUS_OK;
+ }
for (int i = 0; i < _scripts.getSize(); i++) {
refreshScriptBreakpoints(_scripts[i]);
@@ -588,9 +651,13 @@ bool ScEngine::refreshScriptBreakpoints() {
//////////////////////////////////////////////////////////////////////////
bool ScEngine::refreshScriptBreakpoints(ScScript *script) {
- if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK;
+ if (!_gameRef->getDebugMgr()->_enabled) {
+ return STATUS_OK;
+ }
- if (!script || !script->_filename) return STATUS_FAILED;
+ if (!script || !script->_filename) {
+ return STATUS_FAILED;
+ }
for (int i = 0; i < _breakpoints.getSize(); i++) {
if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), script->_filename) == 0) {
@@ -598,14 +665,18 @@ bool ScEngine::refreshScriptBreakpoints(ScScript *script) {
return STATUS_OK;
}
}
- if (script->_breakpoints.getSize() > 0) script->_breakpoints.removeAll();
+ if (script->_breakpoints.getSize() > 0) {
+ script->_breakpoints.removeAll();
+ }
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
bool ScEngine::saveBreakpoints() {
- if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK;
+ if (!_gameRef->getDebugMgr()->_enabled) {
+ return STATUS_OK;
+ }
char text[512];
@@ -628,7 +699,9 @@ bool ScEngine::saveBreakpoints() {
//////////////////////////////////////////////////////////////////////////
bool ScEngine::loadBreakpoints() {
- if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK;
+ if (!_gameRef->getDebugMgr()->_enabled) {
+ return STATUS_OK;
+ }
char key[100];
@@ -641,7 +714,9 @@ bool ScEngine::loadBreakpoints() {
char *path = BaseUtils::strEntry(0, breakpoint.c_str(), ':');
char *line = BaseUtils::strEntry(1, breakpoint.c_str(), ':');
- if (path != NULL && line != NULL) addBreakpoint(path, atoi(line));
+ if (path != NULL && line != NULL) {
+ addBreakpoint(path, atoi(line));
+ }
delete[] path;
delete[] line;
path = NULL;
@@ -654,7 +729,9 @@ bool ScEngine::loadBreakpoints() {
//////////////////////////////////////////////////////////////////////////
void ScEngine::addScriptTime(const char *filename, uint32 time) {
- if (!_isProfiling) return;
+ if (!_isProfiling) {
+ return;
+ }
AnsiString fileName = filename;
fileName.toLowercase();
@@ -664,7 +741,9 @@ void ScEngine::addScriptTime(const char *filename, uint32 time) {
//////////////////////////////////////////////////////////////////////////
void ScEngine::enableProfiling() {
- if (_isProfiling) return;
+ if (_isProfiling) {
+ return;
+ }
// destroy old data, if any
_scriptTimes.clear();
@@ -676,7 +755,9 @@ void ScEngine::enableProfiling() {
//////////////////////////////////////////////////////////////////////////
void ScEngine::disableProfiling() {
- if (!_isProfiling) return;
+ if (!_isProfiling) {
+ return;
+ }
dumpStats();
_isProfiling = false;
diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h
index e443ec5832..fc441347df 100644
--- a/engines/wintermute/base/scriptables/script_engine.h
+++ b/engines/wintermute/base/scriptables/script_engine.h
@@ -48,13 +48,17 @@ public:
CScCachedScript(const char *filename, byte *buffer, uint32 size) {
_timestamp = g_system->getMillis();
_buffer = new byte[size];
- if (_buffer) memcpy(_buffer, buffer, size);
+ if (_buffer) {
+ memcpy(_buffer, buffer, size);
+ }
_size = size;
_filename = filename;
};
~CScCachedScript() {
- if (_buffer) delete[] _buffer;
+ if (_buffer) {
+ delete[] _buffer;
+ }
};
uint32 _timestamp;
diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp
index 41059b2d80..0380103cd4 100644
--- a/engines/wintermute/base/scriptables/script_ext_array.cpp
+++ b/engines/wintermute/base/scriptables/script_ext_array.cpp
@@ -47,8 +47,9 @@ SXArray::SXArray(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) {
int numParams = stack->pop()->getInt(0);
- if (numParams == 1) _length = stack->pop()->getInt(0);
- else if (numParams > 1) {
+ if (numParams == 1) {
+ _length = stack->pop()->getInt(0);
+ } else if (numParams > 1) {
_length = numParams;
char paramName[20];
for (int i = 0; i < numParams; i++) {
@@ -86,7 +87,9 @@ const char *SXArray::scToString() {
}
}
- if (i < _length - 1 && strlen(dummy) + 1 < 32768) strcat(dummy, ",");
+ if (i < _length - 1 && strlen(dummy) + 1 < 32768) {
+ strcat(dummy, ",");
+ }
}
return dummy;
}
@@ -124,12 +127,14 @@ bool SXArray::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
stack->push(_values->getProp(paramName));
_values->deleteProp(paramName);
_length--;
- } else stack->pushNULL();
+ } else {
+ stack->pushNULL();
+ }
return STATUS_OK;
+ } else {
+ return STATUS_FAILED;
}
-
- else return STATUS_FAILED;
}
@@ -160,7 +165,9 @@ ScValue *SXArray::scGetProperty(const char *name) {
char ParamName[20];
if (validNumber(name, ParamName)) {
return _values->getProp(ParamName);
- } else return _scValue;
+ } else {
+ return _scValue;
+ }
}
}
@@ -190,10 +197,14 @@ bool SXArray::scSetProperty(const char *name, ScValue *value) {
else {
char paramName[20];
if (validNumber(name, paramName)) {
- int Index = atoi(paramName);
- if (Index >= _length) _length = Index + 1;
+ int index = atoi(paramName);
+ if (index >= _length) {
+ _length = index + 1;
+ }
return _values->setProp(paramName, value);
- } else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
}
}
@@ -223,7 +234,9 @@ bool SXArray::validNumber(const char *origStr, char *outStr) {
int index = atoi(origStr);
sprintf(outStr, "%d", index);
return true;
- } else return false;
+ } else {
+ return false;
+ }
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/wintermute/base/scriptables/script_ext_array.h b/engines/wintermute/base/scriptables/script_ext_array.h
index 8eb86c4e69..67a1104b46 100644
--- a/engines/wintermute/base/scriptables/script_ext_array.h
+++ b/engines/wintermute/base/scriptables/script_ext_array.h
@@ -35,7 +35,7 @@ namespace WinterMute {
class SXArray : public BaseScriptable {
public:
- bool push(ScValue *Val);
+ bool push(ScValue *val);
bool validNumber(const char *origStr, char *outStr);
DECLARE_PERSISTENT(SXArray, BaseScriptable)
SXArray(BaseGame *inGame, ScStack *stack);
diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp
index d2fd3663c7..a3bb7e2183 100644
--- a/engines/wintermute/base/scriptables/script_ext_date.cpp
+++ b/engines/wintermute/base/scriptables/script_ext_date.cpp
@@ -199,10 +199,9 @@ bool SXDate::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
g_system->getTimeAndDate(_tm);
stack->pushNULL();
return STATUS_OK;
- }
-
- else
+ } else {
return STATUS_FAILED;
+ }
}
@@ -216,9 +215,9 @@ ScValue *SXDate::scGetProperty(const char *name) {
if (strcmp(name, "Type") == 0) {
_scValue->setString("date");
return _scValue;
+ } else {
+ return _scValue;
}
-
- else return _scValue;
}
diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp
index 7da1601bdc..437fbb64a2 100644
--- a/engines/wintermute/base/scriptables/script_ext_file.cpp
+++ b/engines/wintermute/base/scriptables/script_ext_file.cpp
@@ -51,10 +51,12 @@ BaseScriptable *makeSXFile(BaseGame *inGame, ScStack *stack) {
//////////////////////////////////////////////////////////////////////////
SXFile::SXFile(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) {
stack->correctParams(1);
- ScValue *Val = stack->pop();
+ ScValue *val = stack->pop();
_filename = NULL;
- if (!Val->isNULL()) BaseUtils::setString(&_filename, Val->getString());
+ if (!val->isNULL()) {
+ BaseUtils::setString(&_filename, val->getString());
+ }
_readFile = NULL;
_writeFile = NULL;
@@ -94,8 +96,11 @@ void SXFile::close() {
//////////////////////////////////////////////////////////////////////////
const char *SXFile::scToString() {
- if (_filename) return _filename;
- else return "[file object]";
+ if (_filename) {
+ return _filename;
+ } else {
+ return "[file object]";
+ }
}
#define FILE_BUFFER_SIZE 32768
@@ -129,24 +134,37 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
if (!_readFile) {
//script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename);
close();
- } else _textMode = strcmp(name, "OpenAsText") == 0;
+ } else {
+ _textMode = strcmp(name, "OpenAsText") == 0;
+ }
} else {
if (strcmp(name, "OpenAsText") == 0) {
- if (_mode == 2) _writeFile = openForWrite(_filename, false);
- else _writeFile = openForAppend(_filename, false);
+ if (_mode == 2) {
+ _writeFile = openForWrite(_filename, false);
+ } else {
+ _writeFile = openForAppend(_filename, false);
+ }
} else {
- if (_mode == 2) _writeFile = openForWrite(_filename, true);
- else _writeFile = openForAppend(_filename, true);
+ if (_mode == 2) {
+ _writeFile = openForWrite(_filename, true);
+ } else {
+ _writeFile = openForAppend(_filename, true);
+ }
}
if (!_writeFile) {
//script->runtimeError("File.%s: Error opening file '%s' for writing.", Name, _filename);
close();
- } else _textMode = strcmp(name, "OpenAsText") == 0;
+ } 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 STATUS_OK;
}
@@ -221,7 +239,9 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
bool ret = STATUS_FAILED;
do {
ret = _readFile->read(&b, 1);
- if (ret != 1) break;
+ if (ret != 1) {
+ break;
+ }
if (counter > bufSize) {
buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE);
@@ -231,8 +251,9 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
buf[counter] = '\0';
foundNewLine = true;
break;
- } else if (b == 0x0D) continue;
- else {
+ } else if (b == 0x0D) {
+ continue;
+ } else {
buf[counter] = b;
counter++;
}
@@ -244,8 +265,11 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
}
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);
@@ -272,14 +296,17 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
bool ret = STATUS_FAILED;
while (counter < (uint32)textLen) {
ret = _readFile->read(&b, 1);
- if (ret != 1) break;
+ if (ret != 1) {
+ break;
+ }
if (counter > bufSize) {
buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE);
bufSize += FILE_BUFFER_SIZE;
}
- if (b == 0x0D) continue;
- else {
+ if (b == 0x0D) {
+ continue;
+ } else {
buf[counter] = b;
counter++;
}
@@ -291,8 +318,11 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
}
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);
@@ -335,8 +365,11 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
return STATUS_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 STATUS_OK;
}
@@ -355,8 +388,8 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
if (!_readFile->err()) {
stack->pushInt(val);
} else {
- stack->pushNULL();
- }
+ stack->pushNULL();
+ }
return STATUS_OK;
}
@@ -375,7 +408,7 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
if (!_readFile->err()) {
stack->pushInt(65536 + val);
} else {
- stack->pushNULL();
+ stack->pushNULL();
}
return STATUS_OK;
}
@@ -411,7 +444,7 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
return STATUS_OK;
}
float val;
- (*(uint32*)&val) = _readFile->readUint32LE();
+ (*(uint32 *)&val) = _readFile->readUint32LE();
if (!_readFile->err()) {
stack->pushFloat(val);
} else {
@@ -433,8 +466,11 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
return STATUS_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 STATUS_OK;
}
@@ -458,8 +494,12 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
stack->pushString((char *)str);
}
delete[] str;
- } else stack->pushNULL();
- } else stack->pushNULL();
+ } else {
+ stack->pushNULL();
+ }
+ } else {
+ stack->pushNULL();
+ }
return STATUS_OK;
}
@@ -548,7 +588,7 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
stack->pushBool(false);
return STATUS_OK;
}
- uint32 *ptr = (uint32*)&val;
+ uint32 *ptr = (uint32 *)&val;
_writeFile->writeUint32LE(*ptr);
stack->pushBool(true);
@@ -594,10 +634,9 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
stack->pushBool(true);
return STATUS_OK;
+ } else {
+ return BaseScriptable::scCallMethod(script, stack, thisStack, name);
}
-
-
- else return BaseScriptable::scCallMethod(script, stack, thisStack, name);
}
@@ -651,9 +690,9 @@ ScValue *SXFile::scGetProperty(const char *name) {
else if (strcmp(name, "AccessMode") == 0) {
_scValue->setInt(_mode);
return _scValue;
+ } else {
+ return BaseScriptable::scGetProperty(name);
}
-
- else return BaseScriptable::scGetProperty(name);
}
@@ -681,43 +720,46 @@ bool SXFile::scSetProperty(const char *name, ScValue *value) {
//////////////////////////////////////////////////////////////////////////
uint32 SXFile::getPos() {
- if (_mode == 1 && _readFile)
+ if (_mode == 1 && _readFile) {
return _readFile->pos();
- else if ((_mode == 2 || _mode == 3) && _writeFile) {
+ } else if ((_mode == 2 || _mode == 3) && _writeFile) {
error("SXFile - getPos for WriteFile not supported");
return 0;
// return ftell((FILE *)_writeFile);
- } else {
+ } else {
return 0;
}
}
//////////////////////////////////////////////////////////////////////////
bool SXFile::setPos(uint32 pos, int whence) {
- if (_mode == 1 && _readFile)
+ if (_mode == 1 && _readFile) {
return _readFile->seek(pos, whence);
- else if ((_mode == 2 || _mode == 3) && _writeFile) {
+ } else if ((_mode == 2 || _mode == 3) && _writeFile) {
error("SXFile - seeking in WriteFile not supported");
return false;
// return fseek((FILE *)_writeFile, pos, (int)origin) == 0;
+ } else {
+ return false;
}
- else return false;
}
//////////////////////////////////////////////////////////////////////////
uint32 SXFile::getLength() {
- if (_mode == 1 && _readFile)
+ if (_mode == 1 && _readFile) {
return _readFile->size();
- else if ((_mode == 2 || _mode == 3) && _writeFile) {
+ } else if ((_mode == 2 || _mode == 3) && _writeFile) {
error("SXFile - reading length for WriteFile not supported");
return 0;
-/*
- uint32 currentPos = ftell((FILE *)_writeFile);
- fseek((FILE *)_writeFile, 0, SEEK_END);
- int ret = ftell((FILE *)_writeFile);
- fseek((FILE *)_writeFile, CurrentPos, SEEK_SET);
- return Ret;*/
- } else return 0;
+ /*
+ uint32 currentPos = ftell((FILE *)_writeFile);
+ fseek((FILE *)_writeFile, 0, SEEK_END);
+ int ret = ftell((FILE *)_writeFile);
+ fseek((FILE *)_writeFile, CurrentPos, SEEK_SET);
+ return Ret;*/
+ } else {
+ return 0;
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -744,24 +786,28 @@ bool SXFile::persist(BasePersistenceManager *persistMgr) {
// open for reading
if (_mode == 1) {
_readFile = _gameRef->_fileManager->openFile(_filename);
- if (!_readFile)
+ if (!_readFile) {
close();
+ }
}
// open for writing / appending
else {
if (_textMode) {
- if (_mode == 2)
+ if (_mode == 2) {
_writeFile = openForWrite(_filename, false);
- else
+ } else {
_writeFile = openForAppend(_filename, false);
+ }
} else {
- if (_mode == 2)
+ if (_mode == 2) {
_writeFile = openForWrite(_filename, true);
- else
+ } else {
_writeFile = openForAppend(_filename, true);
+ }
}
- if (_writeFile)
+ if (_writeFile) {
close();
+ }
}
setPos(pos);
}
@@ -777,7 +823,7 @@ Common::WriteStream *SXFile::openForWrite(const Common::String &filename, bool b
// Should replace fopen(..., "ab+") and fopen(..., "a+")
Common::WriteStream *SXFile::openForAppend(const Common::String &filename, bool binary) {
- error("SXFile::openForAppend - WriteFiles not supported");
+ error("SXFile::openForAppend - WriteFiles not supported");
}
} // end of namespace WinterMute
diff --git a/engines/wintermute/base/scriptables/script_ext_math.cpp b/engines/wintermute/base/scriptables/script_ext_math.cpp
index 1c37a15aa9..525b43434f 100644
--- a/engines/wintermute/base/scriptables/script_ext_math.cpp
+++ b/engines/wintermute/base/scriptables/script_ext_math.cpp
@@ -243,9 +243,9 @@ bool SXMath::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
stack->correctParams(1);
stack->pushFloat(radianToDegree(stack->pop()->getFloat()));
return STATUS_OK;
+ } else {
+ return STATUS_FAILED;
}
-
- else return STATUS_FAILED;
}
@@ -267,9 +267,9 @@ ScValue *SXMath::scGetProperty(const char *name) {
else if (strcmp(name, "PI") == 0) {
_scValue->setFloat(M_PI);
return _scValue;
+ } else {
+ return _scValue;
}
-
- else return _scValue;
}
diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp
index 3d3f0b218b..e15af3446e 100644
--- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp
+++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp
@@ -70,7 +70,9 @@ void *SXMemBuffer::scToMemBuffer() {
//////////////////////////////////////////////////////////////////////////
void SXMemBuffer::cleanup() {
- if (_size) free(_buffer);
+ if (_size) {
+ free(_buffer);
+ }
_buffer = NULL;
_size = 0;
}
@@ -81,14 +83,18 @@ bool SXMemBuffer::resize(int newSize) {
if (_size == 0) {
_buffer = malloc(newSize);
- if (_buffer) _size = newSize;
+ if (_buffer) {
+ _size = newSize;
+ }
} else {
void *newBuf = realloc(_buffer, newSize);
if (!newBuf) {
if (newSize == 0) {
_buffer = newBuf;
_size = newSize;
- } else return STATUS_FAILED;
+ } else {
+ return STATUS_FAILED;
+ }
} else {
_buffer = newBuf;
_size = newSize;
@@ -107,14 +113,16 @@ bool SXMemBuffer::checkBounds(ScScript *script, int start, int length) {
script->runtimeError("Cannot use Set/Get methods on an uninitialized memory buffer");
return false;
}
- if (_size == 0)
+ if (_size == 0) {
return true;
+ }
if (start < 0 || length == 0 || start + length > _size) {
script->runtimeError("Set/Get method call is out of bounds");
return false;
- } else
+ } else {
return true;
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -132,10 +140,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
stack->correctParams(1);
int newSize = stack->pop()->getInt();
newSize = MAX(0, newSize);
- if (DID_SUCCEED(resize(newSize)))
+ if (DID_SUCCEED(resize(newSize))) {
stack->pushBool(true);
- else
+ } else {
stack->pushBool(false);
+ }
return STATUS_OK;
}
@@ -146,10 +155,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
else if (strcmp(name, "GetBool") == 0) {
stack->correctParams(1);
int start = stack->pop()->getInt();
- if (!checkBounds(script, start, sizeof(bool)))
+ if (!checkBounds(script, start, sizeof(bool))) {
stack->pushNULL();
- else
+ } else {
stack->pushBool(*(bool *)((byte *)_buffer + start));
+ }
return STATUS_OK;
}
@@ -160,10 +170,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
else if (strcmp(name, "GetByte") == 0) {
stack->correctParams(1);
int start = stack->pop()->getInt();
- if (!checkBounds(script, start, sizeof(byte)))
+ if (!checkBounds(script, start, sizeof(byte))) {
stack->pushNULL();
- else
+ } else {
stack->pushInt(*(byte *)((byte *)_buffer + start));
+ }
return STATUS_OK;
}
@@ -174,10 +185,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
else if (strcmp(name, "GetShort") == 0) {
stack->correctParams(1);
int Start = stack->pop()->getInt();
- if (!checkBounds(script, Start, sizeof(short)))
+ if (!checkBounds(script, Start, sizeof(short))) {
stack->pushNULL();
- else
+ } else {
stack->pushInt(65536 + * (short *)((byte *)_buffer + Start));
+ }
return STATUS_OK;
}
@@ -188,10 +200,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
else if (strcmp(name, "GetInt") == 0 || strcmp(name, "GetLong") == 0) {
stack->correctParams(1);
int start = stack->pop()->getInt();
- if (!checkBounds(script, start, sizeof(int)))
+ if (!checkBounds(script, start, sizeof(int))) {
stack->pushNULL();
- else
+ } else {
stack->pushInt(*(int *)((byte *)_buffer + start));
+ }
return STATUS_OK;
}
@@ -202,10 +215,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
else if (strcmp(name, "GetFloat") == 0) {
stack->correctParams(1);
int start = stack->pop()->getInt();
- if (!checkBounds(script, start, sizeof(float)))
+ if (!checkBounds(script, start, sizeof(float))) {
stack->pushNULL();
- else
+ } else {
stack->pushFloat(*(float *)((byte *)_buffer + start));
+ }
return STATUS_OK;
}
@@ -216,10 +230,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
else if (strcmp(name, "GetDouble") == 0) {
stack->correctParams(1);
int start = stack->pop()->getInt();
- if (!checkBounds(script, start, sizeof(double)))
+ if (!checkBounds(script, start, sizeof(double))) {
stack->pushNULL();
- else
+ } else {
stack->pushFloat(*(double *)((byte *)_buffer + start));
+ }
return STATUS_OK;
}
@@ -242,9 +257,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
}
}
- if (!checkBounds(script, start, length))
+ if (!checkBounds(script, start, length)) {
stack->pushNULL();
- else {
+ } else {
char *str = new char[length + 1];
strncpy(str, (const char *)_buffer + start, length);
str[length] = '\0';
@@ -260,9 +275,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
else if (strcmp(name, "GetPointer") == 0) {
stack->correctParams(1);
int start = stack->pop()->getInt();
- if (!checkBounds(script, start, sizeof(void *)))
+ if (!checkBounds(script, start, sizeof(void *))) {
stack->pushNULL();
- else {
+ } else {
void *pointer = *(void **)((byte *)_buffer + start);
SXMemBuffer *buf = new SXMemBuffer(_gameRef, pointer);
stack->pushNative(buf, false);
@@ -278,9 +293,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
int start = stack->pop()->getInt();
bool val = stack->pop()->getBool();
- if (!checkBounds(script, start, sizeof(bool)))
+ if (!checkBounds(script, start, sizeof(bool))) {
stack->pushBool(false);
- else {
+ } else {
*(bool *)((byte *)_buffer + start) = val;
stack->pushBool(true);
}
@@ -295,9 +310,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
int start = stack->pop()->getInt();
byte val = (byte)stack->pop()->getInt();
- if (!checkBounds(script, start, sizeof(byte)))
+ if (!checkBounds(script, start, sizeof(byte))) {
stack->pushBool(false);
- else {
+ } else {
*(byte *)((byte *)_buffer + start) = val;
stack->pushBool(true);
}
@@ -312,9 +327,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
int start = stack->pop()->getInt();
short val = (short)stack->pop()->getInt();
- if (!checkBounds(script, start, sizeof(short)))
+ if (!checkBounds(script, start, sizeof(short))) {
stack->pushBool(false);
- else {
+ } else {
*(short *)((byte *)_buffer + start) = val;
stack->pushBool(true);
}
@@ -329,9 +344,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
int start = stack->pop()->getInt();
int val = stack->pop()->getInt();
- if (!checkBounds(script, start, sizeof(int)))
+ if (!checkBounds(script, start, sizeof(int))) {
stack->pushBool(false);
- else {
+ } else {
*(int *)((byte *)_buffer + start) = val;
stack->pushBool(true);
}
@@ -346,9 +361,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
int start = stack->pop()->getInt();
float val = (float)stack->pop()->getFloat();
- if (!checkBounds(script, start, sizeof(float)))
+ if (!checkBounds(script, start, sizeof(float))) {
stack->pushBool(false);
- else {
+ } else {
*(float *)((byte *)_buffer + start) = val;
stack->pushBool(true);
}
@@ -363,9 +378,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
int start = stack->pop()->getInt();
double val = stack->pop()->getFloat();
- if (!checkBounds(script, start, sizeof(double)))
+ if (!checkBounds(script, start, sizeof(double))) {
stack->pushBool(false);
- else {
+ } else {
*(double *)((byte *)_buffer + start) = val;
stack->pushBool(true);
}
@@ -380,9 +395,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
int start = stack->pop()->getInt();
const char *val = stack->pop()->getString();
- if (!checkBounds(script, start, strlen(val) + 1))
+ if (!checkBounds(script, start, strlen(val) + 1)) {
stack->pushBool(false);
- else {
+ } else {
memcpy((byte *)_buffer + start, val, strlen(val) + 1);
stack->pushBool(true);
}
@@ -395,11 +410,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
else if (strcmp(name, "SetPointer") == 0) {
stack->correctParams(2);
int start = stack->pop()->getInt();
- /* ScValue *Val = */ stack->pop();
+ /* ScValue *val = */ stack->pop();
- if (!checkBounds(script, start, sizeof(void *)))
+ if (!checkBounds(script, start, sizeof(void *))) {
stack->pushBool(false);
- else {
+ } else {
/*
int Pointer = (int)Val->getMemBuffer();
memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*));
@@ -426,9 +441,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt
}
stack->pushNULL();
return STATUS_OK;
+ } else {
+ return STATUS_FAILED;
}
-
- else return STATUS_FAILED;
}
@@ -450,9 +465,9 @@ ScValue *SXMemBuffer::scGetProperty(const char *name) {
if (strcmp(name, "Size") == 0) {
_scValue->setInt(_size);
return _scValue;
+ } else {
+ return BaseScriptable::scGetProperty(name);
}
-
- else return BaseScriptable::scGetProperty(name);
}
@@ -487,12 +502,16 @@ bool SXMemBuffer::persist(BasePersistenceManager *persistMgr) {
persistMgr->transfer(TMEMBER(_size));
if (persistMgr->getIsSaving()) {
- if (_size > 0) persistMgr->putBytes((byte *)_buffer, _size);
+ if (_size > 0) {
+ persistMgr->putBytes((byte *)_buffer, _size);
+ }
} else {
if (_size > 0) {
_buffer = malloc(_size);
persistMgr->getBytes((byte *)_buffer, _size);
- } else _buffer = NULL;
+ } else {
+ _buffer = NULL;
+ }
}
return STATUS_OK;
@@ -501,8 +520,11 @@ bool SXMemBuffer::persist(BasePersistenceManager *persistMgr) {
//////////////////////////////////////////////////////////////////////////
int SXMemBuffer::scCompare(BaseScriptable *val) {
- if (_buffer == val->scToMemBuffer()) return 0;
- else return 1;
+ if (_buffer == val->scToMemBuffer()) {
+ return 0;
+ } else {
+ return 1;
+ }
}
} // end of namespace WinterMute
diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp
index 385d7ca746..1c7349bd8d 100644
--- a/engines/wintermute/base/scriptables/script_ext_string.cpp
+++ b/engines/wintermute/base/scriptables/script_ext_string.cpp
@@ -61,13 +61,17 @@ SXString::SXString(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) {
setStringVal(val->getString());
}
- if (_capacity == 0) setStringVal("");
+ if (_capacity == 0) {
+ setStringVal("");
+ }
}
//////////////////////////////////////////////////////////////////////////
SXString::~SXString() {
- if (_string) delete[] _string;
+ if (_string) {
+ delete[] _string;
+ }
}
@@ -87,8 +91,11 @@ void SXString::setStringVal(const char *val) {
//////////////////////////////////////////////////////////////////////////
const char *SXString::scToString() {
- if (_string) return _string;
- else return "[null string]";
+ if (_string) {
+ return _string;
+ } else {
+ return "[null string]";
+ }
}
@@ -108,22 +115,26 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
int start = stack->pop()->getInt();
int end = stack->pop()->getInt();
- if (end < start) BaseUtils::swap(&start, &end);
+ if (end < start) {
+ BaseUtils::swap(&start, &end);
+ }
//try {
WideString str;
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
str = StringUtil::utf8ToWide(_string);
- else
+ } else {
str = StringUtil::ansiToWide(_string);
+ }
//WideString subStr = str.substr(start, end - start + 1);
WideString subStr(str.c_str() + start, end - start + 1);
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
stack->pushString(StringUtil::wideToUtf8(subStr).c_str());
- else
+ } else {
stack->pushString(StringUtil::wideToAnsi(subStr).c_str());
+ }
// } catch (std::exception &) {
// stack->pushNULL();
// }
@@ -146,22 +157,26 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
return STATUS_OK;
}
- if (val->isNULL()) len = strlen(_string) - start;
+ if (val->isNULL()) {
+ len = strlen(_string) - start;
+ }
// try {
WideString str;
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
str = StringUtil::utf8ToWide(_string);
- else
+ } else {
str = StringUtil::ansiToWide(_string);
+ }
// WideString subStr = str.substr(start, len);
WideString subStr(str.c_str() + start, len);
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
stack->pushString(StringUtil::wideToUtf8(subStr).c_str());
- else
+ } else {
stack->pushString(StringUtil::wideToAnsi(subStr).c_str());
+ }
// } catch (std::exception &) {
// stack->pushNULL();
// }
@@ -176,17 +191,19 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
stack->correctParams(0);
WideString str;
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
str = StringUtil::utf8ToWide(_string);
- else
+ } else {
str = StringUtil::ansiToWide(_string);
+ }
str.toUppercase();
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
stack->pushString(StringUtil::wideToUtf8(str).c_str());
- else
+ } else {
stack->pushString(StringUtil::wideToAnsi(str).c_str());
+ }
return STATUS_OK;
}
@@ -198,17 +215,19 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
stack->correctParams(0);
WideString str;
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
str = StringUtil::utf8ToWide(_string);
- else
+ } else {
str = StringUtil::ansiToWide(_string);
+ }
str.toLowercase();
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
stack->pushString(StringUtil::wideToUtf8(str).c_str());
- else
+ } else {
stack->pushString(StringUtil::wideToAnsi(str).c_str());
+ }
return STATUS_OK;
}
@@ -223,16 +242,18 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
int index = stack->pop()->getInt();
WideString str;
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
str = StringUtil::utf8ToWide(_string);
- else
+ } else {
str = StringUtil::ansiToWide(_string);
+ }
WideString toFind;
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
toFind = StringUtil::utf8ToWide(strToFind);
- else
+ } else {
toFind = StringUtil::ansiToWide(strToFind);
+ }
int indexOf = StringUtil::indexOf(str, toFind, index);
stack->pushInt(indexOf);
@@ -247,7 +268,9 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
stack->correctParams(1);
ScValue *val = stack->pop();
char separators[MAX_PATH_LENGTH] = ",";
- if (!val->isNULL()) strcpy(separators, val->getString());
+ if (!val->isNULL()) {
+ strcpy(separators, val->getString());
+ }
SXArray *array = new SXArray(_gameRef);
if (!array) {
@@ -257,16 +280,18 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
WideString str;
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
str = StringUtil::utf8ToWide(_string);
- else
+ } else {
str = StringUtil::ansiToWide(_string);
+ }
WideString delims;
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
delims = StringUtil::utf8ToWide(separators);
- else
+ } else {
delims = StringUtil::ansiToWide(separators);
+ }
Common::Array<WideString> parts;
@@ -298,10 +323,11 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
for (Common::Array<WideString>::iterator it = parts.begin(); it != parts.end(); ++it) {
WideString &part = (*it);
- if (_gameRef->_textEncoding == TEXT_UTF8)
+ if (_gameRef->_textEncoding == TEXT_UTF8) {
val = new ScValue(_gameRef, StringUtil::wideToUtf8(part).c_str());
- else
+ } else {
val = new ScValue(_gameRef, StringUtil::wideToAnsi(part).c_str());
+ }
array->push(val);
delete val;
@@ -310,9 +336,9 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
stack->pushNative(array, false);
return STATUS_OK;
+ } else {
+ return STATUS_FAILED;
}
-
- else return STATUS_FAILED;
}
@@ -334,8 +360,9 @@ ScValue *SXString::scGetProperty(const char *name) {
if (_gameRef->_textEncoding == TEXT_UTF8) {
WideString wstr = StringUtil::utf8ToWide(_string);
_scValue->setInt(wstr.size());
- } else
+ } else {
_scValue->setInt(strlen(_string));
+ }
return _scValue;
}
@@ -345,9 +372,9 @@ ScValue *SXString::scGetProperty(const char *name) {
else if (strcmp(name, "Capacity") == 0) {
_scValue->setInt(_capacity);
return _scValue;
+ } else {
+ return _scValue;
}
-
- else return _scValue;
}
@@ -358,8 +385,9 @@ bool SXString::scSetProperty(const char *name, ScValue *value) {
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "Capacity") == 0) {
int32 newCap = (uint32)value->getInt();
- if (newCap < (int32)(strlen(_string) + 1)) _gameRef->LOG(0, "Warning: cannot lower string capacity");
- else if (newCap != _capacity) {
+ if (newCap < (int32)(strlen(_string) + 1)) {
+ _gameRef->LOG(0, "Warning: cannot lower string capacity");
+ } else if (newCap != _capacity) {
char *newStr = new char[newCap];
if (newStr) {
memset(newStr, 0, newCap);
@@ -370,9 +398,9 @@ bool SXString::scSetProperty(const char *name, ScValue *value) {
}
}
return STATUS_OK;
+ } else {
+ return STATUS_FAILED;
}
-
- else return STATUS_FAILED;
}
@@ -384,12 +412,16 @@ bool SXString::persist(BasePersistenceManager *persistMgr) {
persistMgr->transfer(TMEMBER(_capacity));
if (persistMgr->getIsSaving()) {
- if (_capacity > 0) persistMgr->putBytes((byte *)_string, _capacity);
+ if (_capacity > 0) {
+ persistMgr->putBytes((byte *)_string, _capacity);
+ }
} else {
if (_capacity > 0) {
_string = new char[_capacity];
persistMgr->getBytes((byte *)_string, _capacity);
- } else _string = NULL;
+ } else {
+ _string = NULL;
+ }
}
return STATUS_OK;
diff --git a/engines/wintermute/base/scriptables/script_stack.cpp b/engines/wintermute/base/scriptables/script_stack.cpp
index 74cc7a57ee..0d4ea54b8c 100644
--- a/engines/wintermute/base/scriptables/script_stack.cpp
+++ b/engines/wintermute/base/scriptables/script_stack.cpp
@@ -96,16 +96,22 @@ ScValue *ScStack::getPushValue() {
//////////////////////////////////////////////////////////////////////////
ScValue *ScStack::getTop() {
- if (_sP < 0 || _sP >= _values.getSize()) return NULL;
- else return _values[_sP];
+ if (_sP < 0 || _sP >= _values.getSize()) {
+ return NULL;
+ } else {
+ return _values[_sP];
+ }
}
//////////////////////////////////////////////////////////////////////////
ScValue *ScStack::getAt(int index) {
index = _sP - index;
- if (index < 0 || index >= _values.getSize()) return NULL;
- else return _values[index];
+ if (index < 0 || index >= _values.getSize()) {
+ return NULL;
+ } else {
+ return _values[index];
+ }
}
diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp
index 5e824cd10c..01cb4044ff 100644
--- a/engines/wintermute/base/scriptables/script_value.cpp
+++ b/engines/wintermute/base/scriptables/script_value.cpp
@@ -122,7 +122,9 @@ ScValue::ScValue(BaseGame *inGame, const char *val): BaseClass(inGame) {
void ScValue::cleanup(bool ignoreNatives) {
deleteProps();
- if (_valString) delete[] _valString;
+ if (_valString) {
+ delete[] _valString;
+ }
if (!ignoreNatives) {
if (_valNative && !_persistent) {
@@ -157,7 +159,9 @@ ScValue::~ScValue() {
//////////////////////////////////////////////////////////////////////////
ScValue *ScValue::getProp(const char *name) {
- if (_type == VAL_VARIABLE_REF) return _valRef->getProp(name);
+ if (_type == VAL_VARIABLE_REF) {
+ return _valRef->getProp(name);
+ }
if (_type == VAL_STRING && strcmp(name, "Length") == 0) {
_gameRef->_scValue->_type = VAL_INT;
@@ -178,18 +182,24 @@ ScValue *ScValue::getProp(const char *name) {
ScValue *ret = NULL;
- if (_type == VAL_NATIVE && _valNative) ret = _valNative->scGetProperty(name);
+ if (_type == VAL_NATIVE && _valNative) {
+ ret = _valNative->scGetProperty(name);
+ }
if (ret == NULL) {
_valIter = _valObject.find(name);
- if (_valIter != _valObject.end()) ret = _valIter->_value;
+ if (_valIter != _valObject.end()) {
+ ret = _valIter->_value;
+ }
}
return ret;
}
//////////////////////////////////////////////////////////////////////////
bool ScValue::deleteProp(const char *name) {
- if (_type == VAL_VARIABLE_REF) return _valRef->deleteProp(name);
+ if (_type == VAL_VARIABLE_REF) {
+ return _valRef->deleteProp(name);
+ }
_valIter = _valObject.find(name);
if (_valIter != _valObject.end()) {
@@ -204,8 +214,9 @@ bool ScValue::deleteProp(const char *name) {
//////////////////////////////////////////////////////////////////////////
bool ScValue::setProp(const char *name, ScValue *val, bool copyWhole, bool setAsConst) {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->setProp(name, val);
+ }
bool ret = STATUS_FAILED;
if (_type == VAL_NATIVE && _valNative) {
@@ -219,15 +230,19 @@ bool ScValue::setProp(const char *name, ScValue *val, bool copyWhole, bool setAs
if (_valIter != _valObject.end()) {
newVal = _valIter->_value;
}
- if (!newVal)
+ if (!newVal) {
newVal = new ScValue(_gameRef);
- else newVal->cleanup();
+ } else {
+ newVal->cleanup();
+ }
newVal->copy(val, copyWhole);
newVal->_isConstVar = setAsConst;
_valObject[name] = newVal;
- if (_type != VAL_NATIVE) _type = VAL_OBJECT;
+ if (_type != VAL_NATIVE) {
+ _type = VAL_OBJECT;
+ }
/*
_valIter = _valObject.find(Name);
@@ -250,8 +265,9 @@ bool ScValue::setProp(const char *name, ScValue *val, bool copyWhole, bool setAs
//////////////////////////////////////////////////////////////////////////
bool ScValue::propExists(const char *name) {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->propExists(name);
+ }
_valIter = _valObject.find(name);
return (_valIter != _valObject.end());
@@ -273,15 +289,18 @@ void ScValue::deleteProps() {
void ScValue::CleanProps(bool includingNatives) {
_valIter = _valObject.begin();
while (_valIter != _valObject.end()) {
- if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) _valIter->_value->setNULL();
+ if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) {
+ _valIter->_value->setNULL();
+ }
_valIter++;
}
}
//////////////////////////////////////////////////////////////////////////
bool ScValue::isNULL() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->isNULL();
+ }
return (_type == VAL_NULL);
}
@@ -289,8 +308,9 @@ bool ScValue::isNULL() {
//////////////////////////////////////////////////////////////////////////
bool ScValue::isNative() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->isNative();
+ }
return (_type == VAL_NATIVE);
}
@@ -298,8 +318,9 @@ bool ScValue::isNative() {
//////////////////////////////////////////////////////////////////////////
bool ScValue::isString() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->isString();
+ }
return (_type == VAL_STRING);
}
@@ -307,8 +328,9 @@ bool ScValue::isString() {
//////////////////////////////////////////////////////////////////////////
bool ScValue::isFloat() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->isFloat();
+ }
return (_type == VAL_FLOAT);
}
@@ -316,8 +338,9 @@ bool ScValue::isFloat() {
//////////////////////////////////////////////////////////////////////////
bool ScValue::isInt() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->isInt();
+ }
return (_type == VAL_INT);
}
@@ -325,8 +348,9 @@ bool ScValue::isInt() {
//////////////////////////////////////////////////////////////////////////
bool ScValue::isBool() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->isBool();
+ }
return (_type == VAL_BOOL);
}
@@ -334,8 +358,9 @@ bool ScValue::isBool() {
//////////////////////////////////////////////////////////////////////////
bool ScValue::isObject() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->isObject();
+ }
return (_type == VAL_OBJECT);
}
@@ -343,8 +368,9 @@ bool ScValue::isObject() {
//////////////////////////////////////////////////////////////////////////
TValType ScValue::getTypeTolerant() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->getType();
+ }
return _type;
}
@@ -414,8 +440,11 @@ void ScValue::setString(const char *val) {
}
setStringVal(val);
- if (_valString) _type = VAL_STRING;
- else _type = VAL_NULL;
+ if (_valString) {
+ _type = VAL_STRING;
+ } else {
+ _type = VAL_NULL;
+ }
}
void ScValue::setString(const Common::String &val) {
@@ -450,7 +479,9 @@ void ScValue::setNULL() {
if (_valNative && !_persistent) {
_valNative->_refCount--;
- if (_valNative->_refCount <= 0) delete _valNative;
+ if (_valNative->_refCount <= 0) {
+ delete _valNative;
+ }
}
_valNative = NULL;
deleteProps();
@@ -472,7 +503,9 @@ void ScValue::setNative(BaseScriptable *val, bool persistent) {
if (_valNative && !_persistent) {
_valNative->_refCount--;
if (_valNative->_refCount <= 0) {
- if (_valNative != val) delete _valNative;
+ if (_valNative != val) {
+ delete _valNative;
+ }
_valNative = NULL;
}
}
@@ -481,7 +514,9 @@ void ScValue::setNative(BaseScriptable *val, bool persistent) {
_persistent = persistent;
_valNative = val;
- if (_valNative && !_persistent) _valNative->_refCount++;
+ if (_valNative && !_persistent) {
+ _valNative->_refCount++;
+ }
}
}
@@ -507,8 +542,9 @@ void ScValue::setReference(ScValue *val) {
//////////////////////////////////////////////////////////////////////////
bool ScValue::getBool(bool defaultVal) {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->getBool();
+ }
switch (_type) {
case VAL_BOOL:
@@ -534,7 +570,9 @@ bool ScValue::getBool(bool defaultVal) {
//////////////////////////////////////////////////////////////////////////
int ScValue::getInt(int defaultVal) {
- if (_type == VAL_VARIABLE_REF) return _valRef->getInt();
+ if (_type == VAL_VARIABLE_REF) {
+ return _valRef->getInt();
+ }
switch (_type) {
case VAL_BOOL:
@@ -560,8 +598,9 @@ int ScValue::getInt(int defaultVal) {
//////////////////////////////////////////////////////////////////////////
double ScValue::getFloat(double defaultVal) {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->getFloat();
+ }
switch (_type) {
case VAL_BOOL:
@@ -586,19 +625,23 @@ double ScValue::getFloat(double defaultVal) {
//////////////////////////////////////////////////////////////////////////
void *ScValue::getMemBuffer() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->getMemBuffer();
+ }
- if (_type == VAL_NATIVE)
+ if (_type == VAL_NATIVE) {
return _valNative->scToMemBuffer();
- else return (void *)NULL;
+ } else {
+ return (void *)NULL;
+ }
}
//////////////////////////////////////////////////////////////////////////
const char *ScValue::getString() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->getString();
+ }
switch (_type) {
case VAL_OBJECT:
@@ -647,11 +690,15 @@ const char *ScValue::getString() {
//////////////////////////////////////////////////////////////////////////
BaseScriptable *ScValue::getNative() {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->getNative();
+ }
- if (_type == VAL_NATIVE) return _valNative;
- else return NULL;
+ if (_type == VAL_NATIVE) {
+ return _valNative;
+ } else {
+ return NULL;
+ }
}
@@ -668,12 +715,16 @@ void ScValue::copy(ScValue *orig, bool copyWhole) {
if (_valNative && !_persistent) {
_valNative->_refCount--;
if (_valNative->_refCount <= 0) {
- if (_valNative != orig->_valNative) delete _valNative;
+ if (_valNative != orig->_valNative) {
+ delete _valNative;
+ }
_valNative = NULL;
}
}
- if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && copyWhole) orig = orig->_valRef;
+ if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && copyWhole) {
+ orig = orig->_valRef;
+ }
cleanup(true);
@@ -687,7 +738,9 @@ void ScValue::copy(ScValue *orig, bool copyWhole) {
_persistent = orig->_persistent;
_valNative = orig->_valNative;
- if (_valNative && !_persistent) _valNative->_refCount++;
+ if (_valNative && !_persistent) {
+ _valNative->_refCount++;
+ }
//!!!! ref->native++
// copy properties
@@ -698,7 +751,9 @@ void ScValue::copy(ScValue *orig, bool copyWhole) {
_valObject[orig->_valIter->_key]->copy(orig->_valIter->_value);
orig->_valIter++;
}
- } else _valObject.clear();
+ } else {
+ _valObject.clear();
+ }
}
@@ -730,7 +785,9 @@ void ScValue::setValue(ScValue *val) {
}
}
// otherwise just copy everything
- else copy(val);
+ else {
+ copy(val);
+ }
}
@@ -841,39 +898,60 @@ int ScValue::compare(ScValue *val1, ScValue *val2) {
// same class?
if (strcmp(val1->getNative()->getClassName(), val2->getNative()->getClassName()) == 0) {
return val1->getNative()->scCompare(val2->getNative());
- } else return strcmp(val1->getString(), val2->getString());
+ } else {
+ return strcmp(val1->getString(), val2->getString());
+ }
}
// both objects?
- if (val1->isObject() && val2->isObject()) return -1;
+ if (val1->isObject() && val2->isObject()) {
+ return -1;
+ }
// null states
- if (val1->isNULL() && !val2->isNULL()) return -1;
- else if (!val1->isNULL() && val2->isNULL()) return 1;
- else if (val1->isNULL() && val2->isNULL()) return 0;
+ if (val1->isNULL() && !val2->isNULL()) {
+ return -1;
+ } else if (!val1->isNULL() && val2->isNULL()) {
+ return 1;
+ } else if (val1->isNULL() && val2->isNULL()) {
+ return 0;
+ }
// one of them is string? convert both to string
- if (val1->isString() || val2->isString()) return strcmp(val1->getString(), val2->getString());
+ if (val1->isString() || val2->isString()) {
+ return strcmp(val1->getString(), val2->getString());
+ }
// one of them is float?
if (val1->isFloat() || val2->isFloat()) {
- if (val1->getFloat() < val2->getFloat()) return -1;
- else if (val1->getFloat() > val2->getFloat()) return 1;
- else return 0;
+ if (val1->getFloat() < val2->getFloat()) {
+ return -1;
+ } else if (val1->getFloat() > val2->getFloat()) {
+ return 1;
+ } else {
+ return 0;
+ }
}
// otherwise compare as int's
- if (val1->getInt() < val2->getInt()) return -1;
- else if (val1->getInt() > val2->getInt()) return 1;
- else return 0;
+ if (val1->getInt() < val2->getInt()) {
+ return -1;
+ } else if (val1->getInt() > val2->getInt()) {
+ return 1;
+ } else {
+ return 0;
+ }
}
//////////////////////////////////////////////////////////////////////////
int ScValue::compareStrict(ScValue *val1, ScValue *val2) {
- if (val1->getTypeTolerant() != val2->getTypeTolerant()) return -1;
- else return ScValue::compare(val1, val2);
+ if (val1->getTypeTolerant() != val2->getTypeTolerant()) {
+ return -1;
+ } else {
+ return ScValue::compare(val1, val2);
+ }
}
@@ -1013,16 +1091,18 @@ bool ScValue::dbgSetVal() {
//////////////////////////////////////////////////////////////////////////
int ScValue::dbgGetNumProperties() {
- if (_valNative && _valNative->_scProp)
+ if (_valNative && _valNative->_scProp) {
return _valNative->_scProp->dbgGetNumProperties();
- else return _valObject.size();
+ } else {
+ return _valObject.size();
+ }
}
//////////////////////////////////////////////////////////////////////////
bool ScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value) {
- if (_valNative && _valNative->_scProp)
+ if (_valNative && _valNative->_scProp) {
return _valNative->_scProp->dbgGetProperty(index, name, value);
- else {
+ } else {
int count = 0;
_valIter = _valObject.begin();
while (_valIter != _valObject.end()) {
@@ -1040,8 +1120,9 @@ bool ScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value
//////////////////////////////////////////////////////////////////////////
bool ScValue::dbgGetDescription(char *buf, int bufSize) {
- if (_type == VAL_VARIABLE_REF)
+ if (_type == VAL_VARIABLE_REF) {
return _valRef->dbgGetDescription(buf, bufSize);
+ }
if (_type == VAL_NATIVE) {
_valNative->scDebuggerDesc(buf, bufSize);