From 6e0907a6b164892aa8478b87ef3d5f2f19e1cd71 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 9 Jul 2012 15:07:34 +0900 Subject: [PATCH] Delay the "too many entities" check. Rather than checking the raw edict count in the entities file against the progs' max_edicts, check the allocated entity's number. This allows loading of sophisticated maps (eg, digs04) that prune many of their entities. --- libs/gamecode/pr_parse.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/gamecode/pr_parse.c b/libs/gamecode/pr_parse.c index 379ac2427..e9ec0e5cf 100644 --- a/libs/gamecode/pr_parse.c +++ b/libs/gamecode/pr_parse.c @@ -434,8 +434,6 @@ ED_SpawnEntities (progs_t *pr, plitem_t *entity_list) max_edicts -= *pr->num_edicts; count = PL_A_NumObjects (entity_list); - if (count > max_edicts) - PR_Error (pr, "too many entities: %d > %d", count, max_edicts); for (i = 0; i < count; i++) { entity = PL_ObjectAtIndex (entity_list, i); @@ -448,6 +446,11 @@ ED_SpawnEntities (progs_t *pr, plitem_t *entity_list) else ent = ED_Alloc (pr); + // don't allow the last edict to be used, as otherwise we can't detect + // too many edicts + if (NUM_FOR_EDICT (pr, ent) >= pr->max_edicts - 1) + PR_Error (pr, "too many entities: %d > %d", count, max_edicts); + ED_InitEntity (pr, entity, ent); // remove things from different skill levels or deathmatch