* Implemented the following GPL functions: IsIcoOn, IcoStat, IsObjOn, IsObjOff, IsObjAway

* Changed GameObject::_location to an int since we sometimes use location -1.
* Some more uint <-> int changes to prevent comparisons between signed and unsigned.

svn-id: r42452
This commit is contained in:
Denis Kasak 2009-07-13 19:53:53 +00:00
parent f8c20b9e9c
commit 04e4bfdbbe
4 changed files with 61 additions and 9 deletions

View file

@ -118,13 +118,13 @@ void Script::setupCommandList() {
static const GPL2Function gplFunctions[] = {
{ "Not", &Script::funcNot },
{ "Random", &Script::funcRandom },
{ "IsIcoOn", NULL },
{ "IsIcoOn", &Script::funcIsIcoOn },
{ "IsIcoAct", NULL },
{ "IcoStat", NULL },
{ "IcoStat", &Script::funcIcoStat },
{ "ActIco", NULL },
{ "IsObjOn", NULL },
{ "IsObjOff", NULL },
{ "IsObjAway", NULL },
{ "IsObjOn", &Script::funcIsObjOn },
{ "IsObjOff", &Script::funcIsObjOff },
{ "IsObjAway", &Script::funcIsObjAway },
{ "ObjStat", NULL },
{ "LastBlock", NULL },
{ "AtBegin", NULL },
@ -222,6 +222,46 @@ int Script::funcNot(int n) {
return !n;
}
int Script::funcIsIcoOn(int iconID) {
iconID -= 1;
return _vm->_game->getIconStatus(iconID) == 1;
}
int Script::funcIcoStat(int iconID) {
iconID -= 1;
int status = _vm->_game->getIconStatus(iconID);
return (status == 1) ? 1 : 2;
}
int Script::funcIsObjOn(int objID) {
objID -= 1;
GameObject *obj = _vm->_game->getObject(objID);
return obj->_visible;
}
int Script::funcIsObjOff(int objID) {
objID -= 1;
GameObject *obj = _vm->_game->getObject(objID);
// We index locations from 0 (as opposed to the original player where it was from 1)
// That's why the "invalid" location 0 from the data files is converted to -1
return !obj->_visible && obj->_location != -1;
}
int Script::funcIsObjAway(int objID) {
objID -= 1;
GameObject *obj = _vm->_game->getObject(objID);
// see Script::funcIsObjOff
return !obj->_visible && obj->_location == -1;
}
/* GPL commands */
void Script::load(Common::Queue<int> &params) {