aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction
diff options
context:
space:
mode:
authorNicola Mettifogo2007-10-14 20:59:46 +0000
committerNicola Mettifogo2007-10-14 20:59:46 +0000
commit652069f1a639cac69d5c4fd87149f1f068251c38 (patch)
tree46d5e7a7612cfb9941c13c78cb78add08aee050b /engines/parallaction
parent0e693cbbfb4b115490fb503e9b28eb1248879c8d (diff)
downloadscummvm-rg350-652069f1a639cac69d5c4fd87149f1f068251c38.tar.gz
scummvm-rg350-652069f1a639cac69d5c4fd87149f1f068251c38.tar.bz2
scummvm-rg350-652069f1a639cac69d5c4fd87149f1f068251c38.zip
Made location parser more fault-tolerant, in that it prints out a warning message instead of exiting ScummVM when it encounters an unexpected keywords in the scripts.
svn-id: r29220
Diffstat (limited to 'engines/parallaction')
-rw-r--r--engines/parallaction/parallaction.h7
-rw-r--r--engines/parallaction/parser_br.cpp17
-rw-r--r--engines/parallaction/parser_ns.cpp48
-rw-r--r--engines/parallaction/staticres.cpp6
4 files changed, 23 insertions, 55 deletions
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index 87c071ab2b..5238f8f913 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -723,7 +723,8 @@ protected:
int numZones;
} _locParseCtxt;
- DECLARE_UNQUALIFIED_LOCATION_PARSER(invalid);
+ void warning_unexpected();
+
DECLARE_UNQUALIFIED_LOCATION_PARSER(endlocation);
DECLARE_UNQUALIFIED_LOCATION_PARSER(location);
DECLARE_UNQUALIFIED_LOCATION_PARSER(disk);
@@ -738,8 +739,6 @@ protected:
DECLARE_UNQUALIFIED_LOCATION_PARSER(endcomment);
DECLARE_UNQUALIFIED_LOCATION_PARSER(sound);
DECLARE_UNQUALIFIED_LOCATION_PARSER(music);
- DECLARE_UNQUALIFIED_LOCATION_PARSER(redundant);
- DECLARE_UNQUALIFIED_ZONE_PARSER(invalid);
DECLARE_UNQUALIFIED_ZONE_PARSER(limits);
DECLARE_UNQUALIFIED_ZONE_PARSER(moveto);
DECLARE_UNQUALIFIED_ZONE_PARSER(type);
@@ -748,7 +747,6 @@ protected:
DECLARE_UNQUALIFIED_ZONE_PARSER(flags);
DECLARE_UNQUALIFIED_ZONE_PARSER(endzone);
DECLARE_UNQUALIFIED_ZONE_PARSER(null);
- DECLARE_UNQUALIFIED_ANIM_PARSER(invalid);
DECLARE_UNQUALIFIED_ANIM_PARSER(script);
DECLARE_UNQUALIFIED_ANIM_PARSER(commands);
DECLARE_UNQUALIFIED_ANIM_PARSER(type);
@@ -758,7 +756,6 @@ protected:
DECLARE_UNQUALIFIED_ANIM_PARSER(position);
DECLARE_UNQUALIFIED_ANIM_PARSER(moveto);
DECLARE_UNQUALIFIED_ANIM_PARSER(endanimation);
- DECLARE_UNQUALIFIED_COMMAND_PARSER(invalid);
DECLARE_UNQUALIFIED_COMMAND_PARSER(flags);
DECLARE_UNQUALIFIED_COMMAND_PARSER(animation);
DECLARE_UNQUALIFIED_COMMAND_PARSER(zone);
diff --git a/engines/parallaction/parser_br.cpp b/engines/parallaction/parser_br.cpp
index b68dfccc00..b92da0478f 100644
--- a/engines/parallaction/parser_br.cpp
+++ b/engines/parallaction/parser_br.cpp
@@ -784,6 +784,8 @@ typedef OpcodeImpl<Parallaction_br> OpcodeV2;
#define LOCATION_PARSER(sig) OpcodeV2(this, &Parallaction_br::locParse_##sig)
#define COMMAND_PARSER(sig) OpcodeV2(this, &Parallaction_br::cmdParse_##sig)
+#define WARNING_PARSER(sig) OpcodeV2(this, &Parallaction_br::warning_##sig)
+
void Parallaction_br::initParsers() {
static const OpcodeV2 op0[] = {
@@ -827,7 +829,7 @@ void Parallaction_br::initParsers() {
static const OpcodeV2 op2[] = {
- COMMAND_PARSER(invalid),
+ WARNING_PARSER(unexpected),
COMMAND_PARSER(flags), // set
COMMAND_PARSER(flags), // clear
COMMAND_PARSER(animation), // start
@@ -853,8 +855,8 @@ void Parallaction_br::initParsers() {
COMMAND_PARSER(math), // inc
COMMAND_PARSER(math), // dec
COMMAND_PARSER(test), // test
- COMMAND_PARSER(invalid),
- COMMAND_PARSER(invalid),
+ WARNING_PARSER(unexpected),
+ WARNING_PARSER(unexpected),
COMMAND_PARSER(math), // let
COMMAND_PARSER(music),
COMMAND_PARSER(zone), // fix
@@ -865,7 +867,7 @@ void Parallaction_br::initParsers() {
COMMAND_PARSER(give),
COMMAND_PARSER(text),
COMMAND_PARSER(unary), // part
- COMMAND_PARSER(invalid),
+ WARNING_PARSER(unexpected),
COMMAND_PARSER(simple), // return
COMMAND_PARSER(simple), // onsave
COMMAND_PARSER(simple), // offsave
@@ -878,7 +880,7 @@ void Parallaction_br::initParsers() {
_commandParsers.push_back(&op2[i]);
static const OpcodeV2 op4[] = {
- LOCATION_PARSER(invalid),
+ WARNING_PARSER(unexpected),
LOCATION_PARSER(character),
LOCATION_PARSER(endlocation),
LOCATION_PARSER(ifchar),
@@ -899,14 +901,13 @@ void Parallaction_br::initParsers() {
LOCATION_PARSER(zeta),
LOCATION_PARSER(music),
LOCATION_PARSER(sound)
-// LOCATION_PARSER(redundant) // for redundant endanimation
};
for (i = 0; i < ARRAYSIZE(op4); i++)
_locationParsers.push_back(&op4[i]);
static const OpcodeV2 op5[] = {
- ZONE_PARSER(invalid),
+ WARNING_PARSER(unexpected),
ZONE_PARSER(endzone),
ZONE_PARSER(limits),
ZONE_PARSER(moveto),
@@ -920,7 +921,7 @@ void Parallaction_br::initParsers() {
_locationZoneParsers.push_back(&op5[i]);
static const OpcodeV2 op6[] = {
- ANIM_PARSER(invalid),
+ WARNING_PARSER(unexpected),
ANIM_PARSER(endanimation),
ANIM_PARSER(endanimation), // endzone
ANIM_PARSER(script),
diff --git a/engines/parallaction/parser_ns.cpp b/engines/parallaction/parser_ns.cpp
index 41bd97e3b3..885d147572 100644
--- a/engines/parallaction/parser_ns.cpp
+++ b/engines/parallaction/parser_ns.cpp
@@ -74,12 +74,8 @@ namespace Parallaction {
#define DECLARE_LOCATION_PARSER(sig) void Parallaction_ns::locParse_##sig()
-
-
-DECLARE_ANIM_PARSER(invalid) {
- debugC(7, kDebugParser, "ANIM_PARSER(invalid) ");
-
- error("unknown statement '%s' in animation %s", _tokens[0], _locParseCtxt.a->_label._text);
+void Parallaction_ns::warning_unexpected() {
+ warning("unexpected keyword '%s'", _tokens[0]);
}
@@ -590,12 +586,6 @@ DECLARE_COMMAND_PARSER(move) {
addCommand();
}
-DECLARE_COMMAND_PARSER(invalid) {
- debugC(7, kDebugParser, "COMMAND_PARSER(invalid) ");
-
- error("Can't parse unknown command '%s'", _tokens[0]);
-}
-
DECLARE_COMMAND_PARSER(endcommands) {
debugC(7, kDebugParser, "COMMAND_PARSER(endcommands) ");
@@ -822,12 +812,6 @@ char *Parallaction_ns::parseDialogueString(Script &script) {
}
-DECLARE_LOCATION_PARSER(invalid) {
- debugC(7, kDebugParser, "LOCATION_PARSER(invalid) ");
-
- error("unknown keyword '%s' in location '%s'", _tokens[0], _locParseCtxt.filename);
-}
-
DECLARE_LOCATION_PARSER(endlocation) {
debugC(7, kDebugParser, "LOCATION_PARSER(endlocation) ");
@@ -967,12 +951,6 @@ DECLARE_LOCATION_PARSER(music) {
_soundMan->setMusicFile(_tokens[1]);
}
-DECLARE_LOCATION_PARSER(redundant) {
- debugC(7, kDebugParser, "LOCATION_PARSER(redundant) ");
-
- warning("redundant '%s' line found in script '%s'", _tokens[0], _locParseCtxt.filename);
-}
-
void Parallaction_ns::parseLocation(const char *filename) {
debugC(1, kDebugParser, "parseLocation('%s')", filename);
@@ -1050,6 +1028,8 @@ typedef OpcodeImpl<Parallaction_ns> OpcodeV1;
#define LOCATION_PARSER(sig) OpcodeV1(this, &Parallaction_ns::locParse_##sig)
#define COMMAND_PARSER(sig) OpcodeV1(this, &Parallaction_ns::cmdParse_##sig)
+#define WARNING_PARSER(sig) OpcodeV1(this, &Parallaction_br::warning_##sig)
+
void Parallaction_ns::initParsers() {
static const OpcodeV1 op0[] = {
@@ -1081,7 +1061,7 @@ void Parallaction_ns::initParsers() {
static const OpcodeV1 op2[] = {
- COMMAND_PARSER(invalid),
+ WARNING_PARSER(unexpected),
COMMAND_PARSER(flags), // set
COMMAND_PARSER(flags), // clear
COMMAND_PARSER(animation), // start
@@ -1107,7 +1087,7 @@ void Parallaction_ns::initParsers() {
static const OpcodeV1 op4[] = {
- LOCATION_PARSER(invalid),
+ WARNING_PARSER(unexpected),
LOCATION_PARSER(endlocation),
LOCATION_PARSER(location),
LOCATION_PARSER(disk),
@@ -1121,30 +1101,28 @@ void Parallaction_ns::initParsers() {
LOCATION_PARSER(comment),
LOCATION_PARSER(endcomment),
LOCATION_PARSER(sound),
- LOCATION_PARSER(music),
- LOCATION_PARSER(redundant) // for redundant endanimation
+ LOCATION_PARSER(music)
};
for (i = 0; i < ARRAYSIZE(op4); i++)
_locationParsers.push_back(&op4[i]);
static const OpcodeV1 op5[] = {
- ZONE_PARSER(invalid),
+ WARNING_PARSER(unexpected),
ZONE_PARSER(limits),
ZONE_PARSER(moveto),
ZONE_PARSER(type),
ZONE_PARSER(commands),
ZONE_PARSER(label),
ZONE_PARSER(flags),
- ZONE_PARSER(endzone),
- ZONE_PARSER(null)
+ ZONE_PARSER(endzone)
};
for (i = 0; i < ARRAYSIZE(op5); i++)
_locationZoneParsers.push_back(&op5[i]);
static const OpcodeV1 op6[] = {
- ANIM_PARSER(invalid),
+ WARNING_PARSER(unexpected),
ANIM_PARSER(script),
ANIM_PARSER(commands),
ANIM_PARSER(type),
@@ -1196,12 +1174,6 @@ DECLARE_ZONE_PARSER(null) {
}
-DECLARE_ZONE_PARSER(invalid) {
- debugC(7, kDebugParser, "ZONE_PARSER(invalid) ");
-
- error("unknown statement '%s' in zone %s", _tokens[0], _locParseCtxt.z->_label._text);
-}
-
DECLARE_ZONE_PARSER(endzone) {
debugC(7, kDebugParser, "ZONE_PARSER(endzone) ");
diff --git a/engines/parallaction/staticres.cpp b/engines/parallaction/staticres.cpp
index b7af7dc1b2..53d370a0a8 100644
--- a/engines/parallaction/staticres.cpp
+++ b/engines/parallaction/staticres.cpp
@@ -332,8 +332,7 @@ const char *_locationStmtRes_ns[] = {
"comment",
"endcomment",
"sound",
- "music",
- "endanimation"
+ "music"
};
const char *_locationZoneStmtRes_ns[] = {
@@ -343,8 +342,7 @@ const char *_locationZoneStmtRes_ns[] = {
"commands",
"label",
"flags",
- "endzone",
- "endcommands" // this to prevent unexpected statements in the scripts to crash the parser
+ "endzone"
};
const char *_locationAnimStmtRes_ns[] = {