merge 1.5.3-RC1

This commit is contained in:
Pavel Stupnikov
2015-11-01 21:17:36 +03:00
62 changed files with 767 additions and 1268 deletions
+1 -4
View File
@@ -1,4 +1,4 @@
/* $Id: network.cpp 26788 2014-09-07 14:21:16Z frosch $ */
/* $Id: network.cpp 27431 2015-11-01 11:59:17Z frosch $ */
/*
* This file is part of OpenTTD.
@@ -63,7 +63,6 @@ NetworkCompanyState *_network_company_states = NULL; ///< Statistics about some
ClientID _network_own_client_id; ///< Our client identifier.
ClientID _redirect_console_to_client; ///< If not invalid, redirect the console output to a client.
bool _network_need_advertise; ///< Whether we need to advertise.
uint32 _network_last_advertise_frame; ///< Last time we did advertise.
uint8 _network_reconnect; ///< Reconnect timeout
StringList _network_bind_list; ///< The addresses to bind on.
StringList _network_host_list; ///< The servers we know.
@@ -760,7 +759,6 @@ bool NetworkServerStart()
if (_network_dedicated) IConsoleCmdExec("exec scripts/on_dedicated.scr 0");
/* Try to register us to the master server */
_network_last_advertise_frame = 0;
_network_need_advertise = true;
NetworkUDPAdvertise();
@@ -1077,7 +1075,6 @@ void NetworkStartUp()
/* Network is available */
_network_available = NetworkCoreInitialize();
_network_dedicated = false;
_network_last_advertise_frame = 0;
_network_need_advertise = true;
_network_advertise_retries = 0;
+1 -2
View File
@@ -1,4 +1,4 @@
/* $Id: network_func.h 26788 2014-09-07 14:21:16Z frosch $ */
/* $Id: network_func.h 27431 2015-11-01 11:59:17Z frosch $ */
/*
* This file is part of OpenTTD.
@@ -34,7 +34,6 @@ extern NetworkCompanyState *_network_company_states;
extern ClientID _network_own_client_id;
extern ClientID _redirect_console_to_client;
extern bool _network_need_advertise;
extern uint32 _network_last_advertise_frame;
extern uint8 _network_reconnect;
extern StringList _network_bind_list;
extern StringList _network_host_list;
+1 -2
View File
@@ -1954,7 +1954,6 @@ struct NetworkClientListWindow : Window {
SetDParam(1, INVALID_COMPANY);
uint width2 = GetStringBoundingBox(STR_NETWORK_CLIENT_EXTRA).width;
size->width = WD_FRAMERECT_LEFT + this->server_client_width + this->icon_size.width + WD_FRAMERECT_LEFT + width + WD_FRAMERECT_RIGHT + width2;
//size->width = WD_FRAMERECT_LEFT + this->server_client_width + this->company_icon_width + width + WD_FRAMERECT_RIGHT;
}
virtual void OnPaint()
@@ -2012,7 +2011,7 @@ struct NetworkClientListWindow : Window {
SetDParam(1, ci->client_playas == INVALID_COMPANY ? ci->client_playas : ci->client_playas + 1);
DrawString(rtl ? left : name_left + extra, rtl ? name_right - extra : right, y + text_offset, STR_NETWORK_CLIENT_EXTRA, TC_FROMSTRING, SA_RIGHT);
y += this->line_height;
y += line_height;
}
}
+21 -9
View File
@@ -1,4 +1,4 @@
/* $Id: network_udp.cpp 26486 2014-04-23 21:12:09Z rubidium $ */
/* $Id: network_udp.cpp 27431 2015-11-01 11:59:17Z frosch $ */
/*
* This file is part of OpenTTD.
@@ -42,9 +42,9 @@ static ThreadMutex *_network_udp_mutex = ThreadMutex::New();
/** Session key to register ourselves to the master server */
static uint64 _session_key = 0;
static const uint ADVERTISE_NORMAL_INTERVAL = 30000; ///< interval between advertising in ticks (15 minutes)
static const uint ADVERTISE_RETRY_INTERVAL = 300; ///< re-advertise when no response after this many ticks (9 seconds)
static const uint ADVERTISE_RETRY_TIMES = 3; ///< give up re-advertising after this much failed retries
static const uint32 ADVERTISE_NORMAL_INTERVAL = 15 * 60 * 1000; ///< interval between advertising in ms (15 minutes)
static const uint32 ADVERTISE_RETRY_INTERVAL = 10 * 1000; ///< re-advertise when no response after this many ms (10 seconds)
static const uint32 ADVERTISE_RETRY_TIMES = 3; ///< give up re-advertising after this much failed retries
NetworkUDPSocketHandler *_udp_client_socket = NULL; ///< udp client socket
NetworkUDPSocketHandler *_udp_server_socket = NULL; ///< udp server socket
@@ -616,25 +616,37 @@ static void NetworkUDPAdvertiseThread(void *pntr)
*/
void NetworkUDPAdvertise()
{
static uint32 _last_advertisement = 0; ///< The time of the last advertisement (used to check for wrapping of time)
static uint32 _next_advertisement = 0; ///< The next time we should perform a normal advertisement.
static uint32 _next_retry = 0; ///< The next time we should perform a retry of an advertisement.
/* Check if we should send an advertise */
if (!_networking || !_network_server || !_network_udp_server || !_settings_client.network.server_advertise) return;
if (_network_need_advertise) {
if (_network_need_advertise || _realtime_tick < _last_advertisement) {
/* Forced advertisement, or a wrapping of time in which case we determine the advertisement/retry times again. */
_network_need_advertise = false;
_network_advertise_retries = ADVERTISE_RETRY_TIMES;
} else {
/* Only send once every ADVERTISE_NORMAL_INTERVAL ticks */
if (_network_advertise_retries == 0) {
if ((_network_last_advertise_frame + ADVERTISE_NORMAL_INTERVAL) > _frame_counter) return;
if (_realtime_tick <= _next_advertisement) return;
_network_advertise_retries = ADVERTISE_RETRY_TIMES;
} else {
/* An actual retry. */
if (_realtime_tick <= _next_retry) return;
}
if ((_network_last_advertise_frame + ADVERTISE_RETRY_INTERVAL) > _frame_counter) return;
}
_network_advertise_retries--;
_network_last_advertise_frame = _frame_counter;
_last_advertisement = _realtime_tick;
_next_advertisement = _realtime_tick + ADVERTISE_NORMAL_INTERVAL;
_next_retry = _realtime_tick + ADVERTISE_RETRY_INTERVAL;
/* Make sure we do not have an overflow when checking these; when time wraps, we simply force an advertisement. */
if (_next_advertisement < _last_advertisement) _next_advertisement = UINT32_MAX;
if (_next_retry < _last_advertisement) _next_retry = UINT32_MAX;
if (!ThreadObject::New(NetworkUDPAdvertiseThread, NULL)) {
NetworkUDPAdvertiseThread(NULL);