commit 1c79e556a77612e852e3a507abfb63daf510098f Author: /dev/humancontroller Date: Tue Nov 8 19:11:40 2011 +0100 fix trigger targeting when there are "gaps" in the [targetname, targetname2, targetname3, targetname4] list diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c index 6dc67f8..dc0b1c5 100644 --- a/src/game/g_spawn.c +++ b/src/game/g_spawn.c @@ -477,12 +477,14 @@ void G_SpawnGEntityFromSpawnVars( void ) if( ent->targets[ i ] ) ent->targets[ j++ ] = ent->targets[ i ]; } + ent->targets[ j ] = NULL; j = 0; for( i = 0; i < MAX_TARGETNAMES; ++i ) { if( ent->targetnames[ i ] ) ent->targetnames[ j++ ] = ent->targetnames[ i ]; } + ent->targetnames[ j ] = NULL; // if we didn't get a classname, don't bother spawning anything if( !G_CallSpawn( ent ) ) diff --git a/src/game/g_utils.c b/src/game/g_utils.c index 894dccb..2ed4f85 100644 --- a/src/game/g_utils.c +++ b/src/game/g_utils.c @@ -184,7 +184,7 @@ gentity_t *G_Find( gentity_t *from, int fieldofs, const char *match ) /* ============= -G_FindTargets +G_TargetFind ============= */ gentity_t *G_TargetFind( gentity_t *targ, int *tIx, int *tnIx, gentity_t *self ) @@ -192,14 +192,16 @@ gentity_t *G_TargetFind( gentity_t *targ, int *tIx, int *tnIx, gentity_t *self ) if( targ ) goto cont; - for( *tIx = 0; self->targets[ *tIx ]; ++(*tIx) ) + for( targ = &g_entities[ 0 ]; targ < &g_entities[ level.num_entities ]; ++targ ) { - for( *tnIx = 0; *tnIx < MAX_TARGETNAMES; ++(*tnIx) ) + for( *tIx = 0; self->targets[ *tIx ]; ++(*tIx) ) { - cont: - targ = G_Find( targ, FOFS( targetnames[ *tnIx ] ), self->targets[ *tIx ] ); - if( targ ) - return targ; + for( *tnIx = 0; targ->targetnames[ *tnIx ]; ++(*tnIx) ) + { + if( !Q_stricmp( self->targets[ *tIx ], targ->targetnames[ *tnIx ] ) ) + return targ; + cont:; + } } }