Skip to content

Commit

Permalink
PEGASUS: Fix stupid bugs in the item code
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Hoops committed Sep 8, 2011
1 parent ecd81a9 commit 715c95e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion engines/pegasus/items/biochips/biochipitem.cpp
Expand Up @@ -34,7 +34,7 @@ namespace Pegasus {
BiochipItem::BiochipItem(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
Item(id, neighborhood, room, direction) {

PegasusEngine *vm = (PegasusEngine *)vm;
PegasusEngine *vm = (PegasusEngine *)g_engine;

Common::SeekableReadStream *biochipInfo = vm->_resFork->getResource(MKTAG('B', 'i', 'o', 'I'), kItemBaseResID + id);
if (biochipInfo) {
Expand Down
2 changes: 1 addition & 1 deletion engines/pegasus/items/inventory/inventoryitem.cpp
Expand Up @@ -33,7 +33,7 @@ namespace Pegasus {
InventoryItem::InventoryItem(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
Item(id, neighborhood, room, direction) {

PegasusEngine *vm = (PegasusEngine *)vm;
PegasusEngine *vm = (PegasusEngine *)g_engine;

Common::SeekableReadStream *leftInfo = vm->_resFork->getResource(MKTAG('L', 'e', 'f', 't'), kItemBaseResID + id);
if (leftInfo) {
Expand Down
19 changes: 11 additions & 8 deletions engines/pegasus/items/item.cpp
Expand Up @@ -48,8 +48,8 @@ Item::Item(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID r
_itemInfo.infoLeftTime = info->readUint32BE();
_itemInfo.infoRightStart = info->readUint32BE();
_itemInfo.infoRightStop = info->readUint32BE();
_itemInfo.dragSpriteNormalID = info->readUint32BE();
_itemInfo.dragSpriteUsedID = info->readUint32BE();
_itemInfo.dragSpriteNormalID = info->readUint16BE();
_itemInfo.dragSpriteUsedID = info->readUint16BE();

if (vm->isDemo()) {
// Adjust info right times to account for the stuff that was chopped out of the
Expand Down Expand Up @@ -95,18 +95,20 @@ Item::Item(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID r
}

Common::SeekableReadStream *middleAreaInfo = vm->_resFork->getResource(kMiddleAreaInfoResType, kItemBaseResID + id);
if (!middleAreaInfo)
error("Middle area info not found for item %d", id);

_sharedAreaInfo = readItemState(middleAreaInfo);

delete middleAreaInfo;
if (middleAreaInfo) {
_sharedAreaInfo = readItemState(middleAreaInfo);
delete middleAreaInfo;
} else {
// Only kArgonPickup does not have this
memset(&_sharedAreaInfo, 0, sizeof(_sharedAreaInfo));
}

Common::SeekableReadStream *extraInfo = vm->_resFork->getResource(kItemExtraInfoResType, kItemBaseResID + id);
if (!extraInfo)
error("Extra info not found for item %d", id);

_itemExtras.numEntries = extraInfo->readUint16BE();
_itemExtras.entries = new ItemExtraEntry[_itemExtras.numEntries];
for (uint16 i = 0; i < _itemExtras.numEntries; i++) {
_itemExtras.entries[i].extraID = extraInfo->readUint32BE();
_itemExtras.entries[i].extraArea = extraInfo->readUint16BE();
Expand Down Expand Up @@ -255,6 +257,7 @@ ItemStateInfo Item::readItemState(Common::SeekableReadStream *stream) {
ItemStateInfo info;

info.numEntries = stream->readUint16BE();
info.entries = new ItemStateEntry[info.numEntries];
for (uint16 i = 0; i < info.numEntries; i++) {
info.entries[i].itemState = stream->readSint16BE();
info.entries[i].itemTime = stream->readUint32BE();
Expand Down

0 comments on commit 715c95e

Please sign in to comment.