[Scummvm-git-logs] scummvm master -> c6a121b112809b54f6dce5f977253e6ab2394d43
OMGPizzaGuy
noreply at scummvm.org
Tue Apr 2 02:06:38 UTC 2024
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:
04cc2a954d ULTIMA8: Initialize paths with "data" fallback directory.
c6a121b112 ULTIMA8: Remove FileSystem singleton class.
Commit: 04cc2a954d214bfd84f9817220d1ffcfe501d46a
https://github.com/scummvm/scummvm/commit/04cc2a954d214bfd84f9817220d1ffcfe501d46a
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2024-04-01T20:22:53-05:00
Commit Message:
ULTIMA8: Initialize paths with "data" fallback directory.
Changed paths:
engines/ultima/ultima8/filesys/file_system.cpp
engines/ultima/ultima8/ultima8.cpp
engines/ultima/ultima8/ultima8.h
diff --git a/engines/ultima/ultima8/filesys/file_system.cpp b/engines/ultima/ultima8/filesys/file_system.cpp
index c47c834fef5..c457aac51ae 100644
--- a/engines/ultima/ultima8/filesys/file_system.cpp
+++ b/engines/ultima/ultima8/filesys/file_system.cpp
@@ -45,11 +45,6 @@ Common::SeekableReadStream *FileSystem::ReadFile(const Common::Path &path) {
if (f->open(path))
return f;
- // Some games have some files in a "data" subdir.
- Common::Path altpath = Common::Path("data").join(path);
- if (f->open(altpath))
- return f;
-
delete f;
return nullptr;
}
diff --git a/engines/ultima/ultima8/ultima8.cpp b/engines/ultima/ultima8/ultima8.cpp
index 624709a9d6b..fd9860054d7 100644
--- a/engines/ultima/ultima8/ultima8.cpp
+++ b/engines/ultima/ultima8/ultima8.cpp
@@ -172,6 +172,12 @@ Common::Error Ultima8Engine::run() {
return result;
}
+void Ultima8Engine::initializePath(const Common::FSNode& gamePath) {
+ Engine::initializePath(gamePath);
+
+ // Crusader: No Regret (DOS/German)
+ SearchMan.addSubDirectoryMatching(gamePath, "data", 0, 4);
+}
bool Ultima8Engine::initialize() {
// Call syncSoundSettings to get default volumes set
@@ -183,7 +189,7 @@ bool Ultima8Engine::initialize() {
GUIErrorMessageFormat(_("Unable to locate the '%s' engine data file."), "ultima8.dat");
return false;
}
- SearchMan.add("data", archive);
+ SearchMan.add("ultima8.dat", archive);
return true;
}
diff --git a/engines/ultima/ultima8/ultima8.h b/engines/ultima/ultima8/ultima8.h
index 71a99fcc8e9..1490c646811 100644
--- a/engines/ultima/ultima8/ultima8.h
+++ b/engines/ultima/ultima8/ultima8.h
@@ -178,6 +178,8 @@ public:
Ultima8Engine(OSystem *syst, const Ultima::UltimaGameDescription *gameDesc);
~Ultima8Engine() override;
+ void initializePath(const Common::FSNode &gamePath) override;
+
static Ultima8Engine *get_instance() {
return _instance;
}
Commit: c6a121b112809b54f6dce5f977253e6ab2394d43
https://github.com/scummvm/scummvm/commit/c6a121b112809b54f6dce5f977253e6ab2394d43
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2024-04-01T20:22:53-05:00
Commit Message:
ULTIMA8: Remove FileSystem singleton class.
All file access now directly uses Common::File.
Changed paths:
R engines/ultima/ultima8/filesys/file_system.cpp
R engines/ultima/ultima8/filesys/file_system.h
engines/ultima/module.mk
engines/ultima/ultima8/audio/cru_music_process.cpp
engines/ultima/ultima8/conf/config_file_manager.cpp
engines/ultima/ultima8/games/cru_game.cpp
engines/ultima/ultima8/games/game_data.cpp
engines/ultima/ultima8/games/u8_game.cpp
engines/ultima/ultima8/graphics/fonts/font_manager.cpp
engines/ultima/ultima8/gumps/movie_gump.cpp
engines/ultima/ultima8/gumps/shape_viewer_gump.cpp
engines/ultima/ultima8/gumps/weasel_gump.cpp
engines/ultima/ultima8/misc/debugger.cpp
engines/ultima/ultima8/ultima8.cpp
engines/ultima/ultima8/ultima8.h
diff --git a/engines/ultima/module.mk b/engines/ultima/module.mk
index ad2782b6f77..1a60f83f034 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/file_system.o \
ultima8/filesys/flex_file.o \
ultima8/filesys/raw_archive.o \
ultima8/filesys/savegame.o \
diff --git a/engines/ultima/ultima8/audio/cru_music_process.cpp b/engines/ultima/ultima8/audio/cru_music_process.cpp
index a25c295f439..fdfb1426a37 100644
--- a/engines/ultima/ultima8/audio/cru_music_process.cpp
+++ b/engines/ultima/ultima8/audio/cru_music_process.cpp
@@ -19,12 +19,12 @@
*
*/
+#include "common/file.h"
#include "common/system.h"
#include "common/config-manager.h"
#include "ultima/ultima8/ultima8.h"
#include "ultima/ultima8/audio/cru_music_process.h"
-#include "ultima/ultima8/filesys/file_system.h"
#include "audio/mods/mod_xm_s3m.h"
#include "ultima/ultima8/world/world.h"
@@ -184,16 +184,15 @@ void CruMusicProcess::playMusic_internal(int track) {
if (track > 0) {
// TODO: It's a bit ugly having this here. Should be in GameData.
const Std::string fname = Std::string::format("sound/%s.amf", _trackNames[track]);
- FileSystem *filesystem = FileSystem::get_instance();
- assert(filesystem);
- Common::SeekableReadStream *rs = filesystem->ReadFile(fname.c_str());
- if (!rs) {
+ auto *rs = new Common::File();
+ if (!rs->open(Common::Path(fname))) {
// This happens in No Regret demo.
warning("Couldn't load AMF file: %s", fname.c_str());
+ delete rs;
return;
}
- Audio::AudioStream *stream = Audio::makeModXmS3mStream(rs, DisposeAfterUse::NO);
+ Audio::AudioStream *stream = Audio::makeModXmS3mStream(rs, DisposeAfterUse::YES);
if (!stream) {
error("Couldn't create stream from AMF file: %s", fname.c_str());
return;
diff --git a/engines/ultima/ultima8/conf/config_file_manager.cpp b/engines/ultima/ultima8/conf/config_file_manager.cpp
index 5153fcfdb6f..7c6451dc180 100644
--- a/engines/ultima/ultima8/conf/config_file_manager.cpp
+++ b/engines/ultima/ultima8/conf/config_file_manager.cpp
@@ -19,9 +19,10 @@
*
*/
+#include "common/file.h"
+
#include "ultima/ultima8/misc/debugger.h"
#include "ultima/ultima8/conf/config_file_manager.h"
-#include "ultima/ultima8/filesys/file_system.h"
namespace Ultima {
namespace Ultima8 {
@@ -44,8 +45,9 @@ ConfigFileManager::~ConfigFileManager() {
}
bool ConfigFileManager::readConfigFile(const Common::Path &fname, const Std::string &category) {
- Common::SeekableReadStream *f = FileSystem::get_instance()->ReadFile(fname);
- if (!f) return false;
+ Common::File f;
+ if (!f.open(fname))
+ return false;
ConfigFile *configFile = new ConfigFile();
configFile->_category = category;
@@ -53,7 +55,7 @@ bool ConfigFileManager::readConfigFile(const Common::Path &fname, const Std::str
// We need various characters as the inis are used for translations.
configFile->_iniFile.allowNonEnglishCharacters();
- if (!configFile->_iniFile.loadFromStream(*f)) {
+ if (!configFile->_iniFile.loadFromStream(f)) {
delete configFile;
return false;
}
diff --git a/engines/ultima/ultima8/filesys/file_system.cpp b/engines/ultima/ultima8/filesys/file_system.cpp
deleted file mode 100644
index c457aac51ae..00000000000
--- a/engines/ultima/ultima8/filesys/file_system.cpp
+++ /dev/null
@@ -1,53 +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/filesys/file_system.h"
-#include "ultima/ultima8/ultima8.h"
-#include "common/savefile.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-using Std::string;
-
-FileSystem *FileSystem::_fileSystem = nullptr;
-
-FileSystem::FileSystem() {
- _fileSystem = this;
-}
-
-FileSystem::~FileSystem() {
- _fileSystem = nullptr;
-}
-
-
-// Open a streaming file as readable. Streamed (0 on failure)
-Common::SeekableReadStream *FileSystem::ReadFile(const Common::Path &path) {
- Common::File *f = new Common::File();
- if (f->open(path))
- return f;
-
- delete f;
- return nullptr;
-}
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/filesys/file_system.h b/engines/ultima/ultima8/filesys/file_system.h
deleted file mode 100644
index 1ec318f182b..00000000000
--- a/engines/ultima/ultima8/filesys/file_system.h
+++ /dev/null
@@ -1,48 +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_FILESYSTEM_H
-#define ULTIMA8_FILESYS_FILESYSTEM_H
-
-#include "common/file.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-class FileSystem {
-public:
- FileSystem();
- ~FileSystem();
-
- static FileSystem *get_instance() {
- return _fileSystem;
- }
-
- Common::SeekableReadStream *ReadFile(const Common::Path &path);
-
-private:
- static FileSystem *_fileSystem;
-};
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima8/games/cru_game.cpp b/engines/ultima/ultima8/games/cru_game.cpp
index edc3e71efd4..672532496e9 100644
--- a/engines/ultima/ultima8/games/cru_game.cpp
+++ b/engines/ultima/ultima8/games/cru_game.cpp
@@ -20,12 +20,12 @@
*/
#include "common/config-manager.h"
+#include "common/file.h"
#include "common/translation.h"
#include "ultima/ultima8/misc/common_types.h"
#include "ultima/ultima8/games/cru_game.h"
#include "ultima/ultima8/games/start_crusader_process.h"
-#include "ultima/ultima8/filesys/file_system.h"
#include "ultima/ultima8/graphics/palette_manager.h"
#include "ultima/ultima8/gumps/movie_gump.h"
#include "ultima/ultima8/gumps/gump_notify_process.h"
@@ -56,15 +56,14 @@ CruGame::~CruGame() {
}
static bool loadPalette(const char *path, PaletteManager::PalIndex index) {
- Common::SeekableReadStream *pf = FileSystem::get_instance()->ReadFile(path);
- if (!pf) {
+ Common::File pf;
+ if (!pf.open(path)) {
warning("Unable to load %s", path);
return false;
}
Common::MemoryReadStream xfds(CruXFormPal, 1024);
- PaletteManager::get_instance()->load(index, *pf, xfds);
- delete pf;
+ PaletteManager::get_instance()->load(index, pf, xfds);
return true;
}
@@ -184,9 +183,10 @@ void CruGame::playDemoScreen() {
Kernel::get_instance()->addProcess(menuproc);
static const Common::Path bmp_filename = "static/buyme.dat";
- Common::SeekableReadStream *bmprs = FileSystem::get_instance()->ReadFile(bmp_filename);
- if (!bmprs) {
+ auto *bmprs = new Common::File();
+ if (!bmprs->open(bmp_filename)) {
warning("RemorseGame::playDemoScreen: error opening demo background: %s", bmp_filename.toString().c_str());
+ delete bmprs;
return;
}
Gump *gump = new CruDemoGump(bmprs);
@@ -202,17 +202,23 @@ void CruGame::playDemoScreen() {
ProcId CruGame::playCreditsNoMenu() {
static const Common::Path txt_filename = "static/credits.dat";
static const Common::Path bmp_filename = "static/cred.dat";
- Common::SeekableReadStream *txtrs = FileSystem::get_instance()->ReadFile(txt_filename);
- Common::SeekableReadStream *bmprs = FileSystem::get_instance()->ReadFile(bmp_filename);
+ auto *txtrs = new Common::File();
+ auto *bmprs = new Common::File();
- if (!txtrs) {
+ if (!txtrs->open(txt_filename)) {
warning("RemorseGame::playCredits: error opening credits text: %s", txt_filename.toString().c_str());
+ delete txtrs;
+ delete bmprs;
return 0;
}
- if (!bmprs) {
+
+ if (!bmprs->open(bmp_filename)) {
warning("RemorseGame::playCredits: error opening credits background: %s", bmp_filename.toString().c_str());
+ delete txtrs;
+ delete bmprs;
return 0;
}
+
Gump *creditsgump = new CruCreditsGump(txtrs, bmprs);
creditsgump->InitGump(nullptr);
creditsgump->CreateNotifier();
diff --git a/engines/ultima/ultima8/games/game_data.cpp b/engines/ultima/ultima8/games/game_data.cpp
index d8583fdf01f..d7b4a244c8c 100644
--- a/engines/ultima/ultima8/games/game_data.cpp
+++ b/engines/ultima/ultima8/games/game_data.cpp
@@ -20,11 +20,11 @@
*/
#include "common/config-manager.h"
+#include "common/file.h"
#include "ultima/ultima8/misc/common_types.h"
#include "ultima/ultima8/misc/util.h"
#include "ultima/ultima8/games/game_data.h"
-#include "ultima/ultima8/filesys/file_system.h"
#include "ultima/ultima8/usecode/usecode_flex.h"
#include "ultima/ultima8/graphics/main_shape_archive.h"
#include "ultima/ultima8/graphics/fonts/font_shape_archive.h"
@@ -225,10 +225,8 @@ FrameID GameData::translate(FrameID f) {
}
void GameData::loadU8Data() {
- FileSystem *filesystem = FileSystem::get_instance();
-
- Common::SeekableReadStream *fd = filesystem->ReadFile("static/fixed.dat");
- if (!fd)
+ auto *fd = new Common::File();
+ if (!fd->open("static/fixed.dat"))
error("Unable to load static/fixed.dat");
_fixed = new RawArchive(fd);
@@ -242,18 +240,16 @@ void GameData::loadU8Data() {
filename += "usecode.flx";
- Common::SeekableReadStream *uds = filesystem->ReadFile(filename.c_str());
- if (!uds)
+ auto *uds = new Common::File();
+ if (!uds->open(Common::Path(filename)))
error("Unable to load %s", filename.c_str());
_mainUsecode = new UsecodeFlex(uds);
// Load main shapes
debug(MM_INFO, "Load Shapes");
- Common::SeekableReadStream *sf = filesystem->ReadFile("static/u8shapes.flx");
- if (!sf) sf = filesystem->ReadFile("static/u8shapes.cmp");
-
- if (!sf)
+ auto *sf = new Common::File();
+ if (!(sf->open("static/u8shapes.flx") || sf->open("static/u8shapes.cmp")))
error("Unable to load static/u8shapes.flx or static/u8shapes.cmp");
_mainShapes = new MainShapeArchive(sf, MAINSHAPES,
@@ -267,24 +263,24 @@ void GameData::loadU8Data() {
config->readConfigFile("u8game.ini", "game");
// Load typeflags
- Common::SeekableReadStream *tfs = filesystem->ReadFile("static/typeflag.dat");
- if (!tfs)
+ auto *tfs = new Common::File();
+ if (!tfs->open("static/typeflag.dat"))
error("Unable to load static/typeflag.dat");
_mainShapes->loadTypeFlags(tfs);
delete tfs;
// Load animdat
- Common::SeekableReadStream *af = filesystem->ReadFile("static/anim.dat");
- if (!af)
+ auto *af = new Common::File();
+ if (!af->open("static/anim.dat"))
error("Unable to load static/anim.dat");
_mainShapes->loadAnimDat(af);
delete af;
// Load weapon overlay data
- Common::SeekableReadStream *wod = filesystem->ReadFile("static/wpnovlay.dat");
- if (!wod)
+ auto *wod = new Common::File();
+ if (!wod->open("static/wpnovlay.dat"))
error("Unable to load static/wpnovlay.dat");
RawArchive *overlayflex = new RawArchive(wod);
@@ -293,8 +289,8 @@ void GameData::loadU8Data() {
delete overlayflex;
// Load _globs
- Common::SeekableReadStream *gds = filesystem->ReadFile("static/glob.flx");
- if (!gds)
+ auto *gds = new Common::File();
+ if (!gds->open("static/glob.flx"))
error("Unable to load static/glob.flx");
RawArchive *globflex = new RawArchive(gds);
@@ -315,8 +311,8 @@ void GameData::loadU8Data() {
delete globflex;
// Load fonts
- Common::SeekableReadStream *fds = filesystem->ReadFile("static/u8fonts.flx");
- if (!fds)
+ auto *fds = new Common::File();
+ if (!fds->open("static/u8fonts.flx"))
error("Unable to load static/u8fonts.flx");
_fonts = new FontShapeArchive(fds, OTHER,
@@ -324,37 +320,37 @@ void GameData::loadU8Data() {
_fonts->setHVLeads();
// Load \mouse
- Common::SeekableReadStream *msds = filesystem->ReadFile("static/u8mouse.shp");
- if (!msds)
+ auto *msds = new Common::File();
+ if (!msds->open("static/u8mouse.shp"))
error("Unable to load static/u8mouse.shp");
_mouse = new Shape(msds, 0);
_mouse->setPalette(PaletteManager::get_instance()->getPalette(PaletteManager::Pal_Game));
delete msds;
- Common::SeekableReadStream *gumpds = filesystem->ReadFile("static/u8gumps.flx");
- if (!gumpds)
+ auto *gumpds = new Common::File();
+ if (!gumpds->open("static/u8gumps.flx"))
error("Unable to load static/u8gumps.flx");
_gumps = new GumpShapeArchive(gumpds, GUMPS,
PaletteManager::get_instance()->getPalette(PaletteManager::Pal_Game));
- Common::SeekableReadStream *gumpageds = filesystem->ReadFile("static/gumpage.dat");
- if (!gumpageds)
+ auto *gumpageds = new Common::File();
+ if (!gumpageds->open("static/gumpage.dat"))
error("Unable to load static/gumpage.dat");
_gumps->loadGumpage(gumpageds);
delete gumpageds;
- Common::SeekableReadStream *mf = filesystem->ReadFile("sound/music.flx");
- if (!mf)
+ auto *mf = new Common::File();
+ if (!mf->open("sound/music.flx"))
error("Unable to load sound/music.flx");
_music = new MusicFlex(mf);
- Common::SeekableReadStream *sndflx = filesystem->ReadFile("sound/sound.flx");
- if (!sndflx)
+ auto *sndflx = new Common::File();
+ if (!sndflx->open("sound/sound.flx"))
error("Unable to load sound/sound.flx");
_soundFlex = new SoundFlex(sndflx);
@@ -436,26 +432,25 @@ SpeechFlex *GameData::getSpeechFlex(uint32 shapeNum) {
return nullptr;
SpeechFlex **s = _speech[shapeNum];
- if (s) return *s;
-
- s = new SpeechFlex*;
- *s = nullptr;
+ if (s)
+ return *s;
char langletter = _gameInfo->getLanguageFileLetter();
if (!langletter) {
warning("GameData::getSpeechFlex: Unknown language.");
- delete s;
return nullptr;
}
Common::Path path(Common::String::format("sound/%c%i.flx", langletter, shapeNum));
- FileSystem *filesystem = FileSystem::get_instance();
- Common::SeekableReadStream *sflx = filesystem->ReadFile(path);
- if (sflx) {
- *s = new SpeechFlex(sflx);
+ auto *sflx = new Common::File();
+ if (!sflx->open(path)) {
+ delete sflx;
+ return nullptr;
}
+ s = new SpeechFlex *;
+ *s = new SpeechFlex(sflx);
_speech[shapeNum] = s;
return *s;
@@ -498,10 +493,8 @@ const FireType *GameData::getFireType(uint16 type) const {
}
void GameData::loadRemorseData() {
- FileSystem *filesystem = FileSystem::get_instance();
-
- Common::SeekableReadStream *fd = filesystem->ReadFile("static/fixed.dat");
- if (!fd)
+ auto *fd = new Common::File();
+ if (!fd->open("static/fixed.dat"))
error("Unable to load static/fixed.dat");
_fixed = new RawArchive(fd);
@@ -514,17 +507,16 @@ void GameData::loadRemorseData() {
filename += langletter;
filename += "usecode.flx";
- Common::SeekableReadStream *uds = filesystem->ReadFile(filename.c_str());
- if (!uds)
+ auto *uds = new Common::File();
+ if (!uds->open(filename.c_str()))
error("Unable to load %s", filename.c_str());
_mainUsecode = new UsecodeFlex(uds);
// Load main shapes
debug(MM_INFO, "Load Shapes");
- Common::SeekableReadStream *sf = filesystem->ReadFile("static/shapes.flx");
-
- if (!sf)
+ auto *sf = new Common::File();
+ if (!sf->open("static/shapes.flx"))
error("Unable to load static/shapes.flx");
_mainShapes = new MainShapeArchive(sf, MAINSHAPES,
@@ -541,24 +533,24 @@ void GameData::loadRemorseData() {
config->readConfigFile("remorsegame.ini", "game");
// Load typeflags
- Common::SeekableReadStream *tfs = filesystem->ReadFile("static/typeflag.dat");
- if (!tfs)
+ auto *tfs = new Common::File();
+ if (!tfs->open("static/typeflag.dat"))
error("Unable to load static/typeflag.dat");
_mainShapes->loadTypeFlags(tfs);
delete tfs;
// Load animdat
- Common::SeekableReadStream *af = filesystem->ReadFile("static/anim.dat");
- if (!af)
+ auto *af = new Common::File();
+ if (!af->open("static/anim.dat"))
error("Unable to load static/anim.dat");
_mainShapes->loadAnimDat(af);
delete af;
// Load weapon overlay data
- Common::SeekableReadStream *wod = filesystem->ReadFile("static/wpnovlay.dat");
- if (!wod)
+ auto *wod = new Common::File();
+ if (!wod->open("static/wpnovlay.dat"))
error("Unable to load static/wpnovlay.dat");
RawArchive *overlayflex = new RawArchive(wod);
@@ -567,8 +559,8 @@ void GameData::loadRemorseData() {
delete overlayflex;
// Load globs
- Common::SeekableReadStream *gds = filesystem->ReadFile("static/glob.flx");
- if (!gds)
+ auto *gds = new Common::File();
+ if (!gds->open("static/glob.flx"))
error("Unable to load static/glob.flx");
RawArchive *globflex = new RawArchive(gds);
@@ -589,8 +581,8 @@ void GameData::loadRemorseData() {
delete globflex;
// Load fonts
- Common::SeekableReadStream *fds = filesystem->ReadFile("static/fonts.flx");
- if (!fds)
+ auto *fds = new Common::File();
+ if (!fds->open("static/fonts.flx"))
error("Unable to load static/fonts.flx");
_fonts = new FontShapeArchive(fds, OTHER,
@@ -598,31 +590,31 @@ void GameData::loadRemorseData() {
_fonts->setHVLeads();
// Load mouse
- Common::SeekableReadStream *msds = filesystem->ReadFile("static/mouse.shp");
- if (!msds)
+ auto *msds = new Common::File();
+ if (!msds->open("static/mouse.shp"))
error("Unable to load static/mouse.shp");
_mouse = new Shape(msds, 0);
_mouse->setPalette(PaletteManager::get_instance()->getPalette(PaletteManager::Pal_Game));
delete msds;
- Common::SeekableReadStream *gumpds = filesystem->ReadFile("static/gumps.flx");
- if (!gumpds)
+ auto *gumpds = new Common::File();
+ if (!gumpds->open("static/gumps.flx"))
error("Unable to load static/gumps.flx");
_gumps = new GumpShapeArchive(gumpds, GUMPS,
PaletteManager::get_instance()->getPalette(PaletteManager::Pal_Game));
- Common::SeekableReadStream *dtableds = filesystem->ReadFile("static/dtable.flx");
- if (!dtableds)
+ auto *dtableds = new Common::File();
+ if (!dtableds->open("static/dtable.flx"))
error("Unable to load static/dtable.flx");
RawArchive *dtableflex = new RawArchive(dtableds);
_npcTable = NPCDat::load(dtableflex);
delete dtableflex;
- Common::SeekableReadStream *damageds = filesystem->ReadFile("static/damage.flx");
- if (!damageds)
+ auto *damageds = new Common::File();
+ if (!damageds->open("static/damage.flx"))
error("Unable to load static/damage.flx");
RawArchive *damageflex = new RawArchive(damageds);
@@ -633,8 +625,8 @@ void GameData::loadRemorseData() {
delete damageflex;
- Common::SeekableReadStream *combatds = filesystem->ReadFile("static/combat.dat");
- if (!combatds)
+ auto *combatds = new Common::File();
+ if (!combatds->open("static/combat.dat"))
error("Unable to load static/combat.dat");
RawArchive *combatflex = new RawArchive(combatds);
@@ -651,8 +643,8 @@ void GameData::loadRemorseData() {
delete combatflex;
- Common::SeekableReadStream *stuffds = filesystem->ReadFile("static/stuff.dat");
- if (!stuffds)
+ auto *stuffds = new Common::File();
+ if (!stuffds->open("static/stuff.dat"))
error("Unable to load static/stuff.dat");
// Weasel shop data.
@@ -665,8 +657,8 @@ void GameData::loadRemorseData() {
delete stuffds;
- Common::SeekableReadStream *xformpalds = filesystem->ReadFile("static/xformpal.dat");
- if (!xformpalds)
+ auto *xformpalds = new Common::File();
+ if (!xformpalds->open("static/xformpal.dat"))
error("Unable to load static/xformpal.dat");
RawArchive *xformpalflex = new RawArchive(xformpalds);
@@ -680,8 +672,8 @@ void GameData::loadRemorseData() {
// Note: No MusicFlex for Remorse, as the music is all in different AMF files.
// The remorse_music_process will load them.
- Common::SeekableReadStream *sndflx = filesystem->ReadFile("sound/sound.flx");
- if (!sndflx)
+ auto *sndflx = new Common::File();
+ if (!sndflx->open("sound/sound.flx"))
error("Unable to load sound/sound.flx");
_soundFlex = new SoundFlex(sndflx);
diff --git a/engines/ultima/ultima8/games/u8_game.cpp b/engines/ultima/ultima8/games/u8_game.cpp
index 2f62fa549fe..138815678b7 100644
--- a/engines/ultima/ultima8/games/u8_game.cpp
+++ b/engines/ultima/ultima8/games/u8_game.cpp
@@ -20,6 +20,7 @@
*/
#include "common/config-manager.h"
+#include "common/file.h"
#include "ultima/ultima8/misc/debugger.h"
@@ -27,7 +28,6 @@
#include "ultima/ultima8/graphics/palette_manager.h"
#include "ultima/ultima8/graphics/fade_to_modal_process.h"
-#include "ultima/ultima8/filesys/file_system.h"
#include "ultima/ultima8/games/game_data.h"
#include "ultima/ultima8/graphics/xform_blend.h"
#include "ultima/ultima8/filesys/u8_save_file.h"
@@ -70,16 +70,15 @@ U8Game::~U8Game() {
bool U8Game::loadFiles() {
// Load palette
debug(MM_INFO, "Load Palette");
- Common::SeekableReadStream *pf = FileSystem::get_instance()->ReadFile("static/u8pal.pal");
- if (!pf) {
+ Common::File pf;
+ if (!pf.open("static/u8pal.pal")) {
warning("Unable to load static/u8pal.pal.");
return false;
}
- pf->seek(4); // seek past header
+ pf.seek(4); // seek past header
Common::MemoryReadStream xfds(U8XFormPal, 1024);
- PaletteManager::get_instance()->load(PaletteManager::Pal_Game, *pf, xfds);
- delete pf;
+ PaletteManager::get_instance()->load(PaletteManager::Pal_Game, pf, xfds);
debug(MM_INFO, "Load GameData");
GameData::get_instance()->loadU8Data();
@@ -100,9 +99,10 @@ bool U8Game::startGame() {
// reserve ObjId 666 for the Guardian Bark hack
objman->reserveObjId(666);
- Common::SeekableReadStream *savers = FileSystem::get_instance()->ReadFile("savegame/u8save.000");
- if (!savers) {
+ auto *savers = new Common::File();
+ if (!savers->open("savegame/u8save.000")) {
warning("Unable to load savegame/u8save.000.");
+ delete savers;
return false;
}
U8SaveFile *u8save = new U8SaveFile(savers);
@@ -165,10 +165,10 @@ ProcId U8Game::playIntroMovie(bool fade) {
filename += langletter;
filename += "intro.skf";
- FileSystem *filesys = FileSystem::get_instance();
- Common::SeekableReadStream *skf = filesys->ReadFile(filename.c_str());
- if (!skf) {
+ auto *skf = new Common::File();
+ if (!skf->open(filename.c_str())) {
debug(MM_INFO, "U8Game::playIntro: movie not found.");
+ delete skf;
return 0;
}
@@ -177,10 +177,10 @@ ProcId U8Game::playIntroMovie(bool fade) {
ProcId U8Game::playEndgameMovie(bool fade) {
static const Common::Path filename = "static/endgame.skf";
- FileSystem *filesys = FileSystem::get_instance();
- Common::SeekableReadStream *skf = filesys->ReadFile(filename);
- if (!skf) {
+ auto *skf = new Common::File();
+ if (!skf->open(filename)) {
debug(MM_INFO, "U8Game::playEndgame: movie not found.");
+ delete skf;
return 0;
}
@@ -199,9 +199,10 @@ void U8Game::playCredits() {
filename += langletter;
filename += "credits.dat";
- Common::SeekableReadStream *rs = FileSystem::get_instance()->ReadFile(filename.c_str());
- if (!rs) {
+ auto *rs = new Common::File();
+ if (!rs->open(filename.c_str())) {
warning("U8Game::playCredits: error opening credits file: %s", filename.c_str());
+ delete rs;
return;
}
Std::string text = getCreditText(rs);
@@ -219,9 +220,10 @@ void U8Game::playCredits() {
void U8Game::playQuotes() {
static const Common::Path filename = "static/quotes.dat";
- Common::SeekableReadStream *rs = FileSystem::get_instance()->ReadFile(filename);
- if (!rs) {
+ auto *rs = new Common::File();
+ if (!rs->open(filename)) {
warning("U8Game::playQuotes: error opening quotes file: %s", filename.toString().c_str());
+ delete rs;
return;
}
const Std::string text = getCreditText(rs);
diff --git a/engines/ultima/ultima8/graphics/fonts/font_manager.cpp b/engines/ultima/ultima8/graphics/fonts/font_manager.cpp
index 2334824f9ac..157511405e4 100644
--- a/engines/ultima/ultima8/graphics/fonts/font_manager.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/font_manager.cpp
@@ -19,6 +19,9 @@
*
*/
+#include "common/config-manager.h"
+#include "common/file.h"
+
#include "ultima/ultima.h"
#include "ultima/ultima8/misc/common_types.h"
@@ -27,13 +30,11 @@
#include "ultima/ultima8/games/game_data.h"
#include "ultima/ultima8/graphics/fonts/shape_font.h"
#include "ultima/ultima8/graphics/fonts/font_shape_archive.h"
-#include "ultima/ultima8/filesys/file_system.h"
#include "ultima/ultima8/graphics/fonts/tt_font.h"
#include "ultima/ultima8/graphics/fonts/jp_font.h"
#include "ultima/ultima8/graphics/palette.h"
#include "ultima/ultima8/graphics/palette_manager.h"
-#include "common/config-manager.h"
#include "graphics/fonts/ttf.h"
namespace Ultima {
@@ -99,9 +100,8 @@ Graphics::Font *FontManager::getTTF_Font(const Common::Path &filename, int point
if (iter != _ttfFonts.end())
return iter->_value;
- Common::SeekableReadStream *fontids;
- fontids = FileSystem::get_instance()->ReadFile(filename);
- if (!fontids) {
+ Common::File fontids;
+ if (!fontids.open(filename)) {
warning("Failed to open TTF: %s", filename.toString().c_str());
return nullptr;
}
@@ -110,7 +110,7 @@ Graphics::Font *FontManager::getTTF_Font(const Common::Path &filename, int point
// open font using ScummVM TTF API
// Note: The RWops and ReadStream will be deleted by the TTF_Font
Graphics::TTFRenderMode mode = antialiasing ? Graphics::kTTFRenderModeNormal : Graphics::kTTFRenderModeMonochrome;
- Graphics::Font *font = Graphics::loadTTFFont(*fontids, pointsize, Graphics::kTTFSizeModeCharacter, 0, 0, mode, 0, false);
+ Graphics::Font *font = Graphics::loadTTFFont(fontids, pointsize, Graphics::kTTFSizeModeCharacter, 0, 0, mode, 0, false);
if (!font) {
warning("Failed to open TTF: %s", filename.toString().c_str());
diff --git a/engines/ultima/ultima8/gumps/movie_gump.cpp b/engines/ultima/ultima8/gumps/movie_gump.cpp
index 6060b2c9e79..419daae75d9 100644
--- a/engines/ultima/ultima8/gumps/movie_gump.cpp
+++ b/engines/ultima/ultima8/gumps/movie_gump.cpp
@@ -19,6 +19,8 @@
*
*/
+#include "common/file.h"
+
#include "ultima/ultima8/gumps/movie_gump.h"
#include "ultima/ultima8/graphics/avi_player.h"
@@ -42,8 +44,6 @@
#include "ultima/ultima8/gumps/cru_status_gump.h"
#include "ultima/ultima8/gumps/widgets/text_widget.h"
-#include "ultima/ultima8/filesys/file_system.h"
-
namespace Ultima {
namespace Ultima8 {
@@ -79,14 +79,14 @@ static Std::string _fixCrusaderMovieName(const Std::string &s) {
static Common::SeekableReadStream *_tryLoadCruMovieFile(const Std::string &filename, const char *extn) {
const Std::string path = Std::string::format("flics/%s.%s", filename.c_str(), extn);
- FileSystem *filesys = FileSystem::get_instance();
- Common::SeekableReadStream *rs = filesys->ReadFile(path.c_str());
- if (!rs) {
+ auto *rs = new Common::File();
+ if (!rs->open(path.c_str())) {
// Try with a "0" in the name
const Std::string adjustedfn = Std::string::format("flics/0%s.%s", filename.c_str(), extn);
- rs = filesys->ReadFile(adjustedfn.c_str());
- if (!rs)
+ if (!rs->open(adjustedfn.c_str())) {
+ delete rs;
return nullptr;
+ }
}
return rs;
}
diff --git a/engines/ultima/ultima8/gumps/shape_viewer_gump.cpp b/engines/ultima/ultima8/gumps/shape_viewer_gump.cpp
index fdc5f229868..05cf3cd8cb4 100644
--- a/engines/ultima/ultima8/gumps/shape_viewer_gump.cpp
+++ b/engines/ultima/ultima8/gumps/shape_viewer_gump.cpp
@@ -19,6 +19,8 @@
*
*/
+#include "common/file.h"
+
#include "ultima/ultima8/gumps/shape_viewer_gump.h"
#include "ultima/ultima8/graphics/render_surface.h"
@@ -39,7 +41,6 @@
#include "ultima/ultima8/graphics/mouse_shape_archive.h"
#include "ultima/ultima8/graphics/texture.h"
-#include "ultima/ultima8/filesys/file_system.h"
#include "ultima/ultima8/convert/u8/convert_shape_u8.h"
#include "ultima/ultima8/graphics/palette.h"
#include "ultima/ultima8/graphics/palette_manager.h"
@@ -356,21 +357,24 @@ void ShapeViewerGump::U8ShapeViewer() {
ShapeArchive *mouseShapes = new MouseShapeArchive(gamedata->getMouse(), GameData::OTHER);
archives.push_back(ShapeArchiveEntry("mouse", mouseShapes, DisposeAfterUse::YES));
- FileSystem *filesys = FileSystem::get_instance();
- Common::SeekableReadStream *eintro = filesys->ReadFile("static/eintro.skf");
- if (eintro) {
+ auto *eintro = new Common::File();
+ if (eintro->open("static/eintro.skf")) {
ShapeArchive *eintroshapes = new ShapeArchive(eintro, GameData::OTHER,
PaletteManager::get_instance()->getPalette(PaletteManager::Pal_Game),
&U8SKFShapeFormat);
archives.push_back(ShapeArchiveEntry("eintro", eintroshapes, DisposeAfterUse::YES));
+ } else {
+ delete eintro;
}
- Common::SeekableReadStream *endgame = filesys->ReadFile("static/endgame.skf");
- if (endgame) {
+ auto *endgame = new Common::File();
+ if (endgame->open("static/endgame.skf")) {
ShapeArchive *endgameshapes = new ShapeArchive(endgame, GameData::OTHER,
PaletteManager::get_instance()->getPalette(PaletteManager::Pal_Game),
&U8SKFShapeFormat);
archives.push_back(ShapeArchiveEntry("endgame", endgameshapes, DisposeAfterUse::YES));
+ } else {
+ delete endgame;
}
Gump *desktopGump = Ultima8Engine::get_instance()->getDesktopGump();
diff --git a/engines/ultima/ultima8/gumps/weasel_gump.cpp b/engines/ultima/ultima8/gumps/weasel_gump.cpp
index 1ce8f7fdc49..3e21729310d 100644
--- a/engines/ultima/ultima8/gumps/weasel_gump.cpp
+++ b/engines/ultima/ultima8/gumps/weasel_gump.cpp
@@ -35,7 +35,6 @@
#include "ultima/ultima8/audio/audio_process.h"
#include "ultima/ultima8/world/get_object.h"
#include "ultima/ultima8/world/item_factory.h"
-#include "ultima/ultima8/filesys/file_system.h"
namespace Ultima {
namespace Ultima8 {
diff --git a/engines/ultima/ultima8/misc/debugger.cpp b/engines/ultima/ultima8/misc/debugger.cpp
index fda82e736f1..244bd9c5389 100644
--- a/engines/ultima/ultima8/misc/debugger.cpp
+++ b/engines/ultima/ultima8/misc/debugger.cpp
@@ -20,13 +20,13 @@
*/
#include "common/config-manager.h"
+#include "common/file.h"
#include "common/tokenizer.h"
#include "image/png.h"
#include "image/bmp.h"
#include "ultima/ultima8/ultima8.h"
#include "ultima/ultima8/audio/audio_process.h"
#include "ultima/ultima8/audio/music_process.h"
-#include "ultima/ultima8/filesys/file_system.h"
#include "ultima/ultima8/games/game_data.h"
#include "ultima/ultima8/graphics/inverter_process.h"
#include "ultima/ultima8/graphics/main_shape_archive.h"
@@ -1749,10 +1749,10 @@ bool Debugger::cmdPlayMovie(int argc, const char **argv) {
}
Common::String filename = Common::String::format("static/%s.skf", argv[1]);
- FileSystem *filesys = FileSystem::get_instance();
- Common::SeekableReadStream *skf = filesys->ReadFile(filename.c_str());
- if (!skf) {
+ auto *skf = new Common::File();
+ if (!skf->open(filename.c_str())) {
debugPrintf("movie not found.\n");
+ delete skf;
return true;
}
diff --git a/engines/ultima/ultima8/ultima8.cpp b/engines/ultima/ultima8/ultima8.cpp
index fd9860054d7..265a4a42b77 100644
--- a/engines/ultima/ultima8/ultima8.cpp
+++ b/engines/ultima/ultima8/ultima8.cpp
@@ -19,6 +19,7 @@
*
*/
+#include "common/file.h"
#include "common/rational.h"
#include "common/translation.h"
#include "common/compression/unzip.h"
@@ -28,7 +29,6 @@
// TODO: !! a lot of these includes are just for some hacks... clean up sometime
#include "ultima/ultima8/conf/config_file_manager.h"
-#include "ultima/ultima8/filesys/file_system.h"
#include "ultima/ultima8/kernel/object_manager.h"
#include "ultima/ultima8/games/start_u8_process.h"
#include "ultima/ultima8/games/start_crusader_process.h"
@@ -126,7 +126,7 @@ Ultima8Engine *Ultima8Engine::_instance = nullptr;
Ultima8Engine::Ultima8Engine(OSystem *syst, const Ultima::UltimaGameDescription *gameDesc) :
Engine(syst), _gameDescription(gameDesc), _randomSource("Ultima8"),
- _isRunning(false), _gameInfo(nullptr), _fileSystem(nullptr),
+ _isRunning(false), _gameInfo(nullptr),
_configFileMan(nullptr), _saveCount(0), _game(nullptr), _lastError(Common::kNoError),
_kernel(nullptr), _objectManager(nullptr), _mouse(nullptr), _ucMachine(nullptr),
_screen(nullptr), _fontManager(nullptr), _paletteManager(nullptr), _gameData(nullptr),
@@ -151,7 +151,6 @@ Ultima8Engine::~Ultima8Engine() {
delete _world;
delete _fontManager;
delete _screen;
- delete _fileSystem;
delete _configFileMan;
delete _gameInfo;
@@ -227,7 +226,6 @@ Common::Error Ultima8Engine::startup() {
debug(MM_INFO, "-- Initializing Pentagram --");
_gameInfo = nullptr;
- _fileSystem = new FileSystem;
_configFileMan = new ConfigFileManager();
_fontManager = new FontManager();
_kernel = new Kernel();
diff --git a/engines/ultima/ultima8/ultima8.h b/engines/ultima/ultima8/ultima8.h
index 1490c646811..b689add966e 100644
--- a/engines/ultima/ultima8/ultima8.h
+++ b/engines/ultima/ultima8/ultima8.h
@@ -55,7 +55,6 @@ class Mouse;
class AvatarMoverProcess;
class Texture;
class AudioMixer;
-class FileSystem;
class ConfigFileManager;
struct GameInfo;
@@ -75,7 +74,6 @@ private:
const UltimaGameDescription *_gameDescription;
// minimal system
- FileSystem *_fileSystem;
ConfigFileManager *_configFileMan;
static Ultima8Engine *_instance;
More information about the Scummvm-git-logs
mailing list