fixed some parts of arc for -Wpedantic, also fixed some entity.c wrong offsets for size
This commit is contained in:
parent
d01d78972e
commit
d89c95688e
6 changed files with 21 additions and 11 deletions
|
|
@ -25,6 +25,8 @@ typedef struct ARC_DCircle {
|
|||
double r;
|
||||
} ARC_DCircle;
|
||||
|
||||
void TEMP_Circle_Placeholder(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ void ARC_ConfigType_SpriteCopyFn(void **type, ARC_ParserTagToken *parsedData, AR
|
|||
|
||||
//really large number in case a system has 64 digit pointer addresses
|
||||
char pointerCString[64];
|
||||
sprintf(pointerCString, "%p", sprite);
|
||||
sprintf(pointerCString, "%p", (void *)sprite);
|
||||
|
||||
/* ~ spritesheet ~ */
|
||||
|
||||
|
|
@ -198,7 +198,7 @@ void ARC_ConfigType_SpriteDestroyFn(ARC_Config *config, void *type){
|
|||
|
||||
//really large number in case a system has 64 digit pointer addresses
|
||||
char pointerCString[64];
|
||||
sprintf(pointerCString, "%p", sprite);
|
||||
sprintf(pointerCString, "%p", (void *)sprite);
|
||||
|
||||
/* ~ spritesheet ~ */
|
||||
//create a name based on the type and the sprite pointer to have a unique name for cleanup on remove
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ void ARC_Renderer_CreateWithEngineData(ARC_Renderer **renderer, ARC_EngineData *
|
|||
|
||||
if((*renderer)->renderer == NULL){
|
||||
arc_errno = ARC_ERRNO_NULL;
|
||||
ARC_DEBUG_LOG_ERROR_WITH_VARIABLES("SDL_CreateRenderer(%p, NULL);", data->window);
|
||||
ARC_DEBUG_LOG_ERROR_WITH_VARIABLES("SDL_CreateRenderer(%p, NULL);", (void *)data->window);
|
||||
free(renderer);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ void ARC_Sprite_Copy(ARC_Sprite **newSprite, ARC_Sprite *oldSprite){
|
|||
}
|
||||
|
||||
void ARC_Sprite_Render(ARC_Sprite *sprite, ARC_Renderer *renderer, ARC_FRect renderBounds){
|
||||
SDL_RenderTexture(renderer->renderer, sprite->spritesheet->texture, (SDL_FRect *)(sprite->frames.data + sprite->frameIndex), (SDL_FRect *)&renderBounds);
|
||||
SDL_RenderTexture(renderer->renderer, sprite->spritesheet->texture, ((SDL_FRect *)sprite->frames.data) + sprite->frameIndex, (SDL_FRect *)&renderBounds);
|
||||
}
|
||||
|
||||
void ARC_Sprite_RenderAt(ARC_Sprite *sprite, ARC_Renderer *renderer, ARC_FPoint point, double scale){
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
#include "arc/math/circle.h"
|
||||
|
||||
void TEMP_Circle_Placeholder(void){
|
||||
}
|
||||
|
|
@ -42,6 +42,10 @@ void ARC_EntitySystem_Create(ARC_EntitySystem **entitySystem){
|
|||
|
||||
//init an empty query
|
||||
(*entitySystem)->query = NULL;
|
||||
|
||||
//add the first offset as 0
|
||||
uint32_t zero = 0;
|
||||
ARC_VectorInline_Add(((*entitySystem)->offsetVector), (void *)&zero);
|
||||
}
|
||||
|
||||
void ARC_EntitySystem_Destroy(ARC_EntitySystem *entitySystem){
|
||||
|
|
@ -76,10 +80,7 @@ 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 = 0;
|
||||
if(ARC_VectorInline_GetSize(entitySystem->offsetVector) != 0){
|
||||
totalSize = *(uint32_t *)ARC_VectorInline_Get(entitySystem->offsetVector, offsetEndIndex - 1);
|
||||
}
|
||||
uint32_t totalSize = *(uint32_t *)ARC_VectorInline_Get(entitySystem->offsetVector, offsetEndIndex - 1);
|
||||
|
||||
//if the new component size would overflow, throw an error
|
||||
if(totalSize > (~(uint32_t)0) - componentSize){
|
||||
|
|
@ -88,16 +89,18 @@ uint32_t ARC_EntitySystem_RegisterComponent(ARC_EntitySystem *entitySystem, uint
|
|||
return ~(uint32_t)0;
|
||||
}
|
||||
|
||||
//add the component size to the total size for the next offset
|
||||
totalSize += componentSize;
|
||||
|
||||
//add the component size to the total size and the offset vector array
|
||||
ARC_VectorInline_Add(entitySystem->offsetVector, &totalSize);
|
||||
ARC_VectorInline_Add(entitySystem->sizeVector , &componentSize);
|
||||
totalSize += componentSize;
|
||||
|
||||
//create the resized data vector that can now house the registered component
|
||||
ARC_VectorInline_Create(&(entitySystem->data), totalSize, NULL, NULL);
|
||||
|
||||
//get the id (last index) in the offset vector
|
||||
return ARC_VectorInline_GetSize(entitySystem->offsetVector) - 1;
|
||||
return ARC_VectorInline_GetSize(entitySystem->sizeVector) - 1;
|
||||
}
|
||||
|
||||
ARC_Entity ARC_EntitySystem_InitEntity(ARC_EntitySystem *entitySystem){
|
||||
|
|
@ -169,7 +172,8 @@ ARC_Bool ARC_EntitySystem_HasComponent(ARC_EntitySystem *entitySystem, ARC_Entit
|
|||
void *ARC_EntitySystem_GetComponentData(ARC_EntitySystem *entitySystem, ARC_Entity entity, ARC_EntityComponent component){
|
||||
//get the entity row, then offset that for the component to get the component data
|
||||
void *data = ARC_VectorInline_Get(entitySystem->data, (uint32_t)entity);
|
||||
return data + *(int32_t *)ARC_VectorInline_Get(entitySystem->offsetVector, (uint32_t)component);
|
||||
int32_t temp = *(int32_t *)ARC_VectorInline_Get(entitySystem->offsetVector, (uint32_t)component);
|
||||
return data + temp;
|
||||
}
|
||||
|
||||
ARC_Array ARC_EntitySystem_QueryComponentsData(ARC_EntitySystem *entitySystem, ARC_Array components){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue