summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/network/core/config.h4
-rw-r--r--src/network/network.cpp11
-rw-r--r--src/network/network_base.h1
-rw-r--r--src/network/network_client.cpp22
-rw-r--r--src/network/network_server.cpp7
-rw-r--r--src/settings_type.h2
6 files changed, 20 insertions, 27 deletions
diff --git a/src/network/core/config.h b/src/network/core/config.h
index 9dac7ebe5..03f3e3b06 100644
--- a/src/network/core/config.h
+++ b/src/network/core/config.h
@@ -36,9 +36,9 @@ enum {
NETWORK_NAME_LENGTH = 80, ///< The maximum length of the server name and map name, in bytes including '\0'
NETWORK_COMPANY_NAME_LENGTH = 31, ///< The maximum length of the company name, in bytes including '\0'
NETWORK_HOSTNAME_LENGTH = 80, ///< The maximum length of the host name, in bytes including '\0'
- NETWORK_UNIQUE_ID_LENGTH = 33, ///< The maximum length of the unique id of the clients, in bytes including '\0'
+ NETWORK_SERVER_ID_LENGTH = 33, ///< The maximum length of the network id of the servers, in bytes including '\0'
NETWORK_REVISION_LENGTH = 15, ///< The maximum length of the revision, in bytes including '\0'
- NETWORK_PASSWORD_LENGTH = 33, ///< The maximum length of the password, in bytes including '\0' (must be >= NETWORK_UNIQUE_ID_LENGTH)
+ NETWORK_PASSWORD_LENGTH = 33, ///< The maximum length of the password, in bytes including '\0' (must be >= NETWORK_SERVER_ID_LENGTH)
NETWORK_CLIENTS_LENGTH = 200, ///< The maximum length for the list of clients that controls a company, in bytes including '\0'
NETWORK_CLIENT_NAME_LENGTH = 25, ///< The maximum length of a client's name, in bytes including '\0'
NETWORK_RCONCOMMAND_LENGTH = 500, ///< The maximum length of a rconsole command, in bytes including '\0'
diff --git a/src/network/network.cpp b/src/network/network.cpp
index c57703efb..380902d63 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -851,7 +851,6 @@ static void NetworkInitGameInfo()
ci->client_address = NetworkAddress((sockaddr*)&sock, sizeof(sock));
strecpy(ci->client_name, _settings_client.network.client_name, lastof(ci->client_name));
- strecpy(ci->unique_id, _settings_client.network.network_id, lastof(ci->unique_id));
}
bool NetworkServerStart()
@@ -1146,7 +1145,7 @@ void NetworkGameLoop()
NetworkSend();
}
-static void NetworkGenerateUniqueId()
+static void NetworkGenerateServerId()
{
Md5 checksum;
uint8 digest[16];
@@ -1154,7 +1153,7 @@ static void NetworkGenerateUniqueId()
char coding_string[NETWORK_NAME_LENGTH];
int di;
- snprintf(coding_string, sizeof(coding_string), "%d%s", (uint)Random(), "OpenTTD Unique ID");
+ snprintf(coding_string, sizeof(coding_string), "%d%s", (uint)Random(), "OpenTTD Server ID");
/* Generate the MD5 hash */
checksum.Append((const uint8*)coding_string, strlen(coding_string));
@@ -1164,7 +1163,7 @@ static void NetworkGenerateUniqueId()
sprintf(hex_output + di * 2, "%02x", digest[di]);
}
- /* _network_unique_id is our id */
+ /* _settings_client.network.network_id is our id */
snprintf(_settings_client.network.network_id, sizeof(_settings_client.network.network_id), "%s", hex_output);
}
@@ -1197,8 +1196,8 @@ void NetworkStartUp()
_network_need_advertise = true;
_network_advertise_retries = 0;
- /* Generate an unique id when there is none yet */
- if (StrEmpty(_settings_client.network.network_id)) NetworkGenerateUniqueId();
+ /* Generate an server id when there is none yet */
+ if (StrEmpty(_settings_client.network.network_id)) NetworkGenerateServerId();
memset(&_network_game_info, 0, sizeof(_network_game_info));
diff --git a/src/network/network_base.h b/src/network/network_base.h
index ff204062f..219afe927 100644
--- a/src/network/network_base.h
+++ b/src/network/network_base.h
@@ -29,7 +29,6 @@ struct NetworkClientInfo : NetworkClientInfoPool::PoolItem<&_networkclientinfo_p
CompanyID client_playas; ///< As which company is this client playing (CompanyID)
NetworkAddress client_address; ///< IP-address of the client (so he can be banned)
Date join_date; ///< Gamedate the client has joined
- char unique_id[NETWORK_UNIQUE_ID_LENGTH]; ///< Every play sends an unique id so we can indentify him
NetworkClientInfo(ClientID client_id = INVALID_CLIENT_ID) : client_id(client_id) {}
~NetworkClientInfo();
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index 688a21ef0..9a2608536 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -42,7 +42,7 @@ static uint32 last_ack_frame;
/** One bit of 'entropy' used to generate a salt for the company passwords. */
static uint32 _password_game_seed;
/** The other bit of 'entropy' used to generate a salt for the company passwords. */
-static char _password_server_unique_id[NETWORK_UNIQUE_ID_LENGTH];
+static char _password_server_id[NETWORK_SERVER_ID_LENGTH];
/** Maximum number of companies of the currently joined server. */
static uint8 _network_server_max_companies;
@@ -57,8 +57,8 @@ const char *_network_join_server_password = NULL;
/** Company password from -P argument */
const char *_network_join_company_password = NULL;
-/** Make sure the unique ID length is the same as a md5 hash. */
-assert_compile(NETWORK_UNIQUE_ID_LENGTH == 16 * 2 + 1);
+/** Make sure the server ID length is the same as a md5 hash. */
+assert_compile(NETWORK_SERVER_ID_LENGTH == 16 * 2 + 1);
/**
* Generates a hashed password for the company name.
@@ -69,16 +69,16 @@ static const char *GenerateCompanyPasswordHash(const char *password)
{
if (StrEmpty(password)) return password;
- char salted_password[NETWORK_UNIQUE_ID_LENGTH];
+ char salted_password[NETWORK_SERVER_ID_LENGTH];
memset(salted_password, 0, sizeof(salted_password));
snprintf(salted_password, sizeof(salted_password), "%s", password);
- /* Add the game seed and the server's unique ID as the salt. */
- for (uint i = 0; i < NETWORK_UNIQUE_ID_LENGTH - 1; i++) salted_password[i] ^= _password_server_unique_id[i] ^ (_password_game_seed >> i);
+ /* Add the game seed and the server's ID as the salt. */
+ for (uint i = 0; i < NETWORK_SERVER_ID_LENGTH - 1; i++) salted_password[i] ^= _password_server_id[i] ^ (_password_game_seed >> i);
Md5 checksum;
uint8 digest[16];
- static char hashed_password[NETWORK_UNIQUE_ID_LENGTH];
+ static char hashed_password[NETWORK_SERVER_ID_LENGTH];
/* Generate the MD5 hash */
checksum.Append((const uint8*)salted_password, sizeof(salted_password) - 1);
@@ -96,7 +96,7 @@ static const char *GenerateCompanyPasswordHash(const char *password)
void HashCurrentCompanyPassword(const char *password)
{
_password_game_seed = _settings_game.game_creation.generation_seed;
- strecpy(_password_server_unique_id, _settings_client.network.network_id, lastof(_password_server_unique_id));
+ strecpy(_password_server_id, _settings_client.network.network_id, lastof(_password_server_id));
const char *new_pw = GenerateCompanyPasswordHash(password);
strecpy(_network_company_states[_local_company].password, new_pw, lastof(_network_company_states[_local_company].password));
@@ -138,7 +138,6 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_JOIN)
* String: Client Name (max NETWORK_NAME_LENGTH)
* uint8: Play as Company id (1..MAX_COMPANIES)
* uint8: Language ID
- * String: Unique id to find the client back in server-listing
*/
Packet *p;
@@ -150,7 +149,6 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_JOIN)
p->Send_string(_settings_client.network.client_name); // Client name
p->Send_uint8 (_network_join_as); // PlayAs
p->Send_uint8 (NETLANG_ANY); // Language
- p->Send_string(_settings_client.network.network_id);
MY_CLIENT->Send_Packet(p);
}
@@ -532,7 +530,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_NEED_PASSWORD)
case NETWORK_COMPANY_PASSWORD:
/* Initialize the password hash salting variables. */
_password_game_seed = p->Recv_uint32();
- p->Recv_string(_password_server_unique_id, sizeof(_password_server_unique_id));
+ p->Recv_string(_password_server_id, sizeof(_password_server_id));
if (MY_CLIENT->HasClientQuit()) return NETWORK_RECV_STATUS_MALFORMED_PACKET;
password = _network_join_company_password;
/* FALL THROUGH */
@@ -554,7 +552,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_WELCOME)
/* Initialize the password hash salting variables, even if they were previously. */
_password_game_seed = p->Recv_uint32();
- p->Recv_string(_password_server_unique_id, sizeof(_password_server_unique_id));
+ p->Recv_string(_password_server_id, sizeof(_password_server_id));
/* Start receiving the map */
SEND_COMMAND(PACKET_CLIENT_GETMAP)();
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 8e68f5c97..54623fc8f 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -658,7 +658,6 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
}
char name[NETWORK_CLIENT_NAME_LENGTH];
- char unique_id[NETWORK_UNIQUE_ID_LENGTH];
NetworkClientInfo *ci;
CompanyID playas;
NetworkLanguage client_lang;
@@ -676,7 +675,6 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
p->Recv_string(name, sizeof(name));
playas = (Owner)p->Recv_uint8();
client_lang = (NetworkLanguage)p->Recv_uint8();
- p->Recv_string(unique_id, sizeof(unique_id));
if (cs->HasClientQuit()) return NETWORK_RECV_STATUS_CONN_LOST;
@@ -714,7 +712,6 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
ci = cs->GetInfo();
strecpy(ci->client_name, name, lastof(ci->client_name));
- strecpy(ci->unique_id, unique_id, lastof(ci->unique_id));
ci->client_playas = playas;
ci->client_lang = client_lang;
@@ -1733,10 +1730,10 @@ void NetworkServerShowStatusToConsole()
const char *status;
status = (cs->status < (ptrdiff_t)lengthof(stat_str) ? stat_str[cs->status] : "unknown");
- IConsolePrintF(CC_INFO, "Client #%1d name: '%s' status: '%s' frame-lag: %3d company: %1d IP: %s unique-id: '%s'",
+ IConsolePrintF(CC_INFO, "Client #%1d name: '%s' status: '%s' frame-lag: %3d company: %1d IP: %s",
cs->client_id, ci->client_name, status, lag,
ci->client_playas + (Company::IsValidID(ci->client_playas) ? 1 : 0),
- GetClientIP(ci), ci->unique_id);
+ GetClientIP(ci));
}
}
diff --git a/src/settings_type.h b/src/settings_type.h
index 5fef70dfa..d5e17520a 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -133,7 +133,7 @@ struct NetworkSettings {
char client_name[NETWORK_CLIENT_NAME_LENGTH]; ///< name of the player (as client)
char default_company_pass[NETWORK_PASSWORD_LENGTH]; ///< default password for new companies in encrypted form
char connect_to_ip[NETWORK_HOSTNAME_LENGTH]; ///< default for the "Add server" query
- char network_id[NETWORK_UNIQUE_ID_LENGTH]; ///< semi-unique ID of the client
+ char network_id[NETWORK_SERVER_ID_LENGTH]; ///< network ID for servers
bool autoclean_companies; ///< automatically remove companies that are not in use
uint8 autoclean_unprotected; ///< remove passwordless companies after this many months
uint8 autoclean_protected; ///< remove the password from passworded companies after this many months