Partially reverting commit 28568, so now engine is back in charge for parsing locations. I'm going to convert this if/else/else hell into smaller opcode-like routines to achieve more flexibility first, and then assign version-specific opcodes to subclasses.
svn-id: r28609
This commit is contained in:
parent
92ea1804ca
commit
76e1be89c3
4 changed files with 87 additions and 104 deletions
|
@ -39,7 +39,7 @@ void Parallaction::parseLocation(const char *filename) {
|
||||||
uint16 _si = 1;
|
uint16 _si = 1;
|
||||||
_gfx->setFont(_labelFont);
|
_gfx->setFont(_labelFont);
|
||||||
|
|
||||||
Script *_locationScript = _disk->loadLocation(filename);
|
Script *script = _disk->loadLocation(filename);
|
||||||
_hasLocationSound = false;
|
_hasLocationSound = false;
|
||||||
|
|
||||||
// WORKAROUND: the original code erroneously incremented
|
// WORKAROUND: the original code erroneously incremented
|
||||||
|
@ -68,17 +68,48 @@ void Parallaction::parseLocation(const char *filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fillBuffers(*_locationScript, true);
|
fillBuffers(*script, true);
|
||||||
|
|
||||||
printf("ciao (%s)\n", filename);
|
|
||||||
|
|
||||||
while (scumm_stricmp(_tokens[0], "ENDLOCATION")) {
|
while (scumm_stricmp(_tokens[0], "ENDLOCATION")) {
|
||||||
|
|
||||||
printf("inst = %s\n", _tokens[0]);
|
printf("inst = %s\n", _tokens[0]);
|
||||||
|
|
||||||
bool parsed = parseLocationLine(filename, _locationScript);
|
if (!scumm_stricmp(_tokens[0], "LOCATION")) {
|
||||||
if (!parsed) {
|
// The parameter for location is 'location.mask'.
|
||||||
|
// If mask is not present, then it is assumed
|
||||||
|
// that path & mask are encoded in the background
|
||||||
|
// bitmap, otherwise a separate .msk file exists.
|
||||||
|
|
||||||
|
char *mask = strchr(_tokens[1], '.');
|
||||||
|
if (mask) {
|
||||||
|
mask[0] = '\0';
|
||||||
|
mask++;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(_location._name, _tokens[1]);
|
||||||
|
switchBackground(_location._name, mask);
|
||||||
|
|
||||||
|
if (_tokens[2][0] != '\0') {
|
||||||
|
_char._ani._left = atoi(_tokens[2]);
|
||||||
|
_char._ani._top = atoi(_tokens[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_tokens[4][0] != '\0') {
|
||||||
|
_char._ani._frame = atoi(_tokens[4]);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (!scumm_stricmp(_tokens[0], "DISK")) {
|
||||||
|
_disk->selectArchive(_tokens[1]);
|
||||||
|
} else
|
||||||
|
if (!scumm_stricmp(_tokens[0], "NODES")) {
|
||||||
|
parseWalkNodes(*script, _location._walkNodes);
|
||||||
|
} else
|
||||||
|
if (!scumm_stricmp(_tokens[0], "ZONE")) {
|
||||||
|
parseZone(*script, _zones, _tokens[1]);
|
||||||
|
} else
|
||||||
|
if (!scumm_stricmp(_tokens[0], "ANIMATION")) {
|
||||||
|
parseAnimation(*script, _animations, _tokens[1]);
|
||||||
|
} else
|
||||||
if (!scumm_stricmp(_tokens[0], "LOCALFLAGS")) {
|
if (!scumm_stricmp(_tokens[0], "LOCALFLAGS")) {
|
||||||
_si = 1; // _localFlagNames[0] = 'visited'
|
_si = 1; // _localFlagNames[0] = 'visited'
|
||||||
while (_tokens[_si][0] != '\0') {
|
while (_tokens[_si][0] != '\0') {
|
||||||
|
@ -87,10 +118,10 @@ void Parallaction::parseLocation(const char *filename) {
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if (!scumm_stricmp(_tokens[0], "COMMANDS")) {
|
if (!scumm_stricmp(_tokens[0], "COMMANDS")) {
|
||||||
parseCommands(*_locationScript, _location._commands);
|
parseCommands(*script, _location._commands);
|
||||||
} else
|
} else
|
||||||
if (!scumm_stricmp(_tokens[0], "ACOMMANDS")) {
|
if (!scumm_stricmp(_tokens[0], "ACOMMANDS")) {
|
||||||
parseCommands(*_locationScript, _location._aCommands);
|
parseCommands(*script, _location._aCommands);
|
||||||
} else
|
} else
|
||||||
if (!scumm_stricmp(_tokens[0], "FLAGS")) {
|
if (!scumm_stricmp(_tokens[0], "FLAGS")) {
|
||||||
if ((_localFlags[_currentLocationIndex] & kFlagsVisited) == 0) {
|
if ((_localFlags[_currentLocationIndex] & kFlagsVisited) == 0) {
|
||||||
|
@ -109,10 +140,10 @@ void Parallaction::parseLocation(const char *filename) {
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if (!scumm_stricmp(_tokens[0], "COMMENT")) {
|
if (!scumm_stricmp(_tokens[0], "COMMENT")) {
|
||||||
_location._comment = parseComment(*_locationScript);
|
_location._comment = parseComment(*script);
|
||||||
} else
|
} else
|
||||||
if (!scumm_stricmp(_tokens[0], "ENDCOMMENT")) {
|
if (!scumm_stricmp(_tokens[0], "ENDCOMMENT")) {
|
||||||
_location._endComment = parseComment(*_locationScript);
|
_location._endComment = parseComment(*script);
|
||||||
} else
|
} else
|
||||||
if (!scumm_stricmp(_tokens[0], "SOUND")) {
|
if (!scumm_stricmp(_tokens[0], "SOUND")) {
|
||||||
if (getPlatform() == Common::kPlatformAmiga) {
|
if (getPlatform() == Common::kPlatformAmiga) {
|
||||||
|
@ -125,14 +156,13 @@ void Parallaction::parseLocation(const char *filename) {
|
||||||
_soundMan->setMusicFile(_tokens[1]);
|
_soundMan->setMusicFile(_tokens[1]);
|
||||||
} else
|
} else
|
||||||
error("unknown keyword '%s' in location '%s'", _tokens[0], filename);
|
error("unknown keyword '%s' in location '%s'", _tokens[0], filename);
|
||||||
}
|
|
||||||
|
|
||||||
fillBuffers(*_locationScript, true);
|
fillBuffers(*script, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
resolveLocationForwards();
|
resolveLocationForwards();
|
||||||
|
|
||||||
delete _locationScript;
|
delete script;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -424,7 +424,7 @@ public:
|
||||||
DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(end);
|
DECLARE_UNQUALIFIED_INSTRUCTION_OPCODE(end);
|
||||||
|
|
||||||
void parseLocation(const char *filename);
|
void parseLocation(const char *filename);
|
||||||
virtual bool parseLocationLine(const char *filename, Script *script) = 0;
|
|
||||||
void changeCursor(int32 index);
|
void changeCursor(int32 index);
|
||||||
void showCursor(bool visible);
|
void showCursor(bool visible);
|
||||||
void changeCharacter(const char *name);
|
void changeCharacter(const char *name);
|
||||||
|
@ -628,8 +628,6 @@ public:
|
||||||
virtual void callFunction(uint index, void* parm);
|
virtual void callFunction(uint index, void* parm);
|
||||||
void renderLabel(Graphics::Surface *cnv, char *text);
|
void renderLabel(Graphics::Surface *cnv, char *text);
|
||||||
void setMousePointer(int16 index);
|
void setMousePointer(int16 index);
|
||||||
virtual bool parseLocationLine(const char *filename, Script *script);
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Menu* _menu;
|
Menu* _menu;
|
||||||
|
@ -696,7 +694,6 @@ public:
|
||||||
public:
|
public:
|
||||||
typedef void (Parallaction_br::*Callable)(void*);
|
typedef void (Parallaction_br::*Callable)(void*);
|
||||||
virtual void callFunction(uint index, void* parm);
|
virtual void callFunction(uint index, void* parm);
|
||||||
virtual bool parseLocationLine(const char *filename, Script *script);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Table *_countersNames;
|
Table *_countersNames;
|
||||||
|
|
|
@ -350,7 +350,7 @@ void skip(Script* script, const char* endToken) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
bool Parallaction_br::parseLocationLine(const char *filename, Script *script) {
|
bool Parallaction_br::parseLocationLine(const char *filename, Script *script) {
|
||||||
|
|
||||||
bool parsed = true;
|
bool parsed = true;
|
||||||
|
@ -420,6 +420,6 @@ bool Parallaction_br::parseLocationLine(const char *filename, Script *script) {
|
||||||
|
|
||||||
return parsed;
|
return parsed;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace Parallaction
|
} // namespace Parallaction
|
||||||
|
|
|
@ -199,49 +199,5 @@ int Parallaction_ns::go() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Parallaction_ns::parseLocationLine(const char *filename, Script *script) {
|
|
||||||
|
|
||||||
bool parsed = true;
|
|
||||||
|
|
||||||
if (!scumm_stricmp(_tokens[0], "LOCATION")) {
|
|
||||||
// The parameter for location is 'location.mask'.
|
|
||||||
// If mask is not present, then it is assumed
|
|
||||||
// that path & mask are encoded in the background
|
|
||||||
// bitmap, otherwise a separate .msk file exists.
|
|
||||||
|
|
||||||
char *mask = strchr(_tokens[1], '.');
|
|
||||||
if (mask) {
|
|
||||||
mask[0] = '\0';
|
|
||||||
mask++;
|
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(_location._name, _tokens[1]);
|
|
||||||
switchBackground(_location._name, mask);
|
|
||||||
|
|
||||||
if (_tokens[2][0] != '\0') {
|
|
||||||
_char._ani._left = atoi(_tokens[2]);
|
|
||||||
_char._ani._top = atoi(_tokens[3]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_tokens[4][0] != '\0') {
|
|
||||||
_char._ani._frame = atoi(_tokens[4]);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
if (!scumm_stricmp(_tokens[0], "DISK")) {
|
|
||||||
_disk->selectArchive(_tokens[1]);
|
|
||||||
} else
|
|
||||||
if (!scumm_stricmp(_tokens[0], "NODES")) {
|
|
||||||
parseWalkNodes(*script, _location._walkNodes);
|
|
||||||
} else
|
|
||||||
if (!scumm_stricmp(_tokens[0], "ZONE")) {
|
|
||||||
parseZone(*script, _zones, _tokens[1]);
|
|
||||||
} else
|
|
||||||
if (!scumm_stricmp(_tokens[0], "ANIMATION")) {
|
|
||||||
parseAnimation(*script, _animations, _tokens[1]);
|
|
||||||
} else
|
|
||||||
parsed = false;
|
|
||||||
|
|
||||||
return parsed;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Parallaction
|
} // namespace Parallaction
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue