diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2011-01-16 02:46:13 +0100 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2011-01-16 02:46:13 +0100 |
| commit | 3a85f876ca899d2ea523dafc79e6d3735ed52611 (patch) | |
| tree | a84e4700572c74cd208c8ad051d023ace4062e2c /src/net_client.c | |
| parent | 459a1f83b51a506f538bf495f9a85cf399070a85 (diff) | |
| parent | 89c5e3062f1c7cca1e410e0cbd7eda1985db39e4 (diff) | |
Merge branch 'master' of ssh://wg.reiner-h.de:22003/~git/oxen
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 b86508c..031e6af 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 = create_playerlist(); 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); |
