From 49a31a58e1b77ed0d88c0271247d4f707cf8b641 Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Tue, 25 Jan 2011 14:36:47 +0100 Subject: implement part of state_client_play_cards(); added new message type: hello reply from server which notifies clients of their player-ids --- src/game.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/game.c') diff --git a/src/game.c b/src/game.c index 6addee3..e2d8f88 100644 --- a/src/game.c +++ b/src/game.c @@ -110,10 +110,11 @@ void start_game(const bool servermode, const char* addr, const char* port) for(int i = 0; i < num_players; i++) { - net_recv(client_socks.sockets[i], msg_type_hello); - // assign ids (starting with 1; 0 is invalid) + net_recv(client_socks.sockets[i], msg_type_hello_c); + // assign ids (starting with 1; 0 is invalid) and notify clients of their ids client_socks.player_ids[i] = i+1; data->player_list.players[i].player_id = i+1; + net_send(client_socks.sockets[i], msg_type_hello_s, &data->player_list.players[i]); printf("Player connected: %s\n", data->player_list.players[i].player_name); } @@ -133,7 +134,8 @@ void start_game(const bool servermode, const char* addr, const char* port) data_store_t *data = data_store(); strncpy(data->nickname, "nickname", 10); - net_send(sock, msg_type_hello, NULL); + net_send(sock, msg_type_hello_c, NULL); + net_recv(sock, msg_type_hello_s); net_recv(sock, msg_type_start_game); ui_init(); -- cgit v1.2.3