[iortcw] 88/95: All: Fix spawn/freed entity logic

Simon McVittie smcv at debian.org
Fri Sep 8 10:42:27 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to tag 1.51
in repository iortcw.

commit a350b579de6596e2eccbc3e571aaf732f121e90e
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date:   Sat Jun 3 12:01:22 2017 -0400

    All: Fix spawn/freed entity logic
    
    Not sure if it caused (or will cause) any issues
---
 MP/code/game/g_utils.c | 9 +++++++--
 SP/code/game/g_utils.c | 9 +++++++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/MP/code/game/g_utils.c b/MP/code/game/g_utils.c
index d73c138..8b38f1b 100644
--- a/MP/code/game/g_utils.c
+++ b/MP/code/game/g_utils.c
@@ -439,11 +439,11 @@ gentity_t *G_Spawn( void ) {
 			G_InitGentity( e );
 			return e;
 		}
-		if ( i != ENTITYNUM_MAX_NORMAL ) {
+		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 );
 		}
@@ -470,6 +470,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 ) {
diff --git a/SP/code/game/g_utils.c b/SP/code/game/g_utils.c
index dbd35e7..abc2149 100644
--- a/SP/code/game/g_utils.c
+++ b/SP/code/game/g_utils.c
@@ -442,11 +442,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 );
 		}
@@ -473,6 +473,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 ) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git



More information about the Pkg-games-commits mailing list