From b87c11a4a14343a23c35e43b02bc8f4ff6b40922 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Tue, 3 Jun 2008 00:49:27 +0000 Subject: Fixed initialization of parsers, necessary after the latest removal of static arrays. svn-id: r32509 --- engines/parallaction/parallaction.h | 1 + engines/parallaction/parallaction_br.cpp | 21 +++++++++++++++++++++ engines/parallaction/parallaction_ns.cpp | 2 ++ engines/parallaction/parser.h | 18 ++++++++---------- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 3117424373..63042a8882 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -723,6 +723,7 @@ private: const Callable *_callables; void parseLocation(const char* name); + void loadProgram(AnimationPtr a, const char *filename); DECLARE_UNQUALIFIED_COMMAND_OPCODE(location); DECLARE_UNQUALIFIED_COMMAND_OPCODE(open); diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp index f07d201ae9..62cc702222 100644 --- a/engines/parallaction/parallaction_br.cpp +++ b/engines/parallaction/parallaction_br.cpp @@ -74,7 +74,9 @@ int Parallaction_br::init() { initCursors(); initOpcodes(); _locationParser = new LocationParser_br(this); + _locationParser->init(); _programParser = new ProgramParser_br(this); + _programParser->init(); _part = -1; @@ -258,6 +260,25 @@ void Parallaction_br::parseLocation(const char *filename) { return; } +void Parallaction_br::loadProgram(AnimationPtr a, const char *filename) { + debugC(1, kDebugParser, "loadProgram(Animation: %s, script: %s)", a->_name, filename); + + Script *script = _disk->loadScript(filename); + ProgramPtr program(new Program); + program->_anim = a; + + _programParser->parse(script, program); + + delete script; + + _vm->_location._programs.push_back(program); + + debugC(1, kDebugParser, "loadProgram() done"); + + return; +} + + void Parallaction_br::changeCharacter(const char *name) { diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index 9c1b25d824..2cca3a6a4a 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -137,7 +137,9 @@ int Parallaction_ns::init() { initCursors(); initOpcodes(); _locationParser = new LocationParser_ns(this); + _locationParser->init(); _programParser = new ProgramParser_ns(this); + _programParser->init(); _introSarcData1 = 0; _introSarcData2 = 1; diff --git a/engines/parallaction/parser.h b/engines/parallaction/parser.h index fa5d0527ed..22d3119d87 100644 --- a/engines/parallaction/parser.h +++ b/engines/parallaction/parser.h @@ -207,7 +207,6 @@ protected: } _forwardedCommands[MAX_FORWARDS]; uint _numForwardedCommands; - void init(); void clearSet(OpcodeSet &opcodes) { for (Common::Array::iterator i = opcodes.begin(); i != opcodes.end(); ++i) delete *i; @@ -216,9 +215,10 @@ protected: public: LocationParser_ns(Parallaction_ns *vm) : _vm(vm) { - init(); } + virtual void init(); + virtual ~LocationParser_ns() { delete _commandsNames; delete _locationStmt; @@ -282,13 +282,12 @@ protected: DECLARE_UNQUALIFIED_ANIM_PARSER(moveto); DECLARE_UNQUALIFIED_ANIM_PARSER(endanimation); - void init(); - public: LocationParser_br(Parallaction_br *vm) : LocationParser_ns((Parallaction_ns*)vm), _vm(vm) { - init(); } + virtual void init(); + virtual ~LocationParser_br() { delete _commandsNames; delete _locationStmt; @@ -343,7 +342,6 @@ protected: void parseLValue(ScriptVar &var, const char *str); virtual void parseRValue(ScriptVar &var, const char *str); - void init(); void clearSet(OpcodeSet &opcodes) { for (Common::Array::iterator i = opcodes.begin(); i != opcodes.end(); ++i) delete *i; @@ -352,9 +350,10 @@ protected: public: ProgramParser_ns(Parallaction_ns *vm) : _vm(vm) { - init(); } + virtual void init(); + virtual ~ProgramParser_ns() { delete _instructionNames; clearSet(_instructionParsers); @@ -380,13 +379,12 @@ protected: virtual void parseRValue(ScriptVar &var, const char *str); - void init(); - public: ProgramParser_br(Parallaction_br *vm) : ProgramParser_ns((Parallaction_ns*)vm), _vm(vm) { - init(); } + virtual void init(); + virtual ~ProgramParser_br() { delete _instructionNames; delete _parser; -- cgit v1.2.3