aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2022-01-08 14:24:20 +0000
committerSimon Tatham <anakin@pobox.com>2022-01-08 14:27:16 +0000
commitefbb2e3a31b16d34e060de633c5083c662a9ddac (patch)
tree6eb65a409a9d9ddbe22cbcd48af8bc4e2df6e4cf
parent1600818848fc99eb53e0de240670b598ac490fdc (diff)
downloadpuzzles-efbb2e3a31b16d34e060de633c5083c662a9ddac.zip
puzzles-efbb2e3a31b16d34e060de633c5083c662a9ddac.tar.gz
puzzles-efbb2e3a31b16d34e060de633c5083c662a9ddac.tar.bz2
puzzles-efbb2e3a31b16d34e060de633c5083c662a9ddac.tar.xz
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.
-rw-r--r--mosaic.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/mosaic.c b/mosaic.c
index 15aa96d..4f73e8f 100644
--- 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 @@ static game_params *default_params(void)
ret->width = DEFAULT_SIZE;
ret->height = DEFAULT_SIZE;
- ret->aggressive = true;
+ ret->aggressive = DEFAULT_AGGRESSIVENESS;
return ret;
}
@@ -196,7 +197,7 @@ static char *encode_params(const game_params *params, bool full)
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);