aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--world.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/world.c b/world.c
index 3b736e6..920484c 100644
--- a/world.c
+++ b/world.c
@@ -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] :