[Scummvm-git-logs] scummvm master -> ce52a33ff18b1d4312ad293469a0da03db6b14c3

eriktorbjorn eriktorbjorn at telia.com
Tue Jul 6 09:07:41 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
ce52a33ff1 STARK: Avoid adding \0 to a String


Commit: ce52a33ff18b1d4312ad293469a0da03db6b14c3
    https://github.com/scummvm/scummvm/commit/ce52a33ff18b1d4312ad293469a0da03db6b14c3
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2021-07-06T11:06:33+02:00

Commit Message:
STARK: Avoid adding \0 to a String

We are still deciding on whether or not that should even be allowed, so
let's get rid of the cases where it's not actively needed. The purpose
here is to skip past unknown parts of the stream, so there's no need
storing the data in a String. Let's just document that it's ok for it to
skip past \0 as well.

This happens in my Swedish CD version of The Longest Journey, but not in
my English DVD version.

Changed paths:
    engines/stark/formats/iss.cpp


diff --git a/engines/stark/formats/iss.cpp b/engines/stark/formats/iss.cpp
index e56cb4d7ab..0fc37954f3 100644
--- a/engines/stark/formats/iss.cpp
+++ b/engines/stark/formats/iss.cpp
@@ -64,6 +64,14 @@ protected:
 	}
 };
 
+static void skipString(Common::SeekableReadStream *stream) {
+	// Skip until the next space. Note that this will read past \0
+	// characters as well. That's not a bug.
+	byte ch;
+	while ((ch = stream->readByte()) != 0x20)
+		;
+}
+
 static Common::String readString(Common::SeekableReadStream *stream) {
 	Common::String ret = "";
 	byte ch;
@@ -86,24 +94,24 @@ Audio::RewindableAudioStream *makeISSStream(Common::SeekableReadStream *stream,
 		codec = readString(stream);
 		blockSize = (uint16)strtol(codec.c_str(), 0, 10);
 
-		readString(stream);
+		skipString(stream);
 		// name ?
 
-		readString(stream);
+		skipString(stream);
 		// ?
 
 		codec = readString(stream);
 		channels = (uint16)strtol(codec.c_str(), 0, 10) + 1;
 
-		readString(stream);
+		skipString(stream);
 		// ?
 
 		codec = readString(stream);
 		freq = 44100 / (uint16)strtol(codec.c_str(), 0, 10);
 
-		readString(stream);
+		skipString(stream);
 
-		readString(stream);
+		skipString(stream);
 
 		codec = readString(stream);
 		size = (uint32)strtol(codec.c_str(), 0, 10);
@@ -111,7 +119,7 @@ Audio::RewindableAudioStream *makeISSStream(Common::SeekableReadStream *stream,
 		return new ISSADPCMStream(stream, DisposeAfterUse::YES, size, freq, channels, blockSize);
 	} else if (codec.equals("Sound")) {
 
-		readString(stream);
+		skipString(stream);
 		// name ?
 
 		codec = readString(stream);
@@ -120,15 +128,15 @@ Audio::RewindableAudioStream *makeISSStream(Common::SeekableReadStream *stream,
 		codec = readString(stream);
 		channels = (uint16)strtol(codec.c_str(), 0, 10) + 1;
 
-		readString(stream);
+		skipString(stream);
 		// ?
 
 		codec = readString(stream);
 		freq = 44100 / (uint16)strtol(codec.c_str(), 0, 10);
 
-		readString(stream);
+		skipString(stream);
 
-		readString(stream);
+		skipString(stream);
 
 		flags = Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN;
 		if (channels == 2)




More information about the Scummvm-git-logs mailing list