[Scummvm-cvs-logs] SF.net SVN: scummvm: [30841] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Sun Feb 10 00:26:45 CET 2008
Revision: 30841
http://scummvm.svn.sourceforge.net/scummvm/?rev=30841&view=rev
Author: peres001
Date: 2008-02-09 15:26:45 -0800 (Sat, 09 Feb 2008)
Log Message:
-----------
More refactoring for command parsing/execution.
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/exec_br.cpp
scummvm/trunk/engines/parallaction/exec_ns.cpp
scummvm/trunk/engines/parallaction/objects.h
scummvm/trunk/engines/parallaction/parallaction.cpp
scummvm/trunk/engines/parallaction/parallaction.h
scummvm/trunk/engines/parallaction/parser_br.cpp
scummvm/trunk/engines/parallaction/parser_ns.cpp
Modified: scummvm/trunk/engines/parallaction/exec_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_br.cpp 2008-02-09 22:07:51 UTC (rev 30840)
+++ scummvm/trunk/engines/parallaction/exec_br.cpp 2008-02-09 23:26:45 UTC (rev 30841)
@@ -165,11 +165,11 @@
}
DECLARE_COMMAND_OPCODE(start) {
- _cmdRunCtxt.cmd->u._animation->_flags |= kFlagsActing;
+ _cmdRunCtxt.cmd->u._zone->_flags |= kFlagsActing;
}
DECLARE_COMMAND_OPCODE(stop) {
- _cmdRunCtxt.cmd->u._animation->_flags &= ~kFlagsActing;
+ _cmdRunCtxt.cmd->u._zone->_flags &= ~kFlagsActing;
}
Modified: scummvm/trunk/engines/parallaction/exec_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_ns.cpp 2008-02-09 22:07:51 UTC (rev 30840)
+++ scummvm/trunk/engines/parallaction/exec_ns.cpp 2008-02-09 23:26:45 UTC (rev 30841)
@@ -225,7 +225,7 @@
DECLARE_COMMAND_OPCODE(start) {
- _cmdRunCtxt.cmd->u._animation->_flags |= kFlagsActing;
+ _cmdRunCtxt.cmd->u._zone->_flags |= kFlagsActing;
}
@@ -315,7 +315,7 @@
DECLARE_COMMAND_OPCODE(stop) {
- _cmdRunCtxt.cmd->u._animation->_flags &= ~kFlagsActing;
+ _cmdRunCtxt.cmd->u._zone->_flags &= ~kFlagsActing;
}
Modified: scummvm/trunk/engines/parallaction/objects.h
===================================================================
--- scummvm/trunk/engines/parallaction/objects.h 2008-02-09 22:07:51 UTC (rev 30840)
+++ scummvm/trunk/engines/parallaction/objects.h 2008-02-09 23:26:45 UTC (rev 30841)
@@ -93,7 +93,6 @@
struct CommandData {
uint32 _flags;
- Animation * _animation;
Zone* _zone;
char* _string;
uint16 _callable;
Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp 2008-02-09 22:07:51 UTC (rev 30840)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp 2008-02-09 23:26:45 UTC (rev 30841)
@@ -55,13 +55,6 @@
uint16 _score = 1;
char _password[8];
-Command * _forwardedCommands[MAX_FORWARDS] = {
- NULL
-};
-
-char _forwardedAnimationNames[MAX_FORWARDS][20];
-uint16 _numForwards = 0;
-
uint32 _commandFlags = 0;
uint16 _introSarcData3 = 200;
uint16 _introSarcData2 = 1;
Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h 2008-02-09 22:07:51 UTC (rev 30840)
+++ scummvm/trunk/engines/parallaction/parallaction.h 2008-02-09 23:26:45 UTC (rev 30841)
@@ -150,9 +150,6 @@
extern uint16 _language;
extern uint32 _engineFlags;
#define MAX_FORWARDS 50
-extern Command *_forwardedCommands[];
-extern char _forwardedAnimationNames[][20];
-extern uint16 _numForwards;
extern char _slideText[][MAX_TOKEN_LEN];
extern uint16 _introSarcData3; // sarcophagus stuff to be saved
extern uint16 _introSarcData2; // sarcophagus stuff to be saved
@@ -757,11 +754,19 @@
Animation *parseAnimation(Script &script, AnimationList &list, char *name);
void parseCommands(Script &script, CommandList&);
void parseCommandFlags();
+ void saveCommandForward(const char *name, Command* cmd);
+ void resolveCommandForwards();
void createCommand(uint id);
void addCommand();
void initOpcodes();
void initParsers();
+ struct CommandForwardReference {
+ char name[20];
+ Command* cmd;
+ } _forwardedCommands[MAX_FORWARDS];
+ uint _numForwardedCommands;
+
// program parser
OpcodeSet _instructionParsers;
Table *_instructionNames;
@@ -954,7 +959,6 @@
DECLARE_UNQUALIFIED_LOCATION_PARSER(null);
DECLARE_UNQUALIFIED_COMMAND_PARSER(ifchar);
DECLARE_UNQUALIFIED_COMMAND_PARSER(endif);
- DECLARE_UNQUALIFIED_COMMAND_PARSER(zone);
DECLARE_UNQUALIFIED_COMMAND_PARSER(location);
DECLARE_UNQUALIFIED_COMMAND_PARSER(toggle);
DECLARE_UNQUALIFIED_COMMAND_PARSER(string);
Modified: scummvm/trunk/engines/parallaction/parser_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser_br.cpp 2008-02-09 22:07:51 UTC (rev 30840)
+++ scummvm/trunk/engines/parallaction/parser_br.cpp 2008-02-09 23:26:45 UTC (rev 30841)
@@ -420,26 +420,6 @@
}
-DECLARE_COMMAND_PARSER(zone) {
- debugC(7, kDebugParser, "COMMAND_PARSER(zone) ");
-
- createCommand(_lookup);
-
- _locParseCtxt.cmd->u._zone = findZone(_tokens[_locParseCtxt.nextToken]);
- _locParseCtxt.nextToken++;
-
- if (_locParseCtxt.cmd->u._zone == NULL) {
- assert(_numForwards < MAX_FORWARDS);
- strcpy(_forwardedAnimationNames[_numForwards], _tokens[_locParseCtxt.nextToken-1]);
- _forwardedCommands[_numForwards] = _locParseCtxt.cmd;
- _numForwards++;
- }
-
- parseCommandFlags();
- addCommand();
-}
-
-
DECLARE_COMMAND_PARSER(zeta) {
debugC(7, kDebugParser, "COMMAND_PARSER(zeta) ");
@@ -824,7 +804,7 @@
WARNING_PARSER(unexpected),
COMMAND_PARSER(flags), // set
COMMAND_PARSER(flags), // clear
- COMMAND_PARSER(animation), // start
+ COMMAND_PARSER(zone), // start
COMMAND_PARSER(zone), // speak
COMMAND_PARSER(zone), // get
COMMAND_PARSER(location),
@@ -837,7 +817,7 @@
COMMAND_PARSER(drop),
COMMAND_PARSER(simple), // quit
COMMAND_PARSER(move),
- COMMAND_PARSER(animation), // stop
+ COMMAND_PARSER(zone), // stop
COMMAND_PARSER(string), // character
COMMAND_PARSER(string), // followme
COMMAND_PARSER(simple), // onmouse
Modified: scummvm/trunk/engines/parallaction/parser_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser_ns.cpp 2008-02-09 22:07:51 UTC (rev 30840)
+++ scummvm/trunk/engines/parallaction/parser_ns.cpp 2008-02-09 23:26:45 UTC (rev 30841)
@@ -495,30 +495,15 @@
}
-DECLARE_COMMAND_PARSER(animation) {
- debugC(7, kDebugParser, "COMMAND_PARSER(animation) ");
-
- createCommand(_lookup);
-
- _locParseCtxt.cmd->u._animation = findAnimation(_tokens[_locParseCtxt.nextToken]);
- _locParseCtxt.nextToken++;
- if (_locParseCtxt.cmd->u._animation == NULL) {
- strcpy(_forwardedAnimationNames[_numForwards], _tokens[_locParseCtxt.nextToken-1]);
- _forwardedCommands[_numForwards] = _locParseCtxt.cmd;
- _numForwards++;
- }
-
- parseCommandFlags();
- addCommand();
-}
-
-
DECLARE_COMMAND_PARSER(zone) {
debugC(7, kDebugParser, "COMMAND_PARSER(zone) ");
createCommand(_lookup);
_locParseCtxt.cmd->u._zone = findZone(_tokens[_locParseCtxt.nextToken]);
+ if (_locParseCtxt.cmd->u._zone == NULL) {
+ saveCommandForward(_tokens[_locParseCtxt.nextToken], _locParseCtxt.cmd);
+ }
_locParseCtxt.nextToken++;
parseCommandFlags();
@@ -670,6 +655,25 @@
}
+void Parallaction_ns::saveCommandForward(const char *name, Command* cmd) {
+ assert(_numForwardedCommands < MAX_FORWARDS);
+
+ strcpy(_forwardedCommands[_numForwardedCommands].name, name);
+ _forwardedCommands[_numForwardedCommands].cmd = cmd;
+
+ _numForwardedCommands++;
+}
+
+void Parallaction_ns::resolveCommandForwards() {
+ for (uint i = 0; i < _numForwardedCommands; i++) {
+ _forwardedCommands[i].cmd->u._zone = findZone(_forwardedCommands[i].name);
+ if (_forwardedCommands[i].cmd->u._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 Parallaction_ns::parseCommands(Script &script, CommandList& list) {
debugC(5, kDebugParser, "parseCommands()");
@@ -975,6 +979,8 @@
allocateLocationSlot(filename);
// printf("got location slot #%i for %s\n", _currentLocationIndex, filename);
+ _numForwardedCommands = 0;
+
Script *script = _disk->loadLocation(filename);
// TODO: the following two lines are specific to Nippon Safes
@@ -994,12 +1000,7 @@
delete script;
- // this resolves any forward references in the script
- for (uint16 _si = 0; _forwardedCommands[_si]; _si++) {
- _forwardedCommands[_si]->u._animation = findAnimation(_forwardedAnimationNames[_si]);
- _forwardedCommands[_si] = NULL;
- }
- _numForwards = 0;
+ resolveCommandForwards();
// this loads animation scripts
AnimationList::iterator it = _animations.begin();
@@ -1081,7 +1082,7 @@
WARNING_PARSER(unexpected),
COMMAND_PARSER(flags), // set
COMMAND_PARSER(flags), // clear
- COMMAND_PARSER(animation), // start
+ COMMAND_PARSER(zone), // start
COMMAND_PARSER(zone), // speak
COMMAND_PARSER(zone), // get
COMMAND_PARSER(location), // location
@@ -1094,7 +1095,7 @@
COMMAND_PARSER(drop), // drop
COMMAND_PARSER(simple), // quit
COMMAND_PARSER(move), // move
- COMMAND_PARSER(animation), // stop
+ COMMAND_PARSER(zone), // stop
COMMAND_PARSER(endcommands), // endcommands
COMMAND_PARSER(endcommands) // endzone
};
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