changed array size to no longer be a pointer, need to check every file that references array to hopefully not have broken anything

This commit is contained in:
herbglitch 2023-07-07 00:58:23 -06:00
parent 56a4aa9d39
commit 533541b852
6 changed files with 29 additions and 24 deletions

View file

@ -265,9 +265,8 @@ uint8_t ARC_RectArray_Read(ARC_Config* config, ARC_String *string, void **value)
}
*value = malloc(sizeof(ARC_Array));
((ARC_Array *) *value)->data = malloc(sizeof(ARC_Rect) * arraySize);
((ARC_Array *) *value)->size = malloc(sizeof(uint32_t));
*((ARC_Array *) *value)->size = arraySize;
((ARC_Array *) *value)->data = malloc(sizeof(ARC_Rect) * arraySize);
((ARC_Array *) *value)->size = arraySize;
uint64_t index = 0;
arraySize = 0;
@ -291,13 +290,13 @@ uint8_t ARC_RectArray_Read(ARC_Config* config, ARC_String *string, void **value)
index = i + 1;
if(arraySize == *((ARC_Array *) *value)->size){
if(arraySize == ((ARC_Array *) *value)->size){
break;
}
}
}
if(arraySize != *((ARC_Array *) *value)->size){
if(arraySize != ((ARC_Array *) *value)->size){
ARC_RectArray_ReadRect(config, stripped, index, stripped->length - index, &arraySize, value);
}
ARC_String_Destroy(stripped);
@ -449,7 +448,7 @@ uint8_t ARC_Sprite_Read(ARC_Config* config, ARC_String *string, void **value){
// Scale frames to match spritesheet size
// TODO: possible bug for sheets that use same frames
if(spritesheet->size){
for(uint32_t i = 0; i < *frames->size; i++){
for(uint32_t i = 0; i < frames->size; i++){
((ARC_Rect *)frames->data)[i].x *= *spritesheet->size;
((ARC_Rect *)frames->data)[i].y *= *spritesheet->size;
((ARC_Rect *)frames->data)[i].w *= *spritesheet->size;

View file

@ -38,7 +38,7 @@ void ARC_Sprite_RenderRotated(ARC_Sprite *sprite, ARC_Renderer *renderer, ARC_Re
void ARC_Sprite_IterateFrame(ARC_Sprite *sprite){
++*sprite->frameIndex;
if(*sprite->frameIndex == *sprite->frames->size){
if(*sprite->frameIndex == sprite->frames->size){
*sprite->frameIndex = 0;
}
}
@ -47,4 +47,8 @@ ARC_Rect *ARC_Sprite_GetBounds(ARC_Sprite *sprite){
return (ARC_Rect *)sprite->frames->data + *sprite->frameIndex;
}
ARC_Array *ARC_Sprite_GetAllBounds(ARC_Sprite *sprite){
return sprite->frames;
}
#endif // ARC_SDL