aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMatthew Hoops2012-08-28 16:50:15 -0400
committerMatthew Hoops2012-08-28 16:50:15 -0400
commitf61146f32791831211c7b9399ec681aed109f03b (patch)
tree7aa7e8d749448f06427cce963ba088e2f9d71716 /engines
parent81e7c9a0c1599786a1aeb73d243609a2d280335f (diff)
downloadscummvm-rg350-f61146f32791831211c7b9399ec681aed109f03b.tar.gz
scummvm-rg350-f61146f32791831211c7b9399ec681aed109f03b.tar.bz2
scummvm-rg350-f61146f32791831211c7b9399ec681aed109f03b.zip
PEGASUS: Remove g_allItems global construction
Diffstat (limited to 'engines')
-rw-r--r--engines/pegasus/items/itemlist.cpp8
-rw-r--r--engines/pegasus/items/itemlist.h3
-rw-r--r--engines/pegasus/neighborhood/caldoria/caldoria.cpp8
-rw-r--r--engines/pegasus/neighborhood/mars/mars.cpp8
-rw-r--r--engines/pegasus/neighborhood/neighborhood.cpp4
-rw-r--r--engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp8
-rw-r--r--engines/pegasus/neighborhood/norad/delta/noraddelta.cpp2
-rw-r--r--engines/pegasus/neighborhood/prehistoric/prehistoric.cpp10
-rw-r--r--engines/pegasus/neighborhood/tsa/fulltsa.cpp4
-rw-r--r--engines/pegasus/neighborhood/wsc/wsc.cpp16
-rw-r--r--engines/pegasus/pegasus.cpp22
-rw-r--r--engines/pegasus/pegasus.h2
12 files changed, 47 insertions, 48 deletions
diff --git a/engines/pegasus/items/itemlist.cpp b/engines/pegasus/items/itemlist.cpp
index 4c30975589..ff8cae546b 100644
--- a/engines/pegasus/items/itemlist.cpp
+++ b/engines/pegasus/items/itemlist.cpp
@@ -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() {
}
diff --git a/engines/pegasus/items/itemlist.h b/engines/pegasus/items/itemlist.h
index b5a1d489be..173a54104d 100644
--- a/engines/pegasus/items/itemlist.h
+++ b/engines/pegasus/items/itemlist.h
@@ -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
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
index 6421195c8e..8c31debf1c 100644
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -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() {
diff --git a/engines/pegasus/neighborhood/mars/mars.cpp b/engines/pegasus/neighborhood/mars/mars.cpp
index 8c1098a73d..9cc8ab63d4 100644
--- a/engines/pegasus/neighborhood/mars/mars.cpp
+++ b/engines/pegasus/neighborhood/mars/mars.cpp
@@ -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);
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index a93dd7e0a7..bb2c6486cc 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -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 {
diff --git a/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp b/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
index 2d050d9aa5..793d8ffb59 100644
--- a/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
+++ b/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
@@ -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;
diff --git a/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp b/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
index cf21f7744f..01530023c8 100644
--- a/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
+++ b/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
@@ -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)
diff --git a/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp b/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
index dcc00ab651..11e28f072d 100644
--- a/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
+++ b/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
@@ -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;
}
}
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.cpp b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
index bb7a701200..2269ea7122 100644
--- a/engines/pegasus/neighborhood/tsa/fulltsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
@@ -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;
diff --git a/engines/pegasus/neighborhood/wsc/wsc.cpp b/engines/pegasus/neighborhood/wsc/wsc.cpp
index 39fbe37648..e3a0eff01b 100644
--- a/engines/pegasus/neighborhood/wsc/wsc.cpp
+++ b/engines/pegasus/neighborhood/wsc/wsc.cpp
@@ -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));
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index ad0abc2186..efa57d586f 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -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;
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 7f4fae5f11..661f8e0f9d 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -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;