about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorJune McEnroe <programble@gmail.com>2018-03-05 12:45:17 -0500
committerJune McEnroe <programble@gmail.com>2018-03-05 12:45:17 -0500
commitf883e5bf73cc11f545ef5a72cbebf8f2aeea69da (patch)
tree014ae5454831fdc82ddb232bea6f00ee697b9c28
parentUndef COLOR_ constants in torus.h (diff)
downloadtorus-f883e5bf73cc11f545ef5a72cbebf8f2aeea69da.tar.gz
torus-f883e5bf73cc11f545ef5a72cbebf8f2aeea69da.zip
Pack message type enums
-rw-r--r--torus.h27
1 files changed, 12 insertions, 15 deletions
diff --git a/torus.h b/torus.h
index fd158ed..6d819a3 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;