summaryrefslogtreecommitdiff
path: root/web/web_control.c
diff options
context:
space:
mode:
Diffstat (limited to 'web/web_control.c')
-rw-r--r--web/web_control.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/web/web_control.c b/web/web_control.c
index 39b92ba..310bbcf 100644
--- a/web/web_control.c
+++ b/web/web_control.c
@@ -20,7 +20,6 @@ static int curr_match_id = 0;
void set_active_player(int pn)
{
state->active_player = pn;
- state->active_leg = state->legs[pn-1];
scoreboard_set_player_active(pn);
if (state->mode == M_PVC && pn == 2)
@@ -36,7 +35,7 @@ void toggle_active_player()
void update_user_rem_from_pts(int pts)
{
- update_player_rem(state->active_player, state->active_leg->rem - pts);
+ update_player_rem(state->active_player, state_active_leg()->rem - pts);
scoreboard_flush_player_info(state->active_player);
}
@@ -160,12 +159,12 @@ void handle_next()
void user_visit(int points)
{
- if (!is_points_valid(points, state->active_leg->rem)) {
+ if (!is_points_valid(points, state_active_leg()->rem)) {
oi();
return;
}
- struct leg *l = state->active_leg;
+ struct leg *l = state_active_leg();
if (l->n_visits == l->size_visits)
leg_grow_visits(l);
struct visit *v = l->visits + l->n_visits++;
@@ -212,7 +211,7 @@ static bool player_is_comp(int pn)
static void undo_active()
{
- struct leg *l = state->active_leg;
+ struct leg *l = state_active_leg();
if (player_is_comp(state->active_player)) {
l->rem += l->visits[--l->n_visits].points;
@@ -227,7 +226,6 @@ static void undo_active()
update_player_rem(state->active_player, l->rem);
state->active_player = prev_throw_player();
- state->active_leg = state->legs[state->active_player - 1];
}
static bool first_user_has_thrown() {
@@ -252,7 +250,7 @@ void user_undo()
if (state->num_darts) {
state->num_darts = 0;
- struct leg *l = state->active_leg;
+ struct leg *l = state_active_leg();
scoreboard_set_player_avg(state->active_player,
((double)(l->start - l->visits[l->n_visits-2].rem) /
(l->n_visits - 1)));
@@ -262,7 +260,6 @@ void user_undo()
}
state->active_player = prev_throw_player();
- state->active_leg = state->legs[state->active_player - 1];
while (player_is_comp(state->active_player))
undo_active();
undo_active();