Skip to content

Commit a9f81b7

Browse files
ShadowNinjaZeno-
authored andcommittedJan 23, 2015
Send real port to server list
1 parent 1702c34 commit a9f81b7

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed
 

‎src/server.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,9 @@ Server::~Server()
428428
void Server::start(Address bind_addr)
429429
{
430430
DSTACK(__FUNCTION_NAME);
431+
432+
m_bind_addr = bind_addr;
433+
431434
infostream<<"Starting server on "
432435
<< bind_addr.serializeString() <<"..."<<std::endl;
433436

@@ -678,6 +681,7 @@ void Server::AsyncRunStep(bool initial_step)
678681
g_settings->getBool("server_announce"))
679682
{
680683
ServerList::sendAnnounce(counter ? "update" : "start",
684+
m_bind_addr.getPort(),
681685
m_clients.getPlayerNames(),
682686
m_uptime.get(),
683687
m_env->getGameTime(),
@@ -5093,8 +5097,8 @@ void dedicated_server_loop(Server &server, bool &kill)
50935097
{
50945098
infostream<<"Dedicated server quitting"<<std::endl;
50955099
#if USE_CURL
5096-
if(g_settings->getBool("server_announce") == true)
5097-
ServerList::sendAnnounce("delete");
5100+
if(g_settings->getBool("server_announce"))
5101+
ServerList::sendAnnounce("delete", server.m_bind_addr.getPort());
50985102
#endif
50995103
break;
51005104
}

‎src/server.h

+3
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ class Server : public con::PeerHandler, public MapEventReceiver,
340340
u8* ser_vers, u16* prot_vers, u8* major, u8* minor, u8* patch,
341341
std::string* vers_string);
342342

343+
// Bind address
344+
Address m_bind_addr;
345+
343346
private:
344347

345348
friend class EmergeThread;

‎src/serverlist.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ const std::string serializeJson(const std::vector<ServerListSpec> &serverlist)
189189

190190
#if USE_CURL
191191
void sendAnnounce(const std::string &action,
192+
const u16 port,
192193
const std::vector<std::string> &clients_names,
193194
const double uptime,
194195
const u32 game_time,
@@ -199,7 +200,7 @@ void sendAnnounce(const std::string &action,
199200
{
200201
Json::Value server;
201202
server["action"] = action;
202-
server["port"] = g_settings->getU16("port");
203+
server["port"] = port;
203204
if (g_settings->exists("server_address")) {
204205
server["address"] = g_settings->get("server_address");
205206
}

‎src/serverlist.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace ServerList
3838
std::vector<ServerListSpec> deSerializeJson(const std::string &liststring);
3939
const std::string serializeJson(const std::vector<ServerListSpec> &serverlist);
4040
#if USE_CURL
41-
void sendAnnounce(const std::string &action,
41+
void sendAnnounce(const std::string &action, const u16 port,
4242
const std::vector<std::string> &clients_names = std::vector<std::string>(),
4343
const double uptime = 0, const u32 game_time = 0,
4444
const float lag = 0, const std::string &gameid = "",

0 commit comments

Comments
 (0)