summaryrefslogtreecommitdiff
path: root/src/net_server.c
diff options
context:
space:
mode:
authorReiner Herrmann <reiner@reiner-h.de>2011-01-16 02:46:13 +0100
committerReiner Herrmann <reiner@reiner-h.de>2011-01-16 02:46:13 +0100
commit3a85f876ca899d2ea523dafc79e6d3735ed52611 (patch)
treea84e4700572c74cd208c8ad051d023ace4062e2c /src/net_server.c
parent459a1f83b51a506f538bf495f9a85cf399070a85 (diff)
parent89c5e3062f1c7cca1e410e0cbd7eda1985db39e4 (diff)
Merge branch 'master' of ssh://wg.reiner-h.de:22003/~git/oxen
Diffstat (limited to 'src/net_server.c')
-rw-r--r--src/net_server.c22
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);