From c88a524298aa46157638a74416e8c6e968772758 Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Thu, 20 Jan 2011 18:32:39 +0100 Subject: implemented functions for notifying server of selected tablestack and for broadcasting the selection results to all clients --- src/net_server.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/net_server.c') diff --git a/src/net_server.c b/src/net_server.c index 0cba08c..731e232 100644 --- a/src/net_server.c +++ b/src/net_server.c @@ -158,6 +158,26 @@ void server_start_game(int* clients, const uint8_t clientcount, const player_lis free(buf); } +/** + * Server side function; broadcast a selected table stack to all clients + * @param[in] clients Array of sockets with connections to clients + * @param[in] clientcount Number of sockets/clients + * @param[in] stackindex Selected stack to broadcast + */ +void server_send_selected_stack(int* clients, const uint8_t clientcount, const uint8_t stackindex) +{ + assert(clients != NULL); + assert(stackindex <= NUM_TABLE_STACKS); + + uint8_t buf[3]; + buf[NET_MSG_OFFSET_TYPE] = msg_type_selected_stack_s; + buf[NET_MSG_OFFSET_PAYLOAD_LENGTH] = 1; + buf[NET_MSG_OFFSET_PAYLOAD] = stackindex; + + for(int i=0; i