summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/net.c8
-rw-r--r--src/net.h5
2 files changed, 6 insertions, 7 deletions
diff --git a/src/net.c b/src/net.c
index 0eea8a9..0567179 100644
--- a/src/net.c
+++ b/src/net.c
@@ -118,7 +118,7 @@ void client_hello(int sock, const char* username)
buf = malloc(namelen+2); // type + len + username
- buf[0] = CLIENT_HELLO;
+ buf[0] = msg_type_hello;
buf[1] = namelen;
memcpy(buf+2, username, namelen);
@@ -187,7 +187,7 @@ void server_start_game(int* clients, const uint8_t clientcount, const char* user
buflen += strlen(usernames[i]);
buf = malloc(buflen);
- buf[pos++] = SERVER_START_GAME;
+ buf[pos++] = msg_type_start_game;
buf[pos++] = clientcount;
// copy usernames with length to buffer
for(int i=0; i<usercount; i++)
@@ -217,7 +217,7 @@ char* server_recv_hello(int sock)
recv(sock, buf, 13, 0);
- assert(buf[0] == CLIENT_HELLO);
+ assert(buf[0] == msg_type_hello);
namelen = buf[1];
name = malloc(namelen+1);
@@ -247,7 +247,7 @@ void* server_recv(int sock, uint8_t wanted)
switch(type)
{
- case CLIENT_HELLO:
+ case msg_type_hello:
result = server_recv_hello(sock);
break;
}
diff --git a/src/net.h b/src/net.h
index 6a3d1a5..2fb28c0 100644
--- a/src/net.h
+++ b/src/net.h
@@ -3,13 +3,12 @@
#define MAX_PLAYERS 10
-enum packet_type { CLIENT_HELLO, SERVER_START_GAME };
-
typedef enum
{
// Specify message type identifier here
- msg_type_hello = 0x0
+ msg_type_hello = 0x0,
+ msg_type_start_game = 0x1
} msg_type_t;
typedef struct