diff options
author | Strangerke | 2015-11-30 13:09:36 +0100 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-12-23 21:33:44 +0100 |
commit | 4a90aba77af7de91f03dc51a7180637eb843ca95 (patch) | |
tree | 5472dfc43a98a41240ac70e9023534a9004f9ebb /engines | |
parent | d45d46c2cb682937ae64373aeee9517ba2ca346d (diff) | |
download | scummvm-rg350-4a90aba77af7de91f03dc51a7180637eb843ca95.tar.gz scummvm-rg350-4a90aba77af7de91f03dc51a7180637eb843ca95.tar.bz2 scummvm-rg350-4a90aba77af7de91f03dc51a7180637eb843ca95.zip |
LAB: Get rid of a goto
Diffstat (limited to 'engines')
-rw-r--r-- | engines/lab/engine.cpp | 941 | ||||
-rw-r--r-- | engines/lab/lab.h | 1 |
2 files changed, 472 insertions, 470 deletions
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp index 37a897779b..7d67241513 100644 --- a/engines/lab/engine.cpp +++ b/engines/lab/engine.cpp @@ -618,17 +618,10 @@ void LabEngine::decIncInv(uint16 *CurInv, bool dec) { /* The main game loop */ /******************************************************************************/ void LabEngine::mainGameLoop() { - uint32 Class; + uint16 actionMode = 4; + uint16 curInv = MAPNUM; - uint16 Qualifier, ActionMode = 4; - uint16 CurInv = MAPNUM, LastInv = MAPNUM, Old; - - bool ForceDraw = false, doit, GotMessage = true; - - uint16 OldRoomNum, OldDirection = 0, GadID = 0, NewDir; - - CloseDataPtr OldCPtr, TempCPtr, HCPtr = NULL; - ViewData *VPtr; + bool forceDraw = false, GotMessage = true; VGASetPal(initcolors, 8); @@ -650,11 +643,10 @@ void LabEngine::mainGameLoop() { LongWinInFront = false; drawPanel(); - perFlipGadget(ActionMode); + perFlipGadget(actionMode); /* Set up initial picture. */ - uint16 code = 0; while (1) { WSDL_ProcessInput(1); @@ -680,7 +672,7 @@ void LabEngine::mainGameLoop() { if (noupdatediff) { _roomsFound->inclElement(_roomNum); /* Potentially entered another room */ - ForceDraw = (strcmp(Test, CurFileName) != 0) || ForceDraw; + forceDraw = (strcmp(Test, CurFileName) != 0) || forceDraw; noupdatediff = false; CurFileName = Test; @@ -703,8 +695,8 @@ void LabEngine::mainGameLoop() { } else readPict(CurFileName, false); - drawRoomMessage(CurInv, CPtr); - ForceDraw = false; + drawRoomMessage(curInv, CPtr); + forceDraw = false; mayShowCrumbIndicator(); WSDL_UpdateScreen(); @@ -713,9 +705,9 @@ void LabEngine::mainGameLoop() { eatMessages(); } - if (ForceDraw) { - drawRoomMessage(CurInv, CPtr); - ForceDraw = false; + if (forceDraw) { + drawRoomMessage(curInv, CPtr); + forceDraw = false; WSDL_UpdateScreen(); } } @@ -724,7 +716,6 @@ void LabEngine::mainGameLoop() { interfaceOn(); IntuiMessage *curMsg = getMsg(); - Common::Point curPos; if (curMsg == NULL) { /* Does music load and next animation frame when you've run out of messages */ GotMessage = false; _music->checkRoomMusic(); @@ -735,21 +726,19 @@ void LabEngine::mainGameLoop() { int result = followCrumbs(); if (result != 0) { - curPos = WSDL_GetMousePos(); - Class = GADGETUP; - Qualifier = 0; - + uint16 code = 0; if (result == VKEY_UPARROW) - code = GadID = 7; + code = 7; else if (result == VKEY_LTARROW) - code = GadID = 6; + code = 6; else if (result == VKEY_RTARROW) - code = GadID = 8; + code = 8; GotMessage = true; mayShowCrumbIndicator(); WSDL_UpdateScreen(); - goto from_crumbs; + if (!from_crumbs(GADGETUP, code, 0, WSDL_GetMousePos(), curInv, curMsg, forceDraw, code, actionMode)) + break; } } @@ -758,528 +747,540 @@ void LabEngine::mainGameLoop() { } else { GotMessage = true; - Class = curMsg->msgClass; - code = curMsg->code; - Qualifier = curMsg->qualifier; + Common::Point curPos; curPos.x = curMsg->mouseX; curPos.y = curMsg->mouseY; - GadID = curMsg->gadgetID; _followingCrumbs = false; + if (!from_crumbs(curMsg->msgClass, curMsg->code, curMsg->qualifier, curPos, curInv, curMsg, forceDraw, curMsg->gadgetID, actionMode)) + break; + } + } -from_crumbs: - DoBlack = false; + delete _conditions; + delete _roomsFound; - if ((Class == RAWKEY) && (!LongWinInFront)) { - if (code == 13) { /* The return key */ - Class = MOUSEBUTTONS; - Qualifier = IEQUALIFIER_LEFTBUTTON; - curPos = _event->getMousePos(); - } else if (getPlatform() == Common::kPlatformWindows && - (code == 'b' || code == 'B')) { /* Start bread crumbs */ - _breadCrumbs[0]._roomNum = 0; - _numCrumbs = 0; - _droppingCrumbs = true; - mayShowCrumbIndicator(); - WSDL_UpdateScreen(); - } else if (code == 'f' || code == 'F' || - code == 'r' || code == 'R') { /* Follow bread crumbs */ - if (_droppingCrumbs) { - if (_numCrumbs > 0) { - _followingCrumbs = true; - _followCrumbsFast = (code == 'r' || code == 'R'); - _isCrumbTurning = false; - _isCrumbWaiting = false; - getTime(&_crumbSecs, &_crumbMicros); - - if (Alternate) { - eatMessages(); - Alternate = false; - DoBlack = true; - DoNotDrawMessage = false; - - MainDisplay = true; - interfaceOn(); /* Sets the correct gadget list */ - drawPanel(); - drawRoomMessage(CurInv, CPtr); - WSDL_UpdateScreen(); - } - } else { - _breadCrumbs[0]._roomNum = 0; - _droppingCrumbs = false; + if (_rooms) { + free(_rooms); + _rooms = nullptr; + } - // Need to hide indicator!!!! - mayShowCrumbIndicatorOff(); - WSDL_UpdateScreen(); - } - } - } else if ((code == 315) || (code == 'x') || (code == 'X') - || (code == 'q') || (code == 'Q')) { /* Quit? */ - DoNotDrawMessage = false; - drawMessage("Do you want to quit? (Y/N)"); - doit = false; - eatMessages(); - interfaceOff(); - - while (1) { - _music->updateMusic(); /* Make sure we check the music at least after every message */ - curMsg = getMsg(); - - if (curMsg == NULL) { /* Does music load and next animation frame when you've run out of messages */ - _music->updateMusic(); - diffNextFrame(); - } else { - if (curMsg->msgClass == RAWKEY) { - if ((curMsg->code == 'Y') || (curMsg->code == 'y') || (curMsg->code == 'Q') || (curMsg->code == 'q')) { - doit = true; - break; - } else if (curMsg->code < 128) { - break; - } - } else if (curMsg->msgClass == MOUSEBUTTONS) { - break; - } - } + if (Inventory) { + for (int i = 1; i <= NumInv; i++) { + if (Inventory[i].name) + free(Inventory[i].name); + + if (Inventory[i].BInvName) + free(Inventory[i].BInvName); + } + + free(Inventory); + } +} + +bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Common::Point tmpPos, uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode) { + uint32 msgClass = tmpClass; + Common::Point curPos = tmpPos; + + uint16 OldRoomNum, OldDirection = 0; + uint16 LastInv = MAPNUM, Old; + CloseDataPtr OldCPtr, TempCPtr, HCPtr = NULL; + ViewData *VPtr; + bool doit; + uint16 NewDir; + + + DoBlack = false; + + if ((msgClass == RAWKEY) && (!LongWinInFront)) { + if (code == 13) { /* The return key */ + msgClass = MOUSEBUTTONS; + Qualifier = IEQUALIFIER_LEFTBUTTON; + curPos = _event->getMousePos(); + } else if (getPlatform() == Common::kPlatformWindows && + (code == 'b' || code == 'B')) { /* Start bread crumbs */ + _breadCrumbs[0]._roomNum = 0; + _numCrumbs = 0; + _droppingCrumbs = true; + mayShowCrumbIndicator(); + WSDL_UpdateScreen(); + } else if (code == 'f' || code == 'F' || + code == 'r' || code == 'R') { /* Follow bread crumbs */ + if (_droppingCrumbs) { + if (_numCrumbs > 0) { + _followingCrumbs = true; + _followCrumbsFast = (code == 'r' || code == 'R'); + _isCrumbTurning = false; + _isCrumbWaiting = false; + getTime(&_crumbSecs, &_crumbMicros); + + if (Alternate) { + eatMessages(); + Alternate = false; + DoBlack = true; + DoNotDrawMessage = false; + + MainDisplay = true; + interfaceOn(); /* Sets the correct gadget list */ + drawPanel(); + drawRoomMessage(curInv, CPtr); + WSDL_UpdateScreen(); } + } else { + _breadCrumbs[0]._roomNum = 0; + _droppingCrumbs = false; - if (doit) { - stopDiff(); + // Need to hide indicator!!!! + mayShowCrumbIndicatorOff(); + WSDL_UpdateScreen(); + } + } + } else if ((code == 315) || (code == 'x') || (code == 'X') + || (code == 'q') || (code == 'Q')) { /* Quit? */ + DoNotDrawMessage = false; + drawMessage("Do you want to quit? (Y/N)"); + doit = false; + eatMessages(); + interfaceOff(); + + while (1) { + _music->updateMusic(); /* Make sure we check the music at least after every message */ + curMsg = getMsg(); + + if (curMsg == NULL) { /* Does music load and next animation frame when you've run out of messages */ + _music->updateMusic(); + diffNextFrame(); + } else { + if (curMsg->msgClass == RAWKEY) { + if ((curMsg->code == 'Y') || (curMsg->code == 'y') || (curMsg->code == 'Q') || (curMsg->code == 'q')) { + doit = true; + break; + } else if (curMsg->code < 128) { + break; + } + } else if (curMsg->msgClass == MOUSEBUTTONS) { break; - } else { - ForceDraw = true; - interfaceOn(); } - } else if (code == 9) { /* TAB key */ - Class = DELTAMOVE; - } else if (code == 27) { /* ESC key */ - CPtr = NULL; } + } - eatMessages(); + if (doit) { + stopDiff(); + return false; + } else { + forceDraw = true; + interfaceOn(); } + } else if (code == 9) { /* TAB key */ + msgClass = DELTAMOVE; + } else if (code == 27) { /* ESC key */ + CPtr = NULL; + } - if (LongWinInFront) { - if ((Class == RAWKEY) || - ((Class == MOUSEBUTTONS) && - ((IEQUALIFIER_LEFTBUTTON & Qualifier) || - (IEQUALIFIER_RBUTTON & Qualifier)))) { - LongWinInFront = false; - DoNotDrawMessage = false; - drawPanel(); - drawRoomMessage(CurInv, CPtr); - WSDL_UpdateScreen(); - } - } else if ((Class == GADGETUP) && !Alternate) { - if (GadID <= 5) { - if ((ActionMode == 4) && (GadID == 4) && (CPtr != NULL)) { - doMainView(&CPtr); + eatMessages(); + } - DoBlack = true; - HCPtr = NULL; - CPtr = NULL; - mayShowCrumbIndicator(); - WSDL_UpdateScreen(); - } else if (GadID == 5) { - eatMessages(); + if (LongWinInFront) { + if ((msgClass == RAWKEY) || + ((msgClass == MOUSEBUTTONS) && + ((IEQUALIFIER_LEFTBUTTON & Qualifier) || + (IEQUALIFIER_RBUTTON & Qualifier)))) { + LongWinInFront = false; + DoNotDrawMessage = false; + drawPanel(); + drawRoomMessage(curInv, CPtr); + WSDL_UpdateScreen(); + } + } else if ((msgClass == GADGETUP) && !Alternate) { + if (gadgetId <= 5) { + if ((actionMode == 4) && (gadgetId == 4) && (CPtr != NULL)) { + doMainView(&CPtr); - Alternate = true; - DoBlack = true; - DoNotDrawMessage = false; - interfaceOn(); /* Sets the correct gadget list */ + DoBlack = true; + HCPtr = NULL; + CPtr = NULL; + mayShowCrumbIndicator(); + WSDL_UpdateScreen(); + } else if (gadgetId == 5) { + eatMessages(); + + Alternate = true; + DoBlack = true; + DoNotDrawMessage = false; + interfaceOn(); /* Sets the correct gadget list */ - MainDisplay = false; + MainDisplay = false; - if (LastInv && _conditions->in(LastInv)) { - CurInv = LastInv; - Test = getInvName(CurInv); - } else - decIncInv(&CurInv, false); + if (LastInv && _conditions->in(LastInv)) { + curInv = LastInv; + Test = getInvName(curInv); + } else + decIncInv(&curInv, false); - drawPanel(); - drawRoomMessage(CurInv, CPtr); + drawPanel(); + drawRoomMessage(curInv, CPtr); - mayShowCrumbIndicator(); - WSDL_UpdateScreen(); - } else { - Old = ActionMode; - ActionMode = GadID; + mayShowCrumbIndicator(); + WSDL_UpdateScreen(); + } else { + Old = actionMode; + actionMode = gadgetId; + + if (Old < 5) + perFlipGadget(Old); + + perFlipGadget(actionMode); + + if (gadgetId == 0) + drawStaticMessage(kTextTakeWhat); + else if (gadgetId == 1) + drawStaticMessage(kTextMoveWhat); + else if (gadgetId == 2) + drawStaticMessage(kTextOpenWhat); + else if (gadgetId == 3) + drawStaticMessage(kTextCloseWhat); + else if (gadgetId == 4) + drawStaticMessage(kTextLookWhat); - if (Old < 5) - perFlipGadget(Old); + WSDL_UpdateScreen(); + } + } else if (gadgetId == 9) { + doUse(MAPNUM); - perFlipGadget(ActionMode); + mayShowCrumbIndicator(); + WSDL_UpdateScreen(); + } else if (gadgetId >= 6) { /* Arrow Gadgets */ + CPtr = NULL; + HCPtr = NULL; - if (GadID == 0) - drawStaticMessage(kTextTakeWhat); - else if (GadID == 1) - drawStaticMessage(kTextMoveWhat); - else if (GadID == 2) - drawStaticMessage(kTextOpenWhat); - else if (GadID == 3) - drawStaticMessage(kTextCloseWhat); - else if (GadID == 4) - drawStaticMessage(kTextLookWhat); + if ((gadgetId == 6) || (gadgetId == 8)) { + if (gadgetId == 6) + drawStaticMessage(kTextTurnLeft); + else + drawStaticMessage(kTextTurnRight); - WSDL_UpdateScreen(); - } - } else if (GadID == 9) { - doUse(MAPNUM); + CurFileName = " "; - mayShowCrumbIndicator(); - WSDL_UpdateScreen(); - } else if (GadID >= 6) { /* Arrow Gadgets */ - CPtr = NULL; - HCPtr = NULL; + OldDirection = Direction; - if ((GadID == 6) || (GadID == 8)) { - if (GadID == 6) - drawStaticMessage(kTextTurnLeft); - else - drawStaticMessage(kTextTurnRight); + NewDir = Direction; + processArrow(&NewDir, gadgetId - 6); + doTurn(Direction, NewDir, &CPtr); + DoBlack = true; + Direction = NewDir; + forceDraw = true; - CurFileName = " "; + mayShowCrumbIndicator(); + WSDL_UpdateScreen(); + } else if (gadgetId == 7) { + OldRoomNum = _roomNum; - OldDirection = Direction; + if (doGoForward(&CPtr)) { + if (OldRoomNum == _roomNum) + DoBlack = true; + } else { + DoBlack = true; + processArrow(&Direction, gadgetId - 6); - NewDir = Direction; - processArrow(&NewDir, GadID - 6); - doTurn(Direction, NewDir, &CPtr); + if (OldRoomNum != _roomNum) { + drawStaticMessage(kTextGoForward); + _roomsFound->inclElement(_roomNum); /* Potentially entered a new room */ + CurFileName = " "; + forceDraw = true; + } else { DoBlack = true; - Direction = NewDir; - ForceDraw = true; + drawStaticMessage(kTextNoPath); + } + } - mayShowCrumbIndicator(); - WSDL_UpdateScreen(); - } else if (GadID == 7) { - OldRoomNum = _roomNum; - - if (doGoForward(&CPtr)) { - if (OldRoomNum == _roomNum) - DoBlack = true; - } else { - DoBlack = true; - processArrow(&Direction, GadID - 6); - - if (OldRoomNum != _roomNum) { - drawStaticMessage(kTextGoForward); - _roomsFound->inclElement(_roomNum); /* Potentially entered a new room */ - CurFileName = " "; - ForceDraw = true; - } else { - DoBlack = true; - drawStaticMessage(kTextNoPath); + if (_followingCrumbs) { + if (_isCrumbTurning) { + if (Direction == OldDirection) { + _followingCrumbs = false; + } + } else { + if (_roomNum == OldRoomNum) { // didn't get there? + _followingCrumbs = false; + } + } + } else if (_droppingCrumbs && OldRoomNum != _roomNum) { + // If in surreal maze, turn off DroppingCrumbs. + // Note: These numbers were generated by parsing the + // "Maps" file, which is why they are hard-coded. Bleh! + if (_roomNum >= 245 && _roomNum <= 280) { + _followingCrumbs = false; + _droppingCrumbs = false; + _numCrumbs = 0; + _breadCrumbs[0]._roomNum = 0; + } else { + bool intersect = false; + for (int idx = 0; idx < _numCrumbs; idx++) { + if (_breadCrumbs[idx]._roomNum == _roomNum) { + _numCrumbs = idx + 1; + _breadCrumbs[_numCrumbs]._roomNum = 0; + intersect = true; } } - if (_followingCrumbs) { - if (_isCrumbTurning) { - if (Direction == OldDirection) { - _followingCrumbs = false; - } - } else { - if (_roomNum == OldRoomNum) { // didn't get there? - _followingCrumbs = false; - } + if (!intersect) { + if (_numCrumbs == MAX_CRUMBS) { + _numCrumbs = MAX_CRUMBS - 1; + memcpy(&_breadCrumbs[0], &_breadCrumbs[1], _numCrumbs * sizeof _breadCrumbs[0]); } - } else if (_droppingCrumbs && OldRoomNum != _roomNum) { - // If in surreal maze, turn off DroppingCrumbs. - // Note: These numbers were generated by parsing the - // "Maps" file, which is why they are hard-coded. Bleh! - if (_roomNum >= 245 && _roomNum <= 280) { - _followingCrumbs = false; - _droppingCrumbs = false; - _numCrumbs = 0; - _breadCrumbs[0]._roomNum = 0; - } else { - bool intersect = false; - for (int idx = 0; idx < _numCrumbs; idx++) { - if (_breadCrumbs[idx]._roomNum == _roomNum) { - _numCrumbs = idx + 1; - _breadCrumbs[_numCrumbs]._roomNum = 0; - intersect = true; - } - } - - if (!intersect) { - if (_numCrumbs == MAX_CRUMBS) { - _numCrumbs = MAX_CRUMBS - 1; - memcpy(&_breadCrumbs[0], &_breadCrumbs[1], _numCrumbs * sizeof _breadCrumbs[0]); - } - - _breadCrumbs[_numCrumbs]._roomNum = _roomNum; - _breadCrumbs[_numCrumbs++]._direction = Direction; - } - } - } - mayShowCrumbIndicator(); - WSDL_UpdateScreen(); + _breadCrumbs[_numCrumbs]._roomNum = _roomNum; + _breadCrumbs[_numCrumbs++]._direction = Direction; + } } } - } else if ((Class == GADGETUP) && Alternate) { - DoBlack = true; - - if (GadID == 0) { - eatMessages(); - Alternate = false; - DoBlack = true; - DoNotDrawMessage = false; - MainDisplay = true; - interfaceOn(); /* Sets the correct gadget list */ - drawPanel(); - drawRoomMessage(CurInv, CPtr); - - WSDL_UpdateScreen(); - } + mayShowCrumbIndicator(); + WSDL_UpdateScreen(); + } + } + } else if ((msgClass == GADGETUP) && Alternate) { + DoBlack = true; - GadID--; + if (gadgetId == 0) { + eatMessages(); + Alternate = false; + DoBlack = true; + DoNotDrawMessage = false; - if (GadID == 0) { - interfaceOff(); - stopDiff(); - CurFileName = " "; + MainDisplay = true; + interfaceOn(); /* Sets the correct gadget list */ + drawPanel(); + drawRoomMessage(curInv, CPtr); - doit = !saveRestoreGame(); - CPtr = NULL; + WSDL_UpdateScreen(); + } - MainDisplay = true; + gadgetId--; - CurInv = MAPNUM; - LastInv = MAPNUM; + if (gadgetId == 0) { + interfaceOff(); + stopDiff(); + CurFileName = " "; - Test = getInvName(CurInv); + doit = !saveRestoreGame(); + CPtr = NULL; - drawPanel(); + MainDisplay = true; - if (doit) { - drawMessage("Disk operation failed."); - VGASetPal(initcolors, 8); + curInv = MAPNUM; + LastInv = MAPNUM; - WSDL_UpdateScreen(); + Test = getInvName(curInv); - g_system->delayMillis(1000); - } else { - WSDL_UpdateScreen(); - } - } else if (GadID == 1) { - if (!doUse(CurInv)) { - Old = ActionMode; - ActionMode = 5; /* Use button */ + drawPanel(); - if (Old < 5) - perFlipGadget(Old); + if (doit) { + drawMessage("Disk operation failed."); + VGASetPal(initcolors, 8); - drawStaticMessage(kTextUseOnWhat); - MainDisplay = true; + WSDL_UpdateScreen(); - WSDL_UpdateScreen(); - } - } else if (GadID == 2) { - MainDisplay = !MainDisplay; + g_system->delayMillis(1000); + } else { + WSDL_UpdateScreen(); + } + } else if (gadgetId == 1) { + if (!doUse(curInv)) { + Old = actionMode; + actionMode = 5; /* Use button */ - if ((CurInv == 0) || (CurInv > NumInv)) { - CurInv = 1; + if (Old < 5) + perFlipGadget(Old); - while ((CurInv <= NumInv) && (!_conditions->in(CurInv))) - CurInv++; - } + drawStaticMessage(kTextUseOnWhat); + MainDisplay = true; - if ((CurInv <= NumInv) && _conditions->in(CurInv) && - Inventory[CurInv].BInvName) - Test = getInvName(CurInv); + WSDL_UpdateScreen(); + } + } else if (gadgetId == 2) { + MainDisplay = !MainDisplay; - WSDL_UpdateScreen(); - } else if (GadID == 3) { /* Left gadget */ - decIncInv(&CurInv, true); - LastInv = CurInv; - DoNotDrawMessage = false; - drawRoomMessage(CurInv, CPtr); + if ((curInv == 0) || (curInv > NumInv)) { + curInv = 1; - WSDL_UpdateScreen(); - } else if (GadID == 4) { /* Right gadget */ - decIncInv(&CurInv, false); - LastInv = CurInv; - DoNotDrawMessage = false; - drawRoomMessage(CurInv, CPtr); + while ((curInv <= NumInv) && (!_conditions->in(curInv))) + curInv++; + } - WSDL_UpdateScreen(); - } else if (GadID == 5) { /* bread crumbs */ - _breadCrumbs[0]._roomNum = 0; - _numCrumbs = 0; - _droppingCrumbs = true; - mayShowCrumbIndicator(); - WSDL_UpdateScreen(); - } else if (GadID == 6) { /* follow crumbs */ - if (_droppingCrumbs) { - if (_numCrumbs > 0) { - _followingCrumbs = true; - _followCrumbsFast = false; - _isCrumbTurning = false; - _isCrumbWaiting = false; - getTime(&_crumbSecs, &_crumbMicros); - - eatMessages(); - Alternate = false; - DoBlack = true; - DoNotDrawMessage = false; - - MainDisplay = true; - interfaceOn(); /* Sets the correct gadget list */ - drawPanel(); - drawRoomMessage(CurInv, CPtr); - WSDL_UpdateScreen(); - } else { - _breadCrumbs[0]._roomNum = 0; - _droppingCrumbs = false; - - // Need to hide indicator!!!! - mayShowCrumbIndicatorOff(); - WSDL_UpdateScreen(); - } - } - } - } else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier) && MainDisplay) { - interfaceOff(); - MainDisplay = true; + if ((curInv <= NumInv) && _conditions->in(curInv) && + Inventory[curInv].BInvName) + Test = getInvName(curInv); - doit = false; + WSDL_UpdateScreen(); + } else if (gadgetId == 3) { /* Left gadget */ + decIncInv(&curInv, true); + LastInv = curInv; + DoNotDrawMessage = false; + drawRoomMessage(curInv, CPtr); - if (CPtr) { - if ((CPtr->CloseUpType == SPECIALLOCK) && MainDisplay) /* LAB: Labyrinth specific code */ - mouseCombination(curPos); - else if ((CPtr->CloseUpType == SPECIALBRICK) && MainDisplay) - mouseTile(curPos); - else - doit = true; - } else - doit = true; + WSDL_UpdateScreen(); + } else if (gadgetId == 4) { /* Right gadget */ + decIncInv(&curInv, false); + LastInv = curInv; + DoNotDrawMessage = false; + drawRoomMessage(curInv, CPtr); + WSDL_UpdateScreen(); + } else if (gadgetId == 5) { /* bread crumbs */ + _breadCrumbs[0]._roomNum = 0; + _numCrumbs = 0; + _droppingCrumbs = true; + mayShowCrumbIndicator(); + WSDL_UpdateScreen(); + } else if (gadgetId == 6) { /* follow crumbs */ + if (_droppingCrumbs) { + if (_numCrumbs > 0) { + _followingCrumbs = true; + _followCrumbsFast = false; + _isCrumbTurning = false; + _isCrumbWaiting = false; + getTime(&_crumbSecs, &_crumbMicros); - if (doit) { - HCPtr = NULL; eatMessages(); + Alternate = false; + DoBlack = true; + DoNotDrawMessage = false; - if (ActionMode == 0) { /* Take something. */ - if (doActionRule(Common::Point(curPos.x, curPos.y), ActionMode, _roomNum, &CPtr)) - CurFileName = NewFileName; - else if (takeItem(curPos.x, curPos.y, &CPtr)) - drawStaticMessage(kTextTakeItem); - else if (doActionRule(curPos, TAKEDEF - 1, _roomNum, &CPtr)) - CurFileName = NewFileName; - else if (doActionRule(curPos, TAKE - 1, 0, &CPtr)) - CurFileName = NewFileName; - else if (curPos.y < (VGAScaleY(149) + SVGACord(2))) - drawStaticMessage(kTextNothing); - } else if ((ActionMode == 1) /* Manipulate an object */ || - (ActionMode == 2) /* Open up a "door" */ || - (ActionMode == 3)) { /* Close a "door" */ - if (doActionRule(curPos, ActionMode, _roomNum, &CPtr)) - CurFileName = NewFileName; - else if (!doActionRule(curPos, ActionMode, 0, &CPtr)) { - if (curPos.y < (VGAScaleY(149) + SVGACord(2))) - drawStaticMessage(kTextNothing); - } - } else if (ActionMode == 4) { /* Look at closeups */ - TempCPtr = CPtr; - setCurClose(curPos, &TempCPtr); - - if (CPtr == TempCPtr) { - if (curPos.y < (VGAScaleY(149) + SVGACord(2))) - drawStaticMessage(kTextNothing); - } else if (TempCPtr->GraphicName) { - if (*(TempCPtr->GraphicName)) { - DoBlack = true; - CPtr = TempCPtr; - } else if (curPos.y < (VGAScaleY(149) + SVGACord(2))) - drawStaticMessage(kTextNothing); - } else if (curPos.y < (VGAScaleY(149) + SVGACord(2))) - drawStaticMessage(kTextNothing); - } else if ((ActionMode == 5) && - _conditions->in(CurInv)) { /* Use an item on something else */ - if (doOperateRule(curPos.x, curPos.y, CurInv, &CPtr)) { - CurFileName = NewFileName; - - if (!_conditions->in(CurInv)) - decIncInv(&CurInv, false); - } else if (curPos.y < (VGAScaleY(149) + SVGACord(2))) - drawStaticMessage(kTextNothing); - } - } - - mayShowCrumbIndicator(); - WSDL_UpdateScreen(); - } else if (Class == DELTAMOVE) { - VPtr = getViewData(_roomNum, Direction); - OldCPtr = VPtr->closeUps; - - if (HCPtr == NULL) { - TempCPtr = CPtr; - setCurClose(curPos, &TempCPtr); - - if ((TempCPtr == NULL) || (TempCPtr == CPtr)) { - if (CPtr == NULL) - HCPtr = OldCPtr; - else - HCPtr = CPtr->SubCloseUps; - } else - HCPtr = TempCPtr->NextCloseUp; - } else - HCPtr = HCPtr->NextCloseUp; - + MainDisplay = true; + interfaceOn(); /* Sets the correct gadget list */ + drawPanel(); + drawRoomMessage(curInv, CPtr); + WSDL_UpdateScreen(); + } else { + _breadCrumbs[0]._roomNum = 0; + _droppingCrumbs = false; - if (HCPtr == NULL) { - if (CPtr == NULL) - HCPtr = OldCPtr; - else - HCPtr = CPtr->SubCloseUps; + // Need to hide indicator!!!! + mayShowCrumbIndicatorOff(); + WSDL_UpdateScreen(); } + } + } + } else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier) && MainDisplay) { + interfaceOff(); + MainDisplay = true; - if (HCPtr) - _event->setMousePos(Common::Point(scaleX((HCPtr->x1 + HCPtr->x2) / 2), scaleY((HCPtr->y1 + HCPtr->y2) / 2))); - } else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) { - eatMessages(); - Alternate = !Alternate; - DoBlack = true; - DoNotDrawMessage = false; - MainDisplay = true; - interfaceOn(); /* Sets the correct gadget list */ + doit = false; - if (Alternate) { - if (LastInv && _conditions->in(LastInv)) - CurInv = LastInv; - else - decIncInv(&CurInv, false); + if (CPtr) { + if ((CPtr->CloseUpType == SPECIALLOCK) && MainDisplay) /* LAB: Labyrinth specific code */ + mouseCombination(curPos); + else if ((CPtr->CloseUpType == SPECIALBRICK) && MainDisplay) + mouseTile(curPos); + else + doit = true; + } else + doit = true; + + + if (doit) { + HCPtr = NULL; + eatMessages(); + + if (actionMode == 0) { /* Take something. */ + if (doActionRule(Common::Point(curPos.x, curPos.y), actionMode, _roomNum, &CPtr)) + CurFileName = NewFileName; + else if (takeItem(curPos.x, curPos.y, &CPtr)) + drawStaticMessage(kTextTakeItem); + else if (doActionRule(curPos, TAKEDEF - 1, _roomNum, &CPtr)) + CurFileName = NewFileName; + else if (doActionRule(curPos, TAKE - 1, 0, &CPtr)) + CurFileName = NewFileName; + else if (curPos.y < (VGAScaleY(149) + SVGACord(2))) + drawStaticMessage(kTextNothing); + } else if ((actionMode == 1) /* Manipulate an object */ || + (actionMode == 2) /* Open up a "door" */ || + (actionMode == 3)) { /* Close a "door" */ + if (doActionRule(curPos, actionMode, _roomNum, &CPtr)) + CurFileName = NewFileName; + else if (!doActionRule(curPos, actionMode, 0, &CPtr)) { + if (curPos.y < (VGAScaleY(149) + SVGACord(2))) + drawStaticMessage(kTextNothing); } - - drawPanel(); - drawRoomMessage(CurInv, CPtr); - - mayShowCrumbIndicator(); - WSDL_UpdateScreen(); + } else if (actionMode == 4) { /* Look at closeups */ + TempCPtr = CPtr; + setCurClose(curPos, &TempCPtr); + + if (CPtr == TempCPtr) { + if (curPos.y < (VGAScaleY(149) + SVGACord(2))) + drawStaticMessage(kTextNothing); + } else if (TempCPtr->GraphicName) { + if (*(TempCPtr->GraphicName)) { + DoBlack = true; + CPtr = TempCPtr; + } else if (curPos.y < (VGAScaleY(149) + SVGACord(2))) + drawStaticMessage(kTextNothing); + } else if (curPos.y < (VGAScaleY(149) + SVGACord(2))) + drawStaticMessage(kTextNothing); + } else if ((actionMode == 5) && + _conditions->in(curInv)) { /* Use an item on something else */ + if (doOperateRule(curPos.x, curPos.y, curInv, &CPtr)) { + CurFileName = NewFileName; + + if (!_conditions->in(curInv)) + decIncInv(&curInv, false); + } else if (curPos.y < (VGAScaleY(149) + SVGACord(2))) + drawStaticMessage(kTextNothing); } } - } - delete _conditions; - delete _roomsFound; + mayShowCrumbIndicator(); + WSDL_UpdateScreen(); + } else if (msgClass == DELTAMOVE) { + VPtr = getViewData(_roomNum, Direction); + OldCPtr = VPtr->closeUps; + + if (HCPtr == NULL) { + TempCPtr = CPtr; + setCurClose(curPos, &TempCPtr); + + if ((TempCPtr == NULL) || (TempCPtr == CPtr)) { + if (CPtr == NULL) + HCPtr = OldCPtr; + else + HCPtr = CPtr->SubCloseUps; + } else + HCPtr = TempCPtr->NextCloseUp; + } else + HCPtr = HCPtr->NextCloseUp; - if (_rooms) { - free(_rooms); - _rooms = nullptr; - } - if (Inventory) { - for (code = 1; code <= NumInv; code++) { - if (Inventory[code].name) - free(Inventory[code].name); + if (HCPtr == NULL) { + if (CPtr == NULL) + HCPtr = OldCPtr; + else + HCPtr = CPtr->SubCloseUps; + } - if (Inventory[code].BInvName) - free(Inventory[code].BInvName); + if (HCPtr) + _event->setMousePos(Common::Point(scaleX((HCPtr->x1 + HCPtr->x2) / 2), scaleY((HCPtr->y1 + HCPtr->y2) / 2))); + } else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) { + eatMessages(); + Alternate = !Alternate; + DoBlack = true; + DoNotDrawMessage = false; + MainDisplay = true; + interfaceOn(); /* Sets the correct gadget list */ + + if (Alternate) { + if (LastInv && _conditions->in(LastInv)) + curInv = LastInv; + else + decIncInv(&curInv, false); } - free(Inventory); + drawPanel(); + drawRoomMessage(curInv, CPtr); + + mayShowCrumbIndicator(); + WSDL_UpdateScreen(); } + return true; } void LabEngine::go() { diff --git a/engines/lab/lab.h b/engines/lab/lab.h index b2ec4b1c26..f403e4596d 100644 --- a/engines/lab/lab.h +++ b/engines/lab/lab.h @@ -131,6 +131,7 @@ private: private: bool createScreen(bool HiRes); + bool from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Common::Point tmpPos, uint16 &curInv, IntuiMessage * curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode); public: void waitTOF(); |