diff options
Diffstat (limited to 'src/game.c')
| -rw-r--r-- | src/game.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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 |
