diff options
author | johndoe123 | 2012-09-28 11:03:00 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:43:43 +0200 |
commit | d1927ef8e6e0ebcc02400e97fa8f2055fc86983e (patch) | |
tree | ca06420fba6da52a04d53eb508c7c4a8e8672c6e /engines/neverhood | |
parent | cce19001fd353664f4348adf291080cef9da50b0 (diff) | |
download | scummvm-rg350-d1927ef8e6e0ebcc02400e97fa8f2055fc86983e.tar.gz scummvm-rg350-d1927ef8e6e0ebcc02400e97fa8f2055fc86983e.tar.bz2 scummvm-rg350-d1927ef8e6e0ebcc02400e97fa8f2055fc86983e.zip |
NEVERHOOD: Move Klayman teleporter appear/disappear animation code from the several subclasses to the base Klayman class; the code was equal except for the animation hashes
Diffstat (limited to 'engines/neverhood')
-rw-r--r-- | engines/neverhood/klayman.cpp | 254 | ||||
-rw-r--r-- | engines/neverhood/klayman.h | 12 |
2 files changed, 53 insertions, 213 deletions
diff --git a/engines/neverhood/klayman.cpp b/engines/neverhood/klayman.cpp index 6ce39a7930..2954852167 100644 --- a/engines/neverhood/klayman.cpp +++ b/engines/neverhood/klayman.cpp @@ -2310,6 +2310,38 @@ void Klayman::stIdleTeleporterHands2() { NextState(&Klayman::stIdleSitBlinkSecond); } +void Klayman::teleporterAppear(uint32 fileHash) { + _status2 = 0; + _acceptInput = false; + startAnimation(fileHash, 0, -1); + SetUpdateHandler(&Klayman::update); + SetMessageHandler(&Klayman::hmTeleporterAppearDisappear); + SetSpriteUpdate(NULL); +} + +void Klayman::teleporterDisappear(uint32 fileHash) { + _status2 = 0; + _acceptInput = false; + startAnimation(fileHash, 0, -1); + SetUpdateHandler(&Klayman::update); + SetMessageHandler(&Klayman::hmTeleporterAppearDisappear); + SetSpriteUpdate(NULL); +} + +uint32 Klayman::hmTeleporterAppearDisappear(int messageNum, const MessageParam ¶m, Entity *sender) { + uint32 messageResult = handleMessage41D480(messageNum, param, sender); + switch (messageNum) { + case 0x100D: + if (param.asInteger() == 0x4E0A2C24) { + _soundResource1.play(0x85B10BB8); + } else if (param.asInteger() == 0x4E6A0CA0) { + _soundResource1.play(0xC5B709B0); + } + break; + } + return messageResult; +} + //############################################################################## // KmScene1001 @@ -3004,47 +3036,15 @@ uint32 KmScene1109::xHandleMessage(int messageNum, const MessageParam ¶m) { GotoState(&Klayman::stGetUpFromTeleporter); break; case 0x483D: - stTeleporterAppear(); + teleporterAppear(0x2C2A4A1C); break; case 0x483E: - stTeleporterDisappear(); + teleporterDisappear(0x3C2E4245); break; } return 0; } -uint32 KmScene1109::hmTeleporterAppearDisappear(int messageNum, const MessageParam ¶m, Entity *sender) { - uint32 messageResult = Klayman::handleMessage41D480(messageNum, param, sender); - switch (messageNum) { - case 0x100D: - if (param.asInteger() == 0x4E0A2C24) { - _soundResource1.play(0x85B10BB8); - } else if (param.asInteger() == 0x4E6A0CA0) { - _soundResource1.play(0xC5B709B0); - } - break; - } - return messageResult; -} - -void KmScene1109::stTeleporterAppear() { - _status2 = 0; - _acceptInput = false; - startAnimation(0x2C2A4A1C, 0, -1); - SetUpdateHandler(&Klayman::update); - SetSpriteUpdate(NULL); - SetMessageHandler(&KmScene1109::hmTeleporterAppearDisappear); -} - -void KmScene1109::stTeleporterDisappear() { - _status2 = 0; - _acceptInput = false; - startAnimation(0x3C2E4245, 0, -1); - SetUpdateHandler(&Klayman::update); - SetSpriteUpdate(NULL); - SetMessageHandler(&KmScene1109::hmTeleporterAppearDisappear); -} - // KmScene1201 KmScene1201::KmScene1201(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y, Entity *class464) @@ -3540,10 +3540,10 @@ uint32 KmScene1306::xHandleMessage(int messageNum, const MessageParam ¶m) { GotoState(&Klayman::stGetUpFromTeleporter); break; case 0x483D: - stTeleporterAppear(); + teleporterAppear(0xEE084A04); break; case 0x483E: - stTeleporterDisappear(); + teleporterDisappear(0xB86A4274); break; case 0x483F: startSpecialWalkRight(param.asInteger()); @@ -3555,37 +3555,6 @@ uint32 KmScene1306::xHandleMessage(int messageNum, const MessageParam ¶m) { return messageResult; } -void KmScene1306::stTeleporterAppear() { - _status2 = 0; - _acceptInput = false; - startAnimation(0xEE084A04, 0, -1); - SetUpdateHandler(&Klayman::update); - SetSpriteUpdate(NULL); - SetMessageHandler(&KmScene1306::hmTeleporterAppearDisappear); -} - -void KmScene1306::stTeleporterDisappear() { - _status2 = 0; - _acceptInput = false; - startAnimation(0xB86A4274, 0, -1); - SetUpdateHandler(&Klayman::update); - SetSpriteUpdate(NULL); - SetMessageHandler(&KmScene1306::hmTeleporterAppearDisappear); -} - -uint32 KmScene1306::hmTeleporterAppearDisappear(int messageNum, const MessageParam ¶m, Entity *sender) { - uint32 messageResult = handleMessage41D480(messageNum, param, sender); - switch (messageNum) { - case 0x100D: - if (param.asInteger() == 0x4E0A2C24) { - _soundResource1.play(0x85B10BB8); - } else if (param.asInteger() == 0x4E6A0CA0) { - _soundResource1.play(0xC5B709B0); - } - } - return messageResult; -} - KmScene1308::KmScene1308(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y) : Klayman(vm, parentScene, x, y, 1000, 1000), _flag1(false) { @@ -4154,29 +4123,15 @@ uint32 KmScene1705::xHandleMessage(int messageNum, const MessageParam ¶m) { GotoState(&Klayman::stGetUpFromTeleporter); break; case 0x483D: - stTeleporterAppear(); + teleporterAppear(0x5E0A4905); break; case 0x483E: - stTeleporterDisappear(); + teleporterDisappear(0xD86E4477); break; } return messageResult; } -uint32 KmScene1705::hmTeleporterAppearDisappear(int messageNum, const MessageParam ¶m, Entity *sender) { - uint32 messageResult = handleMessage41D480(messageNum, param, sender); - switch (messageNum) { - case 0x100D: - if (param.asInteger() == 0x4E0A2C24) { - _soundResource1.play(0x85B10BB8); - } else if (param.asInteger() == 0x4E6A0CA0) { - _soundResource1.play(0xC5B709B0); - } - break; - } - return messageResult; -} - void KmScene1705::suFallSkipJump() { updateDeltaXY(); HitRect *hitRect = _vm->_collisionMan->findHitRectAtPos(_x, _y + 10); @@ -4197,24 +4152,6 @@ void KmScene1705::stFallSkipJump() { NextState(&Klayman::stLandOnFeet); } -void KmScene1705::stTeleporterAppear() { - _status2 = 0; - _acceptInput = false; - startAnimation(0x5E0A4905, 0, -1); - SetUpdateHandler(&Klayman::update); - SetSpriteUpdate(NULL); - SetMessageHandler(&KmScene1705::hmTeleporterAppearDisappear); -} - -void KmScene1705::stTeleporterDisappear() { - _status2 = 0; - _acceptInput = false; - startAnimation(0xD86E4477, 0, -1); - SetUpdateHandler(&Klayman::update); - SetSpriteUpdate(NULL); - SetMessageHandler(&KmScene1705::hmTeleporterAppearDisappear); -} - KmScene1901::KmScene1901(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y) : Klayman(vm, parentScene, x, y, 1000, 1000) { @@ -4309,47 +4246,15 @@ uint32 KmScene2001::xHandleMessage(int messageNum, const MessageParam ¶m) { GotoState(&Klayman::stGetUpFromTeleporter); break; case 0x483D: - stTeleporterAppear(); + teleporterAppear(0xBE68CC54); break; case 0x483E: - stTeleporterDisappear(); + teleporterDisappear(0x18AB4ED4); break; } return 0; } -uint32 KmScene2001::hmTeleporterAppearDisappear(int messageNum, const MessageParam ¶m, Entity *sender) { - uint32 messageResult = handleMessage41D480(messageNum, param, sender); - switch (messageNum) { - case 0x100D: - if (param.asInteger() == 0x4E0A2C24) { - _soundResource1.play(0x85B10BB8); - } if (param.asInteger() == 0x4E6A0CA0) { - _soundResource1.play(0xC5B709B0); - } - break; - } - return messageResult; -} - -void KmScene2001::stTeleporterAppear() { - _status2 = 0; - _acceptInput = false; - startAnimation(0xBE68CC54, 0, -1); - SetUpdateHandler(&Klayman::update); - SetSpriteUpdate(NULL); - SetMessageHandler(&KmScene2001::hmTeleporterAppearDisappear); -} - -void KmScene2001::stTeleporterDisappear() { - _status2 = 0; - _acceptInput = false; - startAnimation(0x18AB4ED4, 0, -1); - SetUpdateHandler(&Klayman::update); - SetSpriteUpdate(NULL); - SetMessageHandler(&KmScene2001::hmTeleporterAppearDisappear); -} - KmScene2101::KmScene2101(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y) : Klayman(vm, parentScene, x, y, 1000, 1000), _isSittingInTeleporter(false) { @@ -4427,10 +4332,10 @@ uint32 KmScene2101::xHandleMessage(int messageNum, const MessageParam ¶m) { GotoState(&Klayman::stGetUpFromTeleporter); break; case 0x483D: - stTeleporterAppear(); + teleporterAppear(0xFF290E30); break; case 0x483E: - stTeleporterDisappear(); + teleporterDisappear(0x9A28CA1C); break; } return messageResult; @@ -4459,20 +4364,6 @@ uint32 KmScene2101::hmHitByDoor(int messageNum, const MessageParam ¶m, Entit return messageResult; } -uint32 KmScene2101::hmTeleporterAppearDisappear(int messageNum, const MessageParam ¶m, Entity *sender) { - uint32 messageResult = handleMessage41D480(messageNum, param, sender); - switch (messageNum) { - case 0x100D: - if (param.asInteger() == 0x4E0A2C24) { - _soundResource1.play(0x85B10BB8); - } else if (param.asInteger() == 0x4E6A0CA0) { - _soundResource1.play(0xC5B709B0); - } - break; - } - return messageResult; -} - void KmScene2101::stHitByDoor() { _status2 = 1; _acceptInput = false; @@ -4483,24 +4374,6 @@ void KmScene2101::stHitByDoor() { _soundResource1.play(0x402E82D4); } -void KmScene2101::stTeleporterAppear() { - _status2 = 0; - _acceptInput = false; - startAnimation(0xFF290E30, 0, -1); - SetUpdateHandler(&Klayman::update); - SetSpriteUpdate(NULL); - SetMessageHandler(&KmScene2101::hmTeleporterAppearDisappear); -} - -void KmScene2101::stTeleporterDisappear() { - _status2 = 0; - _acceptInput = false; - startAnimation(0x9A28CA1C, 0, -1); - SetUpdateHandler(&Klayman::update); - SetSpriteUpdate(NULL); - SetMessageHandler(&KmScene2101::hmTeleporterAppearDisappear); -} - KmScene2201::KmScene2201(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y, NRect *clipRects, int clipRectsCount) // TODO: NRect *rect1, int16 unk in Klayman ctor : Klayman(vm, parentScene, x, y, 1000, 1000) { @@ -5277,7 +5150,7 @@ uint32 KmScene2401::xHandleMessage(int messageNum, const MessageParam ¶m) { return messageResult; } -uint32 KmScene2401::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { +uint32 KmScene2401::hmSpit(int messageNum, const MessageParam ¶m, Entity *sender) { uint32 messageResult = Klayman::handleMessage41D480(messageNum, param, sender); switch (messageNum) { case 0x100D: @@ -5312,7 +5185,7 @@ void KmScene2401::stTrySpitIntoPipe() { _contSpit = false; startAnimation(0x1808B150, 0, -1); SetUpdateHandler(&Klayman::update); - SetMessageHandler(&KmScene2401::handleMessage); + SetMessageHandler(&KmScene2401::hmSpit); SetSpriteUpdate(NULL); } } @@ -5324,7 +5197,7 @@ void KmScene2401::spitIntoPipe() { _acceptInput = false; startAnimation(0x1B08B553, 0, -1); SetUpdateHandler(&Klayman::update); - SetMessageHandler(&KmScene2401::handleMessage); + SetMessageHandler(&KmScene2401::hmSpit); SetSpriteUpdate(NULL); NextState(&KmScene2401::stContSpitIntoPipe); } @@ -5334,7 +5207,7 @@ void KmScene2401::stContSpitIntoPipe() { _acceptInput = true; startAnimationByHash(0x1808B150, 0x16401CA6, 0); SetUpdateHandler(&Klayman::update); - SetMessageHandler(&KmScene2401::handleMessage); + SetMessageHandler(&KmScene2401::hmSpit); SetSpriteUpdate(NULL); } @@ -5908,46 +5781,15 @@ uint32 KmScene2805::xHandleMessage(int messageNum, const MessageParam ¶m) { GotoState(&Klayman::stGetUpFromTeleporter); break; case 0x483D: - stTeleporterAppear(); + teleporterAppear(0xDE284B74); break; case 0x483E: - stTeleporterDisappear(); + teleporterDisappear(0xD82A4094); break; } return 0; } -uint32 KmScene2805::hmTeleporterAppearDisappear(int messageNum, const MessageParam ¶m, Entity *sender) { - uint32 messageResult = handleMessage41D480(messageNum, param, sender); - switch (messageNum) { - case 0x100D: - if (param.asInteger() == 0x4E0A2C24) - _soundResource1.play(0x85B10BB8); - else if (param.asInteger() == 0x4E6A0CA0) - _soundResource1.play(0xC5B709B0); - break; - } - return messageResult; -} - -void KmScene2805::stTeleporterAppear() { - _status2 = 0; - _acceptInput = false; - SetUpdateHandler(&Klayman::update); - SetSpriteUpdate(NULL); - SetMessageHandler(&KmScene2805::hmTeleporterAppearDisappear); - startAnimation(0xDE284B74, 0, -1); -} - -void KmScene2805::stTeleporterDisappear() { - _status2 = 0; - _acceptInput = false; - SetUpdateHandler(&Klayman::update); - SetSpriteUpdate(NULL); - SetMessageHandler(&KmScene2805::hmTeleporterAppearDisappear); - startAnimation(0xD82A4094, 0, -1); -} - KmScene2806::KmScene2806(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y, bool flag, NRect *clipRects, uint clipRectsCount) : Klayman(vm, parentScene, x, y, 1000, 1000), diff --git a/engines/neverhood/klayman.h b/engines/neverhood/klayman.h index 787ad7eb95..600cdbfdad 100644 --- a/engines/neverhood/klayman.h +++ b/engines/neverhood/klayman.h @@ -178,6 +178,10 @@ public: void stDoIdleTeleporterHands2(); void stIdleTeleporterHands2(); + void teleporterAppear(uint32 fileHash); + void teleporterDisappear(uint32 fileHash); + uint32 hmTeleporterAppearDisappear(int messageNum, const MessageParam ¶m, Entity *sender); + protected: Entity *_parentScene; Sprite *_attachedSprite; @@ -351,7 +355,6 @@ public: protected: bool _isSittingInTeleporter; uint32 xHandleMessage(int messageNum, const MessageParam ¶m); - uint32 hmTeleporterAppearDisappear(int messageNum, const MessageParam ¶m, Entity *sender); void stTeleporterAppear(); void stTeleporterDisappear(); }; @@ -410,7 +413,6 @@ public: protected: bool _isSittingInTeleporter; uint32 xHandleMessage(int messageNum, const MessageParam ¶m); - uint32 hmTeleporterAppearDisappear(int messageNum, const MessageParam ¶m, Entity *sender); void stTeleporterAppear(); void stTeleporterDisappear(); }; @@ -467,7 +469,6 @@ public: protected: bool _isSittingInTeleporter; uint32 xHandleMessage(int messageNum, const MessageParam ¶m); - uint32 hmTeleporterAppearDisappear(int messageNum, const MessageParam ¶m, Entity *sender); void suFallSkipJump(); void stFallSkipJump(); void stTeleporterAppear(); @@ -487,7 +488,6 @@ public: protected: bool _isSittingInTeleporter; uint32 xHandleMessage(int messageNum, const MessageParam ¶m); - uint32 hmTeleporterAppearDisappear(int messageNum, const MessageParam ¶m, Entity *sender); void stTeleporterAppear(); void stTeleporterDisappear(); }; @@ -499,7 +499,6 @@ protected: bool _isSittingInTeleporter; uint32 xHandleMessage(int messageNum, const MessageParam ¶m); uint32 hmHitByDoor(int messageNum, const MessageParam ¶m, Entity *sender); - uint32 hmTeleporterAppearDisappear(int messageNum, const MessageParam ¶m, Entity *sender); void stHitByDoor(); void stTeleporterAppear(); void stTeleporterDisappear(); @@ -592,7 +591,7 @@ protected: uint32 _spitDestPipeIndex; uint32 _spitContDestPipeIndex; uint32 xHandleMessage(int messageNum, const MessageParam ¶m); - uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); + uint32 hmSpit(int messageNum, const MessageParam ¶m, Entity *sender); void stTrySpitIntoPipe(); void spitIntoPipe(); void stContSpitIntoPipe(); @@ -658,7 +657,6 @@ public: protected: bool _isSittingInTeleporter; uint32 xHandleMessage(int messageNum, const MessageParam ¶m); - uint32 hmTeleporterAppearDisappear(int messageNum, const MessageParam ¶m, Entity *sender); void stTeleporterAppear(); void stTeleporterDisappear(); }; |