[Scummvm-git-logs] scummvm master -> 1aea38cc6312fcac4cf988ea755b1ff8fe628eab

sev- sev at scummvm.org
Tue Jul 21 16:23:47 UTC 2020


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:
cd7b892d0c MOHAWK: Fix mess with stream pointers casting
1aea38cc63 COMMON: Makw SeekableSubReadStreamEndian subclass of SeekableReadStreamEndian


Commit: cd7b892d0c66c7b292223c9c4377a9cb42882d3c
    https://github.com/scummvm/scummvm/commit/cd7b892d0c66c7b292223c9c4377a9cb42882d3c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-07-21T18:20:00+02:00

Commit Message:
MOHAWK: Fix mess with stream pointers casting

Changed paths:
    engines/mohawk/bitmap.cpp
    engines/mohawk/bitmap.h
    engines/mohawk/livingbooks_graphics.cpp
    engines/mohawk/livingbooks_graphics.h


diff --git a/engines/mohawk/bitmap.cpp b/engines/mohawk/bitmap.cpp
index 205feb824f..d8dddd3c5c 100644
--- a/engines/mohawk/bitmap.cpp
+++ b/engines/mohawk/bitmap.cpp
@@ -677,9 +677,7 @@ MohawkSurface *MystBitmap::decodeImage(Common::SeekableReadStream *stream) {
 
 #endif
 
-MohawkSurface *LivingBooksBitmap_v1::decodeImage(Common::SeekableReadStream *stream) {
-	Common::SeekableSubReadStreamEndian *endianStream = (Common::SeekableSubReadStreamEndian *)stream;
-
+MohawkSurface *LivingBooksBitmap_v1::decodeImageLB(Common::SeekableReadStreamEndian *endianStream) {
 	// 12 bytes header for the image
 	_header.format = endianStream->readUint16();
 	_header.bytesPerRow = endianStream->readUint16();
@@ -709,7 +707,7 @@ MohawkSurface *LivingBooksBitmap_v1::decodeImage(Common::SeekableReadStream *str
 		if (lengthBits != LEN_BITS)
 			error("Length bits modified to %d", lengthBits);
 
-		_data = decompressLZ(stream, uncompressedSize);
+		_data = decompressLZ(endianStream, uncompressedSize);
 
 		if (endianStream->pos() != endianStream->size())
 			error("LivingBooksBitmap_v1 decompression failed");
@@ -728,8 +726,8 @@ MohawkSurface *LivingBooksBitmap_v1::decodeImage(Common::SeekableReadStream *str
 		if (!endianStream->isBE())
 			leRLE8 = true;
 
-		_data = stream;
-		stream = nullptr;
+		_data = endianStream;
+		endianStream = nullptr;
 	}
 
 	Graphics::Surface *surface = createSurface(_header.width, _header.height);
@@ -740,7 +738,7 @@ MohawkSurface *LivingBooksBitmap_v1::decodeImage(Common::SeekableReadStream *str
 		drawRaw(surface);
 
 	delete _data;
-	delete stream;
+	delete endianStream;
 
 	MohawkSurface *mhkSurface = new MohawkSurface(surface);
 	mhkSurface->setOffsetX(offsetX);
diff --git a/engines/mohawk/bitmap.h b/engines/mohawk/bitmap.h
index 18ea72b3ee..c93960e6d1 100644
--- a/engines/mohawk/bitmap.h
+++ b/engines/mohawk/bitmap.h
@@ -167,7 +167,7 @@ public:
 	LivingBooksBitmap_v1() : MohawkBitmap() {}
 	~LivingBooksBitmap_v1() override {}
 
-	MohawkSurface *decodeImage(Common::SeekableReadStream *stream) override;
+	MohawkSurface *decodeImageLB(Common::SeekableReadStreamEndian *stream);
 
 protected:
 	byte getBitsPerPixel() override { return 8; }
diff --git a/engines/mohawk/livingbooks_graphics.cpp b/engines/mohawk/livingbooks_graphics.cpp
index bb521eee22..d672967b38 100644
--- a/engines/mohawk/livingbooks_graphics.cpp
+++ b/engines/mohawk/livingbooks_graphics.cpp
@@ -32,18 +32,25 @@
 namespace Mohawk {
 
 LBGraphics::LBGraphics(MohawkEngine_LivingBooks *vm, uint16 width, uint16 height) : GraphicsManager(), _vm(vm) {
-	_bmpDecoder = _vm->isPreMohawk() ? new LivingBooksBitmap_v1() : new MohawkBitmap();
+	_bmpDecoder = nullptr;
+	_bmpDecoderLB = nullptr;
+
+	if (_vm->isPreMohawk())
+		_bmpDecoderLB = new LivingBooksBitmap_v1();
+	else
+		_bmpDecoder =  new MohawkBitmap();
 
 	initGraphics(width, height);
 }
 
 LBGraphics::~LBGraphics() {
 	delete _bmpDecoder;
+	delete _bmpDecoderLB;
 }
 
 MohawkSurface *LBGraphics::decodeImage(uint16 id) {
 	if (_vm->isPreMohawk())
-		return _bmpDecoder->decodeImage(_vm->wrapStreamEndian(ID_BMAP, id));
+		return _bmpDecoderLB->decodeImage(_vm->wrapStreamEndian(ID_BMAP, id));
 
 	return _bmpDecoder->decodeImage(_vm->getResource(ID_TBMP, id));
 }
diff --git a/engines/mohawk/livingbooks_graphics.h b/engines/mohawk/livingbooks_graphics.h
index 72d4c7b0ca..8485d5670c 100644
--- a/engines/mohawk/livingbooks_graphics.h
+++ b/engines/mohawk/livingbooks_graphics.h
@@ -44,6 +44,7 @@ protected:
 
 private:
 	MohawkBitmap *_bmpDecoder;
+	LivingBooksBitmap_v1 *_bmpDecoderLB;
 	MohawkEngine_LivingBooks *_vm;
 };
 


Commit: 1aea38cc6312fcac4cf988ea755b1ff8fe628eab
    https://github.com/scummvm/scummvm/commit/1aea38cc6312fcac4cf988ea755b1ff8fe628eab
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-07-21T18:20:00+02:00

Commit Message:
COMMON: Makw SeekableSubReadStreamEndian subclass of SeekableReadStreamEndian

Changed paths:
    common/memstream.h
    common/stream.h
    common/substream.h
    engines/kyra/resource/resource.cpp
    engines/saga/saga.h


diff --git a/common/memstream.h b/common/memstream.h
index 4bbcc2b401..00ae80950c 100644
--- a/common/memstream.h
+++ b/common/memstream.h
@@ -81,7 +81,7 @@ public:
 class MemoryReadStreamEndian : public MemoryReadStream, public SeekableReadStreamEndian {
 public:
 	MemoryReadStreamEndian(const byte *buf, uint32 len, bool bigEndian)
-		: MemoryReadStream(buf, len), SeekableReadStreamEndian(bigEndian) {}
+		: MemoryReadStream(buf, len), SeekableReadStreamEndian(bigEndian), ReadStreamEndian(bigEndian) {}
 
 	int32 pos() const { return MemoryReadStream::pos(); }
 	int32 size() const { return MemoryReadStream::size(); }
diff --git a/common/stream.h b/common/stream.h
index a3843290e2..1da3cba560 100644
--- a/common/stream.h
+++ b/common/stream.h
@@ -279,6 +279,8 @@ public:
  */
 class ReadStream : virtual public Stream {
 public:
+	ReadStream() {}
+
 	/**
 	 * Returns true if a read failed because the stream end has been reached.
 	 * This flag is cleared by clearErr().
@@ -707,7 +709,7 @@ public:
  * This is a SeekableReadStream subclass which adds non-endian read
  * methods whose endianness is set during the stream creation.
  */
-class SeekableReadStreamEndian : public SeekableReadStream, public ReadStreamEndian {
+class SeekableReadStreamEndian : virtual public SeekableReadStream, virtual public ReadStreamEndian {
 public:
 	SeekableReadStreamEndian(bool bigEndian) : ReadStreamEndian(bigEndian) {}
 };
diff --git a/common/substream.h b/common/substream.h
index e3161c0a53..8bc68cc8a9 100644
--- a/common/substream.h
+++ b/common/substream.h
@@ -66,7 +66,7 @@ public:
  * Manipulating the parent stream directly /will/ mess up a substream.
  * @see SubReadStream
  */
-class SeekableSubReadStream : public SubReadStream, public SeekableReadStream {
+class SeekableSubReadStream : public SubReadStream, virtual public SeekableReadStream {
 protected:
 	SeekableReadStream *_parentStream;
 	uint32 _begin;
@@ -86,12 +86,20 @@ public:
  * Manipulating the parent stream directly /will/ mess up a substream.
  * @see SubReadStream
  */
-class SeekableSubReadStreamEndian : public SeekableSubReadStream, public ReadStreamEndian {
+class SeekableSubReadStreamEndian :  virtual public SeekableSubReadStream, virtual public SeekableReadStreamEndian {
 public:
 	SeekableSubReadStreamEndian(SeekableReadStream *parentStream, uint32 begin, uint32 end, bool bigEndian, DisposeAfterUse::Flag disposeParentStream = DisposeAfterUse::NO)
 		: SeekableSubReadStream(parentStream, begin, end, disposeParentStream),
+		  SeekableReadStreamEndian(bigEndian),
 		  ReadStreamEndian(bigEndian) {
 	}
+
+	virtual int32 pos() const { return SeekableSubReadStream::pos(); }
+	virtual int32 size() const { return SeekableSubReadStream::size(); }
+
+	virtual bool seek(int32 offset, int whence = SEEK_SET) { return SeekableSubReadStream::seek(offset, whence); }
+	void hexdump(int len, int bytesPerLine = 16, int startOffset = 0) { SeekableSubReadStream::hexdump(len, bytesPerLine, startOffset); }
+	bool skip(uint32 offset) { return SeekableSubReadStream::seek(offset, SEEK_CUR); }
 };
 
 /**
diff --git a/engines/kyra/resource/resource.cpp b/engines/kyra/resource/resource.cpp
index 502cb86524..6b8538046a 100644
--- a/engines/kyra/resource/resource.cpp
+++ b/engines/kyra/resource/resource.cpp
@@ -30,7 +30,7 @@ namespace Kyra {
 
 class EndianAwareStreamWrapper : public Common::SeekableReadStreamEndian {
 public:
-	EndianAwareStreamWrapper(Common::SeekableReadStream *stream, bool bigEndian, bool disposeAfterUse = true) : Common::SeekableReadStreamEndian(bigEndian), _stream(stream), _dispose(disposeAfterUse) {}
+	EndianAwareStreamWrapper(Common::SeekableReadStream *stream, bool bigEndian, bool disposeAfterUse = true) : Common::SeekableReadStreamEndian(bigEndian), Common::ReadStreamEndian(bigEndian), _stream(stream), _dispose(disposeAfterUse) {}
 	~EndianAwareStreamWrapper() override { if (_dispose) delete _stream; }
 
 	// Common::Stream interface
@@ -44,7 +44,7 @@ public:
 	int32 pos() const override { return _stream->pos(); }
 	int32 size() const override { return _stream->size(); }
 	bool seek(int32 offset, int whence = SEEK_SET) override { return _stream->seek(offset, whence); }
-	
+
 private:
 	Common::SeekableReadStream *_stream;
 	bool _dispose;
diff --git a/engines/saga/saga.h b/engines/saga/saga.h
index f69c4893e1..be6325cbed 100644
--- a/engines/saga/saga.h
+++ b/engines/saga/saga.h
@@ -457,7 +457,8 @@ public:
 class ByteArrayReadStreamEndian : public Common::MemoryReadStreamEndian {
 public:
 	ByteArrayReadStreamEndian(const ByteArray & byteArray, bool bigEndian = false)
-		: Common::MemoryReadStreamEndian(byteArray.getBuffer(), byteArray.size(), bigEndian) {
+		: Common::MemoryReadStreamEndian(byteArray.getBuffer(), byteArray.size(), bigEndian),
+		ReadStreamEndian(bigEndian) {
 	}
 };
 




More information about the Scummvm-git-logs mailing list