aboutsummaryrefslogtreecommitdiff
path: root/client/helloworld/main.c
diff options
context:
space:
mode:
authorTrumeet <yuuta@yuuta.moe>2022-07-29 11:55:40 -0700
committerTrumeet <yuuta@yuuta.moe>2022-07-29 11:55:40 -0700
commit41d27344c3b489466632bd2f1314fd69ff0a363c (patch)
tree4fbb1e118593da7b78813fbd9184d9c7a0c450d6 /client/helloworld/main.c
parentb897bfe9f99872c701924f3cce269e6a36ea5bb5 (diff)
downloadacron-41d27344c3b489466632bd2f1314fd69ff0a363c.tar
acron-41d27344c3b489466632bd2f1314fd69ff0a363c.tar.gz
acron-41d27344c3b489466632bd2f1314fd69ff0a363c.tar.bz2
acron-41d27344c3b489466632bd2f1314fd69ff0a363c.zip
fix(libacron): spec incompliance: player is optional in disconnect events
API:CHANGE
Diffstat (limited to 'client/helloworld/main.c')
-rw-r--r--client/helloworld/main.c20
1 files changed, 12 insertions, 8 deletions
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
+}