summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-03-15 00:32:18 +0000
committerrubidium <rubidium@openttd.org>2009-03-15 00:32:18 +0000
commitb25a4f8231f3ded44038ea454a3d4c6a2dc9217d (patch)
tree776122508c686680b9c97f37ba3cb92ef905d67f /src/network
parentd72273d1f3b55df0e301408d630f24ef92ea8479 (diff)
downloadopenttd-b25a4f8231f3ded44038ea454a3d4c6a2dc9217d.tar.xz
(svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
Diffstat (limited to 'src/network')
-rw-r--r--src/network/core/core.cpp4
-rw-r--r--src/network/core/host.cpp2
-rw-r--r--src/network/core/os_abstraction.h14
-rw-r--r--src/network/core/udp.cpp4
-rw-r--r--src/network/network.cpp138
-rw-r--r--src/network/network_chat_gui.cpp4
-rw-r--r--src/network/network_client.cpp316
-rw-r--r--src/network/network_gui.cpp26
-rw-r--r--src/network/network_internal.h8
-rw-r--r--src/network/network_server.cpp520
-rw-r--r--src/network/network_udp.cpp26
11 files changed, 531 insertions, 531 deletions
diff --git a/src/network/core/core.cpp b/src/network/core/core.cpp
index 645259053..1c0ecad40 100644
--- a/src/network/core/core.cpp
+++ b/src/network/core/core.cpp
@@ -52,8 +52,8 @@ bool NetworkCoreInitialize()
}
}
}
-#endif // __AMIGA__
-#endif // __MORPHOS__ / __AMIGA__
+#endif /* __AMIGA__ */
+#endif /* __MORPHOS__ / __AMIGA__ */
/* Let's load the network in windows */
#ifdef WIN32
diff --git a/src/network/core/host.cpp b/src/network/core/host.cpp
index c88c96f55..bcd317f8c 100644
--- a/src/network/core/host.cpp
+++ b/src/network/core/host.cpp
@@ -200,7 +200,7 @@ void NetworkFindBroadcastIPs(uint32 *broadcast, int limit)
/* Now display to the debug all the detected ips */
DEBUG(net, 3, "Detected broadcast addresses:");
for (int i = 0; broadcast[i] != 0; i++) {
- DEBUG(net, 3, "%d) %s", i, inet_ntoa(*(struct in_addr *)&broadcast[i])); //inet_ntoa(inaddr));
+ DEBUG(net, 3, "%d) %s", i, inet_ntoa(*(struct in_addr *)&broadcast[i])); // inet_ntoa(inaddr));
}
}
diff --git a/src/network/core/os_abstraction.h b/src/network/core/os_abstraction.h
index 481f8ff33..8d5723639 100644
--- a/src/network/core/os_abstraction.h
+++ b/src/network/core/os_abstraction.h
@@ -50,7 +50,7 @@ typedef unsigned long in_addr_t;
# include <sys/ioctl.h>
# if defined(__BEOS__) && defined(BEOS_NET_SERVER)
# include <be/net/socket.h>
-# include <be/kernel/OS.h> // snooze()
+# include <be/kernel/OS.h> /* snooze() */
# include <be/net/netdb.h>
typedef unsigned long in_addr_t;
# define INADDR_NONE INADDR_BROADCAST
@@ -85,7 +85,7 @@ typedef unsigned long in_addr_t;
# include <errno.h>
# include <sys/time.h>
# include <netdb.h>
-#endif // UNIX
+#endif /* UNIX */
#ifdef __BEOS__
typedef int socklen_t;
@@ -146,13 +146,13 @@ typedef unsigned long in_addr_t;
/* MorphOS and Amiga stuff */
#if defined(__MORPHOS__) || defined(__AMIGA__)
# include <exec/types.h>
-# include <proto/exec.h> // required for Open/CloseLibrary()
+# include <proto/exec.h> /* required for Open/CloseLibrary() */
/* MorphOS defines his network functions with UBYTE arrays while we
* use char arrays. This gives tons of unneeded warnings */
# define UBYTE char
# if defined(__MORPHOS__)
-# include <sys/filio.h> // FIO* defines
-# include <sys/sockio.h> // SIO* defines
+# include <sys/filio.h> /* FIO* defines */
+# include <sys/sockio.h> /* SIO* defines */
# include <netinet/in.h>
# else /* __AMIGA__ */
# include <proto/socket.h>
@@ -174,7 +174,7 @@ typedef unsigned long in_addr_t;
extern struct MsgPort *TimerPort;
extern struct timerequest *TimerRequest;
# endif
-#endif // __MORPHOS__ || __AMIGA__
+#endif /* __MORPHOS__ || __AMIGA__ */
static inline bool SetNonBlocking(SOCKET d)
{
@@ -193,7 +193,7 @@ static inline bool SetNonBlocking(SOCKET d)
static inline bool SetNoDelay(SOCKET d)
{
/* XXX should this be done at all? */
-#if !defined(BEOS_NET_SERVER) // not implemented on BeOS net_server
+#if !defined(BEOS_NET_SERVER) /* not implemented on BeOS net_server */
int b = 1;
/* The (const char*) cast is needed for windows */
return setsockopt(d, IPPROTO_TCP, TCP_NODELAY, (const char*)&b, sizeof(b)) == 0;
diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp
index 8035446c0..6c921ae0a 100644
--- a/src/network/core/udp.cpp
+++ b/src/network/core/udp.cpp
@@ -50,7 +50,7 @@ bool NetworkUDPSocketHandler::Listen(const uint32 host, const uint16 port, const
if (broadcast) {
/* Enable broadcast */
unsigned long val = 1;
-#ifndef BEOS_NET_SERVER // will work around this, some day; maybe.
+#ifndef BEOS_NET_SERVER /* will work around this, some day; maybe. */
setsockopt(this->sock, SOL_SOCKET, SO_BROADCAST, (char *) &val , sizeof(val));
#endif
}
@@ -233,7 +233,7 @@ void NetworkUDPSocketHandler::Recv_NetworkGameInfo(Packet *p, NetworkGameInfo *i
*dst = c;
dst = &c->next;
}
- } /* Fallthrough */
+ } // Fallthrough
case 3:
info->game_date = Clamp(p->Recv_uint32(), 0, MAX_DATE);
info->start_date = Clamp(p->Recv_uint32(), 0, MAX_DATE);
diff --git a/src/network/network.cpp b/src/network/network.cpp
index f3b036592..f6d4caf50 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -79,12 +79,12 @@ extern NetworkUDPSocketHandler *_udp_client_socket; ///< udp client socket
extern NetworkUDPSocketHandler *_udp_server_socket; ///< udp server socket
extern NetworkUDPSocketHandler *_udp_master_socket; ///< udp master socket
-// The listen socket for the server
+/* The listen socket for the server */
static SOCKET _listensocket;
-// The amount of clients connected
+/* The amount of clients connected */
static byte _network_clients_connected = 0;
-// The identifier counter for new clients (is never decreased)
+/* The identifier counter for new clients (is never decreased) */
static ClientID _network_client_id = CLIENT_ID_FIRST;
/* Some externs / forwards */
@@ -149,8 +149,8 @@ NetworkClientSocket *NetworkFindClientStateFromClientID(ClientID client_id)
return NULL;
}
-// NetworkGetClientName is a server-safe function to get the name of the client
-// if the user did not send it yet, Client #<no> is used.
+/* NetworkGetClientName is a server-safe function to get the name of the client
+ * if the user did not send it yet, Client #<no> is used. */
void NetworkGetClientName(char *client_name, size_t size, const NetworkClientSocket *cs)
{
const NetworkClientInfo *ci = cs->GetInfo();
@@ -187,9 +187,9 @@ bool NetworkCompanyIsPassworded(CompanyID company_id)
return HasBit(_network_company_passworded, company_id);
}
-// This puts a text-message to the console, or in the future, the chat-box,
-// (to keep it all a bit more general)
-// If 'self_send' is true, this is the client who is sending the message
+/* This puts a text-message to the console, or in the future, the chat-box,
+ * (to keep it all a bit more general)
+ * If 'self_send' is true, this is the client who is sending the message */
void NetworkTextMessage(NetworkAction action, ConsoleColour colour, bool self_send, const char *name, const char *str, int64 data)
{
const int duration = 10; // Game days the messages stay visible
@@ -236,13 +236,13 @@ void NetworkTextMessage(NetworkAction action, ConsoleColour colour, bool self_se
NetworkAddChatMessage((TextColour)colour, duration, "%s", message);
}
-// Calculate the frame-lag of a client
+/* Calculate the frame-lag of a client */
uint NetworkCalculateLag(const NetworkClientSocket *cs)
{
int lag = cs->last_frame_server - cs->last_frame;
- // This client has missed his ACK packet after 1 DAY_TICKS..
- // so we increase his lag for every frame that passes!
- // The packet can be out by a max of _net_frame_freq
+ /* This client has missed his ACK packet after 1 DAY_TICKS..
+ * so we increase his lag for every frame that passes!
+ * The packet can be out by a max of _net_frame_freq */
if (cs->last_frame_server + DAY_TICKS + _settings_client.network.frame_freq < _frame_counter)
lag += _frame_counter - (cs->last_frame_server + DAY_TICKS + _settings_client.network.frame_freq);
@@ -250,8 +250,8 @@ uint NetworkCalculateLag(const NetworkClientSocket *cs)
}
-// There was a non-recoverable error, drop back to the main menu with a nice
-// error
+/* There was a non-recoverable error, drop back to the main menu with a nice
+ * error */
static void NetworkError(StringID error_string)
{
_switch_mode = SM_MENU;
@@ -267,11 +267,11 @@ static void ServerStartError(const char *error)
static void NetworkClientError(NetworkRecvStatus res, NetworkClientSocket *cs)
{
- // First, send a CLIENT_ERROR to the server, so he knows we are
- // disconnection (and why!)
+ /* First, send a CLIENT_ERROR to the server, so he knows we are
+ * disconnection (and why!) */
NetworkErrorCode errorno;
- // We just want to close the connection..
+ /* We just want to close the connection.. */
if (res == NETWORK_RECV_STATUS_CLOSE_QUERY) {
cs->has_quit = true;
NetworkCloseClient(cs);
@@ -287,7 +287,7 @@ static void NetworkClientError(NetworkRecvStatus res, NetworkClientSocket *cs)
case NETWORK_RECV_STATUS_NEWGRF_MISMATCH: errorno = NETWORK_ERROR_NEWGRF_MISMATCH; break;
default: errorno = NETWORK_ERROR_GENERAL; break;
}
- // This means we fucked up and the server closed the connection
+ /* This means we fucked up and the server closed the connection */
if (res != NETWORK_RECV_STATUS_SERVER_ERROR && res != NETWORK_RECV_STATUS_SERVER_FULL &&
res != NETWORK_RECV_STATUS_SERVER_BANNED) {
SEND_COMMAND(PACKET_CLIENT_ERROR)(errorno);
@@ -388,16 +388,16 @@ void ParseConnectionString(const char **company, const char **port, char *connec
}
}
-// Creates a new client from a socket
-// Used both by the server and the client
+/* Creates a new client from a socket
+ * Used both by the server and the client */
static NetworkClientSocket *NetworkAllocClient(SOCKET s)
{
if (_network_server) {
- // Can we handle a new client?
+ /* Can we handle a new client? */
if (_network_clients_connected >= MAX_CLIENTS) return NULL;
if (_network_game_info.clients_on >= _settings_client.network.max_clients) return NULL;
- // Register the login
+ /* Register the login */
_network_clients_connected++;
}
@@ -419,7 +419,7 @@ static NetworkClientSocket *NetworkAllocClient(SOCKET s)
return cs;
}
-// Close a connection
+/* Close a connection */
void NetworkCloseClient(NetworkClientSocket *cs)
{
/*
@@ -434,7 +434,7 @@ void NetworkCloseClient(NetworkClientSocket *cs)
DEBUG(net, 1, "Closed client connection %d", cs->client_id);
if (!cs->has_quit && _network_server && cs->status > STATUS_INACTIVE) {
- // We did not receive a leave message from this client...
+ /* We did not receive a leave message from this client... */
char client_name[NETWORK_CLIENT_NAME_LENGTH];
NetworkClientSocket *new_cs;
@@ -442,7 +442,7 @@ void NetworkCloseClient(NetworkClientSocket *cs)
NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, NULL, STR_NETWORK_ERR_CLIENT_CONNECTION_LOST);
- // Inform other clients of this... strange leaving ;)
+ /* Inform other clients of this... strange leaving ;) */
FOR_ALL_CLIENT_SOCKETS(new_cs) {
if (new_cs->status > STATUS_AUTH && cs != new_cs) {
SEND_COMMAND(PACKET_SERVER_ERROR_QUIT)(new_cs, cs->client_id, NETWORK_ERROR_CONNECTION_LOST);
@@ -457,7 +457,7 @@ void NetworkCloseClient(NetworkClientSocket *cs)
}
if (_network_server) {
- // We just lost one client :(
+ /* We just lost one client :( */
if (cs->status >= STATUS_AUTH) _network_game_info.clients_on--;
_network_clients_connected--;
@@ -470,7 +470,7 @@ void NetworkCloseClient(NetworkClientSocket *cs)
CheckMinActiveClients();
}
-// For the server, to accept new clients
+/* For the server, to accept new clients */
static void NetworkAcceptClients()
{
struct sockaddr_in sin;
@@ -478,7 +478,7 @@ static void NetworkAcceptClients()
uint i;
bool banned;
- // Should never ever happen.. is it possible??
+ /* Should never ever happen.. is it possible?? */
assert(_listensocket != INVALID_SOCKET);
for (;;) {
@@ -534,8 +534,8 @@ static void NetworkAcceptClients()
cs = NetworkAllocClient(s);
if (cs == NULL) {
- // no more clients allowed?
- // Send to the client that we are full!
+ /* no more clients allowed?
+ * Send to the client that we are full! */
Packet p(PACKET_SERVER_FULL);
p.PrepareToSend();
@@ -545,16 +545,16 @@ static void NetworkAcceptClients()
continue;
}
- // a new client has connected. We set him at inactive for now
- // maybe he is only requesting server-info. Till he has sent a PACKET_CLIENT_MAP_OK
- // the client stays inactive
+ /* a new client has connected. We set him at inactive for now
+ * maybe he is only requesting server-info. Till he has sent a PACKET_CLIENT_MAP_OK
+ * the client stays inactive */
cs->status = STATUS_INACTIVE;
cs->GetInfo()->client_ip = sin.sin_addr.s_addr; // Save the IP of the client
}
}
-// Set up the listen socket for the server
+/* Set up the listen socket for the server */
static bool NetworkListen()
{
SOCKET ls;
@@ -570,7 +570,7 @@ static bool NetworkListen()
{ // reuse the socket
int reuse = 1;
- // The (const char*) cast is needed for windows!!
+ /* The (const char*) cast is needed for windows!! */
if (setsockopt(ls, SOL_SOCKET, SO_REUSEADDR, (const char*)&reuse, sizeof(reuse)) == -1) {
ServerStartError("setsockopt() on listen socket failed");
return false;
@@ -607,7 +607,7 @@ static void InitializeNetworkPools()
_NetworkClientInfo_pool.AddBlockToPool();
}
-// Close all current connections
+/* Close all current connections */
static void NetworkClose()
{
NetworkClientSocket *cs;
@@ -641,7 +641,7 @@ static void NetworkClose()
InitializeNetworkPools();
}
-// Inits the network (cleans sockets and stuff)
+/* Inits the network (cleans sockets and stuff) */
static void NetworkInitialize()
{
InitializeNetworkPools();
@@ -670,9 +670,9 @@ public:
}
};
-// Query a server to fetch his game-info
-// If game_info is true, only the gameinfo is fetched,
-// else only the client_info is fetched
+/* Query a server to fetch his game-info
+ * If game_info is true, only the gameinfo is fetched,
+ * else only the client_info is fetched */
void NetworkTCPQueryServer(NetworkAddress address)
{
if (!_network_available) return;
@@ -747,7 +747,7 @@ public:
};
-// Used by clients, to connect to a server
+/* Used by clients, to connect to a server */
void NetworkClientConnectGame(NetworkAddress address)
{
if (!_network_available) return;
@@ -794,7 +794,7 @@ bool NetworkServerStart()
NetworkInitialize();
if (!NetworkListen()) return false;
- // Try to start UDP-server
+ /* Try to start UDP-server */
_network_udp_server = true;
_network_udp_server = _udp_server_socket->Listen(_network_server_bind_ip, _settings_client.network.server_port, false);
@@ -814,9 +814,9 @@ bool NetworkServerStart()
NetworkInitGameInfo();
- // execute server initialization script
+ /* execute server initialization script */
IConsoleCmdExec("exec scripts/on_server.scr 0");
- // if the server is dedicated ... add some other script
+ /* if the server is dedicated ... add some other script */
if (_network_dedicated) IConsoleCmdExec("exec scripts/on_dedicated.scr 0");
_min_active_clients_paused = false;
@@ -829,8 +829,8 @@ bool NetworkServerStart()
return true;
}
-// The server is rebooting...
-// The only difference with NetworkDisconnect, is the packets that is sent
+/* The server is rebooting...
+ * The only difference with NetworkDisconnect, is the packets that is sent */
void NetworkReboot()
{
if (_network_server) {
@@ -844,7 +844,7 @@ void NetworkReboot()
NetworkClose();
}
-// We want to disconnect from the host/clients
+/* We want to disconnect from the host/clients */
void NetworkDisconnect()
{
if (_network_server) {
@@ -862,7 +862,7 @@ void NetworkDisconnect()
NetworkClose();
}
-// Receives something from the network
+/* Receives something from the network */
static bool NetworkReceive()
{
NetworkClientSocket *cs;
@@ -878,7 +878,7 @@ static bool NetworkReceive()
FD_SET(cs->sock, &write_fd);
}
- // take care of listener port
+ /* take care of listener port */
if (_network_server) FD_SET(_listensocket, &read_fd);
tv.tv_sec = tv.tv_usec = 0; // don't block at all.
@@ -889,10 +889,10 @@ static bool NetworkReceive()
#endif
if (n == -1 && !_network_server) NetworkError(STR_NETWORK_ERR_LOSTCONNECTION);
- // accept clients..
+ /* accept clients.. */
if (_network_server && FD_ISSET(_listensocket, &read_fd)) NetworkAcceptClients();
- // read stuff from clients
+ /* read stuff from clients */
FOR_ALL_CLIENT_SOCKETS(cs) {
cs->writable = !!FD_ISSET(cs->sock, &write_fd);
if (FD_ISSET(cs->sock, &read_fd)) {
@@ -901,13 +901,13 @@ static bool NetworkReceive()
} else {
NetworkRecvStatus res;
- // The client already was quiting!
+ /* The client already was quiting! */
if (cs->has_quit) return false;
res = NetworkClient_ReadPackets(cs);
if (res != NETWORK_RECV_STATUS_OKAY) {
- // The client made an error of which we can not recover
- // close the client and drop back to main menu
+ /* The client made an error of which we can not recover
+ * close the client and drop back to main menu */
NetworkClientError(res, cs);
return false;
}
@@ -917,7 +917,7 @@ static bool NetworkReceive()
return true;
}
-// This sends all buffered commands (if possible)
+/* This sends all buffered commands (if possible) */
static void NetworkSend()
{
NetworkClientSocket *cs;
@@ -926,7 +926,7 @@ static void NetworkSend()
cs->Send_Packets();
if (cs->status == STATUS_MAP) {
- // This client is in the middle of a map-send, call the function for that
+ /* This client is in the middle of a map-send, call the function for that */
SEND_COMMAND(PACKET_SERVER_MAP)(cs);
}
}
@@ -941,7 +941,7 @@ static bool NetworkDoClientLoop()
StateGameLoop();
- // Check if we are in sync!
+ /* Check if we are in sync! */
if (_sync_frame != 0) {
if (_sync_frame == _frame_counter) {
#ifdef NETWORK_SEND_DOUBLE_SEED
@@ -956,9 +956,9 @@ static bool NetworkDoClientLoop()
return false;
}
- // If this is the first time we have a sync-frame, we
- // need to let the server know that we are ready and at the same
- // frame as he is.. so we can start playing!
+ /* If this is the first time we have a sync-frame, we
+ * need to let the server know that we are ready and at the same
+ * frame as he is.. so we can start playing! */
if (_network_first_time) {
_network_first_time = false;
SEND_COMMAND(PACKET_CLIENT_ACK)();
@@ -974,7 +974,7 @@ static bool NetworkDoClientLoop()
return true;
}
-// We have to do some UDP checking
+/* We have to do some UDP checking */
void NetworkUDPGameLoop()
{
_network_content_client.SendReceive();
@@ -990,8 +990,8 @@ void NetworkUDPGameLoop()
}
}
-// The main loop called from ttd.c
-// Here we also have to do StateGameLoop if needed!
+/* The main loop called from ttd.c
+ * Here we also have to do StateGameLoop if needed! */
void NetworkGameLoop()
{
if (!_networking) return;
@@ -1031,9 +1031,9 @@ void NetworkGameLoop()
bool send_frame = false;
- // We first increase the _frame_counter
+ /* We first increase the _frame_counter */
_frame_counter++;
- // Update max-frame-counter
+ /* Update max-frame-counter */
if (_frame_counter > _frame_counter_max) {
_frame_counter_max = _frame_counter + _settings_client.network.frame_freq;
send_frame = true;
@@ -1041,7 +1041,7 @@ void NetworkGameLoop()
NetworkExecuteLocalCommandQueue();
- // Then we make the frame
+ /* Then we make the frame */
StateGameLoop();
_sync_seed_1 = _random.state[0];
@@ -1051,15 +1051,15 @@ void NetworkGameLoop()
NetworkServer_Tick(send_frame);
} else {
- // Client
+ /* Client */
- // Make sure we are at the frame were the server is (quick-frames)
+ /* Make sure we are at the frame were the server is (quick-frames) */
if (_frame_counter_server > _frame_counter) {
while (_frame_counter_server > _frame_counter) {
if (!NetworkDoClientLoop()) break;
}
} else {
- // Else, keep on going till _frame_counter_max
+ /* Else, keep on going till _frame_counter_max */
if (_frame_counter_max > _frame_counter) NetworkDoClientLoop();
}
}
diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp
index 7331ea4ae..64178e8df 100644
--- a/src/network/network_chat_gui.cpp
+++ b/src/network/network_chat_gui.cpp
@@ -316,8 +316,8 @@ public:
*item = MAX_CLIENT_SLOTS;
}
- /* Then, try townnames */
- /* Not that the following assumes all town indices are adjacent, ie no
+ /* Then, try townnames
+ * Not that the following assumes all town indices are adjacent, ie no
* towns have been deleted. */
if (*item <= (uint)MAX_CLIENT_SLOTS + GetMaxTownIndex()) {
const Town *t;
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index 5aef979a6..8b24b9849 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -26,10 +26,10 @@
#include "table/strings.h"
-// This file handles all the client-commands
+/* This file handles all the client-commands */
-// So we don't make too much typos ;)
+/* So we don't make too much typos ;) */
#define MY_CLIENT GetNetworkClientSocket(0)
static uint32 last_ack_frame;
@@ -94,19 +94,19 @@ void HashCurrentCompanyPassword(const char *password)
}
-// **********
-// Sending functions
-// DEF_CLIENT_SEND_COMMAND has no parameters
-// **********
+/***********
+ * Sending functions
+ * DEF_CLIENT_SEND_COMMAND has no parameters
+ ************/
DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_COMPANY_INFO)
{
- //
- // Packet: CLIENT_COMPANY_INFO
- // Function: Request company-info (in detail)
- // Data:
- // <none>
- //
+ /*
+ * Packet: CLIENT_COMPANY_INFO
+ * Function: Request company-info (in detail)
+ * Data:
+ * <none>
+ */
Packet *p;
_network_join_status = NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO;
InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
@@ -117,16 +117,16 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_COMPANY_INFO)
DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_JOIN)
{
- //
- // Packet: CLIENT_JOIN
- // Function: Try to join the server
- // Data:
- // String: OpenTTD Revision (norev000 if no revision)
- // 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: CLIENT_JOIN
+ * Function: Try to join the server
+ * Data:
+ * String: OpenTTD Revision (norev000 if no revision)
+ * 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;
_network_join_status = NETWORK_JOIN_STATUS_AUTHORIZING;
@@ -143,11 +143,11 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_JOIN)
DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_NEWGRFS_CHECKED)
{
- //
- // Packet: CLIENT_NEWGRFS_CHECKED
- // Function: Tell the server that we have the required GRFs
- // Data:
- //
+ /*
+ * Packet: CLIENT_NEWGRFS_CHECKED
+ * Function: Tell the server that we have the required GRFs
+ * Data:
+ */
Packet *p = NetworkSend_Init(PACKET_CLIENT_NEWGRFS_CHECKED);
MY_CLIENT->Send_Packet(p);
@@ -155,13 +155,13 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_NEWGRFS_CHECKED)
DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_PASSWORD)(NetworkPasswordType type, const char *password)
{
- //
- // Packet: CLIENT_PASSWORD
- // Function: Send a password to the server to authorize
- // Data:
- // uint8: NetworkPasswordType
- // String: Password
- //
+ /*
+ * Packet: CLIENT_PASSWORD
+ * Function: Send a password to the server to authorize
+ * Data:
+ * uint8: NetworkPasswordType
+ * String: Password
+ */
Packet *p = NetworkSend_Init(PACKET_CLIENT_PASSWORD);
p->Send_uint8 (type);
p->Send_string(type == NETWORK_GAME_PASSWORD ? password : GenerateCompanyPasswordHash(password));
@@ -170,12 +170,12 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_PASSWORD)(NetworkPasswordType type,
DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_GETMAP)
{
- //
- // Packet: CLIENT_GETMAP
- // Function: Request the map from the server
- // Data:
- // <none>
- //
+ /*
+ * Packet: CLIENT_GETMAP
+ * Function: Request the map from the server
+ * Data:
+ * <none>
+ */
Packet *p = NetworkSend_Init(PACKET_CLIENT_GETMAP);
MY_CLIENT->Send_Packet(p);
@@ -183,12 +183,12 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_GETMAP)
DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_MAP_OK)
{
- //
- // Packet: CLIENT_MAP_OK
- // Function: Tell the server that we are done receiving/loading the map
- // Data:
- // <none>
- //
+ /*
+ * Packet: CLIENT_MAP_OK
+ * Function: Tell the server that we are done receiving/loading the map
+ * Data:
+ * <none>
+ */
Packet *p = NetworkSend_Init(PACKET_CLIENT_MAP_OK);
MY_CLIENT->Send_Packet(p);
@@ -196,12 +196,12 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_MAP_OK)
DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_ACK)
{
- //
- // Packet: CLIENT_ACK
- // Function: Tell the server we are done with this frame
- // Data:
- // uint32: current FrameCounter of the client
- //
+ /*
+ * Packet: CLIENT_ACK
+ * Function: Tell the server we are done with this frame
+ * Data:
+ * uint32: current FrameCounter of the client
+ */
Packet *p = NetworkSend_Init(PACKET_CLIENT_ACK);
@@ -209,21 +209,21 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_ACK)
MY_CLIENT->Send_Packet(p);
}
-// Send a command packet to the server
+/* Send a command packet to the server */
DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_COMMAND)(const CommandPacket *cp)
{
- //
- // Packet: CLIENT_COMMAND
- // Function: Send a DoCommand to the Server
- // Data:
- // uint8: CompanyID (0..MAX_COMPANIES-1)
- // uint32: CommandID (see command.h)
- // uint32: P1 (free variables used in DoCommand)
- // uint32: P2
- // uint32: Tile
- // string: text
- // uint8: CallBackID (see callback_table.c)
- //
+ /*
+ * Packet: CLIENT_COMMAND
+ * Function: Send a DoCommand to the Server
+ * Data:
+ * uint8: CompanyID (0..MAX_COMPANIES-1)
+ * uint32: CommandID (see command.h)
+ * uint32: P1 (free variables used in DoCommand)
+ * uint32: P2
+ * uint32: Tile
+ * string: text
+ * uint8: CallBackID (see callback_table.c)
+ */
Packet *p = NetworkSend_Init(PACKET_CLIENT_COMMAND);
MY_CLIENT->Send_Command(p, cp);
@@ -231,19 +231,19 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_COMMAND)(const CommandPacket *cp)
MY_CLIENT->Send_Packet(p);
}
-// Send a chat-packet over the network
+/* Send a chat-packet over the network */
DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_CHAT)(NetworkAction action, DestType type, int dest, const char *msg, int64 data)
{
- //
- // Packet: CLIENT_CHAT
- // Function: Send a chat-packet to the serve
- // Data:
- // uint8: ActionID (see network_data.h, NetworkAction)
- // uint8: Destination Type (see network_data.h, DestType);
- // uint32: Destination CompanyID/Client-identifier
- // String: Message (max NETWORK_CHAT_LENGTH)
- // uint64: Some arbitrary number
- //
+ /*
+ * Packet: CLIENT_CHAT
+ * Function: Send a chat-packet to the serve
+ * Data:
+ * uint8: ActionID (see network_data.h, NetworkAction)
+ * uint8: Destination Type (see network_data.h, DestType);
+ * uint32: Destination CompanyID/Client-identifier
+ * String: Message (max NETWORK_CHAT_LENGTH)
+ * uint64: Some arbitrary number
+ */
Packet *p = NetworkSend_Init(PACKET_CLIENT_CHAT);
@@ -256,15 +256,15 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_CHAT)(NetworkAction action, DestType
MY_CLIENT->Send_Packet(p);
}
-// Send an error-packet over the network
+/* Send an error-packet over the network */
DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_ERROR)(NetworkErrorCode errorno)
{
- //
- // Packet: CLIENT_ERROR
- // Function: The client made an error and is quiting the game
- // Data:
- // uint8: ErrorID (see network_data.h, NetworkErrorCode)
- //
+ /*
+ * Packet: CLIENT_ERROR
+ * Function: The client made an error and is quiting the game
+ * Data:
+ * uint8: ErrorID (see network_data.h, NetworkErrorCode)
+ */
Packet *p = NetworkSend_Init(PACKET_CLIENT_ERROR);
p->Send_uint8(errorno);
@@ -273,12 +273,12 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_ERROR)(NetworkErrorCode errorno)
DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_SET_PASSWORD)(const char *password)
{
- //
- // Packet: PACKET_CLIENT_SET_PASSWORD
- // Function: Set the password for the clients current company
- // Data:
- // String: Password
- //
+ /*
+ * Packet: PACKET_CLIENT_SET_PASSWORD
+ * Function: Set the password for the clients current company
+ * Data:
+ * String: Password
+ */
Packet *p = NetworkSend_Init(PACKET_CLIENT_SET_PASSWORD);
p->Send_string(GenerateCompanyPasswordHash(password));
@@ -287,26 +287,26 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_SET_PASSWORD)(const char *password)
DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_SET_NAME)(const char *name)
{
- //
- // Packet: PACKET_CLIENT_SET_NAME
- // Function: Gives the client a new name
- // Data:
- // String: Name
- //
+ /*
+ * Packet: PACKET_CLIENT_SET_NAME
+ * Function: Gives the client a new name
+ * Data:
+ * String: Name
+ */
Packet *p = NetworkSend_Init(PACKET_CLIENT_SET_NAME);
p->Send_string(name);
MY_CLIENT->Send_Packet(p);
}
-// Send an quit-packet over the network
+/* Send an quit-packet over the network */
DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_QUIT)()
{
- //
- // Packet: CLIENT_QUIT
- // Function: The client is quiting the game
- // Data:
- //
+ /*
+ * Packet: CLIENT_QUIT
+ * Function: The client is quiting the game
+ * Data:
+ */
Packet *p = NetworkSend_Init(PACKET_CLIENT_QUIT);
MY_CLIENT->Send_Packet(p);
@@ -329,17 +329,17 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_MOVE)(CompanyID company, const char
}
-// **********
-// Receiving functions
-// DEF_CLIENT_RECEIVE_COMMAND has parameter: Packet *p
-// **********
+/***********
+ * Receiving functions
+ * DEF_CLIENT_RECEIVE_COMMAND has parameter: Packet *p
+ ************/
extern bool SafeSaveOrLoad(const char *filename, int mode, GameMode newgm, Subdirectory subdir);
extern StringID _switch_mode_errorstr;
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_FULL)
{
- // We try to join a server which is full
+ /* We try to join a server which is full */
_switch_mode_errorstr = STR_NETWORK_ERR_SERVER_FULL;
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
@@ -348,7 +348,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_FULL)
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_BANNED)
{
- // We try to join a server where we are banned
+ /* We try to join a server where we are banned */
_switch_mode_errorstr = STR_NETWORK_ERR_SERVER_BANNED;
DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
@@ -391,9 +391,9 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMPANY_INFO)
return NETWORK_RECV_STATUS_CLOSE_QUERY;
}
-// This packet contains info about the client (playas and name)
-// as client we save this in NetworkClientInfo, linked via 'client_id'
-// which is always an unique number on a server.
+/* This packet contains info about the client (playas and name)
+ * as client we save this in NetworkClientInfo, linked via 'client_id'
+ * which is always an unique number on a server. */
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
{
NetworkClientInfo *ci;
@@ -411,11 +411,11 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
ci = NetworkFindClientInfoFromClientID(client_id);
if (ci != NULL) {
if (playas == ci->client_playas && strcmp(name, ci->client_name) != 0) {
- // Client name changed, display the change
+ /* Client name changed, display the change */
NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, name);
} else if (playas != ci->client_playas) {
- // The client changed from client-player..
- // Do not display that for now
+ /* The client changed from client-player..
+ * Do not display that for now */
}
ci->client_playas = playas;
@@ -426,7 +426,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
return NETWORK_RECV_STATUS_OKAY;
}
- // We don't have this client_id yet, find an empty client_id, and put the data there
+ /* We don't have this client_id yet, find an empty client_id, and put the data there */
ci = new NetworkClientInfo(client_id);
ci->client_playas = playas;
if (client_id == _network_own_client_id) MY_CLIENT->SetInfo(ci);
@@ -531,7 +531,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_WELCOME)
_password_game_seed = p->Recv_uint32();
p->Recv_string(_password_server_unique_id, sizeof(_password_server_unique_id));
- // Start receiving the map
+ /* Start receiving the map */
SEND_COMMAND(PACKET_CLIENT_GETMAP)();
return NETWORK_RECV_STATUS_OKAY;
}
@@ -542,7 +542,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_WAIT)
_network_join_waiting = p->Recv_uint8();
InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
- // We are put on hold for receiving the map.. we need GUI for this ;)
+ /* We are put on hold for receiving the map.. we need GUI for this ;) */
DEBUG(net, 1, "The server is currently busy sending the map to someone else, please wait..." );
DEBUG(net, 1, "There are %d clients in front of you", _network_join_waiting);
@@ -559,7 +559,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
if (MY_CLIENT->has_quit) return NETWORK_RECV_STATUS_CONN_LOST;
- // First packet, init some stuff
+ /* First packet, init some stuff */
if (maptype == MAP_PACKET_START) {
file_pointer = FioFOpenFile("network_client.tmp", "wb", AUTOSAVE_DIR);;
if (file_pointer == NULL) {
@@ -583,12 +583,12 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
_network_join_status = NETWORK_JOIN_STATUS_DOWNLOADING;
InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
- // The first packet does not contain any more data
+ /* The first packet does not contain any more data */
return NETWORK_RECV_STATUS_OKAY;
}
if (maptype == MAP_PACKET_NORMAL) {
- // We are still receiving data, put it to the file
+ /* We are still receiving data, put it to the file */
if (fwrite(p->buffer + p->pos, 1, p->size - p->pos, file_pointer) != (size_t)(p->size - p->pos)) {
_switch_mode_errorstr = STR_NETWORK_ERR_SAVEGAMEERROR;
return NETWORK_RECV_STATUS_SAVEGAME;
@@ -598,7 +598,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
InvalidateWindow(WC_NETWORK_STATUS_WINDOW, 0);
}
- // Check if this was the last packet
+ /* Check if this was the last packet */
if (maptype == MAP_PACKET_END) {
fclose(file_pointer);
@@ -614,7 +614,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
/* If the savegame has successfully loaded, ALL windows have been removed,
* only toolbar/statusbar and gamefield are visible */
- // Say we received the map and loaded it correctly!
+ /* Say we received the map and loaded it correctly! */
SEND_COMMAND(PACKET_CLIENT_MAP_OK)();
/* New company/spectator (invalid company) or company we want to join is not active
@@ -630,7 +630,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
NetworkSend_Command(0, 0, 0, CMD_COMPANY_CTRL, NULL, NULL);
}
} else {
- // take control over an existing company
+ /* take control over an existing company */
SetLocalCompany(_network_playas);
}
}
@@ -643,8 +643,8 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_FRAME)
_frame_counter_server = p->Recv_uint32();
_frame_counter_max = p->Recv_uint32();
#ifdef ENABLE_NETWORK_SYNC_EVERY_FRAME
- // Test if the server supports this option
- // and if we are at the frame the server is
+ /* Test if the server supports this option
+ * and if we are at the frame the server is */
if (p->pos < p->size) {
_sync_frame = _frame_counter_server;
_sync_seed_1 = p->Recv_uint32();
@@ -655,8 +655,8 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_FRAME)
#endif
DEBUG(net, 5, "Received FRAME %d", _frame_counter_server);
- // Let the server know that we received this frame correctly
- // We do this only once per day, to save some bandwidth ;)
+ /* Let the server know that we received this frame correctly
+ * We do this only once per day, to save some bandwidth ;) */
if (!_network_first_time && last_ack_frame < _frame_counter) {
last_ack_frame = _frame_counter + DAY_TICKS;
DEBUG(net, 4, "Sent ACK at %d", _frame_counter);
@@ -690,8 +690,8 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMMAND)
return NETWORK_RECV_STATUS_MALFORMED_PACKET;
}
- // The server did send us this command..
- // queue it in our own queue, so we can handle it in the upcoming frame!
+ /* The server did send us this command..
+ * queue it in our own queue, so we can handle it in the upcoming frame! */
NetworkAddCommandQueue(cp);
return NETWORK_RECV_STATUS_OKAY;
@@ -776,7 +776,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_QUIT)
InvalidateWindow(WC_CLIENT_LIST, 0);
- // If we come here it means we could not locate the client.. strange :s
+ /* If we come here it means we could not locate the client.. strange :s */
return NETWORK_RECV_STATUS_OKAY;
}
@@ -802,10 +802,10 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_SHUTDOWN)
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_NEWGAME)
{
- // To trottle the reconnects a bit, every clients waits
- // his _local_company value before reconnecting
- // COMPANY_SPECTATOR is currently 255, so to avoid long wait periods
- // set the max to 10.
+ /* To trottle the reconnects a bit, every clients waits
+ * his _local_company value before reconnecting
+ * COMPANY_SPECTATOR is currently 255, so to avoid long wait periods
+ * set the max to 10. */
_network_reconnect = min(_local_company + 1, 10);
_switch_mode_errorstr = STR_NETWORK_SERVER_REBOOT;
@@ -868,69 +868,69 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMPANY_UPDATE)
}
-// The layout for the receive-functions by the client
+/* The layout for the receive-functions by the client */
typedef NetworkRecvStatus NetworkClientPacket(Packet *p);
-// This array matches PacketType. At an incoming
-// packet it is matches against this array
-// and that way the right function to handle that
-// packet is found.
+/* This array matches PacketType. At an incoming
+ * packet it is matches against this array
+ * and that way the right function to handle that
+ * packet is found. */
static NetworkClientPacket * const _network_client_packet[] = {
RECEIVE_COMMAND(PACKET_SERVER_FULL),
RECEIVE_COMMAND(PACKET_SERVER_BANNED),
- NULL, /*PACKET_CLIENT_JOIN,*/
+ NULL, // PACKET_CLIENT_JOIN,
RECEIVE_COMMAND(PACKET_SERVER_ERROR),
- NULL, /*PACKET_CLIENT_COMPANY_INFO,*/
+ NULL, // PACKET_CLIENT_COMPANY_INFO,
RECEIVE_COMMAND(PACKET_SERVER_COMPANY_INFO),
RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO),
RECEIVE_COMMAND(PACKET_SERVER_NEED_PASSWORD),
- NULL, /*PACKET_CLIENT_PASSWORD,*/
+ NULL, // PACKET_CLIENT_PASSWORD,
RECEIVE_COMMAND(PACKET_SERVER_WELCOME),
- NULL, /*PACKET_CLIENT_GETMAP,*/
+ NULL, // PACKET_CLIENT_GETMAP,
RECEIVE_COMMAND(PACKET_SERVER_WAIT),
RECEIVE_COMMAND(PACKET_SERVER_MAP),
- NULL, /*PACKET_CLIENT_MAP_OK,*/
+ NULL, // PACKET_CLIENT_MAP_OK,
RECEIVE_COMMAND(PACKET_SERVER_JOIN),
RECEIVE_COMMAND(PACKET_SERVER_FRAME),
RECEIVE_COMMAND(PACKET_SERVER_SYNC),
- NULL, /*PACKET_CLIENT_ACK,*/
- NULL, /*PACKET_CLIENT_COMMAND,*/
+ NULL, // PACKET_CLIENT_ACK,
+ NULL, // PACKET_CLIENT_COMMAND,
RECEIVE_COMMAND(PACKET_SERVER_COMMAND),
- NULL, /*PACKET_CLIENT_CHAT,*/
+ NULL, // PACKET_CLIENT_CHAT,
RECEIVE_COMMAND(PACKET_SERVER_CHAT),
- NULL, /*PACKET_CLIENT_SET_PASSWORD,*/
- NULL, /*PACKET_CLIENT_SET_NAME,*/
- NULL, /*PACKET_CLIENT_QUIT,*/
- NULL, /*PACKET_CLIENT_ERROR,*/
+ NULL, // PACKET_CLIENT_SET_PASSWORD,
+ NULL, // PACKET_CLIENT_SET_NAME,
+ NULL, // PACKET_CLIENT_QUIT,
+ NULL, // PACKET_CLIENT_ERROR,
RECEIVE_COMMAND(PACKET_SERVER_QUIT),
RECEIVE_COMMAND(PACKET_SERVER_ERROR_QUIT),
RECEIVE_COMMAND(PACKET_SERVER_SHUTDOWN),
RECEIVE_COMMAND(PACKET_SERVER_NEWGAME),
RECEIVE_COMMAND(PACKET_SERVER_RCON),
- NULL, /*PACKET_CLIENT_RCON,*/
+ NULL, // PACKET_CLIENT_RCON,
RECEIVE_COMMAND(PACKET_SERVER_CHECK_NEWGRFS),
- NULL, /*PACKET_CLIENT_NEWGRFS_CHECKED,*/
+ NULL, // PACKET_CLIENT_NEWGRFS_CHECKED,
RECEIVE_COMMAND(PACKET_SERVER_MOVE),
- NULL, /* PACKET_CLIENT_MOVE */
+ NULL, // PACKET_CLIENT_MOVE
RECEIVE_COMMAND(PACKET_SERVER_COMPANY_UPDATE),
RECEIVE_COMMAND(PACKET_SERVER_CONFIG_UPDATE),
};
-// If this fails, check the array above with network_data.h
+/* If this fails, check the array above with network_data.h */
assert_compile(lengthof(_network_client_packet) == PACKET_END);
-// Is called after a client is connected to the server
+/* Is called after a client is connected to the server */
void NetworkClient_Connected()
{
- // Set the frame-counter to 0 so nothing happens till we are ready
+ /* Set the frame-counter to 0 so nothing happens till we are ready */
_frame_counter = 0;
_frame_counter_server = 0;
last_ack_frame = 0;
- // Request the game-info
+ /* Request the game-info */
SEND_COMMAND(PACKET_CLIENT_JOIN)();
}
-// Reads the packets from the socket-stream, if available
+/* Reads the packets from the socket-stream, if available */
NetworkRecvStatus NetworkClient_ReadPackets(NetworkClientSocket *cs)
{
Packet *p;
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 6190f78a8..8cb514813 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -828,7 +828,7 @@ void ShowNetworkGameWindow()
char * const *srv;
first = false;
- // add all servers from the config file to our list
+ /* add all servers from the config file to our list */
for (srv = &_network_host_list[0]; srv != endof(_network_host_list) && *srv != NULL; srv++) {
NetworkAddServer(*srv);
}
@@ -1391,16 +1391,16 @@ NetworkCompanyInfo *GetLobbyCompanyInfo(CompanyID company)
return (lobby != NULL && company < MAX_COMPANIES) ? &lobby->company_info[company] : NULL;
}
-// The window below gives information about the connected clients
-// and also makes able to give money to them, kick them (if server)
-// and stuff like that.
+/* The window below gives information about the connected clients
+ * and also makes able to give money to them, kick them (if server)
+ * and stuff like that. */
extern void DrawCompanyIcon(CompanyID cid, int x, int y);
-// Every action must be of this form
+/* Every action must be of this form */
typedef void ClientList_Action_Proc(byte client_no);
-// Max 10 actions per client
+/* Max 10 actions per client */
#define MAX_CLIENTLIST_ACTION 10
enum {
@@ -1429,7 +1429,7 @@ static const WindowDesc _client_list_desc = {
_client_list_widgets,
};
-// Finds the Xth client-info that is active
+/* Finds the Xth client-info that is active */
static const NetworkClientInfo *NetworkFindClientInfo(byte client_no)
{
const NetworkClientInfo *ci;
@@ -1442,7 +1442,7 @@ static const NetworkClientInfo *NetworkFindClientInfo(byte client_no)
return NULL;
}
-// Here we start to define the options out of the menu
+/* Here we start to define the options out of the menu */
static void ClientList_Kick(byte client_no)
{
const NetworkClientInfo *ci = NetworkFindClientInfo(client_no);
@@ -1576,7 +1576,7 @@ struct NetworkClientListPopupWindow : Window {
{
int num = 0;
- // Find the amount of actions
+ /* Find the amount of actions */
for (int i = 0; i < MAX_CLIENTLIST_ACTION; i++) {
if (this->action[i][0] == '\0') continue;
if (this->proc[i] == NULL) continue;
@@ -1677,7 +1677,7 @@ struct NetworkClientListWindow : Window
/* If height is changed */
if (this->height != CLNWND_OFFSET + num + 1) {
- // XXX - magic unfortunately; (num + 2) has to be one bigger than heigh (num + 1)
+ /* XXX - magic unfortunately; (num + 2) has to be one bigger than heigh (num + 1) */
this->SetDirty();
this->widget[3].bottom = this->widget[3].top + num + 2;
this->height = CLNWND_OFFSET + num + 1;
@@ -1778,7 +1778,7 @@ void ShowNetworkNeedPassword(NetworkPasswordType npt)
ShowQueryString(STR_EMPTY, caption, 20, 180, FindWindowById(WC_NETWORK_STATUS_WINDOW, 0), CS_ALPHANUMERAL, QSF_NONE);
}
-// Vars needed for the join-GUI
+/* Vars needed for the join-GUI */
NetworkJoinStatus _network_join_status;
uint8 _network_join_waiting;
uint32 _network_join_bytes;
@@ -1812,7 +1812,7 @@ struct NetworkJoinStatusWindow : Window {
SetDParam(1, _network_join_bytes_total);
DrawStringCentered(125, 46, STR_NETWORK_CONNECTING_DOWNLOADING, TC_GREY);
/* Fallthrough */
- default: /* Waiting is 15%, so the resting receivement of map is maximum 70% */
+ default: // Waiting is 15%, so the resting receivement of map is maximum 70%
progress = 15 + _network_join_bytes * (100 - 15) / _network_join_bytes_total;
}
@@ -1822,7 +1822,7 @@ struct NetworkJoinStatusWindow : Window {
virtual void OnClick(Point pt, int widget)
{
- if (widget == 2) { //Disconnect button
+ if (widget == 2) { // Disconnect button
NetworkDisconnect();
SwitchToMode(SM_MENU);
ShowNetworkGameWindow();
diff --git a/src/network/network_internal.h b/src/network/network_internal.h
index 32b229976..696d42828 100644
--- a/src/network/network_internal.h
+++ b/src/network/network_internal.h
@@ -100,7 +100,7 @@ extern uint32 _frame_counter;
extern uint32 _last_sync_frame; // Used in the server to store the last time a sync packet was sent to clients.
-// networking settings
+/* networking settings */
extern uint32 _broadcast_list[MAX_INTERFACES + 1];
extern uint32 _network_server_bind_ip;
@@ -108,7 +108,7 @@ extern uint32 _network_server_bind_ip;
extern uint32 _sync_seed_1, _sync_seed_2;
extern uint32 _sync_frame;
extern bool _network_first_time;
-// Vars needed for the join-GUI
+/* Vars needed for the join-GUI */
extern NetworkJoinStatus _network_join_status;
extern uint8 _network_join_waiting;
extern uint32 _network_join_bytes;
@@ -146,7 +146,7 @@ void NetworkAddCommandQueue(CommandPacket cp, NetworkClientSocket *cs = NULL);
void NetworkExecuteLocalCommandQueue();
void NetworkFreeLocalCommandQueue();
-// from network.c
+/* from network.c */
void NetworkCloseClient(NetworkClientSocket *cs);
void NetworkTextMessage(NetworkAction action, ConsoleColour colour, bool self_send, const char *name, const char *str = "", int64 data = 0);
void NetworkGetClientName(char *clientname, size_t size, const NetworkClientSocket *cs);
@@ -156,7 +156,7 @@ NetworkClientSocket *NetworkFindClientStateFromClientID(ClientID client_id);
StringID GetNetworkErrorMsg(NetworkErrorCode err);
bool NetworkFindName(char new_name[NETWORK_CLIENT_NAME_LENGTH]);
-// Macros to make life a bit more easier
+/* Macros to make life a bit more easier */
#define DEF_CLIENT_RECEIVE_COMMAND(type) NetworkRecvStatus NetworkPacketReceive_ ## type ## _command(Packet *p)
#define DEF_CLIENT_SEND_COMMAND(type) void NetworkPacketSend_ ## type ## _command()
#define DEF_CLIENT_SEND_COMMAND_PARAM(type) void NetworkPacketSend_ ## type ## _command
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index b286fdfd8..d2654751d 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -26,25 +26,25 @@
#include "table/strings.h"
-// This file handles all the server-commands
+/* This file handles all the server-commands */
static void NetworkHandleCommandQueue(NetworkClientSocket *cs);
-// **********
-// Sending functions
-// DEF_SERVER_SEND_COMMAND has parameter: NetworkClientSocket *cs
-// **********
+/***********
+ * Sending functions
+ * DEF_SERVER_SEND_COMMAND has parameter: NetworkClientSocket *cs
+ ************/
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_CLIENT_INFO)(NetworkClientSocket *cs, NetworkClientInfo *ci)
{
- //
- // Packet: SERVER_CLIENT_INFO
- // Function: Sends info about a client
- // Data:
- // uint32: The identifier of the client (always unique on a server. 1 = server, 0 is invalid)
- // uint8: As which company the client is playing
- // String: The name of the client
- //
+ /*
+ * Packet: SERVER_CLIENT_INFO
+ * Function: Sends info about a client
+ * Data:
+ * uint32: The identifier of the client (always unique on a server. 1 = server, 0 is invalid)
+ * uint8: As which company the client is playing
+ * String: The name of the client
+ */
if (ci->client_id != INVALID_CLIENT_ID) {
Packet *p = NetworkSend_Init(PACKET_SERVER_CLIENT_INFO);
@@ -58,11 +58,11 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_CLIENT_INFO)(NetworkClientSocket *cs
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_COMPANY_INFO)
{
- //
- // Packet: SERVER_COMPANY_INFO
- // Function: Sends info about the companies
- // Data:
- //
+ /*
+ * Packet: SERVER_COMPANY_INFO
+ * Function: Sends info about the companies
+ * Data:
+ */
/* Fetch the latest version of the stats */
NetworkCompanyStats company_stats[MAX_COMPANIES];
@@ -125,12 +125,12 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_COMPANY_INFO)
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_ERROR)(NetworkClientSocket *cs, NetworkErrorCode error)
{
- //
- // Packet: SERVER_ERROR
- // Function: The client made an error
- // Data:
- // uint8: ErrorID (see network_data.h, NetworkErrorCode)
- //
+ /*
+ * Packet: SERVER_ERROR
+ * Function: The client made an error
+ * Data:
+ * uint8: ErrorID (see network_data.h, NetworkErrorCode)
+ */
char str[100];
Packet *p = NetworkSend_Init(PACKET_SERVER_ERROR);
@@ -141,7 +141,7 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_ERROR)(NetworkClientSocket *cs, Netw
StringID strid = GetNetworkErrorMsg(error);
GetString(str, strid, lastof(str));
- // Only send when the current client was in game
+ /* Only send when the current client was in game */
if (cs->status > STATUS_AUTH) {
NetworkClientSocket *new_cs;
char client_name[NETWORK_CLIENT_NAME_LENGTH];
@@ -154,8 +154,8 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_ERROR)(NetworkClientSocket *cs, Netw
FOR_ALL_CLIENT_SOCKETS(new_cs) {
if (new_cs->status > STATUS_AUTH && new_cs != cs) {
- // Some errors we filter to a more general error. Clients don't have to know the real
- // reason a joining failed.
+ /* Some errors we filter to a more general error. Clients don't have to know the real
+ * reason a joining failed. */
if (error == NETWORK_ERROR_NOT_AUTHORIZED || error == NETWORK_ERROR_NOT_EXPECTED || error == NETWORK_ERROR_WRONG_REVISION)
error = NETWORK_ERROR_ILLEGAL_PACKET;
@@ -168,24 +168,24 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_ERROR)(NetworkClientSocket *cs, Netw
cs->has_quit = true;
- // Make sure the data get's there before we close the connection
+ /* Make sure the data get's there before we close the connection */
cs->Send_Packets();
- // The client made a mistake, so drop his connection now!
+ /* The client made a mistake, so drop his connection now! */
NetworkCloseClient(cs);
}
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_CHECK_NEWGRFS)(NetworkClientSocket *cs)
{
- //
- // Packet: PACKET_SERVER_CHECK_NEWGRFS
- // Function: Sends info about the used GRFs to the client
- // Data:
- // uint8: Amount of GRFs
- // And then for each GRF:
- // uint32: GRF ID
- // 16 * uint8: MD5 checksum of the GRF
- //
+ /*
+ * Packet: PACKET_SERVER_CHECK_NEWGRFS
+ * Function: Sends info about the used GRFs to the client
+ * Data:
+ * uint8: Amount of GRFs
+ * And then for each GRF:
+ * uint32: GRF ID
+ * 16 * uint8: MD5 checksum of the GRF
+ */
Packet *p = NetworkSend_Init(PACKET_SERVER_CHECK_NEWGRFS);
const GRFConfig *c;
@@ -205,12 +205,12 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_CHECK_NEWGRFS)(NetworkClientSocket *
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_NEED_PASSWORD)(NetworkClientSocket *cs, NetworkPasswordType type)
{
- //
- // Packet: SERVER_NEED_PASSWORD
- // Function: Indication to the client that the server needs a password
- // Data:
- // uint8: Type of password
- //
+ /*
+ * Packet: SERVER_NEED_PASSWORD
+ * Function: Indication to the client that the server needs a password
+ * Data:
+ * uint8: Type of password
+ */
/* Invalid packet when status is AUTH or higher */
if (cs->status >= STATUS_AUTH) return;
@@ -226,17 +226,17 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_NEED_PASSWORD)(NetworkClientSocket *
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_WELCOME)
{
- //
- // Packet: SERVER_WELCOME
- // Function: The client is joined and ready to receive his map
- // Data:
- // uint32: Own Client identifier
- //
+ /*
+ * Packet: SERVER_WELCOME
+ * Function: The client is joined and ready to receive his map
+ * Data:
+ * uint32: Own Client identifier
+ */
Packet *p;
NetworkClientSocket *new_cs;
- // Invalid packet when status is AUTH or higher
+ /* Invalid packet when status is AUTH or higher */
if (cs->status >= STATUS_AUTH) return;
cs->status = STATUS_AUTH;
@@ -248,29 +248,29 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_WELCOME)
p->Send_string(_settings_client.network.network_id);
cs->Send_Packet(p);
- // Transmit info about all the active clients
+ /* Transmit info about all the active clients */
FOR_ALL_CLIENT_SOCKETS(new_cs) {
if (new_cs != cs && new_cs->status > STATUS_AUTH)
SEND_COMMAND(PACKET_SERVER_CLIENT_INFO)(cs, new_cs->GetInfo());
}
- // Also send the info of the server
+ /* Also send the info of the server */
SEND_COMMAND(PACKET_SERVER_CLIENT_INFO)(cs, NetworkFindClientInfoFromClientID(CLIENT_ID_SERVER));
}
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_WAIT)
{
- //
- // Packet: PACKET_SERVER_WAIT
- // Function: The client can not receive the map at the moment because
- // someone else is already receiving the map
- // Data:
- // uint8: Clients awaiting map
- //
+ /*
+ * Packet: PACKET_SERVER_WAIT
+ * Function: The client can not receive the map at the moment because
+ * someone else is already receiving the map
+ * Data:
+ * uint8: Clients awaiting map
+ */
int waiting = 0;
NetworkClientSocket *new_cs;
Packet *p;
- // Count how many clients are waiting in the queue
+ /* Count how many clients are waiting in the queue */
FOR_ALL_CLIENT_SOCKETS(new_cs) {
if (new_cs->status == STATUS_MAP_WAIT) waiting++;
}
@@ -280,28 +280,28 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_WAIT)
cs->Send_Packet(p);
}
-// This sends the map to the client
+/* This sends the map to the client */
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_MAP)
{
- //
- // Packet: SERVER_MAP
- // Function: Sends the map to the client, or a part of it (it is splitted in
- // a lot of multiple packets)
- // Data:
- // uint8: packet-type (MAP_PACKET_START, MAP_PACKET_NORMAL and MAP_PACKET_END)
- // if MAP_PACKET_START:
- // uint32: The current FrameCounter
- // if MAP_PACKET_NORMAL:
- // piece of the map (till max-size of packet)
- // if MAP_PACKET_END:
- // nothing
- //
+ /*
+ * Packet: SERVER_MAP
+ * Function: Sends the map to the client, or a part of it (it is splitted in
+ * a lot of multiple packets)
+ * Data:
+ * uint8: packet-type (MAP_PACKET_START, MAP_PACKET_NORMAL and MAP_PACKET_END)
+ * if MAP_PACKET_START:
+ * uint32: The current FrameCounter
+ * if MAP_PACKET_NORMAL:
+ * piece of the map (till max-size of packet)
+ * if MAP_PACKET_END:
+ * nothing
+ */
static FILE *file_pointer;
static uint sent_packets; // How many packets we did send succecfully last time
if (cs->status < STATUS_AUTH) {
- // Illegal call, return error and ignore the packet
+ /* Illegal call, return error and ignore the packet */
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_AUTHORIZED);
return;
}
@@ -310,7 +310,7 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_MAP)
const char *filename = "network_server.tmp";
Packet *p;
- // Make a dump of the current game
+ /* Make a dump of the current game */
if (SaveOrLoad(filename, SL_SAVE, AUTOSAVE_DIR) != SL_OK) usererror("network savedump failed");
file_pointer = FioFOpenFile(filename, "rb", AUTOSAVE_DIR);
@@ -318,7 +318,7 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_MAP)
if (ftell(file_pointer) == 0) usererror("network savedump failed - zero sized savegame?");
- // Now send the _frame_counter and how many packets are coming
+ /* Now send the _frame_counter and how many packets are coming */
p = NetworkSend_Init(PACKET_SERVER_MAP);
p->Send_uint8 (MAP_PACKET_START);
p->Send_uint32(_frame_counter);
@@ -348,49 +348,49 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_MAP)
p->size += res;
cs->Send_Packet(p);
if (feof(file_pointer)) {
- // Done reading!
+ /* Done reading! */
Packet *p = NetworkSend_Init(PACKET_SERVER_MAP);
p->Send_uint8(MAP_PACKET_END);
cs->Send_Packet(p);
- // Set the status to DONE_MAP, no we will wait for the client
- // to send it is ready (maybe that happens like never ;))
+ /* Set the status to DONE_MAP, no we will wait for the client
+ * to send it is ready (maybe that happens like never ;)) */
cs->status = STATUS_DONE_MAP;
fclose(file_pointer);
{
NetworkClientSocket *new_cs;
bool new_map_client = false;
- // Check if there is a client waiting for receiving the map
- // and start sending him the map
+ /* Check if there is a client waiting for receiving the map
+ * and start sending him the map */
FOR_ALL_CLIENT_SOCKETS(new_cs) {
if (new_cs->status == STATUS_MAP_WAIT) {
- // Check if we already have a new client to send the map to
+ /* Check if we already have a new client to send the map to */
if (!new_map_client) {
- // If not, this client will get the map
+ /* If not, this client will get the map */
new_cs->status = STATUS_AUTH;
new_map_client = true;
SEND_COMMAND(PACKET_SERVER_MAP)(new_cs);
} else {
- // Else, send the other clients how many clients are in front of them
+ /* Else, send the other clients how many clients are in front of them */
SEND_COMMAND(PACKET_SERVER_WAIT)(new_cs);
}
}
}
}
- // There is no more data, so break the for
+ /* There is no more data, so break the for */
break;
}
}
- // Send all packets (forced) and check if we have send it all
+ /* Send all packets (forced) and check if we have send it all */
cs->Send_Packets();
if (cs->IsPacketQueueEmpty()) {
- // All are sent, increase the sent_packets
+ /* All are sent, increase the sent_packets */
sent_packets *= 2;
} else {
- // Not everything is sent, decrease the sent_packets
+ /* Not everything is sent, decrease the sent_packets */
if (sent_packets > 1) sent_packets /= 2;
}
}
@@ -398,14 +398,14 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_MAP)
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_JOIN)(NetworkClientSocket *cs, ClientID client_id)
{
- //
- // Packet: SERVER_JOIN
- // Function: A client is joined (all active clients receive this after a
- // PACKET_CLIENT_MAP_OK) Mostly what directly follows is a
- // PACKET_SERVER_CLIENT_INFO
- // Data:
- // uint32: Client-identifier
- //
+ /*
+ * Packet: SERVER_JOIN
+ * Function: A client is joined (all active clients receive this after a
+ * PACKET_CLIENT_MAP_OK) Mostly what directly follows is a
+ * PACKET_SERVER_CLIENT_INFO
+ * Data:
+ * uint32: Client-identifier
+ */
Packet *p = NetworkSend_Init(PACKET_SERVER_JOIN);
@@ -417,16 +417,16 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_JOIN)(NetworkClientSocket *cs, Clien
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_FRAME)
{
- //
- // Packet: SERVER_FRAME
- // Function: Sends the current frame-counter to the client
- // Data:
- // uint32: Frame Counter
- // uint32: Frame Counter Max (how far may the client walk before the server?)
- // [uint32: general-seed-1]
- // [uint32: general-seed-2]
- // (last two depends on compile-settings, and are not default settings)
- //
+ /*
+ * Packet: SERVER_FRAME
+ * Function: Sends the current frame-counter to the client
+ * Data:
+ * uint32: Frame Counter
+ * uint32: Frame Counter Max (how far may the client walk before the server?)
+ * [uint32: general-seed-1]
+ * [uint32: general-seed-2]
+ * (last two depends on compile-settings, and are not default settings)
+ */
Packet *p = NetworkSend_Init(PACKET_SERVER_FRAME);
p->Send_uint32(_frame_counter);
@@ -442,15 +442,15 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_FRAME)
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_SYNC)
{
- //
- // Packet: SERVER_SYNC
- // Function: Sends a sync-check to the client
- // Data:
- // uint32: Frame Counter
- // uint32: General-seed-1
- // [uint32: general-seed-2]
- // (last one depends on compile-settings, and are not default settings)
- //
+ /*
+ * Packet: SERVER_SYNC
+ * Function: Sends a sync-check to the client
+ * Data:
+ * uint32: Frame Counter
+ * uint32: General-seed-1
+ * [uint32: general-seed-2]
+ * (last one depends on compile-settings, and are not default settings)
+ */
Packet *p = NetworkSend_Init(PACKET_SERVER_SYNC);
p->Send_uint32(_frame_counter);
@@ -464,19 +464,19 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_SYNC)
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_COMMAND)(NetworkClientSocket *cs, const CommandPacket *cp)
{
- //
- // Packet: SERVER_COMMAND
- // Function: Sends a DoCommand to the client
- // Data:
- // uint8: CompanyID (0..MAX_COMPANIES-1)
- // uint32: CommandID (see command.h)
- // uint32: P1 (free variables used in DoCommand)
- // uint32: P2
- // uint32: Tile
- // string: text
- // uint8: CallBackID (see callback_table.c)
- // uint32: Frame of execution
- //
+ /*
+ * Packet: SERVER_COMMAND
+ * Function: Sends a DoCommand to the client
+ * Data:
+ * uint8: CompanyID (0..MAX_COMPANIES-1)
+ * uint32: CommandID (see command.h)
+ * uint32: P1 (free variables used in DoCommand)
+ * uint32: P2
+ * uint32: Tile
+ * string: text
+ * uint8: CallBackID (see callback_table.c)
+ * uint32: Frame of execution
+ */
Packet *p = NetworkSend_Init(PACKET_SERVER_COMMAND);
@@ -489,15 +489,15 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_COMMAND)(NetworkClientSocket *cs, co
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_CHAT)(NetworkClientSocket *cs, NetworkAction action, ClientID client_id, bool self_send, const char *msg, int64 data)
{
- //
- // Packet: SERVER_CHAT
- // Function: Sends a chat-packet to the client
- // Data:
- // uint8: ActionID (see network_data.h, NetworkAction)
- // uint32: Client-identifier
- // String: Message (max NETWORK_CHAT_LENGTH)
- // uint64: Arbitrary data
- //
+ /*
+ * Packet: SERVER_CHAT
+ * Function: Sends a chat-packet to the client
+ * Data:
+ * uint8: ActionID (see network_data.h, NetworkAction)
+ * uint32: Client-identifier
+ * String: Message (max NETWORK_CHAT_LENGTH)
+ * uint64: Arbitrary data
+ */
Packet *p = NetworkSend_Init(PACKET_SERVER_CHAT);
@@ -512,14 +512,14 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_CHAT)(NetworkClientSocket *cs, Netwo
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_ERROR_QUIT)(NetworkClientSocket *cs, ClientID client_id, NetworkErrorCode errorno)
{
- //
- // Packet: SERVER_ERROR_QUIT
- // Function: One of the clients made an error and is quiting the game
- // This packet informs the other clients of that.
- // Data:
- // uint32: Client-identifier
- // uint8: ErrorID (see network_data.h, NetworkErrorCode)
- //
+ /*
+ * Packet: SERVER_ERROR_QUIT
+ * Function: One of the clients made an error and is quiting the game
+ * This packet informs the other clients of that.
+ * Data:
+ * uint32: Client-identifier
+ * uint8: ErrorID (see network_data.h, NetworkErrorCode)
+ */
Packet *p = NetworkSend_Init(PACKET_SERVER_ERROR_QUIT);
@@ -531,13 +531,13 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_ERROR_QUIT)(NetworkClientSocket *cs,
DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_QUIT)(NetworkClientSocket *cs, ClientID client_id)
{
- //
- // Packet: SERVER_ERROR_QUIT
- // Function: A client left the game, and this packets informs the other clients
- // of that.
- // Data:
- // uint32: Client-identifier
- //
+ /*
+ * Packet: SERVER_ERROR_QUIT
+ * Function: A client left the game, and this packets informs the other clients
+ * of that.
+ * Data:
+ * uint32: Client-identifier
+ */
Packet *p = NetworkSend_Init(PACKET_SERVER_QUIT);
@@ -548,12 +548,12 @@ DEF_SERVER_SEND_COMMAND_PARAM(PACKET_SERVER_QUIT)(NetworkClientSocket *cs, Clien
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_SHUTDOWN)
{
- //
- // Packet: SERVER_SHUTDOWN
- // Function: Let the clients know that the server is closing
- // Data:
- // <none>
- //
+ /*
+ * Packet: SERVER_SHUTDOWN
+ * Function: Let the clients know that the server is closing
+ * Data:
+ * <none>
+ */
Packet *p = NetworkSend_Init(PACKET_SERVER_SHUTDOWN);
cs->Send_Packet(p);
@@ -561,12 +561,12 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_SHUTDOWN)
DEF_SERVER_SEND_COMMAND(PACKET_SERVER_NEWGAME)
{
- //
- // Packet: PACKET_SERVER_NEWGAME
- // Function: Let the clients know that the server is loading a new map
- // Data:
- // <none>
- //
+ /*
+ * Packet: PACKET_SERVER_NEWGAME
+ * Function: Let the clients know that the server is loading a new map
+ * Data:
+ * <none>
+ */
Packet *p = NetworkSend_Init(PACKET_SERVER_NEWGAME);
cs->Send_Packet(p);
@@ -607,10 +607,10 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_CONFIG_UPDATE)
cs->Send_Packet(p);
}
-// **********
-// Receiving functions
-// DEF_SERVER_RECEIVE_COMMAND has parameter: NetworkClientSocket *cs, Packet *p
-// **********
+/***********
+ * Receiving functions
+ * DEF_SERVER_RECEIVE_COMMAND has parameter: NetworkClientSocket *cs, Packet *p
+ ************/
DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMPANY_INFO)
{
@@ -656,9 +656,9 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
p->Recv_string(client_revision, sizeof(client_revision));
- // Check if the client has revision control enabled
+ /* Check if the client has revision control enabled */
if (!IsNetworkCompatibleVersion(client_revision)) {
- // Different revisions!!
+ /* Different revisions!! */
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_WRONG_REVISION);
return;
}
@@ -670,21 +670,21 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
if (cs->has_quit) return;
- // join another company does not affect these values
+ /* join another company does not affect these values */
switch (playas) {
- case COMPANY_NEW_COMPANY: /* New company */
+ case COMPANY_NEW_COMPANY: // New company
if (ActiveCompanyCount() >= _settings_client.network.max_companies) {
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_FULL);
return;
}
break;
- case COMPANY_SPECTATOR: /* Spectator */
+ case COMPANY_SPECTATOR: // Spectator
if (NetworkSpectatorCount() >= _settings_client.network.max_spectators) {
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_FULL);
return;
}
break;
- default: /* Join another company (companies 1-8 (index 0-7)) */
+ default: // Join another company (companies 1-8 (index 0-7))
if (!IsValidCompanyID(playas) || !IsHumanCompany(playas)) {
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_COMPANY_MISMATCH);
return;
@@ -692,11 +692,11 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
break;
}
- // We need a valid name.. make it Player
+ /* We need a valid name.. make it Player */
if (StrEmpty(name)) strecpy(name, "Player", lastof(name));
if (!NetworkFindName(name)) { // Change name if duplicate
- // We could not create a name for this client
+ /* We could not create a name for this client */
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NAME_IN_USE);
return;
}
@@ -728,9 +728,9 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_PASSWORD)
p->Recv_string(password, sizeof(password));
if (cs->status == STATUS_AUTHORIZING && type == NETWORK_GAME_PASSWORD) {
- // Check game-password
+ /* Check game-password */
if (strcmp(password, _settings_client.network.server_password) != 0) {
- // Password is invalid
+ /* Password is invalid */
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_WRONG_PASSWORD);
return;
}
@@ -742,14 +742,14 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_PASSWORD)
return;
}
- // Valid password, allow user
+ /* Valid password, allow user */
SEND_COMMAND(PACKET_SERVER_WELCOME)(cs);
return;
} else if (cs->status == STATUS_AUTHORIZING && type == NETWORK_COMPANY_PASSWORD) {
ci = cs->GetInfo();
if (strcmp(password, _network_company_states[ci->client_playas].password) != 0) {
- // Password is invalid
+ /* Password is invalid */
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_WRONG_PASSWORD);
return;
}
@@ -767,30 +767,30 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_GETMAP)
{
NetworkClientSocket *new_cs;
- // The client was never joined.. so this is impossible, right?
- // Ignore the packet, give the client a warning, and close his connection
+ /* The client was never joined.. so this is impossible, right?
+ * Ignore the packet, give the client a warning, and close his connection */
if (cs->status < STATUS_AUTH || cs->has_quit) {
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_AUTHORIZED);
return;
}
- // Check if someone else is receiving the map
+ /* Check if someone else is receiving the map */
FOR_ALL_CLIENT_SOCKETS(new_cs) {
if (new_cs->status == STATUS_MAP) {
- // Tell the new client to wait
+ /* Tell the new client to wait */
cs->status = STATUS_MAP_WAIT;
SEND_COMMAND(PACKET_SERVER_WAIT)(cs);
return;
}
}
- // We receive a request to upload the map.. give it to the client!
+ /* We receive a request to upload the map.. give it to the client! */
SEND_COMMAND(PACKET_SERVER_MAP)(cs);
}
DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_MAP_OK)
{
- // Client has the map, now start syncing
+ /* Client has the map, now start syncing */
if (cs->status == STATUS_DONE_MAP && !cs->has_quit) {
char client_name[NETWORK_CLIENT_NAME_LENGTH];
NetworkClientSocket *new_cs;
@@ -799,15 +799,15 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_MAP_OK)
NetworkTextMessage(NETWORK_ACTION_JOIN, CC_DEFAULT, false, client_name);
- // Mark the client as pre-active, and wait for an ACK
- // so we know he is done loading and in sync with us
+ /* Mark the client as pre-active, and wait for an ACK
+ * so we know he is done loading and in sync with us */
cs->status = STATUS_PRE_ACTIVE;
NetworkHandleCommandQueue(cs);
SEND_COMMAND(PACKET_SERVER_FRAME)(cs);
SEND_COMMAND(PACKET_SERVER_SYNC)(cs);
- // This is the frame the client receives
- // we need it later on to make sure the client is not too slow
+ /* This is the frame the client receives
+ * we need it later on to make sure the client is not too slow */
cs->last_frame = _frame_counter;
cs->last_frame_server = _frame_counter;
@@ -831,7 +831,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_MAP_OK)
/* quickly update the syncing client with company details */
SEND_COMMAND(PACKET_SERVER_COMPANY_UPDATE)(cs);
} else {
- // Wrong status for this packet, give a warning to client, and close connection
+ /* Wrong status for this packet, give a warning to client, and close connection */
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_EXPECTED);
}
}
@@ -844,8 +844,8 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)
{
NetworkClientSocket *new_cs;
- // The client was never joined.. so this is impossible, right?
- // Ignore the packet, give the client a warning, and close his connection
+ /* The client was never joined.. so this is impossible, right?
+ * Ignore the packet, give the client a warning, and close his connection */
if (cs->status < STATUS_DONE_MAP || cs->has_quit) {
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_EXPECTED);
return;
@@ -912,19 +912,19 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)
cp.p2 = cs->client_id;
}
- // The frame can be executed in the same frame as the next frame-packet
- // That frame just before that frame is saved in _frame_counter_max
+ /* The frame can be executed in the same frame as the next frame-packet
+ * That frame just before that frame is saved in _frame_counter_max */
cp.frame = _frame_counter_max + 1;
cp.next = NULL;
CommandCallback *callback = cp.callback;
- // Queue the command for the clients (are send at the end of the frame
- // if they can handle it ;))
+ /* Queue the command for the clients (are send at the end of the frame
+ * if they can handle it ;)) */
FOR_ALL_CLIENT_SOCKETS(new_cs) {
if (new_cs->status >= STATUS_MAP) {
- // Callbacks are only send back to the client who sent them in the
- // first place. This filters that out.
+ /* Callbacks are only send back to the client who sent them in the
+ * first place. This filters that out. */
cp.callback = (new_cs != cs) ? NULL : callback;
cp.my_cmd = (new_cs == cs);
NetworkAddCommandQueue(cp, new_cs);
@@ -938,14 +938,14 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)
DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_ERROR)
{
- // This packets means a client noticed an error and is reporting this
- // to us. Display the error and report it to the other clients
+ /* This packets means a client noticed an error and is reporting this
+ * to us. Display the error and report it to the other clients */
NetworkClientSocket *new_cs;
char str[100];
char client_name[NETWORK_CLIENT_NAME_LENGTH];
NetworkErrorCode errorno = (NetworkErrorCode)p->Recv_uint8();
- // The client was never joined.. thank the client for the packet, but ignore it
+ /* The client was never joined.. thank the client for the packet, but ignore it */
if (cs->status < STATUS_DONE_MAP || cs->has_quit) {
cs->has_quit = true;
return;
@@ -971,12 +971,12 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_ERROR)
DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_QUIT)
{
- // The client wants to leave. Display this and report it to the other
- // clients.
+ /* The client wants to leave. Display this and report it to the other
+ * clients. */
NetworkClientSocket *new_cs;
char client_name[NETWORK_CLIENT_NAME_LENGTH];
- // The client was never joined.. thank the client for the packet, but ignore it
+ /* The client was never joined.. thank the client for the packet, but ignore it */
if (cs->status < STATUS_DONE_MAP || cs->has_quit) {
cs->has_quit = true;
return;
@@ -1024,9 +1024,9 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_ACK)
IConsoleCmdExec("exec scripts/on_server_connect.scr 0");
}
- // The client received the frame, make note of it
+ /* The client received the frame, make note of it */
cs->last_frame = frame;
- // With those 2 values we can calculate the lag realtime
+ /* With those 2 values we can calculate the lag realtime */
cs->last_frame_server = _frame_counter;
}
@@ -1055,7 +1055,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
}
}
- // Display the message locally (so you know you have sent it)
+ /* Display the message locally (so you know you have sent it) */
if (from_id != (ClientID)dest) {
if (from_id == CLIENT_ID_SERVER) {
ci = NetworkFindClientInfoFromClientID(from_id);
@@ -1074,8 +1074,8 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
break;
case DESTTYPE_TEAM: {
bool show_local = true; // If this is false, the message is already displayed
- // on the client who did sent it.
- /* Find all clients that belong to this company */
+ /* on the client who did sent it.
+ * Find all clients that belong to this company */
ci_to = NULL;
FOR_ALL_CLIENT_SOCKETS(cs) {
ci = cs->GetInfo();
@@ -1097,7 +1097,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
/* There is no such client */
if (ci_to == NULL) break;
- // Display the message locally (so you know you have sent it)
+ /* Display the message locally (so you know you have sent it) */
if (ci != NULL && show_local) {
if (from_id == CLIENT_ID_SERVER) {
char name[NETWORK_NAME_LENGTH];
@@ -1199,7 +1199,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_SET_NAME)
if (cs->has_quit) return;
if (ci != NULL) {
- // Display change
+ /* Display change */
if (NetworkFindName(client_name)) {
NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, client_name);
strecpy(ci->client_name, client_name, lastof(ci->client_name));
@@ -1255,56 +1255,56 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_MOVE)
NetworkServerDoMove(cs->client_id, company_id);
}
-// The layout for the receive-functions by the server
+/* The layout for the receive-functions by the server */
typedef void NetworkServerPacket(NetworkClientSocket *cs, Packet *p);
-// This array matches PacketType. At an incoming
-// packet it is matches against this array
-// and that way the right function to handle that
-// packet is found.
+/* This array matches PacketType. At an incoming
+ * packet it is matches against this array
+ * and that way the right function to handle that
+ * packet is found. */
static NetworkServerPacket * const _network_server_packet[] = {
- NULL, /*PACKET_SERVER_FULL,*/
- NULL, /*PACKET_SERVER_BANNED,*/
+ NULL, // PACKET_SERVER_FULL,
+ NULL, // PACKET_SERVER_BANNED,
RECEIVE_COMMAND(PACKET_CLIENT_JOIN),
- NULL, /*PACKET_SERVER_ERROR,*/
+ NULL, // PACKET_SERVER_ERROR,
RECEIVE_COMMAND(PACKET_CLIENT_COMPANY_INFO),
- NULL, /*PACKET_SERVER_COMPANY_INFO,*/
- NULL, /*PACKET_SERVER_CLIENT_INFO,*/
- NULL, /*PACKET_SERVER_NEED_PASSWORD,*/
+ NULL, // PACKET_SERVER_COMPANY_INFO,
+ NULL, // PACKET_SERVER_CLIENT_INFO,
+ NULL, // PACKET_SERVER_NEED_PASSWORD,
RECEIVE_COMMAND(PACKET_CLIENT_PASSWORD),
- NULL, /*PACKET_SERVER_WELCOME,*/
+ NULL, // PACKET_SERVER_WELCOME,
RECEIVE_COMMAND(PACKET_CLIENT_GETMAP),
- NULL, /*PACKET_SERVER_WAIT,*/
- NULL, /*PACKET_SERVER_MAP,*/
+ NULL, // PACKET_SERVER_WAIT,
+ NULL, // PACKET_SERVER_MAP,
RECEIVE_COMMAND(PACKET_CLIENT_MAP_OK),
- NULL, /*PACKET_SERVER_JOIN,*/
- NULL, /*PACKET_SERVER_FRAME,*/
- NULL, /*PACKET_SERVER_SYNC,*/
+ NULL, // PACKET_SERVER_JOIN,
+ NULL, // PACKET_SERVER_FRAME,
+ NULL, // PACKET_SERVER_SYNC,
RECEIVE_COMMAND(PACKET_CLIENT_ACK),
RECEIVE_COMMAND(PACKET_CLIENT_COMMAND),
- NULL, /*PACKET_SERVER_COMMAND,*/
+ NULL, // PACKET_SERVER_COMMAND,
RECEIVE_COMMAND(PACKET_CLIENT_CHAT),
- NULL, /*PACKET_SERVER_CHAT,*/
+ NULL, // PACKET_SERVER_CHAT,
RECEIVE_COMMAND(PACKET_CLIENT_SET_PASSWORD),
RECEIVE_COMMAND(PACKET_CLIENT_SET_NAME),
RECEIVE_COMMAND(PACKET_CLIENT_QUIT),
RECEIVE_COMMAND(PACKET_CLIENT_ERROR),
- NULL, /*PACKET_SERVER_QUIT,*/
- NULL, /*PACKET_SERVER_ERROR_QUIT,*/
- NULL, /*PACKET_SERVER_SHUTDOWN,*/
- NULL, /*PACKET_SERVER_NEWGAME,*/
- NULL, /*PACKET_SERVER_RCON,*/
+ NULL, // PACKET_SERVER_QUIT,
+ NULL, // PACKET_SERVER_ERROR_QUIT,
+ NULL, // PACKET_SERVER_SHUTDOWN,
+ NULL, // PACKET_SERVER_NEWGAME,
+ NULL, // PACKET_SERVER_RCON,
RECEIVE_COMMAND(PACKET_CLIENT_RCON),
- NULL, /*PACKET_CLIENT_CHECK_NEWGRFS,*/
+ NULL, // PACKET_CLIENT_CHECK_NEWGRFS,
RECEIVE_COMMAND(PACKET_CLIENT_NEWGRFS_CHECKED),
- NULL, /*PACKET_SERVER_MOVE,*/
+ NULL, // PACKET_SERVER_MOVE,
RECEIVE_COMMAND(PACKET_CLIENT_MOVE),
- NULL, /*PACKET_SERVER_COMPANY_UPDATE,*/
- NULL, /*PACKET_SERVER_CONFIG_UPDATE,*/
+ NULL, // PACKET_SERVER_COMPANY_UPDATE,
+ NULL, // PACKET_SERVER_CONFIG_UPDATE,
};
-// If this fails, check the array above with network_data.h
+/* If this fails, check the array above with network_data.h */
assert_compile(lengthof(_network_server_packet) == PACKET_END);
void NetworkSocketHandler::Send_CompanyInformation(Packet *p, const Company *c, const NetworkCompanyStats *stats)
@@ -1373,7 +1373,7 @@ void NetworkPopulateCompanyStats(NetworkCompanyStats *stats)
stats[v->owner].num_vehicle[type]++;
}
- // Go through all stations and count the types of stations
+ /* Go through all stations and count the types of stations */
FOR_ALL_STATIONS(s) {
if (IsValidCompanyID(s->owner)) {
NetworkCompanyStats *npi = &stats[s->owner];
@@ -1387,7 +1387,7 @@ void NetworkPopulateCompanyStats(NetworkCompanyStats *stats)
}
}
-// Send a packet to all clients with updated info about this client_id
+/* Send a packet to all clients with updated info about this client_id */
void NetworkUpdateClientInfo(ClientID client_id)
{
NetworkClientSocket *cs;
@@ -1465,8 +1465,8 @@ static void NetworkAutoCleanCompanies()
}
}
-// This function changes new_name to a name that is unique (by adding #1 ...)
-// and it returns true if that succeeded.
+/* This function changes new_name to a name that is unique (by adding #1 ...)
+ * and it returns true if that succeeded. */
bool NetworkFindName(char new_name[NETWORK_CLIENT_NAME_LENGTH])
{
bool found_name = false;
@@ -1530,7 +1530,7 @@ bool NetworkServerChangeClientName(ClientID client_id, const char *new_name)
return true;
}
-// Reads a packet from the stream
+/* Reads a packet from the stream */
bool NetworkServer_ReadPackets(NetworkClientSocket *cs)
{
Packet *p;
@@ -1548,7 +1548,7 @@ bool NetworkServer_ReadPackets(NetworkClientSocket *cs)
return true;
}
-// Handle the local command-queue
+/* Handle the local command-queue */
static void NetworkHandleCommandQueue(NetworkClientSocket *cs)
{
CommandPacket *cp;
@@ -1561,7 +1561,7 @@ static void NetworkHandleCommandQueue(NetworkClientSocket *cs)
}
}
-// This is called every tick if this is a _network_server
+/* This is called every tick if this is a _network_server */
void NetworkServer_Tick(bool send_frame)
{
NetworkClientSocket *cs;
@@ -1576,23 +1576,23 @@ void NetworkServer_Tick(bool send_frame)
}
#endif
- // Now we are done with the frame, inform the clients that they can
- // do their frame!
+ /* Now we are done with the frame, inform the clients that they can
+ * do their frame! */
FOR_ALL_CLIENT_SOCKETS(cs) {
- // Check if the speed of the client is what we can expect from a client
+ /* Check if the speed of the client is what we can expect from a client */
if (cs->status == STATUS_ACTIVE) {
- // 1 lag-point per day
+ /* 1 lag-point per day */
int lag = NetworkCalculateLag(cs) / DAY_TICKS;
if (lag > 0) {
if (lag > 3) {
- // Client did still not report in after 4 game-day, drop him
- // (that is, the 3 of above, + 1 before any lag is counted)
+ /* Client did still not report in after 4 game-day, drop him
+ * (that is, the 3 of above, + 1 before any lag is counted) */
IConsolePrintF(CC_ERROR,"Client #%d is dropped because the client did not respond for more than 4 game-days", cs->client_id);
NetworkCloseClient(cs);
continue;
}
- // Report once per time we detect the lag
+ /* Report once per time we detect the lag */
if (cs->lag_test == 0) {
IConsolePrintF(CC_WARNING,"[%d] Client #%d is slow, try increasing *net_frame_freq to a higher value!", _frame_counter, cs->client_id);
cs->lag_test = 1;
@@ -1615,14 +1615,14 @@ void NetworkServer_Tick(bool send_frame)
}
if (cs->status >= STATUS_PRE_ACTIVE) {
- // Check if we can send command, and if we have anything in the queue
+ /* Check if we can send command, and if we have anything in the queue */
NetworkHandleCommandQueue(cs);
- // Send an updated _frame_counter_max to the client
+ /* Send an updated _frame_counter_max to the client */
if (send_frame) SEND_COMMAND(PACKET_SERVER_FRAME)(cs);
#ifndef ENABLE_NETWORK_SYNC_EVERY_FRAME
- // Send a sync-check packet
+ /* Send a sync-check packet */
if (send_sync) SEND_COMMAND(PACKET_SERVER_SYNC)(cs);
#endif
}
diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp
index 00c5410db..6f533937e 100644
--- a/src/network/network_udp.cpp
+++ b/src/network/network_udp.cpp
@@ -69,7 +69,7 @@ public:
DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_FIND_SERVER)
{
- // Just a fail-safe.. should never happen
+ /* Just a fail-safe.. should never happen */
if (!_network_udp_server) {
return;
}
@@ -101,7 +101,7 @@ DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_FIND_SERVER)
Packet packet(PACKET_UDP_SERVER_RESPONSE);
this->Send_NetworkGameInfo(&packet, &ngi);
- // Let the client know that we are here
+ /* Let the client know that we are here */
this->SendPacket(&packet, client_addr);
DEBUG(net, 2, "[udp] queried from '%s'", inet_ntoa(client_addr->sin_addr));
@@ -109,7 +109,7 @@ DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_FIND_SERVER)
DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_DETAIL_INFO)
{
- // Just a fail-safe.. should never happen
+ /* Just a fail-safe.. should never happen */
if (!_network_udp_server) return;
Packet packet(PACKET_UDP_SERVER_DETAIL_INFO);
@@ -214,12 +214,12 @@ DEF_UDP_RECEIVE_COMMAND(Client, PACKET_UDP_SERVER_RESPONSE)
{
NetworkGameList *item;
- // Just a fail-safe.. should never happen
+ /* Just a fail-safe.. should never happen */
if (_network_udp_server) return;
DEBUG(net, 4, "[udp] server response from %s:%d", inet_ntoa(client_addr->sin_addr), ntohs(client_addr->sin_port));
- // Find next item
+ /* Find next item */
item = NetworkGameListAddItem(inet_addr(inet_ntoa(client_addr->sin_addr)), ntohs(client_addr->sin_port));
this->Recv_NetworkGameInfo(p, &item->info);
@@ -347,7 +347,7 @@ void ClientNetworkUDPSocketHandler::HandleIncomingNetworkGameInfoGRFConfig(GRFCo
SetBit(config->flags, GCF_COPY);
}
-// Close UDP connection
+/* Close UDP connection */
void NetworkUDPCloseAll()
{
DEBUG(net, 1, "[udp] closed listeners");
@@ -362,7 +362,7 @@ void NetworkUDPCloseAll()
_network_udp_broadcast = 0;
}
-// Broadcast to all ips
+/* Broadcast to all ips */
static void NetworkUDPBroadCast(NetworkUDPSocketHandler *socket)
{
uint i;
@@ -382,7 +382,7 @@ static void NetworkUDPBroadCast(NetworkUDPSocketHandler *socket)
}
-// Request the the server-list from the master server
+/* Request the the server-list from the master server */
void NetworkUDPQueryMasterServer()
{
struct sockaddr_in out_addr;
@@ -397,7 +397,7 @@ void NetworkUDPQueryMasterServer()
out_addr.sin_port = htons(NETWORK_MASTER_SERVER_PORT);
out_addr.sin_addr.s_addr = NetworkResolveHost(NETWORK_MASTER_SERVER_HOST);
- // packet only contains protocol version
+ /* packet only contains protocol version */
p.Send_uint8(NETWORK_MASTER_SERVER_VERSION);
_udp_client_socket->SendPacket(&p, &out_addr);
@@ -405,13 +405,13 @@ void NetworkUDPQueryMasterServer()
DEBUG(net, 2, "[udp] master server queried at %s:%d", inet_ntoa(out_addr.sin_addr), ntohs(out_addr.sin_port));
}
-// Find all servers
+/* Find all servers */
void NetworkUDPSearchGame()
{
- // We are still searching..
+ /* We are still searching.. */
if (_network_udp_broadcast > 0) return;
- // No UDP-socket yet..
+ /* No UDP-socket yet.. */
if (!_udp_client_socket->IsConnected()) {
if (!_udp_client_socket->Listen(0, 0, true)) return;
}
@@ -465,7 +465,7 @@ void NetworkUDPQueryServerThread(void *pntr)
void NetworkUDPQueryServer(NetworkAddress address, bool manually)
{
- // No UDP-socket yet..
+ /* No UDP-socket yet.. */
if (!_udp_client_socket->IsConnected()) {
if (!_udp_client_socket->Listen(0, 0, true)) return;
}