mirror of https://github.com/OpenTTD/OpenTTD
(svn r21853) -Codechange: HashCurrentCompanyPassword is only used by servers, so move it to network_server.* (dihedral)
parent
e95718bf43
commit
e54a1f6721
|
@ -202,25 +202,6 @@ const char *GenerateCompanyPasswordHash(const char *password, const char *passwo
|
||||||
return hashed_password;
|
return hashed_password;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Hash the current company password; used when the server 'company' sets his/her password.
|
|
||||||
*/
|
|
||||||
void HashCurrentCompanyPassword(const char *password)
|
|
||||||
{
|
|
||||||
uint32 password_game_seed;
|
|
||||||
char password_server_id[NETWORK_SERVER_ID_LENGTH];
|
|
||||||
|
|
||||||
password_game_seed = _settings_game.game_creation.generation_seed;
|
|
||||||
strecpy(password_server_id, _settings_client.network.network_id, lastof(password_server_id));
|
|
||||||
|
|
||||||
const char *new_pw = GenerateCompanyPasswordHash(password, password_server_id, password_game_seed);
|
|
||||||
strecpy(_network_company_states[_local_company].password, new_pw, lastof(_network_company_states[_local_company].password));
|
|
||||||
|
|
||||||
if (_network_server) {
|
|
||||||
NetworkServerUpdateCompanyPassworded(_local_company, !StrEmpty(_network_company_states[_local_company].password));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the company we want to join requires a password.
|
* Check if the company we want to join requires a password.
|
||||||
* @param company_id id of the company we want to check the 'passworded' flag for.
|
* @param company_id id of the company we want to check the 'passworded' flag for.
|
||||||
|
|
|
@ -19,9 +19,6 @@ void NetworkStartUp();
|
||||||
void NetworkShutDown();
|
void NetworkShutDown();
|
||||||
void NetworkDrawChatMessage();
|
void NetworkDrawChatMessage();
|
||||||
|
|
||||||
const char *GenerateCompanyPasswordHash(const char *password, const char *password_server_id, uint32 password_game_seed);
|
|
||||||
void HashCurrentCompanyPassword(const char *password);
|
|
||||||
|
|
||||||
extern bool _networking; ///< are we in networking mode?
|
extern bool _networking; ///< are we in networking mode?
|
||||||
extern bool _network_server; ///< network-server is active
|
extern bool _network_server; ///< network-server is active
|
||||||
extern bool _network_available; ///< is network mode available?
|
extern bool _network_available; ///< is network mode available?
|
||||||
|
|
|
@ -168,6 +168,7 @@ uint NetworkCalculateLag(const NetworkClientSocket *cs);
|
||||||
NetworkClientSocket *NetworkFindClientStateFromClientID(ClientID client_id);
|
NetworkClientSocket *NetworkFindClientStateFromClientID(ClientID client_id);
|
||||||
StringID GetNetworkErrorMsg(NetworkErrorCode err);
|
StringID GetNetworkErrorMsg(NetworkErrorCode err);
|
||||||
bool NetworkFindName(char new_name[NETWORK_CLIENT_NAME_LENGTH]);
|
bool NetworkFindName(char new_name[NETWORK_CLIENT_NAME_LENGTH]);
|
||||||
|
const char *GenerateCompanyPasswordHash(const char *password, const char *password_server_id, uint32 password_game_seed);
|
||||||
|
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
#endif /* NETWORK_INTERNAL_H */
|
#endif /* NETWORK_INTERNAL_H */
|
||||||
|
|
|
@ -1629,6 +1629,26 @@ bool NetworkServerChangeClientName(ClientID client_id, const char *new_name)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hash the current company password; used when the server 'company' sets his/her password.
|
||||||
|
* @param password The password to hash.
|
||||||
|
*/
|
||||||
|
void HashCurrentCompanyPassword(const char *password)
|
||||||
|
{
|
||||||
|
uint32 password_game_seed;
|
||||||
|
char password_server_id[NETWORK_SERVER_ID_LENGTH];
|
||||||
|
|
||||||
|
password_game_seed = _settings_game.game_creation.generation_seed;
|
||||||
|
strecpy(password_server_id, _settings_client.network.network_id, lastof(password_server_id));
|
||||||
|
|
||||||
|
const char *new_pw = GenerateCompanyPasswordHash(password, password_server_id, password_game_seed);
|
||||||
|
strecpy(_network_company_states[_local_company].password, new_pw, lastof(_network_company_states[_local_company].password));
|
||||||
|
|
||||||
|
if (_network_server) {
|
||||||
|
NetworkServerUpdateCompanyPassworded(_local_company, !StrEmpty(_network_company_states[_local_company].password));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Handle the local command-queue */
|
/* Handle the local command-queue */
|
||||||
static void NetworkHandleCommandQueue(NetworkClientSocket *cs)
|
static void NetworkHandleCommandQueue(NetworkClientSocket *cs)
|
||||||
{
|
{
|
||||||
|
|
|
@ -118,6 +118,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
void NetworkServer_Tick(bool send_frame);
|
void NetworkServer_Tick(bool send_frame);
|
||||||
|
void HashCurrentCompanyPassword(const char *password);
|
||||||
|
|
||||||
#define FOR_ALL_CLIENT_SOCKETS_FROM(var, start) FOR_ALL_ITEMS_FROM(NetworkClientSocket, clientsocket_index, var, start)
|
#define FOR_ALL_CLIENT_SOCKETS_FROM(var, start) FOR_ALL_ITEMS_FROM(NetworkClientSocket, clientsocket_index, var, start)
|
||||||
#define FOR_ALL_CLIENT_SOCKETS(var) FOR_ALL_CLIENT_SOCKETS_FROM(var, 0)
|
#define FOR_ALL_CLIENT_SOCKETS(var) FOR_ALL_CLIENT_SOCKETS_FROM(var, 0)
|
||||||
|
|
Loading…
Reference in New Issue