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

@@ -7,6 +7,7 @@
#include <sdl3game/registry.h>
#include <sdl3game/staticstring.h>
#include <sdl3game/iterator.h>
#include <sdl3game/error.h>
actor HEAP_ACTOR[MAX_HEAP_ACTOR];
sprite HEAP_SPRITE[MAX_HEAP_SPRITE];
@@ -14,10 +15,11 @@ spritesheet HEAP_SPRITESHEET[MAX_HEAP_SPRITESHEET];
character HEAP_CHARACTER[MAX_HEAP_CHARACTER];
string HEAP_STRING[MAX_HEAP_STRING];
ErrorContext *heap_init()
akerr_ErrorContext *heap_init()
{
PREPARE_ERROR(errctx);
int i = 0;
akerr_name_for_status(AKERR_SDL, "SDL Error");
for ( i = 0; i < MAX_HEAP_ACTOR; i++) {
memset(&HEAP_ACTOR[i], 0x00, sizeof(actor));
}
@@ -36,7 +38,7 @@ ErrorContext *heap_init()
SUCCEED_RETURN(errctx);
}
ErrorContext *heap_next_actor(actor **dest)
akerr_ErrorContext *heap_next_actor(actor **dest)
{
PREPARE_ERROR(errctx);
for (int i = 0; i < MAX_HEAP_ACTOR; i++ ) {
@@ -46,10 +48,10 @@ ErrorContext *heap_next_actor(actor **dest)
*dest = &HEAP_ACTOR[i];
SUCCEED_RETURN(errctx);
}
FAIL_RETURN(errctx, ERR_HEAP, "Unable to find unused actor on the heap");
FAIL_RETURN(errctx, AKERR_HEAP, "Unable to find unused actor on the heap");
}
ErrorContext *heap_next_sprite(sprite **dest)
akerr_ErrorContext *heap_next_sprite(sprite **dest)
{
PREPARE_ERROR(errctx);
for (int i = 0; i < MAX_HEAP_SPRITE; i++ ) {
@@ -59,10 +61,10 @@ ErrorContext *heap_next_sprite(sprite **dest)
*dest = &HEAP_SPRITE[i];
SUCCEED_RETURN(errctx);
}
FAIL_RETURN(errctx, ERR_HEAP, "Unable to find unused sprite on the heap");
FAIL_RETURN(errctx, AKERR_HEAP, "Unable to find unused sprite on the heap");
}
ErrorContext *heap_next_spritesheet(spritesheet **dest)
akerr_ErrorContext *heap_next_spritesheet(spritesheet **dest)
{
PREPARE_ERROR(errctx);
for (int i = 0; i < MAX_HEAP_SPRITESHEET; i++ ) {
@@ -72,10 +74,10 @@ ErrorContext *heap_next_spritesheet(spritesheet **dest)
*dest = &HEAP_SPRITESHEET[i];
SUCCEED_RETURN(errctx);
}
FAIL_RETURN(errctx, ERR_HEAP, "Unable to find unused spritesheet on the heap");
FAIL_RETURN(errctx, AKERR_HEAP, "Unable to find unused spritesheet on the heap");
}
ErrorContext *heap_next_character(character **dest)
akerr_ErrorContext *heap_next_character(character **dest)
{
PREPARE_ERROR(errctx);
for (int i = 0; i < MAX_HEAP_CHARACTER; i++ ) {
@@ -85,10 +87,10 @@ ErrorContext *heap_next_character(character **dest)
*dest = &HEAP_CHARACTER[i];
SUCCEED_RETURN(errctx);
}
FAIL_RETURN(errctx, ERR_HEAP, "Unable to find unused character on the heap");
FAIL_RETURN(errctx, AKERR_HEAP, "Unable to find unused character on the heap");
}
ErrorContext *heap_next_string(string **dest)
akerr_ErrorContext *heap_next_string(string **dest)
{
PREPARE_ERROR(errctx);
for (int i = 0; i < MAX_HEAP_STRING; i++ ) {
@@ -98,14 +100,14 @@ ErrorContext *heap_next_string(string **dest)
*dest = &HEAP_STRING[i];
SUCCEED_RETURN(errctx);
}
FAIL_RETURN(errctx, ERR_HEAP, "Unable to find unused string on the heap");
FAIL_RETURN(errctx, AKERR_HEAP, "Unable to find unused string on the heap");
}
ErrorContext *heap_release_actor(actor *ptr)
akerr_ErrorContext *heap_release_actor(actor *ptr)
{
int i = 0;
PREPARE_ERROR(errctx);
FAIL_ZERO_RETURN(errctx, ptr, ERR_NULLPOINTER, "NULL actor reference");
FAIL_ZERO_RETURN(errctx, ptr, AKERR_NULLPOINTER, "NULL actor reference");
if ( ptr->refcount > 0 ) {
ptr->refcount -= 1;
}
@@ -124,11 +126,11 @@ ErrorContext *heap_release_actor(actor *ptr)
SUCCEED_RETURN(errctx);
}
ErrorContext *heap_release_character(character *basechar)
akerr_ErrorContext *heap_release_character(character *basechar)
{
PREPARE_ERROR(errctx);
iterator opflags;
FAIL_ZERO_RETURN(errctx, basechar, ERR_NULLPOINTER, "NULL character reference");
FAIL_ZERO_RETURN(errctx, basechar, AKERR_NULLPOINTER, "NULL character reference");
BITMASK_CLEAR(opflags.flags);
BITMASK_ADD(opflags.flags, ITERATOR_OP_RELEASE);
@@ -142,10 +144,10 @@ ErrorContext *heap_release_character(character *basechar)
SUCCEED_RETURN(errctx);
}
ErrorContext *heap_release_sprite(sprite *ptr)
akerr_ErrorContext *heap_release_sprite(sprite *ptr)
{
PREPARE_ERROR(errctx);
FAIL_ZERO_RETURN(errctx, ptr, ERR_NULLPOINTER, "Received NULL sprite reference");
FAIL_ZERO_RETURN(errctx, ptr, AKERR_NULLPOINTER, "Received NULL sprite reference");
if ( ptr->refcount > 0 ) {
ptr->refcount -= 1;
}
@@ -160,10 +162,10 @@ ErrorContext *heap_release_sprite(sprite *ptr)
SUCCEED_RETURN(errctx);
}
ErrorContext *heap_release_spritesheet(spritesheet *ptr)
akerr_ErrorContext *heap_release_spritesheet(spritesheet *ptr)
{
PREPARE_ERROR(errctx);
FAIL_ZERO_RETURN(errctx, ptr, ERR_NULLPOINTER, "Received NULL spritesheet reference");
FAIL_ZERO_RETURN(errctx, ptr, AKERR_NULLPOINTER, "Received NULL spritesheet reference");
if ( ptr->refcount > 0 ) {
ptr->refcount -= 1;
}
@@ -177,10 +179,10 @@ ErrorContext *heap_release_spritesheet(spritesheet *ptr)
SUCCEED_RETURN(errctx);
}
ErrorContext *heap_release_string(string *ptr)
akerr_ErrorContext *heap_release_string(string *ptr)
{
PREPARE_ERROR(errctx);
FAIL_ZERO_RETURN(errctx, ptr, ERR_NULLPOINTER, "Received NULL string reference");
FAIL_ZERO_RETURN(errctx, ptr, AKERR_NULLPOINTER, "Received NULL string reference");
if ( ptr->refcount > 0 ) {
ptr->refcount -= 1;
}