本文整理汇总了C++中Q_sprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ Q_sprintf函数的具体用法?C++ Q_sprintf怎么用?C++ Q_sprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Q_sprintf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: CL_LevelShot_f
/*
==================
CL_LevelShot_f
splash logo while map is loading
==================
*/
void CL_LevelShot_f( void )
{
size_t ft1, ft2;
string filename;
if( cls.scrshot_request != scrshot_plaque ) return;
cls.scrshot_request = scrshot_inactive;
// check for exist
if( cls.demoplayback && ( cls.demonum != -1 ))
{
Q_sprintf( cls.shotname, "levelshots/%s_%s.bmp", cls.demoname, glState.wideScreen ? "16x9" : "4x3" );
Q_snprintf( filename, sizeof( filename ), "demos/%s.dem", cls.demoname );
// make sure what levelshot is newer than demo
ft1 = FS_FileTime( filename, false );
ft2 = FS_FileTime( cls.shotname, true );
}
else
{
Q_sprintf( cls.shotname, "levelshots/%s_%s.bmp", clgame.mapname, glState.wideScreen ? "16x9" : "4x3" );
// make sure what levelshot is newer than bsp
ft1 = FS_FileTime( cl.worldmodel->name, false );
ft2 = FS_FileTime( cls.shotname, true );
}
// missing levelshot or level never than levelshot
if( ft2 == -1 || ft1 > ft2 )
cls.scrshot_action = scrshot_plaque; // build new frame for levelshot
else cls.scrshot_action = scrshot_inactive; // disable - not needs
}
开发者ID:mittorn,项目名称:xash3d,代码行数:39,代码来源:cl_cmds.c
示例2: ClientFindFromSteamID
/* <ee430> ../engine/sv_steam3.cpp:290 */
void CSteam3Server::OnGSClientApprove(GSClientApprove_t *pGSClientSteam2Accept)
{
client_t* cl = ClientFindFromSteamID(pGSClientSteam2Accept->m_SteamID);
if (!cl)
return;
if (SV_FilterUser(&cl->network_userid))
{
char msg[256];
Q_sprintf(msg, "You have been banned from this server\n");
SV_RejectConnection(&cl->netchan.remote_address, msg);
SV_DropClient(cl, 0, "STEAM UserID %s is in server ban list\n", SV_GetClientIDString(cl));
}
else if (SV_CheckForDuplicateSteamID(cl) != -1)
{
char msg[256];
Q_sprintf(msg, "Your UserID is already in use on this server.\n");
SV_RejectConnection(&cl->netchan.remote_address, msg);
SV_DropClient(cl, 0, "STEAM UserID %s is already\nin use on this server\n", SV_GetClientIDString(cl));
}
else
{
char msg[512];
Q_snprintf(msg, ARRAYSIZE(msg), "\"%s<%i><%s><>\" STEAM USERID validated\n", cl->name, cl->userid, SV_GetClientIDString(cl));
#ifdef REHLDS_CHECKS
msg[ARRAYSIZE(msg) - 1] = 0;
#endif
Con_DPrintf("%s", msg);
Log_Printf("%s", msg);
}
}
开发者ID:vlad-slick,项目名称:rehlds,代码行数:33,代码来源:sv_steam3.cpp
示例3: UI_RegisterClientSkin
/*
* UI_RegisterClientSkin
*/
static qbool
UI_RegisterClientSkin(Playerinfo *pi, const char *modelName,
const char *skinName)
{
char filename[MAX_QPATH];
Q_sprintf(filename, sizeof(filename),
Pplayermodels "/%s/lower_%s.skin", modelName,
skinName);
pi->legsSkin = trap_R_RegisterSkin(filename);
Q_sprintf(filename, sizeof(filename),
Pplayermodels "/%s/upper_%s.skin", modelName,
skinName);
pi->torsoSkin = trap_R_RegisterSkin(filename);
Q_sprintf(filename, sizeof(filename), Pplayermodels "/%s/head_%s.skin",
modelName,
skinName);
pi->headSkin = trap_R_RegisterSkin(filename);
if(!pi->legsSkin || !pi->torsoSkin || !pi->headSkin)
return qfalse;
return qtrue;
}
开发者ID:icanhas,项目名称:yantar,代码行数:29,代码来源:players.c
示例4: RANDOM_LONG
void CHostageImprov::Afraid()
{
char animInto[32];
char animLoop[32];
char animExit[32];
if (IsCrouching())
return;
if (m_animateState.GetPerformance() == HostageAnimateState::Flinching ||
m_animateState.GetPerformance() == HostageAnimateState::Afraid)
return;
if (!IsMoving())
{
m_animateState.Reset();
m_animateState.SetPerformance(HostageAnimateState::Afraid);
int which = RANDOM_LONG(0, 100) % 3 + 1;
Q_sprintf(animInto, "cower_into_%d", which);
Q_sprintf(animLoop, "cower_loop_%d", which);
Q_sprintf(animExit, "cower_exit_%d", which);
m_animateState.AddSequence(this, animInto);
m_animateState.AddSequence(this, animLoop, RANDOM_FLOAT(3, 10));
m_animateState.AddSequence(this, animExit);
}
}
开发者ID:Solexid,项目名称:ReGameDLL_CS,代码行数:29,代码来源:hostage_improv.cpp
示例5: Q_sscanf
void CEnvLight::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd)
{
if (FStrEq(pkvd->szKeyName, "_light"))
{
int r, g, b, v, j;
j = Q_sscanf(pkvd->szValue, "%d %d %d %d\n", &r, &g, &b, &v);
if (j == 1)
g = b = r;
else if (j == 4)
{
r = r * (v / 255.0);
g = g * (v / 255.0);
b = b * (v / 255.0);
}
// simulate qrad direct, ambient,and gamma adjustments, as well as engine scaling
r = Q_pow(r / 114.0, 0.6) * 264;
g = Q_pow(g / 114.0, 0.6) * 264;
b = Q_pow(b / 114.0, 0.6) * 264;
pkvd->fHandled = TRUE;
char szColor[64];
Q_sprintf(szColor, "%d", r);
CVAR_SET_STRING("sv_skycolor_r", szColor);
Q_sprintf(szColor, "%d", g);
CVAR_SET_STRING("sv_skycolor_g", szColor);
Q_sprintf(szColor, "%d", b);
CVAR_SET_STRING("sv_skycolor_b", szColor);
}
else
CLight::KeyValue(pkvd);
}
开发者ID:Slinfy97,项目名称:ReGameDLL_CS,代码行数:35,代码来源:lights.cpp
示例6: UTIL_MakeAimVectors
void CEnvLight::__MAKE_VHOOK(Spawn)()
{
#ifdef HOOK_GAMEDLL
// NOTE: fix negative the values for function sprintf from STD C++:
// expected - sv_skyvec_y "0.000000"
// with using sprintf from STD C++, got - sv_skyvec_y "-0.000000"
// If we not doing it then the test will be failed!
#define SPRINTF_OLD_STD_FIX + 0
#else
#define SPRINTF_OLD_STD_FIX
#endif
char szVector[64];
UTIL_MakeAimVectors(pev->angles);
Q_sprintf(szVector, "%f", gpGlobals->v_forward.x SPRINTF_OLD_STD_FIX);
CVAR_SET_STRING("sv_skyvec_x", szVector);
Q_sprintf(szVector, "%f", gpGlobals->v_forward.y SPRINTF_OLD_STD_FIX);
CVAR_SET_STRING("sv_skyvec_y", szVector);
Q_sprintf(szVector, "%f", gpGlobals->v_forward.z SPRINTF_OLD_STD_FIX);
CVAR_SET_STRING("sv_skyvec_z", szVector);
CLight::Spawn();
}
开发者ID:Slinfy97,项目名称:ReGameDLL_CS,代码行数:26,代码来源:lights.cpp
示例7: cvarsetfsafe
/* expands value to a string and calls cvarsetstr/cvarsetstrsafe */
void
cvarsetfsafe(const char *var_name, float value)
{
char val[32];
if(Q_isintegral(value))
Q_sprintf(val, sizeof(val), "%i", (int)value);
else
Q_sprintf(val, sizeof(val), "%f", value);
cvarsetstrsafe(var_name, val);
}
开发者ID:icanhas,项目名称:yantar,代码行数:12,代码来源:cvar.c
示例8: cvarsetf
void
cvarsetf(const char *var_name, float value)
{
char val[32];
if(value == (int)value)
Q_sprintf(val, sizeof(val), "%i", (int)value);
else
Q_sprintf(val, sizeof(val), "%f", value);
cvarsetstr(var_name, val);
}
开发者ID:icanhas,项目名称:yantar,代码行数:11,代码来源:cvar.c
示例9: CG_LoadingClient
void
CG_LoadingClient(int clientNum)
{
const char *info;
char *skin;
char personality[MAX_QPATH];
char model[MAX_QPATH];
char iconName[MAX_QPATH];
info = CG_ConfigString(CS_PLAYERS + clientNum);
if(loadingPlayerIconCount < MAX_LOADING_PLAYER_ICONS){
Q_strncpyz(model, Info_ValueForKey(info, "model"), sizeof(model));
skin = strrchr(model, '/');
if(skin)
*skin++ = '\0';
else
skin = "default";
Q_sprintf(iconName, MAX_QPATH,
Pplayermodels "/%s/icon_%s", model, skin);
loadingPlayerIcons[loadingPlayerIconCount]
= trap_R_RegisterShaderNoMip(iconName);
if(!loadingPlayerIcons[loadingPlayerIconCount]){
Q_sprintf(iconName, MAX_QPATH,
Pplayermodels "/characters/%s/icon_%s",
model, skin);
loadingPlayerIcons[loadingPlayerIconCount]
= trap_R_RegisterShaderNoMip(iconName);
}
if(!loadingPlayerIcons[loadingPlayerIconCount]){
Q_sprintf(iconName, MAX_QPATH,
Pplayermodels "/%s/icon_%s",
DEFAULT_MODEL, "default");
loadingPlayerIcons[loadingPlayerIconCount]
= trap_R_RegisterShaderNoMip(iconName);
}
if(loadingPlayerIcons[loadingPlayerIconCount])
loadingPlayerIconCount++;
}
Q_strncpyz(personality, Info_ValueForKey(info, "n"),
sizeof(personality));
Q_cleanstr(personality);
if(cgs.gametype == GT_SINGLE_PLAYER)
trap_sndregister(va(Pannounce "/%s", personality), qtrue);
CG_LoadingString(personality);
}
开发者ID:icanhas,项目名称:yantar,代码行数:50,代码来源:info.c
示例10: Q_min
BOOL CItemBattery::__MAKE_VHOOK(MyTouch)(CBasePlayer *pPlayer)
{
if (pPlayer->pev->armorvalue < MAX_NORMAL_BATTERY && (pPlayer->pev->weapons & (1 << WEAPON_SUIT)))
{
int pct;
char szcharge[64];
pPlayer->pev->armorvalue += gSkillData.batteryCapacity;
pPlayer->pev->armorvalue = Q_min(pPlayer->pev->armorvalue, MAX_NORMAL_BATTERY);
EMIT_SOUND(pPlayer->edict(), CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM);
MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev);
WRITE_STRING(STRING(pev->classname));
MESSAGE_END();
// Suit reports new power level
// For some reason this wasn't working in release build -- round it.
pct = int(float(pPlayer->pev->armorvalue * 100.0f) * (1.0f / MAX_NORMAL_BATTERY) + 0.5f);
pct = (pct / 5);
if (pct > 0)
pct--;
Q_sprintf(szcharge,"!HEV_%1dP", pct);
pPlayer->SetSuitUpdate(szcharge, FALSE, SUIT_NEXT_IN_30SEC);
return TRUE;
}
return FALSE;
}
开发者ID:a1batross,项目名称:ReGameDLL_CS,代码行数:31,代码来源:items.cpp
示例11: sysgetdefaulthomepath
/*
* sysgetdefaulthomepath
*/
char *
sysgetdefaulthomepath(void)
{
char *p;
if(!*homePath){
if((p = getenv("HOME")) != NULL){
Q_sprintf(homePath, sizeof(homePath), "%s%c", p,
PATH_SEP);
#ifdef MACOS_X
Q_strcat(homePath, sizeof(homePath),
"Library/Application Support/");
if(com_homepath->string[0])
Q_strcat(homePath, sizeof(homePath),
com_homepath->string);
else
Q_strcat(homePath, sizeof(homePath),
HOMEPATH_NAME_MACOSX);
#else
if(com_homepath->string[0])
Q_strcat(homePath, sizeof(homePath),
com_homepath->string);
else
Q_strcat(homePath, sizeof(homePath),
HOMEPATH_NAME_UNIX);
#endif
}
}
return homePath;
}
开发者ID:icanhas,项目名称:yantar,代码行数:35,代码来源:sys.c
示例12: DeathmatchScoreboardMessage
/*
* DeathmatchScoreboardMessage
*
*/
void
DeathmatchScoreboardMessage(Gentity *ent)
{
char entry[1024];
char string[1400];
int stringlength;
int i, j;
Gclient *cl;
int numSorted, scoreFlags, accuracy, perfect;
/* send the latest information on all clients */
string[0] = 0;
stringlength = 0;
scoreFlags = 0;
numSorted = level.numConnectedClients;
for(i=0; i < numSorted; i++){
int ping;
cl = &level.clients[level.sortedClients[i]];
if(cl->pers.connected == CON_CONNECTING)
ping = -1;
else
ping = cl->ps.ping < 999 ? cl->ps.ping : 999;
if(cl->accuracy_shots)
accuracy = cl->accuracy_hits * 100 / cl->accuracy_shots;
else
accuracy = 0;
perfect =
(cl->ps.persistant[PERS_RANK] == 0 &&
cl->ps.persistant[PERS_KILLED] == 0) ? 1 : 0;
Q_sprintf (entry, sizeof(entry),
" %i %i %i %i %i %i %i %i %i %i %i %i %i %i",
level.sortedClients[i],
cl->ps.persistant[PERS_SCORE], ping,
(level.time - cl->pers.enterTime)/60000,
scoreFlags,
g_entities[level.sortedClients[i]].s.powerups, accuracy,
cl->ps.persistant[PERS_IMPRESSIVE_COUNT],
cl->ps.persistant[PERS_EXCELLENT_COUNT],
cl->ps.persistant[PERS_GAUNTLET_FRAG_COUNT],
cl->ps.persistant[PERS_DEFEND_COUNT],
cl->ps.persistant[PERS_ASSIST_COUNT],
perfect,
cl->ps.persistant[PERS_CAPTURES]);
j = strlen(entry);
if(stringlength + j >= sizeof(string))
break;
strcpy (string + stringlength, entry);
stringlength += j;
}
trap_SendServerCommand(ent-g_entities, va("scores %i %i %i%s", i,
level.teamScores[TEAM_RED], level.teamScores[TEAM_BLUE],
string));
}
开发者ID:icanhas,项目名称:yantar,代码行数:64,代码来源:cmds.c
示例13: R_LevelShot
/*
* R_LevelShot
*
* levelshots are specialized 128*128 thumbnails for
* the menu system, sampled down from full screen distorted images
*/
void
R_LevelShot(void)
{
char checkname[MAX_OSPATH];
byte *buffer;
byte *source, *allsource;
byte *src, *dst;
size_t offset = 0;
int padlen;
int x, y;
int r, g, b;
float xScale, yScale;
int xx, yy;
Q_sprintf(checkname, sizeof(checkname), "levelshots/%s.tga", tr.world->baseName);
allsource = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &padlen);
source = allsource + offset;
buffer = ri.hunkalloctemp(128 * 128*3 + 18);
Q_Memset (buffer, 0, 18);
buffer[2] = 2; /* uncompressed type */
buffer[12] = 128;
buffer[14] = 128;
buffer[16] = 24; /* pixel size */
/* resample from source */
xScale = glConfig.vidWidth / 512.0f;
yScale = glConfig.vidHeight / 384.0f;
for(y = 0; y < 128; y++)
for(x = 0; x < 128; x++){
r = g = b = 0;
for(yy = 0; yy < 3; yy++)
for(xx = 0; xx < 4; xx++){
src = source +
(3 * glConfig.vidWidth + padlen) * (int)((y*3 + yy) * yScale) +
3 * (int)((x*4 + xx) * xScale);
r += src[0];
g += src[1];
b += src[2];
}
dst = buffer + 18 + 3 * (y * 128 + x);
dst[0] = b / 12;
dst[1] = g / 12;
dst[2] = r / 12;
}
/* gamma correct */
if(glConfig.deviceSupportsGamma){
R_GammaCorrect(buffer + 18, 128 * 128 * 3);
}
ri.fswritefile(checkname, buffer, 128 * 128*3 + 18);
ri.hunkfreetemp(buffer);
ri.hunkfreetemp(allsource);
ri.Printf(PRINT_ALL, "Wrote %s\n", checkname);
}
开发者ID:icanhas,项目名称:yantar,代码行数:65,代码来源:init.c
示例14: cvarwritevars
/*
* Appends lines containing "set variable value" for
* all variables with the archive flag set.
*/
void
cvarwritevars(Fhandle f)
{
size_t len; /* total length of name + archival string */
char buffer[1024];
Cvar *var;
for(var = cvarlist; var != nil; var = var->next){
if(var->name == nil)
continue;
if(!(var->flags & CVAR_ARCHIVE)){
continue;
}
/* write the latched value, even if it hasn't taken effect yet */
if(var->latchedString != nil){
len = strlen(var->name) + strlen(var->latchedString);
if(len+10 > sizeof(buffer)){
comprintf(S_COLOR_YELLOW
"WARNING: value of variable "
"\"%s\" too long to write to file\n",
var->name);
continue;
}
Q_sprintf (buffer, sizeof(buffer),
"seta %s \"%s\"\n", var->name,
var->latchedString);
}else{
len = strlen(var->name) + strlen(var->string);
if(len+10 > sizeof(buffer)){
comprintf(S_COLOR_YELLOW
"WARNING: value of variable "
"\"%s\" too long to write to file\n",
var->name);
continue;
}
Q_sprintf (buffer, sizeof(buffer),
"seta %s \"%s\"\n", var->name,
var->string);
}
fswrite(buffer, strlen(buffer), f);
}
}
开发者ID:icanhas,项目名称:yantar,代码行数:48,代码来源:cvar.c
示例15: Q_sprintf
NOXREF char *vstr(float *v)
{
static int idx = 0;
static char string[ 16 ][ 1024 ];
idx = (idx + 1) % 0xF;
Q_sprintf(string[ idx ], "%.4f %.4f %.4f", v[0], v[1], v[2]);
return string[ idx ];
}
开发者ID:a1batross,项目名称:ReGameDLL_CS,代码行数:10,代码来源:combat.cpp
示例16: Sys_LoadDll
/*
* First try to load library name from system library path,
* from executable path, then fs_basepath.
*/
void *
Sys_LoadDll(const char *name, qbool useSystemLib)
{
void *dllhandle;
if(useSystemLib)
comprintf("Trying to load \"%s\"...\n", name);
if(!useSystemLib || !(dllhandle = Sys_LoadLibrary(name))){
const char *topDir;
char libPath[MAX_OSPATH];
topDir = Sys_BinaryPath();
if(!*topDir)
topDir = ".";
comprintf("Trying to load \"%s\" from \"%s\"...\n", name,
topDir);
Q_sprintf(libPath, sizeof(libPath), "%s%c%s", topDir, PATH_SEP,
name);
if(!(dllhandle = Sys_LoadLibrary(libPath))){
const char *basePath = cvargetstr("fs_basepath");
if(!basePath || !*basePath)
basePath = ".";
if(fscomparefname(topDir, basePath)){
comprintf("Trying to load \"%s\" from \"%s\"...\n",
name, basePath);
Q_sprintf(libPath, sizeof(libPath), "%s%c%s",
basePath, PATH_SEP, name);
dllhandle = Sys_LoadLibrary(libPath);
}
if(!dllhandle)
comprintf("Loading \"%s\" failed\n", name);
}
}
return dllhandle;
}
开发者ID:icanhas,项目名称:yantar,代码行数:46,代码来源:main.c
示例17: CL_SaveShot_f
/*
==================
CL_SaveShot_f
mini-pic in loadgame menu
==================
*/
void CL_SaveShot_f( void )
{
if( Cmd_Argc() < 2 )
{
Msg( "Usage: saveshot <savename>\n" );
return;
}
Q_sprintf( cls.shotname, "save/%s.bmp", Cmd_Argv( 1 ));
cls.scrshot_action = scrshot_savegame; // build new frame for saveshot
}
开发者ID:mittorn,项目名称:xash3d,代码行数:18,代码来源:cl_cmds.c
示例18: CL_DemoShot_f
/*
==================
CL_DemoShot_f
mini-pic in playdemo menu
==================
*/
void CL_DemoShot_f( void )
{
if( Cmd_Argc() < 2 )
{
Msg( "Usage: demoshot <demoname>\n" );
return;
}
Q_sprintf( cls.shotname, "demos/%s.bmp", Cmd_Argv( 1 ));
cls.scrshot_action = scrshot_demoshot; // build new frame for demoshot
}
开发者ID:mittorn,项目名称:xash3d,代码行数:18,代码来源:cl_cmds.c
示例19: sysinit
void
sysinit(void)
{
char pidbuf[16];
cmdadd("in_restart", Sys_In_Restart_f);
cvarsetstr("arch", OS_STRING " " ARCH_STRING);
cvarsetstr("username", sysgetcurrentuser());
Q_sprintf(pidbuf, sizeof(pidbuf), "%d", Sys_PID());
cvarget("pid", pidbuf, CVAR_ROM);
cvarsetdesc("pid", "process ID, for debugging purposes");
}
开发者ID:icanhas,项目名称:yantar,代码行数:12,代码来源:main.c
示例20: R_ScreenShotJPEG_f
void
R_ScreenShotJPEG_f(void)
{
char checkname[MAX_OSPATH];
static int lastNumber = -1;
qbool silent;
if(!strcmp(ri.cmdargv(1), "levelshot")){
R_LevelShot();
return;
}
if(!strcmp(ri.cmdargv(1), "silent")){
silent = qtrue;
}else{
silent = qfalse;
}
if(ri.cmdargc() == 2 && !silent){
/* explicit filename */
Q_sprintf(checkname, MAX_OSPATH, "screenshots/%s.jpg", ri.cmdargv(1));
}else{
/* scan for a free filename */
/* if we have saved a previous screenshot, don't scan
* again, because recording demo avis can involve
* thousands of shots */
if(lastNumber == -1){
lastNumber = 0;
}
/* scan for a free number */
for(; lastNumber <= 9999; lastNumber++){
R_ScreenshotFilenameJPEG(lastNumber, checkname);
if(!ri.fsfileexists(checkname)){
break; /* file doesn't exist */
}
}
if(lastNumber == 10000){
ri.Printf (PRINT_ALL, "ScreenShot: Couldn't create a file\n");
return;
}
lastNumber++;
}
R_TakeScreenshot(0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname, qtrue);
if(!silent){
ri.Printf (PRINT_ALL, "Wrote %s\n", checkname);
}
}
开发者ID:icanhas,项目名称:yantar,代码行数:53,代码来源:init.c
注:本文中的Q_sprintf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论