diff options
author | Olivier Gayot <duskcoder@gmail.com> | 2015-01-09 16:32:50 +0100 |
---|---|---|
committer | Olivier Gayot <duskcoder@gmail.com> | 2015-01-09 16:32:50 +0100 |
commit | 4c826c50bb7a8d79201cc7d8f68b8805030aa98c (patch) | |
tree | 8e30262c703c16cdf01f442410260a6107a0ee8d /jouer.c | |
parent | bfdf279cac51fe8945e59cd566cba2cb2efcffce (diff) |
use a new field which contains the playing character
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'jouer.c')
-rw-r--r-- | jouer.c | 26 |
1 files changed, 15 insertions, 11 deletions
@@ -108,16 +108,18 @@ static void update_current_character(struct team_t *t1, struct team_t *t2, struc } static -enum action_state_t select_target(SURFACES *surfaces, POSITIONS *positions, struct team_t *t1, struct team_t *t2, - void *data, void (*cb)(SURFACES *, POSITIONS *, struct character_t *, struct character_t *, void *)) +enum action_state_t select_target(struct action_params_t *params, void *data, + void (*cb)(SURFACES *, POSITIONS *, struct character_t *, struct character_t *, void *)) { - SDL_Event event; + SURFACES *surfaces = params->surfaces; + POSITIONS *positions = params->positions; /* select our own character because he exists no matter what */ - struct team_t *target_team = t1; + struct team_t *target_team = params->src->team; int selection = target_team->chr_cur; int new_selection; + SDL_Event event; - update_selected_target(surfaces, positions, &t1->chrs[selection]); + update_selected_target(surfaces, positions, &target_team->chrs[selection]); SDL_Flip(surfaces->Pecran); for (;;) { @@ -158,12 +160,12 @@ enum action_state_t select_target(SURFACES *surfaces, POSITIONS *positions, stru case SDLK_h: case SDLK_RIGHT: case SDLK_l: - new_selection = get_alive_character((target_team == t1) ? t2 : t1); + new_selection = get_alive_character((target_team == params->t1) ? params->t2 : params->t1); if (new_selection < 0) continue; selection = new_selection; - target_team = (target_team == t1) ? t2 : t1; + target_team = (target_team == params->t1) ? params->t2 : params->t1; update_selected_target(surfaces, positions, &target_team->chrs[selection]); SDL_Flip(surfaces->Pecran); break; @@ -171,7 +173,7 @@ enum action_state_t select_target(SURFACES *surfaces, POSITIONS *positions, stru case SDLK_f: update_selected_target(surfaces, positions, NULL); - (*cb)(surfaces, positions, &t1->chrs[t1->chr_cur], &target_team->chrs[selection], data); + (*cb)(surfaces, positions, params->src, &target_team->chrs[selection], data); SDL_Flip(surfaces->Pecran); @@ -221,7 +223,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->surfaces, params->positions, params->t1, params->t2, target->data, target->f); + enum action_state_t state = select_target(params, target->data, target->f); if (state == ACTION_PERFORMED) return ACTION_PERFORMED; @@ -265,8 +267,10 @@ int Fjouer (SURFACES *surfaces, POSITIONS *positions, struct team_t *t1, struct .surfaces = surfaces, .positions = positions, - .t1 = playing_team, - .t2 = (playing_team == t1) ? t2 : t1, + .t1 = t1, + .t2 = t2, + + .src = &playing_team->chrs[playing_team->chr_cur], }; enum action_state_t state; |