diff options
author | June McEnroe <june@causal.agency> | 2018-03-05 12:45:17 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2018-03-05 12:45:17 -0500 |
commit | 7bac64b1b3d8a0ab763aa584e3b085b45ae082b7 (patch) | |
tree | 6a7d9306dd4b0f7e9658660159cc4ed26a511e76 /torus.h | |
parent | Undef COLOR_ constants in torus.h (diff) | |
download | torus-7bac64b1b3d8a0ab763aa584e3b085b45ae082b7.tar.gz torus-7bac64b1b3d8a0ab763aa584e3b085b45ae082b7.zip |
Pack message type enums
Diffstat (limited to '')
-rw-r--r-- | torus.h | 27 |
1 files 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 <stdint.h> #include <time.h> +#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; |