diff options
author | June McEnroe <programble@gmail.com> | 2017-07-31 22:14:56 -0400 |
---|---|---|
committer | June McEnroe <programble@gmail.com> | 2017-07-31 22:14:56 -0400 |
commit | 4204d65ff0dd3eaf1e300658d58254ceb27c2c1c (patch) | |
tree | bf78feb251fff82d13ab5fc761ca420353307fc7 /client.c | |
parent | Show other clients' cursors (diff) | |
download | torus-4204d65ff0dd3eaf1e300658d58254ceb27c2c1c.tar.gz torus-4204d65ff0dd3eaf1e300658d58254ceb27c2c1c.zip |
Use designated initializers for messages
I did not realize this syntax was so powerful.
Diffstat (limited to '')
-rwxr-xr-x | client.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/client.c b/client.c index d77aeb7..74e3a6f 100755 --- a/client.c +++ b/client.c @@ -38,16 +38,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(uint8_t color, 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); } |