aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2008-09-13 16:51:46 +0000
committerMax Horn2008-09-13 16:51:46 +0000
commit655ce26b3f09628d9408a4d82efe3a26116999fe (patch)
tree779a25dbe25c8f916fb385b3dd2d48e0e379d9ec
parentb86a047164b54c20366fcbe21b55bf63f2ced5f4 (diff)
downloadscummvm-rg350-655ce26b3f09628d9408a4d82efe3a26116999fe.tar.gz
scummvm-rg350-655ce26b3f09628d9408a4d82efe3a26116999fe.tar.bz2
scummvm-rg350-655ce26b3f09628d9408a4d82efe3a26116999fe.zip
Big patch changing the signature of various Stream methods (some ports may need to be slightly tweaked to fix overloading errors/warnings)
svn-id: r34514
-rw-r--r--backends/fs/stdiostream.cpp30
-rw-r--r--backends/fs/stdiostream.h8
-rw-r--r--backends/fs/symbian/symbianstream.cpp59
-rw-r--r--backends/fs/symbian/symbianstream.h8
-rw-r--r--backends/platform/dc/vmsave.cpp14
-rw-r--r--backends/platform/ds/arm9/source/gbampsave.cpp10
-rw-r--r--backends/platform/ds/arm9/source/gbampsave.h8
-rw-r--r--backends/platform/ds/arm9/source/ramsave.cpp10
-rw-r--r--backends/platform/ds/arm9/source/ramsave.h8
-rw-r--r--backends/platform/ps2/savefile.cpp23
-rw-r--r--backends/platform/ps2/savefile.h20
-rw-r--r--backends/saves/compressed/compressed-saves.cpp10
-rw-r--r--common/file.cpp28
-rw-r--r--common/file.h8
-rw-r--r--common/stream.cpp12
-rw-r--r--common/stream.h66
-rw-r--r--common/unarj.cpp8
-rw-r--r--common/unarj.h6
-rw-r--r--engines/agi/sound.cpp4
-rw-r--r--engines/agi/wagparser.h4
-rw-r--r--engines/cine/texte.cpp2
-rw-r--r--engines/cine/various.cpp2
-rw-r--r--engines/gob/dataio.cpp20
-rw-r--r--engines/gob/dataio.h6
-rw-r--r--engines/gob/saveload.cpp2
-rw-r--r--engines/kyra/resource.cpp2
-rw-r--r--engines/kyra/resource_intern.cpp26
-rw-r--r--engines/kyra/script.cpp8
-rw-r--r--engines/kyra/vqa.cpp4
-rw-r--r--engines/m4/converse.cpp4
-rw-r--r--engines/m4/midi.cpp2
-rw-r--r--engines/parallaction/disk.h6
-rw-r--r--engines/parallaction/disk_ns.cpp24
-rw-r--r--engines/saga/rscfile.cpp6
-rw-r--r--engines/scumm/file.cpp16
-rw-r--r--engines/scumm/file.h29
-rw-r--r--engines/scumm/file_nes.cpp6
-rw-r--r--engines/scumm/file_nes.h6
-rw-r--r--engines/scumm/smush/chunk.cpp8
-rw-r--r--engines/scumm/smush/chunk.h6
-rw-r--r--engines/scumm/smush/smush_player.cpp2
-rw-r--r--engines/scumm/smush/smush_player.h2
-rw-r--r--engines/sword1/music.cpp2
-rw-r--r--engines/sword2/sound.h2
-rw-r--r--engines/tinsel/sound.cpp4
-rw-r--r--engines/tinsel/sound.h2
-rw-r--r--sound/adpcm.cpp2
-rw-r--r--sound/flac.cpp2
-rw-r--r--sound/mods/infogrames.cpp8
-rw-r--r--sound/wave.cpp4
50 files changed, 289 insertions, 270 deletions
diff --git a/backends/fs/stdiostream.cpp b/backends/fs/stdiostream.cpp
index f3f20eacb5..fafcca989b 100644
--- a/backends/fs/stdiostream.cpp
+++ b/backends/fs/stdiostream.cpp
@@ -126,43 +126,33 @@ bool StdioStream::eos() const {
return feof((FILE *)_handle) != 0;
}
-uint32 StdioStream::pos() const {
- // FIXME: ftell can return -1 to indicate an error (in which case errno gets set)
- // Maybe we should support that, too?
+int32 StdioStream::pos() const {
return ftell((FILE *)_handle);
}
-uint32 StdioStream::size() const {
- uint32 oldPos = ftell((FILE *)_handle);
+int32 StdioStream::size() const {
+ int32 oldPos = ftell((FILE *)_handle);
fseek((FILE *)_handle, 0, SEEK_END);
- uint32 length = ftell((FILE *)_handle);
+ int32 length = ftell((FILE *)_handle);
fseek((FILE *)_handle, oldPos, SEEK_SET);
return length;
}
-void StdioStream::seek(int32 offs, int whence) {
- assert(_handle);
-
- if (fseek((FILE *)_handle, offs, whence) != 0)
- clearerr((FILE *)_handle); // FIXME: why do we call clearerr here?
-
- // FIXME: fseek has a return value to indicate errors;
- // Maybe we should support that, too?
+bool StdioStream::seek(int32 offs, int whence) {
+ return fseek((FILE *)_handle, offs, whence) == 0;
}
uint32 StdioStream::read(void *ptr, uint32 len) {
- return (uint32)fread((byte *)ptr, 1, len, (FILE *)_handle);
+ return fread((byte *)ptr, 1, len, (FILE *)_handle);
}
uint32 StdioStream::write(const void *ptr, uint32 len) {
- return (uint32)fwrite(ptr, 1, len, (FILE *)_handle);
+ return fwrite(ptr, 1, len, (FILE *)_handle);
}
-void StdioStream::flush() {
- // TODO: Should check the return value of fflush, and if it is non-zero,
- // check errno and set an error flag.
- fflush((FILE *)_handle);
+bool StdioStream::flush() {
+ return fflush((FILE *)_handle) == 0;
}
StdioStream *StdioStream::makeFromPath(const Common::String &path, bool writeMode) {
diff --git a/backends/fs/stdiostream.h b/backends/fs/stdiostream.h
index 02e5463f63..f40ddd9867 100644
--- a/backends/fs/stdiostream.h
+++ b/backends/fs/stdiostream.h
@@ -51,11 +51,11 @@ public:
bool eos() const;
virtual uint32 write(const void *dataPtr, uint32 dataSize);
- virtual void flush();
+ virtual bool flush();
- virtual uint32 pos() const;
- virtual uint32 size() const;
- void seek(int32 offs, int whence = SEEK_SET);
+ virtual int32 pos() const;
+ virtual int32 size() const;
+ bool seek(int32 offs, int whence = SEEK_SET);
uint32 read(void *dataPtr, uint32 dataSize);
};
diff --git a/backends/fs/symbian/symbianstream.cpp b/backends/fs/symbian/symbianstream.cpp
index 61fc5a04fb..4d2ec11ab3 100644
--- a/backends/fs/symbian/symbianstream.cpp
+++ b/backends/fs/symbian/symbianstream.cpp
@@ -104,10 +104,9 @@ size_t ReadData(const void* ptr, size_t size, size_t numItems, TSymbianFileEntry
TPtr8 pointer ( (unsigned char*) ptr, totsize);
// Nothing cached and we want to load at least KInputBufferLength bytes
- if(totsize >= KInputBufferLength) {
+ if (totsize >= KInputBufferLength) {
TUint32 totLength = 0;
- if(entry->_inputPos != KErrNotFound)
- {
+ if (entry->_inputPos != KErrNotFound) {
TPtr8 cacheBuffer( (unsigned char*) entry->_inputBuffer+entry->_inputPos, entry->_inputBufferLen - entry->_inputPos, KInputBufferLength);
pointer.Append(cacheBuffer);
entry->_inputPos = KErrNotFound;
@@ -121,44 +120,39 @@ size_t ReadData(const void* ptr, size_t size, size_t numItems, TSymbianFileEntry
pointer.Set((unsigned char*) ptr, totLength, totsize);
- }
- else {
+ } else {
// Nothing in buffer
- if(entry->_inputPos == KErrNotFound) {
+ if (entry->_inputPos == KErrNotFound) {
TPtr8 cacheBuffer( (unsigned char*) entry->_inputBuffer, KInputBufferLength);
entry->_lastError = entry->_fileHandle.Read(cacheBuffer);
- if(cacheBuffer.Length() >= totsize) {
+ if (cacheBuffer.Length() >= totsize) {
pointer.Copy(cacheBuffer.Left(totsize));
entry->_inputPos = totsize;
entry->_inputBufferLen = cacheBuffer.Length();
- }
- else {
+ } else {
pointer.Copy(cacheBuffer);
entry->_inputPos = KErrNotFound;
}
- }
- else {
+ } else {
TPtr8 cacheBuffer( (unsigned char*) entry->_inputBuffer, entry->_inputBufferLen, KInputBufferLength);
- if(entry->_inputPos+totsize < entry->_inputBufferLen) {
+ if (entry->_inputPos+totsize < entry->_inputBufferLen) {
pointer.Copy(cacheBuffer.Mid(entry->_inputPos, totsize));
entry->_inputPos+=totsize;
- }
- else {
+ } else {
pointer.Copy(cacheBuffer.Mid(entry->_inputPos, entry->_inputBufferLen-entry->_inputPos));
cacheBuffer.SetLength(0);
entry->_lastError = entry->_fileHandle.Read(cacheBuffer);
- if(cacheBuffer.Length() >= totsize-pointer.Length()) {
+ if (cacheBuffer.Length() >= totsize-pointer.Length()) {
TUint32 restSize = totsize-pointer.Length();
pointer.Append(cacheBuffer.Left(restSize));
entry->_inputPos = restSize;
entry->_inputBufferLen = cacheBuffer.Length();
- }
- else {
+ } else {
pointer.Append(cacheBuffer);
entry->_inputPos = KErrNotFound;
}
@@ -166,7 +160,7 @@ size_t ReadData(const void* ptr, size_t size, size_t numItems, TSymbianFileEntry
}
}
- if((numItems * size) != pointer.Length() && entry->_lastError == KErrNone) {
+ if((numItems * size) != pointer.Length() && entry->_lastError == KErrNone) {
entry->_eofReached = ETrue;
}
@@ -197,20 +191,19 @@ bool SymbianStdioStream::eos() const {
return entry->_eofReached != 0;
}
-uint32 SymbianStdioStream::pos() const {
+int32 SymbianStdioStream::pos() const {
TInt pos = 0;
TSymbianFileEntry* entry = ((TSymbianFileEntry*)(_handle));
entry->_lastError = entry->_fileHandle.Seek(ESeekCurrent, pos);
- if(entry->_lastError == KErrNone && entry->_inputPos != KErrNotFound)
- {
- pos+=(entry->_inputPos - entry->_inputBufferLen);
- }
+ if (entry->_lastError == KErrNone && entry->_inputPos != KErrNotFound) {
+ pos += (entry->_inputPos - entry->_inputBufferLen);
+ }
return pos;
}
-uint32 SymbianStdioStream::size() const {
+int32 SymbianStdioStream::size() const {
TInt length = 0;
((TSymbianFileEntry*)(_handle))->_fileHandle.Size(length);
@@ -218,21 +211,21 @@ uint32 SymbianStdioStream::size() const {
return length;
}
-void SymbianStdioStream::seek(int32 offs, int whence) {
+bool SymbianStdioStream::seek(int32 offs, int whence) {
assert(_handle);
TSeek seekMode = ESeekStart;
TInt pos = offs;
TSymbianFileEntry* entry = ((TSymbianFileEntry*)(_handle));
- switch(whence) {
+ switch (whence) {
case SEEK_SET:
seekMode = ESeekStart;
break;
case SEEK_CUR:
seekMode = ESeekCurrent;
- if(entry->_inputPos != KErrNotFound) {
- pos+=(entry->_inputPos - entry->_inputBufferLen);
+ if (entry->_inputPos != KErrNotFound) {
+ pos += (entry->_inputPos - entry->_inputBufferLen);
}
break;
case SEEK_END:
@@ -243,10 +236,9 @@ void SymbianStdioStream::seek(int32 offs, int whence) {
entry->_inputPos = KErrNotFound;
entry->_eofReached = EFalse;
- if (entry->_fileHandle.Seek(seekMode, pos) != 0)
- {
- ((TSymbianFileEntry *)(_handle))->_lastError = 0; // FIXME: why do we call clearerr here?
- }
+ entry->_fileHandle.Seek(seekMode, pos);
+
+ return true; // FIXME: Probably should return a value based on what _fileHandle.Seek returns
}
uint32 SymbianStdioStream::read(void *ptr, uint32 len) {
@@ -267,8 +259,9 @@ uint32 SymbianStdioStream::write(const void *ptr, uint32 len) {
return 0;
}
-void SymbianStdioStream::flush() {
+bool SymbianStdioStream::flush() {
((TSymbianFileEntry*)(_handle))->_fileHandle.Flush();
+ return true;
}
SymbianStdioStream *SymbianStdioStream::makeFromPath(const Common::String &path, bool writeMode) {
diff --git a/backends/fs/symbian/symbianstream.h b/backends/fs/symbian/symbianstream.h
index 776446c5f5..180e6bffcb 100644
--- a/backends/fs/symbian/symbianstream.h
+++ b/backends/fs/symbian/symbianstream.h
@@ -51,11 +51,11 @@ public:
bool eos() const;
virtual uint32 write(const void *dataPtr, uint32 dataSize);
- virtual void flush();
+ virtual bool flush();
- virtual uint32 pos() const;
- virtual uint32 size() const;
- void seek(int32 offs, int whence = SEEK_SET);
+ virtual int32 pos() const;
+ virtual int32 size() const;
+ bool seek(int32 offs, int whence = SEEK_SET);
uint32 read(void *dataPtr, uint32 dataSize);
};
diff --git a/backends/platform/dc/vmsave.cpp b/backends/platform/dc/vmsave.cpp
index 6ab8fc4558..5fe532e1f1 100644
--- a/backends/platform/dc/vmsave.cpp
+++ b/backends/platform/dc/vmsave.cpp
@@ -271,8 +271,8 @@ private:
int _pos, _size;
uint32 read(void *buf, uint32 cnt);
- void skip(uint32 offset);
- void seek(int32 offs, int whence);
+ bool skip(uint32 offset);
+ bool seek(int32 offs, int whence);
public:
InVMSave()
@@ -286,8 +286,8 @@ public:
}
bool eos() const { return _pos >= _size; }
- uint32 pos() const { return _pos; }
- uint32 size() const { return _size; }
+ int32 pos() const { return _pos; }
+ int32 size() const { return _size; }
bool readSaveGame(const char *filename)
{ return ::readSaveGame(buffer, _size, filename); }
@@ -378,15 +378,16 @@ uint32 InVMSave::read(void *buf, uint32 cnt)
return cnt;
}
-void InVMSave::skip(uint32 offset)
+bool InVMSave::skip(uint32 offset)
{
int nbyt = offset;
if (_pos + nbyt > _size)
nbyt = (_size - _pos);
_pos += nbyt;
+ return true;
}
-void InVMSave::seek(int32 offs, int whence)
+bool InVMSave::seek(int32 offs, int whence)
{
switch(whence) {
case SEEK_SET:
@@ -403,6 +404,7 @@ void InVMSave::seek(int32 offs, int whence)
_pos = 0;
else if (_pos > _size)
_pos = _size;
+ return true;
}
uint32 OutVMSave::write(const void *buf, uint32 cnt)
diff --git a/backends/platform/ds/arm9/source/gbampsave.cpp b/backends/platform/ds/arm9/source/gbampsave.cpp
index 9c8af81a6e..8209b783fa 100644
--- a/backends/platform/ds/arm9/source/gbampsave.cpp
+++ b/backends/platform/ds/arm9/source/gbampsave.cpp
@@ -54,8 +54,8 @@ bool GBAMPSaveFile::eos() const {
return DS::std_feof(handle);
}
-void GBAMPSaveFile::skip(uint32 bytes) {
- DS::std_fseek(handle, bytes, SEEK_CUR);
+bool GBAMPSaveFile::skip(uint32 bytes) {
+ return DS::std_fseek(handle, bytes, SEEK_CUR) == 0;
}
void GBAMPSaveFile::flushSaveBuffer() {
@@ -67,11 +67,11 @@ void GBAMPSaveFile::flushSaveBuffer() {
}
}
-uint32 GBAMPSaveFile::pos() const {
+int32 GBAMPSaveFile::pos() const {
return DS::std_ftell(handle);
}
-uint32 GBAMPSaveFile::size() const {
+int32 GBAMPSaveFile::size() const {
int position = pos();
DS::std_fseek(handle, 0, SEEK_END);
int size = DS::std_ftell(handle);
@@ -80,7 +80,7 @@ uint32 GBAMPSaveFile::size() const {
}
void GBAMPSaveFile::seek(int32 pos, int whence) {
- DS::std_fseek(handle, pos, whence);
+ return DS::std_fseek(handle, pos, whence) == 0;
}
diff --git a/backends/platform/ds/arm9/source/gbampsave.h b/backends/platform/ds/arm9/source/gbampsave.h
index d0cbc68bfd..6ddc4fd964 100644
--- a/backends/platform/ds/arm9/source/gbampsave.h
+++ b/backends/platform/ds/arm9/source/gbampsave.h
@@ -43,11 +43,11 @@ public:
virtual uint32 write(const void *buf, uint32 size);
virtual bool eos() const;
- virtual void skip(uint32 bytes);
+ virtual bool skip(uint32 bytes);
- virtual uint32 pos() const;
- virtual uint32 size() const;
- virtual void seek(int32 pos, int whence);
+ virtual int32 pos() const;
+ virtual int32 size() const;
+ virtual bool seek(int32 pos, int whence);
void flushSaveBuffer();
diff --git a/backends/platform/ds/arm9/source/ramsave.cpp b/backends/platform/ds/arm9/source/ramsave.cpp
index be355ce76f..8442fd6b88 100644
--- a/backends/platform/ds/arm9/source/ramsave.cpp
+++ b/backends/platform/ds/arm9/source/ramsave.cpp
@@ -181,15 +181,15 @@ uint32 DSSaveFile::read(void *buf, uint32 size) {
return size;
}
-uint32 DSSaveFile::pos() const {
+int32 DSSaveFile::pos() const {
return ptr;
}
-uint32 DSSaveFile::size() const {
+int32 DSSaveFile::size() const {
return save.size;
}
-void DSSaveFile::seek(int32 pos, int whence) {
+bool DSSaveFile::seek(int32 pos, int whence) {
switch (whence) {
case SEEK_SET: {
ptr = pos;
@@ -204,15 +204,17 @@ void DSSaveFile::seek(int32 pos, int whence) {
break;
}
}
+ return true;
}
bool DSSaveFile::eos() const {
return ptr >= (int) save.size;
}
-void DSSaveFile::skip(uint32 bytes) {
+bool DSSaveFile::skip(uint32 bytes) {
ptr = ptr + bytes;
if (ptr > (int) save.size) ptr = save.size;
+ return true;
}
uint32 DSSaveFile::write(const void *buf, uint32 size) {
diff --git a/backends/platform/ds/arm9/source/ramsave.h b/backends/platform/ds/arm9/source/ramsave.h
index f919da18db..e276775b66 100644
--- a/backends/platform/ds/arm9/source/ramsave.h
+++ b/backends/platform/ds/arm9/source/ramsave.h
@@ -62,11 +62,11 @@ public:
bool isOpen() const { return isOpenFlag; }
virtual bool eos() const;
- virtual void skip(uint32 size);
+ virtual bool skip(uint32 size);
- virtual uint32 pos() const;
- virtual uint32 size() const;
- virtual void seek(int32 pos, int whence);
+ virtual int32 pos() const;
+ virtual int32 size() const;
+ virtual bool seek(int32 pos, int whence);
uint32 read(void *buf, uint32 size);
uint32 write(const void *buf, uint32 size);
diff --git a/backends/platform/ps2/savefile.cpp b/backends/platform/ps2/savefile.cpp
index 5ee724cd3f..7d45aabda7 100644
--- a/backends/platform/ps2/savefile.cpp
+++ b/backends/platform/ps2/savefile.cpp
@@ -112,24 +112,26 @@ bool UclInSaveFile::eos(void) const {
return bufTell() == bufSize();
}
-uint32 UclInSaveFile::pos(void) const {
+int32 UclInSaveFile::pos(void) const {
return bufTell();
}
-uint32 UclInSaveFile::size(void) const {
+int32 UclInSaveFile::size(void) const {
return bufSize();
}
-void UclInSaveFile::seek(int pos, int whence) {
+bool UclInSaveFile::seek(int pos, int whence) {
bufSeek(pos, whence);
+ return true;
}
uint32 UclInSaveFile::read(void *ptr, uint32 size) {
return (uint32)bufRead(ptr, (int)size);
}
-void UclInSaveFile::skip(uint32 offset) {
+bool UclInSaveFile::skip(uint32 offset) {
bufSeek(offset, SEEK_CUR);
+ return true;s
}
UclOutSaveFile::UclOutSaveFile(const char *filename, OSystem_PS2 *system, Gs2dScreen *screen, McAccess *mc) : RawWriteFile(mc) {
@@ -168,12 +170,12 @@ void UclOutSaveFile::clearIOFailed(void) {
_ioFailed = false;
}
-void UclOutSaveFile::flush(void) {
+bool UclOutSaveFile::flush(void) {
if (_pos != 0) {
if (_wasFlushed) {
printf("Multiple calls to UclOutSaveFile::flush!\n");
_ioFailed = true;
- return;
+ return false;
}
uint32 compSize = _pos * 2;
uint8 *compBuf = (uint8*)memalign(64, compSize + 8);
@@ -193,6 +195,7 @@ void UclOutSaveFile::flush(void) {
}
_wasFlushed = true;
}
+ return true;
}
/* ----------------------------------------- Glue Classes for POSIX Memory Card Access ----------------------------------------- */
@@ -216,11 +219,11 @@ uint32 Ps2McReadFile::write(const void *src, uint32 len) {
return 0;
}
-uint32 Ps2McReadFile::tell(void) {
+int32 Ps2McReadFile::tell(void) {
return bufTell();
}
-uint32 Ps2McReadFile::size(void) {
+int32 Ps2McReadFile::size(void) {
return bufSize();
}
@@ -253,11 +256,11 @@ uint32 Ps2McWriteFile::write(const void *src, uint32 len) {
return len;
}
-uint32 Ps2McWriteFile::tell(void) {
+int32 Ps2McWriteFile::tell(void) {
return bufTell();
}
-uint32 Ps2McWriteFile::size(void) {
+int32 Ps2McWriteFile::size(void) {
return bufTell();
}
diff --git a/backends/platform/ps2/savefile.h b/backends/platform/ps2/savefile.h
index 4832b8c3fe..fd09c823d0 100644
--- a/backends/platform/ps2/savefile.h
+++ b/backends/platform/ps2/savefile.h
@@ -41,7 +41,7 @@ public:
UclOutSaveFile(const char *filename, OSystem_PS2 *system, Gs2dScreen *screen, McAccess *mc);
virtual ~UclOutSaveFile(void);
virtual uint32 write(const void *ptr, uint32 size);
- virtual void flush(void);
+ virtual bool flush(void);
virtual bool ioFailed(void) const;
virtual void clearIOFailed(void);
private:
@@ -60,11 +60,11 @@ public:
virtual uint32 read(void *ptr, uint32 size);
virtual bool ioFailed(void) const;
virtual void clearIOFailed(void);
- virtual void skip(uint32 offset);
+ virtual bool skip(uint32 offset);
- virtual uint32 pos(void) const;
- virtual uint32 size(void) const;
- virtual void seek(int pos, int whence = SEEK_SET);
+ virtual int32 pos(void) const;
+ virtual int32 size(void) const;
+ virtual bool seek(int pos, int whence = SEEK_SET);
private:
Gs2dScreen *_screen;
bool _ioFailed;
@@ -75,7 +75,7 @@ public:
AutoSaveFile(Ps2SaveFileManager *saveMan, const char *filename);
~AutoSaveFile(void);
virtual uint32 write(const void *ptr, uint32 size);
- virtual void flush(void) {}
+ virtual bool flush(void) {}
virtual bool ioFailed(void) { return false; };
virtual void clearIOFailed(void) {}
private:
@@ -95,8 +95,8 @@ public:
virtual bool open(const char *name);
virtual uint32 read(void *dest, uint32 len);
virtual uint32 write(const void *src, uint32 len);
- virtual uint32 tell(void);
- virtual uint32 size(void);
+ virtual int32 tell(void);
+ virtual int32 size(void);
virtual int seek(int32 offset, int origin);
virtual bool eof(void);
};
@@ -108,8 +108,8 @@ public:
virtual bool open(const char *name);
virtual uint32 read(void *dest, uint32 len);
virtual uint32 write(const void *src, uint32 len);
- virtual uint32 tell(void);
- virtual uint32 size(void);
+ virtual int32 tell(void);
+ virtual int32 size(void);
virtual int seek(int32 offset, int origin);
virtual bool eof(void);
};
diff --git a/backends/saves/compressed/compressed-saves.cpp b/backends/saves/compressed/compressed-saves.cpp
index 0c4fec0e24..27b8749911 100644
--- a/backends/saves/compressed/compressed-saves.cpp
+++ b/backends/saves/compressed/compressed-saves.cpp
@@ -125,13 +125,13 @@ public:
return (_zlibErr == Z_STREAM_END);
//return _pos == _origSize;
}
- uint32 pos() const {
+ int32 pos() const {
return _pos;
}
- uint32 size() const {
+ int32 size() const {
return _origSize;
}
- void seek(int32 offset, int whence = SEEK_SET) {
+ bool seek(int32 offset, int whence = SEEK_SET) {
int32 newPos = 0;
assert(whence != SEEK_END); // SEEK_END not supported
switch(whence) {
@@ -155,7 +155,7 @@ public:
_wrapped->seek(0, SEEK_SET);
_zlibErr = inflateReset(&_stream);
if (_zlibErr != Z_OK)
- return;
+ return false; // FIXME: STREAM REWRITE
_stream.next_in = _buf;
_stream.avail_in = 0;
}
@@ -169,6 +169,8 @@ public:
while (!ioFailed() && offset > 0) {
offset -= read(tmpBuf, MIN((int32)sizeof(tmpBuf), offset));
}
+
+ return true; // FIXME: STREAM REWRITE
}
};
diff --git a/common/file.cpp b/common/file.cpp
index ba94cb285a..1297775f15 100644
--- a/common/file.cpp
+++ b/common/file.cpp
@@ -113,13 +113,7 @@ bool File::open(const FilesystemNode &node) {
} else if (node.isDirectory()) {
warning("File::open: Trying to open a FilesystemNode which is a directory");
return false;
- } /*else if (!node.isReadable() && mode == kFileReadMode) {
- warning("File::open: Trying to open an unreadable FilesystemNode object for reading");
- return false;
- } else if (!node.isWritable() && mode == kFileWriteMode) {
- warning("File::open: Trying to open an unwritable FilesystemNode object for writing");
- return false;
- }*/
+ }
String filename(node.getName());
@@ -181,19 +175,19 @@ bool File::eos() const {
return _handle->eos();
}
-uint32 File::pos() const {
+int32 File::pos() const {
assert(_handle);
return _handle->pos();
}
-uint32 File::size() const {
+int32 File::size() const {
assert(_handle);
return _handle->size();
}
-void File::seek(int32 offs, int whence) {
+bool File::seek(int32 offs, int whence) {
assert(_handle);
- _handle->seek(offs, whence);
+ return _handle->seek(offs, whence);
}
uint32 File::read(void *ptr, uint32 len) {
@@ -223,13 +217,7 @@ bool DumpFile::open(const FilesystemNode &node) {
if (node.isDirectory()) {
warning("File::open: Trying to open a FilesystemNode which is a directory");
return false;
- } /*else if (!node.isReadable() && mode == kFileReadMode) {
- warning("File::open: Trying to open an unreadable FilesystemNode object for reading");
- return false;
- } else if (!node.isWritable() && mode == kFileWriteMode) {
- warning("File::open: Trying to open an unwritable FilesystemNode object for writing");
- return false;
- }*/
+ }
_handle = node.openForWriting();
@@ -263,9 +251,9 @@ uint32 DumpFile::write(const void *ptr, uint32 len) {
return _handle->write(ptr, len);
}
-void DumpFile::flush() {
+bool DumpFile::flush() {
assert(_handle);
- _handle->flush();
+ return _handle->flush();
}
} // End of namespace Common
diff --git a/common/file.h b/common/file.h
index 4b7674584d..b4cadd7256 100644
--- a/common/file.h
+++ b/common/file.h
@@ -92,9 +92,9 @@ public:
void clearIOFailed();
bool eos() const;
- virtual uint32 pos() const;
- virtual uint32 size() const;
- void seek(int32 offs, int whence = SEEK_SET);
+ virtual int32 pos() const;
+ virtual int32 size() const;
+ bool seek(int32 offs, int whence = SEEK_SET);
uint32 read(void *dataPtr, uint32 dataSize);
};
@@ -132,7 +132,7 @@ public:
virtual uint32 write(const void *dataPtr, uint32 dataSize);
- virtual void flush();
+ virtual bool flush();
};
} // End of namespace Common
diff --git a/common/stream.cpp b/common/stream.cpp
index d866fe0b5a..1ddaa17575 100644
--- a/common/stream.cpp
+++ b/common/stream.cpp
@@ -60,7 +60,7 @@ uint32 MemoryReadStream::read(void *dataPtr, uint32 dataSize) {
return dataSize;
}
-void MemoryReadStream::seek(int32 offs, int whence) {
+bool MemoryReadStream::seek(int32 offs, int whence) {
// Pre-Condition
assert(_pos <= _size);
switch (whence) {
@@ -81,6 +81,8 @@ void MemoryReadStream::seek(int32 offs, int whence) {
}
// Post-Condition
assert(_pos <= _size);
+
+ return true; // FIXME: STREAM REWRITE
}
#define LF 0x0A
@@ -241,7 +243,7 @@ SeekableSubReadStream::SeekableSubReadStream(SeekableReadStream *parentStream, u
_parentStream->seek(_pos);
}
-void SeekableSubReadStream::seek(int32 offset, int whence) {
+bool SeekableSubReadStream::seek(int32 offset, int whence) {
assert(_pos >= _begin);
assert(_pos <= _end);
@@ -259,7 +261,7 @@ void SeekableSubReadStream::seek(int32 offset, int whence) {
assert(_pos >= _begin);
assert(_pos <= _end);
- _parentStream->seek(_pos);
+ return _parentStream->seek(_pos);
}
BufferedReadStream::BufferedReadStream(ReadStream *parentStream, uint32 bufSize, bool disposeParentStream)
@@ -324,7 +326,7 @@ BufferedSeekableReadStream::BufferedSeekableReadStream(SeekableReadStream *paren
_parentStream(parentStream) {
}
-void BufferedSeekableReadStream::seek(int32 offset, int whence) {
+bool BufferedSeekableReadStream::seek(int32 offset, int whence) {
// If it is a "local" seek, we may get away with "seeking" around
// in the buffer only.
// Note: We could try to handle SEEK_END and SEEK_SET, too, but
@@ -339,6 +341,8 @@ void BufferedSeekableReadStream::seek(int32 offset, int whence) {
_pos = _bufSize;
_parentStream->seek(offset, whence);
}
+
+ return true; // FIXME: STREAM REWRITE
}
} // End of namespace Common
diff --git a/common/stream.h b/common/stream.h
index babb00e706..de7f1fedf6 100644
--- a/common/stream.h
+++ b/common/stream.h
@@ -75,8 +75,10 @@ public:
* Commit any buffered data to the underlying channel or
* storage medium; unbuffered streams can use the default
* implementation.
+ *
+ * @return true on success, false in case of a failure
*/
- virtual void flush() {}
+ virtual bool flush() { return true; }
/**
* Finalize and close this stream. To be called right before this
@@ -85,7 +87,7 @@ public:
* closing (and this flushing, if buffered) the stream.
*
* After this method has been called, no further writes may be
- * peformed on the stream. Calling ioFailed() is allowed.
+ * performed on the stream. Calling ioFailed() is allowed.
*
* By default, this just flushes the stream.
*/
@@ -303,18 +305,46 @@ public:
/**
* Interface for a seekable & readable data stream.
*
- * @todo We really need better error handling here!
- * Like seek should somehow indicate whether it failed.
+ * @todo Get rid of SEEK_SET, SEEK_CUR, or SEEK_END, use our own constants
*/
class SeekableReadStream : virtual public ReadStream {
public:
- virtual uint32 pos() const = 0;
- virtual uint32 size() const = 0;
+ /**
+ * Obtains the current value of the stream position indicator of the
+ * stream.
+ *
+ * @return the current position indicator, or -1 if an error occurred.
+ */
+ virtual int32 pos() const = 0;
- virtual void seek(int32 offset, int whence = SEEK_SET) = 0;
+ /**
+ * Obtains the total size of the stream, measured in bytes.
+ * If this value is unknown or can not be computed, -1 is returned.
+ *
+ * @return the size of the stream, or -1 if an error occurred
+ */
+ virtual int32 size() const = 0;
- void skip(uint32 offset) { seek(offset, SEEK_CUR); }
+ /**
+ * Sets the stream position indicator for the stream. The new position,
+ * measured in bytes, is obtained by adding offset bytes to the position
+ * specified by whence. If whence is set to SEEK_SET, SEEK_CUR, or
+ * SEEK_END, the offset is relative to the start of the file, the current
+ * position indicator, or end-of-file, respectively. A successful call
+ * to the seek() method clears the end-of-file indicator for the stream.
+ *
+ * @param offset the relative offset in bytes
+ * @param whence the seek reference: SEEK_SET, SEEK_CUR, or SEEK_END
+ * @return true on success, false in case of a failure
+ */
+ virtual bool seek(int32 offset, int whence = SEEK_SET) = 0;
+
+ /**
+ * TODO: Get rid of this??? Or keep it and document it
+ * @return true on success, false in case of a failure
+ */
+ virtual bool skip(uint32 offset) { return seek(offset, SEEK_CUR); }
/**
* DEPRECATED: Do not use this method! Instead use readLine_NEW() or readline().
@@ -401,10 +431,10 @@ protected:
public:
SeekableSubReadStream(SeekableReadStream *parentStream, uint32 begin, uint32 end, bool disposeParentStream = false);
- virtual uint32 pos() const { return _pos - _begin; }
- virtual uint32 size() const { return _end - _begin; }
+ virtual int32 pos() const { return _pos - _begin; }
+ virtual int32 size() const { return _end - _begin; }
- virtual void seek(int32 offset, int whence = SEEK_SET);
+ virtual bool seek(int32 offset, int whence = SEEK_SET);
};
/**
@@ -471,10 +501,10 @@ protected:
public:
BufferedSeekableReadStream(SeekableReadStream *parentStream, uint32 bufSize, bool disposeParentStream = false);
- virtual uint32 pos() const { return _parentStream->pos() - (_bufSize - _pos); }
- virtual uint32 size() const { return _parentStream->size(); }
+ virtual int32 pos() const { return _parentStream->pos() - (_bufSize - _pos); }
+ virtual int32 size() const { return _parentStream->size(); }
- virtual void seek(int32 offset, int whence = SEEK_SET);
+ virtual bool seek(int32 offset, int whence = SEEK_SET);
};
@@ -516,11 +546,11 @@ public:
uint32 read(void *dataPtr, uint32 dataSize);
- bool eos() const { return _pos == _size; }
- uint32 pos() const { return _pos; }
- uint32 size() const { return _size; }
+ bool eos() const { return _pos == _size; } // FIXME: Wrong
+ int32 pos() const { return _pos; }
+ int32 size() const { return _size; }
- void seek(int32 offs, int whence = SEEK_SET);
+ bool seek(int32 offs, int whence = SEEK_SET);
};
diff --git a/common/unarj.cpp b/common/unarj.cpp
index 9a7766a41f..13ff0fd673 100644
--- a/common/unarj.cpp
+++ b/common/unarj.cpp
@@ -320,16 +320,16 @@ bool ArjFile::eos() {
return _uncompressed->eos();
}
-uint32 ArjFile::pos() {
+int32 ArjFile::pos() {
return _uncompressed->pos();
}
-uint32 ArjFile::size() {
+int32 ArjFile::size() {
return _uncompressed->size();
}
-void ArjFile::seek(int32 offset, int whence) {
- _uncompressed->seek(offset, whence);
+bool ArjFile::seek(int32 offset, int whence) {
+ return _uncompressed->seek(offset, whence);
}
void ArjFile::init_getbits() {
diff --git a/common/unarj.h b/common/unarj.h
index c8965968f6..bc9575fdc2 100644
--- a/common/unarj.h
+++ b/common/unarj.h
@@ -115,9 +115,9 @@ public:
uint32 read(void *dataPtr, uint32 dataSize);
bool eos();
- uint32 pos();
- uint32 size();
- void seek(int32 offset, int whence = SEEK_SET);
+ int32 pos();
+ int32 size();
+ bool seek(int32 offset, int whence = SEEK_SET);
bool isOpen() { return _isOpen; }
private:
diff --git a/engines/agi/sound.cpp b/engines/agi/sound.cpp
index 1312dd414d..3b28e75c56 100644
--- a/engines/agi/sound.cpp
+++ b/engines/agi/sound.cpp
@@ -1013,7 +1013,7 @@ bool IIgsSoundMgr::loadInstrumentHeaders(const Common::String &exePath, const II
// Open the executable file and check that it has correct size
file.open(exePath);
- if (file.size() != exeInfo.exeSize) {
+ if (file.size() != (int32)exeInfo.exeSize) {
debugC(3, kDebugLevelSound, "Apple IIGS executable (%s) has wrong size (Is %d, should be %d)",
exePath.c_str(), file.size(), exeInfo.exeSize);
}
@@ -1023,7 +1023,7 @@ bool IIgsSoundMgr::loadInstrumentHeaders(const Common::String &exePath, const II
file.close();
// Check that we got enough data to be able to parse the instruments
- if (data && data->size() >= (exeInfo.instSetStart + exeInfo.instSet.byteCount)) {
+ if (data && data->size() >= (int32)(exeInfo.instSetStart + exeInfo.instSet.byteCount)) {
// Check instrument set's length (The info's saved in the executable)
data->seek(exeInfo.instSetStart - 4);
uint16 instSetByteCount = data->readUint16LE();
diff --git a/engines/agi/wagparser.h b/engines/agi/wagparser.h
index 2f4003315f..827720ac85 100644
--- a/engines/agi/wagparser.h
+++ b/engines/agi/wagparser.h
@@ -201,7 +201,9 @@ protected:
class WagFileParser {
// Constants, type definitions, enumerations etc.
public:
- static const uint WINAGI_VERSION_LENGTH = 16; ///< WinAGI's version string's length (Always 16)
+ enum {
+ WINAGI_VERSION_LENGTH = 16 ///< WinAGI's version string's length (Always 16)
+ };
typedef Common::Array<WagProperty> PropertyList; ///< A type definition for an array of *.wag file properties
public:
diff --git a/engines/cine/texte.cpp b/engines/cine/texte.cpp
index c8d48d3a06..ffc36b4b1a 100644
--- a/engines/cine/texte.cpp
+++ b/engines/cine/texte.cpp
@@ -61,7 +61,7 @@ void loadTextData(const char *filename) {
const uint bytesPerChar = fontDataSize / numChars; // Observed values: 64.
static const uint bytesPerRow = FONT_WIDTH / 2; // The input font data is 4-bit so it takes only half the space
- if (headerSize + fontDataSize != fileHandle.size()) {
+ if (headerSize + fontDataSize != (uint)fileHandle.size()) {
warning("loadTextData: file '%s' (entrySize = %d, entryCount = %d) is of incorrect size %d", filename, entrySize, entryCount, fileHandle.size());
}
diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp
index 2621278c59..92fd35d865 100644
--- a/engines/cine/various.cpp
+++ b/engines/cine/various.cpp
@@ -497,7 +497,7 @@ enum CineSaveGameFormat detectSaveGameFormat(Common::SeekableReadStream &fHandle
uint animEntrySize = animEntrySizeChoices[i];
// Jump over the animDataTable entries and the screen parameters
- uint32 newPos = animDataTableStart + animEntrySize * animEntriesCount + sizeofScreenParams;
+ int32 newPos = animDataTableStart + animEntrySize * animEntriesCount + sizeofScreenParams;
// Check that there's data left after the point we're going to jump to
if (newPos >= fHandle.size()) {
continue;
diff --git a/engines/gob/dataio.cpp b/engines/gob/dataio.cpp
index bcf566d134..0a3f317ada 100644
--- a/engines/gob/dataio.cpp
+++ b/engines/gob/dataio.cpp
@@ -62,31 +62,33 @@ DataStream::~DataStream() {
}
}
-uint32 DataStream::pos() const {
+int32 DataStream::pos() const {
if (_stream)
return _stream->pos();
- uint32 resPos = _io->getChunkPos(_handle);
- if (resPos != 0xFFFFFFFF)
+ int32 resPos = _io->getChunkPos(_handle);
+ if (resPos != -1)
return resPos;
return _io->file_getHandle(_handle)->pos();
}
-uint32 DataStream::size() const {
+int32 DataStream::size() const {
if (_stream)
return _stream->size();
return _size;
}
-void DataStream::seek(int32 offset, int whence) {
+bool DataStream::seek(int32 offset, int whence) {
if (_stream)
- _stream->seek(offset, whence);
+ return _stream->seek(offset, whence);
else if ((_handle < 50) || (_handle >= 128))
- _io->file_getHandle(_handle)->seek(offset, whence);
- else
- _io->seekChunk(_handle, offset, whence);
+ return _io->file_getHandle(_handle)->seek(offset, whence);
+ else {
+ _io->seekChunk(_handle, offset, whence);
+ return true;
+ }
}
bool DataStream::eos() const {
diff --git a/engines/gob/dataio.h b/engines/gob/dataio.h
index 4b4c79d1eb..c67dc89df8 100644
--- a/engines/gob/dataio.h
+++ b/engines/gob/dataio.h
@@ -45,10 +45,10 @@ public:
DataStream(byte *buf, uint32 dSize, bool dispose = true);
virtual ~DataStream();
- virtual uint32 pos() const;
- virtual uint32 size() const;
+ virtual int32 pos() const;
+ virtual int32 size() const;
- virtual void seek(int32 offset, int whence = SEEK_SET);
+ virtual bool seek(int32 offset, int whence = SEEK_SET);
virtual bool eos() const;
diff --git a/engines/gob/saveload.cpp b/engines/gob/saveload.cpp
index fa9f8ea7a9..e3212ac8ff 100644
--- a/engines/gob/saveload.cpp
+++ b/engines/gob/saveload.cpp
@@ -513,7 +513,7 @@ bool StagedSave::read() {
return false;
}
- uint32 saveSize = getSize();
+ int32 saveSize = getSize();
if (in->size() != saveSize) {
warning("Wrong size (%d != %d)", in->size(), saveSize);
return false;
diff --git a/engines/kyra/resource.cpp b/engines/kyra/resource.cpp
index 531f875cc3..0f0a643017 100644
--- a/engines/kyra/resource.cpp
+++ b/engines/kyra/resource.cpp
@@ -262,7 +262,7 @@ bool Resource::loadFileToBuf(const char *file, void *buf, uint32 maxSize) {
return false;
memset(buf, 0, maxSize);
- stream->read(buf, (maxSize <= stream->size()) ? maxSize : stream->size());
+ stream->read(buf, ((int32)maxSize <= stream->size()) ? maxSize : stream->size());
delete stream;
return true;
}
diff --git a/engines/kyra/resource_intern.cpp b/engines/kyra/resource_intern.cpp
index e6b3b14c8a..f97319a43a 100644
--- a/engines/kyra/resource_intern.cpp
+++ b/engines/kyra/resource_intern.cpp
@@ -127,8 +127,8 @@ bool ResLoaderPak::checkFilename(Common::String filename) const {
}
bool ResLoaderPak::isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const {
- uint32 filesize = stream.size();
- uint32 offset = 0;
+ int32 filesize = stream.size();
+ int32 offset = 0;
bool switchEndian = false;
bool firstFile = true;
@@ -138,7 +138,7 @@ bool ResLoaderPak::isLoadable(const Common::String &filename, Common::SeekableRe
offset = SWAP_BYTES_32(offset);
}
- Common::String file = "";
+ Common::String file;
while (!stream.eos()) {
// The start offset of a file should never be in the filelist
if (offset < stream.pos() || offset > filesize)
@@ -146,7 +146,7 @@ bool ResLoaderPak::isLoadable(const Common::String &filename, Common::SeekableRe
byte c = 0;
- file = "";
+ file.clear();
while (!stream.eos() && (c = stream.readByte()) != 0)
file += c;
@@ -196,9 +196,9 @@ struct PlainArchiveListSearch {
} // end of anonymous namespace
Common::Archive *ResLoaderPak::load(Resource *owner, const Common::String &filename, Common::SeekableReadStream &stream) const {
- uint32 filesize = stream.size();
+ int32 filesize = stream.size();
- uint32 startoffset = 0, endoffset = 0;
+ int32 startoffset = 0, endoffset = 0;
bool switchEndian = false;
bool firstFile = true;
@@ -210,7 +210,7 @@ Common::Archive *ResLoaderPak::load(Resource *owner, const Common::String &filen
PlainArchive::FileInputList files;
- Common::String file = "";
+ Common::String file;
while (!stream.eos()) {
// The start offset of a file should never be in the filelist
if (startoffset < stream.pos() || startoffset > filesize) {
@@ -218,7 +218,7 @@ Common::Archive *ResLoaderPak::load(Resource *owner, const Common::String &filen
return false;
}
- file = "";
+ file.clear();
byte c = 0;
while (!stream.eos() && (c = stream.readByte()) != 0)
@@ -301,7 +301,7 @@ bool ResLoaderInsMalcolm::checkFilename(Common::String filename) const {
bool ResLoaderInsMalcolm::isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const {
stream.seek(3, SEEK_SET);
- uint32 size = stream.readUint32LE();
+ int32 size = stream.readUint32LE();
if (size+7 > stream.size())
return false;
@@ -322,13 +322,13 @@ Common::Archive *ResLoaderInsMalcolm::load(Resource *owner, const Common::String
// first file is the index table
uint32 size = stream.readUint32LE();
- Common::String temp = "";
+ Common::String temp;
for (uint32 i = 0; i < size; ++i) {
byte c = stream.readByte();
if (c == '\\') {
- temp = "";
+ temp.clear();
} else if (c == 0x0D) {
// line endings are CRLF
c = stream.readByte();
@@ -363,12 +363,12 @@ bool ResLoaderTlk::checkFilename(Common::String filename) const {
bool ResLoaderTlk::isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const {
uint16 entries = stream.readUint16LE();
- uint32 entryTableSize = (entries * 8);
+ int32 entryTableSize = (entries * 8);
if (entryTableSize + 2 > stream.size())
return false;
- uint32 offset = 0;
+ int32 offset = 0;
for (uint i = 0; i < entries; ++i) {
stream.readUint32LE();
diff --git a/engines/kyra/script.cpp b/engines/kyra/script.cpp
index df933c3ed8..dba09f08ef 100644
--- a/engines/kyra/script.cpp
+++ b/engines/kyra/script.cpp
@@ -255,13 +255,13 @@ uint32 ScriptFileParser::getIFFBlockSize(const uint32 chunkName) {
_stream->seek(_startOffset + 0x0C);
- while (_stream->pos() < _endOffset) {
+ while ((uint)_stream->pos() < _endOffset) {
uint32 chunk = _stream->readUint32LE();
uint32 size_temp = _stream->readUint32BE();
if (chunk != chunkName) {
_stream->seek((size_temp + 1) & (~1), SEEK_CUR);
- assert(_stream->pos() <= _endOffset);
+ assert((uint)_stream->pos() <= _endOffset);
} else {
size = size_temp;
break;
@@ -274,13 +274,13 @@ uint32 ScriptFileParser::getIFFBlockSize(const uint32 chunkName) {
bool ScriptFileParser::loadIFFBlock(const uint32 chunkName, void *loadTo, uint32 ptrSize) {
_stream->seek(_startOffset + 0x0C);
- while (_stream->pos() < _endOffset) {
+ while ((uint)_stream->pos() < _endOffset) {
uint32 chunk = _stream->readUint32LE();
uint32 chunkSize = _stream->readUint32BE();
if (chunk != chunkName) {
_stream->seek((chunkSize + 1) & (~1), SEEK_CUR);
- assert(_stream->pos() <= _endOffset);
+ assert((uint)_stream->pos() <= _endOffset);
} else {
uint32 loadSize = 0;
diff --git a/engines/kyra/vqa.cpp b/engines/kyra/vqa.cpp
index 9a9941e20e..0f6440fd47 100644
--- a/engines/kyra/vqa.cpp
+++ b/engines/kyra/vqa.cpp
@@ -406,7 +406,7 @@ void VQAMovie::displayFrame(uint frameNum) {
byte *inbuf, *outbuf;
uint32 insize, outsize;
- uint32 end;
+ int32 end;
switch (tag) {
case MKID_BE('SND0'): // Uncompressed sound
@@ -594,7 +594,7 @@ void VQAMovie::play() {
uint32 insize, outsize;
if (_stream) {
- while (_file->pos() < (_frameInfo[0] & 0x7FFFFFFF)) {
+ while ((uint)_file->pos() < (_frameInfo[0] & 0x7FFFFFFF)) {
uint32 tag = readTag();
uint32 size = _file->readUint32BE();
diff --git a/engines/m4/converse.cpp b/engines/m4/converse.cpp
index 5b8bdab9d6..47d84f6a28 100644
--- a/engines/m4/converse.cpp
+++ b/engines/m4/converse.cpp
@@ -544,10 +544,10 @@ void Converse::loadConversation(const char *convName) {
curNode, _convNodes[curNode]->entries.size() - 1);
// Seek to chunk data (i.e. TEXT/MESG tag, which is usually right
// after this chunk but it can be further on in conditional reply chunks
- assert(data >= convS->pos());
+ assert((int)data >= convS->pos());
// If the entry's data is not right after the entry, remember the position
// to return to after the data is read
- if (chunk == CHUNK_CRPL && data != convS->pos())
+ if (chunk == CHUNK_CRPL && (int)data != convS->pos())
returnAddress = convS->pos();
convS->seek(data, SEEK_SET);
}
diff --git a/engines/m4/midi.cpp b/engines/m4/midi.cpp
index 51dd8654ae..3f1da2a369 100644
--- a/engines/m4/midi.cpp
+++ b/engines/m4/midi.cpp
@@ -269,7 +269,7 @@ byte *MidiPlayer::convertHMPtoSMF(byte *data, uint32 inSize, uint32 &outSize) {
byte lastCmd = 0;
// Now we can finally convert the track
- uint32 endPos = readS.pos() + trackLength;
+ int32 endPos = readS.pos() + trackLength;
while (readS.pos() < endPos) {
// Convert the VLQ
byte vlq[4];
diff --git a/engines/parallaction/disk.h b/engines/parallaction/disk.h
index 0176260129..30d820c6d2 100644
--- a/engines/parallaction/disk.h
+++ b/engines/parallaction/disk.h
@@ -104,10 +104,10 @@ public:
Common::String name() const;
bool openArchivedFile(const char *name);
void closeArchivedFile();
- uint32 size() const;
- uint32 pos() const;
+ int32 size() const;
+ int32 pos() const;
bool eos() const;
- void seek(int32 offs, int whence = SEEK_SET);
+ bool seek(int32 offs, int whence = SEEK_SET);
uint32 read(void *dataPtr, uint32 dataSize);
};
diff --git a/engines/parallaction/disk_ns.cpp b/engines/parallaction/disk_ns.cpp
index 55e6fc5e77..c50373aba1 100644
--- a/engines/parallaction/disk_ns.cpp
+++ b/engines/parallaction/disk_ns.cpp
@@ -156,11 +156,11 @@ void Archive::closeArchivedFile() {
}
-uint32 Archive::size() const {
+int32 Archive::size() const {
return (_file == true ? _fileEndOffset - _fileOffset : 0);
}
-uint32 Archive::pos() const {
+int32 Archive::pos() const {
return (_file == true ? _fileCursor - _fileOffset : 0 );
}
@@ -168,7 +168,7 @@ bool Archive::eos() const {
return (_file == true ? _fileCursor == _fileEndOffset : true );
}
-void Archive::seek(int32 offs, int whence) {
+bool Archive::seek(int32 offs, int whence) {
assert(_file == true && _fileCursor <= _fileEndOffset);
switch (whence) {
@@ -184,7 +184,7 @@ void Archive::seek(int32 offs, int whence) {
}
assert(_fileCursor <= _fileEndOffset && _fileCursor >= _fileOffset);
- _archive.seek(_fileCursor, SEEK_SET);
+ return _archive.seek(_fileCursor, SEEK_SET);
}
uint32 Archive::read(void *dataPtr, uint32 dataSize) {
@@ -234,16 +234,16 @@ public:
return _input->read(data, dataSize);
}
- uint32 pos() const {
+ int32 pos() const {
return _input->pos();
}
- uint32 size() const {
+ int32 size() const {
return _input->size();
}
- void seek(int32 offset, int whence) {
- _input->seek(offset, whence);
+ bool seek(int32 offset, int whence) {
+ return _input->seek(offset, whence);
}
};
@@ -798,11 +798,11 @@ public:
if (_dispose) delete _stream;
}
- uint32 size() const {
+ int32 size() const {
return _stream->size();
}
- uint32 pos() const {
+ int32 pos() const {
return _stream->pos();
}
@@ -810,8 +810,8 @@ public:
return _stream->eos();
}
- void seek(int32 offs, int whence = SEEK_SET) {
- _stream->seek(offs, whence);
+ bool seek(int32 offs, int whence = SEEK_SET) {
+ return _stream->seek(offs, whence);
}
uint32 read(void *dataPtr, uint32 dataSize) {
diff --git a/engines/saga/rscfile.cpp b/engines/saga/rscfile.cpp
index d1ad46a6fc..05b1162973 100644
--- a/engines/saga/rscfile.cpp
+++ b/engines/saga/rscfile.cpp
@@ -121,7 +121,7 @@ bool Resource::loadSagaContext(ResourceContext *context, uint32 contextOffset, u
resourceData->offset = contextOffset + readS1.readUint32();
resourceData->size = readS1.readUint32();
//sanity check
- if ((resourceData->offset > context->file->size()) || (resourceData->size > contextSize)) {
+ if ((resourceData->offset > (uint)context->file->size()) || (resourceData->size > contextSize)) {
result = false;
break;
}
@@ -181,8 +181,8 @@ bool Resource::loadMacContext(ResourceContext *context) {
macDataLength = context->file->readUint32BE();
macMapLength = context->file->readUint32BE();
- if (macDataOffset >= context->file->size() || macMapOffset >= context->file->size() ||
- macDataLength + macMapLength > context->file->size()) {
+ if (macDataOffset >= (uint)context->file->size() || macMapOffset >= (uint)context->file->size() ||
+ macDataLength + macMapLength > (uint)context->file->size()) {
return false;
}
diff --git a/engines/scumm/file.cpp b/engines/scumm/file.cpp
index 075b44d24d..22079332e4 100644
--- a/engines/scumm/file.cpp
+++ b/engines/scumm/file.cpp
@@ -42,9 +42,9 @@ void ScummFile::setEnc(byte value) {
_encbyte = value;
}
-void ScummFile::setSubfileRange(uint32 start, uint32 len) {
+void ScummFile::setSubfileRange(int32 start, int32 len) {
// TODO: Add sanity checks
- const uint32 fileSize = File::size();
+ const int32 fileSize = File::size();
assert(start <= fileSize);
assert(start + len <= fileSize);
_subFileStart = start;
@@ -129,15 +129,15 @@ bool ScummFile::eos() {
return _subFileLen ? (pos() >= _subFileLen) : File::eos();
}
-uint32 ScummFile::pos() {
+int32 ScummFile::pos() {
return File::pos() - _subFileStart;
}
-uint32 ScummFile::size() {
+int32 ScummFile::size() {
return _subFileLen ? _subFileLen : File::size();
}
-void ScummFile::seek(int32 offs, int whence) {
+bool ScummFile::seek(int32 offs, int whence) {
if (_subFileLen) {
// Constrain the seek to the subfile
switch (whence) {
@@ -154,7 +154,7 @@ void ScummFile::seek(int32 offs, int whence) {
assert((int32)_subFileStart <= offs && offs <= (int32)(_subFileStart + _subFileLen));
whence = SEEK_SET;
}
- File::seek(offs, whence);
+ return File::seek(offs, whence);
}
uint32 ScummFile::read(void *dataPtr, uint32 dataSize) {
@@ -162,9 +162,9 @@ uint32 ScummFile::read(void *dataPtr, uint32 dataSize) {
if (_subFileLen) {
// Limit the amount we read by the subfile boundaries.
- const uint32 curPos = pos();
+ const int32 curPos = pos();
assert(_subFileLen >= curPos);
- uint32 newPos = curPos + dataSize;
+ int32 newPos = curPos + dataSize;
if (newPos > _subFileLen) {
dataSize = _subFileLen - curPos;
_myIoFailed = true;
diff --git a/engines/scumm/file.h b/engines/scumm/file.h
index 3a044935a1..336f3cde12 100644
--- a/engines/scumm/file.h
+++ b/engines/scumm/file.h
@@ -40,25 +40,26 @@ public:
virtual bool openSubFile(const Common::String &filename) = 0;
virtual bool eos() = 0;
- virtual uint32 pos() = 0;
- virtual uint32 size() = 0;
- virtual void seek(int32 offs, int whence = SEEK_SET) = 0;
+ virtual int32 pos() = 0;
+ virtual int32 size() = 0;
+ virtual bool seek(int32 offs, int whence = SEEK_SET) = 0;
virtual uint32 read(void *dataPtr, uint32 dataSize) = 0;
};
class ScummFile : public BaseScummFile {
private:
byte _encbyte;
- uint32 _subFileStart;
- uint32 _subFileLen;
+ int32 _subFileStart;
+ int32 _subFileLen;
bool _myIoFailed;
+
+ void setSubfileRange(int32 start, int32 len);
+ void resetSubfile();
+
public:
ScummFile();
void setEnc(byte value);
- void setSubfileRange(uint32 start, uint32 len);
- void resetSubfile();
-
bool open(const Common::String &filename);
bool openSubFile(const Common::String &filename);
@@ -66,9 +67,9 @@ public:
void clearIOFailed() { _myIoFailed = false; BaseScummFile::clearIOFailed(); }
bool eos();
- uint32 pos();
- uint32 size();
- void seek(int32 offs, int whence = SEEK_SET);
+ int32 pos();
+ int32 size();
+ bool seek(int32 offs, int whence = SEEK_SET);
uint32 read(void *dataPtr, uint32 dataSize);
};
@@ -111,9 +112,9 @@ public:
void close();
bool eos() { return _stream->eos(); }
- uint32 pos() { return _stream->pos(); }
- uint32 size() { return _stream->size(); }
- void seek(int32 offs, int whence = SEEK_SET) { _stream->seek(offs, whence); }
+ int32 pos() { return _stream->pos(); }
+ int32 size() { return _stream->size(); }
+ bool seek(int32 offs, int whence = SEEK_SET) { return _stream->seek(offs, whence); }
uint32 read(void *dataPtr, uint32 dataSize) { return _stream->read(dataPtr, dataSize); }
};
diff --git a/engines/scumm/file_nes.cpp b/engines/scumm/file_nes.cpp
index 8325436f87..0ddbd0b3ee 100644
--- a/engines/scumm/file_nes.cpp
+++ b/engines/scumm/file_nes.cpp
@@ -1124,8 +1124,7 @@ bool ScummNESFile::generateResource(int res) {
write_byte(&out, 0xD1);
write_byte(&out, 0xF5);
- if (_stream)
- delete _stream;
+ delete _stream;
_stream = new Common::MemoryReadStream(_buf, bufsize);
@@ -1221,8 +1220,7 @@ bool ScummNESFile::generateIndex() {
for (i = 0; i < (int)sizeof(lfl_index); i++)
write_byte(&out, ((byte *)&lfl_index)[i]);
- if (_stream)
- delete _stream;
+ delete _stream;
_stream = new Common::MemoryReadStream(_buf, bufsize);
diff --git a/engines/scumm/file_nes.h b/engines/scumm/file_nes.h
index 3d7fd64ebe..f1a07f8085 100644
--- a/engines/scumm/file_nes.h
+++ b/engines/scumm/file_nes.h
@@ -69,9 +69,9 @@ public:
void close();
bool eos() { return _stream->eos(); }
- uint32 pos() { return _stream->pos(); }
- uint32 size() { return _stream->size(); }
- void seek(int32 offs, int whence = SEEK_SET) { _stream->seek(offs, whence); }
+ int32 pos() { return _stream->pos(); }
+ int32 size() { return _stream->size(); }
+ bool seek(int32 offs, int whence = SEEK_SET) { return _stream->seek(offs, whence); }
uint32 read(void *dataPtr, uint32 dataSize) { return _stream->read(dataPtr, dataSize); }
};
diff --git a/engines/scumm/smush/chunk.cpp b/engines/scumm/smush/chunk.cpp
index 5e6f05b3e4..855f0a3985 100644
--- a/engines/scumm/smush/chunk.cpp
+++ b/engines/scumm/smush/chunk.cpp
@@ -45,7 +45,7 @@ bool BaseChunk::eos() const {
return _curPos >= _size;
}
-uint32 BaseChunk::pos() const {
+int32 BaseChunk::pos() const {
return _curPos;
}
@@ -53,11 +53,11 @@ Chunk::type BaseChunk::getType() const {
return _type;
}
-uint32 BaseChunk::size() const {
+int32 BaseChunk::size() const {
return _size;
}
-void BaseChunk::seek(int32 delta, int dir) {
+bool BaseChunk::seek(int32 delta, int dir) {
switch (dir) {
case SEEK_CUR:
_curPos += delta;
@@ -85,6 +85,8 @@ void BaseChunk::seek(int32 delta, int dir) {
warning("Looks like you compressed file %s in wrong way. It has FLU index which was not updated", _name.c_str());
error("invalid seek request : %d > %d (delta == %d)", _curPos, _size, delta);
}
+
+ return true;
}
FileChunk::FileChunk(BaseScummFile *data, int offset) {
diff --git a/engines/scumm/smush/chunk.h b/engines/scumm/smush/chunk.h
index ca4a3cdd99..08d7037d1c 100644
--- a/engines/scumm/smush/chunk.h
+++ b/engines/scumm/smush/chunk.h
@@ -55,10 +55,10 @@ protected:
public:
Chunk::type getType() const;
- uint32 size() const;
+ int32 size() const;
bool eos() const;
- uint32 pos() const;
- void seek(int32 delta, int dir);
+ int32 pos() const;
+ bool seek(int32 delta, int dir);
};
class FileChunk : public BaseChunk {
diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp
index e4d8393dbe..9100d95e5d 100644
--- a/engines/scumm/smush/smush_player.cpp
+++ b/engines/scumm/smush/smush_player.cpp
@@ -315,7 +315,7 @@ void SmushPlayer::release() {
_codec47 = 0;
}
-void SmushPlayer::checkBlock(const Chunk &b, Chunk::type type_expected, uint32 min_size) {
+void SmushPlayer::checkBlock(const Chunk &b, Chunk::type type_expected, int32 min_size) {
if (type_expected != b.getType()) {
error("Chunk type is different from expected : %x != %x", b.getType(), type_expected);
}
diff --git a/engines/scumm/smush/smush_player.h b/engines/scumm/smush/smush_player.h
index 64ae167349..29a2397d58 100644
--- a/engines/scumm/smush/smush_player.h
+++ b/engines/scumm/smush/smush_player.h
@@ -121,7 +121,7 @@ private:
bool readString(const char *file);
void decodeFrameObject(int codec, const uint8 *src, int left, int top, int width, int height);
- void checkBlock(const Chunk &, Chunk::type, uint32 = 0);
+ void checkBlock(const Chunk &, Chunk::type, int32 = 0);
void handleAnimHeader(Chunk &);
void handleFrame(Chunk &);
void handleNewPalette(Chunk &);
diff --git a/engines/sword1/music.cpp b/engines/sword1/music.cpp
index 6cb82bc0b0..27e7568fcc 100644
--- a/engines/sword1/music.cpp
+++ b/engines/sword1/music.cpp
@@ -80,7 +80,7 @@ BaseAudioStream::~BaseAudioStream() {
void BaseAudioStream::reinit(int size, int rate, byte flags) {
_isStereo = (flags & Audio::Mixer::FLAG_STEREO) != 0;
_rate = rate;
- assert((uint)size <= (_sourceStream->size() - _sourceStream->pos()));
+ assert(size <= (_sourceStream->size() - _sourceStream->pos()));
_bitsPerSample = ((flags & Audio::Mixer::FLAG_16BITS) != 0) ? 16 : 8;
_samplesLeft = (size * 8) / _bitsPerSample;
if ((_bitsPerSample != 16) && (_bitsPerSample != 8))
diff --git a/engines/sword2/sound.h b/engines/sword2/sound.h
index b89ef8f12b..684be3dacd 100644
--- a/engines/sword2/sound.h
+++ b/engines/sword2/sound.h
@@ -124,7 +124,7 @@ struct SoundFileHandle {
Common::File file;
uint32 *idxTab;
uint32 idxLen;
- uint32 fileSize;
+ int32 fileSize;
uint32 fileType;
volatile bool inUse;
};
diff --git a/engines/tinsel/sound.cpp b/engines/tinsel/sound.cpp
index e2a24dbd47..e37c80ec61 100644
--- a/engines/tinsel/sound.cpp
+++ b/engines/tinsel/sound.cpp
@@ -74,7 +74,7 @@ bool SoundManager::playSample(int id, Audio::Mixer::SoundType type, Audio::Sound
assert(id > 0 && id < _sampleIndexLen);
// get file offset for this sample
- uint32 dwSampleIndex = _sampleIndex[id];
+ int32 dwSampleIndex = _sampleIndex[id];
// move to correct position in the sample file
_sampleStream.seek(dwSampleIndex);
@@ -166,7 +166,7 @@ void SoundManager::openSampleFiles(void) {
if (_sampleIndex == NULL) {
// allocate a buffer for the indices
- _sampleIndex = (uint32 *)malloc(_sampleIndexLen);
+ _sampleIndex = (int32 *)malloc(_sampleIndexLen);
// make sure memory allocated
if (_sampleIndex == NULL) {
diff --git a/engines/tinsel/sound.h b/engines/tinsel/sound.h
index 56618eeb8e..c17995e91e 100644
--- a/engines/tinsel/sound.h
+++ b/engines/tinsel/sound.h
@@ -52,7 +52,7 @@ protected:
Audio::SoundHandle _handle;
/** Sample index buffer and number of entries */
- uint32 *_sampleIndex;
+ int32 *_sampleIndex;
/** Number of entries in the sample index */
long _sampleIndexLen;
diff --git a/sound/adpcm.cpp b/sound/adpcm.cpp
index ad072af360..a30cf9c61e 100644
--- a/sound/adpcm.cpp
+++ b/sound/adpcm.cpp
@@ -38,7 +38,7 @@ class ADPCMInputStream : public AudioStream {
private:
Common::SeekableReadStream *_stream;
bool _disposeAfterUse;
- uint32 _endpos;
+ int32 _endpos;
int _channels;
typesADPCM _type;
uint32 _blockAlign;
diff --git a/sound/flac.cpp b/sound/flac.cpp
index bb1a6fb4be..7b46f0660f 100644
--- a/sound/flac.cpp
+++ b/sound/flac.cpp
@@ -656,7 +656,7 @@ inline ::FLAC__StreamDecoderWriteStatus FlacInputStream::callbackWrite(const ::F
inline ::FLAC__SeekableStreamDecoderSeekStatus FlacInputStream::callbackSeek(FLAC__uint64 absoluteByteOffset) {
_inStream->seek(absoluteByteOffset, SEEK_SET);
- const bool result = (absoluteByteOffset == _inStream->pos());
+ const bool result = (absoluteByteOffset == (FLAC__uint64)_inStream->pos());
#ifdef LEGACY_FLAC
return result ? FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK : FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR;
diff --git a/sound/mods/infogrames.cpp b/sound/mods/infogrames.cpp
index d5b285576a..a5b3ea1f35 100644
--- a/sound/mods/infogrames.cpp
+++ b/sound/mods/infogrames.cpp
@@ -61,10 +61,10 @@ bool Infogrames::Instruments::load(const char *ins) {
bool Infogrames::Instruments::load(Common::SeekableReadStream &ins) {
int i;
- uint32 fsize;
- uint32 offset[32];
- uint32 offsetRepeat[32];
- uint32 dataOffset;
+ int32 fsize;
+ int32 offset[32];
+ int32 offsetRepeat[32];
+ int32 dataOffset;
unload();
diff --git a/sound/wave.cpp b/sound/wave.cpp
index 249518aafc..72a3992401 100644
--- a/sound/wave.cpp
+++ b/sound/wave.cpp
@@ -34,7 +34,7 @@
namespace Audio {
bool loadWAVFromStream(Common::SeekableReadStream &stream, int &size, int &rate, byte &flags, uint16 *wavType, int *blockAlign_) {
- const uint32 initialPos = stream.pos();
+ const int32 initialPos = stream.pos();
byte buf[4+1];
buf[4] = 0;
@@ -45,7 +45,7 @@ bool loadWAVFromStream(Common::SeekableReadStream &stream, int &size, int &rate,
return false;
}
- uint32 wavLength = stream.readUint32LE();
+ int32 wavLength = stream.readUint32LE();
stream.read(buf, 4);
if (memcmp(buf, "WAVE", 4) != 0) {