コード例 #1
0
ファイル: cg_democams.cpp プロジェクト: Picmip/qfusion
/*
* 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
0
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
0
ファイル: g_cmds.cpp プロジェクト: DenMSC/qfusion
/*
* 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
0
ファイル: a_vote.c プロジェクト: Raptor007/aq2-tng
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
0
// -> scream
char *Dem_PlayerNameTeam(char *t)
{
	int	i;
	client_t *client;
	static char	n[1024];
	int	sep;

	n[0] = 0;

	sep = 0;

	for (i = 0, client = svs.clients; i < MAX_CLIENTS; i++, client++)
	{
		if (!client->name[0] || client->spectator)
			continue;

		if (strcmp(t, Info_ValueForKey(client->userinfo, "team"))==0)
		{
			if (sep >= 1)
				Q_strncatz (n, "_", sizeof(n));
//				snprintf (n, sizeof(n), "%s_", n);
			Q_strncatz (n, client->name, sizeof(n));
//			snprintf (n, sizeof(n),"%s%s", n, client->name);
			sep++;
		}
	}

	return n;
}
コード例 #6
0
ファイル: a_xcmds.c プロジェクト: DusteDdk/aq2-tng-bk
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);
}
コード例 #7
0
ファイル: a_match.c プロジェクト: Maniac-/aq2-tng
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);

}
コード例 #8
0
ファイル: g_gameteams.cpp プロジェクト: tenght/qfusion
/*
* 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 );
}
コード例 #9
0
ファイル: a_xgame.c プロジェクト: DusteDdk/aq2-tng-bk
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);
}
コード例 #10
0
ファイル: ui_joinserver.c プロジェクト: q3aql/quake2
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);
}
コード例 #11
0
ファイル: ui_startserver.c プロジェクト: Racenet/racesow
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 ) );
}
コード例 #12
0
ファイル: ui_startserver.c プロジェクト: Racenet/racesow
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 );
    }
}
コード例 #13
0
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;
}
コード例 #14
0
/*
* 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 ) );

}
コード例 #15
0
ファイル: g_cmds.c プロジェクト: j0ki/racesow
/*
* 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
}
コード例 #16
0
ファイル: a_xmenu.c プロジェクト: DusteDdk/aq2-tng-bk
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;
}
コード例 #17
0
ファイル: snd_decoder.c プロジェクト: codetwister/qfusion
static void decoder_register( snd_decoder_t *decoder )
{
	decoder->next = decoders;
	decoders = decoder;

	if( extensionlist_size - strlen( extensionlist ) - 1 < strlen( decoder->ext ) + 1 )
	{
		char *oldlist = extensionlist;
		extensionlist_size = max( extensionlist_size * 2, (int)( strlen( extensionlist ) + strlen( decoder->ext ) + 1 + 1 ) );
		extensionlist = S_Malloc( extensionlist_size );
		Q_strncpyz( extensionlist, oldlist, extensionlist_size );
		S_Free( oldlist );
	}
	Q_strncatz( extensionlist, " ", extensionlist_size );
	Q_strncatz( extensionlist, decoder->ext, extensionlist_size );
}
コード例 #18
0
ファイル: sv_ccmds.c プロジェクト: Racenet/racesow
/*
* SV_Download_f
* Download command issued from server
*/
static void SV_Download_f( void )
{
	qboolean success;
	char *s;
	char url[MAX_STRING_CHARS], filepath[MAX_QPATH], writepath[MAX_QPATH];

	if( Cmd_Argc() != 2 )
	{
		Com_Printf( "Usage: %s <url>\n", Cmd_Argv( 0 ) );
		Com_Printf( "Downloads .pk3 or .pak from URL to gamedir and adds it to the server\n" );
		Com_Printf( "Note, server will not function properly while downloading\n" );
		return;
	}

	s = Cmd_Argv( 1 );
	if( !Com_GlobMatch( "*://*", s, qfalse ) )
		Q_strncpyz( url, "http://", sizeof( url ) );
	else
		url[0] = 0;
	Q_strncatz( url, s, sizeof( url ) );

	s = strrchr( url, '/' );
	if( !s )
	{
		Com_Printf( "%s: invalid URL\n", Cmd_Argv( 0 ) );
		return;
	}

	Q_strncpyz( filepath, va( "%s/%s", FS_GameDirectory(), s + 1 ), sizeof( filepath ) );
	Q_strncpyz( writepath, va( "%s.tmp", filepath ), sizeof( writepath ) );

	if( !FS_CheckPakExtension( writepath ) )
	{
		Com_Printf( "Missing or invalid archive extension. Only download of pack files is supported\n" );
		return;
	}

	Com_Printf( "download url: %s\n", url );

	webDownloadPercentPrint = 0;

	success = Web_Get( url, NULL, writepath, qtrue, 60 * 30, 60, SV_WebDownloadProgress, qfalse );

	if( !success )
	{
		Com_Printf( "Server web download failed\n" );
		return;
	}

	if( !FS_MoveBaseFile( writepath, filepath ) )
	{
		Com_Printf( "Couldn't rename the downloaded file. Download failed\n" );
		return;
	}

	Com_Printf( "Download successful\n" );

	// update the map list, which also does a filesystem rescan
	ML_Update();
}
コード例 #19
0
ファイル: cl_sound.c プロジェクト: Kaperstone/warsow
/*
* CL_SetSoundExtension
*/
static char *CL_SetSoundExtension( const char *name )
{
	unsigned int i;
	char *finalname;
	size_t finalname_size, maxlen;
	const char *extension;

	assert( name );

	if( COM_FileExtension( name ) )
		return TempCopyString( name );

	maxlen = 0;
	for( i = 0; i < NUM_SOUND_EXTENSIONS; i++ )
	{
		if( strlen( SOUND_EXTENSIONS[i] ) > maxlen )
			maxlen = strlen( SOUND_EXTENSIONS[i] );
	}

	finalname_size = strlen( name ) + maxlen + 1;
	finalname = Mem_TempMalloc( finalname_size );
	Q_strncpyz( finalname, name, finalname_size );

	extension = FS_FirstExtension( finalname, SOUND_EXTENSIONS, NUM_SOUND_EXTENSIONS );
	if( extension )
		Q_strncatz( finalname, extension, finalname_size );
	// if not found, we just pass it without the extension

	return finalname;
}
コード例 #20
0
ファイル: sv_ccmds.c プロジェクト: Kiln707/KMQuake2
/*
==================
SV_ConSay_f
==================
*/
void SV_ConSay_f(void)
{
	client_t *client;
	int		j;
	char	*p;
	char	text[1024];

	if (Cmd_Argc () < 2)
		return;

//	strncpy (text, "console: ");
	Q_strncpyz (text, "console: ", sizeof(text));
	p = Cmd_Args();

	if (*p == '"')
	{
		p++;
		p[strlen(p)-1] = 0;
	}

//	strncat(text, p);
	Q_strncatz(text, p, sizeof(text));

	for (j = 0, client = svs.clients; j < maxclients->value; j++, client++)
	{
		if (client->state != cs_spawned)
			continue;
		SV_ClientPrintf(client, PRINT_CHAT, "%s\n", text);
	}
}
コード例 #21
0
ファイル: a_vote.c プロジェクト: Raptor007/aq2-tng
void Cmd_Kicklist_f(edict_t *ent)
{
  char buf[MAX_STRING_CHARS], tbuf[256];

  if (!use_kickvote->value) {
	  gi.cprintf(ent, PRINT_HIGH, "Kick voting is disabled.\n");
	  return;
  }

  strcpy(buf, "Available players to kick:\n\n");
  _printplayerlist(ent, buf, _vkMarkThis);

  // adding vote settings
  Com_sprintf (tbuf, sizeof(tbuf), "Vote rules: %i client%s min. (currently %i),\n" \
	   "%.1f%% must have voted overall (currently %.1f%%)\n" \
	   "and %.1f%% on the same (currently %.1f%% on %s),\n" \
	   "kicked players %s be temporarily banned.\n\n",
	   (int) (kickvote_min->value),
	   (kickvote_min->value == 1) ? "" : "s",
	   _numclients(),
	   kickvote_need->value, Allkickvotes,
	   kickvote_pass->value, Mostkickpercent,
	   Mostkickvotes == NULL ? "nobody" : Mostkickvotes->client->pers.netname,
	   kickvote_tempban ? "will" : "won't");
  // double percent sign! cprintf will process them as format strings.

  Q_strncatz(buf, tbuf, sizeof(buf));
  gi.cprintf(ent, PRINT_MEDIUM, "%s", buf);
}
コード例 #22
0
ファイル: pr_clcmd.c プロジェクト: ProfessorKaos64/ftequake
//string	findkeysforcommand(string command) = #610;
void QCBUILTIN PF_cl_findkeysforcommand (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
	const char *cmdname = PR_GetStringOfs(prinst, OFS_PARM0);
	int bindmap = (prinst->callargc > 1)?G_FLOAT(OFS_PARM1):0;
	int keynums[2];
	char keyname[512];

	M_FindKeysForCommand(bindmap, 0, cmdname, keynums, NULL, countof(keynums));

	keyname[0] = '\0';

	Q_strncatz (keyname, va(" \'%i\'", MP_TranslateFTEtoQCCodes(keynums[0])), sizeof(keyname));
	Q_strncatz (keyname, va(" \'%i\'", MP_TranslateFTEtoQCCodes(keynums[1])), sizeof(keyname));

	RETURN_TSTRING(keyname);
}
コード例 #23
0
ファイル: ui_rocketmodule.cpp プロジェクト: ewirch/qfusion
// preload all fonts in fonts/ directory with extension ext
void RocketModule::preloadFonts( const char *ext )
{
	int i, j, numFonts;
	char listbuf[1024], scratch[MAX_QPATH + 6];
	char *ptr;

	numFonts = trap::FS_GetFileList( "fonts", ext, NULL, 0, 0, 0 );
	if( !numFonts )
	{
		Com_Printf("Warning: no fonts found for preloading!\n" );
		return;
	}

	i = 0;
	do
	{
		j = trap::FS_GetFileList( "fonts", ext, listbuf, sizeof( listbuf ), i, numFonts );

		if( !j )
		{
			i++; // can happen if the filename is too long to fit into the buffer or we're done
			continue;
		}
		i += j;

		for( ptr = listbuf; j > 0; j--, ptr += strlen( ptr ) + 1 )
		{
			strcpy( scratch, "fonts/" );
			Q_strncatz( scratch, ptr, sizeof( scratch ) );
			Rocket::Core::FontDatabase::LoadFontFace( scratch );

			// Com_Printf("** Preloaded font %s\n", scratch );
		}
	} while( i < numFonts );
}
コード例 #24
0
ファイル: sv_send.c プロジェクト: Clever-Boy/qfusion
/*
* SV_AddServerCommand
* 
* The given command will be transmitted to the client, and is guaranteed to
* not have future snapshot_t executed before it is executed
*/
void SV_AddServerCommand( client_t *client, const char *cmd )
{
	int index;
	unsigned int i;

	if( !client )
		return;

	if( client->edict && ( client->edict->r.svflags & SVF_FAKECLIENT ) )
		return;

	if( !cmd || !cmd[0] || !strlen( cmd ) )
		return;

	// ch : To avoid overflow of messages from excessive amount of configstrings
	// we batch them here. On incoming "cs" command, we'll trackback the queue
	// to find a pending "cs" command that has space in it. If we'll find one,
	// we'll batch this there, if not, we'll create a new one.
	if( !strncmp( cmd, "cs ", 3 ) )
	{
		// length of the index/value (leave room for one space and null char)
		size_t len = strlen( cmd ) - 1;
		for( i = client->reliableSequence; i > client->reliableSent; i-- )
		{
			size_t otherLen;
			char *otherCmd;

			otherCmd= client->reliableCommands[i & ( MAX_RELIABLE_COMMANDS - 1)];
			if( !strncmp( otherCmd, "cs ", 3 ) )
			{
				otherLen = strlen( otherCmd );
				// is there any room? (should check for sizeof client->reliableCommands[0]?)
				if( (otherLen + len) < MAX_STRING_CHARS )
				{
					// yahoo, put it in here
					Q_strncatz( otherCmd, cmd + 2, MAX_STRING_CHARS - 1 );
					return;
				}
			}
		}
	}

	client->reliableSequence++;
	// if we would be losing an old command that hasn't been acknowledged, we must drop the connection
	// we check == instead of >= so a broadcast print added by SV_DropClient() doesn't cause a recursive drop client
	if( client->reliableSequence - client->reliableAcknowledge == MAX_RELIABLE_COMMANDS + 1 )
	{
		//Com_Printf( "===== pending server commands =====\n" );
		for( i = client->reliableAcknowledge + 1; i <= client->reliableSequence; i++ )
		{
			Com_DPrintf( "cmd %5d: %s\n", i, client->reliableCommands[i & ( MAX_RELIABLE_COMMANDS-1 )] );
		}
		Com_DPrintf( "cmd %5d: %s\n", i, cmd );
		SV_DropClient( client, DROP_TYPE_GENERAL, "%s", "Error: Server command overflow" );
		return;
	}
	index = client->reliableSequence & ( MAX_RELIABLE_COMMANDS - 1 );
	Q_strncpyz( client->reliableCommands[index], cmd, sizeof( client->reliableCommands[index] ) );
}
コード例 #25
0
ファイル: g_gameteams.cpp プロジェクト: tenght/qfusion
static void WeaponString( edict_t *who, int weapon, char *buf, int buflen, const char *current_color )
{
	int strong_ammo, weak_ammo;
	gs_weapon_definition_t *weapondef = GS_GetWeaponDef( weapon );

	Q_snprintfz( buf, buflen, "%s%s%s", ( GS_FindItemByTag( weapon )->color ? GS_FindItemByTag( weapon )->color : "" ),
		GS_FindItemByTag( weapon )->shortname, current_color );

	strong_ammo = who->r.client->ps.inventory[weapondef->firedef.ammo_id];
	weak_ammo = who->r.client->ps.inventory[weapondef->firedef_weak.ammo_id];
	if( weapon == WEAP_GUNBLADE )
		Q_strncatz( buf, va( ":%i", strong_ammo ), buflen );
	else if( strong_ammo > 0 )
		Q_strncatz( buf, va( ":%i/%i", strong_ammo, weak_ammo ), buflen );
	else
		Q_strncatz( buf, va( ":%i", weak_ammo ), buflen );
}
コード例 #26
0
ファイル: a_dom.c プロジェクト: Raptor007/aq2-tng
void DomSetupStatusbar( void )
{
	Q_strncatz(level.statusbar, 
		// Red Team
		"yb -172 " "if 24 xr -24 pic 24 endif " "xr -92 num 4 26 "
		// Blue Team
		"yb -148 " "if 25 xr -24 pic 25 endif " "xr -92 num 4 27 ",
		sizeof(level.statusbar) );
	
	if( teamCount >= 3 )
	{
		Q_strncatz(level.statusbar, 
			// Green Team
			"yb -124 " "if 30 xr -24 pic 30 endif " "xr -92 num 4 31 ",
			sizeof(level.statusbar) );
	}
}
コード例 #27
0
ファイル: sv_oob.c プロジェクト: futurepneu/racemod
/**
 * Writes the tags of the server for filtering in the Steam server browser.
 *
 * @param tags string where to write the tags (at least MAX_STEAMQUERY_TAG_STRING bytes)
 */
static void SV_GetSteamTags( char *tags )
{
	// Currently there is no way to filter by tag in the game itself,
	// so this is mostly to make sure the tags aren't empty on old servers if they are added.

	Q_strncpyz( tags, Cvar_String( "g_gametype" ), MAX_STEAMQUERY_TAG_STRING );

	if( Cvar_Value( "g_instagib" ) )
	{
		if( tags[0] )
			Q_strncatz( tags, ",", MAX_STEAMQUERY_TAG_STRING );
		Q_strncatz( tags, "instagib", MAX_STEAMQUERY_TAG_STRING );
	}

	// If sv_tags cvar is added, every comma-separated tag from the cvar must be added separately
	// (so the last tag exceeding MAX_STEAMQUERY_TAG_STRING isn't cut off)
	// and validated not to contain any characters disallowed in userinfo (CVAR_SERVERINFO).
}
コード例 #28
0
ファイル: g_cmds.cpp プロジェクト: codetwister/qfusion
/*
* Cmd_Say_f
*/
void Cmd_Say_f( edict_t *ent, bool arg0, bool checkflood )
{
	char *p;
	char text[2048];

	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 ) );
		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, false, "%s", text );
}
コード例 #29
0
ファイル: g_gameteams.cpp プロジェクト: tenght/qfusion
static void Say_Team_Current_Weapon( edict_t *who, char *buf, int buflen, const char *current_color )
{
	if( !who->s.weapon )
	{
		buf[0] = 0;
		return;
	}

	WeaponString( who, who->s.weapon, buf, buflen, current_color );
	Q_strncatz( buf, current_color, buflen );
}
コード例 #30
0
ファイル: g_gameteams.cpp プロジェクト: tenght/qfusion
static void Say_Team_Drop_Location( edict_t *who, char *buf, int buflen, const char *current_color )
{
	if( !who->r.client->teamstate.last_drop_item )
	{
		buf[0] = 0;
	}
	else
	{
		G_MapLocationNameForTAG( G_MapLocationTAGForOrigin( who->r.client->teamstate.last_drop_location ), buf, buflen );
		Q_strncatz( buf, current_color, buflen );
	}
}