From e7ea69b2603e7047ad13774b648dc2fb4089af6b Mon Sep 17 00:00:00 2001
From: David Vazgenovich Shakaryan <dvshakaryan@gmail.com>
Date: Sun, 15 May 2022 02:44:24 -0700
Subject: web: avoid setting stdev twice on load

---
 web/web_opts.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

(limited to 'web')

diff --git a/web/web_opts.c b/web/web_opts.c
index e1c5eb5..b459305 100644
--- a/web/web_opts.c
+++ b/web/web_opts.c
@@ -4,6 +4,7 @@
 #include "comp.h"
 
 #include <math.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -80,31 +81,31 @@ char *read_opt(char *opt)
 	return val;
 }
 
-void read_delay()
+bool read_delay()
 {
 	char *val = read_opt("delay");
-	if (!val) return;
+	if (!val) return false;
 
 	set_delay(val);
 	free(val);
+	return true;
 }
 
-void read_difficulty()
+bool read_difficulty()
 {
 	char *val = read_opt("difficulty");
-	if (!val) return;
+	if (!val) return false;
 
 	set_difficulty(val);
 	free(val);
+	return true;
 }
 
 void opts_init()
 {
-	// TODO call only when no stored diff setting
-	set_stdev(difficulty);
-
 	read_delay();
-	read_difficulty();
+	if (!read_difficulty())
+		set_stdev(difficulty);
 
 	char buf[64];
 	sprintf(buf, "%d", delay_ms);
-- 
cgit v1.2.3-70-g09d2