[Scummvm-git-logs] scummvm master -> 61bf089cb6cfcf7363d860e10acbd596459b2bc7
bluegr
bluegr at gmail.com
Tue Nov 17 21:56:24 UTC 2020
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
5dbea61544 STARTREK: Refactor menu code to remove goto's. Some cleanup
61bf089cb6 STARTREK: Remove the remaining goto's
Commit: 5dbea615449887dc7f47f7a6bee335930e9ba330
https://github.com/scummvm/scummvm/commit/5dbea615449887dc7f47f7a6bee335930e9ba330
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-11-17T23:40:10+02:00
Commit Message:
STARTREK: Refactor menu code to remove goto's. Some cleanup
Changed paths:
engines/startrek/menu.cpp
engines/startrek/resource.cpp
engines/startrek/startrek.h
diff --git a/engines/startrek/menu.cpp b/engines/startrek/menu.cpp
index b260201853..04754edc6f 100644
--- a/engines/startrek/menu.cpp
+++ b/engines/startrek/menu.cpp
@@ -344,63 +344,24 @@ int StarTrekEngine::showActionMenu() {
break;
case TREKEVENT_MOUSEMOVE:
-mousePosChanged: {
- Common::Point mouse = _gfx->getMousePos();
- Common::Point relMouse(mouse.x - pos.x, mouse.y - pos.y);
-
- Common::String bitmapName;
- Common::Point lockMousePoint(-1, -1);
-
- // Check if the mouse is hovering over one of the selectable actions
- if (relMouse.x >= 39 && relMouse.x <= 50 && relMouse.y >= 2 && relMouse.y <= 17) {
- action = ACTION_OPTIONS;
- bitmapName = "options";
- lockMousePoint = Common::Point(pos.x + 44, pos.y + 2);
- } else if (relMouse.x >= 18 && relMouse.x <= 38 && relMouse.y >= 2 && relMouse.y <= 9) {
- action = ACTION_LOOK;
- bitmapName = "look";
- lockMousePoint = Common::Point(pos.x + 28, pos.y + 6);
- } else if (relMouse.x >= 18 && relMouse.x <= 38 && relMouse.y >= 11 && relMouse.y <= 17) {
- action = ACTION_TALK;
- bitmapName = "talk";
- lockMousePoint = Common::Point(pos.x + 27, pos.y + 14);
- } else if (relMouse.x >= 2 && relMouse.x <= 13 && relMouse.y >= 16 && relMouse.y <= 26) {
- action = ACTION_USE;
- bitmapName = "use";
- lockMousePoint = Common::Point(pos.x + 7, pos.y + 19);
- } else if (relMouse.x >= 40 && relMouse.x <= 53 && relMouse.y >= 34 && relMouse.y <= 43) {
- action = ACTION_GET;
- bitmapName = "get";
- lockMousePoint = Common::Point(pos.x + 44, pos.y + 38);
- } else {
- action = ACTION_WALK;
- bitmapName = "walk";
- }
-
- _gfx->setMouseBitmap(bitmapName);
-
- if (lockMousePoint.x != -1)
- _gfx->lockMousePosition(lockMousePoint.x, lockMousePoint.y);
- else
- _gfx->unlockMousePosition();
- }
+ action = mouseMoveEvent();
break;
case TREKEVENT_RBUTTONDOWN:
-exitMenu:
displayMenu = false;
action = ACTION_WALK;
break;
case TREKEVENT_KEYDOWN: {
int nextAction = action;
- const int *lookupArray;
switch (event.kbd.keycode) {
case Common::KEYCODE_ESCAPE:
case Common::KEYCODE_SPACE:
case Common::KEYCODE_F2: // Exit menu without selecting anything
- goto exitMenu;
+ displayMenu = false;
+ action = ACTION_WALK;
+ break;
case Common::KEYCODE_RETURN:
case Common::KEYCODE_KP_ENTER:
@@ -422,29 +383,22 @@ exitMenu:
// Direction buttons
case Common::KEYCODE_UP:
case Common::KEYCODE_KP8:
- lookupArray = actionMappingUp;
- goto lookupNextAction;
+ nextAction = lookupNextAction(actionMappingUp, action);
+ break;
case Common::KEYCODE_RIGHT:
case Common::KEYCODE_KP6:
- lookupArray = actionMappingRight;
- goto lookupNextAction;
+ nextAction = lookupNextAction(actionMappingRight, action);
+ break;
case Common::KEYCODE_DOWN:
case Common::KEYCODE_KP2:
- lookupArray = actionMappingDown;
- goto lookupNextAction;
+ nextAction = lookupNextAction(actionMappingDown, action);
+ break;
case Common::KEYCODE_LEFT:
case Common::KEYCODE_KP4:
- lookupArray = actionMappingLeft;
- goto lookupNextAction;
-
-lookupNextAction:
- // Use a lookup table to decide which action is next after a direction
- // button is pressed.
- assert((action >= ACTION_WALK && action <= ACTION_TALK) || action == ACTION_OPTIONS);
- nextAction = lookupArray[action == ACTION_OPTIONS ? 5 : action - 1];
+ nextAction = lookupNextAction(actionMappingLeft, action);
break;
default:
@@ -465,7 +419,7 @@ lookupNextAction:
_gfx->warpMouse(pos.x + p.x, pos.y + p.y);
}
- goto mousePosChanged;
+ action = mouseMoveEvent();
}
default:
@@ -498,6 +452,13 @@ lookupNextAction:
return action;
}
+int StarTrekEngine::lookupNextAction(const int *lookupArray, int action) {
+ // Use a lookup table to decide which action is next after a direction
+ // button is pressed.
+ assert((action >= ACTION_WALK && action <= ACTION_TALK) || action == ACTION_OPTIONS);
+ return lookupArray[action == ACTION_OPTIONS ? 5 : action - 1];
+}
+
void StarTrekEngine::loadMenuButtons(String mnuFilename, int xpos, int ypos) {
if (_activeMenu == nullptr)
_keyboardControlsMouseOutsideMenu = _keyboardControlsMouse;
@@ -602,6 +563,73 @@ void StarTrekEngine::enableMenuButtons(uint32 bits) {
_activeMenu->disabledButtons &= ~bits;
}
+int StarTrekEngine::leftClickEvent() {
+ if (_activeMenu->selectedButton != -1) {
+ _sound->playSoundEffectIndex(SND_SELECTION);
+ return _activeMenu->retvals[_activeMenu->selectedButton];
+ } else {
+ Common::Point mouse = _gfx->getMousePos();
+ if (getMenuButtonAt(_activeMenu->sprites, _activeMenu->numButtons, mouse.x, mouse.y) == -1) {
+ _sound->playSoundEffectIndex(SND_SELECTION);
+ return MENUEVENT_LCLICK_OFFBUTTON;
+ }
+ }
+}
+
+int StarTrekEngine::rightClickEvent() {
+ _sound->playSoundEffectIndex(SND_SELECTION);
+ if (_activeMenu->selectedButton == -1)
+ return MENUEVENT_RCLICK_OFFBUTTON;
+ else
+ return MENUEVENT_RCLICK_ONBUTTON;
+}
+
+int StarTrekEngine::mouseMoveEvent() {
+ const Common::Point pos(50, 50); // Top-left position to put action menu at
+ int action = ACTION_WALK;
+
+ Common::Point mouse = _gfx->getMousePos();
+ Common::Point relMouse(mouse.x - pos.x, mouse.y - pos.y);
+
+ Common::String bitmapName;
+ Common::Point lockMousePoint(-1, -1);
+
+ // Check if the mouse is hovering over one of the selectable actions
+ if (relMouse.x >= 39 && relMouse.x <= 50 && relMouse.y >= 2 && relMouse.y <= 17) {
+ action = ACTION_OPTIONS;
+ bitmapName = "options";
+ lockMousePoint = Common::Point(pos.x + 44, pos.y + 2);
+ } else if (relMouse.x >= 18 && relMouse.x <= 38 && relMouse.y >= 2 && relMouse.y <= 9) {
+ action = ACTION_LOOK;
+ bitmapName = "look";
+ lockMousePoint = Common::Point(pos.x + 28, pos.y + 6);
+ } else if (relMouse.x >= 18 && relMouse.x <= 38 && relMouse.y >= 11 && relMouse.y <= 17) {
+ action = ACTION_TALK;
+ bitmapName = "talk";
+ lockMousePoint = Common::Point(pos.x + 27, pos.y + 14);
+ } else if (relMouse.x >= 2 && relMouse.x <= 13 && relMouse.y >= 16 && relMouse.y <= 26) {
+ action = ACTION_USE;
+ bitmapName = "use";
+ lockMousePoint = Common::Point(pos.x + 7, pos.y + 19);
+ } else if (relMouse.x >= 40 && relMouse.x <= 53 && relMouse.y >= 34 && relMouse.y <= 43) {
+ action = ACTION_GET;
+ bitmapName = "get";
+ lockMousePoint = Common::Point(pos.x + 44, pos.y + 38);
+ } else {
+ action = ACTION_WALK;
+ bitmapName = "walk";
+ }
+
+ _gfx->setMouseBitmap(bitmapName);
+
+ if (lockMousePoint.x != -1)
+ _gfx->lockMousePosition(lockMousePoint.x, lockMousePoint.y);
+ else
+ _gfx->unlockMousePosition();
+
+ return action;
+}
+
int StarTrekEngine::handleMenuEvents(uint32 ticksUntilClickingEnabled, bool inTextbox) {
uint32 tickWhenClickingEnabled = _clockTicks + ticksUntilClickingEnabled;
@@ -656,34 +684,17 @@ int StarTrekEngine::handleMenuEvents(uint32 ticksUntilClickingEnabled, bool inTe
}
case TREKEVENT_LBUTTONDOWN:
-lclick:
- if (_activeMenu->selectedButton != -1) {
- _sound->playSoundEffectIndex(SND_SELECTION);
- return _activeMenu->retvals[_activeMenu->selectedButton];
- } else {
- Common::Point mouse = _gfx->getMousePos();
- if (getMenuButtonAt(_activeMenu->sprites, _activeMenu->numButtons, mouse.x, mouse.y) == -1) {
- _sound->playSoundEffectIndex(SND_SELECTION);
- return MENUEVENT_LCLICK_OFFBUTTON;
- }
- }
- break;
+ return leftClickEvent();
case TREKEVENT_RBUTTONDOWN:
-rclick:
- _sound->playSoundEffectIndex(SND_SELECTION);
- if (_activeMenu->selectedButton == -1)
- return MENUEVENT_RCLICK_OFFBUTTON;
- else
- return MENUEVENT_RCLICK_ONBUTTON;
- break;
+ return rightClickEvent();
case TREKEVENT_KEYDOWN:
if (inTextbox) {
switch (event.kbd.keycode) {
case Common::KEYCODE_ESCAPE:
case Common::KEYCODE_F2:
- goto rclick;
+ return rightClickEvent();
case Common::KEYCODE_RETURN:
case Common::KEYCODE_KP_ENTER:
@@ -778,12 +789,12 @@ rclick:
switch (event.kbd.keycode) {
case Common::KEYCODE_ESCAPE:
case Common::KEYCODE_F2:
- goto rclick;
+ return rightClickEvent();
case Common::KEYCODE_RETURN:
case Common::KEYCODE_KP_ENTER:
case Common::KEYCODE_F1:
- goto lclick;
+ return leftClickEvent();
case Common::KEYCODE_HOME:
case Common::KEYCODE_KP7:
@@ -1113,8 +1124,7 @@ void StarTrekEngine::showRepublicMap(int16 arg0, int16 turbolift) {
_gfx->drawAllSprites();
break;
- case TREKEVENT_LBUTTONDOWN: {
-lclick:
+ case TREKEVENT_LBUTTONDOWN:
clickedArea = getRepublicMapAreaOrFailure(turbolift);
if (clickedArea == 0) {
} else if (clickedArea == 6) {
@@ -1126,7 +1136,6 @@ lclick:
} else
exitLoop = true;
break;
- }
case TREKEVENT_MOUSEMOVE: {
if (_gfx->getMousePos().y < 96) // TODO: more elegant solution
@@ -1158,7 +1167,18 @@ lclick:
case Common::KEYCODE_RETURN:
case Common::KEYCODE_KP_ENTER:
case Common::KEYCODE_F1:
- goto lclick;
+ // Same as TREKEVENT_LBUTTONDOWN
+ clickedArea = getRepublicMapAreaOrFailure(turbolift);
+ if (clickedArea == 0) {
+ } else if (clickedArea == 6) {
+ Common::String text = "#GENE\\GENE_F14#Turbolift access is blocked by an extremely high radiation level.";
+ showTextbox("Mr. Spock", text, 50, 50, TEXTCOLOR_YELLOW, 0); // ENHANCEMENT: Speaker is Spock
+ } else if (clickedArea == 7) {
+ Common::String text = "#GENE\\GENE_F15#This turbolift cannot reach that area of the ship.";
+ showTextbox("Mr. Spock", text, 50, 50, TEXTCOLOR_YELLOW, 0); // ENHANCEMENT: Speaker is Spock
+ } else
+ exitLoop = true;
+ break;
default:
break;
diff --git a/engines/startrek/resource.cpp b/engines/startrek/resource.cpp
index 74d17a2fb8..318793a08d 100644
--- a/engines/startrek/resource.cpp
+++ b/engines/startrek/resource.cpp
@@ -242,8 +242,8 @@ Common::MemoryReadStreamEndian *Resource::loadFile(Common::String filename, int
if (_isDemo && _platform == Common::kPlatformDOS) {
stream = dataFile->readStream(index.uncompressedSize);
} else {
- uint16 uncompressedSize = (_platform == Common::kPlatformAmiga) ? dataFile->readUint16BE() : dataFile->readUint16LE();
- uint16 compressedSize = (_platform == Common::kPlatformAmiga) ? dataFile->readUint16BE() : dataFile->readUint16LE();
+ uint16 uncompressedSize = bigEndian ? dataFile->readUint16BE() : dataFile->readUint16LE();
+ uint16 compressedSize = bigEndian ? dataFile->readUint16BE() : dataFile->readUint16LE();
stream = decodeLZSS(dataFile->readStream(compressedSize), uncompressedSize);
}
diff --git a/engines/startrek/startrek.h b/engines/startrek/startrek.h
index 8441fd168a..879038baaa 100644
--- a/engines/startrek/startrek.h
+++ b/engines/startrek/startrek.h
@@ -731,6 +731,11 @@ public:
Resource *_resource;
private:
+ int leftClickEvent();
+ int rightClickEvent();
+ int mouseMoveEvent();
+ int lookupNextAction(const int *lookupArray, int action);
+
Common::RandomSource _randomSource;
Common::SineTable _sineTable;
Common::CosineTable _cosineTable;
Commit: 61bf089cb6cfcf7363d860e10acbd596459b2bc7
https://github.com/scummvm/scummvm/commit/61bf089cb6cfcf7363d860e10acbd596459b2bc7
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2020-11-17T23:55:58+02:00
Commit Message:
STARTREK: Remove the remaining goto's
Changed paths:
engines/startrek/actors.cpp
engines/startrek/room.h
engines/startrek/rooms/demon4.cpp
engines/startrek/rooms/love1.cpp
engines/startrek/rooms/love2.cpp
engines/startrek/rooms/veng2.cpp
engines/startrek/textbox.cpp
diff --git a/engines/startrek/actors.cpp b/engines/startrek/actors.cpp
index 199532a258..1ef78d1e26 100644
--- a/engines/startrek/actors.cpp
+++ b/engines/startrek/actors.cpp
@@ -1215,12 +1215,10 @@ int StarTrekEngine::showInventoryMenu(int x, int y, bool restoreMouse) {
}
case TREKEVENT_LBUTTONDOWN:
-exitWithSelection:
displayMenu = false;
break;
case TREKEVENT_RBUTTONDOWN:
-exitWithoutSelection:
displayMenu = false;
lastItemIndex = -1;
break;
@@ -1229,12 +1227,15 @@ exitWithoutSelection:
switch (event.kbd.keycode) {
case Common::KEYCODE_ESCAPE:
case Common::KEYCODE_F2:
- goto exitWithoutSelection;
+ displayMenu = false;
+ lastItemIndex = -1;
+ break;
case Common::KEYCODE_RETURN:
case Common::KEYCODE_KP_ENTER:
case Common::KEYCODE_F1:
- goto exitWithSelection;
+ displayMenu = false;
+ break;
case Common::KEYCODE_HOME:
case Common::KEYCODE_KP7:
diff --git a/engines/startrek/room.h b/engines/startrek/room.h
index 929638785d..233a059ae9 100644
--- a/engines/startrek/room.h
+++ b/engines/startrek/room.h
@@ -2608,6 +2608,7 @@ public:
void veng2UseImpulseConsole();
void veng2SpockReachedImpulseConsole();
void veng2SpockUsedImpulseConsole();
+ void veng2PowerWeapons();
void veng2UseMainComputer();
void veng2UseSTricorderOnMainComputer();
void veng2SpockReachedMainComputerToPutTricorder();
diff --git a/engines/startrek/rooms/demon4.cpp b/engines/startrek/rooms/demon4.cpp
index fa976229dd..fe19f4d598 100644
--- a/engines/startrek/rooms/demon4.cpp
+++ b/engines/startrek/rooms/demon4.cpp
@@ -475,11 +475,11 @@ bool Room::demon4ShowSunPuzzle() {
switch (event.type) {
case TREKEVENT_LBUTTONDOWN: {
- lclick:
Common::Point mousePos = _vm->_gfx->getMousePos();
- if (_vm->_gfx->getSpriteAt(mousePos) == &doneButtonSprite)
- goto done;
- else {
+ if (_vm->_gfx->getSpriteAt(mousePos) == &doneButtonSprite) {
+ solved = (abs(sliderY) <= 2 && abs(sliderR) <= 2 && abs(sliderB) <= 2);
+ continueLoop = false;
+ } else {
if (mousePos.y >= 0x64 && mousePos.y <= 0x86) {
if (mousePos.x >= 0xa0 && mousePos.x <= 0xa6)
sliderY = mousePos.y - 0x75;
@@ -494,11 +494,7 @@ bool Room::demon4ShowSunPuzzle() {
}
case TREKEVENT_RBUTTONDOWN:
- done:
- if (abs(sliderY) <= 2 && abs(sliderR) <= 2 && abs(sliderB) <= 2)
- solved = true;
- else
- solved = false;
+ solved = (abs(sliderY) <= 2 && abs(sliderR) <= 2 && abs(sliderB) <= 2);
continueLoop = false;
break;
@@ -506,12 +502,30 @@ bool Room::demon4ShowSunPuzzle() {
switch (event.kbd.keycode) {
case Common::KEYCODE_ESCAPE:
case Common::KEYCODE_F2:
- goto done;
+ solved = (abs(sliderY) <= 2 && abs(sliderR) <= 2 && abs(sliderB) <= 2);
+ continueLoop = false;
+ break;
case Common::KEYCODE_RETURN:
case Common::KEYCODE_KP_ENTER:
- case Common::KEYCODE_F1:
- goto lclick;
+ case Common::KEYCODE_F1: {
+ // Same as TREKEVENT_LBUTTONDOWN
+ Common::Point mousePos = _vm->_gfx->getMousePos();
+ if (_vm->_gfx->getSpriteAt(mousePos) == &doneButtonSprite) {
+ solved = (abs(sliderY) <= 2 && abs(sliderR) <= 2 && abs(sliderB) <= 2);
+ continueLoop = false;
+ } else {
+ if (mousePos.y >= 0x64 && mousePos.y <= 0x86) {
+ if (mousePos.x >= 0xa0 && mousePos.x <= 0xa6)
+ sliderY = mousePos.y - 0x75;
+ else if (mousePos.x >= 0xa8 && mousePos.x <= 0xae)
+ sliderR = mousePos.y - 0x75;
+ else if (mousePos.x >= 0xb0 && mousePos.x <= 0xb6)
+ sliderB = mousePos.y - 0x75;
+ sliderChanged = true;
+ }
+ }
+ }
default:
break;
diff --git a/engines/startrek/rooms/love1.cpp b/engines/startrek/rooms/love1.cpp
index f6828053f7..0a6c5cfeb0 100644
--- a/engines/startrek/rooms/love1.cpp
+++ b/engines/startrek/rooms/love1.cpp
@@ -61,23 +61,23 @@ void Room::love1Tick1() {
case BOTTLETYPE_N2O:
strcpy(_roomVar.love.bottleAnimation, "btle1");
_roomVar.love.itemInNozzle = OBJECT_IN2O;
- goto common;
+ loadActorAnim(OBJECT_BOTTLE, _roomVar.love.bottleAnimation, 0xa3, 0x72, 0);
+ break;
case BOTTLETYPE_NH3:
strcpy(_roomVar.love.bottleAnimation, "btle2");
_roomVar.love.itemInNozzle = OBJECT_INH3;
- goto common;
+ loadActorAnim(OBJECT_BOTTLE, _roomVar.love.bottleAnimation, 0xa3, 0x72, 0);
+ break;
case BOTTLETYPE_H2O:
strcpy(_roomVar.love.bottleAnimation, "btle3");
_roomVar.love.itemInNozzle = OBJECT_IH2O;
- goto common;
+ loadActorAnim(OBJECT_BOTTLE, _roomVar.love.bottleAnimation, 0xa3, 0x72, 0);
+ break;
case BOTTLETYPE_RLG:
strcpy(_roomVar.love.bottleAnimation, "btle4");
_roomVar.love.itemInNozzle = OBJECT_IRLG;
- goto common;
-
-common:
loadActorAnim(OBJECT_BOTTLE, _roomVar.love.bottleAnimation, 0xa3, 0x72, 0);
- // fall through
+ break;
case BOTTLETYPE_NONE:
default:
diff --git a/engines/startrek/rooms/love2.cpp b/engines/startrek/rooms/love2.cpp
index 369f4035de..913cf5b142 100644
--- a/engines/startrek/rooms/love2.cpp
+++ b/engines/startrek/rooms/love2.cpp
@@ -563,17 +563,23 @@ void Room::love2UseSynthesizer() {
showDescription(51, true);
showText(TX_SPEAKER_KIRK, 2, true);
loadActorStandAnim(OBJECT_VIRUSSAMPLE);
- goto closeSynthesizerDoor;
+ // Close synthesizer door
+ loadActorAnim(OBJECT_SYNTHESIZER_DOOR, "s3r3d5", 0x8a, 0x8d, 0);
+ playSoundEffectIndex(SND_DOOR1);
+ _awayMission->love.synthesizerContents = 0;
+ break;
case SYNTHITEM_CURE_SAMPLE: // Wet goo
-wetGooFailure:
showDescription(50, true);
showText(TX_SPEAKER_MCCOY, 21, true);
loadActorStandAnim(OBJECT_CURESAMPLE);
- goto closeSynthesizerDoor;
+ // Close synthesizer door
+ loadActorAnim(OBJECT_SYNTHESIZER_DOOR, "s3r3d5", 0x8a, 0x8d, 0);
+ playSoundEffectIndex(SND_DOOR1);
+ _awayMission->love.synthesizerContents = 0;
+ break;
case SYNTHITEM_BOTTLE: // Nothing happens
-bottleFailure:
showText(TX_SPEAKER_SPOCK, 28, true);
break;
@@ -581,32 +587,33 @@ bottleFailure:
default:
_awayMission->love.synthesizerBottleIndex = BOTTLETYPE_H2O;
strcpy(_roomVar.love.chamberOutputAnim, "btle3");
-produceBottle:
+ // Produce bottle
loadActorAnim(OBJECT_SYNTHESIZER_DOOR, "s3r3d2", 0x8a, 0x8d, 3); // -> love2SynthesizerDoorClosed
playSoundEffectIndex(SND_DOOR1);
break;
-
-closeSynthesizerDoor:
- loadActorAnim(OBJECT_SYNTHESIZER_DOOR, "s3r3d5", 0x8a, 0x8d, 0);
- playSoundEffectIndex(SND_DOOR1);
- _awayMission->love.synthesizerContents = 0;
- break;
}
} else if (c1 == CANTYPE_H2 && c2 == CANTYPE_N2) {
switch (_awayMission->love.synthesizerContents) {
case SYNTHITEM_PBC: // Inert matter
-inertMatterFailure:
showDescription(49, true);
showText(TX_SPEAKER_SPOCK, 39, true); // BUGFIX: original didn't play audio
loadActorStandAnim(OBJECT_POLYBERYLCARBONATE);
- goto closeSynthesizerDoor;
+ // Close synthesizer door
+ loadActorAnim(OBJECT_SYNTHESIZER_DOOR, "s3r3d5", 0x8a, 0x8d, 0);
+ playSoundEffectIndex(SND_DOOR1);
+ _awayMission->love.synthesizerContents = 0;
+ break;
case SYNTHITEM_VIRUS_SAMPLE: // Colorless goo (with useful information about virus in ammonia)
showDescription(48, true);
showText(TX_SPEAKER_SPOCK, 34, true); // BUGFIX: original didn't play audio
showText(TX_SPEAKER_MCCOY, 23, true);
loadActorStandAnim(OBJECT_VIRUSSAMPLE);
- goto closeSynthesizerDoor;
+ // Close synthesizer door
+ loadActorAnim(OBJECT_SYNTHESIZER_DOOR, "s3r3d5", 0x8a, 0x8d, 0);
+ playSoundEffectIndex(SND_DOOR1);
+ _awayMission->love.synthesizerContents = 0;
+ break;
case SYNTHITEM_CURE_SAMPLE: // Cure
loadActorStandAnim(OBJECT_CURESAMPLE);
@@ -615,36 +622,62 @@ inertMatterFailure:
break;
case SYNTHITEM_BOTTLE: // Nothing happens
- goto bottleFailure;
+ showText(TX_SPEAKER_SPOCK, 28, true);
+ break;
case SYNTHITEM_NONE: // Ammonia
default:
_awayMission->love.synthesizerBottleIndex = BOTTLETYPE_NH3;
strcpy(_roomVar.love.chamberOutputAnim, "btle2");
- goto produceBottle;
+ // Produce bottle
+ loadActorAnim(OBJECT_SYNTHESIZER_DOOR, "s3r3d2", 0x8a, 0x8d, 3); // -> love2SynthesizerDoorClosed
+ playSoundEffectIndex(SND_DOOR1);
+ break;
}
} else if (c1 == CANTYPE_O2 && c2 == CANTYPE_N2) {
switch (_awayMission->love.synthesizerContents) {
case SYNTHITEM_PBC: // Inert matter
- goto inertMatterFailure;
+ showDescription(49, true);
+ showText(TX_SPEAKER_SPOCK, 39, true); // BUGFIX: original didn't play audio
+ loadActorStandAnim(OBJECT_POLYBERYLCARBONATE);
+ // Close synthesizer door
+ loadActorAnim(OBJECT_SYNTHESIZER_DOOR, "s3r3d5", 0x8a, 0x8d, 0);
+ playSoundEffectIndex(SND_DOOR1);
+ _awayMission->love.synthesizerContents = 0;
+ break;
case SYNTHITEM_VIRUS_SAMPLE: // Wet goo
showDescription(47, true);
showText(TX_SPEAKER_MCCOY, 17, true);
loadActorStandAnim(OBJECT_VIRUSSAMPLE);
- goto closeSynthesizerDoor;
+ // Close synthesizer door
+ loadActorAnim(OBJECT_SYNTHESIZER_DOOR, "s3r3d5", 0x8a, 0x8d, 0);
+ playSoundEffectIndex(SND_DOOR1);
+ _awayMission->love.synthesizerContents = 0;
+ break;
case SYNTHITEM_CURE_SAMPLE: // Wet goo
- goto wetGooFailure;
+ showDescription(50, true);
+ showText(TX_SPEAKER_MCCOY, 21, true);
+ loadActorStandAnim(OBJECT_CURESAMPLE);
+ // Close synthesizer door
+ loadActorAnim(OBJECT_SYNTHESIZER_DOOR, "s3r3d5", 0x8a, 0x8d, 0);
+ playSoundEffectIndex(SND_DOOR1);
+ _awayMission->love.synthesizerContents = 0;
+ break;
case SYNTHITEM_BOTTLE: // Nothing happens
- goto bottleFailure;
+ showText(TX_SPEAKER_SPOCK, 28, true);
+ break;
case SYNTHITEM_NONE: // Laughing gas
default:
_awayMission->love.synthesizerBottleIndex = BOTTLETYPE_N2O;
strcpy(_roomVar.love.chamberOutputAnim, "btle1");
- goto produceBottle;
+ // Produce bottle
+ loadActorAnim(OBJECT_SYNTHESIZER_DOOR, "s3r3d2", 0x8a, 0x8d, 3); // -> love2SynthesizerDoorClosed
+ playSoundEffectIndex(SND_DOOR1);
+ break;
}
}
} else {
diff --git a/engines/startrek/rooms/veng2.cpp b/engines/startrek/rooms/veng2.cpp
index 72be99376b..a21cde2a8a 100644
--- a/engines/startrek/rooms/veng2.cpp
+++ b/engines/startrek/rooms/veng2.cpp
@@ -674,6 +674,24 @@ void Room::veng2SpockReachedImpulseConsole() {
loadActorAnimC(OBJECT_SPOCK, "susemn", -1, -1, &Room::veng2SpockUsedImpulseConsole);
}
+void Room::veng2PowerWeapons() {
+ if (_awayMission->veng.poweredSystem == 2) {
+ playVoc("LD6BMOFF");
+ loadActorAnim2(OBJECT_DAMAGE_DISPLAY_1, "s7r2sh3", DAMAGE_DISPLAY_1_X, DAMAGE_DISPLAY_1_Y);
+ }
+ _awayMission->veng.poweredSystem = 1;
+ showText(TX_SPEAKER_KIJE, 88, true);
+ if (_awayMission->veng.toldElasiToBeamOver) {
+ showText(TX_SPEAKER_SPOCK, 52, true);
+ _awayMission->veng.elasiShieldsDown = true;
+ _awayMission->veng.counterUntilElasiBoardWithInvitation = 900;
+ }
+ if (_awayMission->veng.elasiShipDecloaked && !_awayMission->veng.elasiHailedRepublic) {
+ showText(TX_SPEAKER_SPOCK, 33, true);
+ _awayMission->veng.counterUntilElasiBoardWithShieldsDown = 1800;
+ }
+}
+
void Room::veng2SpockUsedImpulseConsole() {
_awayMission->disableInput = false;
showText(TX_SPEAKER_SPOCK, 69, true);
@@ -687,29 +705,14 @@ void Room::veng2SpockUsedImpulseConsole() {
int choice = showMultipleTexts(choices);
if (choice == 0) { // Weapons
- if (_awayMission->veng.toldElasiToBeamOver) {
-powerWeapons:
- if (_awayMission->veng.poweredSystem == 2) {
- playVoc("LD6BMOFF");
- loadActorAnim2(OBJECT_DAMAGE_DISPLAY_1, "s7r2sh3", DAMAGE_DISPLAY_1_X, DAMAGE_DISPLAY_1_Y);
- }
- _awayMission->veng.poweredSystem = 1;
- showText(TX_SPEAKER_KIJE, 88, true);
- if (_awayMission->veng.toldElasiToBeamOver) {
- showText(TX_SPEAKER_SPOCK, 52, true);
- _awayMission->veng.elasiShieldsDown = true;
- _awayMission->veng.counterUntilElasiBoardWithInvitation = 900;
- }
- if (_awayMission->veng.elasiShipDecloaked && !_awayMission->veng.elasiHailedRepublic) {
- showText(TX_SPEAKER_SPOCK, 33, true);
- _awayMission->veng.counterUntilElasiBoardWithShieldsDown = 1800;
- }
- } else if (_awayMission->veng.countdownStarted)
+ if (_awayMission->veng.toldElasiToBeamOver)
+ veng2PowerWeapons();
+ else if (_awayMission->veng.countdownStarted)
showText(TX_SPEAKER_SPOCK, 35, true);
else if (_awayMission->veng.poweredSystem == 1) // Weapons already powered
showText(TX_SPEAKER_KIJE, 91, true);
else
- goto powerWeapons;
+ veng2PowerWeapons();
} else if (choice == 1) { // Shields
if (_awayMission->veng.poweredSystem == 2) // Shields already powered
showText(TX_SPEAKER_KIJE, 89, true);
diff --git a/engines/startrek/textbox.cpp b/engines/startrek/textbox.cpp
index 474af78cb6..79a6c108e2 100644
--- a/engines/startrek/textbox.cpp
+++ b/engines/startrek/textbox.cpp
@@ -363,13 +363,27 @@ int StarTrekEngine::showText(TextGetterFunc textGetter, uintptr var, int xoffset
if (scrollOffset == 0)
disableMenuButtons(1 << TEXTBUTTON_SCROLLUP);
enableMenuButtons(1 << TEXTBUTTON_SCROLLDOWN);
- goto readjustScroll;
+ textboxSprite.bitmapChanged = true;
+ drawMainText(
+ textBitmap,
+ numTextLines - scrollOffset,
+ numTextboxLines,
+ lineFormattedText.c_str() + scrollOffset * (TEXTBOX_WIDTH - 2),
+ numChoicesWithNames != 0);
+ break;
case TEXTBUTTON_GOTO_TOP:
scrollOffset = 0;
disableMenuButtons(1 << TEXTBUTTON_SCROLLUP);
enableMenuButtons(1 << TEXTBUTTON_SCROLLDOWN);
- goto readjustScroll;
+ textboxSprite.bitmapChanged = true;
+ drawMainText(
+ textBitmap,
+ numTextLines - scrollOffset,
+ numTextboxLines,
+ lineFormattedText.c_str() + scrollOffset * (TEXTBOX_WIDTH - 2),
+ numChoicesWithNames != 0);
+ break;
case TEXTBUTTON_SCROLLDOWN:
case TEXTBUTTON_SCROLLDOWN_ONELINE:
@@ -381,15 +395,19 @@ int StarTrekEngine::showText(TextGetterFunc textGetter, uintptr var, int xoffset
scrollOffset = numTextLines - 1;
if (scrollOffset + numTextboxLines >= numTextLines)
disableMenuButtons(1 << TEXTBUTTON_SCROLLDOWN);
- goto readjustScroll;
+ textboxSprite.bitmapChanged = true;
+ drawMainText(
+ textBitmap,
+ numTextLines - scrollOffset,
+ numTextboxLines,
+ lineFormattedText.c_str() + scrollOffset * (TEXTBOX_WIDTH - 2),
+ numChoicesWithNames != 0);
+ break;
case TEXTBUTTON_GOTO_BOTTOM:
scrollOffset = numTextLines - numTextboxLines;
enableMenuButtons(1 << TEXTBUTTON_SCROLLUP);
disableMenuButtons(1 << TEXTBUTTON_SCROLLDOWN);
- goto readjustScroll;
-
-readjustScroll:
textboxSprite.bitmapChanged = true;
drawMainText(
textBitmap,
More information about the Scummvm-git-logs
mailing list