Mercurial > hg > openttd
changeset 5864:c07f3d0a6cc3 draft
(svn r8445) -Cleanup: remove some @params from comments as the parameters did not exist anymore and add comments to several variables/functions.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sun, 28 Jan 2007 20:47:25 +0000 |
parents | 7e473060a6f0 |
children | a339ec477b6b |
files | src/network/core/config.h src/network/core/core.cpp src/network/core/core.h src/network/core/packet.cpp src/network/core/tcp.cpp src/network/core/tcp.h src/network/core/udp.cpp src/network/core/udp.h |
diffstat | 8 files changed, 43 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- 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 */
--- 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 @@ /** * Initializes the network core (as that is needed for some platforms + * @return true if the core has been initialized, false otherwise */ bool NetworkCoreInitialize(void) {
--- 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 @@ 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 */
--- 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 @@ /** * 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) {
--- 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 @@ * 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 */
--- a/src/network/core/tcp.h +++ b/src/network/core/tcp.h @@ -55,18 +55,20 @@ 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 @@ 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();
--- 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 @@ /** * Close the given UDP socket - * @param udp the socket to close */ void NetworkUDPSocketHandler::Close() { @@ -87,7 +85,6 @@ /** * 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 @@ /** * Receive a packet at UDP level - * @param udp the socket to receive the packet on */ void NetworkUDPSocketHandler::ReceivePackets() { @@ -305,7 +301,10 @@ } } -/* 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 @@ } } -/* +/** * 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) { \
--- a/src/network/core/udp.h +++ b/src/network/core/udp.h @@ -120,8 +120,9 @@ * 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);