From 4006358492b800db0602ed0eca600166caec22e4 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Fri, 2 Jun 2017 21:31:38 -0500 Subject: [PATCH] Fix spawn/freed entity logic (specifically harvester skulls) - Actually use the second 'force' pass in G_Spawn when out of available slots. - Make G_EntitiesFree return qtrue if we can open a new slot. (Only used when spawning Harvester skulls.) Fixes not spawning Harvester skulls when there are no 'open freed slots', but we have other slots available to open. --- code/game/g_utils.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/code/game/g_utils.c b/code/game/g_utils.c index 41781556..bcc1200d 100644 --- a/code/game/g_utils.c +++ b/code/game/g_utils.c @@ -411,11 +411,11 @@ gentity_t *G_Spawn( void ) { G_InitGentity( e ); return e; } - if ( i != MAX_GENTITIES ) { + if ( level.num_entities < ENTITYNUM_MAX_NORMAL ) { break; } } - if ( i == ENTITYNUM_MAX_NORMAL ) { + if ( level.num_entities == ENTITYNUM_MAX_NORMAL ) { for (i = 0; i < MAX_GENTITIES; i++) { G_Printf("%4i: %s\n", i, g_entities[i].classname); } @@ -442,6 +442,11 @@ qboolean G_EntitiesFree( void ) { int i; gentity_t *e; + if ( level.num_entities < ENTITYNUM_MAX_NORMAL ) { + // can open a new slot if needed + return qtrue; + } + e = &g_entities[MAX_CLIENTS]; for ( i = MAX_CLIENTS; i < level.num_entities; i++, e++) { if ( e->inuse ) {