From 41d27344c3b489466632bd2f1314fd69ff0a363c Mon Sep 17 00:00:00 2001 From: Trumeet Date: Fri, 29 Jul 2022 11:55:40 -0700 Subject: fix(libacron): spec incompliance: player is optional in disconnect events API:CHANGE --- client/helloworld/main.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'client/helloworld/main.c') diff --git a/client/helloworld/main.c b/client/helloworld/main.c index c112fcb..cba7e30 100644 --- a/client/helloworld/main.c +++ b/client/helloworld/main.c @@ -120,13 +120,17 @@ 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("Unknown player disconnected: %s.\n", o->reason); + } else { + 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); + } break; } case AC_EVENT_PLAYER_JOIN: { @@ -367,4 +371,4 @@ int main(int argc, char **argv) { mtx_destroy(&mtx_conn); #endif return r; -} \ No newline at end of file +} -- cgit v1.2.3