Loading sprites and tiles both work correctly with relative paths, now using akgl_path_relative* helpers

This commit is contained in:
2026-05-24 19:57:43 -04:00
parent 980bbc56fb
commit 8f613397d6
5 changed files with 51 additions and 38 deletions

View File

@@ -12,6 +12,7 @@
#include <akgl/registry.h>
#include <akgl/staticstring.h>
#include <akgl/iterator.h>
#include <akgl/util.h>
akerr_ErrorContext *akgl_sprite_sheet_coords_for_frame(akgl_Sprite *self, SDL_FRect *srccoords, uint8_t frameid)
{
@@ -48,11 +49,7 @@ static akerr_ErrorContext *akgl_sprite_load_json_spritesheet(json_t *json, akgl_
CATCH(errctx, akgl_string_initialize(tmpstr, NULL));
CATCH(errctx, akgl_get_json_object_value((json_t *)json, "spritesheet", &spritesheet_json));
CATCH(errctx, akgl_get_json_string_value((json_t *)spritesheet_json, "filename", &ss_filename));
if ( ss_filename->data[0] != '/' ) {
SDL_snprintf((char *)&tmpstr->data, AKGL_MAX_STRING_LENGTH, "%s/%s", relative_path, ss_filename->data);
} else {
SDL_snprintf((char *)&tmpstr->data, AKGL_MAX_STRING_LENGTH, "%s", ss_filename->data);
}
CATCH(errctx, akgl_path_relative(relative_path, ss_filename->data, tmpstr));
*sheet = SDL_GetPointerProperty(
AKGL_REGISTRY_SPRITESHEET,
(char *)&tmpstr->data,