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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sun Nov 9 10:39:36 CET 2008


Revision: 34945
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34945&view=rev
Author:   peres001
Date:     2008-11-09 09:39:36 +0000 (Sun, 09 Nov 2008)

Log Message:
-----------
Update ReadStringStream and parser to work with the new eos() logic.

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

Modified: scummvm/trunk/engines/parallaction/parser.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser.cpp	2008-11-09 05:24:08 UTC (rev 34944)
+++ scummvm/trunk/engines/parallaction/parser.cpp	2008-11-09 09:39:36 UTC (rev 34945)
@@ -42,23 +42,28 @@
 
 char *Script::readLine(char *buf, size_t bufSize) {
 
-	uint16 _si;
-	char v2 = 0;
-	for ( _si = 0; _si<bufSize; _si++) {
+	uint16 i;
+	for (i = 0; i < bufSize; i++) {
 
-		v2 = _input->readSByte();
+		char c = _input->readSByte();
 
-		if (v2 == 0xA || v2 == 0xD || _input->eos()) break;
-		if (!_input->eos() && _si < bufSize) buf[_si] = v2;
+		if (_input->eos())
+			break;
+
+		if (c == 0xA || c == 0xD)
+			break;
+
+		if (i < bufSize)
+			buf[i] = c;
 	}
 
 	_line++;
 
-	if (_si == 0 && _input->eos())
+	if (i == 0 && _input->eos())
 		return 0;
 
-	buf[_si] = 0xA;
-	buf[_si+1] = '\0';
+	buf[i] = 0xA;
+	buf[i+1] = '\0';
 
 	return buf;
 

Modified: scummvm/trunk/engines/parallaction/parser.h
===================================================================
--- scummvm/trunk/engines/parallaction/parser.h	2008-11-09 05:24:08 UTC (rev 34944)
+++ scummvm/trunk/engines/parallaction/parser.h	2008-11-09 09:39:36 UTC (rev 34945)
@@ -433,6 +433,7 @@
 	char *_text;
 	uint32	_pos;
 	uint32	_size;
+	bool _eos;
 
 public:
 	ReadStringStream(const Common::String &text) {
@@ -440,6 +441,7 @@
 		strcpy(_text, text.c_str());
 		_size = text.size();
 		_pos = 0;
+		_eos = false;
 	}
 
 	~ReadStringStream() {
@@ -449,6 +451,7 @@
 	uint32 read(void *buffer, uint32 size) {
 		if (_pos + size > _size) {
 			size = _size - _pos;
+			_eos = true;
 		}
 		memcpy(buffer, _text + _pos, size);
 		_pos += size;
@@ -456,7 +459,7 @@
 	}
 
 	bool eos() const {
-		return _pos == _size; // FIXME (eos definition change)
+		return _eos;
 	}
 
 };


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