[Scummvm-cvs-logs] scummvm master -> 2f73d64e803c3be97d20bdbd1c4c482e783eb3d6
lordhoto
lordhoto at gmail.com
Mon Jan 28 17:46:02 CET 2013
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
edfcd768ba COMMON: Make BufferedSeekableReadStream use the buffer with SEEK_SET and SEEK_END
2f73d64e80 Merge pull request #305 from giucam/bufferedseekable
Commit: edfcd768ba394150df34d59f08765c3e061e6c72
https://github.com/scummvm/scummvm/commit/edfcd768ba394150df34d59f08765c3e061e6c72
Author: Giulio Camuffo (giuliocamuffo at gmail.com)
Date: 2013-01-26T10:12:26-08:00
Commit Message:
COMMON: Make BufferedSeekableReadStream use the buffer with SEEK_SET and SEEK_END
Changed paths:
common/stream.cpp
diff --git a/common/stream.cpp b/common/stream.cpp
index 85647bf..d3cfce4 100644
--- a/common/stream.cpp
+++ b/common/stream.cpp
@@ -379,12 +379,25 @@ BufferedSeekableReadStream::BufferedSeekableReadStream(SeekableReadStream *paren
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
- // since they are rarely used, it seems not worth the effort.
_eos = false; // seeking always cancels EOS
- if (whence == SEEK_CUR && (int)_pos + offset >= 0 && _pos + offset <= _bufSize) {
- _pos += offset;
+ int relOffset = 0;
+ switch (whence) {
+ case SEEK_SET:
+ relOffset = offset - pos();
+ break;
+ case SEEK_CUR:
+ relOffset = offset;
+ break;
+ case SEEK_END:
+ relOffset = (size() + offset) - pos();
+ break;
+ default:
+ break;
+ }
+
+ if ((int)_pos + relOffset >= 0 && _pos + relOffset <= _bufSize) {
+ _pos += relOffset;
// Note: we do not need to reset parent's eos flag here. It is
// sufficient that it is reset when actually seeking in the parent.
Commit: 2f73d64e803c3be97d20bdbd1c4c482e783eb3d6
https://github.com/scummvm/scummvm/commit/2f73d64e803c3be97d20bdbd1c4c482e783eb3d6
Author: Johannes Schickel (lordhoto at gmail.com)
Date: 2013-01-28T08:43:52-08:00
Commit Message:
Merge pull request #305 from giucam/bufferedseekable
Make BufferedSeekableReadStream use the buffer with SEEK_SET and SEEK_END
Changed paths:
common/stream.cpp
More information about the Scummvm-git-logs
mailing list