aboutsummaryrefslogtreecommitdiff
path: root/engines/gob
diff options
context:
space:
mode:
authorSven Hesse2009-06-22 16:29:45 +0000
committerSven Hesse2009-06-22 16:29:45 +0000
commit7ba9c46cb0e80eebb2fab718c2f4cd8913ab8890 (patch)
treed3af1be0b14469d7e9aed70dcfca9c2cff0641e9 /engines/gob
parent565a9f5b0d4528b09531e1c381f81587546a0580 (diff)
downloadscummvm-rg350-7ba9c46cb0e80eebb2fab718c2f4cd8913ab8890.tar.gz
scummvm-rg350-7ba9c46cb0e80eebb2fab718c2f4cd8913ab8890.tar.bz2
scummvm-rg350-7ba9c46cb0e80eebb2fab718c2f4cd8913ab8890.zip
More signess consistency on the reading and seeking methods
svn-id: r41771
Diffstat (limited to 'engines/gob')
-rw-r--r--engines/gob/script.cpp21
-rw-r--r--engines/gob/script.h8
2 files changed, 17 insertions, 12 deletions
diff --git a/engines/gob/script.cpp b/engines/gob/script.cpp
index e4808cf9ce..de7f0095a4 100644
--- a/engines/gob/script.cpp
+++ b/engines/gob/script.cpp
@@ -52,8 +52,11 @@ Script::~Script() {
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;
@@ -61,15 +64,17 @@ uint32 Script::read(byte *data, uint32 size) {
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 @@ bool Script::seek(int32 offset, int whence) {
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;
}
diff --git a/engines/gob/script.h b/engines/gob/script.h
index 28d8483272..52f322f1f4 100644
--- a/engines/gob/script.h
+++ b/engines/gob/script.h
@@ -40,9 +40,9 @@ public:
~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 @@ public:
// 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 @@ public:
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();