mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-28 00:49:11 +00:00
(svn r13334) -Codechange: move the network settings variables from network/network_internal to settings.
This commit is contained in:
@@ -216,8 +216,8 @@ uint NetworkCalculateLag(const NetworkTCPSocketHandler *cs)
|
||||
// This client has missed his ACK packet after 1 DAY_TICKS..
|
||||
// so we increase his lag for every frame that passes!
|
||||
// The packet can be out by a max of _net_frame_freq
|
||||
if (cs->last_frame_server + DAY_TICKS + _network_frame_freq < _frame_counter)
|
||||
lag += _frame_counter - (cs->last_frame_server + DAY_TICKS + _network_frame_freq);
|
||||
if (cs->last_frame_server + DAY_TICKS + _settings_client.network.frame_freq < _frame_counter)
|
||||
lag += _frame_counter - (cs->last_frame_server + DAY_TICKS + _settings_client.network.frame_freq);
|
||||
|
||||
return lag;
|
||||
}
|
||||
@@ -332,7 +332,7 @@ void CheckMinPlayers()
|
||||
{
|
||||
if (!_network_dedicated) return;
|
||||
|
||||
if (NetworkCountPlayers() < _network_min_players) {
|
||||
if (NetworkCountPlayers() < _settings_client.network.min_players) {
|
||||
if (_min_players_paused) return;
|
||||
|
||||
_min_players_paused = true;
|
||||
@@ -662,7 +662,7 @@ void NetworkCloseClient(NetworkTCPSocketHandler *cs)
|
||||
}
|
||||
|
||||
/* When the client was PRE_ACTIVE, the server was in pause mode, so unpause */
|
||||
if (cs->status == STATUS_PRE_ACTIVE && _network_pause_on_join) {
|
||||
if (cs->status == STATUS_PRE_ACTIVE && _settings_client.network.pause_on_join) {
|
||||
DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
|
||||
NetworkServer_HandleChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game unpaused", NETWORK_SERVER_INDEX);
|
||||
}
|
||||
@@ -802,7 +802,7 @@ static bool NetworkListen()
|
||||
SOCKET ls;
|
||||
struct sockaddr_in sin;
|
||||
|
||||
DEBUG(net, 1, "Listening on %s:%d", _network_server_bind_ip_host, _network_server_port);
|
||||
DEBUG(net, 1, "Listening on %s:%d", _settings_client.network.server_bind_ip, _settings_client.network.server_port);
|
||||
|
||||
ls = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (ls == INVALID_SOCKET) {
|
||||
@@ -823,7 +823,7 @@ static bool NetworkListen()
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_addr.s_addr = _network_server_bind_ip;
|
||||
sin.sin_port = htons(_network_server_port);
|
||||
sin.sin_port = htons(_settings_client.network.server_port);
|
||||
|
||||
if (bind(ls, (struct sockaddr*)&sin, sizeof(sin)) != 0) {
|
||||
ServerStartError("bind() failed");
|
||||
@@ -923,7 +923,7 @@ void NetworkAddServer(const char *b)
|
||||
|
||||
ttd_strlcpy(host, b, lengthof(host));
|
||||
|
||||
ttd_strlcpy(_network_default_ip, b, lengthof(_network_default_ip));
|
||||
ttd_strlcpy(_settings_client.network.connect_to_ip, b, lengthof(_settings_client.network.connect_to_ip));
|
||||
rport = NETWORK_DEFAULT_PORT;
|
||||
|
||||
ParseConnectionString(&player, &port, host);
|
||||
@@ -961,8 +961,8 @@ bool NetworkClientConnectGame(const char *host, uint16 port)
|
||||
|
||||
if (port == 0) return false;
|
||||
|
||||
ttd_strlcpy(_network_last_host, host, sizeof(_network_last_host));
|
||||
_network_last_port = port;
|
||||
ttd_strlcpy(_settings_client.network.last_host, host, sizeof(_settings_client.network.last_host));
|
||||
_settings_client.network.last_port = port;
|
||||
|
||||
NetworkDisconnect();
|
||||
NetworkUDPCloseAll();
|
||||
@@ -987,11 +987,16 @@ static void NetworkInitGameInfo()
|
||||
{
|
||||
NetworkClientInfo *ci;
|
||||
|
||||
ttd_strlcpy(_network_game_info.server_name, _network_server_name, sizeof(_network_game_info.server_name));
|
||||
ttd_strlcpy(_network_game_info.server_password, _network_server_password, sizeof(_network_server_password));
|
||||
ttd_strlcpy(_network_game_info.rcon_password, _network_rcon_password, sizeof(_network_rcon_password));
|
||||
if (_network_game_info.server_name[0] == '\0')
|
||||
_network_game_info.clients_max = _settings_client.network.max_clients;
|
||||
_network_game_info.companies_max = _settings_client.network.max_companies;
|
||||
_network_game_info.spectators_max = _settings_client.network.max_spectators;
|
||||
_network_game_info.server_lang = _settings_client.network.server_lang;
|
||||
ttd_strlcpy(_network_game_info.server_name, _settings_client.network.server_name, sizeof(_network_game_info.server_name));
|
||||
ttd_strlcpy(_network_game_info.server_password, _settings_client.network.server_password, sizeof(_network_game_info.server_password));
|
||||
ttd_strlcpy(_network_game_info.rcon_password, _settings_client.network.rcon_password, sizeof(_network_game_info.rcon_password));
|
||||
if (StrEmpty(_network_game_info.server_name)) {
|
||||
snprintf(_network_game_info.server_name, sizeof(_network_game_info.server_name), "Unnamed Server");
|
||||
}
|
||||
|
||||
ttd_strlcpy(_network_game_info.server_revision, _openttd_revision, sizeof(_network_game_info.server_revision));
|
||||
|
||||
@@ -1014,7 +1019,7 @@ static void NetworkInitGameInfo()
|
||||
_network_game_info.map_height = MapSizeY();
|
||||
_network_game_info.map_set = _settings_game.game_creation.landscape;
|
||||
|
||||
_network_game_info.use_password = (_network_server_password[0] != '\0');
|
||||
_network_game_info.use_password = !StrEmpty(_settings_client.network.server_password);
|
||||
|
||||
// We use _network_client_info[MAX_CLIENT_INFO - 1] to store the server-data in it
|
||||
// The index is NETWORK_SERVER_INDEX ( = 1)
|
||||
@@ -1024,8 +1029,8 @@ static void NetworkInitGameInfo()
|
||||
ci->client_index = NETWORK_SERVER_INDEX;
|
||||
ci->client_playas = _network_dedicated ? PLAYER_SPECTATOR : _local_player;
|
||||
|
||||
ttd_strlcpy(ci->client_name, _network_player_name, sizeof(ci->client_name));
|
||||
ttd_strlcpy(ci->unique_id, _network_unique_id, sizeof(ci->unique_id));
|
||||
ttd_strlcpy(ci->client_name, _settings_client.network.player_name, sizeof(ci->client_name));
|
||||
ttd_strlcpy(ci->unique_id, _settings_client.network.network_id, sizeof(ci->unique_id));
|
||||
}
|
||||
|
||||
bool NetworkServerStart()
|
||||
@@ -1041,7 +1046,7 @@ bool NetworkServerStart()
|
||||
|
||||
// Try to start UDP-server
|
||||
_network_udp_server = true;
|
||||
_network_udp_server = _udp_server_socket->Listen(_network_server_bind_ip, _network_server_port, false);
|
||||
_network_udp_server = _udp_server_socket->Listen(_network_server_bind_ip, _settings_client.network.server_port, false);
|
||||
|
||||
_network_server = true;
|
||||
_networking = true;
|
||||
@@ -1332,7 +1337,7 @@ void NetworkGameLoop()
|
||||
_frame_counter++;
|
||||
// Update max-frame-counter
|
||||
if (_frame_counter > _frame_counter_max) {
|
||||
_frame_counter_max = _frame_counter + _network_frame_freq;
|
||||
_frame_counter_max = _frame_counter + _settings_client.network.frame_freq;
|
||||
send_frame = true;
|
||||
}
|
||||
|
||||
@@ -1382,7 +1387,7 @@ static void NetworkGenerateUniqueId()
|
||||
sprintf(hex_output + di * 2, "%02x", digest[di]);
|
||||
|
||||
/* _network_unique_id is our id */
|
||||
snprintf(_network_unique_id, sizeof(_network_unique_id), "%s", hex_output);
|
||||
snprintf(_settings_client.network.network_id, sizeof(_settings_client.network.network_id), "%s", hex_output);
|
||||
}
|
||||
|
||||
void NetworkStartDebugLog(const char *hostname, uint16 port)
|
||||
@@ -1429,12 +1434,12 @@ void NetworkStartUp()
|
||||
_network_advertise_retries = 0;
|
||||
|
||||
/* Load the ip from the openttd.cfg */
|
||||
_network_server_bind_ip = inet_addr(_network_server_bind_ip_host);
|
||||
_network_server_bind_ip = inet_addr(_settings_client.network.server_bind_ip);
|
||||
/* And put the data back in it in case it was an invalid ip */
|
||||
snprintf(_network_server_bind_ip_host, sizeof(_network_server_bind_ip_host), "%s", inet_ntoa(*(struct in_addr *)&_network_server_bind_ip));
|
||||
snprintf(_settings_client.network.server_bind_ip, sizeof(_settings_client.network.server_bind_ip), "%s", inet_ntoa(*(struct in_addr *)&_network_server_bind_ip));
|
||||
|
||||
/* Generate an unique id when there is none yet */
|
||||
if (_network_unique_id[0] == '\0') NetworkGenerateUniqueId();
|
||||
if (StrEmpty(_settings_client.network.network_id)) NetworkGenerateUniqueId();
|
||||
|
||||
{
|
||||
byte cl_max = _network_game_info.clients_max;
|
||||
|
@@ -17,7 +17,6 @@ extern bool _network_server; ///< network-server is active
|
||||
extern bool _network_available; ///< is network mode available?
|
||||
extern bool _network_dedicated; ///< are we a dedicated server?
|
||||
extern bool _network_advertise; ///< is the server advertising to the master server?
|
||||
extern bool _network_reload_cfg; ///< will we reload the entire config for the next game?
|
||||
|
||||
#else /* ENABLE_NETWORK */
|
||||
/* Network function stubs when networking is disabled */
|
||||
|
@@ -84,7 +84,7 @@ void HashCurrentCompanyPassword()
|
||||
if (StrEmpty(_network_player_info[_local_player].password)) return;
|
||||
|
||||
_password_game_seed = _settings_game.game_creation.generation_seed;
|
||||
ttd_strlcpy(_password_server_unique_id, _network_unique_id, sizeof(_password_server_unique_id));
|
||||
ttd_strlcpy(_password_server_unique_id, _settings_client.network.network_id, sizeof(_password_server_unique_id));
|
||||
|
||||
const char *new_pw = GenerateCompanyPasswordHash(_network_player_info[_local_player].password);
|
||||
ttd_strlcpy(_network_player_info[_local_player].password, new_pw, sizeof(_network_player_info[_local_player].password));
|
||||
@@ -131,10 +131,10 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_JOIN)
|
||||
|
||||
p = NetworkSend_Init(PACKET_CLIENT_JOIN);
|
||||
p->Send_string(_openttd_revision);
|
||||
p->Send_string(_network_player_name); // Player name
|
||||
p->Send_string(_settings_client.network.player_name); // Player name
|
||||
p->Send_uint8 (_network_playas); // PlayAs
|
||||
p->Send_uint8 (NETLANG_ANY); // Language
|
||||
p->Send_string(_network_unique_id);
|
||||
p->Send_string(_settings_client.network.network_id);
|
||||
MY_CLIENT->Send_Packet(p);
|
||||
}
|
||||
|
||||
|
@@ -240,7 +240,7 @@ protected:
|
||||
public:
|
||||
NetworkGameWindow(const WindowDesc *desc) : QueryStringBaseWindow(desc)
|
||||
{
|
||||
ttd_strlcpy(this->edit_str_buf, _network_player_name, lengthof(this->edit_str_buf));
|
||||
ttd_strlcpy(this->edit_str_buf, _settings_client.network.player_name, lengthof(this->edit_str_buf));
|
||||
this->afilter = CS_ALPHANUMERAL;
|
||||
InitializeTextBuffer(&this->text, this->edit_str_buf, lengthof(this->edit_str_buf), 120);
|
||||
|
||||
@@ -290,7 +290,7 @@ public:
|
||||
sel->info.grfconfig == NULL);
|
||||
|
||||
SetDParam(0, 0x00);
|
||||
SetDParam(1, _lan_internet_types_dropdown[_network_lan_internet]);
|
||||
SetDParam(1, _lan_internet_types_dropdown[_settings_client.network.lan_internet]);
|
||||
this->DrawWidgets();
|
||||
|
||||
/* Edit box to set player name */
|
||||
@@ -315,7 +315,7 @@ public:
|
||||
y += NET_PRC__SIZE_OF_ROW;
|
||||
}
|
||||
|
||||
const NetworkGameList *last_joined = NetworkGameListAddItem(inet_addr(_network_last_host), _network_last_port);
|
||||
const NetworkGameList *last_joined = NetworkGameListAddItem(inet_addr(_settings_client.network.last_host), _settings_client.network.last_port);
|
||||
/* Draw the last joined server, if any */
|
||||
if (last_joined != NULL) this->DrawServerLine(last_joined, y = this->widget[NGWW_LASTJOINED].top + 3, last_joined == sel);
|
||||
|
||||
@@ -406,7 +406,7 @@ public:
|
||||
break;
|
||||
|
||||
case NGWW_CONN_BTN: // 'Connection' droplist
|
||||
ShowDropDownMenu(this, _lan_internet_types_dropdown, _network_lan_internet, NGWW_CONN_BTN, 0, 0); // do it for widget NSSW_CONN_BTN
|
||||
ShowDropDownMenu(this, _lan_internet_types_dropdown, _settings_client.network.lan_internet, NGWW_CONN_BTN, 0, 0); // do it for widget NSSW_CONN_BTN
|
||||
break;
|
||||
|
||||
case NGWW_NAME: // Sort by name
|
||||
@@ -432,7 +432,7 @@ public:
|
||||
} break;
|
||||
|
||||
case NGWW_LASTJOINED: {
|
||||
NetworkGameList *last_joined = NetworkGameListAddItem(inet_addr(_network_last_host), _network_last_port);
|
||||
NetworkGameList *last_joined = NetworkGameListAddItem(inet_addr(_settings_client.network.last_host), _settings_client.network.last_port);
|
||||
if (last_joined != NULL) {
|
||||
this->server = last_joined;
|
||||
this->SetDirty();
|
||||
@@ -440,7 +440,7 @@ public:
|
||||
} break;
|
||||
|
||||
case NGWW_FIND: // Find server automatically
|
||||
switch (_network_lan_internet) {
|
||||
switch (_settings_client.network.lan_internet) {
|
||||
case 0: NetworkUDPSearchGame(); break;
|
||||
case 1: NetworkUDPQueryMasterServer(); break;
|
||||
}
|
||||
@@ -448,7 +448,7 @@ public:
|
||||
|
||||
case NGWW_ADD: // Add a server
|
||||
ShowQueryString(
|
||||
BindCString(_network_default_ip),
|
||||
BindCString(_settings_client.network.connect_to_ip),
|
||||
STR_NETWORK_ENTER_IP,
|
||||
31 | 0x1000, // maximum number of characters OR
|
||||
250, // characters up to this width pixels, whichever is satisfied first
|
||||
@@ -461,8 +461,8 @@ public:
|
||||
|
||||
case NGWW_JOIN: // Join Game
|
||||
if (this->server != NULL) {
|
||||
snprintf(_network_last_host, sizeof(_network_last_host), "%s", inet_ntoa(*(struct in_addr *)&this->server->ip));
|
||||
_network_last_port = this->server->port;
|
||||
snprintf(_settings_client.network.last_host, sizeof(_settings_client.network.last_host), "%s", inet_ntoa(*(struct in_addr *)&this->server->ip));
|
||||
_settings_client.network.last_port = this->server->port;
|
||||
ShowNetworkLobbyWindow(this->server);
|
||||
}
|
||||
break;
|
||||
@@ -481,7 +481,7 @@ public:
|
||||
{
|
||||
switch (widget) {
|
||||
case NGWW_CONN_BTN:
|
||||
_network_lan_internet = index;
|
||||
_settings_client.network.lan_internet = index;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -521,9 +521,9 @@ public:
|
||||
|
||||
/* The name is only allowed when it starts with a letter! */
|
||||
if (!StrEmpty(this->edit_str_buf) && this->edit_str_buf[0] != ' ') {
|
||||
ttd_strlcpy(_network_player_name, this->edit_str_buf, lengthof(_network_player_name));
|
||||
ttd_strlcpy(_settings_client.network.player_name, this->edit_str_buf, lengthof(_settings_client.network.player_name));
|
||||
} else {
|
||||
ttd_strlcpy(_network_player_name, "Player", lengthof(_network_player_name));
|
||||
ttd_strlcpy(_settings_client.network.player_name, "Player", lengthof(_settings_client.network.player_name));
|
||||
}
|
||||
return state;
|
||||
}
|
||||
@@ -665,7 +665,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
|
||||
|
||||
NetworkStartServerWindow(const WindowDesc *desc) : QueryStringBaseWindow(desc)
|
||||
{
|
||||
ttd_strlcpy(this->edit_str_buf, _network_server_name, lengthof(this->edit_str_buf));
|
||||
ttd_strlcpy(this->edit_str_buf, _settings_client.network.server_name, lengthof(this->edit_str_buf));
|
||||
|
||||
_saveload_mode = SLD_NEW_GAME;
|
||||
BuildFileList();
|
||||
@@ -676,7 +676,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
|
||||
InitializeTextBuffer(&this->text, this->edit_str_buf, lengthof(this->edit_str_buf), 160);
|
||||
|
||||
this->field = NSSW_GAMENAME;
|
||||
_network_game_info.use_password = !StrEmpty(_network_server_password);
|
||||
_network_game_info.use_password = !StrEmpty(_settings_client.network.server_password);
|
||||
|
||||
this->FindWindowPlacementAndResize(desc);
|
||||
}
|
||||
@@ -737,7 +737,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
|
||||
|
||||
case NSSW_SETPWD: // Set password button
|
||||
this->widget_id = NSSW_SETPWD;
|
||||
ShowQueryString(BindCString(_network_server_password), STR_NETWORK_SET_PASSWORD, 20, 250, this, CS_ALPHANUMERAL);
|
||||
ShowQueryString(BindCString(_settings_client.network.server_password), STR_NETWORK_SET_PASSWORD, 20, 250, this, CS_ALPHANUMERAL);
|
||||
break;
|
||||
|
||||
case NSSW_SELMAP: { // Select map
|
||||
@@ -862,7 +862,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
|
||||
if (this->field == NSSW_GAMENAME) {
|
||||
if (this->HandleEditBoxKey(NSSW_GAMENAME, key, keycode, state) == 1) return state; // enter pressed
|
||||
|
||||
ttd_strlcpy(_network_server_name, this->text.buf, sizeof(_network_server_name));
|
||||
ttd_strlcpy(_settings_client.network.server_name, this->text.buf, sizeof(_settings_client.network.server_name));
|
||||
}
|
||||
|
||||
return state;
|
||||
@@ -873,8 +873,8 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
|
||||
if (str == NULL) return;
|
||||
|
||||
if (this->widget_id == NSSW_SETPWD) {
|
||||
ttd_strlcpy(_network_server_password, str, lengthof(_network_server_password));
|
||||
_network_game_info.use_password = !StrEmpty(_network_server_password);
|
||||
ttd_strlcpy(_settings_client.network.server_password, str, lengthof(_settings_client.network.server_password));
|
||||
_network_game_info.use_password = !StrEmpty(_settings_client.network.server_password);
|
||||
} else {
|
||||
int32 value = atoi(str);
|
||||
this->InvalidateWidget(this->widget_id);
|
||||
@@ -1104,22 +1104,22 @@ struct NetworkLobbyWindow : public Window {
|
||||
case NLWW_JOIN: // Join company
|
||||
/* Button can be clicked only when it is enabled */
|
||||
_network_playas = this->company;
|
||||
NetworkClientConnectGame(_network_last_host, _network_last_port);
|
||||
NetworkClientConnectGame(_settings_client.network.last_host, _settings_client.network.last_port);
|
||||
break;
|
||||
|
||||
case NLWW_NEW: // New company
|
||||
_network_playas = PLAYER_NEW_COMPANY;
|
||||
NetworkClientConnectGame(_network_last_host, _network_last_port);
|
||||
NetworkClientConnectGame(_settings_client.network.last_host, _settings_client.network.last_port);
|
||||
break;
|
||||
|
||||
case NLWW_SPECTATE: // Spectate game
|
||||
_network_playas = PLAYER_SPECTATOR;
|
||||
NetworkClientConnectGame(_network_last_host, _network_last_port);
|
||||
NetworkClientConnectGame(_settings_client.network.last_host, _settings_client.network.last_port);
|
||||
break;
|
||||
|
||||
case NLWW_REFRESH: // Refresh
|
||||
NetworkTCPQueryServer(_network_last_host, _network_last_port); // company info
|
||||
NetworkUDPQueryServer(_network_last_host, _network_last_port); // general data
|
||||
NetworkTCPQueryServer(_settings_client.network.last_host, _settings_client.network.last_port); // company info
|
||||
NetworkUDPQueryServer(_settings_client.network.last_host, _settings_client.network.last_port); // general data
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1162,8 +1162,8 @@ static void ShowNetworkLobbyWindow(NetworkGameList *ngl)
|
||||
{
|
||||
DeleteWindowById(WC_NETWORK_WINDOW, 0);
|
||||
|
||||
NetworkTCPQueryServer(_network_last_host, _network_last_port); // company info
|
||||
NetworkUDPQueryServer(_network_last_host, _network_last_port); // general data
|
||||
NetworkTCPQueryServer(_settings_client.network.last_host, _settings_client.network.last_port); // company info
|
||||
NetworkUDPQueryServer(_settings_client.network.last_host, _settings_client.network.last_port); // general data
|
||||
|
||||
new NetworkLobbyWindow(&_network_lobby_window_desc, ngl);
|
||||
}
|
||||
@@ -1894,7 +1894,7 @@ struct NetworkCompanyPasswordWindow : public QueryStringBaseWindow {
|
||||
{
|
||||
this->parent = parent;
|
||||
this->afilter = CS_ALPHANUMERAL;
|
||||
InitializeTextBuffer(&this->text, this->edit_str_buf, min(lengthof(_network_default_company_pass), lengthof(this->edit_str_buf)), 0);
|
||||
InitializeTextBuffer(&this->text, this->edit_str_buf, min(lengthof(_settings_client.network.default_company_pass), lengthof(this->edit_str_buf)), 0);
|
||||
|
||||
this->FindWindowPlacementAndResize(desc);
|
||||
}
|
||||
@@ -1902,7 +1902,7 @@ struct NetworkCompanyPasswordWindow : public QueryStringBaseWindow {
|
||||
void OnOk()
|
||||
{
|
||||
if (this->IsWidgetLowered(NCPWW_SAVE_AS_DEFAULT_PASSWORD)) {
|
||||
snprintf(_network_default_company_pass, lengthof(_network_default_company_pass), "%s", this->edit_str_buf);
|
||||
snprintf(_settings_client.network.default_company_pass, lengthof(_settings_client.network.default_company_pass), "%s", this->edit_str_buf);
|
||||
}
|
||||
|
||||
/* empty password is a '*' because of console argument */
|
||||
|
@@ -130,11 +130,7 @@ VARDEF NetworkGameInfo _network_game_info;
|
||||
VARDEF NetworkPlayerInfo _network_player_info[MAX_PLAYERS];
|
||||
VARDEF NetworkClientInfo _network_client_info[MAX_CLIENT_INFO];
|
||||
|
||||
VARDEF char _network_player_name[NETWORK_CLIENT_NAME_LENGTH];
|
||||
VARDEF char _network_default_ip[NETWORK_HOSTNAME_LENGTH];
|
||||
|
||||
VARDEF uint16 _network_own_client_index;
|
||||
VARDEF char _network_unique_id[NETWORK_UNIQUE_ID_LENGTH]; // Our own unique ID
|
||||
|
||||
VARDEF uint32 _frame_counter_server; // The frame_counter of the server, if in network-mode
|
||||
VARDEF uint32 _frame_counter_max; // To where we may go with our clients
|
||||
@@ -144,26 +140,11 @@ VARDEF uint32 _last_sync_frame; // Used in the server to store the last time a s
|
||||
// networking settings
|
||||
VARDEF uint32 _broadcast_list[MAX_INTERFACES + 1];
|
||||
|
||||
VARDEF uint16 _network_server_port;
|
||||
/* We use bind_ip and bind_ip_host, where bind_ip_host is the readable form of
|
||||
bind_ip_host, and bind_ip the numeric value, because we want a nice number
|
||||
in the openttd.cfg, but we wants to use the uint32 internally.. */
|
||||
VARDEF uint32 _network_server_bind_ip;
|
||||
VARDEF char _network_server_bind_ip_host[NETWORK_HOSTNAME_LENGTH];
|
||||
VARDEF bool _is_network_server; // Does this client wants to be a network-server?
|
||||
VARDEF char _network_server_name[NETWORK_NAME_LENGTH];
|
||||
VARDEF char _network_server_password[NETWORK_PASSWORD_LENGTH];
|
||||
VARDEF char _network_rcon_password[NETWORK_PASSWORD_LENGTH];
|
||||
VARDEF char _network_default_company_pass[NETWORK_PASSWORD_LENGTH];
|
||||
|
||||
VARDEF uint16 _network_max_join_time; ///< Time a client can max take to join
|
||||
VARDEF bool _network_pause_on_join; ///< Pause the game when a client tries to join (more chance of succeeding join)
|
||||
|
||||
VARDEF uint16 _redirect_console_to_client;
|
||||
|
||||
VARDEF uint16 _network_sync_freq;
|
||||
VARDEF uint8 _network_frame_freq;
|
||||
|
||||
VARDEF uint32 _sync_seed_1, _sync_seed_2;
|
||||
VARDEF uint32 _sync_frame;
|
||||
VARDEF bool _network_first_time;
|
||||
@@ -173,27 +154,16 @@ VARDEF uint8 _network_join_waiting;
|
||||
VARDEF uint16 _network_join_kbytes;
|
||||
VARDEF uint16 _network_join_kbytes_total;
|
||||
|
||||
VARDEF char _network_last_host[NETWORK_HOSTNAME_LENGTH];
|
||||
VARDEF short _network_last_port;
|
||||
VARDEF uint32 _network_last_host_ip;
|
||||
VARDEF uint8 _network_reconnect;
|
||||
|
||||
VARDEF bool _network_udp_server;
|
||||
VARDEF uint16 _network_udp_broadcast;
|
||||
|
||||
VARDEF byte _network_lan_internet;
|
||||
|
||||
VARDEF bool _network_need_advertise;
|
||||
VARDEF uint32 _network_last_advertise_frame;
|
||||
VARDEF uint8 _network_advertise_retries;
|
||||
|
||||
VARDEF bool _network_autoclean_companies;
|
||||
VARDEF uint8 _network_autoclean_unprotected; // Remove a company after X months
|
||||
VARDEF uint8 _network_autoclean_protected; // Unprotect a company after X months
|
||||
|
||||
VARDEF Year _network_restart_game_year; // If this year is reached, the server automaticly restarts
|
||||
VARDEF uint8 _network_min_players; // Minimum number of players for game to unpause
|
||||
|
||||
void NetworkTCPQueryServer(const char* host, unsigned short port);
|
||||
|
||||
byte NetworkSpectatorCount();
|
||||
|
@@ -230,7 +230,7 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_NEED_PASSWORD)(NetworkTCPSocketHandl
|
||||
Packet *p = NetworkSend_Init(PACKET_SERVER_NEED_PASSWORD);
|
||||
p->Send_uint8(type);
|
||||
p->Send_uint32(_settings_game.game_creation.generation_seed);
|
||||
p->Send_string(_network_unique_id);
|
||||
p->Send_string(_settings_client.network.network_id);
|
||||
cs->Send_Packet(p);
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_WELCOME)
|
||||
p = NetworkSend_Init(PACKET_SERVER_WELCOME);
|
||||
p->Send_uint16(cs->index);
|
||||
p->Send_uint32(_settings_game.game_creation.generation_seed);
|
||||
p->Send_string(_network_unique_id);
|
||||
p->Send_string(_settings_client.network.network_id);
|
||||
cs->Send_Packet(p);
|
||||
|
||||
// Transmit info about all the active clients
|
||||
@@ -800,7 +800,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_MAP_OK)
|
||||
}
|
||||
}
|
||||
|
||||
if (_network_pause_on_join) {
|
||||
if (_settings_client.network.pause_on_join) {
|
||||
/* Now pause the game till the client is in sync */
|
||||
DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
|
||||
|
||||
@@ -1021,7 +1021,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_ACK)
|
||||
/* Now he is! Unpause the game */
|
||||
cs->status = STATUS_ACTIVE;
|
||||
|
||||
if (_network_pause_on_join) {
|
||||
if (_settings_client.network.pause_on_join) {
|
||||
DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
|
||||
NetworkServer_HandleChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game unpaused (client connected)", NETWORK_SERVER_INDEX);
|
||||
}
|
||||
@@ -1365,7 +1365,7 @@ void NetworkUpdateClientInfo(uint16 client_index)
|
||||
/* Check if we want to restart the map */
|
||||
static void NetworkCheckRestartMap()
|
||||
{
|
||||
if (_network_restart_game_year != 0 && _cur_year >= _network_restart_game_year) {
|
||||
if (_settings_client.network.restart_game_year != 0 && _cur_year >= _settings_client.network.restart_game_year) {
|
||||
DEBUG(net, 0, "Auto-restarting map. Year %d reached", _cur_year);
|
||||
|
||||
StartNewGameWithoutGUI(GENERATE_NEW_SEED);
|
||||
@@ -1384,7 +1384,7 @@ static void NetworkAutoCleanCompanies()
|
||||
const Player *p;
|
||||
bool clients_in_company[MAX_PLAYERS];
|
||||
|
||||
if (!_network_autoclean_companies) return;
|
||||
if (!_settings_client.network.autoclean_companies) return;
|
||||
|
||||
memset(clients_in_company, 0, sizeof(clients_in_company));
|
||||
|
||||
@@ -1409,13 +1409,13 @@ static void NetworkAutoCleanCompanies()
|
||||
_network_player_info[p->index].months_empty++;
|
||||
|
||||
/* Is the company empty for autoclean_unprotected-months, and is there no protection? */
|
||||
if (_network_player_info[p->index].months_empty > _network_autoclean_unprotected && _network_player_info[p->index].password[0] == '\0') {
|
||||
if (_network_player_info[p->index].months_empty > _settings_client.network.autoclean_unprotected && _network_player_info[p->index].password[0] == '\0') {
|
||||
/* Shut the company down */
|
||||
DoCommandP(0, 2, p->index, NULL, CMD_PLAYER_CTRL);
|
||||
IConsolePrintF(CC_DEFAULT, "Auto-cleaned company #%d", p->index + 1);
|
||||
}
|
||||
/* Is the compnay empty for autoclean_protected-months, and there is a protection? */
|
||||
if (_network_player_info[p->index].months_empty > _network_autoclean_protected && _network_player_info[p->index].password[0] != '\0') {
|
||||
if (_network_player_info[p->index].months_empty > _settings_client.network.autoclean_protected && _network_player_info[p->index].password[0] != '\0') {
|
||||
/* Unprotect the company */
|
||||
_network_player_info[p->index].password[0] = '\0';
|
||||
IConsolePrintF(CC_DEFAULT, "Auto-removed protection from company #%d", p->index+1);
|
||||
@@ -1510,7 +1510,7 @@ void NetworkServer_Tick(bool send_frame)
|
||||
#endif
|
||||
|
||||
#ifndef ENABLE_NETWORK_SYNC_EVERY_FRAME
|
||||
if (_frame_counter >= _last_sync_frame + _network_sync_freq) {
|
||||
if (_frame_counter >= _last_sync_frame + _settings_client.network.sync_freq) {
|
||||
_last_sync_frame = _frame_counter;
|
||||
send_sync = true;
|
||||
}
|
||||
@@ -1542,8 +1542,8 @@ void NetworkServer_Tick(bool send_frame)
|
||||
}
|
||||
} else if (cs->status == STATUS_PRE_ACTIVE) {
|
||||
int lag = NetworkCalculateLag(cs);
|
||||
if (lag > _network_max_join_time) {
|
||||
IConsolePrintF(CC_ERROR,"Client #%d is dropped because it took longer than %d ticks for him to join", cs->index, _network_max_join_time);
|
||||
if (lag > _settings_client.network.max_join_time) {
|
||||
IConsolePrintF(CC_ERROR,"Client #%d is dropped because it took longer than %d ticks for him to join", cs->index, _settings_client.network.max_join_time);
|
||||
NetworkCloseClient(cs);
|
||||
}
|
||||
} else if (cs->status == STATUS_INACTIVE) {
|
||||
|
@@ -428,7 +428,7 @@ static void NetworkUDPBroadCast(NetworkUDPSocketHandler *socket)
|
||||
struct sockaddr_in out_addr;
|
||||
|
||||
out_addr.sin_family = AF_INET;
|
||||
out_addr.sin_port = htons(_network_server_port);
|
||||
out_addr.sin_port = htons(_settings_client.network.server_port);
|
||||
out_addr.sin_addr.s_addr = _broadcast_list[i];
|
||||
|
||||
DEBUG(net, 4, "[udp] broadcasting to %s", inet_ntoa(out_addr.sin_addr));
|
||||
@@ -535,7 +535,7 @@ void NetworkUDPRemoveAdvertise()
|
||||
Packet p(PACKET_UDP_SERVER_UNREGISTER);
|
||||
/* Packet is: Version, server_port */
|
||||
p.Send_uint8 (NETWORK_MASTER_SERVER_VERSION);
|
||||
p.Send_uint16(_network_server_port);
|
||||
p.Send_uint16(_settings_client.network.server_port);
|
||||
_udp_master_socket->SendPacket(&p, &out_addr);
|
||||
}
|
||||
|
||||
@@ -584,7 +584,7 @@ void NetworkUDPAdvertise()
|
||||
/* Packet is: WELCOME_MESSAGE, Version, server_port */
|
||||
p.Send_string(NETWORK_MASTER_SERVER_WELCOME_MESSAGE);
|
||||
p.Send_uint8 (NETWORK_MASTER_SERVER_VERSION);
|
||||
p.Send_uint16(_network_server_port);
|
||||
p.Send_uint16(_settings_client.network.server_port);
|
||||
_udp_master_socket->SendPacket(&p, &out_addr);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user