summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-01-28 20:47:25 +0000
committerrubidium <rubidium@openttd.org>2007-01-28 20:47:25 +0000
commitf72dde5236afd8d9a2e29ae1750e8933666b711f (patch)
treef0a56923473a03a88c71f37b852a587ba3c56fa7 /src/network
parent2e984e04775e97ce07698c5f45ed868cb1727ead (diff)
downloadopenttd-f72dde5236afd8d9a2e29ae1750e8933666b711f.tar.xz
(svn r8445) -Cleanup: remove some @params from comments as the parameters did not exist anymore and add comments to several variables/functions.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/core/config.h4
-rw-r--r--src/network/core/core.cpp5
-rw-r--r--src/network/core/core.h8
-rw-r--r--src/network/core/packet.cpp4
-rw-r--r--src/network/core/tcp.cpp3
-rw-r--r--src/network/core/tcp.h24
-rw-r--r--src/network/core/udp.cpp15
-rw-r--r--src/network/core/udp.h3
8 files changed, 43 insertions, 23 deletions
diff --git a/src/network/core/config.h b/src/network/core/config.h
index 71f3983a9..63b54f7ce 100644
--- a/src/network/core/config.h
+++ b/src/network/core/config.h
@@ -5,6 +5,10 @@
#ifdef ENABLE_NETWORK
+/**
+ * @file config.h Configuration options of the network stuff
+ */
+
/** DNS hostname of the masterserver */
#define NETWORK_MASTER_SERVER_HOST "master.openttd.org"
/** Message sent to the masterserver to 'identify' this client as OpenTTD */
diff --git a/src/network/core/core.cpp b/src/network/core/core.cpp
index ca953e5f0..259ccf6c8 100644
--- a/src/network/core/core.cpp
+++ b/src/network/core/core.cpp
@@ -6,6 +6,10 @@
#include "../../debug.h"
#include "os_abstraction.h"
+/**
+ * @file core.cpp Functions used to initialize/shut down the core network
+ */
+
#ifdef __MORPHOS__
/* the library base is required here */
struct Library *SocketBase = NULL;
@@ -13,6 +17,7 @@ struct Library *SocketBase = NULL;
/**
* Initializes the network core (as that is needed for some platforms
+ * @return true if the core has been initialized, false otherwise
*/
bool NetworkCoreInitialize(void)
{
diff --git a/src/network/core/core.h b/src/network/core/core.h
index f88fd0116..a4cef3b5e 100644
--- a/src/network/core/core.h
+++ b/src/network/core/core.h
@@ -7,9 +7,14 @@
#include "os_abstraction.h"
+/**
+ * @file core.h Base for all network types (UDP and TCP)
+ */
+
bool NetworkCoreInitialize(void);
void NetworkCoreShutdown(void);
+/** Status of a network client; reasons why a client has quit */
typedef enum {
NETWORK_RECV_STATUS_OKAY, ///< Everything is okay
NETWORK_RECV_STATUS_DESYNC, ///< A desync did occur
@@ -32,7 +37,10 @@ public:
bool has_quit; ///< Whether the current client has quit/send a bad packet
SOCKET sock; ///< The socket currently connected to
public:
+ /** Create a new unbound socket */
NetworkSocketHandler() { this->sock = INVALID_SOCKET; this->has_quit = false; }
+
+ /** Close the socket when distructing the socket handler */
virtual ~NetworkSocketHandler() { this->Close(); }
/** Really close the socket */
diff --git a/src/network/core/packet.cpp b/src/network/core/packet.cpp
index fe10af48f..a1f50e15e 100644
--- a/src/network/core/packet.cpp
+++ b/src/network/core/packet.cpp
@@ -10,7 +10,7 @@
#include "packet.h"
/**
- * @file packet.h Basic functions to create, fill and read packets.
+ * @file packet.cpp Basic functions to create, fill and read packets.
*/
@@ -94,6 +94,8 @@ void NetworkSend_uint64(Packet *packet, uint64 data)
/**
* Sends a string over the network. It sends out
* the string + '\0'. No size-byte or something.
+ * @param packet packet to send the string in
+ * @param data the string to send
*/
void NetworkSend_string(Packet *packet, const char* data)
{
diff --git a/src/network/core/tcp.cpp b/src/network/core/tcp.cpp
index 54271de57..8a7da433d 100644
--- a/src/network/core/tcp.cpp
+++ b/src/network/core/tcp.cpp
@@ -15,7 +15,7 @@
#include "../../helpers.hpp"
/**
- * @file tcp.c Basic functions to receive and send TCP packets.
+ * @file tcp.cpp Basic functions to receive and send TCP packets.
*/
/** Very ugly temporary hack !!! */
@@ -43,7 +43,6 @@ void NetworkTCPSocketHandler::Initialize()
* A socket can make errors. When that happens this handles what to do.
* For clients: close connection and drop back to main-menu
* For servers: close connection and that is it
- * @param cs the client to close the connection of
* @return the new status
* TODO: needs to be splitted when using client and server socket packets
*/
diff --git a/src/network/core/tcp.h b/src/network/core/tcp.h
index c15f851aa..74e2880e7 100644
--- a/src/network/core/tcp.h
+++ b/src/network/core/tcp.h
@@ -55,18 +55,20 @@ enum {
PACKET_END ///< Must ALWAYS be on the end of this list!! (period)
};
+/** Packet that wraps a command */
typedef struct CommandPacket {
- struct CommandPacket *next;
+ struct CommandPacket *next; ///< the next command packet (if in queue)
PlayerByte player; ///< player that is executing the command
uint32 cmd; ///< command being executed
uint32 p1; ///< parameter p1
uint32 p2; ///< parameter p2
TileIndex tile; ///< tile command being executed on
- char text[80];
+ char text[80]; ///< possible text sent for name changes etc
uint32 frame; ///< the frame in which this packet is executed
byte callback; ///< any callback function executed upon successful completion of the command
} CommandPacket;
+/** Status of a client */
typedef enum {
STATUS_INACTIVE, ///< The client is not connected nor active
STATUS_AUTH, ///< The client is authorized
@@ -81,18 +83,18 @@ typedef enum {
class NetworkTCPSocketHandler : public NetworkSocketHandler {
/* TODO: rewrite into a proper class */
public:
- uint16 index;
- uint32 last_frame;
- uint32 last_frame_server;
- byte lag_test; // This byte is used for lag-testing the client
+ uint16 index; ///< Client index
+ uint32 last_frame; ///< Last frame we have executed
+ uint32 last_frame_server; ///< Last frame the server has executed
+ byte lag_test; ///< Byte used for lag-testing the client
- ClientStatus status;
- bool writable; // is client ready to write to?
+ ClientStatus status; ///< Status of this client
+ bool writable; ///< Can we write to this socket?
- Packet *packet_queue; // Packets that are awaiting delivery
- Packet *packet_recv; // Partially received packet
+ Packet *packet_queue; ///< Packets that are awaiting delivery
+ Packet *packet_recv; ///< Partially received packet
- CommandPacket *command_queue; // The command-queue awaiting delivery
+ CommandPacket *command_queue; ///< The command-queue awaiting delivery
NetworkRecvStatus CloseConnection();
void Initialize();
diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp
index f20f98ba9..e6eedffc7 100644
--- a/src/network/core/udp.cpp
+++ b/src/network/core/udp.cpp
@@ -10,12 +10,11 @@
#include "udp.h"
/**
- * @file udp.c Basic functions to receive and send UDP packets.
+ * @file core/udp.cpp Basic functions to receive and send UDP packets.
*/
/**
* Start listening on the given host and port.
- * @param udp the place where the (references to the) UDP are stored
* @param host the host (ip) to listen on
* @param port the port to listen on
* @param broadcast whether to allow broadcast sending/receiving
@@ -69,7 +68,6 @@ bool NetworkUDPSocketHandler::Listen(const uint32 host, const uint16 port, const
/**
* Close the given UDP socket
- * @param udp the socket to close
*/
void NetworkUDPSocketHandler::Close()
{
@@ -87,7 +85,6 @@ NetworkRecvStatus NetworkUDPSocketHandler::CloseConnection()
/**
* Send a packet over UDP
- * @param udp the socket to send over
* @param p the packet to send
* @param recv the receiver (target) of the packet
*/
@@ -106,7 +103,6 @@ void NetworkUDPSocketHandler::SendPacket(Packet *p, const struct sockaddr_in *re
/**
* Receive a packet at UDP level
- * @param udp the socket to receive the packet on
*/
void NetworkUDPSocketHandler::ReceivePackets()
{
@@ -305,7 +301,10 @@ void NetworkUDPSocketHandler::Recv_NetworkGameInfo(Packet *p, NetworkGameInfo *i
}
}
-/* Defines a simple (switch) case for each network packet */
+/**
+ * Defines a simple (switch) case for each network packet
+ * @param type the packet type to create the case for
+ */
#define UDP_COMMAND(type) case type: this->NetworkPacketReceive_ ## type ## _command(p, client_addr); break;
/**
@@ -345,12 +344,12 @@ void NetworkUDPSocketHandler::HandleUDPPacket(Packet *p, const struct sockaddr_i
}
}
-/*
+/**
* Create stub implementations for all receive commands that only
* show a warning that the given command is not available for the
* socket where the packet came from.
+ * @param type the packet type to create the stub for
*/
-
#define DEFINE_UNAVAILABLE_UDP_RECEIVE_COMMAND(type) \
void NetworkUDPSocketHandler::NetworkPacketReceive_## type ##_command(\
Packet *p, const struct sockaddr_in *client_addr) { \
diff --git a/src/network/core/udp.h b/src/network/core/udp.h
index 1d09675ef..e2ac876a9 100644
--- a/src/network/core/udp.h
+++ b/src/network/core/udp.h
@@ -120,8 +120,9 @@ protected:
* the grfconfig list of the NetworkGameInfo.
* @param config the GRF to handle
*/
- virtual void HandleIncomingNetworkGameInfoGRFConfig(GRFConfig *config) { NOT_REACHED(); }
+ virtual void HandleIncomingNetworkGameInfoGRFConfig(GRFConfig *config) = 0;
public:
+ /** On destructing of this class, the socket needs to be closed */
virtual ~NetworkUDPSocketHandler() { this->Close(); }
bool Listen(uint32 host, uint16 port, bool broadcast);