aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Snover2016-12-18 15:54:14 -0600
committerColin Snover2016-12-18 19:02:41 -0600
commit1a3d47bcb5d4318424d309bb659e1fe4655e2175 (patch)
tree45cf4f74e709d2e5093c81bd9294a6f576e95bc7
parentb011af94855ba48b866ad866ae40dde40669607d (diff)
downloadscummvm-rg350-1a3d47bcb5d4318424d309bb659e1fe4655e2175.tar.gz
scummvm-rg350-1a3d47bcb5d4318424d309bb659e1fe4655e2175.tar.bz2
scummvm-rg350-1a3d47bcb5d4318424d309bb659e1fe4655e2175.zip
SCI: Remove restriction on backwards seeking
SaveFileRewriteStream enables backwards seeking, which is necessary for the chase.dat in Phant1 to be parsed correctly by the game.
-rw-r--r--engines/sci/engine/kfile.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp
index 6aad256664..995f421623 100644
--- a/engines/sci/engine/kfile.cpp
+++ b/engines/sci/engine/kfile.cpp
@@ -659,22 +659,21 @@ reg_t kFileIOWriteString(EngineState *s, int argc, reg_t *argv) {
reg_t kFileIOSeek(EngineState *s, int argc, reg_t *argv) {
uint16 handle = argv[0].toUint16();
- uint16 offset = ABS<int16>(argv[1].toSint16()); // can be negative
+ int16 offset = argv[1].toSint16();
uint16 whence = argv[2].toUint16();
debugC(kDebugLevelFile, "kFileIO(seek): %d, %d, %d", handle, offset, whence);
FileHandle *f = getFileFromHandle(s, handle);
if (f && f->_in) {
- // Backward seeking isn't supported in zip file streams, thus adapt the
- // parameters accordingly if games ask for such a seek mode. A known
- // case where this is requested is the save file manager in Phantasmagoria
- if (whence == SEEK_END) {
- whence = SEEK_SET;
- offset = f->_in->size() - offset;
+ const bool success = f->_in->seek(offset, whence);
+ if (getSciVersion() >= SCI_VERSION_2) {
+ if (success) {
+ return make_reg(0, f->_in->pos());
+ }
+ return SIGNAL_REG;
}
-
- return make_reg(0, f->_in->seek(offset, whence));
+ return make_reg(0, success);
} else if (f && f->_out) {
error("kFileIOSeek: Unsupported seek operation on a writeable stream (offset: %d, whence: %d)", offset, whence);
}