changeset 1371:bacbc8e248a5

Prevent the user from starting another potion test before the previous has been interrupted or finished, in order not to submit incorrect data in the asynchronous submit timer.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 26 Mar 2011 19:52:50 +0200
parents 3fdc8697e0d5
children 71d077d39236
files gm-alchemist.tf
diffstat 1 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/gm-alchemist.tf	Sat Mar 26 13:31:37 2011 +0200
+++ b/gm-alchemist.tf	Sat Mar 26 19:52:50 2011 +0200
@@ -137,8 +137,13 @@
 
 
 /def -i tmix =\
-	/set alch_submit=1%;\
-	/mix %{*}
+	/if (alch_testing)\
+		/msq Previous test still running.%;\
+	/else \
+		/set alch_testing=1%;\
+		/set alch_submit=1%;\
+		/mix %{*}%;\
+	/endif
 
 
 /def -i galch_get_organ =\
@@ -159,7 +164,8 @@
 		/let _herb=$[replace("_"," ", alch_herb)]%;\
 		/msq Returning '%{_herb}' in can '%{alch_jar}'%;\
 		@@put %{_herb} in %{alch_jar}%;\
-	/endif
+	/endif%;\
+	/set alch_testing=0
 
 
 /gdef -i -msimple -Ealch_st -aBCred -t"You need a prepared alchemist's flask first." galch_need_flask =\
@@ -172,6 +178,7 @@
 /gdef -i -mregexp -Ealch_st -aBCred -t"^ \.\. but you do not (seem to have any '[a-z_ -]+' on you|have enough '[a-z_ -]+' left)\." galch_has_no2 =\
 	/galch_return
 
+
 /def -i galch_interrupted =\
 	/if (alch_st) /galch_return%;/endif
 
@@ -208,7 +215,8 @@
 		/if (galch_update("-"))\
 			/msq Added no match for %{alch_mineral}, %{alch_organ}, %{alch_herb} to database.%;\
 		/endif%;\
-	/endif
+	/endif%;\
+	/set alch_testing=0
 
 /gdef -i -F -aCgreen -mregexp -t"^You submit the contents of a flask containing " galch_submit_done =\
 	@@drop empty flask%;\
@@ -221,17 +229,20 @@
 	/let _match=$[replace(" ","_",{P1})]%;\
 	/if (galch_update(strcat("?", _match)))\
 		/msq Added near-match '%{_match}' (%{alch_mineral}, %{alch_organ}, %{alch_herb}) to database.%;\
-	/endif
+	/endif%;\
+	/set alch_testing=0
 
 /gdef -i -F -aCgreen -mregexp -t"^Flask '([a-z_ -]+)' accepted\." galch_submit_match =\
 	/set alch_close=1%;\
 	/let _match=$[replace(" ","_",{P1})]%;\
 	/if (galch_update(strcat("!", _match)))\
 		/msq Added MATCH '%{_match}' (%{alch_mineral}, %{alch_organ}, %{alch_herb}) to database.%;\
-	/endif
+	/endif%;\
+	/set alch_testing=0
 
 /gdef -i -F -aBCred -msimple -t"You've already researched that flask." galch_submit_already =\
-	/set alch_close=1
+	/set alch_close=1%;\
+	/set alch_testing=0
 
 
 ;; Store organ into proper can