Try fix spawn on nowhere

This commit is contained in:
mittorn 2016-09-30 11:36:32 +07:00
parent 40f7666c10
commit 76bfbd3cdb
3 changed files with 32 additions and 13 deletions

View File

@ -14,7 +14,7 @@ LOCAL_MODULE_FILENAME = libserver_hardfp
endif
LOCAL_CFLAGS += -D_LINUX -DCLIENT_WEAPONS -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf \
-fno-exceptions -DNO_VOICEGAMEMGR -w
-fno-exceptions -DNO_VOICEGAMEMGR
LOCAL_CPPFLAGS := $(LOCAL_CFLAGS) -frtti

View File

@ -63,9 +63,18 @@ public:
private:
};
class CBasePlayerStart : public CPointEntity
{
public:
// prevent transition as FCAP_ACROSS_TRANSITION does not help
virtual int ObjectCaps( void ) { return CPointEntity::ObjectCaps() | FCAP_DONT_SAVE; }
private:
};
// These are the new entry points to entities.
LINK_ENTITY_TO_CLASS( info_player_deathmatch, CBaseDMStart )
LINK_ENTITY_TO_CLASS( info_player_start, CPointEntity )
LINK_ENTITY_TO_CLASS( info_player_start, CBasePlayerStart )
LINK_ENTITY_TO_CLASS( info_landmark, CPointEntity )
void CBaseDMStart::KeyValue( KeyValueData *pkvd )

View File

@ -1506,27 +1506,31 @@ bool CoopRestorePlayerCoords(CBaseEntity *player, Vector *origin, Vector *angles
return false;
}
bool CoopGetSpawnPoint( Vector *point, Vector *angles)
bool CoopGetSpawnPoint( Vector *origin, Vector *angles)
{
if(!g_SavedCoords.valid)
return false;
validateoffset();
*point = g_SavedCoords.triggerorigin + g_SavedCoords.offset;
Vector point = g_SavedCoords.triggerorigin + g_SavedCoords.offset;
*angles = g_SavedCoords.triggerangles;
if( !g_SavedCoords.validspawnpoint )
{
TraceResult tr;
Vector angle;
UTIL_MakeVectorsPrivate( *angles, (float*)&angle, NULL, NULL );
UTIL_TraceHull( *point, *point + angle * 100, missile, human_hull, NULL, &tr );
if( !tr.fStartSolid )
UTIL_TraceHull( point, point + angle * 100, missile, human_hull, NULL, &tr );
if( !tr.fStartSolid && !tr.fAllSolid )
{
g_SavedCoords.triggerorigin = tr.vecEndPos;
g_SavedCoords.validspawnpoint = true;
}
else
{
g_SavedCoords.valid = false;
return false;
}
}
*origin = point;
return true;
}
@ -1546,21 +1550,17 @@ void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator )
{
m_uTouchCount |= ENTINDEX( pActivator->edict() );
unsigned int count1 = m_uTouchCount;
unsigned int count1 = 0;
unsigned int count2 = 0;
unsigned int i = 0;
// count set bits
count1 = count1 - ((count1 >> 1) & 0x55555555);
count1 = (count1 & 0x33333333) + ((count1 >> 2) & 0x33333333);
count1 = (((count1 + (count1 >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
// loop through all clients, count number of players
for( i = 1; i <= gpGlobals->maxClients; i++ )
{
CBaseEntity *plr = UTIL_PlayerByIndex( i );
if( plr )
// count only players in the transition volume
if( plr && InTransitionVolume( plr, m_szLandmarkName ) )
{
count2++;
char *ip = g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( plr->edict() ), "ip" );
@ -1568,6 +1568,7 @@ void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator )
// player touched trigger, save it's coordinates
if( m_uTouchCount & (i - 1) )
{
count1++;
strcpy(l_SavedCoords.ip[l_SavedCoords.iCount], ip );
l_SavedCoords.origin[l_SavedCoords.iCount] = plr->pev->origin;
l_SavedCoords.angles[l_SavedCoords.iCount] = plr->pev->angles;
@ -1594,6 +1595,15 @@ void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator )
if( count1 == 1 && count2 == 2 )
return;
// check if it is near spawn point
Vector point, angles;
if( CoopGetSpawnPoint(&point, &angles ) )
if( (VecBModelOrigin(pev) - point).Length() < 200 )
// need almost all players agree to go back
if( count2 - count1 > 1 )
return;
g_SavedCoords.triggerangles = pActivator->pev->angles;
g_SavedCoords.triggerorigin = pActivator->pev->origin;
g_SavedCoords.valid = true;