summaryrefslogtreecommitdiff
path: root/src/network/network_client.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-01-21 11:17:40 +0000
committerrubidium <rubidium@openttd.org>2010-01-21 11:17:40 +0000
commitf608ad7bafab32db9a16c0d5e1aeab23b3860389 (patch)
tree014217639f652c966575c58cc47e399a7d1046ad /src/network/network_client.cpp
parente130e4e9bacf704fc6e9eebf20d35fe5918227af (diff)
downloadopenttd-f608ad7bafab32db9a16c0d5e1aeab23b3860389.tar.xz
(svn r18875) -Codechange: remove some unneeded bits from the network protocol and improve the naming of some variables
Diffstat (limited to 'src/network/network_client.cpp')
-rw-r--r--src/network/network_client.cpp22
1 files changed, 10 insertions, 12 deletions
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)();