diff options
-rw-r--r-- | world.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -1,4 +1,6 @@ #include "world.h" +#include "platform.h" +#include "error.h" void init_world(World* world) { world->entity_count = 0; @@ -7,6 +9,16 @@ void init_world(World* world) { Entity new_entity(World* world) { Entity e; +#if DEBUG + if ( + world->entity_count >= max_entities + && world->recycle_bin_count == 0 + ) { + platform_err("Too many entities.\n"); + platform_abort(error_out_of_memory); + } +#endif + e = world->recycle_bin_count > 0 ? world->recycle_bin[--world->recycle_bin_count] : |