本文整理汇总了C++中Cvar_VariableValue函数的典型用法代码示例。如果您正苦于以下问题:C++ Cvar_VariableValue函数的具体用法?C++ Cvar_VariableValue怎么用?C++ Cvar_VariableValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Cvar_VariableValue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CL_SendConnectPacket
/*
=======================
CL_SendConnectPacket
We have gotten a challenge from the server, so try and
connect.
======================
*/
void CL_SendConnectPacket (void)
{
netadr_t adr;
int port;
if (!NET_StringToAdr (cls.servername, &adr))
{
Com_Printf ("Bad server address\n");
cls.connect_time = 0;
return;
}
if (adr.port == 0)
adr.port = BigShort (PORT_SERVER);
port = Cvar_VariableValue ("qport");
userinfo_modified = false;
Netchan_OutOfBandPrint (NS_CLIENT, adr, "connect %i %i %i \"%s\"\n",
PROTOCOL_VERSION, port, cls.challenge, Cvar_Userinfo() );
}
示例2: IN_Frame
void IN_Frame (void) {
// bk001130 - from cvs 1.17 (mkv)
IN_JoyMove(); // FIXME: disable if on desktop?
if ( cls.keyCatchers & KEYCATCH_CONSOLE )
{
// temporarily deactivate if not in the game and
// running on the desktop
// voodoo always counts as full screen
if (Cvar_VariableValue ("r_fullscreen") == 0
&& strcmp( Cvar_VariableString("r_glDriver"), _3DFX_DRIVER_NAME ) )
{
IN_DeactivateMouse ();
return;
}
}
IN_ActivateMouse();
}
示例3: Cvar_Toggle_f
/*
============
Cvar_Toggle_f
Toggles a cvar for easy single key binding, optionally through a list of
given values
============
*/
void Cvar_Toggle_f(void)
{
int i, c = Cmd_Argc();
char *curval;
if (c < 2)
{
Com_Printf("usage: toggle <variable> [value1, value2, ...]\n");
return;
}
if (c == 2)
{
Cvar_Set2(Cmd_Argv(1), va("%d",
!Cvar_VariableValue(Cmd_Argv(1))),
qfalse);
return;
}
if (c == 3)
{
Com_Printf("toggle: nothing to toggle to\n");
return;
}
curval = Cvar_VariableString(Cmd_Argv(1));
// don't bother checking the last arg for a match since the desired
// behaviour is the same as no match (set to the first argument)
for (i = 2; i + 1 < c; i++)
{
if (strcmp(curval, Cmd_Argv(i)) == 0)
{
Cvar_Set2(Cmd_Argv(1), Cmd_Argv(i + 1), qfalse);
return;
}
}
// fallback
Cvar_Set2(Cmd_Argv(1), Cmd_Argv(2), qfalse);
}
示例4: SV_CheckForSavegame
/*
=================
SV_CheckForSavegame
=================
*/
void SV_CheckForSavegame (void)
{
char name[MAX_OSPATH];
FILE *f;
int i;
if (sv_noreload->value)
return;
if (Cvar_VariableValue ("deathmatch"))
return;
Com_sprintf (name, sizeof(name), "%s/save/current/%s.sav", FS_Gamedir(), sv.name);
f = fopen (name, "rb");
if (!f)
return; // no savegame
fclose (f);
SV_ClearWorld ();
// get configstrings and areaportals
SV_ReadLevelFile ();
if (!sv.loadgame)
{ // coming back to a level after being in a different
// level, so run it for ten seconds
// rlava2 was sending too many lightstyles, and overflowing the
// reliable data. temporarily changing the server state to loading
// prevents these from being passed down.
server_state_t previousState; // PGM
previousState = sv.state; // PGM
sv.state = ss_loading; // PGM
for (i=0 ; i<100 ; i++)
ge->RunFrame ();
sv.state = previousState; // PGM
}
}
示例5: SVC_Status
/*
================
SVC_Status
Responds with all the info that qplug or qspy can see about the server
and all connected players. Used for getting detailed information after
the simple info query.
================
*/
void SVC_Status( netadr_t from ) {
char player[1024];
char status[MAX_MSGLEN];
int i;
client_t *cl;
playerState_t *ps;
int statusLength;
int playerLength;
char infostring[MAX_INFO_STRING];
// ignore if we are in single player
if ( Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER ) {
return;
}
strcpy( infostring, Cvar_InfoString( CVAR_SERVERINFO ) );
// echo back the parameter to status. so master servers can use it as a challenge
// to prevent timed spoofed reply packets that add ghost servers
Info_SetValueForKey( infostring, "challenge", Cmd_Argv(1) );
status[0] = 0;
statusLength = 0;
for (i=0 ; i < sv_maxclients->integer ; i++) {
cl = &svs.clients[i];
if ( cl->state >= CS_CONNECTED ) {
ps = SV_GameClientNum( i );
Com_sprintf (player, sizeof(player), "%i %i \"%s\"\n",
ps->persistant[PERS_SCORE], cl->ping, cl->name);
playerLength = strlen(player);
if (statusLength + playerLength >= sizeof(status) ) {
break; // can't hold any more
}
strcpy (status + statusLength, player);
statusLength += playerLength;
}
}
NET_OutOfBandPrint( NS_SERVER, from, "statusResponse\n%s\n%s", infostring, status );
}
示例6: Host_Exec_f
/*
===============
Host_Exec_f
===============
*/
void Host_Exec_f( void )
{
string cfgpath;
char *f, *txt;
size_t len;
if( Cmd_Argc() != 2 )
{
Msg( "Usage: exec <filename>\n" );
return;
}
// HACKHACK: don't execute listenserver.cfg in singleplayer
if( !Q_stricmp( Cvar_VariableString( "lservercfgfile" ), Cmd_Argv( 1 )))
{
if( Cvar_VariableValue( "maxplayers" ) == 1.0f )
return;
}
Q_strncpy( cfgpath, Cmd_Argv( 1 ), sizeof( cfgpath ));
FS_DefaultExtension( cfgpath, ".cfg" ); // append as default
f = FS_LoadFile( cfgpath, &len, false );
if( !f )
{
MsgDev( D_NOTE, "couldn't exec %s\n", Cmd_Argv( 1 ));
return;
}
// adds \n\0 at end of the file
txt = Z_Malloc( len + 2 );
Q_memcpy( txt, f, len );
Q_strncat( txt, "\n", len + 2 );
Mem_Free( f );
MsgDev( D_INFO, "execing %s\n", Cmd_Argv( 1 ));
Cbuf_InsertText( txt );
Mem_Free( txt );
}
示例7: NET_OpenIPX
/*
====================
NET_OpenIPX
====================
*/
void NET_OpenIPX (void)
{
int port;
int dedicated;
dedicated = Cvar_VariableValue ("dedicated");
if (!ipx_sockets[NS_SERVER])
{
port = Cvar_Get("ipx_hostport", "0", CVAR_NOSET)->value;
if (!port)
{
port = Cvar_Get("hostport", "0", CVAR_NOSET)->value;
if (!port)
{
port = Cvar_Get("port", va("%i", PORT_SERVER), CVAR_NOSET)->value;
}
}
ipx_sockets[NS_SERVER] = NET_IPXSocket (port);
}
// dedicated servers don't need client ports
if (dedicated)
return;
if (!ipx_sockets[NS_CLIENT])
{
port = Cvar_Get("ipx_clientport", "0", CVAR_NOSET)->value;
if (!port)
{
port = Cvar_Get("clientport", va("%i", PORT_CLIENT), CVAR_NOSET)->value;
if (!port)
port = PORT_ANY;
}
ipx_sockets[NS_CLIENT] = NET_IPXSocket (port);
if (!ipx_sockets[NS_CLIENT])
ipx_sockets[NS_CLIENT] = NET_IPXSocket (PORT_ANY);
}
}
示例8: CL_InitUI
void CL_InitUI( void ) {
int v;
vmInterpret_t interpret;
// load the dll or bytecode
interpret = Cvar_VariableValue("vm_ui");
if(cl_connectedToPureServer)
{
// if sv_pure is set we only allow qvms to be loaded
if(interpret != VMI_COMPILED && interpret != VMI_BYTECODE)
interpret = VMI_COMPILED;
}
uivm = VM_Create( "ui", CL_UISystemCalls, interpret );
if ( !uivm ) {
Com_Error( ERR_FATAL, "VM_Create on UI failed" );
}
// sanity check
v = VM_Call( uivm, UI_GETAPIVERSION );
if (v == UI_OLD_API_VERSION) {
// Com_Printf(S_COLOR_YELLOW "WARNING: loading old Quake III Arena User Interface version %d\n", v );
// init for this gamestate
VM_Call( uivm, UI_INIT, (clc.state >= CA_CONNECTING_NAT && clc.state < CA_ACTIVE));
}
else if (v != UI_API_VERSION) {
// Free uivm now, so UI_SHUTDOWN doesn't get called later.
VM_Free( uivm );
uivm = NULL;
Com_Error( ERR_DROP, "User Interface is version %d, expected %d", v, UI_API_VERSION );
cls.uiStarted = qfalse;
}
else {
// init for this gamestate
VM_Call( uivm, UI_INIT, (clc.state >= CA_CONNECTING_NAT && clc.state < CA_ACTIVE) );
}
}
示例9: SV_Auth_Ban_f
/*
==================
SV_Auth_Ban_f
Ban a user from the server
and the group
==================
*/
static void SV_Auth_Ban_f(void) {
client_t *cl;
char *d, *h, *m;
if (!com_sv_running->integer) {
Com_Printf("Server is not running.\n");
return;
}
if (Cvar_VariableValue("auth") == 0) {
Com_Printf("Auth services are disabled\n");
return;
}
if (Cmd_Argc() < 5) {
Com_Printf ("Usage: auth-ban <client> <days> <hours> <mins>\n");
return;
}
cl = SV_GetPlayerByHandle();
if (!cl) {
return;
}
if (cl->netchan.remoteAddress.type == NA_LOOPBACK) {
SV_SendServerCommand(NULL, "print \"%s\"", "Cannot ban host client\n");
return;
}
d = Cmd_Argv(2);
h = Cmd_Argv(3);
m = Cmd_Argv(4);
VM_Call(gvm, GAME_AUTH_BAN, (int)(cl - svs.clients), atoi(d), atoi(h), atoi(m));
}
示例10: Cvar_Toggle_f
/*
============
Cvar_Toggle_f
Toggles a cvar for easy single key binding,
optionally through a list of given values
============
*/
void Cvar_Toggle_f( void )
{
int i, c;
const char *varname, *curval;
c = Cmd_Argc();
if ( c < 2 )
{
Cmd_PrintUsage(_("<variable> [<value> …]"), NULL);
return;
}
varname = Cmd_Argv( 1 );
if ( c == 2 )
{
Cvar_Set2( varname, va( "%d", !Cvar_VariableValue( varname ) ), qfalse );
return;
}
curval = Cvar_VariableString( Cmd_Argv( 1 ) );
// don't bother checking the last value for a match, since the desired
// behaviour is the same as if the last value didn't match:
// set the variable to the first value
for ( i = 2; i < c - 1; ++i )
{
if ( !strcmp( curval, Cmd_Argv( i ) ) )
{
Cvar_Set2( varname, Cmd_Argv( i + 1 ), qfalse );
return;
}
}
// fallback
Cvar_Set2( varname, Cmd_Argv( 2 ), qfalse );
}
示例11: Cvar_Cycle_f
void Cvar_Cycle_f (void)
{
int i;
if (Cmd_Argc() < 3)
{
Con_Printf("cycle <cvar> <value list>: cycle cvar through a list of values\n");
return;
}
//loop through the args until you find one that matches the current cvar value.
//yes, this will get stuck on a list that contains the same value twice.
//it's not worth dealing with, and i'm not even sure it can be dealt with.
for (i=2;i<Cmd_Argc();i++)
{
//zero is assumed to be a string, even though it could actually be zero. The worst case
//is that the first time you call this command, it won't match on zero when it should, but after that,
//it will be comparing strings that all had the same source (the user) so it will work.
if (atof(Cmd_Argv(i)) == 0)
{
if (!strcmp(Cmd_Argv(i), Cvar_VariableString(Cmd_Argv(1))))
break;
}
else
{
if (atof(Cmd_Argv(i)) == Cvar_VariableValue(Cmd_Argv(1)))
break;
}
}
if (i == Cmd_Argc())
Cvar_Set (Cmd_Argv(1), Cmd_Argv(2)); // no match
else if (i + 1 == Cmd_Argc())
Cvar_Set (Cmd_Argv(1), Cmd_Argv(2)); // matched last value in list
else
Cvar_Set (Cmd_Argv(1), Cmd_Argv(i+1)); // matched earlier in list
}
示例12: SV_Nextserver
void SV_Nextserver(void)
{
char * v;
//ZOID, ss_pic can be nextserver'd in coop mode
if (sv.state == ss_game || (sv.state == ss_pic && !Cvar_VariableValue("coop")))
{
return; // can't nextserver while playing a normal game
}
svs.spawncount++; // make sure another doesn't sneak in
v = Cvar_VariableString("nextserver");
if (!v[0])
{
Cbuf_AddText("killserver\n");
}
else
{
Cbuf_AddText(v);
Cbuf_AddText("\n");
}
Cvar_Set("nextserver", "");
}
示例13: R_CalcEntAlpha
/*
=================
R_CalcEntAlpha
=================
*/
float R_CalcEntAlpha (float alpha, vec3_t point)
{
float baseDist, newAlpha;
vec3_t vert_len;
newAlpha = alpha;
if (!(currententity->renderfx & RF2_CAMERAMODEL) || !(currententity->flags & RF_TRANSLUCENT))
{
newAlpha = max(min(newAlpha, 1.0f), 0.0f);
return newAlpha;
}
baseDist = Cvar_VariableValue("cg_thirdperson_dist");
if (baseDist < 1) baseDist = 50;
VectorSubtract(r_newrefdef.vieworg, point, vert_len);
newAlpha *= VectorLength(vert_len) / baseDist;
if (newAlpha > alpha) newAlpha = alpha;
newAlpha = max(min(newAlpha, 1.0f), 0.0f);
return newAlpha;
}
示例14: Physics_Step
/* Monsters freefall when they don't have a ground entity, otherwise
all movement is done with discrete steps.
This is also used for objects that have become still on the ground, but
will fall if the floor is pulled out from under them.
*/
void Physics_Step(edict_t *ent)
{
// Freefall if not onground
if(!(ent->v.flags & (FL_ONGROUND|FL_FLY|FL_SWIM)))
{
#if 0
// [19/3/2013] TODO: Replace! ~hogsy
if(ent->v.velocity[2] < Cvar_VariableValue("server_gravityamount")*-0.1f) //sv_gravity.value*-0.1f)
bHitSound = true;
#endif
Game->Physics_SetGravity(ent);
Game->Physics_CheckVelocity(ent);
SV_FlyMove(ent,host_frametime,NULL);
SV_LinkEdict(ent,true);
}
// Regular thinking
Server_RunThink(ent);
Game->Physics_CheckWaterTransition(ent);
}
示例15: CL_InitUI
void CL_InitUI( void ) {
int v;
vmInterpret_t interpret;
// load the dll or bytecode
if ( cl_connectedToPureServer != 0 ) {
// if sv_pure is set we only allow qvms to be loaded
interpret = VMI_COMPILED;
}
else {
interpret = Cvar_VariableValue( "vm_ui" );
}
uivm = VM_Create( "ui", CL_UISystemCalls, interpret );
if ( !uivm ) {
Com_Error( ERR_FATAL, "VM_Create on UI failed" );
}
// sanity check
v = VM_Call( uivm, UI_GETAPIVERSION );
if (v == UI_OLD_API_VERSION) {
// Com_Printf(S_COLOR_YELLOW "WARNING: loading old Quake III Arena User Interface version %d\n", v );
// init for this gamestate
VM_Call( uivm, UI_INIT, (cls.state >= CA_AUTHORIZING && cls.state < CA_ACTIVE));
}
else if (v != UI_API_VERSION) {
Com_Error( ERR_DROP, "User Interface is version %d, expected %d", v, UI_API_VERSION );
cls.uiStarted = qfalse;
}
else {
// init for this gamestate
VM_Call( uivm, UI_INIT, (cls.state >= CA_AUTHORIZING && cls.state < CA_ACTIVE) );
}
// reset any CVAR_CHEAT cvars registered by ui
if ( !clc.demoplaying && !cl_connectedToCheatServer )
Cvar_SetCheatState();
}