diff options
-rw-r--r-- | entry.h | 14 | ||||
-rw-r--r-- | jouer.c | 7 |
2 files changed, 11 insertions, 10 deletions
@@ -5,6 +5,13 @@ #include "players.h" #include "target.h" +struct action_t { + void *data; + void (*f)(SURFACES *, POSITIONS *, struct character_t *, struct target_t *, void *data); + + enum target_type_t target; +}; + struct entry_t { /* displayed name */ char *name; @@ -13,12 +20,7 @@ struct entry_t { union { struct entry_t *children; - struct { - void *data; - void (*f)(SURFACES *, POSITIONS *, struct character_t *, struct target_t *, void *data); - - enum target_type_t target; - } action; + struct action_t action; }; }; @@ -117,8 +117,7 @@ static void update_current_character(struct team_t *t1, struct team_t *t2, struc } static -enum action_state_t select_target(struct action_params_t *params, void *data, - void (*cb)(SURFACES *, POSITIONS *, struct character_t *, struct target_t *, void *)) +enum action_state_t select_target(struct action_params_t *params, const struct action_t *action) { SURFACES *surfaces = params->surfaces; POSITIONS *positions = params->positions; @@ -195,7 +194,7 @@ enum action_state_t select_target(struct action_params_t *params, void *data, case SDLK_f: update_selected_target(surfaces, positions, NULL); - (*cb)(surfaces, positions, params->src, &target, data); + (*action->f)(surfaces, positions, params->src, &target, action->data); return ACTION_PERFORMED; default: @@ -237,7 +236,7 @@ enum action_state_t dig_entry(const struct entry_t *entries, int cnt_entries, st case SDLK_RETURN: target = &entries[selection]; if (!target->children_cnt) { - enum action_state_t state = select_target(params, target->action.data, target->action.f); + enum action_state_t state = select_target(params, &target->action); if (state == ACTION_PERFORMED) return ACTION_PERFORMED; |