WINTERMUTE: Rename FuncName->funcName in ScStack

This commit is contained in:
Einar Johan Trøan Sømåen 2012-07-03 05:08:59 +02:00
parent 6c6c0bb016
commit c27d6585df
38 changed files with 1638 additions and 1638 deletions

View File

@ -855,12 +855,12 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// GoTo / GoToAsync
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "GoTo") == 0 || strcmp(name, "GoToAsync") == 0) {
stack->CorrectParams(2);
int X = stack->Pop()->GetInt();
int Y = stack->Pop()->GetInt();
stack->correctParams(2);
int X = stack->pop()->GetInt();
int Y = stack->pop()->GetInt();
goTo(X, Y);
if (strcmp(name, "GoToAsync") != 0) script->WaitForExclusive(this);
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -868,24 +868,24 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// GoToObject / GoToObjectAsync
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GoToObject") == 0 || strcmp(name, "GoToObjectAsync") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
if (!Val->IsNative()) {
script->RuntimeError("actor.%s method accepts an entity refrence only", name);
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
CAdObject *Obj = (CAdObject *)Val->GetNative();
if (!Obj || Obj->_type != OBJECT_ENTITY) {
script->RuntimeError("actor.%s method accepts an entity refrence only", name);
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
CAdEntity *Ent = (CAdEntity *)Obj;
if (Ent->_walkToX == 0 && Ent->_walkToY == 0) goTo(Ent->_posX, Ent->_posY);
else goTo(Ent->_walkToX, Ent->_walkToY, Ent->_walkToDir);
if (strcmp(name, "GoToObjectAsync") != 0) script->WaitForExclusive(this);
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -893,9 +893,9 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// TurnTo / TurnToAsync
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "TurnTo") == 0 || strcmp(name, "TurnToAsync") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
int dir;
CScValue *val = stack->Pop();
CScValue *val = stack->pop();
// turn to object?
if (val->IsNative() && Game->ValidObject((CBObject *)val->GetNative())) {
@ -910,7 +910,7 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
turnTo((TDirection)dir);
if (strcmp(name, "TurnToAsync") != 0) script->WaitForExclusive(this);
}
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -918,8 +918,8 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// IsWalking
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "IsWalking") == 0) {
stack->CorrectParams(0);
stack->PushBool(_state == STATE_FOLLOWING_PATH);
stack->correctParams(0);
stack->pushBool(_state == STATE_FOLLOWING_PATH);
return S_OK;
}
@ -927,8 +927,8 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// MergeAnims
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "MergeAnims") == 0) {
stack->CorrectParams(1);
stack->PushBool(SUCCEEDED(mergeAnims(stack->Pop()->GetString())));
stack->correctParams(1);
stack->pushBool(SUCCEEDED(mergeAnims(stack->pop()->GetString())));
return S_OK;
}
@ -936,8 +936,8 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// UnloadAnim
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "UnloadAnim") == 0) {
stack->CorrectParams(1);
const char *AnimName = stack->Pop()->GetString();
stack->correctParams(1);
const char *AnimName = stack->pop()->GetString();
bool Found = false;
for (int i = 0; i < _anims.GetSize(); i++) {
@ -954,7 +954,7 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
Found = true;
}
}
stack->PushBool(Found);
stack->pushBool(Found);
return S_OK;
}
@ -962,9 +962,9 @@ HRESULT CAdActor::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// HasAnim
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "HasAnim") == 0) {
stack->CorrectParams(1);
const char *AnimName = stack->Pop()->GetString();
stack->PushBool(getAnimByName(AnimName) != NULL);
stack->correctParams(1);
const char *AnimName = stack->pop()->GetString();
stack->pushBool(getAnimByName(AnimName) != NULL);
return S_OK;
}

View File

@ -630,10 +630,10 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// StopSound
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "StopSound") == 0 && _subtype == ENTITY_SOUND) {
stack->CorrectParams(0);
stack->correctParams(0);
if (FAILED(stopSFX(false))) stack->PushBool(false);
else stack->PushBool(true);
if (FAILED(stopSFX(false))) stack->pushBool(false);
else stack->pushBool(true);
return S_OK;
}
@ -641,11 +641,11 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// PlayTheora
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "PlayTheora") == 0) {
stack->CorrectParams(4);
const char *filename = stack->Pop()->GetString();
bool looping = stack->Pop()->GetBool(false);
CScValue *valAlpha = stack->Pop();
int startTime = stack->Pop()->GetInt();
stack->correctParams(4);
const char *filename = stack->pop()->GetString();
bool looping = stack->pop()->GetBool(false);
CScValue *valAlpha = stack->pop();
int startTime = stack->pop()->GetInt();
delete _theora;
_theora = new CVidTheoraPlayer(Game);
@ -653,10 +653,10 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
if (!valAlpha->IsNULL()) _theora->setAlphaImage(valAlpha->GetString());
_theora->play(VID_PLAY_POS, 0, 0, false, false, looping, startTime, _scale >= 0.0f ? _scale : -1.0f, _sFXVolume);
//if(m_Scale>=0) m_Theora->m_PlayZoom = m_Scale;
stack->PushBool(true);
stack->pushBool(true);
} else {
script->RuntimeError("Entity.PlayTheora - error playing video '%s'", filename);
stack->PushBool(false);
stack->pushBool(false);
}
return S_OK;
@ -666,13 +666,13 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// StopTheora
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "StopTheora") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (_theora) {
_theora->stop();
delete _theora;
_theora = NULL;
stack->PushBool(true);
} else stack->PushBool(false);
stack->pushBool(true);
} else stack->pushBool(false);
return S_OK;
}
@ -681,9 +681,9 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// IsTheoraPlaying
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "IsTheoraPlaying") == 0) {
stack->CorrectParams(0);
if (_theora && _theora->isPlaying()) stack->PushBool(true);
else stack->PushBool(false);
stack->correctParams(0);
if (_theora && _theora->isPlaying()) stack->pushBool(true);
else stack->pushBool(false);
return S_OK;
}
@ -692,11 +692,11 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// PauseTheora
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "PauseTheora") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (_theora && _theora->isPlaying()) {
_theora->pause();
stack->PushBool(true);
} else stack->PushBool(false);
stack->pushBool(true);
} else stack->pushBool(false);
return S_OK;
}
@ -705,11 +705,11 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// ResumeTheora
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "ResumeTheora") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (_theora && _theora->isPaused()) {
_theora->resume();
stack->PushBool(true);
} else stack->PushBool(false);
stack->pushBool(true);
} else stack->pushBool(false);
return S_OK;
}
@ -718,9 +718,9 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// IsTheoraPaused
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "IsTheoraPaused") == 0) {
stack->CorrectParams(0);
if (_theora && _theora->isPaused()) stack->PushBool(true);
else stack->PushBool(false);
stack->correctParams(0);
if (_theora && _theora->isPaused()) stack->pushBool(true);
else stack->pushBool(false);
return S_OK;
}
@ -730,13 +730,13 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// CreateRegion
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "CreateRegion") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (!_region) {
_region = new CBRegion(Game);
Game->RegisterObject(_region);
}
if (_region) stack->PushNative(_region, true);
else stack->PushNULL();
if (_region) stack->pushNative(_region, true);
else stack->pushNULL();
return S_OK;
}
@ -745,12 +745,12 @@ HRESULT CAdEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// DeleteRegion
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "DeleteRegion") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (_region) {
Game->UnregisterObject(_region);
_region = NULL;
stack->PushBool(true);
} else stack->PushBool(false);
stack->pushBool(true);
} else stack->pushBool(false);
return S_OK;
}

View File

@ -321,22 +321,22 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// ChangeScene
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "ChangeScene") == 0) {
stack->CorrectParams(3);
const char *Filename = stack->Pop()->GetString();
CScValue *valFadeOut = stack->Pop();
CScValue *valFadeIn = stack->Pop();
stack->correctParams(3);
const char *Filename = stack->pop()->GetString();
CScValue *valFadeOut = stack->pop();
CScValue *valFadeIn = stack->pop();
bool TransOut = valFadeOut->IsNULL() ? true : valFadeOut->GetBool();
bool TransIn = valFadeIn->IsNULL() ? true : valFadeIn->GetBool();
ScheduleChangeScene(Filename, TransIn);
if (TransOut) _transMgr->start(TRANSITION_FADE_OUT, true);
stack->PushNULL();
stack->pushNULL();
//HRESULT ret = ChangeScene(stack->Pop()->GetString());
//if(FAILED(ret)) stack->PushBool(false);
//else stack->PushBool(true);
//HRESULT ret = ChangeScene(stack->pop()->GetString());
//if(FAILED(ret)) stack->pushBool(false);
//else stack->pushBool(true);
return S_OK;
}
@ -345,15 +345,15 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// LoadActor
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "LoadActor") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
CAdActor *act = new CAdActor(Game);
if (act && SUCCEEDED(act->loadFile(stack->Pop()->GetString()))) {
if (act && SUCCEEDED(act->loadFile(stack->pop()->GetString()))) {
AddObject(act);
stack->PushNative(act, true);
stack->pushNative(act, true);
} else {
delete act;
act = NULL;
stack->PushNULL();
stack->pushNULL();
}
return S_OK;
}
@ -362,15 +362,15 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// LoadEntity
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "LoadEntity") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
CAdEntity *ent = new CAdEntity(Game);
if (ent && SUCCEEDED(ent->loadFile(stack->Pop()->GetString()))) {
if (ent && SUCCEEDED(ent->loadFile(stack->pop()->GetString()))) {
AddObject(ent);
stack->PushNative(ent, true);
stack->pushNative(ent, true);
} else {
delete ent;
ent = NULL;
stack->PushNULL();
stack->pushNULL();
}
return S_OK;
}
@ -379,13 +379,13 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// UnloadObject / UnloadActor / UnloadEntity / DeleteEntity
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "UnloadObject") == 0 || strcmp(name, "UnloadActor") == 0 || strcmp(name, "UnloadEntity") == 0 || strcmp(name, "DeleteEntity") == 0) {
stack->CorrectParams(1);
CScValue *val = stack->Pop();
stack->correctParams(1);
CScValue *val = stack->pop();
CAdObject *obj = (CAdObject *)val->GetNative();
RemoveObject(obj);
if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL();
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -393,13 +393,13 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// CreateEntity
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "CreateEntity") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
CAdEntity *Ent = new CAdEntity(Game);
AddObject(Ent);
if (!Val->IsNULL()) Ent->setName(Val->GetString());
stack->PushNative(Ent, true);
stack->pushNative(Ent, true);
return S_OK;
}
@ -407,13 +407,13 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// CreateItem
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "CreateItem") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
CAdItem *Item = new CAdItem(Game);
AddItem(Item);
if (!Val->IsNULL()) Item->setName(Val->GetString());
stack->PushNative(Item, true);
stack->pushNative(Item, true);
return S_OK;
}
@ -421,8 +421,8 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// DeleteItem
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "DeleteItem") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
CAdItem *Item = NULL;
if (Val->IsNative()) Item = (CAdItem *)Val->GetNative();
@ -432,7 +432,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
DeleteItem(Item);
}
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -440,8 +440,8 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// QueryItem
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "QueryItem") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
CAdItem *Item = NULL;
if (Val->IsInt()) {
@ -451,8 +451,8 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
Item = GetItemByName(Val->GetString());
}
if (Item) stack->PushNative(Item, true);
else stack->PushNULL();
if (Item) stack->pushNative(Item, true);
else stack->pushNULL();
return S_OK;
}
@ -462,13 +462,13 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// AddResponse/AddResponseOnce/AddResponseOnceGame
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "AddResponse") == 0 || strcmp(name, "AddResponseOnce") == 0 || strcmp(name, "AddResponseOnceGame") == 0) {
stack->CorrectParams(6);
int id = stack->Pop()->GetInt();
const char *text = stack->Pop()->GetString();
CScValue *val1 = stack->Pop();
CScValue *val2 = stack->Pop();
CScValue *val3 = stack->Pop();
CScValue *val4 = stack->Pop();
stack->correctParams(6);
int id = stack->pop()->GetInt();
const char *text = stack->pop()->GetString();
CScValue *val1 = stack->pop();
CScValue *val2 = stack->pop();
CScValue *val3 = stack->pop();
CScValue *val4 = stack->pop();
if (_responseBox) {
CAdResponse *res = new CAdResponse(Game);
@ -489,7 +489,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
} else {
script->RuntimeError("Game.AddResponse: response box is not defined");
}
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -498,10 +498,10 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// ResetResponse
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "ResetResponse") == 0) {
stack->CorrectParams(1);
int ID = stack->Pop()->GetInt(-1);
stack->correctParams(1);
int ID = stack->pop()->GetInt(-1);
ResetResponse(ID);
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -509,10 +509,10 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// ClearResponses
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "ClearResponses") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
_responseBox->clearResponses();
_responseBox->clearButtons();
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -520,20 +520,20 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// GetResponse
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetResponse") == 0) {
stack->CorrectParams(1);
bool AutoSelectLast = stack->Pop()->GetBool();
stack->correctParams(1);
bool AutoSelectLast = stack->pop()->GetBool();
if (_responseBox) {
_responseBox->weedResponses();
if (_responseBox->_responses.GetSize() == 0) {
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
if (_responseBox->_responses.GetSize() == 1 && AutoSelectLast) {
stack->PushInt(_responseBox->_responses[0]->_iD);
stack->pushInt(_responseBox->_responses[0]->_iD);
_responseBox->handleResponse(_responseBox->_responses[0]);
_responseBox->clearResponses();
return S_OK;
@ -546,7 +546,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
_stateEx = GAME_WAITING_RESPONSE;
} else {
script->RuntimeError("Game.GetResponse: response box is not defined");
stack->PushNULL();
stack->pushNULL();
}
return S_OK;
}
@ -556,13 +556,13 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// GetNumResponses
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetNumResponses") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (_responseBox) {
_responseBox->weedResponses();
stack->PushInt(_responseBox->_responses.GetSize());
stack->pushInt(_responseBox->_responses.GetSize());
} else {
script->RuntimeError("Game.GetNumResponses: response box is not defined");
stack->PushNULL();
stack->pushNULL();
}
return S_OK;
}
@ -572,15 +572,15 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// StartDlgBranch
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "StartDlgBranch") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
Common::String BranchName;
if (Val->IsNULL()) {
BranchName.format("line%d", script->_currentLine);
} else BranchName = Val->GetString();
StartDlgBranch(BranchName.c_str(), script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent);
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -589,14 +589,14 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// EndDlgBranch
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "EndDlgBranch") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
const char *BranchName = NULL;
CScValue *Val = stack->Pop();
CScValue *Val = stack->pop();
if (!Val->IsNULL()) BranchName = Val->GetString();
EndDlgBranch(BranchName, script->_filename == NULL ? "" : script->_filename, script->_threadEvent == NULL ? "" : script->_threadEvent);
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -605,11 +605,11 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// GetCurrentDlgBranch
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetCurrentDlgBranch") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (_dlgPendingBranches.GetSize() > 0) {
stack->PushString(_dlgPendingBranches[_dlgPendingBranches.GetSize() - 1]);
} else stack->PushNULL();
stack->pushString(_dlgPendingBranches[_dlgPendingBranches.GetSize() - 1]);
} else stack->pushNULL();
return S_OK;
}
@ -646,26 +646,26 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// IsItemTaken
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "IsItemTaken") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
CScValue *val = stack->Pop();
CScValue *val = stack->pop();
if (!val->IsNULL()) {
for (int i = 0; i < _inventories.GetSize(); i++) {
CAdInventory *Inv = _inventories[i];
for (int j = 0; j < Inv->_takenItems.GetSize(); j++) {
if (val->GetNative() == Inv->_takenItems[j]) {
stack->PushBool(true);
stack->pushBool(true);
return S_OK;
} else if (scumm_stricmp(val->GetString(), Inv->_takenItems[j]->_name) == 0) {
stack->PushBool(true);
stack->pushBool(true);
return S_OK;
}
}
}
} else script->RuntimeError("Game.IsItemTaken: item name expected");
stack->PushBool(false);
stack->pushBool(false);
return S_OK;
}
@ -673,11 +673,11 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// GetInventoryWindow
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetInventoryWindow") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (_inventoryBox && _inventoryBox->_window)
stack->PushNative(_inventoryBox->_window, true);
stack->pushNative(_inventoryBox->_window, true);
else
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -686,11 +686,11 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// GetResponsesWindow
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetResponsesWindow") == 0 || strcmp(name, "GetResponseWindow") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (_responseBox && _responseBox->_window)
stack->PushNative(_responseBox->_window, true);
stack->pushNative(_responseBox->_window, true);
else
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -699,18 +699,18 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// LoadResponseBox
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "LoadResponseBox") == 0) {
stack->CorrectParams(1);
const char *Filename = stack->Pop()->GetString();
stack->correctParams(1);
const char *Filename = stack->pop()->GetString();
Game->UnregisterObject(_responseBox);
_responseBox = new CAdResponseBox(Game);
if (_responseBox && !FAILED(_responseBox->loadFile(Filename))) {
RegisterObject(_responseBox);
stack->PushBool(true);
stack->pushBool(true);
} else {
delete _responseBox;
_responseBox = NULL;
stack->PushBool(false);
stack->pushBool(false);
}
return S_OK;
}
@ -719,18 +719,18 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// LoadInventoryBox
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "LoadInventoryBox") == 0) {
stack->CorrectParams(1);
const char *Filename = stack->Pop()->GetString();
stack->correctParams(1);
const char *Filename = stack->pop()->GetString();
Game->UnregisterObject(_inventoryBox);
_inventoryBox = new CAdInventoryBox(Game);
if (_inventoryBox && !FAILED(_inventoryBox->loadFile(Filename))) {
RegisterObject(_inventoryBox);
stack->PushBool(true);
stack->pushBool(true);
} else {
delete _inventoryBox;
_inventoryBox = NULL;
stack->PushBool(false);
stack->pushBool(false);
}
return S_OK;
}
@ -739,12 +739,12 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// LoadItems
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "LoadItems") == 0) {
stack->CorrectParams(2);
const char *Filename = stack->Pop()->GetString();
bool Merge = stack->Pop()->GetBool(false);
stack->correctParams(2);
const char *Filename = stack->pop()->GetString();
bool Merge = stack->pop()->GetBool(false);
HRESULT Ret = LoadItemsFile(Filename, Merge);
stack->PushBool(SUCCEEDED(Ret));
stack->pushBool(SUCCEEDED(Ret));
return S_OK;
}
@ -753,9 +753,9 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// AddSpeechDir
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "AddSpeechDir") == 0) {
stack->CorrectParams(1);
const char *Dir = stack->Pop()->GetString();
stack->PushBool(SUCCEEDED(AddSpeechDir(Dir)));
stack->correctParams(1);
const char *Dir = stack->pop()->GetString();
stack->pushBool(SUCCEEDED(AddSpeechDir(Dir)));
return S_OK;
}
@ -764,9 +764,9 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// RemoveSpeechDir
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "RemoveSpeechDir") == 0) {
stack->CorrectParams(1);
const char *Dir = stack->Pop()->GetString();
stack->PushBool(SUCCEEDED(RemoveSpeechDir(Dir)));
stack->correctParams(1);
const char *Dir = stack->pop()->GetString();
stack->pushBool(SUCCEEDED(RemoveSpeechDir(Dir)));
return S_OK;
}
@ -775,11 +775,11 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// SetSceneViewport
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetSceneViewport") == 0) {
stack->CorrectParams(4);
int X = stack->Pop()->GetInt();
int Y = stack->Pop()->GetInt();
int Width = stack->Pop()->GetInt();
int Height = stack->Pop()->GetInt();
stack->correctParams(4);
int X = stack->pop()->GetInt();
int Y = stack->pop()->GetInt();
int Width = stack->pop()->GetInt();
int Height = stack->pop()->GetInt();
if (Width <= 0) Width = _renderer->_width;
if (Height <= 0) Height = _renderer->_height;
@ -787,7 +787,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
if (!_sceneViewport) _sceneViewport = new CBViewport(Game);
if (_sceneViewport) _sceneViewport->setRect(X, Y, X + Width, Y + Height);
stack->PushBool(true);
stack->pushBool(true);
return S_OK;
}
@ -1065,22 +1065,22 @@ HRESULT CAdGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *this
// Actor
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "Actor") == 0) {
stack->CorrectParams(0);
this_obj = thisStack->GetTop();
stack->correctParams(0);
this_obj = thisStack->getTop();
this_obj->SetNative(new CAdActor(Game));
stack->PushNULL();
stack->pushNULL();
}
//////////////////////////////////////////////////////////////////////////
// Entity
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Entity") == 0) {
stack->CorrectParams(0);
this_obj = thisStack->GetTop();
stack->correctParams(0);
this_obj = thisStack->getTop();
this_obj->SetNative(new CAdEntity(Game));
stack->PushNULL();
stack->pushNULL();
}
@ -1520,12 +1520,12 @@ HRESULT CAdGame::WindowLoadHook(CUIWindow *Win, char **Buffer, char **params) {
//////////////////////////////////////////////////////////////////////////
HRESULT CAdGame::WindowScriptMethodHook(CUIWindow *Win, CScScript *script, CScStack *stack, const char *name) {
if (strcmp(name, "CreateEntityContainer") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
CUIEntity *Ent = new CUIEntity(Game);
if (!Val->IsNULL()) Ent->setName(Val->GetString());
stack->PushNative(Ent, true);
stack->pushNative(Ent, true);
Ent->_parent = Win;
Win->_widgets.Add(Ent);

View File

@ -434,23 +434,23 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// SetHoverSprite
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SetHoverSprite") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
bool SetCurrent = false;
if (_currentSprite && _currentSprite == _spriteHover) SetCurrent = true;
const char *Filename = stack->Pop()->GetString();
const char *Filename = stack->pop()->GetString();
delete _spriteHover;
_spriteHover = NULL;
CBSprite *spr = new CBSprite(Game, this);
if (!spr || FAILED(spr->loadFile(Filename))) {
stack->PushBool(false);
stack->pushBool(false);
script->RuntimeError("Item.SetHoverSprite failed for file '%s'", Filename);
} else {
_spriteHover = spr;
if (SetCurrent) _currentSprite = _spriteHover;
stack->PushBool(true);
stack->pushBool(true);
}
return S_OK;
}
@ -459,10 +459,10 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// GetHoverSprite
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetHoverSprite") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (!_spriteHover || !_spriteHover->_filename) stack->PushNULL();
else stack->PushString(_spriteHover->_filename);
if (!_spriteHover || !_spriteHover->_filename) stack->pushNULL();
else stack->pushString(_spriteHover->_filename);
return S_OK;
}
@ -470,9 +470,9 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// GetHoverSpriteObject
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetHoverSpriteObject") == 0) {
stack->CorrectParams(0);
if (!_spriteHover) stack->PushNULL();
else stack->PushNative(_spriteHover, true);
stack->correctParams(0);
if (!_spriteHover) stack->pushNULL();
else stack->pushNative(_spriteHover, true);
return S_OK;
}
@ -480,19 +480,19 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// SetNormalCursor
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SetNormalCursor") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
const char *Filename = stack->Pop()->GetString();
const char *Filename = stack->pop()->GetString();
delete _cursorNormal;
_cursorNormal = NULL;
CBSprite *spr = new CBSprite(Game);
if (!spr || FAILED(spr->loadFile(Filename))) {
stack->PushBool(false);
stack->pushBool(false);
script->RuntimeError("Item.SetNormalCursor failed for file '%s'", Filename);
} else {
_cursorNormal = spr;
stack->PushBool(true);
stack->pushBool(true);
}
return S_OK;
}
@ -501,10 +501,10 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// GetNormalCursor
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetNormalCursor") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (!_cursorNormal || !_cursorNormal->_filename) stack->PushNULL();
else stack->PushString(_cursorNormal->_filename);
if (!_cursorNormal || !_cursorNormal->_filename) stack->pushNULL();
else stack->pushString(_cursorNormal->_filename);
return S_OK;
}
@ -512,10 +512,10 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// GetNormalCursorObject
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetNormalCursorObject") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (!_cursorNormal) stack->PushNULL();
else stack->PushNative(_cursorNormal, true);
if (!_cursorNormal) stack->pushNULL();
else stack->pushNative(_cursorNormal, true);
return S_OK;
}
@ -523,19 +523,19 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// SetHoverCursor
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SetHoverCursor") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
const char *Filename = stack->Pop()->GetString();
const char *Filename = stack->pop()->GetString();
delete _cursorHover;
_cursorHover = NULL;
CBSprite *spr = new CBSprite(Game);
if (!spr || FAILED(spr->loadFile(Filename))) {
stack->PushBool(false);
stack->pushBool(false);
script->RuntimeError("Item.SetHoverCursor failed for file '%s'", Filename);
} else {
_cursorHover = spr;
stack->PushBool(true);
stack->pushBool(true);
}
return S_OK;
}
@ -544,10 +544,10 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// GetHoverCursor
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetHoverCursor") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (!_cursorHover || !_cursorHover->_filename) stack->PushNULL();
else stack->PushString(_cursorHover->_filename);
if (!_cursorHover || !_cursorHover->_filename) stack->pushNULL();
else stack->pushString(_cursorHover->_filename);
return S_OK;
}
@ -555,10 +555,10 @@ HRESULT CAdItem::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// GetHoverCursorObject
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetHoverCursorObject") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (!_cursorHover) stack->PushNULL();
else stack->PushNative(_cursorHover, true);
if (!_cursorHover) stack->pushNULL();
else stack->pushNative(_cursorHover, true);
return S_OK;
}

View File

@ -232,8 +232,8 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// GetNode
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "GetNode") == 0) {
stack->CorrectParams(1);
CScValue *val = stack->Pop();
stack->correctParams(1);
CScValue *val = stack->pop();
int node = -1;
if (val->_type == VAL_INT) node = val->GetInt();
@ -247,17 +247,17 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
}
}
if (node < 0 || node >= _nodes.GetSize()) stack->PushNULL();
if (node < 0 || node >= _nodes.GetSize()) stack->pushNULL();
else {
switch (_nodes[node]->_type) {
case OBJECT_ENTITY:
stack->PushNative(_nodes[node]->_entity, true);
stack->pushNative(_nodes[node]->_entity, true);
break;
case OBJECT_REGION:
stack->PushNative(_nodes[node]->_region, true);
stack->pushNative(_nodes[node]->_region, true);
break;
default:
stack->PushNULL();
stack->pushNULL();
}
}
return S_OK;
@ -267,20 +267,20 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// AddRegion / AddEntity
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "AddRegion") == 0 || strcmp(name, "AddEntity") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
CAdSceneNode *Node = new CAdSceneNode(Game);
if (strcmp(name, "AddRegion") == 0) {
CAdRegion *Region = new CAdRegion(Game);
if (!Val->IsNULL()) Region->setName(Val->GetString());
Node->setRegion(Region);
stack->PushNative(Region, true);
stack->pushNative(Region, true);
} else {
CAdEntity *Entity = new CAdEntity(Game);
if (!Val->IsNULL()) Entity->setName(Val->GetString());
Node->setEntity(Entity);
stack->PushNative(Entity, true);
stack->pushNative(Entity, true);
}
_nodes.Add(Node);
return S_OK;
@ -290,21 +290,21 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// InsertRegion / InsertEntity
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "InsertRegion") == 0 || strcmp(name, "InsertEntity") == 0) {
stack->CorrectParams(2);
int Index = stack->Pop()->GetInt();
CScValue *Val = stack->Pop();
stack->correctParams(2);
int Index = stack->pop()->GetInt();
CScValue *Val = stack->pop();
CAdSceneNode *Node = new CAdSceneNode(Game);
if (strcmp(name, "InsertRegion") == 0) {
CAdRegion *Region = new CAdRegion(Game);
if (!Val->IsNULL()) Region->setName(Val->GetString());
Node->setRegion(Region);
stack->PushNative(Region, true);
stack->pushNative(Region, true);
} else {
CAdEntity *Entity = new CAdEntity(Game);
if (!Val->IsNULL()) Entity->setName(Val->GetString());
Node->setEntity(Entity);
stack->PushNative(Entity, true);
stack->pushNative(Entity, true);
}
if (Index < 0) Index = 0;
if (Index <= _nodes.GetSize() - 1) _nodes.InsertAt(Index, Node);
@ -317,8 +317,8 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// DeleteNode
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "DeleteNode") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
CAdSceneNode *ToDelete = NULL;
if (Val->IsNative()) {
@ -336,7 +336,7 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
}
}
if (ToDelete == NULL) {
stack->PushBool(false);
stack->pushBool(false);
return S_OK;
}
@ -348,7 +348,7 @@ HRESULT CAdLayer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
break;
}
}
stack->PushBool(true);
stack->pushBool(true);
return S_OK;
}

View File

@ -193,11 +193,11 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// PlayAnim / PlayAnimAsync
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "PlayAnim") == 0 || strcmp(name, "PlayAnimAsync") == 0) {
stack->CorrectParams(1);
if (FAILED(playAnim(stack->Pop()->GetString()))) stack->PushBool(false);
stack->correctParams(1);
if (FAILED(playAnim(stack->pop()->GetString()))) stack->pushBool(false);
else {
if (strcmp(name, "PlayAnimAsync") != 0) script->WaitFor(this);
stack->PushBool(true);
stack->pushBool(true);
}
return S_OK;
}
@ -206,9 +206,9 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// Reset
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Reset") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
reset();
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -216,8 +216,8 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// IsTalking
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "IsTalking") == 0) {
stack->CorrectParams(0);
stack->PushBool(_state == STATE_TALKING);
stack->correctParams(0);
stack->pushBool(_state == STATE_TALKING);
return S_OK;
}
@ -225,13 +225,13 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// StopTalk / StopTalking
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "StopTalk") == 0 || strcmp(name, "StopTalking") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (_sentence) _sentence->finish();
if (_state == STATE_TALKING) {
_state = _nextState;
_nextState = STATE_READY;
stack->PushBool(true);
} else stack->PushBool(false);
stack->pushBool(true);
} else stack->pushBool(false);
return S_OK;
}
@ -239,13 +239,13 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// ForceTalkAnim
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "ForceTalkAnim") == 0) {
stack->CorrectParams(1);
const char *AnimName = stack->Pop()->GetString();
stack->correctParams(1);
const char *AnimName = stack->pop()->GetString();
delete[] _forcedTalkAnimName;
_forcedTalkAnimName = new char[strlen(AnimName) + 1];
strcpy(_forcedTalkAnimName, AnimName);
_forcedTalkAnimUsed = false;
stack->PushBool(true);
stack->pushBool(true);
return S_OK;
}
@ -254,17 +254,17 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// Talk / TalkAsync
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Talk") == 0 || strcmp(name, "TalkAsync") == 0) {
stack->CorrectParams(5);
stack->correctParams(5);
const char *Text = stack->Pop()->GetString();
CScValue *SoundVal = stack->Pop();
int Duration = stack->Pop()->GetInt();
CScValue *ValStances = stack->Pop();
const char *Text = stack->pop()->GetString();
CScValue *SoundVal = stack->pop();
int Duration = stack->pop()->GetInt();
CScValue *ValStances = stack->pop();
const char *Stances = ValStances->IsNULL() ? NULL : ValStances->GetString();
int Align;
CScValue *val = stack->Pop();
CScValue *val = stack->pop();
if (val->IsNULL()) Align = TAL_CENTER;
else Align = val->GetInt();
@ -275,7 +275,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
talk(Text, Sound, Duration, Stances, (TTextAlign)Align);
if (strcmp(name, "TalkAsync") != 0) script->WaitForExclusive(this);
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -283,13 +283,13 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// StickToRegion
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "StickToRegion") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
CAdLayer *Main = ((CAdGame *)Game)->_scene->_mainLayer;
bool RegFound = false;
int i;
CScValue *Val = stack->Pop();
CScValue *Val = stack->pop();
if (Val->IsNULL() || !Main) {
_stickRegion = NULL;
RegFound = true;
@ -316,7 +316,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
}
if (!RegFound) _stickRegion = NULL;
stack->PushBool(RegFound);
stack->pushBool(RegFound);
return S_OK;
}
@ -324,13 +324,13 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// SetFont
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetFont") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
if (Val->IsNULL()) SetFont(NULL);
else SetFont(Val->GetString());
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -338,9 +338,9 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// GetFont
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetFont") == 0) {
stack->CorrectParams(0);
if (_font && _font->_filename) stack->PushString(_font->_filename);
else stack->PushNULL();
stack->correctParams(0);
if (_font && _font->_filename) stack->pushString(_font->_filename);
else stack->pushNULL();
return S_OK;
}
@ -348,17 +348,17 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// TakeItem
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "TakeItem") == 0) {
stack->CorrectParams(2);
stack->correctParams(2);
if (!_inventory) {
_inventory = new CAdInventory(Game);
((CAdGame *)Game)->RegisterInventory(_inventory);
}
CScValue *val = stack->Pop();
CScValue *val = stack->pop();
if (!val->IsNULL()) {
const char *ItemName = val->GetString();
val = stack->Pop();
val = stack->pop();
const char *InsertAfter = val->IsNULL() ? NULL : val->GetString();
if (FAILED(_inventory->InsertItem(ItemName, InsertAfter))) script->RuntimeError("Cannot add item '%s' to inventory", ItemName);
else {
@ -368,7 +368,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
} else script->RuntimeError("TakeItem: item name expected");
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -376,14 +376,14 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// DropItem
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "DropItem") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
if (!_inventory) {
_inventory = new CAdInventory(Game);
((CAdGame *)Game)->RegisterInventory(_inventory);
}
CScValue *val = stack->Pop();
CScValue *val = stack->pop();
if (!val->IsNULL()) {
if (FAILED(_inventory->RemoveItem(val->GetString()))) script->RuntimeError("Cannot remove item '%s' from inventory", val->GetString());
else {
@ -392,7 +392,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
}
} else script->RuntimeError("DropItem: item name expected");
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -400,22 +400,22 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// GetItem
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetItem") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
if (!_inventory) {
_inventory = new CAdInventory(Game);
((CAdGame *)Game)->RegisterInventory(_inventory);
}
CScValue *val = stack->Pop();
CScValue *val = stack->pop();
if (val->_type == VAL_STRING) {
CAdItem *item = ((CAdGame *)Game)->GetItemByName(val->GetString());
if (item) stack->PushNative(item, true);
else stack->PushNULL();
if (item) stack->pushNative(item, true);
else stack->pushNULL();
} else if (val->IsNULL() || val->GetInt() < 0 || val->GetInt() >= _inventory->_takenItems.GetSize())
stack->PushNULL();
stack->pushNULL();
else
stack->PushNative(_inventory->_takenItems[val->GetInt()], true);
stack->pushNative(_inventory->_takenItems[val->GetInt()], true);
return S_OK;
}
@ -424,27 +424,27 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// HasItem
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "HasItem") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
if (!_inventory) {
_inventory = new CAdInventory(Game);
((CAdGame *)Game)->RegisterInventory(_inventory);
}
CScValue *val = stack->Pop();
CScValue *val = stack->pop();
if (!val->IsNULL()) {
for (int i = 0; i < _inventory->_takenItems.GetSize(); i++) {
if (val->GetNative() == _inventory->_takenItems[i]) {
stack->PushBool(true);
stack->pushBool(true);
return S_OK;
} else if (scumm_stricmp(val->GetString(), _inventory->_takenItems[i]->_name) == 0) {
stack->PushBool(true);
stack->pushBool(true);
return S_OK;
}
}
} else script->RuntimeError("HasItem: item name expected");
stack->PushBool(false);
stack->pushBool(false);
return S_OK;
}
@ -452,14 +452,14 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// CreateParticleEmitter
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "CreateParticleEmitter") == 0) {
stack->CorrectParams(3);
bool FollowParent = stack->Pop()->GetBool();
int OffsetX = stack->Pop()->GetInt();
int OffsetY = stack->Pop()->GetInt();
stack->correctParams(3);
bool FollowParent = stack->pop()->GetBool();
int OffsetX = stack->pop()->GetInt();
int OffsetY = stack->pop()->GetInt();
CPartEmitter *Emitter = createParticleEmitter(FollowParent, OffsetX, OffsetY);
if (Emitter) stack->PushNative(_partEmitter, true);
else stack->PushNULL();
if (Emitter) stack->pushNative(_partEmitter, true);
else stack->pushNULL();
return S_OK;
}
@ -468,12 +468,12 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// DeleteParticleEmitter
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "DeleteParticleEmitter") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (_partEmitter) {
Game->UnregisterObject(_partEmitter);
_partEmitter = NULL;
}
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -482,11 +482,11 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// AddAttachment
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "AddAttachment") == 0) {
stack->CorrectParams(4);
const char *Filename = stack->Pop()->GetString();
bool PreDisplay = stack->Pop()->GetBool(true);
int OffsetX = stack->Pop()->GetInt();
int OffsetY = stack->Pop()->GetInt();
stack->correctParams(4);
const char *Filename = stack->pop()->GetString();
bool PreDisplay = stack->pop()->GetBool(true);
int OffsetX = stack->pop()->GetInt();
int OffsetY = stack->pop()->GetInt();
HRESULT res;
CAdEntity *Ent = new CAdEntity(Game);
@ -494,7 +494,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
delete Ent;
Ent = NULL;
script->RuntimeError("AddAttachment() failed loading entity '%s'", Filename);
stack->PushBool(false);
stack->pushBool(false);
} else {
Game->RegisterObject(Ent);
@ -505,7 +505,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
if (PreDisplay) _attachmentsPre.Add(Ent);
else _attachmentsPost.Add(Ent);
stack->PushBool(true);
stack->pushBool(true);
}
return S_OK;
@ -515,8 +515,8 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// RemoveAttachment
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "RemoveAttachment") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
bool Found = false;
if (Val->IsNative()) {
CBScriptable *Obj = Val->GetNative();
@ -555,7 +555,7 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
}
}
}
stack->PushBool(Found);
stack->pushBool(Found);
return S_OK;
}
@ -564,8 +564,8 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// GetAttachment
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetAttachment") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
CAdObject *Ret = NULL;
if (Val->IsInt()) {
@ -597,8 +597,8 @@ HRESULT CAdObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
}
}
if (Ret != NULL) stack->PushNative(Ret, true);
else stack->PushNULL();
if (Ret != NULL) stack->pushNative(Ret, true);
else stack->pushNULL();
return S_OK;
}

View File

@ -225,10 +225,10 @@ HRESULT CAdRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// SkipTo
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SkipTo")==0) {
stack->CorrectParams(2);
_posX = stack->Pop()->GetInt();
_posY = stack->Pop()->GetInt();
stack->PushNULL();
stack->correctParams(2);
_posX = stack->pop()->GetInt();
_posY = stack->pop()->GetInt();
stack->pushNULL();
return S_OK;
}

View File

@ -492,7 +492,7 @@ HRESULT CAdResponseBox::listen(CBScriptHolder *param1, uint32 param2) {
} else if (scumm_stricmp(obj->_name, "next") == 0) {
_scrollOffset++;
} else if (scumm_stricmp(obj->_name, "response") == 0) {
if (_waitingScript) _waitingScript->_stack->PushInt(_responses[param2]->_iD);
if (_waitingScript) _waitingScript->_stack->pushInt(_responses[param2]->_iD);
handleResponse(_responses[param2]);
_waitingScript = NULL;
Game->_state = GAME_RUNNING;

View File

@ -1253,15 +1253,15 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// LoadActor
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "LoadActor") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
CAdActor *act = new CAdActor(Game);
if (act && SUCCEEDED(act->loadFile(stack->Pop()->GetString()))) {
if (act && SUCCEEDED(act->loadFile(stack->pop()->GetString()))) {
addObject(act);
stack->PushNative(act, true);
stack->pushNative(act, true);
} else {
delete act;
act = NULL;
stack->PushNULL();
stack->pushNULL();
}
return S_OK;
}
@ -1270,15 +1270,15 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// LoadEntity
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "LoadEntity") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
CAdEntity *ent = new CAdEntity(Game);
if (ent && SUCCEEDED(ent->loadFile(stack->Pop()->GetString()))) {
if (ent && SUCCEEDED(ent->loadFile(stack->pop()->GetString()))) {
addObject(ent);
stack->PushNative(ent, true);
stack->pushNative(ent, true);
} else {
delete ent;
ent = NULL;
stack->PushNULL();
stack->pushNULL();
}
return S_OK;
}
@ -1287,13 +1287,13 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// CreateEntity
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "CreateEntity") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
CAdEntity *Ent = new CAdEntity(Game);
addObject(Ent);
if (!Val->IsNULL()) Ent->setName(Val->GetString());
stack->PushNative(Ent, true);
stack->pushNative(Ent, true);
return S_OK;
}
@ -1301,13 +1301,13 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// UnloadObject / UnloadActor / UnloadEntity / UnloadActor3D / DeleteEntity
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "UnloadObject") == 0 || strcmp(name, "UnloadActor") == 0 || strcmp(name, "UnloadEntity") == 0 || strcmp(name, "UnloadActor3D") == 0 || strcmp(name, "DeleteEntity") == 0) {
stack->CorrectParams(1);
CScValue *val = stack->Pop();
stack->correctParams(1);
CScValue *val = stack->pop();
CAdObject *obj = (CAdObject *)val->GetNative();
removeObject(obj);
if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL();
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -1315,15 +1315,15 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// SkipTo
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SkipTo") == 0) {
stack->CorrectParams(2);
CScValue *val1 = stack->Pop();
CScValue *val2 = stack->Pop();
stack->correctParams(2);
CScValue *val1 = stack->pop();
CScValue *val2 = stack->pop();
if (val1->IsNative()) {
skipToObject((CBObject *)val1->GetNative());
} else {
skipTo(val1->GetInt(), val2->GetInt());
}
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -1331,16 +1331,16 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// ScrollTo / ScrollToAsync
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "ScrollTo") == 0 || strcmp(name, "ScrollToAsync") == 0) {
stack->CorrectParams(2);
CScValue *val1 = stack->Pop();
CScValue *val2 = stack->Pop();
stack->correctParams(2);
CScValue *val1 = stack->pop();
CScValue *val2 = stack->pop();
if (val1->IsNative()) {
scrollToObject((CBObject *)val1->GetNative());
} else {
scrollTo(val1->GetInt(), val2->GetInt());
}
if (strcmp(name, "ScrollTo") == 0) script->WaitForExclusive(this);
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -1348,23 +1348,23 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// GetLayer
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetLayer") == 0) {
stack->CorrectParams(1);
CScValue *val = stack->Pop();
stack->correctParams(1);
CScValue *val = stack->pop();
if (val->IsInt()) {
int layer = val->GetInt();
if (layer < 0 || layer >= _layers.GetSize()) stack->PushNULL();
else stack->PushNative(_layers[layer], true);
if (layer < 0 || layer >= _layers.GetSize()) stack->pushNULL();
else stack->pushNative(_layers[layer], true);
} else {
const char *LayerName = val->GetString();
bool LayerFound = false;
for (int i = 0; i < _layers.GetSize(); i++) {
if (scumm_stricmp(LayerName, _layers[i]->_name) == 0) {
stack->PushNative(_layers[i], true);
stack->pushNative(_layers[i], true);
LayerFound = true;
break;
}
}
if (!LayerFound) stack->PushNULL();
if (!LayerFound) stack->pushNULL();
}
return S_OK;
}
@ -1373,10 +1373,10 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// GetWaypointGroup
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetWaypointGroup") == 0) {
stack->CorrectParams(1);
int group = stack->Pop()->GetInt();
if (group < 0 || group >= _waypointGroups.GetSize()) stack->PushNULL();
else stack->PushNative(_waypointGroups[group], true);
stack->correctParams(1);
int group = stack->pop()->GetInt();
if (group < 0 || group >= _waypointGroups.GetSize()) stack->pushNULL();
else stack->pushNative(_waypointGroups[group], true);
return S_OK;
}
@ -1384,12 +1384,12 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// GetNode
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetNode") == 0) {
stack->CorrectParams(1);
const char *nodeName = stack->Pop()->GetString();
stack->correctParams(1);
const char *nodeName = stack->pop()->GetString();
CBObject *node = getNodeByName(nodeName);
if (node) stack->PushNative((CBScriptable *)node, true);
else stack->PushNULL();
if (node) stack->pushNative((CBScriptable *)node, true);
else stack->pushNULL();
return S_OK;
}
@ -1398,8 +1398,8 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// GetFreeNode
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetFreeNode") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
CAdObject *Ret = NULL;
if (Val->IsInt()) {
@ -1414,8 +1414,8 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
}
}
}
if (Ret) stack->PushNative(Ret, true);
else stack->PushNULL();
if (Ret) stack->pushNative(Ret, true);
else stack->pushNULL();
return S_OK;
}
@ -1424,10 +1424,10 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// GetRegionAt
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetRegionAt") == 0) {
stack->CorrectParams(3);
int X = stack->Pop()->GetInt();
int Y = stack->Pop()->GetInt();
CScValue *Val = stack->Pop();
stack->correctParams(3);
int X = stack->pop()->GetInt();
int Y = stack->pop()->GetInt();
CScValue *Val = stack->pop();
bool IncludeDecors = false;
if (!Val->IsNULL()) IncludeDecors = Val->GetBool();
@ -1438,12 +1438,12 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
if (Node->_type == OBJECT_REGION && Node->_region->_active && Node->_region->PointInRegion(X, Y)) {
if (Node->_region->_decoration && !IncludeDecors) continue;
stack->PushNative(Node->_region, true);
stack->pushNative(Node->_region, true);
return S_OK;
}
}
}
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -1451,11 +1451,11 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// IsBlockedAt
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "IsBlockedAt") == 0) {
stack->CorrectParams(2);
int X = stack->Pop()->GetInt();
int Y = stack->Pop()->GetInt();
stack->correctParams(2);
int X = stack->pop()->GetInt();
int Y = stack->pop()->GetInt();
stack->PushBool(isBlockedAt(X, Y));
stack->pushBool(isBlockedAt(X, Y));
return S_OK;
}
@ -1463,11 +1463,11 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// IsWalkableAt
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "IsWalkableAt") == 0) {
stack->CorrectParams(2);
int X = stack->Pop()->GetInt();
int Y = stack->Pop()->GetInt();
stack->correctParams(2);
int X = stack->pop()->GetInt();
int Y = stack->pop()->GetInt();
stack->PushBool(isWalkableAt(X, Y));
stack->pushBool(isWalkableAt(X, Y));
return S_OK;
}
@ -1475,11 +1475,11 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// GetScaleAt
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetScaleAt") == 0) {
stack->CorrectParams(2);
int X = stack->Pop()->GetInt();
int Y = stack->Pop()->GetInt();
stack->correctParams(2);
int X = stack->pop()->GetInt();
int Y = stack->pop()->GetInt();
stack->PushFloat(getZoomAt(X, Y));
stack->pushFloat(getZoomAt(X, Y));
return S_OK;
}
@ -1487,11 +1487,11 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// GetRotationAt
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetRotationAt") == 0) {
stack->CorrectParams(2);
int X = stack->Pop()->GetInt();
int Y = stack->Pop()->GetInt();
stack->correctParams(2);
int X = stack->pop()->GetInt();
int Y = stack->pop()->GetInt();
stack->PushFloat(getRotationAt(X, Y));
stack->pushFloat(getRotationAt(X, Y));
return S_OK;
}
@ -1499,13 +1499,13 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// IsScrolling
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "IsScrolling") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
bool Ret = false;
if (_autoScroll) {
if (_targetOffsetLeft != _offsetLeft || _targetOffsetTop != _offsetTop) Ret = true;
}
stack->PushBool(Ret);
stack->pushBool(Ret);
return S_OK;
}
@ -1513,17 +1513,17 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// FadeOut / FadeOutAsync
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0) {
stack->CorrectParams(5);
uint32 Duration = stack->Pop()->GetInt(500);
byte Red = stack->Pop()->GetInt(0);
byte Green = stack->Pop()->GetInt(0);
byte Blue = stack->Pop()->GetInt(0);
byte Alpha = stack->Pop()->GetInt(0xFF);
stack->correctParams(5);
uint32 Duration = stack->pop()->GetInt(500);
byte Red = stack->pop()->GetInt(0);
byte Green = stack->pop()->GetInt(0);
byte Blue = stack->pop()->GetInt(0);
byte Alpha = stack->pop()->GetInt(0xFF);
_fader->fadeOut(DRGBA(Red, Green, Blue, Alpha), Duration);
if (strcmp(name, "FadeOutAsync") != 0) script->WaitFor(_fader);
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -1531,17 +1531,17 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// FadeIn / FadeInAsync
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0) {
stack->CorrectParams(5);
uint32 Duration = stack->Pop()->GetInt(500);
byte Red = stack->Pop()->GetInt(0);
byte Green = stack->Pop()->GetInt(0);
byte Blue = stack->Pop()->GetInt(0);
byte Alpha = stack->Pop()->GetInt(0xFF);
stack->correctParams(5);
uint32 Duration = stack->pop()->GetInt(500);
byte Red = stack->pop()->GetInt(0);
byte Green = stack->pop()->GetInt(0);
byte Blue = stack->pop()->GetInt(0);
byte Alpha = stack->pop()->GetInt(0xFF);
_fader->fadeIn(DRGBA(Red, Green, Blue, Alpha), Duration);
if (strcmp(name, "FadeInAsync") != 0) script->WaitFor(_fader);
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -1549,8 +1549,8 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// GetFadeColor
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetFadeColor") == 0) {
stack->CorrectParams(0);
stack->PushInt(_fader->getCurrentColor());
stack->correctParams(0);
stack->pushInt(_fader->getCurrentColor());
return S_OK;
}
@ -1558,10 +1558,10 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// IsPointInViewport
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "IsPointInViewport") == 0) {
stack->CorrectParams(2);
int X = stack->Pop()->GetInt();
int Y = stack->Pop()->GetInt();
stack->PushBool(pointInViewport(X, Y));
stack->correctParams(2);
int X = stack->pop()->GetInt();
int Y = stack->pop()->GetInt();
stack->pushBool(pointInViewport(X, Y));
return S_OK;
}
@ -1569,11 +1569,11 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// SetViewport
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetViewport") == 0) {
stack->CorrectParams(4);
int X = stack->Pop()->GetInt();
int Y = stack->Pop()->GetInt();
int Width = stack->Pop()->GetInt();
int Height = stack->Pop()->GetInt();
stack->correctParams(4);
int X = stack->pop()->GetInt();
int Y = stack->pop()->GetInt();
int Width = stack->pop()->GetInt();
int Height = stack->pop()->GetInt();
if (Width <= 0) Width = Game->_renderer->_width;
if (Height <= 0) Height = Game->_renderer->_height;
@ -1581,7 +1581,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
if (!_viewport) _viewport = new CBViewport(Game);
if (_viewport) _viewport->setRect(X, Y, X + Width, Y + Height);
stack->PushBool(true);
stack->pushBool(true);
return S_OK;
}
@ -1590,8 +1590,8 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// AddLayer
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "AddLayer") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
CAdLayer *Layer = new CAdLayer(Game);
if (!Val->IsNULL()) Layer->setName(Val->GetString());
@ -1602,7 +1602,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
_layers.Add(Layer);
Game->RegisterObject(Layer);
stack->PushNative(Layer, true);
stack->pushNative(Layer, true);
return S_OK;
}
@ -1610,9 +1610,9 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// InsertLayer
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "InsertLayer") == 0) {
stack->CorrectParams(2);
int Index = stack->Pop()->GetInt();
CScValue *Val = stack->Pop();
stack->correctParams(2);
int Index = stack->pop()->GetInt();
CScValue *Val = stack->pop();
CAdLayer *Layer = new CAdLayer(Game);
if (!Val->IsNULL()) Layer->setName(Val->GetString());
@ -1626,7 +1626,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
Game->RegisterObject(Layer);
stack->PushNative(Layer, true);
stack->pushNative(Layer, true);
return S_OK;
}
@ -1634,8 +1634,8 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// DeleteLayer
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "DeleteLayer") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
CAdLayer *ToDelete = NULL;
if (Val->IsNative()) {
@ -1653,13 +1653,13 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
}
}
if (ToDelete == NULL) {
stack->PushBool(false);
stack->pushBool(false);
return S_OK;
}
if (ToDelete->_main) {
script->RuntimeError("Scene.DeleteLayer - cannot delete main scene layer");
stack->PushBool(false);
stack->pushBool(false);
return S_OK;
}
@ -1670,7 +1670,7 @@ HRESULT CAdScene::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
break;
}
}
stack->PushBool(true);
stack->pushBool(true);
return S_OK;
}

View File

@ -123,9 +123,9 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack
// SetSprite
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SetSprite") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
CScValue *Val = stack->Pop();
CScValue *Val = stack->pop();
bool SetCurrent = false;
if (_currentSprite && _currentSprite == _sprite) SetCurrent = true;
@ -136,17 +136,17 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack
if (Val->IsNULL()) {
_sprite = NULL;
if (SetCurrent) _currentSprite = NULL;
stack->PushBool(true);
stack->pushBool(true);
} else {
const char *Filename = Val->GetString();
CBSprite *spr = new CBSprite(Game, this);
if (!spr || FAILED(spr->loadFile(Filename))) {
script->RuntimeError("SetSprite method failed for file '%s'", Filename);
stack->PushBool(false);
stack->pushBool(false);
} else {
_sprite = spr;
if (SetCurrent) _currentSprite = _sprite;
stack->PushBool(true);
stack->pushBool(true);
}
}
return S_OK;
@ -156,10 +156,10 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack
// GetSprite
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetSprite") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (!_sprite || !_sprite->_filename) stack->PushNULL();
else stack->PushString(_sprite->_filename);
if (!_sprite || !_sprite->_filename) stack->pushNULL();
else stack->pushString(_sprite->_filename);
return S_OK;
}
@ -167,10 +167,10 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack
// GetSpriteObject
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetSpriteObject") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (!_sprite) stack->PushNULL();
else stack->PushNative(_sprite, true);
if (!_sprite) stack->pushNULL();
else stack->pushNative(_sprite, true);
return S_OK;
}
@ -178,19 +178,19 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack
// AddTalkSprite
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "AddTalkSprite") == 0) {
stack->CorrectParams(2);
stack->correctParams(2);
const char *Filename = stack->Pop()->GetString();
bool Ex = stack->Pop()->GetBool();
const char *Filename = stack->pop()->GetString();
bool Ex = stack->pop()->GetBool();
CBSprite *spr = new CBSprite(Game, this);
if (!spr || FAILED(spr->loadFile(Filename))) {
stack->PushBool(false);
stack->pushBool(false);
script->RuntimeError("AddTalkSprite method failed for file '%s'", Filename);
} else {
if (Ex) _talkSpritesEx.Add(spr);
else _talkSprites.Add(spr);
stack->PushBool(true);
stack->pushBool(true);
}
return S_OK;
}
@ -199,10 +199,10 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack
// RemoveTalkSprite
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "RemoveTalkSprite") == 0) {
stack->CorrectParams(2);
stack->correctParams(2);
const char *Filename = stack->Pop()->GetString();
bool Ex = stack->Pop()->GetBool();
const char *Filename = stack->pop()->GetString();
bool Ex = stack->pop()->GetBool();
int i;
bool SetCurrent = false;
@ -231,7 +231,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack
}
stack->PushBool(true);
stack->pushBool(true);
if (SetCurrent) _currentSprite = _sprite;
if (SetTemp2) _tempSprite2 = _sprite;
@ -242,16 +242,16 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack
// SetTalkSprite
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetTalkSprite") == 0) {
stack->CorrectParams(2);
stack->correctParams(2);
const char *Filename = stack->Pop()->GetString();
bool Ex = stack->Pop()->GetBool();
const char *Filename = stack->pop()->GetString();
bool Ex = stack->pop()->GetBool();
bool SetCurrent = false;
bool SetTemp2 = false;
CBSprite *spr = new CBSprite(Game, this);
if (!spr || FAILED(spr->loadFile(Filename))) {
stack->PushBool(false);
stack->pushBool(false);
script->RuntimeError("SetTalkSprite method failed for file '%s'", Filename);
} else {
@ -276,7 +276,7 @@ HRESULT CAdTalkHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack
// set new
if (Ex) _talkSpritesEx.Add(spr);
else _talkSprites.Add(spr);
stack->PushBool(true);
stack->pushBool(true);
if (SetCurrent) _currentSprite = spr;
if (SetTemp2) _tempSprite2 = spr;

View File

@ -407,10 +407,10 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// GetSound
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "GetSound") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (_sound && _sound->_soundFilename) stack->PushString(_sound->_soundFilename);
else stack->PushNULL();
if (_sound && _sound->_soundFilename) stack->pushString(_sound->_soundFilename);
else stack->pushNULL();
return S_OK;
}
@ -418,19 +418,19 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// SetSound
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SetSound") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
delete _sound;
_sound = NULL;
if (!Val->IsNULL()) {
_sound = new CBSound(Game);
if (!_sound || FAILED(_sound->setSound(Val->GetString(), SOUND_SFX, false))) {
stack->PushBool(false);
stack->pushBool(false);
delete _sound;
_sound = NULL;
} else stack->PushBool(true);
} else stack->PushBool(true);
} else stack->pushBool(true);
} else stack->pushBool(true);
return S_OK;
}
@ -438,12 +438,12 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// GetSubframe
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "GetSubframe") == 0) {
stack->CorrectParams(1);
int Index = stack->Pop()->GetInt(-1);
stack->correctParams(1);
int Index = stack->pop()->GetInt(-1);
if (Index < 0 || Index >= _subframes.GetSize()) {
script->RuntimeError("Frame.GetSubframe: Subframe index %d is out of range.", Index);
stack->PushNULL();
} else stack->PushNative(_subframes[Index], true);
stack->pushNULL();
} else stack->pushNative(_subframes[Index], true);
return S_OK;
}
@ -452,8 +452,8 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// DeleteSubframe
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "DeleteSubframe") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
if (Val->IsInt()) {
int Index = Val->GetInt(-1);
if (Index < 0 || Index >= _subframes.GetSize()) {
@ -469,7 +469,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
}
}
}
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -477,8 +477,8 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// AddSubframe
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "AddSubframe") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
const char *Filename = NULL;
if (!Val->IsNULL()) Filename = Val->GetString();
@ -489,7 +489,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
}
_subframes.Add(Sub);
stack->PushNative(Sub, true);
stack->pushNative(Sub, true);
return S_OK;
}
@ -497,11 +497,11 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// InsertSubframe
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "InsertSubframe") == 0) {
stack->CorrectParams(2);
int Index = stack->Pop()->GetInt();
stack->correctParams(2);
int Index = stack->pop()->GetInt();
if (Index < 0) Index = 0;
CScValue *Val = stack->Pop();
CScValue *Val = stack->pop();
const char *Filename = NULL;
if (!Val->IsNULL()) Filename = Val->GetString();
@ -513,7 +513,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
if (Index >= _subframes.GetSize()) _subframes.Add(Sub);
else _subframes.InsertAt(Index, Sub);
stack->PushNative(Sub, true);
stack->pushNative(Sub, true);
return S_OK;
}
@ -521,12 +521,12 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// GetEvent
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetSubframe") == 0) {
stack->CorrectParams(1);
int Index = stack->Pop()->GetInt(-1);
stack->correctParams(1);
int Index = stack->pop()->GetInt(-1);
if (Index < 0 || Index >= _applyEvent.GetSize()) {
script->RuntimeError("Frame.GetEvent: Event index %d is out of range.", Index);
stack->PushNULL();
} else stack->PushString(_applyEvent[Index]);
stack->pushNULL();
} else stack->pushString(_applyEvent[Index]);
return S_OK;
}
@ -534,16 +534,16 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// AddEvent
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "AddEvent") == 0) {
stack->CorrectParams(1);
const char *Event = stack->Pop()->GetString();
stack->correctParams(1);
const char *Event = stack->pop()->GetString();
for (int i = 0; i < _applyEvent.GetSize(); i++) {
if (scumm_stricmp(_applyEvent[i], Event) == 0) {
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
}
_applyEvent.Add(Event);
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -551,8 +551,8 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// DeleteEvent
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "DeleteEvent") == 0) {
stack->CorrectParams(1);
const char *Event = stack->Pop()->GetString();
stack->correctParams(1);
const char *Event = stack->pop()->GetString();
for (int i = 0; i < _applyEvent.GetSize(); i++) {
if (scumm_stricmp(_applyEvent[i], Event) == 0) {
delete [] _applyEvent[i];
@ -560,7 +560,7 @@ HRESULT CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
break;
}
}
stack->PushNULL();
stack->pushNULL();
return S_OK;
}

File diff suppressed because it is too large Load Diff

View File

@ -78,8 +78,8 @@ HRESULT CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScSta
// IsKeyDown
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "IsKeyDown") == 0) {
stack->CorrectParams(1);
CScValue *val = stack->Pop();
stack->correctParams(1);
CScValue *val = stack->pop();
int vKey;
if (val->_type == VAL_STRING && strlen(val->GetString()) > 0) {
@ -94,7 +94,7 @@ HRESULT CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScSta
// SDL_Scancode scanCode = SDL_GetScancodeFromKey(VKeyToKeyCode(vKey));
bool isDown = _keyStates[VKeyToKeyCode(vKey)];
stack->PushBool(isDown);
stack->pushBool(isDown);
return S_OK;
}

View File

@ -171,11 +171,11 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// SkipTo
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SkipTo") == 0) {
stack->CorrectParams(2);
_posX = stack->Pop()->GetInt();
_posY = stack->Pop()->GetInt();
stack->correctParams(2);
_posX = stack->pop()->GetInt();
_posY = stack->pop()->GetInt();
afterMove();
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -184,8 +184,8 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// Caption
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Caption") == 0) {
stack->CorrectParams(1);
stack->PushString(getCaption(stack->Pop()->GetInt()));
stack->correctParams(1);
stack->pushString(getCaption(stack->pop()->GetInt()));
return S_OK;
}
@ -194,9 +194,9 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// SetCursor
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetCursor") == 0) {
stack->CorrectParams(1);
if (SUCCEEDED(setCursor(stack->Pop()->GetString()))) stack->PushBool(true);
else stack->PushBool(false);
stack->correctParams(1);
if (SUCCEEDED(setCursor(stack->pop()->GetString()))) stack->pushBool(true);
else stack->pushBool(false);
return S_OK;
}
@ -205,7 +205,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// RemoveCursor
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "RemoveCursor") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (!_sharedCursors) {
delete _cursor;
_cursor = NULL;
@ -213,7 +213,7 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
_cursor = NULL;
}
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -222,9 +222,9 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// GetCursor
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetCursor") == 0) {
stack->CorrectParams(0);
if (!_cursor || !_cursor->_filename) stack->PushNULL();
else stack->PushString(_cursor->_filename);
stack->correctParams(0);
if (!_cursor || !_cursor->_filename) stack->pushNULL();
else stack->pushString(_cursor->_filename);
return S_OK;
}
@ -233,9 +233,9 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// GetCursorObject
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetCursorObject") == 0) {
stack->CorrectParams(0);
if (!_cursor) stack->PushNULL();
else stack->PushNative(_cursor, true);
stack->correctParams(0);
if (!_cursor) stack->pushNULL();
else stack->pushNative(_cursor, true);
return S_OK;
}
@ -244,10 +244,10 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// HasCursor
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "HasCursor") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (_cursor) stack->PushBool(true);
else stack->PushBool(false);
if (_cursor) stack->pushBool(true);
else stack->pushBool(false);
return S_OK;
}
@ -256,9 +256,9 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// SetCaption
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetCaption") == 0) {
stack->CorrectParams(2);
setCaption(stack->Pop()->GetString(), stack->Pop()->GetInt());
stack->PushNULL();
stack->correctParams(2);
setCaption(stack->pop()->GetString(), stack->pop()->GetInt());
stack->pushNULL();
return S_OK;
}
@ -267,12 +267,12 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// LoadSound
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "LoadSound") == 0) {
stack->CorrectParams(1);
const char *Filename = stack->Pop()->GetString();
stack->correctParams(1);
const char *Filename = stack->pop()->GetString();
if (SUCCEEDED(playSFX(Filename, false, false)))
stack->PushBool(true);
stack->pushBool(true);
else
stack->PushBool(false);
stack->pushBool(false);
return S_OK;
}
@ -281,15 +281,15 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// PlaySound
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "PlaySound") == 0) {
stack->CorrectParams(3);
stack->correctParams(3);
const char *Filename;
bool Looping;
uint32 LoopStart;
CScValue *val1 = stack->Pop();
CScValue *val2 = stack->Pop();
CScValue *val3 = stack->Pop();
CScValue *val1 = stack->pop();
CScValue *val2 = stack->pop();
CScValue *val3 = stack->pop();
if (val1->_type == VAL_BOOL) {
Filename = NULL;
@ -302,8 +302,8 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
LoopStart = val3->GetInt();
}
if (FAILED(playSFX(Filename, Looping, true, NULL, LoopStart))) stack->PushBool(false);
else stack->PushBool(true);
if (FAILED(playSFX(Filename, Looping, true, NULL, LoopStart))) stack->pushBool(false);
else stack->pushBool(true);
return S_OK;
}
@ -311,13 +311,13 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// PlaySoundEvent
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "PlaySoundEvent") == 0) {
stack->CorrectParams(2);
stack->correctParams(2);
const char *Filename;
const char *EventName;
CScValue *val1 = stack->Pop();
CScValue *val2 = stack->Pop();
CScValue *val1 = stack->pop();
CScValue *val2 = stack->pop();
if (val2->IsNULL()) {
Filename = NULL;
@ -327,8 +327,8 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
EventName = val2->GetString();
}
if (FAILED(playSFX(Filename, false, true, EventName))) stack->PushBool(false);
else stack->PushBool(true);
if (FAILED(playSFX(Filename, false, true, EventName))) stack->pushBool(false);
else stack->pushBool(true);
return S_OK;
}
@ -336,10 +336,10 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// StopSound
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "StopSound") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (FAILED(stopSFX())) stack->PushBool(false);
else stack->PushBool(true);
if (FAILED(stopSFX())) stack->pushBool(false);
else stack->pushBool(true);
return S_OK;
}
@ -347,10 +347,10 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// PauseSound
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "PauseSound") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (FAILED(pauseSFX())) stack->PushBool(false);
else stack->PushBool(true);
if (FAILED(pauseSFX())) stack->pushBool(false);
else stack->pushBool(true);
return S_OK;
}
@ -358,10 +358,10 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// ResumeSound
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "ResumeSound") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (FAILED(resumeSFX())) stack->PushBool(false);
else stack->PushBool(true);
if (FAILED(resumeSFX())) stack->pushBool(false);
else stack->pushBool(true);
return S_OK;
}
@ -369,10 +369,10 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// IsSoundPlaying
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "IsSoundPlaying") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (_sFX && _sFX->isPlaying()) stack->PushBool(true);
else stack->PushBool(false);
if (_sFX && _sFX->isPlaying()) stack->pushBool(true);
else stack->pushBool(false);
return S_OK;
}
@ -380,11 +380,11 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// SetSoundPosition
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetSoundPosition") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
uint32 Time = stack->Pop()->GetInt();
if (FAILED(setSFXTime(Time))) stack->PushBool(false);
else stack->PushBool(true);
uint32 Time = stack->pop()->GetInt();
if (FAILED(setSFXTime(Time))) stack->pushBool(false);
else stack->pushBool(true);
return S_OK;
}
@ -392,10 +392,10 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// GetSoundPosition
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetSoundPosition") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (!_sFX) stack->PushInt(0);
else stack->PushInt(_sFX->getPositionTime());
if (!_sFX) stack->pushInt(0);
else stack->pushInt(_sFX->getPositionTime());
return S_OK;
}
@ -403,11 +403,11 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// SetSoundVolume
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetSoundVolume") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
int Volume = stack->Pop()->GetInt();
if (FAILED(setSFXVolume(Volume))) stack->PushBool(false);
else stack->PushBool(true);
int Volume = stack->pop()->GetInt();
if (FAILED(setSFXVolume(Volume))) stack->pushBool(false);
else stack->pushBool(true);
return S_OK;
}
@ -415,10 +415,10 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// GetSoundVolume
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetSoundVolume") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (!_sFX) stack->PushInt(_sFXVolume);
else stack->PushInt(_sFX->getVolume());
if (!_sFX) stack->pushInt(_sFXVolume);
else stack->pushInt(_sFX->getVolume());
return S_OK;
}
@ -427,13 +427,13 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// SoundFXNone
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SoundFXNone") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
_sFXType = SFX_NONE;
_sFXParam1 = 0;
_sFXParam2 = 0;
_sFXParam3 = 0;
_sFXParam4 = 0;
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -442,13 +442,13 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// SoundFXEcho
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SoundFXEcho") == 0) {
stack->CorrectParams(4);
stack->correctParams(4);
_sFXType = SFX_ECHO;
_sFXParam1 = (float)stack->Pop()->GetFloat(0); // Wet/Dry Mix [%] (0-100)
_sFXParam2 = (float)stack->Pop()->GetFloat(0); // Feedback [%] (0-100)
_sFXParam3 = (float)stack->Pop()->GetFloat(333.0f); // Left Delay [ms] (1-2000)
_sFXParam4 = (float)stack->Pop()->GetFloat(333.0f); // Right Delay [ms] (1-2000)
stack->PushNULL();
_sFXParam1 = (float)stack->pop()->GetFloat(0); // Wet/Dry Mix [%] (0-100)
_sFXParam2 = (float)stack->pop()->GetFloat(0); // Feedback [%] (0-100)
_sFXParam3 = (float)stack->pop()->GetFloat(333.0f); // Left Delay [ms] (1-2000)
_sFXParam4 = (float)stack->pop()->GetFloat(333.0f); // Right Delay [ms] (1-2000)
stack->pushNULL();
return S_OK;
}
@ -457,13 +457,13 @@ HRESULT CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// SoundFXReverb
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SoundFXReverb") == 0) {
stack->CorrectParams(4);
stack->correctParams(4);
_sFXType = SFX_REVERB;
_sFXParam1 = (float)stack->Pop()->GetFloat(0); // In Gain [dB] (-96 - 0)
_sFXParam2 = (float)stack->Pop()->GetFloat(0); // Reverb Mix [dB] (-96 - 0)
_sFXParam3 = (float)stack->Pop()->GetFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000)
_sFXParam4 = (float)stack->Pop()->GetFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999)
stack->PushNULL();
_sFXParam1 = (float)stack->pop()->GetFloat(0); // In Gain [dB] (-96 - 0)
_sFXParam2 = (float)stack->pop()->GetFloat(0); // Reverb Mix [dB] (-96 - 0)
_sFXParam3 = (float)stack->pop()->GetFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000)
_sFXParam4 = (float)stack->pop()->GetFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999)
stack->pushNULL();
return S_OK;
}

View File

@ -216,14 +216,14 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// AddPoint
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "AddPoint") == 0) {
stack->CorrectParams(2);
int X = stack->Pop()->GetInt();
int Y = stack->Pop()->GetInt();
stack->correctParams(2);
int X = stack->pop()->GetInt();
int Y = stack->pop()->GetInt();
_points.Add(new CBPoint(X, Y));
CreateRegion();
stack->PushBool(true);
stack->pushBool(true);
return S_OK;
}
@ -232,17 +232,17 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// InsertPoint
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "InsertPoint") == 0) {
stack->CorrectParams(3);
int Index = stack->Pop()->GetInt();
int X = stack->Pop()->GetInt();
int Y = stack->Pop()->GetInt();
stack->correctParams(3);
int Index = stack->pop()->GetInt();
int X = stack->pop()->GetInt();
int Y = stack->pop()->GetInt();
if (Index >= 0 && Index < _points.GetSize()) {
_points.InsertAt(Index, new CBPoint(X, Y));
CreateRegion();
stack->PushBool(true);
} else stack->PushBool(false);
stack->pushBool(true);
} else stack->pushBool(false);
return S_OK;
}
@ -251,18 +251,18 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// SetPoint
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetPoint") == 0) {
stack->CorrectParams(3);
int Index = stack->Pop()->GetInt();
int X = stack->Pop()->GetInt();
int Y = stack->Pop()->GetInt();
stack->correctParams(3);
int Index = stack->pop()->GetInt();
int X = stack->pop()->GetInt();
int Y = stack->pop()->GetInt();
if (Index >= 0 && Index < _points.GetSize()) {
_points[Index]->x = X;
_points[Index]->y = Y;
CreateRegion();
stack->PushBool(true);
} else stack->PushBool(false);
stack->pushBool(true);
} else stack->pushBool(false);
return S_OK;
}
@ -271,8 +271,8 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// RemovePoint
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "RemovePoint") == 0) {
stack->CorrectParams(1);
int Index = stack->Pop()->GetInt();
stack->correctParams(1);
int Index = stack->pop()->GetInt();
if (Index >= 0 && Index < _points.GetSize()) {
delete _points[Index];
@ -281,8 +281,8 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
_points.RemoveAt(Index);
CreateRegion();
stack->PushBool(true);
} else stack->PushBool(false);
stack->pushBool(true);
} else stack->pushBool(false);
return S_OK;
}
@ -291,16 +291,16 @@ HRESULT CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// GetPoint
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetPoint") == 0) {
stack->CorrectParams(1);
int Index = stack->Pop()->GetInt();
stack->correctParams(1);
int Index = stack->pop()->GetInt();
if (Index >= 0 && Index < _points.GetSize()) {
CScValue *Val = stack->GetPushValue();
CScValue *Val = stack->getPushValue();
if (Val) {
Val->SetProperty("X", _points[Index]->x);
Val->SetProperty("Y", _points[Index]->y);
}
} else stack->PushNULL();
} else stack->pushNULL();
return S_OK;
}

View File

@ -114,10 +114,10 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac
// DEBUG_CrashMe
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "DEBUG_CrashMe") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
byte *p = 0;
*p = 10;
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -126,13 +126,13 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac
// ApplyEvent
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "ApplyEvent") == 0) {
stack->CorrectParams(1);
CScValue *val = stack->Pop();
stack->correctParams(1);
CScValue *val = stack->pop();
HRESULT ret;
ret = applyEvent(val->GetString());
if (SUCCEEDED(ret)) stack->PushBool(true);
else stack->PushBool(false);
if (SUCCEEDED(ret)) stack->pushBool(true);
else stack->pushBool(false);
return S_OK;
}
@ -141,8 +141,8 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac
// CanHandleEvent
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "CanHandleEvent") == 0) {
stack->CorrectParams(1);
stack->PushBool(canHandleEvent(stack->Pop()->GetString()));
stack->correctParams(1);
stack->pushBool(canHandleEvent(stack->pop()->GetString()));
return S_OK;
}
@ -151,8 +151,8 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac
// CanHandleMethod
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "CanHandleMethod") == 0) {
stack->CorrectParams(1);
stack->PushBool(canHandleMethod(stack->Pop()->GetString()));
stack->correctParams(1);
stack->pushBool(canHandleMethod(stack->pop()->GetString()));
return S_OK;
}
@ -161,8 +161,8 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac
// AttachScript
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "AttachScript") == 0) {
stack->CorrectParams(1);
stack->PushBool(SUCCEEDED(addScript(stack->Pop()->GetString())));
stack->correctParams(1);
stack->pushBool(SUCCEEDED(addScript(stack->pop()->GetString())));
return S_OK;
}
@ -171,9 +171,9 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac
// DetachScript
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "DetachScript") == 0) {
stack->CorrectParams(2);
const char *Filename = stack->Pop()->GetString();
bool KillThreads = stack->Pop()->GetBool(false);
stack->correctParams(2);
const char *Filename = stack->pop()->GetString();
bool KillThreads = stack->pop()->GetBool(false);
bool ret = false;
for (int i = 0; i < _scripts.GetSize(); i++) {
if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0) {
@ -182,7 +182,7 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac
break;
}
}
stack->PushBool(ret);
stack->pushBool(ret);
return S_OK;
}
@ -191,8 +191,8 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac
// IsScriptRunning
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "IsScriptRunning") == 0) {
stack->CorrectParams(1);
const char *Filename = stack->Pop()->GetString();
stack->correctParams(1);
const char *Filename = stack->pop()->GetString();
bool ret = false;
for (int i = 0; i < _scripts.GetSize(); i++) {
if (scumm_stricmp(_scripts[i]->_filename, Filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) {
@ -200,7 +200,7 @@ HRESULT CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStac
break;
}
}
stack->PushBool(ret);
stack->pushBool(ret);
return S_OK;
} else return CBScriptable::scCallMethod(script, stack, thisStack, name);

View File

@ -63,8 +63,8 @@ CBScriptable::~CBScriptable() {
//////////////////////////////////////////////////////////////////////////
HRESULT CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) {
/*
stack->CorrectParams(0);
stack->PushNULL();
stack->correctParams(0);
stack->pushNULL();
script->RuntimeError("Call to undefined method '%s'.", name);
return S_OK;

View File

@ -512,12 +512,12 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// GetFrame
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "GetFrame") == 0) {
stack->CorrectParams(1);
int Index = stack->Pop()->GetInt(-1);
stack->correctParams(1);
int Index = stack->pop()->GetInt(-1);
if (Index < 0 || Index >= _frames.GetSize()) {
script->RuntimeError("Sprite.GetFrame: Frame index %d is out of range.", Index);
stack->PushNULL();
} else stack->PushNative(_frames[Index], true);
stack->pushNULL();
} else stack->pushNative(_frames[Index], true);
return S_OK;
}
@ -525,8 +525,8 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// DeleteFrame
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "DeleteFrame") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
if (Val->IsInt()) {
int Index = Val->GetInt(-1);
if (Index < 0 || Index >= _frames.GetSize()) {
@ -543,7 +543,7 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
}
}
}
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -551,9 +551,9 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// Reset
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Reset") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
Reset();
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -561,8 +561,8 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// AddFrame
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "AddFrame") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
const char *Filename = NULL;
if (!Val->IsNULL()) Filename = Val->GetString();
@ -576,7 +576,7 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
}
_frames.Add(Frame);
stack->PushNative(Frame, true);
stack->pushNative(Frame, true);
return S_OK;
}
@ -584,11 +584,11 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// InsertFrame
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "InsertFrame") == 0) {
stack->CorrectParams(2);
int Index = stack->Pop()->GetInt();
stack->correctParams(2);
int Index = stack->pop()->GetInt();
if (Index < 0) Index = 0;
CScValue *Val = stack->Pop();
CScValue *Val = stack->pop();
const char *Filename = NULL;
if (!Val->IsNULL()) Filename = Val->GetString();
@ -602,7 +602,7 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
if (Index >= _frames.GetSize()) _frames.Add(Frame);
else _frames.InsertAt(Index, Frame);
stack->PushNative(Frame, true);
stack->pushNative(Frame, true);
return S_OK;
}
@ -610,9 +610,9 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// Pause
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Pause") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
_paused = true;
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -620,9 +620,9 @@ HRESULT CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thi
// Play
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Play") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
_paused = false;
stack->PushNULL();
stack->pushNULL();
return S_OK;
}

View File

@ -348,10 +348,10 @@ HRESULT CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *t
// GetImage
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "GetImage") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (!_surfaceFilename) stack->PushNULL();
else stack->PushString(_surfaceFilename);
if (!_surfaceFilename) stack->pushNULL();
else stack->pushString(_surfaceFilename);
return S_OK;
}
@ -359,20 +359,20 @@ HRESULT CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *t
// SetImage
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetImage") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
if (Val->IsNULL()) {
if (_surface) Game->_surfaceStorage->removeSurface(_surface);
delete[] _surfaceFilename;
_surfaceFilename = NULL;
stack->PushBool(true);
stack->pushBool(true);
} else {
const char *Filename = Val->GetString();
if (SUCCEEDED(setSurface(Filename))) {
setDefaultRect();
stack->PushBool(true);
} else stack->PushBool(false);
stack->pushBool(true);
} else stack->pushBool(false);
}
return S_OK;

View File

@ -421,13 +421,13 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack
// SetBorder
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SetBorder") == 0) {
stack->CorrectParams(4);
int BorderX = stack->Pop()->GetInt();
int BorderY = stack->Pop()->GetInt();
int BorderWidth = stack->Pop()->GetInt();
int BorderHeight = stack->Pop()->GetInt();
stack->correctParams(4);
int BorderX = stack->pop()->GetInt();
int BorderY = stack->pop()->GetInt();
int BorderWidth = stack->pop()->GetInt();
int BorderHeight = stack->pop()->GetInt();
stack->PushBool(SUCCEEDED(setBorder(BorderX, BorderY, BorderWidth, BorderHeight)));
stack->pushBool(SUCCEEDED(setBorder(BorderX, BorderY, BorderWidth, BorderHeight)));
return S_OK;
}
@ -435,13 +435,13 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack
// SetBorderThickness
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetBorderThickness") == 0) {
stack->CorrectParams(4);
int Left = stack->Pop()->GetInt();
int Right = stack->Pop()->GetInt();
int Top = stack->Pop()->GetInt();
int Bottom = stack->Pop()->GetInt();
stack->correctParams(4);
int Left = stack->pop()->GetInt();
int Right = stack->pop()->GetInt();
int Top = stack->pop()->GetInt();
int Bottom = stack->pop()->GetInt();
stack->PushBool(SUCCEEDED(setBorderThickness(Left, Right, Top, Bottom)));
stack->pushBool(SUCCEEDED(setBorderThickness(Left, Right, Top, Bottom)));
return S_OK;
}
@ -449,9 +449,9 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack
// AddSprite
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "AddSprite") == 0) {
stack->CorrectParams(1);
const char *SpriteFile = stack->Pop()->GetString();
stack->PushBool(SUCCEEDED(addSprite(SpriteFile)));
stack->correctParams(1);
const char *SpriteFile = stack->pop()->GetString();
stack->pushBool(SUCCEEDED(addSprite(SpriteFile)));
return S_OK;
}
@ -459,9 +459,9 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack
// RemoveSprite
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "RemoveSprite") == 0) {
stack->CorrectParams(1);
const char *SpriteFile = stack->Pop()->GetString();
stack->PushBool(SUCCEEDED(removeSprite(SpriteFile)));
stack->correctParams(1);
const char *SpriteFile = stack->pop()->GetString();
stack->pushBool(SUCCEEDED(removeSprite(SpriteFile)));
return S_OK;
}
@ -470,9 +470,9 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack
// Start
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Start") == 0) {
stack->CorrectParams(1);
_overheadTime = stack->Pop()->GetInt();
stack->PushBool(SUCCEEDED(start()));
stack->correctParams(1);
_overheadTime = stack->pop()->GetInt();
stack->pushBool(SUCCEEDED(start()));
return S_OK;
}
@ -481,7 +481,7 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack
// Stop
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Stop") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
for (int i = 0; i < _particles.GetSize(); i++) {
delete _particles[i];
@ -489,7 +489,7 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack
_particles.RemoveAll();
_running = false;
stack->PushBool(true);
stack->pushBool(true);
return S_OK;
}
@ -498,9 +498,9 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack
// Pause
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Pause") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
_running = false;
stack->PushBool(true);
stack->pushBool(true);
return S_OK;
}
@ -509,9 +509,9 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack
// Resume
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Resume") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
_running = true;
stack->PushBool(true);
stack->pushBool(true);
return S_OK;
}
@ -520,12 +520,12 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack
// AddGlobalForce
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "AddGlobalForce") == 0) {
stack->CorrectParams(3);
const char *forceName = stack->Pop()->GetString();
float Angle = stack->Pop()->GetFloat();
float Strength = stack->Pop()->GetFloat();
stack->correctParams(3);
const char *forceName = stack->pop()->GetString();
float Angle = stack->pop()->GetFloat();
float Strength = stack->pop()->GetFloat();
stack->PushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, Angle, Strength)));
stack->pushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, Angle, Strength)));
return S_OK;
}
@ -534,14 +534,14 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack
// AddPointForce
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "AddPointForce") == 0) {
stack->CorrectParams(5);
const char *forceName = stack->Pop()->GetString();
int PosX = stack->Pop()->GetInt();
int PosY = stack->Pop()->GetInt();
float Angle = stack->Pop()->GetFloat();
float Strength = stack->Pop()->GetFloat();
stack->correctParams(5);
const char *forceName = stack->pop()->GetString();
int PosX = stack->pop()->GetInt();
int PosY = stack->pop()->GetInt();
float Angle = stack->pop()->GetFloat();
float Strength = stack->pop()->GetFloat();
stack->PushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, PosX, PosY, Angle, Strength)));
stack->pushBool(SUCCEEDED(addForce(forceName, CPartForce::FORCE_GLOBAL, PosX, PosY, Angle, Strength)));
return S_OK;
}
@ -550,10 +550,10 @@ HRESULT CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack
// RemoveForce
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "RemoveForce") == 0) {
stack->CorrectParams(1);
const char *forceName = stack->Pop()->GetString();
stack->correctParams(1);
const char *forceName = stack->pop()->GetString();
stack->PushBool(SUCCEEDED(removeForce(forceName)));
stack->pushBool(SUCCEEDED(removeForce(forceName)));
return S_OK;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<CScValue *, CScValue *> _values;

View File

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

View File

@ -671,16 +671,16 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// SetDisabledFont
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SetDisabledFont") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
if (_fontDisable) Game->_fontStorage->RemoveFont(_fontDisable);
if (Val->IsNULL()) {
_fontDisable = NULL;
stack->PushBool(true);
stack->pushBool(true);
} else {
_fontDisable = Game->_fontStorage->AddFont(Val->GetString());
stack->PushBool(_fontDisable != NULL);
stack->pushBool(_fontDisable != NULL);
}
return S_OK;
}
@ -689,16 +689,16 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// SetHoverFont
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetHoverFont") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
if (_fontHover) Game->_fontStorage->RemoveFont(_fontHover);
if (Val->IsNULL()) {
_fontHover = NULL;
stack->PushBool(true);
stack->pushBool(true);
} else {
_fontHover = Game->_fontStorage->AddFont(Val->GetString());
stack->PushBool(_fontHover != NULL);
stack->pushBool(_fontHover != NULL);
}
return S_OK;
}
@ -707,16 +707,16 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// SetPressedFont
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetPressedFont") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
if (_fontPress) Game->_fontStorage->RemoveFont(_fontPress);
if (Val->IsNULL()) {
_fontPress = NULL;
stack->PushBool(true);
stack->pushBool(true);
} else {
_fontPress = Game->_fontStorage->AddFont(Val->GetString());
stack->PushBool(_fontPress != NULL);
stack->pushBool(_fontPress != NULL);
}
return S_OK;
}
@ -725,16 +725,16 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// SetFocusedFont
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetFocusedFont") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
if (_fontFocus) Game->_fontStorage->RemoveFont(_fontFocus);
if (Val->IsNULL()) {
_fontFocus = NULL;
stack->PushBool(true);
stack->pushBool(true);
} else {
_fontFocus = Game->_fontStorage->AddFont(Val->GetString());
stack->PushBool(_fontFocus != NULL);
stack->pushBool(_fontFocus != NULL);
}
return S_OK;
}
@ -743,16 +743,16 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// SetDisabledImage
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetDisabledImage") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
delete _imageDisable;
_imageDisable = new CBSprite(Game);
const char *Filename = stack->Pop()->GetString();
const char *Filename = stack->pop()->GetString();
if (!_imageDisable || FAILED(_imageDisable->loadFile(Filename))) {
delete _imageDisable;
_imageDisable = NULL;
stack->PushBool(false);
} else stack->PushBool(true);
stack->pushBool(false);
} else stack->pushBool(true);
return S_OK;
}
@ -761,9 +761,9 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// GetDisabledImage
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetDisabledImage") == 0) {
stack->CorrectParams(0);
if (!_imageDisable || !_imageDisable->_filename) stack->PushNULL();
else stack->PushString(_imageDisable->_filename);
stack->correctParams(0);
if (!_imageDisable || !_imageDisable->_filename) stack->pushNULL();
else stack->pushString(_imageDisable->_filename);
return S_OK;
}
@ -772,9 +772,9 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// GetDisabledImageObject
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetDisabledImageObject") == 0) {
stack->CorrectParams(0);
if (!_imageDisable) stack->PushNULL();
else stack->PushNative(_imageDisable, true);
stack->correctParams(0);
if (!_imageDisable) stack->pushNULL();
else stack->pushNative(_imageDisable, true);
return S_OK;
}
@ -784,16 +784,16 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// SetHoverImage
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetHoverImage") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
delete _imageHover;
_imageHover = new CBSprite(Game);
const char *Filename = stack->Pop()->GetString();
const char *Filename = stack->pop()->GetString();
if (!_imageHover || FAILED(_imageHover->loadFile(Filename))) {
delete _imageHover;
_imageHover = NULL;
stack->PushBool(false);
} else stack->PushBool(true);
stack->pushBool(false);
} else stack->pushBool(true);
return S_OK;
}
@ -802,9 +802,9 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// GetHoverImage
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetHoverImage") == 0) {
stack->CorrectParams(0);
if (!_imageHover || !_imageHover->_filename) stack->PushNULL();
else stack->PushString(_imageHover->_filename);
stack->correctParams(0);
if (!_imageHover || !_imageHover->_filename) stack->pushNULL();
else stack->pushString(_imageHover->_filename);
return S_OK;
}
@ -813,9 +813,9 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// GetHoverImageObject
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetHoverImageObject") == 0) {
stack->CorrectParams(0);
if (!_imageHover) stack->PushNULL();
else stack->PushNative(_imageHover, true);
stack->correctParams(0);
if (!_imageHover) stack->pushNULL();
else stack->pushNative(_imageHover, true);
return S_OK;
}
@ -824,16 +824,16 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// SetPressedImage
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetPressedImage") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
delete _imagePress;
_imagePress = new CBSprite(Game);
const char *Filename = stack->Pop()->GetString();
const char *Filename = stack->pop()->GetString();
if (!_imagePress || FAILED(_imagePress->loadFile(Filename))) {
delete _imagePress;
_imagePress = NULL;
stack->PushBool(false);
} else stack->PushBool(true);
stack->pushBool(false);
} else stack->pushBool(true);
return S_OK;
}
@ -842,9 +842,9 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// GetPressedImage
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetPressedImage") == 0) {
stack->CorrectParams(0);
if (!_imagePress || !_imagePress->_filename) stack->PushNULL();
else stack->PushString(_imagePress->_filename);
stack->correctParams(0);
if (!_imagePress || !_imagePress->_filename) stack->pushNULL();
else stack->pushString(_imagePress->_filename);
return S_OK;
}
@ -853,9 +853,9 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// GetPressedImageObject
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetPressedImageObject") == 0) {
stack->CorrectParams(0);
if (!_imagePress) stack->PushNULL();
else stack->PushNative(_imagePress, true);
stack->correctParams(0);
if (!_imagePress) stack->pushNULL();
else stack->pushNative(_imagePress, true);
return S_OK;
}
@ -864,16 +864,16 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// SetFocusedImage
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetFocusedImage") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
delete _imageFocus;
_imageFocus = new CBSprite(Game);
const char *Filename = stack->Pop()->GetString();
const char *Filename = stack->pop()->GetString();
if (!_imageFocus || FAILED(_imageFocus->loadFile(Filename))) {
delete _imageFocus;
_imageFocus = NULL;
stack->PushBool(false);
} else stack->PushBool(true);
stack->pushBool(false);
} else stack->pushBool(true);
return S_OK;
}
@ -882,9 +882,9 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// GetFocusedImage
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetFocusedImage") == 0) {
stack->CorrectParams(0);
if (!_imageFocus || !_imageFocus->_filename) stack->PushNULL();
else stack->PushString(_imageFocus->_filename);
stack->correctParams(0);
if (!_imageFocus || !_imageFocus->_filename) stack->pushNULL();
else stack->pushString(_imageFocus->_filename);
return S_OK;
}
@ -893,9 +893,9 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// GetFocusedImageObject
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetFocusedImageObject") == 0) {
stack->CorrectParams(0);
if (!_imageFocus) stack->PushNULL();
else stack->PushNative(_imageFocus, true);
stack->correctParams(0);
if (!_imageFocus) stack->pushNULL();
else stack->pushNative(_imageFocus, true);
return S_OK;
}
@ -904,13 +904,13 @@ HRESULT CUIButton::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// Press
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Press") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (_visible && !_disable) {
_oneTimePress = true;
_oneTimePressTime = CBPlatform::GetTime();
}
stack->PushNULL();
stack->pushNULL();
return S_OK;
}

View File

@ -366,11 +366,11 @@ HRESULT CUIEdit::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// SetSelectedFont
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SetSelectedFont") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
if (_fontSelected) Game->_fontStorage->RemoveFont(_fontSelected);
_fontSelected = Game->_fontStorage->AddFont(stack->Pop()->GetString());
stack->PushBool(_fontSelected != NULL);
_fontSelected = Game->_fontStorage->AddFont(stack->pop()->GetString());
stack->pushBool(_fontSelected != NULL);
return S_OK;
}

View File

@ -256,10 +256,10 @@ HRESULT CUIEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// GetEntity
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "GetEntity") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (_entity) stack->PushNative(_entity, true);
else stack->PushNULL();
if (_entity) stack->pushNative(_entity, true);
else stack->pushNULL();
return S_OK;
}
@ -268,14 +268,14 @@ HRESULT CUIEntity::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// SetEntity
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetEntity") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
const char *Filename = stack->Pop()->GetString();
const char *Filename = stack->pop()->GetString();
if (SUCCEEDED(setEntity(Filename)))
stack->PushBool(true);
stack->pushBool(true);
else
stack->PushBool(false);
stack->pushBool(false);
return S_OK;
}

View File

@ -142,16 +142,16 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// SetFont
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SetFont") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
if (_font) Game->_fontStorage->RemoveFont(_font);
if (Val->IsNULL()) {
_font = NULL;
stack->PushBool(true);
stack->pushBool(true);
} else {
_font = Game->_fontStorage->AddFont(Val->GetString());
stack->PushBool(_font != NULL);
stack->pushBool(_font != NULL);
}
return S_OK;
}
@ -160,15 +160,15 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// SetImage
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetImage") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
/* const char *Filename = */ Val->GetString();
delete _image;
_image = NULL;
if (Val->IsNULL()) {
stack->PushBool(true);
stack->pushBool(true);
return S_OK;
}
@ -176,8 +176,8 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
if (!_image || FAILED(_image->loadFile(Val->GetString()))) {
delete _image;
_image = NULL;
stack->PushBool(false);
} else stack->PushBool(true);
stack->pushBool(false);
} else stack->pushBool(true);
return S_OK;
}
@ -186,9 +186,9 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// GetImage
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetImage") == 0) {
stack->CorrectParams(0);
if (!_image || !_image->_filename) stack->PushNULL();
else stack->PushString(_image->_filename);
stack->correctParams(0);
if (!_image || !_image->_filename) stack->pushNULL();
else stack->pushString(_image->_filename);
return S_OK;
}
@ -197,9 +197,9 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// GetImageObject
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetImageObject") == 0) {
stack->CorrectParams(0);
if (!_image) stack->PushNULL();
else stack->PushNative(_image, true);
stack->correctParams(0);
if (!_image) stack->pushNULL();
else stack->pushNative(_image, true);
return S_OK;
}
@ -208,9 +208,9 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// Focus
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Focus") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
focus();
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -218,14 +218,14 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// MoveAfter / MoveBefore
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "MoveAfter") == 0 || strcmp(name, "MoveBefore") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
if (_parent && _parent->_type == UI_WINDOW) {
CUIWindow *win = (CUIWindow *)_parent;
int i;
bool found = false;
CScValue *val = stack->Pop();
CScValue *val = stack->pop();
// find directly
if (val->IsNative()) {
CUIObject *widget = (CUIObject *)val->GetNative();
@ -258,14 +258,14 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
win->_widgets.RemoveAt(j);
done = true;
stack->PushBool(true);
stack->pushBool(true);
break;
}
}
if (!done) stack->PushBool(false);
} else stack->PushBool(false);
if (!done) stack->pushBool(false);
} else stack->pushBool(false);
} else stack->PushBool(false);
} else stack->pushBool(false);
return S_OK;
}
@ -274,7 +274,7 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// MoveToBottom
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "MoveToBottom") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (_parent && _parent->_type == UI_WINDOW) {
CUIWindow *win = (CUIWindow *)_parent;
@ -285,8 +285,8 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
break;
}
}
stack->PushBool(true);
} else stack->PushBool(false);
stack->pushBool(true);
} else stack->pushBool(false);
return S_OK;
}
@ -295,7 +295,7 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// MoveToTop
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "MoveToTop") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (_parent && _parent->_type == UI_WINDOW) {
CUIWindow *win = (CUIWindow *)_parent;
@ -306,8 +306,8 @@ HRESULT CUIObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
break;
}
}
stack->PushBool(true);
} else stack->PushBool(false);
stack->pushBool(true);
} else stack->pushBool(false);
return S_OK;
}

View File

@ -381,9 +381,9 @@ HRESULT CUIText::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// SizeToFit
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SizeToFit") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
SizeToFit();
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -391,9 +391,9 @@ HRESULT CUIText::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
// HeightToFit
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "HeightToFit") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
if (_font && _text) _height = _font->getTextHeight((byte *)_text, _width);
stack->PushNULL();
stack->pushNULL();
return S_OK;
}

View File

@ -695,20 +695,20 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// GetWidget / GetControl
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "GetWidget") == 0 || strcmp(name, "GetControl") == 0) {
stack->CorrectParams(1);
CScValue *val = stack->Pop();
stack->correctParams(1);
CScValue *val = stack->pop();
if (val->GetType() == VAL_INT) {
int widget = val->GetInt();
if (widget < 0 || widget >= _widgets.GetSize()) stack->PushNULL();
else stack->PushNative(_widgets[widget], true);
if (widget < 0 || widget >= _widgets.GetSize()) stack->pushNULL();
else stack->pushNative(_widgets[widget], true);
} else {
for (int i = 0; i < _widgets.GetSize(); i++) {
if (scumm_stricmp(_widgets[i]->_name, val->GetString()) == 0) {
stack->PushNative(_widgets[i], true);
stack->pushNative(_widgets[i], true);
return S_OK;
}
}
stack->PushNULL();
stack->pushNULL();
}
return S_OK;
@ -718,11 +718,11 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// SetInactiveFont
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetInactiveFont") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
if (_fontInactive) Game->_fontStorage->RemoveFont(_fontInactive);
_fontInactive = Game->_fontStorage->AddFont(stack->Pop()->GetString());
stack->PushBool(_fontInactive != NULL);
_fontInactive = Game->_fontStorage->AddFont(stack->pop()->GetString());
stack->pushBool(_fontInactive != NULL);
return S_OK;
}
@ -731,16 +731,16 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// SetInactiveImage
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "SetInactiveImage") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
delete _imageInactive;
_imageInactive = new CBSprite(Game);
const char *Filename = stack->Pop()->GetString();
const char *Filename = stack->pop()->GetString();
if (!_imageInactive || FAILED(_imageInactive->loadFile(Filename))) {
delete _imageInactive;
_imageInactive = NULL;
stack->PushBool(false);
} else stack->PushBool(true);
stack->pushBool(false);
} else stack->pushBool(true);
return S_OK;
}
@ -749,9 +749,9 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// GetInactiveImage
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetInactiveImage") == 0) {
stack->CorrectParams(0);
if (!_imageInactive || !_imageInactive->_filename) stack->PushNULL();
else stack->PushString(_imageInactive->_filename);
stack->correctParams(0);
if (!_imageInactive || !_imageInactive->_filename) stack->pushNULL();
else stack->pushString(_imageInactive->_filename);
return S_OK;
}
@ -760,9 +760,9 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// GetInactiveImageObject
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetInactiveImageObject") == 0) {
stack->CorrectParams(0);
if (!_imageInactive) stack->PushNULL();
else stack->PushNative(_imageInactive, true);
stack->correctParams(0);
if (!_imageInactive) stack->pushNULL();
else stack->pushNative(_imageInactive, true);
return S_OK;
}
@ -772,8 +772,8 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// Close
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Close") == 0) {
stack->CorrectParams(0);
stack->PushBool(SUCCEEDED(close()));
stack->correctParams(0);
stack->pushBool(SUCCEEDED(close()));
return S_OK;
}
@ -781,10 +781,10 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// GoExclusive
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GoExclusive") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
goExclusive();
script->WaitFor(this);
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -792,10 +792,10 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// GoSystemExclusive
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GoSystemExclusive") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
goSystemExclusive();
script->WaitFor(this);
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -803,10 +803,10 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// Center
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Center") == 0) {
stack->CorrectParams(0);
stack->correctParams(0);
_posX = (Game->_renderer->_width - _width) / 2;
_posY = (Game->_renderer->_height - _height) / 2;
stack->PushNULL();
stack->pushNULL();
return S_OK;
}
@ -814,13 +814,13 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// LoadFromFile
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "LoadFromFile") == 0) {
stack->CorrectParams(1);
stack->correctParams(1);
CScValue *Val = stack->Pop();
CScValue *Val = stack->pop();
cleanup();
if (!Val->IsNULL()) {
stack->PushBool(SUCCEEDED(loadFile(Val->GetString())));
} else stack->PushBool(true);
stack->pushBool(SUCCEEDED(loadFile(Val->GetString())));
} else stack->pushBool(true);
return S_OK;
}
@ -829,12 +829,12 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// CreateButton
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "CreateButton") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
CUIButton *Btn = new CUIButton(Game);
if (!Val->IsNULL()) Btn->setName(Val->GetString());
stack->PushNative(Btn, true);
stack->pushNative(Btn, true);
Btn->_parent = this;
_widgets.Add(Btn);
@ -846,12 +846,12 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// CreateStatic
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "CreateStatic") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
CUIText *Sta = new CUIText(Game);
if (!Val->IsNULL()) Sta->setName(Val->GetString());
stack->PushNative(Sta, true);
stack->pushNative(Sta, true);
Sta->_parent = this;
_widgets.Add(Sta);
@ -863,12 +863,12 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// CreateEditor
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "CreateEditor") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
CUIEdit *Edi = new CUIEdit(Game);
if (!Val->IsNULL()) Edi->setName(Val->GetString());
stack->PushNative(Edi, true);
stack->pushNative(Edi, true);
Edi->_parent = this;
_widgets.Add(Edi);
@ -880,12 +880,12 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// CreateWindow
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "CreateWindow") == 0) {
stack->CorrectParams(1);
CScValue *Val = stack->Pop();
stack->correctParams(1);
CScValue *Val = stack->pop();
CUIWindow *Win = new CUIWindow(Game);
if (!Val->IsNULL()) Win->setName(Val->GetString());
stack->PushNative(Win, true);
stack->pushNative(Win, true);
Win->_parent = this;
_widgets.Add(Win);
@ -897,8 +897,8 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
// DeleteControl / DeleteButton / DeleteStatic / DeleteEditor / DeleteWindow
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "DeleteControl") == 0 || strcmp(name, "DeleteButton") == 0 || strcmp(name, "DeleteStatic") == 0 || strcmp(name, "DeleteEditor") == 0 || strcmp(name, "DeleteWindow") == 0) {
stack->CorrectParams(1);
CScValue *val = stack->Pop();
stack->correctParams(1);
CScValue *val = stack->pop();
CUIObject *obj = (CUIObject *)val->GetNative();
for (int i = 0; i < _widgets.GetSize(); i++) {
@ -908,7 +908,7 @@ HRESULT CUIWindow::scCallMethod(CScScript *script, CScStack *stack, CScStack *th
if (val->GetType() == VAL_VARIABLE_REF) val->SetNULL();
}
}
stack->PushNULL();
stack->pushNULL();
return S_OK;
} else if SUCCEEDED(Game->WindowScriptMethodHook(this, script, stack, name)) return S_OK;