mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Palisade: explicitly use 'signed char' for clues.
Previously, the typedef 'clue' was just 'char', but it was used in the expectation that it would be signed. So on platforms that default to unsigned char, such as 32-bit Arm, Palisade would completely fail to function correctly.
This commit is contained in:
10
palisade.c
10
palisade.c
@ -46,7 +46,7 @@ struct game_params {
|
|||||||
int w, h, k;
|
int w, h, k;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef char clue;
|
typedef signed char clue;
|
||||||
typedef unsigned char borderflag;
|
typedef unsigned char borderflag;
|
||||||
|
|
||||||
typedef struct shared_state {
|
typedef struct shared_state {
|
||||||
@ -622,7 +622,7 @@ static char *new_game_desc(const game_params *params, random_state *rs,
|
|||||||
{
|
{
|
||||||
int w = params->w, h = params->h, wh = w*h, k = params->k;
|
int w = params->w, h = params->h, wh = w*h, k = params->k;
|
||||||
|
|
||||||
clue *numbers = snewn(wh + 1, clue), *p;
|
clue *numbers = snewn(wh + 1, clue);
|
||||||
borderflag *rim = snewn(wh, borderflag);
|
borderflag *rim = snewn(wh, borderflag);
|
||||||
borderflag *scratch_borders = snewn(wh, borderflag);
|
borderflag *scratch_borders = snewn(wh, borderflag);
|
||||||
|
|
||||||
@ -682,7 +682,8 @@ static char *new_game_desc(const game_params *params, random_state *rs,
|
|||||||
sfree(shuf);
|
sfree(shuf);
|
||||||
sfree(dsf);
|
sfree(dsf);
|
||||||
|
|
||||||
p = numbers;
|
char *output = snewn(wh + 1, char), *p = output;
|
||||||
|
|
||||||
r = 0;
|
r = 0;
|
||||||
for (i = 0; i < wh; ++i) {
|
for (i = 0; i < wh; ++i) {
|
||||||
if (numbers[i] != EMPTY) {
|
if (numbers[i] != EMPTY) {
|
||||||
@ -699,7 +700,8 @@ static char *new_game_desc(const game_params *params, random_state *rs,
|
|||||||
}
|
}
|
||||||
*p++ = '\0';
|
*p++ = '\0';
|
||||||
|
|
||||||
return sresize(numbers, p - numbers, clue);
|
sfree(numbers);
|
||||||
|
return sresize(output, p - output, char);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *validate_desc(const game_params *params, const char *desc)
|
static const char *validate_desc(const game_params *params, const char *desc)
|
||||||
|
Reference in New Issue
Block a user