Ticket #9356: preagi_winnie_inline.patch

File preagi_winnie_inline.patch, 4.1 KB (added by SF/agf863, 13 years ago)

Patch to convert preagi_winnie macros to inline functions

  • engines/agi/preagi_winnie.cpp

    diff --git a/engines/agi/preagi_winnie.cpp b/engines/agi/preagi_winnie.cpp
    index c92434c..825159b 100644
    a b int Winnie::getObjInRoom(int iRoom) {  
    217217        return 0;
    218218}
    219219
    220 #define setTakeDrop() {\
    221         if (getObjInRoom(_room))\
    222                 fCanSel[IDI_WTP_SEL_TAKE] = true;\
    223         else\
    224                 fCanSel[IDI_WTP_SEL_TAKE] = false;\
    225         if (_game.iObjHave)\
    226                 fCanSel[IDI_WTP_SEL_DROP] = true;\
    227         else\
    228                 fCanSel[IDI_WTP_SEL_DROP] = false;\
     220inline void Winnie::setTakeDrop(int fCanSel[]) {
     221        fCanSel[IDI_WTP_SEL_TAKE] = getObjInRoom(_room);
     222        fCanSel[IDI_WTP_SEL_DROP] = _game.iObjHave;
    229223}
    230224
    231225void Winnie::setFlag(int iFlag) {
    int Winnie::parser(int pc, int index, uint8 *buffer) {  
    281275                                fCanSel[IDI_WTP_SEL_EAST] = fCanSel[IDI_WTP_SEL_WEST] = true;
    282276
    283277                        // check if object in room or player carrying one
    284                         setTakeDrop();
     278                        setTakeDrop(fCanSel);
    285279
    286280                        // check which rows have a menu option
    287281                        for (iSel = 0; iSel < IDI_WTP_MAX_OPTION; iSel++) {
    int Winnie::parser(int pc, int index, uint8 *buffer) {  
    367361                                break;
    368362                        case IDI_WTP_SEL_TAKE:
    369363                                takeObj(_room);
    370                                 setTakeDrop();
     364                                setTakeDrop(fCanSel);
    371365                                break;
    372366                        case IDI_WTP_SEL_DROP:
    373367                                dropObj(_room);
    374                                 setTakeDrop();
     368                                setTakeDrop(fCanSel);
    375369                                break;
    376370                        }
    377371                }
    void Winnie::getMenuMouseSel(int *iSel, int fCanSel[], int x, int y) {  
    796790        }
    797791}
    798792
    799 #define makeSel() {\
    800         if (fCanSel[*iSel]) {\
    801                 return;\
    802         } else {\
    803                 keyHelp();\
    804                 clrMenuSel(iSel, fCanSel);\
    805         }\
     793inline void Winnie::makeSel(int *iSel, int fCanSel[]) {
     794        if (fCanSel[*iSel]) {
     795                return;
     796        } else {
     797                keyHelp();
     798                clrMenuSel(iSel, fCanSel);
     799        }
    806800}
    807801
    808802void Winnie::getMenuSel(char *szMenu, int *iSel, int fCanSel[]) {
    void Winnie::getMenuSel(char *szMenu, int *iSel, int fCanSel[]) {  
    844838                                // Click to move
    845839                                if (fCanSel[IDI_WTP_SEL_NORTH] && hotspotNorth.contains(event.mouse.x, event.mouse.y)) {
    846840                                        *iSel = IDI_WTP_SEL_NORTH;
    847                                         makeSel();
     841                                        makeSel(iSel, fCanSel);
    848842                                        _vm->_gfx->setCursorPalette(false);
    849843                                        return;
    850844                                } else if (fCanSel[IDI_WTP_SEL_SOUTH] && hotspotSouth.contains(event.mouse.x, event.mouse.y)) {
    851845                                        *iSel = IDI_WTP_SEL_SOUTH;
    852                                         makeSel();
     846                                        makeSel(iSel, fCanSel);
    853847                                        _vm->_gfx->setCursorPalette(false);
    854848                                        return;
    855849                                } else if (fCanSel[IDI_WTP_SEL_WEST] && hotspotWest.contains(event.mouse.x, event.mouse.y)) {
    856850                                        *iSel = IDI_WTP_SEL_WEST;
    857                                         makeSel();
     851                                        makeSel(iSel, fCanSel);
    858852                                        _vm->_gfx->setCursorPalette(false);
    859853                                        return;
    860854                                } else if (fCanSel[IDI_WTP_SEL_EAST] && hotspotEast.contains(event.mouse.x, event.mouse.y)) {
    861855                                        *iSel = IDI_WTP_SEL_EAST;
    862                                         makeSel();
     856                                        makeSel(iSel, fCanSel);
    863857                                        _vm->_gfx->setCursorPalette(false);
    864858                                        return;
    865859                                } else {
    void Winnie::getMenuSel(char *szMenu, int *iSel, int fCanSel[]) {  
    944938                                        break;
    945939                                case Common::KEYCODE_n:
    946940                                        *iSel = IDI_WTP_SEL_NORTH;
    947                                         makeSel();
     941                                        makeSel(iSel, fCanSel);
    948942                                        break;
    949943                                case Common::KEYCODE_s:
    950944                                        if (event.kbd.flags & Common::KBD_CTRL) {
    951945                                                _vm->flipflag(fSoundOn);
    952946                                        } else {
    953947                                                *iSel = IDI_WTP_SEL_SOUTH;
    954                                                 makeSel();
     948                                                makeSel(iSel, fCanSel);
    955949                                        }
    956950                                        break;
    957951                                case Common::KEYCODE_e:
    958952                                        *iSel = IDI_WTP_SEL_EAST;
    959                                         makeSel();
     953                                        makeSel(iSel, fCanSel);
    960954                                        break;
    961955                                case Common::KEYCODE_w:
    962956                                        *iSel = IDI_WTP_SEL_WEST;
    963                                         makeSel();
     957                                        makeSel(iSel, fCanSel);
    964958                                        break;
    965959                                case Common::KEYCODE_t:
    966960                                        *iSel = IDI_WTP_SEL_TAKE;
    967                                         makeSel();
     961                                        makeSel(iSel, fCanSel);
    968962                                        break;
    969963                                case Common::KEYCODE_d:
    970964                                        *iSel = IDI_WTP_SEL_DROP;
    971                                         makeSel();
     965                                        makeSel(iSel, fCanSel);
    972966                                        break;
    973967                                case Common::KEYCODE_RETURN:
    974968                                        switch (*iSel) {
  • engines/agi/preagi_winnie.h

    diff --git a/engines/agi/preagi_winnie.h b/engines/agi/preagi_winnie.h
    index 5a5472f..f0b7e56 100644
    a b private:  
    342342        void saveGame();
    343343        void loadGame();
    344344        void dropObjRnd();
     345        inline void setTakeDrop(int[]);
     346        inline void makeSel(int*, int[]);
    345347
    346348        void wind();
    347349        void mist();