summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-04-09 01:16:15 +0000
committerrubidium <rubidium@openttd.org>2009-04-09 01:16:15 +0000
commitebe0f9e7f7a62d6eef467180ce3fad749e7ce8b7 (patch)
tree1d1ccdd8f3fc4ccb6a615a057b4f8ba4df159d6e
parentc08c4224bede1a8b0d0de776fde50226a917fb3c (diff)
downloadopenttd-ebe0f9e7f7a62d6eef467180ce3fad749e7ce8b7.tar.xz
(svn r15998) -Codechange: some coding style updates
-rw-r--r--src/network/network.cpp15
-rw-r--r--src/network/network_gamelist.cpp8
2 files changed, 9 insertions, 14 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp
index e442e46d6..59a5cf55f 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -483,9 +483,6 @@ void NetworkCloseClient(NetworkClientSocket *cs)
/* For the server, to accept new clients */
static void NetworkAcceptClients(SOCKET ls)
{
- NetworkClientSocket *cs;
- bool banned;
-
for (;;) {
struct sockaddr_storage sin;
memset(&sin, 0, sizeof(sin));
@@ -501,7 +498,7 @@ static void NetworkAcceptClients(SOCKET ls)
SetNoDelay(s); // XXX error handling?
/* Check if the client is banned */
- banned = false;
+ bool banned = false;
for (char **iter = _network_ban_list.Begin(); iter != _network_ban_list.End(); iter++) {
banned = address.IsInNetmask(*iter);
if (banned) {
@@ -518,7 +515,7 @@ static void NetworkAcceptClients(SOCKET ls)
/* If this client is banned, continue with next client */
if (banned) continue;
- cs = NetworkAllocClient(s);
+ NetworkClientSocket *cs = NetworkAllocClient(s);
if (cs == NULL) {
/* no more clients allowed?
* Send to the client that we are full! */
@@ -817,7 +814,6 @@ void NetworkDisconnect()
static bool NetworkReceive()
{
NetworkClientSocket *cs;
- int n;
fd_set read_fd, write_fd;
struct timeval tv;
@@ -836,9 +832,9 @@ static bool NetworkReceive()
tv.tv_sec = tv.tv_usec = 0; // don't block at all.
#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
- n = WaitSelect(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv, NULL);
+ int n = WaitSelect(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv, NULL);
#endif
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.Finish(digest);
- for (di = 0; di < 16; ++di)
+ for (di = 0; di < 16; ++di) {
sprintf(hex_output + di * 2, "%02x", digest[di]);
+ }
/* _network_unique_id is our id */
snprintf(_settings_client.network.network_id, sizeof(_settings_client.network.network_id), "%s", hex_output);
diff --git a/src/network/network_gamelist.cpp b/src/network/network_gamelist.cpp
index ee55976f6..4e96ad019 100644
--- a/src/network/network_gamelist.cpp
+++ b/src/network/network_gamelist.cpp
@@ -102,10 +102,8 @@ NetworkGameList *NetworkGameListAddItem(NetworkAddress address)
* @param remove pointer to the item to be removed */
void NetworkGameListRemoveItem(NetworkGameList *remove)
{
- NetworkGameList *item, *prev_item;
-
- prev_item = NULL;
- for (item = _network_game_list; item != NULL; item = item->next) {
+ NetworkGameList *prev_item = NULL;
+ for (NetworkGameList *item = _network_game_list; item != NULL; item = item->next) {
if (remove == item) {
if (prev_item == NULL) {
_network_game_list = remove->next;
@@ -127,7 +125,7 @@ void NetworkGameListRemoveItem(NetworkGameList *remove)
}
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?
REFRESH_GAMEINFO_X_REQUERIES = 50, ///< Refresh the game info itself after REFRESH_GAMEINFO_X_REQUERIES * REQUERY_EVERY_X_GAMELOOPS game loops
};