From 5fae11b871850ffce45499b5b2fa37dbbdb40706 Mon Sep 17 00:00:00 2001 From: Matthew Stewart Date: Wed, 8 Aug 2018 00:42:25 -0400 Subject: STARTREK: Move VENG function into common code --- engines/startrek/module.mk | 3 ++- engines/startrek/room.h | 7 +++--- engines/startrek/rooms/veng1.cpp | 34 +++---------------------- engines/startrek/rooms/veng3.cpp | 34 +++---------------------- engines/startrek/rooms/veng5.cpp | 5 ++++ engines/startrek/rooms/venga.cpp | 54 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 73 insertions(+), 64 deletions(-) create mode 100644 engines/startrek/rooms/venga.cpp diff --git a/engines/startrek/module.mk b/engines/startrek/module.mk index 99d77911f3..0f82c852fc 100644 --- a/engines/startrek/module.mk +++ b/engines/startrek/module.mk @@ -76,7 +76,8 @@ MODULE_OBJS = \ rooms/veng5.o \ rooms/veng6.o \ rooms/veng7.o \ - rooms/veng8.o + rooms/veng8.o \ + rooms/venga.o diff --git a/engines/startrek/room.h b/engines/startrek/room.h index b67bd675fe..4f0a1723aa 100644 --- a/engines/startrek/room.h +++ b/engines/startrek/room.h @@ -2523,7 +2523,6 @@ public: void veng1GetDebris(); void veng1ReachedDebrisToGet(); void veng1TriedToGetDebris(); - void veng1UseMccoyOnDeadGuy(); // TODO: common code // VENG2 @@ -2637,7 +2636,6 @@ public: void veng3GetCable(); void veng3ReachedCable(); void veng3PickedUpCable(); - void veng3UseMccoyOnDeadGuy(); // TODO: Common code // VENG4 @@ -2714,7 +2712,7 @@ public: void veng5GetPowerPack(); void veng5ReachedPowerPack(); void veng5PickedUpPowerPack(); - // TODO: common code (and scanning the dead guy) + // TODO: common code // VENG6 void veng6Tick1(); @@ -2725,6 +2723,9 @@ public: // VENG8 void veng8Tick1(); + // VENGA (common code) + void vengaUseMccoyOnDeadGuy(); + public: // Room-specific variables. This is memset'ed to 0 when the room is initialized. // NOTE: Any changes here must be reflected in the corresponding serializer functions. diff --git a/engines/startrek/rooms/veng1.cpp b/engines/startrek/rooms/veng1.cpp index dc39eb588b..e6834580de 100644 --- a/engines/startrek/rooms/veng1.cpp +++ b/engines/startrek/rooms/veng1.cpp @@ -116,9 +116,10 @@ extern const RoomAction veng1ActionList[] = { { {ACTION_DONE_WALK, 11, 0, 0}, &Room::veng1ReachedDebrisToGet }, { {ACTION_DONE_ANIM, 12, 0, 0}, &Room::veng1TriedToGetDebris }, - { {ACTION_USE, OBJECT_IMEDKIT, OBJECT_DEAD_GUY, 0}, &Room::veng1UseMccoyOnDeadGuy }, - { {ACTION_USE, OBJECT_IMTRICOR, OBJECT_DEAD_GUY, 0}, &Room::veng1UseMccoyOnDeadGuy }, - { {ACTION_USE, OBJECT_MCCOY, OBJECT_DEAD_GUY, 0}, &Room::veng1UseMccoyOnDeadGuy }, + // Common code + { {ACTION_USE, OBJECT_IMEDKIT, OBJECT_DEAD_GUY, 0}, &Room::vengaUseMccoyOnDeadGuy }, + { {ACTION_USE, OBJECT_IMTRICOR, OBJECT_DEAD_GUY, 0}, &Room::vengaUseMccoyOnDeadGuy }, + { {ACTION_USE, OBJECT_MCCOY, OBJECT_DEAD_GUY, 0}, &Room::vengaUseMccoyOnDeadGuy }, }; extern const int veng1NumActions = ARRAYSIZE(veng1ActionList); @@ -390,31 +391,4 @@ void Room::veng1TriedToGetDebris() { } } -void Room::veng1UseMccoyOnDeadGuy() { // NOTE: Identical to function in VENG3 - int val = getRandomWordInRange(0, 5); - - switch (val) { - case 0: - // NOTE: The exact text differs from the text used in DEM3. But, in order for this - // text indexing scheme to work, two rooms can't use the same audio with different - // text. Original was "He's dead, jim." instead of "He's dead, Jim...". - showText(TX_SPEAKER_MCCOY, TX_DEM3_019); - break; - - case 1: - showText(TX_SPEAKER_MCCOY, TX_VEN4_016); - break; - - case 2: - case 3: - showText(TX_SPEAKER_MCCOY, TX_G_014); - break; - - case 4: - case 5: - showText(TX_SPEAKER_MCCOY, TX_VEN0_016); - break; - } -} - } diff --git a/engines/startrek/rooms/veng3.cpp b/engines/startrek/rooms/veng3.cpp index 649288be66..969a8a1037 100644 --- a/engines/startrek/rooms/veng3.cpp +++ b/engines/startrek/rooms/veng3.cpp @@ -91,9 +91,10 @@ extern const RoomAction veng3ActionList[] = { { {ACTION_DONE_WALK, 11, 0, 0}, &Room::veng3ReachedCable }, { {ACTION_DONE_ANIM, 12, 0, 0}, &Room::veng3PickedUpCable }, - { {ACTION_USE, OBJECT_IMEDKIT, OBJECT_DEAD_GUY, 0}, &Room::veng3UseMccoyOnDeadGuy }, - { {ACTION_USE, OBJECT_IMTRICOR, OBJECT_DEAD_GUY, 0}, &Room::veng3UseMccoyOnDeadGuy }, - { {ACTION_USE, OBJECT_MCCOY, OBJECT_DEAD_GUY, 0}, &Room::veng3UseMccoyOnDeadGuy }, + // Common code + { {ACTION_USE, OBJECT_IMEDKIT, OBJECT_DEAD_GUY, 0}, &Room::vengaUseMccoyOnDeadGuy }, + { {ACTION_USE, OBJECT_IMTRICOR, OBJECT_DEAD_GUY, 0}, &Room::vengaUseMccoyOnDeadGuy }, + { {ACTION_USE, OBJECT_MCCOY, OBJECT_DEAD_GUY, 0}, &Room::vengaUseMccoyOnDeadGuy }, }; extern const int veng3NumActions = ARRAYSIZE(veng3ActionList); @@ -353,31 +354,4 @@ void Room::veng3PickedUpCable() { _awayMission->veng.tookCableFromSickbayHallway = true; } -void Room::veng3UseMccoyOnDeadGuy() { // NOTE: Identical to function in VENG1 - int val = getRandomWordInRange(0, 5); - - switch (val) { - case 0: - // NOTE: The exact text differs from the text used in DEM3. But, in order for this - // text indexing scheme to work, two rooms can't use the same audio with different - // text. Original was "He's dead, jim." instead of "He's dead, Jim...". - showText(TX_SPEAKER_MCCOY, TX_DEM3_019); - break; - - case 1: - showText(TX_SPEAKER_MCCOY, TX_VEN4_016); - break; - - case 2: - case 3: - showText(TX_SPEAKER_MCCOY, TX_G_014); - break; - - case 4: - case 5: - showText(TX_SPEAKER_MCCOY, TX_VEN0_016); - break; - } -} - } diff --git a/engines/startrek/rooms/veng5.cpp b/engines/startrek/rooms/veng5.cpp index c89795f914..52bf7ea940 100644 --- a/engines/startrek/rooms/veng5.cpp +++ b/engines/startrek/rooms/veng5.cpp @@ -76,6 +76,11 @@ extern const RoomAction veng5ActionList[] = { { {ACTION_GET, OBJECT_POWER_PACK, 0, 0}, &Room::veng5GetPowerPack }, { {ACTION_DONE_WALK, 6, 0, 0}, &Room::veng5ReachedPowerPack }, { {ACTION_DONE_ANIM, 7, 0, 0}, &Room::veng5PickedUpPowerPack }, + + // Common code + { {ACTION_USE, OBJECT_IMEDKIT, OBJECT_DEAD_GUY, 0}, &Room::vengaUseMccoyOnDeadGuy }, + { {ACTION_USE, OBJECT_IMTRICOR, OBJECT_DEAD_GUY, 0}, &Room::vengaUseMccoyOnDeadGuy }, + { {ACTION_USE, OBJECT_MCCOY, OBJECT_DEAD_GUY, 0}, &Room::vengaUseMccoyOnDeadGuy }, }; extern const int veng5NumActions = ARRAYSIZE(veng5ActionList); diff --git a/engines/startrek/rooms/venga.cpp b/engines/startrek/rooms/venga.cpp new file mode 100644 index 0000000000..0110331796 --- /dev/null +++ b/engines/startrek/rooms/venga.cpp @@ -0,0 +1,54 @@ +/* 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 "startrek/room.h" + +namespace StarTrek { + +void Room::vengaUseMccoyOnDeadGuy() { + int val = getRandomWordInRange(0, 5); + + switch (val) { + case 0: + // NOTE: The exact text differs from the text used in DEM3. But, in order for this + // text indexing scheme to work, two rooms can't use the same audio with different + // text. Original was "He's dead, jim." instead of "He's dead, Jim...". + showText(TX_SPEAKER_MCCOY, TX_DEM3_019); + break; + + case 1: + showText(TX_SPEAKER_MCCOY, TX_VEN4_016); + break; + + case 2: + case 3: + showText(TX_SPEAKER_MCCOY, TX_G_014); + break; + + case 4: + case 5: + showText(TX_SPEAKER_MCCOY, TX_VEN0_016); + break; + } +} + +} -- cgit v1.2.3