From 76bfbd3cdb60d73e486fae3376f1737d8f1cddb7 Mon Sep 17 00:00:00 2001 From: mittorn Date: Fri, 30 Sep 2016 11:36:32 +0700 Subject: [PATCH] Try fix spawn on nowhere --- dlls/Android.mk | 2 +- dlls/subs.cpp | 11 ++++++++++- dlls/triggers.cpp | 32 +++++++++++++++++++++----------- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/dlls/Android.mk b/dlls/Android.mk index 24f03e4b..f69aa7de 100644 --- a/dlls/Android.mk +++ b/dlls/Android.mk @@ -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 diff --git a/dlls/subs.cpp b/dlls/subs.cpp index bc7baf18..6ee695d8 100644 --- a/dlls/subs.cpp +++ b/dlls/subs.cpp @@ -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 ) diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 105b8e3b..59f593d4 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -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;