Permalink
Browse files

STARTREK: Refactor text using integer constants

  • Loading branch information...
Drenn1 authored and sev- committed May 28, 2018
1 parent 29e62d1 commit 30c41ae6341045ca6aacf0532aa413402a5c0656
@@ -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;
@@ -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;
}
@@ -28,6 +28,7 @@
#include "common/str.h"

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

using Common::SharedPtr;

@@ -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
Oops, something went wrong.

0 comments on commit 30c41ae

Please sign in to comment.