[Scummvm-git-logs] scummvm master -> 4a26b5631cf7256f02d92275a9b4ab3330d810f3
mduggan
noreply at scummvm.org
Thu Dec 28 21:35:21 UTC 2023
This automated email contains information about 6 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
cde990a2f5 ULTIMA8: Switch U8SaveFile to inherit from Common::Archive
2b5aa2ea4d ULTIMA8: Remove unused methods and constructors for flex archives
a9656587e9 ULTIMA8: Merge ArchiveFile with FlexFile as there are no other derived classes.
7b4b059934 ULTIMA8: Fix variable naming on static methods for flex and save files
d746282206 ULTIMA8: Read flex file metadata instead of seeking back to the table.
4a26b5631c ULTIMA8: Remove superfluous get index count method for flex files
Commit: cde990a2f5627039cd6fa7bd7923018befef931f
https://github.com/scummvm/scummvm/commit/cde990a2f5627039cd6fa7bd7923018befef931f
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-12-29T08:35:15+11:00
Commit Message:
ULTIMA8: Switch U8SaveFile to inherit from Common::Archive
Changed paths:
R engines/ultima/ultima8/filesys/named_archive_file.h
engines/ultima/ultima8/audio/music_flex.cpp
engines/ultima/ultima8/audio/sound_flex.h
engines/ultima/ultima8/filesys/archive.cpp
engines/ultima/ultima8/filesys/archive.h
engines/ultima/ultima8/filesys/u8_save_file.cpp
engines/ultima/ultima8/filesys/u8_save_file.h
engines/ultima/ultima8/games/u8_game.cpp
engines/ultima/ultima8/world/actors/npc_dat.h
diff --git a/engines/ultima/ultima8/audio/music_flex.cpp b/engines/ultima/ultima8/audio/music_flex.cpp
index ccf3469b308..bd54c006dd5 100644
--- a/engines/ultima/ultima8/audio/music_flex.cpp
+++ b/engines/ultima/ultima8/audio/music_flex.cpp
@@ -19,6 +19,7 @@
*
*/
+#include "ultima/shared/std/string.h"
#include "ultima/ultima8/misc/debugger.h"
#include "ultima/ultima8/audio/music_flex.h"
diff --git a/engines/ultima/ultima8/audio/sound_flex.h b/engines/ultima/ultima8/audio/sound_flex.h
index 4f25f06262d..f4d29447993 100644
--- a/engines/ultima/ultima8/audio/sound_flex.h
+++ b/engines/ultima/ultima8/audio/sound_flex.h
@@ -22,6 +22,7 @@
#ifndef ULTIMA8_AUDIO_SOUNDFLEX_H
#define ULTIMA8_AUDIO_SOUNDFLEX_H
+#include "ultima/shared/std/string.h"
#include "ultima/ultima8/filesys/archive.h"
namespace Ultima {
diff --git a/engines/ultima/ultima8/filesys/archive.cpp b/engines/ultima/ultima8/filesys/archive.cpp
index dc227f5852f..2bbca5714c0 100644
--- a/engines/ultima/ultima8/filesys/archive.cpp
+++ b/engines/ultima/ultima8/filesys/archive.cpp
@@ -58,15 +58,15 @@ bool Archive::addSource(ArchiveFile *af) {
bool Archive::addSource(Common::SeekableReadStream *rs) {
ArchiveFile *s = nullptr;
- if (!rs) return false;
+ if (!rs)
+ return false;
if (FlexFile::isFlexFile(rs)) {
s = new FlexFile(rs);
- } else if (U8SaveFile::isU8SaveFile(rs)) {
- s = new U8SaveFile(rs);
}
- if (!s) return false;
+ if (!s)
+ return false;
if (!s->isValid()) {
delete s;
return false;
diff --git a/engines/ultima/ultima8/filesys/archive.h b/engines/ultima/ultima8/filesys/archive.h
index f057447f7c8..47da8541f88 100644
--- a/engines/ultima/ultima8/filesys/archive.h
+++ b/engines/ultima/ultima8/filesys/archive.h
@@ -22,8 +22,6 @@
#ifndef ULTIMA8_FILESYS_ARCHIVE_H
#define ULTIMA8_FILESYS_ARCHIVE_H
-#include "ultima/shared/std/string.h"
-
namespace Ultima {
namespace Ultima8 {
@@ -38,7 +36,7 @@ public:
explicit Archive(ArchiveFile *af);
//! create Archive with a single input source, autodetecting the type
- //! Will create FlexFile, U8SaveFile or ZipFile; ids will be deleted.
+ //! Will create FlexFile; ids will be deleted.
explicit Archive(Common::SeekableReadStream *rs);
virtual ~Archive();
diff --git a/engines/ultima/ultima8/filesys/named_archive_file.h b/engines/ultima/ultima8/filesys/named_archive_file.h
deleted file mode 100644
index 843c0679979..00000000000
--- a/engines/ultima/ultima8/filesys/named_archive_file.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef ULTIMA8_FILESYS_NAMEDARCHIVEFILE_H
-#define ULTIMA8_FILESYS_NAMEDARCHIVEFILE_H
-
-#include "ultima/ultima8/filesys/archive_file.h"
-#include "ultima/ultima8/misc/classtype.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-class NamedArchiveFile : public ArchiveFile {
-public:
- NamedArchiveFile() : _indexCount(0) { }
- ~NamedArchiveFile() override { }
-
- bool exists(uint32 index) override {
- Std::string name;
- return (indexToName(index, name));
- }
- bool exists(const Std::string &name) override = 0;
-
- uint8 *getObject(uint32 index, uint32 *size = 0) override {
- Std::string name;
- if (!indexToName(index, name))
- return nullptr;
- return getObject(name, size);
- }
- uint8 *getObject(const Std::string &name, uint32 *size = 0) override = 0;
-
- uint32 getSize(uint32 index) const override {
- Std::string name;
- if (!indexToName(index, name))
- return 0;
- return getSize(name);
- }
- uint32 getSize(const Std::string &name) const override = 0;
-
- uint32 getCount() const override = 0;
-
- uint32 getIndexCount() const override {
- return _indexCount;
- }
-
- bool isIndexed() const override {
- return false;
- }
- bool isNamed() const override {
- return true;
- }
-
-protected:
- bool indexToName(uint32 index, Std::string &name) const {
- Common::HashMap<uint32, Std::string>::const_iterator iter;
- iter = _indexedNames.find(index);
- if (iter == _indexedNames.end()) return false;
- name = iter->_value;
- return true;
- }
-
- void storeIndexedName(const Std::string &name) {
- uint32 index;
- bool hasIndex = extractIndexFromName(name, index);
- if (hasIndex) {
- _indexedNames[index] = name;
- if (index >= _indexCount) _indexCount = index + 1;
- }
- }
-
- Common::HashMap<uint32, Std::string> _indexedNames;
- uint32 _indexCount;
-};
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima8/filesys/u8_save_file.cpp b/engines/ultima/ultima8/filesys/u8_save_file.cpp
index 8db2fae01be..207e2a303fb 100644
--- a/engines/ultima/ultima8/filesys/u8_save_file.cpp
+++ b/engines/ultima/ultima8/filesys/u8_save_file.cpp
@@ -19,6 +19,7 @@
*
*/
+#include "common/memstream.h"
#include "ultima/ultima8/misc/debugger.h"
#include "ultima/ultima8/filesys/u8_save_file.h"
@@ -26,7 +27,7 @@
namespace Ultima {
namespace Ultima8 {
-U8SaveFile::U8SaveFile(Common::SeekableReadStream *rs) : _rs(rs), _count(0) {
+U8SaveFile::U8SaveFile(Common::SeekableReadStream *rs) : _rs(rs) {
_valid = isU8SaveFile(_rs);
if (_valid)
@@ -49,67 +50,56 @@ bool U8SaveFile::isU8SaveFile(Common::SeekableReadStream *_rs) {
bool U8SaveFile::readMetadata() {
_rs->seek(0x18);
- _count = _rs->readUint16LE();
+ uint16 count = _rs->readUint16LE();
- _offsets.resize(_count);
- _sizes.resize(_count);
-
- for (unsigned int i = 0; i < _count; ++i) {
+ for (unsigned int i = 0; i < count; ++i) {
uint32 namelen = _rs->readUint32LE();
- char *buf = new char[namelen];
- _rs->read(buf, static_cast<int32>(namelen));
- Std::string filename = buf;
- _indices[filename] = i;
- storeIndexedName(filename);
- delete[] buf;
- _sizes[i] = _rs->readUint32LE();
- _offsets[i] = _rs->pos();
- _rs->skip(_sizes[i]); // skip data
+ char *name = new char[namelen];
+ _rs->read(name, static_cast<int32>(namelen));
+
+ FileEntry fe;
+ fe._size = _rs->readUint32LE();
+ fe._offset = _rs->pos();
+
+ _map[Common::String(name)] = fe;
+ delete[] name;
+ _rs->skip(fe._size); // skip data
}
return true;
}
-bool U8SaveFile::findIndex(const Std::string &name, uint32 &index) const {
- Common::HashMap<Common::String, uint32>::const_iterator iter;
- iter = _indices.find(name);
- if (iter == _indices.end()) return false;
- index = iter->_value;
- return true;
+bool U8SaveFile::hasFile(const Common::Path &path) const {
+ return _map.contains(path.toString());
}
-bool U8SaveFile::exists(const Std::string &name) {
- uint32 index;
- return findIndex(name, index);
-}
+int U8SaveFile::listMembers(Common::ArchiveMemberList& list) const {
+ list.clear();
+ for (U8SaveFileMap::const_iterator it = _map.begin(); it != _map.end(); ++it) {
+ list.push_back(Common::ArchiveMemberPtr(new Common::GenericArchiveMember(it->_key, *this)));
+ }
-uint8 *U8SaveFile::getObject(const Std::string &name, uint32 *sizep) {
- uint32 index;
- if (!findIndex(name, index))
- return nullptr;
+ return list.size();
+}
- uint32 size = _sizes[index];
- if (size == 0)
+const Common::ArchiveMemberPtr U8SaveFile::getMember(const Common::Path& path) const {
+ if (!hasFile(path))
return nullptr;
- uint8 *object = new uint8[size];
- uint32 offset = _offsets[index];
-
- _rs->seek(offset);
- _rs->read(object, size);
-
- if (sizep) *sizep = size;
-
- return object;
+ Common::String name = path.toString();
+ return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, *this));
}
+Common::SeekableReadStream* U8SaveFile::createReadStreamForMember(const Common::Path& path) const {
+ if (!hasFile(path))
+ return nullptr;
-uint32 U8SaveFile::getSize(const Std::string &name) const {
- uint32 index;
- if (!findIndex(name, index))
- return 0;
+ const FileEntry &fe = _map[path.toString()];
+ uint8 *data = (uint8 *)malloc(fe._size);
+ _rs->seek(fe._offset);
+ _rs->read(data, fe._size);
- return _sizes[index];
+ return new Common::MemoryReadStream(data, fe._size, DisposeAfterUse::YES);
}
} // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/filesys/u8_save_file.h b/engines/ultima/ultima8/filesys/u8_save_file.h
index 04ef0c79f5b..5e38adabdd9 100644
--- a/engines/ultima/ultima8/filesys/u8_save_file.h
+++ b/engines/ultima/ultima8/filesys/u8_save_file.h
@@ -22,42 +22,49 @@
#ifndef ULTIMA8_FILESYS_U8SAVEFILE_H
#define ULTIMA8_FILESYS_U8SAVEFILE_H
-#include "ultima/ultima8/filesys/named_archive_file.h"
+#include "common/archive.h"
+
#include "ultima/shared/std/containers.h"
+#include "ultima/shared/std/string.h"
namespace Ultima {
namespace Ultima8 {
-class U8SaveFile : public NamedArchiveFile {
+class U8SaveFile : public Common::Archive {
public:
//! create U8SaveFile from datasource; U8SaveFile takes ownership of ds
//! and deletes it when destructed
explicit U8SaveFile(Common::SeekableReadStream *rs);
~U8SaveFile() override;
- bool exists(const Std::string &name) override;
-
- uint8 *getObject(const Std::string &name, uint32 *size = 0) override;
-
- uint32 getSize(const Std::string &name) const override;
-
- uint32 getCount() const override {
- return _count;
+ //! Check if constructed object is indeed a valid archive
+ bool isValid() const {
+ return _valid;
}
+ // Common::Archive API implementation
+ bool hasFile(const Common::Path &path) const override;
+ int listMembers(Common::ArchiveMemberList &list) const override;
+ const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override;
+ Common::SeekableReadStream *createReadStreamForMember(const Common::Path &path) const override;
+
static bool isU8SaveFile(Common::SeekableReadStream *rs);
protected:
Common::SeekableReadStream *_rs;
- uint32 _count;
+ bool _valid;
+
+ struct FileEntry {
+ uint32 _offset;
+ uint32 _size;
+ FileEntry() : _offset(0), _size(0) {}
+ };
- Common::HashMap<Common::String, uint32> _indices;
- Std::vector<uint32> _offsets;
- Std::vector<uint32> _sizes;
+ typedef Common::HashMap<Common::String, FileEntry, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> U8SaveFileMap;
+ U8SaveFileMap _map;
private:
bool readMetadata();
- bool findIndex(const Std::string &name, uint32 &index) const;
};
} // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/games/u8_game.cpp b/engines/ultima/ultima8/games/u8_game.cpp
index b247ec600db..4640ff3356e 100644
--- a/engines/ultima/ultima8/games/u8_game.cpp
+++ b/engines/ultima/ultima8/games/u8_game.cpp
@@ -107,19 +107,19 @@ bool U8Game::startGame() {
}
U8SaveFile *u8save = new U8SaveFile(savers);
- Common::SeekableReadStream *nfd = u8save->getDataSource("NONFIXED.DAT");
+ Common::SeekableReadStream *nfd = u8save->createReadStreamForMember("NONFIXED.DAT");
if (!nfd) {
warning("Unable to load savegame/u8save.000/NONFIXED.DAT.");
return false;
}
World::get_instance()->loadNonFixed(nfd); // deletes nfd
- Common::SeekableReadStream *icd = u8save->getDataSource("ITEMCACH.DAT");
+ Common::SeekableReadStream *icd = u8save->createReadStreamForMember("ITEMCACH.DAT");
if (!icd) {
warning("Unable to load savegame/u8save.000/ITEMCACH.DAT.");
return false;
}
- Common::SeekableReadStream *npcd = u8save->getDataSource("NPCDATA.DAT");
+ Common::SeekableReadStream *npcd = u8save->createReadStreamForMember("NPCDATA.DAT");
if (!npcd) {
warning("Unable to load savegame/u8save.000/NPCDATA.DAT.");
delete icd;
diff --git a/engines/ultima/ultima8/world/actors/npc_dat.h b/engines/ultima/ultima8/world/actors/npc_dat.h
index 98a1aabd78a..bf0322611cd 100644
--- a/engines/ultima/ultima8/world/actors/npc_dat.h
+++ b/engines/ultima/ultima8/world/actors/npc_dat.h
@@ -22,6 +22,7 @@
#ifndef WORLD_ACTORS_NPC_DAT_H
#define WORLD_ACTORS_NPC_DAT_H
+#include "ultima/shared/std/string.h"
#include "ultima/ultima8/filesys/raw_archive.h"
namespace Ultima {
Commit: 2b5aa2ea4da1641c1068e9c7c61d7e4de08c06e8
https://github.com/scummvm/scummvm/commit/2b5aa2ea4da1641c1068e9c7c61d7e4de08c06e8
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-12-29T08:35:15+11:00
Commit Message:
ULTIMA8: Remove unused methods and constructors for flex archives
Changed paths:
engines/ultima/ultima8/filesys/archive.cpp
engines/ultima/ultima8/filesys/archive.h
engines/ultima/ultima8/filesys/archive_file.h
engines/ultima/ultima8/filesys/flex_file.h
engines/ultima/ultima8/filesys/raw_archive.h
engines/ultima/ultima8/graphics/fonts/font_shape_archive.h
engines/ultima/ultima8/graphics/gump_shape_archive.h
engines/ultima/ultima8/graphics/main_shape_archive.h
engines/ultima/ultima8/graphics/shape_archive.h
diff --git a/engines/ultima/ultima8/filesys/archive.cpp b/engines/ultima/ultima8/filesys/archive.cpp
index 2bbca5714c0..2bd2a05b226 100644
--- a/engines/ultima/ultima8/filesys/archive.cpp
+++ b/engines/ultima/ultima8/filesys/archive.cpp
@@ -37,11 +37,6 @@ Archive::~Archive() {
_sources.clear();
}
-
-Archive::Archive(ArchiveFile *af) : _count(0) {
- addSource(af);
-}
-
Archive::Archive(Common::SeekableReadStream *rs) : _count(0) {
addSource(rs);
}
diff --git a/engines/ultima/ultima8/filesys/archive.h b/engines/ultima/ultima8/filesys/archive.h
index 47da8541f88..352baf44b74 100644
--- a/engines/ultima/ultima8/filesys/archive.h
+++ b/engines/ultima/ultima8/filesys/archive.h
@@ -32,9 +32,6 @@ public:
//! create Archive without any input sources
Archive();
- //! create Archive with a single input source
- explicit Archive(ArchiveFile *af);
-
//! create Archive with a single input source, autodetecting the type
//! Will create FlexFile; ids will be deleted.
explicit Archive(Common::SeekableReadStream *rs);
diff --git a/engines/ultima/ultima8/filesys/archive_file.h b/engines/ultima/ultima8/filesys/archive_file.h
index c30b4743515..a9934e62e5d 100644
--- a/engines/ultima/ultima8/filesys/archive_file.h
+++ b/engines/ultima/ultima8/filesys/archive_file.h
@@ -92,12 +92,6 @@ public:
//! store the indexed entries of this file
virtual uint32 getIndexCount() const = 0;
- //! is archive indexed?
- virtual bool isIndexed() const = 0;
-
- //! is archive named?
- virtual bool isNamed() const = 0;
-
protected:
static bool extractIndexFromName(const Std::string &name, uint32 &index);
diff --git a/engines/ultima/ultima8/filesys/flex_file.h b/engines/ultima/ultima8/filesys/flex_file.h
index 1d95c6ddc59..7a0bf51ad2a 100644
--- a/engines/ultima/ultima8/filesys/flex_file.h
+++ b/engines/ultima/ultima8/filesys/flex_file.h
@@ -72,13 +72,6 @@ public:
return _count;
}
- bool isIndexed() const override {
- return true;
- }
- bool isNamed() const override {
- return false;
- }
-
static bool isFlexFile(Common::SeekableReadStream *rs);
protected:
diff --git a/engines/ultima/ultima8/filesys/raw_archive.h b/engines/ultima/ultima8/filesys/raw_archive.h
index 1a82bb5f511..8078ac496a9 100644
--- a/engines/ultima/ultima8/filesys/raw_archive.h
+++ b/engines/ultima/ultima8/filesys/raw_archive.h
@@ -33,7 +33,6 @@ class IDataSource;
class RawArchive : public Archive {
public:
RawArchive() : Archive() { }
- explicit RawArchive(ArchiveFile *af) : Archive(af) { }
explicit RawArchive(Common::SeekableReadStream *rs) : Archive(rs) { }
~RawArchive() override;
diff --git a/engines/ultima/ultima8/graphics/fonts/font_shape_archive.h b/engines/ultima/ultima8/graphics/fonts/font_shape_archive.h
index ed32b75361a..46e2602bb13 100644
--- a/engines/ultima/ultima8/graphics/fonts/font_shape_archive.h
+++ b/engines/ultima/ultima8/graphics/fonts/font_shape_archive.h
@@ -34,9 +34,6 @@ public:
FontShapeArchive(uint16 id, Palette *pal = 0,
const ConvertShapeFormat *format = 0)
: ShapeArchive(id, pal, format) { }
- FontShapeArchive(ArchiveFile *af, uint16 id, Palette *pal = 0,
- const ConvertShapeFormat *format = 0)
- : ShapeArchive(af, id, pal, format) { }
FontShapeArchive(Common::SeekableReadStream *rs, uint16 id, Palette *pal = 0,
const ConvertShapeFormat *format = 0)
: ShapeArchive(rs, id, pal, format) { }
diff --git a/engines/ultima/ultima8/graphics/gump_shape_archive.h b/engines/ultima/ultima8/graphics/gump_shape_archive.h
index 10ae91756ad..30811716986 100644
--- a/engines/ultima/ultima8/graphics/gump_shape_archive.h
+++ b/engines/ultima/ultima8/graphics/gump_shape_archive.h
@@ -35,9 +35,6 @@ public:
GumpShapeArchive(uint16 id, Palette *pal = 0,
const ConvertShapeFormat *format = 0)
: ShapeArchive(id, pal, format) { }
- GumpShapeArchive(ArchiveFile *af, uint16 id, Palette *pal = 0,
- const ConvertShapeFormat *format = 0)
- : ShapeArchive(af, id, pal, format) { }
GumpShapeArchive(Common::SeekableReadStream *rs, uint16 id, Palette *pal = 0,
const ConvertShapeFormat *format = 0)
: ShapeArchive(rs, id, pal, format) { }
diff --git a/engines/ultima/ultima8/graphics/main_shape_archive.h b/engines/ultima/ultima8/graphics/main_shape_archive.h
index 06b174a5f31..aa7824ce9ef 100644
--- a/engines/ultima/ultima8/graphics/main_shape_archive.h
+++ b/engines/ultima/ultima8/graphics/main_shape_archive.h
@@ -38,9 +38,6 @@ public:
MainShapeArchive(uint16 id, Palette *pal = 0,
const ConvertShapeFormat *format = 0)
: ShapeArchive(id, pal, format), _typeFlags(0), _animDat(0) { }
- MainShapeArchive(ArchiveFile *af, uint16 id, Palette *pal = 0,
- const ConvertShapeFormat *format = 0)
- : ShapeArchive(af, id, pal, format), _typeFlags(0), _animDat(0) { }
MainShapeArchive(Common::SeekableReadStream *rs, uint16 id, Palette *pal = 0,
const ConvertShapeFormat *format = 0)
: ShapeArchive(rs, id, pal, format), _typeFlags(0), _animDat(0) { }
diff --git a/engines/ultima/ultima8/graphics/shape_archive.h b/engines/ultima/ultima8/graphics/shape_archive.h
index 80b9b0c171f..e59bcebcb12 100644
--- a/engines/ultima/ultima8/graphics/shape_archive.h
+++ b/engines/ultima/ultima8/graphics/shape_archive.h
@@ -36,9 +36,6 @@ public:
ShapeArchive(uint16 id, Palette *pal = 0,
const ConvertShapeFormat *format = 0)
: Archive(), _id(id), _format(format), _palette(pal) { }
- ShapeArchive(ArchiveFile *af, uint16 id, Palette *pal = 0,
- const ConvertShapeFormat *format = 0)
- : Archive(af), _id(id), _format(format), _palette(pal) { }
ShapeArchive(Common::SeekableReadStream *rs, uint16 id, Palette *pal = 0,
const ConvertShapeFormat *format = 0)
: Archive(rs), _id(id), _format(format), _palette(pal) { }
Commit: a9656587e9017e80f18917a744ca320f954c28ea
https://github.com/scummvm/scummvm/commit/a9656587e9017e80f18917a744ca320f954c28ea
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-12-29T08:35:15+11:00
Commit Message:
ULTIMA8: Merge ArchiveFile with FlexFile as there are no other derived classes.
Changed paths:
R engines/ultima/ultima8/filesys/archive_file.cpp
R engines/ultima/ultima8/filesys/archive_file.h
engines/ultima/module.mk
engines/ultima/ultima8/filesys/archive.cpp
engines/ultima/ultima8/filesys/archive.h
engines/ultima/ultima8/filesys/flex_file.cpp
engines/ultima/ultima8/filesys/flex_file.h
diff --git a/engines/ultima/module.mk b/engines/ultima/module.mk
index aed24caed1c..ad2782b6f77 100644
--- a/engines/ultima/module.mk
+++ b/engines/ultima/module.mk
@@ -416,7 +416,6 @@ MODULE_OBJS += \
ultima8/convert/u8/convert_shape_u8.o \
ultima8/convert/crusader/convert_shape_crusader.o \
ultima8/filesys/archive.o \
- ultima8/filesys/archive_file.o \
ultima8/filesys/file_system.o \
ultima8/filesys/flex_file.o \
ultima8/filesys/raw_archive.o \
diff --git a/engines/ultima/ultima8/filesys/archive.cpp b/engines/ultima/ultima8/filesys/archive.cpp
index 2bd2a05b226..396de84ac74 100644
--- a/engines/ultima/ultima8/filesys/archive.cpp
+++ b/engines/ultima/ultima8/filesys/archive.cpp
@@ -41,7 +41,7 @@ Archive::Archive(Common::SeekableReadStream *rs) : _count(0) {
addSource(rs);
}
-bool Archive::addSource(ArchiveFile *af) {
+bool Archive::addSource(FlexFile *af) {
_sources.push_back(af);
uint32 indexcount = af->getIndexCount();
@@ -51,17 +51,10 @@ bool Archive::addSource(ArchiveFile *af) {
}
bool Archive::addSource(Common::SeekableReadStream *rs) {
- ArchiveFile *s = nullptr;
-
if (!rs)
return false;
- if (FlexFile::isFlexFile(rs)) {
- s = new FlexFile(rs);
- }
-
- if (!s)
- return false;
+ FlexFile *s = new FlexFile(rs);
if (!s->isValid()) {
delete s;
return false;
@@ -81,7 +74,7 @@ void Archive::uncache() {
}
uint8 *Archive::getRawObject(uint32 index, uint32 *sizep) {
- ArchiveFile *f = findArchiveFile(index);
+ FlexFile *f = findArchiveFile(index);
if (!f)
return nullptr;
@@ -89,13 +82,13 @@ uint8 *Archive::getRawObject(uint32 index, uint32 *sizep) {
}
uint32 Archive::getRawSize(uint32 index) const {
- ArchiveFile *f = findArchiveFile(index);
+ FlexFile *f = findArchiveFile(index);
if (!f) return 0;
return f->getSize(index);
}
-ArchiveFile *Archive::findArchiveFile(uint32 index) const {
+FlexFile *Archive::findArchiveFile(uint32 index) const {
unsigned int n = _sources.size();
for (unsigned int i = 1; i <= n; ++i) {
if (_sources[n - i]->exists(index))
diff --git a/engines/ultima/ultima8/filesys/archive.h b/engines/ultima/ultima8/filesys/archive.h
index 352baf44b74..8e061fb338e 100644
--- a/engines/ultima/ultima8/filesys/archive.h
+++ b/engines/ultima/ultima8/filesys/archive.h
@@ -25,7 +25,7 @@
namespace Ultima {
namespace Ultima8 {
-class ArchiveFile;
+class FlexFile;
class Archive {
public:
@@ -39,10 +39,10 @@ public:
virtual ~Archive();
//! add input source.
- //! ArchiveFile will be deleted on destruction
+ //! FlexFile will be deleted on destruction
//! Input sources are used in the reversed order they are added.
//! Effect of adding sources after having accessed objects is undef.
- bool addSource(ArchiveFile *af);
+ bool addSource(FlexFile *af);
//! add input source, autodetecting the type (as the constructor)
bool addSource(Common::SeekableReadStream *rs);
@@ -76,9 +76,9 @@ protected:
uint32 getRawSize(uint32 index) const;
private:
- Std::vector<ArchiveFile *> _sources;
+ Std::vector<FlexFile *> _sources;
- ArchiveFile *findArchiveFile(uint32 index) const;
+ FlexFile *findArchiveFile(uint32 index) const;
};
} // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/filesys/archive_file.cpp b/engines/ultima/ultima8/filesys/archive_file.cpp
deleted file mode 100644
index 1a5392850fa..00000000000
--- a/engines/ultima/ultima8/filesys/archive_file.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "ultima/ultima8/misc/debugger.h"
-
-#include "ultima/ultima8/filesys/archive_file.h"
-#include "common/memstream.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-//static
-bool ArchiveFile::extractIndexFromName(const Std::string &name, uint32 &index) {
- if (name.size() == 0) return false;
-
- char *endptr;
- long val;
-
- val = strtol(name.c_str(), &endptr, 10);
-
- // if remainder of name doesn't start with a '.', invalid name
- if (*endptr != '\0' && *endptr != '.') return false;
-
- if (val < 0) return false;
-
- index = static_cast<uint32>(val);
-
- return true;
-}
-
-Common::SeekableReadStream *ArchiveFile::getDataSource(uint32 index, bool is_text) {
- uint32 size;
- uint8 *buf = getObject(index, &size);
-
- if (!buf)
- return nullptr;
-
- return new Common::MemoryReadStream(buf, size, DisposeAfterUse::YES);
-}
-
-Common::SeekableReadStream *ArchiveFile::getDataSource(const Std::string &name, bool is_text) {
- uint32 size;
- uint8 *buf = getObject(name, &size);
-
- if (!buf)
- return nullptr;
-
- return new Common::MemoryReadStream(buf, size, DisposeAfterUse::YES);
-}
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/filesys/archive_file.h b/engines/ultima/ultima8/filesys/archive_file.h
deleted file mode 100644
index a9934e62e5d..00000000000
--- a/engines/ultima/ultima8/filesys/archive_file.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef ULTIMA8_FILESYS_ARCHIVEFILE_H
-#define ULTIMA8_FILESYS_ARCHIVEFILE_H
-
-#include "ultima/shared/std/string.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-class ArchiveFile {
-public:
- virtual ~ArchiveFile() { }
-
- //! Check if constructed object is indeed a valid archive
- virtual bool isValid() const {
- return _valid;
- }
-
- //! Check if numbered object exists
- //! If the Flex has named objects, only objects with numerical names will
- //! be returned (the filename without the extension must be an integer)
- //! \param index index of object to check for
- virtual bool exists(uint32 index) = 0;
-
- //! Check if named object exists
- //! If the Flex is not named, name must be an integer with
- //! an optional extension
- //! \param name name of object to check for
- virtual bool exists(const Std::string &name) = 0;
-
-
- //! Get object from file; returns NULL if index is invalid.
- //! Must delete the returned buffer afterwards.
- //! See also exists(uint32 index)
- //! \param index index of object to fetch
- //! \param size if non-NULL, size of object is stored in *size
- virtual uint8 *getObject(uint32 index, uint32 *size = 0) = 0;
-
- //! Get named object from file; returns NULL if name is invalid.
- //! Must delete the returned buffer afterwards.
- //! See also exists(Std::string name)
- //! \param name name of object to fetch
- //! \param size if non-NULL, size of object is stored in *size
- virtual uint8 *getObject(const Std::string &name, uint32 *size = 0) = 0;
-
-
- //! Get size of object; returns zero if index is invalid.
- //! See also exists(uint32 index)
- //! \param index index of object to get size of
- virtual uint32 getSize(uint32 index) const = 0;
-
- //! Get size of named object; returns zero if name is invalid
- //! See also exists(Std::string name)
- //! \param index index of object to get size of
- virtual uint32 getSize(const Std::string &name) const = 0;
-
- //! Get object as a Common::SeekableReadStream
- //! Delete the SeekableReadStream afterwards; that will delete the data as well
- Common::SeekableReadStream *getDataSource(uint32 index, bool is_text = false);
-
- //! Get named as a Common::SeekableReadStream
- //! Delete the SeekableReadStream afterwards; that will delete the data as well
- Common::SeekableReadStream *getDataSource(const Std::string &name, bool is_text = false);
-
- //! Get upper bound for number of objects.
- //! In an indexed file this is (probably) the highest index plus one,
- //! while in a named file it's (probably) the actual count
- virtual uint32 getCount() const = 0;
-
- //! Get the highest index in the file
- //! Guaranteed to be sufficiently large for a vector that needs to
- //! store the indexed entries of this file
- virtual uint32 getIndexCount() const = 0;
-
-protected:
- static bool extractIndexFromName(const Std::string &name, uint32 &index);
-
- bool _valid;
-};
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima8/filesys/flex_file.cpp b/engines/ultima/ultima8/filesys/flex_file.cpp
index c5a7249b153..f586665d688 100644
--- a/engines/ultima/ultima8/filesys/flex_file.cpp
+++ b/engines/ultima/ultima8/filesys/flex_file.cpp
@@ -19,6 +19,8 @@
*
*/
+#include "common/memstream.h"
+
#include "ultima/ultima8/misc/debugger.h"
#include "ultima/ultima8/filesys/flex_file.h"
@@ -79,6 +81,16 @@ uint32 FlexFile::getOffset(uint32 index) {
return _rs->readUint32LE();
}
+Common::SeekableReadStream *FlexFile::getDataSource(uint32 index, bool is_text) {
+ uint32 size;
+ uint8 *buf = getObject(index, &size);
+
+ if (!buf)
+ return nullptr;
+
+ return new Common::MemoryReadStream(buf, size, DisposeAfterUse::YES);
+}
+
uint8 *FlexFile::getObject(uint32 index, uint32 *sizep) {
if (index >= _count)
return nullptr;
@@ -107,9 +119,5 @@ uint32 FlexFile::getSize(uint32 index) const {
return length;
}
-bool FlexFile::nameToIndex(const Std::string &name, uint32 &index) const {
- return extractIndexFromName(name, index);
-}
-
} // End of namespace Ultima8
} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/filesys/flex_file.h b/engines/ultima/ultima8/filesys/flex_file.h
index 7a0bf51ad2a..bf681379f82 100644
--- a/engines/ultima/ultima8/filesys/flex_file.h
+++ b/engines/ultima/ultima8/filesys/flex_file.h
@@ -22,63 +22,63 @@
#ifndef ULTIMA8_FILESYS_FLEXFILE_H
#define ULTIMA8_FILESYS_FLEXFILE_H
-#include "ultima/ultima8/filesys/archive_file.h"
-
namespace Ultima {
namespace Ultima8 {
-class FlexFile : public ArchiveFile {
+class FlexFile {
public:
//! create FlexFile from datasource; FlexFile takes ownership of ds
//! and deletes it when destructed
explicit FlexFile(Common::SeekableReadStream *rs);
- ~FlexFile() override;
-
- bool exists(uint32 index) override {
- return getSize(index) > 0;
- }
- bool exists(const Std::string &name) override {
- uint32 index;
- if (nameToIndex(name, index))
- return exists(index);
- else
- return false;
- }
+ ~FlexFile();
- uint8 *getObject(uint32 index, uint32 *size = nullptr) override;
- uint8 *getObject(const Std::string &name, uint32 *size = nullptr) override {
- uint32 index;
- if (nameToIndex(name, index))
- return getObject(index, size);
- else
- return nullptr;
+ //! Check if constructed object is indeed a valid archive
+ virtual bool isValid() const {
+ return _valid;
}
-
- uint32 getSize(uint32 index) const override;
- uint32 getSize(const Std::string &name) const override {
- uint32 index;
- if (nameToIndex(name, index))
- return getSize(index);
- else
- return 0;
+ //! Check if numbered object exists
+ //! \param index index of object to check for
+ bool exists(uint32 index) {
+ return getSize(index) > 0;
}
- uint32 getCount() const override {
+ //! Get object as a Common::SeekableReadStream
+ //! Delete the SeekableReadStream afterwards; that will delete the data as well
+ Common::SeekableReadStream *getDataSource(uint32 index, bool is_text = false);
+
+ //! Get object from file; returns NULL if index is invalid.
+ //! Must delete the returned buffer afterwards.
+ //! See also exists(uint32 index)
+ //! \param index index of object to fetch
+ //! \param size if non-NULL, size of object is stored in *size
+ uint8 *getObject(uint32 index, uint32 *size = nullptr);
+
+ //! Get size of object; returns zero if index is invalid.
+ //! See also exists(uint32 index)
+ //! \param index index of object to get size of
+ uint32 getSize(uint32 index) const;
+
+ //! Get upper bound for number of objects.
+ //! In an indexed file this is (probably) the highest index plus one,
+ //! while in a named file it's (probably) the actual count
+ uint32 getCount() const {
return _count;
}
- uint32 getIndexCount() const override {
+ //! Get the highest index in the file
+ //! Guaranteed to be sufficiently large for a vector that needs to
+ //! store the indexed entries of this file
+ uint32 getIndexCount() const {
return _count;
}
static bool isFlexFile(Common::SeekableReadStream *rs);
protected:
- bool nameToIndex(const Std::string &name, uint32 &index) const;
-
Common::SeekableReadStream *_rs;
uint32 _count;
+ bool _valid;
private:
uint32 getOffset(uint32 index);
Commit: 7b4b0599343eebd721f49fe6519df480a33ceb31
https://github.com/scummvm/scummvm/commit/7b4b0599343eebd721f49fe6519df480a33ceb31
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-12-29T08:35:15+11:00
Commit Message:
ULTIMA8: Fix variable naming on static methods for flex and save files
Changed paths:
engines/ultima/ultima8/filesys/flex_file.cpp
engines/ultima/ultima8/filesys/flex_file.h
engines/ultima/ultima8/filesys/u8_save_file.cpp
diff --git a/engines/ultima/ultima8/filesys/flex_file.cpp b/engines/ultima/ultima8/filesys/flex_file.cpp
index f586665d688..09d2ee62263 100644
--- a/engines/ultima/ultima8/filesys/flex_file.cpp
+++ b/engines/ultima/ultima8/filesys/flex_file.cpp
@@ -57,11 +57,11 @@ FlexFile::~FlexFile() {
}
//static
-bool FlexFile::isFlexFile(Common::SeekableReadStream *_rs) {
- _rs->seek(0);
+bool FlexFile::isFlexFile(Common::SeekableReadStream *rs) {
+ rs->seek(0);
int i;
char buf[FLEX_HDR_SIZE];
- _rs->read(buf, FLEX_HDR_SIZE);
+ rs->read(buf, FLEX_HDR_SIZE);
for (i = 0; i < FLEX_HDR_SIZE; ++i) {
if (buf[i] == FLEX_HDR_PAD) break;
diff --git a/engines/ultima/ultima8/filesys/flex_file.h b/engines/ultima/ultima8/filesys/flex_file.h
index bf681379f82..884922b09ee 100644
--- a/engines/ultima/ultima8/filesys/flex_file.h
+++ b/engines/ultima/ultima8/filesys/flex_file.h
@@ -33,7 +33,7 @@ public:
~FlexFile();
//! Check if constructed object is indeed a valid archive
- virtual bool isValid() const {
+ bool isValid() const {
return _valid;
}
diff --git a/engines/ultima/ultima8/filesys/u8_save_file.cpp b/engines/ultima/ultima8/filesys/u8_save_file.cpp
index 207e2a303fb..21980a9e9ed 100644
--- a/engines/ultima/ultima8/filesys/u8_save_file.cpp
+++ b/engines/ultima/ultima8/filesys/u8_save_file.cpp
@@ -39,10 +39,10 @@ U8SaveFile::~U8SaveFile() {
}
//static
-bool U8SaveFile::isU8SaveFile(Common::SeekableReadStream *_rs) {
- _rs->seek(0);
+bool U8SaveFile::isU8SaveFile(Common::SeekableReadStream *rs) {
+ rs->seek(0);
char buf[24];
- _rs->read(buf, 23);
+ rs->read(buf, 23);
buf[23] = '\0';
return (strncmp(buf, "Ultima 8 SaveGame File.", 23) == 0);
Commit: d746282206486223da841605e5798b7eb1359752
https://github.com/scummvm/scummvm/commit/d746282206486223da841605e5798b7eb1359752
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-12-29T08:35:15+11:00
Commit Message:
ULTIMA8: Read flex file metadata instead of seeking back to the table.
Changed paths:
engines/ultima/ultima8/filesys/flex_file.cpp
engines/ultima/ultima8/filesys/flex_file.h
engines/ultima/ultima8/filesys/u8_save_file.cpp
diff --git a/engines/ultima/ultima8/filesys/flex_file.cpp b/engines/ultima/ultima8/filesys/flex_file.cpp
index 09d2ee62263..a57ff3acdec 100644
--- a/engines/ultima/ultima8/filesys/flex_file.cpp
+++ b/engines/ultima/ultima8/filesys/flex_file.cpp
@@ -31,25 +31,11 @@ static const int FLEX_TABLE_OFFSET = 0x80;
static const int FLEX_HDR_SIZE = 0x52;
static const char FLEX_HDR_PAD = 0x1A;
-FlexFile::FlexFile(Common::SeekableReadStream *rs) : _rs(rs), _count(0) {
+FlexFile::FlexFile(Common::SeekableReadStream *rs) : _rs(rs) {
_valid = isFlexFile(_rs);
- if (_valid) {
- _rs->seek(FLEX_HDR_SIZE + 2);
- _count = _rs->readUint32LE();
- }
- if (_count > 4095) {
- // In practice the largest flex in either Crusader or U8 games has
- // 3074 entries, so this seems invalid.
- warning("Flex invalid: improbable number of entries %d", _count);
- _valid = false;
- _count = 0;
- }
- if (rs->size() < FLEX_TABLE_OFFSET + 8 * _count) {
- warning("Flex invalid: stream not long enough for offset table");
- _valid = false;
- _count = 0;
- }
+ if (_valid)
+ _valid = readMetadata();
}
FlexFile::~FlexFile() {
@@ -76,9 +62,33 @@ bool FlexFile::isFlexFile(Common::SeekableReadStream *rs) {
return false;
}
-uint32 FlexFile::getOffset(uint32 index) {
- _rs->seek(FLEX_TABLE_OFFSET + 8 * index);
- return _rs->readUint32LE();
+bool FlexFile::readMetadata() {
+ _rs->seek(FLEX_HDR_SIZE + 2);
+ uint32 count = _rs->readUint32LE();
+
+ if (count > 4095) {
+ // In practice the largest flex in either Crusader or U8 games has
+ // 3074 entries, so this seems invalid.
+ warning("Flex invalid: improbable number of entries %d", count);
+ return false;
+ }
+
+ if (_rs->size() < FLEX_TABLE_OFFSET + 8 * count) {
+ warning("Flex invalid: stream not long enough for offset table");
+ return false;
+ }
+
+ _entries.reserve(count);
+ _rs->seek(FLEX_TABLE_OFFSET);
+ for (unsigned int i = 0; i < count; ++i) {
+ FileEntry fe;
+ fe._offset = _rs->readUint32LE();
+ fe._size = _rs->readUint32LE();
+
+ _entries.push_back(fe);
+ }
+
+ return true;
}
Common::SeekableReadStream *FlexFile::getDataSource(uint32 index, bool is_text) {
@@ -92,31 +102,30 @@ Common::SeekableReadStream *FlexFile::getDataSource(uint32 index, bool is_text)
}
uint8 *FlexFile::getObject(uint32 index, uint32 *sizep) {
- if (index >= _count)
+ if (index >= _entries.size())
return nullptr;
- uint32 size = getSize(index);
+ uint32 size = _entries[index]._size;
if (size == 0)
return nullptr;
uint8 *object = new uint8[size];
- uint32 offset = getOffset(index);
+ uint32 offset = _entries[index]._offset;
_rs->seek(offset);
_rs->read(object, size);
- if (sizep) *sizep = size;
+ if (sizep)
+ *sizep = size;
return object;
}
uint32 FlexFile::getSize(uint32 index) const {
- if (index >= _count) return 0;
-
- _rs->seek(FLEX_TABLE_OFFSET + 4 + 8 * index);
- uint32 length = _rs->readUint32LE();
+ if (index >= _entries.size())
+ return 0;
- return length;
+ return _entries[index]._size;
}
} // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/filesys/flex_file.h b/engines/ultima/ultima8/filesys/flex_file.h
index 884922b09ee..8e5282cb740 100644
--- a/engines/ultima/ultima8/filesys/flex_file.h
+++ b/engines/ultima/ultima8/filesys/flex_file.h
@@ -63,25 +63,32 @@ public:
//! In an indexed file this is (probably) the highest index plus one,
//! while in a named file it's (probably) the actual count
uint32 getCount() const {
- return _count;
+ return _entries.size();
}
//! Get the highest index in the file
//! Guaranteed to be sufficiently large for a vector that needs to
//! store the indexed entries of this file
uint32 getIndexCount() const {
- return _count;
+ return _entries.size();
}
static bool isFlexFile(Common::SeekableReadStream *rs);
protected:
Common::SeekableReadStream *_rs;
- uint32 _count;
bool _valid;
+ struct FileEntry {
+ uint32 _offset;
+ uint32 _size;
+ FileEntry() : _offset(0), _size(0) {}
+ };
+
+ Common::Array<FileEntry> _entries;
+
private:
- uint32 getOffset(uint32 index);
+ bool readMetadata();
};
} // End of namespace Ultima8
diff --git a/engines/ultima/ultima8/filesys/u8_save_file.cpp b/engines/ultima/ultima8/filesys/u8_save_file.cpp
index 21980a9e9ed..cf7c8816e70 100644
--- a/engines/ultima/ultima8/filesys/u8_save_file.cpp
+++ b/engines/ultima/ultima8/filesys/u8_save_file.cpp
@@ -55,7 +55,7 @@ bool U8SaveFile::readMetadata() {
for (unsigned int i = 0; i < count; ++i) {
uint32 namelen = _rs->readUint32LE();
char *name = new char[namelen];
- _rs->read(name, static_cast<int32>(namelen));
+ _rs->read(name, namelen);
FileEntry fe;
fe._size = _rs->readUint32LE();
Commit: 4a26b5631cf7256f02d92275a9b4ab3330d810f3
https://github.com/scummvm/scummvm/commit/4a26b5631cf7256f02d92275a9b4ab3330d810f3
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-12-29T08:35:15+11:00
Commit Message:
ULTIMA8: Remove superfluous get index count method for flex files
Changed paths:
engines/ultima/ultima8/filesys/archive.cpp
engines/ultima/ultima8/filesys/flex_file.h
diff --git a/engines/ultima/ultima8/filesys/archive.cpp b/engines/ultima/ultima8/filesys/archive.cpp
index 396de84ac74..289dc20f286 100644
--- a/engines/ultima/ultima8/filesys/archive.cpp
+++ b/engines/ultima/ultima8/filesys/archive.cpp
@@ -44,8 +44,9 @@ Archive::Archive(Common::SeekableReadStream *rs) : _count(0) {
bool Archive::addSource(FlexFile *af) {
_sources.push_back(af);
- uint32 indexcount = af->getIndexCount();
- if (indexcount > _count) _count = indexcount;
+ uint32 indexcount = af->getCount();
+ if (indexcount > _count)
+ _count = indexcount;
return true;
}
diff --git a/engines/ultima/ultima8/filesys/flex_file.h b/engines/ultima/ultima8/filesys/flex_file.h
index 8e5282cb740..7a7f95e8bb7 100644
--- a/engines/ultima/ultima8/filesys/flex_file.h
+++ b/engines/ultima/ultima8/filesys/flex_file.h
@@ -66,13 +66,6 @@ public:
return _entries.size();
}
- //! Get the highest index in the file
- //! Guaranteed to be sufficiently large for a vector that needs to
- //! store the indexed entries of this file
- uint32 getIndexCount() const {
- return _entries.size();
- }
-
static bool isFlexFile(Common::SeekableReadStream *rs);
protected:
More information about the Scummvm-git-logs
mailing list