aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/helloworld/main.c3
-rw-r--r--client/libacron/ids.c4
-rw-r--r--client/libacron/include/common.h1
-rw-r--r--client/libacron/private/serializer.c7
4 files changed, 14 insertions, 1 deletions
diff --git a/client/helloworld/main.c b/client/helloworld/main.c
index 6c46ed0..8b3486b 100644
--- a/client/helloworld/main.c
+++ b/client/helloworld/main.c
@@ -98,8 +98,9 @@ static void handle_event(const ac_event_t *event) {
}
case AC_EVENT_ENTITY_DEATH: {
ac_event_entity_death_t *o = (ac_event_entity_death_t *) event;
- printf("Entity '%s' died at %s(%.2f, %.2f, %.2f): %s.\n",
+ printf("Entity '%s' (%s) died at %s(%.2f, %.2f, %.2f): %s.\n",
o->entity.name,
+ o->entity.type,
world_name(o->entity.world),
o->entity.pos.x,
o->entity.pos.y,
diff --git a/client/libacron/ids.c b/client/libacron/ids.c
index 7af471d..65be0ab 100644
--- a/client/libacron/ids.c
+++ b/client/libacron/ids.c
@@ -16,6 +16,7 @@ int ac_object_free(ac_obj_t *obj) {
ac_event_player_join_t *v = (ac_event_player_join_t *) obj;
if (v->player.name) free(v->player.name);
if (v->player.uuid) free(v->player.uuid);
+ if (v->player.type) free(v->player.type);
goto ok;
}
case AC_EVENT_PLAYER_DISCONNECT: {
@@ -23,6 +24,7 @@ int ac_object_free(ac_obj_t *obj) {
if (v->player) {
if (v->player->name) free(v->player->name);
if (v->player->uuid) free(v->player->uuid);
+ if (v->player->type) free(v->player->type);
free(v->player);
}
if (v->reason) free(v->reason);
@@ -32,6 +34,7 @@ int ac_object_free(ac_obj_t *obj) {
ac_event_entity_death_t *v = (ac_event_entity_death_t *) obj;
if (v->entity.name) free(v->entity.name);
if (v->entity.uuid) free(v->entity.uuid);
+ if (v->entity.type) free(v->entity.type);
if (v->message) free(v->message);
goto ok;
}
@@ -39,6 +42,7 @@ int ac_object_free(ac_obj_t *obj) {
ac_event_player_message_t *v = (ac_event_player_message_t *) obj;
if (v->player.name) free(v->player.name);
if (v->player.uuid) free(v->player.uuid);
+ if (v->player.type) free(v->player.type);
if (v->text) free(v->text);
goto ok;
}
diff --git a/client/libacron/include/common.h b/client/libacron/include/common.h
index 89738c4..79dd29b 100644
--- a/client/libacron/include/common.h
+++ b/client/libacron/include/common.h
@@ -50,6 +50,7 @@ typedef struct ac_vec2f {
typedef struct ac_entity {
char *name;
char *uuid;
+ char *type;
ac_vec3d_t pos;
enum ac_world world;
} ac_entity_t;
diff --git a/client/libacron/private/serializer.c b/client/libacron/private/serializer.c
index d5171ba..c997585 100644
--- a/client/libacron/private/serializer.c
+++ b/client/libacron/private/serializer.c
@@ -104,6 +104,13 @@ static int deserialize_entity(const json_object *json, ac_entity_t *entity) {
return r;
}
+ if ((r = get_child(json, "type", json_type_string, true, &arg))) {
+ return r;
+ }
+ if ((r = strdup2(json_object_get_string(arg), &entity->type))) {
+ return r;
+ }
+
if ((r = get_child(json, "world", json_type_string, false, &arg))) {
return r;
}