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

dreammaster paulfgilbert at gmail.com
Wed Feb 19 05:11:27 UTC 2020


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:
a840f128a1 ULTIMA8: Removing redundant code


Commit: a840f128a16f38730b4084e9322f80f367662a95
    https://github.com/scummvm/scummvm/commit/a840f128a16f38730b4084e9322f80f367662a95
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-02-18T20:49:02-08:00

Commit Message:
ULTIMA8: Removing redundant code

Changed paths:
  R engines/ultima/ultima8/filesys/dir_file.cpp
  R engines/ultima/ultima8/filesys/dir_file.h
  R engines/ultima/ultima8/filesys/list_files.cpp
    engines/ultima/ultima8/convert/convert_shape.cpp
    engines/ultima/ultima8/filesys/archive.cpp
    engines/ultima/ultima8/filesys/archive.h
    engines/ultima/ultima8/filesys/file_system.h
    engines/ultima/ultima8/filesys/idata_source.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/convert/convert_shape.cpp b/engines/ultima/ultima8/convert/convert_shape.cpp
index 28e291a..7275c58 100644
--- a/engines/ultima/ultima8/convert/convert_shape.cpp
+++ b/engines/ultima/ultima8/convert/convert_shape.cpp
@@ -400,11 +400,9 @@ int ConvertShape::CalcNumFrames(IDataSource *source, const ConvertShapeFormat *c
 		if (csf->_bytes_frameheader_unk) source->skip(csf->_bytes_frameheader_unk);
 
 		// Read frame_length
-#ifdef TODO
 		uint32 frame_length = real_len-frame_offset;
 		if (csf->_bytes_frame_length)
 			frame_length = source->readX(csf->_bytes_frame_length) + csf->_bytes_frame_length_kludge;
-#endif
 	}
 
 	source->seek(save_pos);
diff --git a/engines/ultima/ultima8/filesys/archive.cpp b/engines/ultima/ultima8/filesys/archive.cpp
index a405df4..8c59c7f 100644
--- a/engines/ultima/ultima8/filesys/archive.cpp
+++ b/engines/ultima/ultima8/filesys/archive.cpp
@@ -27,7 +27,6 @@
 #include "ultima/ultima8/filesys/named_archive_file.h"
 #include "ultima/ultima8/filesys/flex_file.h"
 #include "ultima/ultima8/filesys/u8_save_file.h"
-#include "ultima/ultima8/filesys/dir_file.h"
 
 namespace Ultima {
 namespace Ultima8 {
@@ -56,11 +55,6 @@ Archive::Archive(IDataSource *ids) {
 	addSource(ids);
 }
 
-Archive::Archive(const Std::string &path) {
-	_count = 0;
-	addSource(path);
-}
-
 bool Archive::addSource(ArchiveFile *af) {
 	_sources.push_back(af);
 
@@ -90,16 +84,6 @@ bool Archive::addSource(IDataSource *ids) {
 	return addSource(s);
 }
 
-bool Archive::addSource(const Std::string &path) {
-	ArchiveFile *s = new DirFile(path);
-	if (!s->isValid()) {
-		delete s;
-		return false;
-	}
-
-	return addSource(s);
-}
-
 void Archive::cache() {
 	for (unsigned int i = 0; i < _count; ++i)
 		cache(i);
diff --git a/engines/ultima/ultima8/filesys/archive.h b/engines/ultima/ultima8/filesys/archive.h
index 87a6509..af02839 100644
--- a/engines/ultima/ultima8/filesys/archive.h
+++ b/engines/ultima/ultima8/filesys/archive.h
@@ -47,10 +47,6 @@ public:
 	//! Will create FlexFile, U8SaveFile or ZipFile; ids will be deleted.
 	explicit Archive(IDataSource *ids);
 
-	//! create Archive with a single directory input source
-	//! Will create DirFile.
-	explicit Archive(const Std::string &path);
-
 	virtual ~Archive();
 
 	//! add input source.
@@ -62,10 +58,6 @@ public:
 	//! add input source, autodetecting the type (as the constructor)
 	bool addSource(IDataSource *ids);
 
-	//! add directory input source (as the constructor)
-	bool addSource(const Std::string &path);
-
-
 	//! Cache all objects
 	void cache();
 
diff --git a/engines/ultima/ultima8/filesys/dir_file.cpp b/engines/ultima/ultima8/filesys/dir_file.cpp
deleted file mode 100644
index 7e5c4e6..0000000
--- a/engines/ultima/ultima8/filesys/dir_file.cpp
+++ /dev/null
@@ -1,112 +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 2
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "ultima/ultima8/misc/pent_include.h"
-
-#include "ultima/ultima8/filesys/dir_file.h"
-#include "ultima/ultima8/filesys/idata_source.h"
-#include "ultima/ultima8/filesys/file_system.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-DEFINE_RUNTIME_CLASSTYPE_CODE(DirFile, NamedArchiveFile)
-
-DirFile::DirFile(const Std::string &path) {
-	_path = path;
-	if (_path.size() == 0) {
-		_valid = false;
-		return;
-	}
-
-	if (_path[_path.size() - 1] != '/') _path += "/";
-
-	_valid = readMetadata();
-}
-
-
-DirFile::~DirFile() {
-}
-
-bool DirFile::readMetadata() {
-	FileSystem *filesys = FileSystem::get_instance();
-	FileSystem::FileList files;
-
-	/*int ret =*/ filesys->ListFiles(_path + "*", files);
-
-	// TODO: check if directory actually exists
-
-	_count = files.size();
-
-	FileSystem::FileList::iterator iter;
-
-	for (iter = files.begin(); iter != files.end(); ++iter) {
-		Std::string name = *iter;
-		Std::string::size_type pos = name.rfind("/");
-		if (pos != Std::string::npos) {
-			name.erase(0, pos + 1);
-			//pout << "DirFile: " << name << Std::endl;
-			storeIndexedName(name);
-		}
-	}
-
-	return true;
-}
-
-bool DirFile::exists(const Std::string &name) {
-	FileSystem *filesys = FileSystem::get_instance();
-	IDataSource *ids = filesys->ReadFile(_path + name);
-	if (!ids) return false;
-
-	delete ids;
-	return true;
-}
-
-uint32 DirFile::getSize(const Std::string &name) {
-	FileSystem *filesys = FileSystem::get_instance();
-	IDataSource *ids = filesys->ReadFile(_path + name);
-	if (!ids) return 0;
-
-	uint32 size = ids->getSize();
-	delete ids;
-	return size;
-}
-
-uint8 *DirFile::getObject(const Std::string &name, uint32 *sizep) {
-	FileSystem *filesys = FileSystem::get_instance();
-	IDataSource *ids = filesys->ReadFile(_path + name);
-	if (!ids) return 0;
-
-	uint32 size = ids->getSize();
-	if (size == 0) return 0;
-
-	uint8 *buf = new uint8[size];
-	ids->read(buf, size);
-	delete ids;
-
-	if (sizep) *sizep = size;
-
-	return buf;
-}
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/filesys/dir_file.h b/engines/ultima/ultima8/filesys/dir_file.h
deleted file mode 100644
index 46c478c..0000000
--- a/engines/ultima/ultima8/filesys/dir_file.h
+++ /dev/null
@@ -1,61 +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 2
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ULTIMA8_FILESYS_DIRFILE_H
-#define ULTIMA8_FILESYS_DIRFILE_H
-
-#include "ultima/ultima8/filesys/named_archive_file.h"
-#include "ultima/ultima8/misc/p_dynamic_cast.h"
-#include "ultima/shared/std/string.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-class DirFile : public NamedArchiveFile {
-public:
-	ENABLE_RUNTIME_CLASSTYPE()
-
-	//! create DirFile from path
-	explicit DirFile(const Std::string &path);
-	~DirFile() override;
-
-	bool exists(const Std::string &name) override;
-
-	uint8 *getObject(const Std::string &name, uint32 *size = 0) override;
-
-	uint32 getSize(const Std::string &name) override;
-
-	uint32 getCount() override {
-		return _count;
-	}
-
-protected:
-	bool readMetadata();
-
-	Std::string _path;
-	uint32 _count;
-};
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima8/filesys/file_system.h b/engines/ultima/ultima8/filesys/file_system.h
index c618736..2b02032 100644
--- a/engines/ultima/ultima8/filesys/file_system.h
+++ b/engines/ultima/ultima8/filesys/file_system.h
@@ -77,14 +77,6 @@ public:
 	//! \return true if successful; otherwise, false.
 	bool MkDir(const Std::string &path); // can handle both paths and vpaths
 
-	typedef Common::List<Std::string> FileList;
-
-	//! List files matching a mask
-	//! \param mask the mask to match
-	//! \param files the FileList to which the found files are appended
-	//! \param return OS-specific (FIXME!)
-	int ListFiles(const Std::string mask, FileList &files);
-
 private:
 	static void switch_slashes(Std::string &name);
 	static bool base_to_uppercase(Std::string &str, int count);
diff --git a/engines/ultima/ultima8/filesys/idata_source.h b/engines/ultima/ultima8/filesys/idata_source.h
index 9a4e192..0f6ada1 100644
--- a/engines/ultima/ultima8/filesys/idata_source.h
+++ b/engines/ultima/ultima8/filesys/idata_source.h
@@ -112,59 +112,6 @@ public:
 	virtual Common::SeekableReadStream *GetRawStream() {
 		return 0;
 	}
-
-	/* SDL_RWops functions: */
-#if TODO
-	static int rw_seek(SDL_RWops *context, int offset, int whence) {
-		IDataSource *ids = static_cast<IDataSource *>
-		                   (context->hidden.unknown.data1);
-		switch (whence) {
-		case SEEK_SET:
-			ids->seek(offset);
-			break;
-		case SEEK_CUR:
-			ids->skip(offset);
-			break;
-		case SEEK_END:
-			ids->seek(ids->getSize() + offset);
-			break;
-		default:
-			return -1;
-			break;
-		}
-		return ids->getPos();
-	}
-	static int rw_read(SDL_RWops *context, void *ptr, int size, int maxnum) {
-		IDataSource *ids = static_cast<IDataSource *>
-		                   (context->hidden.unknown.data1);
-		if (size == 0) return 0;
-		int nbytes = ids->read(ptr, maxnum * size);
-		return (nbytes / size);
-	}
-	static int rw_write(SDL_RWops * /*context*/, const void * /*ptr*/,
-	                    int /*size*/, int /*num*/) {
-		return 0;
-	}
-	static int rw_close(SDL_RWops *context) {
-		IDataSource *ids = static_cast<IDataSource *>
-		                   (context->hidden.unknown.data1);
-		delete ids;
-		SDL_FreeRW(context);
-		return 0;
-	}
-
-	//! Create an SDL_RWops structure from this IDataSource.
-	//! It will delete the IDataSource (and itself) when closed.
-	SDL_RWops *getRWops() {
-		SDL_RWops *rwops = SDL_AllocRW();
-		rwops->seek = rw_seek;
-		rwops->read = rw_read;
-		rwops->write = rw_write;
-		rwops->close = rw_close;
-		rwops->hidden.unknown.data1 = static_cast<void *>(this);
-		return rwops;
-	}
-#endif
 };
 
 
diff --git a/engines/ultima/ultima8/filesys/list_files.cpp b/engines/ultima/ultima8/filesys/list_files.cpp
deleted file mode 100644
index 3c5b511..0000000
--- a/engines/ultima/ultima8/filesys/list_files.cpp
+++ /dev/null
@@ -1,91 +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 2
- * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef ULTIMA8_FILESYS_LISTFILES_H
-#define ULTIMA8_FILESYS_LISTFILES_H
-
-#include "ultima/shared/std/string.h"
-#include "ultima/ultima8/filesys/file_system.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-int FileSystem::ListFiles(const Std::string mask, FileList &files) {
-	// TODO: Figure out if this is for standard filesystem or saves
-#ifdef TODO
-	glob_t globres;
-	Std::string name(mask);
-
-	// get the 'root' (@u8 or whatever) stub
-	const Std::string rootpath(name.substr(0, name.find('/')));
-
-	// munge the path to a 'real' one.
-	if (!rewrite_virtual_path(name)) {
-		perr << "Warning: FileSystem sandbox violation when accessing:"
-		     << Std::endl << "\t" << mask << Std::endl;
-		return -1;
-	}
-
-#if 0
-	pout << "Root: " << rootpath << Std::endl;
-	pout << name << "\t" << name.size() << Std::endl;
-	pout << mask << '\t' << mask.size() << Std::endl;
-#endif
-
-	// calculate the difference in length between the real path, the
-	// original path, and the root @whatever
-	uint32 newplen = name.size() - mask.size() + rootpath.size();
-
-	int err = glob(name.c_str(), GLOB_NOSORT, 0, &globres);
-
-	switch (err) {
-	case 0:  //OK
-		for (unsigned int i = 0; i < globres.gl_pathc; i++) {
-			Std::string newfname(globres.gl_pathv[i]);
-#if 0
-			pout << newfname << Std::endl;
-#endif
-			newfname = rootpath + newfname.substr(newplen);
-			// If the OS uses anything other then / as a path seperator,
-			// they probably need to swap it back here...
-#if 0
-			pout << newfname << Std::endl;
-#endif
-			files.push_back(newfname);
-		}
-		globfree(&globres);
-		return 0;
-	case 3:  //no matches
-		return 0;
-	default: //error
-		perr << "Glob error " << err << Std::endl;
-		return err;
-	}
-#else
-	error("TODO: ListFiles");
-#endif
-}
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima8/filesys/raw_archive.h b/engines/ultima/ultima8/filesys/raw_archive.h
index d1ca3a3..8b74d17 100644
--- a/engines/ultima/ultima8/filesys/raw_archive.h
+++ b/engines/ultima/ultima8/filesys/raw_archive.h
@@ -39,7 +39,6 @@ public:
 	RawArchive() : Archive() { }
 	explicit RawArchive(ArchiveFile *af) : Archive(af) { }
 	explicit RawArchive(IDataSource *ids) : Archive(ids) { }
-	explicit RawArchive(const Std::string &path) : Archive(path) { }
 
 	~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 e5ebf17..706bff5 100644
--- a/engines/ultima/ultima8/graphics/fonts/font_shape_archive.h
+++ b/engines/ultima/ultima8/graphics/fonts/font_shape_archive.h
@@ -44,11 +44,7 @@ public:
 	FontShapeArchive(IDataSource *ds, uint16 id_, Palette *pal_ = 0,
 	                 const ConvertShapeFormat *format_ = 0)
 		: ShapeArchive(ds, id_, pal_, format_) { }
-	FontShapeArchive(const Std::string &path, uint16 id_,
-	                 Palette *pal_ = 0,
-	                 const ConvertShapeFormat *format_ = 0)
-		: ShapeArchive(path, id_, pal_, format_) { }
-
+ 
 	~FontShapeArchive() override { }
 
 	//! load HVLeads from u8.ini
diff --git a/engines/ultima/ultima8/graphics/gump_shape_archive.h b/engines/ultima/ultima8/graphics/gump_shape_archive.h
index 0174071..c79cd32 100644
--- a/engines/ultima/ultima8/graphics/gump_shape_archive.h
+++ b/engines/ultima/ultima8/graphics/gump_shape_archive.h
@@ -44,10 +44,6 @@ public:
 	GumpShapeArchive(IDataSource *ds, uint16 id_, Palette *pal_ = 0,
 	                 const ConvertShapeFormat *format_ = 0)
 		: ShapeArchive(ds, id_, pal_, format_) { }
-	GumpShapeArchive(const Std::string &path, uint16 id_,
-	                 Palette *pal_ = 0,
-	                 const ConvertShapeFormat *format_ = 0)
-		: ShapeArchive(path, id_, pal_, format_) { }
 
 	~GumpShapeArchive() override;
 
diff --git a/engines/ultima/ultima8/graphics/main_shape_archive.h b/engines/ultima/ultima8/graphics/main_shape_archive.h
index e3a7a85..1f8171f 100644
--- a/engines/ultima/ultima8/graphics/main_shape_archive.h
+++ b/engines/ultima/ultima8/graphics/main_shape_archive.h
@@ -48,10 +48,6 @@ public:
 	MainShapeArchive(IDataSource *ds, uint16 id_, Palette *pal_ = 0,
 	                 const ConvertShapeFormat *format_ = 0)
 		: ShapeArchive(ds, id_, pal_, format_), _typeFlags(0), _animDat(0) { }
-	MainShapeArchive(const Std::string &path, uint16 id_,
-	                 Palette *pal_ = 0,
-	                 const ConvertShapeFormat *format_ = 0)
-		: ShapeArchive(path, id_, pal_, format_), _typeFlags(0), _animDat(0) { }
 
 	~MainShapeArchive() override;
 
diff --git a/engines/ultima/ultima8/graphics/shape_archive.h b/engines/ultima/ultima8/graphics/shape_archive.h
index f6b6139..92b3611 100644
--- a/engines/ultima/ultima8/graphics/shape_archive.h
+++ b/engines/ultima/ultima8/graphics/shape_archive.h
@@ -46,10 +46,6 @@ public:
 	ShapeArchive(IDataSource *ds, uint16 id, Palette *pal = 0,
 	             const ConvertShapeFormat *format = 0)
 		: Archive(ds), _id(id), _format(format), _palette(pal) { }
-	ShapeArchive(const Std::string &path, uint16 id,
-	             Palette *pal = 0,
-	             const ConvertShapeFormat *format = 0)
-		: Archive(path), _id(id), _format(format), _palette(pal) { }
 
 	~ShapeArchive() override;
 




More information about the Scummvm-git-logs mailing list