comparison libmlk-rpg/mlk/rpg/tileset-file.c @ 474:ca30ff96bbe0

core: util -> mlk_util
author David Demelier <markand@malikania.fr>
date Mon, 27 Feb 2023 12:41:53 +0100
parents bc5483849614
children d6757c30658e
comparison
equal deleted inserted replaced
473:02b16dd49b54 474:ca30ff96bbe0
191 * owned by the tileset_file structure. 191 * owned by the tileset_file structure.
192 */ 192 */
193 while (fscanf(ctx->fp, "%hu|" MAX_F(FILENAME_MAX) "|%u", &id, filename, &delay) == 3) { 193 while (fscanf(ctx->fp, "%hu|" MAX_F(FILENAME_MAX) "|%u", &id, filename, &delay) == 3) {
194 anim = mlk_alloc_pool_new(&ctx->tf->anims[0]); 194 anim = mlk_alloc_pool_new(&ctx->tf->anims[0]);
195 195
196 if (mlk_image_open(&anim->texture, util_pathf("%s/%s", ctx->basedir, filename)) < 0) 196 if (mlk_image_open(&anim->texture, mlk_util_pathf("%s/%s", ctx->basedir, filename)) < 0)
197 return -1; 197 return -1;
198 198
199 mlk_sprite_init(&anim->sprite, &anim->texture, ctx->tilewidth, ctx->tileheight); 199 mlk_sprite_init(&anim->sprite, &anim->texture, ctx->tilewidth, ctx->tileheight);
200 mlk_animation_init(&anim->animation, &anim->sprite, delay); 200 mlk_animation_init(&anim->animation, &anim->sprite, delay);
201 } 201 }
234 if (ctx->tilewidth == 0 || ctx->tileheight == 0) 234 if (ctx->tilewidth == 0 || ctx->tileheight == 0)
235 return errorf("missing tile dimensions before image"); 235 return errorf("missing tile dimensions before image");
236 if (!(p = strchr(line, '|'))) 236 if (!(p = strchr(line, '|')))
237 return errorf("could not parse image"); 237 return errorf("could not parse image");
238 238
239 if (mlk_image_open(&ctx->tf->image, util_pathf("%s/%s", ctx->basedir, p + 1)) < 0) 239 if (mlk_image_open(&ctx->tf->image, mlk_util_pathf("%s/%s", ctx->basedir, p + 1)) < 0)
240 return -1; 240 return -1;
241 241
242 mlk_sprite_init(&ctx->tf->sprite, &ctx->tf->image, ctx->tilewidth, ctx->tileheight); 242 mlk_sprite_init(&ctx->tf->sprite, &ctx->tf->image, ctx->tilewidth, ctx->tileheight);
243 ctx->tileset->sprite = &ctx->tf->sprite; 243 ctx->tileset->sprite = &ctx->tf->sprite;
244 244
257 { "tiledefs", parse_tiledefs }, 257 { "tiledefs", parse_tiledefs },
258 { "animations", parse_animations }, 258 { "animations", parse_animations },
259 { "image", parse_image } 259 { "image", parse_image }
260 }; 260 };
261 261
262 for (size_t i = 0; i < UTIL_SIZE(props); ++i) { 262 for (size_t i = 0; i < MLK_UTIL_SIZE(props); ++i) {
263 if (strncmp(line, props[i].property, strlen(props[i].property)) == 0) 263 if (strncmp(line, props[i].property, strlen(props[i].property)) == 0)
264 return props[i].read(ctx, line); 264 return props[i].read(ctx, line);
265 } 265 }
266 266
267 return 0; 267 return 0;