~kikoodx/sle

a3e60cc0824ff3bd44ce7fa2983415a9b3d27c4e — KikooDX 3 years ago 0dc7fb3
editing_area/level.c: Specify char signes
1 files changed, 7 insertions(+), 8 deletions(-)

M src/editing_area/level.c
M src/editing_area/level.c => src/editing_area/level.c +7 -8
@@ 11,13 11,13 @@ static const int kble_fmt_version = 0;

static int read_byte(FILE *file);
static Tile read_byte_group(FILE *file, int size);
static int write_byte(FILE *file, char byte);
static int write_byte(FILE *file, unsigned char byte);
static int write_byte_group(FILE *file, Tile value, int size);

int level_read(struct Level *level, char *path)
{
	FILE *file = NULL;
	char byte = 0;
	unsigned char byte = 0;
	unsigned int tile_size = 0;
	int level_size = 0;
	int i = 0;


@@ 114,12 114,11 @@ int level_write(struct Level level, char *path)
	for (i = 0; i < level_size; i += 1) {
		tile = level.data[i];
		tile_size = 1;
		while (tile >>= 8) {
		while (tile >>= 8)
			tile_size += 1;
			INFO_VAR("%d", tile);
		}
		if (tile_size > max_tile_size) {
			max_tile_size = tile_size;
			INFO_VAR("%d", max_tile_size);
		}
	}
	INFO("max tile size is");


@@ 162,7 161,7 @@ static int read_byte(FILE *file)
static Tile read_byte_group(FILE *file, int size)
{
	int group = 0;
	char *byte_ptr = (char *)&group;
	unsigned char *byte_ptr = (unsigned char *)&group;
	int value = 0;
	int i = 0;
	byte_ptr += size;


@@ 176,7 175,7 @@ static Tile read_byte_group(FILE *file, int size)
}

/* Write a single byte safely (handle EOF). Return -1 if error. */
static int write_byte(FILE *file, char byte)
static int write_byte(FILE *file, unsigned char byte)
{
	const int result = fputc(byte, file);
	if (result == EOF) {


@@ 189,7 188,7 @@ static int write_byte(FILE *file, char byte)
/* Write an integer as multiple bytes. Return -1 if error. */
static int write_byte_group(FILE *file, Tile value, int size)
{
	char *value_ptr = (char *)&value;
	unsigned char *value_ptr = (unsigned char *)&value;
	value_ptr += size;
	int error;
	int i = 0;