aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2018-04-01 22:54:38 -0400
committerPaul Gilbert2018-04-01 22:54:38 -0400
commitd621bf68164d7fbe8cdd57632db1080f4f74527a (patch)
treed83468e488cb720ca8d19bdc4e3e4161904bd739 /engines
parent0cde83ea01cfa1bfd3253bcfa3a7af0b7af5ad02 (diff)
downloadscummvm-rg350-d621bf68164d7fbe8cdd57632db1080f4f74527a.tar.gz
scummvm-rg350-d621bf68164d7fbe8cdd57632db1080f4f74527a.tar.bz2
scummvm-rg350-d621bf68164d7fbe8cdd57632db1080f4f74527a.zip
XEEN: Fix object 0 not being removable, _objNumber cleanup
The original used 0 as "unset", and object index + 1 to indicate the object at the current location. Given all the +1/-1 usages, I've simplified the use of _objNumber to use -1 as unset, allowing the direct object index to be used otherwise
Diffstat (limited to 'engines')
-rw-r--r--engines/xeen/interface_scene.cpp16
-rw-r--r--engines/xeen/map.cpp2
-rw-r--r--engines/xeen/party.cpp4
-rw-r--r--engines/xeen/scripts.cpp13
4 files changed, 17 insertions, 18 deletions
diff --git a/engines/xeen/interface_scene.cpp b/engines/xeen/interface_scene.cpp
index 043ef2cbbe..2fcb378537 100644
--- a/engines/xeen/interface_scene.cpp
+++ b/engines/xeen/interface_scene.cpp
@@ -380,7 +380,7 @@ InterfaceScene::InterfaceScene(XeenEngine *vm): _vm(vm) {
_flipDefaultGround = false;
_isAttacking = false;
_charsShooting = false;
- _objNumber = 0;
+ _objNumber = -1;
_combatFloatCounter = 0;
_thinWall = false;
_isAnimReset = false;
@@ -392,9 +392,8 @@ void InterfaceScene::drawScene() {
Map &map = *_vm->_map;
Scripts &scripts = *_vm->_scripts;
- MazeObject &objObject = map._mobData._objects[_objNumber];
+ MazeObject *obj = (_objNumber == -1) ? nullptr : &map._mobData._objects[_objNumber];
Direction partyDirection = _vm->_party->_mazeDirection;
- int objNum = _objNumber - 1;
// Loop to update the frame numbers for each maze object, applying the animation frame
// limits as specified by the map's _animationInfo listing
@@ -407,9 +406,9 @@ void InterfaceScene::drawScene() {
mazeObject._frame = animEntry._frame1._frames[directionIndex];
} else {
++mazeObject._frame;
- if ((int)idx == objNum && scripts._animCounter > 0 && (
- objObject._spriteId == (_vm->_files->_ccNum ? 15 : 16) ||
- objObject._spriteId == 58 || objObject._spriteId == 73)) {
+ if ((int)idx == _objNumber && scripts._animCounter > 0 && (
+ obj->_spriteId == (_vm->_files->_ccNum ? 15 : 16) ||
+ obj->_spriteId == 58 || obj->_spriteId == 73)) {
if (mazeObject._frame > 4 || mazeObject._spriteId == 58)
mazeObject._frame = 1;
} else if (mazeObject._frame >= animEntry._frame2._frames[directionIndex]) {
@@ -599,7 +598,7 @@ void InterfaceScene::drawIndoorsScene() {
_isAnimReset = false;
// Code in the original that's not being used
- //MazeObject &objObject = map._mobData._objects[_objNumber - 1];
+ //MazeObject &objObject = map._mobData._objects[_objNumber];
// Only the front rank of pow points result in a Pow splatter effect
for (int idx = 0; idx < 3; ++idx) {
@@ -2652,7 +2651,7 @@ void InterfaceScene::setIndoorsObjects() {
Common::Point mazePos = _vm->_party->_mazePosition;
Direction dir = _vm->_party->_mazeDirection;
Common::Point pt;
- _objNumber = 0;
+ _objNumber = -1;
Common::Array<MazeObject> &objects = _vm->_map->_mobData._objects;
for (uint idx = 0; idx < objects.size(); ++idx) {
@@ -3361,6 +3360,7 @@ void InterfaceScene::setOutdoorsObjects() {
const Common::Point &pt = party._mazePosition;
Direction dir = party._mazeDirection;
int posIndex;
+ _objNumber = -1;
for (uint idx = 0; idx < map._mobData._objects.size(); ++idx) {
MazeObject &obj = map._mobData._objects[idx];
diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp
index 19312b6bcc..b0c269cdab 100644
--- a/engines/xeen/map.cpp
+++ b/engines/xeen/map.cpp
@@ -636,7 +636,7 @@ void Map::load(int mapId) {
PleaseWait waitMsg(intf._falling);
waitMsg.show();
- intf._objNumber = 0;
+ intf._objNumber = -1;
party._stepped = true;
party._mazeId = mapId;
saveMaze();
diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp
index 31a43be0a4..d92a4952cc 100644
--- a/engines/xeen/party.cpp
+++ b/engines/xeen/party.cpp
@@ -1439,8 +1439,8 @@ bool Party::giveExt(int mode1, uint val1, int mode2, uint val2, int mode3, uint
Sound &sound = *g_vm->_sound;
Character &c = _itemsCharacter;
- if (intf._objNumber && !scripts._animCounter) {
- MazeObject &obj = map._mobData._objects[intf._objNumber - 1];
+ if (intf._objNumber != -1 && !scripts._animCounter) {
+ MazeObject &obj = map._mobData._objects[intf._objNumber];
switch (obj._spriteId) {
case 15:
if (!files._ccNum)
diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp
index 3a3c9d6d65..896387f4d3 100644
--- a/engines/xeen/scripts.cpp
+++ b/engines/xeen/scripts.cpp
@@ -210,8 +210,8 @@ int Scripts::checkEvents() {
if (party._treasure._hasItems || party._treasure._gold || party._treasure._gems)
party.giveTreasure();
- if (_animCounter > 0 && intf._objNumber) {
- MazeObject &selectedObj = map._mobData._objects[intf._objNumber - 1];
+ if (_animCounter > 0 && intf._objNumber != -1) {
+ MazeObject &selectedObj = map._mobData._objects[intf._objNumber];
if (selectedObj._spriteId == (ccNum ? 15 : 16)) {
for (uint idx = 0; idx < 16; ++idx) {
@@ -240,8 +240,8 @@ int Scripts::checkEvents() {
if (_scriptExecuted)
intf.clearEvents();
- if (_scriptExecuted || !intf._objNumber || _dirFlag) {
- if (_dirFlag && !_scriptExecuted && intf._objNumber && !map._currentIsEvent) {
+ if (_scriptExecuted || intf._objNumber == -1 || _dirFlag) {
+ if (_dirFlag && !_scriptExecuted && intf._objNumber != -1 && !map._currentIsEvent) {
sound.playFX(21);
}
} else {
@@ -496,8 +496,7 @@ bool Scripts::cmdTeleport(ParamsIterator &params) {
party._stepped = true;
if (mapId != party._mazeId) {
- int spriteId = (intf._objNumber == 0) ? -1 :
- map._mobData._objects[intf._objNumber - 1]._spriteId;
+ int spriteId = (intf._objNumber == -1) ? -1 : map._mobData._objects[intf._objNumber - 1]._spriteId;
switch (spriteId) {
case 47:
@@ -798,7 +797,7 @@ bool Scripts::cmdRemove(ParamsIterator &params) {
Interface &intf = *_vm->_interface;
Map &map = *_vm->_map;
- if (intf._objNumber) {
+ if (intf._objNumber != -1) {
// Give the active object a completely way out of bounds position
MazeObject &obj = map._mobData._objects[intf._objNumber];
obj._position = Common::Point(128, 128);