ref: efbb2e3a31b16d34e060de633c5083c662a9ddac
parent: 1600818848fc99eb53e0de240670b598ac490fdc
author: Simon Tatham <anakin@pobox.com>
date: Sat Jan 8 09:24:20 EST 2022
Mosaic: fix encoding of aggressiveness in game params. The default setting for 'aggressiveness' is true. But the extra suffix to specify it in the full version of the encoded game params was being set if aggressiveness _was_ true, not if it was false. Result: round trip encode/decode of a non-aggressive configuration fails, because the encoded string has no aggressiveness suffix, and the decoder interprets that as going back into aggressive mode. Pulled out the default setting into a #define which is checked consistently in both locations.
--- a/mosaic.c
+++ b/mosaic.c
@@ -22,6 +22,7 @@
#include "puzzles.h"
#define DEFAULT_SIZE 10
+#define DEFAULT_AGGRESSIVENESS true
#define MAX_TILES 10000
#define MAX_TILES_ERROR "Maximum size is 10000 tiles"
#define DEFAULT_TILE_SIZE 32
@@ -138,7 +139,7 @@
ret->width = DEFAULT_SIZE;
ret->height = DEFAULT_SIZE;
- ret->aggressive = true;
+ ret->aggressive = DEFAULT_AGGRESSIVENESS;
return ret;
}
@@ -196,7 +197,7 @@
int pos = 0;
pos += sprintf(encoded + pos, "%dx%d", params->width, params->height);
if (full) {
- if (params->aggressive)
+ if (params->aggressive != DEFAULT_AGGRESSIVENESS)
pos += sprintf(encoded + pos, "h%d", params->aggressive);
}
return dupstr(encoded);