[Scummvm-cvs-logs] SF.net SVN: scummvm:[39738] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Sun Mar 29 14:41:00 CEST 2009
Revision: 39738
http://scummvm.svn.sourceforge.net/scummvm/?rev=39738&view=rev
Author: peres001
Date: 2009-03-29 12:41:00 +0000 (Sun, 29 Mar 2009)
Log Message:
-----------
Commands now evaluate their reference Zone at runtime, thus handling of forward references in the parser is no more needed.
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/exec.cpp
scummvm/trunk/engines/parallaction/objects.cpp
scummvm/trunk/engines/parallaction/objects.h
scummvm/trunk/engines/parallaction/parser.h
scummvm/trunk/engines/parallaction/parser_ns.cpp
Modified: scummvm/trunk/engines/parallaction/exec.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec.cpp 2009-03-29 12:28:24 UTC (rev 39737)
+++ scummvm/trunk/engines/parallaction/exec.cpp 2009-03-29 12:41:00 UTC (rev 39738)
@@ -102,6 +102,16 @@
CommandPtr cmd = *first;
+ if (cmd->_valid && !cmd->_zone && !cmd->_zoneName.empty()) {
+ // try binding the command to a zone
+ cmd->_zone = _vm->_location.findZone(cmd->_zoneName.c_str());
+ cmd->_valid = cmd->_zone != 0;
+ }
+
+ if (!cmd->_valid) {
+ continue;
+ }
+
if (cmd->_flagsOn & kFlagsGlobal) {
useFlags = _globalFlags | kFlagsGlobal;
useLocalFlags = false;
Modified: scummvm/trunk/engines/parallaction/objects.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/objects.cpp 2009-03-29 12:28:24 UTC (rev 39737)
+++ scummvm/trunk/engines/parallaction/objects.cpp 2009-03-29 12:41:00 UTC (rev 39738)
@@ -34,6 +34,7 @@
_id = 0;
_flagsOn = 0;
_flagsOff = 0;
+ _valid = false;
_flags = 0;
_string = 0;
Modified: scummvm/trunk/engines/parallaction/objects.h
===================================================================
--- scummvm/trunk/engines/parallaction/objects.h 2009-03-29 12:28:24 UTC (rev 39737)
+++ scummvm/trunk/engines/parallaction/objects.h 2009-03-29 12:41:00 UTC (rev 39738)
@@ -112,6 +112,7 @@
uint16 _id;
uint32 _flagsOn;
uint32 _flagsOff;
+ bool _valid;
Command();
~Command();
@@ -119,6 +120,7 @@
// Common fields
uint32 _flags;
ZonePtr _zone;
+ Common::String _zoneName;
char* _string;
uint16 _callable;
uint16 _object;
Modified: scummvm/trunk/engines/parallaction/parser.h
===================================================================
--- scummvm/trunk/engines/parallaction/parser.h 2009-03-29 12:28:24 UTC (rev 39737)
+++ scummvm/trunk/engines/parallaction/parser.h 2009-03-29 12:41:00 UTC (rev 39738)
@@ -204,17 +204,9 @@
void parseCommands(CommandList&);
void parseCommandFlags();
void parseCommandFlag(CommandPtr cmd, const char *flag, Table *table);
- void saveCommandForward(const char *name, CommandPtr cmd);
- void resolveCommandForwards();
void createCommand(uint id);
void addCommand();
- struct CommandForwardReference {
- char name[20];
- CommandPtr cmd;
- } _forwardedCommands[MAX_FORWARDS];
- uint _numForwardedCommands;
-
void clearSet(OpcodeSet &opcodes) {
for (Common::Array<const Opcode*>::iterator i = opcodes.begin(); i != opcodes.end(); ++i)
delete *i;
Modified: scummvm/trunk/engines/parallaction/parser_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser_ns.cpp 2009-03-29 12:28:24 UTC (rev 39737)
+++ scummvm/trunk/engines/parallaction/parser_ns.cpp 2009-03-29 12:41:00 UTC (rev 39738)
@@ -631,10 +631,7 @@
createCommand(_parser->_lookup);
- ctxt.cmd->_zone = _vm->_location.findZone(_tokens[ctxt.nextToken]);
- if (!ctxt.cmd->_zone) {
- saveCommandForward(_tokens[ctxt.nextToken], ctxt.cmd);
- }
+ ctxt.cmd->_zoneName = _tokens[ctxt.nextToken];
ctxt.nextToken++;
parseCommandFlags();
@@ -776,28 +773,10 @@
ctxt.nextToken = 1;
ctxt.cmd = CommandPtr(new Command);
ctxt.cmd->_id = id;
+ ctxt.cmd->_valid = true;
}
-void LocationParser_ns::saveCommandForward(const char *name, CommandPtr cmd) {
- assert(_numForwardedCommands < MAX_FORWARDS);
-
- strcpy(_forwardedCommands[_numForwardedCommands].name, name);
- _forwardedCommands[_numForwardedCommands].cmd = cmd;
-
- _numForwardedCommands++;
-}
-
-void LocationParser_ns::resolveCommandForwards() {
- for (uint i = 0; i < _numForwardedCommands; i++) {
- _forwardedCommands[i].cmd->_zone = _vm->_location.findZone(_forwardedCommands[i].name);
- if (_forwardedCommands[i].cmd->_zone == 0) {
- warning("Cannot find zone '%s' into current location script. This may be a bug in the original scripts.\n", _forwardedCommands[i].name);
- }
- }
- _numForwardedCommands = 0;
-}
-
void LocationParser_ns::parseCommands(CommandList& list) {
debugC(5, kDebugParser, "parseCommands()");
@@ -1058,7 +1037,6 @@
void LocationParser_ns::parse(Script *script) {
_zoneProg = 0;
- _numForwardedCommands = 0;
ctxt.end = false;
_script = script;
@@ -1071,8 +1049,6 @@
_parser->parseStatement();
} while (!ctxt.end);
_parser->popTables();
-
- resolveCommandForwards();
}
void LocationParser_ns::parsePointList(PointList &list) {
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