本文整理汇总了C++中Q_atof函数的典型用法代码示例。如果您正苦于以下问题:C++ Q_atof函数的具体用法?C++ Q_atof怎么用?C++ Q_atof使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Q_atof函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KeyValue
void CFuncRotating :: KeyValue( KeyValueData* pkvd)
{
if( FStrEq( pkvd->szKeyName, "fanfriction" ))
{
m_flFanFriction = Q_atof( pkvd->szValue ) / 100.0f;
pkvd->fHandled = TRUE;
}
else if( FStrEq( pkvd->szKeyName, "spawnorigin" ))
{
Vector tmp = Q_atov( pkvd->szValue );
if( tmp != g_vecZero ) SetAbsOrigin( tmp );
}
else if( FStrEq( pkvd->szKeyName, "sounds" ))
{
m_sounds = ALLOC_STRING( pkvd->szValue );
pkvd->fHandled = TRUE;
}
else if( FStrEq( pkvd->szKeyName, "volume" ))
{
m_flVolume = bound( 0.0f, Q_atof( pkvd->szValue ) / 10.0f, 1.0f );
pkvd->fHandled = TRUE;
}
else
{
CBaseDelay::KeyValue( pkvd );
}
}
示例2: Cam_Pos_f
static void Cam_Pos_f (void)
{
if (Cmd_Argc() == 1)
{
Com_Printf ("\"%s %s %s\"\n", myftos(cl.simorg[0]), myftos(cl.simorg[1]), myftos(cl.simorg[2]));
return;
}
if (Cmd_Argc() == 2) {
// cam_pos "x y z" --> cam_pos x y z
Cmd_TokenizeString (va("cam_pos %s", Cmd_Argv(1)));
}
if (Cmd_Argc() != 4) {
Com_Printf("usage:\n"
"cam_pos - show current coordinates\n"
"cam pos x y z - set new coordinates\n");
return;
}
if (!cls.demoplayback && !cl.spectator)
return;
Cam_Reset();
Cam_Pos_Set(Q_atof(Cmd_Argv(1)), Q_atof(Cmd_Argv(2)), Q_atof(Cmd_Argv(3)));
}
示例3: Cam_Angles_f
static void Cam_Angles_f (void)
{
if (Cmd_Argc() == 1)
{
Com_Printf ("\"%s %s %s\"\n", myftos(cl.viewangles[0]), myftos(cl.viewangles[1]), myftos(cl.viewangles[2]));
return;
}
if (Cmd_Argc() == 2) {
// cam_angles "pitch yaw roll" --> cam_pos pitch yaw roll
Cmd_TokenizeString (va("cam_angles %s", Cmd_Argv(1)));
}
if (Cmd_Argc() != 4 && Cmd_Argc() != 3) {
Com_Printf("usage:\n"
"cam_pos - show current angles\n"
"cam pos pitch yaw [roll] - set new angles\n");
return;
}
if (!cls.demoplayback && !cl.spectator)
return;
Cam_Angles_Set(Q_atof(Cmd_Argv(1)), Q_atof(Cmd_Argv(2)), Q_atof(Cmd_Argv(3)));
}
示例4: Q_atof
/* <1836dc> ../cstrike/dlls/subs.cpp:397 */
void CBaseToggle::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd)
{
if (FStrEq(pkvd->szKeyName, "lip"))
{
m_flLip = Q_atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "wait"))
{
m_flWait = Q_atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "master"))
{
m_sMaster = ALLOC_STRING(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "distance"))
{
m_flMoveDistance = Q_atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else
CBaseDelay::KeyValue(pkvd);
}
示例5: Q_atof
void CFuncVehicle::KeyValue(KeyValueData *pkvd)
{
if (FStrEq(pkvd->szKeyName, "length"))
{
m_length = Q_atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "width"))
{
m_width = Q_atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "height"))
{
m_height = Q_atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "startspeed"))
{
m_startSpeed = Q_atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "sounds"))
{
m_sounds = Q_atoi(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "volume"))
{
// rounding values to integer
m_flVolume = Q_atoi(pkvd->szValue);
m_flVolume *= 0.1f;
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "bank"))
{
m_flBank = Q_atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "acceleration"))
{
m_acceleration = Q_atoi(pkvd->szValue);
if (m_acceleration < 1)
m_acceleration = 1;
else if (m_acceleration > 10)
m_acceleration = 10;
pkvd->fHandled = TRUE;
}
else
{
CBaseEntity::KeyValue(pkvd);
}
}
示例6: atof
bool C_PhysPropClientside::KeyValue( const char *szKeyName, const char *szValue )
{
if (FStrEq(szKeyName, "physdamagescale"))
{
m_impactEnergyScale = atof(szValue);
}
else if ( FStrEq(szKeyName, "health") )
{
m_iHealth = Q_atoi(szValue);
}
else if (FStrEq(szKeyName, "spawnflags"))
{
m_spawnflags = Q_atoi(szValue);
}
else if (FStrEq(szKeyName, "model"))
{
SetModelName( AllocPooledString( szValue ) );
}
else if (FStrEq(szKeyName, "fademaxdist"))
{
m_fadeMaxDist = Q_atof(szValue);
}
else if (FStrEq(szKeyName, "fademindist"))
{
m_fadeMinDist = Q_atof(szValue);
}
else if (FStrEq(szKeyName, "fadescale"))
{
m_flFadeScale = Q_atof(szValue);
}
else if (FStrEq(szKeyName, "inertiaScale"))
{
m_inertiaScale = Q_atof(szValue);
}
else if (FStrEq(szKeyName, "skin"))
{
m_nSkin = Q_atoi(szValue);
}
else if (FStrEq(szKeyName, "physicsmode"))
{
m_iPhysicsMode = Q_atoi(szValue);
}
else
{
if ( !BaseClass::KeyValue( szKeyName, szValue ) )
{
// key hasn't been handled
return false;
}
}
return true;
}
示例7: Rulesets_OnChange_r_fullbrightSkins
void Rulesets_OnChange_r_fullbrightSkins (cvar_t *var, char *value, qbool *cancel)
{
char *fbs;
qbool fbskins_policy = (cls.demoplayback || cl.spectator) ? 1 :
*(fbs = Info_ValueForKey(cl.serverinfo, "fbskins")) ? bound(0, Q_atof(fbs), 1) :
cl.teamfortress ? 0 : 1;
float fbskins = bound (0.0, Q_atof (value), fbskins_policy);
if (!cl.spectator && cls.state != ca_disconnected) {
if (fbskins > 0.0)
Cbuf_AddText (va("say all skins %d%% fullbright\n", (int) (fbskins * 100.0)));
else
Cbuf_AddText (va("say not using fullbright skins\n"));
}
}
示例8: Check_Gamma
// check gamma settings
void Check_Gamma (unsigned char *pal)
{
float f, inf;
unsigned char palette[768];
int i;
if ((i = COM_CheckParm("-gamma")) != 0 && i+1 < com_argc)
vid_gamma = bound (0.3, Q_atof(com_argv[i+1]), 1);
else
vid_gamma = 1;
Cvar_SetValue (&gl_gamma, vid_gamma);
for (i=0 ; i<768 ; i++)
{
f = pow ( (pal[i]+1)/256.0 , vid_gamma );
inf = f*255 + 0.5;
if (inf < 0)
inf = 0;
if (inf > 255)
inf = 255;
palette[i] = inf;
}
memcpy (pal, palette, sizeof(palette));
}
示例9: CSCR_ParseHeader
/*
======================
CSCR_ParseHeader
Check version and seek to first cvar name
======================
*/
qboolean CSCR_ParseHeader( parserstate_t *ps )
{
if( !CSCR_ExpectString( ps, "VERSION", false, true ) )
return false;
// Parse in the version #
// Get the first token.
ps->buf = COM_ParseFile( ps->buf, ps->token );
if( Q_atof( ps->token ) != 1 )
{
MsgDev( D_ERROR, "File %s has wrong version %s!\n", ps->filename, ps->token );
return false;
}
if( !CSCR_ExpectString( ps, "DESCRIPTION", false, true ) )
return false;
ps->buf = COM_ParseFile( ps->buf, ps->token );
if( Q_stricmp( ps->token, "INFO_OPTIONS") && Q_stricmp( ps->token, "SERVER_OPTIONS" ) )
{
MsgDev( D_ERROR, "DESCRIPTION must be INFO_OPTIONS or SERVER_OPTIONS\n");
return false;
}
if( !CSCR_ExpectString( ps, "{", false, true ) )
return false;
return true;
}
示例10: SV_Serverinfo_f
void SV_Serverinfo_f (void)
{
cvar_t *var;
if (Cmd_Argc() == 1)
{
Con_Printf ("Server info settings:\n");
Info_Print (svs.info);
return;
}
if (Cmd_Argc() != 3)
{
Con_Printf ("usage: serverinfo [ <key> <value> ]\n");
return;
}
if (Cmd_Argv(1)[0] == '*')
{
Con_Printf ("Star variables cannot be changed.\n");
return;
}
Info_SetValueForKey (svs.info, Cmd_Argv(1), Cmd_Argv(2), MAX_SERVERINFO_STRING);
// if this is a cvar, change it too
var = Cvar_FindVar (Cmd_Argv(1));
if (var)
{
Z_Free (var->string); // free the old value string
var->string = CopyString (Cmd_Argv(2));
var->value = Q_atof (var->string);
}
SV_SendServerInfoChange(Cmd_Argv(1), Cmd_Argv(2));
}
示例11: Cvar_Value
/*
============
Cvar_Value
============
*/
float Cvar_Value (const char *name)
{
cvar_t *var = Cvar_Find (name);
if (!var)
return 0;
return Q_atof (var->string);
}
示例12: ParseFloats
int ParseFloats(char *s, float *f, int *f_size)
{
int i, argc;
if (!s || !f || !f_size)
{
Sys_Error("ParseFloats() wrong params");
}
if (f_size[0] <= 0)
{
return (f_size[0] = 0); // array have no size, unusual but no crime
}
Cmd_TokenizeString(s);
argc = min(Cmd_Argc(), f_size[0]);
for (i = 0; i < argc; i++)
{
f[i] = Q_atof(Cmd_Argv(i));
}
for (; i < f_size[0]; i++)
{
f[i] = 0; // zeroing unused elements
}
return (f_size[0] = argc);
}
示例13: ALLOC_STRING
/* <f6d87> ../cstrike/dlls/mortar.cpp:71 */
void CFuncMortarField::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd)
{
if (FStrEq(pkvd->szKeyName, "m_iszXController"))
{
m_iszXController = ALLOC_STRING(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "m_iszYController"))
{
m_iszYController = ALLOC_STRING(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "m_flSpread"))
{
m_flSpread = Q_atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "m_fControl"))
{
m_fControl = Q_atoi(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "m_iCount"))
{
m_iCount = Q_atoi(pkvd->szValue);
pkvd->fHandled = TRUE;
}
}
示例14: Q_malloc
cvar_t *Cvar_Create (char *name, char *string, int cvarflags)
{
cvar_t *v;
int key;
if ((v = Cvar_Find(name))) {
v->flags &= ~CVAR_TEMP;
v->flags |= cvarflags;
return v;
}
v = (cvar_t *) Q_malloc(sizeof(cvar_t));
memset(v, 0, sizeof(cvar_t));
// Cvar doesn't exist, so we create it
v->next = cvar_vars;
cvar_vars = v;
key = Com_HashKey (name) % VAR_HASHPOOL_SIZE;
v->hash_next = cvar_hash[key];
cvar_hash[key] = v;
v->name = Q_strdup(name);
v->string = Q_strdup(string);
v->defaultvalue = Q_strdup(string);
v->flags = cvarflags | CVAR_USER_CREATED;
v->value = Q_atof (v->string);
v->integer = Q_atoi (v->string);
StringToRGB_W(v->string, v->color);
v->modified = true;
#ifdef WITH_TCL
TCL_RegisterVariable (v);
#endif
return v;
}
示例15: Cvar_RegisterVariable
/*
============
Cvar_RegisterVariable
Adds a freestanding variable to the variable list.
============
*/
void Cvar_RegisterVariable (cvar_t *variable)
{
char *oldstr;
// first check to see if it has allready been defined
if (Cvar_FindVar (variable->name))
{
Con_Printf ("Can't register variable %s, allready defined\n", variable->name);
return;
}
// check for overlap with a command
if (Cmd_Exists (variable->name))
{
Con_Printf ("Cvar_RegisterVariable: %s is a command\n", variable->name);
return;
}
// copy the value off, because future sets will Z_Free it
oldstr = variable->string;
variable->string = (char*) Z_Malloc (Q_strlen(variable->string)+1);
Q_strcpy (variable->string, oldstr);
variable->value = Q_atof (variable->string);
// link the variable in
variable->next = cvar_vars;
cvar_vars = variable;
}