diff options
Diffstat (limited to 'engines/pegasus/neighborhood/mars')
-rw-r--r-- | engines/pegasus/neighborhood/mars/mars.cpp | 40 | ||||
-rw-r--r-- | engines/pegasus/neighborhood/mars/mars.h | 10 | ||||
-rw-r--r-- | engines/pegasus/neighborhood/mars/robotship.cpp | 6 | ||||
-rw-r--r-- | engines/pegasus/neighborhood/mars/robotship.h | 2 |
4 files changed, 14 insertions, 44 deletions
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(); |