(svn r8445) -Cleanup: remove some @params from comments as the parameters did not exist anymore and add comments to several variables/functions.

This commit is contained in:
rubidium 2007-01-28 20:47:25 +00:00
parent 2e984e0477
commit f72dde5236
8 changed files with 43 additions and 23 deletions

View File

@ -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 */

View File

@ -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)
{

View File

@ -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 */

View File

@ -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)
{

View File

@ -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
*/

View File

@ -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();

View File

@ -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) { \

View File

@ -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);