aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNicola Mettifogo2007-03-24 21:18:08 +0000
committerNicola Mettifogo2007-03-24 21:18:08 +0000
commit7b9c74acae0543fedaf01c96c2720f244434c38e (patch)
tree69e6fb9d4082891527559acb79d0439ba702328d /engines
parent3034cb127329da8de756cee5a48e927206e396fb (diff)
downloadscummvm-rg350-7b9c74acae0543fedaf01c96c2720f244434c38e.tar.gz
scummvm-rg350-7b9c74acae0543fedaf01c96c2720f244434c38e.tar.bz2
scummvm-rg350-7b9c74acae0543fedaf01c96c2720f244434c38e.zip
Added new class Table, and updated Disk accordingly. Tables can be populated after their creation or wrapped around existing arrays. Thus, the old functions (initTable, freeTable and searchTable) have been removed.
svn-id: r26295
Diffstat (limited to 'engines')
-rw-r--r--engines/parallaction/animation.cpp12
-rw-r--r--engines/parallaction/commands.cpp22
-rw-r--r--engines/parallaction/dialogue.cpp24
-rw-r--r--engines/parallaction/disk.cpp38
-rw-r--r--engines/parallaction/disk.h5
-rw-r--r--engines/parallaction/location.cpp22
-rw-r--r--engines/parallaction/parallaction.cpp128
-rw-r--r--engines/parallaction/parallaction.h49
-rw-r--r--engines/parallaction/staticres.cpp41
-rw-r--r--engines/parallaction/zone.cpp14
10 files changed, 186 insertions, 169 deletions
diff --git a/engines/parallaction/animation.cpp b/engines/parallaction/animation.cpp
index 166fdfaf79..5069dd238c 100644
--- a/engines/parallaction/animation.cpp
+++ b/engines/parallaction/animation.cpp
@@ -97,9 +97,9 @@ Animation *Parallaction::parseAnimation(Script& script, Node *list, char *name)
}
if (!scumm_stricmp(_tokens[0], "type")) {
if (_tokens[2][0] != '\0') {
- vD0->_type = ((4 + searchTable(_tokens[2], const_cast<const char **>(_objectsNames))) << 16) & 0xFFFF0000;
+ vD0->_type = ((4 + _objectsNames->lookup(_tokens[2])) << 16) & 0xFFFF0000;
}
- int16 _si = searchTable(_tokens[1], _zoneTypeNames);
+ int16 _si = _zoneTypeNames->lookup(_tokens[1]);
if (_si != -1) {
vD0->_type |= 1 << (_si-1);
if (((vD0->_type & 0xFFFF) != kZoneNone) && ((vD0->_type & 0xFFFF) != kZoneCommand)) {
@@ -114,7 +114,7 @@ Animation *Parallaction::parseAnimation(Script& script, Node *list, char *name)
uint16 _si = 1;
do {
- byte _al = searchTable(_tokens[_si], _zoneFlagNames);
+ byte _al = _zoneFlagNames->lookup(_tokens[_si]);
_si++;
vD0->_flags |= 1 << (_al - 1);
} while (!scumm_stricmp(_tokens[_si++], "|"));
@@ -304,7 +304,7 @@ void Parallaction::parseScriptLine(Instruction *inst, Animation *a, LocalVariabl
a = findAnimation(&_tokens[1][2]);
}
- int16 _si = searchTable(_tokens[0], _instructionNames);
+ int16 _si = _instructionNames->lookup(_tokens[0]);
inst->_index = _si;
// printf("token[0] = %s (%i)\n", _tokens[0], inst->_index);
@@ -395,7 +395,7 @@ void Parallaction::parseScriptLine(Instruction *inst, Animation *a, LocalVariabl
break;
case INST_CALL: { // call
- int16 _ax = searchTable(_tokens[1], _callableNames);
+ int16 _ax = _callableNames->lookup(_tokens[1]);
inst->_opBase._index = _ax - 1;
if (_ax - 1 < 0) exit(0);
}
@@ -497,7 +497,7 @@ void jobRunScripts(void *parm, Job *j) {
while ((inst->_index != INST_SHOW) && (a->_flags & kFlagsActing)) {
- debugC(1, kDebugJobs, "Animation: %s, instruction: %s", a->_label._text, inst->_index == INST_END ? "end" : _instructionNames[inst->_index - 1]);
+ debugC(1, kDebugJobs, "Animation: %s, instruction: %s", a->_label._text, inst->_index == INST_END ? "end" : _instructionNamesRes[inst->_index - 1]);
switch (inst->_index) {
case INST_ENDLOOP: // endloop
diff --git a/engines/parallaction/commands.cpp b/engines/parallaction/commands.cpp
index cac2983254..095816d3b7 100644
--- a/engines/parallaction/commands.cpp
+++ b/engines/parallaction/commands.cpp
@@ -59,7 +59,7 @@ Command *Parallaction::parseCommands(Script &script) {
Command *cmd = new Command;
- cmd->_id = _vm->searchTable(_tokens[0], commands_names);
+ cmd->_id = _commandsNames->lookup(_tokens[0]);
uint16 _si = 1;
// printf("cmd id = %i", cmd->_id);
@@ -68,9 +68,9 @@ Command *Parallaction::parseCommands(Script &script) {
case CMD_SET: // set
case CMD_CLEAR: // clear
case CMD_TOGGLE: // toggle
- if (_vm->searchTable(_tokens[1], const_cast<const char **>(_globalTable)) == -1) {
+ if (_globalTable->lookup(_tokens[1]) == -1) {
do {
- char _al = _vm->searchTable(_tokens[_si], const_cast<const char **>(_localFlagNames));
+ char _al = _localFlagNames->lookup(_tokens[_si]);
_si++;
cmd->u._flags |= 1 << (_al - 1);
} while (!scumm_stricmp(_tokens[_si++], "|"));
@@ -78,7 +78,7 @@ Command *Parallaction::parseCommands(Script &script) {
} else {
cmd->u._flags |= kFlagsGlobal;
do {
- char _al = _vm->searchTable(_tokens[1], const_cast<const char **>(_globalTable));
+ char _al = _globalTable->lookup(_tokens[1]);
_si++;
cmd->u._flags |= 1 << (_al - 1);
} while (!scumm_stricmp(_tokens[_si++], "|"));
@@ -114,12 +114,12 @@ Command *Parallaction::parseCommands(Script &script) {
break;
case CMD_CALL: // call
- cmd->u._callable = _vm->searchTable(_tokens[_si], _callableNames) - 1;
+ cmd->u._callable = _callableNames->lookup(_tokens[_si]) - 1;
_si++;
break;
case CMD_DROP: // drop
- cmd->u._object = _vm->searchTable(_tokens[_si], const_cast<const char **>(_objectsNames));
+ cmd->u._object = _objectsNames->lookup(_tokens[_si]);
_si++;
break;
@@ -146,10 +146,10 @@ Command *Parallaction::parseCommands(Script &script) {
cmd->_flagsOn |= kFlagsEnter;
} else
if (!scumm_strnicmp(_tokens[_si], "no", 2)) {
- byte _al = _vm->searchTable(&_tokens[_si][2], const_cast<const char **>(_localFlagNames));
+ byte _al = _localFlagNames->lookup(&_tokens[_si][2]);
cmd->_flagsOff |= 1 << (_al - 1);
} else {
- byte _al = _vm->searchTable(_tokens[_si], const_cast<const char **>(_localFlagNames));
+ byte _al = _localFlagNames->lookup(_tokens[_si]);
cmd->_flagsOn |= 1 << (_al - 1);
}
@@ -171,10 +171,10 @@ Command *Parallaction::parseCommands(Script &script) {
cmd->_flagsOn |= kFlagsEnter;
} else
if (!scumm_strnicmp(_tokens[_si], "no", 2)) {
- byte _al = _vm->searchTable(&_tokens[_si][2], const_cast<const char **>(_globalTable));
+ byte _al = _globalTable->lookup(&_tokens[_si][2]);
cmd->_flagsOff |= 1 << (_al - 1);
} else {
- byte _al = _vm->searchTable(_tokens[_si], const_cast<const char **>(_globalTable));
+ byte _al = _globalTable->lookup(_tokens[_si]);
cmd->_flagsOn |= 1 << (_al - 1);
}
@@ -229,7 +229,7 @@ void Parallaction::runCommands(Command *list, Zone *z) {
if ((cmd->_flagsOn & v8) != cmd->_flagsOn) continue;
if ((cmd->_flagsOff & ~v8) != cmd->_flagsOff) continue;
- debugC(1, kDebugLocation, "runCommands: %s (on: %x, off: %x)", commands_names[cmd->_id-1], cmd->_flagsOn, cmd->_flagsOff);
+ debugC(1, kDebugLocation, "runCommands: %s (on: %x, off: %x)", _commandsNamesRes[cmd->_id-1], cmd->_flagsOn, cmd->_flagsOff);
switch (cmd->_id) {
diff --git a/engines/parallaction/dialogue.cpp b/engines/parallaction/dialogue.cpp
index d4576f60f6..166da25380 100644
--- a/engines/parallaction/dialogue.cpp
+++ b/engines/parallaction/dialogue.cpp
@@ -64,7 +64,7 @@ Dialogue *Parallaction::parseDialogue(Script &script) {
// printf("parseDialogue()\n");
uint16 num_questions = 0;
uint16 v50[20];
- char *_questions_names[20];
+ Table _questions_names(20);
Question *_questions[20];
for (uint16 _si = 0; _si < 20; _si++) {
@@ -79,8 +79,7 @@ Dialogue *Parallaction::parseDialogue(Script &script) {
_questions[num_questions] = new Dialogue;
Dialogue *vB4 = _questions[num_questions];
- _questions_names[num_questions] = (char*)malloc(strlen(_tokens[1])+1);
- strcpy(_questions_names[num_questions], _tokens[1]);
+ _questions_names.addData(_tokens[1]);
vB4->_text = parseDialogueString(script);
// printf("Question: '%s'\n", vB4->_text);
@@ -93,24 +92,24 @@ Dialogue *Parallaction::parseDialogue(Script &script) {
fillBuffers(script, true);
while (scumm_stricmp(_tokens[0], "endquestion")) { // parse answers
- const char** v60 = const_cast<const char **>(_localFlagNames);
- uint16 v56 = 1;
-
if (_tokens[1][0]) {
+ Table* v60 = _localFlagNames;
+ uint16 v56 = 1;
+
if (!scumm_stricmp(_tokens[1], "global")) {
v56 = 2;
- v60 = const_cast<const char **>(_globalTable);
+ v60 = _globalTable;
vB4->_yesFlags[_di] |= kFlagsGlobal;
}
do {
if (!scumm_strnicmp(_tokens[v56], "no", 2)) {
- byte _al = _vm->searchTable(_tokens[v56]+2, v60);
+ byte _al = v60->lookup(_tokens[v56]+2);
vB4->_noFlags[_di] |= 1 << (_al - 1);
} else {
- byte _al = _vm->searchTable(_tokens[v56], v60);
+ byte _al = v60->lookup(_tokens[v56]);
vB4->_yesFlags[_di] |= 1 << (_al - 1);
}
@@ -142,14 +141,12 @@ Dialogue *Parallaction::parseDialogue(Script &script) {
}
- _questions_names[num_questions] = NULL;
-
for (uint16 _si = 0; _si <num_questions; _si++) {
for (uint16 v5A = 0; v5A < 5; v5A++) {
if (_questions[_si]->_answers[v5A] == 0) continue;
- int16 v58 = _vm->searchTable(_questions[_si]->_following._names[v5A], const_cast<const char **>(_questions_names));
+ int16 v58 = _questions_names.lookup(_questions[_si]->_following._names[v5A]);
free(_questions[_si]->_following._names[v5A]);
if (v58 == -1) {
@@ -166,9 +163,6 @@ Dialogue *Parallaction::parseDialogue(Script &script) {
}
}
- for (uint16 _si = 0; _si < num_questions; _si++)
- free(_questions_names[_si]);
-
return _questions[0];
}
diff --git a/engines/parallaction/disk.cpp b/engines/parallaction/disk.cpp
index 052a218071..5fa595d04b 100644
--- a/engines/parallaction/disk.cpp
+++ b/engines/parallaction/disk.cpp
@@ -68,8 +68,6 @@ void Disk::setLanguage(uint16 language) {
return;
}
-
-
#pragma mark -
@@ -532,6 +530,26 @@ void DosDisk::loadScenery(const char *name, const char *mask) {
}
+Table* DosDisk::loadTable(const char* name) {
+ char path[PATH_LEN];
+ sprintf(path, "%s.tab", name);
+
+ Common::File stream;
+ if (!stream.open(path))
+ errorFileNotFound(path);
+
+ Table *t = new Table(100);
+
+ fillBuffers(stream);
+ while (scumm_stricmp(_tokens[0], "ENDTABLE")) {
+ t->addData(_tokens[0]);
+ fillBuffers(stream);
+ }
+
+ stream.close();
+
+ return t;
+}
#pragma mark -
@@ -591,7 +609,23 @@ void AmigaDisk::loadScenery(const char* background, const char* mask) {
return;
}
+Table* AmigaDisk::loadTable(const char* name) {
+
+ char path[PATH_LEN];
+ sprintf(path, "%s.table", name);
+
+ _archive.openArchivedFile(path);
+ Table *t = new Table(100);
+
+ fillBuffers(_archive);
+ while (scumm_stricmp(_tokens[0], "ENDTABLE")) {
+ t->addData(_tokens[0]);
+ fillBuffers(_archive);
+ }
+
+ return t;
+}
} // namespace Parallaction
diff --git a/engines/parallaction/disk.h b/engines/parallaction/disk.h
index 552a68b907..5d2473e4fb 100644
--- a/engines/parallaction/disk.h
+++ b/engines/parallaction/disk.h
@@ -35,6 +35,7 @@ namespace Parallaction {
#define MAX_ARCHIVE_ENTRIES 384
+class Table;
class Parallaction;
class Gfx;
class Script;
@@ -101,7 +102,7 @@ public:
virtual Cnv* loadFrames(const char* name) = 0;
virtual void loadSlide(const char *filename) = 0;
virtual void loadScenery(const char* background, const char* mask) = 0;
-
+ virtual Table* loadTable(const char* name) = 0;
};
@@ -136,6 +137,7 @@ public:
Cnv* loadFrames(const char* name);
void loadSlide(const char *filename);
void loadScenery(const char* background, const char* mask);
+ Table* loadTable(const char* name);
};
class AmigaDisk : public Disk {
@@ -155,6 +157,7 @@ public:
Cnv* loadFrames(const char* name);
void loadSlide(const char *filename);
void loadScenery(const char* background, const char* mask);
+ Table* loadTable(const char* name);
};
} // namespace Parallaction
diff --git a/engines/parallaction/location.cpp b/engines/parallaction/location.cpp
index 597f867573..41fe5c467e 100644
--- a/engines/parallaction/location.cpp
+++ b/engines/parallaction/location.cpp
@@ -38,7 +38,7 @@ void parseWalkNodes(Script &script, Node *list);
void Parallaction::parseLocation(const char *filename) {
- printf("parseLocation(%s)", filename);
+// printf("parseLocation(%s)", filename);
debugC(1, kDebugLocation, "parseLocation('%s')", filename);
uint16 _si = 1;
@@ -49,7 +49,7 @@ void Parallaction::parseLocation(const char *filename) {
fillBuffers(*_locationScript, true);
while (scumm_stricmp(_tokens[0], "ENDLOCATION")) {
- printf("token[0] = %s", _tokens[0]);
+// printf("token[0] = %s", _tokens[0]);
if (!scumm_stricmp(_tokens[0], "LOCATION")) {
// The parameter for location is 'location.mask'.
@@ -106,11 +106,9 @@ void Parallaction::parseLocation(const char *filename) {
if (!scumm_stricmp(_tokens[0], "LOCALFLAGS")) {
_si = 1; // _localFlagNames[0] = 'visited'
while (_tokens[_si][0] != '\0') {
- _localFlagNames[_si] = (char*)malloc(strlen(_tokens[_si])+1);
- strcpy(_localFlagNames[_si], _tokens[_si]);
+ _localFlagNames->addData(_tokens[_si]);
_si++;
}
- _localFlagNames[_si] = 0;
}
if (!scumm_stricmp(_tokens[0], "COMMANDS")) {
_location._commands = parseCommands(*_locationScript);
@@ -125,7 +123,7 @@ void Parallaction::parseLocation(const char *filename) {
_si = 1;
do {
- byte _al = searchTable(_tokens[_si], const_cast<const char **>(_localFlagNames));
+ byte _al = _localFlagNames->lookup(_tokens[_si]);
_localFlags[_currentLocationIndex] |= 1 << (_al - 1);
_si++;
@@ -180,14 +178,12 @@ void resolveLocationForwards() {
void Parallaction::freeLocation() {
debugC(7, kDebugLocation, "freeLocation");
- uint16 _si = 1;
- while (_localFlagNames[_si] != 0) {
- free(_localFlagNames[_si]);
- _localFlagNames[_si] = NULL;
- _si++;
- }
- debugC(7, kDebugLocation, "freeLocation: localflags names freed");
+ if (_localFlagNames)
+ delete _localFlagNames;
+ _localFlagNames = new Table(120);
+ _localFlagNames->addData("visited");
+ debugC(7, kDebugLocation, "freeLocation: localflags names freed");
freeNodeList(_vm->_location._walkNodes._next);
_vm->_location._walkNodes._next = NULL;
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index 5c2c94f1b4..7b254655c7 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -55,50 +55,11 @@ char _saveData1[30] = { '\0' };
uint16 _language = 0;
char _slideText[2][40];
uint32 _engineFlags = 0;
-char *_objectsNames[100];
Zone *_activeZone = NULL;
uint16 _score = 1;
uint32 _localFlags[120] = { 0 };
-
-static char tmp_visited_str[] = "visited";
-
-char *_localFlagNames[32] = {
- tmp_visited_str, // "visited",
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0
-};
-
Command * _forwardedCommands[20] = {
NULL,
NULL,
@@ -126,8 +87,6 @@ char _forwardedAnimationNames[20][20];
uint16 _numForwards = 0;
char _soundFile[20];
-char *_globalTable[32];
-
byte _mouseHidden = 0;
uint32 _commandFlags = 0;
@@ -167,6 +126,19 @@ Parallaction::Parallaction(OSystem *syst) :
Parallaction::~Parallaction() {
delete _midiPlayer;
delete _disk;
+ delete _globalTable;
+
+ if (_objectsNames)
+ delete _objectsNames;
+
+ delete _callableNames;
+ delete _commandsNames;
+ delete _instructionNames;
+ delete _zoneTypeNames;
+ delete _zoneFlagNames;
+
+ if (_localFlagNames)
+ delete _localFlagNames;
}
@@ -178,6 +150,11 @@ int Parallaction::init() {
return -1;
}
+ _objectsNames = NULL;
+ _globalTable = NULL;
+ _localFlagNames = NULL;
+ initResources();
+
_skipMenu = false;
_transCurrentHoverItem = 0;
@@ -278,8 +255,7 @@ void Parallaction::initGame() {
}
void Parallaction::initGlobals() {
-
- initTable("global.tab", _globalTable);
+ _globalTable = _disk->loadTable("global");
}
// FIXME: the engine has 3 event loops. The following routine hosts the main one,
@@ -721,7 +697,7 @@ void Parallaction::changeCursor(int32 index) {
-void freeCharacter() {
+void Parallaction::freeCharacter() {
_vm->_gfx->freeCnv(_vm->_char._normalFrames);
if (_vm->_char._normalFrames) delete _vm->_char._normalFrames;
@@ -730,7 +706,8 @@ void freeCharacter() {
_vm->_gfx->freeCnv(_vm->_char._miniFrames);
if (_vm->_char._miniFrames) delete _vm->_char._miniFrames;
- _vm->freeTable(_objectsNames);
+ if (_objectsNames) delete _objectsNames;
+ _objectsNames = NULL;
_vm->_gfx->freeCnv(_vm->_char._talk);
if (_vm->_char._talk) delete _vm->_char._talk;
@@ -829,8 +806,7 @@ void Parallaction::changeCharacter(const char *name) {
sprintf(path, "mini%s", v32);
_vm->_char._miniFrames = _disk->loadFrames(path);
- sprintf(path, "%s.tab", name);
- initTable(path, _objectsNames);
+ _objectsNames = _disk->loadTable(name);
refreshInventory(name);
@@ -970,64 +946,42 @@ void jobWaitRemoveJob(void *parm, Job *j) {
}
-void Parallaction::initTable(const char *path, char** table) {
-// printf("initTable(%s)\n", path);
-
- Common::File stream;
-
- if (!stream.open(path))
- errorFileNotFound(path);
-
- uint16 count = 0;
-
- fillBuffers(stream);
- while (scumm_stricmp(_tokens[0], "ENDTABLE")) {
+Table::Table(uint32 size) : _size(size), _used(0), _disposeMemory(true) {
+ _data = (char**)malloc(sizeof(char*)*size);
+}
- table[count] = (char*)malloc(strlen(_tokens[0])+1);
- strcpy(table[count], _tokens[0]);
+Table::Table(uint32 size, const char **data) : _size(size), _used(size), _disposeMemory(false) {
+ _data = const_cast<char**>(data);
+}
- count++;
- fillBuffers(stream);
- }
+Table::~Table() {
- table[count] = NULL;
+ if (!_disposeMemory) return;
- stream.close();
+ for (uint32 i = 0; i < _used; i++)
+ free(_data[i]);
- return;
+ free(_data);
}
-void Parallaction::freeTable(char** table) {
-
- uint16 count = 0;
-
- while (table[count]) {
+void Table::addData(const char* s) {
- free(table[count]);
- table[count] = NULL;
+ if (!(_used < _size))
+ error("Table overflow");
- count++;
- }
-
- return;
+ _data[_used++] = strdup(s);
}
-int16 Parallaction::searchTable(const char *s, const char **table) {
+int16 Table::lookup(const char* s) {
- int16 count = 0;
-
- if (!s) return 0;
-
- while (table[count]) {
- if (!scumm_stricmp(table[count], s)) return count + 1;
- count++;
+ for (uint16 i = 0; i < _used; i++) {
+ if (!scumm_stricmp(_data[i], s)) return i + 1;
}
return -1;
}
-
} // namespace Parallaction
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index 665a389013..611381c5ca 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -118,19 +118,12 @@ extern char _slideText[][40];
extern uint16 _introSarcData3; // sarcophagus stuff to be saved
extern uint16 _introSarcData2; // sarcophagus stuff to be saved
-extern char *_globalTable[];
extern char _saveData1[];
extern byte _mouseHidden;
extern uint32 _commandFlags;
-extern char *_objectsNames[];
-extern const char *_zoneTypeNames[];
-extern const char *_zoneFlagNames[];
-extern char *_localFlagNames[];
-extern const char *commands_names[];
-
-extern const char *_instructionNames[];
-extern const char *_callableNames[];
+extern const char *_instructionNamesRes[];
+extern const char *_commandsNamesRes[];
extern const char *_dinoName;
extern const char *_donnaName;
@@ -264,6 +257,26 @@ struct Character {
};
+
+class Table {
+
+ char **_data;
+ uint16 _size;
+ uint16 _used;
+ bool _disposeMemory;
+
+public:
+ Table(uint32 size);
+ Table(uint32 size, const char** data);
+
+ ~Table();
+
+ void addData(const char* s);
+
+ int16 lookup(const char* s);
+};
+
+
class Parallaction : public Engine {
public:
@@ -283,9 +296,9 @@ public:
void waitTime(uint32 t);
- static void initTable(const char *path, char **table);
- static void freeTable(char** table);
- static int16 searchTable(const char *s, const char **table);
+// static void initTable(const char *path, char **table);
+// static void freeTable(char** table);
+// static int16 searchTable(const char *s, const char **table);
void parseLocation(const char *filename);
void changeCursor(int32 index);
@@ -301,6 +314,15 @@ public:
void resumeJobs();
void runJobs();
+ Table *_globalTable;
+ Table *_objectsNames;
+ Table *_zoneTypeNames;
+ Table *_zoneFlagNames;
+ Table *_commandsNames;
+ Table *_callableNames;
+ Table *_instructionNames;
+ Table *_localFlagNames;
+
void freeZones(Node *list);
Animation *findAnimation(const char *name);
Zone *findZone(const char *name);
@@ -418,6 +440,9 @@ protected: // members
Command *parseCommands(Script &script);
void freeCommands(Command*);
+ void freeCharacter();
+
+ void initResources();
};
diff --git a/engines/parallaction/staticres.cpp b/engines/parallaction/staticres.cpp
index 9a233b6a6a..076ad8bf5d 100644
--- a/engines/parallaction/staticres.cpp
+++ b/engines/parallaction/staticres.cpp
@@ -20,8 +20,10 @@
*
*/
+#include "parallaction/parallaction.h"
#include "parallaction/graphics.h"
+
namespace Parallaction {
byte Gfx::_mouseArrow[256] = {
@@ -45,7 +47,7 @@ byte Gfx::_mouseArrow[256] = {
-const char *_zoneFlagNames[] = {
+const char *_zoneFlagNamesRes[] = {
"closed",
"active",
"remove",
@@ -57,11 +59,10 @@ const char *_zoneFlagNames[] = {
"looping",
"added",
"character",
- "nowalk",
- 0
+ "nowalk"
};
-const char *_zoneTypeNames[] = {
+const char *_zoneTypeNamesRes[] = {
"examine",
"door",
"get",
@@ -73,8 +74,7 @@ const char *_zoneTypeNames[] = {
"none",
"trap",
"yourself",
- "Command",
- 0
+ "Command"
};
const char _gameNames[10][20] = {
@@ -90,7 +90,7 @@ const char _gameNames[10][20] = {
"GAME10"
};
-const char *commands_names[] = {
+const char *_commandsNamesRes[] = {
"set",
"clear",
"start",
@@ -106,11 +106,10 @@ const char *commands_names[] = {
"drop",
"quit",
"move",
- "stop",
- 0
+ "stop"
};
-const char *_instructionNames[] = {
+const char *_instructionNamesRes[] = {
"on",
"off",
"x",
@@ -128,11 +127,10 @@ const char *_instructionNames[] = {
"wait",
"start",
"sound",
- "move",
- 0
+ "move"
};
-const char *_callableNames[] = {
+const char *_callableNamesRes[] = {
"HBOff",
"Projector",
"StartIntro",
@@ -157,8 +155,7 @@ const char *_callableNames[] = {
"Frankenstain",
"Finito",
"Ridux",
- "TestResult",
- 0
+ "TestResult"
};
@@ -238,4 +235,18 @@ const char *_minidoughName = "minidough";
const char *_minidrkiName = "minidrki";
+void Parallaction::initResources() {
+
+ _callableNames = new Table(ARRAYSIZE(_callableNamesRes), _callableNamesRes);
+ _instructionNames = new Table(ARRAYSIZE(_instructionNamesRes), _instructionNamesRes);
+ _zoneFlagNames = new Table(ARRAYSIZE(_zoneFlagNamesRes), _zoneFlagNamesRes);
+ _zoneTypeNames = new Table(ARRAYSIZE(_zoneTypeNamesRes), _zoneTypeNamesRes);
+ _commandsNames = new Table(ARRAYSIZE(_commandsNamesRes), _commandsNamesRes);
+
+ _localFlagNames = new Table(120);
+ _localFlagNames->addData("visited");
+
+}
+
+
} // namespace Parallaction
diff --git a/engines/parallaction/zone.cpp b/engines/parallaction/zone.cpp
index 19ac4f80e5..a7a8b8a31b 100644
--- a/engines/parallaction/zone.cpp
+++ b/engines/parallaction/zone.cpp
@@ -80,9 +80,9 @@ void Parallaction::parseZone(Script &script, Node *list, char *name) {
}
if (!scumm_stricmp(_tokens[0], "type")) {
if (_tokens[2][0] != '\0') {
- z->_type = (4 + searchTable(_tokens[2], const_cast<const char **>(_objectsNames))) << 16;
+ z->_type = (4 + _objectsNames->lookup(_tokens[2])) << 16;
}
- int16 _si = searchTable(_tokens[1], _zoneTypeNames);
+ int16 _si = _zoneTypeNames->lookup(_tokens[1]);
if (_si != -1) {
z->_type |= 1 << (_si - 1);
parseZoneTypeBlock(script, z);
@@ -100,7 +100,7 @@ void Parallaction::parseZone(Script &script, Node *list, char *name) {
uint16 _si = 1;
do {
- char _al = searchTable(_tokens[_si], _zoneFlagNames);
+ char _al = _zoneFlagNames->lookup(_tokens[_si]);
_si++;
z->_flags |= 1 << (_al - 1);
} while (!scumm_stricmp(_tokens[_si++], "|"));
@@ -307,19 +307,19 @@ void Parallaction::parseZoneTypeBlock(Script &script, Zone *z) {
}
if (!scumm_stricmp(_tokens[0], "icon")) {
- u->get->_icon = 4 + searchTable(_tokens[1], const_cast<const char **>(_objectsNames));
+ u->get->_icon = 4 + _objectsNames->lookup(_tokens[1]);
}
break;
case kZoneMerge: // merge Zone init
if (!scumm_stricmp(_tokens[0], "obj1")) {
- u->merge->_obj1 = 4 + searchTable(_tokens[1], const_cast<const char **>(_objectsNames));
+ u->merge->_obj1 = 4 + _objectsNames->lookup(_tokens[1]);
}
if (!scumm_stricmp(_tokens[0], "obj2")) {
- u->merge->_obj2 = 4 + searchTable(_tokens[1], const_cast<const char **>(_objectsNames));
+ u->merge->_obj2 = 4 + _objectsNames->lookup(_tokens[1]);
}
if (!scumm_stricmp(_tokens[0], "newobj")) {
- u->merge->_obj3 = 4 + searchTable(_tokens[1], const_cast<const char **>(_objectsNames));
+ u->merge->_obj3 = 4 + _objectsNames->lookup(_tokens[1]);
}
break;