move NULL entity registration to world initialisation
This commit is contained in:
parent
eea39b6dca
commit
764a5a09fc
@ -42,11 +42,6 @@ enum error_t entity_registry_init(struct entity_registry_t *self) {
|
|||||||
|
|
||||||
if (entities == NULL) return ERR_ALLOC;
|
if (entities == NULL) return ERR_ALLOC;
|
||||||
|
|
||||||
struct entity_registrant_t null_entity;
|
|
||||||
entity_registrant_init(&null_entity, "NULL", '0');
|
|
||||||
|
|
||||||
entities[0] = null_entity;
|
|
||||||
|
|
||||||
self->entities = entities;
|
self->entities = entities;
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,15 @@ enum error_t world_init(struct world_t *self, size_t height, size_t width) {
|
|||||||
enum error_t err = entity_registry_init(&self->registered_entities);
|
enum error_t err = entity_registry_init(&self->registered_entities);
|
||||||
if (err != ERR_OK) return err;
|
if (err != ERR_OK) return err;
|
||||||
|
|
||||||
|
struct entity_registrant_t null_entity;
|
||||||
|
err = entity_registrant_init(&null_entity, "NULL", '?');
|
||||||
|
if (err != ERR_OK) {
|
||||||
|
entity_registry_free(&self->registered_entities);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
self->registered_entities.entities[0] = null_entity;
|
||||||
|
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user