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_server.c | |
| parent | 4ed53bf1c06324e0bdca274090ec49e56848f00d (diff) | |
Renamed receive buffer offset macros. Changed argument data types of client_recv and server_recv.
Diffstat (limited to 'src/net_server.c')
| -rw-r--r-- | src/net_server.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/net_server.c b/src/net_server.c index edafed2..f55c558 100644 --- a/src/net_server.c +++ b/src/net_server.c @@ -133,9 +133,9 @@ void server_start_game(int* clients, const uint8_t clientcount, const player_lis printf("server_start_game: Out of memory\n"); exit(EXIT_FAILURE); } - buf[INDEX_TYPE] = msg_type_start_game; - buf[INDEX_LEN] = buflen; - pos = INDEX_PAYLOAD; + buf[NET_MSG_OFFSET_TYPE] = msg_type_start_game; + buf[NET_MSG_OFFSET_PAYLOAD_LENGTH] = buflen; + pos = NET_MSG_OFFSET_PAYLOAD; buf[pos++] = players->count; // copy usernames with length to buffer for(int i=0; i<usercount; i++) @@ -165,9 +165,9 @@ static char* server_recv_hello(int sock, uint8_t data_len) recv(sock, buf, data_len, 0); - assert(buf[INDEX_TYPE] == msg_type_hello); + assert(buf[NET_MSG_OFFSET_TYPE] == msg_type_hello); - namelen = buf[INDEX_LEN] - 2; + namelen = buf[NET_MSG_OFFSET_PAYLOAD_LENGTH] - 2; name = malloc(namelen+1); if(name == NULL) { @@ -187,7 +187,7 @@ static char* server_recv_hello(int sock, uint8_t data_len) * @param[in] wanted Packet type that should be handled * @return Pointer to desired data or NULL if not in recv queue */ -void* server_recv(int sock, uint8_t wanted) +void* server_recv(int sock, msg_type_t wanted) { void* result = NULL; uint8_t buf[10], type, data_len; @@ -195,8 +195,8 @@ void* server_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) return NULL; @@ -219,10 +219,10 @@ void server_deal_cards(int sock, const hand h) { uint8_t buf[2+MAX_HAND_CARDS]; - buf[INDEX_TYPE] = msg_type_deal_cards; - buf[INDEX_LEN] = 2+MAX_HAND_CARDS; + buf[NET_MSG_OFFSET_TYPE] = msg_type_deal_cards; + buf[NET_MSG_OFFSET_PAYLOAD_LENGTH] = 2+MAX_HAND_CARDS; for(int i=0; i<MAX_HAND_CARDS; i++) - buf[INDEX_PAYLOAD+i] = h[i]; + buf[NET_MSG_OFFSET_PAYLOAD+i] = h[i]; send(sock, buf, 2+MAX_HAND_CARDS, 0); |
