From 3e8b8b804e7b30f096e557839eb5cc419a647f78 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Sat, 21 May 2022 04:43:19 -0700 Subject: web: use function ptrs for menu options This avoids having to keep the options and their order in sync between separate display and submit functions. --- web/web_match.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'web/web_match.c') diff --git a/web/web_match.c b/web/web_match.c index 0ebc56e..cd87c5a 100644 --- a/web/web_match.c +++ b/web/web_match.c @@ -60,6 +60,7 @@ void match_opts_new() if (match_opts) match_opts_free(); match_opts = calloc(1, sizeof(*match_opts)); + match_opts->start_pts = 501; match_opts->size_players = 2; match_opts->players = malloc( @@ -77,8 +78,12 @@ void match_opts_add_player(enum player_type type, char *name) sizeof(*(match_opts->players))); } - match_opts->players[match_opts->num_players].type = type; - match_opts->players[match_opts->num_players++].name = name; + int pn = ++match_opts->num_players; + if (!match_opts->throws_first) + match_opts->throws_first = pn; + + match_opts->players[pn - 1].type = type; + match_opts->players[pn - 1].name = name; } void match_opts_free() -- cgit v1.2.3-70-g09d2