aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2009-02-19 20:20:14 +0000
committerWillem Jan Palenstijn2009-02-19 20:20:14 +0000
commit2595783e9fc522e5c6d37672b230b409024e34e5 (patch)
treefe329f3cc1d80c47cb62e221b8f089e4ab3efd03 /engines/sci
parent51f0a3bf7edac01d0d7036b3f1d0e7aa16aea504 (diff)
downloadscummvm-rg350-2595783e9fc522e5c6d37672b230b409024e34e5.tar.gz
scummvm-rg350-2595783e9fc522e5c6d37672b230b409024e34e5.tar.bz2
scummvm-rg350-2595783e9fc522e5c6d37672b230b409024e34e5.zip
Function call order in expressions isn't well-defined. Also fix missing shift and moved some comments.
svn-id: r38562
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/exereader.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/engines/sci/exereader.cpp b/engines/sci/exereader.cpp
index 0435f8c97f..efb4969973 100644
--- a/engines/sci/exereader.cpp
+++ b/engines/sci/exereader.cpp
@@ -116,6 +116,7 @@ bool isLZEXECompressed(Common::SeekableReadStream *exeStream) {
// Calculate code segment offset in exe file
filepos += exeStream->readUint16LE(); // at pos 22, +2
+ filepos <<= 4;
// First relocation item offset should be 0x1c
if (exeStream->readUint16LE() != 0x1c) // at pos 24, +2
@@ -156,7 +157,8 @@ uint getBit(Common::SeekableReadStream *input) {
_bitCount--;
if (_bitCount <= 0) {
- _bits = input->readByte() | input->readByte() << 8;
+ _bits = input->readByte();
+ _bits |= input->readByte() << 8;
if (_bitCount == -1) { /* special case for first bit word */
bit = _bits & 1;
@@ -174,19 +176,6 @@ bool readSciVersionFromExe(Common::SeekableReadStream *exeStream, int *version)
int len = exeStream->size();
unsigned char *buffer = NULL;
char result_string[10]; /* string-encoded result, copied from buf */
- int state = 0;
- /* 'state' encodes how far we have matched the version pattern
- ** "n.nnn.nnn"
- **
- ** n.nnn.nnn
- ** 0123456789
- **
- ** Since we cannot be certain that the pattern does not begin with an
- ** alphanumeric character, some states are ambiguous.
- ** The pattern is expected to be terminated with a non-alphanumeric
- ** character.
- */
-
// Read the executable
bool isLZEXE = isLZEXECompressed(exeStream);
@@ -235,7 +224,8 @@ bool readSciVersionFromExe(Common::SeekableReadStream *exeStream, int *version)
} else
repeat += 2;
} else {
- repeat = ((getBit(exeStream) << 1) | getBit(exeStream)) + 2;
+ repeat = getBit(exeStream) << 1;
+ repeat += getBit(exeStream) + 2;
offset = exeStream->readByte() | 0xFF00;
}
@@ -250,6 +240,20 @@ bool readSciVersionFromExe(Common::SeekableReadStream *exeStream, int *version)
// Find SCI version number
+ int state = 0;
+ /* 'state' encodes how far we have matched the version pattern
+ ** "n.nnn.nnn"
+ **
+ ** n.nnn.nnn
+ ** 0123456789
+ **
+ ** Since we cannot be certain that the pattern does not begin with an
+ ** alphanumeric character, some states are ambiguous.
+ ** The pattern is expected to be terminated with a non-alphanumeric
+ ** character.
+ */
+
+
int accept;
unsigned char *buf = buffer;