mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-24 10:45:46 +00:00
PEGASUS: Remove g_allItems global construction
This commit is contained in:
parent
81e7c9a0c1
commit
f61146f327
engines/pegasus
@ -26,14 +26,12 @@
|
||||
#include "common/error.h"
|
||||
#include "common/stream.h"
|
||||
|
||||
#include "engines/pegasus/items/item.h"
|
||||
#include "engines/pegasus/items/itemlist.h"
|
||||
#include "pegasus/pegasus.h"
|
||||
#include "pegasus/items/item.h"
|
||||
#include "pegasus/items/itemlist.h"
|
||||
|
||||
namespace Pegasus {
|
||||
|
||||
// TODO: Don't use global construction!
|
||||
ItemList g_allItems;
|
||||
|
||||
ItemList::ItemList() {
|
||||
}
|
||||
|
||||
|
@ -52,8 +52,7 @@ public:
|
||||
|
||||
typedef ItemList::iterator ItemIterator;
|
||||
|
||||
// TODO: Don't use global construction!
|
||||
extern ItemList g_allItems;
|
||||
#define g_allItems (((PegasusEngine *)g_engine)->getAllItems())
|
||||
|
||||
} // End of namespace Pegasus
|
||||
|
||||
|
@ -1175,7 +1175,7 @@ void Caldoria::receiveNotification(Notification *notification, const Notificatio
|
||||
arriveAt(kCaldoria27, GameState.getCurrentDirection());
|
||||
break;
|
||||
case kCaGTCardSwipe:
|
||||
item = (InventoryItem *)g_allItems.findItemByID(kKeyCard);
|
||||
item = (InventoryItem *)_vm->getAllItems().findItemByID(kKeyCard);
|
||||
_vm->addItemToInventory(item);
|
||||
setCurrentActivation(kActivateReadyToTransport);
|
||||
break;
|
||||
@ -1212,7 +1212,7 @@ void Caldoria::receiveNotification(Notification *notification, const Notificatio
|
||||
}
|
||||
break;
|
||||
case kCa53EastShootSinclair:
|
||||
_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kStunGun));
|
||||
_vm->addItemToInventory((InventoryItem *)_vm->getAllItems().findItemByID(kStunGun));
|
||||
startExtraSequence(kCa53EastZoomOutFromSinclair, kExtraCompletedFlag, false);
|
||||
GameState.setScoringStunnedSinclair(true);
|
||||
break;
|
||||
@ -1769,8 +1769,8 @@ void Caldoria::openElevatorMovie() {
|
||||
void Caldoria::emptyOJGlass() {
|
||||
GameState.setTakenItemID(kOrangeJuiceGlassFull, false);
|
||||
GameState.setTakenItemID(kOrangeJuiceGlassEmpty, true);
|
||||
_vm->removeItemFromInventory((InventoryItem *)g_allItems.findItemByID(kOrangeJuiceGlassFull));
|
||||
_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kOrangeJuiceGlassEmpty));
|
||||
_vm->removeItemFromInventory((InventoryItem *)_vm->getAllItems().findItemByID(kOrangeJuiceGlassFull));
|
||||
_vm->addItemToInventory((InventoryItem *)_vm->getAllItems().findItemByID(kOrangeJuiceGlassEmpty));
|
||||
}
|
||||
|
||||
void Caldoria::doorBombTimerExpired() {
|
||||
|
@ -1632,7 +1632,7 @@ void Mars::activateHotspots() {
|
||||
case MakeRoomView(kMars56, kEast):
|
||||
switch (getCurrentActivation()) {
|
||||
case kActivateReactorReadyForNitrogen:
|
||||
item = (InventoryItem *)g_allItems.findItemByID(kNitrogenCanister);
|
||||
item = (InventoryItem *)_vm->getAllItems().findItemByID(kNitrogenCanister);
|
||||
if (item->getItemState() != kNitrogenFull)
|
||||
_vm->getAllHotspots().deactivateOneHotspot(kMars57DropNitrogenSpotID);
|
||||
// Fall through...
|
||||
@ -2151,7 +2151,7 @@ void Mars::receiveNotification(Notification *notification, const NotificationFla
|
||||
}
|
||||
break;
|
||||
case kMarsTurnOnPod:
|
||||
item = (InventoryItem *)g_allItems.findItemByID(kMarsCard);
|
||||
item = (InventoryItem *)_vm->getAllItems().findItemByID(kMarsCard);
|
||||
_vm->addItemToInventory(item);
|
||||
GameState.setScoringTurnedOnTransport();
|
||||
loadLoopSound1("");
|
||||
@ -2259,7 +2259,7 @@ void Mars::receiveNotification(Notification *notification, const NotificationFla
|
||||
GameState.setMarsLockFrozen(false);
|
||||
break;
|
||||
case kMars57FreezeLock:
|
||||
item = (InventoryItem *)g_allItems.findItemByID(kNitrogenCanister);
|
||||
item = (InventoryItem *)_vm->getAllItems().findItemByID(kNitrogenCanister);
|
||||
item->setItemState(kNitrogenEmpty);
|
||||
_vm->addItemToInventory(item);
|
||||
setCurrentActivation(kActivateReactorReadyForCrowBar);
|
||||
@ -2271,7 +2271,7 @@ void Mars::receiveNotification(Notification *notification, const NotificationFla
|
||||
_utilityFuse.lightFuse();
|
||||
break;
|
||||
case kMars57BreakLock:
|
||||
item = (InventoryItem *)g_allItems.findItemByID(kCrowbar);
|
||||
item = (InventoryItem *)_vm->getAllItems().findItemByID(kCrowbar);
|
||||
_vm->addItemToInventory(item);
|
||||
GameState.setScoringUsedCrowBar();
|
||||
GameState.setMarsLockBroken(true);
|
||||
|
@ -676,7 +676,7 @@ void Neighborhood::clickInHotspot(const Input &input, const Hotspot *clickedSpot
|
||||
}
|
||||
|
||||
if (itemID != kNoItemID) {
|
||||
Item *draggingItem = g_allItems.findItemByID(itemID);
|
||||
Item *draggingItem = _vm->getAllItems().findItemByID(itemID);
|
||||
|
||||
if (draggingItem) {
|
||||
takeItemFromRoom(draggingItem);
|
||||
@ -1157,7 +1157,7 @@ void Neighborhood::activateOneHotspot(HotspotInfoTable::Entry &entry, Hotspot *h
|
||||
break;
|
||||
default:
|
||||
if ((hotspot->getHotspotFlags() & kPickUpBiochipSpotFlag) != 0) {
|
||||
Item *item = g_allItems.findItemByID(entry.hotspotItem);
|
||||
Item *item = _vm->getAllItems().findItemByID(entry.hotspotItem);
|
||||
if (item && item->getItemNeighborhood() == getObjectID())
|
||||
hotspot->setActive();
|
||||
} else {
|
||||
|
@ -136,25 +136,25 @@ void NoradAlpha::start() {
|
||||
RoomID itemRoom;
|
||||
DirectionConstant itemDirection;
|
||||
|
||||
Item *item = (Item *)g_allItems.findItemByID(kGasCanister);
|
||||
Item *item = (Item *)_vm->getAllItems().findItemByID(kGasCanister);
|
||||
item->getItemRoom(itemNeighborhood, itemRoom, itemDirection);
|
||||
|
||||
if (itemNeighborhood == getObjectID()) {
|
||||
_fillingStationItem = item;
|
||||
} else {
|
||||
item = (Item *)g_allItems.findItemByID(kAirMask);
|
||||
item = (Item *)_vm->getAllItems().findItemByID(kAirMask);
|
||||
item->getItemRoom(itemNeighborhood, itemRoom, itemDirection);
|
||||
|
||||
if (itemNeighborhood == getObjectID()) {
|
||||
_fillingStationItem = item;
|
||||
} else {
|
||||
item = (Item *)g_allItems.findItemByID(kNitrogenCanister);
|
||||
item = (Item *)_vm->getAllItems().findItemByID(kNitrogenCanister);
|
||||
item->getItemRoom(itemNeighborhood, itemRoom, itemDirection);
|
||||
|
||||
if (itemNeighborhood == getObjectID()) {
|
||||
_fillingStationItem = item;
|
||||
} else {
|
||||
item = (Item *)g_allItems.findItemByID(kArgonCanister);
|
||||
item = (Item *)_vm->getAllItems().findItemByID(kArgonCanister);
|
||||
item->getItemRoom(itemNeighborhood, itemRoom, itemDirection);
|
||||
if (itemNeighborhood == getObjectID())
|
||||
_fillingStationItem = item;
|
||||
|
@ -846,7 +846,7 @@ void NoradDelta::doSolve() {
|
||||
|
||||
if (GameState.getCurrentRoomAndView() == MakeRoomView(kNorad68, kWest)) {
|
||||
if (!_vm->playerHasItemID(kRetinalScanBiochip))
|
||||
_vm->addItemToBiochips((BiochipItem *)g_allItems.findItemByID(kRetinalScanBiochip));
|
||||
_vm->addItemToBiochips((BiochipItem *)_vm->getAllItems().findItemByID(kRetinalScanBiochip));
|
||||
|
||||
BiochipItem *biochip = _vm->getCurrentBiochip();
|
||||
if (biochip != 0 && biochip->getObjectID() != kRetinalScanBiochip && g_interface)
|
||||
|
@ -284,7 +284,7 @@ void Prehistoric::turnTo(const DirectionConstant newDirection) {
|
||||
break;
|
||||
case MakeRoomView(kPrehistoric16, kNorth):
|
||||
case MakeRoomView(kPrehistoric21, kWest):
|
||||
keyCard = g_allItems.findItemByID(kKeyCard);
|
||||
keyCard = _vm->getAllItems().findItemByID(kKeyCard);
|
||||
if (keyCard->getItemState() == kFlashlightOff) {
|
||||
keyCard->setItemState(kFlashlightOn);
|
||||
playSpotSoundSync(kPrehistoricFlashlightClickIn, kPrehistoricFlashlightClickOut);
|
||||
@ -294,7 +294,7 @@ void Prehistoric::turnTo(const DirectionConstant newDirection) {
|
||||
case MakeRoomView(kPrehistoric16, kWest):
|
||||
case MakeRoomView(kPrehistoric21, kNorth):
|
||||
case MakeRoomView(kPrehistoric21, kSouth):
|
||||
keyCard = g_allItems.findItemByID(kKeyCard);
|
||||
keyCard = _vm->getAllItems().findItemByID(kKeyCard);
|
||||
if (keyCard->getItemState() == kFlashlightOn) {
|
||||
keyCard->setItemState(kFlashlightOff);
|
||||
playSpotSoundSync(kPrehistoricFlashlightClickIn, kPrehistoricFlashlightClickOut);
|
||||
@ -356,7 +356,7 @@ void Prehistoric::arriveAt(const RoomID room, const DirectionConstant direction)
|
||||
zoomToVault();
|
||||
break;
|
||||
case MakeRoomView(kPrehistoric16, kNorth):
|
||||
keyCard = g_allItems.findItemByID(kKeyCard);
|
||||
keyCard = _vm->getAllItems().findItemByID(kKeyCard);
|
||||
|
||||
if (keyCard->getItemState() == kFlashlightOff) {
|
||||
keyCard->setItemState(kFlashlightOn);
|
||||
@ -383,7 +383,7 @@ void Prehistoric::arriveAt(const RoomID room, const DirectionConstant direction)
|
||||
case MakeRoomView(kPrehistoric19, kNorth):
|
||||
case MakeRoomView(kPrehistoric20, kNorth):
|
||||
case MakeRoomView(kPrehistoric21, kEast):
|
||||
keyCard = g_allItems.findItemByID(kKeyCard);
|
||||
keyCard = _vm->getAllItems().findItemByID(kKeyCard);
|
||||
|
||||
if (keyCard->getItemState() == kFlashlightOn) {
|
||||
keyCard->setItemState(kFlashlightOff);
|
||||
@ -554,7 +554,7 @@ void Prehistoric::receiveNotification(Notification *notification, const Notifica
|
||||
break;
|
||||
case kPre25EastUnlockingVaultNoLog:
|
||||
case kPre25EastUnlockingVaultWithLog:
|
||||
_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kJourneymanKey));
|
||||
_vm->addItemToInventory((InventoryItem *)_vm->getAllItems().findItemByID(kJourneymanKey));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1108,7 +1108,7 @@ void FullTSA::pickedUpItem(Item *item) {
|
||||
GameState.setScoringGotJourneymanKey(true);
|
||||
break;
|
||||
case kPegasusBiochip:
|
||||
biochip = (BiochipItem *)g_allItems.findItemByID(kMapBiochip);
|
||||
biochip = (BiochipItem *)_vm->getAllItems().findItemByID(kMapBiochip);
|
||||
_vm->addItemToBiochips(biochip);
|
||||
GameState.setScoringGotPegasusBiochip(true);
|
||||
break;
|
||||
@ -2373,7 +2373,7 @@ void FullTSA::receiveNotification(Notification *notification, const Notification
|
||||
|
||||
switch (lastExtra) {
|
||||
case kTSAGTCardSwipe:
|
||||
item = (InventoryItem *)g_allItems.findItemByID(kKeyCard);
|
||||
item = (InventoryItem *)_vm->getAllItems().findItemByID(kKeyCard);
|
||||
_vm->addItemToInventory(item);
|
||||
setCurrentActivation(kActivateTSAReadyToTransport);
|
||||
break;
|
||||
|
@ -1098,7 +1098,7 @@ void WSC::closeDoorOffScreen(const RoomID room, const DirectionConstant) {
|
||||
case kWSC82:
|
||||
case kWSC92:
|
||||
case kWSC93:
|
||||
keyCard = g_allItems.findItemByID(kKeyCard);
|
||||
keyCard = _vm->getAllItems().findItemByID(kKeyCard);
|
||||
if (keyCard->getItemState() == kFlashlightOn && (GameState.getCurrentRoom() == kWSC81 ||
|
||||
GameState.getCurrentRoom() == kWSC93)) {
|
||||
keyCard->setItemState(kFlashlightOff);
|
||||
@ -1166,11 +1166,11 @@ void WSC::doorOpened() {
|
||||
|
||||
switch (GameState.getCurrentRoomAndView()) {
|
||||
case MakeRoomView(kWSC42, kEast):
|
||||
_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kSinclairKey));
|
||||
_vm->addItemToInventory((InventoryItem *)_vm->getAllItems().findItemByID(kSinclairKey));
|
||||
break;
|
||||
case MakeRoomView(kWSC58, kSouth):
|
||||
GameState.setScoringUsedCrowBarInWSC();
|
||||
_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kCrowbar));
|
||||
_vm->addItemToInventory((InventoryItem *)_vm->getAllItems().findItemByID(kCrowbar));
|
||||
break;
|
||||
case MakeRoomView(kWSC06, kNorth):
|
||||
case MakeRoomView(kWSC79, kWest):
|
||||
@ -1663,7 +1663,7 @@ void WSC::receiveNotification(Notification *notification, const NotificationFlag
|
||||
makeContinuePoint();
|
||||
break;
|
||||
case kWSCDartScan2:
|
||||
_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kPoisonDart));
|
||||
_vm->addItemToInventory((InventoryItem *)_vm->getAllItems().findItemByID(kPoisonDart));
|
||||
GameState.setScoringRemovedDart();
|
||||
GameState.setWSCRemovedDart(true);
|
||||
setUpPoison();
|
||||
@ -1915,7 +1915,7 @@ void WSC::receiveNotification(Notification *notification, const NotificationFlag
|
||||
//g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/WSC/XN59WD", false, kWarningInterruption);
|
||||
break;
|
||||
case kW98RobotGassed:
|
||||
item = (Item *)g_allItems.findItemByID(kArgonCanister);
|
||||
item = (Item *)_vm->getAllItems().findItemByID(kArgonCanister);
|
||||
_vm->addItemToInventory((InventoryItem *)item);
|
||||
setCurrentActivation(kActivationRobotDead);
|
||||
GameState.setWSCRobotDead(true);
|
||||
@ -2112,7 +2112,7 @@ void WSC::activateOneHotspot(HotspotInfoTable::Entry &entry, Hotspot *hotspot) {
|
||||
hotspot->setActive();
|
||||
break;
|
||||
case kW98DropArgonSpotID:
|
||||
argonCanister = g_allItems.findItemByID(kArgonCanister);
|
||||
argonCanister = _vm->getAllItems().findItemByID(kArgonCanister);
|
||||
if (argonCanister->getItemState() != kArgonFull)
|
||||
hotspot->setInactive();
|
||||
break;
|
||||
@ -2342,9 +2342,9 @@ void WSC::pickedUpItem(Item *item) {
|
||||
break;
|
||||
case kArgonPickup:
|
||||
_vm->removeItemFromInventory((InventoryItem *)item);
|
||||
item = (Item *)g_allItems.findItemByID(kArgonCanister);
|
||||
item = (Item *)_vm->getAllItems().findItemByID(kArgonCanister);
|
||||
_vm->addItemToInventory((InventoryItem *)item);
|
||||
item = (Item *)g_allItems.findItemByID(kSinclairKey);
|
||||
item = (Item *)_vm->getAllItems().findItemByID(kSinclairKey);
|
||||
_vm->addItemToInventory((InventoryItem *)item);
|
||||
_vm->getAllHotspots().setHotspotRect(kWSC02SouthMorphOutSpotID,
|
||||
Common::Rect(kNavAreaLeft, kNavAreaTop, 512 + kNavAreaLeft, 256 + kNavAreaTop));
|
||||
|
@ -470,14 +470,14 @@ bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
|
||||
setEnergyDeathReason(stream->readByte());
|
||||
|
||||
// Items
|
||||
g_allItems.readFromStream(stream);
|
||||
_allItems.readFromStream(stream);
|
||||
|
||||
// Inventory
|
||||
byte itemCount = stream->readByte();
|
||||
|
||||
if (itemCount > 0) {
|
||||
for (byte i = 0; i < itemCount; i++) {
|
||||
InventoryItem *inv = (InventoryItem *)g_allItems.findItemByID((ItemID)stream->readUint16BE());
|
||||
InventoryItem *inv = (InventoryItem *)_allItems.findItemByID((ItemID)stream->readUint16BE());
|
||||
addItemToInventory(inv);
|
||||
}
|
||||
|
||||
@ -489,7 +489,7 @@ bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
|
||||
|
||||
if (biochipCount > 0) {
|
||||
for (byte i = 0; i < biochipCount; i++) {
|
||||
BiochipItem *biochip = (BiochipItem *)g_allItems.findItemByID((ItemID)stream->readUint16BE());
|
||||
BiochipItem *biochip = (BiochipItem *)_allItems.findItemByID((ItemID)stream->readUint16BE());
|
||||
addItemToBiochips(biochip);
|
||||
}
|
||||
|
||||
@ -541,7 +541,7 @@ bool PegasusEngine::writeToStream(Common::WriteStream *stream, int saveType) {
|
||||
stream->writeByte(getEnergyDeathReason());
|
||||
|
||||
// Items
|
||||
g_allItems.writeToStream(stream);
|
||||
_allItems.writeToStream(stream);
|
||||
|
||||
// Inventory
|
||||
byte itemCount = _items.getNumItems();
|
||||
@ -1392,7 +1392,7 @@ bool PegasusEngine::itemInLocation(const ItemID itemID, const NeighborhoodID nei
|
||||
RoomID itemRoom;
|
||||
DirectionConstant itemDirection;
|
||||
|
||||
Item *item = g_allItems.findItemByID(itemID);
|
||||
Item *item = _allItems.findItemByID(itemID);
|
||||
item->getItemRoom(itemNeighborhood, itemRoom, itemDirection);
|
||||
|
||||
return itemNeighborhood == neighborhood && itemRoom == room && itemDirection == direction;
|
||||
@ -1503,17 +1503,17 @@ void PegasusEngine::startNewGame() {
|
||||
removeAllItemsFromInventory();
|
||||
removeAllItemsFromBiochips();
|
||||
|
||||
BiochipItem *biochip = (BiochipItem *)g_allItems.findItemByID(kAIBiochip);
|
||||
BiochipItem *biochip = (BiochipItem *)_allItems.findItemByID(kAIBiochip);
|
||||
addItemToBiochips(biochip);
|
||||
|
||||
if (isDemo()) {
|
||||
biochip = (BiochipItem *)g_allItems.findItemByID(kPegasusBiochip);
|
||||
biochip = (BiochipItem *)_allItems.findItemByID(kPegasusBiochip);
|
||||
addItemToBiochips(biochip);
|
||||
biochip = (BiochipItem *)g_allItems.findItemByID(kMapBiochip);
|
||||
biochip = (BiochipItem *)_allItems.findItemByID(kMapBiochip);
|
||||
addItemToBiochips(biochip);
|
||||
InventoryItem *item = (InventoryItem *)g_allItems.findItemByID(kKeyCard);
|
||||
InventoryItem *item = (InventoryItem *)_allItems.findItemByID(kKeyCard);
|
||||
addItemToInventory(item);
|
||||
item = (InventoryItem *)g_allItems.findItemByID(kJourneymanKey);
|
||||
item = (InventoryItem *)_allItems.findItemByID(kJourneymanKey);
|
||||
addItemToInventory(item);
|
||||
_currentItemID = kJourneymanKey;
|
||||
} else {
|
||||
@ -2154,7 +2154,7 @@ void PegasusEngine::drawScaledFrame(const Graphics::Surface *frame, uint16 x, ui
|
||||
}
|
||||
|
||||
void PegasusEngine::destroyInventoryItem(const ItemID itemID) {
|
||||
InventoryItem *item = (InventoryItem *)g_allItems.findItemByID(itemID);
|
||||
InventoryItem *item = (InventoryItem *)_allItems.findItemByID(itemID);
|
||||
|
||||
ItemExtraEntry entry;
|
||||
|
||||
|
@ -132,6 +132,7 @@ public:
|
||||
void setAmbienceLevel(uint16);
|
||||
|
||||
// Items
|
||||
ItemList &getAllItems() { return _allItems; }
|
||||
bool playerHasItem(const Item *);
|
||||
bool playerHasItemID(const ItemID);
|
||||
void checkFlashlight();
|
||||
@ -228,6 +229,7 @@ private:
|
||||
void giveIdleTime();
|
||||
|
||||
// Items
|
||||
ItemList _allItems;
|
||||
void createItems();
|
||||
void createItem(ItemID itemID, NeighborhoodID neighborhoodID, RoomID roomID, DirectionConstant direction);
|
||||
Inventory _items;
|
||||
|
Loading…
Reference in New Issue
Block a user