void TestStatPanel( const CCommand &args )
{
	int iPanelType;

	if( args.ArgC() < 2 )
	{
		ConMsg( "Usage:  teststatpanel < panel type > < optional record type >\n" );
		ConMsg( "Usable panel types are %d to %d. Record types are %d to %d\n", TFSTAT_UNDEFINED + 1, TFSTAT_MAX - 1, RECORDBREAK_NONE+1, RECORDBREAK_MAX-1 );
		return;
	}

	if ( statPanel )
	{
		iPanelType = atoi( args.Arg( 1 ) );
		int iRecordType = RECORDBREAK_BEST;

		if ( args.ArgC() >= 3 )
		{
			iRecordType = atoi( args.Arg( 2 ) );
		}

		if ( ( iPanelType <= TFSTAT_UNDEFINED ) || ( iPanelType >= TFSTAT_MAX ) || (iRecordType <= RECORDBREAK_NONE) || (iRecordType >= RECORDBREAK_MAX) )
		{
			ConMsg( "Usage:  teststatpanel < panel type > < optional record type >\n" );
			ConMsg( "Usable panel types are %d to %d. Record types are %d to %d\n", TFSTAT_UNDEFINED + 1, TFSTAT_MAX - 1, RECORDBREAK_NONE+1, RECORDBREAK_MAX-1 );
			return;
		}

		statPanel->TestStatPanel( (TFStatType_t) iPanelType, (RecordBreakType_t)iRecordType );
	}
}
void CClientState::FileRequested(const char *fileName, unsigned int transferID )
{
	ConMsg( "File '%s' requested from server %s.\n", fileName, m_NetChannel->GetAddress() );

	if ( !cl_allowupload.GetBool() )
	{
		ConMsg( "File uploading disabled.\n" );
		m_NetChannel->DenyFile( fileName, transferID );
		return;
	}

	// TODO check if file valid for uploading
	m_NetChannel->SendFile( fileName, transferID );
}
Exemplo n.º 3
0
void CHLTVDemoRecorder::StartRecording( const char *filename, bool bContinuously ) 
{
	StopRecording();	// stop if we're already recording
	
	if ( !m_DemoFile.Open( filename, false ) )
	{
		ConMsg ("StartRecording: couldn't open demo file %s.\n", filename );
		return;
	}

	ConMsg ("Recording SourceTV demo to %s...\n", filename);

	demoheader_t *dh = &m_DemoFile.m_DemoHeader;

	// open demo header file containing sigondata
	Q_memset( dh, 0, sizeof(demoheader_t));

	Q_strncpy( dh->demofilestamp, DEMO_HEADER_ID, sizeof(dh->demofilestamp) );
	dh->demoprotocol = DEMO_PROTOCOL;
	dh->networkprotocol = PROTOCOL_VERSION;

	Q_strncpy( dh->mapname, hltv->GetMapName(), sizeof( dh->mapname ) );

	char szGameDir[MAX_OSPATH];
	Q_strncpy(szGameDir, com_gamedir, sizeof( szGameDir ) );
	Q_FileBase ( szGameDir, dh->gamedirectory, sizeof( dh->gamedirectory ) );

	Q_strncpy( dh->servername, host_name.GetString(), sizeof( dh->servername ) );

	Q_strncpy( dh->clientname, "SourceTV Demo", sizeof( dh->servername ) );

	// write demo file header info
	m_DemoFile.WriteDemoHeader();
	
	dh->signonlength = WriteSignonData(); // demoheader will be written when demo is closed

	m_nFrameCount = 0;

	m_nStartTick = host_tickcount;

	// Demo playback should read this as an incoming message.
	// Write the client's realtime value out so we can synchronize the reads.
	m_DemoFile.WriteCmdHeader( dem_synctick, 0 );

	m_bIsRecording = true;

	m_SequenceInfo = 1;
	m_nDeltaTick = -1;
}
Exemplo n.º 4
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CommentaryShowModelViewer( const CCommand &args )
{
	if ( args.ArgC() < 2 )
	{
		ConMsg( "Usage: commentary_showmodelviewer <model name> <optional attached model name>\n" );
		return;
	}

	CBaseViewport *pViewport = dynamic_cast<CBaseViewport *>( GetClientMode()->GetViewport() );
	if ( pViewport )
	{
		IViewPortPanel *pCommentaryPanel = pViewport->FindPanelByName( PANEL_COMMENTARY_MODELVIEWER );
		if ( !pCommentaryPanel )
		{
			pCommentaryPanel = pViewport->CreatePanelByName( PANEL_COMMENTARY_MODELVIEWER );
			pViewport->AddNewPanel( pCommentaryPanel, "PANEL_COMMENTARY_MODELVIEWER" );
		}

		if ( pCommentaryPanel )
		{
			//((CCommentaryModelViewer*)pCommentaryPanel)->InvalidateLayout( false, true );
			((CCommentaryModelViewer*)pCommentaryPanel)->SetModel( args[1], args[2] );
			pViewport->ShowPanel( pCommentaryPanel, true );
		}
	}
}
static inline void HLTV_CopyExitingEnt( CEntityReadInfo &u )
{
	if ( !u.m_bAsDelta )  // Should never happen on a full update.
	{
		Assert(0); // cl.validsequence = 0;
		ConMsg( "WARNING: CopyExitingEnt on full update.\n" );
		u.m_UpdateType = Failed;	// break out
		return;
	}

	CFrameSnapshot *pFromSnapshot =	u.m_pFrom->GetSnapshot();	// get from snapshot
	
	const int ent = u.m_nOldEntity;
	
	CFrameSnapshot *pSnapshot = u.m_pTo->GetSnapshot(); // get to snapshot
	
	// copy ent handle, serial numbers & class info
	Assert( ent < pFromSnapshot->m_nNumEntities );
	pSnapshot->m_pEntities[ent] = pFromSnapshot->m_pEntities[ent];
	
	Assert( pSnapshot->m_pEntities[ent].m_pPackedData != INVALID_PACKED_ENTITY_HANDLE );

	// increase PackedEntity reference counter
	PackedEntity *pEntity =	framesnapshotmanager->GetPackedEntity( pSnapshot, ent );
	Assert( pEntity );
	pEntity->m_ReferenceCount++;


	Assert( u.m_pTo->last_entity <= ent );
	
	// mark flags as received
	u.m_pTo->last_entity = ent;
	u.m_pTo->transmit_entity.Set( ent );
}
void CClientState::ConnectionClosing( const char * reason )
{
	// if connected, shut down host
	if ( m_nSignonState > SIGNONSTATE_NONE )
	{
		ConMsg( "Disconnect: %s.\n", reason );
		if ( !Q_stricmp( reason, INVALID_STEAM_TICKET ) )
		{
			g_eSteamLoginFailure = STEAMLOGINFAILURE_BADTICKET;
		}
		else if ( !Q_stricmp( reason, INVALID_STEAM_LOGON ) )
		{
			g_eSteamLoginFailure = STEAMLOGINFAILURE_NOSTEAMLOGIN;
		}
		else if ( !Q_stricmp( reason, INVALID_STEAM_LOGGED_IN_ELSEWHERE ) )
		{
			g_eSteamLoginFailure = STEAMLOGINFAILURE_LOGGED_IN_ELSEWHERE;
		}
		else if ( !Q_stricmp( reason, INVALID_STEAM_VACBANSTATE ) )
		{
			g_eSteamLoginFailure = STEAMLOGINFAILURE_VACBANNED;
		}
		else
		{
			g_eSteamLoginFailure = STEAMLOGINFAILURE_NONE;
		}
		COM_ExplainDisconnection( true, "Disconnect: %s.\n", reason );
		SCR_EndLoadingPlaque();
		Host_Disconnect(true);
	}
}
bool CHLTVClientState::ProcessClassInfo( SVC_ClassInfo *msg )
{
	if ( !msg->m_bCreateOnClient )
	{
		ConMsg("HLTV SendTable CRC differs from server.\n");
		Disconnect();
		return false;
	}

#ifdef _HLTVTEST
	RecvTable_Term( false );
#endif

	// Create all of the send tables locally
	DataTable_CreateClientTablesFromServerTables();

	// Now create all of the server classes locally, too
	DataTable_CreateClientClassInfosFromServerClasses( this );

	LinkClasses();	// link server and client classes
		
	if ( !RecvTable_CreateDecoders( serverGameDLL->GetStandardSendProxies() ) ) // create receive table decoders
	{
		Host_EndGame( true, "CL_ParseClassInfo_EndClasses: CreateDecoders failed.\n" );
		return false;
	}

	return true;
}
Exemplo n.º 8
0
void CHLTVDemoRecorder::StopRecording()
{
	if ( !m_bIsRecording )
		return;

	// Demo playback should read this as an incoming message.
	m_DemoFile.WriteCmdHeader( dem_stop, GetRecordingTick() );

	// update demo header info
	m_DemoFile.m_DemoHeader.playback_ticks = GetRecordingTick();
	m_DemoFile.m_DemoHeader.playback_time =  host_state.interval_per_tick *	GetRecordingTick();
	m_DemoFile.m_DemoHeader.playback_frames = m_nFrameCount;

	// write updated version
	m_DemoFile.WriteDemoHeader();

	m_DemoFile.Close();

	m_bIsRecording = false;

	// clear writing data buffer
	if ( m_MessageData.GetBasePointer() )
	{
		delete [] m_MessageData.GetBasePointer();
		m_MessageData.StartWriting( NULL, 0 );
	}
	
	ConMsg("Completed SourceTV demo \"%s\", recording time %.1f\n",
		m_DemoFile.m_szFileName,
		m_DemoFile.m_DemoHeader.playback_time );
}
Exemplo n.º 9
0
void BaseProvider::ConsolePrint(const char *str)
{
#if SOURCE_ENGINE >= SE_ORANGEBOX
	ConMsg("%s", str);
#else
	Msg("%s", str);
#endif
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CNetworkStringTable::Dump( void )
{
	ConMsg( "Table %s\n", GetTableName() );
	ConMsg( "  %i/%i items\n", GetNumStrings(), GetMaxStrings() );
	for ( int i = 0; i < GetNumStrings() ; i++ )
	{
		ConMsg( "  %i : %s\n", i, GetString( i ) );
	}
	if ( m_pItemsClientSide )
	{
		for ( int i = 0; i < (int)m_pItemsClientSide->Count() ; i++ )
		{
			ConMsg( "  %i : %s\n", i, m_pItemsClientSide->String( i ) );
		}
	}
	ConMsg( "\n" );
}
Exemplo n.º 11
0
bool CHLTVClientState::ProcessServerInfo(SVC_ServerInfo *msg )
{
	// Reset client state
	Clear();

	// is server a HLTV proxy or demo file ?
	if ( !m_pHLTV->IsPlayingBack() )
	{
		if ( !msg->m_bIsHLTV )
		{
			ConMsg ( "Server (%s) is not a SourceTV proxy.\n", m_NetChannel->GetAddress() );
			Disconnect();
			return false; 
		}	
	}

	// tell HLTV relay to clear everything
	m_pHLTV->StartRelay();

	// Process the message
	if ( !CBaseClientState::ProcessServerInfo( msg ) )
	{
		Disconnect();
		return false;
	}

	m_StringTableContainer = m_pHLTV->m_StringTables;

	Assert( m_StringTableContainer->GetNumTables() == 0); // must be empty

#ifndef SHARED_NET_STRING_TABLES
	// relay uses normal string tables without a change history
	m_StringTableContainer->EnableRollback( false );
#endif

	// copy setting from HLTV client to HLTV server 
	m_pHLTV->m_nGameServerMaxClients = m_nMaxClients;
	m_pHLTV->serverclasses		= m_nServerClasses;
	m_pHLTV->serverclassbits	= m_nServerClassBits;
	m_pHLTV->m_nPlayerSlot		= m_nPlayerSlot;
	
	// copy other settings to HLTV server
	m_pHLTV->worldmapCRC		= msg->m_nMapCRC;
	m_pHLTV->clientDllCRC		= msg->m_nClientCRC;
	m_pHLTV->m_flTickInterval	= msg->m_fTickInterval;

	host_state.interval_per_tick = msg->m_fTickInterval;
		
	Q_strncpy( m_pHLTV->m_szMapname, msg->m_szMapName, sizeof(m_pHLTV->m_szMapname) );
	Q_strncpy( m_pHLTV->m_szSkyname, msg->m_szSkyName, sizeof(m_pHLTV->m_szSkyname) );

	return true;
}
Exemplo n.º 12
0
void CHLTVClientState::RunFrame()
{
	CBaseClientState::RunFrame();

	if ( m_NetChannel && m_NetChannel->IsTimedOut() && IsConnected() )
	{
		ConMsg ("\nSourceTV connection timed out.\n");
		Disconnect();
		return;
	}

	UpdateStats();
}
Exemplo n.º 13
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : DEMOACTION - 
// Output : char const
//-----------------------------------------------------------------------------
char const *CBaseDemoAction::NameForType( DEMOACTION actionType )
{
	int idx = (int)actionType;
	if ( idx < 0 || idx >= NUM_DEMO_ACTIONS )
	{
		ConMsg( "ERROR: CBaseDemoAction::NameForType type %i out of range\n", idx );
		return g_rgDemoTypeNames[ DEMO_ACTION_UNKNOWN ].name;
	}
	
	DemoActionDictionary *entry = &g_rgDemoTypeNames[ idx ];
	Assert( entry->actiontype == actionType );

	return entry->name;
}
Exemplo n.º 14
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : DEMOACTION - 
// Output : char const
//-----------------------------------------------------------------------------
char const *CBaseDemoAction::NameForTimingType( DEMOACTIONTIMINGTYPE timingType )
{
	int idx = (int)timingType;
	if ( idx < 0 || idx >= NUM_TIMING_TYPES )
	{
		ConMsg( "ERROR: CBaseDemoAction::NameForTimingType type %i out of range\n", idx );
		return g_rgDemoTimingTypeNames[ ACTION_USES_NEITHER ].name;
	}
	
	DemoTimingTagDictionary *entry = &g_rgDemoTimingTypeNames[ idx ];
	Assert( entry->timingtype == timingType );

	return entry->name;
}
Exemplo n.º 15
0
bool CClientState::ProcessUserMessage(SVC_UserMessage *msg)
{
	// buffer for incoming user message
	byte userdata[ MAX_USER_MSG_DATA ] = { 0 };
	bf_read userMsg( "UserMessage(read)", userdata, sizeof( userdata ) );
	msg->m_DataIn.ReadBits( userdata, msg->m_nLength );
	userMsg.StartReading( userdata, Bits2Bytes( msg->m_nLength ) );

	// dispatch message to client.dll
	if ( !g_ClientDLL->DispatchUserMessage( msg->m_nMsgType, userMsg ) )
	{
		ConMsg( "Couldn't dispatch user message (%i)\n", msg->m_nMsgType );
		return false;
	}

	return true;
}
Exemplo n.º 16
0
/*
====================
//	if( r_drawtranslucentworld )
//	{
//		bSaveDrawTranslucentWorld = r_drawtranslucentworld->GetBool();
		// NOTE! : We use to set this to 0 for HDR.
		//		r_drawtranslucentworld->SetValue( 0 );
//	}
//	if( r_drawtranslucentrenderables )
R_TimeRefresh_f

For program optimization
====================
*/
void R_TimeRefresh_f (void)
{
	int			i;
	float		start, stop, time;
	CViewSetup		view;

	materials->Flush( true );

	Q_memset(&view, 0, sizeof(view));
	view.origin = MainViewOrigin();
	view.angles[0] = 0;
	view.angles[1] = 0;
	view.angles[2] = 0;
	view.x = 0;
	view.y = 0;
	view.width = videomode->GetModeWidth();
	view.height = videomode->GetModeHeight();
	view.fov = 75;
	view.fovViewmodel = 75;
	view.m_flAspectRatio = 1.0f;
	view.zNear = 4;
	view.zFar = MAX_COORD_FLOAT;
	view.zNearViewmodel = 4;
	view.zFarViewmodel = MAX_COORD_FLOAT;

	int savedeveloper = developer.GetInt();
	developer.SetValue( 0 );

	start = Sys_FloatTime ();
	for (i=0 ; i<128 ; i++)
	{
		view.angles[1] = i/128.0*360.0;
		g_ClientDLL->RenderView( view, VIEW_CLEAR_COLOR, RENDERVIEW_DRAWVIEWMODEL | RENDERVIEW_DRAWHUD );
		Shader_SwapBuffers();
	}

	materials->Flush( true );
	Shader_SwapBuffers();
	stop = Sys_FloatTime ();
	time = stop-start;

	developer.SetValue( savedeveloper );

	ConMsg ("%f seconds (%f fps)\n", time, 128/time);
}
Exemplo n.º 17
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : actionType - 
//-----------------------------------------------------------------------------
CBaseDemoAction	*CBaseDemoAction::CreateDemoAction( DEMOACTION actionType )
{
	int idx = (int)actionType;
	if ( idx < 0 || idx >= NUM_DEMO_ACTIONS )
	{
		Sys_Error( "CBaseDemoAction::AddFactory: Bogus factory type %i\n", idx );
		return NULL;
	}

	DEMOACTIONFACTORY_FUNC pfn = g_rgDemoTypeNames[ idx ].func;
	if ( !pfn )
	{
		ConMsg( "CBaseDemoAction::CreateDemoAction:  Missing factory for %s\n",
			NameForType( actionType ) );
		return NULL;
	}

	return (*pfn)();
}
Exemplo n.º 18
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : actionType - 
//			*parent - 
//			*action - 
//			newaction - 
// Output : CBaseActionEditDialog
//-----------------------------------------------------------------------------
CBaseActionEditDialog *CBaseDemoAction::CreateActionEditor( DEMOACTION actionType, CDemoEditorPanel *parent, CBaseDemoAction *action, bool newaction )
{
	int idx = (int)actionType;
	if ( idx < 0 || idx >= NUM_DEMO_ACTIONS )
	{
		Sys_Error( "CBaseDemoAction::AddFactory: Bogus factory type %i\n", idx );
		return NULL;
	}

	DEMOACTIONEDIT_FUNC pfn = g_rgDemoTypeNames[ idx ].editfunc;
	if ( !pfn )
	{
		ConMsg( "CBaseDemoAction::CreateActionEditor:  Missing edit factory for %s\n",
			NameForType( actionType ) );
		return NULL;
	}

	return (*pfn)( parent, action, newaction );
}
Exemplo n.º 19
0
//-----------------------------------------------------------------------------
// Computes the lightmap color at a particular point
//-----------------------------------------------------------------------------
static void ComputeLightmapColor( SurfaceHandle_t surfID, int ds, int dt, bool bUseLightStyles, Vector& c )
{
	msurfacelighting_t *pLighting = SurfaceLighting( surfID );

	ColorRGBExp32* pLightmap = pLighting->m_pSamples;
	if( !pLightmap )
	{
		static int messagecount = 0;
		if ( ++messagecount < 10 )
		{
			// Stop spamming. I heard you already!!!
			ConMsg( "hit surface has no samples\n" );
		}
		return;
	}

	int smax = ( pLighting->m_LightmapExtents[0] ) + 1;
	int tmax = ( pLighting->m_LightmapExtents[1] ) + 1;
	int offset = smax * tmax;
	if ( SurfHasBumpedLightmaps( surfID ) )
	{
		offset *= ( NUM_BUMP_VECTS + 1 );
	}

	pLightmap += dt * smax + ds;
	int nMaxMaps = bUseLightStyles ? MAXLIGHTMAPS : 1; 
	for (int maps = 0 ; maps < nMaxMaps && pLighting->m_nStyles[maps] != 255 ; ++maps)
	{
		float scale = LightStyleValue( pLighting->m_nStyles[maps] );

		c[0] += TexLightToLinear( pLightmap->r, pLightmap->exponent ) * scale;
		c[1] += TexLightToLinear( pLightmap->g, pLightmap->exponent ) * scale;
		c[2] += TexLightToLinear( pLightmap->b, pLightmap->exponent ) * scale;

		// Check version 32 in source safe for some debugging crap
		pLightmap += offset;
	}
}
Exemplo n.º 20
0
void CC_Mom_ZoneMark(const CCommand &args)
{
    if (!mom_zone_edit.GetBool()) return;

    CBasePlayer *pPlayer = UTIL_GetLocalPlayer();

    if (!pPlayer) return;


    int zonetype = -1;

    if (g_MapzoneEdit.GetBuildStage() >= BUILDSTAGE_END)
    {
        if (args.ArgC() > 1)
        {
            zonetype = g_MapzoneEdit.ShortNameToZoneType(args[1]);
        }
        else
        {
            zonetype = g_MapzoneEdit.ShortNameToZoneType(mom_zone_defzone.GetString());
        }

        if (zonetype == MOMZONETYPE_START || zonetype == MOMZONETYPE_STOP)
        {
            // Count zones to make sure we don't create multiple instances.
            int startnum = 0;
            int endnum = 0;

            CBaseEntity *pEnt;

            pEnt = gEntList.FindEntityByClassname(NULL, "trigger_momentum_timer_start");
            while (pEnt)
            {
                startnum++;
                pEnt = gEntList.FindEntityByClassname(pEnt, "trigger_momentum_timer_start");
            }

            pEnt = gEntList.FindEntityByClassname(NULL, "trigger_momentum_timer_stop");
            while (pEnt)
            {
                endnum++;
                pEnt = gEntList.FindEntityByClassname(pEnt, "trigger_momentum_timer_stop");
            }

            DevMsg("Found %i starts and %i ends (previous)\n", startnum, endnum);

            if (!mom_zone_ignorewarning.GetBool() && startnum && endnum)
            {
                g_MapzoneEdit.SetBuildStage(BUILDSTAGE_NONE);

                ConMsg("Map already has a start and an end! Use mom_zone_defzone to set another type.\n");

                return;
            }

            //The user is trying to make multiple starts?
            if (zonetype == MOMZONETYPE_START)
            {
                 // Switch between start and end.
                 zonetype = (startnum <= endnum) ? MOMZONETYPE_START : MOMZONETYPE_STOP;
            }
            //else the zonetype can be STOP, allowing for multiple stop triggers to be created
        }
    }

    trace_t tr;
    Vector vecFwd;

    AngleVectors(pPlayer->EyeAngles(), &vecFwd);

    UTIL_TraceLine(pPlayer->EyePosition(), pPlayer->EyePosition() + vecFwd * g_MapzoneEdit.GetZoom(), MASK_PLAYERSOLID, pPlayer, COLLISION_GROUP_NONE, &tr);


    g_MapzoneEdit.Build(&tr.endpos, zonetype);
}
Exemplo n.º 21
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CGameServer::DumpPrecacheStats( INetworkStringTable *table )
{
	if ( table == NULL )
	{
		ConMsg( "Can only dump stats when active in a level\n" );
		return;
	}

	CPrecacheItem *items = NULL;
	if ( table == m_pModelPrecacheTable )
	{
		items = model_precache;
	}
	else if ( table == m_pGenericPrecacheTable )
	{
		items = generic_precache;
	}
	else if ( table == m_pSoundPrecacheTable )
	{
		items = sound_precache;
	}
	else if ( table == m_pDecalPrecacheTable )
	{
		items = decal_precache;
	}

	if ( !items )
		return;

	int count = table->GetNumStrings();
	int maxcount = table->GetMaxStrings();

	ConMsg( "\n" );
	ConMsg( "Precache table %s:  %i of %i slots used\n", table->GetTableName(),
		count, maxcount );

	for ( int i = 0; i < count; i++ )
	{
		char const *name = table->GetString( i );
		CPrecacheItem *slot = &items[ i ];
		
		int testLength;
		const CPrecacheUserData *p = ( const CPrecacheUserData * )table->GetStringUserData( i, &testLength );
		ErrorIfNot( testLength == sizeof( *p ),
			("CGameServer::DumpPrecacheStats: invalid CPrecacheUserData length (%d)", testLength)
		);

		if ( !name || !slot || !p )
			continue;

		ConMsg( "%03i:  %s (%s):   ",
			i,
			name, 
			GetFlagString( p->flags ) );

		if ( slot->GetReferenceCount() == 0 )
		{
			ConMsg( " never used\n" );
		}
		else
		{
			ConMsg( " %i refs, first %.2f mru %.2f\n",
				slot->GetReferenceCount(), 
				slot->GetFirstReference(), 
				slot->GetMostRecentReference() );
		}
	}

	ConMsg( "\n" );
}
Exemplo n.º 22
0
//-----------------------------------------------------------------------------
// Host_Stats_f - prints out interesting stats about the server...
//-----------------------------------------------------------------------------
void Host_Stats_f (void)
{
	char stats[512];
	g_ServerRemoteAccess.GetStatsString(stats, sizeof(stats));
	ConMsg("CPU   In    Out   Uptime  Users   FPS    Players\n%s\n", stats);
}
Exemplo n.º 23
0
void SetMaster_f( const CCommand &args )
{
	if ( IsUsingMasterLegacyMode() )
	{
		master->SetMaster_Legacy_f( args );
		return;
	}
#ifndef NO_STEAM
	ISteamMasterServerUpdater *s = SteamMasterServerUpdater();
#else
	ISteamMasterServerUpdater *s = NULL;
#endif
	if ( !s )
		return;	
	
	char szMasterAddress[128]; // IP:Port string of master
	const char *pszCmd = NULL;
	
	int count = args.ArgC();

	// Usage help
	if ( count < 2 )
	{
		ConMsg("Usage:\nsetmaster <add | remove | enable | disable> <IP:port>\n");

		if ( s->GetNumMasterServers() == 0 )
		{
			ConMsg("Current:  None\n");
		}
		else
		{
			ConMsg("Current:\n");

			for ( int i=0; i < s->GetNumMasterServers(); i++ )
			{
				char szAdr[512];
				if ( s->GetMasterServerAddress( i, szAdr, sizeof( szAdr ) ) != 0 )
					ConMsg( "  %i:  %s\n", i+1, szAdr );
			}
		}
		
		return;
	}

	pszCmd = args[1];
	if ( !pszCmd || !pszCmd[0] )
		return;

	// Check for disabling...
	if ( !Q_stricmp( pszCmd, "disable") )
	{
		g_bEnableMasterServerUpdater = false;
	}
	else if (!Q_stricmp( pszCmd, "enable") )
	{
		g_bEnableMasterServerUpdater = true;
	}
	else if ( !Q_stricmp( pszCmd, "add" ) || !Q_stricmp( pszCmd, "remove" ) )
	{
		// Figure out what they want to do.
		// build master address
		szMasterAddress[0] = 0;

		for ( int i= 2; i<count; i++ )
		{
			Q_strcat( szMasterAddress, args[i], sizeof( szMasterAddress ) );
		}

		if ( !Q_stricmp( pszCmd, "add" ) )
		{
			if ( s->AddMasterServer( szMasterAddress ) )
			{
				ConMsg ( "Adding master at %s\n", szMasterAddress );
			}
			else
			{
				ConMsg ( "Master at %s already in list\n", szMasterAddress );
			}

			// If we get here, masters are definitely being used.
			g_bEnableMasterServerUpdater = true;
		}
		else
		{
			// Find master server
			if ( !s->RemoveMasterServer( szMasterAddress ) )
			{
				ConMsg( "Can't remove master %s, not in list\n", szMasterAddress );
			}
		}
	}
	else
	{
		ConMsg( "Invalid setmaster command\n" );
	}
	
	// Resend the rules just in case we added a new server.
	sv.SetMasterServerRulesDirty();
}
Exemplo n.º 24
0
static SpewRetval_t _SpewMessage( SpewType_t spewType, const char *pGroupName, int nLevel, const Color *pColor, const tchar* pMsgFormat, va_list args )
{
	tchar pTempBuffer[5020];

	assert( _tcslen( pMsgFormat ) < sizeof( pTempBuffer) ); // check that we won't artifically truncate the string

	/* Printf the file and line for warning + assert only... */
	int len = 0;
	if ((spewType == SPEW_ASSERT) )
	{
		len = _sntprintf( pTempBuffer, sizeof( pTempBuffer ) - 1, _T("%s (%d) : "), s_pFileName, s_Line );
	}

	if ( len == -1 )
		return SPEW_ABORT;
	
	/* Create the message.... */
	int val= _vsntprintf( &pTempBuffer[len], sizeof( pTempBuffer ) - len - 1, pMsgFormat, args );
	if ( val == -1 )
		return SPEW_ABORT;

	len += val;
	assert( len * sizeof(*pMsgFormat) < sizeof(pTempBuffer) ); /* use normal assert here; to avoid recursion. */

	// Add \n for warning and assert
	if ((spewType == SPEW_ASSERT) )
	{
		len += _stprintf( &pTempBuffer[len], _T("\n") ); 
	}
	
	assert( len < sizeof(pTempBuffer)/sizeof(pTempBuffer[0]) - 1 ); /* use normal assert here; to avoid recursion. */
	assert( s_SpewOutputFunc );
	
	/* direct it to the appropriate target(s) */
	SpewRetval_t ret;
	assert( g_pSpewInfo == NULL );
	SpewInfo_t spewInfo =
	{
		pColor,
		pGroupName,
		nLevel
	};

	g_pSpewInfo = &spewInfo;
	ret = s_SpewOutputFunc( spewType, pTempBuffer );
	g_pSpewInfo = NULL;

	switch (ret)
	{
// Asserts put the break into the macro so it occurs in the right place
	case SPEW_DEBUGGER:
		if ( spewType != SPEW_ASSERT )
		{
			DebuggerBreak();
		}
		break;
		
	case SPEW_ABORT:
//		MessageBox(NULL,"Error in _SpewMessage","Error",MB_OK);
		ConMsg( _T("Exiting on SPEW_ABORT\n") );
		exit(0);
	}

	return ret;
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *value - 
// Output : int
//-----------------------------------------------------------------------------
int CNetworkStringTable::AddString( bool bIsServer, const char *string, int length /*= -1*/, const void *userdata /*= NULL*/ )
{
	bool bHasChanged;
	CNetworkStringTableItem *item;
	
	if ( !string )
	{
		Assert( string );
		ConMsg( "Warning:  Can't add NULL string to table %s\n", GetTableName() );
		return INVALID_STRING_INDEX;
	}

#ifdef _DEBUG
	if ( m_bLocked )
	{
		DevMsg("Warning! CNetworkStringTable::AddString: adding '%s' while locked.\n", string );
	}
#endif

	int i = m_pItems->Find( string );
	if ( !bIsServer )
	{
		if ( m_pItems->IsValidIndex( i ) && !m_pItemsClientSide )
		{
			bIsServer = true;
		}
	}

	if ( !bIsServer && m_pItemsClientSide )
	{
		i = m_pItemsClientSide->Find( string );

		if ( !m_pItemsClientSide->IsValidIndex( i ) )
		{
			// not in list yet, create it now
			if ( m_pItemsClientSide->Count() >= (unsigned int)GetMaxStrings() )
			{
				// Too many strings, FIXME: Print warning message
				ConMsg( "Warning:  Table %s is full, can't add %s\n", GetTableName(), string );
				return INVALID_STRING_INDEX;
			}

			// create new item
			{
			MEM_ALLOC_CREDIT();
			i = m_pItemsClientSide->Insert( string );
			}

			item = &m_pItemsClientSide->Element( i );

			// set changed ticks

			item->m_nTickChanged = m_nTickCount;

	#ifndef	SHARED_NET_STRING_TABLES
			item->m_nTickCreated = m_nTickCount;

			if ( m_bChangeHistoryEnabled )
			{
				item->EnableChangeHistory();
			}
	#endif

			bHasChanged = true;
		}
		else
		{
			item = &m_pItemsClientSide->Element( i ); // item already exists
			bHasChanged = false;  // not changed yet
		}

		if ( length > -1 )
		{
			if ( item->SetUserData( m_nTickCount, length, userdata ) )
			{
				bHasChanged = true;
			}
		}

		if ( bHasChanged && !m_bChangeHistoryEnabled )
		{
			DataChanged( -i, item );
		}

		// Negate i for returning to client
		i = -i;
	}
	else
	{
		// See if it's already there
		i = m_pItems->Find( string );

		if ( !m_pItems->IsValidIndex( i ) )
		{
			// not in list yet, create it now
			if ( m_pItems->Count() >= (unsigned int)GetMaxStrings() )
			{
				// Too many strings, FIXME: Print warning message
				ConMsg( "Warning:  Table %s is full, can't add %s\n", GetTableName(), string );
				return INVALID_STRING_INDEX;
			}

			// create new item
			{
			MEM_ALLOC_CREDIT();
			i = m_pItems->Insert( string );
			}

			item = &m_pItems->Element( i );

			// set changed ticks

			item->m_nTickChanged = m_nTickCount;

	#ifndef	SHARED_NET_STRING_TABLES
			item->m_nTickCreated = m_nTickCount;

			if ( m_bChangeHistoryEnabled )
			{
				item->EnableChangeHistory();
			}
	#endif

			bHasChanged = true;
		}
		else
		{
			item = &m_pItems->Element( i ); // item already exists
			bHasChanged = false;  // not changed yet
		}

		if ( length > -1 )
		{
			if ( item->SetUserData( m_nTickCount, length, userdata ) )
			{
				bHasChanged = true;
			}
		}

		if ( bHasChanged && !m_bChangeHistoryEnabled )
		{
			DataChanged( i, item );
		}
	}

	return i;
}
Exemplo n.º 26
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void ConVar_PrintDescription( const ConCommandBase *pVar )
{
	bool bMin, bMax;
	float fMin, fMax;
	const char *pStr;

	assert( pVar );

	Color clr;
	clr.SetColor( 255, 100, 100, 255 );

	if ( !pVar->IsCommand() )
	{
		ConVar *var = ( ConVar * )pVar;
		const ConVar_ServerBounded *pBounded = dynamic_cast<const ConVar_ServerBounded*>( var );

		bMin = var->GetMin( fMin );
		bMax = var->GetMax( fMax );

		const char *value = NULL;
		char tempVal[ 32 ];

		if ( pBounded || var->IsFlagSet( FCVAR_NEVER_AS_STRING ) )
		{
			value = tempVal;
			
			int intVal = pBounded ? pBounded->GetInt() : var->GetInt();
			float floatVal = pBounded ? pBounded->GetFloat() : var->GetFloat();

			if ( fabs( (float)intVal - floatVal ) < 0.000001 )
			{
				Q_snprintf( tempVal, sizeof( tempVal ), "%d", intVal );
			}
			else
			{
				Q_snprintf( tempVal, sizeof( tempVal ), "%f", floatVal );
			}
		}
		else
		{
			value = var->GetString();
		}

		if ( value )
		{
			ConColorMsg( clr, "\"%s\" = \"%s\"", var->GetName(), value );

			if ( stricmp( value, var->GetDefault() ) )
			{
				ConMsg( " ( def. \"%s\" )", var->GetDefault() );
			}
		}

		if ( bMin )
		{
			ConMsg( " min. %f", fMin );
		}
		if ( bMax )
		{
			ConMsg( " max. %f", fMax );
		}

		ConMsg( "\n" );

		// Handled virtualized cvars.
		if ( pBounded && fabs( pBounded->GetFloat() - var->GetFloat() ) > 0.0001f )
		{
			ConColorMsg( clr, "** NOTE: The real value is %.3f but the server has temporarily restricted it to %.3f **\n",
				var->GetFloat(), pBounded->GetFloat() );
		}
	}
	else
	{
		ConCommand *var = ( ConCommand * )pVar;

		ConColorMsg( clr, "\"%s\"\n", var->GetName() );
	}

	ConVar_PrintFlags( pVar );

	pStr = pVar->GetHelpText();
	if ( pStr && pStr[0] )
	{
		ConMsg( " - %s\n", pStr );
	}
}
Exemplo n.º 27
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void ConVar_PrintFlags( const ConCommandBase *var )
{
	bool any = false;
	if ( var->IsFlagSet( FCVAR_GAMEDLL ) )
	{
		ConMsg( " game" );
		any = true;
	}

	if ( var->IsFlagSet( FCVAR_CLIENTDLL ) )
	{
		ConMsg( " client" );
		any = true;
	}

	if ( var->IsFlagSet( FCVAR_ARCHIVE ) )
	{
		ConMsg( " archive" );
		any = true;
	}

	if ( var->IsFlagSet( FCVAR_NOTIFY ) )
	{
		ConMsg( " notify" );
		any = true;
	}

	if ( var->IsFlagSet( FCVAR_SPONLY ) )
	{
		ConMsg( " singleplayer" );
		any = true;
	}

	if ( var->IsFlagSet( FCVAR_NOT_CONNECTED ) )
	{
		ConMsg( " notconnected" );
		any = true;
	}

	if ( var->IsFlagSet( FCVAR_CHEAT ) )
	{
		ConMsg( " cheat" );
		any = true;
	}

	if ( var->IsFlagSet( FCVAR_REPLICATED ) )
	{
		ConMsg( " replicated" );
		any = true;
	}

	if ( var->IsFlagSet( FCVAR_SERVER_CAN_EXECUTE ) )
	{
		ConMsg( " server_can_execute" );
		any = true;
	}

	if ( var->IsFlagSet( FCVAR_CLIENTCMD_CAN_EXECUTE ) )
	{
		ConMsg( " clientcmd_can_execute" );
		any = true;
	}

	if ( any )
	{
		ConMsg( "\n" );
	}
}
Exemplo n.º 28
0
void CGameClient::FileDenied(const char *fileName, unsigned int transferID )
{
	ConMsg( "Downloading file '%s' from client %s failed.\n", fileName, GetClientName() );
}
Exemplo n.º 29
0
static int luasrc_ConMsg (lua_State *L) {
  ConMsg(luaL_checkstring(L, 1));
  return 0;
}