move NULL entity registration to world initialisation

This commit is contained in:
snit 2024-09-29 01:28:14 -05:00
parent eea39b6dca
commit 764a5a09fc
2 changed files with 9 additions and 5 deletions

View File

@ -42,11 +42,6 @@ enum error_t entity_registry_init(struct entity_registry_t *self) {
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;
return ERR_OK;
}

View File

@ -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);
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;
}