mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-04 18:06:26 +00:00
VCRUISE: Migrate engine to Path
This commit is contained in:
parent
ca246ba56a
commit
1968695f6e
@ -421,11 +421,12 @@ void SfxData::load(Common::SeekableReadStream &stream, Audio::Mixer *mixer) {
|
||||
sfxPath.trim();
|
||||
}
|
||||
|
||||
sfxPath = Common::String("Sfx/") + sfxPath;
|
||||
Common::Path sfxPath_("Sfx/");
|
||||
sfxPath_.appendInPlace(sfxPath);
|
||||
|
||||
Common::File f;
|
||||
if (!f.open(sfxPath)) {
|
||||
warning("SfxData::load: Could not open sample file '%s'", sfxPath.c_str());
|
||||
if (!f.open(sfxPath_)) {
|
||||
warning("SfxData::load: Could not open sample file '%s'", sfxPath_.toString(Common::Path::kNativeSeparator).c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -2874,7 +2875,7 @@ void Runtime::changeToScreen(uint roomNumber, uint screenNumber) {
|
||||
} else if (_gameID == GID_REAH) {
|
||||
_scriptSet.reset();
|
||||
|
||||
Common::String logicFileName = Common::String::format("Log/Room%02i.log", static_cast<int>(roomNumber));
|
||||
Common::Path logicFileName(Common::String::format("Log/Room%02i.log", static_cast<int>(roomNumber)));
|
||||
Common::File logicFile;
|
||||
if (logicFile.open(logicFileName)) {
|
||||
_scriptSet = compileReahLogicFile(logicFile, static_cast<uint>(logicFile.size()), logicFileName);
|
||||
@ -2886,7 +2887,7 @@ void Runtime::changeToScreen(uint roomNumber, uint screenNumber) {
|
||||
|
||||
_map.clear();
|
||||
|
||||
Common::String mapFileName = Common::String::format("Map/Room%02i.map", static_cast<int>(roomNumber));
|
||||
Common::Path mapFileName(Common::String::format("Map/Room%02i.map", static_cast<int>(roomNumber)));
|
||||
Common::File mapFile;
|
||||
|
||||
if (mapFile.open(mapFileName)) {
|
||||
@ -3382,7 +3383,7 @@ void Runtime::changeMusicTrack(int track) {
|
||||
if (_musicMute && !_musicMuteDisabled)
|
||||
return;
|
||||
|
||||
Common::String wavFileName = Common::String::format("Sfx/Music-%02i.wav", static_cast<int>(track));
|
||||
Common::Path wavFileName(Common::String::format("Sfx/Music-%02i.wav", static_cast<int>(track)));
|
||||
Common::File *wavFile = new Common::File();
|
||||
if (wavFile->open(wavFileName)) {
|
||||
if (Audio::SeekableAudioStream *audioStream = Audio::makeWAVStream(wavFile, DisposeAfterUse::YES)) {
|
||||
@ -3392,7 +3393,7 @@ void Runtime::changeMusicTrack(int track) {
|
||||
_musicPlayer->play(applyVolumeScale(_musicVolume), 0);
|
||||
}
|
||||
} else {
|
||||
warning("Music file '%s' is missing", wavFileName.c_str());
|
||||
warning("Music file '%s' is missing", wavFileName.toString(Common::Path::kNativeSeparator).c_str());
|
||||
delete wavFile;
|
||||
}
|
||||
}
|
||||
@ -3419,7 +3420,8 @@ void Runtime::startScoreSection() {
|
||||
if (sectionDef.musicFileName.empty()) {
|
||||
_scoreSectionEndTime = sectionDef.volumeOrDurationInSeconds * 1000u + g_system->getMillis();
|
||||
} else {
|
||||
Common::String trackFileName = Common::String("Sfx/") + sectionDef.musicFileName;
|
||||
Common::Path trackFileName("Sfx/");
|
||||
trackFileName.appendInPlace(sectionDef.musicFileName);
|
||||
|
||||
Common::File *trackFile = new Common::File();
|
||||
if (trackFile->open(trackFileName)) {
|
||||
@ -3429,11 +3431,11 @@ void Runtime::startScoreSection() {
|
||||
|
||||
_scoreSectionEndTime = static_cast<uint32>(audioStream->getLength().msecs()) + g_system->getMillis();
|
||||
} else {
|
||||
warning("Couldn't create Vorbis stream for music file '%s'", trackFileName.c_str());
|
||||
warning("Couldn't create Vorbis stream for music file '%s'", trackFileName.toString(Common::Path::kNativeSeparator).c_str());
|
||||
delete trackFile;
|
||||
}
|
||||
} else {
|
||||
warning("Music file '%s' is missing", trackFileName.c_str());
|
||||
warning("Music file '%s' is missing", trackFileName.toString(Common::Path::kNativeSeparator).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3490,7 +3492,7 @@ void Runtime::changeAnimation(const AnimationDef &animDef, uint initialFrame, bo
|
||||
_animDecoder.reset();
|
||||
_animDecoderState = kAnimDecoderStateStopped;
|
||||
|
||||
Common::String aviFileName = Common::String::format("Anims/Anim%04i.avi", animFile);
|
||||
Common::Path aviFileName(Common::String::format("Anims/Anim%04i.avi", animFile));
|
||||
Common::File *aviFile = new Common::File();
|
||||
|
||||
if (aviFile->open(aviFileName)) {
|
||||
@ -3506,7 +3508,7 @@ void Runtime::changeAnimation(const AnimationDef &animDef, uint initialFrame, bo
|
||||
|
||||
applyAnimationVolume();
|
||||
|
||||
Common::String sfxFileName = Common::String::format("Sfx/Anim%04i.sfx", animFile);
|
||||
Common::Path sfxFileName(Common::String::format("Sfx/Anim%04i.sfx", animFile));
|
||||
Common::File sfxFile;
|
||||
|
||||
_sfxData.reset();
|
||||
@ -3515,14 +3517,14 @@ void Runtime::changeAnimation(const AnimationDef &animDef, uint initialFrame, bo
|
||||
_sfxData.load(sfxFile, _mixer);
|
||||
sfxFile.close();
|
||||
|
||||
Common::String dtaFileName = Common::String::format("Anims/Anim%04i.dta", animFile);
|
||||
Common::Path dtaFileName(Common::String::format("Anims/Anim%04i.dta", animFile));
|
||||
Common::File dtaFile;
|
||||
|
||||
if (dtaFile.open(dtaFileName))
|
||||
loadFrameData(&dtaFile);
|
||||
dtaFile.close();
|
||||
|
||||
Common::String twoDtFileName = Common::String::format("Dta/Anim%04i.2dt", animFile);
|
||||
Common::Path twoDtFileName(Common::String::format("Dta/Anim%04i.2dt", animFile));
|
||||
Common::File twoDtFile;
|
||||
|
||||
if (twoDtFile.open(twoDtFileName))
|
||||
@ -4231,11 +4233,11 @@ Common::SharedPtr<ScriptSet> Runtime::compileSchizmLogicSet(const uint *roomNumb
|
||||
if (roomNumber < _roomDuplicationOffsets.size())
|
||||
roomFile -= _roomDuplicationOffsets[roomNumber];
|
||||
|
||||
Common::String logicFileName = Common::String::format("Log/Room%02u.log", roomFile);
|
||||
Common::Path logicFileName(Common::String::format("Log/Room%02u.log", roomFile));
|
||||
|
||||
Common::File logicFile;
|
||||
if (logicFile.open(logicFileName)) {
|
||||
debug(1, "Compiling script %s...", logicFileName.c_str());
|
||||
debug(1, "Compiling script %s...", logicFileName.toString(Common::Path::kNativeSeparator).c_str());
|
||||
compileSchizmLogicFile(*scriptSet, roomNumber, roomFile, logicFile, static_cast<uint>(logicFile.size()), logicFileName, gs.get());
|
||||
logicFile.close();
|
||||
}
|
||||
@ -4704,11 +4706,13 @@ Common::String Runtime::getFileNameForItemGraphic(uint itemID) const {
|
||||
}
|
||||
|
||||
Common::SharedPtr<Graphics::Surface> Runtime::loadGraphic(const Common::String &graphicName, bool required) {
|
||||
Common::String filePath = Common::String("Gfx/") + graphicName + ".bmp";
|
||||
Common::Path filePath("Gfx/");
|
||||
filePath.appendInPlace(graphicName);
|
||||
filePath.appendInPlace(".bmp");
|
||||
|
||||
Common::File f;
|
||||
if (!f.open(filePath)) {
|
||||
warning("Couldn't open BMP file '%s'", filePath.c_str());
|
||||
warning("Couldn't open BMP file '%s'", filePath.toString(Common::Path::kNativeSeparator).c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -4718,7 +4722,7 @@ Common::SharedPtr<Graphics::Surface> Runtime::loadGraphic(const Common::String &
|
||||
|
||||
Image::BitmapDecoder bmpDecoder;
|
||||
if (!bmpDecoder.loadStream(f)) {
|
||||
warning("Failed to load BMP file '%s'", filePath.c_str());
|
||||
warning("Failed to load BMP file '%s'", filePath.toString(Common::Path::kNativeSeparator).c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -4729,7 +4733,7 @@ Common::SharedPtr<Graphics::Surface> Runtime::loadGraphic(const Common::String &
|
||||
}
|
||||
|
||||
bool Runtime::loadSubtitles(Common::CodePage codePage, bool guessCodePage) {
|
||||
Common::String filePath = Common::String::format("Log/Speech%02u.txt", _languageIndex);
|
||||
Common::Path filePath(Common::String::format("Log/Speech%02u.txt", _languageIndex));
|
||||
|
||||
Common::INIFile ini;
|
||||
|
||||
|
@ -150,7 +150,7 @@ struct ScriptNamedInstruction {
|
||||
|
||||
class ScriptCompiler {
|
||||
public:
|
||||
ScriptCompiler(TextParser &parser, const Common::String &blamePath, ScriptDialect dialect, uint loadAsRoom, uint fileRoom, IScriptCompilerGlobalState *gs);
|
||||
ScriptCompiler(TextParser &parser, const Common::Path &blamePath, ScriptDialect dialect, uint loadAsRoom, uint fileRoom, IScriptCompilerGlobalState *gs);
|
||||
|
||||
void compileScriptSet(ScriptSet *ss);
|
||||
|
||||
@ -179,7 +179,7 @@ private:
|
||||
|
||||
TextParser &_parser;
|
||||
NumberParsingMode _numberParsingMode;
|
||||
const Common::String _blamePath;
|
||||
const Common::Path _blamePath;
|
||||
|
||||
ScriptDialect _dialect;
|
||||
uint _loadAsRoom;
|
||||
@ -226,7 +226,7 @@ private:
|
||||
Common::Array<Common::SharedPtr<Script> > _functions;
|
||||
};
|
||||
|
||||
ScriptCompiler::ScriptCompiler(TextParser &parser, const Common::String &blamePath, ScriptDialect dialect, uint loadAsRoom, uint fileRoom, IScriptCompilerGlobalState *gs)
|
||||
ScriptCompiler::ScriptCompiler(TextParser &parser, const Common::Path &blamePath, ScriptDialect dialect, uint loadAsRoom, uint fileRoom, IScriptCompilerGlobalState *gs)
|
||||
: _numberParsingMode(kNumberParsingHex), _parser(parser), _blamePath(blamePath), _dialect(dialect), _loadAsRoom(loadAsRoom), _fileRoom(fileRoom), _gs(gs),
|
||||
_scrToken(nullptr), _eroomToken(nullptr) {
|
||||
}
|
||||
@ -1355,7 +1355,7 @@ ScriptSet::ScriptSet() {
|
||||
IScriptCompilerGlobalState::~IScriptCompilerGlobalState() {
|
||||
}
|
||||
|
||||
static void compileLogicFile(ScriptSet &scriptSet, Common::ReadStream &stream, uint streamSize, const Common::String &blamePath, ScriptDialect dialect, uint loadAsRoom, uint fileRoom, IScriptCompilerGlobalState *gs) {
|
||||
static void compileLogicFile(ScriptSet &scriptSet, Common::ReadStream &stream, uint streamSize, const Common::Path &blamePath, ScriptDialect dialect, uint loadAsRoom, uint fileRoom, IScriptCompilerGlobalState *gs) {
|
||||
LogicUnscrambleStream unscrambleStream(&stream, streamSize);
|
||||
TextParser parser(&unscrambleStream);
|
||||
|
||||
@ -1368,14 +1368,14 @@ Common::SharedPtr<IScriptCompilerGlobalState> createScriptCompilerGlobalState()
|
||||
return Common::SharedPtr<IScriptCompilerGlobalState>(new ScriptCompilerGlobalState());
|
||||
}
|
||||
|
||||
Common::SharedPtr<ScriptSet> compileReahLogicFile(Common::ReadStream &stream, uint streamSize, const Common::String &blamePath) {
|
||||
Common::SharedPtr<ScriptSet> compileReahLogicFile(Common::ReadStream &stream, uint streamSize, const Common::Path &blamePath) {
|
||||
Common::SharedPtr<ScriptSet> scriptSet(new ScriptSet());
|
||||
|
||||
compileLogicFile(*scriptSet, stream, streamSize, blamePath, kScriptDialectReah, 0, 0, nullptr);
|
||||
return scriptSet;
|
||||
}
|
||||
|
||||
void compileSchizmLogicFile(ScriptSet &scriptSet, uint loadAsRoom, uint fileRoom, Common::ReadStream &stream, uint streamSize, const Common::String &blamePath, IScriptCompilerGlobalState *gs) {
|
||||
void compileSchizmLogicFile(ScriptSet &scriptSet, uint loadAsRoom, uint fileRoom, Common::ReadStream &stream, uint streamSize, const Common::Path &blamePath, IScriptCompilerGlobalState *gs) {
|
||||
compileLogicFile(scriptSet, stream, streamSize, blamePath, kScriptDialectSchizm, loadAsRoom, fileRoom, gs);
|
||||
}
|
||||
|
||||
|
@ -284,8 +284,8 @@ struct IScriptCompilerGlobalState {
|
||||
};
|
||||
|
||||
Common::SharedPtr<IScriptCompilerGlobalState> createScriptCompilerGlobalState();
|
||||
Common::SharedPtr<ScriptSet> compileReahLogicFile(Common::ReadStream &stream, uint streamSize, const Common::String &blamePath);
|
||||
void compileSchizmLogicFile(ScriptSet &scriptSet, uint loadAsRoom, uint fileRoom, Common::ReadStream &stream, uint streamSize, const Common::String &blamePath, IScriptCompilerGlobalState *gs);
|
||||
Common::SharedPtr<ScriptSet> compileReahLogicFile(Common::ReadStream &stream, uint streamSize, const Common::Path &blamePath);
|
||||
void compileSchizmLogicFile(ScriptSet &scriptSet, uint loadAsRoom, uint fileRoom, Common::ReadStream &stream, uint streamSize, const Common::Path &blamePath, IScriptCompilerGlobalState *gs);
|
||||
bool checkSchizmLogicForDuplicatedRoom(Common::ReadStream &stream, uint streamSize);
|
||||
void optimizeScriptSet(ScriptSet &scriptSet);
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/path.h"
|
||||
#include "common/stream.h"
|
||||
#include "common/textconsole.h"
|
||||
|
||||
@ -125,36 +126,36 @@ void TextParser::requeue(const Common::String &str, const TextParserState &state
|
||||
requeue(str.c_str(), str.size(), state);
|
||||
}
|
||||
|
||||
void TextParser::expectToken(Common::String &outToken, const Common::String &blamePath) {
|
||||
void TextParser::expectToken(Common::String &outToken, const Common::Path &blamePath) {
|
||||
TextParserState state;
|
||||
expectTokenInternal(outToken, blamePath, state);
|
||||
}
|
||||
|
||||
void TextParser::expectShort(int16 &outInt, const Common::String &blamePath) {
|
||||
void TextParser::expectShort(int16 &outInt, const Common::Path &blamePath) {
|
||||
int i;
|
||||
expectInt(i, blamePath);
|
||||
outInt = static_cast<int16>(i);
|
||||
}
|
||||
|
||||
void TextParser::expectInt(int &outInt, const Common::String &blamePath) {
|
||||
void TextParser::expectInt(int &outInt, const Common::Path &blamePath) {
|
||||
Common::String token;
|
||||
TextParserState state;
|
||||
expectTokenInternal(token, blamePath, state);
|
||||
|
||||
if (!sscanf(token.c_str(), "%i", &outInt))
|
||||
error("Parsing error in '%s' at line %i col %i: Integer was malformed", blamePath.c_str(), static_cast<int>(state._lineNum), static_cast<int>(state._col));
|
||||
error("Parsing error in '%s' at line %i col %i: Integer was malformed", blamePath.toString(Common::Path::kNativeSeparator).c_str(), static_cast<int>(state._lineNum), static_cast<int>(state._col));
|
||||
}
|
||||
|
||||
void TextParser::expectUInt(uint &outUInt, const Common::String &blamePath) {
|
||||
void TextParser::expectUInt(uint &outUInt, const Common::Path &blamePath) {
|
||||
Common::String token;
|
||||
TextParserState state;
|
||||
expectTokenInternal(token, blamePath, state);
|
||||
|
||||
if (!sscanf(token.c_str(), "%u", &outUInt))
|
||||
error("Parsing error in '%s' at line %i col %i: Unsigned integer was malformed", blamePath.c_str(), static_cast<int>(state._lineNum), static_cast<int>(state._col));
|
||||
error("Parsing error in '%s' at line %i col %i: Unsigned integer was malformed", blamePath.toString(Common::Path::kNativeSeparator).c_str(), static_cast<int>(state._lineNum), static_cast<int>(state._col));
|
||||
}
|
||||
|
||||
void TextParser::expectLine(Common::String &outToken, const Common::String &blamePath, bool continueToNextLine) {
|
||||
void TextParser::expectLine(Common::String &outToken, const Common::Path &blamePath, bool continueToNextLine) {
|
||||
outToken.clear();
|
||||
|
||||
char c = 0;
|
||||
@ -187,13 +188,13 @@ void TextParser::expectLine(Common::String &outToken, const Common::String &blam
|
||||
outToken = outToken.substr(0, nonWhitespaceLength);
|
||||
}
|
||||
|
||||
void TextParser::expect(const char *str, const Common::String &blamePath) {
|
||||
void TextParser::expect(const char *str, const Common::Path &blamePath) {
|
||||
Common::String token;
|
||||
TextParserState state;
|
||||
expectTokenInternal(token, blamePath, state);
|
||||
|
||||
if (token != str)
|
||||
error("Parsing error in '%s' at line %i col %i: Expected token '%s' but found '%s'", blamePath.c_str(), static_cast<int>(state._lineNum), static_cast<int>(state._col), str, token.c_str());
|
||||
error("Parsing error in '%s' at line %i col %i: Expected token '%s' but found '%s'", blamePath.toString(Common::Path::kNativeSeparator).c_str(), static_cast<int>(state._lineNum), static_cast<int>(state._col), str, token.c_str());
|
||||
}
|
||||
|
||||
void TextParser::skipToEOL() {
|
||||
@ -236,9 +237,9 @@ bool TextParser::checkEOL() {
|
||||
}
|
||||
}
|
||||
|
||||
void TextParser::expectTokenInternal(Common::String &outToken, const Common::String &blamePath, TextParserState &outState) {
|
||||
void TextParser::expectTokenInternal(Common::String &outToken, const Common::Path &blamePath, TextParserState &outState) {
|
||||
if (!parseToken(outToken, outState))
|
||||
error("Parsing error in '%s' unexpected end of file", blamePath.c_str());
|
||||
error("Parsing error in '%s' unexpected end of file", blamePath.toString(Common::Path::kNativeSeparator).c_str());
|
||||
}
|
||||
|
||||
bool TextParser::parseToken(Common::String &outString, TextParserState &outState) {
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
namespace Common {
|
||||
|
||||
class Path;
|
||||
class ReadStream;
|
||||
|
||||
} // End of namespace Common
|
||||
@ -56,19 +57,19 @@ public:
|
||||
void requeue(const char *chars, uint numChars, const TextParserState &state);
|
||||
void requeue(const Common::String &str, const TextParserState &state);
|
||||
|
||||
void expectToken(Common::String &outToken, const Common::String &blamePath);
|
||||
void expectShort(int16 &outInt, const Common::String &blamePath);
|
||||
void expectInt(int &outInt, const Common::String &blamePath);
|
||||
void expectUInt(uint &outUInt, const Common::String &blamePath);
|
||||
void expectLine(Common::String &outToken, const Common::String &blamePath, bool continueToNextLine);
|
||||
void expectToken(Common::String &outToken, const Common::Path &blamePath);
|
||||
void expectShort(int16 &outInt, const Common::Path &blamePath);
|
||||
void expectInt(int &outInt, const Common::Path &blamePath);
|
||||
void expectUInt(uint &outUInt, const Common::Path &blamePath);
|
||||
void expectLine(Common::String &outToken, const Common::Path &blamePath, bool continueToNextLine);
|
||||
|
||||
void expect(const char *str, const Common::String &blamePath);
|
||||
void expect(const char *str, const Common::Path &blamePath);
|
||||
|
||||
void skipToEOL();
|
||||
bool checkEOL();
|
||||
|
||||
private:
|
||||
void expectTokenInternal(Common::String &outToken, const Common::String &blamePath, TextParserState &outState);
|
||||
void expectTokenInternal(Common::String &outToken, const Common::Path &blamePath, TextParserState &outState);
|
||||
|
||||
static bool isDelimiter(char c);
|
||||
static bool isCompoundDelimiter(char c1, char c2);
|
||||
|
@ -42,7 +42,7 @@
|
||||
namespace VCruise {
|
||||
|
||||
VCruiseEngine::VCruiseEngine(OSystem *syst, const VCruiseGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
|
||||
const Common::FSNode gameDataDir(ConfMan.get("path"));
|
||||
const Common::FSNode gameDataDir(ConfMan.getPath("path"));
|
||||
}
|
||||
|
||||
VCruiseEngine::~VCruiseEngine() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user