diff options
author | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2024-06-19 21:39:43 +0200 |
---|---|---|
committer | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2024-06-19 21:39:43 +0200 |
commit | 0c097be7c7809e86f3ebdd1bd9fe2f857919c5cd (patch) | |
tree | 47d1565504787725f52ec58bfacaea422c4d69f4 /src | |
parent | dfe8ddb9ff8b3f90036a0e47220b6c180cc95ea7 (diff) |
client: handle CPKT_HI
Signed-off-by: Lizzy Fleckenstein <lizzy@vlhl.dev>
Diffstat (limited to 'src')
-rw-r--r-- | src/client.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/client.c b/src/client.c index b15a3df..0ab1b53 100644 --- a/src/client.c +++ b/src/client.c @@ -24,6 +24,7 @@ typedef struct { str pass; uint64_t self_id; array(player) players; + str server_motd; } client; void gfx_alt_buffer(bool enable) @@ -43,6 +44,7 @@ void gfx_render(client *c, uint64_t dtime) { gfx_clear(); printf("\e[H"); + printf("%.*s\n", PSTR(c->server_motd)); for (size_t i = 0; i < c->players.len; i++) printf("%.*s\n", PSTR(c->players.data[i].name)); fflush(stdout); @@ -63,6 +65,7 @@ void client_exit(client *c, int ret) { free(c->name.data); free(c->pass.data); + free(c->server_motd.data); free_players(c); @@ -105,6 +108,16 @@ bool handle_players(str *w, client *c) return true; } +bool handle_hi(str *w, client *c) +{ + str motd; + if (!deser_str(w, &motd)) + return false; + + c->server_motd = str_clone(motd); + return true; +} + bool handle_pkt(client *c, str pkt) { pkt_type type; @@ -112,6 +125,7 @@ bool handle_pkt(client *c, str pkt) return false; switch (type) { + case CPKT_HI: return handle_hi(&pkt, c); case CPKT_PLAYERS: return handle_players(&pkt, c); default: return false; } |