From a9f81b729b1cc90db5574fdb97542901e695bf69 Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Wed, 21 Jan 2015 14:32:12 -0500 Subject: Send real port to server list --- src/server.cpp | 8 ++++++-- src/server.h | 3 +++ src/serverlist.cpp | 3 ++- src/serverlist.h | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/server.cpp b/src/server.cpp index c948427ad..fba512049 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -428,6 +428,9 @@ Server::~Server() void Server::start(Address bind_addr) { DSTACK(__FUNCTION_NAME); + + m_bind_addr = bind_addr; + infostream<<"Starting server on " << bind_addr.serializeString() <<"..."<getBool("server_announce")) { ServerList::sendAnnounce(counter ? "update" : "start", + m_bind_addr.getPort(), m_clients.getPlayerNames(), m_uptime.get(), m_env->getGameTime(), @@ -5093,8 +5097,8 @@ void dedicated_server_loop(Server &server, bool &kill) { infostream<<"Dedicated server quitting"<getBool("server_announce") == true) - ServerList::sendAnnounce("delete"); + if(g_settings->getBool("server_announce")) + ServerList::sendAnnounce("delete", server.m_bind_addr.getPort()); #endif break; } diff --git a/src/server.h b/src/server.h index e9cf0a25c..3d6b00d99 100644 --- a/src/server.h +++ b/src/server.h @@ -340,6 +340,9 @@ public: u8* ser_vers, u16* prot_vers, u8* major, u8* minor, u8* patch, std::string* vers_string); + // Bind address + Address m_bind_addr; + private: friend class EmergeThread; diff --git a/src/serverlist.cpp b/src/serverlist.cpp index 65c75fec2..472a6b85c 100644 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -189,6 +189,7 @@ const std::string serializeJson(const std::vector &serverlist) #if USE_CURL void sendAnnounce(const std::string &action, + const u16 port, const std::vector &clients_names, const double uptime, const u32 game_time, @@ -199,7 +200,7 @@ void sendAnnounce(const std::string &action, { Json::Value server; server["action"] = action; - server["port"] = g_settings->getU16("port"); + server["port"] = port; if (g_settings->exists("server_address")) { server["address"] = g_settings->get("server_address"); } diff --git a/src/serverlist.h b/src/serverlist.h index 7a7461ebd..8ffea44cc 100644 --- a/src/serverlist.h +++ b/src/serverlist.h @@ -38,7 +38,7 @@ namespace ServerList std::vector deSerializeJson(const std::string &liststring); const std::string serializeJson(const std::vector &serverlist); #if USE_CURL - void sendAnnounce(const std::string &action, + void sendAnnounce(const std::string &action, const u16 port, const std::vector &clients_names = std::vector(), const double uptime = 0, const u32 game_time = 0, const float lag = 0, const std::string &gameid = "", -- cgit v1.2.3