Added a test for the entity lookup and fixed a bug found through that test.
This commit is contained in:
parent
cea20bdaa2
commit
275dbdc748
|
@ -1,2 +1,3 @@
|
|||
tests/internal/basic-tag-registry-usage
|
||||
tests/internal/entity-lookup
|
||||
tests/interface/entity-creation
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
#include <state.h>
|
||||
#include <entity.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
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);
|
||||
}
|
Reference in New Issue