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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Tue Jul 29 14:59:56 CEST 2008


Revision: 33408
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33408&view=rev
Author:   peres001
Date:     2008-07-29 12:59:55 +0000 (Tue, 29 Jul 2008)

Log Message:
-----------
* Implemented pause/resume of command execution
* Implemented command opcode MOVE (not the script instruction).

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/exec.h
    scummvm/trunk/engines/parallaction/exec_br.cpp
    scummvm/trunk/engines/parallaction/exec_ns.cpp
    scummvm/trunk/engines/parallaction/parallaction_br.cpp

Modified: scummvm/trunk/engines/parallaction/exec.h
===================================================================
--- scummvm/trunk/engines/parallaction/exec.h	2008-07-29 12:56:32 UTC (rev 33407)
+++ scummvm/trunk/engines/parallaction/exec.h	2008-07-29 12:59:55 UTC (rev 33408)
@@ -47,14 +47,30 @@
 	struct ParallactionStruct1 {
 		CommandPtr cmd;
 		ZonePtr	z;
+		bool suspend;
 	} _ctxt;
 
 	OpcodeSet	_opcodes;
 
+	struct SuspendedContext {
+		bool valid;
+		CommandList::iterator first;
+		CommandList::iterator last;
+		ZonePtr	zone;
+	} _suspendedCtxt;
+
+	ZonePtr	_execZone;
+	void runList(CommandList::iterator first, CommandList::iterator last);
+	void createSuspendList(CommandList::iterator first, CommandList::iterator last);
+	void cleanSuspendedList();
+
 public:
 	virtual void init() = 0;
 	virtual void run(CommandList &list, ZonePtr z = nullZonePtr);
+	void runSuspended();
+
 	CommandExec() {
+		_suspendedCtxt.valid = false;
 	}
 	virtual ~CommandExec() {
 		for (Common::Array<const Opcode*>::iterator i = _opcodes.begin(); i != _opcodes.end(); ++i)

Modified: scummvm/trunk/engines/parallaction/exec_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_br.cpp	2008-07-29 12:56:32 UTC (rev 33407)
+++ scummvm/trunk/engines/parallaction/exec_br.cpp	2008-07-29 12:59:55 UTC (rev 33408)
@@ -178,7 +178,8 @@
 
 
 DECLARE_COMMAND_OPCODE(move) {
-	warning("Parallaction_br::cmdOp_move not yet implemented");
+	_vm->_char.scheduleWalk(_ctxt.cmd->u._move.x, _ctxt.cmd->u._move.y);
+	_ctxt.suspend = true;
 }
 
 DECLARE_COMMAND_OPCODE(start) {

Modified: scummvm/trunk/engines/parallaction/exec_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-07-29 12:56:32 UTC (rev 33407)
+++ scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-07-29 12:59:55 UTC (rev 33408)
@@ -428,23 +428,18 @@
 	return;
 }
 
-void CommandExec::run(CommandList& list, ZonePtr z) {
-	if (list.size() == 0) {
-		debugC(3, kDebugExec, "runCommands: nothing to do");
-		return;
-	}
+void CommandExec::runList(CommandList::iterator first, CommandList::iterator last) {
 
-	debugC(3, kDebugExec, "runCommands starting");
-
 	uint32 useFlags = 0;
 	bool useLocalFlags;
 
-	CommandList::iterator it = list.begin();
-	for ( ; it != list.end(); it++) {
+	_ctxt.suspend = false;
+
+	for ( ; first != last; first++) {
 		if (_engineFlags & kEngineQuit)
 			break;
 
-		CommandPtr cmd = *it;
+		CommandPtr cmd = *first;
 
 		if (cmd->_flagsOn & kFlagsGlobal) {
 			useFlags = _commandFlags | kFlagsGlobal;
@@ -462,18 +457,67 @@
 
 		if (!onMatch || !offMatch) continue;
 
-		_ctxt.z = z;
+		_ctxt.z = _execZone;
 		_ctxt.cmd = cmd;
 
 		(*_opcodes[cmd->_id])();
+
+		if (_ctxt.suspend) {
+			createSuspendList(++first, last);
+			return;
+		}
 	}
 
+}
+
+void CommandExec::run(CommandList& list, ZonePtr z) {
+	if (list.size() == 0) {
+		debugC(3, kDebugExec, "runCommands: nothing to do");
+		return;
+	}
+
+	_execZone = z;
+
+	debugC(3, kDebugExec, "runCommands starting");
+	runList(list.begin(), list.end());
 	debugC(3, kDebugExec, "runCommands completed");
+}
 
-	return;
+void CommandExec::createSuspendList(CommandList::iterator first, CommandList::iterator last) {
+	if (first == last) {
+		return;
+	}
 
+	debugC(3, kDebugExec, "CommandExec::createSuspendList()");
+
+	_suspendedCtxt.valid = true;
+	_suspendedCtxt.first = first;
+	_suspendedCtxt.last = last;
+	_suspendedCtxt.zone = _execZone;
 }
 
+void CommandExec::cleanSuspendedList() {
+	debugC(3, kDebugExec, "CommandExec::cleanSuspended()");
+
+	_suspendedCtxt.valid = false;
+	_suspendedCtxt.first = _suspendedCtxt.last;
+	_suspendedCtxt.zone = nullZonePtr;
+}
+
+void CommandExec::runSuspended() {
+	if (_engineFlags & kEngineWalking) {
+		return;
+	}
+
+	if (_suspendedCtxt.valid) {
+		debugC(3, kDebugExec, "CommandExec::runSuspended()");
+
+		_execZone = _suspendedCtxt.zone;
+		runList(_suspendedCtxt.first, _suspendedCtxt.last);
+		cleanSuspendedList();
+	}
+}
+
 CommandExec_ns::CommandExec_ns(Parallaction_ns* vm) : _vm(vm) {
 
 }

Modified: scummvm/trunk/engines/parallaction/parallaction_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_br.cpp	2008-07-29 12:56:32 UTC (rev 33407)
+++ scummvm/trunk/engines/parallaction/parallaction_br.cpp	2008-07-29 12:59:55 UTC (rev 33408)
@@ -237,6 +237,8 @@
 void Parallaction_br::runPendingZones() {
 	ZonePtr z;
 
+	_cmdExec->runSuspended();
+
 	if (_activeZone) {
 		z = _activeZone;	// speak Zone or sound
 		_activeZone = nullZonePtr;


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