diff options
| author | Mario Kilies <MarioKilies@GMX.net> | 2011-01-16 02:45:16 +0100 |
|---|---|---|
| committer | Mario Kilies <MarioKilies@GMX.net> | 2011-01-16 02:45:16 +0100 |
| commit | 493b581dfa5a06134f524fe026a2fde5c4a83af5 (patch) | |
| tree | df5175cebe34a0850e615ff505148f5b53e001d6 /src/net_client.c | |
| parent | 4ed53bf1c06324e0bdca274090ec49e56848f00d (diff) | |
Renamed receive buffer offset macros. Changed argument data types of client_recv and server_recv.
Diffstat (limited to 'src/net_client.c')
| -rw-r--r-- | src/net_client.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/net_client.c b/src/net_client.c index 9aff39f..5e23e7a 100644 --- a/src/net_client.c +++ b/src/net_client.c @@ -26,9 +26,9 @@ void client_hello(int sock, const char* username) exit(EXIT_FAILURE); } - buf[INDEX_TYPE] = msg_type_hello; - buf[INDEX_LEN] = namelen+2; - memcpy(buf+INDEX_PAYLOAD, username, namelen); + buf[NET_MSG_OFFSET_TYPE] = msg_type_hello; + buf[NET_MSG_OFFSET_PAYLOAD_LENGTH] = namelen+2; + memcpy(buf+NET_MSG_OFFSET_PAYLOAD, username, namelen); send(sock, buf, namelen+2, 0); @@ -91,7 +91,7 @@ static player_list* client_recv_player_list(int sock, uint8_t data_len) recv(sock, buf, data_len, 0); - assert(buf[INDEX_TYPE] == msg_type_start_game); + assert(buf[NET_MSG_OFFSET_TYPE] == msg_type_start_game); players = malloc(sizeof(player_list)); if(players == NULL) @@ -100,7 +100,7 @@ static player_list* client_recv_player_list(int sock, uint8_t data_len) exit(EXIT_FAILURE); } - pos = INDEX_PAYLOAD; + pos = NET_MSG_OFFSET_PAYLOAD; players->count = buf[pos++]; // read usernames from buffer @@ -125,7 +125,7 @@ static hand* client_recv_deal_cards(int sock, uint8_t data_len) recv(sock, buf, data_len, 0); - assert(buf[INDEX_TYPE] == msg_type_deal_cards); + assert(buf[NET_MSG_OFFSET_TYPE] == msg_type_deal_cards); for(int i=0; i<MAX_HAND_CARDS; i++) *h[i] = (card) buf[i+2]; @@ -139,7 +139,7 @@ static hand* client_recv_deal_cards(int sock, uint8_t data_len) * @param[in] wanted Desired packet type * @return Pointer to desired data */ -void* client_recv(int sock, uint8_t wanted) +void* client_recv(int sock, msg_type_t wanted) { void* result = NULL; uint8_t buf[10], type, data_len; @@ -147,8 +147,8 @@ void* client_recv(int sock, uint8_t wanted) assert(len != -1); - type = buf[INDEX_TYPE]; - data_len = buf[INDEX_LEN]; + type = buf[NET_MSG_OFFSET_TYPE]; + data_len = buf[NET_MSG_OFFSET_PAYLOAD_LENGTH]; if(type != wanted) { printf("client_recv: received type %d instead of %d", type, wanted); |
