shithub: battleship

Download patch

ref: 28cacde37de17e1f471b215e55d644b53881a24b
parent: 8f1306dfeadd090819c1257d2d4c244e52f98614
author: rodri <rgl@antares-labs.eu>
date: Sat Nov 16 09:10:47 EST 2024

bts: fix confirmdone().

--- a/bts.c
+++ b/bts.c
@@ -708,15 +708,16 @@
 	};
 
 	csetcursor(mc, &anchor);
-	readmouse(mc);
-	while(mc->buttons == 0)
+	while(mc->buttons != 0)			/* ignore any buttons already pressed */
 		readmouse(mc);
+	while(mc->buttons == 0)			/* wait for a button press */
+		readmouse(mc);
 	if(mc->buttons != 4){
 		while(nbrecv(kctl->c, nil))	/* flush key presses */
 		csetcursor(mc, nil);
 		return 0;
 	}
-	while(mc->buttons){
+	while(mc->buttons){			/* commit action on button release */
 		if(mc->buttons != 4){
 			while(nbrecv(kctl->c, nil));
 			csetcursor(mc, nil);