本文整理汇总了C++中ConVarRef::IsValid方法的典型用法代码示例。如果您正苦于以下问题:C++ ConVarRef::IsValid方法的具体用法?C++ ConVarRef::IsValid怎么用?C++ ConVarRef::IsValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConVarRef
的用法示例。
在下文中一共展示了ConVarRef::IsValid方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LevelInit
void ClientModeHLNormal::LevelInit( const char *newmap )
{
// reset ambient light
static ConVarRef mat_ambient_light_r( "mat_ambient_light_r" );
static ConVarRef mat_ambient_light_g( "mat_ambient_light_g" );
static ConVarRef mat_ambient_light_b( "mat_ambient_light_b" );
if ( mat_ambient_light_r.IsValid() )
{
mat_ambient_light_r.SetValue( "0" );
}
if ( mat_ambient_light_g.IsValid() )
{
mat_ambient_light_g.SetValue( "0" );
}
if ( mat_ambient_light_b.IsValid() )
{
mat_ambient_light_b.SetValue( "0" );
}
BaseClass::LevelInit(newmap);
// sdk: make sure no windows are left open from before
SDK_CloseAllWindows();
// clear any DSP effects
CLocalPlayerFilter filter;
enginesound->SetRoomType( filter, 0 );
enginesound->SetPlayerDSP( filter, 0, true );
}
示例2: BlackBox_Record
void BlackBox_Record( const char *type, const char *pFormat, ... )
{
static ConVarRef blackbox( "blackbox" );
if ( IsX360() )
return;
if ( !blackbox.IsValid() || !blackbox.GetBool() )
return;
int type_num;
for ( type_num = 0; type_num < blackboxrecorder->GetTypeCount(); type_num++ )
{
if ( !V_strcasecmp( blackboxrecorder->GetTypeName( type_num ), type ) )
break;
}
if ( type_num >= blackboxrecorder->GetTypeCount() )
{
Msg( "Invalid blackbox type: %s\n", type );
return;
}
char szMessage[1024];
va_list marker;
va_start( marker, pFormat);
Q_vsnprintf( szMessage, sizeof( szMessage ), pFormat, marker);
va_end( marker );
//Msg( "Record: %s: %s\n", type, szMessage );
blackboxrecorder->Record( type_num, szMessage );
}
示例3: LevelInit
//====================================================================
// Prepara al Cliente para el inicio de un nivel
//====================================================================
void InClientMode::LevelInit( const char *newmap )
{
// Reiniciamos la luz de ambiente
static ConVarRef mat_ambient_light_r( "mat_ambient_light_r" );
static ConVarRef mat_ambient_light_g( "mat_ambient_light_g" );
static ConVarRef mat_ambient_light_b( "mat_ambient_light_b" );
if ( mat_ambient_light_r.IsValid() )
mat_ambient_light_r.SetValue( "0" );
if ( mat_ambient_light_g.IsValid() )
mat_ambient_light_g.SetValue( "0" );
if ( mat_ambient_light_b.IsValid() )
mat_ambient_light_b.SetValue( "0" );
BaseClass::LevelInit( newmap );
// clear any DSP effects
CLocalPlayerFilter filter;
enginesound->SetRoomType( filter, 0 );
enginesound->SetPlayerDSP( filter, 0, true );
}
示例4: RenderVideo
void CReplayRenderer::RenderVideo()
{
#if _DEBUG
static ConVarRef replay_fake_render( "replay_fake_render" );
if ( replay_fake_render.IsValid() && replay_fake_render.GetBool() )
return;
#endif
if ( !engine->IsInGame() )
return;
if ( !m_LayoffResult.IsValid() )
return;
CompositeAndLayoffFrame( m_nFrame++ );
}
示例5: DoClick
//-----------------------------------------------------------------------------
// Purpose: Activate a button click.
//-----------------------------------------------------------------------------
void Button::DoClick()
{
SetSelected(true);
FireActionSignal();
PlayButtonReleasedSound();
static ConVarRef vgui_nav_lock( "vgui_nav_lock" );
if ( ( !vgui_nav_lock.IsValid() || vgui_nav_lock.GetInt() == 0 ) && NavigateActivate() )
{
vgui_nav_lock.SetValue( 1 );
}
if ( !m_bStaySelectedOnClick )
{
SetSelected(false);
}
}
示例6: OnCompletedAsyncDeviceAttached
//=============================================================================
void CUIGameData::OnCompletedAsyncDeviceAttached( CAsyncCtxUIOnDeviceAttached * job )
{
ISelectStorageDeviceClient *pStorageDeviceClient = m_pSelectStorageClient;
m_pSelectStorageClient = NULL;
static ConVarRef mm_dlcs_mask_extras( "mm_dlcs_mask_extras" );
if ( mm_dlcs_mask_extras.IsValid() )
{
#ifdef _X360
int iDLCmask = mm_dlcs_mask_extras.GetInt();
if ( engine->IsLowViolence() && XGetGameRegion() == XC_GAME_REGION_EUROPE_REST )
{
// iDLCmask |= ( 1 << ? );
}
mm_dlcs_mask_extras.SetValue( iDLCmask );
#endif
}
uint nRet = job ? job->GetContainerOpenResult() : ERROR_SUCCESS;
if ( nRet != ERROR_SUCCESS )
{
CloseWaitScreen( NULL, "ReportDeviceCorrupt" );
pStorageDeviceClient->OnDeviceFail( ISelectStorageDeviceClient::FAIL_CORRUPT );
}
else
{
// Notify that data has loaded
pStorageDeviceClient->AfterDeviceMounted();
// Check for opening a new storage device immediately
if ( m_pSelectStorageClient == NULL )
{
// Close down the waiting screen
CloseWaitScreen( NULL, "OnCompletedAsyncDeviceAttached" );
}
}
}
示例7: webspec_callback
//=================================================================================
// Callback for the 'webspec' protocol
// Manages spectator connections & sending Initial messages to new spectators
//=================================================================================
int webspec_callback(struct libwebsocket_context *ctx, struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, void *user, void *in, size_t len)
{
switch (reason) {
case LWS_CALLBACK_ESTABLISHED:
{
Msg("[WS] New connection\n");
// New connection
ws_spectators.AddToTail(wsi);
// Send basic game info to let client set up
// MapName, Server name (may remove), current team names
char *buffer = (char*)malloc(MAX_BUFFER_SIZE);
char *mapName = (char*) STRING(gpGlobals->mapname);
ConVarRef hostNameCVar = ConVarRef("hostname");
string_t hostname;
if (hostNameCVar.IsValid())
hostname = MAKE_STRING(hostNameCVar.GetString());
else
hostname = MAKE_STRING("WebSpec Demo Server"); //Can't imagine when hostname would be invalid, but this is Source
int length = snprintf(buffer, MAX_BUFFER_SIZE, "%c%s:%s:%s:%s", WSPacket_Init, mapName, STRING(hostname), STRING(ws_teamName[1]), STRING(ws_teamName[0]));
SendPacketToOne(buffer, length, wsi);
free(buffer);
//Send connected players
IPlayerInfo *playerInfo;
for (int i=1; i<=gpGlobals->maxClients; i++) {
playerInfo = playerInfoManager->GetPlayerInfo(engine->PEntityOfEntIndex(i));
if (playerInfo != NULL && playerInfo->IsConnected()) {
buffer = (char *)malloc(MAX_BUFFER_SIZE);
int userid = playerInfo->GetUserID();
int teamid = playerInfo->GetTeamIndex();
int health = playerInfo->GetHealth();
int maxHealth = playerInfo->GetMaxHealth();
bool alive = !playerInfo->IsDead();
string_t playerName = MAKE_STRING(playerInfo->GetName());
//Pointer magic to get TF2 class
CBaseEntity *playerEntity = serverGameEnts->EdictToBaseEntity(engine->PEntityOfEntIndex(i));
int playerClass = *MakePtr(int*, playerEntity, WSOffsets::pCTFPlayer__m_iClass);
float uberCharge = 0.0f;
if (playerClass == TFClass_Medic) {
//Way more pointer magic to get ubercharge from medigun
CBaseCombatCharacter *playerCombatCharacter = CBaseEntity_MyCombatCharacterPointer(playerEntity);
CBaseCombatWeapon *slot1Weapon = CBaseCombatCharacter_Weapon_GetSlot(playerCombatCharacter, 1);
uberCharge = *MakePtr(float*, slot1Weapon, WSOffsets::pCWeaponMedigun__m_flChargeLevel);
}
int length = snprintf(buffer, MAX_BUFFER_SIZE, "%c%d:%d:%d:%d:%d:%d:0:%d:%s", 'C', userid, teamid, playerClass,
health, maxHealth, alive, Round(uberCharge*100.0f), STRING(playerName));
SendPacketToOne(buffer, length, wsi);
free(buffer);
}
}
break;
}
示例8: WriteSaveData
//=========================================================
//=========================================================
bool C_GameInstructor::WriteSaveData()
{
if ( engine->IsPlayingDemo() )
return false;
if ( !m_bDirtySaveData )
return true;
#ifdef _X360
float flPlatTime = Plat_FloatTime();
static ConVarRef host_write_last_time( "host_write_last_time" );
if ( host_write_last_time.IsValid() )
{
float flTimeSinceLastWrite = flPlatTime - host_write_last_time.GetFloat();
if ( flTimeSinceLastWrite < 3.5f )
{
// Prevent writing to the same storage device twice in less than 3 second succession for TCR success!
// This happens after leaving a game in splitscreen.
//DevMsg( "Waiting to write Game Instructor for splitscreen slot %d... (%.1f seconds remain)\n", m_nSplitScreenSlot, 3.5f - flTimeSinceLastWrite );
return false;
}
}
#endif
// Always mark as clean state to avoid re-entry on
// subsequent frames when storage device might be
// in a yet-unmounted state.
m_bDirtySaveData = false;
#ifdef _X360
DevMsg( "Write Game Instructor for splitscreen slot %d at time: %.1f\n", m_nSplitScreenSlot, flPlatTime );
if ( m_nSplitScreenSlot < 0 )
return false;
if ( m_nSplitScreenSlot >= (int) XBX_GetNumGameUsers() )
return false;
int iController = XBX_GetUserId( m_nSplitScreenSlot );
if ( iController < 0 || XBX_GetUserIsGuest( iController ) )
{
// Can't save data for guests
return false;
}
DWORD nStorageDevice = XBX_GetStorageDeviceId( iController );
if ( !XBX_DescribeStorageDevice( nStorageDevice ) )
return false;
#endif
// Build key value data to save
KeyValues *data = new KeyValues( "Game Instructor Counts" );
KeyValues::AutoDelete autoDelete(data);
for ( int i = 0; i < m_Lessons.Count(); ++i )
{
CBaseLesson *pLesson = m_Lessons[i];
int iDisplayCount = pLesson->GetDisplayCount();
int iSuccessCount = pLesson->GetSuccessCount();
if ( iDisplayCount || iSuccessCount )
{
// We've got some data worth saving
KeyValues *pKVData = new KeyValues( pLesson->GetName() );
if ( iDisplayCount )
pKVData->SetInt( "display", iDisplayCount );
if ( iSuccessCount )
pKVData->SetInt( "success", iSuccessCount );
data->AddSubKey( pKVData );
}
}
// Save it!
CUtlBuffer buf( 0, 0, CUtlBuffer::TEXT_BUFFER );
data->RecursiveSaveToFile( buf, 0 );
char szFilename[_MAX_PATH];
#ifdef _X360
if ( IsX360() )
{
XBX_MakeStorageContainerRoot( iController, XBX_USER_SETTINGS_CONTAINER_DRIVE, szFilename, sizeof( szFilename ) );
int nLen = strlen( szFilename );
Q_snprintf( szFilename + nLen, sizeof( szFilename ) - nLen, ":\\game_instructor_counts.txt" );
}
else
#endif
{
Q_snprintf( szFilename, sizeof( szFilename ), "save/game_instructor_counts.txt" );
filesystem->CreateDirHierarchy( "save", "MOD" );
}
//.........这里部分代码省略.........
示例9: Joystick_Advanced
//-----------------------------------------------------------------------------
// Purpose: Advanced joystick setup
//-----------------------------------------------------------------------------
void CInput::Joystick_Advanced(void)
{
// called whenever an update is needed
int i;
DWORD dwTemp;
if ( IsX360() )
{
// Xbox always uses a joystick
in_joystick.SetValue( 1 );
}
// Initialize all the maps
for ( i = 0; i < MAX_JOYSTICK_AXES; i++ )
{
m_rgAxes[i].AxisMap = GAME_AXIS_NONE;
m_rgAxes[i].ControlMap = JOY_ABSOLUTE_AXIS;
}
if ( !joy_advanced.GetBool() )
{
// default joystick initialization
// 2 axes only with joystick control
m_rgAxes[JOY_AXIS_X].AxisMap = GAME_AXIS_YAW;
m_rgAxes[JOY_AXIS_Y].AxisMap = GAME_AXIS_FORWARD;
}
else
{
if ( Q_stricmp( joy_name.GetString(), "joystick") != 0 )
{
// notify user of advanced controller
Msg( "Using joystick '%s' configuration\n", joy_name.GetString() );
}
// advanced initialization here
// data supplied by user via joy_axisn cvars
dwTemp = ( joy_movement_stick.GetBool() ) ? (DWORD)joy_advaxisu.GetInt() : (DWORD)joy_advaxisx.GetInt();
m_rgAxes[JOY_AXIS_X].AxisMap = dwTemp & 0x0000000f;
m_rgAxes[JOY_AXIS_X].ControlMap = dwTemp & JOY_RELATIVE_AXIS;
DescribeJoystickAxis( "JOY_AXIS_X", &m_rgAxes[JOY_AXIS_X] );
dwTemp = ( joy_movement_stick.GetBool() ) ? (DWORD)joy_advaxisr.GetInt() : (DWORD)joy_advaxisy.GetInt();
m_rgAxes[JOY_AXIS_Y].AxisMap = dwTemp & 0x0000000f;
m_rgAxes[JOY_AXIS_Y].ControlMap = dwTemp & JOY_RELATIVE_AXIS;
DescribeJoystickAxis( "JOY_AXIS_Y", &m_rgAxes[JOY_AXIS_Y] );
dwTemp = (DWORD)joy_advaxisz.GetInt();
m_rgAxes[JOY_AXIS_Z].AxisMap = dwTemp & 0x0000000f;
m_rgAxes[JOY_AXIS_Z].ControlMap = dwTemp & JOY_RELATIVE_AXIS;
DescribeJoystickAxis( "JOY_AXIS_Z", &m_rgAxes[JOY_AXIS_Z] );
dwTemp = ( joy_movement_stick.GetBool() ) ? (DWORD)joy_advaxisy.GetInt() : (DWORD)joy_advaxisr.GetInt();
m_rgAxes[JOY_AXIS_R].AxisMap = dwTemp & 0x0000000f;
m_rgAxes[JOY_AXIS_R].ControlMap = dwTemp & JOY_RELATIVE_AXIS;
DescribeJoystickAxis( "JOY_AXIS_R", &m_rgAxes[JOY_AXIS_R] );
dwTemp = ( joy_movement_stick.GetBool() ) ? (DWORD)joy_advaxisx.GetInt() : (DWORD)joy_advaxisu.GetInt();
m_rgAxes[JOY_AXIS_U].AxisMap = dwTemp & 0x0000000f;
m_rgAxes[JOY_AXIS_U].ControlMap = dwTemp & JOY_RELATIVE_AXIS;
DescribeJoystickAxis( "JOY_AXIS_U", &m_rgAxes[JOY_AXIS_U] );
dwTemp = (DWORD)joy_advaxisv.GetInt();
m_rgAxes[JOY_AXIS_V].AxisMap = dwTemp & 0x0000000f;
m_rgAxes[JOY_AXIS_V].ControlMap = dwTemp & JOY_RELATIVE_AXIS;
DescribeJoystickAxis( "JOY_AXIS_V", &m_rgAxes[JOY_AXIS_V] );
Msg( "Advanced Joystick settings initialized\n" );
}
// If we have an xcontroller, load the cfg file if it hasn't been loaded.
static ConVarRef var( "joy_xcontroller_found" );
if ( var.IsValid() && var.GetBool() && in_joystick.GetBool() )
{
if ( joy_xcontroller_cfg_loaded.GetInt() < 2 )
{
engine->ClientCmd_Unrestricted( "exec 360controller.cfg" );
if ( IsLinux () )
{
engine->ClientCmd_Unrestricted( "exec 360controller-linux.cfg" );
}
joy_xcontroller_cfg_loaded.SetValue( 2 );
}
}
else if ( joy_xcontroller_cfg_loaded.GetInt() > 0 )
{
engine->ClientCmd_Unrestricted( "exec undo360controller.cfg" );
joy_xcontroller_cfg_loaded.SetValue( 0 );
}
}