[Scummvm-cvs-logs] SF.net SVN: scummvm:[41771] scummvm/trunk/engines/gob
drmccoy at users.sourceforge.net
drmccoy at users.sourceforge.net
Mon Jun 22 18:29:45 CEST 2009
Revision: 41771
http://scummvm.svn.sourceforge.net/scummvm/?rev=41771&view=rev
Author: drmccoy
Date: 2009-06-22 16:29:45 +0000 (Mon, 22 Jun 2009)
Log Message:
-----------
More signess consistency on the reading and seeking methods
Modified Paths:
--------------
scummvm/trunk/engines/gob/script.cpp
scummvm/trunk/engines/gob/script.h
Modified: scummvm/trunk/engines/gob/script.cpp
===================================================================
--- scummvm/trunk/engines/gob/script.cpp 2009-06-22 16:29:31 UTC (rev 41770)
+++ scummvm/trunk/engines/gob/script.cpp 2009-06-22 16:29:45 UTC (rev 41771)
@@ -52,24 +52,29 @@
delete _parser;
}
-uint32 Script::read(byte *data, uint32 size) {
- uint32 toRead = MIN<uint32>(size, _totSize - (_totPtr - _totData));
+uint32 Script::read(byte *data, int32 size) {
+ int32 toRead = MIN<int32>(size, _totSize - (_totPtr - _totData));
+ if (toRead < 1)
+ return 0;
+
memcpy(data, _totPtr, toRead);
_totPtr += toRead;
return toRead;
}
-uint32 Script::peek(byte *data, uint32 size, int32 offset) const {
+uint32 Script::peek(byte *data, int32 size, int32 offset) const {
int32 totOffset = ((_totPtr + offset) - _totData);
- if (totOffset < 0)
+ if (totOffset < 1)
return 0;
if (((uint32) totOffset) >= _totSize)
return 0;
- uint32 toPeek = MIN<uint32>(size, _totSize - totOffset);
+ int32 toPeek = MIN<int32>(size, _totSize - totOffset);
+ if (toPeek < 1)
+ return 0;
memcpy(data, _totPtr + offset, toPeek);
@@ -110,13 +115,13 @@
return true;
}
-bool Script::skip(uint32 offset) {
+bool Script::skip(int32 offset) {
return seek(offset, SEEK_CUR);
}
-uint32 Script::getOffset(byte *ptr) {
+int32 Script::getOffset(byte *ptr) {
if (!_totData)
- return 0;
+ return -1;
return ptr - _totData;
}
Modified: scummvm/trunk/engines/gob/script.h
===================================================================
--- scummvm/trunk/engines/gob/script.h 2009-06-22 16:29:31 UTC (rev 41770)
+++ scummvm/trunk/engines/gob/script.h 2009-06-22 16:29:45 UTC (rev 41771)
@@ -40,9 +40,9 @@
~Script();
/** Read data and move the pointer accordingly. */
- uint32 read(byte *data, uint32 size);
+ uint32 read(byte *data, int32 size);
/** Read data (from an optional offset) without moving the pointer. */
- uint32 peek(byte *data, uint32 size, int32 offset = 0) const;
+ uint32 peek(byte *data, int32 size, int32 offset = 0) const;
// Stream properties
int32 pos() const;
@@ -50,7 +50,7 @@
// Stream seeking
bool seek(int32 offset, int whence = SEEK_SET);
- bool skip(uint32 offset);
+ bool skip(int32 offset);
// Reading data
byte readByte ();
@@ -89,7 +89,7 @@
char *getResultStr();
/** Returns the offset the specified pointer is within the script data. */
- uint32 getOffset(byte *ptr);
+ int32 getOffset(byte *ptr);
/** Returns the raw data pointer. */
byte *getData();
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