本文整理汇总了C++中Q_strncatz函数的典型用法代码示例。如果您正苦于以下问题:C++ Q_strncatz函数的具体用法?C++ Q_strncatz怎么用?C++ Q_strncatz使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Q_strncatz函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CG_AddPrint_Cmd_f
/*
* CG_AddPrint_Cmd_f
*/
static void CG_AddPrint_Cmd_f( void ) {
cg_subtitle_t *sub;
sub = CG_Democam_RegisterSubtitle();
if( !sub ) {
CG_Printf( "DemoCam Error: Failed to allocate the subtitle\n" );
return;
}
if( trap_Cmd_Argc() > 1 ) {
char str[MAX_STRING_CHARS]; // one line of the console can't handle more than this
int i;
str[0] = 0;
for( i = 1; i < trap_Cmd_Argc(); i++ ) {
Q_strncatz( str, trap_Cmd_Argv( i ), sizeof( str ) );
if( i < trap_Cmd_Argc() - 1 ) {
Q_strncatz( str, " ", sizeof( str ) );
}
}
sub->text = CG_CopyString( str );
} else {
sub->text = CG_CopyString( "" );
}
sub->highprint = true;
}
示例2: _printplayerlist
void _printplayerlist (edict_t * self, char *buf,
qboolean (*markthis) (edict_t * self, edict_t * other))
{
int count = 0, i;
edict_t *other;
char dummy, tmpbuf[32];
Q_strncatz (buf, " # Name\n", MAX_STRING_CHARS);
Q_strncatz (buf, "------------------------------------\n", MAX_STRING_CHARS);
for (i = 1; i <= game.maxclients; i++)
{
other = &g_edicts[i];
if (other->client && other != self && other->inuse)
{
if (markthis (self, other) == true)
dummy = '*';
else
dummy = ' ';
sprintf (tmpbuf, "%2i %c%s\n", i, dummy, other->client->pers.netname);
count++;
Q_strncatz (buf, tmpbuf, MAX_STRING_CHARS);
}
}
if (!count)
Q_strncatz (buf, "None\n", MAX_STRING_CHARS);
Q_strncatz (buf, "\n", MAX_STRING_CHARS);
}
示例3: Cmd_Say_f
/*
* Cmd_Say_f
*/
void Cmd_Say_f( edict_t *ent, bool arg0, bool checkflood )
{
char *p;
char text[2048];
size_t arg0len = 0;
#ifdef AUTHED_SAY
if( sv_mm_enable->integer && ent->r.client && ent->r.client->mm_session <= 0 )
{
// unauthed players are only allowed to chat to public at non play-time
if( GS_MatchState() == MATCH_STATE_PLAYTIME )
{
G_PrintMsg( ent, "%s", S_COLOR_YELLOW "You must authenticate to be able to communicate to other players during the match.\n");
return;
}
}
#endif
if( checkflood )
{
if( CheckFlood( ent, false ) )
return;
}
if( ent->r.client && ( ent->r.client->muted & 1 ) )
return;
if( trap_Cmd_Argc() < 2 && !arg0 )
return;
text[0] = 0;
if( arg0 )
{
Q_strncatz( text, trap_Cmd_Argv( 0 ), sizeof( text ) );
Q_strncatz( text, " ", sizeof( text ) );
arg0len = strlen( text );
Q_strncatz( text, trap_Cmd_Args(), sizeof( text ) );
}
else
{
p = trap_Cmd_Args();
if( *p == '"' )
{
if( p[strlen( p )-1] == '"' )
p[strlen( p )-1] = 0;
p++;
}
Q_strncatz( text, p, sizeof( text ) );
}
// don't let text be too long for malicious reasons
text[arg0len + (MAX_CHAT_BYTES - 1)] = 0;
if( !Q_stricmp( text, "gg" ) || !Q_stricmp( text, "good game" ) )
G_AwardFairPlay( ent );
G_ChatMsg( NULL, ent, false, "%s", text );
}
示例4: _printplayerlist
void _printplayerlist (edict_t * self, char *buf,
qboolean (*markthis) (edict_t * self, edict_t * other))
{
int count = 0, i;
edict_t *other;
char dummy, tmpbuf[32];
Q_strncatz (buf, " # Name\n", MAX_STRING_CHARS);
Q_strncatz (buf, "------------------------------------\n", MAX_STRING_CHARS);
for (i = 0, other = g_edicts + 1; i < game.maxclients; i++, other++)
{
if (!other->inuse || !other->client || other->client->pers.mvdspec)
continue;
if (other == self)
continue;
if (markthis (self, other) == true)
dummy = '*';
else
dummy = ' ';
sprintf (tmpbuf, "%2i %c%s\n", i, dummy, other->client->pers.netname);
count++;
Q_strncatz (buf, tmpbuf, MAX_STRING_CHARS);
}
if (!count)
Q_strncatz (buf, "None\n", MAX_STRING_CHARS);
Q_strncatz (buf, "\n", MAX_STRING_CHARS);
}
示例5: _Cmd_Rules_f
void _Cmd_Rules_f (edict_t * self, char *argument)
{
char section[32], mbuf[1024], *p, buf[30][INI_STR_LEN];
int i, j = 0;
ini_t ini;
strcpy (mbuf, "\n");
if (*argument)
Q_strncpyz(section, argument, sizeof(section));
else
strcpy (section, "main");
if (OpenIniFile (GAMEVERSION "/prules.ini", &ini))
{
i = ReadIniSection (&ini, section, buf, 30);
while (j < i)
{
p = buf[j++];
if (*p == '.')
p++;
Q_strncatz(mbuf, p, sizeof(mbuf));
Q_strncatz(mbuf, "\n", sizeof(mbuf));
}
CloseIniFile (&ini);
}
if (!j)
gi.cprintf (self, PRINT_MEDIUM, "No rules on %s available\n", section);
else
gi.cprintf (self, PRINT_MEDIUM, "%s", mbuf);
}
示例6: Cmd_Teamname_f
void Cmd_Teamname_f(edict_t * ent)
{
int i, argc, teamNum;
char temp[32];
team_t *team;
if (!matchmode->value) {
gi.cprintf(ent, PRINT_HIGH, "This command needs matchmode to be enabled\n");
return;
}
if(ctf->value) {
gi.cprintf(ent, PRINT_HIGH, "You can't change teamnames in ctf mode\n");
return;
}
teamNum = ent->client->resp.team;
if (teamNum == NOTEAM) {
gi.cprintf( ent, PRINT_HIGH, "You need to be on a team for that...\n" );
return;
}
team = &teams[teamNum];
if (team->captain != ent) {
gi.cprintf( ent, PRINT_HIGH, "You need to be a captain for that\n" );
return;
}
if (team->ready) {
gi.cprintf( ent, PRINT_HIGH, "You can't use this while 'ready'\n" );
return;
}
if (team_round_going || team_game_going) {
gi.cprintf(ent, PRINT_HIGH, "You can't use this while playing\n");
return;
}
argc = gi.argc();
if (argc < 2) {
gi.cprintf( ent, PRINT_HIGH, "Your team name is %s\n", team->name );
return;
}
Q_strncpyz(temp, gi.argv(1), sizeof(temp));
for (i = 2; i <= argc; i++) {
Q_strncatz(temp, " ", sizeof(temp));
Q_strncatz(temp, gi.argv(i), sizeof(temp));
}
temp[18] = 0;
if (!temp[0])
strcpy( temp, "noname" );
gi.dprintf("%s (team %i) is now known as %s\n", team->name, teamNum, temp);
IRC_printf(IRC_T_GAME, "%n (team %i) is now known as %n", team->name, teamNum, temp);
strcpy(team->name, temp);
gi.cprintf(ent, PRINT_HIGH, "New team name: %s\n", team->name);
}
示例7: G_Teams_Invite_f
/*
* G_Teams_Invite_f
*/
void G_Teams_Invite_f( edict_t *ent )
{
char *text;
edict_t *toinvite;
int team;
if( ( !ent->r.inuse || !ent->r.client ) )
return;
text = trap_Cmd_Argv( 1 );
if( !text || !strlen( text ) )
{
int i;
edict_t *e;
char msg[1024];
msg[0] = 0;
Q_strncatz( msg, "Usage: invite <player>\n", sizeof( msg ) );
Q_strncatz( msg, "- List of current players:\n", sizeof( msg ) );
for( i = 0, e = game.edicts+1; i < gs.maxclients; i++, e++ )
{
if( !e->r.inuse )
continue;
Q_strncatz( msg, va( "%3i: %s\n", PLAYERNUM( e ), e->r.client->netname ), sizeof( msg ) );
}
G_PrintMsg( ent, "%s", msg );
return;
}
team = ent->s.team;
if( !G_Teams_TeamIsLocked( team ) )
{
G_PrintMsg( ent, "Your team is not locked.\n" );
return;
}
toinvite = G_PlayerForText( text );
if( !toinvite )
{
G_PrintMsg( ent, "No such player.\n" );
return;
}
if( G_Teams_PlayerIsInvited( team, toinvite ) )
{
G_PrintMsg( ent, "%s%s is already invited to your team.\n", toinvite->r.client->netname, S_COLOR_WHITE );
return;
}
G_Teams_InvitePlayer( team, toinvite );
G_PrintMsg( NULL, "%s%s invited %s%s to team %s%s.\n", ent->r.client->netname, S_COLOR_WHITE,
toinvite->r.client->netname, S_COLOR_WHITE, GS_TeamName( team ), S_COLOR_WHITE );
}
示例8: GetLastKilledTarget
void GetLastKilledTarget (edict_t * self, char *buf)
{
int kills, i;
kills = ReadKilledPlayers (self);
if (!kills) {
strcpy (buf, "nobody");
return;
}
strcpy (buf, self->client->resp.last_killed_target[0]->client->pers.netname);
for (i = 1; i < kills; i++)
{
if (i == kills - 1)
Q_strncatz(buf, " and ", PARSE_BUFSIZE);
else
Q_strncatz(buf, ", ", PARSE_BUFSIZE);
Q_strncatz(buf, self->client->resp.last_killed_target[i]->client->
pers.netname, PARSE_BUFSIZE);
}
ResetKills (self);
}
示例9: CopyServerTitle
void CopyServerTitle(char *buf, int size, const serverStatus_t *status)
{
char map[64], *s;
int clients, len, mlen, i, maxLen;
s = Info_ValueForKey(status->infostring, "hostname");
Q_strncpyz(buf, s, size);
s = Info_ValueForKey(status->infostring, "mapname");
clients = atoi(Info_ValueForKey(status->infostring, "maxclients"));
Com_sprintf(map, sizeof(map), " %-10s %2i/%2i", s, status->numPlayers, clients );
len = strlen(buf);
mlen = strlen(map);
maxLen = min(titleMax, size);
if(len + mlen > maxLen) {
if(maxLen < mlen-3)
buf[0] = 0;
else
buf[maxLen-mlen-3] = 0;
Q_strncatz(buf, "...", size);
}
else
{
for(i = len; i < maxLen-mlen; i++)
buf[i] = ' ';
buf[i] = 0;
}
Q_strncatz(buf, map, size);
}
示例10: StartServerActionFunc
static void StartServerActionFunc( menucommon_t *unused )
{
char *str;
char mapname[MAX_CONFIGSTRING_CHARS];
char starservercmd[MAX_STRING_CHARS];
m_listitem_t *mapitem;
mapitem = UI_FindItemInScrollListWithId( &mapList, mapList_cur_idx );
if( !mapitem || !mapitem->name )
return;
trap_Cvar_Set( "g_gametype", startserver_gametype_names[m_gametype] );
trap_Cvar_SetValue( "sv_skilllevel", m_skill );
trap_Cvar_SetValue( "sv_cheats", m_cheats );
trap_Cvar_SetValue( "sv_public", m_public );
str = UI_GetMenuitemFieldBuffer( UI_MenuItemByName( "m_startserver_hostname" ) );
if( str ) trap_Cvar_Set( "sv_hostname", str );
str = UI_GetMenuitemFieldBuffer( UI_MenuItemByName( "m_startserver_maxplayers" ) );
if( str ) trap_Cvar_Set( "sv_maxclients", str );
// game stuff, overriding local gametype config
starservercmd[0] = '\0';
Q_strncatz( starservercmd, va( "g_instagib %i;", m_instagib ), sizeof( starservercmd ) );
trap_Cvar_SetValue( "g_instagib", (float)m_instagib );
str = UI_GetMenuitemFieldBuffer( UI_MenuItemByName( "m_startserver_timelimit" ) );
if( str )
{
Q_strncatz( starservercmd, va( "g_timelimit %s;", str ), sizeof( starservercmd ) );
trap_Cvar_Set( "g_timelimit", str );
}
str = UI_GetMenuitemFieldBuffer( UI_MenuItemByName( "m_startserver_scorelimit" ) );
if( str )
{
Q_strncatz( starservercmd, va( "g_scorelimit %s;", str ), sizeof( starservercmd ) );
trap_Cvar_Set( "g_scorelimit", str );
}
str = UI_GetMenuitemFieldBuffer( UI_MenuItemByName( "m_startserver_numbots" ) );
if( str )
{
Q_strncatz( starservercmd, va( "g_numbots %s;", str ), sizeof( starservercmd ) );
trap_Cvar_Set( "g_numbots", str );
}
trap_Cvar_ForceSet( "ui_startservercmd", starservercmd );
if( uis.serverState )
trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect\n" );
if( trap_ML_GetMapByNum( (int)((size_t)mapitem->data), mapname, sizeof( mapname ) ) )
trap_Cvar_ForceSet( "ui_startserver_lastselectedmap", mapname );
trap_Cmd_ExecuteText( EXEC_APPEND, va( "map \"%s\"\n", mapitem->name ) );
}
示例11: MapsList_ChooseMap
static void MapsList_ChooseMap( menucommon_t *menuitem )
{
char path[MAX_CONFIGSTRING_CHARS + 6]; // wsw: Medar: could do this in not so ugly way
m_listitem_t *item;
menucommon_t *mapitem;
char mapinfo[MAX_CONFIGSTRING_CHARS];
const char *mapname, *fullname;
int id = ( menuitem ? menuitem->localdata[1] : mapList_cur_idx );
mapitem = UI_MenuItemByName( "m_startserver_map" );
if( mapitem )
Q_strncpyz( mapitem->title, "initial map", sizeof( mapitem->title ) );
mapList_suggested_gametype = 0;
item = UI_FindItemInScrollListWithId( &mapList, id );
if( item && item->name )
{
if( !trap_ML_GetMapByNum( (int)((size_t)item->data), mapinfo, sizeof( mapinfo ) ) )
return;
mapname = mapinfo;
fullname = mapinfo + strlen( mapname ) + 1;
if( menuitem )
{
mapList_cur_idx = id;
trap_Cvar_ForceSet( "ui_startserver_lastselectedmap", "" );
}
if( mapitem )
{
Q_strncatz( mapitem->title, ": " S_COLOR_WHITE, sizeof( mapitem->title ) );
if( !trap_Cvar_Value( "ui_maplist_sortmethod" ) )
Q_strncatz( mapitem->title, mapname, sizeof( mapitem->title ) );
else
Q_strncatz( mapitem->title, *fullname ? fullname : mapname, sizeof( mapitem->title ) );
}
#ifdef SUGGEST_MAP_GAMETYPE
mapList_suggested_gametype = SuggestGameType( mapname );
// if( m_gametypes_item )
// {
// m_gametypes_item->curvalue = mapList_suggested_gametype;
// M_GametypeFunc( m_gametypes_item );
// }
#endif
Q_snprintfz( path, sizeof( path ), "levelshots/%s.jpg", mapname );
s_levelshot = trap_R_RegisterLevelshot( path, trap_R_RegisterPic( PATH_UKNOWN_MAP_PIC ), NULL );
}
}
示例12: Q_snprintfz
char *G_Gametype_GENERIC_ScoreboardMessage( void )
{
char entry[MAX_TOKEN_CHARS];
size_t len;
int i;
edict_t *e;
int carrierIcon;
*scoreboardString = 0;
len = 0;
Q_snprintfz( entry, sizeof(entry), "&t %i 0 0 ", TEAM_PLAYERS );
if( SCOREBOARD_MSG_MAXSIZE - len > strlen( entry ) )
{
Q_strncatz( scoreboardString, entry, sizeof( scoreboardString ) );
len = strlen( scoreboardString );
}
// players
for( i = 0; i < teamlist[TEAM_PLAYERS].numplayers; i++ )
{
e = game.edicts + teamlist[TEAM_PLAYERS].playerIndices[i];
if( e->s.effects & EF_CARRIER )
carrierIcon = trap_ImageIndex( ( e->s.team == TEAM_BETA ) ? PATH_ALPHAFLAG_ICON : PATH_BETAFLAG_ICON );
else if( e->s.effects & EF_QUAD )
carrierIcon = trap_ImageIndex( PATH_QUAD_ICON );
else if( e->s.effects & EF_SHELL )
carrierIcon = trap_ImageIndex( PATH_SHELL_ICON );
else if( e->s.effects & EF_REGEN )
carrierIcon = trap_ImageIndex( PATH_REGEN_ICON );
else
carrierIcon = 0;
Q_snprintfz( entry, sizeof( entry ), "&p %i %i %i %i %i ",
PLAYERNUM( e ),
e->r.client->level.stats.score,
e->r.client->r.ping > 999 ? 999 : e->r.client->r.ping,
carrierIcon,
( level.ready[PLAYERNUM( e )] || GS_MatchState() >= MATCH_STATE_PLAYTIME ) ? trap_ImageIndex( PATH_VSAY_YES_ICON ) : 0
);
if( SCOREBOARD_MSG_MAXSIZE - len > strlen( entry ) )
{
Q_strncatz( scoreboardString, entry, sizeof( scoreboardString ) );
len = strlen( scoreboardString );
}
}
return scoreboardString;
}
示例13: TV_Cmd_Spectators_f
/*
* TV_Cmd_Spectators_f
*/
static void TV_Cmd_Spectators_f( client_t *client )
{
int i;
int count = 0;
int start = 0;
char line[64];
char msg[1024];
client_t *cl;
relay_t *relay = client->relay;
int maxclients = tv_maxclients->integer;
if( Cmd_Argc() > 1 )
start = atoi( Cmd_Argv( 1 ) );
clamp( start, 0, maxclients - 1 );
// print information
msg[0] = 0;
for( i = start; i < maxclients; i++ )
{
cl = &tvs.clients[i];
if( cl->state >= CS_SPAWNED )
{
if( cl->relay != client->relay )
continue;
Q_snprintfz( line, sizeof( line ), "%s%s%s\n", count ? " " : "", S_COLOR_WHITE, cl->name );
if( strlen( line ) + strlen( msg ) > sizeof( msg ) - 100 )
{
// can't print all of them in one packet
Q_strncatz( msg, " ...\n", sizeof( msg ) );
break;
}
if( !count )
Q_strncatz( msg, "---------------\n", sizeof( msg ) );
Q_strncatz( msg, line, sizeof( msg ) );
count++;
}
}
if( count )
Q_strncatz( msg, "---------------\n", sizeof( msg ) );
Q_strncatz( msg, va( "%i %s\n", count, Cmd_Argv( 0 ) ), sizeof( msg ) );
TV_Downstream_Msg( client, relay, NULL, false, "%s", msg );
if( i < maxclients )
TV_Downstream_Msg( client, relay, NULL, false, "Type '%s %i' for more %s\n", Cmd_Argv( 0 ), i, Cmd_Argv( 0 ) );
}
示例14: Cmd_Say_f
/*
* Cmd_Say_f
*/
void Cmd_Say_f( edict_t *ent, qboolean arg0, qboolean checkflood )
{
char *p;
char text[2048];
if( checkflood )
{
if( CheckFlood( ent, qfalse ) )
return;
}
if( ent->r.client && ent->r.client->muted & 1 )
return;
if( trap_Cmd_Argc() < 2 && !arg0 )
return;
text[0] = 0;
if( arg0 )
{
Q_strncatz( text, trap_Cmd_Argv( 0 ), sizeof( text ) );
Q_strncatz( text, " ", sizeof( text ) );
Q_strncatz( text, trap_Cmd_Args(), sizeof( text ) );
}
else
{
p = trap_Cmd_Args();
if( *p == '"' )
{
if( p[strlen( p )-1] == '"' )
p[strlen( p )-1] = 0;
p++;
}
Q_strncatz( text, p, sizeof( text ) );
}
// don't let text be too long for malicious reasons
if( strlen( text ) > 150 )
text[150] = 0;
G_ChatMsg( NULL, ent, qfalse, "%s", text );
// racesow
RS_ircSendMessage( va( "%s", COM_RemoveColorTokens(( ent->r.client->netname ) )),
va( "%s", COM_RemoveColorTokens(( text)) ) );
// !racesow
}
示例15: xMenu_New
qboolean
xMenu_New (edict_t * ent, char *title, char *subtitle,
void (*DoAddMenu) (edict_t * ent, int fromix))
{
if (!DoAddMenu)
return false;
if (!X_MENU)
{
//no menu yet, allocate memory for it...
X_MENU = gi.TagMalloc (sizeof (xmenu_t), TAG_GAME);
if (!X_MENU)
{
gi.dprintf ("Error allocating xmenu space\n");
return false;
}
}
X_MENU->DoAddMenu = DoAddMenu;
X_MENU->xmenucount = 2;
X_MENU->xmenutop = 0;
//memset(xmenuentries, 0, sizeof(xmenuentries));
strcpy (X_MENU->xmenuentries[0].name, "*");
if (title)
Q_strncatz(X_MENU->xmenuentries[0].name, title, XMENU_TITLE_MAX);
else
Q_strncatz(X_MENU->xmenuentries[0].name, "Menu", XMENU_TITLE_MAX);
if (subtitle)
Q_strncpyz(X_MENU->xmenuentries[1].name, subtitle, XMENU_TITLE_MAX);
else
Q_strncpyz(X_MENU->xmenuentries[1].name, "make your choice", XMENU_TITLE_MAX);
X_MENU->xmenuentries[0].SelectFunc = NULL;
X_MENU->xmenuentries[1].SelectFunc = NULL;
DoAddMenu (ent, 0);
if (X_MENU->xmenucount > 2)
{
xMenu_Set (ent);
if (ent->client->menu)
PMenu_Close (ent);
PMenu_Open (ent, X_MENU->themenu, 5, XMENU_END_ENTRY);
return true;
}
return false;
}