[Scummvm-cvs-logs] SF.net SVN: scummvm:[35783] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Thu Jan 8 08:11:33 CET 2009


Revision: 35783
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35783&view=rev
Author:   peres001
Date:     2009-01-08 07:11:32 +0000 (Thu, 08 Jan 2009)

Log Message:
-----------
Don't assert anymore when a command flag doesn't exist, but ignore it and print a warning instead. Some location scripts in BRA are totally broken.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/parser.h
    scummvm/trunk/engines/parallaction/parser_ns.cpp

Modified: scummvm/trunk/engines/parallaction/parser.h
===================================================================
--- scummvm/trunk/engines/parallaction/parser.h	2009-01-08 00:24:19 UTC (rev 35782)
+++ scummvm/trunk/engines/parallaction/parser.h	2009-01-08 07:11:32 UTC (rev 35783)
@@ -200,6 +200,7 @@
 	void		parseAnimation(AnimationList &list, char *name);
 	void		parseCommands(CommandList&);
 	void		parseCommandFlags();
+	void 		parseCommandFlag(CommandPtr cmd, const char *flag, Table *table, bool checkTrap);
 	void 		saveCommandForward(const char *name, CommandPtr cmd);
 	void 		resolveCommandForwards();
 	void		createCommand(uint id);

Modified: scummvm/trunk/engines/parallaction/parser_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser_ns.cpp	2009-01-08 00:24:19 UTC (rev 35782)
+++ scummvm/trunk/engines/parallaction/parser_ns.cpp	2009-01-08 07:11:32 UTC (rev 35783)
@@ -216,7 +216,7 @@
 	int16 _si = _zoneTypeNames->lookup(_tokens[1]);
 	if (_si != Table::notFound) {
 		ctxt.a->_type |= 1 << (_si-1);
-		if (((ctxt.a->_type & 0xFFFF) != kZoneNone) && ((ctxt.a->_type & 0xFFFF) != kZoneCommand)) {
+		if (/*((ctxt.a->_type & 0xFFFF) != kZoneNone) &&*/ ((ctxt.a->_type & 0xFFFF) != kZoneCommand)) {
 			parseZoneTypeBlock(ctxt.a);
 		}
 	}
@@ -711,66 +711,58 @@
 	ctxt.endcommands = true;
 }
 
+void LocationParser_ns::parseCommandFlag(CommandPtr cmd, const char *flag, Table *table, bool checkTrap) {
+
+	if (!scumm_stricmp(flag, "exit")) {
+		cmd->_flagsOn |= kFlagsExit;
+	} else
+	if (checkTrap && !scumm_stricmp(flag, "exittrap")) {
+		cmd->_flagsOn |= kFlagsExit;
+	} else
+	if (!scumm_stricmp(flag, "enter")) {
+		cmd->_flagsOn |= kFlagsEnter;
+	} else
+	if (checkTrap && !scumm_stricmp(flag, "entertrap")) {
+		cmd->_flagsOn |= kFlagsEnter;
+	} else
+	if (!scumm_strnicmp(flag, "no", 2)) {
+		byte _al = table->lookup(flag+2);
+		if (_al != Table::notFound) {
+			cmd->_flagsOff |= 1 << (_al - 1);
+		} else {
+			warning("Flag '%s' not found", flag);
+		}
+	} else {
+		byte _al = table->lookup(flag);
+		if (_al != Table::notFound) {
+			cmd->_flagsOn |= 1 << (_al - 1);
+		} else {
+			warning("Flag '%s' not found", flag);
+		}
+	}
+}
+
 void LocationParser_ns::parseCommandFlags() {
 
 	int _si = ctxt.nextToken;
 	CommandPtr cmd = ctxt.cmd;
 
 	if (!scumm_stricmp(_tokens[_si], "flags")) {
-		_si++;
-
 		do {
-			if (!scumm_stricmp(_tokens[_si], "exit") || !scumm_stricmp(_tokens[_si], "exittrap")) {
-				cmd->_flagsOn |= kFlagsExit;
-			} else
-			if (!scumm_stricmp(_tokens[_si], "enter") || !scumm_stricmp(_tokens[_si], "entertrap")) {
-				cmd->_flagsOn |= kFlagsEnter;
-			} else
-			if (!scumm_strnicmp(_tokens[_si], "no", 2)) {
-				byte _al = _vm->_localFlagNames->lookup(&_tokens[_si][2]);
-				assert(_al != Table::notFound);
-				cmd->_flagsOff |= 1 << (_al - 1);
-			} else {
-				byte _al = _vm->_localFlagNames->lookup(_tokens[_si]);
-				assert(_al != Table::notFound);
-				cmd->_flagsOn |= 1 << (_al - 1);
-			}
-
 			_si++;
-
-		} while (!scumm_stricmp(_tokens[_si++], "|"));
-
+			parseCommandFlag(cmd, _tokens[_si], _vm->_localFlagNames, true);
+			_si++;
+		} while (!scumm_stricmp(_tokens[_si], "|"));
 	}
 
 	if (!scumm_stricmp(_tokens[_si], "gflags")) {
-		_si++;
-		cmd->_flagsOn |= kFlagsGlobal;
-
 		do {
-			if (!scumm_stricmp(_tokens[_si], "exit")) {
-				cmd->_flagsOn |= kFlagsExit;
-			} else
-			if (!scumm_stricmp(_tokens[_si], "enter")) {
-				cmd->_flagsOn |= kFlagsEnter;
-			} else
-			if (!scumm_strnicmp(_tokens[_si], "no", 2)) {
-				byte _al = _vm->_globalFlagsNames->lookup(&_tokens[_si][2]);
-				assert(_al != Table::notFound);
-				cmd->_flagsOff |= 1 << (_al - 1);
-			} else {
-				byte _al = _vm->_globalFlagsNames->lookup(_tokens[_si]);
-				assert(_al != Table::notFound);
-				cmd->_flagsOn |= 1 << (_al - 1);
-			}
-
 			_si++;
-
-		} while (!scumm_stricmp(_tokens[_si++], "|"));
-
+			parseCommandFlag(cmd, _tokens[_si], _vm->_globalFlagsNames, false);
+			_si++;
+		} while (!scumm_stricmp(_tokens[_si], "|"));
+		cmd->_flagsOn |= kFlagsGlobal;
 	}
-
-	_si = ctxt.nextToken;
-
 }
 
 void LocationParser_ns::addCommand() {
@@ -1407,7 +1399,7 @@
 		}
 
 		_script->readLineToken(true);
-	} while (scumm_stricmp(_tokens[0], "endzone"));
+	} while (scumm_stricmp(_tokens[0], "endzone") && scumm_stricmp(_tokens[0], "endanimation"));
 
 	z->u.get = data;
 
@@ -1428,7 +1420,7 @@
 		}
 
 		_script->readLineToken(true);
-	} while (scumm_stricmp(_tokens[0], "endzone"));
+	} while (scumm_stricmp(_tokens[0], "endzone") && scumm_stricmp(_tokens[0], "endanimation"));
 
 	z->u.examine = data;
 
@@ -1472,7 +1464,7 @@
 		}
 
 		_script->readLineToken(true);
-	} while (scumm_stricmp(_tokens[0], "endzone"));
+	} while (scumm_stricmp(_tokens[0], "endzone") && scumm_stricmp(_tokens[0], "endanimation"));
 
 	z->u.door = data;
 
@@ -1496,7 +1488,7 @@
 		}
 
 		_script->readLineToken(true);
-	} while (scumm_stricmp(_tokens[0], "endzone"));
+	} while (scumm_stricmp(_tokens[0], "endzone") && scumm_stricmp(_tokens[0], "endanimation"));
 
 	z->u.merge = data;
 
@@ -1517,7 +1509,7 @@
 		}
 
 		_script->readLineToken(true);
-	} while (scumm_stricmp(_tokens[0], "endzone"));
+	} while (scumm_stricmp(_tokens[0], "endzone") && scumm_stricmp(_tokens[0], "endanimation"));
 
 	z->u.hear = data;
 
@@ -1537,7 +1529,7 @@
 		}
 
 		_script->readLineToken(true);
-	} while (scumm_stricmp(_tokens[0], "endzone"));
+	} while (scumm_stricmp(_tokens[0], "endzone") && scumm_stricmp(_tokens[0], "endanimation"));
 
 	z->u.speak = data;
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list