[Scummvm-git-logs] scummvm master -> 46444527a11638018f8bec12583ce33d59313a75
OMGPizzaGuy
48367439+OMGPizzaGuy at users.noreply.github.com
Sun Feb 21 20:20:38 UTC 2021
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
95df5223cf ULTIMA8: Remove IFileDataSource as it is no longer used
bbeb33d8d0 ULTIMA8: Replace use of OAutoBufferDataSource with MemoryWriteStreamDynamic
cb4defed89 ULTIMA8: Remove OAutoBufferDataSource as it is no longer used
46444527a1 ULTIMA8: Remove unused method in ODataSource
Commit: 95df5223cfac8e48c0ebf332ba74ddbbec159ec2
https://github.com/scummvm/scummvm/commit/95df5223cfac8e48c0ebf332ba74ddbbec159ec2
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2021-02-21T14:20:20-06:00
Commit Message:
ULTIMA8: Remove IFileDataSource as it is no longer used
Changed paths:
engines/ultima/ultima8/filesys/idata_source.h
diff --git a/engines/ultima/ultima8/filesys/idata_source.h b/engines/ultima/ultima8/filesys/idata_source.h
index c240c59d91..6a70ca46f0 100644
--- a/engines/ultima/ultima8/filesys/idata_source.h
+++ b/engines/ultima/ultima8/filesys/idata_source.h
@@ -72,40 +72,6 @@ public:
}
};
-
-class IFileDataSource: public IDataSource {
-private:
- Common::SeekableReadStream *_in;
-
-public:
- IFileDataSource(Common::SeekableReadStream *data_stream) : _in(data_stream) {
- }
-
- ~IFileDataSource() override {
- delete _in;
- }
-
- uint32 read(void *b, uint32 len) override {
- return _in->read(b, len);
- }
-
- bool seek(int32 position, int whence = SEEK_SET) override {
- return _in->seek(position, whence);
- }
-
- int32 size() const override {
- return _in->size();
- }
-
- int32 pos() const override {
- return _in->pos();
- }
-
- bool eos() const override {
- return _in->eos();
- }
-};
-
class IBufferDataSource : public IDataSource {
protected:
const uint8 *_buf;
Commit: bbeb33d8d0fe7eca764c3cba02137719ec15edd4
https://github.com/scummvm/scummvm/commit/bbeb33d8d0fe7eca764c3cba02137719ec15edd4
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2021-02-21T14:20:21-06:00
Commit Message:
ULTIMA8: Replace use of OAutoBufferDataSource with MemoryWriteStreamDynamic
Changed paths:
engines/ultima/ultima8/convert/convert_shape.cpp
engines/ultima/ultima8/filesys/savegame.cpp
engines/ultima/ultima8/filesys/savegame.h
engines/ultima/ultima8/ultima8.cpp
diff --git a/engines/ultima/ultima8/convert/convert_shape.cpp b/engines/ultima/ultima8/convert/convert_shape.cpp
index 7897de56fa..50bd51a027 100644
--- a/engines/ultima/ultima8/convert/convert_shape.cpp
+++ b/engines/ultima/ultima8/convert/convert_shape.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "common/memstream.h"
#include "ultima/ultima8/convert/convert_shape.h"
#include "ultima/ultima8/filesys/idata_source.h"
#include "ultima/ultima8/filesys/odata_source.h"
@@ -220,7 +221,7 @@ void ConvertShapeFrame::Read(IDataSource *source, const ConvertShapeFormat *csf,
}
void ConvertShapeFrame::ReadCmpFrame(IDataSource *source, const ConvertShapeFormat *csf, const uint8 special[256], ConvertShapeFrame *prev) {
- static OAutoBufferDataSource *rlebuf = nullptr;
+ Common::MemoryWriteStreamDynamic rlebuf(DisposeAfterUse::YES);
uint8 outbuf[512];
// Read unknown
@@ -235,11 +236,8 @@ void ConvertShapeFrame::ReadCmpFrame(IDataSource *source, const ConvertShapeForm
_line_offsets = new uint32 [_height];
- if (!rlebuf) rlebuf = new OAutoBufferDataSource(1024);
- rlebuf->clear();
-
for(int32 y = 0; y < _height; ++y) {
- _line_offsets[y] = rlebuf->pos();
+ _line_offsets[y] = rlebuf.pos();
int32 xpos = 0;
@@ -252,7 +250,7 @@ void ConvertShapeFrame::ReadCmpFrame(IDataSource *source, const ConvertShapeForm
skip = _width-(xpos-skip);
}
- rlebuf->writeByte(skip);
+ rlebuf.writeByte(skip);
if (xpos >= _width) break;
@@ -262,8 +260,8 @@ void ConvertShapeFrame::ReadCmpFrame(IDataSource *source, const ConvertShapeForm
// Is this required???? It seems hacky and pointless
if (dlen == 0 || dlen == 1) {
source->seek(-1, SEEK_CUR);
- rlebuf->seek(-1, SEEK_CUR);
- rlebuf->writeByte(skip + (_width - xpos));
+ rlebuf.seek(-1, SEEK_CUR);
+ rlebuf.writeByte(skip + (_width - xpos));
break;
}
@@ -305,20 +303,20 @@ void ConvertShapeFrame::ReadCmpFrame(IDataSource *source, const ConvertShapeForm
perr << "Error! Corrupt Frame. RLE dlen too large" << Std::endl;
}
- rlebuf->writeByte((dlen+extra) << _compression);
- rlebuf->write(outbuf,dlen+extra);
+ rlebuf.writeByte((dlen+extra) << _compression);
+ rlebuf.write(outbuf,dlen+extra);
} else {
- rlebuf->writeByte((dlen << 1) | 1);
- rlebuf->writeByte(source->readByte());
+ rlebuf.writeByte((dlen << 1) | 1);
+ rlebuf.writeByte(source->readByte());
xpos+=dlen;
}
} while (xpos < _width);
}
- _bytes_rle = rlebuf->pos();
+ _bytes_rle = rlebuf.pos();
_rle_data = new uint8[_bytes_rle];
- memcpy (_rle_data, rlebuf->getData(), _bytes_rle);
+ memcpy (_rle_data, rlebuf.getData(), _bytes_rle);
}
void ConvertShapeFrame::GetPixels(uint8 *buf, int32 count, int32 x, int32 y) {
diff --git a/engines/ultima/ultima8/filesys/savegame.cpp b/engines/ultima/ultima8/filesys/savegame.cpp
index 4bd8154f9a..0bd0f48e3a 100644
--- a/engines/ultima/ultima8/filesys/savegame.cpp
+++ b/engines/ultima/ultima8/filesys/savegame.cpp
@@ -22,7 +22,6 @@
#include "ultima/ultima8/filesys/savegame.h"
#include "ultima/ultima8/filesys/idata_source.h"
-#include "ultima/ultima8/filesys/odata_source.h"
namespace Ultima {
namespace Ultima8 {
@@ -128,8 +127,8 @@ bool SavegameWriter::writeFile(const Std::string &name, const uint8 *data, uint3
return true;
}
-bool SavegameWriter::writeFile(const Std::string &name, OAutoBufferDataSource *ods) {
- return writeFile(name, ods->getData(), ods->size());
+bool SavegameWriter::writeFile(const Std::string &name, Common::MemoryWriteStreamDynamic *buf) {
+ return writeFile(name, buf->getData(), buf->pos());
}
} // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/filesys/savegame.h b/engines/ultima/ultima8/filesys/savegame.h
index f1ae00f211..539b49150e 100644
--- a/engines/ultima/ultima8/filesys/savegame.h
+++ b/engines/ultima/ultima8/filesys/savegame.h
@@ -26,6 +26,7 @@
#include "ultima/shared/std/string.h"
#include "common/hashmap.h"
#include "common/stream.h"
+#include "common/memstream.h"
#include "engines/metaengine.h"
namespace Ultima {
@@ -33,7 +34,6 @@ namespace Ultima8 {
class ZipFile;
class IDataSource;
-class OAutoBufferDataSource;
class SavegameReader {
struct FileEntry {
@@ -82,10 +82,10 @@ public:
//! \param size (in bytes) of data
bool writeFile(const Std::string &name, const uint8 *data, uint32 size);
- //! write a file to the savegame from an OAutoBufferDataSource
+ //! write a file to the savegame from an memory stream
//! \param name name of the file
- //! \param buf the OBufferDataSource to save
- bool writeFile(const Std::string &name, OAutoBufferDataSource *buf);
+ //! \param buf the MemoryWriteStreamDynamic to save
+ bool writeFile(const Std::string &name, Common::MemoryWriteStreamDynamic *buf);
//! finish savegame
bool finish();
diff --git a/engines/ultima/ultima8/ultima8.cpp b/engines/ultima/ultima8/ultima8.cpp
index 21ffac010e..ff9ab5b4ff 100644
--- a/engines/ultima/ultima8/ultima8.cpp
+++ b/engines/ultima/ultima8/ultima8.cpp
@@ -941,53 +941,51 @@ Common::Error Ultima8Engine::saveGameStream(Common::WriteStream *stream, bool is
_saveCount++;
SavegameWriter *sgw = new SavegameWriter(stream);
-
- // We'll make it 2KB initially
- OAutoBufferDataSource buf(2048);
+ Common::MemoryWriteStreamDynamic buf(DisposeAfterUse::YES);
_gameInfo->save(&buf);
sgw->writeFile("GAME", &buf);
- buf.clear();
+ buf.seek(0);
writeSaveInfo(&buf);
sgw->writeFile("INFO", &buf);
- buf.clear();
+ buf.seek(0);
_kernel->save(&buf);
sgw->writeFile("KERNEL", &buf);
- buf.clear();
+ buf.seek(0);
_objectManager->save(&buf);
sgw->writeFile("OBJECTS", &buf);
- buf.clear();
+ buf.seek(0);
_world->save(&buf);
sgw->writeFile("WORLD", &buf);
- buf.clear();
+ buf.seek(0);
_world->saveMaps(&buf);
sgw->writeFile("MAPS", &buf);
- buf.clear();
+ buf.seek(0);
_world->getCurrentMap()->save(&buf);
sgw->writeFile("CURRENTMAP", &buf);
- buf.clear();
+ buf.seek(0);
_ucMachine->saveStrings(&buf);
sgw->writeFile("UCSTRINGS", &buf);
- buf.clear();
+ buf.seek(0);
_ucMachine->saveGlobals(&buf);
sgw->writeFile("UCGLOBALS", &buf);
- buf.clear();
+ buf.seek(0);
_ucMachine->saveLists(&buf);
sgw->writeFile("UCLISTS", &buf);
- buf.clear();
+ buf.seek(0);
save(&buf);
sgw->writeFile("APP", &buf);
- buf.clear();
+ buf.seek(0);
sgw->finish();
Commit: cb4defed8926301d1003de0bdb1643d54fcb6449
https://github.com/scummvm/scummvm/commit/cb4defed8926301d1003de0bdb1643d54fcb6449
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2021-02-21T14:20:21-06:00
Commit Message:
ULTIMA8: Remove OAutoBufferDataSource as it is no longer used
Changed paths:
engines/ultima/ultima8/filesys/odata_source.h
diff --git a/engines/ultima/ultima8/filesys/odata_source.h b/engines/ultima/ultima8/filesys/odata_source.h
index 1bbbd25996..2cbddba208 100644
--- a/engines/ultima/ultima8/filesys/odata_source.h
+++ b/engines/ultima/ultima8/filesys/odata_source.h
@@ -53,107 +53,6 @@ public:
};
};
-
-class OAutoBufferDataSource: public ODataSource {
-protected:
- uint8 *_buf;
- uint8 *_bufPtr;
- uint32 _size;
- uint32 _loc;
- uint32 _allocated;
-
- void checkResize(uint32 num_bytes) {
- // Increment loc
- _loc += num_bytes;
-
- // Don't need to resize
- if (_loc <= _size) return;
-
- // Reallocate the buffer
- if (_loc > _allocated) {
- // The old pointer position
- uint32 position = static_cast<uint32>(_bufPtr - _buf);
-
- // The new buffer and size (2 times what is needed)
- _allocated = _loc * 2;
- uint8 *new_buf = new uint8[_allocated];
-
- memcpy(new_buf, _buf, _size);
- delete [] _buf;
-
- _buf = new_buf;
- _bufPtr = _buf + position;
- }
-
- // Update size
- _size = _loc;
- }
-
-public:
- OAutoBufferDataSource(uint32 initial_len) : _size(0), _loc(0), _allocated(initial_len) {
- // Make the min allocated size 16 bytes
- if (_allocated < 16)
- _allocated = 16;
- _buf = _bufPtr = new uint8[_allocated];
- };
-
- //! Get a pointer to the data buffer.
- const uint8 *getData() {
- return _buf;
- }
-
- ~OAutoBufferDataSource() override {
- delete [] _buf;
- }
-
- uint32 write(const void *b, uint32 len) override {
- checkResize(len);
- Common::copy((const byte *)b, (const byte *)b + len, _bufPtr);
- _bufPtr += len;
- return len;
- };
-
- bool seek(int32 position, int whence = SEEK_SET) override {
- assert(whence == SEEK_SET);
- // No seeking past the end of the buffer
- if (position <= static_cast<int32>(_size)) _loc = position;
- else _loc = _size;
-
- _bufPtr = const_cast<unsigned char *>(_buf) + _loc;
- return true;
- };
-
- void skip(int32 position) override {
- // No seeking past the end
- if (position >= 0) {
- _loc += position;
- if (_loc > _size) _loc = _size;
- }
- // No seeking past the start
- else {
- uint32 invpos = -position;
- if (invpos > _loc) invpos = _loc;
- _loc -= invpos;
- }
- _bufPtr = const_cast<unsigned char *>(_buf) + _loc;
- };
-
- int32 size() const override {
- return _size;
- };
-
- int32 pos() const override {
- return static_cast<int32>(_bufPtr - _buf);
- };
-
- // Don't actually do anything substantial
- virtual void clear() {
- _bufPtr = _buf;
- _size = 0;
- _loc = 0;
- }
-};
-
} // End of namespace Ultima8
} // End of namespace Ultima
Commit: 46444527a11638018f8bec12583ce33d59313a75
https://github.com/scummvm/scummvm/commit/46444527a11638018f8bec12583ce33d59313a75
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2021-02-21T14:20:21-06:00
Commit Message:
ULTIMA8: Remove unused method in ODataSource
Changed paths:
engines/ultima/ultima8/filesys/odata_source.h
diff --git a/engines/ultima/ultima8/filesys/odata_source.h b/engines/ultima/ultima8/filesys/odata_source.h
index 2cbddba208..5b39545953 100644
--- a/engines/ultima/ultima8/filesys/odata_source.h
+++ b/engines/ultima/ultima8/filesys/odata_source.h
@@ -47,10 +47,6 @@ public:
else if (num_bytes == 3) writeUint24LE(val);
else writeUint32LE(val);
}
-
- virtual void skip(int32 delta) {
- seek(delta, SEEK_CUR);
- };
};
} // End of namespace Ultima8
More information about the Scummvm-git-logs
mailing list