diff options
author | athrxx | 2011-10-30 20:33:01 +0100 |
---|---|---|
committer | athrxx | 2011-11-04 21:46:32 +0100 |
commit | 1527e7b1b437792b15bd64f3dee0d5c31f55e1ad (patch) | |
tree | 1259058b83bfb31b7e593edb855c96bf63dd46ca /engines | |
parent | 99aaf242016f02b2aa0f65469e3f79139424e4d4 (diff) | |
download | scummvm-rg350-1527e7b1b437792b15bd64f3dee0d5c31f55e1ad.tar.gz scummvm-rg350-1527e7b1b437792b15bd64f3dee0d5c31f55e1ad.tar.bz2 scummvm-rg350-1527e7b1b437792b15bd64f3dee0d5c31f55e1ad.zip |
KYRA: (LOL) minor fix, cleanup and renaming
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/items_lol.cpp | 40 | ||||
-rw-r--r-- | engines/kyra/lol.h | 4 | ||||
-rw-r--r-- | engines/kyra/script_lol.cpp | 17 |
3 files changed, 25 insertions, 36 deletions
diff --git a/engines/kyra/items_lol.cpp b/engines/kyra/items_lol.cpp index 7e9ae439fc..0d6e99a696 100644 --- a/engines/kyra/items_lol.cpp +++ b/engines/kyra/items_lol.cpp @@ -127,14 +127,8 @@ Item LoLEngine::makeItem(int itemType, int curFrame, int flags) { continue; bool t = false; - Item ii = i; - while (ii && !t) { - t = testUnkItemFlags(ii); - if (t) - break; - else - ii = _itemsInPlay[ii - 1].nextAssignedObject; - } + for (Item ii = i; ii && !t; ii = _itemsInPlay[ii].nextAssignedObject) + t = isItemMoveable(ii); if (t) { cnt = diff; @@ -144,24 +138,20 @@ Item LoLEngine::makeItem(int itemType, int curFrame, int flags) { Item slot = i; if (cnt) { - slot = r; - if (testUnkItemFlags(r)) { + slot = 0; + if (isItemMoveable(r)) { if (_itemsInPlay[r].nextAssignedObject) _itemsInPlay[_itemsInPlay[r].nextAssignedObject].level = _itemsInPlay[r].level; deleteItem(r); slot = r; } else { - uint16 ii = _itemsInPlay[slot].nextAssignedObject; - while (ii) { - if (testUnkItemFlags(ii)) { - _itemsInPlay[slot].nextAssignedObject = _itemsInPlay[ii].nextAssignedObject; - deleteItem(ii); - slot = ii; - break; - } else { - slot = ii; - } - ii = _itemsInPlay[slot].nextAssignedObject; + for (uint16 ii = _itemsInPlay[r].nextAssignedObject; ii; ii = _itemsInPlay[ii].nextAssignedObject) { + if (!isItemMoveable(ii)) + continue; + _itemsInPlay[r].nextAssignedObject = _itemsInPlay[ii].nextAssignedObject; + deleteItem(ii); + slot = ii; + break; } } } @@ -219,7 +209,7 @@ bool LoLEngine::addItemToInventory(Item itemIndex) { return true; } -bool LoLEngine::testUnkItemFlags(Item itemIndex) { +bool LoLEngine::isItemMoveable(Item itemIndex) { if (!(_itemsInPlay[itemIndex].shpCurFrame_flg & 0x4000)) return false; @@ -304,7 +294,7 @@ bool LoLEngine::itemEquipped(int charNum, uint16 itemType) { return false; } -void LoLEngine::setItemPosition(Item item, uint16 x, uint16 y, int flyingHeight, int b) { +void LoLEngine::setItemPosition(Item item, uint16 x, uint16 y, int flyingHeight, int moveable) { if (!flyingHeight) { x = (x & 0xffc0) | 0x40; y = (y & 0xffc0) | 0x40; @@ -316,7 +306,7 @@ void LoLEngine::setItemPosition(Item item, uint16 x, uint16 y, int flyingHeight, _itemsInPlay[item].block = block; _itemsInPlay[item].flyingHeight = flyingHeight; - if (b) + if (moveable) _itemsInPlay[item].shpCurFrame_flg |= 0x4000; else _itemsInPlay[item].shpCurFrame_flg &= 0xbfff; @@ -325,7 +315,7 @@ void LoLEngine::setItemPosition(Item item, uint16 x, uint16 y, int flyingHeight, assignItemToBlock(&_levelBlockProperties[block].assignedObjects, item); reassignDrawObjects(_currentDirection, item, &_levelBlockProperties[block], false); - if (b) + if (moveable) runLevelScriptCustom(block, 0x80, -1, item, 0, 0); checkSceneUpdateNeed(block); diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h index b2039b399d..5f6be61d64 100644 --- a/engines/kyra/lol.h +++ b/engines/kyra/lol.h @@ -1206,14 +1206,14 @@ private: Item makeItem(int itemType, int curFrame, int flags); void placeMoveLevelItem(Item itemIndex, int level, int block, int xOffs, int yOffs, int flyingHeight); bool addItemToInventory(Item itemIndex); - bool testUnkItemFlags(Item itemIndex); + bool isItemMoveable(Item itemIndex); void deleteItem(Item itemIndex); ItemInPlay *findObject(uint16 index); void runItemScript(int charNum, Item item, int flags, int next, int reg4); void setHandItem(Item itemIndex); bool itemEquipped(int charNum, uint16 itemType); - void setItemPosition(Item item, uint16 x, uint16 y, int flyingHeight, int b); + void setItemPosition(Item item, uint16 x, uint16 y, int flyingHeight, int moveable); void removeLevelItem(Item item, int block); bool launchObject(int objectType, Item item, int startX, int startY, int flyingHeight, int direction, int, int attackerId, int c); void endObjectFlight(FlyingObject *t, int x, int y, int collisionObject); diff --git a/engines/kyra/script_lol.cpp b/engines/kyra/script_lol.cpp index 91fada9e2a..85fc3fdb16 100644 --- a/engines/kyra/script_lol.cpp +++ b/engines/kyra/script_lol.cpp @@ -2054,17 +2054,16 @@ int LoLEngine::olol_changeItemTypeOrFlag(EMCState *script) { return 0; ItemInPlay *i = &_itemsInPlay[stackPos(0)]; - int r = stackPos(2) & 0x1fff; + int16 val = stackPos(2); - if (stackPos(1) == 4) { - i->itemPropertyIndex = r; - return r; - } else if (stackPos(1) == 15) { - i->shpCurFrame_flg = (i->shpCurFrame_flg & 0xe000) | r; - return r; - } + if (stackPos(1) == 4) + i->itemPropertyIndex = val; + else if (stackPos(1) == 15) + i->shpCurFrame_flg = (i->shpCurFrame_flg & 0xe000) | (val & 0x1fff); + else + val = -1; - return -1; + return val; } int LoLEngine::olol_placeInventoryItemInHand(EMCState *script) { |