Mercurial > molko
comparison libmlk-rpg/mlk/rpg/tileset-file.c @ 547:c7664b679a95
misc: remove error codes for now
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 06 Mar 2023 20:03:00 +0100 |
parents | c2124ecb2423 |
children |
comparison
equal
deleted
inserted
replaced
546:b7da58230a66 | 547:c7664b679a95 |
---|---|
126 | 126 |
127 static int | 127 static int |
128 parse_tilewidth(struct context *ctx, const char *line) | 128 parse_tilewidth(struct context *ctx, const char *line) |
129 { | 129 { |
130 if (sscanf(line, "tilewidth|%u", &ctx->tilewidth) != 1 || ctx->tilewidth == 0) | 130 if (sscanf(line, "tilewidth|%u", &ctx->tilewidth) != 1 || ctx->tilewidth == 0) |
131 return MLK_ERR_FORMAT; | 131 return mlk_errf("tilewidth is null"); |
132 | 132 |
133 return 0; | 133 return 0; |
134 } | 134 } |
135 | 135 |
136 static int | 136 static int |
137 parse_tileheight(struct context *ctx, const char *line) | 137 parse_tileheight(struct context *ctx, const char *line) |
138 { | 138 { |
139 if (sscanf(line, "tileheight|%u", &ctx->tileheight) != 1 || ctx->tileheight == 0) | 139 if (sscanf(line, "tileheight|%u", &ctx->tileheight) != 1 || ctx->tileheight == 0) |
140 return MLK_ERR_FORMAT; | 140 return mlk_errf("tileheight is null"); |
141 | 141 |
142 return 0; | 142 return 0; |
143 } | 143 } |
144 | 144 |
145 static int | 145 static int |
233 | 233 |
234 static int | 234 static int |
235 parse_image(struct context *ctx, const char *line) | 235 parse_image(struct context *ctx, const char *line) |
236 { | 236 { |
237 char *p; | 237 char *p; |
238 int err; | |
239 | 238 |
240 if (ctx->tilewidth == 0 || ctx->tileheight == 0) | 239 if (ctx->tilewidth == 0 || ctx->tileheight == 0) |
241 return MLK_ERR_FORMAT; | 240 return mlk_errf("missing tile dimensions before image"); |
242 if (!(p = strchr(line, '|'))) | 241 if (!(p = strchr(line, '|'))) |
243 return MLK_ERR_FORMAT; | 242 return mlk_errf("could not parse image"); |
244 if ((err = mlk_image_open(&ctx->tf->image, mlk_util_pathf("%s/%s", ctx->basedir, p + 1))) < 0) | 243 if (mlk_image_open(&ctx->tf->image, mlk_util_pathf("%s/%s", ctx->basedir, p + 1)) < 0) |
245 return err; | 244 return -1; |
246 | 245 |
247 ctx->tf->sprite.texture = &ctx->tf->image; | 246 ctx->tf->sprite.texture = &ctx->tf->image; |
248 ctx->tf->sprite.cellw = ctx->tilewidth; | 247 ctx->tf->sprite.cellw = ctx->tilewidth; |
249 ctx->tf->sprite.cellh = ctx->tileheight; | 248 ctx->tf->sprite.cellh = ctx->tileheight; |
250 mlk_sprite_init(&ctx->tf->sprite); | 249 mlk_sprite_init(&ctx->tf->sprite); |
297 | 296 |
298 static int | 297 static int |
299 check(const struct tileset *tileset) | 298 check(const struct tileset *tileset) |
300 { | 299 { |
301 if (!tileset->sprite) | 300 if (!tileset->sprite) |
302 return MLK_ERR_FORMAT; | 301 return mlk_errf("missing tileset image"); |
303 | 302 |
304 return 0; | 303 return 0; |
305 } | 304 } |
306 | 305 |
307 int | 306 int |