Author: mordante
Date: Sun Jun 22 12:59:51 2008
New Revision: 27395
URL: http://svn.gna.org/viewcvs/wesnoth?rev=27395&view=rev
Log:
Zookeeper discovered wesnoth no longer starts if the binary has the name wesnoth
in it. This was caused by the automatic server start code. The bug has been
fixed, but the server start code still looks fragile.
Modified:
trunk/src/game.cpp
Modified: trunk/src/game.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game.cpp?rev=27395&r1=27394&r2=27395&view=diff
==============================================================================
--- trunk/src/game.cpp (original)
+++ trunk/src/game.cpp Sun Jun 22 12:59:51 2008
@@ -1660,6 +1660,10 @@
void game_controller::start_wesnothd()
{
+ if(game_config::wesnothd_name.empty()) {
+ throw game::mp_server_error("Couldn't locate the server
binary.");
+
+ }
std::string config = "data/lan_server.cfg";
#ifndef _WIN32
config = "\"" + game_config::wesnothd_name +"\" -c " + config + " -d -t
2 -T 5 ";
@@ -2725,10 +2729,22 @@
#endif
try {
+ /**
+ * @todo We try to guess the name of the server from the name
of the
+ * binary started. This is very fragile it breaks in at least
the
+ * following cases.
+ * - Wesnoth got renamed to something without wesnoth in it.
+ * - Wesnoth got a pre/suffix but the server not.
+ */
std::string program(argv[0]);
std::string wesnoth("wesnoth");
- program.replace(program.rfind(wesnoth), wesnoth.length(),
"wesnothd");
- game_config::wesnothd_name = program;
+ const size_t offset = program.rfind(wesnoth);
+ if(offset != std::string::npos) {
+ program.replace(offset, wesnoth.length(), "wesnothd");
+ game_config::wesnothd_name = program;
+ } else {
+ std::cerr << "Wesnoth doesn't have the name wesnoth, so
can't locate the server.\n";
+ }
std::cerr << "Battle for Wesnoth v" << game_config::revision <<
'\n';
time_t t = time(NULL);
std::cerr << "Started on " << ctime(&t) << "\n";
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits