本文整理汇总了C++中Q_strncpyz函数的典型用法代码示例。如果您正苦于以下问题:C++ Q_strncpyz函数的具体用法?C++ Q_strncpyz怎么用?C++ Q_strncpyz使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Q_strncpyz函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GLimp_Init
/*
** GLimp_Init
**
** This is the platform specific OpenGL initialization function. It
** is responsible for loading OpenGL, initializing it, setting
** extensions, creating a window of the appropriate size, doing
** fullscreen manipulations, etc. Its overall responsibility is
** to make sure that a functional OpenGL subsystem is operating
** when it returns to the ref.
*/
void GLimp_Init( void ) {
char buf[1024];
cvar_t *lastValidRenderer = ri.Cvar_Get( "r_lastValidRenderer", "(uninitialized)", CVAR_ARCHIVE );
cvar_t *cv;
ri.Printf( PRINT_ALL, "Initializing OpenGL subsystem\n" );
//
// check OS version to see if we can do fullscreen display changes
//
if ( !GLW_CheckOSVersion() ) {
ri.Error( ERR_VID_FATAL, "GLimp_Init() - incorrect operating system\n" );
}
// save off hInstance and wndproc
cv = ri.Cvar_Get( "win_hinstance", "", 0 );
sscanf( cv->string, "%i", (int *)&g_wv.hInstance );
cv = ri.Cvar_Get( "win_wndproc", "", 0 );
sscanf( cv->string, "%i", (int *)&glw_state.wndproc );
r_allowSoftwareGL = ri.Cvar_Get( "r_allowSoftwareGL", "0", CVAR_LATCH );
r_maskMinidriver = ri.Cvar_Get( "r_maskMinidriver", "0", CVAR_LATCH );
// load appropriate DLL and initialize subsystem
GLW_StartOpenGL();
// get our config strings
Q_strncpyz( glConfig.vendor_string, qglGetString( GL_VENDOR ), sizeof( glConfig.vendor_string ) );
Q_strncpyz( glConfig.renderer_string, qglGetString( GL_RENDERER ), sizeof( glConfig.renderer_string ) );
Q_strncpyz( glConfig.version_string, qglGetString( GL_VERSION ), sizeof( glConfig.version_string ) );
Q_strncpyz( glConfig.extensions_string, qglGetString( GL_EXTENSIONS ), sizeof( glConfig.extensions_string ) );
// TTimo - safe check
if ( strlen( qglGetString( GL_EXTENSIONS ) ) >= sizeof( glConfig.extensions_string ) ) {
Com_Printf( S_COLOR_YELLOW "WARNNING: GL extensions string too long (%d), truncated to %d\n", strlen( qglGetString( GL_EXTENSIONS ) ), sizeof( glConfig.extensions_string ) );
}
//
// chipset specific configuration
//
Q_strncpyz( buf, glConfig.renderer_string, sizeof( buf ) );
Q_strlwr( buf );
//
// NOTE: if changing cvars, do it within this block. This allows them
// to be overridden when testing driver fixes, etc. but only sets
// them to their default state when the hardware is first installed/run.
//
if ( Q_stricmp( lastValidRenderer->string, glConfig.renderer_string ) ) {
glConfig.hardwareType = GLHW_GENERIC;
ri.Cvar_Set( "r_textureMode", "GL_LINEAR_MIPMAP_NEAREST" );
// VOODOO GRAPHICS w/ 2MB
if ( strstr( buf, "voodoo graphics/1 tmu/2 mb" ) ) {
ri.Cvar_Set( "r_picmip", "2" );
ri.Cvar_Get( "r_picmip", "1", CVAR_ARCHIVE | CVAR_LATCH );
} else
{
//----(SA) FIXME: RETURN TO DEFAULT Another id build change for DK/DM
ri.Cvar_Set( "r_picmip", "1" ); //----(SA) was "1" // JPW NERVE back to 1
//----(SA)
if ( strstr( buf, "rage 128" ) || strstr( buf, "rage128" ) ) {
ri.Cvar_Set( "r_finish", "0" );
}
// Savage3D and Savage4 should always have trilinear enabled
else if ( strstr( buf, "savage3d" ) || strstr( buf, "s3 savage4" ) ) {
ri.Cvar_Set( "r_texturemode", "GL_LINEAR_MIPMAP_LINEAR" );
}
}
}
//
// this is where hardware specific workarounds that should be
// detected/initialized every startup should go.
//
if ( strstr( buf, "banshee" ) || strstr( buf, "voodoo3" ) ) {
glConfig.hardwareType = GLHW_3DFX_2D3D;
}
// VOODOO GRAPHICS w/ 2MB
else if ( strstr( buf, "voodoo graphics/1 tmu/2 mb" ) ) {
} else if ( strstr( buf, "glzicd" ) ) {
} else if ( strstr( buf, "rage pro" ) /*|| strstr( buf, "Rage Pro")*/ || strstr( buf, "ragepro" ) ) {
glConfig.hardwareType = GLHW_RAGEPRO;
ri.Printf( PRINT_WARNING, "WARNING: Rage Pro hardware is unsupported. Rendering errors may occur.\n" );
} else if ( strstr( buf, "rage 128" ) ) {
} else if ( strstr( buf, "permedia2" ) ) {
glConfig.hardwareType = GLHW_PERMEDIA2;
//.........这里部分代码省略.........
开发者ID:chegestar,项目名称:omni-bot,代码行数:101,代码来源:win_glimp.c
示例2: RE_RegisterModel
/*
====================
RE_RegisterModel
Loads in a model for the given name
Zero will be returned if the model fails to load.
An entry will be retained for failed models as an
optimization to prevent disk rescanning if they are
asked for again.
====================
*/
qhandle_t RE_RegisterModel( const char *name )
{
model_t *mod;
unsigned *buffer;
int bufferLen = 0;
int lod;
int ident;
qboolean loaded;
qhandle_t hModel;
int numLoaded;
if ( !name || !name[ 0 ] )
{
ri.Printf( PRINT_ALL, "RE_RegisterModel: NULL name\n" );
return 0;
}
if ( strlen( name ) >= MAX_QPATH )
{
Com_Printf( "Model name exceeds MAX_QPATH\n" );
return 0;
}
// search the currently loaded models
for ( hModel = 1; hModel < tr.numModels; hModel++ )
{
mod = tr.models[ hModel ];
if ( !strcmp( mod->name, name ) )
{
if ( mod->type == MOD_BAD )
{
return 0;
}
return hModel;
}
}
// allocate a new model_t
if ( ( mod = R_AllocModel() ) == NULL )
{
ri.Printf( PRINT_WARNING, "RE_RegisterModel: R_AllocModel() failed for '%s'\n", name );
return 0;
}
// only set the name after the model has been successfully loaded
Q_strncpyz( mod->name, name, sizeof( mod->name ) );
// make sure the render thread is stopped
R_SyncRenderThread();
mod->numLods = 0;
// load the files
numLoaded = 0;
#if defined( COMPAT_ET )
if ( strstr( name, ".mds" ) || strstr( name, ".mdm" ) || strstr( name, ".mdx" ) || strstr( name, ".md5mesh" ) || strstr( name, ".psk" ) )
#else
if ( strstr( name, ".md5mesh" ) || strstr( name, ".psk" ) )
#endif
{
// try loading skeletal file
loaded = qfalse;
bufferLen = ri.FS_ReadFile( name, ( void ** ) &buffer );
if ( buffer )
{
loadmodel = mod;
ident = LittleLong( * ( unsigned * ) buffer );
#if defined( COMPAT_ET )
#if 0
if ( ident == MDS_IDENT )
{
loaded = R_LoadMDS( mod, buffer, name );
}
else
#endif
if ( ident == MDM_IDENT )
{
loaded = R_LoadMDM( mod, buffer, name );
}
else if ( ident == MDX_IDENT )
//.........这里部分代码省略.........
开发者ID:ghostmod,项目名称:Unvanquished,代码行数:101,代码来源:tr_model.c
示例3: R_LoadMD5Anim
//.........这里部分代码省略.........
if ( Q_stricmp( token, "numAnimatedComponents" ) )
{
ri.Printf( PRINT_WARNING, "RE_RegisterAnimation: expected 'numAnimatedComponents' found '%s' in model '%s'\n", token,
name );
return qfalse;
}
token = COM_ParseExt2( &buf_p, qfalse );
anim->numAnimatedComponents = atoi( token );
// parse hierarchy {
token = COM_ParseExt2( &buf_p, qtrue );
if ( Q_stricmp( token, "hierarchy" ) )
{
ri.Printf( PRINT_WARNING, "RE_RegisterAnimation: expected 'hierarchy' found '%s' in model '%s'\n", token, name );
return qfalse;
}
token = COM_ParseExt2( &buf_p, qfalse );
if ( Q_stricmp( token, "{" ) )
{
ri.Printf( PRINT_WARNING, "RE_RegisterAnimation: expected '{' found '%s' in model '%s'\n", token, name );
return qfalse;
}
// parse all the channels
anim->channels = ri.Hunk_Alloc( sizeof( md5Channel_t ) * anim->numChannels, h_low );
for ( i = 0, channel = anim->channels; i < anim->numChannels; i++, channel++ )
{
token = COM_ParseExt2( &buf_p, qtrue );
Q_strncpyz( channel->name, token, sizeof( channel->name ) );
//ri.Printf(PRINT_ALL, "RE_RegisterAnimation: '%s' has channel '%s'\n", name, channel->name);
token = COM_ParseExt2( &buf_p, qfalse );
channel->parentIndex = atoi( token );
if ( channel->parentIndex >= anim->numChannels )
{
ri.Error( ERR_DROP, "RE_RegisterAnimation: '%s' has channel '%s' with bad parent index %i while numBones is %i\n",
name, channel->name, channel->parentIndex, anim->numChannels );
}
token = COM_ParseExt2( &buf_p, qfalse );
channel->componentsBits = atoi( token );
token = COM_ParseExt2( &buf_p, qfalse );
channel->componentsOffset = atoi( token );
}
// parse }
token = COM_ParseExt2( &buf_p, qtrue );
if ( Q_stricmp( token, "}" ) )
{
ri.Printf( PRINT_WARNING, "RE_RegisterAnimation: expected '}' found '%s' in model '%s'\n", token, name );
return qfalse;
}
// parse bounds {
token = COM_ParseExt2( &buf_p, qtrue );
if ( Q_stricmp( token, "bounds" ) )
开发者ID:gfx0,项目名称:Unvanquished,代码行数:67,代码来源:tr_animation.c
示例4: Cmd_ArgsBuffer
/*
============
Cmd_ArgsBuffer
The interpreted versions use this because
they can't have pointers returned to them
============
*/
M_EXPORT void M_DECL Cmd_ArgsBuffer( char *buffer, int bufferLength ) {
Q_strncpyz( buffer, Cmd_Args(), bufferLength );
}
开发者ID:DaveHogan,项目名称:FQuake3,代码行数:11,代码来源:cmd.c
示例5: UI_RegisterClientModelname
/*
==========================
UI_RegisterClientModelname
==========================
*/
qboolean UI_RegisterClientModelname( playerInfo_t *pi, const char *modelSkinName, const char *headModelSkinName, const char *teamName ) {
char modelName[MAX_QPATH];
char skinName[MAX_QPATH];
char headModelName[MAX_QPATH];
char headSkinName[MAX_QPATH];
char filename[MAX_QPATH];
char *slash;
pi->torsoModel = 0;
pi->headModel = 0;
if ( !modelSkinName[0] ) {
return qfalse;
}
Q_strncpyz( modelName, modelSkinName, sizeof( modelName ) );
slash = strchr( modelName, '/' );
if ( !slash ) {
// modelName did not include a skin name
Q_strncpyz( skinName, "default", sizeof( skinName ) );
} else {
Q_strncpyz( skinName, slash + 1, sizeof( skinName ) );
*slash = '\0';
}
Q_strncpyz( headModelName, headModelSkinName, sizeof( headModelName ) );
slash = strchr( headModelName, '/' );
if ( !slash ) {
// modelName did not include a skin name
Q_strncpyz( headSkinName, "default", sizeof( skinName ) );
} else {
Q_strncpyz( headSkinName, slash + 1, sizeof( skinName ) );
*slash = '\0';
}
// load cmodels before models so filecache works
Com_sprintf( filename, sizeof( filename ), "models/players/%s/lower.md3", modelName );
pi->legsModel = trap_R_RegisterModel( filename );
if ( !pi->legsModel ) {
Com_sprintf( filename, sizeof( filename ), "models/players/characters/%s/lower.md3", modelName );
pi->legsModel = trap_R_RegisterModel( filename );
if ( !pi->legsModel ) {
Com_Printf( "Failed to load model file %s\n", filename );
return qfalse;
}
}
Com_sprintf( filename, sizeof( filename ), "models/players/%s/upper.md3", modelName );
pi->torsoModel = trap_R_RegisterModel( filename );
if ( !pi->torsoModel ) {
Com_sprintf( filename, sizeof( filename ), "models/players/characters/%s/upper.md3", modelName );
pi->torsoModel = trap_R_RegisterModel( filename );
if ( !pi->torsoModel ) {
Com_Printf( "Failed to load model file %s\n", filename );
return qfalse;
}
}
if (headModelName[0] == '*' ) {
Com_sprintf( filename, sizeof( filename ), "models/players/heads/%s/%s.md3", &headModelName[1], &headModelName[1] );
}
else {
Com_sprintf( filename, sizeof( filename ), "models/players/%s/head.md3", headModelName );
}
pi->headModel = trap_R_RegisterModel( filename );
if ( !pi->headModel && headModelName[0] != '*') {
Com_sprintf( filename, sizeof( filename ), "models/players/heads/%s/%s.md3", headModelName, headModelName );
pi->headModel = trap_R_RegisterModel( filename );
}
if (!pi->headModel) {
Com_Printf( "Failed to load model file %s\n", filename );
return qfalse;
}
// if any skins failed to load, fall back to default
if ( !UI_RegisterClientSkin( pi, modelName, skinName, headModelName, headSkinName, teamName) ) {
if ( !UI_RegisterClientSkin( pi, modelName, "default", headModelName, "default", teamName ) ) {
Com_Printf( "Failed to load skin file: %s : %s\n", modelName, skinName );
return qfalse;
}
}
// load the animations
Com_sprintf( filename, sizeof( filename ), "models/players/%s/animation.cfg", modelName );
if ( !UI_ParseAnimationFile( filename, pi->animations ) ) {
Com_sprintf( filename, sizeof( filename ), "models/players/characters/%s/animation.cfg", modelName );
if ( !UI_ParseAnimationFile( filename, pi->animations ) ) {
Com_Printf( "Failed to load animation file %s\n", filename );
return qfalse;
}
}
//.........这里部分代码省略.........
开发者ID:openmoh,项目名称:ioq3,代码行数:101,代码来源:ui_players.c
示例6: Cmd_TokenizeString2
/*
============
Cmd_TokenizeString
Parses the given string into command line tokens.
The text is copied to a seperate buffer and 0 characters
are inserted in the apropriate place, The argv array
will point into this temporary buffer.
============
*/
static void Cmd_TokenizeString2(const char *text_in, qboolean ignoreQuotes)
{
const char *text;
char *textOut;
// clear previous args
cmd_argc = 0;
if (!text_in)
{
return;
}
Q_strncpyz(cmd_cmd, text_in, sizeof(cmd_cmd));
text = text_in;
textOut = cmd_tokenized;
while (1)
{
if (cmd_argc == MAX_STRING_TOKENS)
{
return; // this is usually something malicious
}
while (1)
{
// skip whitespace
while (*text && *text <= ' ')
{
text++;
}
if (!*text)
{
return; // all tokens parsed
}
// skip // comments
if (text[0] == '/' && text[1] == '/')
{
// lets us put 'http://' in commandlines
if (text == text_in || (text > text_in && text[-1] != ':'))
{
return; // all tokens parsed
}
}
// skip /* */ comments
if (text[0] == '/' && text[1] == '*')
{
while (*text && (text[0] != '*' || text[1] != '/'))
{
text++;
}
if (!*text)
{
return; // all tokens parsed
}
text += 2;
}
else
{
break; // we are ready to parse a token
}
}
// handle quoted strings
// NOTE: this doesn't handle \" escaping
if (!ignoreQuotes && *text == '"')
{
cmd_argv[cmd_argc] = textOut;
cmd_argc++;
text++;
while (*text && *text != '"')
{
*textOut++ = *text++;
}
*textOut++ = 0;
if (!*text)
{
return; // all tokens parsed
}
text++;
continue;
}
// regular token
cmd_argv[cmd_argc] = textOut;
cmd_argc++;
//.........这里部分代码省略.........
开发者ID:dstaesse,项目名称:etlegacy,代码行数:101,代码来源:cmd.c
示例7: UI_SPPostgameMenu_f
/*
=================
UI_SPPostgameMenu_f
=================
*/
void UI_SPPostgameMenu_f( void ) {
int playerGameRank;
int playerClientNum;
int n;
int oldFrags, newFrags;
const char *arena;
int awardValues[6];
char map[MAX_QPATH];
char info[MAX_INFO_STRING];
memset( &postgameMenuInfo, 0, sizeof(postgameMenuInfo) );
trap_GetConfigString( CS_SYSTEMINFO, info, sizeof(info) );
postgameMenuInfo.serverId = atoi( Info_ValueForKey( info, "sv_serverid" ) );
trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) );
Q_strncpyz( map, Info_ValueForKey( info, "mapname" ), sizeof(map) );
arena = UI_GetArenaInfoByMap( map );
if ( !arena ) {
return;
}
Q_strncpyz( arenainfo, arena, sizeof(arenainfo) );
postgameMenuInfo.level = atoi( Info_ValueForKey( arenainfo, "num" ) );
postgameMenuInfo.numClients = atoi( UI_Argv( 1 ) );
playerClientNum = atoi( UI_Argv( 2 ) );
playerGameRank = 8; // in case they ended game as a spectator
if( postgameMenuInfo.numClients > MAX_SCOREBOARD_CLIENTS ) {
postgameMenuInfo.numClients = MAX_SCOREBOARD_CLIENTS;
}
for( n = 0; n < postgameMenuInfo.numClients; n++ ) {
postgameMenuInfo.clientNums[n] = atoi( UI_Argv( 8 + n * 3 + 1 ) );
postgameMenuInfo.ranks[n] = atoi( UI_Argv( 8 + n * 3 + 2 ) );
postgameMenuInfo.scores[n] = atoi( UI_Argv( 8 + n * 3 + 3 ) );
if( postgameMenuInfo.clientNums[n] == playerClientNum ) {
playerGameRank = (postgameMenuInfo.ranks[n] & ~RANK_TIED_FLAG) + 1;
}
}
UI_SetBestScore( postgameMenuInfo.level, playerGameRank );
// process award stats and prepare presentation data
awardValues[AWARD_ACCURACY] = atoi( UI_Argv( 3 ) );
awardValues[AWARD_IMPRESSIVE] = atoi( UI_Argv( 4 ) );
awardValues[AWARD_EXCELLENT] = atoi( UI_Argv( 5 ) );
awardValues[AWARD_GAUNTLET] = atoi( UI_Argv( 6 ) );
awardValues[AWARD_FRAGS] = atoi( UI_Argv( 7 ) );
awardValues[AWARD_PERFECT] = atoi( UI_Argv( 8 ) );
postgameMenuInfo.numAwards = 0;
if( awardValues[AWARD_ACCURACY] >= 50 ) {
UI_LogAwardData( AWARD_ACCURACY, 1 );
postgameMenuInfo.awardsEarned[postgameMenuInfo.numAwards] = AWARD_ACCURACY;
postgameMenuInfo.awardsLevels[postgameMenuInfo.numAwards] = awardValues[AWARD_ACCURACY];
postgameMenuInfo.numAwards++;
}
if( awardValues[AWARD_IMPRESSIVE] ) {
UI_LogAwardData( AWARD_IMPRESSIVE, awardValues[AWARD_IMPRESSIVE] );
postgameMenuInfo.awardsEarned[postgameMenuInfo.numAwards] = AWARD_IMPRESSIVE;
postgameMenuInfo.awardsLevels[postgameMenuInfo.numAwards] = awardValues[AWARD_IMPRESSIVE];
postgameMenuInfo.numAwards++;
}
if( awardValues[AWARD_EXCELLENT] ) {
UI_LogAwardData( AWARD_EXCELLENT, awardValues[AWARD_EXCELLENT] );
postgameMenuInfo.awardsEarned[postgameMenuInfo.numAwards] = AWARD_EXCELLENT;
postgameMenuInfo.awardsLevels[postgameMenuInfo.numAwards] = awardValues[AWARD_EXCELLENT];
postgameMenuInfo.numAwards++;
}
if( awardValues[AWARD_GAUNTLET] ) {
UI_LogAwardData( AWARD_GAUNTLET, awardValues[AWARD_GAUNTLET] );
postgameMenuInfo.awardsEarned[postgameMenuInfo.numAwards] = AWARD_GAUNTLET;
postgameMenuInfo.awardsLevels[postgameMenuInfo.numAwards] = awardValues[AWARD_GAUNTLET];
postgameMenuInfo.numAwards++;
}
oldFrags = UI_GetAwardLevel( AWARD_FRAGS ) / 100;
UI_LogAwardData( AWARD_FRAGS, awardValues[AWARD_FRAGS] );
newFrags = UI_GetAwardLevel( AWARD_FRAGS ) / 100;
if( newFrags > oldFrags ) {
postgameMenuInfo.awardsEarned[postgameMenuInfo.numAwards] = AWARD_FRAGS;
postgameMenuInfo.awardsLevels[postgameMenuInfo.numAwards] = newFrags * 100;
postgameMenuInfo.numAwards++;
}
if( awardValues[AWARD_PERFECT] ) {
UI_LogAwardData( AWARD_PERFECT, 1 );
postgameMenuInfo.awardsEarned[postgameMenuInfo.numAwards] = AWARD_PERFECT;
//.........这里部分代码省略.........
开发者ID:PropheteMath,项目名称:OpenArenaBB,代码行数:101,代码来源:ui_sppostgame.c
示例8: Cvar_InfoStringBuffer
/*
=====================
Cvar_InfoStringBuffer
=====================
*/
void Cvar_InfoStringBuffer( int bit, char* buff, int buffsize ) {
Q_strncpyz(buff,Cvar_InfoString(bit),buffsize);
}
开发者ID:DarthFutuza,项目名称:JediKnightGalaxies,代码行数:8,代码来源:cvar.cpp
示例9: RE_RegisterModel
/*
====================
RE_RegisterModel
Loads in a model for the given name
Zero will be returned if the model fails to load.
An entry will be retained for failed models as an
optimization to prevent disk rescanning if they are
asked for again.
====================
*/
qhandle_t RE_RegisterModel( const char *name )
{
model_t *mod;
unsigned *buf;
int lod;
int ident;
qboolean loaded;
qhandle_t hModel;
int numLoaded;
if ( !name || !name[0] )
{
CL_RefPrintf( PRINT_ALL, "RE_RegisterModel: NULL name\n" );
return 0;
}
if ( strlen( name ) >= MAX_QPATH )
{
Com_Printf( "Model name exceeds MAX_QPATH\n" );
return 0;
}
//
// search the currently loaded models
//
for ( hModel = 1 ; hModel < tr.numModels; hModel++ )
{
mod = tr.models[hModel];
if ( !strcmp( mod->name, name ) )
{
if( mod->type == MOD_BAD )
{
return 0;
}
return hModel;
}
}
// allocate a new model_t
if ( ( mod = R_AllocModel() ) == NULL )
{
CL_RefPrintf( PRINT_WARNING, "RE_RegisterModel: R_AllocModel() failed for '%s'\n", name);
return 0;
}
// only set the name after the model has been successfully loaded
Q_strncpyz( mod->name, name, sizeof( mod->name ) );
// make sure the render thread is stopped
R_SyncRenderThread();
mod->numLods = 0;
//
// load the files
//
numLoaded = 0;
for ( lod = MD3_MAX_LODS - 1 ; lod >= 0 ; lod-- )
{
char filename[1024];
strcpy( filename, name );
if ( lod != 0 )
{
char namebuf[80];
if ( strrchr( filename, '.' ) )
{
*strrchr( filename, '.' ) = 0;
}
sprintf( namebuf, "_%d.md3", lod );
strcat( filename, namebuf );
}
FS_ReadFile( filename, (void **)&buf );
if ( !buf )
{
continue;
}
loadmodel = mod;
ident = LittleLong(*(unsigned *)buf);
if ( ident == MD4_IDENT )
//.........这里部分代码省略.........
开发者ID:zturtleman,项目名称:recoil,代码行数:101,代码来源:tr_model.c
示例10: G_Say
void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) {
int j;
gentity_t *other;
int color;
char name[64];
// don't let text be too long for malicious reasons
char text[MAX_SAY_TEXT];
char location[64];
if ( g_gametype.integer < GT_TEAM && mode == SAY_TEAM ) {
mode = SAY_ALL;
}
/* LQ3A: Spectators can only talk to other spectators when muted. */
if ((ent->client->sess.sessionTeam == TEAM_SPECTATOR) && g_spectatorMute.integer)
{
mode = SAY_TEAM;
}
switch ( mode ) {
default:
case SAY_ALL:
G_LogPrintf( "say: %s: %s\n", ent->client->pers.netname, chatText );
Com_sprintf (name, sizeof(name), "%s%c%c"EC": ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE );
color = COLOR_GREEN;
break;
case SAY_TEAM:
G_LogPrintf( "sayteam: %s: %s\n", ent->client->pers.netname, chatText );
if (Team_GetLocationMsg(ent, location, sizeof(location)))
Com_sprintf (name, sizeof(name), EC"(%s%c%c"EC") (%s)"EC": ",
ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE, location);
else
Com_sprintf (name, sizeof(name), EC"(%s%c%c"EC")"EC": ",
ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE );
color = COLOR_CYAN;
break;
case SAY_TELL:
if (target && g_gametype.integer >= GT_TEAM &&
target->client->sess.sessionTeam == ent->client->sess.sessionTeam &&
Team_GetLocationMsg(ent, location, sizeof(location)))
Com_sprintf (name, sizeof(name), EC"[%s%c%c"EC"] (%s)"EC": ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE, location );
else
Com_sprintf (name, sizeof(name), EC"[%s%c%c"EC"]"EC": ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE );
color = COLOR_MAGENTA;
break;
}
Q_strncpyz( text, chatText, sizeof(text) );
if ( target ) {
G_SayTo( ent, target, mode, color, name, text );
return;
}
// echo the text to the console
if ( g_dedicated.integer ) {
G_Printf( "%s%s\n", name, text);
}
// send it to all the apropriate clients
for (j = 0; j < level.maxclients; j++) {
other = &g_entities[j];
G_SayTo( ent, other, mode, color, name, text );
}
}
开发者ID:monoknot,项目名称:loaded-q3a,代码行数:65,代码来源:g_cmds.c
示例11: Cmd_CallTeamVote_f
/*
==================
Cmd_CallTeamVote_f
==================
*/
void Cmd_CallTeamVote_f( gentity_t *ent ) {
int i, team, cs_offset;
char arg1[MAX_STRING_TOKENS];
char arg2[MAX_STRING_TOKENS];
team = ent->client->sess.sessionTeam;
if ( team == TEAM_RED )
cs_offset = 0;
else if ( team == TEAM_BLUE )
cs_offset = 1;
else
return;
if ( !g_allowVote.integer ) {
trap_SendServerCommand( ent-g_entities, "print \"Voting not allowed here.\n\"" );
return;
}
if ( level.teamVoteTime[cs_offset] ) {
trap_SendServerCommand( ent-g_entities, "print \"A team vote is already in progress.\n\"" );
return;
}
if ( ent->client->pers.teamVoteCount >= MAX_VOTE_COUNT ) {
trap_SendServerCommand( ent-g_entities, "print \"You have called the maximum number of team votes.\n\"" );
return;
}
if ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {
trap_SendServerCommand( ent-g_entities, "print \"Not allowed to call a vote as spectator.\n\"" );
return;
}
// make sure it is a valid command to vote on
trap_Argv( 1, arg1, sizeof( arg1 ) );
arg2[0] = '\0';
for ( i = 2; i < trap_Argc(); i++ ) {
if (i > 2)
strcat(arg2, " ");
trap_Argv( i, &arg2[strlen(arg2)], sizeof( arg2 ) - strlen(arg2) );
}
if( strchr( arg1, ';' ) || strchr( arg2, ';' ) ) {
trap_SendServerCommand( ent-g_entities, "print \"Invalid vote string.\n\"" );
return;
}
if ( !Q_stricmp( arg1, "leader" ) ) {
char netname[MAX_NETNAME], leader[MAX_NETNAME];
if ( !arg2[0] ) {
i = ent->client->ps.clientNum;
}
else {
// numeric values are just slot numbers
for (i = 0; i < 3; i++) {
if ( !arg2[i] || arg2[i] < '0' || arg2[i] > '9' )
break;
}
if ( i >= 3 || !arg2[i]) {
i = atoi( arg2 );
if ( i < 0 || i >= level.maxclients ) {
trap_SendServerCommand( ent-g_entities, va("print \"Bad client slot: %i\n\"", i) );
return;
}
if ( !g_entities[i].inuse ) {
trap_SendServerCommand( ent-g_entities, va("print \"Client %i is not active\n\"", i) );
return;
}
}
else {
Q_strncpyz(leader, arg2, sizeof(leader));
Q_CleanStr(leader);
for ( i = 0 ; i < level.maxclients ; i++ ) {
if ( level.clients[i].pers.connected == CON_DISCONNECTED )
continue;
if (level.clients[i].sess.sessionTeam != team)
continue;
Q_strncpyz(netname, level.clients[i].pers.netname, sizeof(netname));
Q_CleanStr(netname);
if ( !Q_stricmp(netname, leader) ) {
break;
}
}
if ( i >= level.maxclients ) {
trap_SendServerCommand( ent-g_entities, va("print \"%s is not a valid player on your team.\n\"", arg2) );
return;
}
}
}
Com_sprintf(arg2, sizeof(arg2), "%d", i);
} else {
trap_SendServerCommand( ent-g_entities, "print \"Invalid vote string.\n\"" );
trap_SendServerCommand( ent-g_entities, "print \"Team vote commands are: leader <player>.\n\"" );
return;
}
//.........这里部分代码省略.........
开发者ID:monoknot,项目名称:loaded-q3a,代码行数:101,代码来源:g_cmds.c
示例12: BG_SiegeParseClassFile
void BG_SiegeParseClassFile(const char *filename, siegeClassDesc_t *descBuffer)
{
fileHandle_t f;
int len;
int i;
char classInfo[4096];
char parseBuf[4096];
len = trap->FS_Open( filename, &f, FS_READ );
if (!f || len >= 4096)
{
return;
}
trap->FS_Read( classInfo, len, f );
trap->FS_Close( f );
classInfo[len] = 0;
//first get the description if we have a buffer for it
if (descBuffer)
{
if (!BG_SiegeGetPairedValue(classInfo, "description", descBuffer->desc))
{
Q_strncpyz(descBuffer->desc, "DESCRIPTION UNAVAILABLE", sizeof(descBuffer->desc));
}
//Hit this assert? Memory has already been trashed. Increase
//SIEGE_CLASS_DESC_LEN.
assert(strlen(descBuffer->desc) < SIEGE_CLASS_DESC_LEN);
}
BG_SiegeGetValueGroup(classInfo, "ClassInfo", classInfo);
//Parse name
if (BG_SiegeGetPairedValue(classInfo, "name", parseBuf))
{
Q_strncpyz(bgSiegeClasses[bgNumSiegeClasses].name, parseBuf, sizeof(bgSiegeClasses[0].name));
}
else
{
Com_Error(ERR_DROP, "Siege class without name entry");
}
//Parse forced model
if (BG_SiegeGetPairedValue(classInfo, "model", parseBuf))
{
Q_strncpyz(bgSiegeClasses[bgNumSiegeClasses].forcedModel, parseBuf, sizeof(bgSiegeClasses[0].forcedModel));
}
else
{ //It's ok if there isn't one, it's optional.
bgSiegeClasses[bgNumSiegeClasses].forcedModel[0] = 0;
}
//Parse forced skin
if (BG_SiegeGetPairedValue(classInfo, "skin", parseBuf))
{
Q_strncpyz(bgSiegeClasses[bgNumSiegeClasses].forcedSkin, parseBuf, sizeof(bgSiegeClasses[0].forcedSkin));
}
else
{ //It's ok if there isn't one, it's optional.
bgSiegeClasses[bgNumSiegeClasses].forcedSkin[0] = 0;
}
//Parse first saber
if (BG_SiegeGetPairedValue(classInfo, "saber1", parseBuf))
{
Q_strncpyz(bgSiegeClasses[bgNumSiegeClasses].saber1, parseBuf, sizeof(bgSiegeClasses[0].saber1));
}
else
{ //It's ok if there isn't one, it's optional.
bgSiegeClasses[bgNumSiegeClasses].saber1[0] = 0;
}
//Parse second saber
if (BG_SiegeGetPairedValue(classInfo, "saber2", parseBuf))
{
Q_strncpyz(bgSiegeClasses[bgNumSiegeClasses].saber2, parseBuf, sizeof(bgSiegeClasses[0].saber2));
}
else
{ //It's ok if there isn't one, it's optional.
bgSiegeClasses[bgNumSiegeClasses].saber2[0] = 0;
}
//Parse forced saber stance
if (BG_SiegeGetPairedValue(classInfo, "saberstyle", parseBuf))
{
bgSiegeClasses[bgNumSiegeClasses].saberStance = BG_SiegeTranslateGenericTable(parseBuf, StanceTable, qtrue);
}
else
{ //It's ok if there isn't one, it's optional.
bgSiegeClasses[bgNumSiegeClasses].saberStance = 0;
}
//Parse forced saber color
if (BG_SiegeGetPairedValue(classInfo, "sabercolor", parseBuf))
{
bgSiegeClasses[bgNumSiegeClasses].forcedSaberColor = atoi(parseBuf);
//.........这里部分代码省略.........
开发者ID:BSzili,项目名称:OpenJK,代码行数:101,代码来源:bg_saga.c
示例13: BG_SiegeTranslateForcePowers
//======================================
//Class loading functions
//======================================
void BG_SiegeTranslateForcePowers(char *buf, siegeClass_t *siegeClass)
{
char checkPower[1024];
char checkLevel[256];
int l = 0;
int k = 0;
int j = 0;
int i = 0;
int parsedLevel = 0;
qboolean allPowers = qfalse;
qboolean noPowers = qfalse;
if (!Q_stricmp(buf, "FP_ALL"))
{ //this is a special case, just give us all the powers on level 3
allPowers = qtrue;
}
if (buf[0] == '0' && !buf[1])
{ //no powers then
noPowers = qtrue;
}
//First clear out the powers, or in the allPowers case, give us all level 3.
while (i < NUM_FORCE_POWERS)
{
if (allPowers)
{
siegeClass->forcePowerLevels[i] = FORCE_LEVEL_3;
}
else
{
siegeClass->forcePowerLevels[i] = 0;
}
i++;
}
if (allPowers || noPowers)
{ //we're done now then.
return;
}
i = 0;
while (buf[i])
{ //parse through the list which is seperated by |, and add all the weapons into a bitflag
if (buf[i] != ' ' && buf[i] != '|')
{
j = 0;
while (buf[i] && buf[i] != ' ' && buf[i] != '|' && buf[i] != ',')
{
checkPower[j] = buf[i];
j++;
i++;
}
checkPower[j] = 0;
if (buf[i] == ',')
{ //parse the power level
i++;
l = 0;
while (buf[i] && buf[i] != ' ' && buf[i] != '|')
{
checkLevel[l] = buf[i];
l++;
i++;
}
checkLevel[l] = 0;
parsedLevel = atoi(checkLevel);
//keep sane limits on the powers
if (parsedLevel < 0)
{
parsedLevel = 0;
}
if (parsedLevel > FORCE_LEVEL_5)
{
parsedLevel = FORCE_LEVEL_5;
}
}
else
{ //if it's not there, assume level 3 I guess.
parsedLevel = 3;
}
if (checkPower[0])
{ //Got the name, compare it against the weapon table strings.
k = 0;
if (!Q_stricmp(checkPower, "FP_JUMP"))
{ //haqery
Q_strncpyz(checkPower, "FP_LEVITATION", sizeof(checkPower));
}
while (FPTable[k].id != -1 && FPTable[k].name[0])
{
if (!Q_stricmp(checkPower, FPTable[k].name))
{ //found it, add the weapon into the weapons value
//.........这里部分代码省略.........
开发者ID:BSzili,项目名称:OpenJK,代码行数:101,代码来源:bg_saga.c
示例14: BG_SiegeParseTeamFile
void BG_SiegeParseTeamFile(const char *filename)
{
fileHandle_t f;
int len;
char teamInfo[2048];
char parseBuf[1024];
char lookString[256];
int i = 1;
qboolean success = qtrue;
len = trap->FS_Open(filename, &f, FS_READ);
if (!f || len >= 2048)
{
return;
}
trap->FS_Read( teamInfo, len, f );
trap->FS_Close( f );
teamInfo[len] = 0;
if (BG_SiegeGetPairedValue(teamInfo, "name", parseBuf))
{
Q_strncpyz(bgSiegeTeams[bgNumSiegeTeams].name, parseBuf, sizeof(bgSiegeTeams[0].name));
}
else
{
Com_Error(ERR_DROP, "Siege team with no name definition");
}
//I don't entirely like doing things this way but it's the easiest way.
#ifdef _CGAME
if (BG_SiegeGetPairedValue(teamInfo, "FriendlyShader", parseBuf))
bgSiegeTeams[bgNumSiegeTeams].friendlyShader = trap->R_RegisterShaderNoMip(parseBuf);
#else
bgSiegeTeams[bgNumSiegeTeams].friendlyShader = 0;
#endif
bgSiegeTeams[bgNumSiegeTeams].numClasses = 0;
if (BG_SiegeGetValueGroup(teamInfo, "Classes", teamInfo))
{
while (success && i < MAX_SIEGE_CLASSES)
{ //keep checking for group values named class# up to MAX_SIEGE_CLASSES until we can't find one.
Q_strncpyz(lookString, va("class%i", i), sizeof(lookString));
success = BG_SiegeGetPairedValue(teamInfo, lookString, parseBuf);
if (!success)
{
break;
}
bgSiegeTeams[bgNumSiegeTeams].classes[bgSiegeTeams[bgNumSiegeTeams].numClasses] = BG_SiegeFindClassByName(parseBuf);
if (!bgSiegeTeams[bgNumSiegeTeams].classes[bgSiegeTeams[bgNumSiegeTeams].numClasses])
{
Com_Printf( "Invalid class specified: '%s'\n", parseBuf);
}
bgSiegeTeams[bgNumSiegeTeams].numClasses++;
i++;
}
}
if (!bgSiegeTeams[bgNumSiegeTeams].numClasses)
{
Com_Error(ERR_DROP, "Team defined with no allowable classes\n");
}
//If we get here then it was a success, so increment the team number
bgNumSiegeTeams++;
}
开发者ID:BSzili,项目名称:OpenJK,代码行数:75,代码来源:bg_saga.c
示例15: Cmd_CleanHomepath_f
/**
* @brief Recursively removes files matching a given pattern from homepath.
*
* Useful for removing incomplete downloads and other garbage.
* Files listed in the com_cleanWhitelist cvar are protected from deletion.
* Additionally, executable and configuration files are protected unless 'force'
* argument is passed to this command.
*/
void Cmd_CleanHomepath_f(void)
{
int i, j, patternFiles = 0, delFiles = 0, totalFiles = 0;
char path[MAX_OSPATH];
qboolean force = qfalse, pretend = qfalse;
// *.so and *.dll are denied per default in FS_Remove but throw a Com_Error() -> game aborts
const char whitelist[] = ".txt .cfg .dat .gm .way .so .dll";
if (Cmd_Argc() < 3)
{
// files in fs_homepath are downloaded again when required - but better print a warning for inexperienced users
Com_Printf("usage: clean [force | pretend] [modname / all] [pattern 1] [pattern n]\n"
"example: clean all *tmp */zzz* etmain/etkey\n"
"Warning: This command deletes files in fs_homepath. If you are not sure how to use this command do not play with fire!\n");
return;
}
// if home- and basepath are same better don't start to clean ...
if (FS_IsSamePath(Cvar_VariableString("fs_homepath"), Cvar_VariableString("fs_basepath")))
{
Com_Printf("Invalid configuration to run clean cmd - 'fs_homepath' and 'fs_basepath' are equal.\n");
return;
}
// avoid unreferenced pk3 runtime issues (not on HD but still referenced in game)
#ifndef DEDICATED
if (cls.state != CA_DISCONNECTED)
{
Com_Printf("You are connected to a server - enter '/disconnect' to run '/clean'.\n");
return;
}
#else
if (com_sv_running && com_sv_running->integer)
{
Com_Printf("Server is running - enter '/killserver' to run '/clean'.\n");
return;
}
#endif // DEDICATED
Cvar_VariableStringBuffer("fs_homepath", path, sizeof(path));
// if there are any command options, they must be at the very beginning
for (i = 1; i < Cmd_Argc(); i++)
{
if (!Q_stricmp(Cmd_Argv(i), "force") || !Q_stricmp(Cmd_Argv(i), "f"))
{
force = qtrue;
continue;
}
if (!Q_stricmp(Cmd_Argv(i), "pretend") || !Q_stricmp(Cmd_Argv(i), "p"))
{
pretend = qtrue;
continue;
}
break;
}
// if the first argument is "all" or "*", search the whole homepath
if (Q_stricmp(Cmd_Argv(i), "all") && Q_stricmp(Cmd_Argv(i), "*"))
{
Q_strcat(path, sizeof(path), va("%c%s", PATH_SEP, Cmd_Argv(i)));
// check if it points to a valid directory
if (FS_OSStatFile(path) != 1)
{
Com_Printf("Cannot commence cleaning, because \"%s\" is not a valid directory under fs_homepath (%s)\n", Cmd_Argv(i), path);
return;
}
}
for (i++; i < Cmd_Argc(); i++)
{
char **pFiles = NULL;
pFiles = Sys_ListFiles(path, NULL, Cmd_Argv(i), &patternFiles, qtrue);
Com_Printf("Found %i files matching the pattern \"%s\" under %s\n", patternFiles, Cmd_Argv(i), path);
for (j = 0; j < patternFiles; j++)
{
char *tokens;
char tmp_whitelist[MAX_OSPATH];
qboolean whitelisted = qfalse;
totalFiles++;
Q_strncpyz(tmp_whitelist, (force ? Cvar_VariableString("com_cleanwhitelist") : va("%s %s", Cvar_VariableString("com_cleanwhitelist"), whitelist)), sizeof(tmp_whitelist));
// Check if this file is in the whitelist
//.........这里部分代码省略.........
开发者ID:dstaesse,项目名称:etlegacy,代码行数:101,代码来源:cmd.c
示例16: RadioBroadcast
void RadioBroadcast (edict_t * ent, int partner, char *msg)
{
int j, i, msg_len, numSnds;
edict_t *other;
radio_msg_t *radio_msgs;
int msg_soundIndex = 0;
char msgname_num[8], filteredmsg[48];
qboolean found = false;
radio_t *radio;
if (!IS_ALIVE(ent))
return;
if (!teamplay->value)
{
if (!DMFLAGS( (DF_MODELTEAMS | DF_SKINTEAMS) ))
return; // don't allow in a non-team setup...
}
radio = &ent->client->resp.radio;
if (radio->power_off)
{
gi.centerprintf (ent, "Your radio is off!");
return;
}
if (partner && radio->partner == NULL)
{
gi.cprintf (ent, PRINT_HIGH, "You don't have a partner.\n");
return;
}
if (radio->gender)
{
radio_msgs = female_radio_msgs;
numSnds = numFemaleSnds;
}
else
{
radio_msgs = male_radio_msgs;
numSnds = numMaleSnds;
}
i = found = 0;
msg_len = 0;
Q_strncpyz(filteredmsg, msg, sizeof(filteredmsg));
for(i = 0; i < numSnds; i++)
{
if (!Q_stricmp(radio_msgs[i].msg, filteredmsg))
{
found = true;
msg_soundIndex = radio_msgs[i].sndIndex;
msg_len = radio_msgs[i].length;
break;
}
}
if (!found)
{
gi.centerprintf (ent, "'%s' is not a valid radio message", filteredmsg);
return;
}
if (radiolog->value)
{
gi.cprintf (NULL, PRINT_CHAT, "[%s RADIO] %s: %s\n",
partner ? "PARTNER" : "TEAM", ent->client->pers.netname, filteredmsg);
}
//TempFile BEGIN
if (Q_stricmp (filteredmsg, "enemyd") == 0)
{
if (ent->client->radio_num_kills > 1 && ent->client->radio_num_kills <= 10)
{
// If we are reporting enemy down, add the number of kills.
sprintf( msgname_num, "%i", ent->client->radio_num_kills );
ent->client->radio_num_kills = 0; // prevent from getting into an endless loop
RadioBroadcast(ent, partner, msgname_num); // Now THAT'S recursion! =)
}
ent->client->radio_num_kills = 0;
}
//TempFile END
//AQ2:TNG Slicer
if (radio_repeat->value)
{ //SLIC2 Optimization
if (CheckForRepeat (ent, i) == false)
return;
}
if (radio_max->value)
{
if (CheckForFlood (ent) == false)
return;
}
//AQ2:TNG END
//.........这里部分代码省略.........
开发者ID:Raptor007,项目名称:aq2-tng,代码行数:101,代码来源:a_radio.c
示例17: Cmd_ArgsBuffer
/*
============
Cmd_ArgsBuffer
The interpreted versions use this because
they can't have pointers returned to them
============
*/
void Cmd_ArgsBuffer(char *buffer, int bufferLength)
{
Q_strncpyz(buffer, Cmd_Args(), bufferLength);
}
开发者ID:dstaesse,项目名称:etlegacy,代码行数:12,代码来源:cmd.c
示例18: NET_StringToAdr
|
请发表评论