diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-08-29 20:29:53 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-08-29 20:29:53 +0000 |
commit | 91705f88735b8efdbf263a22ef02c1b87c964b5b (patch) | |
tree | 1b4aa522b3cea519f0aba659b03efccb7ce8ced0 | |
parent | c0ff89295d11d3e328b0d93c014c6ca82c690a78 (diff) | |
download | mana-91705f88735b8efdbf263a22ef02c1b87c964b5b.tar.gz mana-91705f88735b8efdbf263a22ef02c1b87c964b5b.tar.bz2 mana-91705f88735b8efdbf263a22ef02c1b87c964b5b.tar.xz mana-91705f88735b8efdbf263a22ef02c1b87c964b5b.zip |
Applied patch by Andrew Harrison, adding a command line option to specify which
configuration file to use.
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | src/main.cpp | 65 |
2 files changed, 48 insertions, 33 deletions
@@ -1,7 +1,13 @@ +2006-08-29 Andrew Harrison <atharris@users.sourceforge.net> + + * src/main.cpp: Added command line option to specify which + configuration file to use (patch applied by Bjørn Lindeijer). + 2006-08-29 Matthias Hartmann <hartmann.matthias@gmail.com> - * data/graphics/sprites/item006.png, data/graphics/sprites/item006.xml, - data/graphics/sprites/item008.xml Fixed fancy hat + silk headband positions. + * data/graphics/sprites/item006.png, + data/graphics/sprites/item006.xml, data/graphics/sprites/item008.xml: + Fixed fancy hat + silk headband positions. 2006-08-29 Philipp Sehmisch <tmw@crushnet.org> @@ -24,8 +30,8 @@ 2006-08-27 Bjørn Lindeijer <bjorn@lindeijer.nl> - * src/net/inventoryhandler.cpp: Applied patch by AHarrison that adds - item pickup messages to the chat window. + * src/net/inventoryhandler.cpp: Applied patch by Andrew Harrison that + adds item pickup messages to the chat window. * NEWS: Updated with some recently added and fixed issues. Doesn't mention any of the recent content updates yet. @@ -67,7 +73,7 @@ * data/help/commands.txt, README, src/game.cpp, src/gui/chat.cpp, src/gui/window.cpp, src/gui/window.h: Added support for sticky windows - as discussed with doener. Patch by AHarrison. + as discussed with doener. Patch by Andrew Harrison. * data/items.xml: Added jeans shorts. 2006-08-24 Philipp Sehmisch <tmw@crushnet.org> diff --git a/src/main.cpp b/src/main.cpp index 3a1cdf7d..bc6cedc4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -107,9 +107,33 @@ namespace { } /** + * A structure holding the values of various options that can be passed from + * the command line. + */ +struct Options +{ + /** + * Constructor. + */ + Options(): + printHelp(false), + skipUpdate(false), + chooseDefault(false) + {}; + + bool printHelp; + bool skipUpdate; + bool chooseDefault; + std::string username; + std::string password; + std::string playername; + std::string configPath; +}; + +/** * Do all initialization stuff */ -void init_engine() +void init_engine(const Options &options) { // Initialize SDL if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) { @@ -191,7 +215,10 @@ void init_engine() // Checking if the configuration file exists... otherwise creates it with // default options ! FILE *tmwFile = 0; - std::string configPath = homeDir + "/config.xml"; + std::string configPath = options.configPath; + if (configPath == "") { + configPath = homeDir + "/config.xml"; + } tmwFile = fopen(configPath.c_str(), "r"); // If we can't read it, it doesn't exist ! @@ -302,29 +329,6 @@ void exit_engine() delete logger; } -/** - * A structure holding the values of various options that can be passed from - * the command line. - */ -struct Options -{ - /** - * Constructor. - */ - Options(): - printHelp(false), - skipUpdate(false), - chooseDefault(false) - {}; - - bool printHelp; - bool skipUpdate; - bool chooseDefault; - std::string username; - std::string password; - std::string playername; -}; - void printHelp() { std::cout @@ -335,13 +339,14 @@ void printHelp() << " -U --username : Login with this username" << std::endl << " -P --password : Login with this password" << std::endl << " -D --default : Bypass the login process with default settings" << std::endl - << " -p --playername : Login with this player" + << " -p --playername : Login with this player" << std::endl + << " -C --configfile : Configuration file to use" << std::endl; } void parseOptions(int argc, char *argv[], Options &options) { - const char *optstring = "huU:P:Dp:"; + const char *optstring = "huU:P:Dp:C:"; const struct option long_options[] = { { "help", no_argument, 0, 'h' }, @@ -350,6 +355,7 @@ void parseOptions(int argc, char *argv[], Options &options) { "password", required_argument, 0, 'P' }, { "default", no_argument, 0, 'D' }, { "playername", required_argument, 0, 'p' }, + { "configfile", required_argument, 0, 'C' }, { 0 } }; @@ -380,6 +386,9 @@ void parseOptions(int argc, char *argv[], Options &options) case 'p': options.playername = optarg; break; + case 'C': + options.configPath = optarg; + break; } } } @@ -509,7 +518,7 @@ int main(int argc, char *argv[]) // Initialize PhysicsFS PHYSFS_init(argv[0]); - init_engine(); + init_engine(options); SDL_Event event; |