mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
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.
This commit is contained in:
5
mosaic.c
5
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);
|
||||
|
Reference in New Issue
Block a user