diff --git a/src/player/inc/human_player.h b/src/player/inc/human_player.h index fc6dd07..7d28b34 100644 --- a/src/player/inc/human_player.h +++ b/src/player/inc/human_player.h @@ -52,7 +52,7 @@ struct human_player } d; } sel[MAX_SELECTED_INSTANCES]; - struct + struct human_player_target { const struct instance *ins; unsigned char t, n; diff --git a/src/player/src/human_player.c b/src/player/src/human_player.c index ffc4fd4..1d2af7d 100644 --- a/src/player/src/human_player.c +++ b/src/player/src/human_player.c @@ -430,9 +430,12 @@ static void set_target(struct human_player *const h, struct unit *const u, const struct unit_target *const t) { unit_set_target(u, t); - memset(&h->target, 0, sizeof h->target); - h->target.ins = t->ins; - h->target.render = true; + + h->target = (const struct human_player_target) + { + .ins = t->ins, + .render = true + }; } static void target_from_pos(struct player *const p, @@ -487,7 +490,9 @@ static void move_units(struct human_player *const h, static void deselect_instances(struct human_player *const h) { - memset(h->sel, 0, sizeof h->sel); + for (size_t i = 0; i < sizeof h->sel / sizeof *h->sel; i++) + h->sel[i] = (const struct sel_instance){0}; + h->n_sel = 0; } @@ -520,7 +525,7 @@ static void update_target(struct human_player *const h) enum {TOGGLE = 10}; if (!i->alive) - memset(&h->target, 0, sizeof h->target); + h->target = (const struct human_player_target){0}; else if (++h->target.t >= TOGGLE) { enum {TIMES = 5}; @@ -529,7 +534,7 @@ static void update_target(struct human_player *const h) h->target.t = 0; if (++h->target.n >= TIMES) - memset(&h->target, 0, sizeof h->target); + h->target = (const struct human_player_target){0}; } } }