[Scummvm-cvs-logs] SF.net SVN: scummvm: [28639] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Thu Aug 16 21:47:22 CEST 2007
Revision: 28639
http://scummvm.svn.sourceforge.net/scummvm/?rev=28639&view=rev
Author: peres001
Date: 2007-08-16 12:47:22 -0700 (Thu, 16 Aug 2007)
Log Message:
-----------
Now using stacks to keep track of multiple levels when parsing location scripts.
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/animation.cpp
scummvm/trunk/engines/parallaction/commands.cpp
scummvm/trunk/engines/parallaction/location.cpp
scummvm/trunk/engines/parallaction/parallaction.cpp
scummvm/trunk/engines/parallaction/parallaction.h
scummvm/trunk/engines/parallaction/zone.cpp
Modified: scummvm/trunk/engines/parallaction/animation.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/animation.cpp 2007-08-16 18:42:28 UTC (rev 28638)
+++ scummvm/trunk/engines/parallaction/animation.cpp 2007-08-16 19:47:22 UTC (rev 28639)
@@ -95,7 +95,12 @@
}
}
- _locAnimParseCtxt.end = true;
+ _locAnimParseCtxt.a->_oldPos.x = -1000;
+ _locAnimParseCtxt.a->_oldPos.y = -1000;
+
+ _locAnimParseCtxt.a->_flags |= 0x1000000;
+
+ popParserTables();
}
@@ -141,7 +146,13 @@
DECLARE_ANIM_PARSER(endanimation) {
- _locAnimParseCtxt.end = true;
+
+ _locAnimParseCtxt.a->_oldPos.x = -1000;
+ _locAnimParseCtxt.a->_oldPos.y = -1000;
+
+ _locAnimParseCtxt.a->_flags |= 0x1000000;
+
+ popParserTables();
}
Animation *Parallaction::parseAnimation(Script& script, AnimationList &list, char *name) {
@@ -157,19 +168,8 @@
_locAnimParseCtxt.end = false;
_locAnimParseCtxt.script = &script;
- do {
- fillBuffers(script, true);
+ pushParserTables(_locationAnimParsers, _locationAnimStmt);
- int index = _locationAnimStmt->lookup(_tokens[0]);
- (this->*_locationAnimParsers[index])();
-
- } while (!_locAnimParseCtxt.end);
-
- a->_oldPos.x = -1000;
- a->_oldPos.y = -1000;
-
- a->_flags |= 0x1000000;
-
return a;
}
Modified: scummvm/trunk/engines/parallaction/commands.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/commands.cpp 2007-08-16 18:42:28 UTC (rev 28638)
+++ scummvm/trunk/engines/parallaction/commands.cpp 2007-08-16 19:47:22 UTC (rev 28639)
@@ -154,7 +154,7 @@
}
DECLARE_COMMAND_PARSER(endcommands) {
- _cmdParseCtxt.end = true;
+ popParserTables();
}
void Parallaction::parseCommandFlags() {
@@ -238,14 +238,8 @@
_cmdParseCtxt.list = &list;
_cmdParseCtxt.end = false;
- do {
- fillBuffers(script, true);
+ pushParserTables(_commandParsers, _commandsNames);
- _lookup = _commandsNames->lookup(_tokens[0]);
- (this->*_commandParsers[_lookup])();
-
- } while (!_cmdParseCtxt.end);
-
}
DECLARE_COMMAND_OPCODE(invalid) {
Modified: scummvm/trunk/engines/parallaction/location.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/location.cpp 2007-08-16 18:42:28 UTC (rev 28638)
+++ scummvm/trunk/engines/parallaction/location.cpp 2007-08-16 19:47:22 UTC (rev 28639)
@@ -165,20 +165,21 @@
_gfx->setFont(_labelFont);
_hasLocationSound = false;
- _locParseCtxt.end = false;;
+ _locParseCtxt.end = false;
_locParseCtxt.script = script;
_locParseCtxt.filename = filename;
+ pushParserTables(_locationParsers, _locationStmt);
do {
fillBuffers(*script, true);
- int index = _locationStmt->lookup(_tokens[0]);
- (this->*_locationParsers[index])();
+ parseStatement();
} while (!_locParseCtxt.end);
+ popParserTables();
delete script;
Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp 2007-08-16 18:42:28 UTC (rev 28638)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp 2007-08-16 19:47:22 UTC (rev 28639)
@@ -849,6 +849,30 @@
return notFound;
}
+void Parallaction::pushParserTables(const Opcode* opcodes, Table *statements) {
+
+ _opcodes.push(_currentOpcodes);
+ _statements.push(_currentStatements);
+
+ _currentOpcodes = opcodes;
+ _currentStatements = statements;
+
+}
+
+void Parallaction::popParserTables() {
+ assert(_opcodes.size() > 0);
+
+ _currentOpcodes = _opcodes.pop();
+ _currentStatements = _statements.pop();
+}
+
+void Parallaction::parseStatement() {
+ assert(_currentOpcodes != 0);
+
+ _lookup = _currentStatements->lookup(_tokens[0]);
+ (this->*(_currentOpcodes[_lookup]))();
+}
+
void Parallaction::initOpcodes() {
static const Opcode op0[] = {
@@ -998,6 +1022,9 @@
_locationAnimParsers = op6;
+ _currentOpcodes = 0;
+ _currentStatements = 0;
+
}
} // namespace Parallaction
Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h 2007-08-16 18:42:28 UTC (rev 28638)
+++ scummvm/trunk/engines/parallaction/parallaction.h 2007-08-16 19:47:22 UTC (rev 28639)
@@ -27,8 +27,8 @@
#define PARALLACTION_H
#include "common/str.h"
+#include "common/stack.h"
-
#include "engines/engine.h"
#include "parallaction/defs.h"
@@ -348,6 +348,16 @@
uint _lookup;
+ Common::Stack<const Opcode*> _opcodes;
+ Common::Stack<Table*> _statements;
+
+ const Opcode *_currentOpcodes;
+ Table *_currentStatements;
+
+ void pushParserTables(const Opcode* opcodes, Table* statements);
+ void popParserTables();
+ void parseStatement();
+
struct {
Command *cmd;
int nextToken;
Modified: scummvm/trunk/engines/parallaction/zone.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/zone.cpp 2007-08-16 18:42:28 UTC (rev 28638)
+++ scummvm/trunk/engines/parallaction/zone.cpp 2007-08-16 19:47:22 UTC (rev 28639)
@@ -48,7 +48,7 @@
}
DECLARE_ZONE_PARSER(endzone) {
- _locZoneParseCtxt.end = true;
+ popParserTables();
}
DECLARE_ZONE_PARSER(limits) {
@@ -75,7 +75,7 @@
parseZoneTypeBlock(*_locZoneParseCtxt.script, _locZoneParseCtxt.z);
}
- _locZoneParseCtxt.end = true;
+ popParserTables();
}
@@ -120,15 +120,8 @@
list.push_front(z);
- do {
+ pushParserTables(_locationZoneParsers, _locationZoneStmt);
- fillBuffers(script, true);
-
- int index = _locationZoneStmt->lookup(_tokens[0]);
- (this->*_locationZoneParsers[index])();
-
- } while (!_locZoneParseCtxt.end);
-
return;
}
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