Stop tracktrains that does not have players

This commit is contained in:
mittorn 2016-10-03 03:55:11 +00:00
parent 9eee0f6b89
commit e739165fdf

View File

@ -25,6 +25,7 @@
#include "cbase.h"
#include "trains.h"
#include "saverestore.h"
#include "game.h"
static void PlatSpawnInsideTrigger(entvars_t* pevPlatform);
@ -1131,6 +1132,22 @@ void CFuncTrackTrain::Next( void )
return;
}
// prevent train without players going to other map
if( mp_coop.value && pev->globalname && STRING( pev->globalname )[0] )
{
CBaseEntity *pList;
Vector mins = pev->absmin;
Vector maxs = pev->absmax;
maxs.z += 8;
int count = UTIL_EntitiesInBox( &pList, 1, mins, maxs, FL_ONGROUND );
if( !count || !pList->IsPlayer() )
{
pev->velocity = g_vecZero;
NextThink( pev->ltime + time, TRUE );
return;
}
}
UpdateSound();
Vector nextPos = pev->origin;