Send real port to server list
authorShadowNinja <shadowninja@minetest.net>
Wed, 21 Jan 2015 19:32:12 +0000 (14:32 -0500)
committerCraig Robbins <kde.psych@gmail.com>
Fri, 23 Jan 2015 11:38:34 +0000 (21:38 +1000)
src/server.cpp
src/server.h
src/serverlist.cpp
src/serverlist.h

index c948427ad559b3c584f1f8910f39a43d9c87cb21..fba512049d6b145fc9c64996676accf82e6dbfc1 100644 (file)
@@ -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() <<"..."<<std::endl;
 
@@ -678,6 +681,7 @@ void Server::AsyncRunStep(bool initial_step)
                                g_settings->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"<<std::endl;
 #if USE_CURL
-                       if(g_settings->getBool("server_announce") == true)
-                               ServerList::sendAnnounce("delete");
+                       if(g_settings->getBool("server_announce"))
+                               ServerList::sendAnnounce("delete", server.m_bind_addr.getPort());
 #endif
                        break;
                }
index e9cf0a25c984ddadef2e28382ed1d2ebaca048db..3d6b00d99f65073c843f5561777cbb7b046a3a66 100644 (file)
@@ -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;
index 65c75fec23c6c3cdf2ee01f8e34e5de0901a168f..472a6b85c285cbc4acb2df56f2aebf249171071b 100644 (file)
@@ -189,6 +189,7 @@ 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,
                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");
        }
index 7a7461ebdaef6421c0b57e2a0429d98364dd47c5..8ffea44cc70e579f69f678fc6e0742aa2fd8b4c1 100644 (file)
@@ -38,7 +38,7 @@ namespace 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,
+       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 = "",