Added aliases with sizes for the integer and floating-point numbers

This commit is contained in:
abdelrahman committed 2022-11-27 15:04:34 +00:00
1 parent 45f6021f82
commit 5e6211c2a9
14 files changed
+146 -136

No files matched your search

+7 -6
View File
@@ -1,4 +1,5 @@
#include "ObjectStore.h"
#include "aliases.h"
#include "constants.h"
#include "engine_build_config.h"
#include "reusable_ids.h"
@@ -13,8 +14,8 @@
#endif /* DEBUG_ENGINE */
struct object_store {
size_t count;
size_t deleted_count;
u64 count;
u64 deleted_count;
ObjectID reusable_ids[MAX_OBJ_COUNT];
void *object_ptrs[MAX_OBJ_COUNT];
EventHandlerPtr event_handlers[MAX_OBJ_COUNT];
@@ -45,7 +46,7 @@ bool object_exists(ObjectStore *os, void *object) {
// This is a crude implementation for checking that an object has already
// been added.
// TODO (Abdelrahman): Figure out if there is a better way of doing this
for (size_t i = 0; i < MAX_OBJ_COUNT; ++i) {
for (u64 i = 0; i < MAX_OBJ_COUNT; ++i) {
if (object == os->object_ptrs[i]) {
return true;
}
@@ -68,7 +69,7 @@ ObjectID add_object_to_store(ObjectStore *os, void *object, EventHandlerPtr eh,
ObjectID id;
if (os->deleted_count > 0) {
id = (ObjectID)reuse_id((int32_t *)os->reusable_ids, os->deleted_count);
id = (ObjectID)reuse_id((i32 *)os->reusable_ids, os->deleted_count);
os->deleted_count -= 1;
os->count += 1;
} else {
@@ -115,7 +116,7 @@ void handle_all_objects_events(ObjectStore *os, const SDL_Event *event) {
}
}
void update_all_objects(ObjectStore *os, float delta) {
void update_all_objects(ObjectStore *os, f32 delta) {
if (!os || os->count == 0) {
return;
}
@@ -149,7 +150,7 @@ void destroy_object_store(ObjectStore **os) {
// TODO (Abdelrahman): Figure out if there is a better way to remove all of
// the existing objects without having to loop for the maximum number of
// objects allowed.
for (size_t i = 0; i < MAX_OBJ_COUNT; ++i) {
for (u64 i = 0; i < MAX_OBJ_COUNT; ++i) {
(*os)->object_ptrs[i] = NULL;
(*os)->event_handlers[i] = NULL;
(*os)->update_funcs[i] = NULL;