TSAGE: Migrate engine to Path

This commit is contained in:
Le Philousophe 2023-11-01 11:05:09 +01:00 committed by Eugene Sandulenko
parent e06e8761f1
commit c803257af9
6 changed files with 16 additions and 16 deletions

View File

@ -48,8 +48,8 @@ Common::Language TSageEngine::getLanguage() const {
return _gameDescription->desc.language;
}
Common::String TSageEngine::getPrimaryFilename() const {
return Common::String(_gameDescription->desc.filesDescriptions[0].fileName);
Common::Path TSageEngine::getPrimaryFilename() const {
return Common::Path(_gameDescription->desc.filesDescriptions[0].fileName);
}
} // End of namespace TsAGE

View File

@ -133,7 +133,7 @@ uint16 BitReader::readToken() {
/*-------------------------------------------------------------------------*/
TLib::TLib(MemoryManager &memManager, const Common::String &filename) :
TLib::TLib(MemoryManager &memManager, const Common::Path &filename) :
_filename(filename), _memoryManager(memManager) {
// If the resource strings list isn't yet loaded, load them
@ -156,7 +156,7 @@ TLib::TLib(MemoryManager &memManager, const Common::String &filename) :
Common::File f;
if (!f.open(filename))
error("Missing file %s", filename.c_str());
error("Missing file %s", filename.toString().c_str());
size = f.size() - 18; // First file header
data = (byte *)malloc(size);
@ -167,10 +167,10 @@ TLib::TLib(MemoryManager &memManager, const Common::String &filename) :
if (filename.equals("BLUE.RLB")) {
for (int i = 2; i < 9; i++) {
Common::String partname = Common::String::format("BLUE.#0%d", i);
Common::Path partname(Common::String::format("BLUE.#0%d", i));
if (!f.open(partname))
error("Missing file %s", partname.c_str());
error("Missing file %s", partname.toString().c_str());
uint32 partsize = f.size() - 4; // Further headers
byte *newdata = (byte *)realloc(data, size + partsize);
@ -188,7 +188,7 @@ TLib::TLib(MemoryManager &memManager, const Common::String &filename) :
}
}
warning("File %s: resulting size is %d bytes", filename.c_str(), size);
warning("File %s: resulting size is %d bytes", filename.toString().c_str(), size);
Common::MemoryReadStream *stream = new Common::MemoryReadStream(data, size, DisposeAfterUse::YES);
@ -198,7 +198,7 @@ TLib::TLib(MemoryManager &memManager, const Common::String &filename) :
Common::File *f = new Common::File;
if (!f->open(filename))
error("Missing file %s", filename.c_str());
error("Missing file %s", filename.toString().c_str());
_file = f;
}
@ -516,7 +516,7 @@ ResourceManager::~ResourceManager() {
delete _libList[idx];
}
void ResourceManager::addLib(const Common::String &libName) {
void ResourceManager::addLib(const Common::Path &libName) {
assert(_libList.size() < 5);
_libList.push_back(new TLib(g_vm->_memoryManager, libName));

View File

@ -144,17 +144,17 @@ private:
MemoryManager &_memoryManager;
private:
Common::SeekableReadStream *_file;
Common::String _filename;
Common::Path _filename;
ResourceList _resources;
SectionList _sections;
void loadSection(uint32 fileOffset);
void loadIndex();
public:
TLib(MemoryManager &memManager, const Common::String &filename);
TLib(MemoryManager &memManager, const Common::Path &filename);
~TLib();
const Common::String &getFilename() { return _filename; }
const Common::Path &getFilename() { return _filename; }
const SectionList &getSections() { return _sections; }
byte *getResource(uint16 id, bool suppressErrors = false);
byte *getResource(ResourceType resType, uint16 resNum, uint16 rlbNum, bool suppressErrors = false);
@ -170,7 +170,7 @@ private:
public:
~ResourceManager();
void addLib(const Common::String &libName);
void addLib(const Common::Path &libName);
byte *getResource(uint16 id, bool suppressErrors = false);
byte *getResource(ResourceType resType, uint16 resNum, uint16 rlbNum, bool suppressErrors = false);

View File

@ -2553,7 +2553,7 @@ PlayStream::~PlayStream() {
remove();
}
bool PlayStream::setFile(const Common::String &filename) {
bool PlayStream::setFile(const Common::Path &filename) {
remove();
// Open the resource file for access

View File

@ -438,7 +438,7 @@ public:
PlayStream();
~PlayStream() override;
bool setFile(const Common::String &filename);
bool setFile(const Common::Path &filename);
bool play(int voiceNum, EventHandler *endAction);
void stop();
bool isPlaying() const;

View File

@ -57,7 +57,7 @@ public:
uint32 getGameID() const;
uint32 getFeatures() const;
Common::Language getLanguage() const;
Common::String getPrimaryFilename() const;
Common::Path getPrimaryFilename() const;
virtual Common::Error init();
Common::Error run() override;