From 1d42944d172cbc725cd025aea1c364c3f13a38e5 Mon Sep 17 00:00:00 2001 From: Trumeet Date: Tue, 9 Aug 2022 17:12:45 -0700 Subject: fix(acronc): optional player for AC_EVENT_PLAYER_DISCONNECT --- client/acronc/client.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/client/acronc/client.c b/client/acronc/client.c index d64f96f..4e91d76 100644 --- a/client/acronc/client.c +++ b/client/acronc/client.c @@ -41,13 +41,18 @@ static void handle_event(const ac_event_t *event) { } case AC_EVENT_PLAYER_DISCONNECT: { ac_event_player_disconnect_t *o = (ac_event_player_disconnect_t *) event; - printf("Player '%s' disconnected at %s(%.2f, %.2f, %.2f): %s.\n", - o->player.name, - world_name(o->player.world), - o->player.pos.x, - o->player.pos.y, - o->player.pos.z, - o->reason); + if (o->player) { + printf("Player '%s' disconnected at %s(%.2f, %.2f, %.2f): %s.\n", + o->player->name, + world_name(o->player->world), + o->player->pos.x, + o->player->pos.y, + o->player->pos.z, + o->reason); + } else { + printf("Unknown player disconnected: %s.\n", + o->reason); + } break; } case AC_EVENT_PLAYER_JOIN: { @@ -120,4 +125,4 @@ int handle_object(ac_obj_t *obj) { else handle_event((ac_event_t *) obj); ac_object_free(obj); return 0; -} \ No newline at end of file +} -- cgit v1.2.3