aboutsummaryrefslogtreecommitdiff
path: root/engines/pegasus/neighborhood
diff options
context:
space:
mode:
Diffstat (limited to 'engines/pegasus/neighborhood')
-rw-r--r--engines/pegasus/neighborhood/caldoria/caldoria.cpp16
-rw-r--r--engines/pegasus/neighborhood/caldoria/caldoria.h2
-rw-r--r--engines/pegasus/neighborhood/mars/mars.cpp40
-rw-r--r--engines/pegasus/neighborhood/mars/mars.h10
-rw-r--r--engines/pegasus/neighborhood/mars/robotship.cpp6
-rw-r--r--engines/pegasus/neighborhood/mars/robotship.h2
-rw-r--r--engines/pegasus/neighborhood/neighborhood.cpp6
-rw-r--r--engines/pegasus/neighborhood/neighborhood.h2
-rw-r--r--engines/pegasus/neighborhood/tsa/fulltsa.cpp6
-rw-r--r--engines/pegasus/neighborhood/tsa/fulltsa.h4
10 files changed, 27 insertions, 67 deletions
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
index 8c31debf1c..8d46300d9a 100644
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -150,14 +150,6 @@ static const TimeValue k5To3Time = 41280;
const NotificationFlags kSinclairLoopDoneFlag = kLastNeighborhoodNotificationFlag << 1;
-void doorBombTimerExpiredFunction(FunctionPtr *, void *caldoria) {
- ((Caldoria *)caldoria)->doorBombTimerExpired();
-}
-
-void sinclairTimerExpiredFunction(FunctionPtr *, void *caldoria) {
- ((Caldoria *)caldoria)->sinclairTimerExpired();
-}
-
SinclairCallBack::SinclairCallBack(Caldoria *caldoria) {
_caldoria = caldoria;
}
@@ -941,7 +933,7 @@ void Caldoria::setUpRoofTop() {
} else if (GameState.getCaldoriaDoorBombed()) {
// Long enough for AI hints...?
_utilityFuse.primeFuse(kCardBombCountDownTime);
- _utilityFuse.setFunctionPtr(&doorBombTimerExpiredFunction, (void *)this);
+ _utilityFuse.setFunctor(new Common::Functor0Mem<void, Caldoria>(this, &Caldoria::doorBombTimerExpired));
_utilityFuse.lightFuse();
loopCroppedMovie("Images/Caldoria/A48 Bomb Loop", kCaldoria48CardBombLoopLeft, kCaldoria48CardBombLoopTop);
@@ -965,7 +957,7 @@ void Caldoria::setUpRoofTop() {
if (!GameState.getCaldoriaSinclairShot()) {
if (GameState.getCaldoriaSawVoiceAnalysis() && !_utilityFuse.isFuseLit()) {
_utilityFuse.primeFuse(GameState.getCaldoriaFuseTimeLimit());
- _utilityFuse.setFunctionPtr(&sinclairTimerExpiredFunction, (void *)this);
+ _utilityFuse.setFunctor(new Common::Functor0Mem<void, Caldoria>(this, &Caldoria::sinclairTimerExpired));
_utilityFuse.lightFuse();
}
} else {
@@ -1198,7 +1190,7 @@ void Caldoria::receiveNotification(Notification *notification, const Notificatio
break;
case kCa49NorthVoiceAnalysis:
_utilityFuse.primeFuse(kSinclairShootsTimeLimit);
- _utilityFuse.setFunctionPtr(&sinclairTimerExpiredFunction, (void*) this);
+ _utilityFuse.setFunctor(new Common::Functor0Mem<void, Caldoria>(this, &Caldoria::sinclairTimerExpired));
_utilityFuse.lightFuse();
GameState.setCaldoriaSawVoiceAnalysis(true);
break;
@@ -1614,7 +1606,7 @@ void Caldoria::dropItemIntoRoom(Item *item, Hotspot *dropSpot) {
Neighborhood::dropItemIntoRoom(item, dropSpot);
// Long enough for AI hints...?
_utilityFuse.primeFuse(kCardBombCountDownTime);
- _utilityFuse.setFunctionPtr(&doorBombTimerExpiredFunction, (void *)this);
+ _utilityFuse.setFunctor(new Common::Functor0Mem<void, Caldoria>(this, &Caldoria::doorBombTimerExpired));
_utilityFuse.lightFuse();
GameState.setCaldoriaFuseTimeLimit(kCardBombCountDownTime);
loopCroppedMovie("Images/Caldoria/A48 Bomb Loop", kCaldoria48CardBombLoopLeft, kCaldoria48CardBombLoopTop);
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.h b/engines/pegasus/neighborhood/caldoria/caldoria.h
index f02101ec3b..c9243e0576 100644
--- a/engines/pegasus/neighborhood/caldoria/caldoria.h
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.h
@@ -401,8 +401,6 @@ protected:
class Caldoria : public Neighborhood {
friend class SinclairCallBack;
-friend void doorBombTimerExpiredFunction(FunctionPtr *, void *);
-friend void sinclairTimerExpiredFunction(FunctionPtr *, void *);
public:
Caldoria(InputHandler *, PegasusEngine *);
diff --git a/engines/pegasus/neighborhood/mars/mars.cpp b/engines/pegasus/neighborhood/mars/mars.cpp
index 9cc8ab63d4..e5a4b61a44 100644
--- a/engines/pegasus/neighborhood/mars/mars.cpp
+++ b/engines/pegasus/neighborhood/mars/mars.cpp
@@ -85,28 +85,8 @@ enum {
#define kShuttleTractorBounds Common::Rect(24, 103, 24 + 112, 103 + 30)
#define kShuttleTransportBounds Common::Rect(484, 353, 89 + 484, 79 + 353)
-void robotTimerExpiredFunction(FunctionPtr *, void *mars) {
- ((Mars *)mars)->robotTiredOfWaiting();
-}
-
-void lockThawTimerExpiredFunction(FunctionPtr *, void *mars) {
- ((Mars *)mars)->lockThawed();
-}
-
-void bombTimerExpiredFunction(FunctionPtr *, void *mars) {
- ((Mars *)mars)->didntFindBomb();
-}
-
-void bombTimerExpiredInGameFunction(FunctionPtr *, void *mars) {
- ((Mars *)mars)->bombExplodesInGame();
-}
-
-void airStageExpiredFunction(FunctionPtr *, void *mars) {
- ((Mars *)mars)->airStageExpired();
-}
-
-void marsTimerFunction(FunctionPtr *, void *event) {
- ((MarsTimerEvent *)event)->mars->marsTimerExpired(*(MarsTimerEvent *)event);
+void MarsTimerEvent::fire() {
+ mars->marsTimerExpired(*this);
}
Mars::Mars(InputHandler *nextHandler, PegasusEngine *owner) : Neighborhood(nextHandler, owner, "Mars", kMarsID),
@@ -120,7 +100,7 @@ Mars::Mars(InputHandler *nextHandler, PegasusEngine *owner) : Neighborhood(nextH
_planetMovie(kNoDisplayElement), _junk(kNoDisplayElement), _energyChoiceSpot(kShuttleEnergySpotID),
_gravitonChoiceSpot(kShuttleGravitonSpotID), _tractorChoiceSpot(kShuttleTractorSpotID),
_shuttleViewSpot(kShuttleViewSpotID), _shuttleTransportSpot(kShuttleTransportSpotID) {
- _noAirFuse.setFunctionPtr(&airStageExpiredFunction, this);
+ _noAirFuse.setFunctor(new Common::Functor0Mem<void, Mars>(this, &Mars::airStageExpired));
setIsItemTaken(kMarsCard);
setIsItemTaken(kAirMask);
setIsItemTaken(kCrowbar);
@@ -1341,7 +1321,7 @@ void Mars::arriveAt(const RoomID room, const DirectionConstant direction) {
loadLoopSound2("Sounds/Mars/Robot Loop.aiff", 0x100, 0, 0);
loopExtraSequence(kMars48RobotLoops);
_utilityFuse.primeFuse(kMarsRobotPatienceLimit);
- _utilityFuse.setFunctionPtr(&robotTimerExpiredFunction, (void *)this);
+ _utilityFuse.setFunctor(new Common::Functor0Mem<void, Mars>(this, &Mars::robotTiredOfWaiting));
_utilityFuse.lightFuse();
}
break;
@@ -1349,7 +1329,7 @@ void Mars::arriveAt(const RoomID room, const DirectionConstant direction) {
if (GameState.getMarsSeenRobotAtReactor() && !GameState.getMarsAvoidedReactorRobot()) {
loadLoopSound2("Sounds/Mars/Robot Loop.aiff", 0x100, 0, 0);
_utilityFuse.primeFuse(kMarsRobotPatienceLimit);
- _utilityFuse.setFunctionPtr(&robotTimerExpiredFunction, (void *)this);
+ _utilityFuse.setFunctor(new Common::Functor0Mem<void, Mars>(this, &Mars::robotTiredOfWaiting));
_utilityFuse.lightFuse();
}
break;
@@ -1402,7 +1382,7 @@ void Mars::arriveAt(const RoomID room, const DirectionConstant direction) {
setCurrentActivation(kActivateReactorReadyForCrowBar);
_privateFlags.setFlag(kMarsPrivatePlatformZoomedInFlag, true);
_utilityFuse.primeFuse(kLockFreezeTimeLmit);
- _utilityFuse.setFunctionPtr(&lockThawTimerExpiredFunction, (void *)this);
+ _utilityFuse.setFunctor(new Common::Functor0Mem<void, Mars>(this, &Mars::lockThawed));
_utilityFuse.lightFuse();
} else {
setCurrentActivation(kActivateReactorPlatformOut);
@@ -2184,7 +2164,7 @@ void Mars::receiveNotification(Notification *notification, const NotificationFla
GameState.setMarsSeenRobotAtReactor(true);
loopExtraSequence(kMars48RobotLoops);
_utilityFuse.primeFuse(kMarsRobotPatienceLimit);
- _utilityFuse.setFunctionPtr(&robotTimerExpiredFunction, (void *)this);
+ _utilityFuse.setFunctor(new Common::Functor0Mem<void, Mars>(this, &Mars::robotTiredOfWaiting));
_utilityFuse.lightFuse();
break;
case kMars48RobotDefends:
@@ -2267,7 +2247,7 @@ void Mars::receiveNotification(Notification *notification, const NotificationFla
GameState.setMarsLockFrozen(true);
showExtraView(kMars57LockFrozenView);
_utilityFuse.primeFuse(kLockFreezeTimeLmit);
- _utilityFuse.setFunctionPtr(&lockThawTimerExpiredFunction, (void *)this);
+ _utilityFuse.setFunctor(new Common::Functor0Mem<void, Mars>(this, &Mars::lockThawed));
_utilityFuse.lightFuse();
break;
case kMars57BreakLock:
@@ -2800,7 +2780,7 @@ void Mars::startMarsTimer(TimeValue time, TimeScale scale, MarsTimerCode code) {
_utilityFuse.primeFuse(time, scale);
_marsEvent.mars = this;
_marsEvent.event = code;
- _utilityFuse.setFunctionPtr(&marsTimerFunction, (void *)&_marsEvent);
+ _utilityFuse.setFunctor(new Common::Functor0Mem<void, MarsTimerEvent>(&_marsEvent, &MarsTimerEvent::fire));
_utilityFuse.lightFuse();
}
@@ -3398,7 +3378,7 @@ void Mars::setUpReactorLevel1() {
_choiceHighlight.initReactorChoiceHighlight();
setCurrentActivation(kActivateReactorInGame);
_bombFuse.primeFuse(kColorMatchingTimeLimit);
- _bombFuse.setFunctionPtr(&bombTimerExpiredInGameFunction, (void *)this);
+ _bombFuse.setFunctor(new Common::Functor0Mem<void, Mars>(this, &Mars::bombExplodesInGame));
_bombFuse.lightFuse();
}
diff --git a/engines/pegasus/neighborhood/mars/mars.h b/engines/pegasus/neighborhood/mars/mars.h
index 9aca10a703..3ddbf39515 100644
--- a/engines/pegasus/neighborhood/mars/mars.h
+++ b/engines/pegasus/neighborhood/mars/mars.h
@@ -52,6 +52,8 @@ enum MarsTimerCode {
struct MarsTimerEvent {
Mars *mars;
MarsTimerCode event;
+
+ void fire();
};
enum ShuttleWeaponSelection {
@@ -62,13 +64,7 @@ enum ShuttleWeaponSelection {
};
class Mars : public Neighborhood {
-friend void robotTimerExpiredFunction(FunctionPtr *, void *);
-friend void lockThawTimerExpiredFunction(FunctionPtr *, void *);
-friend void bombTimerExpiredFunction(FunctionPtr *, void *);
-friend void bombTimerExpiredInGameFunction(FunctionPtr *, void *);
-friend void airStageExpiredFunction(FunctionPtr *, void *);
-friend void marsTimerFunction(FunctionPtr *, void *);
-
+friend class MarsTimerEvent;
public:
Mars(InputHandler *, PegasusEngine *);
virtual ~Mars();
diff --git a/engines/pegasus/neighborhood/mars/robotship.cpp b/engines/pegasus/neighborhood/mars/robotship.cpp
index a0ff749910..43a7e558c3 100644
--- a/engines/pegasus/neighborhood/mars/robotship.cpp
+++ b/engines/pegasus/neighborhood/mars/robotship.cpp
@@ -55,10 +55,6 @@ static const CoordType kRovingHeight = kShuttleWindowMidV - kRovingTop;
RobotShip* g_robotShip = 0;
-void timeToDropJunkFunction(FunctionPtr *, void *robotShip) {
- ((RobotShip *)robotShip)->timeToDropJunk();
-}
-
RobotShip::RobotShip() : _spritesMovie(kNoDisplayElement) {
g_robotShip = this;
_shipRange = Common::Rect(kShuttleWindowLeft, kShuttleWindowTop, kShuttleWindowLeft + kShuttleWindowWidth,
@@ -67,7 +63,7 @@ RobotShip::RobotShip() : _spritesMovie(kNoDisplayElement) {
_currentLocation.x = 0;
_currentLocation.y = 0;
_snaring = false;
- _dropJunkFuse.setFunctionPtr(&timeToDropJunkFunction, (void *)this);
+ _dropJunkFuse.setFunctor(new Common::Functor0Mem<void, RobotShip>(this, &RobotShip::timeToDropJunk));
}
RobotShip::~RobotShip() {
diff --git a/engines/pegasus/neighborhood/mars/robotship.h b/engines/pegasus/neighborhood/mars/robotship.h
index b668e8f154..04be3ea56e 100644
--- a/engines/pegasus/neighborhood/mars/robotship.h
+++ b/engines/pegasus/neighborhood/mars/robotship.h
@@ -34,8 +34,6 @@ static const CoordType kShuttleMovieWidth = 114;
static const CoordType kShuttleMovieHeight = 42;
class RobotShip : IdlerTimeBase {
-friend void timeToDropJunkFunction(FunctionPtr *, void *);
-
public:
RobotShip();
virtual ~RobotShip();
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index bb2c6486cc..ae383a661b 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -1740,15 +1740,15 @@ void Neighborhood::useIdleTime() {
}
}
-void timerFunction(FunctionPtr *, void *neighborhood) {
- ((Neighborhood *)neighborhood)->timerExpired(((Neighborhood *)neighborhood)->getTimerEvent());
+void Neighborhood::timerFunction() {
+ timerExpired(getTimerEvent());
}
void Neighborhood::scheduleEvent(const TimeValue time, const TimeScale scale, const uint32 eventType) {
_eventTimer.stopFuse();
_eventTimer.primeFuse(time, scale);
_timerEvent = eventType;
- _eventTimer.setFunctionPtr(&timerFunction, this);
+ _eventTimer.setFunctor(new Common::Functor0Mem<void, Neighborhood>(this, &Neighborhood::timerFunction));
_eventTimer.lightFuse();
}
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index 8a38eb3389..1fef06657a 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -110,7 +110,6 @@ typedef Common::Queue<QueueRequest> NeighborhoodActionQueue;
class Neighborhood : public IDObject, public NotificationReceiver, public InputHandler, public Idler {
friend class StriderCallBack;
-friend void timerFunction(FunctionPtr *, void *);
public:
Neighborhood(InputHandler *nextHandler, PegasusEngine *vm, const Common::String &resName, NeighborhoodID id);
@@ -335,6 +334,7 @@ protected:
virtual void timerExpired(const uint32) {}
bool isEventTimerRunning() { return _eventTimer.isFuseLit(); }
uint32 getTimerEvent() { return _timerEvent; }
+ void timerFunction();
void pauseTimer();
void resumeTimer();
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.cpp b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
index 2269ea7122..98c70aa09d 100644
--- a/engines/pegasus/neighborhood/tsa/fulltsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
@@ -663,8 +663,8 @@ void FullTSA::init() {
entry->hotspotItem = kPegasusBiochip;
}
-void uncreatedInTSAFunction(FunctionPtr *, void *tsa) {
- ((FullTSA *)tsa)->die(kDeathUncreatedInTSA);
+void FullTSA::dieUncreatedInTSA() {
+ die(kDeathUncreatedInTSA);
}
void FullTSA::start() {
@@ -672,7 +672,7 @@ void FullTSA::start() {
if (!GameState.getScoringEnterTSA()) {
_utilityFuse.primeFuse(GameState.getTSAFuseTimeLimit());
- _utilityFuse.setFunctionPtr(&uncreatedInTSAFunction, (void *)this);
+ _utilityFuse.setFunctor(new Common::Functor0Mem<void, FullTSA>(this, &FullTSA::dieUncreatedInTSA));
_utilityFuse.lightFuse();
} else if (GameState.getTSAState() == kTSAPlayerDetectedRip || GameState.getTSAState() == kTSAPlayerNeedsHistoricalLog) {
_ripTimer.initImage();
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.h b/engines/pegasus/neighborhood/tsa/fulltsa.h
index 4260a83a78..7dd11a766c 100644
--- a/engines/pegasus/neighborhood/tsa/fulltsa.h
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.h
@@ -54,8 +54,6 @@ static const RoomID kTSA22Red = 28;
static const RoomID kTSA37 = 42;
class FullTSA : public Neighborhood {
-friend void uncreatedInTSAFunction(FunctionPtr *, void *tsa);
-
public:
FullTSA(InputHandler *, PegasusEngine *);
virtual ~FullTSA() {}
@@ -152,6 +150,8 @@ protected:
Common::String getNavMovieName();
Common::String getSoundSpotsName();
+
+ void dieUncreatedInTSA();
};
} // End of namespace Pegasus