Skip to content

Commit

Permalink
STARTREK: Load all kinds of messages, and remove redundant variables
Browse files Browse the repository at this point in the history
  • Loading branch information
bluegr committed Aug 17, 2019
1 parent 1641bd3 commit d74060e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 70 deletions.
71 changes: 14 additions & 57 deletions engines/startrek/room.cpp
Expand Up @@ -52,9 +52,6 @@ Room::Room(StarTrekEngine *vm, const Common::String &name) : _vm(vm), _awayMissi
rdfFile->read(_rdfData, size);
delete rdfFile;

_rdfName = name;
_roomIndex = name.lastChar() - '0';

_roomActionList = nullptr;

ADD_ROOM_OLD(demon0);
Expand Down Expand Up @@ -133,7 +130,7 @@ void Room::loadRoomMessages() {
const char *text = (const char *)_rdfData + messagesOffset;

do {
while (*text != '#')
while (text[0] != '#' || text[1] != _vm->_missionName[0])
text++;

if (text[5] == '\\')
Expand Down Expand Up @@ -174,62 +171,22 @@ void Room::loadRoomMessage(const char *text) {

}

// HACK: We hardcode the other room messages here. Remove once we figure
// how these are indexed
void Room::loadOtherRoomMessages() {
int *offsets = nullptr;

if (_rdfName == "DEMON0") {
int o[] = { 0x1d9, 0x422, 0x48f, 0x4d1, 0x536, 0x578, -1 };
offsets = o;
} else if (_rdfName == "DEMON1") {
int o[] = {
0x5d4, 0x716, 0x791, 0x7ec, 0x99e, 0xa06, 0xa51, 0xa96, 0xacc, 0xb5a,
0xb87, 0xc46, 0xcd5, 0xd82, 0xe55, 0x107e, 0x1186, 0x11d1, 0x1216, 0x1271,
0x12a4, 0x12f3, 0x1335, 0x1371, 0x13b4, 0x1419, 0x1467, 0x14b2, 0x14fd, -1
};
offsets = o;
} else if (_rdfName == "DEMON2") {
int o[] = {
0x165, 0x195, 0x1c6, 0x1f7, 0x24a, 0x27d, 0x2c6, 0x311, 0x41a, 0x489,
0x538, 0x5ba, 0x64d, 0x74d, 0x7ab, 0x817, 0x8a4, 0x950, 0x9e1, -1
};
offsets = o;
} else if (_rdfName == "DEMON3") {
int o[] = {
0x662, 0x6d3, 0x7a5, 0xa19, 0xa9a, 0xbd7, 0xc30, 0xcfe, 0xe13, 0xed2,
0x104e, 0x118e, 0x1248, 0x12a4, 0x12f4, 0x1383, 0x13d5, 0x1443, 0x14b1,
0x1522, 0x15ab, 0x15f5, 0x1648, 0x16ad, -1
};
offsets = o;
} else if (_rdfName == "DEMON4") {
int o[] = {
0x254, 0x2f3, 0x392, 0x41f, 0x642, 0x7b3, 0xa6a, 0xb34, 0xba4, 0xc7b,
-1
};
offsets = o;
} else if (_rdfName == "DEMON5") {
int o[] = {
0x27c, 0x2e7, 0x387, 0x438, 0x483, 0x4de, 0x58f, 0x5e2, 0x61f, 0x713,
0x783, 0x812, 0x8af, 0x904, 0x95e, 0x9b8, 0xb7e, 0xccc, -1
};
offsets = o;
} else if (_rdfName == "DEMON6") {
int o[] = {
0x265, 0x2cb, 0x40c, 0x473, 0x52a, 0x5cd, 0x697, 0x6e5, 0x787, 0x97b,
0x9f5, 0xa5f, 0xb7e, 0xbf1, 0xca7, 0xe54, 0xee4,
-1
};
offsets = o;
}
uint16 startOffset = readRdfWord(14);
uint16 endOffset = readRdfWord(16);
uint16 offset = startOffset;

if (offsets == nullptr)
return;
while (offset < endOffset) {
uint16 nextOffset = readRdfWord(offset + 4);
if (nextOffset >= endOffset)
break;

while (offset < nextOffset) {
if (*(_rdfData + offset) == 0xeb && *(_rdfData + offset + 2) == '#')
loadRoomMessage((const char *)_rdfData + offset + 2);

int i = 0;
while (offsets[i] != -1) {
loadRoomMessage((const char *)_rdfData + offsets[i]);
i++;
offset++;
}
}
}

Expand Down
2 changes: 0 additions & 2 deletions engines/startrek/room.h
Expand Up @@ -153,8 +153,6 @@ class Room {
const RoomAction *_roomActionList;
int _numRoomActions;

Common::String _rdfName;
int _roomIndex; // ie. for DEMON2, this is 2
Common::HashMap<int, Common::String> _lookMessages;
Common::HashMap<int, Common::String> _lookWithTalkerMessages;
Common::HashMap<int, Common::String> _talkMessages;
Expand Down
23 changes: 12 additions & 11 deletions engines/startrek/rooms/mudda.cpp
Expand Up @@ -20,6 +20,7 @@
*
*/

#include "startrek/startrek.h"
#include "startrek/room.h"

namespace StarTrek {
Expand All @@ -28,7 +29,7 @@ namespace StarTrek {
// mission, despite being mostly the same.

void Room::muddaUseLenseOnDegrimer() {
assert(_roomIndex >= 0 && _roomIndex <= 5);
assert(_vm->_roomIndex >= 0 && _vm->_roomIndex <= 5);

const TextRef text[] = {
TX_MUD0N011, // All of these audio files are identical, but there's one for each room.
Expand All @@ -44,12 +45,12 @@ void Room::muddaUseLenseOnDegrimer() {
loseItem(OBJECT_ILENSES);

_awayMission->mudd.missionScore++;
showDescription(text[_roomIndex]);
showDescription(text[_vm->_roomIndex]);
}


void Room::muddaUseAlienDevice() {
assert(_roomIndex >= 0 && _roomIndex <= 5);
assert(_vm->_roomIndex >= 0 && _vm->_roomIndex <= 5);

const int deviceObjectIndices[] = { // Each room's object index for the explosion is different
9, // MUDD0
Expand All @@ -65,12 +66,12 @@ void Room::muddaUseAlienDevice() {
_awayMission->crewDirectionsAfterWalk[OBJECT_KIRK] = DIR_S;
loadActorStandAnim(OBJECT_KIRK);
Common::Point pos = getActorPos(OBJECT_KIRK);
loadActorAnimC(deviceObjectIndices[_roomIndex], "s4cbxp", pos.x, 10, &Room::muddaFiredAlienDevice);
loadActorAnimC(deviceObjectIndices[_vm->_roomIndex], "s4cbxp", pos.x, 10, &Room::muddaFiredAlienDevice);
playVoc("EXPLO3");
}

void Room::muddaFiredAlienDevice() {
assert(_roomIndex >= 0 && _roomIndex <= 5);
assert(_vm->_roomIndex >= 0 && _vm->_roomIndex <= 5);

const TextRef text[] = {
TX_MUD0_002, // These audio files aren't identical, but the text is mostly the same.
Expand All @@ -85,13 +86,13 @@ void Room::muddaFiredAlienDevice() {
if (!_awayMission->mudd.discoveredLenseAndDegrimerFunction) {
_awayMission->mudd.discoveredLenseAndDegrimerFunction = true;
_awayMission->mudd.missionScore += 5; // BUGFIX: didn't happen if done in MUDD5
showText(TX_SPEAKER_KIRK, text[_roomIndex]);
showText(TX_SPEAKER_KIRK, text[_vm->_roomIndex]);
}
}


void Room::muddaUseDegrimer() {
assert(_roomIndex >= 0 && _roomIndex <= 5);
assert(_vm->_roomIndex >= 0 && _vm->_roomIndex <= 5);

const TextRef text[] = {
TX_MUD0N002, // All of these audio files are identical, but there's one for each room.
Expand All @@ -102,7 +103,7 @@ void Room::muddaUseDegrimer() {
TX_MUD5N001,
};

showDescription(text[_roomIndex]);
showDescription(text[_vm->_roomIndex]);
}

void Room::muddaTick() {
Expand All @@ -114,7 +115,7 @@ void Room::muddaTick() {
// To simplify things, and since it makes more sense, now they'll just collapse on the
// spot instead.

assert(_roomIndex >= 0 && _roomIndex <= 5);
assert(_vm->_roomIndex >= 0 && _vm->_roomIndex <= 5);

/*
// Unused: The positions to they originally walked to before collapsing.
Expand Down Expand Up @@ -172,10 +173,10 @@ void Room::muddaTick() {

for (int i = OBJECT_KIRK; i <= OBJECT_REDSHIRT; i++) {
Common::String anim = getCrewmanAnimFilename(i, "getd");
anim += directions[i][_roomIndex];
anim += directions[i][_vm->_roomIndex];
loadActorAnim2(i, anim);
}
showDescription(deathText[_roomIndex]);
showDescription(deathText[_vm->_roomIndex]);
showGameOverMenu();
}
}
Expand Down

0 comments on commit d74060e

Please sign in to comment.