removed pointless pointers in rectange, reset background clear color, fixed entity, and added some state functions

This commit is contained in:
herbglitch 2025-03-17 02:31:23 -06:00
parent dd1f3ca3e0
commit bd7e3212da
12 changed files with 161 additions and 86 deletions

View file

@ -76,7 +76,10 @@ uint32_t ARC_EntitySystem_RegisterComponent(ARC_EntitySystem *entitySystem, uint
//get the total component size
uint32_t offsetEndIndex = ARC_VectorInline_GetSize(entitySystem->offsetVector);
uint32_t totalSize = *(uint32_t *)ARC_VectorInline_Get(entitySystem->offsetVector, offsetEndIndex);
uint32_t totalSize = 0;
if(ARC_VectorInline_GetSize(entitySystem->offsetVector) != 0){
totalSize = *(uint32_t *)ARC_VectorInline_Get(entitySystem->offsetVector, offsetEndIndex);
}
//if the new component size would overflow, throw an error
if(totalSize > (~(uint32_t)0) - componentSize){
@ -120,6 +123,8 @@ ARC_Entity ARC_EntitySystem_InitEntity(ARC_EntitySystem *entitySystem){
ARC_Entity entity = (ARC_Entity)ARC_VectorInline_GetSize(entitySystem->data);
//TODO: check if this works
ARC_VectorInline_Add(entitySystem->data, NULL);
ARC_VectorInline_Add(entitySystem->flagVector, NULL);
ARC_VectorInline_Add(entitySystem->maskVector, NULL);
//set the flag to make the current entity alive
uint8_t *flagData = (uint8_t *)ARC_VectorInline_Get(entitySystem->flagVector, (uint32_t)entity);

View file

@ -90,7 +90,9 @@ void ARC_VectorInline_Add(ARC_VectorInline *vectorInline, void *data){
}
//add to the vectors array and increase its current size
memcpy(vectorInline->data + (vectorInline->currentSize * vectorInline->typeSize), data, vectorInline->typeSize);
if(data != NULL){
memcpy(vectorInline->data + (vectorInline->currentSize * vectorInline->typeSize), data, vectorInline->typeSize);
}
vectorInline->currentSize++;
}
@ -161,7 +163,7 @@ void *ARC_VectorInline_Get(ARC_VectorInline *vectorInline, uint32_t index){
//check to make sure the given index is in bounds of the vector
if(index >= vectorInline->currentSize){
arc_errno = ARC_ERRNO_DATA;
ARC_DEBUG_LOG_ERROR_WITH_VARIABLES("ARC_VectorInline_Get(vectorInline, %u), index %u bounds", index, index);
ARC_DEBUG_LOG_ERROR_WITH_VARIABLES("ARC_VectorInline_Get(vectorInline, %u), index %u out of bounds", index, index);
return NULL;
}