21 #include "../core/endian_func.hpp" |
21 #include "../core/endian_func.hpp" |
22 #include "../string_func.h" |
22 #include "../string_func.h" |
23 #include "../player_base.h" |
23 #include "../player_base.h" |
24 #include "../player_func.h" |
24 #include "../player_func.h" |
25 #include "../settings_type.h" |
25 #include "../settings_type.h" |
|
26 #include "../rev.h" |
26 |
27 |
27 #include "core/udp.h" |
28 #include "core/udp.h" |
28 |
29 |
29 enum { |
30 enum { |
30 ADVERTISE_NORMAL_INTERVAL = 30000, // interval between advertising in ticks (15 minutes) |
31 ADVERTISE_NORMAL_INTERVAL = 30000, // interval between advertising in ticks (15 minutes) |
66 }; |
67 }; |
67 |
68 |
68 DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_FIND_SERVER) |
69 DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_FIND_SERVER) |
69 { |
70 { |
70 // Just a fail-safe.. should never happen |
71 // Just a fail-safe.. should never happen |
71 if (!_network_udp_server) |
72 if (!_network_udp_server) { |
72 return; |
73 return; |
|
74 } |
|
75 |
|
76 NetworkGameInfo ngi; |
|
77 |
|
78 /* Update some game_info */ |
|
79 ngi.clients_on = _network_game_info.clients_on; |
|
80 ngi.start_date = _network_game_info.start_date; |
|
81 |
|
82 ngi.server_lang = _settings_client.network.server_lang; |
|
83 ngi.use_password = !StrEmpty(_settings_client.network.server_password); |
|
84 ngi.clients_max = _settings_client.network.max_clients; |
|
85 ngi.companies_on = ActivePlayerCount(); |
|
86 ngi.companies_max = _settings_client.network.max_companies; |
|
87 ngi.spectators_on = NetworkSpectatorCount(); |
|
88 ngi.spectators_max = _settings_client.network.max_spectators; |
|
89 ngi.game_date = _date; |
|
90 ngi.map_width = MapSizeX(); |
|
91 ngi.map_height = MapSizeY(); |
|
92 ngi.map_set = _settings_game.game_creation.landscape; |
|
93 ngi.dedicated = _network_dedicated; |
|
94 ngi.grfconfig = _grfconfig; |
|
95 |
|
96 ttd_strlcpy(ngi.map_name, _network_game_info.map_name, lengthof(ngi.map_name)); |
|
97 ttd_strlcpy(ngi.server_name, _settings_client.network.server_name, lengthof(ngi.server_name)); |
|
98 ttd_strlcpy(ngi.server_revision, _openttd_revision, lengthof(ngi.server_revision)); |
73 |
99 |
74 Packet packet(PACKET_UDP_SERVER_RESPONSE); |
100 Packet packet(PACKET_UDP_SERVER_RESPONSE); |
75 |
101 this->Send_NetworkGameInfo(&packet, &ngi); |
76 // Update some game_info |
|
77 _network_game_info.game_date = _date; |
|
78 _network_game_info.map_width = MapSizeX(); |
|
79 _network_game_info.map_height = MapSizeY(); |
|
80 _network_game_info.map_set = _settings_game.game_creation.landscape; |
|
81 _network_game_info.companies_on = ActivePlayerCount(); |
|
82 _network_game_info.spectators_on = NetworkSpectatorCount(); |
|
83 _network_game_info.grfconfig = _grfconfig; |
|
84 |
|
85 this->Send_NetworkGameInfo(&packet, &_network_game_info); |
|
86 |
102 |
87 // Let the client know that we are here |
103 // Let the client know that we are here |
88 this->SendPacket(&packet, client_addr); |
104 this->SendPacket(&packet, client_addr); |
89 |
105 |
90 DEBUG(net, 2, "[udp] queried from '%s'", inet_ntoa(client_addr->sin_addr)); |
106 DEBUG(net, 2, "[udp] queried from '%s'", inet_ntoa(client_addr->sin_addr)); |