Skip to content

Commit

Permalink
STARTREK: Refactor text using integer constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Stewmath authored and sev- committed Aug 9, 2018
1 parent 29e62d1 commit 30c41ae
Show file tree
Hide file tree
Showing 7 changed files with 774 additions and 1,214 deletions.
28 changes: 26 additions & 2 deletions engines/startrek/room.cpp
Expand Up @@ -160,8 +160,6 @@ void Room::loadActorAnim2(int actorIndex, Common::String anim, int16 x, int16 y,
loadActorAnim(actorIndex, anim, x, y, finishedAnimActionParam);
}

// TODO: replace "rdfOffset" with a pointer, so we no longer read from RDF files? (This
// may be necessary to support other platforms; can't leave offsets hardcoded.)
int Room::showRoomSpecificText(const char **array) {
Common::String speaker;
byte textColor;
Expand Down Expand Up @@ -191,6 +189,32 @@ int Room::showRoomSpecificText(const char **array) {
return _vm->showText(&StarTrekEngine::readTextFromArray, (uintptr)array, 20, 20, textColor, true, false, false);
}

int Room::showText(const int *textIDs) {
int numIDs = 0;
while (textIDs[numIDs] != TX_BLANK)
numIDs++;

const char **text = (const char **)malloc(sizeof(const char *) * (numIDs + 1));
for (int i = 0; i <= numIDs; i++)
text[i] = g_gameStrings[textIDs[i]];
int retval = showRoomSpecificText(text);
free(text);

return retval;
}

int Room::showText(int speaker, int text) {
int textIDs[3];
textIDs[0] = speaker;
textIDs[1] = text;
textIDs[2] = TX_BLANK;
showText(textIDs);
}

int Room::showText(int text) {
showText(TX_NULL, text);
}

void Room::giveItem(int item) {
_vm->_itemList[item - ITEMS_START].have = true;
}
Expand Down
6 changes: 5 additions & 1 deletion engines/startrek/room.h
Expand Up @@ -28,6 +28,7 @@
#include "common/str.h"

#include "startrek/startrek.h"
#include "startrek/text.h"

using Common::SharedPtr;

Expand Down Expand Up @@ -102,7 +103,10 @@ class Room {
void loadActorAnim(int actorIndex, Common::String anim, int16 x, int16 y, uint16 field66); // Cmd 0x00
void loadActorStandAnim(int actorIndex); // Cmd 0x01
void loadActorAnim2(int actorIndex, Common::String anim, int16 x, int16 y, uint16 field66);// Cmd 0x02
int showRoomSpecificText(const char **textAddr); // Cmd 0x03
int showRoomSpecificText(const char **textAddr); // (Deprecated, use function below) // Cmd 0x03
int showText(const int *text); // Cmd 0x03
int showText(int speaker, int text); // Cmd 0x03
int showText(int text); // Cmd 0x03
void giveItem(int item); // Cmd 0x04
void loadRoomIndex(int roomIndex, int spawnIndex); // Cmd 0x06
void walkCrewman(int actorIndex, int16 destX, int16 destY, uint16 finishedAnimActionParam);// Cmd 0x08
Expand Down

0 comments on commit 30c41ae

Please sign in to comment.