From 22646d963e2b0c9b5ef629aa7704158026cfa6d1 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Sun, 1 May 2022 15:07:11 -0700 Subject: web: split code into more files This is currently very messy with all the files interdependent on one another and a lot of the logic still in the main file. It will take some time to refactor and clean up. --- web/web_match.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 web/web_match.c (limited to 'web/web_match.c') diff --git a/web/web_match.c b/web/web_match.c new file mode 100644 index 0000000..47bc6e6 --- /dev/null +++ b/web/web_match.c @@ -0,0 +1,20 @@ +#include "web_match.h" + +#include +#include + +struct match_state *state; + +void free_state() +{ + state->legs[1]->n_visits += state->boat_undone; // avoid memory leak + leg_free(state->legs[0]); + leg_free(state->legs[1]); + free(state); + state = NULL; +} + +bool is_match_over() +{ + return state->legs[0]->rem <= 0 || state->legs[1]->rem <= 0; +} -- cgit v1.2.3-70-g09d2