SLUDGE: add game file name getter in detection

This commit is contained in:
yinsimei 2017-06-06 01:04:17 +02:00 committed by Eugene Sandulenko
parent 2ca6845962
commit d5379c212c
9 changed files with 17 additions and 65 deletions

View File

@ -37,6 +37,9 @@ int SludgeEngine::getGameType() const { return _gameDescription->gameType; }
const char *SludgeEngine::getGameId() const { return _gameDescription->desc.gameId;}
uint32 SludgeEngine::getFeatures() const { return _gameDescription->desc.flags; }
Common::Language SludgeEngine::getLanguage() const { return _gameDescription->desc.language; }
const char *SludgeEngine::getGameFile() const {
return _gameDescription->desc.filesDescriptions[0].fileName;
}
} // End of namespace Sludge

View File

@ -81,7 +81,7 @@ char *getPrefsFilename(char *filename) {
return joined;
}
void readIniFile(char *filename) {
void readIniFile(const char *filename) {
char *langName = getPrefsFilename(copyString(filename));
@ -161,7 +161,7 @@ void readIniFile(char *filename) {
fd.close();
}
void saveIniFile(char *filename) {
void saveIniFile(const char *filename) {
#if 0
char *langName = getPrefsFilename(copyString(filename));
FILE *fp = fopen(langName, "wt");

View File

@ -41,8 +41,8 @@ struct settingsStruct {
extern settingsStruct gameSettings;
void readIniFile(char *filename);
void saveIniFile(char *filename);
void readIniFile(const char *filename);
void saveIniFile(const char *filename);
int getLanguageForFileB();
void makeLanguageTable(Common::File *table);

View File

@ -295,7 +295,7 @@ void checkInput() {
#endif
}
int main_loop(char *filename)
int main_loop(const char *filename)
#if 0
try
#endif
@ -304,62 +304,9 @@ int main_loop(char *filename)
winWidth = 640;
winHeight = 480;
char *sludgeFile;
#if 0
time_t t;
srand((unsigned) time(&t));
// bundleFolder is used to look for the game file
// and later to find the shader programs
#ifdef __APPLE__
// bundleFolder is set in applicationDidFinishLaunching.
#elif defined __unix__
bundleFolder = copyString(DATADIR); // DATADIR is defined in the Makefile.
#else
bundleFolder = copyString(argv[0]);
int lastSlash = -1;
for (int i = 0; bundleFolder[i]; i ++) {
if (bundleFolder[i] == PATHSLASH) lastSlash = i;
}
bundleFolder[lastSlash + 1] = NULL;
#endif
#endif
sludgeFile = filename;
if (!sludgeFile) {
sludgeFile = joinStrings(bundleFolder, "gamedata.slg");
if (!(fileExists(sludgeFile))) {
delete sludgeFile;
sludgeFile = joinStrings(bundleFolder, "gamedata");
if (!(fileExists(sludgeFile))) {
#if 0
sludgeFile = grabFileName();
#endif
}
}
}
#if 0
#if defined __unix__ && !(defined __APPLE__)
if (!fileExists(sludgeFile)) {
fprintf(stderr, "Game file not found.\n");
printCmdlineUsage();
if (!initSludge(filename)) {
return 0;
}
#endif
#endif
// The player pressed cancel in the file selection dialogue,
// so we should quit now.
if (!sludgeFile)
return 0;
// OK, so we DO want to start up, then...
setGameFilePath(sludgeFile);
if (!initSludge(sludgeFile))
return 0;
#if 0
/* Initialize the SDL library */

View File

@ -24,7 +24,7 @@
namespace Sludge {
int main_loop(char *filename);
int main_loop(const char *filename);
} // End of namespace Sludge

View File

@ -70,7 +70,7 @@ Common::Error SludgeEngine::run() {
_console = new SludgeConsole(this);
// debug log
main_loop("Welcome.slg");
main_loop(getGameFile());
return Common::kNoError;
}

View File

@ -58,6 +58,8 @@ public:
uint32 getFeatures() const;
Common::Language getLanguage() const;
const char *getGameFile() const;
const SludgeGameDescription *_gameDescription;
private:

View File

@ -135,7 +135,7 @@ void saveHandlers(Common::WriteStream *stream) {
stream->writeUint16BE(currentEvents->spaceFunction);
}
Common::File *openAndVerify(char *filename, char extra1, char extra2,
Common::File *openAndVerify(const char *filename, char extra1, char extra2,
const char *er, int &fileVersion) {
Common::File *fp = new Common::File();
if (!fp->open(filename)) {
@ -186,7 +186,7 @@ Common::File *openAndVerify(char *filename, char extra1, char extra2,
return fp;
}
bool initSludge(char *filename) {
bool initSludge(const char *filename) {
int a = 0;
mouseCursorAnim = makeNullAnim();

View File

@ -76,7 +76,7 @@ struct inputType {
extern unsigned char *gameIcon;
extern int iconW, iconH;
bool initSludge(char *);
bool initSludge(const char *);
void sludgeDisplay();
int startNewFunctionNum(unsigned int, unsigned int, loadedFunction *, variableStack*&, bool = true);
bool handleInput();
@ -87,7 +87,7 @@ void saveHandlers(Common::WriteStream *stream);
void finishFunction(loadedFunction *fun);
void abortFunction(loadedFunction *fun);
Common::File *openAndVerify(char *filename, char extra1, char extra2, const char *er, int &fileVersion);
Common::File *openAndVerify(const char *filename, char extra1, char extra2, const char *er, int &fileVersion);
void freezeSubs();
void unfreezeSubs();