2
* Copyright (C) 2002-2004 by the Widelands Development Team
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
// 2002-02-10 sft+ added config-existing check in handle_options
22
#include "constants.h"
28
Profile g_options(Profile::err_log);
31
/** options_shutdown()
33
* This overrites the old config file with a new one containing
36
void options_shutdown()
38
// write only used configuration entries to the file to sieve out typos
39
// on the commands line etc..
40
g_options.write("config", true);
46
* This functions finally prints the usage and ends the programm
48
static void show_usage(void)
51
"Usage: widelands <option0>=<value0> ... <optionN>=<valueN>\n"
54
" --<config-entry-name>=value overwrites a config file setting\n"
56
" --record Record all events to the given filename for later playback\n"
57
" --playback Playback given filename (see --record)\n"
59
" --coredump Generates a core dump on segfaults instead of using the SDL\n"
61
" --ggz Starts game as GGZ Gaming Zone client (don't use!)\n"
63
" --help Show this help\n"
64
" --version Show version\n"
66
"Bug reports? Suggestions? Check out the project website:\n"
67
" http://www.sourceforge.net/projects/widelands\n"
68
"Hope you enjoy this game!\n");
73
* Print version information
75
static void show_version(void)
80
/** parse_command_line(int argc, char** argv)
82
* Parses the standard cmd line of the program
84
* Returns: true if execution may continue
86
static bool parse_command_line(int argc, char** argv)
88
for(int i = 1; i < argc; i++) {
92
if (strncmp(opt, "--", 2)) {
98
if (!strcmp(opt, "help")) {
102
if (!strcmp(opt, "version")) {
106
if (!strcmp(opt, "ggz")) {
107
NetGGZ::ref()->init();
111
value = strchr(opt, '=');
118
if (!strcmp(opt, "record")) {
119
Sys_SetRecordFile(value);
122
if (!strcmp(opt, "playback")) {
123
Sys_SetPlaybackFile(value);
127
g_options.pull_section("global")->create_val(opt, value);
133
/** options_init(int argc, char** argv)
135
* This function parses the config file and the cmdline.
137
void options_init(int argc, char **argv)
139
g_options.read("config", "global");
141
if (!parse_command_line(argc, argv))