From 7bac64b1b3d8a0ab763aa584e3b085b45ae082b7 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Mon, 5 Mar 2018 12:45:17 -0500 Subject: Pack message type enums --- torus.h | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/torus.h b/torus.h index 5f8eb9a..efe828d 100644 --- a/torus.h +++ b/torus.h @@ -20,6 +20,7 @@ #include #include +#define PACKED __attribute__((packed)) #define ALIGNED(x) __attribute__((aligned(x))) #undef COLOR_BLACK @@ -80,15 +81,13 @@ static const struct { #define SPAWN_COUNT (sizeof(SPAWN) / sizeof(SPAWN[0])) -enum ServerMessageType { - SERVER_TILE, - SERVER_MOVE, - SERVER_PUT, - SERVER_CURSOR, -}; - struct ServerMessage { - enum ServerMessageType type; + enum PACKED { + SERVER_TILE, + SERVER_MOVE, + SERVER_PUT, + SERVER_CURSOR, + } type; union { struct { uint8_t cellX; @@ -111,14 +110,12 @@ struct ServerMessage { #define CURSOR_NONE UINT8_MAX -enum ClientMessageType { - CLIENT_MOVE, - CLIENT_PUT, - CLIENT_SPAWN, -}; - struct ClientMessage { - enum ClientMessageType type; + enum PACKED { + CLIENT_MOVE, + CLIENT_PUT, + CLIENT_SPAWN, + } type; union { struct { int8_t dx; -- cgit 1.4.1