diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-05-21 04:43:19 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-05-21 04:43:19 -0700 |
commit | 3e8b8b804e7b30f096e557839eb5cc419a647f78 (patch) | |
tree | d59809a8d0d77d90984ef70e0ba1ae58d7b3dbc9 /web/web_match.c | |
parent | 35f311f779c039423fc7e2a11f98703c40201846 (diff) | |
download | dartboat-3e8b8b804e7b30f096e557839eb5cc419a647f78.tar.gz dartboat-3e8b8b804e7b30f096e557839eb5cc419a647f78.tar.xz |
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.
Diffstat (limited to 'web/web_match.c')
-rw-r--r-- | web/web_match.c | 9 |
1 files changed, 7 insertions, 2 deletions
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() |