Reorganised the ObjectStore and AssetManager files

This commit is contained in:
abdelrahman committed 2023-01-02 13:08:24 +00:00
1 parent 24a86ba6e3
commit 681fa2a5dc
3 files changed
+129 -126

No files matched your search

+14 -16
View File
@@ -23,6 +23,8 @@ struct object_store {
RenderFuncPtr render_funcs[MAX_OBJ_COUNT];
};
bool object_exists(ObjectStore *os, void *object);
ObjectStore *create_object_store() {
ObjectStore *os = (ObjectStore *)malloc(sizeof(ObjectStore));
if (!os) {
@@ -42,19 +44,6 @@ ObjectStore *create_object_store() {
return os;
}
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) {
if (object == os->object_ptrs[i]) {
return true;
}
}
return false;
}
ObjectID add_object_to_store(ObjectStore *os, void *object, EventHandlerPtr eh,
UpdateFuncPtr uf, RenderFuncPtr rf) {
if (!os || !object || object_exists(os, object) ||
@@ -164,6 +153,15 @@ void destroy_object_store(ObjectStore **os) {
*os = NULL;
}
#ifdef DEBUG_ENGINE
void print_objects(ObjectStore *os) {}
#endif /* DEBUG_ENGINE */
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) {
if (object == os->object_ptrs[i]) {
return true;
}
}
return false;
}