From 6b794d3da775726930f096493bcc9bfbef71d198 Mon Sep 17 00:00:00 2001 From: yinsimei Date: Wed, 12 Jul 2017 21:17:55 +0200 Subject: SLUDGE: remove game settings from Sludge code --- engines/sludge/language.cpp | 116 +------------------------------------------- 1 file changed, 2 insertions(+), 114 deletions(-) (limited to 'engines/sludge/language.cpp') diff --git a/engines/sludge/language.cpp b/engines/sludge/language.cpp index 2f37eb35c4..5b7adeee3a 100644 --- a/engines/sludge/language.cpp +++ b/engines/sludge/language.cpp @@ -20,6 +20,8 @@ * */ +#include "common/debug.h" + #include "sludge/allfiles.h" #include "sludge/newfatal.h" #include "sludge/moreio.h" @@ -27,126 +29,12 @@ #include "sludge/sludge.h" #include "sludge/CommonCode/version.h" -#include "common/debug.h" - namespace Sludge { int *languageTable; Common::String *languageName; settingsStruct gameSettings; -Common::String getPrefsFilename(Common::String filename) { - // Yes, this trashes the original string, but - // we also free it at the end (warning!)... - - int n = filename.size(); - - if (n > 4 && filename[n - 4] == '.') { - filename.setChar(0, n - 4); - } - - // get file name from dir - int pos = 0; - for (int i = 0; i < n; i++) { - if (filename[i] == '/') - pos = i + 1; - } - - Common::String f = filename.c_str() + pos; - Common::String joined = f + ".ini"; - - return joined; -} - -void readIniFile(const Common::String &filename) { - - Common::String langName = getPrefsFilename(filename); - - Common::File fd; - if (!fd.open(langName)) { - debug(kSludgeDebugDataLoad, "Fail to open language file : %s", langName.c_str()); - return; - } - - gameSettings.languageID = 0; - gameSettings.userFullScreen = false; //defaultUserFullScreen(); TODO: false value - gameSettings.refreshRate = 0; - gameSettings.antiAlias = 1; - gameSettings.fixedPixels = false; - gameSettings.noStartWindow = false; - gameSettings.debugMode = false; - - Common::String lineSoFar = ""; - Common::String secondSoFar = ""; - char readChar = ' '; - bool keepGoing = true; - bool doingSecond = false; - - do { - readChar = fd.readByte(); - if (fd.eos()) { - readChar = '\n'; - keepGoing = false; - } - switch (readChar) { - case '\n': - case '\r': - if (doingSecond) { - if (lineSoFar == "LANGUAGE") { - gameSettings.languageID = (uint)secondSoFar.asUint64(); - } else if (lineSoFar == "WINDOW") { - gameSettings.userFullScreen = !secondSoFar.asUint64(); - } else if (lineSoFar == "REFRESH") { - gameSettings.refreshRate = (uint)secondSoFar.asUint64(); - } else if (lineSoFar == "ANTIALIAS") { - gameSettings.antiAlias = (int)secondSoFar.asUint64(); - } else if (lineSoFar == "FIXEDPIXELS") { - gameSettings.fixedPixels = secondSoFar.asUint64(); - } else if (lineSoFar == "NOSTARTWINDOW") { - gameSettings.noStartWindow = secondSoFar.asUint64(); - } else if (lineSoFar == "DEBUGMODE") { - gameSettings.debugMode = secondSoFar.asUint64(); - } - } - doingSecond = false; - lineSoFar.clear(); - secondSoFar.clear(); - break; - - case '=': - doingSecond = true; - break; - - default: - if (doingSecond) { - secondSoFar += readChar; - } else { - lineSoFar += readChar; - } - break; - } - } while (keepGoing); - - fd.close(); -} - -void saveIniFile(const Common::String &filename) { -#if 0 - char *langName = getPrefsFilename(copyString(filename)); - FILE *fp = fopen(langName, "wt"); - delete langName; - - fprintf(fp, "LANGUAGE=%d\n", gameSettings.languageID); - fprintf(fp, "WINDOW=%d\n", ! gameSettings.userFullScreen); - fprintf(fp, "ANTIALIAS=%d\n", gameSettings.antiAlias); - fprintf(fp, "FIXEDPIXELS=%d\n", gameSettings.fixedPixels); - fprintf(fp, "NOSTARTWINDOW=%d\n", gameSettings.noStartWindow); - fprintf(fp, "DEBUGMODE=%d\n", gameSettings.debugMode); - - fclose(fp); -#endif -} - void makeLanguageTable(Common::File *table) { languageTable = new int[gameSettings.numLanguages + 1]; if (!checkNew(languageTable)) -- cgit v1.2.3