mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r15998) -Codechange: some coding style updates
This commit is contained in:
parent
c08c4224be
commit
ebe0f9e7f7
@ -483,9 +483,6 @@ void NetworkCloseClient(NetworkClientSocket *cs)
|
|||||||
/* For the server, to accept new clients */
|
/* For the server, to accept new clients */
|
||||||
static void NetworkAcceptClients(SOCKET ls)
|
static void NetworkAcceptClients(SOCKET ls)
|
||||||
{
|
{
|
||||||
NetworkClientSocket *cs;
|
|
||||||
bool banned;
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
struct sockaddr_storage sin;
|
struct sockaddr_storage sin;
|
||||||
memset(&sin, 0, sizeof(sin));
|
memset(&sin, 0, sizeof(sin));
|
||||||
@ -501,7 +498,7 @@ static void NetworkAcceptClients(SOCKET ls)
|
|||||||
SetNoDelay(s); // XXX error handling?
|
SetNoDelay(s); // XXX error handling?
|
||||||
|
|
||||||
/* Check if the client is banned */
|
/* Check if the client is banned */
|
||||||
banned = false;
|
bool banned = false;
|
||||||
for (char **iter = _network_ban_list.Begin(); iter != _network_ban_list.End(); iter++) {
|
for (char **iter = _network_ban_list.Begin(); iter != _network_ban_list.End(); iter++) {
|
||||||
banned = address.IsInNetmask(*iter);
|
banned = address.IsInNetmask(*iter);
|
||||||
if (banned) {
|
if (banned) {
|
||||||
@ -518,7 +515,7 @@ static void NetworkAcceptClients(SOCKET ls)
|
|||||||
/* If this client is banned, continue with next client */
|
/* If this client is banned, continue with next client */
|
||||||
if (banned) continue;
|
if (banned) continue;
|
||||||
|
|
||||||
cs = NetworkAllocClient(s);
|
NetworkClientSocket *cs = NetworkAllocClient(s);
|
||||||
if (cs == NULL) {
|
if (cs == NULL) {
|
||||||
/* no more clients allowed?
|
/* no more clients allowed?
|
||||||
* Send to the client that we are full! */
|
* Send to the client that we are full! */
|
||||||
@ -817,7 +814,6 @@ void NetworkDisconnect()
|
|||||||
static bool NetworkReceive()
|
static bool NetworkReceive()
|
||||||
{
|
{
|
||||||
NetworkClientSocket *cs;
|
NetworkClientSocket *cs;
|
||||||
int n;
|
|
||||||
fd_set read_fd, write_fd;
|
fd_set read_fd, write_fd;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
@ -836,9 +832,9 @@ static bool NetworkReceive()
|
|||||||
|
|
||||||
tv.tv_sec = tv.tv_usec = 0; // don't block at all.
|
tv.tv_sec = tv.tv_usec = 0; // don't block at all.
|
||||||
#if !defined(__MORPHOS__) && !defined(__AMIGA__)
|
#if !defined(__MORPHOS__) && !defined(__AMIGA__)
|
||||||
n = select(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv);
|
int n = select(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv);
|
||||||
#else
|
#else
|
||||||
n = WaitSelect(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv, NULL);
|
int n = WaitSelect(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv, NULL);
|
||||||
#endif
|
#endif
|
||||||
if (n == -1 && !_network_server) NetworkError(STR_NETWORK_ERR_LOSTCONNECTION);
|
if (n == -1 && !_network_server) NetworkError(STR_NETWORK_ERR_LOSTCONNECTION);
|
||||||
|
|
||||||
@ -1037,8 +1033,9 @@ static void NetworkGenerateUniqueId()
|
|||||||
checksum.Append((const uint8*)coding_string, strlen(coding_string));
|
checksum.Append((const uint8*)coding_string, strlen(coding_string));
|
||||||
checksum.Finish(digest);
|
checksum.Finish(digest);
|
||||||
|
|
||||||
for (di = 0; di < 16; ++di)
|
for (di = 0; di < 16; ++di) {
|
||||||
sprintf(hex_output + di * 2, "%02x", digest[di]);
|
sprintf(hex_output + di * 2, "%02x", digest[di]);
|
||||||
|
}
|
||||||
|
|
||||||
/* _network_unique_id is our id */
|
/* _network_unique_id is our id */
|
||||||
snprintf(_settings_client.network.network_id, sizeof(_settings_client.network.network_id), "%s", hex_output);
|
snprintf(_settings_client.network.network_id, sizeof(_settings_client.network.network_id), "%s", hex_output);
|
||||||
|
@ -102,10 +102,8 @@ NetworkGameList *NetworkGameListAddItem(NetworkAddress address)
|
|||||||
* @param remove pointer to the item to be removed */
|
* @param remove pointer to the item to be removed */
|
||||||
void NetworkGameListRemoveItem(NetworkGameList *remove)
|
void NetworkGameListRemoveItem(NetworkGameList *remove)
|
||||||
{
|
{
|
||||||
NetworkGameList *item, *prev_item;
|
NetworkGameList *prev_item = NULL;
|
||||||
|
for (NetworkGameList *item = _network_game_list; item != NULL; item = item->next) {
|
||||||
prev_item = NULL;
|
|
||||||
for (item = _network_game_list; item != NULL; item = item->next) {
|
|
||||||
if (remove == item) {
|
if (remove == item) {
|
||||||
if (prev_item == NULL) {
|
if (prev_item == NULL) {
|
||||||
_network_game_list = remove->next;
|
_network_game_list = remove->next;
|
||||||
@ -127,7 +125,7 @@ void NetworkGameListRemoveItem(NetworkGameList *remove)
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MAX_GAME_LIST_REQUERY_COUNT = 5, ///< How often do we requery in number of times per server?
|
MAX_GAME_LIST_REQUERY_COUNT = 10, ///< How often do we requery in number of times per server?
|
||||||
REQUERY_EVERY_X_GAMELOOPS = 60, ///< How often do we requery in time?
|
REQUERY_EVERY_X_GAMELOOPS = 60, ///< How often do we requery in time?
|
||||||
REFRESH_GAMEINFO_X_REQUERIES = 50, ///< Refresh the game info itself after REFRESH_GAMEINFO_X_REQUERIES * REQUERY_EVERY_X_GAMELOOPS game loops
|
REFRESH_GAMEINFO_X_REQUERIES = 50, ///< Refresh the game info itself after REFRESH_GAMEINFO_X_REQUERIES * REQUERY_EVERY_X_GAMELOOPS game loops
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user