1 // Copyright (C) 2001, 2002, 2003 Michael Bartl
2 // Copyright (C) 2003, 2004, 2005, 2006 Ulf Lorenz
3 // Copyright (C) 2004, 2005, 2006 Andrea Paternesi
4 // Copyright (C) 2006, 2007, 2008, 2009 Ben Asselstine
5 // Copyright (C) 2007 Ole Laursen
6 // Copyright (C) 2005, 2006 Josef Spillner
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 3 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Library General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
31 #include "Configuration.h"
33 #include "GraphicsCache.h"
34 #include "recently-played-game-list.h"
37 #include "shieldset.h"
47 int main(int argc, char* argv[])
49 srand(time(NULL)); // set the random seed
51 initialize_configuration();
52 Vector<int>::setMaximumWidth(1000);
53 RecentlyPlayedGameList::getInstance()->loadFromFile(File::getSavePath() + "/recently-played.xml");
56 //cout << "Configuration::s_lang.c_str(): " << Configuration::s_lang.c_str() << endl;
57 setlocale(LC_ALL, Configuration::s_lang.c_str());
58 //setlocale(LC_ALL, "");
59 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
60 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
61 textdomain (GETTEXT_PACKAGE);
68 for (int i = 2; i <= argc; i++)
70 string parameter(argv[i-1]);
71 if (parameter == "-c")
74 //convert the next argument
76 long size = strtol(argv[i-1], &error, 10);
77 if (error && (*error != '\0'))
79 cerr <<_("non-numerical value for cache size") <<endl;
82 Configuration::s_cacheSize = size;
84 else if (parameter == "--seed" || parameter == "-S")
87 //convert the next argument
89 long seed = strtol(argv[i-1], &error, 10);
90 if (error && (*error != '\0'))
92 cerr <<_("non-numerical value for seed value") <<endl;
97 else if (parameter == "--turn")
100 kit.turn_filename = argv[i-1];
102 else if (parameter == "--test" || parameter == "-t")
104 kit.start_test_scenario = true;
106 else if (parameter == "--stress-test" || parameter == "-s")
108 kit.start_stress_test = true;
110 else if (parameter == "--robots" || parameter == "-r")
112 kit.start_robots = -1;
114 else if (parameter == "--help" || parameter == "-h")
116 cout << argv[0] << " [OPTION]... [FILE]" << endl << endl;
117 cout << "LordsAWar! " << _("version") << " " << VERSION << endl << endl;
118 cout << _("Options:") << endl << endl;
119 cout << " -h, --help " << _("Shows this help screen") <<endl;
120 cout << " -c <size> " << _("Set the cache size for imagery to SIZE bytes") <<endl;
121 cout << " -t, --test " << _("Start with a test-scenario") << endl;
122 cout << " -S, --seed <number> " << _("Seed the random number generator with NUMBER") << endl;
123 cout << " -s, --stress-test " << _("Non-interactive stress test") << endl;
124 cout << " -r, --robots " << _("Non-interactive network stress test") << endl;
126 cout << _("FILE can be a saved game file (.sav), or a map (.map) file.") << endl;
128 cout << _("Report bugs to") << " <" << PACKAGE_BUGREPORT ">." << endl;
132 kit.load_filename = parameter;
136 if (kit.load_filename != "" && kit.start_test_scenario)
138 cerr <<_("Error: Cannot specify -t and have a file specified.") << endl;
142 if (kit.load_filename != "" && kit.start_stress_test)
144 cerr <<_("Error: Cannot specify -s and have a file specified.") << endl;
148 if (kit.start_stress_test && kit.start_test_scenario)
150 cerr <<_("Error: Cannot specify -s and -t simultaneously.") << endl;
154 if (kit.turn_filename != "" && kit.load_filename == "")
156 cerr <<_("Error: Must specify a file to load when specifying --turn.") << endl;
161 // Check if armysets are in the path (otherwise exit)
162 Armyset::scanSystemCollection();
163 Tileset::scanSystemCollection();
164 Shieldset::scanSystemCollection();
165 Cityset::scanSystemCollection();
168 kit.start_main_loop();