Author: suokko
Date: Mon Jun 23 00:41:36 2008
New Revision: 27422

URL: http://svn.gna.org/viewcvs/wesnoth?rev=27422&view=rev
Log:
* made some of compiler defines to be file specific to reduce recompilation
* Improved wesnothd filename quessing a bit

Modified:
    trunk/SConstruct
    trunk/src/SConscript
    trunk/src/game.cpp

Modified: trunk/SConstruct
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/SConstruct?rev=27422&r1=27421&r2=27422&view=diff
==============================================================================
--- trunk/SConstruct (original)
+++ trunk/SConstruct Mon Jun 23 00:41:36 2008
@@ -234,46 +234,19 @@
 if env['lowmem']:
     env.Append(CPPDEFINES = "LOW_MEM")
 
-if env['fribidi']:
-    env.Append(CPPDEFINES = "HAVE_FRIBIDI")
-
-if env['raw_sockets']:
-    env.Append(CPPDEFINES = "NETWORK_USE_RAW_SOCKETS")
-
 if env['internal_data']:
     env.Append(CPPDEFINES = "USE_INTERNAL_DATA")
 
-if env['python']:
-    env.Append(CPPDEFINES = "HAVE_PYTHON")
+if env['editor2']:
+       env.Append(CPPDEFINES = "USE_EDITOR2")
 
 if have_X:
     env.Append(CPPDEFINES = "_X11")
-
-if sys.platform != "win32":
-    if env['prefsdir']:
-        env.Append(CPPDEFINES = "PREFERENCES_DIR='\"%s\"'" % env['prefsdir'] )
-
-    if env['fifodir']:
-        env.Append(CPPDEFINES = "FIFODIR='\"%s\"'" % env['fifodir'] )
-
-    if env['localedirname']:
-        env.Append(CPPDEFINES = "LOCALEDIR='\"%s\"'" % env['localedirname'] )
-        if not os.path.isabs(env['localedirname']):
-            env.Append(CPPDEFINES = "HAS_RELATIVE_LOCALEDIR")
-
-if env['dummy_locales']:
-    env.Append(CPPDEFINES = "USE_DUMMYLOCALES")
-    
-if env['editor2']:
-    env.Append(CPPDEFINES = "USE_EDITOR2")
 
 # Simulate autools-like behavior of prefix on various paths
 installdirs = Split("bindir datadir fifodir icondir desktopdir mandir docdir 
python_site_packages_dir")
 for d in installdirs:
     env[d] = os.path.join(env["prefix"], env[d])
-
-if env["PLATFORM"] != "win32":
-    env.Append(CPPDEFINES = "WESNOTH_PATH='\"%s\"'" % env['datadir'])
 
 for d in installdirs:
     env[d] = os.path.join("/", env["destdir"], env[d].lstrip("/"))

Modified: trunk/src/SConscript
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/SConscript?rev=27422&r1=27421&r2=27422&view=diff
==============================================================================
--- trunk/src/SConscript (original)
+++ trunk/src/SConscript Mon Jun 23 00:41:36 2008
@@ -6,6 +6,10 @@
 
 Import("*")
 
+python_env = env.Clone()
+if env['python']:
+    python_env.Append(CPPDEFINES = "HAVE_PYTHON")
+
 #color_range.cpp should be removed, but game_config depends on it.
 #game_config has very few things that are needed elsewhere, it should be
 #removed.  Requires moving path and version at least to other files.
@@ -13,13 +17,10 @@
 libwesnoth_core_sources = Split("""
     color_range.cpp
     config.cpp
-    filesystem.cpp
-    game_config.cpp
     gettext.cpp
     log.cpp
     map.cpp
     network.cpp
-    network_worker.cpp
     thread.cpp
     tstring.cpp
     util.cpp
@@ -30,6 +31,34 @@
     serialization/string_utils.cpp
     serialization/tokenizer.cpp
     """)
+
+if env['raw_sockets']:
+    libwesnoth_core_sources.extend( env.Object("network_worker.cpp", 
CPPDEFINES = "NETWORK_USE_RAW_SOCKETS"))
+else:
+    libwesnoth_core_sources.extend( env.Object("network_worker.cpp"))
+
+
+game_config_env = env.Clone()
+
+
+
+if env["PLATFORM"] != "win32":
+       game_config_env.Append(CPPDEFINES = "WESNOTH_PATH='\"%s\"'" % 
env['datadir'])
+
+libwesnoth_core_sources.extend( game_config_env.Object("game_config.cpp"))
+
+filesystem_env = env.Clone()
+
+if env['localedirname']:
+       filesystem_env.Append(CPPDEFINES = "LOCALEDIR='\"%s\"'" % 
env['localedirname'] )
+       if not os.path.isabs(env['localedirname']):
+               filesystem_env.Append(CPPDEFINES = "HAS_RELATIVE_LOCALEDIR")
+
+if env['prefsdir']:
+       filesystem_env.Append(CPPDEFINES = "PREFERENCES_DIR='\"%s\"'" % 
env['prefsdir'] )
+
+libwesnoth_core_sources.extend( filesystem_env.Object("filesystem.cpp"))
+
 libwesnoth_core = env.Library("wesnoth_core", libwesnoth_core_sources)
 
 libwesnoth_sources = Split("""
@@ -43,12 +72,10 @@
     display.cpp
     events.cpp
     filechooser.cpp
-    font.cpp
     generic_event.cpp
     hotkeys.cpp
     image.cpp
     key.cpp
-    language.cpp
     loadscreen.cpp
     map_create.cpp
     map_label.cpp
@@ -111,6 +138,18 @@
     gui/widgets/window.cpp
     gui/widgets/window_builder.cpp
     """)
+
+if env['fribidi']:
+    libwesnoth_sources.extend( env.Object("font.cpp", CPPDEFINES = 
"HAVE_FRIBIDI"))
+else:
+       libwesnoth_sources.extend( env.Object("font.cpp"))
+
+if env['dummy_locales']:
+    libwesnoth_sources.extend( env.Object("language.cpp", CPPDEFINES = 
"USE_DUMMYLOCALES"))
+else:
+       libwesnoth_sources.extend( env.Object("language.cpp"))
+
+
 libwesnoth = env.Library("wesnoth", libwesnoth_sources)
 
 libwesnothd_sources = Split("""
@@ -141,11 +180,9 @@
     actions.cpp
     addon_checks.cpp
     addon_management.cpp
-    ai.cpp
     ai_dfool.cpp
     ai_attack.cpp
     ai_move.cpp
-    ai_python.cpp
     ai_village.cpp
     animated_game.cpp
     attack_prediction.cpp
@@ -172,7 +209,6 @@
     multiplayer.cpp
     multiplayer_ui.cpp
     multiplayer_wait.cpp
-    multiplayer_connect.cpp
     multiplayer_create.cpp
     multiplayer_lobby.cpp
     pathfind.cpp
@@ -204,6 +240,10 @@
     widgets/scrollpane.cpp
     """)
 
+wesnoth_sources.extend( python_env.Object("ai_python.cpp"))
+wesnoth_sources.extend( python_env.Object("ai.cpp"))
+wesnoth_sources.extend( python_env.Object("multiplayer_connect.cpp"))
+
 # used with editor2 option in the wesnoth target
 wesnoth_editor2_sources = Split("""
     editor2/editor_main.cpp
@@ -234,7 +274,9 @@
 from SCons.Script.SConscript import SConsEnvironment
 SConsEnvironment.WesnothProgram = WesnothProgram
 
-env.WesnothProgram("wesnoth", ["game.cpp"] + wesnoth_sources + 
[libwesnoth_core, libwesnoth_sdl, libwesnoth, libcampaignd] + wesnoth_res, 
have_client_prereqs)
+game_cpp = python_env.Object("game.cpp");
+
+env.WesnothProgram("wesnoth", [game_cpp] + wesnoth_sources + [libwesnoth_core, 
libwesnoth_sdl, libwesnoth, libcampaignd] + wesnoth_res, have_client_prereqs)
 
 wesnoth_editor_sources = Split("""
     editor/editor.cpp
@@ -250,9 +292,14 @@
 env.WesnothProgram("wesnoth_editor", wesnoth_editor_sources + 
[libwesnoth_core, libwesnoth_sdl, libwesnoth] + wesnoth_editor_res, 
have_client_prereqs and not env["editor2"])
 
 campaignd_sources = Split("""
-    campaign_server/campaign_server.cpp
     server/input_stream.cpp
     """)
+
+if env['fifodir']:
+       campaignd_sources.extend( 
env.Object("campaign_server/campaign_server.cpp", CPPDEFINES = 
"FIFODIR='\"%s\"'" % env['fifodir']))
+else:
+       campaignd_sources.extend( 
env.Object("campaign_server/campaign_server.cpp"))
+
 env.WesnothProgram("campaignd", campaignd_sources + [libwesnoth_core, 
libwesnothd, libcampaignd], have_server_prereqs)
 
 wesnothd_sources = Split("""
@@ -262,10 +309,14 @@
     server/metrics.cpp
     server/player.cpp
     server/proxy.cpp
-    server/server.cpp
     server/simple_wml.cpp
        time.cpp
     """)
+if env['fifodir']:
+       wesnothd_sources.extend( env.Object("server/server.cpp", CPPDEFINES = 
"FIFODIR='\"%s\"'" % env['fifodir']))
+else:
+       wesnothd_sources.extend( env.Object("server/server.cpp"))
+
 env.WesnothProgram("wesnothd", wesnothd_sources + [libwesnoth_core, 
libwesnothd], have_server_prereqs)
 
 cutter_sources = Split("""
@@ -294,7 +345,7 @@
                     lambda target, source, env: open(str(target[0]), 
"w").write(revision_define),
                     "Generating revision.hpp..."
                     ))
-    env.Append(CPPDEFINES = 'HAVE_REVISION')
+    game_config_env.Append(CPPDEFINES = 'HAVE_REVISION')
 
 sources = []
 if "TAGS" in COMMAND_LINE_TARGETS:

Modified: trunk/src/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game.cpp?rev=27422&r1=27421&r2=27422&view=diff
==============================================================================
--- trunk/src/game.cpp (original)
+++ trunk/src/game.cpp Mon Jun 23 00:41:36 2008
@@ -1664,7 +1664,13 @@
                throw game::mp_server_error("Couldn't locate the server 
binary.");
 
        }
-       std::string config = "data/lan_server.cfg";
+
+       std::string config = get_user_data_dir() + "/lan_server.cfg";
+       if (!file_exists(config))
+       {
+               // copy file if it isn't created yet
+               write_file(config, read_file("data/lan_server.cfg"));
+       }
 #ifndef _WIN32
        config = "\"" + game_config::wesnothd_name +"\" -c " + config + " -d -t 
2 -T 5 ";
        LOG_GENERAL << "Starting wesnothd: "<< config << "\n";
@@ -1676,6 +1682,30 @@
        if (std::system(("cmd /C start \"wesnoth server\" /B \"" + 
game_config::wesnothd_name + "\" -c " + config + " -t 2 -T 5 ").c_str()) != 0)
 #endif
        {
+#ifndef _WIN32
+               // try to locate wesnothd
+               std::string old_name = game_config::wesnothd_name;
+               std::string needle = "wesnothd";
+               size_t found = game_config::wesnothd_name.rfind(needle);
+               if (found != std::string::npos
+                               && found  + needle.size() < 
game_config::wesnothd_name.size())
+               {
+                       game_config::wesnothd_name = 
game_config::wesnothd_name.substr(0, found + needle.size());
+
+                       try {
+                               start_wesnothd();
+                               return;
+                       } catch(...)
+                       {
+                               game_config::wesnothd_name = old_name;
+                               throw;
+                       }
+               }
+               else
+#endif
+               {
+                       // We should show gui to set wesnothd_name
+               }
                LOG_GENERAL << "Failed to run server start script\n";
                throw game::mp_server_error("Starting MP server failed!");
        }
@@ -1685,27 +1715,26 @@
 
 bool game_controller::play_multiplayer()
 {
+
        int res;
 
        state_ = game_state();
        state_.campaign_type = "multiplayer";
        state_.campaign_define = "MULTIPLAYER";
-
-
 
        //Print Gui only if the user hasn't specified any server
        if( multiplayer_server_.empty() ){
                if(gui2::new_widgets) {
                        gui2::tmp_method_selection dlg;
 
-                               dlg.show(disp().video());
-
-                               if(dlg.get_retval() == gui2::tbutton::OK) {
-                                       res = dlg.get_choice();
-                               } else {
-                                       return false;
-
-                               }
+                       dlg.show(disp().video());
+
+                       if(dlg.get_retval() == gui2::tbutton::OK) {
+                               res = dlg.get_choice();
+                       } else {
+                               return false;
+
+                       }
 
                } else {
 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to