Author: grzywacz
Date: Sun Jul 13 11:54:26 2008
New Revision: 27976
URL: http://svn.gna.org/viewcvs/wesnoth?rev=27976&view=rev
Log:
Extracted initial argument parsing and locale init from play_game().
Modified:
trunk/src/game.cpp
Modified: trunk/src/game.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game.cpp?rev=27976&r1=27975&r2=27976&view=diff
==============================================================================
--- trunk/src/game.cpp (original)
+++ trunk/src/game.cpp Sun Jul 13 11:54:26 2008
@@ -2422,8 +2422,7 @@
//! Process commandline-arguments
-static int play_game(int argc, char** argv)
-{
+static int process_command_args(int argc, char** argv) {
//parse arguments that shouldn't require a display device
int arg;
for(arg = 1; arg != argc; ++arg) {
@@ -2616,19 +2615,19 @@
std::cout << lg::list_logdomains() << "\n";
return 0;
}
-
- }
-
- srand(time(NULL));
-
- game_controller game(argc,argv);
- const int start_ticks = SDL_GetTicks();
-
- // I would prefer to setup locale first so that early error
- // messages can get localized, but we need the game_controller
- // initialized to have get_intl_dir() to work. Note: this
- // setlocale() but this does not take GUI language setting
- // into account.
+ }
+
+ // Not the most intuitive solution, but I wanted to leave current
semantics for now
+ return -1;
+}
+
+/**
+ * I would prefer to setup locale first so that early error
+ * messages can get localized, but we need the game_controller
+ * initialized to have get_intl_dir() to work. Note: setlocale()
+ * does not take GUI language setting into account.
+ */
+static void init_locale() {
#ifdef _WIN32
std::setlocale(LC_ALL, "English");
#else
@@ -2641,6 +2640,22 @@
bindtextdomain (PACKAGE "-lib", intl_dir.c_str());
bind_textdomain_codeset (PACKAGE "-lib", "UTF-8");
textdomain (PACKAGE);
+}
+
+//! Setups the game environment
+static int play_game(int argc, char** argv)
+{
+ int finished = process_command_args(argc, argv);
+ if(finished != -1) {
+ return finished;
+ }
+
+ srand(time(NULL));
+
+ game_controller game(argc,argv);
+ const int start_ticks = SDL_GetTicks();
+
+ init_locale();
bool res;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits