diff options
author | Kamil Zbróg | 2013-12-26 14:55:11 +0000 |
---|---|---|
committer | Kamil Zbróg | 2013-12-26 14:55:11 +0000 |
commit | 165b8be77f4621ff5de8a483c6cd9ac497492a0a (patch) | |
tree | 41065a7a961c1b0caa07ac4b2b1b6c027c12ae99 /engines/fullpipe | |
parent | fc04a3c328e70733eea1b065cb5dacc9ec6999f2 (diff) | |
parent | f3691700436e647e808023180430263a6567bfaf (diff) | |
download | scummvm-rg350-165b8be77f4621ff5de8a483c6cd9ac497492a0a.tar.gz scummvm-rg350-165b8be77f4621ff5de8a483c6cd9ac497492a0a.tar.bz2 scummvm-rg350-165b8be77f4621ff5de8a483c6cd9ac497492a0a.zip |
Merge remote-tracking branch 'sync/master' into prince-malik
Diffstat (limited to 'engines/fullpipe')
46 files changed, 4687 insertions, 795 deletions
diff --git a/engines/fullpipe/behavior.cpp b/engines/fullpipe/behavior.cpp index c27f1082f5..abea906d9b 100644 --- a/engines/fullpipe/behavior.cpp +++ b/engines/fullpipe/behavior.cpp @@ -132,7 +132,7 @@ void BehaviorManager::updateBehavior(BehaviorInfo *behaviorInfo, BehaviorEntry * mq->sendNextCommand(); bhi->_flags &= 0xFFFFFFFD; - } else if (behaviorInfo->_counter >= bhi->_delay && bhi->_percent && g_fullpipe->_rnd->getRandomNumber(32767) <= entry->_items[i]->_percent) { + } else if (behaviorInfo->_counter >= bhi->_delay && bhi->_percent && g_fp->_rnd->getRandomNumber(32767) <= entry->_items[i]->_percent) { MessageQueue *mq = new MessageQueue(bhi->_messageQueue, 0, 1); mq->sendNextCommand(); @@ -149,7 +149,7 @@ void BehaviorManager::updateStaticAniBehavior(StaticANIObject *ani, int delay, B MessageQueue *mq = 0; if (bhe->_flags & 1) { - uint rnd = g_fullpipe->_rnd->getRandomNumber(32767); + uint rnd = g_fp->_rnd->getRandomNumber(32767); uint runPercent = 0; for (int i = 0; i < bhe->_itemsCount; i++) { if (!(bhe->_items[i]->_flags & 1) && bhe->_items[i]->_percent) { @@ -164,7 +164,7 @@ void BehaviorManager::updateStaticAniBehavior(StaticANIObject *ani, int delay, B for (int i = 0; i < bhe->_itemsCount; i++) { if (!(bhe->_items[i]->_flags & 1) && delay >= bhe->_items[i]->_delay) { if (bhe->_items[i]->_percent) { - if (g_fullpipe->_rnd->getRandomNumber(32767) <= bhe->_items[i]->_percent) { + if (g_fp->_rnd->getRandomNumber(32767) <= bhe->_items[i]->_percent) { mq = new MessageQueue(bhe->_items[i]->_messageQueue, 0, 1); break; } @@ -198,6 +198,12 @@ void BehaviorManager::setFlagByStaticAniObject(StaticANIObject *ani, int flag) { } } +BehaviorEntryInfo *BehaviorManager::getBehaviorEntryInfoByMessageQueueDataId(StaticANIObject *ani, int id1, int id2) { + warning("STUB: getBehaviorEntryInfoByMessageQueueDataId()"); + + return 0; +} + void BehaviorInfo::clear() { _ani = 0; _staticsId = 0; @@ -246,11 +252,11 @@ void BehaviorInfo::initObjectBehavior(GameVar *var, Scene *sc, StaticANIObject * if (strcmp(var->_value.stringValue, "ROOT")) break; - GameVar *v1 = g_fullpipe->getGameLoaderGameVar()->getSubVarByName("BEHAVIOR")->getSubVarByName(ani->getName()); + GameVar *v1 = g_fp->getGameLoaderGameVar()->getSubVarByName("BEHAVIOR")->getSubVarByName(ani->getName()); if (v1 == var) return; - sc = g_fullpipe->accessScene(ani->_sceneId); + sc = g_fp->accessScene(ani->_sceneId); clear(); var = v1; _itemsCount = var->getSubVarsCount(); diff --git a/engines/fullpipe/behavior.h b/engines/fullpipe/behavior.h index 1ac0b5bbfe..90bb38dc9b 100644 --- a/engines/fullpipe/behavior.h +++ b/engines/fullpipe/behavior.h @@ -81,6 +81,8 @@ class BehaviorManager : public CObject { bool setBehaviorEnabled(StaticANIObject *obj, int aniId, int quId, int flag); void setFlagByStaticAniObject(StaticANIObject *ani, int flag); + + BehaviorEntryInfo *getBehaviorEntryInfoByMessageQueueDataId(StaticANIObject *ani, int id1, int id2); }; } // End of namespace Fullpipe diff --git a/engines/fullpipe/console.cpp b/engines/fullpipe/console.cpp index 587f3dc6e6..06235d3eab 100644 --- a/engines/fullpipe/console.cpp +++ b/engines/fullpipe/console.cpp @@ -20,12 +20,29 @@ * */ +#include "fullpipe/constants.h" #include "fullpipe/fullpipe.h" +#include "fullpipe/gameloader.h" +#include "fullpipe/scene.h" namespace Fullpipe { -Console::Console(FullpipeEngine *vm) : GUI::Debugger() { - _vm = vm; +Console::Console(FullpipeEngine *vm) : GUI::Debugger(), _vm(vm) { + DCmd_Register("scene", WRAP_METHOD(Console, Cmd_Scene)); +} + +bool Console::Cmd_Scene(int argc, const char **argv) { + if (argc != 2) { + int sceneTag = _vm->_currentScene->_sceneId; + DebugPrintf("Current scene: %d (scene tag: %d)\n", _vm->getSceneFromTag(sceneTag), sceneTag); + DebugPrintf("Use %s <scene> to change the current scene\n", argv[0]); + return true; + } else { + int scene = _vm->convertScene(atoi(argv[1])); + _vm->_gameLoader->loadScene(scene); + _vm->_gameLoader->gotoScene(scene, TrubaLeft); + return false; + } } } // End of namespace Fullpipe diff --git a/engines/fullpipe/console.h b/engines/fullpipe/console.h index 9c03081b2b..af2b5114ac 100644 --- a/engines/fullpipe/console.h +++ b/engines/fullpipe/console.h @@ -33,6 +33,8 @@ public: private: FullpipeEngine *_vm; + + bool Cmd_Scene(int argc, const char **argv); }; } // End of namespace Fullpipe diff --git a/engines/fullpipe/constants.h b/engines/fullpipe/constants.h index 1a59cce787..e2dff762ea 100644 --- a/engines/fullpipe/constants.h +++ b/engines/fullpipe/constants.h @@ -25,14 +25,24 @@ namespace Fullpipe { +#define ANI_BALLDROP 2685 +#define ANI_BATUTA 737 #define ANI_BIGBALL 4923 +#define ANI_BIGLUK 909 #define ANI_BOOT_1 4231 #define ANI_BUTTON 598 +#define ANI_BUTTON_6 2988 #define ANI_CLOCK 588 +#define ANI_CLOCK_8 2989 +#define ANI_CORNERSITTER 71 #define ANI_DOMINO_3 2732 #define ANI_DADAYASHIK 306 #define ANI_EGGEATER 334 +#define ANI_EGGIE 4929 +#define ANI_GUM 978 #define ANI_HAND 601 +#define ANI_HANDLE 622 +#define ANI_HOOLIGAN 808 #define ANI_IN1MAN 5110 #define ANI_INV_COIN 875 #define ANI_INV_EGGAPL 1564 @@ -40,17 +50,28 @@ namespace Fullpipe { #define ANI_INV_EGGCOIN 1567 #define ANI_INV_EGGDOM 1561 #define ANI_INV_EGGGLS 1573 +#define ANI_INV_HANDLE 893 #define ANI_INV_MAP 5321 #define ANI_KOZAWKA 495 #define ANI_LIFTBUTTON 2751 +#define ANI_LUKE 803 +#define ANI_MAMASHA 656 #define ANI_MAMASHA_4 660 #define ANI_MAN 322 +#define ANI_NADUVATEL 944 +#define ANI_NEWBALL 1073 +#define ANI_OTMOROZ 419 +#define ANI_PACHKA 975 +#define ANI_PACHKA2 3008 #define ANI_PLANK 501 +#define ANI_PLUSMINUS 2938 #define ANI_SC2_BOX 1020 #define ANI_SC4_BOOT 1035 #define ANI_SC4_COIN 690 +#define ANI_SC7_BOX 791 #define ANI_SPEAKER_4 3275 #define ANI_SPRING 542 +#define ANI_VMYATS 764 #define MSG_CLICKBOTTLE 569 #define MSG_CLICKBUTTON 609 #define MSG_CLICKPLANK 549 @@ -96,46 +117,131 @@ namespace Fullpipe { #define MSG_SC4_KOZAWFALL 2858 #define MSG_SC4_MANFROMBOTTLE 2854 #define MSG_SC4_MANTOBOTTLE 2852 +#define MSG_SC5_BGRSOUNDOFF 5315 +#define MSG_SC5_BGRSOUNDON 5314 +#define MSG_SC5_HANDLEDOWN 916 +#define MSG_SC5_HANDLEUP 915 +#define MSG_SC5_HIDEHANDLE 917 +#define MSG_SC5_MAKEMANFLIGHT 1136 +#define MSG_SC5_MAKEOTMFEEDBACK 1169 +#define MSG_SC5_SHOWHANDLE 918 +#define MSG_SC5_TESTLUK 914 +#define MSG_SC6_BTNPUSH 1017 +#define MSG_SC6_ENABLEDROPS 687 +#define MSG_SC6_INSTHANDLE 1012 +#define MSG_SC6_JUMPBK 2900 +#define MSG_SC6_JUMPFW 2901 +#define MSG_SC6_RESTORESCROLL 2906 +#define MSG_SC6_SHOWNEXTBALL 790 +#define MSG_SC6_STARTDROPS 2897 +#define MSG_SC6_TAKEBALL 682 +#define MSG_SC6_TESTNUMBALLS 2904 +#define MSG_SC6_UTRUBACLICK 1105 +#define MSG_SC7_CLOSELUKE 822 +#define MSG_SC7_HIDEBOX 817 +#define MSG_SC7_HIDELUKE 821 +#define MSG_SC7_OPENLUKE 823 +#define MSG_SC7_PULL 2943 +#define MSG_SC7_SHOWBOX 816 +#define MSG_SC8_ARCADENOW 1044 +#define MSG_SC8_ENTERUP 3037 +#define MSG_SC8_GETHIMUP 789 +#define MSG_SC8_HIDELADDER_D 1107 +#define MSG_SC8_RESUMEFLIGHT 784 +#define MSG_SC8_STANDUP 2976 +#define MSG_SC10_CLICKGUM 992 +#define MSG_SC10_HIDEGUM 993 +#define MSG_SC10_LADDERTOBACK 3002 +#define MSG_SC10_LADDERTOFORE 3004 +#define MSG_SC10_SHOWGUM 994 #define MSG_GOTOLADDER 618 #define MSG_SHAKEBOTTLE 584 #define MSG_SHOOTKOZAW 557 #define MSG_SHOWCOIN 1033 +#define MSG_SPINHANDLE 2398 +#define MSG_STARTARCADE 781 #define MSG_STARTHAND 612 #define MSG_TAKEBOTTLE 614 #define MSG_TAKEKOZAW 611 #define MSG_TESTPLANK 538 #define MSG_UPDATEBOTTLE 613 +#define MV_BLK_CLOSE 911 +#define MV_BLK_OPEN 910 +#define MV_CLK8_GO 2990 +#define MV_CST_CLOSELUKE 807 #define MV_EGTR_FATASK 5332 #define MV_IN1MAN_SLEEP 5111 -#define MV_KZW_JUMP 558 -#define MV_KZW_JUMPROTATE 561 -#define MV_KZW_TOHOLERV 537 -#define MV_KZW_WALKPLANK 500 #define MV_BDG_OPEN 1379 #define MV_BTN_CLICK 599 #define MV_CLK_GO 589 #define MV_HND_POINT 602 +#define MV_KZW_GOR 564 +#define MV_KZW_JUMP 558 +#define MV_KZW_JUMPROTATE 561 +#define MV_KZW_TOHOLERV 537 +#define MV_KZW_WALKPLANK 500 +#define MV_KZW_JUMPHIT 2857 +#define MV_KZW_JUMPOUT 586 +#define MV_KZW_RAISEHEAD 577 +#define MV_KZW_STANDUP 563 +#define MV_KZW_TURN 562 +#define MV_MAN_FROMLADDER 493 +#define MV_MAN_FROMLADDERUP 1522 #define MV_MAN_GOD 481 #define MV_MAN_GOLADDER 451 #define MV_MAN_GOLADDER2 2844 #define MV_MAN_GOU 460 #define MV_MAN_JUMPONPLANK 551 #define MV_MAN_LOOKLADDER 520 +#define MV_MAN_LOOKLADDERRV 556 #define MV_MAN_LOOKUP 4773 #define MV_MAN_PLANKTOLADDER 553 #define MV_MAN_STARTLADDER 452 #define MV_MAN_STARTLADDER2 2842 +#define MV_MAN_STARTLADDERD 457 #define MV_MAN_STOPLADDER 454 #define MV_MAN_STOPLADDER2 2845 #define MV_MAN_TOLADDER 448 +#define MV_MAN_TOLADDERD 1524 #define MV_MAN_TOLADDER2 2841 #define MV_MAN_TURN_LU 486 #define MV_MAN_TURN_SUD 1089 +#define MV_MAN6_TAKEBALL 2691 +#define MV_MAN6_THROWBALL 2692 +#define MV_MAN8_BADLUCK 783 +#define MV_MAN8_DRYGDOWN 770 +#define MV_MAN8_DRYGUP 768 +#define MV_MAN8_HANDSDOWN 772 +#define MV_MAN8_HANDSUP 777 +#define MV_MAN8_JUMP 775 +#define MV_MAN8_JUMPOFF 2969 +#define MV_MAN8_SITDOWN 2968 +#define MV_MANHDL_HANDLEDOWN 630 +#define MV_MANHDL_HANDLEUP 631 +#define MV_MOM_CYCLEBK 3012 +#define MV_MOM_JUMPBK 662 +#define MV_MOM_JUMPFW 661 +#define MV_MOM_STARTBK 3010 +#define MV_MOM_STOPBK 3013 +#define MV_MOM_TAKE1 2885 +#define MV_MOM_TAKE2 2886 +#define MV_MOM_TAKE3 2887 +#define MV_MOM_TAKE4 2888 +#define MV_MOM_TAKE5 2889 +#define MV_NDV_BLOW2 2855 +#define MV_NDV_DENIES 952 +#define MV_NDV_DENY_NOGUM 3022 +#define MV_OTM_BOXHANDLEDOWN 626 +#define MV_OTM_BOXHANDLEUP 627 +#define MV_OTM_HANDLEDOWN 620 +#define MV_OTM_HANDLEUP 621 #define MV_PNK_WEIGHTLEFT 541 #define MV_PNK_WEIGHTRIGHT 502 #define MV_SC4_COIN_default 1029 +#define MV_SC7_BOX_default 792 #define MV_SPK4_PLAY 3276 #define MV_SPR_LOWER 543 +#define MV_VMT_DEF 765 #define PIC_CMN_EVAL 3468 #define PIC_CSR_DEFAULT 4891 #define PIC_CSR_DEFAULT_INV 4892 @@ -173,6 +279,7 @@ namespace Fullpipe { #define PIC_IN1_PIPETITLE 5167 #define PIC_INV_MENU 991 #define PIC_MAP_A13 5275 +#define PIC_MAP_P03 5279 #define PIC_MAP_S01 5223 #define PIC_SC1_KUCHKA 1321 #define PIC_SC1_LADDER 1091 @@ -189,9 +296,19 @@ namespace Fullpipe { #define PIC_SC4_LRTRUBA 616 #define PIC_SC4_MASK 585 #define PIC_SC4_PLANK 5183 +#define PIC_SC6_LADDER 1104 +#define PIC_SC8_ARCADENOW 1043 +#define PIC_SC8_LADDER 754 +#define PIC_SC8_LADDER_D 755 +#define PIC_SC8_LADDERD 1106 +#define PIC_SC10_DTRUBA 974 +#define PIC_SC10_LADDER 995 #define PIC_SCD_SEL 734 #define QU_BALL_WALKL 4920 #define QU_BALL_WALKR 4919 +#define QU_CST_CLOSELUKE 820 +#define QU_EGG6_GOL 4936 +#define QU_EGG6_GOR 4935 #define QU_EGTR_MD2_SHOW 4698 #define QU_EGTR_MD1_SHOW 4697 #define QU_EGTR_SLIMSHOW 4883 @@ -204,11 +321,33 @@ namespace Fullpipe { #define QU_INTR_GETUPMAN 5136 #define QU_INTR_STARTINTRO 5133 #define QU_KOZAW_WALK 505 +#define QU_MOM_JUMPBK 671 +#define QU_MOM_JUMPFW 670 +#define QU_MOM_PUTBALL 2903 +#define QU_MOM_SITDOWN 685 +#define QU_MOM_STANDUP 2899 +#define QU_MOM_TOLIFT 2902 #define QU_PNK_CLICK 550 #define QU_SC3_ENTERLIFT 2779 #define QU_SC3_EXITLIFT 2808 +#define QU_SC6_FALLHANDLE 2995 #define QU_SC4_GOCLOCK 595 #define QU_SC4_MANFROMBOTTLE 2851 +#define QU_SC4_MANTOBOTTLE 2850 +#define QU_SC5_MANBUMP 1167 +#define QU_SC5_MANFLY 1168 +#define QU_SC6_DROPS 2898 +#define QU_SC6_DROPS3 2955 +#define QU_SC6_ENTERLIFT 1054 +#define QU_SC6_EXITLIFT 1055 +#define QU_SC6_FALLBALL 2690 +#define QU_SC6_SHOWHANDLE 1689 +#define QU_SC6_SHOWNEXTBALL 2689 +#define QU_SC8_FINISH 788 +#define QU_SC8_STANDUP 2975 +#define QU_SC10_ENTERLIFT 1067 +#define QU_SC10_EXITLIFT 2809 +#define QU_SC10_TAKEGUM 3026 #define SC_1 301 #define SC_10 653 #define SC_11 654 @@ -264,17 +403,35 @@ namespace Fullpipe { #define SND_4_010 3125 #define SND_4_012 3127 #define SND_4_033 4990 +#define SND_5_026 5316 +#define SND_8_014 3624 #define SND_CMN_031 3516 #define SND_CMN_070 5199 #define SND_INTR_019 5220 +#define ST_BLK_CLOSED 912 +#define ST_BLK_OPEN 913 +#define ST_BTT_CHESHET 746 +#define ST_BTT_NOSPOON 739 +#define ST_BTT_SLEEPS 748 +#define ST_BTT_SPOON 741 #define ST_CLK_CLOSED 590 +#define ST_CST_HANDLELESS 794 #define ST_DYAS_LIES 318 #define ST_EGTR_MID1 2863 #define ST_EGTR_MID2 2869 #define ST_EGTR_SLIM 336 +#define ST_HGN_LOOK 811 +#define ST_HGN_LUKE 810 +#define ST_HDL_BROKEN 3342 +#define ST_HDL_DOWN 625 +#define ST_HDL_PLUGGED 2397 +#define ST_HDL_UP 624 #define ST_HND_EMPTY 603 #define ST_IN1MAN_SLEEP 5112 #define ST_KZW_EMPTY 498 +#define ST_KZW_JUMPOUT 587 +#define ST_KZW_RIGHT 559 +#define ST_KZW_SIT 560 #define ST_LBN_0N 2832 #define ST_LBN_0P 2833 #define ST_LBN_1N 2753 @@ -295,22 +452,71 @@ namespace Fullpipe { #define ST_LBN_8P 2775 #define ST_LBN_9N 2777 #define ST_LBN_9P 2778 +#define ST_LUK_CLOSED 805 +#define ST_LUK_OPEN 806 #define ST_MAN_GOLADDER 450 #define ST_MAN_GOLADDER2 2843 #define ST_MAN_EMPTY 476 #define ST_MAN_LADDERDOWN 521 +#define ST_MAN_LOOKPLANK 555 #define ST_MAN_ONPLANK 552 #define ST_MAN_RIGHT 325 #define ST_MAN_SIT 1164 #define ST_MAN_STANDLADDER 453 #define ST_MAN_UP 449 +#define ST_MAN6_BALL 2688 +#define ST_MAN8_FLYDOWN 771 +#define ST_MAN8_FLYUP 769 +#define ST_MAN8_HANDSUP 773 +#define ST_MAN8_STAND 774 +#define ST_MOM_SITS 659 +#define ST_MOM_STANDS 658 +#define ST_NBL_NORM 1076 +#define ST_NDV_SIT 946 +#define ST_OTM_BOX_LEFT 429 +#define ST_OTM_GLS_LEFT 421 +#define ST_OTM_VNT_LEFT 434 +#define ST_PMS_MINUS 2942 +#define ST_PMS_PLUS 2941 #define ST_PNK_WEIGHTLEFT 503 +#define ST_PNK_WEIGHTRIGHT 504 #define ST_SPR_UP 544 +#define ST_VMT_MIN 766 #define TrubaDown 697 #define TrubaLeft 474 #define TrubaRight 696 #define TrubaUp 680 #define rMV_MAN_LOOKUP 4775 +#define rMV_KZW_GOR 566 + +// Scene 11 +#define ANI_BOOTS_11 2704 +#define ANI_KACHELI 1094 +#define ANI_MAN11 1108 +#define ANI_SWINGER 1113 +#define PIC_SC11_HINT 5170 +#define ST_KCH_STATIC 1122 +#define ST_SWR_SIT 1147 +#define ST_SWR_SITBALD 1153 +#define ST_SWR_STAND3 3014 + +// Scene 15 +#define ANI_BOOT_15 4779 +#define ANI_GRANDMA_ASS 1265 +#define MSG_SC15_ASSDRYG 4755 +#define MSG_SC15_LADDERTOBACK 3259 +#define MSG_SC15_PULL 2940 +#define MSG_SC15_STOPCHANTING 4753 +#define PIC_SC15_DTRUBA 1263 +#define PIC_SC15_LADDER 3253 +#define PIC_SC15_LTRUBA 1261 +#define QU_SC15_ENTERLIFT 2811 +#define QU_SC15_EXITLIFT 2812 +#define SND_15_001 3798 +#define SND_15_006 3808 +#define SND_15_011 4754 +#define ST_GMS_BOOT 1270 +#define ST_GMS_BOOTLESS2 3316 } // End of namespace Fullpipe diff --git a/engines/fullpipe/fullpipe.cpp b/engines/fullpipe/fullpipe.cpp index 970af423ae..a0348a9407 100644 --- a/engines/fullpipe/fullpipe.cpp +++ b/engines/fullpipe/fullpipe.cpp @@ -33,14 +33,14 @@ #include "fullpipe/behavior.h" #include "fullpipe/modal.h" #include "fullpipe/input.h" +#include "fullpipe/motion.h" #include "fullpipe/scenes.h" #include "fullpipe/floaters.h" -#include "fullpipe/motion.h" #include "fullpipe/console.h" namespace Fullpipe { -FullpipeEngine *g_fullpipe = 0; +FullpipeEngine *g_fp = 0; Vars *g_vars = 0; FullpipeEngine::FullpipeEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) { @@ -148,9 +148,16 @@ FullpipeEngine::FullpipeEngine(OSystem *syst, const ADGameDescription *gameDesc) _objectAtCursor = 0; _objectIdAtCursor = 0; + _arcadeOverlay = 0; + _arcadeOverlayHelper = 0; + _arcadeOverlayX = 0; + _arcadeOverlayY = 0; + _arcadeOverlayMidX = 0; + _arcadeOverlayMidY = 0; + _isSaveAllowed = true; - g_fullpipe = this; + g_fp = this; g_vars = new Vars; } diff --git a/engines/fullpipe/fullpipe.h b/engines/fullpipe/fullpipe.h index eb502cbadf..5e4389af7b 100644 --- a/engines/fullpipe/fullpipe.h +++ b/engines/fullpipe/fullpipe.h @@ -63,6 +63,7 @@ struct MessageHandler; struct MovTable; class MGM; class NGIArchive; +class PictureObject; class Scene; class SoundList; class StaticANIObject; @@ -148,9 +149,11 @@ public: void stopAllSounds(); void toggleMute(); void playSound(int id, int flag); + void playTrack(GameVar *sceneVar, const char *name, bool delayed); void startSceneTrack(); void stopSoundStream2(); void stopAllSoundStreams(); + void stopAllSoundInstances(int id); int _sfxVolume; @@ -235,6 +238,7 @@ public: Scene *accessScene(int sceneId); void setSceneMusicParameters(GameVar *var); int convertScene(int scene); + int getSceneFromTag(int tag); NGIArchive *_currArchive; @@ -242,9 +246,18 @@ public: void openHelp(); void openMainMenu(); + PictureObject *_arcadeOverlay; + PictureObject *_arcadeOverlayHelper; + int _arcadeOverlayX; + int _arcadeOverlayY; + int _arcadeOverlayMidX; + int _arcadeOverlayMidY; + void initArcadeKeys(const char *varname); void processArcade(ExCommand *ex); void winArcade(); + void setArcadeOverlay(int picId); + int drawArcadeOverlay(int adjust); void getAllInventory(); @@ -268,7 +281,7 @@ public: }; -extern FullpipeEngine *g_fullpipe; +extern FullpipeEngine *g_fp; extern Vars *g_vars; } // End of namespace Fullpipe diff --git a/engines/fullpipe/gameloader.cpp b/engines/fullpipe/gameloader.cpp index e130337001..57c1b23f66 100644 --- a/engines/fullpipe/gameloader.cpp +++ b/engines/fullpipe/gameloader.cpp @@ -32,19 +32,19 @@ namespace Fullpipe { Inventory2 *getGameLoaderInventory() { - return &g_fullpipe->_gameLoader->_inventory; + return &g_fp->_gameLoader->_inventory; } MctlCompound *getSc2MctlCompoundBySceneId(int16 sceneId) { - for (uint i = 0; i < g_fullpipe->_gameLoader->_sc2array.size(); i++) - if (g_fullpipe->_gameLoader->_sc2array[i]._sceneId == sceneId) - return (MctlCompound *)g_fullpipe->_gameLoader->_sc2array[i]._motionController; + for (uint i = 0; i < g_fp->_gameLoader->_sc2array.size(); i++) + if (g_fp->_gameLoader->_sc2array[i]._sceneId == sceneId) + return (MctlCompound *)g_fp->_gameLoader->_sc2array[i]._motionController; return 0; } InteractionController *getGameLoaderInteractionController() { - return g_fullpipe->_gameLoader->_interactionController; + return g_fp->_gameLoader->_interactionController; } GameLoader::GameLoader() { @@ -68,10 +68,10 @@ GameLoader::GameLoader() { _preloadEntranceId = 0; _updateCounter = 0; - g_fullpipe->_msgX = 0; - g_fullpipe->_msgY = 0; - g_fullpipe->_msgObjectId2 = 0; - g_fullpipe->_msgId = 0; + g_fp->_msgX = 0; + g_fp->_msgY = 0; + g_fp->_msgObjectId2 = 0; + g_fp->_msgId = 0; } GameLoader::~GameLoader() { @@ -91,10 +91,10 @@ bool GameLoader::load(MfcArchive &file) { _gameProject->load(file); - g_fullpipe->_gameProject = _gameProject; + g_fp->_gameProject = _gameProject; - if (g_fullpipe->_gameProjectVersion < 12) { - error("Old gameProjectVersion: %d", g_fullpipe->_gameProjectVersion); + if (g_fp->_gameProjectVersion < 12) { + error("Old gameProjectVersion: %d", g_fp->_gameProjectVersion); } _gameName = file.readPascalString(); @@ -167,7 +167,7 @@ bool GameLoader::gotoScene(int sceneId, int entranceId) { return false; if (_sc2array[sc2idx]._entranceDataCount < 1) { - g_fullpipe->_currentScene = st->_scene; + g_fp->_currentScene = st->_scene; return true; } @@ -186,20 +186,20 @@ bool GameLoader::gotoScene(int sceneId, int entranceId) { if (sg || (sg = _gameVar->getSubVarByName("OBJSTATES")->addSubVarAsInt("SAVEGAME", 0)) != 0) sg->setSubVarAsInt("Entrance", entranceId); - if (!g_fullpipe->sceneSwitcher(_sc2array[sc2idx]._entranceData[entranceIdx])) + if (!g_fp->sceneSwitcher(_sc2array[sc2idx]._entranceData[entranceIdx])) return false; - g_fullpipe->_msgObjectId2 = 0; - g_fullpipe->_msgY = -1; - g_fullpipe->_msgX = -1; + g_fp->_msgObjectId2 = 0; + g_fp->_msgY = -1; + g_fp->_msgX = -1; - g_fullpipe->_currentScene = st->_scene; + g_fp->_currentScene = st->_scene; - MessageQueue *mq1 = g_fullpipe->_currentScene->getMessageQueueById(_sc2array[sc2idx]._entranceData[entranceIdx]->_messageQueueId); + MessageQueue *mq1 = g_fp->_currentScene->getMessageQueueById(_sc2array[sc2idx]._entranceData[entranceIdx]->_messageQueueId); if (mq1) { MessageQueue *mq = new MessageQueue(mq1, 0, 0); - StaticANIObject *stobj = g_fullpipe->_currentScene->getStaticANIObject1ById(_field_FA, -1); + StaticANIObject *stobj = g_fp->_currentScene->getStaticANIObject1ById(_field_FA, -1); if (stobj) { stobj->_flags &= 0x100; @@ -220,7 +220,7 @@ bool GameLoader::gotoScene(int sceneId, int entranceId) { return false; } } else { - StaticANIObject *stobj = g_fullpipe->_currentScene->getStaticANIObject1ById(_field_FA, -1); + StaticANIObject *stobj = g_fp->_currentScene->getStaticANIObject1ById(_field_FA, -1); if (stobj) stobj->_flags &= 0xfeff; } @@ -262,8 +262,8 @@ bool GameLoader::preloadScene(int sceneId, int entranceId) { return false; } - if (g_fullpipe->_currentScene && g_fullpipe->_currentScene->_sceneId == sceneId) - g_fullpipe->_currentScene = 0; + if (g_fp->_currentScene && g_fp->_currentScene->_sceneId == sceneId) + g_fp->_currentScene = 0; saveScenePicAniInfos(sceneId); clearGlobalMessageQueueList1(); @@ -358,7 +358,7 @@ void GameLoader::applyPicAniInfos(Scene *sc, PicAniInfo **picAniInfo, int picAni if (!(picAniInfo[i]->type & 1)) continue; - Scene *scNew = g_fullpipe->accessScene(picAniInfo[i]->sceneId); + Scene *scNew = g_fp->accessScene(picAniInfo[i]->sceneId); if (!scNew) continue; @@ -386,8 +386,8 @@ void GameLoader::saveScenePicAniInfos(int sceneId) { } void GameLoader::updateSystems(int counterdiff) { - if (g_fullpipe->_currentScene) { - g_fullpipe->_currentScene->update(counterdiff); + if (g_fp->_currentScene) { + g_fp->_currentScene->update(counterdiff); _exCommand._messageKind = 17; _updateCounter++; @@ -510,4 +510,8 @@ InputController *FullpipeEngine::getGameLoaderInputController() { return 0; } +MotionController *getCurrSceneSc2MotionController() { + return getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId); +} + } // End of namespace Fullpipe diff --git a/engines/fullpipe/gameloader.h b/engines/fullpipe/gameloader.h index 4f5462671d..074537500c 100644 --- a/engines/fullpipe/gameloader.h +++ b/engines/fullpipe/gameloader.h @@ -111,6 +111,7 @@ class GameLoader : public CObject { Inventory2 *getGameLoaderInventory(); InteractionController *getGameLoaderInteractionController(); MctlCompound *getSc2MctlCompoundBySceneId(int16 sceneId); +MotionController *getCurrSceneSc2MotionController(); } // End of namespace Fullpipe diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp index d54f7591b4..8b2aca4bdb 100644 --- a/engines/fullpipe/gfx.cpp +++ b/engines/fullpipe/gfx.cpp @@ -100,11 +100,11 @@ bool Background::load(MfcArchive &file) { addPictureObject(pct); } - assert(g_fullpipe->_gameProjectVersion >= 4); + assert(g_fp->_gameProjectVersion >= 4); _bigPictureArray1Count = file.readUint32LE(); - assert(g_fullpipe->_gameProjectVersion >= 5); + assert(g_fp->_gameProjectVersion >= 5); _bigPictureArray2Count = file.readUint32LE(); @@ -313,7 +313,7 @@ bool GameObject::load(MfcArchive &file) { _oy = file.readUint32LE(); _priority = file.readUint16LE(); - if (g_fullpipe->_gameProjectVersion >= 11) { + if (g_fp->_gameProjectVersion >= 11) { _field_8 = file.readUint32LE(); } @@ -494,7 +494,7 @@ bool Picture::load(MfcArchive &file) { _y = file.readUint32LE(); _field_44 = file.readUint16LE(); - assert(g_fullpipe->_gameProjectVersion >= 2); + assert(g_fp->_gameProjectVersion >= 2); _width = file.readUint32LE(); _height = file.readUint32LE(); @@ -508,7 +508,7 @@ bool Picture::load(MfcArchive &file) { setAOIDs(); } - assert (g_fullpipe->_gameProjectVersion >= 12); + assert (g_fp->_gameProjectVersion >= 12); _alpha = file.readUint32LE() & 0xff; @@ -527,8 +527,8 @@ bool Picture::load(MfcArchive &file) { } void Picture::setAOIDs() { - int w = (g_fullpipe->_pictureScale + _width - 1) / g_fullpipe->_pictureScale; - int h = (g_fullpipe->_pictureScale + _height - 1) / g_fullpipe->_pictureScale; + int w = (g_fp->_pictureScale + _width - 1) / g_fp->_pictureScale; + int h = (g_fp->_pictureScale + _height - 1) / g_fp->_pictureScale; _memoryObject2->_rows = (byte **)malloc(w * sizeof(int *)); @@ -618,7 +618,7 @@ void Picture::draw(int x, int y, int style, int angle) { if (!pal) { //warning("Picture:draw: using global palette"); - pal = g_fullpipe->_globalPalette; + pal = g_fp->_globalPalette; } Common::Point point; @@ -650,7 +650,7 @@ void Picture::drawRotated(int x, int y, int angle) { } void Picture::displayPicture() { - if (!g_fullpipe->_gameContinue) + if (!g_fp->_gameContinue) return; getData(); @@ -659,22 +659,22 @@ void Picture::displayPicture() { if (!_dataSize) return; - g_fullpipe->_backgroundSurface.fillRect(Common::Rect(0, 0, 800, 600), 0); - g_fullpipe->_system->copyRectToScreen(g_fullpipe->_backgroundSurface.getBasePtr(0, 0), g_fullpipe->_backgroundSurface.pitch, 0, 0, 800, 600); + g_fp->_backgroundSurface.fillRect(Common::Rect(0, 0, 800, 600), 0); + g_fp->_system->copyRectToScreen(g_fp->_backgroundSurface.getBasePtr(0, 0), g_fp->_backgroundSurface.pitch, 0, 0, 800, 600); draw(0, 0, 0, 0); - g_fullpipe->updateEvents(); - g_fullpipe->_system->delayMillis(10); - g_fullpipe->_system->updateScreen(); + g_fp->updateEvents(); + g_fp->_system->delayMillis(10); + g_fp->_system->updateScreen(); - while (g_fullpipe->_gameContinue) { - g_fullpipe->updateEvents(); - g_fullpipe->_system->delayMillis(10); - g_fullpipe->_system->updateScreen(); + while (g_fp->_gameContinue) { + g_fp->updateEvents(); + g_fp->_system->delayMillis(10); + g_fp->_system->updateScreen(); - if (g_fullpipe->_keyState == ' ') { - g_fullpipe->_keyState = Common::KEYCODE_INVALID; + if (g_fp->_keyState == ' ') { + g_fp->_keyState = Common::KEYCODE_INVALID; break; } } @@ -722,7 +722,7 @@ bool Picture::isPixelHitAtPos(int x, int y) { } int Picture::getPixelAtPos(int x, int y) { - return getPixelAtPosEx(x / g_fullpipe->_pictureScale, y / g_fullpipe->_pictureScale); + return getPixelAtPosEx(x / g_fp->_pictureScale, y / g_fp->_pictureScale); return false; } @@ -731,8 +731,8 @@ int Picture::getPixelAtPosEx(int x, int y) { if (x < 0 || y < 0) return 0; - if (x < (g_fullpipe->_pictureScale + _width - 1) / g_fullpipe->_pictureScale && - y < (g_fullpipe->_pictureScale + _height - 1) / g_fullpipe->_pictureScale && + if (x < (g_fp->_pictureScale + _width - 1) / g_fp->_pictureScale && + y < (g_fp->_pictureScale + _height - 1) / g_fp->_pictureScale && _memoryObject2 != 0 && _memoryObject2->_rows != 0) return _memoryObject2->_rows[x][2 * y]; @@ -785,8 +785,8 @@ bool Bitmap::isPixelAtHitPosRB(int x, int y) { void Bitmap::putDib(int x, int y, int32 *palette) { debug(7, "Bitmap::putDib(%d, %d)", x, y); - _x = x - g_fullpipe->_sceneRect.left; - _y = y - g_fullpipe->_sceneRect.top; + _x = x - g_fp->_sceneRect.left; + _y = y - g_fp->_sceneRect.top; if (_type == MKTAG('R', 'B', '\0', '\0')) putDibRB(palette); @@ -807,7 +807,7 @@ bool Bitmap::putDibRB(int32 *palette, int pX, int pY) { uint16 *srcPtr; if (!palette && pX == -1) { - warning("Bitmap::putDibRB(): Both global and local palettes are empty"); + debug(2, "Bitmap::putDibRB(): Both global and local palettes are empty"); return false; } @@ -879,7 +879,7 @@ bool Bitmap::putDibRB(int32 *palette, int pX, int pY) { if (y <= endy) { if (pX == -1) { int bgcolor = palette[(pixel >> 8) & 0xff]; - curDestPtr = (uint16 *)g_fullpipe->_backgroundSurface.getBasePtr(start1, y); + curDestPtr = (uint16 *)g_fp->_backgroundSurface.getBasePtr(start1, y); colorFill(curDestPtr, fillLen, bgcolor); } else { if (y == pY && pX >= start1 && pX < start1 + fillLen) @@ -910,7 +910,7 @@ bool Bitmap::putDibRB(int32 *palette, int pX, int pY) { if (y <= endy) { if (pX == -1) { - curDestPtr = (uint16 *)g_fullpipe->_backgroundSurface.getBasePtr(start1, y); + curDestPtr = (uint16 *)g_fp->_backgroundSurface.getBasePtr(start1, y); paletteFill(curDestPtr, (byte *)srcPtr2, fillLen, (int32 *)palette); } else { if (y == pY && pX >= start1 && pX < start1 + fillLen) @@ -922,7 +922,7 @@ bool Bitmap::putDibRB(int32 *palette, int pX, int pY) { } if (pX == -1) - g_fullpipe->_system->copyRectToScreen(g_fullpipe->_backgroundSurface.getBasePtr(startx, starty), g_fullpipe->_backgroundSurface.pitch, startx, starty, endx + 1 - startx, endy + 1 - starty); + g_fp->_system->copyRectToScreen(g_fp->_backgroundSurface.getBasePtr(startx, starty), g_fp->_backgroundSurface.pitch, startx, starty, endx + 1 - startx, endy + 1 - starty); return false; } @@ -973,17 +973,17 @@ void Bitmap::putDibCB(int32 *palette) { if (_flags & 0x1000000) { for (int y = starty; y < endy; srcPtr -= pitch, y++) { - curDestPtr = (uint16 *)g_fullpipe->_backgroundSurface.getBasePtr(startx, y); + curDestPtr = (uint16 *)g_fp->_backgroundSurface.getBasePtr(startx, y); copierKeyColor(curDestPtr, srcPtr, endx - startx + 1, _flags & 0xff, (int32 *)palette, cb05_format); } } else { for (int y = starty; y <= endy; srcPtr -= pitch, y++) { - curDestPtr = (uint16 *)g_fullpipe->_backgroundSurface.getBasePtr(startx, y); + curDestPtr = (uint16 *)g_fp->_backgroundSurface.getBasePtr(startx, y); copier(curDestPtr, srcPtr, endx - startx + 1, (int32 *)palette, cb05_format); } } - g_fullpipe->_system->copyRectToScreen(g_fullpipe->_backgroundSurface.getBasePtr(startx, starty), g_fullpipe->_backgroundSurface.pitch, startx, starty, endx + 1 - startx, endy + 1 - starty); + g_fp->_system->copyRectToScreen(g_fp->_backgroundSurface.getBasePtr(startx, starty), g_fp->_backgroundSurface.pitch, startx, starty, endx + 1 - startx, endy + 1 - starty); } void Bitmap::colorFill(uint16 *dest, int len, int32 color) { @@ -1178,6 +1178,34 @@ bool BigPicture::load(MfcArchive &file) { return true; } +void BigPicture::draw(int x, int y, int style, int angle) { + if (!_bitmap) + init(); + + if (_bitmap) { + _bitmap->_flags &= 0xFEFFFFFF; + + int nx = _x; + int ny = _y; + + if (x != -1) + nx = x; + + if (y != -1) + ny = y; + + if (_alpha < 0xFF) { + //vrtSetAlphaBlendMode(g_vrtDrawHandle, 1, v9); + } + + _bitmap->putDib(nx, ny, 0); + + if (_alpha < 0xFF) { + //vrtSetAlphaBlendMode(g_vrtDrawHandle, 0, 255); + } + } +} + Shadows::Shadows() { _staticAniObjectId = 0; _movementId = 0; @@ -1194,7 +1222,7 @@ bool Shadows::load(MfcArchive &file) { } void Shadows::init() { - Scene *scene = g_fullpipe->accessScene(_sceneId); + Scene *scene = g_fp->accessScene(_sceneId); StaticANIObject *st; Movement *mov; diff --git a/engines/fullpipe/gfx.h b/engines/fullpipe/gfx.h index 9d5c45de0b..72495bfe0b 100644 --- a/engines/fullpipe/gfx.h +++ b/engines/fullpipe/gfx.h @@ -94,7 +94,7 @@ class Picture : public MemoryObject { void init(); void getDibInfo(); Bitmap *getPixelData(); - void draw(int x, int y, int style, int angle); + virtual void draw(int x, int y, int style, int angle); void drawRotated(int x, int y, int angle); byte getAlpha() { return (byte)_alpha; } @@ -116,6 +116,7 @@ class BigPicture : public Picture { public: BigPicture() {} virtual bool load(MfcArchive &file); + virtual void draw(int x, int y, int style, int angle); }; class GameObject : public CObject { diff --git a/engines/fullpipe/init.cpp b/engines/fullpipe/init.cpp index eb109e11ec..4cf5fbef61 100644 --- a/engines/fullpipe/init.cpp +++ b/engines/fullpipe/init.cpp @@ -45,22 +45,22 @@ void FullpipeEngine::initObjectStates() { setSwallowedEggsState(); setObjectState(sO_WeirdWacko, getObjectEnumState(sO_WeirdWacko, sO_InGlasses)); - setObjectState(sO_TumyTrampie, getObjectEnumState(sO_TumyTrampie, sO_Drinking)); + setObjectState(sO_TummyTrampie, getObjectEnumState(sO_TummyTrampie, sO_IsDrinking)); setObjectState(sO_StairsUp_8, getObjectEnumState(sO_StairsUp_8, sO_NotBroken)); setObjectState(sO_HareTheNooksiter, getObjectEnumState(sO_HareTheNooksiter, sO_WithHandle)); setObjectState(sO_Elephantine, getObjectEnumState(sO_Elephantine, sO_WithBoot)); setObjectState(sO_Fly_12, 0); - setObjectState(sO_ClockAxis, getObjectEnumState(sO_ClockAxis, sO_NotAvailable)); + setObjectState(sO_ClockAxis, getObjectEnumState(sO_ClockAxis, sO_IsNotAvailable)); setObjectState(sO_ClockHandle, getObjectEnumState(sO_ClockHandle, sO_In_7)); - setObjectState(sO_BigMumsy, getObjectEnumState(sO_BigMumsy, sO_Sleeping)); + setObjectState(sO_BigMumsy, getObjectEnumState(sO_BigMumsy, sO_IsSleeping)); setObjectState(sO_CoinSlot_1, getObjectEnumState(sO_CoinSlot_1, sO_Empty)); setObjectState(sO_FriesPit, getObjectEnumState(sO_FriesPit, sO_WithApple)); setObjectState(sO_Jug, getObjectEnumState(sO_Jug, sO_Blocked)); setObjectState(sO_RightStairs_9, getObjectEnumState(sO_RightStairs_9, sO_IsClosed)); setObjectState(sO_Pipe_9, getObjectEnumState(sO_Pipe_9, sO_WithJug)); setObjectState(sO_Inflater, getObjectEnumState(sO_Inflater, sO_WithGum)); - setObjectState(sO_Swingie, getObjectEnumState(sO_Swingie, sO_Swinging)); - setObjectState(sO_DudeJumped, getObjectEnumState(sO_DudeJumped, sO_No)); + setObjectState(sO_Swingie, getObjectEnumState(sO_Swingie, sO_IsSwinging)); + setObjectState(sO_DudeHasJumped, getObjectEnumState(sO_DudeHasJumped, sO_No)); setObjectState(sO_Bridge, getObjectEnumState(sO_Bridge, sO_Convoluted)); setObjectState(sO_Guardian, getObjectEnumState(sO_Guardian, sO_OnRight)); setObjectState(sO_Grandma, getObjectEnumState(sO_Grandma, sO_In_14)); @@ -73,7 +73,7 @@ void FullpipeEngine::initObjectStates() { setObjectState(sO_RightPipe_17, getObjectEnumState(sO_RightPipe_17, sO_IsClosed)); setObjectState(sO_Fly_17, 1); setObjectState(sO_DudeSwinged, 0); - setObjectState(sO_Girl, getObjectEnumState(sO_Girl, sO_Swinging)); + setObjectState(sO_Girl, getObjectEnumState(sO_Girl, sO_IsSwinging)); setObjectState(sO_Sugar, getObjectEnumState(sO_Sugar, sO_Present)); setObjectState(sO_Janitors, getObjectEnumState(sO_Janitors, sO_Together)); setObjectState(sO_Bag_22, getObjectEnumState(sO_Bag_22, sO_NotFallen)); diff --git a/engines/fullpipe/input.cpp b/engines/fullpipe/input.cpp index e98920c78a..5294c4b4ea 100644 --- a/engines/fullpipe/input.cpp +++ b/engines/fullpipe/input.cpp @@ -34,7 +34,7 @@ namespace Fullpipe { InputController::InputController() { - g_fullpipe->_inputController = this; + g_fp->_inputController = this; _flag = 0; _cursorHandle = 0; @@ -55,16 +55,16 @@ InputController::InputController() { InputController::~InputController() { removeMessageHandler(126, -1); - g_fullpipe->_inputController = 0; + g_fp->_inputController = 0; } void InputController::setInputDisabled(bool state) { _flag = state; - g_fullpipe->_inputDisabled = state; + g_fp->_inputDisabled = state; } void setInputDisabled(bool state) { - g_fullpipe->_inputController->setInputDisabled(state); + g_fp->_inputController->setInputDisabled(state); } void InputController::addCursor(CursorInfo *cursor) { @@ -93,8 +93,8 @@ void InputController::drawCursor(int x, int y) { if (_cursorIndex == -1) return; - _cursorBounds.left = g_fullpipe->_sceneRect.left + x - _cursorsArray[_cursorIndex]->hotspotX; - _cursorBounds.top = g_fullpipe->_sceneRect.top + y - _cursorsArray[_cursorIndex]->hotspotY; + _cursorBounds.left = g_fp->_sceneRect.left + x - _cursorsArray[_cursorIndex]->hotspotX; + _cursorBounds.top = g_fp->_sceneRect.top + y - _cursorsArray[_cursorIndex]->hotspotY; _cursorBounds.right = _cursorBounds.left + _cursorsArray[_cursorIndex]->width; _cursorBounds.bottom = _cursorBounds.top + _cursorsArray[_cursorIndex]->height; @@ -274,4 +274,70 @@ void FullpipeEngine::updateCursorCommon() { _cursorId = PIC_CSR_DEFAULT; } +void FullpipeEngine::initArcadeKeys(const char *varname) { + GameVar *var = getGameLoaderGameVar()->getSubVarByName(varname)->getSubVarByName("KEYPOS"); + + if (!var) + return; + + int cnt = var->getSubVarsCount(); + + for (int i = 0; i < cnt; i++) { + Common::Point *point = new Common::Point; + + GameVar *sub = var->getSubVarByIndex(i); + + point->x = sub->getSubVarAsInt("X"); + point->y = sub->getSubVarAsInt("Y"); + + _arcadeKeys.push_back(point); + } +} + +void FullpipeEngine::setArcadeOverlay(int picId) { + Common::Point point; + Common::Point point2; + + _arcadeOverlayX = 800; + _arcadeOverlayY = 545; + + _arcadeOverlayHelper = accessScene(SC_INV)->getPictureObjectById(PIC_CSR_HELPERBGR, 0); + _arcadeOverlay = accessScene(SC_INV)->getPictureObjectById(picId, 0); + + _arcadeOverlay->getDimensions(&point); + _arcadeOverlayHelper->getDimensions(&point2); + + _arcadeOverlayMidX = (point2.x - point.x) / 2; + _arcadeOverlayMidY = abs(point2.y - point.y) / 2; +} + +int FullpipeEngine::drawArcadeOverlay(int adjust) { + _arcadeOverlayHelper->drawAt(_sceneRect.left + _arcadeOverlayX, _sceneRect.top + _arcadeOverlayY); + _arcadeOverlay->drawAt(_sceneRect.left + _arcadeOverlayX + _arcadeOverlayMidX, _sceneRect.top + _arcadeOverlayY + _arcadeOverlayMidY); + + if (adjust) { + if (_arcadeOverlayX > 745) { + _arcadeOverlayX -= 15; + + if (_arcadeOverlayX < 745) + _arcadeOverlayX = 745; + } + + return 1; + } + + if (_arcadeOverlayX >= 800) { + return 0; + } else { + _arcadeOverlayX += 15; + + if (_arcadeOverlayX <= 800) + return 1; + + _arcadeOverlayX = 800; + } + + return 1; +} + } // End of namespace Fullpipe diff --git a/engines/fullpipe/interaction.cpp b/engines/fullpipe/interaction.cpp index cd9aad5b22..9d92638328 100644 --- a/engines/fullpipe/interaction.cpp +++ b/engines/fullpipe/interaction.cpp @@ -36,8 +36,8 @@ int handleObjectInteraction(StaticANIObject *subject, GameObject *object, int in bool canInteractAny(GameObject *obj1, GameObject *obj2, int invId) { int sceneId = 0; - if (g_fullpipe->_currentScene) - sceneId = g_fullpipe->_currentScene->_sceneId; + if (g_fp->_currentScene) + sceneId = g_fp->_currentScene->_sceneId; InteractionController *intC = getGameLoaderInteractionController(); for (ObList::iterator i = intC->_interactions.begin(); i != intC->_interactions.end(); ++i) { @@ -137,7 +137,7 @@ bool InteractionController::handleInteraction(StaticANIObject *subj, GameObject obj->setPicAniInfo(&aniInfo); if (abs(xpos - subj->_ox) > 1 || abs(ypos - subj->_oy) > 1) { - mq = getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId)->doWalkTo(subj, xpos, ypos, 1, cinter->_staticsId2); + mq = getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->doWalkTo(subj, xpos, ypos, 1, cinter->_staticsId2); if (mq) { dur = mq->calcDuration(subj); delete mq; @@ -305,7 +305,7 @@ LABEL_38: if (abs(xpos - subj->_ox) > 1 || abs(ypos - subj->_oy) > 1 || (inter->_staticsId2 != 0 && (subj->_statics == 0 || subj->_statics->_staticsId != inter->_staticsId2))) { - mq = getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId)->method34(subj, xpos, ypos, 1, inter->_staticsId2); + mq = getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->method34(subj, xpos, ypos, 1, inter->_staticsId2); if (!mq) return false; @@ -444,7 +444,7 @@ bool Interaction::load(MfcArchive &file) { } bool Interaction::canInteract(GameObject *obj1, GameObject *obj2, int invId) { - if (_sceneId > 0 && g_fullpipe->_currentScene && g_fullpipe->_currentScene->_sceneId != _sceneId) + if (_sceneId > 0 && g_fp->_currentScene && g_fp->_currentScene->_sceneId != _sceneId) return false; if (_flags & 0x20000) @@ -476,20 +476,20 @@ bool Interaction::canInteract(GameObject *obj1, GameObject *obj2, int invId) { if (_objectState1) { if (_flags & 0x10) { - if ((g_fullpipe->getObjectState(obj1->getName()) & _objectState1) == 0) + if ((g_fp->getObjectState(obj1->getName()) & _objectState1) == 0) return false; } else { - if (g_fullpipe->getObjectState(obj1->getName()) != _objectState1) + if (g_fp->getObjectState(obj1->getName()) != _objectState1) return false; } } if (_objectState2) { if (_flags & 0x10) { - if ((g_fullpipe->getObjectState(obj2->getName()) & _objectState2) == 0) + if ((g_fp->getObjectState(obj2->getName()) & _objectState2) == 0) return false; } else { - if (g_fullpipe->getObjectState(obj2->getName()) != _objectState2) + if (g_fp->getObjectState(obj2->getName()) != _objectState2) return false; } } diff --git a/engines/fullpipe/inventory.cpp b/engines/fullpipe/inventory.cpp index 18ef3c4d97..3e22f8526d 100644 --- a/engines/fullpipe/inventory.cpp +++ b/engines/fullpipe/inventory.cpp @@ -161,7 +161,7 @@ int Inventory2::getItemFlags(int itemId) { } void Inventory2::rebuildItemRects() { - _scene = g_fullpipe->accessScene(_sceneId); + _scene = g_fp->accessScene(_sceneId); if (!_scene) return; @@ -226,11 +226,11 @@ void Inventory2::draw() { if (!_scene) return; - int oldScLeft = g_fullpipe->_sceneRect.left; - int oldScTop = g_fullpipe->_sceneRect.top; + int oldScLeft = g_fp->_sceneRect.left; + int oldScTop = g_fp->_sceneRect.top; - g_fullpipe->_sceneRect.top = -_topOffset; - g_fullpipe->_sceneRect.left = 0; + g_fp->_sceneRect.top = -_topOffset; + g_fp->_sceneRect.left = 0; _picture->draw(-1, -1, 0, 0); @@ -290,8 +290,8 @@ LABEL_25: reset: - g_fullpipe->_sceneRect.top = oldScTop; - g_fullpipe->_sceneRect.left = oldScLeft; + g_fp->_sceneRect.top = oldScTop; + g_fp->_sceneRect.left = oldScLeft; } @@ -365,7 +365,7 @@ int Inventory2::selectItem(int itemId) { int idx = getInventoryPoolItemIndexById(itemId); Picture *pic = _scene->getPictureObjectById(_itemsPool[idx]->pictureObjectId1, 0)->_picture; - g_fullpipe->getGameLoaderInputController()->setCursorItemPicture(pic); + g_fp->getGameLoaderInputController()->setCursorItemPicture(pic); } return _selectedId; @@ -382,7 +382,7 @@ bool Inventory2::unselectItem(bool flag) { _inventoryIcons[i]->isSelected = false; } - g_fullpipe->getGameLoaderInputController()->setCursorItemPicture(0); + g_fp->getGameLoaderInputController()->setCursorItemPicture(0); return true; } diff --git a/engines/fullpipe/lift.cpp b/engines/fullpipe/lift.cpp index 1d6d986977..ca23d8223a 100644 --- a/engines/fullpipe/lift.cpp +++ b/engines/fullpipe/lift.cpp @@ -67,7 +67,7 @@ int FullpipeEngine::lift_getButtonIdP(int objid) { } void FullpipeEngine::lift_setButton(const char *name, int state) { - GameVar *var = g_fullpipe->getGameLoaderGameVar()->getSubVarByName("OBJSTATES")->getSubVarByName(sO_LiftButtons); + GameVar *var = g_fp->getGameLoaderGameVar()->getSubVarByName("OBJSTATES")->getSubVarByName(sO_LiftButtons); if (var) var->setSubVarAsInt(name, state); diff --git a/engines/fullpipe/messagehandlers.cpp b/engines/fullpipe/messagehandlers.cpp index fc57109f07..a9872a5a23 100644 --- a/engines/fullpipe/messagehandlers.cpp +++ b/engines/fullpipe/messagehandlers.cpp @@ -55,7 +55,7 @@ int global_messageHandler1(ExCommand *cmd) { cmd->_messageNum = MV_MAN_STOPLADDER2; } - if (g_fullpipe->_inputDisabled) { + if (g_fp->_inputDisabled) { if (cmd->_messageKind == 17) { switch (cmd->_messageNum) { case 29: @@ -71,25 +71,25 @@ int global_messageHandler1(ExCommand *cmd) { } else if (cmd->_messageKind == 17) { switch (cmd->_messageNum) { case MSG_MANSHADOWSON: - g_fullpipe->_aniMan->_shadowsOn = 1; + g_fp->_aniMan->_shadowsOn = 1; break; case MSG_HMRKICK_STUCCO: global_messageHandler_KickStucco(); break; case MSG_MANSHADOWSOFF: - g_fullpipe->_aniMan->_shadowsOn = 0; + g_fp->_aniMan->_shadowsOn = 0; break; case MSG_DISABLESAVES: - g_fullpipe->disableSaves(cmd); + g_fp->disableSaves(cmd); break; case MSG_ENABLESAVES: - g_fullpipe->enableSaves(); + g_fp->enableSaves(); break; case MSG_HMRKICK_METAL: global_messageHandler_KickMetal(); break; case 29: // left mouse - if (g_fullpipe->_inventoryScene) { + if (g_fp->_inventoryScene) { if (getGameLoaderInventory()->handleLeftClick(cmd)) cmd->_messageKind = 0; } @@ -101,22 +101,22 @@ int global_messageHandler1(ExCommand *cmd) { } break; case 36: // keydown - g_fullpipe->defHandleKeyDown(cmd->_keyCode); + g_fp->defHandleKeyDown(cmd->_keyCode); switch (cmd->_keyCode) { case '\x1B': // ESC - if (g_fullpipe->_currentScene) { + if (g_fp->_currentScene) { getGameLoaderInventory()->unselectItem(0); - g_fullpipe->openMainMenu(); + g_fp->openMainMenu(); cmd->_messageKind = 0; } break; case 't': - g_fullpipe->stopAllSounds(); + g_fp->stopAllSounds(); cmd->_messageKind = 0; break; case 'u': - g_fullpipe->toggleMute(); + g_fp->toggleMute(); cmd->_messageKind = 0; break; case ' ': @@ -130,13 +130,13 @@ int global_messageHandler1(ExCommand *cmd) { } break; case '\t': - if (g_fullpipe->_flgCanOpenMap) - g_fullpipe->openMap(); + if (g_fp->_flgCanOpenMap) + g_fp->openMap(); cmd->_messageKind = 0; break; case 'p': - if (g_fullpipe->_flgCanOpenMap) - g_fullpipe->openHelp(); + if (g_fp->_flgCanOpenMap) + g_fp->openHelp(); cmd->_messageKind = 0; break; default: @@ -144,47 +144,47 @@ int global_messageHandler1(ExCommand *cmd) { } break; case 33: - if (!g_fullpipe->_inventoryScene) + if (!g_fp->_inventoryScene) break; int invItem; - if (g_fullpipe->_updateFlag && (invItem = g_fullpipe->_inventory->getHoveredItem(&g_fullpipe->_mouseScreenPos))) { - g_fullpipe->_cursorId = PIC_CSR_ITN; - if (!g_fullpipe->_currSelectedInventoryItemId && !g_fullpipe->_aniMan->_movement && - !(g_fullpipe->_aniMan->_flags & 0x100) && g_fullpipe->_aniMan->isIdle()) { - int st = g_fullpipe->_aniMan->_statics->_staticsId; + if (g_fp->_updateFlag && (invItem = g_fp->_inventory->getHoveredItem(&g_fp->_mouseScreenPos))) { + g_fp->_cursorId = PIC_CSR_ITN; + if (!g_fp->_currSelectedInventoryItemId && !g_fp->_aniMan->_movement && + !(g_fp->_aniMan->_flags & 0x100) && g_fp->_aniMan->isIdle()) { + int st = g_fp->_aniMan->_statics->_staticsId; ExCommand *newex = 0; if (st == ST_MAN_RIGHT) { - newex = new ExCommand(g_fullpipe->_aniMan->_id, 1, rMV_MAN_LOOKUP, 0, 0, 0, 1, 0, 0, 0); + newex = new ExCommand(g_fp->_aniMan->_id, 1, rMV_MAN_LOOKUP, 0, 0, 0, 1, 0, 0, 0); } else if (st == (0x4000 | ST_MAN_RIGHT)) { - newex = new ExCommand(g_fullpipe->_aniMan->_id, 1, MV_MAN_LOOKUP, 0, 0, 0, 1, 0, 0, 0); + newex = new ExCommand(g_fp->_aniMan->_id, 1, MV_MAN_LOOKUP, 0, 0, 0, 1, 0, 0, 0); } if (newex) { - newex->_keyCode = g_fullpipe->_aniMan->_okeyCode; + newex->_keyCode = g_fp->_aniMan->_okeyCode; newex->_excFlags |= 3; newex->postMessage(); } } - if (g_fullpipe->_currSelectedInventoryItemId != invItem) - g_fullpipe->playSound(SND_CMN_070, 0); + if (g_fp->_currSelectedInventoryItemId != invItem) + g_fp->playSound(SND_CMN_070, 0); - g_fullpipe->_currSelectedInventoryItemId = invItem; - g_fullpipe->setCursor(g_fullpipe->_cursorId); + g_fp->_currSelectedInventoryItemId = invItem; + g_fp->setCursor(g_fp->_cursorId); break; } - if (g_fullpipe->_updateCursorCallback) - g_fullpipe->_updateCursorCallback(); + if (g_fp->_updateCursorCallback) + g_fp->_updateCursorCallback(); - g_fullpipe->_currSelectedInventoryItemId = 0; - g_fullpipe->setCursor(g_fullpipe->_cursorId); + g_fp->_currSelectedInventoryItemId = 0; + g_fp->setCursor(g_fp->_cursorId); break; case 65: // open map - if (cmd->_field_2C == 11 && cmd->_field_14 == ANI_INV_MAP && g_fullpipe->_flgCanOpenMap) - g_fullpipe->openMap(); + if (cmd->_field_2C == 11 && cmd->_field_14 == ANI_INV_MAP && g_fp->_flgCanOpenMap) + g_fp->openMap(); break; default: break; @@ -228,13 +228,13 @@ int global_messageHandler2(ExCommand *cmd) { break; case 28: - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (ani) ani->_priority = cmd->_field_14; break; case 25: - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (ani) { if (cmd->_field_14) { ani->setFlags40(true); @@ -247,7 +247,7 @@ int global_messageHandler2(ExCommand *cmd) { break; case 26: - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (ani) { Movement *mov = ani->_movement; if (mov) @@ -258,7 +258,7 @@ int global_messageHandler2(ExCommand *cmd) { default: #if 0 // We never put anything into _defMsgArray - while (::iterator it = g_fullpipe->_defMsgArray.begin(); it != g_fullpipe->_defMsgArray.end(); ++it) + while (::iterator it = g_fp->_defMsgArray.begin(); it != g_fp->_defMsgArray.end(); ++it) if (((ExCommand *)*it)->_field_24 == _messageNum) { ((ExCommand *)*it)->firef34(v13); res = 1; @@ -267,11 +267,11 @@ int global_messageHandler2(ExCommand *cmd) { //debug_msg(_messageNum); - if (!g_fullpipe->_soundEnabled || cmd->_messageNum != 33 || g_fullpipe->_currSoundListCount <= 0) + if (!g_fp->_soundEnabled || cmd->_messageNum != 33 || g_fp->_currSoundListCount <= 0) return res; - for (int snd = 0; snd < g_fullpipe->_currSoundListCount; snd++) { - SoundList *s = g_fullpipe->_currSoundList1[snd]; + for (int snd = 0; snd < g_fp->_currSoundListCount; snd++) { + SoundList *s = g_fp->_currSoundList1[snd]; int ms = s->getCount(); for (int i = 0; i < ms; i++) { s->getSoundByIndex(i)->setPanAndVolumeByStaticAni(); @@ -292,7 +292,7 @@ int global_messageHandler3(ExCommand *cmd) { case 31: case 32: case 36: - if (g_fullpipe->_inputDisabled) + if (g_fp->_inputDisabled) cmd->_messageKind = 0; break; default: @@ -306,41 +306,41 @@ int global_messageHandler3(ExCommand *cmd) { case 17: switch (cmd->_messageNum) { case 61: - return g_fullpipe->_gameLoader->preloadScene(cmd->_parentId, cmd->_keyCode); + return g_fp->_gameLoader->preloadScene(cmd->_parentId, cmd->_keyCode); case 62: - return g_fullpipe->_gameLoader->gotoScene(cmd->_parentId, cmd->_keyCode); + return g_fp->_gameLoader->gotoScene(cmd->_parentId, cmd->_keyCode); case 64: - if (g_fullpipe->_currentScene && g_fullpipe->_msgObjectId2 - && (!(cmd->_keyCode & 4) || g_fullpipe->_msgObjectId2 != cmd->_field_14 || g_fullpipe->_msgId != cmd->_field_20)) { - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(g_fullpipe->_msgObjectId2, g_fullpipe->_msgId); + if (g_fp->_currentScene && g_fp->_msgObjectId2 + && (!(cmd->_keyCode & 4) || g_fp->_msgObjectId2 != cmd->_field_14 || g_fp->_msgId != cmd->_field_20)) { + ani = g_fp->_currentScene->getStaticANIObject1ById(g_fp->_msgObjectId2, g_fp->_msgId); if (ani) { ani->_flags &= 0xFF7F; ani->_flags &= 0xFEFF; ani->deleteFromGlobalMessageQueue(); } } - g_fullpipe->_msgX = 0; - g_fullpipe->_msgY = 0; - g_fullpipe->_msgObjectId2 = 0; - g_fullpipe->_msgId = 0; + g_fp->_msgX = 0; + g_fp->_msgY = 0; + g_fp->_msgObjectId2 = 0; + g_fp->_msgId = 0; if ((cmd->_keyCode & 1) || (cmd->_keyCode & 2)) { - g_fullpipe->_msgX = cmd->_x; - g_fullpipe->_msgY = cmd->_y; + g_fp->_msgX = cmd->_x; + g_fp->_msgY = cmd->_y; } if (cmd->_keyCode & 4) { - g_fullpipe->_msgObjectId2 = cmd->_field_14; - g_fullpipe->_msgId = cmd->_field_20; + g_fp->_msgObjectId2 = cmd->_field_14; + g_fp->_msgId = cmd->_field_20; } return result; case 29: - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) return result; - if (g_fullpipe->_gameLoader->_interactionController->_flag24) { - ani = g_fullpipe->_currentScene->getStaticANIObjectAtPos(cmd->_sceneClickX, cmd->_sceneClickY); - ani2 = g_fullpipe->_currentScene->getStaticANIObject1ById(g_fullpipe->_gameLoader->_field_FA, -1); + if (g_fp->_gameLoader->_interactionController->_flag24) { + ani = g_fp->_currentScene->getStaticANIObjectAtPos(cmd->_sceneClickX, cmd->_sceneClickY); + ani2 = g_fp->_currentScene->getStaticANIObject1ById(g_fp->_gameLoader->_field_FA, -1); if (ani) { - if (g_fullpipe->_msgObjectId2 == ani->_id && g_fullpipe->_msgId == ani->_okeyCode) { + if (g_fp->_msgObjectId2 == ani->_id && g_fp->_msgId == ani->_okeyCode) { cmd->_messageKind = 0; return result; } @@ -349,10 +349,10 @@ int global_messageHandler3(ExCommand *cmd) { return 1; } } else { - int id = g_fullpipe->_currentScene->getPictureObjectIdAtPos(cmd->_sceneClickX, cmd->_sceneClickY); - PictureObject *pic = g_fullpipe->_currentScene->getPictureObjectById(id, 0); + int id = g_fp->_currentScene->getPictureObjectIdAtPos(cmd->_sceneClickX, cmd->_sceneClickY); + PictureObject *pic = g_fp->_currentScene->getPictureObjectById(id, 0); if (pic) { - if (g_fullpipe->_msgObjectId2 == pic->_id && g_fullpipe->_msgId == pic->_okeyCode) { + if (g_fp->_msgObjectId2 == pic->_id && g_fp->_msgId == pic->_okeyCode) { cmd->_messageKind = 0; return result; } @@ -364,13 +364,13 @@ int global_messageHandler3(ExCommand *cmd) { } } } - if (getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId)->_isEnabled && cmd->_keyCode <= 0) { - if (g_fullpipe->_msgX != cmd->_sceneClickX || g_fullpipe->_msgY != cmd->_sceneClickY) { - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(g_fullpipe->_gameLoader->_field_FA, -1); + if (getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->_isEnabled && cmd->_keyCode <= 0) { + if (g_fp->_msgX != cmd->_sceneClickX || g_fp->_msgY != cmd->_sceneClickY) { + ani = g_fp->_currentScene->getStaticANIObject1ById(g_fp->_gameLoader->_field_FA, -1); if (!ani || (ani->isIdle() && !(ani->_flags & 0x80) && !(ani->_flags & 0x100))) { - result = startWalkTo(g_fullpipe->_gameLoader->_field_FA, -1, cmd->_sceneClickX, cmd->_sceneClickY, 0); + result = startWalkTo(g_fp->_gameLoader->_field_FA, -1, cmd->_sceneClickX, cmd->_sceneClickY, 0); if (result) { - ExCommand *ex = new ExCommand(g_fullpipe->_gameLoader->_field_FA, 17, 64, 0, 0, 0, 1, 0, 0, 0); + ExCommand *ex = new ExCommand(g_fp->_gameLoader->_field_FA, 17, 64, 0, 0, 0, 1, 0, 0, 0); ex->_keyCode = 1; ex->_excFlags |= 3; @@ -388,7 +388,7 @@ int global_messageHandler3(ExCommand *cmd) { return result; } case 58: - g_fullpipe->setCursor(cmd->_keyCode); + g_fp->setCursor(cmd->_keyCode); return result; case 59: setInputDisabled(1); @@ -398,7 +398,7 @@ int global_messageHandler3(ExCommand *cmd) { return result; case 56: if (cmd->_field_2C) { - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (ani) { getGameLoaderInventory()->addItem2(ani); result = 1; @@ -412,13 +412,13 @@ int global_messageHandler3(ExCommand *cmd) { case 57: if (cmd->_field_2C) { if (!cmd->_field_20) { - getGameLoaderInventory()->removeItem2(g_fullpipe->_currentScene, cmd->_parentId, cmd->_x, cmd->_y, cmd->_field_14); + getGameLoaderInventory()->removeItem2(g_fp->_currentScene, cmd->_parentId, cmd->_x, cmd->_y, cmd->_field_14); getGameLoaderInventory()->rebuildItemRects(); return 1; } - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(g_fullpipe->_gameLoader->_field_FA, -1); + ani = g_fp->_currentScene->getStaticANIObject1ById(g_fp->_gameLoader->_field_FA, -1); if (ani) { - getGameLoaderInventory()->removeItem2(g_fullpipe->_currentScene, cmd->_parentId, ani->_ox + cmd->_x, ani->_oy + cmd->_y, ani->_priority + cmd->_field_14); + getGameLoaderInventory()->removeItem2(g_fp->_currentScene, cmd->_parentId, ani->_ox + cmd->_x, ani->_oy + cmd->_y, ani->_priority + cmd->_field_14); getGameLoaderInventory()->rebuildItemRects(); return 1; } @@ -428,13 +428,13 @@ int global_messageHandler3(ExCommand *cmd) { getGameLoaderInventory()->rebuildItemRects(); return 1; case 55: - if (g_fullpipe->_currentScene) { + if (g_fp->_currentScene) { GameObject *obj; if (cmd->_field_14) - obj = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_x, cmd->_y); + obj = g_fp->_currentScene->getStaticANIObject1ById(cmd->_x, cmd->_y); else - obj = g_fullpipe->_currentScene->getPictureObjectById(cmd->_x, cmd->_y); - handleObjectInteraction(g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode), obj, cmd->_field_20); + obj = g_fp->_currentScene->getPictureObjectById(cmd->_x, cmd->_y); + handleObjectInteraction(g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode), obj, cmd->_field_20); result = 1; } return result; @@ -448,7 +448,7 @@ int global_messageHandler3(ExCommand *cmd) { if (cmd->_objtype == kObjTypeObjstateCommand) { ObjstateCommand *c = (ObjstateCommand *)cmd; result = 1; - g_fullpipe->setObjectState(c->_objCommandName, c->_value); + g_fp->setObjectState(c->_objCommandName, c->_value); } return result; default: @@ -461,7 +461,7 @@ int global_messageHandler4(ExCommand *cmd) { switch (cmd->_messageKind) { case 18: { - MessageQueue *mq = new MessageQueue(g_fullpipe->_currentScene->getMessageQueueById(cmd->_messageNum), cmd->_parId, 0); + MessageQueue *mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(cmd->_messageNum), cmd->_parId, 0); if (cmd->_excFlags & 1) mq->_flag1 = 1; @@ -472,10 +472,10 @@ int global_messageHandler4(ExCommand *cmd) { break; } case 2: - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) break; - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -483,10 +483,10 @@ int global_messageHandler4(ExCommand *cmd) { break; case 1: { - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) break; - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -502,10 +502,10 @@ int global_messageHandler4(ExCommand *cmd) { break; } case 8: - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) break; - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -513,10 +513,10 @@ int global_messageHandler4(ExCommand *cmd) { break; case 20: { - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) break; - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -534,10 +534,10 @@ int global_messageHandler4(ExCommand *cmd) { break; } case 21: - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) break; - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -548,17 +548,17 @@ int global_messageHandler4(ExCommand *cmd) { // Nop in original break; case 3: - g_fullpipe->_currentScene->_y = cmd->_messageNum - cmd->_messageNum % g_fullpipe->_scrollSpeed; + g_fp->_currentScene->_y = cmd->_messageNum - cmd->_messageNum % g_fp->_scrollSpeed; break; case 4: - g_fullpipe->_currentScene->_x = cmd->_messageNum - cmd->_messageNum % g_fullpipe->_scrollSpeed; + g_fp->_currentScene->_x = cmd->_messageNum - cmd->_messageNum % g_fp->_scrollSpeed; break; case 19: { - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) break; - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -573,10 +573,10 @@ int global_messageHandler4(ExCommand *cmd) { break; } case 22: - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) break; - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -585,10 +585,10 @@ int global_messageHandler4(ExCommand *cmd) { break; case 6: - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) break; - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -596,18 +596,18 @@ int global_messageHandler4(ExCommand *cmd) { break; case 27: - if (!g_fullpipe->_currentScene || g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode) == 0) { - ani = g_fullpipe->accessScene(cmd->_field_20)->getStaticANIObject1ById(cmd->_parentId, -1); + if (!g_fp->_currentScene || g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode) == 0) { + ani = g_fp->accessScene(cmd->_field_20)->getStaticANIObject1ById(cmd->_parentId, -1); if (ani) { ani = new StaticANIObject(ani); - g_fullpipe->_currentScene->addStaticANIObject(ani, 1); + g_fp->_currentScene->addStaticANIObject(ani, 1); } } // fall through case 5: - if (g_fullpipe->_currentScene) - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + if (g_fp->_currentScene) + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -619,10 +619,10 @@ int global_messageHandler4(ExCommand *cmd) { break; case 10: - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) break; - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -633,34 +633,34 @@ int global_messageHandler4(ExCommand *cmd) { break; case 7: { - if (!g_fullpipe->_currentScene->_picObjList.size()) + if (!g_fp->_currentScene->_picObjList.size()) break; - int offX = g_fullpipe->_scrollSpeed * (cmd->_x / g_fullpipe->_scrollSpeed); - int offY = g_fullpipe->_scrollSpeed * (cmd->_y / g_fullpipe->_scrollSpeed); + int offX = g_fp->_scrollSpeed * (cmd->_x / g_fp->_scrollSpeed); + int offY = g_fp->_scrollSpeed * (cmd->_y / g_fp->_scrollSpeed); if (cmd->_messageNum) { - g_fullpipe->_currentScene->_x = offX - g_fullpipe->_sceneRect.left; - g_fullpipe->_currentScene->_y = offY - g_fullpipe->_sceneRect.top; + g_fp->_currentScene->_x = offX - g_fp->_sceneRect.left; + g_fp->_currentScene->_y = offY - g_fp->_sceneRect.top; if (cmd->_field_24) { - g_fullpipe->_currentScene->_messageQueueId = cmd->_parId; + g_fp->_currentScene->_messageQueueId = cmd->_parId; } } else { - g_fullpipe->_sceneRect.moveTo(offX, offY); + g_fp->_sceneRect.moveTo(offX, offY); - g_fullpipe->_currentScene->_x = 0; - g_fullpipe->_currentScene->_y = 0; + g_fp->_currentScene->_x = 0; + g_fp->_currentScene->_y = 0; - g_fullpipe->_currentScene->updateScrolling2(); + g_fp->_currentScene->updateScrolling2(); } break; } case 34: - if (!g_fullpipe->_currentScene) + if (!g_fp->_currentScene) break; - ani = g_fullpipe->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); + ani = g_fp->_currentScene->getStaticANIObject1ById(cmd->_parentId, cmd->_keyCode); if (!ani) break; @@ -690,15 +690,15 @@ int MovGraph_messageHandler(ExCommand *cmd) { if (cmd->_messageNum != 33) return 0; - StaticANIObject *ani = g_fullpipe->_currentScene->getStaticANIObject1ById(g_fullpipe->_gameLoader->_field_FA, -1); + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObject1ById(g_fp->_gameLoader->_field_FA, -1); - if (!getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId)) + if (!getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)) return 0; - if (getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId)->_objtype != kObjTypeMovGraph || !ani) + if (getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->_objtype != kObjTypeMovGraph || !ani) return 0; - MovGraph *gr = (MovGraph *)getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId); + MovGraph *gr = (MovGraph *)getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId); MovGraphLink *link = 0; double mindistance = 1.0e10; diff --git a/engines/fullpipe/messages.cpp b/engines/fullpipe/messages.cpp index 8ed99fce15..8ca416bb9e 100644 --- a/engines/fullpipe/messages.cpp +++ b/engines/fullpipe/messages.cpp @@ -73,7 +73,7 @@ bool ExCommand::load(MfcArchive &file) { _field_3C = 0; - if (g_fullpipe->_gameProjectVersion >= 12) { + if (g_fp->_gameProjectVersion >= 12) { _excFlags = file.readUint32LE(); _parId = file.readUint32LE(); } @@ -83,12 +83,12 @@ bool ExCommand::load(MfcArchive &file) { bool ExCommand::handleMessage() { int cnt = 0; - for (MessageHandler *m = g_fullpipe->_messageHandlers; m; m = m->nextItem) + for (MessageHandler *m = g_fp->_messageHandlers; m; m = m->nextItem) cnt += m->callback(this); if (_messageKind == 17 || (_excFlags & 1)) { if (_parId) { - MessageQueue *mq = g_fullpipe->_globalMessageQueueList->getMessageQueueById(_parId); + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(_parId); if (mq) mq->update(); } @@ -101,18 +101,18 @@ bool ExCommand::handleMessage() { } void ExCommand::sendMessage() { - g_fullpipe->_exCommandList.push_back(this); + g_fp->_exCommandList.push_back(this); processMessages(); } void ExCommand::postMessage() { - g_fullpipe->_exCommandList.push_back(this); + g_fp->_exCommandList.push_back(this); } void ExCommand::handle() { - if (g_fullpipe->_modalObject) { - g_fullpipe->_modalObject->handleMessage(this); + if (g_fp->_modalObject) { + g_fp->_modalObject->handleMessage(this); delete this; } else { @@ -205,7 +205,7 @@ MessageQueue::MessageQueue(int dataId) { _field_14 = 0; _parId = 0; _dataId = dataId; - _id = g_fullpipe->_globalMessageQueueList->compact(); + _id = g_fp->_globalMessageQueueList->compact(); _isFinished = 0; _flags = 0; _queueName = 0; @@ -231,11 +231,11 @@ MessageQueue::MessageQueue(MessageQueue *src, int parId, int field_38) { else _parId = src->_parId; - _id = g_fullpipe->_globalMessageQueueList->compact(); + _id = g_fp->_globalMessageQueueList->compact(); _dataId = src->_dataId; _flags = src->_flags; - g_fullpipe->_globalMessageQueueList->addMessageQueue(this); + g_fp->_globalMessageQueueList->addMessageQueue(this); _isFinished = 0; _flag1 = 0; @@ -255,7 +255,7 @@ MessageQueue::~MessageQueue() { delete _field_14; if (_flags & 2) { - g_fullpipe->_globalMessageQueueList->removeQueueById(_id); + g_fp->_globalMessageQueueList->removeQueueById(_id); } finish(); @@ -270,7 +270,7 @@ bool MessageQueue::load(MfcArchive &file) { int count = file.readUint16LE(); - assert(g_fullpipe->_gameProjectVersion >= 12); + assert(g_fp->_gameProjectVersion >= 12); _queueName = file.readPascalString(); @@ -291,7 +291,7 @@ bool MessageQueue::load(MfcArchive &file) { bool MessageQueue::chain(StaticANIObject *ani) { if (checkGlobalExCommandList1() && checkGlobalExCommandList2()) { if (!(getFlags() & 2)) { - g_fullpipe->_globalMessageQueueList->addMessageQueue(this); + g_fp->_globalMessageQueueList->addMessageQueue(this); _flags |= 2; } if (ani) { @@ -331,7 +331,7 @@ void MessageQueue::addExCommandToEnd(ExCommand *ex) { } ExCommand *MessageQueue::getExCommandByIndex(uint idx) { - if (idx > getCount()) + if (idx >= getCount()) return 0; Common::List<ExCommand *>::iterator it = _exCommands.begin(); @@ -345,7 +345,7 @@ ExCommand *MessageQueue::getExCommandByIndex(uint idx) { } void MessageQueue::deleteExCommandByIndex(uint idx, bool doFree) { - if (idx > getCount()) + if (idx >= getCount()) return; Common::List<ExCommand *>::iterator it = _exCommands.begin(); @@ -398,7 +398,7 @@ bool MessageQueue::checkGlobalExCommandList1() { if (ex->_messageKind != 1 && ex->_messageKind != 20 && ex->_messageKind != 5 && ex->_messageKind != 27) continue; - for (Common::List<ExCommand *>::iterator it = g_fullpipe->_exCommandList.begin(); it != g_fullpipe->_exCommandList.end(); it++) { + for (Common::List<ExCommand *>::iterator it = g_fp->_exCommandList.begin(); it != g_fp->_exCommandList.end(); it++) { ex1 = *it; if (ex1->_messageKind != 1 && ex1->_messageKind != 20 && ex1->_messageKind != 5 && ex1->_messageKind != 27) @@ -407,7 +407,7 @@ bool MessageQueue::checkGlobalExCommandList1() { if (ex1->_keyCode != ex->_keyCode && ex1->_keyCode != -1 && ex->_keyCode != -1) continue; - MessageQueue *mq = g_fullpipe->_globalMessageQueueList->getMessageQueueById(ex1->_parId); + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(ex1->_parId); if (mq) { if (mq->getFlags() & 1) @@ -427,7 +427,7 @@ bool MessageQueue::checkGlobalExCommandList2() { if (ex->_messageKind != 1 && ex->_messageKind != 20 && ex->_messageKind != 5 && ex->_messageKind != 27) continue; - for (Common::List<ExCommand *>::iterator it = g_fullpipe->_exCommandList.begin(); it != g_fullpipe->_exCommandList.end();) { + for (Common::List<ExCommand *>::iterator it = g_fp->_exCommandList.begin(); it != g_fp->_exCommandList.end();) { ex1 = *it; if (ex1->_messageKind != 1 && ex1->_messageKind != 20 && ex1->_messageKind != 5 && ex1->_messageKind != 27) { @@ -440,7 +440,7 @@ bool MessageQueue::checkGlobalExCommandList2() { continue; } - MessageQueue *mq = g_fullpipe->_globalMessageQueueList->getMessageQueueById(ex1->_parId); + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(ex1->_parId); if (mq) { if (mq->getFlags() & 1) @@ -449,7 +449,7 @@ bool MessageQueue::checkGlobalExCommandList2() { delete mq; } - it = g_fullpipe->_exCommandList.erase(it); + it = g_fp->_exCommandList.erase(it); if (ex1->_excFlags & 2) { delete ex1; @@ -463,7 +463,7 @@ void MessageQueue::finish() { if (!_parId) return; - MessageQueue *mq = g_fullpipe->_globalMessageQueueList->getMessageQueueById(_parId); + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(_parId); _parId = 0; @@ -573,7 +573,7 @@ int GlobalMessageQueueList::compact() { disableQueueById(_storage[i]->_id); remove_at(i); } else { - if (_storage[i]->_id < size() + 2) + if ((uint)_storage[i]->_id < size() + 2) useList[_storage[i]->_id] = 1; i++; } @@ -602,8 +602,8 @@ void clearGlobalMessageQueueList1() { } bool removeMessageHandler(int16 id, int pos) { - if (g_fullpipe->_messageHandlers) { - MessageHandler *curItem = g_fullpipe->_messageHandlers; + if (g_fp->_messageHandlers) { + MessageHandler *curItem = g_fp->_messageHandlers; MessageHandler *prevItem = 0; int curPos = 0; @@ -637,13 +637,13 @@ void addMessageHandler(int (*callback)(ExCommand *), int16 id) { if (getMessageHandlerById(id)) return; - MessageHandler *curItem = g_fullpipe->_messageHandlers; + MessageHandler *curItem = g_fp->_messageHandlers; if (!curItem) return; int index = 0; - for (MessageHandler *i = g_fullpipe->_messageHandlers->nextItem; i; i = i->nextItem) { + for (MessageHandler *i = g_fp->_messageHandlers->nextItem; i; i = i->nextItem) { curItem = i; index++; } @@ -655,7 +655,7 @@ void addMessageHandler(int (*callback)(ExCommand *), int16 id) { } MessageHandler *getMessageHandlerById(int16 id) { - MessageHandler *curItem = g_fullpipe->_messageHandlers; + MessageHandler *curItem = g_fp->_messageHandlers; if (!curItem) return 0; @@ -685,7 +685,7 @@ bool allocMessageHandler(MessageHandler *where, int16 id, int (*callback)(ExComm msg->callback = callback; msg->index = 0; - g_fullpipe->_messageHandlers = msg; + g_fp->_messageHandlers = msg; } return true; @@ -693,7 +693,7 @@ bool allocMessageHandler(MessageHandler *where, int16 id, int (*callback)(ExComm int getMessageHandlersCount() { int result; - MessageHandler *curItem = g_fullpipe->_messageHandlers; + MessageHandler *curItem = g_fp->_messageHandlers; for (result = 0; curItem; result++) curItem = curItem->nextItem; @@ -706,7 +706,7 @@ bool addMessageHandlerByIndex(int (*callback)(ExCommand *), int index, int16 id) return false; if (index) { - MessageHandler *curItem = g_fullpipe->_messageHandlers; + MessageHandler *curItem = g_fp->_messageHandlers; for (int i = index - 1; i > 0; i--) if (curItem) @@ -724,13 +724,13 @@ bool addMessageHandlerByIndex(int (*callback)(ExCommand *), int index, int16 id) } else { MessageHandler *newItem = new MessageHandler; - newItem->nextItem = g_fullpipe->_messageHandlers; + newItem->nextItem = g_fp->_messageHandlers; newItem->id = id; newItem->callback = callback; newItem->index = 0; - updateMessageHandlerIndex(g_fullpipe->_messageHandlers, 1); - g_fullpipe->_messageHandlers = newItem; + updateMessageHandlerIndex(g_fp->_messageHandlers, 1); + g_fp->_messageHandlers = newItem; return true; } @@ -740,7 +740,7 @@ bool insertMessageHandler(int (*callback)(ExCommand *), int index, int16 id) { if (getMessageHandlerById(id)) return false; - MessageHandler *curItem = g_fullpipe->_messageHandlers; + MessageHandler *curItem = g_fp->_messageHandlers; for (int i = index; i > 0; i--) if (curItem) @@ -757,7 +757,7 @@ void clearMessageHandlers() { MessageHandler *curItem; MessageHandler *nextItem; - curItem = g_fullpipe->_messageHandlers; + curItem = g_fp->_messageHandlers; if (curItem) { do { nextItem = curItem->nextItem; @@ -767,32 +767,32 @@ void clearMessageHandlers() { curItem = nextItem; } while (nextItem); - g_fullpipe->_messageHandlers = 0; + g_fp->_messageHandlers = 0; } } void processMessages() { - if (!g_fullpipe->_isProcessingMessages) { - g_fullpipe->_isProcessingMessages = true; + if (!g_fp->_isProcessingMessages) { + g_fp->_isProcessingMessages = true; - while (g_fullpipe->_exCommandList.size()) { - ExCommand *ex = g_fullpipe->_exCommandList.front(); - g_fullpipe->_exCommandList.pop_front(); + while (g_fp->_exCommandList.size()) { + ExCommand *ex = g_fp->_exCommandList.front(); + g_fp->_exCommandList.pop_front(); ex->handleMessage(); } - g_fullpipe->_isProcessingMessages = false; + g_fp->_isProcessingMessages = false; } } void updateGlobalMessageQueue(int id, int objid) { - MessageQueue *m = g_fullpipe->_globalMessageQueueList->getMessageQueueById(id); + MessageQueue *m = g_fp->_globalMessageQueueList->getMessageQueueById(id); if (m) { m->update(); } } bool chainQueue(int queueId, int flags) { - MessageQueue *mq = g_fullpipe->_currentScene->getMessageQueueById(queueId); + MessageQueue *mq = g_fp->_currentScene->getMessageQueueById(queueId); if (!mq) return false; @@ -810,6 +810,25 @@ bool chainQueue(int queueId, int flags) { return true; } +bool chainObjQueue(StaticANIObject *obj, int queueId, int flags) { + MessageQueue *mq = g_fp->_currentScene->getMessageQueueById(queueId); + + if (!mq) + return false; + + MessageQueue *nmq = new MessageQueue(mq, 0, 0); + + nmq->_flags |= flags; + + if (!nmq->chain(obj)) { + delete nmq; + + return false; + } + + return true; +} + void postExCommand(int parentId, int keyCode, int x, int y, int f20, int f14) { ExCommand *ex = new ExCommand(parentId, 17, 64, 0, 0, 0, 1, 0, 0, 0); diff --git a/engines/fullpipe/messages.h b/engines/fullpipe/messages.h index ca61dad007..44245bcf19 100644 --- a/engines/fullpipe/messages.h +++ b/engines/fullpipe/messages.h @@ -178,6 +178,7 @@ void updateGlobalMessageQueue(int id, int objid); void clearGlobalMessageQueueList1(); bool chainQueue(int queueId, int flags); +bool chainObjQueue(StaticANIObject *obj, int queueId, int flags); void postExCommand(int parentId, int keyCode, int x, int y, int f20, int f16); } // End of namespace Fullpipe diff --git a/engines/fullpipe/modal.cpp b/engines/fullpipe/modal.cpp index f766be3eac..516d761aa2 100644 --- a/engines/fullpipe/modal.cpp +++ b/engines/fullpipe/modal.cpp @@ -24,6 +24,7 @@ #include "fullpipe/modal.h" #include "fullpipe/messages.h" #include "fullpipe/constants.h" +#include "fullpipe/motion.h" #include "fullpipe/scenes.h" #include "fullpipe/gameloader.h" @@ -40,17 +41,17 @@ ModalIntro::ModalIntro() { _introFlags = 33; _countDown = 150; - PictureObject *pict = g_fullpipe->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_PIPETITLE, 0); + PictureObject *pict = g_fp->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_PIPETITLE, 0); pict->setFlags(pict->_flags & 0xFFFB); } g_vars->sceneIntro_skipIntro = false; - _sfxVolume = g_fullpipe->_sfxVolume; + _sfxVolume = g_fp->_sfxVolume; } ModalIntro::~ModalIntro() { - g_fullpipe->stopAllSounds(); - g_fullpipe->_sfxVolume = _sfxVolume; + g_fp->stopAllSounds(); + g_fp->_sfxVolume = _sfxVolume; } bool ModalIntro::handleMessage(ExCommand *message) { @@ -84,7 +85,7 @@ bool ModalIntro::init(int counterdiff) { } if (_introFlags & 0x10) - g_fullpipe->_gameLoader->updateSystems(42); + g_fp->_gameLoader->updateSystems(42); _introFlags |= 2; @@ -94,7 +95,7 @@ bool ModalIntro::init(int counterdiff) { if (_introFlags & 4) { ModalVideoPlayer *player = new ModalVideoPlayer(); - g_fullpipe->_modalObject = player; + g_fp->_modalObject = player; player->_parentObj = this; player->play("intro.avi"); @@ -118,7 +119,7 @@ bool ModalIntro::init(int counterdiff) { if (_introFlags & 0x40) { ModalVideoPlayer *player = new ModalVideoPlayer(); - g_fullpipe->_modalObject = player; + g_fp->_modalObject = player; player->_parentObj = this; player->play("intro2.avi"); @@ -151,7 +152,7 @@ bool ModalIntro::init(int counterdiff) { _countDown = 150; _introFlags = (_introFlags & 0xf7) | 0x21; - g_fullpipe->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_PIPETITLE, 0)->_flags &= 0xfffb; + g_fp->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_PIPETITLE, 0)->_flags &= 0xfffb; } if (!(_introFlags & 0x20)) { @@ -159,12 +160,12 @@ bool ModalIntro::init(int counterdiff) { if (!_stillRunning) { _introFlags |= 1; - g_fullpipe->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_PIPETITLE, 0)->_flags &= 0xfffb; - g_fullpipe->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_GAMETITLE, 0)->_flags &= 0xfffb; + g_fp->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_PIPETITLE, 0)->_flags &= 0xfffb; + g_fp->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_GAMETITLE, 0)->_flags &= 0xfffb; chainQueue(QU_INTR_STARTINTRO, 1); } - g_fullpipe->_gameLoader->updateSystems(42); + g_fp->_gameLoader->updateSystems(42); } return true; } @@ -180,7 +181,7 @@ bool ModalIntro::init(int counterdiff) { _introFlags = (_introFlags & 0xdf) | 0x10; - g_fullpipe->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_GAMETITLE, 0)->_flags &= 0xfffb; + g_fp->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_GAMETITLE, 0)->_flags &= 0xfffb; _stillRunning = 0; } @@ -189,14 +190,14 @@ bool ModalIntro::init(int counterdiff) { } void ModalIntro::update() { - if (g_fullpipe->_currentScene) { + if (g_fp->_currentScene) { if (_introFlags & 1) { //sceneFade(virt, g_currentScene, 1); _stillRunning = 255; _introFlags &= 0xfe; if (_introFlags & 0x20) - g_fullpipe->playSound(SND_INTR_019, 0); + g_fp->playSound(SND_INTR_019, 0); } else if (_introFlags & 2) { if (g_vars->sceneIntro_needBlackout) { //vrtRectangle(*(_DWORD *)virt, 0, 0, 0, 800, 600); @@ -209,18 +210,18 @@ void ModalIntro::update() { _introFlags &= 0xfd; } } else if (_stillRunning) { - g_fullpipe->_currentScene->draw(); + g_fp->_currentScene->draw(); } } } void ModalIntro::finish() { - g_fullpipe->_gameLoader->unloadScene(SC_INTRO2); - g_fullpipe->_currentScene = g_fullpipe->accessScene(SC_INTRO1); - g_fullpipe->_gameLoader->preloadScene(SC_INTRO1, TrubaDown); + g_fp->_gameLoader->unloadScene(SC_INTRO2); + g_fp->_currentScene = g_fp->accessScene(SC_INTRO1); + g_fp->_gameLoader->preloadScene(SC_INTRO1, TrubaDown); - if (g_fullpipe->_currentScene) - g_fullpipe->_gameLoader->updateSystems(42); + if (g_fp->_currentScene) + g_fp->_gameLoader->updateSystems(42); } void ModalVideoPlayer::play(const char *fname) { diff --git a/engines/fullpipe/module.mk b/engines/fullpipe/module.mk index bd948b7ab4..6f8fbe2c71 100644 --- a/engines/fullpipe/module.mk +++ b/engines/fullpipe/module.mk @@ -28,6 +28,14 @@ MODULE_OBJS = \ scenes/scene02.o \ scenes/scene03.o \ scenes/scene04.o \ + scenes/scene05.o \ + scenes/scene06.o \ + scenes/scene07.o \ + scenes/scene08.o \ + scenes/scene10.o \ + scenes/scene11.o \ + scenes/scene12.o \ + scenes/scene15.o \ scenes/sceneDbg.o \ scenes/sceneIntro.o diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp index fbe2768486..45ff4ae5f0 100644 --- a/engines/fullpipe/motion.cpp +++ b/engines/fullpipe/motion.cpp @@ -42,6 +42,16 @@ bool MotionController::load(MfcArchive &file) { return true; } +void MotionController::enableLinks(const char *linkName, bool enable) { + warning("STUB: MotionController::enableLinks()"); +} + +MovGraphLink *MotionController::getLinkByName(const char *name) { + warning("STUB: MotionController::getLinkByName()"); + + return 0; +} + bool MctlCompound::load(MfcArchive &file) { debug(5, "MctlCompound::load()"); @@ -185,9 +195,14 @@ MessageQueue *MctlCompound::doWalkTo(StaticANIObject *subj, int xpos, int ypos, return mq; } +MctlCompoundArrayItem::~MctlCompoundArrayItem() { + delete _movGraphReactObj; + delete _motionControllerObj; +} + MctlLadder::MctlLadder() { - _ladder_field_18 = 0; - _objId = 0; + _width = 0; + _ladderX = 0; _height = 0; _ladderY = 0; _ladder_field_14 = 0; @@ -243,7 +258,7 @@ int MctlLadder::findObjectPos(StaticANIObject *obj) { } bool MctlLadder::initMovement(StaticANIObject *ani, MctlLadderMovement *movement) { - GameVar *v = g_fullpipe->getGameLoaderGameVar()->getSubVarByName(ani->getName()); + GameVar *v = g_fp->getGameLoaderGameVar()->getSubVarByName(ani->getName()); if (!v) return false; @@ -298,7 +313,12 @@ void MctlLadder::freeItems() { } MessageQueue *MctlLadder::method34(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) { - warning("STUB: MctlLadder::method34()"); + MessageQueue *mq = doWalkTo(subj, xpos, ypos, fuzzyMatch, staticsId); + + if (mq) { + if (mq->chain(subj)) + return mq; + } return 0; } @@ -309,12 +329,61 @@ MessageQueue *MctlLadder::doWalkTo(StaticANIObject *subj, int xpos, int ypos, in return 0; } +MessageQueue *MctlLadder::controllerWalkTo(StaticANIObject *ani, int off) { + return doWalkTo(ani, _ladderX + off * _width, _ladderY + off * _height, 1, 0); +} + MctlConnectionPoint *MctlCompound::findClosestConnectionPoint(int ox, int oy, int destIndex, int connectionX, int connectionY, int sourceIndex, int *minDistancePtr) { warning("STUB: MctlCompound::findClosestConnectionPoint()"); return 0; } +void MctlCompound::replaceNodeX(int from, int to) { + warning("STUB: MctlCompound::replaceNodeX()"); +} + +MctlConnectionPoint::MctlConnectionPoint() { + _connectionX = 0; + _connectionY = 0; + _field_C = 0; + _field_10 = 0; + _field_14 = 0; + _field_16 = 0; + _messageQueueObj = 0; + _motionControllerObj = 0; +} + +MctlConnectionPoint::~MctlConnectionPoint() { + delete _messageQueueObj; +} + +MovInfo1::MovInfo1(MovInfo1 *src) { + field_0 = src->field_0; + pt1 = src->pt1; + pt2 = src->pt2; + distance1 = src->distance1; + distance2 = src->distance2; + subIndex = src->subIndex; + item1Index = src->item1Index; + items = src->items; + itemsCount = src->itemsCount; + flags = src->flags; +} + +void MovInfo1::clear() { + field_0 = 0; + pt1.x = pt1.y = 0; + pt2.x = pt2.y = 0; + distance1 = 0; + distance2 = 0; + subIndex = 0; + item1Index = 0; + items.clear(); + itemsCount = 0; + flags = 0; +} + bool MctlCompoundArray::load(MfcArchive &file) { debug(5, "MctlCompoundArray::load()"); @@ -404,10 +473,9 @@ int MovGraph::method28() { return 0; } -int MovGraph::method2C() { - warning("STUB: MovGraph::method2C()"); - - return 0; +int MovGraph::method2C(StaticANIObject *obj, int x, int y) { + obj->setOXY(x, y); + return method3C(obj, 1); } MessageQueue *MovGraph::method34(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) { @@ -422,7 +490,7 @@ int MovGraph::changeCallback() { return 0; } -int MovGraph::method3C() { +int MovGraph::method3C(StaticANIObject *ani, int flag) { warning("STUB: MovGraph::method3C()"); return 0; @@ -475,8 +543,8 @@ double MovGraph::calcDistance(Common::Point *point, MovGraphLink *link, int fuzz return -1.0; } } else { - point->x = n1x + (dist2x * distm / link->_distance); - point->y = n1y + (dist2y * distm / link->_distance); + point->x = (int)(n1x + (dist2x * distm / link->_distance)); + point->y = (int)(n1y + (dist2y * distm / link->_distance)); } return res; @@ -529,7 +597,7 @@ bool MovGraph2::initDirections(StaticANIObject *obj, MovGraph2Item *item) { item->_obj = obj; item->_objectId = obj->_id; - GameVar *var = g_fullpipe->getGameLoaderGameVar()->getSubVarByName(obj->_objectName); + GameVar *var = g_fp->getGameLoaderGameVar()->getSubVarByName(obj->_objectName); if (!var) return false; @@ -782,15 +850,13 @@ void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphL } MessageQueue *MovGraph2::buildMovInfo1MessageQueue(MovInfo1 *movInfo) { - MovInfo1 movinfo; - - memcpy(&movinfo, movInfo, sizeof(movinfo)); + MovInfo1 movinfo(movInfo); int curX = movInfo->pt1.x; int curY = movInfo->pt1.y; int curDistance = movInfo->distance1; - MessageQueue *mq = new MessageQueue(g_fullpipe->_globalMessageQueueList->compact()); + MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); for (int i = 0; i < movInfo->itemsCount - 1; i++) { if (movInfo->items[i + 1]->subIndex != 10) { @@ -1026,7 +1092,7 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int } if (obj->_ox == xpos && obj->_oy == ypos) { - g_fullpipe->_globalMessageQueueList->compact(); + g_fp->_globalMessageQueueList->compact(); MessageQueue *mq = new MessageQueue(); @@ -1103,7 +1169,7 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int if (minPath < 0.0 || ((linkInfoSource.node != linkInfoDest.node || !linkInfoSource.node) && !tempLinkList.size())) return 0; - memset(&movInfo1, 0, sizeof(movInfo1)); + movInfo1.clear(); movInfo1.subIndex = idxsub; movInfo1.pt1.x = obj->_ox; @@ -1134,7 +1200,7 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int double dst1 = sqrt((double)((ypos - nod->_y) * (ypos - nod->_y) + (xpos - nod->_x) * (xpos - nod->_x))); int dst = linkInfoDest.link->_movGraphNode2->_distance - nod->_distance; - movInfo1.distance2 = nod->_distance + (dst1 * (double)dst / linkInfoDest.link->_distance); + movInfo1.distance2 = (int)(nod->_distance + (dst1 * (double)dst / linkInfoDest.link->_distance)); calcDistance(&movInfo1.pt2, linkInfoDest.link, 1); @@ -1160,7 +1226,6 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int if (_items2[idx]->_subItems[idxsub]._staticsId1 != obj->_statics->_staticsId) movInfo1.flags |= 2; - // FIXME: This somehow corrupts the heap (reported by MSVC) buildMovInfo1SubItems(&movInfo1, &tempLinkList, &linkInfoSource, &linkInfoDest); MessageQueue *mq = buildMovInfo1MessageQueue(&movInfo1); @@ -1492,7 +1557,7 @@ void MGM::rebuildTables(int objId) { _items[idx]->movements1.clear(); _items[idx]->movements2.clear(); - StaticANIObject *obj = g_fullpipe->_currentScene->getStaticANIObject1ById(objId, -1); + StaticANIObject *obj = g_fp->_currentScene->getStaticANIObject1ById(objId, -1); if (!obj) return; @@ -1528,9 +1593,13 @@ void MGM::updateAnimStatics(StaticANIObject *ani, int staticsId) { ani->queueMessageQueue(0); ani->_movement->gotoLastFrame(); ani->_statics = ani->_movement->_staticsObj2; + + int x = ani->_movement->_ox; + int y = ani->_movement->_oy; + ani->_movement = 0; - ani->setOXY(ani->_movement->_ox, ani->_movement->_oy); + ani->setOXY(x, y); } if (ani->_statics) { @@ -1544,12 +1613,66 @@ void MGM::updateAnimStatics(StaticANIObject *ani, int staticsId) { } } -Common::Point *MGM::getPoint(Common::Point *point, int aniId, int staticsId1, int staticsId2) { - warning("STUB: MGM::getPoint()"); +Common::Point *MGM::getPoint(Common::Point *point, int objectId, int staticsId1, int staticsId2) { + int idx = getItemIndexById(objectId); + + if (idx == -1) { + point->x = -1; + point->y = -1; + } else { + int st1idx = getStaticsIndexById(idx, staticsId1); + int st2idx = getStaticsIndexById(idx, staticsId2); + + if (st1idx == st2idx) { + point->x = 0; + point->y = 0; + } else { + int subidx = st1idx + st2idx * _items[idx]->statics.size(); + + if (!_items[idx]->subItems[subidx]->movement) { + clearMovements2(idx); + recalcOffsets(idx, st1idx, st2idx, false, true); + + if (!_items[idx]->subItems[subidx]->movement) { + clearMovements2(idx); + recalcOffsets(idx, st1idx, st2idx, true, false); + } + } + + MGMSubItem *sub = _items[idx]->subItems[subidx]; + + if (sub->movement) { + point->x = sub->x; + point->y = sub->y; + } else { + point->x = 0; + point->y = 0; + } + } + } return point; } +int MGM::getStaticsIndexById(int idx, int16 id) { + for (uint i = 0; i < _items[idx]->statics.size(); i++) { + if (_items[idx]->statics[i]->_staticsId == id) + return i; + } + + return 0; +} + +void MGM::clearMovements2(int idx) { + _items[idx]->movements2.clear(); +} + +int MGM::recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop) { + warning("STUB: MGM::recalcOffsets()"); + + return 0; +} + MovGraphLink::MovGraphLink() { _distance = 0; _angle = 0; @@ -1712,15 +1835,15 @@ bool MovGraphReact::pointInRegion(int x, int y) { double xinters; Common::Point p, p1, p2; - p.x = (double)x; - p.y = (double)y; + p.x = x; + p.y = y; - p1.x = (double)_points[0]->x; - p1.y = (double)_points[0]->y; + p1.x = _points[0]->x; + p1.y = _points[0]->y; for (int i = 1; i <= _pointCount; i++) { - p2.x = (double)_points[i % _pointCount]->x; - p2.y = (double)_points[i % _pointCount]->y; + p2.x = _points[i % _pointCount]->x; + p2.y = _points[i % _pointCount]->y; if (p.y > MIN(p1.y, p2.y)) { if (p.y <= MAX(p1.y, p2.y)) { @@ -1745,10 +1868,10 @@ bool MovGraphReact::pointInRegion(int x, int y) { } int startWalkTo(int objId, int objKey, int x, int y, int a5) { - MctlCompound *mc = getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId); + MctlCompound *mc = getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId); if (mc) - return (mc->method34(g_fullpipe->_currentScene->getStaticANIObject1ById(objId, objKey), x, y, a5, 0) != 0); + return (mc->method34(g_fp->_currentScene->getStaticANIObject1ById(objId, objKey), x, y, a5, 0) != 0); return 0; } diff --git a/engines/fullpipe/motion.h b/engines/fullpipe/motion.h index b49fea55bc..24f047d76b 100644 --- a/engines/fullpipe/motion.h +++ b/engines/fullpipe/motion.h @@ -28,6 +28,7 @@ namespace Fullpipe { class Statics; class Movement; class MctlConnectionPoint; +class MovGraphLink; int startWalkTo(int objId, int objKey, int x, int y, int a5); int doSomeAnimation(int objId, int objKey, int a3); @@ -50,15 +51,18 @@ public: virtual int removeObject(StaticANIObject *obj) { return 0; } virtual void freeItems() {} virtual int method28() { return 0; } - virtual int method2C() { return 0; } + virtual int method2C(StaticANIObject *obj, int x, int y) { return 0; } virtual int method30() { return 0; } virtual MessageQueue *method34(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) { return 0; } virtual int changeCallback() { return 0; } - virtual int method3C() { return 0; } + virtual int method3C(StaticANIObject *ani, int flag) { return 0; } virtual int method40() { return 0; } virtual int method44() { return 0; } virtual int method48() { return -1; } virtual MessageQueue *doWalkTo(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) { return 0; } + + void enableLinks(const char *linkName, bool enable); + MovGraphLink *getLinkByName(const char *name); }; class MovGraphReact : public CObject { @@ -76,9 +80,7 @@ public: }; class MctlCompoundArrayItem : public CObject { - friend class MctlCompound; - -protected: +public: MotionController *_motionControllerObj; MovGraphReact *_movGraphReactObj; Common::Array<MctlConnectionPoint *> _connectionPoints; @@ -88,6 +90,7 @@ protected: public: MctlCompoundArrayItem() : _movGraphReactObj(0), _motionControllerObj(0), _field_20(0), _field_24(0), _field_28(0) {} + ~MctlCompoundArrayItem(); }; class MctlCompoundArray : public Common::Array<MctlCompoundArrayItem *>, public CObject { @@ -96,9 +99,9 @@ class MctlCompoundArray : public Common::Array<MctlCompoundArrayItem *>, public }; class MctlCompound : public MotionController { +public: MctlCompoundArray _motionControllers; - public: MctlCompound() { _objtype = kObjTypeMctlCompound; } virtual bool load(MfcArchive &file); @@ -111,10 +114,11 @@ class MctlCompound : public MotionController { void initMovGraph2(); MctlConnectionPoint *findClosestConnectionPoint(int ox, int oy, int destIndex, int connectionX, int connectionY, int sourceIndex, int *minDistancePtr); + void replaceNodeX(int from, int to); }; struct MGMSubItem { - int movement; + Movement *movement; int staticsIndex; int field_8; int field_C; @@ -146,6 +150,8 @@ struct MGMInfo { int x2; int y2; int flags; + + MGMInfo() { memset(this, 0, sizeof(MGMInfo)); } }; class MGM : public CObject { @@ -161,6 +167,9 @@ public: MessageQueue *genMovement(MGMInfo *mgminfo); void updateAnimStatics(StaticANIObject *ani, int staticsId); Common::Point *getPoint(Common::Point *point, int aniId, int staticsId1, int staticsId2); + int getStaticsIndexById(int idx, int16 id); + void clearMovements2(int idx); + int recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop); }; struct MctlLadderMovementVars { @@ -181,10 +190,10 @@ struct MctlLadderMovement { class MctlLadder : public MotionController { public: - int _objId; + int _ladderX; int _ladderY; int _ladder_field_14; - int _ladder_field_18; + int _width; int _height; int _ladder_field_20; int _ladder_field_24; @@ -202,6 +211,8 @@ public: virtual MessageQueue *method34(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); virtual MessageQueue *doWalkTo(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); + MessageQueue *controllerWalkTo(StaticANIObject *ani, int off); + private: int findObjectPos(StaticANIObject *obj); bool initMovement(StaticANIObject *ani, MctlLadderMovement *movement); @@ -309,10 +320,10 @@ public: virtual int removeObject(StaticANIObject *obj); virtual void freeItems(); virtual int method28(); - virtual int method2C(); + virtual int method2C(StaticANIObject *obj, int x, int y); virtual MessageQueue *method34(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); virtual int changeCallback(); - virtual int method3C(); + virtual int method3C(StaticANIObject *ani, int flag); virtual int method44(); virtual MessageQueue *doWalkTo(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); virtual int method50(); @@ -362,6 +373,10 @@ struct MovInfo1 { Common::Array<MovInfo1Sub *> items; int itemsCount; int flags; + + MovInfo1() { clear(); } + MovInfo1(MovInfo1 *src); + void clear(); }; struct MovGraph2Item { // 744 @@ -411,6 +426,9 @@ public: int16 _field_16; MessageQueue *_messageQueueObj; int _motionControllerObj; + + MctlConnectionPoint(); + ~MctlConnectionPoint(); }; } // End of namespace Fullpipe diff --git a/engines/fullpipe/ngiarchive.cpp b/engines/fullpipe/ngiarchive.cpp index 5d895c17a0..132f4758d3 100644 --- a/engines/fullpipe/ngiarchive.cpp +++ b/engines/fullpipe/ngiarchive.cpp @@ -91,7 +91,7 @@ NGIArchive::NGIArchive(const Common::String &filename) : _ngiFilename(filename) free(fat); - g_fullpipe->_currArchive = this; + g_fp->_currArchive = this; debug(0, "NGIArchive::NGIArchive(%s): Located %d files", filename.c_str(), _headers.size()); } @@ -103,7 +103,7 @@ NGIArchive::~NGIArchive() { delete it->_value; } - g_fullpipe->_currArchive = 0; + g_fp->_currArchive = 0; } bool NGIArchive::hasFile(const Common::String &name) const { diff --git a/engines/fullpipe/objectnames.h b/engines/fullpipe/objectnames.h index b8696ec672..87442d990a 100644 --- a/engines/fullpipe/objectnames.h +++ b/engines/fullpipe/objectnames.h @@ -30,7 +30,7 @@ namespace Fullpipe { #define sO_Grandma "\xc1\xe0\xe1\xf3\xeb\xff" // "Бабуля" #define sO_Jar_4 "\xc1\xe0\xed\xea\xe0_4" // "Банка_4" #define sO_Pool "\xc1\xe0\xf1\xf1\xe5\xe9\xed" // "Бассейн" -#define sO_TumyTrampie "\xc1\xe0\xf2\xf3\xf2\xe0" // "Батута" +#define sO_TummyTrampie "\xc1\xe0\xf2\xf3\xf2\xe0" // "Батута" #define sO_WithoutBoot "\xc1\xe5\xe7 \xe1\xee\xf2\xe8\xed\xea\xe0" // "Без ботинка" #define sO_WithoutJug "\xc1\xe5\xe7 \xe3\xee\xf0\xf8\xea\xee\xe2" // "Без горшков" #define sO_WithoutCarpet "\xc1\xe5\xe7 \xea\xee\xe2\xf0\xe8\xea\xe0" // "Без коврика" @@ -48,6 +48,10 @@ namespace Fullpipe { #define sO_InSock "\xc2 \xed\xee\xf1\xea\xe5" // "В носке" #define sO_InGlasses "\xc2 \xee\xf7\xea\xe0\xf5" // "В очках" #define sO_In_14 "\xc2_14" // "В_14" +#define sO_In_15 "\xc2_15" // "В_15" +#define sO_In_15_1 "\xc2_15_1" // "В_15_1" +#define sO_In_15_2 "\xc2_15_2" // "В_15_2" +#define sO_In_15_3 "\xc2_15_3" // "В_15_3" #define sO_In_32_Lies "\xc2_32 \xeb\xe5\xe6\xe8\xf2" // "В_32 лежит" #define sO_In_32_Stands "\xc2_32 \xf2\xee\xf0\xf7\xe8\xf2" // "В_32 торчит" #define sO_In_33 "\xc2_33" // "В_33" @@ -78,11 +82,11 @@ namespace Fullpipe { #define sO_Grandpa "\xc4\xe5\xe4\xf3\xf8\xea\xe0" // "Дедушка" #define sO_Plank_25 "\xc4\xee\xf1\xea\xe0_25" // "Доска_25" #define sO_Plank_34 "\xc4\xee\xf1\xea\xe0_34" // "Доска_34" -#define sO_DudeJumped "\xc4\xff\xe4\xff \xef\xf0\xfb\xe3\xe0\xeb" // "Дядя прыгал" +#define sO_DudeHasJumped "\xc4\xff\xe4\xff \xef\xf0\xfb\xe3\xe0\xeb" // "Дядя прыгал" #define sO_Dude "\xc4\xff\xe4\xff" // "Дядя" #define sO_GuvTheDrawer "\xc4\xff\xe4\xff-\xff\xf9\xe8\xea" // "Дядя-ящик" #define sO_DudeSwinged "\xc4\xff\xe4\xff_\xea\xe0\xf2\xe0\xeb\xf1\xff" // "Дядя_катался" -#define sO_Eats "\xc5\xf1\xf2" // "Ест" +#define sO_IsEating "\xc5\xf1\xf2" // "Ест" #define sO_Present "\xc5\xf1\xf2\xfc" // "Есть" #define sO_CloseThing1 "\xc7\xe0\xea\xf0\xfb\xe2\xe0\xe5\xec\xee\xe5 1" // "Закрываемое 1" #define sO_CloseThing2 "\xc7\xe0\xea\xf0\xfb\xe2\xe0\xe5\xec\xee\xe5 2" // "Закрываемое 2" @@ -94,11 +98,11 @@ namespace Fullpipe { #define sO_HalfFull "\xc7\xe0\xef\xee\xeb\xed\xe5\xed \xed\xe0\xef\xee\xeb\xee\xe2\xe8\xed\xf3" // "Заполнен наполовину" #define sO_Full "\xc7\xe0\xef\xee\xeb\xed\xe5\xed \xf6\xe5\xeb\xe8\xea\xee\xec" // "Заполнен целиком" #define sO_MirroredTo "\xc7\xe5\xf0\xea\xe0\xeb\xfc\xed\xe0\xff \xea" // "Зеркальная к" -#define sO_Playing "\xc8\xe3\xf0\xe0\xe5\xf2" // "Играет" +#define sO_IsPlaying "\xc8\xe3\xf0\xe0\xe5\xf2" // "Играет" #define sO_Tub "\xca\xe0\xe4\xea\xe0" // "Кадка" #define sO_Cactus "\xca\xe0\xea\xf2\xf3\xf1" // "Кактус" -#define sO_SwingingWithBoot "\xca\xe0\xf2\xe0\xe5\xf2\xf1\xff \xf1 \xe1\xee\xf2\xe8\xed\xea\xee\xec" // "Катается с ботинком" -#define sO_Swinging "\xca\xe0\xf2\xe0\xe5\xf2\xf1\xff" // "Катается" +#define sO_IsSwingingWithBoot "\xca\xe0\xf2\xe0\xe5\xf2\xf1\xff \xf1 \xe1\xee\xf2\xe8\xed\xea\xee\xec" // "Катается с ботинком" +#define sO_IsSwinging "\xca\xe0\xf2\xe0\xe5\xf2\xf1\xff" // "Катается" #define sO_Swingie "\xca\xe0\xf7\xe5\xeb\xe5\xed\xff" // "Качеленя" #define sO_LiftButtons "\xca\xed\xee\xef\xea\xe8 \xeb\xe8\xf4\xf2\xe0" // "Кнопки лифта" #define sO_Carpet_35 "\xca\xee\xe2\xf0\xe8\xea_35" // "Коврик_35" @@ -135,7 +139,7 @@ namespace Fullpipe { #define sO_NotGrown "\xcd\xe5 \xe2\xfb\xf0\xee\xf1" // "Не вырос" #define sO_DidNotCrackEgg "\xcd\xe5 \xea\xee\xeb\xee\xeb \xff\xe9\xf6\xee" // "Не колол яйцо" #define sO_NotFallen "\xcd\xe5 \xef\xe0\xe4\xe0\xeb" // "Не падал" -#define sO_NotAvailable "\xcd\xe5\xe4\xee\xf1\xf2\xf3\xef\xed\xe0" // "Недоступна" +#define sO_IsNotAvailable "\xcd\xe5\xe4\xee\xf1\xf2\xf3\xef\xed\xe0" // "Недоступна" #define sO_CannotTake "\xcd\xe5\xeb\xfc\xe7\xff \xe2\xe7\xff\xf2\xfc" // "Нельзя взять" #define sO_No "\xcd\xe5\xf2" // "Нет" #define sO_LowerHatch_23 "\xcd\xe8\xe6\xed\xe8\xe9 \xeb\xfe\xea_23" // "Нижний люк_23" @@ -168,8 +172,8 @@ namespace Fullpipe { #define sO_Empty "\xcf\xf3\xf1\xf2" // "Пуст" #define sO_EmptyShe "\xcf\xf3\xf1\xf2\xe0\xff" // "Пустая" #define sO_WayToPipe "\xcf\xf3\xf2\xfc \xea \xf2\xf0\xf3\xe1\xe5" // "Путь к трубе" -#define sO_Drinking "\xcf\xfc\xe5\xf2" // "Пьет" -#define sO_BrokenInPieces "\xd0\xe0\xe7\xe1\xe8\xf2\xe0" // "Разбита" +#define sO_IsDrinking "\xcf\xfc\xe5\xf2" // "Пьет" +#define sO_Broken "\xd0\xe0\xe7\xe1\xe8\xf2\xe0" // "Разбита" #define sO_Unblocked "\xd0\xe0\xe7\xe1\xeb\xee\xea\xe8\xf0\xee\xe2\xe0\xed" // "Разблокирован" #define sO_Unfolded "\xd0\xe0\xe7\xe2\xe5\xf0\xed\xf3\xf2" // "Развернут" #define sO_Jawcrucnher "\xd0\xee\xf2\xee\xf5\xf0\xf3\xf1" // "Ротохрус" @@ -197,16 +201,16 @@ namespace Fullpipe { #define sO_Sugar "\xd1\xe0\xf5\xe0\xf0\xee\xea" // "Сахарок" #define sO_Convoluted "\xd1\xe2\xe5\xf0\xed\xf3\xf2" // "Свернут" #define sO_IsFree "\xd1\xe2\xee\xe1\xee\xe4\xed\xe0" // "Свободна" -#define sO_Sitting "\xd1\xe8\xe4\xe8\xf2" // "Сидит" +#define sO_IsSitting "\xd1\xe8\xe4\xe8\xf2" // "Сидит" #define sO_Laughing "\xd1\xec\xe5\xe5\xf2\xf1\xff" // "Смеется" #define sO_WithEveryone "\xd1\xee \xe2\xf1\xe5\xec\xe8" // "Со всеми" #define sO_WithMop "\xd1\xee \xf8\xe2\xe0\xe1\xf0\xee\xe9" // "Со шваброй" #define sO_WithHose "\xd1\xee \xf8\xeb\xe0\xed\xe3\xee\xec" // "Со шлангом" #define sO_WithBrush "\xd1\xee \xf9\xe5\xf2\xea\xee\xe9" // "Со щеткой" -#define sO_Sleeping "\xd1\xef\xe8\xf2" // "Спит" +#define sO_IsSleeping "\xd1\xef\xe8\xf2" // "Спит" #define sO_OnRight "\xd1\xef\xf0\xe0\xe2\xe0" // "Справа" -#define sO_StandsInBoots "\xd1\xf2\xee\xe8\xf2 \xe2 \xe1\xee\xf2\xe8\xed\xea\xe0\xf5" // "Стоит в ботинках" -#define sO_StandsInCorner "\xd1\xf2\xee\xe8\xf2 \xe2 \xf3\xe3\xeb\xf3" // "Стоит в углу" +#define sO_IsStandingInBoots "\xd1\xf2\xee\xe8\xf2 \xe2 \xe1\xee\xf2\xe8\xed\xea\xe0\xf5" // "Стоит в ботинках" +#define sO_IsStandingInCorner "\xd1\xf2\xee\xe8\xf2 \xe2 \xf3\xe3\xeb\xf3" // "Стоит в углу" #define sO_Guardian "\xd1\xf2\xee\xf0\xee\xe6" // "Сторож" #define sO_Guard_1 "\xd1\xf2\xf0\xe0\xe6 1" // "Страж 1" #define sO_Gurad_2 "\xd1\xf2\xf0\xe0\xe6 2" // "Страж 2" @@ -222,11 +226,11 @@ namespace Fullpipe { #define sO_NearPipe "\xd3 \xf2\xf0\xf3\xe1\xfb" // "У трубы" #define sO_Janitors "\xd3\xe1\xee\xf0\xf9\xe8\xea\xe8" // "Уборщики" #define sO_Janitress "\xd3\xe1\xee\xf0\xf9\xe8\xf6\xe0" // "Уборщица" -#define sO_Gone "\xd3\xe5\xf5\xe0\xeb\xe0" // "Уехала" +#define sO_IsGone "\xd3\xe5\xf5\xe0\xeb\xe0" // "Уехала" #define sO_FallenOnce "\xd3\xef\xe0\xeb \xf0\xe0\xe7" // "Упал раз" #define sO_FallenBrush "\xd3\xef\xe0\xeb\xe0 \xf9\xe5\xf2\xea\xe0" // "Упала щетка" #define sO_NotBroken "\xd6\xe5\xeb\xe0" // "Цела" -#define sO_ScratchingBelly "\xd7\xe5\xf8\xe5\xf2 \xef\xf3\xe7\xee" // "Чешет пузо" +#define sO_IsScratchingBelly "\xd7\xe5\xf8\xe5\xf2 \xef\xf3\xe7\xee" // "Чешет пузо" #define sO_Level0 "\xdd\xf2\xe0\xe6 0" // "Этаж 0" #define sO_Level1 "\xdd\xf2\xe0\xe6 1" // "Этаж 1" #define sO_Level2 "\xdd\xf2\xe0\xe6 2" // "Этаж 2" diff --git a/engines/fullpipe/scene.cpp b/engines/fullpipe/scene.cpp index a5a286cfcb..558a90978a 100644 --- a/engines/fullpipe/scene.cpp +++ b/engines/fullpipe/scene.cpp @@ -114,7 +114,7 @@ void SceneTag::loadScene() { delete file; - g_fullpipe->_currArchive = 0; + g_fp->_currArchive = 0; free(fname); free(archname); @@ -146,7 +146,7 @@ bool Scene::load(MfcArchive &file) { int aniNum = file.readUint16LE(); char *aniname = genFileName(0, aniNum, "ani"); - Common::SeekableReadStream *f = g_fullpipe->_currArchive->createReadStreamForMember(aniname); + Common::SeekableReadStream *f = g_fp->_currArchive->createReadStreamForMember(aniname); StaticANIObject *ani = new StaticANIObject(); @@ -168,7 +168,7 @@ bool Scene::load(MfcArchive &file) { int qNum = file.readUint16LE(); char *qname = genFileName(0, qNum, "qu"); - Common::SeekableReadStream *f = g_fullpipe->_currArchive->createReadStreamForMember(qname); + Common::SeekableReadStream *f = g_fp->_currArchive->createReadStreamForMember(qname); MfcArchive archive(f); archive.readUint16LE(); // Skip 2 bytes @@ -191,7 +191,7 @@ bool Scene::load(MfcArchive &file) { assert(0); } - _libHandle = g_fullpipe->_currArchive; + _libHandle = g_fp->_currArchive; if (_picObjList.size() > 0 && _bgname && strlen(_bgname) > 1) { char fname[260]; @@ -216,10 +216,10 @@ bool Scene::load(MfcArchive &file) { char *slsname = genFileName(0, _sceneId, "sls"); - if (g_fullpipe->_soundEnabled) { + if (g_fp->_soundEnabled) { _soundList = new SoundList(); - if (g_fullpipe->_flgSoundList) { + if (g_fp->_flgSoundList) { char *nlname = genFileName(17, _sceneId, "nl"); _soundList->loadFile(slsname, nlname); @@ -249,7 +249,7 @@ void Scene::init() { _x = 0; _y = 0; - g_fullpipe->_sceneRect.moveTo(0, 0); + g_fp->_sceneRect.moveTo(0, 0); for (uint i = 0; i < _picObjList.size(); i++) ((PictureObject *)_picObjList[i])->clearFlags(); @@ -398,7 +398,7 @@ void Scene::preloadMovements(GameVar *var) { } void Scene::initObjectCursors(const char *varname) { - GameVar *cursorsVar = g_fullpipe->getGameLoaderGameVar()->getSubVarByName(varname)->getSubVarByName("CURSORS"); + GameVar *cursorsVar = g_fp->getGameLoaderGameVar()->getSubVarByName(varname)->getSubVarByName("CURSORS"); if (!cursorsVar || !cursorsVar->_subVars) return; @@ -417,10 +417,10 @@ void Scene::initObjectCursors(const char *varname) { } } - g_fullpipe->_minCursorId = minId; - g_fullpipe->_maxCursorId = maxId; + g_fp->_minCursorId = minId; + g_fp->_maxCursorId = maxId; - g_fullpipe->_objectIdCursors.resize(maxId - minId + 1); + g_fp->_objectIdCursors.resize(maxId - minId + 1); for (GameVar *sub = cursorsVar->_subVars; sub; sub = sub->_nextVarObj) { GameObject *obj = getPictureObjectByName(sub->_varName, -1); @@ -431,7 +431,7 @@ void Scene::initObjectCursors(const char *varname) { PictureObject *pic = getGameLoaderInventory()->getScene()->getPictureObjectByName(sub->_value.stringValue, -1); if (obj && pic) - g_fullpipe->_objectIdCursors[obj->_id - minId] = pic->_id; + g_fp->_objectIdCursors[obj->_id - minId] = pic->_id; } } @@ -451,7 +451,7 @@ void Scene::draw() { updateScrolling(); // Clean previous stuff - g_fullpipe->_backgroundSurface.fillRect(Common::Rect(0, 0, 800, 600), 0); + g_fp->_backgroundSurface.fillRect(Common::Rect(0, 0, 800, 600), 0); drawContent(60000, 0, true); @@ -474,7 +474,7 @@ void Scene::draw() { void Scene::updateScrolling() { if (_messageQueueId && !_x && !_y) { - MessageQueue *mq = g_fullpipe->_globalMessageQueueList->getMessageQueueById(_messageQueueId); + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(_messageQueueId); if (mq) mq->update(); @@ -487,31 +487,31 @@ void Scene::updateScrolling() { int offsetY = 0; if (_x < 0) { - if (!g_fullpipe->_sceneRect.left && !(((PictureObject *)_picObjList[0])->_flags & 2)) + if (!g_fp->_sceneRect.left && !(((PictureObject *)_picObjList[0])->_flags & 2)) _x = 0; - if (_x <= -g_fullpipe->_scrollSpeed) { - offsetX = -g_fullpipe->_scrollSpeed; - _x += g_fullpipe->_scrollSpeed; + if (_x <= -g_fp->_scrollSpeed) { + offsetX = -g_fp->_scrollSpeed; + _x += g_fp->_scrollSpeed; } - } else if (_x >= g_fullpipe->_scrollSpeed) { - offsetX = g_fullpipe->_scrollSpeed; - _x -= g_fullpipe->_scrollSpeed; + } else if (_x >= g_fp->_scrollSpeed) { + offsetX = g_fp->_scrollSpeed; + _x -= g_fp->_scrollSpeed; } else { _x = 0; } if (_y > 0) { - offsetY = g_fullpipe->_scrollSpeed; - _y -= g_fullpipe->_scrollSpeed; + offsetY = g_fp->_scrollSpeed; + _y -= g_fp->_scrollSpeed; } if (_y < 0) { - offsetY -= g_fullpipe->_scrollSpeed; - _y += g_fullpipe->_scrollSpeed; + offsetY -= g_fp->_scrollSpeed; + _y += g_fp->_scrollSpeed; } - g_fullpipe->_sceneRect.translate(offsetX, offsetY); + g_fp->_sceneRect.translate(offsetX, offsetY); } updateScrolling2(); @@ -527,19 +527,19 @@ void Scene::updateScrolling2() { int flags = ((PictureObject *)_picObjList[0])->_flags; - if (g_fullpipe->_sceneRect.left < 0 && !(flags & 2)) - offsetX = -g_fullpipe->_sceneRect.left; + if (g_fp->_sceneRect.left < 0 && !(flags & 2)) + offsetX = -g_fp->_sceneRect.left; - if (g_fullpipe->_sceneRect.top < 0 && !(flags & 0x20)) - offsetY = -g_fullpipe->_sceneRect.top; + if (g_fp->_sceneRect.top < 0 && !(flags & 0x20)) + offsetY = -g_fp->_sceneRect.top; - if (g_fullpipe->_sceneRect.right > point.x - 1 && g_fullpipe->_sceneRect.left > 0 && !(flags & 2)) - offsetX = point.x - g_fullpipe->_sceneRect.right - 1; + if (g_fp->_sceneRect.right > point.x - 1 && g_fp->_sceneRect.left > 0 && !(flags & 2)) + offsetX = point.x - g_fp->_sceneRect.right - 1; - if (g_fullpipe->_sceneRect.bottom > point.y - 1 && g_fullpipe->_sceneRect.top > 0 && !(flags & 0x20)) - offsetY = point.y - g_fullpipe->_sceneRect.bottom - 1; + if (g_fp->_sceneRect.bottom > point.y - 1 && g_fp->_sceneRect.top > 0 && !(flags & 0x20)) + offsetY = point.y - g_fp->_sceneRect.bottom - 1; - g_fullpipe->_sceneRect.translate(offsetX, offsetY); + g_fp->_sceneRect.translate(offsetX, offsetY); } } @@ -602,7 +602,7 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { return; if (_palette) { - g_fullpipe->_globalPalette = _palette->_data; + g_fp->_globalPalette = _palette->_data; } debug(8, "Scene::drawContent(>%d, <%d, %d)", minPri, maxPri, drawBg); @@ -635,7 +635,7 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { debug(8, "w2: %d h2:%d", point.x, point.y); - int bgStX = g_fullpipe->_sceneRect.left % point.x; + int bgStX = g_fp->_sceneRect.left % point.x; if (bgStX < 0) bgStX += point.x; @@ -643,7 +643,7 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { int bgNumX = bgStX / width; int bgOffsetX = bgStX % width; - int bgStY = g_fullpipe->_sceneRect.top % point.y; + int bgStY = g_fp->_sceneRect.top % point.y; if (bgStY < 0) bgStY += point.y; @@ -651,12 +651,12 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { int bgNumY = bgStY / height; int bgOffsetY = bgStY % height; - int bgPosX = g_fullpipe->_sceneRect.left - bgOffsetX; + int bgPosX = g_fp->_sceneRect.left - bgOffsetX; - if (bgPosX < g_fullpipe->_sceneRect.right - 1) { + if (bgPosX < g_fp->_sceneRect.right - 1) { while (1) { int v25 = bgNumY; - for (int y = g_fullpipe->_sceneRect.top - bgOffsetY; y < g_fullpipe->_sceneRect.bottom - 1;) { + for (int y = g_fp->_sceneRect.top - bgOffsetY; y < g_fp->_sceneRect.bottom - 1;) { BigPicture *v27 = _bigPictureArray[bgNumX][v25]; v27->draw(bgPosX, y, 0, 0); y += v27->getDimensions(&point)->y; @@ -678,7 +678,7 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { break; bgNumX = 0; } - if (oldx >= g_fullpipe->_sceneRect.right - 1) + if (oldx >= g_fp->_sceneRect.right - 1) break; } } @@ -703,22 +703,22 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { int height = point.y; if (obj->_flags & 8) { - while (objX > g_fullpipe->_sceneRect.right) { + while (objX > g_fp->_sceneRect.right) { objX -= width; obj->setOXY(objX, objY); } - for (int j = width + objX; width + objX < g_fullpipe->_sceneRect.left; j = width + objX) { + for (int j = width + objX; width + objX < g_fp->_sceneRect.left; j = width + objX) { objX = j; obj->setOXY(j, objY); } } if (obj->_flags & 0x10) { - while (objY > g_fullpipe->_sceneRect.bottom) { + while (objY > g_fp->_sceneRect.bottom) { objY -= height; obj->setOXY(objX, objY); } - for (int j = objY + height; objY + height < g_fullpipe->_sceneRect.top; j = objY + height) { + for (int j = objY + height; objY + height < g_fp->_sceneRect.top; j = objY + height) { objY = j; obj->setOXY(objX, j); } @@ -727,12 +727,12 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { obj->draw(); if (obj->_flags & 2) { - if (objX > g_fullpipe->_sceneRect.left) { + if (objX > g_fp->_sceneRect.left) { obj->setOXY(objX - width, objY); obj->draw(); obj->setOXY(objX, objY); } - if (width + objX < g_fullpipe->_sceneRect.right) { + if (width + objX < g_fp->_sceneRect.right) { obj->setOXY(width + objX, objY); obj->draw(); obj->setOXY(objX, objY); @@ -740,12 +740,12 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { } if (obj->_flags & 0x20) { - if (objY > g_fullpipe->_sceneRect.top) { + if (objY > g_fp->_sceneRect.top) { obj->setOXY(objX, objY - height); obj->draw(); obj->setOXY(objX, objY); } - if (height + objY < g_fullpipe->_sceneRect.bottom) { + if (height + objY < g_fp->_sceneRect.bottom) { obj->setOXY(objX, height + objY); obj->draw(); obj->setOXY(objX, objY); diff --git a/engines/fullpipe/scenes.cpp b/engines/fullpipe/scenes.cpp index 37d1250ae0..96d9cba54f 100644 --- a/engines/fullpipe/scenes.cpp +++ b/engines/fullpipe/scenes.cpp @@ -80,29 +80,120 @@ Vars::Vars() { scene04_dudePosX = 0; scene04_dudePosY = 0; - scene04_var02 = 0; - scene04_var04 = 0; + scene04_bottleIsTaken = false; + scene04_kozyawkaOnLadder = false; scene04_walkingKozyawka = 0; scene04_bottleWeight = 0; - scene04_var07 = 0; - scene04_var08 = 0; - scene04_var09 = 0; - scene04_var10 = 0; - scene04_var11 = 0; - scene04_var12 = 0; - scene04_var13 = 0; - scene04_var14 = 0; - scene04_var15 = 0; + scene04_var07 = false; + scene04_ladderClickable = false; + scene04_handIsDown = false; + scene04_dudeInBottle = false; + scene04_kozHeadRaised = false; + scene04_bottleIsDropped = false; + scene04_bigBallIn = false; + scene04_bigBallCounter = 0; + scene04_bigBallFromLeft = false; scene04_speakerVariant = 0; scene04_speakerPhase = 0; - scene04_var18 = 0; - scene04_var19 = 0; - scene04_var20 = 0; - scene04_var24 = 0; - scene04_var25 = 0; + scene04_clockCanGo = false; + scene04_objectIsTaken = false; + scene04_springOffset = 0; + scene04_lastKozyawka = 0; + scene04_springDelay = 0; scene04_bottleY = 0; scene04_ladderOffset = 0; + scene05_handle = 0; + scene05_wacko = 0; + scene05_bigHatch = 0; + scene05_wackoTicker = 0; + scene05_handleFlipper = 0; + scene05_floatersTicker = 0; + + scene06_manX = 0; + scene06_manY = 0; + scene06_ballX = 0; + scene06_ballY = 0; + scene06_mumsy = 0; + scene06_someBall = 0; + scene06_invHandle = 0; + scene06_liftButton = 0; + scene06_ballDrop = 0; + scene06_arcadeEnabled = false; + scene06_aimingBall = false; + scene06_currentBall = 0; + scene06_ballInHands = 0; + scene06_flyingBall = 0; + scene06_numBallsGiven = 0; + scene06_mumsyNumBalls = 0; + scene06_eggieTimeout = 0; + scene06_eggieDirection = true; + scene06_mumsyGotBall = 0; + scene06_ballDeltaX = 0; + scene06_ballDeltaY = 0; + scene06_sceneClickX = 0; + scene06_sceneClickY = 0; + scene06_mumsyPos = 0; + scene06_mumsyJumpBk = 0; + scene06_mumsyJumpFw = 0; + scene06_mumsyJumpBkPercent = 0; + scene06_mumsyJumpFwPercent = 0; + + scene07_lukeAnim = 0; + scene07_lukePercent = 0; + scene07_plusMinus = 0; + + scene08_batuta = 0; + scene08_vmyats = 0; + scene08_clock = 0; + scene08_inAir = false; + scene08_flyingUp = false; + scene08_onBelly = false; + scene08_stairsOffset = -37; + scene08_snoringCountdown = -1; + scene08_inArcade = false; + scene08_stairsVisible = true; + scene08_manOffsetY = 0; + + scene10_gum = 0; + scene10_packet = 0; + scene10_packet2 = 0; + scene10_inflater = 0; + scene10_ladder = 0; + scene10_hasGum = 0; + + scene11_swingie = 0; + scene11_boots = 0; + scene11_dudeOnSwing = 0; + scene11_hint = 0; + scene11_var02 = 0; + scene11_var03 = 0; + scene11_var04 = 0; + scene11_var05 = 0; + scene11_var06 = 0; + scene11_var07 = 0; + scene11_var08 = 1.0; + scene11_var09 = 1.0; + scene11_var10 = 1.0; + scene11_var11 = 1.0; + scene11_var12 = 0.0; + scene11_var13 = 0; + scene11_var14 = 0; + scene11_var15 = 0; + scene11_var16 = 0; + scene11_var17 = 0; + scene11_var18 = 0; + scene11_var19 = 0; + scene11_var20 = 0; + + scene12_fly = 0; + scene12_flyCountdown = 0; + + scene15_chantingCountdown = 0; + scene15_plusminus = 0; + scene15_ladder = 0; + scene15_boot = 0; + selector = 0; } @@ -123,6 +214,15 @@ int FullpipeEngine::convertScene(int scene) { return scenes[scene - 1]; } +int FullpipeEngine::getSceneFromTag(int tag) { + for (int i = 0; i < ARRAYSIZE(scenes); i++) { + if (scenes[i] == tag) + return i + 1; + } + + return 1; +} + bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { GameVar *sceneVar; Common::Point sceneDim; @@ -265,7 +365,6 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { _updateCursorCallback = scene04_updateCursor; break; -#if 0 case SC_5: sceneVar = _gameLoader->_gameVar->getSubVarByName("SC_5"); scene->preloadMovements(sceneVar); @@ -284,7 +383,7 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { _behaviorManager->initBehavior(scene, sceneVar); scene->initObjectCursors("SC_6"); setSceneMusicParameters(sceneVar); - sub_415300(); + scene06_initMumsy(); insertMessageHandler(sceneHandler06, 2, 2); _updateCursorCallback = scene06_updateCursor; break; @@ -307,11 +406,12 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { _behaviorManager->initBehavior(scene, sceneVar); scene->initObjectCursors("SC_8"); setSceneMusicParameters(sceneVar); - sub_416890(); + scene08_setupMusic(); addMessageHandler(sceneHandler08, 2); _updateCursorCallback = scene08_updateCursor; break; +#if 0 case SC_9: sceneVar = _gameLoader->_gameVar->getSubVarByName("SC_9"); scene->preloadMovements(sceneVar); @@ -322,6 +422,7 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { insertMessageHandler(sceneHandler09, 2, 2); _updateCursorCallback = scene09_updateCursor; break; +#endif case SC_10: sceneVar = _gameLoader->_gameVar->getSubVarByName("SC_10"); @@ -334,6 +435,7 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { _updateCursorCallback = scene10_updateCursor; break; +#if 0 case SC_11: sceneVar = _gameLoader->_gameVar->getSubVarByName("SC_11"); scene->preloadMovements(sceneVar); @@ -342,9 +444,10 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { scene->initObjectCursors("SC_11"); setSceneMusicParameters(sceneVar); insertMessageHandler(sceneHandler11, 2, 2); - scene11_sub_41A980(); + scene11_setupMusic(); _updateCursorCallback = scene11_updateCursor; break; +#endif case SC_12: sceneVar = _gameLoader->_gameVar->getSubVarByName("SC_12"); @@ -357,6 +460,7 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { _updateCursorCallback = defaultUpdateCursor; break; +#if 0 case SC_13: sceneVar = _gameLoader->_gameVar->getSubVarByName("SC_13"); scene->preloadMovements(sceneVar); @@ -379,6 +483,7 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { scene14_sub_41D2B0(); _updateCursorCallback = scene14_updateCursor; break; +#endif case SC_15: sceneVar = _gameLoader->_gameVar->getSubVarByName("SC_15"); @@ -391,6 +496,7 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { _updateCursorCallback = scene15_updateCursor; break; +#if 0 case SC_16: sceneVar = _gameLoader->_gameVar->getSubVarByName("SC_16"); scene->preloadMovements(sceneVar); @@ -695,6 +801,8 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { default: _behaviorManager->initBehavior(0, 0); + + error("Unknown scene %d", entrance->_sceneId); break; } @@ -702,29 +810,9 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { } int defaultUpdateCursor() { - g_fullpipe->updateCursorCommon(); - - return g_fullpipe->_cursorId; -} - -void FullpipeEngine::initArcadeKeys(const char *varname) { - GameVar *var = getGameLoaderGameVar()->getSubVarByName(varname)->getSubVarByName("KEYPOS"); - - if (!var) - return; + g_fp->updateCursorCommon(); - int cnt = var->getSubVarsCount(); - - for (int i = 0; i < cnt; i++) { - Common::Point *point = new Common::Point; - - GameVar *sub = var->getSubVarByIndex(i); - - point->x = sub->getSubVarAsInt("X"); - point->y = sub->getSubVarAsInt("Y"); - - _arcadeKeys.push_back(point); - } + return g_fp->_cursorId; } void FullpipeEngine::processArcade(ExCommand *ex) { diff --git a/engines/fullpipe/scenes.h b/engines/fullpipe/scenes.h index 38f685e82a..270c2038b0 100644 --- a/engines/fullpipe/scenes.h +++ b/engines/fullpipe/scenes.h @@ -25,8 +25,10 @@ namespace Fullpipe { +struct BehaviorEntryInfo; class StaticANIObject; - class MctlLadder; +class MctlLadder; +class MGM; int defaultUpdateCursor(); @@ -50,6 +52,33 @@ int scene04_updateCursor(); void scene04_initScene(Scene *sc); int sceneHandler04(ExCommand *cmd); +void scene05_initScene(Scene *sc); +int sceneHandler05(ExCommand *cmd); + +void scene06_initScene(Scene *sc); +void scene06_initMumsy(); +int sceneHandler06(ExCommand *cmd); +int scene06_updateCursor(); + +void scene07_initScene(Scene *sc); +int sceneHandler07(ExCommand *cmd); + +void scene08_initScene(Scene *sc); +void scene08_setupMusic(); +int sceneHandler08(ExCommand *cmd); +int scene08_updateCursor(); + +void scene10_initScene(Scene *sc); +int sceneHandler10(ExCommand *cmd); +int scene10_updateCursor(); + +void scene12_initScene(Scene *sc); +int sceneHandler12(ExCommand *ex); + +int scene15_updateCursor(); +void scene15_initScene(Scene *sc); +int sceneHandler15(ExCommand *cmd); + void sceneDbgMenu_initScene(Scene *sc); int sceneHandlerDbgMenu(ExCommand *cmd); @@ -113,23 +142,116 @@ public: int scene04_speakerVariant; int scene04_speakerPhase; - int scene04_var02; - int scene04_var04; + bool scene04_bottleIsTaken; + bool scene04_kozyawkaOnLadder; int scene04_bottleWeight; - int scene04_var07; - int scene04_var08; - int scene04_var09; - int scene04_var10; - int scene04_var11; - int scene04_var12; - int scene04_var13; - int scene04_var14; - int scene04_var15; - int scene04_var18; - int scene04_var19; - int scene04_var20; - StaticANIObject *scene04_var24; - int scene04_var25; + bool scene04_var07; + bool scene04_ladderClickable; + bool scene04_handIsDown; + bool scene04_dudeInBottle; + bool scene04_kozHeadRaised; + bool scene04_bottleIsDropped; + bool scene04_bigBallIn; + int scene04_bigBallCounter; + bool scene04_bigBallFromLeft; + bool scene04_clockCanGo; + bool scene04_objectIsTaken; + int scene04_springOffset; + StaticANIObject *scene04_lastKozyawka; + int scene04_springDelay; + + StaticANIObject *scene05_handle; + StaticANIObject *scene05_wacko; + StaticANIObject *scene05_bigHatch; + int scene05_wackoTicker; + int scene05_handleFlipper; + int scene05_floatersTicker; + + StaticANIObject *scene06_mumsy; + int scene06_manX; + int scene06_manY; + int scene06_ballX; + int scene06_ballY; + StaticANIObject *scene06_someBall; + StaticANIObject *scene06_invHandle; + StaticANIObject *scene06_liftButton; + StaticANIObject *scene06_ballDrop; + bool scene06_arcadeEnabled; + bool scene06_aimingBall; + StaticANIObject *scene06_currentBall; + StaticANIObject *scene06_ballInHands; + StaticANIObject *scene06_flyingBall; + Common::Array<StaticANIObject *> scene06_balls; + int scene06_numBallsGiven; + int scene06_mumsyNumBalls; + int scene06_eggieTimeout; + int scene06_eggieDirection; + int scene06_mumsyGotBall; + int scene06_ballDeltaX; + int scene06_ballDeltaY; + int scene06_sceneClickX; + int scene06_sceneClickY; + int scene06_mumsyPos; + BehaviorEntryInfo *scene06_mumsyJumpBk; + BehaviorEntryInfo *scene06_mumsyJumpFw; + int scene06_mumsyJumpBkPercent; + int scene06_mumsyJumpFwPercent; + + BehaviorEntryInfo *scene07_lukeAnim; + int scene07_lukePercent; + StaticANIObject *scene07_plusMinus; + + StaticANIObject *scene08_batuta; + StaticANIObject *scene08_vmyats; + StaticANIObject *scene08_clock; + bool scene08_inAir; + bool scene08_flyingUp; + int scene08_onBelly; + int scene08_stairsOffset; + int scene08_snoringCountdown; + bool scene08_inArcade; + bool scene08_stairsVisible; + int scene08_manOffsetY; + + StaticANIObject *scene10_gum; + StaticANIObject *scene10_packet; + StaticANIObject *scene10_packet2; + StaticANIObject *scene10_inflater; + PictureObject *scene10_ladder; + int scene10_hasGum; + + StaticANIObject *scene11_swingie; + StaticANIObject *scene11_boots; + StaticANIObject *scene11_dudeOnSwing; + PictureObject *scene11_hint; + MGM scene11_var01; + int scene11_var02; + int scene11_var03; + int scene11_var04; + int scene11_var05; + int scene11_var06; + int scene11_var07; + double scene11_var08; + double scene11_var09; + double scene11_var10; + double scene11_var11; + double scene11_var12; + int scene11_var13; + int scene11_var14; + int scene11_var15; + int scene11_var16; + int scene11_var17; + int scene11_var18; + int scene11_var19; + int scene11_var20; + + int scene12_fly; + int scene12_flyCountdown; + + int scene15_chantingCountdown; + StaticANIObject *scene15_plusminus; + PictureObject *scene15_ladder; + StaticANIObject *scene15_boot; PictureObject *selector; }; diff --git a/engines/fullpipe/scenes/scene01.cpp b/engines/fullpipe/scenes/scene01.cpp index 4181bbffe3..6c8f26d209 100644 --- a/engines/fullpipe/scenes/scene01.cpp +++ b/engines/fullpipe/scenes/scene01.cpp @@ -26,6 +26,7 @@ #include "fullpipe/constants.h" #include "fullpipe/gameloader.h" +#include "fullpipe/motion.h" #include "fullpipe/scenes.h" #include "fullpipe/statics.h" @@ -36,7 +37,7 @@ namespace Fullpipe { void scene01_fixEntrance() { - GameVar *var = g_fullpipe->getGameLoaderGameVar()->getSubVarByName("OBJSTATES")->getSubVarByName("SAVEGAME"); + GameVar *var = g_fp->getGameLoaderGameVar()->getSubVarByName("OBJSTATES")->getSubVarByName("SAVEGAME"); if (var->getSubVarAsInt("Entrance") == TrubaLeft) var->setSubVarAsInt("Entrance", TrubaRight); } @@ -48,7 +49,7 @@ void scene01_initScene(Scene *sc, int entrance) { g_vars->scene01_picSc01Osk2 = sc->getPictureObjectById(PIC_SC1_OSK2, 0); g_vars->scene01_picSc01Osk2->_flags &= 0xFFFB; - if (g_fullpipe->getObjectState(sO_EggCracker) == g_fullpipe->getObjectEnumState(sO_EggCracker, sO_DidNotCrackEgg)) { + if (g_fp->getObjectState(sO_EggCracker) == g_fp->getObjectEnumState(sO_EggCracker, sO_DidNotCrackEgg)) { PictureObject *pic = sc->getPictureObjectById(PIC_SC1_KUCHKA, 0); if (pic) pic->_flags &= 0xFFFB; @@ -60,7 +61,7 @@ void scene01_initScene(Scene *sc, int entrance) { bootAnim->_flags &= ~0x04; } - g_fullpipe->lift_setButton(sO_Level2, ST_LBN_2N); + g_fp->lift_setButton(sO_Level2, ST_LBN_2N); } int sceneHandler01(ExCommand *cmd) { @@ -71,7 +72,7 @@ int sceneHandler01(ExCommand *cmd) { if (cmd->_messageNum > MSG_SC1_SHOWOSK) { if (cmd->_messageNum == MSG_SC1_UTRUBACLICK) - handleObjectInteraction(g_fullpipe->_aniMan, g_fullpipe->_currentScene->getPictureObjectById(PIC_SC1_LADDER, 0), 0); + handleObjectInteraction(g_fp->_aniMan, g_fp->_currentScene->getPictureObjectById(PIC_SC1_LADDER, 0), 0); return 0; } @@ -97,19 +98,19 @@ int sceneHandler01(ExCommand *cmd) { return 0; } - if (g_fullpipe->_aniMan2) { - if (g_fullpipe->_aniMan2->_ox < g_fullpipe->_sceneRect.left + 200) { - g_fullpipe->_currentScene->_x = g_fullpipe->_aniMan2->_ox - g_fullpipe->_sceneRect.left - 300; + if (g_fp->_aniMan2) { + if (g_fp->_aniMan2->_ox < g_fp->_sceneRect.left + 200) { + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.left - 300; } - if (g_fullpipe->_aniMan2->_ox > g_fullpipe->_sceneRect.right - 200) - g_fullpipe->_currentScene->_x = g_fullpipe->_aniMan2->_ox - g_fullpipe->_sceneRect.right + 300; + if (g_fp->_aniMan2->_ox > g_fp->_sceneRect.right - 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.right + 300; res = 1; } - g_fullpipe->_behaviorManager->updateBehaviors(); + g_fp->_behaviorManager->updateBehaviors(); - g_fullpipe->startSceneTrack(); + g_fp->startSceneTrack(); return res; } diff --git a/engines/fullpipe/scenes/scene02.cpp b/engines/fullpipe/scenes/scene02.cpp index dd01af4c4b..95cf1df7dd 100644 --- a/engines/fullpipe/scenes/scene02.cpp +++ b/engines/fullpipe/scenes/scene02.cpp @@ -26,6 +26,7 @@ #include "fullpipe/constants.h" #include "fullpipe/gameloader.h" +#include "fullpipe/motion.h" #include "fullpipe/scenes.h" #include "fullpipe/statics.h" @@ -39,12 +40,12 @@ namespace Fullpipe { void scene02_initScene(Scene *sc) { g_vars->scene02_guvTheDrawer = sc->getStaticANIObject1ById(ANI_DADAYASHIK, -1); - if (g_fullpipe->getObjectState(sO_GuvTheDrawer) == g_fullpipe->getObjectEnumState(sO_GuvTheDrawer, sO_Sleeping)) { - Scene *s = g_fullpipe->_currentScene; + if (g_fp->getObjectState(sO_GuvTheDrawer) == g_fp->getObjectEnumState(sO_GuvTheDrawer, sO_IsSleeping)) { + Scene *s = g_fp->_currentScene; - g_fullpipe->_currentScene = sc; + g_fp->_currentScene = sc; g_vars->scene02_guvTheDrawer->changeStatics2(ST_DYAS_LIES); - g_fullpipe->_currentScene = s; + g_fp->_currentScene = s; } g_vars->scene02_boxDelay = 0; @@ -55,23 +56,23 @@ void scene02_initScene(Scene *sc) { g_vars->scene02_boxOpen = false; } else { g_vars->scene02_boxOpen = true; - g_vars->scene02_boxDelay = 100 * g_fullpipe->_rnd->getRandomNumber(32767) + 150; + g_vars->scene02_boxDelay = 100 * g_fp->_rnd->getRandomNumber(32767) + 150; } - g_fullpipe->_floaters->init(g_fullpipe->_gameLoader->_gameVar->getSubVarByName("SC_2")); + g_fp->_floaters->init(g_fp->_gameLoader->_gameVar->getSubVarByName("SC_2")); } void sceneHandler02_ladderClick() { - handleObjectInteraction(g_fullpipe->_aniMan2, g_fullpipe->_currentScene->getPictureObjectById(PIC_SC2_DTRUBA, 0), 0); + handleObjectInteraction(g_fp->_aniMan2, g_fp->_currentScene->getPictureObjectById(PIC_SC2_DTRUBA, 0), 0); } void sceneHandler02_showLadder() { - g_fullpipe->_currentScene->getPictureObjectById(PIC_SC2_LADDER, 0)->_flags |= 4; + g_fp->_currentScene->getPictureObjectById(PIC_SC2_LADDER, 0)->_flags |= 4; } void sceneHandler02_hideLadder() { - g_fullpipe->_currentScene->getPictureObjectById(PIC_SC2_LADDER, 0)->_flags &= 0xfffb; - g_fullpipe->_aniMan2->_priority = 25; + g_fp->_currentScene->getPictureObjectById(PIC_SC2_LADDER, 0)->_flags &= 0xfffb; + g_fp->_aniMan2->_priority = 25; } int sceneHandler02(ExCommand *ex) { @@ -90,7 +91,7 @@ int sceneHandler02(ExCommand *ex) { return 0; case MSG_SC2_PUTMANUP: - g_fullpipe->_aniMan2->_priority = 0; + g_fp->_aniMan2->_priority = 0; return 0; case MSG_SC2_HIDELADDER: @@ -98,12 +99,12 @@ int sceneHandler02(ExCommand *ex) { return 0; case 33: - if (g_fullpipe->_aniMan2) { - if (g_fullpipe->_aniMan2->_ox < g_fullpipe->_sceneRect.left + 200) - g_fullpipe->_currentScene->_x = g_fullpipe->_aniMan2->_ox - g_fullpipe->_sceneRect.left - 300; + if (g_fp->_aniMan2) { + if (g_fp->_aniMan2->_ox < g_fp->_sceneRect.left + 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.left - 300; - if (g_fullpipe->_aniMan2->_ox > g_fullpipe->_sceneRect.right - 200) - g_fullpipe->_currentScene->_x = g_fullpipe->_aniMan2->_ox - g_fullpipe->_sceneRect.right + 300; + if (g_fp->_aniMan2->_ox > g_fp->_sceneRect.right - 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.right + 300; res = 1; } @@ -111,24 +112,24 @@ int sceneHandler02(ExCommand *ex) { if (g_vars->scene02_boxOpen) { if (g_vars->scene02_boxDelay >= 1) { --g_vars->scene02_boxDelay; - } else if (g_fullpipe->_floaters->_array2.size() >= 1) { - if (g_fullpipe->_floaters->_array2[0]->val5 == -50) { - g_fullpipe->_floaters->stopAll(); + } else if (g_fp->_floaters->_array2.size() >= 1) { + if (g_fp->_floaters->_array2[0]->val5 == -50) { + g_fp->_floaters->stopAll(); g_vars->scene02_boxOpen = false; - g_vars->scene02_boxDelay = 100 * g_fullpipe->_rnd->getRandomNumber(32767) + 150; + g_vars->scene02_boxDelay = 100 * g_fp->_rnd->getRandomNumber(32767) + 150; } else { - g_fullpipe->_floaters->_array2[0]->val3 = -50; + g_fp->_floaters->_array2[0]->val3 = -50; } } else { - g_fullpipe->_floaters->genFlies(g_fullpipe->_currentScene, g_fullpipe->_rnd->getRandomNumber(700) + 100, -50, 0, 0); - g_vars->scene02_boxDelay = 500 * g_fullpipe->_rnd->getRandomNumber(32767) + 1000; + g_fp->_floaters->genFlies(g_fp->_currentScene, g_fp->_rnd->getRandomNumber(700) + 100, -50, 0, 0); + g_vars->scene02_boxDelay = 500 * g_fp->_rnd->getRandomNumber(32767) + 1000; } } - g_fullpipe->_floaters->update(); - g_fullpipe->_behaviorManager->updateBehaviors(); + g_fp->_floaters->update(); + g_fp->_behaviorManager->updateBehaviors(); - g_fullpipe->startSceneTrack(); + g_fp->startSceneTrack(); } return res; diff --git a/engines/fullpipe/scenes/scene03.cpp b/engines/fullpipe/scenes/scene03.cpp index 1bfd8b8fcc..40e70e2ea5 100644 --- a/engines/fullpipe/scenes/scene03.cpp +++ b/engines/fullpipe/scenes/scene03.cpp @@ -26,6 +26,7 @@ #include "fullpipe/constants.h" #include "fullpipe/gameloader.h" +#include "fullpipe/motion.h" #include "fullpipe/scenes.h" #include "fullpipe/statics.h" @@ -50,34 +51,34 @@ void scene03_initScene(Scene *sc) { g_vars->scene03_eggeater = sc->getStaticANIObject1ById(ANI_EGGEATER, -1); g_vars->scene03_domino = sc->getStaticANIObject1ById(ANI_DOMINO_3, -1); - GameVar *v = g_fullpipe->_gameLoader->_gameVar->getSubVarByName("OBJSTATES")->getSubVarByName(sO_GulpedEggs); + GameVar *v = g_fp->_gameLoader->_gameVar->getSubVarByName("OBJSTATES")->getSubVarByName(sO_GulpedEggs); g_vars->swallowedEgg1 = v->getSubVarByName(sO_Egg1); g_vars->swallowedEgg2 = v->getSubVarByName(sO_Egg2); g_vars->swallowedEgg3 = v->getSubVarByName(sO_Egg3); - g_fullpipe->lift_setButton(sO_Level2, ST_LBN_2N); + g_fp->lift_setButton(sO_Level2, ST_LBN_2N); - g_fullpipe->lift_sub5(sc, QU_SC3_ENTERLIFT, QU_SC3_EXITLIFT); + g_fp->lift_sub5(sc, QU_SC3_ENTERLIFT, QU_SC3_EXITLIFT); } void scene03_setEaterState() { - if (g_fullpipe->getObjectState(sO_EggGulperGaveCoin) == g_fullpipe->getObjectEnumState(sO_EggGulperGaveCoin, sO_Yes)) { - g_fullpipe->_behaviorManager->setBehaviorEnabled(g_vars->scene03_eggeater, ST_EGTR_SLIM, QU_EGTR_SLIMSHOW, 0); - g_fullpipe->_behaviorManager->setBehaviorEnabled(g_vars->scene03_eggeater, ST_EGTR_MID1, QU_EGTR_MD1_SHOW, 0); - g_fullpipe->_behaviorManager->setBehaviorEnabled(g_vars->scene03_eggeater, ST_EGTR_MID2, QU_EGTR_MD2_SHOW, 0); + if (g_fp->getObjectState(sO_EggGulperGaveCoin) == g_fp->getObjectEnumState(sO_EggGulperGaveCoin, sO_Yes)) { + g_fp->_behaviorManager->setBehaviorEnabled(g_vars->scene03_eggeater, ST_EGTR_SLIM, QU_EGTR_SLIMSHOW, 0); + g_fp->_behaviorManager->setBehaviorEnabled(g_vars->scene03_eggeater, ST_EGTR_MID1, QU_EGTR_MD1_SHOW, 0); + g_fp->_behaviorManager->setBehaviorEnabled(g_vars->scene03_eggeater, ST_EGTR_MID2, QU_EGTR_MD2_SHOW, 0); } } int scene03_updateCursor() { - g_fullpipe->updateCursorCommon(); + g_fp->updateCursorCommon(); - if (g_fullpipe->_cursorId == PIC_CSR_DEFAULT && g_fullpipe->_objectIdAtCursor == PIC_SC3_DOMIN && g_vars->scene03_domino) { + if (g_fp->_cursorId == PIC_CSR_DEFAULT && g_fp->_objectIdAtCursor == PIC_SC3_DOMIN && g_vars->scene03_domino) { if (g_vars->scene03_domino->_flags & 4) - g_fullpipe->_cursorId = PIC_CSR_ITN; + g_fp->_cursorId = PIC_CSR_ITN; } - return g_fullpipe->_cursorId; + return g_fp->_cursorId; } void sceneHandler03_eaterFat() { @@ -94,7 +95,7 @@ void sceneHandler03_swallowEgg(int item) { } else if (!g_vars->swallowedEgg3->_value.intValue) { g_vars->swallowedEgg3->_value.intValue = item; - g_fullpipe->setObjectState(sO_EggGulperGaveCoin, g_fullpipe->getObjectEnumState(sO_EggGulperGaveCoin, sO_Yes)); + g_fp->setObjectState(sO_EggGulperGaveCoin, g_fp->getObjectEnumState(sO_EggGulperGaveCoin, sO_Yes)); scene03_setEaterState(); } @@ -112,7 +113,7 @@ int sceneHandler03_swallowedEgg1State() { } void sceneHandler03_giveCoin(ExCommand *ex) { - MessageQueue *mq = g_fullpipe->_globalMessageQueueList->getMessageQueueById(ex->_parId); + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(ex->_parId); if (mq && mq->getCount() > 0) { ExCommand *ex0 = mq->getExCommandByIndex(0); @@ -136,7 +137,7 @@ void sceneHandler03_giveCoin(ExCommand *ex) { } void sceneHandler03_goLadder() { - handleObjectInteraction(g_fullpipe->_aniMan, g_fullpipe->_currentScene->getPictureObjectById(PIC_SC3_LADDER, 0), 0); + handleObjectInteraction(g_fp->_aniMan, g_fp->_currentScene->getPictureObjectById(PIC_SC3_LADDER, 0), 0); } void sceneHandler03_pushEggStack() { @@ -158,7 +159,7 @@ void sceneHandler03_releaseEgg() { } void sceneHandler03_takeEgg(ExCommand *ex) { - MessageQueue *mq = g_fullpipe->_globalMessageQueueList->getMessageQueueById(ex->_parId); + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(ex->_parId); if (mq && mq->getCount() > 0) { ExCommand *ex0 = mq->getExCommandByIndex(0); @@ -179,7 +180,7 @@ void sceneHandler03_takeEgg(ExCommand *ex) { if (ex1->_objtype == kObjTypeObjstateCommand) { ObjstateCommand *com = (ObjstateCommand *)ex1; - com->_value = g_fullpipe->getObjectEnumState(sO_EggGulper, sO_WantsNothing); + com->_value = g_fp->getObjectEnumState(sO_EggGulper, sO_WantsNothing); } } } @@ -194,11 +195,11 @@ int sceneHandler03(ExCommand *ex) { switch (ex->_messageNum) { case MSG_LIFT_EXITLIFT: - g_fullpipe->lift_exitSeq(ex); + g_fp->lift_exitSeq(ex); break; case MSG_LIFT_CLOSEDOOR: - g_fullpipe->lift_closedoorSeq(); + g_fp->lift_closedoorSeq(); break; case MSG_SC3_ONTAKECOIN: @@ -206,7 +207,7 @@ int sceneHandler03(ExCommand *ex) { break; case MSG_LIFT_STARTEXITQUEUE: - g_fullpipe->lift_startExitQueue(); + g_fp->lift_startExitQueue(); break; case MSG_SC3_RELEASEEGG: @@ -214,7 +215,7 @@ int sceneHandler03(ExCommand *ex) { break; case MSG_LIFT_CLICKBUTTON: - g_fullpipe->lift_animation3(); + g_fp->lift_animation3(); break; case MSG_SC3_HIDEDOMINO: @@ -226,7 +227,7 @@ int sceneHandler03(ExCommand *ex) { break; case MSG_LIFT_GO: - g_fullpipe->lift_goAnimation(); + g_fp->lift_goAnimation(); break; case MSG_SC3_UTRUBACLICK: @@ -238,25 +239,25 @@ int sceneHandler03(ExCommand *ex) { break; case 64: - g_fullpipe->lift_sub05(ex); + g_fp->lift_sub05(ex); break; case 29: { - StaticANIObject *ani = g_fullpipe->_currentScene->getStaticANIObjectAtPos(ex->_sceneClickX, ex->_sceneClickY); + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObjectAtPos(ex->_sceneClickX, ex->_sceneClickY); if (ani && ani->_id == ANI_LIFTBUTTON) { - g_fullpipe->lift_sub1(ani); + g_fp->lift_sub1(ani); ex->_messageKind = 0; return 0; } - if (g_fullpipe->_currentScene->getPictureObjectIdAtPos(ex->_sceneClickX, ex->_sceneClickY) == PIC_SC3_DOMIN) { + if (g_fp->_currentScene->getPictureObjectIdAtPos(ex->_sceneClickX, ex->_sceneClickY) == PIC_SC3_DOMIN) { if (g_vars->scene03_domino) if (g_vars->scene03_domino->_flags & 4) - if (g_fullpipe->_aniMan->isIdle()) - if (!(g_fullpipe->_aniMan->_flags & 0x100) && g_fullpipe->_msgObjectId2 != g_vars->scene03_domino->_id) { - handleObjectInteraction(g_fullpipe->_aniMan, g_vars->scene03_domino, ex->_keyCode); + if (g_fp->_aniMan->isIdle()) + if (!(g_fp->_aniMan->_flags & 0x100) && g_fp->_msgObjectId2 != g_vars->scene03_domino->_id) { + handleObjectInteraction(g_fp->_aniMan, g_vars->scene03_domino, ex->_keyCode); ex->_messageKind = 0; return 0; @@ -270,19 +271,19 @@ int sceneHandler03(ExCommand *ex) { { int res = 0; - if (g_fullpipe->_aniMan2) { - if (g_fullpipe->_aniMan2->_ox < g_fullpipe->_sceneRect.left + 200) - g_fullpipe->_currentScene->_x = g_fullpipe->_aniMan2->_ox - g_fullpipe->_sceneRect.left - 300; + if (g_fp->_aniMan2) { + if (g_fp->_aniMan2->_ox < g_fp->_sceneRect.left + 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.left - 300; - if (g_fullpipe->_aniMan2->_ox > g_fullpipe->_sceneRect.right - 200) - g_fullpipe->_currentScene->_x = g_fullpipe->_aniMan2->_ox - g_fullpipe->_sceneRect.right + 300; + if (g_fp->_aniMan2->_ox > g_fp->_sceneRect.right - 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.right + 300; res = 1; } - g_fullpipe->_behaviorManager->updateBehaviors(); + g_fp->_behaviorManager->updateBehaviors(); - g_fullpipe->startSceneTrack(); + g_fp->startSceneTrack(); return res; } diff --git a/engines/fullpipe/scenes/scene04.cpp b/engines/fullpipe/scenes/scene04.cpp index 07ac109477..fa9f4ceef0 100644 --- a/engines/fullpipe/scenes/scene04.cpp +++ b/engines/fullpipe/scenes/scene04.cpp @@ -26,14 +26,14 @@ #include "fullpipe/constants.h" #include "fullpipe/utils.h" #include "fullpipe/gfx.h" -#include "fullpipe/scenes.h" #include "fullpipe/messages.h" +#include "fullpipe/motion.h" +#include "fullpipe/scenes.h" #include "fullpipe/statics.h" #include "fullpipe/scene.h" #include "fullpipe/interaction.h" #include "fullpipe/gameloader.h" #include "fullpipe/behavior.h" -#include "fullpipe/motion.h" namespace Fullpipe { @@ -52,7 +52,7 @@ void scene04_speakerCallback(int *phase) { if (scene04_speakerPhases[g_vars->scene04_speakerPhase + 6 * g_vars->scene04_speakerVariant] < 0) { g_vars->scene04_speakerPhase = 0; - g_vars->scene04_speakerVariant = g_fullpipe->_rnd->getRandomNumber(2); + g_vars->scene04_speakerVariant = g_fp->_rnd->getRandomNumber(2); } } else { ++g_vars->scene04_speakerPhase; @@ -113,7 +113,7 @@ void scene04_initScene(Scene *sc) { if (plank) plank->_flags |= 8; - if (g_fullpipe->getObjectState(sO_Jar_4) == g_fullpipe->getObjectEnumState(sO_Jar_4, sO_UpsideDown)) { + if (g_fp->getObjectState(sO_Jar_4) == g_fp->getObjectEnumState(sO_Jar_4, sO_UpsideDown)) { g_vars->scene04_bottleObjList.clear(); g_vars->scene04_kozyawkiObjList.clear(); @@ -121,8 +121,8 @@ void scene04_initScene(Scene *sc) { sc->getPictureObjectById(PIC_SC4_MASK, 0)->_flags &= 0xfffb; sc->getStaticANIObject1ById(ANI_SPRING, 0)->_flags &= 0xfffb; - g_vars->scene04_var18 = 0; - g_vars->scene04_var19 = 0; + g_vars->scene04_clockCanGo = false; + g_vars->scene04_objectIsTaken = false; } else { StaticANIObject *spring = sc->getStaticANIObject1ById(ANI_SPRING, -1); @@ -156,33 +156,33 @@ void scene04_initScene(Scene *sc) { } sc->getPictureObjectById(PIC_SC4_BOTTLE2, 0)->_flags &= 0xfffb; - g_vars->scene04_var18 = 1; - g_vars->scene04_var19 = 1; + g_vars->scene04_clockCanGo = true; + g_vars->scene04_objectIsTaken = true; } - g_vars->scene04_var02 = 0; + g_vars->scene04_bottleIsTaken = false; g_vars->scene04_soundPlaying = false; - g_vars->scene04_var04 = 0; + g_vars->scene04_kozyawkaOnLadder = false; g_vars->scene04_walkingKozyawka = 0; g_vars->scene04_bottleWeight = 2; g_vars->scene04_dynamicPhaseIndex = 0; g_vars->scene04_kozyawkiAni.clear(); - g_fullpipe->setObjectState(sO_LowerPipe, g_fullpipe->getObjectEnumState(sO_LowerPipe, sO_IsClosed)); + g_fp->setObjectState(sO_LowerPipe, g_fp->getObjectEnumState(sO_LowerPipe, sO_IsClosed)); - g_vars->scene04_var07 = 0; - g_vars->scene04_var08 = 0; - g_vars->scene04_coinPut = 0; - g_vars->scene04_var09 = 0; - g_vars->scene04_var10 = 0; - g_vars->scene04_var11 = 0; - g_vars->scene04_var12 = 0; - g_vars->scene04_var13 = 1; - g_vars->scene04_var14 = 0; - g_vars->scene04_var15 = 1; + g_vars->scene04_var07 = false; + g_vars->scene04_ladderClickable = false; + g_vars->scene04_coinPut = false; + g_vars->scene04_handIsDown = false; + g_vars->scene04_dudeInBottle = false; + g_vars->scene04_kozHeadRaised = false; + g_vars->scene04_bottleIsDropped = false; + g_vars->scene04_bigBallIn = true; + g_vars->scene04_bigBallCounter = 0; + g_vars->scene04_bigBallFromLeft = true; - if (g_fullpipe->getObjectState(sO_BigMumsy) != g_fullpipe->getObjectEnumState(sO_BigMumsy, sO_Gone)) + if (g_fp->getObjectState(sO_BigMumsy) != g_fp->getObjectEnumState(sO_BigMumsy, sO_IsGone)) g_vars->scene04_mamasha->hide(); g_vars->scene04_speaker = sc->getStaticANIObject1ById(ANI_SPEAKER_4, -1); @@ -192,12 +192,12 @@ void scene04_initScene(Scene *sc) { g_vars->scene04_speakerVariant = 0; g_vars->scene04_speakerPhase = 0; - g_fullpipe->initArcadeKeys("SC_4"); + g_fp->initArcadeKeys("SC_4"); } bool sceneHandler04_friesAreWalking() { - if (g_vars->scene04_dudeOnLadder && g_fullpipe->_aniMan->isIdle() && !(g_fullpipe->_aniMan->_flags & 0x100)) { - int col = g_vars->scene04_ladder->collisionDetection(g_fullpipe->_aniMan); + if (g_vars->scene04_dudeOnLadder && g_fp->_aniMan->isIdle() && !(g_fp->_aniMan->_flags & 0x100)) { + int col = g_vars->scene04_ladder->collisionDetection(g_fp->_aniMan); if (col >= 3 && col <= 6 ) { Movement *koz; @@ -214,59 +214,59 @@ bool sceneHandler04_friesAreWalking() { } int scene04_updateCursor() { - g_fullpipe->updateCursorCommon(); + g_fp->updateCursorCommon(); - if (g_fullpipe->_objectIdAtCursor == PIC_SC4_LRTRUBA) { - if (!g_vars->scene04_var19) { - g_fullpipe->_cursorId = PIC_CSR_DEFAULT; + if (g_fp->_objectIdAtCursor == PIC_SC4_LRTRUBA) { + if (!g_vars->scene04_objectIsTaken) { + g_fp->_cursorId = PIC_CSR_DEFAULT; - return g_fullpipe->_cursorId; + return g_fp->_cursorId; } - } else if (g_fullpipe->_objectIdAtCursor == ANI_PLANK || g_fullpipe->_objectIdAtCursor == PIC_SC4_PLANK) { - if (g_fullpipe->_objectIdAtCursor == ANI_PLANK && g_fullpipe->_cursorId != PIC_CSR_ITN) - return g_fullpipe->_cursorId; + } else if (g_fp->_objectIdAtCursor == ANI_PLANK || g_fp->_objectIdAtCursor == PIC_SC4_PLANK) { + if (g_fp->_objectIdAtCursor == ANI_PLANK && g_fp->_cursorId != PIC_CSR_ITN) + return g_fp->_cursorId; - if (g_fullpipe->_objectIdAtCursor == ANI_PLANK || (g_fullpipe->_objectIdAtCursor == PIC_SC4_PLANK && g_fullpipe->_cursorId == PIC_CSR_DEFAULT)) { + if (g_fp->_objectIdAtCursor == ANI_PLANK || (g_fp->_objectIdAtCursor == PIC_SC4_PLANK && g_fp->_cursorId == PIC_CSR_DEFAULT)) { if (sceneHandler04_friesAreWalking()) { - g_fullpipe->_cursorId = PIC_CSR_ARCADE1; - return g_fullpipe->_cursorId; + g_fp->_cursorId = PIC_CSR_ARCADE1; + return g_fp->_cursorId; } if (g_vars->scene04_soundPlaying) { - g_fullpipe->_cursorId = PIC_CSR_DEFAULT; - return g_fullpipe->_cursorId; + g_fp->_cursorId = PIC_CSR_DEFAULT; + return g_fp->_cursorId; } } } - if (g_fullpipe->_objectIdAtCursor == PIC_CSR_ITN && g_fullpipe->_objectIdAtCursor == PIC_SC4_DOWNTRUBA) - g_fullpipe->_cursorId = PIC_CSR_GOD; + if (g_fp->_objectIdAtCursor == PIC_CSR_ITN && g_fp->_objectIdAtCursor == PIC_SC4_DOWNTRUBA) + g_fp->_cursorId = PIC_CSR_GOD; - return g_fullpipe->_cursorId; + return g_fp->_cursorId; } void sceneHandler04_checkBigBallClick() { - StaticANIObject *ball = g_fullpipe->_currentScene->getStaticANIObject1ById(ANI_BIGBALL, -1); + StaticANIObject *ball = g_fp->_currentScene->getStaticANIObject1ById(ANI_BIGBALL, -1); if (ball) for (uint i = 0; i < ball->_movements.size(); i++) ((Movement *)ball->_movements[i])->_counterMax = 73; - g_vars->scene04_var13 = 1; + g_vars->scene04_bigBallIn = true; } void sceneHandler04_clickBottle() { - if (!g_vars->scene04_var02) - g_vars->scene04_var20 += 5; + if (!g_vars->scene04_bottleIsTaken) + g_vars->scene04_springOffset += 5; } void sceneHandler04_clickButton() { - StaticANIObject *but = g_fullpipe->_currentScene->getStaticANIObject1ById(ANI_BUTTON, -1); + StaticANIObject *but = g_fp->_currentScene->getStaticANIObject1ById(ANI_BUTTON, -1); if (but) { if (!g_vars->scene04_clock->_movement || (g_vars->scene04_clock->_movement->_id == MV_CLK_GO && g_vars->scene04_clock->_movement->_currDynamicPhaseIndex > 3 && g_vars->scene04_clock->_movement->_currDynamicPhaseIndex < 105)) { - if (!g_vars->scene04_hand->_movement && !g_vars->scene04_var02) { + if (!g_vars->scene04_hand->_movement && !g_vars->scene04_bottleIsTaken) { but->startAnim(MV_BTN_CLICK, 0, -1); g_vars->scene04_hand->startAnim(MV_HND_POINT, 0, -1); } @@ -275,22 +275,22 @@ void sceneHandler04_clickButton() { } void sceneHandler04_downLadder(int x, int y) { - g_vars->scene04_ladder->method34(g_fullpipe->_aniMan, x + g_vars->scene04_ladder->_ladder_field_20, y + g_vars->scene04_ladder->_ladder_field_24, 0, 0); + g_vars->scene04_ladder->method34(g_fp->_aniMan, x + g_vars->scene04_ladder->_ladder_field_20, y + g_vars->scene04_ladder->_ladder_field_24, 0, 0); } void sceneHandler04_walkClimbLadder(ExCommand *ex) { - MessageQueue *mq = new MessageQueue(g_fullpipe->_globalMessageQueueList->compact()); + MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); ExCommand *ex1 = new ExCommand(ANI_MAN, 1, MV_MAN_TOLADDER, 0, 0, 0, 1, 0, 0, 0); - ex1->_keyCode = g_fullpipe->_aniMan->_okeyCode; + ex1->_keyCode = g_fp->_aniMan->_okeyCode; ex1->_excFlags |= 2; mq->addExCommandToEnd(ex1); ExCommand *ex2 = new ExCommand(ANI_MAN, 1, MV_MAN_STOPLADDER, 0, 0, 0, 1, 0, 0, 0); - ex2->_keyCode = g_fullpipe->_aniMan->_okeyCode; + ex2->_keyCode = g_fp->_aniMan->_okeyCode; ex2->_excFlags |= 2; mq->addExCommandToEnd(ex2); @@ -313,15 +313,15 @@ void sceneHandler04_walkClimbLadder(ExCommand *ex) { g_vars->scene04_dudeOnLadder = 1; g_vars->scene04_ladder = new MctlLadder; - g_vars->scene04_ladder->_objId = MV_MAN_TURN_SUD; + g_vars->scene04_ladder->_ladderX = 1089; g_vars->scene04_ladder->_ladderY = 406; g_vars->scene04_ladder->_ladder_field_14 = 12; - g_vars->scene04_ladder->_ladder_field_18 = 0; + g_vars->scene04_ladder->_width = 0; g_vars->scene04_ladder->_height = -40; g_vars->scene04_ladder->_ladder_field_20 = 0; g_vars->scene04_ladder->_ladder_field_24 = -60; - g_vars->scene04_ladder->addObject(g_fullpipe->_aniMan); + g_vars->scene04_ladder->addObject(g_fp->_aniMan); if (g_vars->scene04_soundPlaying) { g_vars->scene04_ladder->_movements.front()->movVars->varUpStart = MV_MAN_STARTLADDER2; @@ -335,19 +335,19 @@ void sceneHandler04_walkClimbLadder(ExCommand *ex) { g_vars->scene04_ladder->_movements.front()->staticIds[2] = ST_MAN_GOLADDER; } - g_fullpipe->_aniMan->_priority = 12; + g_fp->_aniMan->_priority = 12; - getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId)->clearEnabled(); + getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->clearEnabled(); getGameLoaderInteractionController()->disableFlag24(); } void sceneHandler04_clickLadder() { - g_vars->scene04_dudePosX = g_fullpipe->_aniMan->_ox; - g_vars->scene04_dudePosY = g_fullpipe->_aniMan->_oy; + g_vars->scene04_dudePosX = g_fp->_aniMan->_ox; + g_vars->scene04_dudePosY = g_fp->_aniMan->_oy; if (g_vars->scene04_dudeOnLadder) { - if (!g_fullpipe->_aniMan->isIdle() || (g_fullpipe->_aniMan->_flags & 0x100)) { - g_vars->scene04_var08 = 1; + if (!g_fp->_aniMan->isIdle() || (g_fp->_aniMan->_flags & 0x100)) { + g_vars->scene04_ladderClickable = true; } else { int h3 = 3 * g_vars->scene04_ladder->_height; int half = abs(g_vars->scene04_ladder->_height) / 2; @@ -363,19 +363,19 @@ void sceneHandler04_clickLadder() { sceneHandler04_downLadder(g_vars->scene04_sceneClickX, g_vars->scene04_sceneClickY); - g_vars->scene04_var08 = 0; + g_vars->scene04_ladderClickable = false; } } else { - if (g_fullpipe->_aniMan->isIdle() && !(g_fullpipe->_aniMan->_flags & 0x100)) { + if (g_fp->_aniMan->isIdle() && !(g_fp->_aniMan->_flags & 0x100)) { if (abs(1095 - g_vars->scene04_dudePosX) > 1 || abs(434 - g_vars->scene04_dudePosY) > 1) { - MessageQueue *mq = getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId)->method34(g_fullpipe->_aniMan, 1095, 434, 1, ST_MAN_UP); + MessageQueue *mq = getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->method34(g_fp->_aniMan, 1095, 434, 1, ST_MAN_UP); if (mq) { ExCommand *ex = new ExCommand(0, 17, MSG_SC4_CLICKLADDER, 0, 0, 0, 1, 0, 0, 0); ex->_excFlags = 3; mq->addExCommandToEnd(ex); - postExCommand(g_fullpipe->_aniMan->_id, 2, 1095, 434, 0, -1); + postExCommand(g_fp->_aniMan->_id, 2, 1095, 434, 0, -1); } } else { sceneHandler04_walkClimbLadder(0); @@ -385,22 +385,22 @@ void sceneHandler04_clickLadder() { } void sceneHandler04_jumpOnLadder() { - if (g_fullpipe->_aniMan->_movement && g_fullpipe->_aniMan->_movement->_id != MV_MAN_LOOKLADDER) + if (g_fp->_aniMan->_movement && g_fp->_aniMan->_movement->_id != MV_MAN_LOOKLADDER) return; - if (g_fullpipe->_aniMan->_statics->_staticsId != ST_MAN_STANDLADDER && g_fullpipe->_aniMan->_statics->_staticsId != ST_MAN_LADDERDOWN) + if (g_fp->_aniMan->_statics->_staticsId != ST_MAN_STANDLADDER && g_fp->_aniMan->_statics->_staticsId != ST_MAN_LADDERDOWN) return; - g_fullpipe->_aniMan->changeStatics2(ST_MAN_LADDERDOWN); + g_fp->_aniMan->changeStatics2(ST_MAN_LADDERDOWN); - g_fullpipe->_aniMan->_flags |= 1; + g_fp->_aniMan->_flags |= 1; MGM mgm; MGMInfo mgminfo; mgm.addItem(ANI_MAN); - mgminfo.ani = g_fullpipe->_aniMan; + mgminfo.ani = g_fp->_aniMan; mgminfo.staticsId2 = ST_MAN_ONPLANK; mgminfo.x1 = 938; mgminfo.y1 = 442; @@ -414,26 +414,26 @@ void sceneHandler04_jumpOnLadder() { if (mq) { mq->_flags |= 1; - if (!mq->chain(g_fullpipe->_aniMan)) + if (!mq->chain(g_fp->_aniMan)) delete mq; - g_fullpipe->_aniMan->_priority = 10; + g_fp->_aniMan->_priority = 10; } - g_vars->scene04_ladderOffset = g_vars->scene04_ladder->collisionDetection(g_fullpipe->_aniMan); + g_vars->scene04_ladderOffset = g_vars->scene04_ladder->collisionDetection(g_fp->_aniMan); } void sceneHandler04_clickPlank() { if (sceneHandler04_friesAreWalking()) sceneHandler04_jumpOnLadder(); else if (g_vars->scene04_dudeOnLadder) - g_fullpipe->playSound(SND_4_033, 0); + g_fp->playSound(SND_4_033, 0); else if (!g_vars->scene04_soundPlaying) chainQueue(QU_PNK_CLICK, 0); } void sceneHandler04_dropBottle() { - g_vars->scene04_var12 = 1; + g_vars->scene04_bottleIsDropped = true; g_vars->scene04_bottleY = 10; g_vars->scene04_bottleWeight = 0; @@ -465,7 +465,7 @@ void sceneHandler04_gotoLadder(ExCommand *ex) { mgm.addItem(ANI_MAN); - mgminfo.ani = g_fullpipe->_aniMan; + mgminfo.ani = g_fp->_aniMan; mgminfo.staticsId2 = ST_MAN_UP; mgminfo.x1 = 1095; mgminfo.y1 = 434; @@ -491,7 +491,7 @@ void sceneHandler04_gotoLadder(ExCommand *ex) { ex2->_keyCode = -1; mq->addExCommandToEnd(ex2); - ExCommand *ex3 = new ExCommand(g_fullpipe->_aniMan->_id, 34, 256, 0, 0, 0, 1, 0, 0, 0); + ExCommand *ex3 = new ExCommand(g_fp->_aniMan->_id, 34, 256, 0, 0, 0, 1, 0, 0, 0); ex3->_field_14 = 256; ex3->_messageNum = 0; ex3->_excFlags |= 3; @@ -505,15 +505,15 @@ void sceneHandler04_gotoLadder(ExCommand *ex) { mq->setFlags(mq->getFlags() | 1); - if (mq->chain(g_fullpipe->_aniMan)) { - g_fullpipe->_aniMan->_priority = 12; - g_fullpipe->_aniMan->_flags |= 1; + if (mq->chain(g_fp->_aniMan)) { + g_fp->_aniMan->_priority = 12; + g_fp->_aniMan->_flags |= 1; } else { delete mq; } } - g_vars->scene04_var04 = 0; + g_vars->scene04_kozyawkaOnLadder = false; } void sceneHandler04_lowerPlank() { @@ -522,7 +522,7 @@ void sceneHandler04_lowerPlank() { void sceneHandler04_manFromBottle() { for (Common::List<GameObject *>::iterator it = g_vars->scene04_bottleObjList.begin(); it != g_vars->scene04_bottleObjList.end(); ++it) - if (*it == g_fullpipe->_aniMan) { + if (*it == g_fp->_aniMan) { g_vars->scene04_bottleObjList.erase(it); g_vars->scene04_bottleWeight -= 9; break; @@ -533,28 +533,343 @@ void sceneHandler04_manFromBottle() { g_vars->scene04_ladder = 0; - getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId)->setEnabled(); + getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->setEnabled(); getGameLoaderInteractionController()->enableFlag24(); } void sceneHandler04_manToBottle() { - g_vars->scene04_bottleObjList.push_back(g_fullpipe->_aniMan); - g_vars->scene04_var20 = 5; + g_vars->scene04_bottleObjList.push_back(g_fp->_aniMan); + g_vars->scene04_springOffset = 5; g_vars->scene04_bottleWeight += 9; - g_fullpipe->_aniMan2 = g_fullpipe->_aniMan; - g_vars->scene04_var10 = 1; + g_fp->_aniMan2 = g_fp->_aniMan; + g_vars->scene04_dudeInBottle = 1; } void sceneHandler04_raisePlank() { g_vars->scene04_plank->startAnim(MV_PNK_WEIGHTLEFT, 0, -1); } +MessageQueue *sceneHandler04_kozFly3(StaticANIObject *ani, double phase) { + MGM mgm; + MGMInfo mgminfo; + + mgm.addItem(ANI_KOZAWKA); + + mgminfo.ani = ani; + mgminfo.staticsId2 = ST_KZW_SIT; + mgminfo.x1 = (int)(723.0 - phase * 185.0); + mgminfo.y1 = 486; + mgminfo.field_1C = 10; + mgminfo.field_10 = 1; + mgminfo.flags = 78; + mgminfo.movementId = MV_KZW_JUMP; + + MessageQueue *mq = mgm.genMovement(&mgminfo); + + if (mq) { + ExCommand *ex = new ExCommand(ANI_KOZAWKA, 1, MV_KZW_STANDUP, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + + ex = new ExCommand(ANI_KOZAWKA, 1, MV_KZW_TURN, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + + for (int i = 0; i < 5; i++) { + ex = new ExCommand(ANI_KOZAWKA, 1, rMV_KZW_GOR, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + } + + ex = new ExCommand(ANI_KOZAWKA, 6, 0, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 3; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + + ex = new ExCommand(ANI_KOZAWKA, 17, MSG_KOZAWRESTART, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 3; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + } + + return mq; +} + +MessageQueue *sceneHandler04_kozFly5(StaticANIObject *ani, double phase) { + MGM mgm; + MGMInfo mgminfo; + + mgm.addItem(ANI_KOZAWKA); + + mgminfo.ani = ani; + mgminfo.staticsId2 = ST_KZW_JUMPOUT; + mgminfo.x1 = 525; + mgminfo.y1 = (int)(344.0 - (double)(320 - g_vars->scene04_bottle->_oy) * phase); + mgminfo.field_1C = 10; + mgminfo.field_10 = 1; + mgminfo.flags = 78; + mgminfo.movementId = MV_KZW_JUMPHIT; + + MessageQueue *mq1 = mgm.genMovement(&mgminfo); + + memset(&mgminfo, 0, sizeof(mgminfo)); + mgminfo.ani = ani; + mgminfo.staticsId1 = ST_KZW_JUMPOUT; + mgminfo.staticsId2 = ST_KZW_SIT; + mgminfo.x2 = 525; + mgminfo.y2 = (int)(344.0 - (double)(320 - g_vars->scene04_bottle->_oy) * phase); + mgminfo.y1 = 486; + mgminfo.field_1C = 10; + mgminfo.field_10 = 1; + mgminfo.flags = 117; + mgminfo.movementId = MV_KZW_JUMPOUT; + + MessageQueue *mq2 = mgm.genMovement(&mgminfo); + + if (mq1 && mq2) { + mq1->addExCommandToEnd(new ExCommand(mq2->getExCommandByIndex(0))); + + delete mq2; + + ExCommand *ex = new ExCommand(ANI_KOZAWKA, 1, MV_KZW_STANDUP, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq1->addExCommandToEnd(ex); + + ex = new ExCommand(ANI_KOZAWKA, 1, MV_KZW_TURN, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq1->addExCommandToEnd(ex); + + for (int i = 0; i < 5; i++) { + ex = new ExCommand(ANI_KOZAWKA, 1, rMV_KZW_GOR, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq1->addExCommandToEnd(ex); + } + + ex = new ExCommand(ANI_KOZAWKA, 6, 0, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 3; + ex->_keyCode = ani->_okeyCode; + mq1->addExCommandToEnd(ex); + + ex = new ExCommand(ANI_KOZAWKA, 17, MSG_KOZAWRESTART, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 3; + ex->_keyCode = ani->_okeyCode; + mq1->addExCommandToEnd(ex); + } + + return mq1; +} + +MessageQueue *sceneHandler04_kozFly6(StaticANIObject *ani) { + MGM mgm; + MGMInfo mgminfo; + + mgm.addItem(ANI_KOZAWKA); + + mgminfo.ani = ani; + mgminfo.staticsId2 = ST_KZW_SIT; + mgminfo.x1 = 397 - 4 * g_fp->_rnd->getRandomNumber(1); + mgminfo.field_1C = ani->_priority; + mgminfo.y1 = g_vars->scene04_bottle->_oy - 4 * g_fp->_rnd->getRandomNumber(1) + 109; + mgminfo.field_10 = 1; + mgminfo.flags = 78; + mgminfo.movementId = MV_KZW_JUMPROTATE; + + MessageQueue *mq = mgm.genMovement(&mgminfo); + + if (mq) { + mq->deleteExCommandByIndex(mq->getCount() - 1, 1); + + ExCommand *ex = new ExCommand(ANI_KOZAWKA, 1, MV_KZW_STANDUP, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + + ex = new ExCommand(ANI_KOZAWKA, 1, MV_KZW_GOR, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + + ex = new ExCommand(ANI_KOZAWKA, 1, MV_KZW_RAISEHEAD, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + + g_vars->scene04_kozHeadRaised = true; + } + + return mq; +} + +void sceneHandler04_kozMove(Movement *mov, int from, int to, Common::Point *points, double phase) { + for (int i = from; i < to; i++) { + mov->setDynamicPhaseIndex(i); + + Common::Point *p; + if (mov->_framePosOffsets) { + p = mov->_framePosOffsets[mov->_currDynamicPhaseIndex]; + } else { + p = &mov->_somePoint; + p->x = 0; + p->y = 0; + } + + p->y = (int)((double)points[i].y * phase); + } +} + +MessageQueue *sceneHandler04_kozFly7(StaticANIObject *ani, double phase) { + MGM mgm; + MGMInfo mgminfo; + + mgm.addItem(ANI_KOZAWKA); + + mgminfo.ani = ani; + mgminfo.staticsId2 = 560; + mgminfo.x1 = (int)(250.0 - phase * 100.0); + mgminfo.y1 = 455; + mgminfo.field_1C = 10; + mgminfo.field_10 = 1; + mgminfo.flags = 78; + mgminfo.movementId = MV_KZW_JUMPROTATE; + + MessageQueue *mq = mgm.genMovement(&mgminfo); + + if (mq) { + sceneHandler04_kozMove(ani->getMovementById(MV_KZW_JUMPROTATE), 1, 9, g_vars->scene04_jumpRotateKozyawki, phase * 0.5 + 1.5); + + ani->_priority = 10; + + ExCommand *ex = new ExCommand(ANI_KOZAWKA, 1, MV_KZW_STANDUP, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + + ex = new ExCommand(ANI_KOZAWKA, 1, MV_KZW_TURN, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + + for (int i = 0; i < 2; i++) { + ex = new ExCommand(ANI_KOZAWKA, 1, rMV_KZW_GOR, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + } + + ex = new ExCommand(ANI_KOZAWKA, 6, 0, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 3; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + + ex = new ExCommand(ANI_KOZAWKA, 17, MSG_KOZAWRESTART, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 3; + ex->_keyCode = ani->_okeyCode; + mq->addExCommandToEnd(ex); + } + + return mq; +} + +static const int kozTrajectory3[] = { + 3, 2, 0, + 3, 2, 0, + 3, 2, 0 +}; + +static const int kozTrajectory4[] = { + 5, 3, 1, + 5, 4, 1, + 5, 3, 1 +}; + +static const int kozTrajectory5[] = { + 6, 5, 4, + 6, 5, 4, + 6, 5, 4 +}; + +static const int kozTrajectory6[] = { + 7, 6, 5, + 7, 6, 5, + 7, 6, 5 +}; + void sceneHandler04_shootKozyawka() { - warning("STUB: sceneHandler04_shootKozyawka()"); + g_vars->scene04_plank->changeStatics2(ST_PNK_WEIGHTRIGHT); + + if (!g_vars->scene04_walkingKozyawka) + return; + + if (g_vars->scene04_walkingKozyawka->_movement) { + if (g_vars->scene04_walkingKozyawka->_movement->_id == MV_KZW_WALKPLANK) { + int dphase = g_vars->scene04_walkingKozyawka->_movement->_currDynamicPhaseIndex; + + if (dphase < 41) { + int col = 3 * dphase / 15; + if (col > 2) + col = 2; + + int row = g_vars->scene04_kozyawkiAni.size(); + if (row > 2) + row = 2; + + int idx = 3 * row + col; + int phase; + + if (g_vars->scene04_ladderOffset == 3) { + phase = kozTrajectory3[idx]; + } else if (g_vars->scene04_ladderOffset == 4) { + phase = kozTrajectory4[idx]; + } else { + if (g_vars->scene04_ladderOffset == 5) + phase = kozTrajectory5[idx]; + else + phase = kozTrajectory6[idx]; + } + + g_vars->scene04_walkingKozyawka->queueMessageQueue(0); + g_vars->scene04_walkingKozyawka->_movement = 0; + g_vars->scene04_walkingKozyawka->_statics = g_vars->scene04_walkingKozyawka->getStaticsById(ST_KZW_RIGHT); + + MessageQueue *mq; + + if (phase > 2) { + if (phase > 5) { + if (phase == 6) + mq = sceneHandler04_kozFly6(g_vars->scene04_walkingKozyawka); + else + mq = sceneHandler04_kozFly7(g_vars->scene04_walkingKozyawka, (double)(phase - 6) * 0.3333333333333333); + } else { + mq = sceneHandler04_kozFly5(g_vars->scene04_walkingKozyawka, (double)(phase - 2) * 0.3333333333333333); + } + } else { + mq = sceneHandler04_kozFly3(g_vars->scene04_walkingKozyawka, (double)phase * 0.5); + } + + if (mq) { + g_vars->scene04_lastKozyawka = g_vars->scene04_walkingKozyawka; + + if (!mq->chain(g_vars->scene04_walkingKozyawka) ) + delete mq; + } + } + } + } + + if (g_vars->scene04_ladderOffset > 3) + g_fp->_aniMan->changeStatics1(ST_MAN_LOOKPLANK); + + g_vars->scene04_kozyawkaOnLadder = true; } void sceneHandler04_showCoin() { - StaticANIObject *ani = g_fullpipe->_currentScene->getStaticANIObject1ById(ANI_SC4_COIN, -1); + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObject1ById(ANI_SC4_COIN, -1); if (ani) { ani->show1(MV_BDG_OPEN, MV_MAN_GOU, MV_SC4_COIN_default, 0); @@ -564,13 +879,15 @@ void sceneHandler04_showCoin() { } void sceneHandler04_stopSound() { + g_vars->scene04_soundPlaying = false; + warning("STUB: sceneHandler04_stopSound()"); } -void sceneHandler04_sub1(ExCommand *ex) { - g_fullpipe->_aniMan->changeStatics2(ST_MAN_SIT); +void sceneHandler04_animOutOfBottle(ExCommand *ex) { + g_fp->_aniMan->changeStatics2(ST_MAN_SIT); - MessageQueue *mq = new MessageQueue(g_fullpipe->_currentScene->getMessageQueueById(QU_SC4_MANFROMBOTTLE), 0, 0); + MessageQueue *mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC4_MANFROMBOTTLE), 0, 0); if (ex) { ExCommand *newex = new ExCommand(ex); @@ -581,8 +898,8 @@ void sceneHandler04_sub1(ExCommand *ex) { mq->_flags |= 1; mq->chain(0); - g_vars->scene04_var10 = 0; - g_fullpipe->_behaviorManager->setFlagByStaticAniObject(g_fullpipe->_aniMan, 1); + g_vars->scene04_dudeInBottle = false; + g_fp->_behaviorManager->setFlagByStaticAniObject(g_fp->_aniMan, 1); } void sceneHandler04_walkKozyawka() { @@ -590,7 +907,7 @@ void sceneHandler04_walkKozyawka() { g_vars->scene04_walkingKozyawka = g_vars->scene04_kozyawkiObjList.front(); g_vars->scene04_kozyawkiObjList.pop_front(); - MessageQueue *mq = new MessageQueue(g_fullpipe->_currentScene->getMessageQueueById(QU_KOZAW_WALK), 0, 1); + MessageQueue *mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_KOZAW_WALK), 0, 1); mq->replaceKeyCode(-1, g_vars->scene04_walkingKozyawka->_okeyCode); mq->chain(0); } @@ -606,34 +923,34 @@ void sceneHandler04_bottleUpdateObjects(int off) { void sceneHandler04_springWobble() { int oldDynIndex = g_vars->scene04_dynamicPhaseIndex; - int newdelta = g_vars->scene04_var20 + g_vars->scene04_dynamicPhaseIndex; + int newdelta = g_vars->scene04_springOffset + g_vars->scene04_dynamicPhaseIndex; - g_vars->scene04_dynamicPhaseIndex += g_vars->scene04_var20; + g_vars->scene04_dynamicPhaseIndex += g_vars->scene04_springOffset; if (newdelta < 0) { newdelta = 0; g_vars->scene04_dynamicPhaseIndex = 0; - g_vars->scene04_var20 = 0; + g_vars->scene04_springOffset = 0; } if (newdelta > 14) { newdelta = 14; g_vars->scene04_dynamicPhaseIndex = 14; - g_vars->scene04_var20 = 0; + g_vars->scene04_springOffset = 0; } if (g_vars->scene04_bottleWeight > newdelta) - g_vars->scene04_var20++; + g_vars->scene04_springOffset++; if (g_vars->scene04_bottleWeight < newdelta) - g_vars->scene04_var20--; + g_vars->scene04_springOffset--; if ((oldDynIndex > g_vars->scene04_bottleWeight && newdelta > g_vars->scene04_bottleWeight) || newdelta <= g_vars->scene04_bottleWeight) { - g_vars->scene04_var25++; + g_vars->scene04_springDelay++; - if (g_vars->scene04_var20 && g_vars->scene04_var25 > 1) { - g_vars->scene04_var25 = 0; - g_vars->scene04_var20 = g_vars->scene04_var20 - g_vars->scene04_var20 / abs(g_vars->scene04_var20); + if (g_vars->scene04_springOffset && g_vars->scene04_springDelay > 1) { + g_vars->scene04_springDelay = 0; + g_vars->scene04_springOffset = g_vars->scene04_springOffset - g_vars->scene04_springOffset / abs(g_vars->scene04_springOffset); } } @@ -652,8 +969,33 @@ void sceneHandler04_springWobble() { sceneHandler04_bottleUpdateObjects(oldDynIndex - g_vars->scene04_dynamicPhaseIndex); } -void sceneHandler04_sub5() { - warning("STUB: sceneHandler04_sub5()"); +void sceneHandler04_leaveScene() { + g_fp->_aniMan2 = 0; + + MessageQueue *mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC4_MANTOBOTTLE), 0, 0); + ExCommand *ex = 0; + + for (uint i = 0; i < mq->getCount(); i++) { + if (mq->getExCommandByIndex(i)->_messageKind == 27) { + ex = mq->getExCommandByIndex(i); + break; + } + } + + if (!ex) { + error("sceneHandler04_leaveScene(): Cannot find exit"); + } + + ex->_y = g_vars->scene04_bottle->_oy - 304; + + mq->chain(0); + + g_vars->scene04_var07 = false; + g_vars->scene04_dudeOnLadder = 0; + + g_fp->_behaviorManager->setFlagByStaticAniObject(g_fp->_aniMan, 0); + + g_fp->updateMapPiece(PIC_MAP_P03, 1); } void sceneHandler04_liftBottle() { @@ -669,46 +1011,122 @@ void sceneHandler04_liftBottle() { sceneHandler04_bottleUpdateObjects(226 - g_vars->scene04_bottle->_oy); g_vars->scene04_spring->setOXY(g_vars->scene04_spring->_ox, 437); - g_vars->scene04_var12 = 0; - g_vars->scene04_var09 = 0; - g_vars->scene04_var19 = 1; + g_vars->scene04_bottleIsDropped = false; + g_vars->scene04_handIsDown = false; + g_vars->scene04_objectIsTaken = true; g_vars->scene04_bottleWeight = 2; - g_vars->scene04_var20 = 10; - g_vars->scene04_var02 = 0; + g_vars->scene04_springOffset = 10; + g_vars->scene04_bottleIsTaken = false; - g_fullpipe->setObjectState(sO_LowerPipe, g_fullpipe->getObjectEnumState(sO_LowerPipe, sO_IsClosed)); + g_fp->setObjectState(sO_LowerPipe, g_fp->getObjectEnumState(sO_LowerPipe, sO_IsClosed)); } } void sceneHandler04_startSounds(const char *snd1, const char *snd2, const char *snd3) { warning("STUB: sceneHandler04_startSounds()"); + + // playFile(snd1); + // playFile(snd2); + // playFile(snd3); } void sceneHandler04_goClock() { sceneHandler04_walkKozyawka(); chainQueue(QU_SC4_GOCLOCK, 0); - g_vars->scene04_soundPlaying = 1; - g_vars->scene04_coinPut = 0; + g_vars->scene04_soundPlaying = true; + g_vars->scene04_coinPut = false; - g_fullpipe->stopAllSoundStreams(); + g_fp->stopAllSoundStreams(); sceneHandler04_startSounds("sc4_start.ogg", "sc4_loop.ogg", "sc4_stop2.ogg"); - g_vars->scene04_var14 = 0; + g_vars->scene04_bigBallCounter = 0; } -void sceneHandler04_sub8(ExCommand *ex) { - warning("STUB: sceneHandler04_sub8()"); -} - -void sceneHandler04_sub12() { - StaticANIObject *ball = g_fullpipe->_currentScene->getStaticANIObject1ById(ANI_BIGBALL, -1); +void sceneHandler04_bigBallOut() { + StaticANIObject *ball = g_fp->_currentScene->getStaticANIObject1ById(ANI_BIGBALL, -1); if (ball && ball->_flags & 4) for (uint i = 0; i < ball->_movements.size(); i++) ((Movement *)ball->_movements[i])->_counterMax = 0; - g_vars->scene04_var13 = 0; + g_vars->scene04_bigBallIn = false; +} + +void sceneHandler04_leaveLadder(ExCommand *ex) { + if (!g_fp->_aniMan->isIdle()) + return; + + if (!(g_fp->_aniMan->_flags & 0x100)) { + if (getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->_objtype == kObjTypeMctlCompound) { + MctlCompound *mc = (MctlCompound *)getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId); + + if (mc->_motionControllers[0]->_movGraphReactObj->pointInRegion(g_fp->_sceneRect.left + ex->_x, g_fp->_sceneRect.top + ex->_y)) { + if (g_vars->scene04_ladder->collisionDetection(g_fp->_aniMan)) { + MessageQueue *mq = g_vars->scene04_ladder->controllerWalkTo(g_fp->_aniMan, 0); + + if (mq) { + mq->addExCommandToEnd(new ExCommand(ex)); + + if (mq->chain(g_fp->_aniMan) ) + ex->_messageKind = 0; + else + delete mq; + + if (g_vars->scene04_bigBallIn) { + sceneHandler04_bigBallOut(); + return; + } + } + } else { + MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); + ExCommand *ex1; + + if (g_fp->_aniMan->_statics->_staticsId == ST_MAN_LADDERDOWN) { + ex1 = new ExCommand(ANI_MAN, 1, MV_MAN_LOOKLADDERRV, 0, 0, 0, 1, 0, 0, 0); + ex1->_keyCode = g_fp->_aniMan->_okeyCode; + ex1->_excFlags |= 2; + mq->addExCommandToEnd(ex1); + } + + ex1 = new ExCommand(ANI_MAN, 1, MV_MAN_STARTLADDERD, 0, 0, 0, 1, 0, 0, 0); + ex1->_keyCode = g_fp->_aniMan->_okeyCode; + ex1->_excFlags |= 2; + mq->addExCommandToEnd(ex1); + + ex1 = new ExCommand(ANI_MAN, 1, MV_MAN_FROMLADDER, 0, 0, 0, 1, 0, 0, 0); + ex1->_keyCode = g_fp->_aniMan->_okeyCode; + ex1->_excFlags |= 2; + mq->addExCommandToEnd(ex1); + + ex1 = new ExCommand(ex); + mq->addExCommandToEnd(ex1); + + mq->setFlags(mq->getFlags() | 1); + + if (mq->chain(g_fp->_aniMan)) { + if (g_vars->scene04_ladder) + delete g_vars->scene04_ladder; + + g_vars->scene04_ladder = 0; + g_vars->scene04_dudeOnLadder = 0; + + ex->_messageKind = 0; + + mc->setEnabled(); + getGameLoaderInteractionController()->enableFlag24(); + } else { + delete mq; + } + + if (g_vars->scene04_bigBallIn) { + sceneHandler04_bigBallOut(); + return; + } + } + } + } + } } void sceneHandler04_handTake() { @@ -717,27 +1135,27 @@ void sceneHandler04_handTake() { if (g_vars->scene04_kozyawkiAni.size()) { if (g_vars->scene04_kozyawkiAni.size() == 1) { chainQueue(QU_HND_TAKE1, 0); - g_vars->scene04_var19 = 0; + g_vars->scene04_objectIsTaken = false; } else { chainQueue((g_vars->scene04_kozyawkiAni.size() != 2) ? QU_HND_TAKEBOTTLE : QU_HND_TAKE2, 0); - g_vars->scene04_var19 = 0; + g_vars->scene04_objectIsTaken = false; } } else { chainQueue(QU_HND_TAKE0, 0); - g_vars->scene04_var19 = 0; + g_vars->scene04_objectIsTaken = false; } } -void sceneHandler04_sub9(StaticANIObject *ani) { +void sceneHandler04_putKozyawkaBack(StaticANIObject *ani) { g_vars->scene04_bottleObjList.push_back(ani); g_vars->scene04_kozyawkiAni.push_back(ani); g_vars->scene04_bottleWeight += 2; g_vars->scene04_walkingKozyawka = 0; - g_vars->scene04_var24 = 0; + g_vars->scene04_lastKozyawka = 0; if (g_vars->scene04_kozyawkiAni.size() > 1 ) - g_vars->scene04_var19 = 0; + g_vars->scene04_objectIsTaken = false; if (g_vars->scene04_kozyawkiAni.size() <= 2 || g_vars->scene04_hand->_movement) { sceneHandler04_walkKozyawka(); @@ -747,39 +1165,39 @@ void sceneHandler04_sub9(StaticANIObject *ani) { } } -void sceneHandler04_sub17() { - StaticANIObject *ball = g_fullpipe->_currentScene->getStaticANIObject1ById(ANI_BIGBALL, -1); +void sceneHandler04_bigBallWalkIn() { + StaticANIObject *ball = g_fp->_currentScene->getStaticANIObject1ById(ANI_BIGBALL, -1); if (g_vars->scene04_dudeOnLadder && (!ball || !(ball->_flags & 4)) - && g_vars->scene04_ladder->collisionDetection(g_fullpipe->_aniMan) > 3) { + && g_vars->scene04_ladder->collisionDetection(g_fp->_aniMan) > 3) { - if (!g_fullpipe->_rnd->getRandomNumber(49)) { - if (g_vars->scene04_var15) + if (!g_fp->_rnd->getRandomNumber(49)) { + if (g_vars->scene04_bigBallFromLeft) chainQueue(QU_BALL_WALKR, 0); else chainQueue(QU_BALL_WALKL, 0); - g_vars->scene04_var15 = !g_vars->scene04_var15; + g_vars->scene04_bigBallFromLeft = !g_vars->scene04_bigBallFromLeft; sceneHandler04_checkBigBallClick(); - g_vars->scene04_var14 = 0; + g_vars->scene04_bigBallCounter = 0; } } } void sceneHandler04_takeBottle() { - g_vars->scene04_var02 = 1; + g_vars->scene04_bottleIsTaken = true; g_vars->scene04_hand->_priority = 5; - g_fullpipe->setObjectState(sO_LowerPipe, g_fullpipe->getObjectEnumState(sO_LowerPipe, sO_IsOpened)); + g_fp->setObjectState(sO_LowerPipe, g_fp->getObjectEnumState(sO_LowerPipe, sO_IsOpened)); } void sceneHandler04_takeKozyawka() { if (g_vars->scene04_kozyawkiAni.size() > 0) { if (g_vars->scene04_kozyawkiAni.size() == 1) - g_vars->scene04_var19 = 1; + g_vars->scene04_objectIsTaken = true; StaticANIObject *koz = g_vars->scene04_kozyawkiAni.front(); g_vars->scene04_kozyawkiAni.pop_front(); @@ -802,7 +1220,7 @@ void sceneHandler04_takeKozyawka() { } void sceneHandler04_testPlank(ExCommand *ex) { - MessageQueue *mq = g_fullpipe->_globalMessageQueueList->getMessageQueueById(ex->_parId); + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(ex->_parId); if (!mq) return; @@ -832,7 +1250,7 @@ void sceneHandler04_updateBottle() { } void sceneHandler04_winArcade() { - if (g_fullpipe->getObjectState(sO_LowerPipe) == g_fullpipe->getObjectEnumState(sO_LowerPipe, sO_IsClosed) + if (g_fp->getObjectState(sO_LowerPipe) == g_fp->getObjectEnumState(sO_LowerPipe, sO_IsClosed) && g_vars->scene04_soundPlaying) { g_vars->scene04_clock->changeStatics2(ST_CLK_CLOSED); g_vars->scene04_hand->changeStatics2(ST_HND_EMPTY); @@ -847,14 +1265,14 @@ void sceneHandler04_winArcade() { g_vars->scene04_walkingKozyawka = 0; } - g_vars->scene04_var19 = 0; - g_vars->scene04_soundPlaying = 0; + g_vars->scene04_objectIsTaken = false; + g_vars->scene04_soundPlaying = false; - getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId)->setEnabled(); + getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->setEnabled(); getGameLoaderInteractionController()->enableFlag24(); - g_fullpipe->stopSoundStream2(); + g_fp->stopSoundStream2(); } } @@ -876,16 +1294,16 @@ int sceneHandler04(ExCommand *ex) { break; case MSG_SHAKEBOTTLE: - if (!g_vars->scene04_var02) - ++g_vars->scene04_var20; + if (!g_vars->scene04_bottleIsTaken) + ++g_vars->scene04_springOffset; break; case MSG_STARTHAND: - g_vars->scene04_var09 = 1; - g_vars->scene04_coinPut = 0; + g_vars->scene04_handIsDown = true; + g_vars->scene04_coinPut = false; - if (g_vars->scene04_var10) - sceneHandler04_sub1(0); + if (g_vars->scene04_dudeInBottle) + sceneHandler04_animOutOfBottle(0); sceneHandler04_handTake(); sceneHandler04_stopSound(); @@ -929,93 +1347,93 @@ int sceneHandler04(ExCommand *ex) { case 33: { - g_vars->scene04_dudePosX = g_fullpipe->_aniMan->_ox; - g_vars->scene04_dudePosY = g_fullpipe->_aniMan->_oy; + g_vars->scene04_dudePosX = g_fp->_aniMan->_ox; + g_vars->scene04_dudePosY = g_fp->_aniMan->_oy; int res = 0; - if (g_fullpipe->_aniMan2) { - if (g_fullpipe->_aniMan->_ox < g_fullpipe->_sceneRect.left + 200) { - g_fullpipe->_currentScene->_x = g_fullpipe->_aniMan->_ox - g_fullpipe->_sceneRect.left - 300; - g_fullpipe->_aniMan->_ox = g_vars->scene04_dudePosX; + if (g_fp->_aniMan2) { + if (g_fp->_aniMan->_ox < g_fp->_sceneRect.left + 200) { + g_fp->_currentScene->_x = g_fp->_aniMan->_ox - g_fp->_sceneRect.left - 300; + g_fp->_aniMan->_ox = g_vars->scene04_dudePosX; } - if (g_fullpipe->_aniMan->_ox > g_fullpipe->_sceneRect.right - 200) { - g_fullpipe->_currentScene->_x = g_fullpipe->_aniMan->_ox - g_fullpipe->_sceneRect.right + 300; + if (g_fp->_aniMan->_ox > g_fp->_sceneRect.right - 200) { + g_fp->_currentScene->_x = g_fp->_aniMan->_ox - g_fp->_sceneRect.right + 300; } res = 1; if (g_vars->scene04_soundPlaying) { - if (g_fullpipe->_aniMan->_movement) { - if (g_fullpipe->_aniMan->_movement->_id == MV_MAN_TOLADDER) { - g_fullpipe->_aniMan2 = 0; + if (g_fp->_aniMan->_movement) { + if (g_fp->_aniMan->_movement->_id == MV_MAN_TOLADDER) { + g_fp->_aniMan2 = 0; - if (g_fullpipe->_sceneRect.left > 380) - g_fullpipe->_currentScene->_x = 380 - g_fullpipe->_sceneRect.left; + if (g_fp->_sceneRect.left > 380) + g_fp->_currentScene->_x = 380 - g_fp->_sceneRect.left; } } } } else { - if (g_fullpipe->_aniMan->_movement && g_fullpipe->_aniMan->_movement->_id == MV_MAN_GOD) - g_fullpipe->_aniMan2 = g_fullpipe->_aniMan; + if (g_fp->_aniMan->_movement && g_fp->_aniMan->_movement->_id == MV_MAN_GOD) + g_fp->_aniMan2 = g_fp->_aniMan; } sceneHandler04_springWobble(); - if (g_vars->scene04_var07 && !g_vars->scene04_var09) - sceneHandler04_sub5(); + if (g_vars->scene04_var07 && !g_vars->scene04_handIsDown) + sceneHandler04_leaveScene(); - if (g_vars->scene04_var12) + if (g_vars->scene04_bottleIsDropped) sceneHandler04_liftBottle(); - if (g_vars->scene04_var08) + if (g_vars->scene04_ladderClickable) sceneHandler04_clickLadder(); - if (g_vars->scene04_var10 && g_vars->scene04_hand->_movement) - sceneHandler04_sub1(0); + if (g_vars->scene04_dudeInBottle && g_vars->scene04_hand->_movement) + sceneHandler04_animOutOfBottle(0); - if (g_vars->scene04_coinPut && g_vars->scene04_var18 && !g_vars->scene04_var09 && !g_vars->scene04_soundPlaying) + if (g_vars->scene04_coinPut && g_vars->scene04_clockCanGo && !g_vars->scene04_handIsDown && !g_vars->scene04_soundPlaying) sceneHandler04_goClock(); if (g_vars->scene04_dudeOnLadder) { if (!g_vars->scene04_soundPlaying) { - g_fullpipe->startSceneTrack(); + g_fp->startSceneTrack(); - g_fullpipe->_behaviorManager->updateBehaviors(); + g_fp->_behaviorManager->updateBehaviors(); return res; } - g_vars->scene04_var14++; + g_vars->scene04_bigBallCounter++; - if (g_vars->scene04_var14 > 600) - sceneHandler04_sub17(); + if (g_vars->scene04_bigBallCounter > 600) + sceneHandler04_bigBallWalkIn(); } if (g_vars->scene04_soundPlaying) { - g_fullpipe->_behaviorManager->updateBehaviors(); + g_fp->_behaviorManager->updateBehaviors(); return res; } - g_fullpipe->startSceneTrack(); + g_fp->startSceneTrack(); - g_fullpipe->_behaviorManager->updateBehaviors(); + g_fp->_behaviorManager->updateBehaviors(); return res; } case 29: { - int picid = g_fullpipe->_currentScene->getPictureObjectIdAtPos(ex->_sceneClickX, ex->_sceneClickY); + int picid = g_fp->_currentScene->getPictureObjectIdAtPos(ex->_sceneClickX, ex->_sceneClickY); - if (g_vars->scene04_var10) { - sceneHandler04_sub1(ex); + if (g_vars->scene04_dudeInBottle) { + sceneHandler04_animOutOfBottle(ex); break; } if (picid == PIC_SC4_LADDER) { - if (!g_vars->scene04_var04) { + if (!g_vars->scene04_kozyawkaOnLadder) { g_vars->scene04_sceneClickX = ex->_sceneClickX; g_vars->scene04_sceneClickY = ex->_sceneClickY; @@ -1031,21 +1449,21 @@ int sceneHandler04(ExCommand *ex) { break; } - StaticANIObject *ani = g_fullpipe->_currentScene->getStaticANIObjectAtPos(ex->_sceneClickX, ex->_sceneClickY); + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObjectAtPos(ex->_sceneClickX, ex->_sceneClickY); if ((ani && ani->_id == ANI_PLANK) || picid == PIC_SC4_PLANK) { sceneHandler04_clickPlank(); ex->_messageKind = 0; } else if (g_vars->scene04_dudeOnLadder) { - sceneHandler04_sub8(ex); - } else if (!ani || !canInteractAny(g_fullpipe->_aniMan, ani, ex->_keyCode)) { - PictureObject *pic = g_fullpipe->_currentScene->getPictureObjectById(picid, 0); - - if (!pic || !canInteractAny(g_fullpipe->_aniMan, pic,ex->_keyCode)) { - if ((g_fullpipe->_sceneRect.right - ex->_sceneClickX < 47 && g_fullpipe->_sceneRect.right < g_fullpipe->_sceneWidth - 1) - || (ex->_sceneClickX - g_fullpipe->_sceneRect.left < 47 && g_fullpipe->_sceneRect.left > 0)) - g_fullpipe->processArcade(ex); + sceneHandler04_leaveLadder(ex); + } else if (!ani || !canInteractAny(g_fp->_aniMan, ani, ex->_keyCode)) { + PictureObject *pic = g_fp->_currentScene->getPictureObjectById(picid, 0); + + if (!pic || !canInteractAny(g_fp->_aniMan, pic,ex->_keyCode)) { + if ((g_fp->_sceneRect.right - ex->_sceneClickX < 47 && g_fp->_sceneRect.right < g_fp->_sceneWidth - 1) + || (ex->_sceneClickX - g_fp->_sceneRect.left < 47 && g_fp->_sceneRect.left > 0)) + g_fp->processArcade(ex); } } } @@ -1061,8 +1479,8 @@ int sceneHandler04(ExCommand *ex) { break; case MSG_SC4_HANDOVER: - g_vars->scene04_var09 = 0; - g_vars->scene04_var19 = 1; + g_vars->scene04_handIsDown = false; + g_vars->scene04_objectIsTaken = true; break; case MSG_SC4_DROPBOTTLE: @@ -1071,14 +1489,14 @@ int sceneHandler04(ExCommand *ex) { case MSG_SC4_COINOUT: g_vars->scene04_clock->changeStatics2(ST_CLK_CLOSED); - g_vars->scene04_coinPut = 0; + g_vars->scene04_coinPut = false; sceneHandler04_stopSound(); - if (g_vars->scene04_kozyawkiAni.size() && !g_vars->scene04_var02) { - g_vars->scene04_var09 = 1; + if (g_vars->scene04_kozyawkiAni.size() && !g_vars->scene04_bottleIsTaken) { + g_vars->scene04_handIsDown = true; - if (g_vars->scene04_var10) - sceneHandler04_sub1(0); + if (g_vars->scene04_dudeInBottle) + sceneHandler04_animOutOfBottle(0); sceneHandler04_handTake(); } @@ -1089,10 +1507,10 @@ int sceneHandler04(ExCommand *ex) { { ExCommand *exnew; - if (g_vars->scene04_var11) { - sceneHandler04_sub9(g_vars->scene04_var24); + if (g_vars->scene04_kozHeadRaised) { + sceneHandler04_putKozyawkaBack(g_vars->scene04_lastKozyawka); - g_vars->scene04_var11 = 0; + g_vars->scene04_kozHeadRaised = 0; exnew = new ExCommand(0, 35, SND_4_010, 0, 0, 0, 1, 0, 0, 0); } else { @@ -1130,7 +1548,7 @@ int sceneHandler04(ExCommand *ex) { break; case MSG_SC4_COINPUT: - g_vars->scene04_coinPut = 1; + g_vars->scene04_coinPut = true; break; } diff --git a/engines/fullpipe/scenes/scene05.cpp b/engines/fullpipe/scenes/scene05.cpp new file mode 100644 index 0000000000..c6e21daf1e --- /dev/null +++ b/engines/fullpipe/scenes/scene05.cpp @@ -0,0 +1,386 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "fullpipe/fullpipe.h" + +#include "fullpipe/objects.h" +#include "fullpipe/objectnames.h" +#include "fullpipe/constants.h" +#include "fullpipe/statics.h" +#include "fullpipe/scene.h" +#include "fullpipe/motion.h" +#include "fullpipe/scenes.h" +#include "fullpipe/messages.h" +#include "fullpipe/floaters.h" +#include "fullpipe/behavior.h" + +namespace Fullpipe { + +void scene05_initScene(Scene *sc) { + g_vars->scene05_handle = sc->getStaticANIObject1ById(ANI_HANDLE, -1); + g_vars->scene05_wacko = sc->getStaticANIObject1ById(ANI_OTMOROZ, -1); + g_vars->scene05_bigHatch = sc->getStaticANIObject1ById(ANI_BIGLUK, -1); + + + g_vars->scene05_wackoTicker = 0; + g_vars->scene05_handleFlipper = 1; + g_vars->scene05_floatersTicker = 1000; + + Scene *oldscene = g_fp->_currentScene; + + g_fp->_currentScene = sc; + + if (g_fp->getObjectState(sO_WeirdWacko) == g_fp->getObjectEnumState(sO_WeirdWacko, sO_InGlasses)) { + g_vars->scene05_wacko->changeStatics2(ST_OTM_GLS_LEFT); + g_vars->scene05_bigHatch->changeStatics2(ST_BLK_CLOSED); + + g_vars->scene05_handle->changeStatics2(ST_HDL_UP); + g_vars->scene05_handle->_flags |= 4; + } else if (g_fp->getObjectState(sO_WeirdWacko) == g_fp->getObjectEnumState(sO_WeirdWacko, sO_WithDrawer)) { + g_vars->scene05_wacko->changeStatics2(ST_OTM_BOX_LEFT); + g_vars->scene05_bigHatch->changeStatics2(ST_BLK_CLOSED); + g_vars->scene05_handle->changeStatics2(ST_HDL_UP); + g_vars->scene05_handle->_flags |= 4; + } else { + g_vars->scene05_wacko->changeStatics2(ST_OTM_VNT_LEFT); + + if (g_fp->getObjectState(sO_WeirdWacko) != g_fp->getObjectEnumState(sO_WeirdWacko, sO_WithPlunger)) { + g_vars->scene05_handle->changeStatics2(ST_HDL_BROKEN); + g_vars->scene05_bigHatch->changeStatics2(ST_BLK_CLOSED); + } + } + + g_fp->_currentScene = oldscene; +} + +void sceneHandler05_makeManFlight() { + int qid; + + if (!g_vars->scene05_bigHatch->_statics || g_vars->scene05_bigHatch->_statics->_staticsId != ST_BLK_OPEN) + qid = QU_SC5_MANBUMP; + else + qid = QU_SC5_MANFLY; + + MessageQueue *mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(qid), 0, 0); + + mq->setFlags(mq->getFlags() | 1); + + mq->chain(0); +} + +void sceneHandler05_makeWackoFeedback() { + int staticsId1; + int staticsId2; + + if (g_fp->getObjectState(sO_WeirdWacko) == g_fp->getObjectEnumState(sO_WeirdWacko, sO_InGlasses)) { + staticsId1 = ST_OTM_GLS_LEFT; + staticsId2 = (g_vars->scene05_handle->_statics->_staticsId == ST_HDL_DOWN) ? MV_OTM_HANDLEUP : MV_OTM_HANDLEDOWN; + } else if (g_fp->getObjectState(sO_WeirdWacko) != g_fp->getObjectEnumState(sO_WeirdWacko, sO_WithDrawer)) { + return; + } else { + staticsId1 = ST_OTM_BOX_LEFT; + staticsId2 = (g_vars->scene05_handle->_statics->_staticsId == ST_HDL_DOWN) ? MV_OTM_BOXHANDLEUP : MV_OTM_BOXHANDLEDOWN; + } + + if (g_vars->scene05_wacko->_movement) + g_vars->scene05_wacko->changeStatics2(g_vars->scene05_wacko->_movement->_staticsObj2->_staticsId); + + if (staticsId1 == g_vars->scene05_wacko->_statics->_staticsId) { + g_vars->scene05_wacko->startAnim(staticsId2, 0, -1); + } else { + MessageQueue *mq = g_vars->scene05_wacko->changeStatics1(staticsId1); + + if (mq) { + mq->setFlags(mq->getFlags() | 1); + + ExCommand *ex = new ExCommand(0, 17, MSG_SC5_MAKEOTMFEEDBACK, 0, 0, 0, 1, 0, 0, 0); + + ex->_excFlags |= 2; + + mq->addExCommandToEnd(ex); + mq->_isFinished = 0; + } + } +} + +void sceneHandler05_resetTicks() { + if (g_fp->_aniMan->_movement && (g_fp->_aniMan->_movement->_id == MV_MANHDL_HANDLEUP + || g_fp->_aniMan->_movement->_id == MV_MANHDL_HANDLEDOWN)) + g_vars->scene05_wackoTicker = g_fp->_updateTicks; + else + g_vars->scene05_wackoTicker = 0; +} + +void sceneHandler05_genFlies() { + if (g_vars->scene05_floatersTicker <= 1000) + return; + + if (g_fp->_rnd->getRandomNumber(1)) { + int numFlies = g_fp->_rnd->getRandomNumber(3) + 1; + + for (int i = 0; i < numFlies; i++) { + int x = g_fp->_rnd->getRandomNumber(55) + 538; + int y = g_fp->_rnd->getRandomNumber(60) + i * 30 + 520; + + g_fp->_floaters->genFlies(g_fp->_currentScene, x, y, 5, 1); + g_fp->_floaters->_array2.back()->val2 = 585; + g_fp->_floaters->_array2.back()->val3 = -70; + g_fp->_floaters->_array2.back()->val11 = 8.0; + } + } + + g_vars->scene05_floatersTicker = 0; +} + +void sceneHandler05_showHandle() { + g_fp->_currentScene->getStaticANIObject1ById(ANI_HANDLE, -1)->show1(-1, -1, -1, 0); +} + +void sceneHandler05_handleDown() { + StaticANIObject *hatch = g_fp->_currentScene->getStaticANIObject1ById(ANI_BIGLUK, -1); + + hatch->changeStatics2(ST_BLK_CLOSED); + hatch->startAnim(MV_BLK_OPEN, 0, -1); + + sceneHandler05_resetTicks(); + sceneHandler05_genFlies(); +} + +void sceneHandler05_hideHandle() { + g_fp->_currentScene->getStaticANIObject1ById(ANI_HANDLE, -1)->hide(); +} + +void sceneHandler05_handleUp() { + StaticANIObject *hatch = g_fp->_currentScene->getStaticANIObject1ById(ANI_BIGLUK, -1); + + hatch->changeStatics2(ST_BLK_OPEN); + hatch->startAnim(MV_BLK_CLOSE, 0, -1); + + sceneHandler05_resetTicks(); +} + +void sceneHandler05_testHatch(ExCommand *inex) { + ExCommand *ex; + + if (g_fp->_currentScene->getStaticANIObject1ById(ANI_BIGLUK, -1)->_statics->_staticsId == ST_BLK_CLOSED) { + ex = new ExCommand(SC_5, 17, 61, 0, 0, 0, 1, 0, 0, 0); + ex->_keyCode = TrubaLeft; + ex->_excFlags |= 2; + ex->postMessage(); + + return; + } + + StaticANIObject *wacko = g_fp->_currentScene->getStaticANIObject1ById(ANI_OTMOROZ, -1); + + if (wacko->_movement) + wacko->changeStatics2(wacko->_movement->_staticsObj2->_staticsId); + + if (g_fp->getObjectState(sO_WeirdWacko) == g_fp->getObjectEnumState(sO_WeirdWacko, sO_InGlasses)) { + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(inex->_parId); + + if (mq) + mq->deleteExCommandByIndex(mq->getCount() - 1, 1); + + if (wacko->_statics->_staticsId != ST_OTM_GLS_LEFT) { + mq = wacko->changeStatics1(ST_OTM_GLS_LEFT); + + if (!mq) { + wacko->changeStatics2(ST_OTM_GLS_LEFT); + mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); + } + + mq->setFlags(mq->getFlags() | 1); + + ex = new ExCommand(ANI_OTMOROZ, 1, MV_OTM_HANDLEUP, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2u; + mq->addExCommandToEnd(ex); + + ex = new ExCommand(SC_5, 17, 61, 0, 0, 0, 1, 0, 0, 0); + ex->_keyCode = TrubaLeft; + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + + mq->_isFinished = 0; + return; + } + + mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); + mq->setFlags(mq->getFlags() | 1); + + ex = new ExCommand(ANI_OTMOROZ, 1, MV_OTM_HANDLEUP, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + + ex = new ExCommand(SC_5, 17, 61, 0, 0, 0, 1, 0, 0, 0); + ex->_keyCode = TrubaLeft; + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + + if (!mq->chain(wacko)) + delete mq; + } else if (g_fp->getObjectState(sO_WeirdWacko) == g_fp->getObjectEnumState(sO_WeirdWacko, sO_WithDrawer)) { + MessageQueue *mq = g_fp->_globalMessageQueueList->getMessageQueueById(inex->_parId); + + if (mq) + mq->deleteExCommandByIndex(mq->getCount() - 1, 1); + + if (wacko->_statics->_staticsId != ST_OTM_BOX_LEFT) { + mq = wacko->changeStatics1(ST_OTM_BOX_LEFT); + if (!mq) { + wacko->changeStatics2(ST_OTM_BOX_LEFT); + mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); + } + + mq->setFlags(mq->getFlags() | 1); + + ex = new ExCommand(ANI_OTMOROZ, 1, MV_OTM_BOXHANDLEUP, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + + ex = new ExCommand(SC_5, 17, 61, 0, 0, 0, 1, 0, 0, 0); + ex->_keyCode = TrubaLeft; + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + + mq->_isFinished = 0; + + return; + } + + mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); + mq->setFlags(mq->getFlags() | 1); + + ex = new ExCommand(ANI_OTMOROZ, 1, MV_OTM_BOXHANDLEUP, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + + ex = new ExCommand(SC_5, 17, 61, 0, 0, 0, 1, 0, 0, 0); + ex->_keyCode = TrubaLeft; + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + + if (!mq->chain(wacko)) + delete mq; + + return; + } else { + ex = new ExCommand(SC_5, 17, 61, 0, 0, 0, 1, 0, 0, 0); + ex->_keyCode = TrubaLeft; + ex->_excFlags |= 2; + ex->postMessage(); + + return; + } +} + + +int sceneHandler05(ExCommand *ex) { + if (ex->_messageKind != 17) + return 0; + + switch (ex->_messageNum) { + case MSG_SC5_BGRSOUNDOFF: + g_fp->stopAllSoundInstances(SND_5_026); + break; + + case MSG_SC5_BGRSOUNDON: + g_fp->playSound(SND_5_026, 1); + break; + + case MSG_SC5_MAKEMANFLIGHT: + sceneHandler05_makeManFlight(); + break; + + case MSG_SC5_MAKEOTMFEEDBACK: + if (!g_fp->_aniMan->_movement || (g_fp->_aniMan->_movement->_id != MV_MANHDL_HANDLEUP + && g_fp->_aniMan->_movement->_id != MV_MANHDL_HANDLEDOWN)) { + sceneHandler05_makeWackoFeedback(); + g_vars->scene05_wackoTicker = 0; + } + break; + + case MSG_SC5_SHOWHANDLE: + sceneHandler05_showHandle(); + break; + + case MSG_SC5_HANDLEDOWN: + g_vars->scene05_handle->changeStatics2(ST_HDL_DOWN); + sceneHandler05_handleDown(); + break; + + case MSG_SC5_HIDEHANDLE: + sceneHandler05_hideHandle(); + break; + + case MSG_SC5_HANDLEUP: + g_vars->scene05_handle->changeStatics2(ST_HDL_UP); + sceneHandler05_handleUp(); + break; + + case MSG_SC5_TESTLUK: + sceneHandler05_testHatch(ex); + break; + + case 33: + { + int res = 0; + if (g_fp->_aniMan2) { + if (g_fp->_aniMan2->_ox < g_fp->_sceneRect.left + 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.left - 300; + + if (g_fp->_aniMan2->_ox > g_fp->_sceneRect.right - 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.right + 300; + + res = 1; + } + + if (g_vars->scene05_wackoTicker) { + if ((g_fp->_updateTicks - g_vars->scene05_wackoTicker) > 62) { + if (!g_fp->_aniMan->_movement || (g_fp->_aniMan->_movement->_id != MV_MANHDL_HANDLEUP + && g_fp->_aniMan->_movement->_id != MV_MANHDL_HANDLEDOWN)) { + if (g_vars->scene05_handleFlipper % 2) + sceneHandler05_makeWackoFeedback(); + + g_vars->scene05_wackoTicker = 0; + + ++g_vars->scene05_handleFlipper; + } + } + } + + ++g_vars->scene05_floatersTicker; + + g_fp->_floaters->update(); + + g_fp->_behaviorManager->updateBehaviors(); + + g_fp->startSceneTrack(); + + return res; + } + } + + return 0; +} + +} // End of namespace Fullpipe diff --git a/engines/fullpipe/scenes/scene06.cpp b/engines/fullpipe/scenes/scene06.cpp new file mode 100644 index 0000000000..c352d27dd6 --- /dev/null +++ b/engines/fullpipe/scenes/scene06.cpp @@ -0,0 +1,770 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "fullpipe/fullpipe.h" + +#include "fullpipe/objects.h" +#include "fullpipe/objectnames.h" +#include "fullpipe/constants.h" +#include "fullpipe/gfx.h" +#include "fullpipe/motion.h" +#include "fullpipe/scenes.h" +#include "fullpipe/statics.h" +#include "fullpipe/scene.h" +#include "fullpipe/messages.h" +#include "fullpipe/gameloader.h" +#include "fullpipe/behavior.h" +#include "fullpipe/interaction.h" + +namespace Fullpipe { + +void scene06_initMumsy() { + g_vars->scene06_mumsyJumpFw = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(g_vars->scene06_mumsy, ST_MOM_STANDS, QU_MOM_JUMPFW); + g_vars->scene06_mumsyJumpBk = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(g_vars->scene06_mumsy, ST_MOM_STANDS, QU_MOM_JUMPBK); + g_vars->scene06_mumsyJumpFwPercent = g_vars->scene06_mumsyJumpFw->_percent; + g_vars->scene06_mumsyJumpBkPercent = g_vars->scene06_mumsyJumpBk->_percent; +} + +int scene06_updateCursor() { + g_fp->updateCursorCommon(); + + if (g_vars->scene06_arcadeEnabled) { + if (g_vars->scene06_aimingBall) { + g_fp->_cursorId = PIC_CSR_ARCADE2_D; + + return PIC_CSR_ARCADE2_D; + } + if (g_fp->_aniMan == (StaticANIObject *)g_fp->_objectAtCursor) { + if (g_fp->_aniMan->_statics->_staticsId == ST_MAN6_BALL && g_fp->_cursorId == PIC_CSR_DEFAULT) { + g_fp->_cursorId = PIC_CSR_ITN; + + return PIC_CSR_ITN; + } + } else if (g_fp->_objectAtCursor && (StaticANIObject *)g_fp->_objectAtCursor == g_vars->scene06_currentBall + && g_fp->_cursorId == PIC_CSR_DEFAULT) { + g_fp->_cursorId = PIC_CSR_ITN; + } + } + + return g_fp->_cursorId; +} + +void sceneHandler06_setExits(Scene *sc) { + MotionController *mc = getSc2MctlCompoundBySceneId(sc->_sceneId); + + mc->enableLinks(sO_CloseThing, (g_fp->getObjectState(sO_BigMumsy) != g_fp->getObjectEnumState(sO_BigMumsy, sO_IsGone))); + mc->enableLinks(sO_CloseThing2, g_vars->scene06_arcadeEnabled); +} + +void sceneHandler06_winArcade() { + g_fp->setObjectState(sO_BigMumsy, g_fp->getObjectEnumState(sO_BigMumsy, sO_IsGone)); + + if (g_fp->getObjectState(sO_ClockAxis) == g_fp->getObjectEnumState(sO_ClockAxis, sO_IsNotAvailable)) + g_fp->setObjectState(sO_ClockAxis, g_fp->getObjectEnumState(sO_ClockAxis, sO_WithoutHandle)); + + if (g_vars->scene06_arcadeEnabled) { + g_fp->_aniMan->_callback2 = 0; + + g_fp->_aniMan->changeStatics2(ST_MAN_RIGHT | 0x4000); + + if (g_vars->scene06_someBall) { + g_vars->scene06_someBall->_flags &= 0xFFFB; + + g_vars->scene06_balls.push_back(g_vars->scene06_someBall); + + g_vars->scene06_someBall = 0; + } + + if (g_vars->scene06_flyingBall) { + g_vars->scene06_flyingBall->_flags &= 0xFFFB; + + g_vars->scene06_balls.push_back(g_vars->scene06_flyingBall); + + g_vars->scene06_flyingBall = 0; + } + + if (g_vars->scene06_ballInHands) { + g_vars->scene06_ballInHands->_flags &= 0xFFFB; + + g_vars->scene06_balls.push_back(g_vars->scene06_ballInHands); + + g_vars->scene06_ballInHands = 0; + } + + g_vars->scene06_arcadeEnabled = false; + g_vars->scene06_aimingBall = false; + } + + g_vars->scene06_mumsy->_flags &= 0xFFFB; + + sceneHandler06_setExits(g_fp->_currentScene); + + getCurrSceneSc2MotionController()->setEnabled(); + getGameLoaderInteractionController()->enableFlag24(); +} + +void sceneHandler06_enableDrops() { + chainQueue(QU_SC6_DROPS, 0); + + g_vars->scene06_mumsy->changeStatics2(ST_MOM_SITS); + g_fp->setObjectState(sO_BigMumsy, g_fp->getObjectEnumState(sO_BigMumsy, sO_IsPlaying)); + + chainQueue(QU_MOM_STANDUP, 1); + + g_vars->scene06_arcadeEnabled = true; + g_vars->scene06_numBallsGiven = 0; + g_vars->scene06_mumsyPos = 0; + g_vars->scene06_mumsyNumBalls = 0; + g_vars->scene06_mumsyGotBall = false; + + sceneHandler06_setExits(g_fp->_currentScene); +} + +void sceneHandler06_mumsyBallTake() { + int momAni = 0; + + switch (g_vars->scene06_mumsyNumBalls) { + case 1: + momAni = MV_MOM_TAKE1; + break; + case 2: + momAni = MV_MOM_TAKE2; + break; + case 3: + momAni = MV_MOM_TAKE3; + break; + case 4: + momAni = MV_MOM_TAKE4; + break; + case 5: + momAni = MV_MOM_TAKE5; + break; + } + + MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); + + ExCommand *ex = new ExCommand(ANI_MAMASHA, 2, 50, 0, 0, 0, 1, 0, 0, 0); + + ex->_excFlags = 2u; + mq->addExCommandToEnd(ex); + + if (g_vars->scene06_mumsyNumBalls >= 5) { + g_fp->setObjectState(sO_BigMumsy, g_fp->getObjectEnumState(sO_BigMumsy, sO_IsGone)); + + if (g_fp->getObjectState(sO_ClockAxis) == g_fp->getObjectEnumState(sO_ClockAxis, sO_IsNotAvailable)) + g_fp->setObjectState(sO_ClockAxis, g_fp->getObjectEnumState(sO_ClockAxis, sO_WithoutHandle)); + + ex = new ExCommand(ANI_MAMASHA, 1, momAni, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + + if (g_vars->scene06_mumsyPos + 3 >= 0) { + ex = new ExCommand(ANI_MAMASHA, 1, MV_MOM_STARTBK, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2u; + mq->addExCommandToEnd(ex); + + for (int i = 0; i < g_vars->scene06_mumsyPos + 3; i++) { + ex = new ExCommand(ANI_MAMASHA, 1, MV_MOM_CYCLEBK, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + } + + ex = new ExCommand(ANI_MAMASHA, 1, MV_MOM_STOPBK, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + } + + ex = new ExCommand(0, 18, QU_MOM_TOLIFT, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 3; + mq->addExCommandToEnd(ex); + } else { + if (momAni) { + ex = new ExCommand(ANI_MAMASHA, 1, momAni, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + } + + if (g_vars->scene06_mumsyPos < 0) { + for (int i = 0; i > g_vars->scene06_mumsyPos; i--) { + ex = new ExCommand(ANI_MAMASHA, 1, MV_MOM_JUMPFW, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + } + } else if (g_vars->scene06_mumsyPos > 0) { + for (int i = 0; i < g_vars->scene06_mumsyPos; i++) { + ex = new ExCommand(ANI_MAMASHA, 1, MV_MOM_JUMPBK, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + mq->addExCommandToEnd(ex); + } + } + + ex = new ExCommand(0, 18, QU_MOM_SITDOWN, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 3u; + mq->addExCommandToEnd(ex); + } + + mq->setFlags(mq->getFlags() | 1); + mq->chain(0); + + g_vars->scene06_mumsyNumBalls = 0; + g_vars->scene06_arcadeEnabled = false; + + g_fp->_aniMan2 = 0; +} + +void sceneHandler06_spinHandle() { + int tummy = g_fp->getObjectState(sO_TummyTrampie); + + if (tummy == g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsEating)) + g_fp->setObjectState(sO_TummyTrampie, g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsSleeping)); + else if (tummy == g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsSleeping)) + g_fp->setObjectState(sO_TummyTrampie, g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsDrinking)); + else if (tummy == g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsDrinking)) + g_fp->setObjectState(sO_TummyTrampie, g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsScratchingBelly)); + else if (tummy == g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsScratchingBelly)) + g_fp->setObjectState(sO_TummyTrampie, g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsEating)); +} + +void sceneHandler06_uPipeClick() { + if (getGameLoaderInteractionController()->_flag24) + handleObjectInteraction(g_fp->_aniMan2, g_fp->_currentScene->getPictureObjectById(PIC_SC6_LADDER, 0), 0); +} + +void sceneHandler06_buttonPush() { + g_vars->scene06_invHandle = g_fp->_currentScene->getStaticANIObject1ById(ANI_INV_HANDLE, -1); + + if (g_vars->scene06_invHandle) + if (g_vars->scene06_invHandle->_flags & 4) + if (g_vars->scene06_invHandle->_statics) + if (g_vars->scene06_invHandle->_statics->_staticsId == ST_HDL_PLUGGED) + chainQueue(QU_SC6_FALLHANDLE, 1); +} + +void sceneHandler06_showNextBall() { + if (g_vars->scene06_balls.size()) { + g_vars->scene06_currentBall = new StaticANIObject(g_vars->scene06_balls.front()); + g_vars->scene06_balls.remove_at(0); + + MessageQueue *mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC6_SHOWNEXTBALL), 0, 1); + + mq->replaceKeyCode(-1, g_vars->scene06_currentBall->_okeyCode); + mq->chain(0); + + ++g_vars->scene06_numBallsGiven; + } +} + +void sceneHandler06_installHandle() { + chainQueue(QU_SC6_SHOWHANDLE, 0); +} + +int sceneHandler06_updateScreenCallback() { + int res; + + res = g_fp->drawArcadeOverlay(g_vars->scene06_arcadeEnabled); + + if (!res) + g_fp->_updateScreenCallback = 0; + + return res; +} + +void sceneHandler06_startAiming() { + if (g_vars->scene06_currentBall) { + g_vars->scene06_currentBall->hide(); + + g_fp->_aniMan->startAnim(MV_MAN6_TAKEBALL, 0, -1); + + g_vars->scene06_ballInHands = g_vars->scene06_currentBall; + g_vars->scene06_currentBall = 0; + + if (getCurrSceneSc2MotionController()->_isEnabled) + g_fp->_updateScreenCallback = sceneHandler06_updateScreenCallback; + + getCurrSceneSc2MotionController()->clearEnabled(); + getGameLoaderInteractionController()->disableFlag24(); + + g_vars->scene06_ballDrop->queueMessageQueue(0); + } +} + +void sceneHandler06_takeBall() { + if (g_vars->scene06_currentBall && !g_vars->scene06_currentBall->_movement && g_vars->scene06_currentBall->_statics->_staticsId == ST_NBL_NORM) { + if (abs(1158 - g_fp->_aniMan->_ox) > 1 + || abs(452 - g_fp->_aniMan->_oy) > 1 + || g_fp->_aniMan->_movement + || g_fp->_aniMan->_statics->_staticsId != (0x4000 | ST_MAN_RIGHT)) { + MessageQueue *mq = getCurrSceneSc2MotionController()->method34(g_fp->_aniMan, 1158, 452, 1, (0x4000 | ST_MAN_RIGHT)); + + if (mq) { + ExCommand *ex = new ExCommand(0, 17, MSG_SC6_TAKEBALL, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 3; + mq->addExCommandToEnd(ex); + + postExCommand(g_fp->_aniMan->_id, 2, 1158, 452, 0, -1); + } + } else { + sceneHandler06_startAiming(); + } + } +} + +void sceneHandler06_aiming() { + if (g_vars->scene06_ballInHands) { + g_vars->scene06_ballDeltaX = 4 * g_fp->_aniMan->_movement->_currDynamicPhaseIndex + 16; + g_vars->scene06_ballDeltaY = 5 * (g_fp->_aniMan->_movement->_currDynamicPhaseIndex + 4); + + if (g_fp->_aniMan->_movement->_currDynamicPhaseIndex < 4) { + g_fp->_aniMan->_movement->setDynamicPhaseIndex(11); + + g_vars->scene06_aimingBall = false; + + return; + } + + g_fp->_aniMan->_movement->setDynamicPhaseIndex(9); + } + + g_vars->scene06_aimingBall = false; +} + +void sceneHandler06_ballStartFly() { + if (g_vars->scene06_ballInHands) { + g_vars->scene06_flyingBall = g_vars->scene06_ballInHands; + g_vars->scene06_ballInHands = 0; + g_vars->scene06_flyingBall->show1(g_fp->_aniMan->_ox - 60, g_fp->_aniMan->_oy - 60, -1, 0); + + g_vars->scene06_flyingBall->_priority = 27; + } +} + +void sceneHandler06_throwCallback(int *arg) { + if (g_vars->scene06_aimingBall) { + int dist = (g_fp->_mouseVirtY - g_vars->scene06_sceneClickY) + * (g_fp->_mouseVirtY - g_vars->scene06_sceneClickY) + + (g_fp->_mouseVirtX - g_vars->scene06_sceneClickX) + * (g_fp->_mouseVirtX - g_vars->scene06_sceneClickX); + + *arg = (int)(sqrt((double)dist) * 0.1); + + if (*arg > 8) + *arg = 8; + } else { + *arg = *arg + 1; + if (*arg == 12) + sceneHandler06_ballStartFly(); + } +} + +void sceneHandler06_throwBall() { + g_fp->_aniMan->_callback2 = sceneHandler06_throwCallback; + g_fp->_aniMan->startAnim(MV_MAN6_THROWBALL, 0, -1); + + g_vars->scene06_aimingBall = true; +} + +void sceneHandler06_eggieWalk() { + if (15 - g_vars->scene06_numBallsGiven >= 4 && !g_fp->_rnd->getRandomNumber(9)) { + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObject1ById(ANI_EGGIE, -1); + + if (!ani || !(ani->_flags & 4)) { + if (g_vars->scene06_eggieDirection) + chainQueue(QU_EGG6_GOR, 0); + else + chainQueue(QU_EGG6_GOL, 0); + + g_vars->scene06_eggieTimeout = 0; + g_vars->scene06_eggieDirection = !g_vars->scene06_eggieDirection; + } + } +} + +void sceneHandler06_dropBall() { + if (g_vars->scene06_numBallsGiven >= 15 || g_vars->scene06_mumsyNumBalls >= 5) + g_vars->scene06_ballDrop->hide(); + else + chainQueue(QU_SC6_DROPS3, 0); +} + +void sceneHandler06_fallBall() { + g_vars->scene06_ballY = 475; + + g_vars->scene06_flyingBall->setOXY(g_vars->scene06_ballX, g_vars->scene06_ballY); + + MessageQueue *mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC6_FALLBALL), 0, 1); + + mq->replaceKeyCode(-1, g_vars->scene06_flyingBall->_okeyCode); + mq->chain(0); + + g_vars->scene06_balls.push_back(g_vars->scene06_flyingBall); + + g_vars->scene06_flyingBall = 0; + + sceneHandler06_dropBall(); + sceneHandler06_eggieWalk(); +} + +void sceneHandler06_catchBall() { + if (g_vars->scene06_flyingBall) { + g_vars->scene06_flyingBall->hide(); + + g_vars->scene06_balls.push_back(g_vars->scene06_flyingBall); + + g_vars->scene06_flyingBall = 0; + + g_vars->scene06_mumsyNumBalls++; + + if (g_vars->scene06_mumsy->_movement) { + Common::Point point; + + if (g_vars->scene06_mumsy->_movement->_id == MV_MOM_JUMPFW) { + if (g_vars->scene06_mumsy->_movement->_currDynamicPhaseIndex <= 5) { + g_vars->scene06_mumsy->_movement->calcSomeXY(point, 0); + + point.x = -point.x; + point.y = -point.y; + } else { + g_vars->scene06_mumsy->_movement->calcSomeXY(point, 1); + + g_vars->scene06_mumsyPos++; + } + } else if (g_vars->scene06_mumsy->_movement->_id == MV_MOM_JUMPBK) { + if (g_vars->scene06_mumsy->_movement->_currDynamicPhaseIndex <= 4) { + g_vars->scene06_mumsy->_movement->calcSomeXY(point, 0); + + point.x = -point.x; + point.y = -point.y; + } else { + g_vars->scene06_mumsy->_movement->calcSomeXY(point, 1); + + g_vars->scene06_mumsyPos--; + } + } + + g_vars->scene06_mumsy->changeStatics2(ST_MOM_STANDS); + g_vars->scene06_mumsy->setOXY(point.x + g_vars->scene06_mumsy->_ox, + point.y + g_vars->scene06_mumsy->_oy); + } else { + g_vars->scene06_mumsy->changeStatics2(ST_MOM_STANDS); + } + + chainQueue(QU_MOM_PUTBALL, 1); + g_vars->scene06_mumsyGotBall = true; + + sceneHandler06_dropBall(); + } +} + +void sceneHandler06_checkBallTarget(int par) { + int pixel; + + if (g_vars->scene06_ballY <= 475) { + if (g_vars->scene06_mumsy->getPixelAtPos(g_vars->scene06_ballX, g_vars->scene06_ballY, &pixel)) { + if (pixel) { + chainObjQueue(g_vars->scene06_mumsy, QU_MOM_JUMPBK, 0); + + sceneHandler06_catchBall(); + } + } + } else { + sceneHandler06_fallBall(); + } +} + +void scene06_initScene(Scene *sc) { + g_vars->scene06_mumsy = sc->getStaticANIObject1ById(ANI_MAMASHA, -1); + g_vars->scene06_someBall = 0; + g_vars->scene06_invHandle = sc->getStaticANIObject1ById(ANI_INV_HANDLE, -1); + g_vars->scene06_liftButton = sc->getStaticANIObject1ById(ANI_BUTTON_6, -1); + g_vars->scene06_ballDrop = sc->getStaticANIObject1ById(ANI_BALLDROP, -1); + g_vars->scene06_arcadeEnabled = false; + g_vars->scene06_aimingBall = false; + g_vars->scene06_currentBall = 0; + g_vars->scene06_ballInHands = 0; + g_vars->scene06_flyingBall = 0; + g_vars->scene06_balls.clear(); + g_vars->scene06_numBallsGiven = 0; + g_vars->scene06_mumsyNumBalls = 0; + g_vars->scene06_eggieTimeout = 0; + g_vars->scene06_eggieDirection = true; + + StaticANIObject *ball = sc->getStaticANIObject1ById(ANI_NEWBALL, -1); + + ball->hide(); + ball->_statics = ball->getStaticsById(ST_NBL_NORM); + g_vars->scene06_balls.push_back(ball); + + for (int i = 0; i < 3; i++) { + StaticANIObject *ball2 = new StaticANIObject(ball); + + ball2->hide(); + ball2->_statics = ball2->getStaticsById(ST_NBL_NORM); + + sc->addStaticANIObject(ball2, 1); + + g_vars->scene06_balls.push_back(ball2); + } + + if (g_fp->getObjectState(sO_BigMumsy) == g_fp->getObjectEnumState(sO_BigMumsy, sO_IsPlaying)) + g_fp->setObjectState(sO_BigMumsy, g_fp->getObjectEnumState(sO_BigMumsy, sO_IsSleeping)); + + if (g_fp->getObjectState(sO_BigMumsy) != g_fp->getObjectEnumState(sO_BigMumsy, sO_IsSleeping)) + g_vars->scene06_mumsy->hide(); + + g_fp->lift_setButton(sO_Level3, ST_LBN_3N); + g_fp->lift_sub5(sc, QU_SC6_ENTERLIFT, QU_SC6_EXITLIFT); + g_fp->initArcadeKeys("SC_6"); + + sceneHandler06_setExits(sc); + + g_fp->setArcadeOverlay(PIC_CSR_ARCADE2); +} + +int sceneHandler06(ExCommand *ex) { + if (ex->_messageKind != 17) + return 0; + + switch(ex->_messageNum) { + case MSG_LIFT_CLOSEDOOR: + g_fp->lift_closedoorSeq(); + break; + + case MSG_LIFT_EXITLIFT: + g_fp->lift_exitSeq(ex); + break; + + case MSG_CMN_WINARCADE: + sceneHandler06_winArcade(); + break; + + case MSG_LIFT_STARTEXITQUEUE: + g_fp->lift_startExitQueue(); + break; + + case MSG_SC6_RESTORESCROLL: + g_fp->_aniMan2 = g_fp->_aniMan; + getCurrSceneSc2MotionController()->setEnabled(); + getGameLoaderInteractionController()->enableFlag24(); + sceneHandler06_setExits(g_fp->_currentScene); + break; + + case MSG_SC6_STARTDROPS: + if (g_fp->getObjectState(sO_BigMumsy) == g_fp->getObjectEnumState(sO_BigMumsy, sO_IsSleeping)) + sceneHandler06_enableDrops(); + break; + + case MSG_SC6_TESTNUMBALLS: + g_vars->scene06_mumsyGotBall = false; + + if (g_vars->scene06_mumsyNumBalls < 5 || !g_vars->scene06_arcadeEnabled) + return 0; + + sceneHandler06_mumsyBallTake(); + break; + + case MSG_SC6_JUMPFW: + ++g_vars->scene06_mumsyPos; + break; + + case MSG_SC6_JUMPBK: + --g_vars->scene06_mumsyPos; + break; + + case MSG_LIFT_CLICKBUTTON: + g_fp->lift_animation3(); + break; + + case MSG_SPINHANDLE: + sceneHandler06_spinHandle(); + break; + + case MSG_LIFT_GO: + g_fp->lift_goAnimation(); + break; + + case MSG_SC6_UTRUBACLICK: + sceneHandler06_uPipeClick(); + break; + + case MSG_SC6_BTNPUSH: + sceneHandler06_buttonPush(); + break; + + case MSG_SC6_SHOWNEXTBALL: + sceneHandler06_showNextBall(); + break; + + case MSG_SC6_INSTHANDLE: + sceneHandler06_installHandle(); + break; + + case MSG_SC6_ENABLEDROPS: + sceneHandler06_enableDrops(); + break; + + case 64: + g_fp->lift_sub05(ex); + break; + + case MSG_SC6_TAKEBALL: + sceneHandler06_takeBall(); + break; + + case 30: + if (g_vars->scene06_aimingBall) { + sceneHandler06_aiming(); + break; + } + + if (!g_vars->scene06_arcadeEnabled) { + // Do nothing + break; + } + break; + + case 29: + { + StaticANIObject *st = g_fp->_currentScene->getStaticANIObjectAtPos(ex->_sceneClickX, ex->_sceneClickY); + + if (st) { + if (!g_vars->scene06_arcadeEnabled && st->_id == ANI_LIFTBUTTON) { + g_fp->lift_sub1(st); + ex->_messageKind = 0; + return 0; + } + + if (g_vars->scene06_currentBall == st) { + if (g_vars->scene06_numBallsGiven == 1) + sceneHandler06_takeBall(); + + ex->_messageKind = 0; + } else if (g_vars->scene06_ballInHands && g_fp->_aniMan == st && !g_fp->_aniMan->_movement && g_fp->_aniMan->_statics->_staticsId == ST_MAN6_BALL) { + g_vars->scene06_sceneClickX = ex->_sceneClickX; + g_vars->scene06_sceneClickY = ex->_sceneClickY; + + sceneHandler06_throwBall(); + } + } + + if (!st || !canInteractAny(g_fp->_aniMan, st, ex->_keyCode)) { + int picId = g_fp->_currentScene->getPictureObjectIdAtPos(ex->_sceneClickX, ex->_sceneClickY); + PictureObject *pic = g_fp->_currentScene->getPictureObjectById(picId, 0); + + if (!pic || !canInteractAny(g_fp->_aniMan, pic, ex->_keyCode)) { + if ((g_fp->_sceneRect.right - ex->_sceneClickX < 47 + && g_fp->_sceneRect.right < g_fp->_sceneWidth - 1) + || (ex->_sceneClickX - g_fp->_sceneRect.left < 47 && g_fp->_sceneRect.left > 0)) { + g_fp->processArcade(ex); + return 0; + } + } + } + } + + break; + + case 33: + { + int res = 0; + + if (g_fp->_aniMan2) { + int ox = g_fp->_aniMan2->_ox; + int oy = g_fp->_aniMan2->_oy; + + g_vars->scene06_manX = ox; + g_vars->scene06_manY = oy; + + if (g_vars->scene06_arcadeEnabled && oy <= 470 && ox >= 1088) { + if (ox < g_fp->_sceneRect.left + 600) { + g_fp->_currentScene->_x = ox - g_fp->_sceneRect.left - 700; + ox = g_vars->scene06_manX; + } + + if (ox > g_fp->_sceneRect.right - 50) + g_fp->_currentScene->_x = ox - g_fp->_sceneRect.right + 70; + } else { + if (ox < g_fp->_sceneRect.left + 200) { + g_fp->_currentScene->_x = ox - g_fp->_sceneRect.left - 300; + ox = g_vars->scene06_manX; + } + + if (ox > g_fp->_sceneRect.right - 200) + g_fp->_currentScene->_x = ox - g_fp->_sceneRect.right + 300; + } + + res = 1; + } + if (g_vars->scene06_arcadeEnabled) { + if (g_vars->scene06_mumsyPos > -3) + g_vars->scene06_mumsyJumpBk->_percent = g_vars->scene06_mumsyJumpBkPercent; + else + g_vars->scene06_mumsyJumpBk->_percent = 0; + + if (g_vars->scene06_mumsyPos < 4) + g_vars->scene06_mumsyJumpFw->_percent = g_vars->scene06_mumsyJumpFwPercent; + else + g_vars->scene06_mumsyJumpFw->_percent = 0; + + if (g_vars->scene06_aimingBall) { + g_vars->scene06_eggieTimeout++; + + if (g_vars->scene06_eggieTimeout >= 600) + sceneHandler06_eggieWalk(); + } + } else { + g_vars->scene06_mumsyJumpFw->_percent = 0; + g_vars->scene06_mumsyJumpBk->_percent = 0; + } + + if (g_vars->scene06_flyingBall) { + g_vars->scene06_ballX = g_vars->scene06_flyingBall->_ox - g_vars->scene06_ballDeltaX; + g_vars->scene06_ballY = g_vars->scene06_flyingBall->_oy - g_vars->scene06_ballDeltaY; + + g_vars->scene06_flyingBall->setOXY(g_vars->scene06_ballX, g_vars->scene06_ballY); + + if (g_vars->scene06_ballDeltaX >= 2) + g_vars->scene06_ballDeltaX -= 2; + + g_vars->scene06_ballDeltaY -= 5; + + sceneHandler06_checkBallTarget(g_vars->scene06_ballDeltaX); + } + if (g_vars->scene06_arcadeEnabled + && !g_vars->scene06_currentBall + && !g_vars->scene06_ballInHands + && !g_vars->scene06_flyingBall + && g_vars->scene06_numBallsGiven >= 15 + && !g_vars->scene06_ballDrop->_movement + && !g_vars->scene06_mumsy->_movement + && !g_vars->scene06_mumsyGotBall) + sceneHandler06_mumsyBallTake(); + g_fp->_behaviorManager->updateBehaviors(); + g_fp->startSceneTrack(); + + return res; + } + } + + return 0; +} + +} // End of namespace Fullpipe diff --git a/engines/fullpipe/scenes/scene07.cpp b/engines/fullpipe/scenes/scene07.cpp new file mode 100644 index 0000000000..207189d151 --- /dev/null +++ b/engines/fullpipe/scenes/scene07.cpp @@ -0,0 +1,175 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "fullpipe/fullpipe.h" + +#include "fullpipe/objects.h" +#include "fullpipe/objectnames.h" +#include "fullpipe/constants.h" +#include "fullpipe/motion.h" +#include "fullpipe/scenes.h" +#include "fullpipe/scene.h" +#include "fullpipe/statics.h" +#include "fullpipe/messages.h" +#include "fullpipe/behavior.h" + +namespace Fullpipe { + +void scene07_initScene(Scene *sc) { + g_vars->scene07_lukeAnim = 0; + g_vars->scene07_lukePercent = 0; + g_vars->scene07_plusMinus = sc->getStaticANIObject1ById(ANI_PLUSMINUS, -1); + + if (g_fp->getObjectState(sO_Guard_1) == g_fp->getObjectEnumState(sO_Guard_1, sO_Off)) + g_vars->scene07_plusMinus->_statics = g_vars->scene07_plusMinus->getStaticsById(ST_PMS_MINUS); + else + g_vars->scene07_plusMinus->_statics = g_vars->scene07_plusMinus->getStaticsById(ST_PMS_PLUS); + + if (g_fp->getObjectState(sO_HareTheNooksiter) == g_fp->getObjectEnumState(sO_HareTheNooksiter, sO_WithoutHandle)) { + Scene *oldsc = g_fp->_currentScene; + + g_fp->_currentScene = sc; + + sc->getStaticANIObject1ById(ANI_CORNERSITTER, -1)->changeStatics2(ST_CST_HANDLELESS); + + g_fp->_currentScene = oldsc; + } +} + +void sceneHandler07_openLuke() { + StaticANIObject *luke = g_fp->_currentScene->getStaticANIObject1ById(ANI_LUKE, -1); + + luke->changeStatics2(ST_LUK_OPEN); + luke->show1(-1, -1, -1, 0); + + if (g_vars->scene07_lukeAnim) { + g_vars->scene07_lukeAnim->_percent = g_vars->scene07_lukePercent; + } else { + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObject1ById(ANI_CORNERSITTER, -1); + + g_vars->scene07_lukeAnim = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(ani, ST_CST_HANDLELESS, QU_CST_CLOSELUKE); + + g_vars->scene07_lukeAnim->_percent = g_vars->scene07_lukePercent; + } +} + +void sceneHandler07_closeLuke() { + g_fp->_currentScene->getStaticANIObject1ById(ANI_LUKE, -1)->changeStatics2(ST_LUK_CLOSED); + + if (!g_vars->scene07_lukeAnim) { + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObject1ById(ANI_CORNERSITTER, -1); + + g_vars->scene07_lukeAnim = g_fp->_behaviorManager->getBehaviorEntryInfoByMessageQueueDataId(ani, ST_CST_HANDLELESS, QU_CST_CLOSELUKE); + } + + g_vars->scene07_lukePercent = g_vars->scene07_lukeAnim->_percent; + g_vars->scene07_lukeAnim->_percent = 0; + + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObject1ById(ANI_HOOLIGAN, -1); + + ani->changeStatics2(ST_HGN_LUKE); + ani->show1(-1, -1, -1, 0); +} + +void sceneHandler07_hideLuke() { + g_fp->_currentScene->getStaticANIObject1ById(ANI_LUKE, -1)->hide(); + + Movement *mov = g_fp->_currentScene->getStaticANIObject1ById(ANI_CORNERSITTER, -1)->_movement; + + if (mov) { + if (mov->_id == MV_CST_CLOSELUKE) { + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObject1ById(ANI_HOOLIGAN, -1); + + ani->changeStatics2(ST_HGN_LOOK); + ani->_flags &= 0xFFFB; + } + } +} + +void sceneHandler07_showBox() { + StaticANIObject *box = g_fp->_currentScene->getStaticANIObject1ById(ANI_SC7_BOX, -1); + + box->show1(492, 474, MV_SC7_BOX_default, 0); + box->_priority = 25; +} + +void sceneHandler07_hideBox() { + g_fp->_currentScene->getStaticANIObject1ById(ANI_SC7_BOX, -1)->hide(); +} + +int sceneHandler07(ExCommand *ex) { + if (ex->_messageKind != 17) + return 0; + + switch(ex->_messageNum) { + case MSG_SC7_OPENLUKE: + sceneHandler07_openLuke(); + break; + + case MSG_SC7_PULL: + if (g_vars->scene07_plusMinus->_statics->_staticsId == ST_PMS_MINUS) + g_vars->scene07_plusMinus->_statics = g_vars->scene07_plusMinus->getStaticsById(ST_PMS_PLUS); + else + g_vars->scene07_plusMinus->_statics = g_vars->scene07_plusMinus->getStaticsById(ST_PMS_MINUS); + + break; + + case MSG_SC7_CLOSELUKE: + sceneHandler07_closeLuke(); + break; + + case MSG_SC7_HIDELUKE: + sceneHandler07_hideLuke(); + break; + + case MSG_SC7_SHOWBOX: + sceneHandler07_showBox(); + break; + + case MSG_SC7_HIDEBOX: + sceneHandler07_hideBox(); + break; + + case 33: + { + int res = 0; + + if (g_fp->_aniMan2) { + if (g_fp->_aniMan2->_ox < g_fp->_sceneRect.left + 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.left - 300; + + if (g_fp->_aniMan2->_ox > g_fp->_sceneRect.right - 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.right + 300; + + res = 1; + } + + g_fp->_behaviorManager->updateBehaviors(); + + return res; + } + } + + return 0; +} + +} // End of namespace Fullpipe diff --git a/engines/fullpipe/scenes/scene08.cpp b/engines/fullpipe/scenes/scene08.cpp new file mode 100644 index 0000000000..ada63ef22d --- /dev/null +++ b/engines/fullpipe/scenes/scene08.cpp @@ -0,0 +1,546 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "fullpipe/fullpipe.h" + +#include "fullpipe/objects.h" +#include "fullpipe/objectnames.h" +#include "fullpipe/constants.h" +#include "fullpipe/motion.h" +#include "fullpipe/scenes.h" +#include "fullpipe/scene.h" +#include "fullpipe/statics.h" +#include "fullpipe/floaters.h" +#include "fullpipe/gameloader.h" +#include "fullpipe/behavior.h" +#include "fullpipe/interaction.h" + +namespace Fullpipe { + +void scene08_initScene(Scene *sc) { + g_vars->scene08_inArcade = false; + g_vars->scene08_inAir = false; + g_vars->scene08_flyingUp = false; + g_vars->scene08_onBelly = false; + g_vars->scene08_batuta = sc->getStaticANIObject1ById(ANI_BATUTA, -1); + g_vars->scene08_vmyats = sc->getStaticANIObject1ById(ANI_VMYATS, -1); + g_vars->scene08_clock = sc->getStaticANIObject1ById(ANI_CLOCK_8, -1); + g_vars->scene08_stairsOffset = -37; + g_vars->scene08_snoringCountdown = -1; + + Scene *oldsc = g_fp->_currentScene; + g_fp->_currentScene = sc; + + int batuta = g_fp->getObjectState(sO_TummyTrampie); + MovGraphLink *lock = getSc2MctlCompoundBySceneId(sc->_sceneId)->getLinkByName(sO_CloseThing); + + if (lock) + lock->_flags &= 0xDFFFFFFF; + + if (batuta == g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsEating)) { + g_vars->scene08_batuta->changeStatics2(ST_BTT_SPOON); + } else if (batuta == g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsDrinking)) { + g_vars->scene08_batuta->changeStatics2(ST_BTT_NOSPOON); + + g_vars->scene08_clock->startAnim(MV_CLK8_GO, 0, -1); + g_vars->scene08_clock->_movement->setDynamicPhaseIndex(3); + } else if (batuta== g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsScratchingBelly)) { + g_vars->scene08_batuta->changeStatics2(ST_BTT_CHESHET); + + g_vars->scene08_clock->startAnim(MV_CLK8_GO, 0, -1); + g_vars->scene08_clock->_movement->setDynamicPhaseIndex(8); + } else if (batuta == g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsSleeping)) { + g_vars->scene08_batuta->changeStatics2(ST_BTT_SLEEPS); + + g_vars->scene08_clock->startAnim(MV_CLK8_GO, 0, -1); + g_vars->scene08_clock->_movement->setDynamicPhaseIndex(2); + + if (lock) + lock->_flags |= 0x20000000; + + g_vars->scene08_snoringCountdown = 71; + } + + g_vars->scene08_clock->_callback2 = 0; + + if (g_fp->getObjectState(sO_StairsUp_8) == g_fp->getObjectEnumState(sO_StairsUp_8, sO_Broken)) { + g_vars->scene08_stairsVisible = false; + + sc->getPictureObjectById(PIC_SC8_LADDER, 0)->_flags &= 0xFFFB; + + g_vars->scene08_stairsOffset = -39; + } else { + g_vars->scene08_stairsVisible = true; + } + + sc->getPictureObjectById(PIC_SC8_ARCADENOW, 0)->_flags &= 0xFFFB; + + g_fp->_currentScene = oldsc; + + g_fp->_floaters->init(g_fp->getGameLoaderGameVar()->getSubVarByName("SC_8")); + g_fp->_floaters->genFlies(sc, 100, 100, 0, 0); + + g_fp->setArcadeOverlay(PIC_CSR_ARCADE3); +} + +void scene08_setupMusic() { + if (g_fp->getObjectState(sO_TummyTrampie) == g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsSleeping)) + g_fp->playTrack(g_fp->getGameLoaderGameVar()->getSubVarByName("SC_8"), "MUSIC_ARCADE", 1); +} + +int scene08_updateCursor() { + g_fp->updateCursorCommon(); + + if (g_vars->scene08_inArcade) { + if (g_vars->scene08_onBelly) { + if (g_fp->_objectIdAtCursor == PIC_SC8_LADDERD && g_fp->_cursorId == PIC_CSR_ITN) + g_fp->_cursorId = PIC_CSR_GOU; + } else { + g_fp->_cursorId = -1; + } + } else { + if (g_fp->_objectIdAtCursor == PIC_SC8_LADDERD && g_fp->_cursorId == PIC_CSR_ITN) { + if (g_fp->_aniMan2->_oy >= 520) { + if (g_fp->_aniMan2->_oy <= 750) + g_fp->_cursorId = PIC_CSR_GOU; + } else { + g_fp->_cursorId = PIC_CSR_GOD; + } + } + } + + return g_fp->_cursorId; +} + +void sceneHandler08_enterUp() { + g_fp->_currentScene->getPictureObjectById(PIC_SC8_LADDER, 0)->_flags &= 0xFFFB; + + g_fp->_aniMan->changeStatics2(ST_MAN8_HANDSUP); + g_fp->_aniMan->setOXY(386, 236); + g_fp->_aniMan->_priority = 10; + g_fp->_aniMan->_flags = 4; + + chainObjQueue(g_fp->_aniMan, QU_SC8_FINISH, 1); + + g_vars->scene08_inAir = false; +} + +void sceneHandler08_winArcade() { + if (g_vars->scene08_inArcade) { + g_vars->scene08_inArcade = false; + g_fp->_sceneRect.top = 0; + g_fp->_sceneRect.bottom = 600; + + sceneHandler08_enterUp(); + } +} + +void sceneHandler08_hideLadder() { + g_fp->_currentScene->getPictureObjectById(PIC_SC8_LADDER_D, 0)->_flags &= 0xFFFB; +} + +void sceneHandler08_arcadeNow() { + MovGraphLink *lnk = getCurrSceneSc2MotionController()->getLinkByName(sO_Stairway); + + g_fp->setObjectState(sO_TummyTrampie, g_fp->getObjectEnumState(sO_TummyTrampie, sO_IsSleeping)); + + g_vars->scene08_batuta->changeStatics2(ST_BTT_SLEEPS); + + if (lnk) + lnk->_flags |= 0x20000000; +} + +void sceneHandler08_resumeFlight() { + g_vars->scene08_manOffsetY = 3; + g_vars->scene08_stairsOffset = -39; + g_vars->scene08_inAir = true; + g_vars->scene08_stairsVisible = false; +} + +int sceneHandler08_calcOffset(int off, int flag) { + if (off > 0) { + if (flag) + return off * 31 / 10; // off * 3.1 + else + return 5 * off; + } else { + return 5 * off; + } +} + +void sceneHandler08_pushCallback(int *par) { + Common::Point point; + + int y = g_fp->_aniMan->_oy + g_fp->_aniMan->getSomeXY(point)->y; + + if (g_fp->_aniMan->_statics && g_fp->_aniMan->_statics->_staticsId == ST_MAN8_FLYDOWN) + y -= 25; + + *par = (y - 703) / 10; + if (*par > 11) { + *par = 11; + g_vars->scene08_manOffsetY = 0; + } + if (*par >= 0) + g_vars->scene08_manOffsetY -= sceneHandler08_calcOffset(*par, g_vars->scene08_manOffsetY < 0); + else + *par = 0; +} + +int sceneHandler08_updateScreenCallback() { + int res; + + res = g_fp->drawArcadeOverlay(g_vars->scene08_inArcade); + + if (!res) + g_fp->_updateScreenCallback = 0; + + return res; +} + +void sceneHandler08_startArcade() { + g_vars->scene08_inArcade = true; + g_vars->scene08_inAir = true; + g_vars->scene08_flyingUp = false; + g_vars->scene08_onBelly = false; + + getGameLoaderInteractionController()->disableFlag24(); + getCurrSceneSc2MotionController()->clearEnabled(); + + g_vars->scene08_batuta->stopAnim_maybe(); + + g_vars->scene08_vmyats->_statics = g_vars->scene08_vmyats->getStaticsById(ST_VMT_MIN); + g_vars->scene08_vmyats->setOXY(382, 703); + g_vars->scene08_vmyats->_priority = 29; + g_vars->scene08_vmyats->_callback2 = sceneHandler08_pushCallback; + + g_fp->_aniMan = g_fp->_currentScene->getStaticANIObject1ById(ANI_MAN, -1); + + g_vars->scene08_manOffsetY = 15; + + g_fp->_currentScene->_y = 0; + + g_fp->_updateScreenCallback = sceneHandler08_updateScreenCallback; +} + +void sceneHandler08_airMoves() { + if (g_fp->_aniMan->isIdle() && !(g_fp->_aniMan->_flags & 0x100)) { + int x = g_fp->_aniMan->_ox; + int y = g_fp->_aniMan->_oy; + Common::Point point; + + if (703 - g_fp->_aniMan->getSomeXY(point)->y - y < 150) { + if (g_fp->_aniMan->_statics) { + if (g_fp->_aniMan->_statics->_staticsId == ST_MAN8_FLYDOWN) { + y -= 25; + + g_fp->_aniMan->setOXY(x, y); + } + } + + g_fp->_aniMan->changeStatics2(ST_MAN8_STAND); + g_fp->_aniMan->setOXY(380, y); + g_fp->_aniMan->startAnim(MV_MAN8_JUMP, 0, -1); + + } else if (g_fp->_aniMan->_statics) { + if (g_fp->_aniMan->_statics->_staticsId == ST_MAN8_FLYUP) { + g_fp->_aniMan->startAnim(MV_MAN8_DRYGUP, 0, -1); + + } else if (g_fp->_aniMan->_statics->_staticsId == ST_MAN8_FLYDOWN) { + g_fp->_aniMan->startAnim(MV_MAN8_DRYGDOWN, 0, -1); + } + } + } +} + +void sceneHandler08_finishArcade() { + g_vars->scene08_inArcade = false; + + getGameLoaderInteractionController()->enableFlag24(); + getCurrSceneSc2MotionController()->setEnabled(); +} + +void sceneHandler08_jumpOff(ExCommand *cmd) { + MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); + + mq->addExCommandToEnd(new ExCommand(cmd)); + mq->setFlags(mq->getFlags() | 1); + + g_fp->_globalMessageQueueList->addMessageQueue(mq); + + g_fp->_aniMan->startAnim(MV_MAN8_JUMPOFF, mq->_id, -1); + + sceneHandler08_finishArcade(); +} + +void sceneHandler08_standUp() { + chainQueue(QU_SC8_STANDUP, 1); + g_vars->scene08_onBelly = false; +} + +void sceneHandler08_jumpLogic(ExCommand *cmd) { + if (g_fp->_currentScene->getPictureObjectIdAtPos(cmd->_sceneClickX, cmd->_sceneClickY) == PIC_SC8_LADDERD) { + sceneHandler08_jumpOff(cmd); + + cmd->_messageKind = 0; + } else { + sceneHandler08_standUp(); + } +} + +void sceneHandler08_badLuck() { + g_fp->_currentScene->getPictureObjectById(PIC_SC8_LADDER, 0)->_flags &= 0xFFFB; + + g_fp->_aniMan->changeStatics2(ST_MAN8_HANDSUP); + g_fp->_aniMan->setOXY(376, 280); + g_fp->_aniMan->_priority = 10; + + MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); + + ExCommand *ex = new ExCommand(g_fp->_aniMan->_id, 1, MV_MAN8_BADLUCK, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 2; + ex->_keyCode = g_fp->_aniMan->_okeyCode; + mq->addExCommandToEnd(ex); + + mq->setFlags(mq->getFlags() | 1); + mq->chain(0); + + g_fp->setObjectState(sO_StairsUp_8, g_fp->getObjectEnumState(sO_StairsUp_8, sO_NotBroken)); + + g_vars->scene08_inAir = false; +} + +void sceneHandler08_sitDown() { + g_fp->_aniMan->setOXY(380, g_fp->_aniMan->_oy); + + g_fp->_aniMan->changeStatics2(ST_MAN8_FLYDOWN); + g_fp->_aniMan->startAnim(MV_MAN8_SITDOWN, 0, -1); + + g_vars->scene08_vmyats->changeStatics2(ST_VMT_MIN); + g_vars->scene08_vmyats->hide(); + + g_vars->scene08_inAir = false; + g_vars->scene08_onBelly = true; +} + +void sceneHandler08_calcFlight() { + Common::Point point; + int y = g_vars->scene08_manOffsetY + g_fp->_aniMan->_oy; + + g_fp->_aniMan->setOXY(g_fp->_aniMan->_ox, y); + + g_vars->scene08_manOffsetY += 2; + + if (g_vars->scene08_manOffsetY < g_vars->scene08_stairsOffset) + g_vars->scene08_manOffsetY = g_vars->scene08_stairsOffset; + + y = y + g_fp->_aniMan->getSomeXY(point)->y; + + if (g_fp->_aniMan->_statics && g_fp->_aniMan->_statics->_staticsId == ST_MAN8_FLYDOWN) + y -= 25; + + if (y <= g_vars->scene08_vmyats->_oy) { + g_vars->scene08_vmyats->hide(); + } else { + g_vars->scene08_vmyats->show1(-1, -1, -1, 0); + + if (!g_vars->scene08_vmyats->_movement) + g_vars->scene08_vmyats->startAnim(MV_VMT_DEF, 0, -1); + } + + if (g_fp->_aniMan->_oy <= 280 && g_vars->scene08_stairsVisible + && g_fp->_aniMan->_statics && g_fp->_aniMan->_statics->_staticsId == ST_MAN8_HANDSUP) { + sceneHandler08_badLuck(); + } else if (g_fp->_aniMan->_oy > 236 || g_vars->scene08_stairsVisible + || !g_fp->_aniMan->_statics || g_fp->_aniMan->_statics->_staticsId != ST_MAN8_HANDSUP) { + if (g_fp->_aniMan->_movement || g_fp->_aniMan->_oy < 660 + || (g_vars->scene08_vmyats->_movement && g_vars->scene08_vmyats->_movement->_currDynamicPhaseIndex > 0) + || abs(g_vars->scene08_manOffsetY) > 2) { + if (g_vars->scene08_manOffsetY >= 0 && !g_fp->_aniMan->_movement) { + if (g_fp->_aniMan->_statics->_staticsId == ST_MAN8_HANDSUP) + g_fp->_aniMan->startAnim(MV_MAN8_HANDSDOWN, 0, -1); + else + g_fp->_aniMan->changeStatics2(ST_MAN8_FLYDOWN); + } + + if (g_fp->_aniMan->_oy < 500 && !g_fp->_aniMan->_movement && g_fp->_aniMan->_statics->_staticsId == ST_MAN8_FLYUP && g_vars->scene08_manOffsetY < 0) + g_fp->_aniMan->startAnim(MV_MAN8_HANDSUP, 0, -1); + } else { + sceneHandler08_sitDown(); + } + } else { + sceneHandler08_enterUp(); + } +} + +void sceneHandler08_checkEndArcade() { + if (g_vars->scene08_flyingUp) { + int x = g_fp->_aniMan->_ox; + int y = g_vars->scene08_manOffsetY + g_fp->_aniMan->_oy; + + if (!((g_vars->scene08_manOffsetY + g_fp->_aniMan->_oy) % 3)) + g_vars->scene08_manOffsetY--; + + g_fp->_aniMan->setOXY(x, y); + + if (y < 80) { + sceneHandler08_finishArcade(); + + ExCommand *ex = new ExCommand(SC_8, 17, 0, 0, 0, 0, 1, 0, 0, 0); + ex->_messageNum = 61; + ex->_excFlags |= 2; + ex->_keyCode = TrubaUp; + + ex->postMessage(); + } + } +} + +int sceneHandler08(ExCommand *cmd) { + if (cmd->_messageKind != 17) + return 0; + + switch (cmd->_messageNum) { + case MSG_CMN_WINARCADE: + sceneHandler08_winArcade(); + break; + + case MSG_SC8_ENTERUP: + sceneHandler08_enterUp(); + break; + + case MSG_SC8_HIDELADDER_D: + sceneHandler08_hideLadder(); + break; + + case MSG_SC8_STANDUP: + g_vars->scene08_manOffsetY = -10; + g_vars->scene08_vmyats->changeStatics2(ST_VMT_MIN); + g_vars->scene08_vmyats->setOXY(382, 703); + g_vars->scene08_vmyats->_priority = 29; + g_vars->scene08_vmyats->_callback2 = sceneHandler08_pushCallback; + g_vars->scene08_inAir = true; + break; + + case MSG_SC8_ARCADENOW: + sceneHandler08_arcadeNow(); + break; + + case MSG_SC8_RESUMEFLIGHT: + sceneHandler08_resumeFlight(); + break; + + case MSG_SC8_GETHIMUP: + g_vars->scene08_manOffsetY = 0; + g_vars->scene08_flyingUp = true; + break; + + case MSG_STARTARCADE: + sceneHandler08_startArcade(); + break; + + case 29: + if (g_vars->scene08_inArcade) { + if (g_vars->scene08_inAir) { + sceneHandler08_airMoves(); + break; + } + if (g_vars->scene08_onBelly) { + sceneHandler08_jumpLogic(cmd); + break; + } + } + break; + + case 33: + { + int res = 0; + + if (g_fp->_aniMan2) { + if (g_vars->scene08_inArcade) { + int scHeight = g_fp->_sceneRect.bottom - g_fp->_sceneRect.top; + + if (g_fp->_aniMan2->_oy < g_fp->_sceneRect.top + 200) { + g_fp->_sceneRect.top = g_fp->_aniMan2->_oy - 200; + + if (g_fp->_sceneRect.top < 0) + g_fp->_sceneRect.top = 0; + + g_fp->_sceneRect.bottom = scHeight + g_fp->_sceneRect.top; + } + + if (g_fp->_aniMan2->_oy > g_fp->_sceneRect.bottom - 350) { + g_fp->_sceneRect.bottom = g_fp->_aniMan2->_oy + 350; + g_fp->_sceneRect.top = g_fp->_aniMan2->_oy + 350 - scHeight; + } + } else { + if (g_fp->_aniMan2->_ox < g_fp->_sceneRect.left + 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.left - 300; + + if (g_fp->_aniMan2->_ox > g_fp->_sceneRect.right - 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.right + 300; + + res = 1; + } + } + + g_fp->_floaters->update(); + + if (g_vars->scene08_inArcade) { + if (g_vars->scene08_inAir) + sceneHandler08_calcFlight(); + } else { + Movement *mov = g_fp->_aniMan->_movement; + + if (mov) { + if (mov->_id == MV_MAN_TOLADDERD && mov->_currDynamicPhaseIndex == 8) + g_fp->_aniMan->_priority = 2; + + if (mov && mov->_id == MV_MAN_FROMLADDERUP && mov->_currDynamicPhaseIndex == 13) + g_fp->_aniMan->_priority = 20; + } + + g_fp->_behaviorManager->updateBehaviors(); + g_fp->startSceneTrack(); + } + + if (g_vars->scene08_flyingUp) + sceneHandler08_checkEndArcade(); + + if (g_vars->scene08_snoringCountdown > 0) { + g_vars->scene08_snoringCountdown--; + + if (!g_vars->scene08_snoringCountdown) { + g_fp->playSound(SND_8_014, 0); + + g_vars->scene08_snoringCountdown = 71; + } + } + + return res; + } + } + + return 0; +} + +} // End of namespace Fullpipe diff --git a/engines/fullpipe/scenes/scene10.cpp b/engines/fullpipe/scenes/scene10.cpp new file mode 100644 index 0000000000..f8d16b2759 --- /dev/null +++ b/engines/fullpipe/scenes/scene10.cpp @@ -0,0 +1,220 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "fullpipe/fullpipe.h" + +#include "fullpipe/objectnames.h" +#include "fullpipe/constants.h" + +#include "fullpipe/gameloader.h" +#include "fullpipe/motion.h" +#include "fullpipe/scenes.h" +#include "fullpipe/statics.h" + +#include "fullpipe/behavior.h" +#include "fullpipe/interaction.h" + +namespace Fullpipe { + +void scene10_initScene(Scene *sc) { + g_vars->scene10_gum = sc->getStaticANIObject1ById(ANI_GUM, -1); + g_vars->scene10_packet = sc->getStaticANIObject1ById(ANI_PACHKA, -1); + g_vars->scene10_packet2 = sc->getStaticANIObject1ById(ANI_PACHKA2, -1); + g_vars->scene10_inflater = sc->getStaticANIObject1ById(ANI_NADUVATEL, -1); + g_vars->scene10_ladder = sc->getPictureObjectById(PIC_SC10_LADDER, 0); + + g_fp->lift_setButton(sO_Level1, ST_LBN_1N); + g_fp->lift_sub5(sc, QU_SC10_ENTERLIFT, QU_SC10_EXITLIFT); + + if (g_fp->getObjectState(sO_Inflater) == g_fp->getObjectEnumState(sO_Inflater, sO_WithGum)) { + g_vars->scene10_hasGum = 1; + } else { + g_vars->scene10_hasGum = 0; + g_vars->scene10_gum->hide(); + } +} + +bool sceneHandler10_inflaterIsBlind() { + return g_vars->scene10_inflater->_movement + && g_vars->scene10_inflater->_movement->_id == MV_NDV_BLOW2 + && g_vars->scene10_inflater->_movement->_currDynamicPhaseIndex < 42; +} + +int scene10_updateCursor() { + g_fp->updateCursorCommon(); + + if (g_fp->_objectIdAtCursor == ANI_PACHKA || g_fp->_objectIdAtCursor == ANI_GUM) { + if (g_fp->_cursorId == PIC_CSR_ITN) { + if (g_vars->scene10_hasGum) + g_fp->_cursorId = (sceneHandler10_inflaterIsBlind() != 0) ? PIC_CSR_ITN_RED : PIC_CSR_ITN_GREEN; + else + g_fp->_cursorId = PIC_CSR_DEFAULT; + } + } + + return g_fp->_cursorId; +} + +void sceneHandler10_clickGum() { + if (g_vars->scene10_hasGum) { + if (sceneHandler10_inflaterIsBlind()) { + if (g_vars->scene10_hasGum) { + int x = g_vars->scene10_gum->_ox - 139; + int y = g_vars->scene10_gum->_oy - 48; + + if (abs(x - g_fp->_aniMan->_ox) > 1 || abs(y - g_fp->_aniMan->_oy) > 1) { + MessageQueue *mq = getCurrSceneSc2MotionController()->method34(g_fp->_aniMan, x, y, 1, ST_MAN_RIGHT); + if (mq) { + ExCommand *ex = new ExCommand(0, 17, MSG_SC10_CLICKGUM, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags = 2; + mq->addExCommandToEnd(ex); + + postExCommand(g_fp->_aniMan->_id, 2, x, y, 0, -1); + } + } else { + g_vars->scene10_hasGum = 0; + + chainQueue(QU_SC10_TAKEGUM, 1); + } + } + } else { + g_vars->scene10_inflater->changeStatics2(ST_NDV_SIT); + + if (g_fp->getObjectState(sO_Inflater) == g_fp->getObjectEnumState(sO_Inflater, sO_WithGum)) + g_vars->scene10_inflater->startAnim(MV_NDV_DENIES, 0, -1); + else + g_vars->scene10_inflater->startAnim(MV_NDV_DENY_NOGUM, 0, -1); + } + } +} + +void sceneHandler10_hideGum() { + g_vars->scene10_gum->hide(); + g_vars->scene10_packet->hide(); + g_vars->scene10_packet2->hide(); +} + +void sceneHandler10_showGum() { + if (g_vars->scene10_hasGum) + g_vars->scene10_gum->show1(-1, -1, -1, 0); + + g_vars->scene10_packet->show1(-1, -1, -1, 0); + g_vars->scene10_packet2->show1(-1, -1, -1, 0); +} + + +int sceneHandler10(ExCommand *ex) { + if (ex->_messageKind != 17) + return 0; + + switch(ex->_messageNum) { + case MSG_LIFT_CLOSEDOOR: + g_fp->lift_closedoorSeq(); + break; + + case MSG_LIFT_EXITLIFT: + g_fp->lift_exitSeq(ex); + break; + + case MSG_LIFT_STARTEXITQUEUE: + g_fp->lift_startExitQueue(); + break; + + case MSG_LIFT_CLICKBUTTON: + g_fp->lift_animation3(); + break; + + case MSG_SC10_LADDERTOBACK: + g_vars->scene10_ladder->_priority = 49; + break; + + case MSG_SC10_LADDERTOFORE: + g_vars->scene10_ladder->_priority = 0; + break; + + case MSG_LIFT_GO: + g_fp->lift_goAnimation(); + break; + + case MSG_SC10_CLICKGUM: + sceneHandler10_clickGum(); + + ex->_messageKind = 0; + break; + + case MSG_SC10_HIDEGUM: + sceneHandler10_hideGum(); + break; + + case MSG_SC10_SHOWGUM: + sceneHandler10_showGum(); + break; + + case 64: + g_fp->lift_sub05(ex); + break; + + case 29: + { + if (g_fp->_currentScene->getPictureObjectIdAtPos(ex->_sceneClickX, ex->_sceneClickY) == PIC_SC10_LADDER) { + handleObjectInteraction(g_fp->_aniMan, g_fp->_currentScene->getPictureObjectById(PIC_SC10_DTRUBA, 0), ex->_keyCode); + ex->_messageKind = 0; + + return 0; + } + + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObjectAtPos(ex->_sceneClickX, ex->_sceneClickY); + + if (ani && ani->_id == ANI_LIFTBUTTON) { + g_fp->lift_sub1(ani); + ex->_messageKind = 0; + + return 0; + } + } + break; + + case 33: + { + int res = 0; + + if (g_fp->_aniMan2) { + if (g_fp->_aniMan2->_ox < g_fp->_sceneRect.left + 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.left - 300; + + if (g_fp->_aniMan2->_ox > g_fp->_sceneRect.right - 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.right + 300; + + res = 1; + } + + g_fp->_behaviorManager->updateBehaviors(); + g_fp->startSceneTrack(); + + return res; + } + } + + return 0; +} + +} // End of namespace Fullpipe diff --git a/engines/fullpipe/scenes/scene11.cpp b/engines/fullpipe/scenes/scene11.cpp new file mode 100644 index 0000000000..240eccf61b --- /dev/null +++ b/engines/fullpipe/scenes/scene11.cpp @@ -0,0 +1,334 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "fullpipe/fullpipe.h" + +#include "fullpipe/objectnames.h" +#include "fullpipe/constants.h" + +#include "fullpipe/gameloader.h" +#include "fullpipe/motion.h" +#include "fullpipe/scenes.h" +#include "fullpipe/statics.h" + +#include "fullpipe/interaction.h" +#include "fullpipe/behavior.h" + + +namespace Fullpipe { + +void scene11_dudeSwingCallback(int *arg) { + warning("STUB: scene11_dudeSwingCallback()"); +} + +void scene11_setupMusic() { + if (g_fp->getObjectState(sO_DudeHasJumped) == g_fp->getObjectEnumState(sO_DudeHasJumped, sO_Yes)) + g_fp->playTrack(g_fp->getGameLoaderGameVar()->getSubVarByName("SC_11"), "MUSIC2", 1); +} + +void scene11_initScene(Scene *sc) { + g_vars->scene11_swingie = sc->getStaticANIObject1ById(ANI_SWINGER, -1); + g_vars->scene11_boots = sc->getStaticANIObject1ById(ANI_BOOTS_11, -1); + g_vars->scene11_var01.clear(); + g_vars->scene11_dudeOnSwing = sc->getStaticANIObject1ById(ANI_MAN11, -1); + g_vars->scene11_dudeOnSwing->_callback2 = scene11_dudeSwingCallback; + g_vars->scene11_dudeOnSwing = sc->getStaticANIObject1ById(ANI_KACHELI, -1); + g_vars->scene11_dudeOnSwing->_callback2 = scene11_dudeSwingCallback; + g_vars->scene11_hint = sc->getPictureObjectById(PIC_SC11_HINT, 0); + g_vars->scene11_hint->_flags &= 0xFFFB; + + g_vars->scene11_var02 = 0; + g_vars->scene11_var03 = 0; + g_vars->scene11_var04 = 0; + g_vars->scene11_var05 = 0; + g_vars->scene11_var06 = 0; + g_vars->scene11_var07 = 0; + g_vars->scene11_var08 = 1.0; + g_vars->scene11_var09 = 1.0; + g_vars->scene11_var10 = 1.0; + g_vars->scene11_var11 = 1.0; + g_vars->scene11_var12 = 1.9849218750000000; + g_vars->scene11_var13 = 0; + g_vars->scene11_var14 = 0; + g_vars->scene11_var15 = 0; + g_vars->scene11_var16 = 0; + g_vars->scene11_var17 = 0; + g_vars->scene11_var18 = 0; + + Scene *oldsc = g_fp->_currentScene; + + g_fp->_currentScene = sc; + + int swingie = g_fp->getObjectState(sO_Swingie); + + if (swingie == g_fp->getObjectEnumState(sO_Swingie, sO_IsSwinging) + || swingie == g_fp->getObjectEnumState(sO_Swingie, sO_IsSwingingWithBoot)) { + g_vars->scene11_var19 = 1; + g_vars->scene11_var20 = 0; + + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing1, 1); + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing2, 1); + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing3, 0); + + ((MctlCompound *)getCurrSceneSc2MotionController())->replaceNodeX(805, 905); + + getSc2MctlCompoundBySceneId(sc->_sceneId)->replaceNodeX(303, 353); + } else if (swingie == g_fp->getObjectEnumState(sO_Swingie, sO_IsStandingInBoots) + || swingie == g_fp->getObjectEnumState(sO_Swingie, sO_IsStandingInCorner)) { + g_vars->scene11_var19 = 0; + g_vars->scene11_var20 = 1; + + g_vars->scene11_swingie->changeStatics2(ST_SWR_STAND3); + + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing1, 0); + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing2, 1); + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing3, 0); + + ((MctlCompound *)getCurrSceneSc2MotionController())->replaceNodeX(905, 805); + } else { + g_vars->scene11_var19 = 0; + g_vars->scene11_var20 = 0; + + if (swingie == g_fp->getObjectEnumState(sO_Swingie, sO_IsSitting)) { + g_vars->scene11_swingie->_movement = 0; + g_vars->scene11_swingie->_statics = g_vars->scene11_swingie->getStaticsById(ST_SWR_SIT); + g_vars->scene11_swingie->setOXY(144, 389); + + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing1, 0); + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing2, 0); + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing3, 1); + } else { + g_vars->scene11_swingie->_movement = 0; + g_vars->scene11_swingie->_statics = g_vars->scene11_swingie->getStaticsById(ST_SWR_SITBALD); + g_vars->scene11_swingie->setOXY(144, 415); + + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing1, 0); + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing2, 0); + getCurrSceneSc2MotionController()->enableLinks(sO_CloseThing3, 1); + } + } + + if (!g_vars->scene11_var19) { + g_vars->scene11_dudeOnSwing->changeStatics2(ST_KCH_STATIC); + g_vars->scene11_dudeOnSwing->setOXY(691, 371); + g_vars->scene11_dudeOnSwing->_priority = 20; + + g_vars->scene11_dudeOnSwing->_flags |= 4; + } + + g_fp->_currentScene = oldsc; + + g_fp->initArcadeKeys("SC_11"); + g_fp->setArcadeOverlay(PIC_CSR_ARCADE5); +} + +int sceneHandler11(ExCommand *cmd) { +#if 0 + if (cmd->_messageKind != 17) + return 0; + + switch (cmd->_messageNum) { + case MSG_CMN_WINARCADE: + sceneHandler11_winArcade(); + break; + + case MSG_SC11_SITSWINGER: + if (g_fp->getObjectState(sO_Swingie) == getObjectEnumState(sO_Swingie, sO_IsStandingInBoots) + || g_fp->getObjectState(sO_Swingie) == g_fp->getObjectEnumState(sO_Swingie, sO_IsStandingInCorner)) { + g_fp->setObjectState(sO_Swingie, g_fp->getObjectEnumState(sO_Swingie, sO_IsSitting)); + } + break; + + case MSG_SC11_MANCRY: + playSound(g_vars->scene11_var07, 0); + g_vars->scene11_var07 = 0; + break; + + case MSG_SC11_RESTARTMAN: + sceneHandler11_restartMan(); + break; + + case MSG_SC11_HITMAN: + sceneHandler11_hitMan(); + break; + + case MSG_SC11_MANTOSWING: + sceneHandler11_manToSwing(); + break; + + case MSG_SC11_PUTBOOT: + sceneHandler11_putBoot(); + break; + + case MSG_SC11_SHOWSWING: + sceneHandler11_showSwing(); + break; + + case 107: + if (g_vars->scene11_var02) + sceneHandler11_sub01(); + break; + + case 33: + { + if (!g_fp->_aniMan2) + goto LABEL_27; + + int x = g_fp->_aniMan2->_ox; + g_vars->scene11_var21 = g_fp->_aniMan2->_ox; + int y = g_fp->_aniMan2->_oy; + g_vars->scene11_var22 = g_fp->_aniMan2->_oy; + if (g_vars->scene11_var03) { + if (x > g_fp->_sceneRect.right - 200) + OffsetRect(&g_fp->_sceneRect, x - g_fp->_sceneRect.right + 200, 0); + goto LABEL_26; + } + if (g_vars->scene11_var04) { + g_fp->_currentScene->bg._x = g_fp->_sceneWidth - x; + if (g_vars->scene11_var21 < 910) + g_vars->scene11_var04 = 0; + LABEL_26: + v2 = 1; + LABEL_27: + if (g_vars->scene11_var20) { + if (g_fp->_sceneRect.left >= 534 && g_vars->scene11_var06 < 534) + sceneHandler11_sub06(); + g_vars->scene11_var06 = g_fp->_sceneRect.left; + } + if (!g_vars->scene11_var02) + goto LABEL_50; + v6 = g_vars->scene11_var16; + if (g_vars->scene11_var16 <= 0 || g_vars->scene11_var15 - g_vars->scene11_var16 <= 72) { + v7 = g_vars->scene11_var18; + } else { + sceneHandler11_sub02(); + v7 = 0; + v6 = 0; + g_vars->scene11_var18 = 0; + g_vars->scene11_var16 = 0; + } + if (!g_vars->scene11_var02) + goto LABEL_50; + if (g_vars->scene11_var17 == v7 || v6 <= 0 || g_vars->scene11_var15 - v6 <= 2) { + LABEL_49: + if (g_vars->scene11_var02) { + LABEL_61: + g_fp->_behaviorManager_updateBehaviors(); + g_fp->startSceneTrack(); + return v2; + } + LABEL_50: + if (g_vars->scene11_var19 + || 0.0 == g_vars->scene11_var10 + && (v8 = g_vars->scene11_dudeOnSwing->_movement) != 0 + && v8->_currDynamicPhaseIndex == 45 + && (g_vars->scene11_dudeOnSwing->changeStatics2(ST_KCH_STATIC), !g_vars->scene11_var02) + && g_vars->scene11_var19) { + if (!g_vars->scene11_swingie->_movement) { + if (g_vars->scene11_boots->_flags & 4 && g_vars->scene11_boots->_statics->_staticsId == ST_BTS11_2) { + sceneHandler11_sub07(); + BehaviorManager_updateBehaviors(&g_behaviorManager); + startSceneTrack(); + return v2; + } + g_vars->scene11_swingie->startAnim(MV_SWR_SWING, 0, -1); + } + } + goto LABEL_61; + } + if (v7 == 1) { + if (!g_vars->scene11_var17) { + sceneHandler11_sub03(); + LABEL_48: + g_vars->scene11_var16 = g_vars->scene11_var15; + goto LABEL_49; + } + } else { + if (v7 != 2) + goto LABEL_48; + if (!g_vars->scene11_var17) { + sceneHandler11_sub04(); + goto LABEL_48; + } + } + sceneHandler11_sub02(); + goto LABEL_48; + } + if (x >= g_fp->_sceneRect.left + 200) { + if (x <= g_fp->_sceneRect.right - 200) { + LABEL_18: + if (y < g_fp->_sceneRect.top + 200) { + g_fp->_currentScene->bg._y = y - g_fp->_sceneRect.top - 300; + y = g_vars->scene11_var22; + x = g_vars->scene11_var21; + } + if (y > g_fp->_sceneRect.bottom - 300) { + g_fp->_currentScene->bg._y = y - g_fp->_sceneRect.bottom + 300; + x = g_vars->scene11_var21; + } + if (x >= 940) + g_vars->scene11_var04 = 1; + goto LABEL_26; + } + g_fp->_currentScene->bg._x = x - g_fp->_sceneRect.right + 300; + } else { + g_fp->_currentScene->bg._x = x - g_fp->_sceneRect.left - 300; + } + y = g_vars->scene11_var22; + x = g_vars->scene11_var21; + goto LABEL_18; + } + + break; + + case 29: + if (g_vars->scene11_var19) { + if (g_fp->_currentScene->getStaticANIObjectAtPos(g_fp->_sceneRect.left + cmd->_x, g_fp->_sceneRect.top + cmd->_y) == g_vars->scene11_swingie && cmd->_keyCode == ANI_INV_BOOT) + sceneHandler11_putBoot(); + } else { + if (!g_vars->scene11_var02) + goto LABEL_69; + sceneHandler11_sub05(); + g_vars->scene11_var16 = g_vars->scene11_var15; + } + if (!g_vars->scene11_var02) { + LABEL_69: + v10 = (GameObject *)Scene_getStaticANIObjectAtPos(g_fp->_currentScene, cmd->_sceneClickX, cmd->_sceneClickY); + if (!v10 || !canInteractAny(&g_fp->_aniMan->go, v10, cmd->_keyCode)) { + v11 = Scene_getPictureObjectIdAtPos(g_fp->_currentScene, cmd->_sceneClickX, cmd->_sceneClickY); + v12 = (GameObject *)Scene_getPictureObjectById(g_fp->_currentScene, v11, 0); + if (!v12 || !canInteractAny(g_fp->_aniMan, v12, cmd->_keyCode)) { + if ((v13 = cmd->_sceneClickX, g_fp->_sceneRect.right - v13 < 47) && g_fp->_sceneRect.right < g_fp->_sceneWidth - 1 || v13 - g_fp->_sceneRect.left < 47 && g_fp->_sceneRect.left > 0) { + processArcade(cmd); + return 0; + } + } + } + return 0; + } + } +#endif + + return 0; +} + +} // End of namespace Fullpipe diff --git a/engines/fullpipe/scenes/scene12.cpp b/engines/fullpipe/scenes/scene12.cpp new file mode 100644 index 0000000000..65f50b465a --- /dev/null +++ b/engines/fullpipe/scenes/scene12.cpp @@ -0,0 +1,85 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "fullpipe/fullpipe.h" + +#include "fullpipe/objects.h" +#include "fullpipe/objectnames.h" +#include "fullpipe/constants.h" +#include "fullpipe/motion.h" +#include "fullpipe/scenes.h" +#include "fullpipe/scene.h" +#include "fullpipe/floaters.h" +#include "fullpipe/messages.h" +#include "fullpipe/statics.h" +#include "fullpipe/behavior.h" + +namespace Fullpipe { + +void scene12_initScene(Scene *sc) { + GameVar *var = g_fp->getGameLoaderGameVar()->getSubVarByName("SC_12"); + g_fp->_floaters->init(var); + + g_vars->scene12_fly = g_fp->getObjectState(sO_Fly_12); + + if (g_vars->scene12_fly) + g_vars->scene12_flyCountdown = 600 * g_fp->_rnd->getRandomNumber(32767) / 0x7fff + 600; + + g_fp->setObjectState(sO_Fly_12, g_fp->_rnd->getRandomNumber(1)); +} + +void sceneHandler12_updateFloaters() { + g_fp->_floaters->genFlies(g_fp->_currentScene, 397, -50, 100, 6); + + g_fp->_floaters->_array2[0]->countdown = g_fp->_rnd->getRandomNumber(6) + 4; + g_fp->_floaters->_array2[0]->val6 = 397; + g_fp->_floaters->_array2[0]->val7 = -50; +} + +int sceneHandler12(ExCommand *cmd) { + int res = 0; + + if (cmd->_messageKind == 17 && cmd->_messageNum == 33) { + if (g_fp->_aniMan2) { + if (g_fp->_aniMan2->_ox < g_fp->_sceneRect.left + 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.left - 300; + + if (g_fp->_aniMan2->_ox > g_fp->_sceneRect.right - 200) + g_fp->_currentScene->_x = g_fp->_aniMan2->_ox - g_fp->_sceneRect.right + 300; + + res = 1; + } + + g_vars->scene12_flyCountdown--; + + if (!g_vars->scene12_flyCountdown) + sceneHandler12_updateFloaters(); + + g_fp->_floaters->update(); + + g_fp->_behaviorManager->updateBehaviors(); + } + + return res; +} + +} // End of namespace Fullpipe diff --git a/engines/fullpipe/scenes/scene15.cpp b/engines/fullpipe/scenes/scene15.cpp new file mode 100644 index 0000000000..8310fc8607 --- /dev/null +++ b/engines/fullpipe/scenes/scene15.cpp @@ -0,0 +1,209 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "fullpipe/fullpipe.h" + +#include "fullpipe/objectnames.h" +#include "fullpipe/constants.h" + +#include "fullpipe/gameloader.h" +#include "fullpipe/motion.h" +#include "fullpipe/scenes.h" +#include "fullpipe/statics.h" + +#include "fullpipe/interaction.h" +#include "fullpipe/behavior.h" + + +namespace Fullpipe { + +void scene15_initScene(Scene *sc) { + g_vars->scene15_chantingCountdown = 0; + + StaticANIObject *grandma = sc->getStaticANIObject1ById(ANI_GRANDMA_ASS, -1); + + Scene *oldsc = g_fp->_currentScene; + g_fp->_currentScene = sc; + + int grandmaState = g_fp->getObjectState(sO_Grandma); + + if (grandmaState == g_fp->getObjectEnumState(sO_Grandma, sO_In_15)) { + grandma->changeStatics2(ST_GMS_BOOT); + grandma->setOXY(97, 399); + g_fp->setObjectState(sO_LeftPipe_15, g_fp->getObjectEnumState(sO_LeftPipe_15, sO_IsClosed)); + } else if (grandmaState == g_fp->getObjectEnumState(sO_Grandma, sO_In_15_1)) { + grandma->changeStatics2(ST_GMS_BOOT); + grandma->setOXY(86, 399); + g_fp->setObjectState(sO_LeftPipe_15, g_fp->getObjectEnumState(sO_LeftPipe_15, sO_IsClosed)); + } else if (grandmaState == g_fp->getObjectEnumState(sO_Grandma, sO_In_15_2)) { + grandma->changeStatics2(ST_GMS_BOOT); + grandma->setOXY(71, 399); + g_fp->setObjectState(sO_LeftPipe_15, g_fp->getObjectEnumState(sO_LeftPipe_15, sO_IsClosed)); + } else if (grandmaState == g_fp->getObjectEnumState(sO_Grandma, sO_In_15_3)) { + grandma->changeStatics2(ST_GMS_BOOT); + grandma->setOXY(49, 399); + g_fp->setObjectState(sO_LeftPipe_15, g_fp->getObjectEnumState(sO_LeftPipe_15, sO_IsClosed)); + } else if (grandmaState == g_fp->getObjectEnumState(sO_Grandma, sO_WithoutBoot)) { + grandma->changeStatics2(ST_GMS_BOOT); + grandma->setOXY(97, 399); + grandma->changeStatics2(ST_GMS_BOOTLESS2); + g_fp->setObjectState(sO_LeftPipe_15, g_fp->getObjectEnumState(sO_LeftPipe_15, sO_IsClosed)); + } else { + grandma->hide(); + g_fp->setObjectState(sO_LeftPipe_15, g_fp->getObjectEnumState(sO_LeftPipe_15, sO_IsOpened)); + } + + g_vars->scene15_plusminus = sc->getStaticANIObject1ById(ANI_PLUSMINUS, -1); + + if (g_fp->getObjectState(sO_Gurad_2) == g_fp->getObjectEnumState(sO_Gurad_2, sO_Off)) + g_vars->scene15_plusminus->_statics = g_vars->scene15_plusminus->getStaticsById(ST_PMS_MINUS); + else + g_vars->scene15_plusminus->_statics = g_vars->scene15_plusminus->getStaticsById(ST_PMS_PLUS); + + g_vars->scene15_ladder = sc->getPictureObjectById(PIC_SC15_LADDER, 0); + g_vars->scene15_boot = sc->getStaticANIObject1ById(ANI_BOOT_15, -1); + + if (g_fp->getObjectState(sO_Boot_15) != g_fp->getObjectEnumState(sO_Boot_15, sO_Available)) + g_vars->scene15_boot->_flags &= 0xFFFB; + + g_fp->_currentScene = oldsc; + + g_fp->lift_setButton(sO_Level5, ST_LBN_5N); + g_fp->lift_sub5(sc, QU_SC15_ENTERLIFT, QU_SC15_EXITLIFT); +} + +int scene15_updateCursor() { + g_fp->updateCursorCommon(); + + if (g_fp->_cursorId == PIC_CSR_ITN && g_fp->_objectIdAtCursor == PIC_SC15_LTRUBA) + g_fp->_cursorId = PIC_CSR_GOL; + + return g_fp->_cursorId; +} + +int sceneHandler15(ExCommand *cmd) { + if (cmd->_messageKind != 17) + return 0; + + switch(cmd->_messageNum) { + case MSG_LIFT_CLOSEDOOR: + g_fp->lift_closedoorSeq(); + break; + + case MSG_LIFT_EXITLIFT: + g_fp->lift_exitSeq(cmd); + break; + + case MSG_LIFT_STARTEXITQUEUE: + g_fp->lift_startExitQueue(); + break; + + case MSG_SC4_HIDEBOOT: + g_vars->scene15_boot->_flags &= 0xFFFB; + break; + + case MSG_SC15_STOPCHANTING: + g_fp->stopAllSoundInstances(SND_15_001); + + g_vars->scene15_chantingCountdown = 120; + break; + + case MSG_SC15_ASSDRYG: + if (g_fp->_rnd->getRandomNumber(1)) + g_fp->playSound(SND_15_011, 0); + else + g_fp->playSound(SND_15_006, 0); + + break; + + case MSG_SC15_LADDERTOBACK: + g_vars->scene15_ladder->_priority = 60; + break; + + case MSG_LIFT_GO: + g_fp->lift_goAnimation(); + break; + + case MSG_LIFT_CLICKBUTTON: + g_fp->lift_animation3(); + break; + + case MSG_SC15_PULL: + if (g_vars->scene15_plusminus->_statics->_staticsId == ST_PMS_MINUS) + g_vars->scene15_plusminus->_statics = g_vars->scene15_plusminus->getStaticsById(ST_PMS_PLUS); + else + g_vars->scene15_plusminus->_statics = g_vars->scene15_plusminus->getStaticsById(ST_PMS_MINUS); + + break; + + case 64: + g_fp->lift_sub05(cmd); + break; + + case 29: + { + if (g_fp->_currentScene->getPictureObjectIdAtPos(cmd->_sceneClickX, cmd->_sceneClickY) == PIC_SC15_LADDER) { + handleObjectInteraction(g_fp->_aniMan, g_fp->_currentScene->getPictureObjectById(PIC_SC15_DTRUBA, 0), cmd->_keyCode); + cmd->_messageKind = 0; + + return 0; + } + + StaticANIObject *ani = g_fp->_currentScene->getStaticANIObjectAtPos(cmd->_sceneClickX, cmd->_sceneClickY); + + if (ani && ani->_id == ANI_LIFTBUTTON) { + g_fp->lift_sub1(ani); + + cmd->_messageKind = 0; + } + break; + } + + case 30: + // nop + break; + + case 33: + if (g_fp->_aniMan2) { + int x = g_fp->_aniMan2->_ox; + + if (x < g_fp->_sceneRect.left + 200) + g_fp->_currentScene->_x = x - 300 - g_fp->_sceneRect.left; + + if (x > g_fp->_sceneRect.right - 200) + g_fp->_currentScene->_x = x + 300 - g_fp->_sceneRect.right; + } + + if (g_vars->scene15_chantingCountdown > 0) { + g_vars->scene15_chantingCountdown--; + + if (!g_vars->scene15_chantingCountdown) + g_fp->playSound(SND_15_001, 1); + } + + g_fp->_behaviorManager->updateBehaviors(); + } + + return 0; +} + +} // End of namespace Fullpipe diff --git a/engines/fullpipe/scenes/sceneDbg.cpp b/engines/fullpipe/scenes/sceneDbg.cpp index 83f3b64ee5..4a3751940f 100644 --- a/engines/fullpipe/scenes/sceneDbg.cpp +++ b/engines/fullpipe/scenes/sceneDbg.cpp @@ -25,6 +25,7 @@ #include "fullpipe/constants.h" #include "fullpipe/gameloader.h" +#include "fullpipe/motion.h" #include "fullpipe/scenes.h" #include "fullpipe/statics.h" #include "fullpipe/input.h" @@ -40,9 +41,9 @@ void sceneDbgMenu_initScene(Scene *sc) { } GameObject *sceneHandlerDbgMenu_getObjectAtXY(int x, int y) { - if (g_fullpipe->_currentScene) - for (uint i = 0; i < g_fullpipe->_currentScene->_picObjList.size(); i++) { - PictureObject *pic = (PictureObject *)g_fullpipe->_currentScene->_picObjList[i]; + if (g_fp->_currentScene) + for (uint i = 0; i < g_fp->_currentScene->_picObjList.size(); i++) { + PictureObject *pic = (PictureObject *)g_fp->_currentScene->_picObjList[i]; if (x >= pic->_ox && y >= pic->_oy) { Common::Point point; @@ -61,8 +62,8 @@ int sceneHandlerDbgMenu(ExCommand *ex) { if (ex->_messageKind != 17) return 0; - int mx = g_fullpipe->_mouseScreenPos.x + g_fullpipe->_sceneRect.left; - int my = g_fullpipe->_mouseScreenPos.y + g_fullpipe->_sceneRect.top; + int mx = g_fp->_mouseScreenPos.x + g_fp->_sceneRect.left; + int my = g_fp->_mouseScreenPos.y + g_fp->_sceneRect.top; if (ex->_messageNum == 29) { GameObject *obj = sceneHandlerDbgMenu_getObjectAtXY(mx, my); @@ -74,18 +75,18 @@ int sceneHandlerDbgMenu(ExCommand *ex) { } if (ex->_messageNum != 33) { if (ex->_messageNum == MSG_RESTARTGAME) { - g_fullpipe->_needRestart = true; + g_fp->_needRestart = true; return 0; } return 0; } - g_fullpipe->_cursorId = PIC_CSR_DEFAULT; - GameObject *obj = g_fullpipe->_currentScene->getStaticANIObjectAtPos(mx, my); + g_fp->_cursorId = PIC_CSR_DEFAULT; + GameObject *obj = g_fp->_currentScene->getStaticANIObjectAtPos(mx, my); if (obj) { if (canInteractAny(0, obj, -3)) { - g_fullpipe->_cursorId = PIC_CSR_DEFAULT; - g_fullpipe->setCursor(PIC_CSR_DEFAULT); + g_fp->_cursorId = PIC_CSR_DEFAULT; + g_fp->setCursor(PIC_CSR_DEFAULT); return 0; } } else { @@ -93,13 +94,13 @@ int sceneHandlerDbgMenu(ExCommand *ex) { if (obj && canInteractAny(0, obj, -3) ) { g_vars->selector->_flags |= 4; g_vars->selector->setOXY(obj->_ox, obj->_oy); - g_fullpipe->_cursorId = PIC_CSR_DEFAULT; - g_fullpipe->setCursor(PIC_CSR_DEFAULT); + g_fp->_cursorId = PIC_CSR_DEFAULT; + g_fp->setCursor(PIC_CSR_DEFAULT); return 0; } g_vars->selector->_flags &= 0xFFFB; } - g_fullpipe->setCursor(g_fullpipe->_cursorId); + g_fp->setCursor(g_fp->_cursorId); return 0; } diff --git a/engines/fullpipe/scenes/sceneIntro.cpp b/engines/fullpipe/scenes/sceneIntro.cpp index d60f90faf7..c9f19f3724 100644 --- a/engines/fullpipe/scenes/sceneIntro.cpp +++ b/engines/fullpipe/scenes/sceneIntro.cpp @@ -24,6 +24,7 @@ #include "fullpipe/constants.h" #include "fullpipe/gameloader.h" +#include "fullpipe/motion.h" #include "fullpipe/scenes.h" #include "fullpipe/modal.h" #include "fullpipe/statics.h" @@ -31,13 +32,13 @@ namespace Fullpipe { int sceneIntro_updateCursor() { - g_fullpipe->_cursorId = 0; + g_fp->_cursorId = 0; return 0; } void sceneIntro_initScene(Scene *sc) { - g_fullpipe->_gameLoader->loadScene(SC_INTRO2); + g_fp->_gameLoader->loadScene(SC_INTRO2); g_vars->sceneIntro_aniin1man = sc->getStaticANIObject1ById(ANI_IN1MAN, -1); g_vars->sceneIntro_needSleep = true; @@ -45,19 +46,19 @@ void sceneIntro_initScene(Scene *sc) { g_vars->sceneIntro_playing = true; g_vars->sceneIntro_needBlackout = false; - if (g_fullpipe->_recordEvents || g_fullpipe->_inputArFlag) + if (g_fp->_recordEvents || g_fp->_inputArFlag) g_vars->sceneIntro_skipIntro = false; - g_fullpipe->_modalObject = new ModalIntro; + g_fp->_modalObject = new ModalIntro; } void sceneHandlerIntro_part1() { - g_fullpipe->_currentScene = g_fullpipe->accessScene(SC_INTRO1); + g_fp->_currentScene = g_fp->accessScene(SC_INTRO1); chainQueue(QU_INTR_FINISH, 0); } void sceneHandlerIntro_part2() { - g_fullpipe->_currentScene = g_fullpipe->accessScene(SC_INTRO2); + g_fp->_currentScene = g_fp->accessScene(SC_INTRO2); chainQueue(QU_IN2_DO, 0); } @@ -101,7 +102,7 @@ int sceneHandlerIntro(ExCommand *ex) { chainQueue(QU_INTR_GETUPMAN, 0); } - g_fullpipe->startSceneTrack(); + g_fp->startSceneTrack(); return 0; } diff --git a/engines/fullpipe/sound.cpp b/engines/fullpipe/sound.cpp index 147d6218c6..a08152e94c 100644 --- a/engines/fullpipe/sound.cpp +++ b/engines/fullpipe/sound.cpp @@ -86,7 +86,7 @@ bool Sound::load(MfcArchive &file, NGIArchive *archive) { _id = file.readUint32LE(); _description = file.readPascalString(); - assert(g_fullpipe->_gameProjectVersion >= 6); + assert(g_fp->_gameProjectVersion >= 6); _objectId = file.readUint16LE(); @@ -128,7 +128,11 @@ void FullpipeEngine::toggleMute() { } void FullpipeEngine::playSound(int id, int flag) { - warning("STUB: FullpipeEngine::playSounds(%d, %d)", id, flag); + warning("STUB: FullpipeEngine::playSound(%d, %d)", id, flag); +} + +void FullpipeEngine::playTrack(GameVar *sceneVar, const char *name, bool delayed) { + warning("STUB: FullpipeEngine::playTrack(var, %s, %d)", name, delayed); } void global_messageHandler_handleSound(ExCommand *cmd) { @@ -143,5 +147,8 @@ void FullpipeEngine::stopAllSoundStreams() { warning("STUB: FullpipeEngine::stopAllSoundStreams()"); } +void FullpipeEngine::stopAllSoundInstances(int id) { + warning("STUB: FullpipeEngine::stopAllSoundInstances(%d)", id); +} } // End of namespace Fullpipe diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp index 747015e9a1..6a56ffd662 100644 --- a/engines/fullpipe/stateloader.cpp +++ b/engines/fullpipe/stateloader.cpp @@ -115,25 +115,25 @@ bool GameProject::load(MfcArchive &file) { _headerFilename = 0; _field_10 = 12; - g_fullpipe->_gameProjectVersion = file.readUint32LE(); - g_fullpipe->_pictureScale = file.readUint16LE(); - g_fullpipe->_scrollSpeed = file.readUint32LE(); + g_fp->_gameProjectVersion = file.readUint32LE(); + g_fp->_pictureScale = file.readUint16LE(); + g_fp->_scrollSpeed = file.readUint32LE(); _headerFilename = file.readPascalString(); - debug(1, "_gameProjectVersion = %d", g_fullpipe->_gameProjectVersion); - debug(1, "_pictureScale = %d", g_fullpipe->_pictureScale); - debug(1, "_scrollSpeed = %d", g_fullpipe->_scrollSpeed); + debug(1, "_gameProjectVersion = %d", g_fp->_gameProjectVersion); + debug(1, "_pictureScale = %d", g_fp->_pictureScale); + debug(1, "_scrollSpeed = %d", g_fp->_scrollSpeed); debug(1, "_headerFilename = %s", _headerFilename); _sceneTagList = new SceneTagList(); _sceneTagList->load(file); - if (g_fullpipe->_gameProjectVersion >= 3) + if (g_fp->_gameProjectVersion >= 3) _field_4 = file.readUint32LE(); - if (g_fullpipe->_gameProjectVersion >= 5) { + if (g_fp->_gameProjectVersion >= 5) { file.readUint32LE(); file.readUint32LE(); } diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp index 12c56fe429..2af9cff743 100644 --- a/engines/fullpipe/statics.cpp +++ b/engines/fullpipe/statics.cpp @@ -191,7 +191,7 @@ bool StaticANIObject::load(MfcArchive &file) { char *movname = genFileName(_id, movNum, "mov"); - Common::SeekableReadStream *f = g_fullpipe->_currArchive->createReadStreamForMember(movname); + Common::SeekableReadStream *f = g_fp->_currArchive->createReadStreamForMember(movname); Movement *mov = new Movement(); @@ -249,11 +249,11 @@ void StaticANIObject::setFlags40(bool state) { void StaticANIObject::deleteFromGlobalMessageQueue() { while (_messageQueueId) { - if (g_fullpipe->_globalMessageQueueList->getMessageQueueById(_messageQueueId)) { + if (g_fp->_globalMessageQueueList->getMessageQueueById(_messageQueueId)) { if (!isIdle()) return; - g_fullpipe->_globalMessageQueueList->deleteQueueById(_messageQueueId); + g_fp->_globalMessageQueueList->deleteQueueById(_messageQueueId); } else { _messageQueueId = 0; } @@ -285,7 +285,7 @@ MessageQueue *StaticANIObject::getMessageQueue() { if (this->_messageQueueId <= 0) return 0; - return g_fullpipe->_globalMessageQueueList->getMessageQueueById(_messageQueueId); + return g_fp->_globalMessageQueueList->getMessageQueueById(_messageQueueId); } bool StaticANIObject::trySetMessageQueue(int msgNum, int qId) { @@ -304,7 +304,7 @@ bool StaticANIObject::trySetMessageQueue(int msgNum, int qId) { bool StaticANIObject::isIdle() { if (_messageQueueId) { - MessageQueue *m = g_fullpipe->_globalMessageQueueList->getMessageQueueById(_messageQueueId); + MessageQueue *m = g_fp->_globalMessageQueueList->getMessageQueueById(_messageQueueId); if (m && m->getFlags() & 1) return false; @@ -429,7 +429,7 @@ void Movement::draw(bool flipFlag, int angle) { int y = _oy - point.y; if (_currDynamicPhase->getPaletteData()) - g_fullpipe->_globalPalette = _currDynamicPhase->getPaletteData(); + g_fp->_globalPalette = _currDynamicPhase->getPaletteData(); if (_currDynamicPhase->getAlpha() < 0xFF) { warning("Movement::draw: alpha < 0xff: %d", _currDynamicPhase->getAlpha()); @@ -499,7 +499,7 @@ void StaticANIObject::draw() { debug(6, "StaticANIObject::draw() (%s) [%d] [%d, %d]", transCyrillic((byte *)_objectName), _id, _ox, _oy); - if (_shadowsOn && g_fullpipe->_currentScene && g_fullpipe->_currentScene->_shadows + if (_shadowsOn && g_fp->_currentScene && g_fp->_currentScene->_shadows && (getCurrDimensions(point)->x != 1 || getCurrDimensions(point)->y != 1)) { DynamicPhase *dyn; @@ -517,7 +517,7 @@ void StaticANIObject::draw() { if (dyn->getDynFlags() & 4) { rect = *dyn->_rect; - DynamicPhase *shd = g_fullpipe->_currentScene->_shadows->findSize(rect.width(), rect.height()); + DynamicPhase *shd = g_fp->_currentScene->_shadows->findSize(rect.width(), rect.height()); if (shd) { shd->getDimensions(&point); int midx = _ox - point.x / 2 - dyn->_someX; @@ -573,7 +573,7 @@ void StaticANIObject::draw2() { } MovTable *StaticANIObject::countMovements() { - GameVar *preloadSubVar = g_fullpipe->getGameLoaderGameVar()->getSubVarByName(getName())->getSubVarByName("PRELOAD"); + GameVar *preloadSubVar = g_fp->getGameLoaderGameVar()->getSubVarByName(getName())->getSubVarByName("PRELOAD"); if (!preloadSubVar || preloadSubVar->getSubVarsCount() == 0) return 0; @@ -599,7 +599,7 @@ MovTable *StaticANIObject::countMovements() { } void StaticANIObject::setSpeed(int speed) { - GameVar *var = g_fullpipe->getGameLoaderGameVar()->getSubVarByName(getName())->getSubVarByName("SpeedUp"); + GameVar *var = g_fp->getGameLoaderGameVar()->getSubVarByName(getName())->getSubVarByName("SpeedUp"); if (!var) return; @@ -886,15 +886,15 @@ void StaticANIObject::changeStatics2(int objId) { deleteFromGlobalMessageQueue(); if (_movement || _statics) { - g_fullpipe->_mgm->addItem(_id); - g_fullpipe->_mgm->updateAnimStatics(this, objId); + g_fp->_mgm->addItem(_id); + g_fp->_mgm->updateAnimStatics(this, objId); } else { _statics = getStaticsById(objId); } if (_messageQueueId) { - if (g_fullpipe->_globalMessageQueueList->getMessageQueueById(_messageQueueId)) - g_fullpipe->_globalMessageQueueList->deleteQueueById(_messageQueueId); + if (g_fp->_globalMessageQueueList->getMessageQueueById(_messageQueueId)) + g_fp->_globalMessageQueueList->deleteQueueById(_messageQueueId); _messageQueueId = 0; } @@ -1376,10 +1376,10 @@ bool Movement::load(MfcArchive &file, StaticANIObject *ani) { _flipFlag = 1; } - if (g_fullpipe->_gameProjectVersion >= 8) + if (g_fp->_gameProjectVersion >= 8) _field_50 = file.readUint32LE(); - if (g_fullpipe->_gameProjectVersion < 12) + if (g_fp->_gameProjectVersion < 12) _counterMax = 83; else _counterMax = file.readUint32LE(); @@ -1817,9 +1817,9 @@ DynamicPhase::DynamicPhase(DynamicPhase *src, bool reverse) { _data = _bitmap->_pixels; _dataSize = src->_dataSize; - if (g_fullpipe->_currArchive) { + if (g_fp->_currArchive) { _mfield_14 = 0; - _libHandle = g_fullpipe->_currArchive; + _libHandle = g_fp->_currArchive; } _mflags |= 1; @@ -1877,12 +1877,12 @@ bool DynamicPhase::load(MfcArchive &file) { _rect->right = file.readUint32LE(); _rect->bottom = file.readUint32LE(); - assert (g_fullpipe->_gameProjectVersion >= 1); + assert (g_fp->_gameProjectVersion >= 1); _someX = file.readUint32LE(); _someY = file.readUint32LE(); - assert (g_fullpipe->_gameProjectVersion >= 12); + assert (g_fp->_gameProjectVersion >= 12); _dynFlags = file.readUint32LE(); @@ -1909,13 +1909,13 @@ bool StaticPhase::load(MfcArchive &file) { _initialCountdown = file.readUint16LE(); _field_6A = file.readUint16LE(); - if (g_fullpipe->_gameProjectVersion >= 12) { + if (g_fp->_gameProjectVersion >= 12) { _exCommand = (ExCommand *)file.readClass(); return true; } - assert (g_fullpipe->_gameProjectVersion >= 12); + assert (g_fp->_gameProjectVersion >= 12); return true; } diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 3a65801951..b3668ea362 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -138,9 +138,9 @@ bool MemoryObject::load(MfcArchive &file) { } } - if (g_fullpipe->_currArchive) { + if (g_fp->_currArchive) { _mfield_14 = 0; - _libHandle = g_fullpipe->_currArchive; + _libHandle = g_fp->_currArchive; } return true; @@ -153,12 +153,12 @@ void MemoryObject::loadFile(char *filename) { return; if (!_data) { - NGIArchive *arr = g_fullpipe->_currArchive; + NGIArchive *arr = g_fp->_currArchive; - if (g_fullpipe->_currArchive != _libHandle && _libHandle) - g_fullpipe->_currArchive = _libHandle; + if (g_fp->_currArchive != _libHandle && _libHandle) + g_fp->_currArchive = _libHandle; - Common::SeekableReadStream *s = g_fullpipe->_currArchive->createReadStreamForMember(filename); + Common::SeekableReadStream *s = g_fp->_currArchive->createReadStreamForMember(filename); if (s) { assert(s->size() > 0); @@ -174,7 +174,7 @@ void MemoryObject::loadFile(char *filename) { warning("MemoryObject::loadFile(): reading failure"); } - g_fullpipe->_currArchive = arr; + g_fp->_currArchive = arr; } } |