null entities placed out of bounds
This commit is contained in:
parent
78cd50a7f4
commit
2562d675f7
@ -12,17 +12,17 @@ int main(void) {
|
|||||||
if (err != ERR_OK) goto error;
|
if (err != ERR_OK) goto error;
|
||||||
|
|
||||||
err = world_register_entity(&world, "john", 'j');
|
err = world_register_entity(&world, "john", 'j');
|
||||||
if (err != ERR_OK) goto error_register;
|
if (err != ERR_OK) goto error_free;
|
||||||
|
|
||||||
err = world_place_entity(&world, 1, 1, 2);
|
err = world_place_entity(&world, 1, 1, 2);
|
||||||
if (err != ERR_OK) goto error_register;
|
if (err != ERR_OK) goto error_free;
|
||||||
|
|
||||||
world_print(&world);
|
world_print(&world);
|
||||||
|
|
||||||
world_free(&world);
|
world_free(&world);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error_register:
|
error_free:
|
||||||
world_free(&world);
|
world_free(&world);
|
||||||
error:
|
error:
|
||||||
printf("ERROR: %s", ERROR_STRS[err]);
|
printf("ERROR: %s", ERROR_STRS[err]);
|
||||||
|
@ -11,7 +11,11 @@ enum error_t world_init(struct world_t *self, size_t height, size_t width) {
|
|||||||
self->height = height;
|
self->height = height;
|
||||||
self->width = width;
|
self->width = width;
|
||||||
|
|
||||||
memset(self->entities, 0, MAX_ENTITIES * sizeof(struct entity_t));
|
for (size_t i = 0; i < MAX_ENTITIES; i++) {
|
||||||
|
self->entities[i].id = 0;
|
||||||
|
self->entities[i].x = self->width;
|
||||||
|
self->entities[i].y = self->height;
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user