Got the suite rebuilding, most tests pass, actor and sprite are failing

This commit is contained in:
2026-05-03 23:57:55 -04:00
parent f475dfb6ee
commit 6763b5629f
36 changed files with 734 additions and 664 deletions

View File

@@ -13,7 +13,7 @@
#include <sdl3game/staticstring.h>
#include <sdl3game/iterator.h>
static ErrorContext *sprite_load_json_spritesheet(json_t *json, spritesheet **sheet, char *relative_path)
static akerr_ErrorContext *sprite_load_json_spritesheet(json_t *json, spritesheet **sheet, char *relative_path)
{
PREPARE_ERROR(errctx);
json_t *spritesheet_json = NULL;
@@ -58,7 +58,7 @@ static ErrorContext *sprite_load_json_spritesheet(json_t *json, spritesheet **sh
SUCCEED_RETURN(errctx);
}
ErrorContext *sprite_load_json(char *filename)
akerr_ErrorContext *sprite_load_json(char *filename)
{
PREPARE_ERROR(errctx);
json_t *json = NULL;
@@ -70,7 +70,7 @@ ErrorContext *sprite_load_json(char *filename)
//string *tmpstr = NULL;
int i = 0;
FAIL_ZERO_RETURN(errctx, filename, ERR_NULLPOINTER, "Received null filename");
FAIL_ZERO_RETURN(errctx, filename, AKERR_NULLPOINTER, "Received null filename");
ATTEMPT {
CATCH(errctx, heap_next_sprite(&obj));
//CATCH(errctx, heap_next_string(&tmpstr));
@@ -83,7 +83,7 @@ ErrorContext *sprite_load_json(char *filename)
FAIL_ZERO_BREAK(
errctx,
json,
ERR_NULLPOINTER,
AKERR_NULLPOINTER,
"Error while loading sprite from %s on line %d: %s", filename, error.line, error.text
);
@@ -119,12 +119,12 @@ ErrorContext *sprite_load_json(char *filename)
SUCCEED_RETURN(errctx);
}
ErrorContext *sprite_initialize(sprite *spr, char *name, spritesheet *sheet)
akerr_ErrorContext *sprite_initialize(sprite *spr, char *name, spritesheet *sheet)
{
PREPARE_ERROR(errctx);
FAIL_ZERO_RETURN(errctx, spr, ERR_NULLPOINTER, "Null sprite reference");
FAIL_ZERO_RETURN(errctx, name, ERR_NULLPOINTER, "Empty sprite name");
FAIL_ZERO_RETURN(errctx, sheet, ERR_NULLPOINTER, "Null spritesheet reference");
FAIL_ZERO_RETURN(errctx, spr, AKERR_NULLPOINTER, "Null sprite reference");
FAIL_ZERO_RETURN(errctx, name, AKERR_NULLPOINTER, "Empty sprite name");
FAIL_ZERO_RETURN(errctx, sheet, AKERR_NULLPOINTER, "Null spritesheet reference");
memset(spr, 0x00, sizeof(sprite));
memcpy(spr->name, name, SPRITE_MAX_NAME_LENGTH);
@@ -132,20 +132,20 @@ ErrorContext *sprite_initialize(sprite *spr, char *name, spritesheet *sheet)
FAIL_ZERO_RETURN(
errctx,
SDL_SetPointerProperty(REGISTRY_SPRITE, (char *)&spr->name, (void *)spr),
ERR_KEY,
AKERR_KEY,
"Unable to add sprite to registry");
spr->refcount += 1;
SUCCEED_RETURN(errctx);
}
ErrorContext *spritesheet_initialize(spritesheet *sheet, int sprite_w, int sprite_h, char *filename)
akerr_ErrorContext *spritesheet_initialize(spritesheet *sheet, int sprite_w, int sprite_h, char *filename)
{
PREPARE_ERROR(errctx);
//string *tmpstr = NULL;
ATTEMPT {
FAIL_ZERO_BREAK(errctx, sheet, ERR_NULLPOINTER, "Null spritesheet pointer");
FAIL_ZERO_BREAK(errctx, filename, ERR_NULLPOINTER, "Null filename pointer");
FAIL_ZERO_BREAK(errctx, sheet, AKERR_NULLPOINTER, "Null spritesheet pointer");
FAIL_ZERO_BREAK(errctx, filename, AKERR_NULLPOINTER, "Null filename pointer");
memset(sheet, 0x00, sizeof(spritesheet));
@@ -156,12 +156,12 @@ ErrorContext *spritesheet_initialize(spritesheet *sheet, int sprite_w, int sprit
//snprintf((char *)&tmpstr->data, MAX_STRING_LENGTH, "%s%s", SDL_GetBasePath(), filename);
sheet->texture = IMG_LoadTexture(renderer, filename);
FAIL_ZERO_BREAK(errctx, sheet->texture, ERR_SDL, "Failed loading asset %s : %s", filename, SDL_GetError());
FAIL_ZERO_BREAK(errctx, sheet->texture, AKERR_SDL, "Failed loading asset %s : %s", filename, SDL_GetError());
FAIL_ZERO_BREAK(
errctx,
SDL_SetPointerProperty(REGISTRY_SPRITESHEET, (char *)sheet->name, (void *)sheet),
ERR_KEY,
AKERR_KEY,
"Unable to add spritesheet to registry: %s",
SDL_GetError());
sheet->refcount += 1;