From 947669f063f3df9fc93a4afb2d7c9e6d3d13813a Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Sat, 29 Jan 2011 15:34:18 +0100 Subject: added documentation --- src/game.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/game.c') diff --git a/src/game.c b/src/game.c index 5cb947d..f714567 100644 --- a/src/game.c +++ b/src/game.c @@ -17,6 +17,11 @@ #include "game_states.h" #include "main_stack.h" +/** + * Game loop for clients. + * Runs from game start to its end + * @param[in] sock Socket with connection to server + */ static void main_loop_client(int sock) { bool running = true; @@ -56,6 +61,11 @@ static void main_loop_client(int sock) } } +/** + * Game loop for server. + * Runs from game start to its end + * @param[in] client_socks Sockets with connection to connected clients + */ static void main_loop_server(socket_list_t* client_socks) { bool running = true; @@ -93,6 +103,14 @@ static void main_loop_server(socket_list_t* client_socks) } } +/** + * Prepares the start of a game. Clients connect to server and in servermode a server + * is started which accepts connections + * @param[in] servermode True if a server should be started to where the local client will connect + * @param[in] addr Hostname/address where a client should try to connect (if NULL, default is "localhost"); in servermode address to which server will bind + * @param[in] port Port to connect to / listen on + * @param[in] num_players Only required on server; number of connections that are accepted before game is starting + */ void start_game(const bool servermode, const char* addr, const char* port, const uint8_t num_players) { assert(port != NULL); // addr can be NULL for server -> listen on every address -- cgit v1.2.3