diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2011-01-15 00:08:52 +0100 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2011-01-15 00:08:52 +0100 |
| commit | 51672dbfc64892250c1514a4258504e99fef8d6a (patch) | |
| tree | 309c1d1bf0541c4be0c73154a99825a9f2f76e36 /src | |
| parent | 5f7ecaecdbd81cb0d40fb5da7f7035b0b8331538 (diff) | |
use already available msg_type enum..
Diffstat (limited to 'src')
| -rw-r--r-- | src/net.c | 8 | ||||
| -rw-r--r-- | src/net.h | 5 |
2 files changed, 6 insertions, 7 deletions
@@ -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; } @@ -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 |
