diff --git a/core/build-config/tests.txt b/core/build-config/tests.txt index b8284b4..75929d2 100644 --- a/core/build-config/tests.txt +++ b/core/build-config/tests.txt @@ -1,2 +1,3 @@ tests/internal/basic-tag-registry-usage +tests/internal/entity-lookup tests/interface/entity-creation \ No newline at end of file diff --git a/core/inc-c/state.h b/core/inc-c/state.h index f929dfc..1458d6b 100644 --- a/core/inc-c/state.h +++ b/core/inc-c/state.h @@ -23,6 +23,6 @@ void mt_cleanup(MtState *state); void mt_start(MtState *state); MtEntity * mt_summon(MtState *state); -void mt_delete(MtEntity *entity); +void mt_drop(MtEntity *entity); #endif // MT_STATE_H diff --git a/core/src-c/entity_lookup.c b/core/src-c/entity_lookup.c index 4dd78c2..13dd34e 100644 --- a/core/src-c/entity_lookup.c +++ b/core/src-c/entity_lookup.c @@ -31,6 +31,7 @@ MtEntity * mt_create_entity(void *state_voidptr, u32_t identifier) { entity = mt_allocate_entity_pool_slot(&state->entity_registry.pool); entity->parent_state = state; + entity->identifier = identifier; level3->entities[identifier & 0xff] = entity; } return entity; diff --git a/core/tests/internal/entity-lookup/main.c b/core/tests/internal/entity-lookup/main.c new file mode 100644 index 0000000..9269386 --- /dev/null +++ b/core/tests/internal/entity-lookup/main.c @@ -0,0 +1,19 @@ +#include +#include + +#include + +int main(int argc, char **argv) +{ + MtState *state = mt_initialize("Interface Test");; + MtEntity *entity = mt_summon(state); + MtEntity *looked_up_entity = mt_get_entity(state, entity->identifier); + + if(entity != looked_up_entity) + printf("Failed looking up entity; the pointers don't match:\nOriginal: %p\nLooked Up: %p\n", entity, looked_up_entity); + else + puts("The entity which was looked up from the identifier does match the original. SUCCESS!"); + + mt_drop(entity); + mt_cleanup(state); +} \ No newline at end of file