diff options
author | June McEnroe <june@causal.agency> | 2017-07-31 22:14:56 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2017-07-31 22:14:56 -0400 |
commit | 5962f9f4a7614da62bdb73954eb624ab19218b1f (patch) | |
tree | 2479750ceef4788220daf45f7bc35979ce4ea058 /help.c | |
parent | Show other clients' cursors (diff) | |
download | torus-5962f9f4a7614da62bdb73954eb624ab19218b1f.tar.gz torus-5962f9f4a7614da62bdb73954eb624ab19218b1f.zip |
Use designated initializers for messages
I did not realize this syntax was so powerful.
Diffstat (limited to '')
-rwxr-xr-x | help.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/help.c b/help.c index ec4a861..7fc5f42 100755 --- a/help.c +++ b/help.c @@ -29,16 +29,18 @@ static void clientMessage(const struct ClientMessage *msg) { } static void clientMove(int8_t dx, int8_t dy) { - struct ClientMessage msg = { .type = CLIENT_MOVE }; - msg.data.m.dx = dx; - msg.data.m.dy = dy; + struct ClientMessage msg = { + .type = CLIENT_MOVE, + .data.m = { .dx = dx, .dy = dy }, + }; clientMessage(&msg); } static void clientPut(char cell) { - struct ClientMessage msg = { .type = CLIENT_PUT }; - msg.data.p.color = color; - msg.data.p.cell = cell; + struct ClientMessage msg = { + .type = CLIENT_PUT, + .data.p = { .color = color, .cell = cell }, + }; clientMessage(&msg); } |