This removes the hacky server_dedicated pseudo-setting.
}
server = new Server(map_dir, gamespec, simple_singleplayer_mode,
- bind_addr.isIPv6());
+ bind_addr.isIPv6(), false);
server->start(bind_addr);
infostream << "Using commanded world path ["
<< game_params.world_path << "]" << std::endl;
- //Run dedicated server if asked to or no other option
- g_settings->set("server_dedicated",
- game_params.is_dedicated_server ? "true" : "false");
-
if (game_params.is_dedicated_server)
return run_dedicated_server(game_params, cmd_args) ? 0 : 1;
try {
// Create server
- Server server(game_params.world_path,
- game_params.game_spec, false, bind_addr.isIPv6(), &iface);
+ Server server(game_params.world_path, game_params.game_spec,
+ false, bind_addr.isIPv6(), true, &iface);
g_term_console.setup(&iface, &kill, admin_nick);
try {
// Create server
Server server(game_params.world_path, game_params.game_spec, false,
- bind_addr.isIPv6());
+ bind_addr.isIPv6(), true);
server.start(bind_addr);
// Run server
const SubgameSpec &gamespec,
bool simple_singleplayer_mode,
bool ipv6,
+ bool dedicated,
ChatInterface *iface
):
m_path_world(path_world),
m_gamespec(gamespec),
m_simple_singleplayer_mode(simple_singleplayer_mode),
+ m_dedicated(dedicated),
m_async_fatal_error(""),
m_env(NULL),
m_con(PROTOCOL_ID,
// send masterserver announce
{
float &counter = m_masterserver_timer;
- if(!isSingleplayer() && (!counter || counter >= 300.0) &&
- g_settings->getBool("server_announce"))
- {
- ServerList::sendAnnounce(counter ? "update" : "start",
+ if (!isSingleplayer() && (!counter || counter >= 300.0) &&
+ g_settings->getBool("server_announce")) {
+ ServerList::sendAnnounce(counter ? ServerList::AA_UPDATE :
+ ServerList::AA_START,
m_bind_addr.getPort(),
m_clients.getPlayerNames(),
m_uptime.get(),
m_lag,
m_gamespec.id,
Mapgen::getMapgenName(m_emerge->mgparams->mgtype),
- m_mods);
+ m_mods,
+ m_dedicated);
counter = 0.01;
}
counter += dtime;
}
server.step(steplen);
- if(server.getShutdownRequested() || kill)
- {
- infostream<<"Dedicated server quitting"<<std::endl;
-#if USE_CURL
- if(g_settings->getBool("server_announce"))
- ServerList::sendAnnounce("delete", server.m_bind_addr.getPort());
-#endif
- break;
- }
-
/*
Profiler
*/
}
}
}
+
+ infostream << "Dedicated server quitting" << std::endl;
+#if USE_CURL
+ if (g_settings->getBool("server_announce"))
+ ServerList::sendAnnounce(ServerList::AA_DELETE,
+ server.m_bind_addr.getPort());
+#endif
}
const SubgameSpec &gamespec,
bool simple_singleplayer_mode,
bool ipv6,
+ bool dedicated,
ChatInterface *iface = NULL
);
~Server();
// functionality
bool m_simple_singleplayer_mode;
u16 m_max_chatmessage_length;
+ // For "dedicated" server list flag
+ bool m_dedicated;
// Thread can set; step() will throw as ServerError
MutexedVariable<std::string> m_async_fatal_error;
#if USE_CURL
-void sendAnnounce(const std::string &action,
+void sendAnnounce(AnnounceAction action,
const u16 port,
const std::vector<std::string> &clients_names,
const double uptime,
const float lag,
const std::string &gameid,
const std::string &mg_name,
- const std::vector<ModSpec> &mods)
+ const std::vector<ModSpec> &mods,
+ bool dedicated)
{
+ static const char *aa_names[] = {"start", "update", "delete"};
Json::Value server;
- server["action"] = action;
+ server["action"] = aa_names[action];
server["port"] = port;
if (g_settings->exists("server_address")) {
server["address"] = g_settings->get("server_address");
}
- if (action != "delete") {
+ if (action != AA_DELETE) {
bool strict_checking = g_settings->getBool("strict_protocol_version_checking");
server["name"] = g_settings->get("server_name");
server["description"] = g_settings->get("server_description");
if (gameid != "") server["gameid"] = gameid;
}
- if (action == "start") {
- server["dedicated"] = g_settings->getBool("server_dedicated");
+ if (action == AA_START) {
+ server["dedicated"] = dedicated;
server["rollback"] = g_settings->getBool("enable_rollback_recording");
server["mapgen"] = mg_name;
server["privs"] = g_settings->get("default_privs");
server["can_see_far_names"] = g_settings->getS16("player_transfer_distance") <= 0;
server["mods"] = Json::Value(Json::arrayValue);
for (std::vector<ModSpec>::const_iterator it = mods.begin();
- it != mods.end();
- ++it) {
+ it != mods.end(); ++it) {
server["mods"].append(it->name);
}
actionstream << "Announcing to " << g_settings->get("serverlist_url") << std::endl;
- } else {
+ } else if (action == AA_UPDATE) {
if (lag)
server["lag"] = lag;
}
}
#endif
-} //namespace ServerList
+} // namespace ServerList
+
namespace ServerList
{
- std::vector<ServerListSpec> getLocal();
- std::vector<ServerListSpec> getOnline();
- bool deleteEntry(const ServerListSpec &server);
- bool insert(const ServerListSpec &server);
- std::vector<ServerListSpec> deSerialize(const std::string &liststring);
- const std::string serialize(const std::vector<ServerListSpec> &serverlist);
- std::vector<ServerListSpec> deSerializeJson(const std::string &liststring);
- const std::string serializeJson(const std::vector<ServerListSpec> &serverlist);
- #if USE_CURL
- void sendAnnounce(const std::string &action, const u16 port,
- const std::vector<std::string> &clients_names = std::vector<std::string>(),
- const double uptime = 0, const u32 game_time = 0,
- const float lag = 0, const std::string &gameid = "",
- const std::string &mg_name = "",
- const std::vector<ModSpec> &mods = std::vector<ModSpec>());
- #endif
-} // ServerList namespace
+std::vector<ServerListSpec> getLocal();
+std::vector<ServerListSpec> getOnline();
+
+bool deleteEntry(const ServerListSpec &server);
+bool insert(const ServerListSpec &server);
+
+std::vector<ServerListSpec> deSerialize(const std::string &liststring);
+const std::string serialize(const std::vector<ServerListSpec> &serverlist);
+std::vector<ServerListSpec> deSerializeJson(const std::string &liststring);
+const std::string serializeJson(const std::vector<ServerListSpec> &serverlist);
+
+#if USE_CURL
+enum AnnounceAction {AA_START, AA_UPDATE, AA_DELETE};
+void sendAnnounce(AnnounceAction, u16 port,
+ const std::vector<std::string> &clients_names = std::vector<std::string>(),
+ double uptime = 0, u32 game_time = 0, float lag = 0,
+ const std::string &gameid = "", const std::string &mg_name = "",
+ const std::vector<ModSpec> &mods = std::vector<ModSpec>(),
+ bool dedicated = false);
+#endif
+
+} // namespace ServerList
#endif