mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-08-14 04:31:05 +00:00
add source-sdk-2013
This commit is contained in:
@@ -42,11 +42,6 @@
|
||||
#include "NextBotManager.h"
|
||||
#endif
|
||||
|
||||
// TODO Why did we add this to the base class guys.
|
||||
#if defined ( TF_DLL ) || defined ( TF_CLIENT_DLL )
|
||||
#include "player_vs_environment/tf_population_manager.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
@@ -90,8 +85,7 @@ ConVar mp_show_voice_icons( "mp_show_voice_icons", "1", FCVAR_REPLICATED, "Show
|
||||
|
||||
#ifdef GAME_DLL
|
||||
|
||||
ConVar tv_delaymapchange( "tv_delaymapchange", "0", FCVAR_NONE, "Delays map change until broadcast is complete" );
|
||||
ConVar tv_delaymapchange_protect( "tv_delaymapchange_protect", "1", FCVAR_NONE, "Protect against doing a manual map change if HLTV is broadcasting and has not caught up with a major game event such as round_end" );
|
||||
ConVar tv_delaymapchange( "tv_delaymapchange", "0", 0, "Delays map change until broadcast is complete" );
|
||||
|
||||
ConVar mp_restartgame( "mp_restartgame", "0", FCVAR_GAMEDLL, "If non-zero, game will restart in the specified number of seconds" );
|
||||
ConVar mp_restartgame_immediate( "mp_restartgame_immediate", "0", FCVAR_GAMEDLL, "If non-zero, game will restart immediately" );
|
||||
@@ -284,7 +278,7 @@ CMultiplayRules::CMultiplayRules()
|
||||
|
||||
if ( cfgfile && cfgfile[0] )
|
||||
{
|
||||
char szCommand[MAX_PATH];
|
||||
char szCommand[256];
|
||||
|
||||
Log( "Executing dedicated server config file %s\n", cfgfile );
|
||||
Q_snprintf( szCommand,sizeof(szCommand), "exec %s\n", cfgfile );
|
||||
@@ -298,7 +292,7 @@ CMultiplayRules::CMultiplayRules()
|
||||
|
||||
if ( cfgfile && cfgfile[0] )
|
||||
{
|
||||
char szCommand[MAX_PATH];
|
||||
char szCommand[256];
|
||||
|
||||
Log( "Executing listen server config file %s\n", cfgfile );
|
||||
Q_snprintf( szCommand,sizeof(szCommand), "exec %s\n", cfgfile );
|
||||
@@ -1155,22 +1149,19 @@ ConVarRef suitcharger( "sk_suitcharger" );
|
||||
}
|
||||
}
|
||||
|
||||
// Strip ' ' and '\n' characters from string.
|
||||
static void StripWhitespaceChars( char *szBuffer )
|
||||
void StripChar(char *szBuffer, const char cWhiteSpace )
|
||||
{
|
||||
char *szOut = szBuffer;
|
||||
|
||||
for ( char *szIn = szOut; *szIn; szIn++ )
|
||||
while ( char *pSpace = strchr( szBuffer, cWhiteSpace ) )
|
||||
{
|
||||
if ( *szIn != ' ' && *szIn != '\r' )
|
||||
*szOut++ = *szIn;
|
||||
char *pNextChar = pSpace + sizeof(char);
|
||||
V_strcpy( pSpace, pNextChar );
|
||||
}
|
||||
*szOut = '\0';
|
||||
}
|
||||
|
||||
void CMultiplayRules::GetNextLevelName( char *pszNextMap, int bufsize, bool bRandom /* = false */ )
|
||||
{
|
||||
char mapcfile[MAX_PATH];
|
||||
char mapcfile[256];
|
||||
DetermineMapCycleFilename( mapcfile, sizeof(mapcfile), false );
|
||||
|
||||
// Check the time of the mapcycle file and re-populate the list of level names if the file has been modified
|
||||
@@ -1188,7 +1179,10 @@ ConVarRef suitcharger( "sk_suitcharger" );
|
||||
// If map cycle file has changed or this is the first time through ...
|
||||
if ( m_nMapCycleTimeStamp != nMapCycleTimeStamp )
|
||||
{
|
||||
// Reload
|
||||
// Reset map index and map cycle timestamp
|
||||
m_nMapCycleTimeStamp = nMapCycleTimeStamp;
|
||||
m_nMapCycleindex = 0;
|
||||
|
||||
LoadMapCycleFile();
|
||||
}
|
||||
}
|
||||
@@ -1212,7 +1206,7 @@ ConVarRef suitcharger( "sk_suitcharger" );
|
||||
|
||||
void CMultiplayRules::DetermineMapCycleFilename( char *pszResult, int nSizeResult, bool bForceSpew )
|
||||
{
|
||||
static char szLastResult[ MAX_PATH ];
|
||||
static char szLastResult[ 256];
|
||||
|
||||
const char *pszVar = mapcyclefile.GetString();
|
||||
if ( *pszVar == '\0' )
|
||||
@@ -1226,7 +1220,7 @@ ConVarRef suitcharger( "sk_suitcharger" );
|
||||
return;
|
||||
}
|
||||
|
||||
char szRecommendedName[ MAX_PATH ];
|
||||
char szRecommendedName[ 256 ];
|
||||
V_sprintf_safe( szRecommendedName, "cfg/%s", pszVar );
|
||||
|
||||
// First, look for a mapcycle file in the cfg directory, which is preferred
|
||||
@@ -1277,12 +1271,7 @@ ConVarRef suitcharger( "sk_suitcharger" );
|
||||
}
|
||||
}
|
||||
|
||||
void CMultiplayRules::LoadMapCycleFileIntoVector( const char *pszMapCycleFile, CUtlVector<char *> &mapList )
|
||||
{
|
||||
CMultiplayRules::RawLoadMapCycleFileIntoVector( pszMapCycleFile, mapList );
|
||||
}
|
||||
|
||||
void CMultiplayRules::RawLoadMapCycleFileIntoVector( const char *pszMapCycleFile, CUtlVector<char *> &mapList )
|
||||
void CMultiplayRules::LoapMapCycleFileIntoVector( const char *pszMapCycleFile, CUtlVector<char *> &mapList )
|
||||
{
|
||||
CUtlBuffer buf;
|
||||
if ( !filesystem->ReadFile( pszMapCycleFile, "GAME", buf ) )
|
||||
@@ -1294,13 +1283,21 @@ ConVarRef suitcharger( "sk_suitcharger" );
|
||||
{
|
||||
bool bIgnore = false;
|
||||
|
||||
// Strip out ' ' and '\r' chars.
|
||||
StripWhitespaceChars( mapList[i] );
|
||||
// Strip out the spaces in the name
|
||||
StripChar( mapList[i] , '\r');
|
||||
StripChar( mapList[i] , ' ');
|
||||
|
||||
if ( !Q_strncmp( mapList[i], "//", 2 ) || mapList[i][0] == '\0' )
|
||||
{
|
||||
bIgnore = true;
|
||||
}
|
||||
else if ( !engine->IsMapValid( mapList[i] ) )
|
||||
{
|
||||
bIgnore = true;
|
||||
|
||||
// If the engine doesn't consider it a valid map remove it from the lists
|
||||
Warning( "Invalid map '%s' included in map cycle file. Ignored.\n", mapList[i] );
|
||||
}
|
||||
|
||||
if ( bIgnore )
|
||||
{
|
||||
@@ -1322,27 +1319,6 @@ ConVarRef suitcharger( "sk_suitcharger" );
|
||||
mapList.RemoveAll();
|
||||
}
|
||||
|
||||
bool CMultiplayRules::IsManualMapChangeOkay( const char **pszReason )
|
||||
{
|
||||
if ( HLTVDirector()->IsActive() && ( HLTVDirector()->GetDelay() >= HLTV_MIN_DIRECTOR_DELAY ) )
|
||||
{
|
||||
if ( tv_delaymapchange.GetBool() && tv_delaymapchange_protect.GetBool() )
|
||||
{
|
||||
float flLastEvent = GetLastMajorEventTime();
|
||||
if ( flLastEvent > -1 )
|
||||
{
|
||||
if ( flLastEvent > ( gpGlobals->curtime - ( HLTVDirector()->GetDelay() + 3 ) ) ) // +3 second delay to prevent instant change after a major event
|
||||
{
|
||||
*pszReason = "\n***WARNING*** Map change blocked. HLTV is broadcasting and has not caught up to the last major game event yet.\nYou can disable this check by setting the value of the server convar \"tv_delaymapchange_protect\" to 0.\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CMultiplayRules::IsMapInMapCycle( const char *pszName )
|
||||
{
|
||||
for ( int i = 0; i < m_MapList.Count(); i++ )
|
||||
@@ -1360,7 +1336,7 @@ ConVarRef suitcharger( "sk_suitcharger" );
|
||||
{
|
||||
char szNextMap[MAX_MAP_NAME];
|
||||
|
||||
if ( nextlevel.GetString() && *nextlevel.GetString() )
|
||||
if ( nextlevel.GetString() && *nextlevel.GetString() && engine->IsMapValid( nextlevel.GetString() ) )
|
||||
{
|
||||
Q_strncpy( szNextMap, nextlevel.GetString(), sizeof( szNextMap ) );
|
||||
}
|
||||
@@ -1375,19 +1351,13 @@ ConVarRef suitcharger( "sk_suitcharger" );
|
||||
|
||||
void CMultiplayRules::LoadMapCycleFile( void )
|
||||
{
|
||||
int nOldCycleIndex = m_nMapCycleindex;
|
||||
m_nMapCycleindex = 0;
|
||||
|
||||
char mapcfile[MAX_PATH];
|
||||
char mapcfile[256];
|
||||
DetermineMapCycleFilename( mapcfile, sizeof(mapcfile), false );
|
||||
|
||||
FreeMapCycleFileVector( m_MapList );
|
||||
|
||||
const int nMapCycleTimeStamp = filesystem->GetPathTime( mapcfile, "GAME" );
|
||||
m_nMapCycleTimeStamp = nMapCycleTimeStamp;
|
||||
|
||||
// Repopulate map list from mapcycle file
|
||||
LoadMapCycleFileIntoVector( mapcfile, m_MapList );
|
||||
LoapMapCycleFileIntoVector( mapcfile, m_MapList );
|
||||
|
||||
// Load server's mapcycle into network string table for client-side voting
|
||||
if ( g_pStringTableServerMapCycle )
|
||||
@@ -1408,15 +1378,37 @@ ConVarRef suitcharger( "sk_suitcharger" );
|
||||
// Search for all pop files that are prefixed with the current map name
|
||||
CUtlString sFileList;
|
||||
|
||||
CUtlVector< CUtlString > defaultPopFiles;
|
||||
CPopulationManager::FindDefaultPopulationFileShortNames( defaultPopFiles );
|
||||
char szBaseName[_MAX_PATH];
|
||||
V_snprintf( szBaseName, sizeof( szBaseName ), "scripts/population/%s*.pop", STRING(gpGlobals->mapname) );
|
||||
|
||||
FOR_EACH_VEC( defaultPopFiles, idx )
|
||||
FileFindHandle_t popHandle;
|
||||
const char *pPopFileName = filesystem->FindFirst( szBaseName, &popHandle );
|
||||
|
||||
while ( pPopFileName && pPopFileName[ 0 ] != '\0' )
|
||||
{
|
||||
sFileList += defaultPopFiles[ idx ];
|
||||
sFileList += "\n";
|
||||
// Skip it if it's a directory or is the folder info
|
||||
if ( filesystem->FindIsDirectory( popHandle ) )
|
||||
{
|
||||
pPopFileName = filesystem->FindNext( popHandle );
|
||||
continue;
|
||||
}
|
||||
|
||||
const char *pchPopPostfix = StringAfterPrefix( pPopFileName, STRING(gpGlobals->mapname) );
|
||||
if ( pchPopPostfix )
|
||||
{
|
||||
char szShortName[_MAX_PATH];
|
||||
V_strncpy( szShortName, ( ( pchPopPostfix[ 0 ] == '_' ) ? ( pchPopPostfix + 1 ) : "normal" ), sizeof( szShortName ) ); // skip the '_'
|
||||
V_StripExtension( szShortName, szShortName, sizeof( szShortName ) );
|
||||
|
||||
sFileList += szShortName;
|
||||
sFileList += '\n';
|
||||
}
|
||||
|
||||
pPopFileName = filesystem->FindNext( popHandle );
|
||||
}
|
||||
|
||||
filesystem->FindClose( popHandle );
|
||||
|
||||
if ( sFileList.Length() > 0 )
|
||||
{
|
||||
g_pStringTableServerPopFiles->AddString( CBaseEntity::IsServer(), "ServerPopFiles", sFileList.Length() + 1, sFileList.String() );
|
||||
@@ -1472,29 +1464,16 @@ ConVarRef suitcharger( "sk_suitcharger" );
|
||||
}
|
||||
#endif
|
||||
|
||||
// If the current map is in the same location in the new map cycle, keep that index. This gives better behavior
|
||||
// when reloading a map cycle that has the current map in it multiple times.
|
||||
int nOldPreviousMap = ( nOldCycleIndex == 0 ) ? ( m_MapList.Count() - 1 ) : ( nOldCycleIndex - 1 );
|
||||
if ( nOldCycleIndex >= 0 && nOldCycleIndex < m_MapList.Count() &&
|
||||
nOldPreviousMap >= 0 && nOldPreviousMap < m_MapList.Count() &&
|
||||
V_strcmp( STRING( gpGlobals->mapname ), m_MapList[ nOldPreviousMap ] ) == 0 )
|
||||
// If the current map selection is in the list, set m_nMapCycleindex to the map that follows it.
|
||||
for ( int i = 0; i < m_MapList.Count(); i++ )
|
||||
{
|
||||
// The old index is still valid, and falls after our current map in the new cycle, use it
|
||||
m_nMapCycleindex = nOldCycleIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, if the current map selection is in the list, set m_nMapCycleindex to the map that follows it.
|
||||
for ( int i = 0; i < m_MapList.Count(); i++ )
|
||||
if ( V_strcmp( STRING( gpGlobals->mapname ), m_MapList[i] ) == 0 )
|
||||
{
|
||||
if ( V_strcmp( STRING( gpGlobals->mapname ), m_MapList[i] ) == 0 )
|
||||
{
|
||||
m_nMapCycleindex = i;
|
||||
IncrementMapCycleIndex();
|
||||
break;
|
||||
}
|
||||
m_nMapCycleindex = i;
|
||||
IncrementMapCycleIndex();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CMultiplayRules::ChangeLevelToMap( const char *pszMap )
|
||||
@@ -1575,7 +1554,7 @@ ConVarRef suitcharger( "sk_suitcharger" );
|
||||
|
||||
Msg( "Skipping: %s\tNext map: %s\n", szSkippedMap, szNextMap );
|
||||
|
||||
if ( nextlevel.GetString() && *nextlevel.GetString() )
|
||||
if ( nextlevel.GetString() && *nextlevel.GetString() && engine->IsMapValid( nextlevel.GetString() ) )
|
||||
{
|
||||
Msg( "Warning! \"nextlevel\" is set to \"%s\" and will override the next map to be played.\n", nextlevel.GetString() );
|
||||
}
|
||||
@@ -1643,6 +1622,10 @@ ConVarRef suitcharger( "sk_suitcharger" );
|
||||
pPlayer->OnAchievementEarned( nAchievementID );
|
||||
}
|
||||
}
|
||||
else if ( FStrEq( pszCommand, "SendServerMapCycle" ) )
|
||||
{
|
||||
LoadMapCycleFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user