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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Mon Feb 19 13:54:03 CET 2007


Revision: 25718
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25718&view=rev
Author:   peres001
Date:     2007-02-19 04:53:59 -0800 (Mon, 19 Feb 2007)

Log Message:
-----------
moved specialised parsing routines in parser.cpp, so code can be refactored more easily

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/animation.cpp
    scummvm/trunk/engines/parallaction/parser.cpp
    scummvm/trunk/engines/parallaction/parser.h
    scummvm/trunk/engines/parallaction/table.cpp

Modified: scummvm/trunk/engines/parallaction/animation.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/animation.cpp	2007-02-19 11:36:31 UTC (rev 25717)
+++ scummvm/trunk/engines/parallaction/animation.cpp	2007-02-19 12:53:59 UTC (rev 25718)
@@ -57,7 +57,6 @@
 
 LValue	getLValue(Instruction *inst, char *str, LocalVariable *locals, Animation *a);
 
-int16	scriptFillBuffers(ArchivedFile *file);
 
 uint16	_numLocals = 0;
 char	_localNames[10][10];
@@ -294,49 +293,9 @@
 
 
 
-//	FIXME
-//	this function does the same Job as parseFillBuffers, except that
-//	it gets input from an ArchivedFile instead of a memory buffer
-//
-int16 scriptFillBuffers(ArchivedFile *file) {
-//	printf("scriptFillBuffers()\n");
-	char v2[] = "\"\0";
 
-	int16 _si = 0;
 
-	for (; _si < 15; _si++)
-		_tokens[_si][0] = '\0';
 
-	char vCA[200];
-	char *vCE = NULL;
-	do {
-		vCE = readArchivedFileText(vCA, 200, file);
-		if (vCE == 0) return 0;
-
-		vCE = Common::ltrim(vCE);
-	} while (strlen(vCE) == 0 || vCE[0] == '#');
-
-	_si = 0;
-	while (strlen(vCE) > 0 && _si < 20) {
-		vCE = parseNextToken(vCE, _tokens[_si], 40, " \t\n");
-		if (_tokens[_si][0] == '"' && _tokens[_si][strlen(_tokens[_si])-1] != '"') {
-
-			vCE = parseNextToken(vCE, _tokens[_si+1], 40, v2);
-			strcat(_tokens[_si], _tokens[_si+1]);
-			_tokens[_si][0] = ' ';
-			vCE++;
-
-		}
-
-		vCE = Common::ltrim(vCE);
-		_si++;
-	}
-
-	return _si;
-}
-
-
-
 void Parallaction::parseScriptLine(Instruction *inst, Animation *a, LocalVariable *locals) {
 //	printf("parseScriptLine()\n");
 

Modified: scummvm/trunk/engines/parallaction/parser.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser.cpp	2007-02-19 11:36:31 UTC (rev 25717)
+++ scummvm/trunk/engines/parallaction/parser.cpp	2007-02-19 12:53:59 UTC (rev 25718)
@@ -22,8 +22,8 @@
 
 #include "parallaction/defs.h"
 #include "parallaction/parser.h"
+#include "parallaction/disk.h"
 
-
 namespace Parallaction {
 
 char			_tokens[20][40];
@@ -119,6 +119,87 @@
 	return _si;
 }
 
+//
+//	FIXME
+//	this function does the same Job as parseFillBuffers, except that
+//	it gets input from a SeekableStream instead of a memory buffer
+//
+uint16 tableFillBuffers(Common::SeekableReadStream &stream) {
+
+	for (uint16 i = 0; i < 20; i++)
+		_tokens[i][0] = '\0';
+
+	char buf[200];
+	char *line = NULL;
+	do {
+		line = stream.readLine(buf, 200);
+		if (line == NULL) return 0;
+
+		line = Common::ltrim(line);
+	} while (strlen(line) == 0 || line[0] == '#');
+
+	uint16 count = 0;
+	while (strlen(line) > 0 && count < 20) {
+		line = parseNextToken(line, _tokens[count], 40, " \t\n");
+		if (_tokens[count][0] == '"' && _tokens[count][strlen(_tokens[count]) - 1] != '"') {
+
+			line = parseNextToken(line, _tokens[count+1], 40, "\"");
+			strcat(_tokens[count], _tokens[count+1] );
+			_tokens[count][0] = ' ';
+			line++;
+
+		}
+
+		line = Common::ltrim(line);
+		count++;
+	}
+
+	return count;
+
+}
+
+//	FIXME
+//	this function does the same Job as parseFillBuffers, except that
+//	it gets input from an ArchivedFile instead of a memory buffer
+//
+int16 scriptFillBuffers(ArchivedFile *file) {
+//	printf("scriptFillBuffers()\n");
+	char v2[] = "\"\0";
+
+	int16 _si = 0;
+
+	for (; _si < 15; _si++)
+		_tokens[_si][0] = '\0';
+
+	char vCA[200];
+	char *vCE = NULL;
+	do {
+		vCE = readArchivedFileText(vCA, 200, file);
+		if (vCE == 0) return 0;
+
+		vCE = Common::ltrim(vCE);
+	} while (strlen(vCE) == 0 || vCE[0] == '#');
+
+	_si = 0;
+	while (strlen(vCE) > 0 && _si < 20) {
+		vCE = parseNextToken(vCE, _tokens[_si], 40, " \t\n");
+		if (_tokens[_si][0] == '"' && _tokens[_si][strlen(_tokens[_si])-1] != '"') {
+
+			vCE = parseNextToken(vCE, _tokens[_si+1], 40, v2);
+			strcat(_tokens[_si], _tokens[_si+1]);
+			_tokens[_si][0] = ' ';
+			vCE++;
+
+		}
+
+		vCE = Common::ltrim(vCE);
+		_si++;
+	}
+
+	return _si;
+}
+
+
 //	looks for next token in a string
 //
 //	scans 's' until one of the stop-chars in 'brk' is found

Modified: scummvm/trunk/engines/parallaction/parser.h
===================================================================
--- scummvm/trunk/engines/parallaction/parser.h	2007-02-19 11:36:31 UTC (rev 25717)
+++ scummvm/trunk/engines/parallaction/parser.h	2007-02-19 12:53:59 UTC (rev 25718)
@@ -24,6 +24,7 @@
 #define PARALLACTION_PARSER_H
 
 #include "parallaction/defs.h"
+#include "common/file.h"
 
 namespace Parallaction {
 
@@ -35,6 +36,10 @@
 uint16	parseFillBuffers();
 char   *parseNextToken(char *s, char *tok, uint16 count, const char *brk);
 
+uint16  tableFillBuffers(Common::SeekableReadStream &stream);
+int16	scriptFillBuffers(ArchivedFile *file);
+
+
 extern char _tokens[][40];
 
 } // namespace Parallaction

Modified: scummvm/trunk/engines/parallaction/table.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/table.cpp	2007-02-19 11:36:31 UTC (rev 25717)
+++ scummvm/trunk/engines/parallaction/table.cpp	2007-02-19 12:53:59 UTC (rev 25718)
@@ -28,47 +28,10 @@
 
 namespace Parallaction {
 
-uint16 tableFillBuffers(Common::SeekableReadStream &stream);
 
-//
-//	FIXME
-//	this function does the same Job as parseFillBuffers, except that
-//	it gets input from a SeekableStream instead of a memory buffer
-//
-uint16 tableFillBuffers(Common::SeekableReadStream &stream) {
 
-	for (uint16 i = 0; i < 20; i++)
-		_tokens[i][0] = '\0';
 
-	char buf[200];
-	char *line = NULL;
-	do {
-		line = stream.readLine(buf, 200);
-		if (line == NULL) return 0;
 
-		line = Common::ltrim(line);
-	} while (strlen(line) == 0 || line[0] == '#');
-
-	uint16 count = 0;
-	while (strlen(line) > 0 && count < 20) {
-		line = parseNextToken(line, _tokens[count], 40, " \t\n");
-		if (_tokens[count][0] == '"' && _tokens[count][strlen(_tokens[count]) - 1] != '"') {
-
-			line = parseNextToken(line, _tokens[count+1], 40, "\"");
-			strcat(_tokens[count], _tokens[count+1] );
-			_tokens[count][0] = ' ';
-			line++;
-
-		}
-
-		line = Common::ltrim(line);
-		count++;
-	}
-
-	return count;
-
-}
-
 void Parallaction::initTable(const char *path, char** table) {
 //	printf("initTable(%s)\n", path);
 


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