コード例 #1
0
/*
=================
ArenaServers_Insert
=================
*/
static void ArenaServers_Insert( char* adrstr, char* info, int pingtime )
{
	servernode_t*	servernodeptr;

	if ((pingtime >= ArenaServers_MaxPing()) && (g_servertype != UIAS_FAVORITES))
	{
		// slow global or local servers do not get entered
		return;
	}

	if (*g_arenaservers.numservers >= g_arenaservers.maxservers) {
		// list full;
		servernodeptr = g_arenaservers.serverlist+(*g_arenaservers.numservers)-1;
	} else {
		// next slot
		servernodeptr = g_arenaservers.serverlist+(*g_arenaservers.numservers);
		(*g_arenaservers.numservers)++;
	}

	Q_strncpyz( servernodeptr->adrstr, adrstr, MAX_ADDRESSLENGTH );

	Q_strncpyz( servernodeptr->hostname, Info_ValueForKey( info, "hostname"), MAX_HOSTNAMELENGTH );
	Q_CleanStr( servernodeptr->hostname );
	Q_strupr( servernodeptr->hostname );

	Q_strncpyz( servernodeptr->mapname, Info_ValueForKey( info, "mapname"), MAX_MAPNAMELENGTH );
	Q_CleanStr( servernodeptr->mapname );

	servernodeptr->numclients = atoi( Info_ValueForKey( info, "clients") );
	servernodeptr->humanplayers = atoi( Info_ValueForKey( info, "g_humanplayers") );
	servernodeptr->maxclients = atoi( Info_ValueForKey( info, "sv_maxclients") );
	servernodeptr->pingtime   = pingtime;
	servernodeptr->minPing    = atoi( Info_ValueForKey( info, "minPing") );
	servernodeptr->maxPing    = atoi( Info_ValueForKey( info, "maxPing") );

	/*
	s = Info_ValueForKey( info, "nettype" );
	for (i=0; ;i++)
	{
		if (!netnames[i])
		{
			servernodeptr->nettype = 0;
			break;
		}
		else if (!Q_stricmp( netnames[i], s ))
		{
			servernodeptr->nettype = i;
			break;
		}
	}
	*/
	servernodeptr->nettype = atoi(Info_ValueForKey(info, "nettype"));
	if (servernodeptr->nettype < 0 || servernodeptr->nettype >= ARRAY_LEN(netnames) - 1) {
		servernodeptr->nettype = 0;
	}

	Q_strncpyz( servernodeptr->gametypeName, Info_ValueForKey( info, "gametype"), sizeof(servernodeptr->gametypeName) );
	Q_CleanStr( servernodeptr->gametypeName );
}
コード例 #2
0
ファイル: main.cpp プロジェクト: D4edalus/CoD4x_Server
//For using chat with @@ prefix
void AdminCmds::SM_PSay(const char* msg, int source)
{
  int i;
  char message[1024];
  char cleannames[128];
  char cleannamed[128];

  Cmd_TokenizeString(msg);

  if(Cmd_Argc() < 2)
  {
    Plugin_ChatPrintf(source, "Usage: @@player message");
    return;
  }

  client_t* cl = Plugin_SV_Cmd_GetPlayerClByHandle(Cmd_Argv(0));

  if(cl == NULL)
  {
    Plugin_ChatPrintf(source, "No player for %s found", Cmd_Argv(0));
    return;
  }
  if(cl->state < CS_ACTIVE)
  {
    Plugin_ChatPrintf(source, "Player %s is not in active", cl->name);
    return;
  }

  message[0] = '\0';
  for(i = 1; i < Cmd_Argc(); ++i)
  {
    Q_strcat(message, sizeof(message), Cmd_Argv(i));
    Q_strcat(message, sizeof(message), " ");
  }

  int destination = NUMFORCLIENT(cl);

  if(source == destination)
  {
      Plugin_ChatPrintf(source, "Why would you send a message to yourself?");
      return;
  }

  Q_strncpyz(cleannames, Plugin_GetPlayerName(source), sizeof(cleannames));
  Q_strncpyz(cleannamed, cl->name, sizeof(cleannamed));

  Q_CleanStr(cleannames);
  Q_CleanStr(cleannamed);

  Plugin_ChatPrintf(source, "^7%s ^1>> ^7%s: %s", cleannames, cleannamed, message);
  Plugin_ChatPrintf(destination, "^7%s ^1>> ^7%s: %s", cleannames, cleannamed, message);
}
コード例 #3
0
ファイル: ui_gameinfo.c プロジェクト: leakcim1324/ETrun
            /*} else if( !Q_stricmp( token.string, "objectives" ) ) {
            	if( !PC_String_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].objectives ) ) {
            		trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
            		trap_PC_FreeSource( handle );
            		return;
            	}*/
        } else if( !Q_stricmp( token.string, "timelimit" ) ) {
            if( !PC_Int_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].Timelimit ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }
        } else if( !Q_stricmp( token.string, "axisrespawntime" ) ) {
            if( !PC_Int_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].AxisRespawnTime ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }
        } else if( !Q_stricmp( token.string, "alliedrespawntime" ) ) {
            if( !PC_Int_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].AlliedRespawnTime ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }
        } else if( !Q_stricmp( token.string, "type" ) ) {
            if( !trap_PC_ReadToken( handle, &token ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            } else {
                if( strstr( token.string, "wolfsp" ) ) {
                    uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_SINGLE_PLAYER);
                }
                if( strstr( token.string, "wolflms" ) ) {
                    uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF_LMS);
                }
                if( strstr( token.string, "wolfmp" ) ) {
                    uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF);
                }
                if( strstr( token.string, "wolfsw" ) ) {
                    uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF_STOPWATCH);
                }
            }
        } else if( !Q_stricmp( token.string, "mapposition_x" ) ) {
            if( !PC_Float_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].mappos[0] ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }
        } else if( !Q_stricmp( token.string, "mapposition_y" ) ) {
            if( !PC_Float_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].mappos[1] ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }
        }
    }

    trap_PC_FreeSource( handle );
    return;
}/* ============= UI_SortArenas CHRUKER: b090 - Sorting the map list ============= */
int QDECL UI_SortArenas( const void *a, const void *b ) {
    mapInfo ca = *(mapInfo*)a;
    mapInfo cb = *(mapInfo*)b;
    char cleanNameA[MAX_STRING_CHARS];
    char cleanNameB[MAX_STRING_CHARS];

    Q_strncpyz(cleanNameA, ca.mapName, sizeof(cleanNameA));
    Q_strncpyz(cleanNameB, cb.mapName, sizeof(cleanNameB));
    Q_CleanStr(cleanNameA);
    Q_CleanStr(cleanNameB);

    return strcmp(cleanNameA, cleanNameB);
} // b090
コード例 #4
0
ファイル: ui_gameinfo.c プロジェクト: leakcim1324/ETrun
/* ================ UI_SortCampaigns CHRUKER: b090 - Sorting the campaign list ================ */
int QDECL UI_SortCampaigns( const void *a, const void *b ) {
    char cleanNameA[MAX_STRING_CHARS];
    char cleanNameB[MAX_STRING_CHARS];

    campaignInfo_t ca = *(campaignInfo_t*)a;
    campaignInfo_t cb = *(campaignInfo_t*)b;

    Q_strncpyz(cleanNameA, ca.campaignName, sizeof(cleanNameA));
    Q_strncpyz(cleanNameB, cb.campaignName, sizeof(cleanNameB));
    Q_CleanStr(cleanNameA);
    Q_CleanStr(cleanNameB);

    return strcmp(cleanNameA, cleanNameB);
} // b090
コード例 #5
0
ファイル: g_svcmds.c プロジェクト: iMp-Rex/OpenJK
/*
===================
ClientForString
===================
*/
gclient_t	*ClientForString( const char *s ) {
	gclient_t	*cl;
	int			idnum;
	char		cleanName[MAX_STRING_CHARS];

	// numeric values could be slot numbers
	if ( StringIsInteger( s ) ) {
		idnum = atoi( s );
		if ( idnum >= 0 && idnum < level.maxclients ) {
			cl = &level.clients[idnum];
			if ( cl->pers.connected == CON_CONNECTED ) {
				return cl;
			}
		}
	}

	// check for a name match
	for ( idnum=0,cl=level.clients ; idnum < level.maxclients ; idnum++,cl++ ) {
		if ( cl->pers.connected != CON_CONNECTED ) {
			continue;
		}
		Q_strncpyz(cleanName, cl->pers.netname, sizeof(cleanName));
		Q_CleanStr(cleanName);
		if ( !Q_stricmp( cleanName, s ) ) {
			return cl;
		}
	}

	G_Printf( "User %s is not on the server\n", s );
	return NULL;
}
コード例 #6
0
ファイル: ui_sppostgame.c プロジェクト: zturtleman/recoil
/*
=================
UI_SPPostgameMenu_MenuDrawScoreLine
=================
*/
static void UI_SPPostgameMenu_MenuDrawScoreLine( int n, int y )
{
    int		rank;
    char	name[64];
    char	info[MAX_INFO_STRING];

    if( n > (postgameMenuInfo.numClients + 1) )
    {
        n -= (postgameMenuInfo.numClients + 2);
    }

    if( n >= postgameMenuInfo.numClients )
    {
        return;
    }

    rank = postgameMenuInfo.ranks[n];
    if( rank & RANK_TIED_FLAG )
    {
        UI_DrawString( 640 - 31 * SMALLCHAR_WIDTH, y, "(tie)", UI_LEFT|UI_SMALLFONT, color_white );
        rank &= ~RANK_TIED_FLAG;
    }
    GetConfigString( CS_PLAYERS + postgameMenuInfo.clientNums[n], info, MAX_INFO_STRING );
    Q_strncpyz( name, Info_ValueForKey( info, "n" ), sizeof(name) );
    Q_CleanStr( name );

    UI_DrawString( 640 - 25 * SMALLCHAR_WIDTH, y, va( "#%i: %-16s %2i", rank + 1, name, postgameMenuInfo.scores[n] ), UI_LEFT|UI_SMALLFONT, color_white );
}
コード例 #7
0
ファイル: g_bot.c プロジェクト: morsik/war-territory
/*
===============
G_RemoveRandomBot
===============
*/
int G_RemoveRandomBot(int team)
{
	int       i;
	char      netname[36];
	gclient_t *cl;

	for (i = 0 ; i < g_maxclients.integer ; i++)
	{
		cl = level.clients + i;
		if (cl->pers.connected != CON_CONNECTED)
		{
			continue;
		}
		if (!(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT))
		{
			continue;
		}
		if (team >= 0 && cl->sess.sessionTeam != team)
		{
			continue;
		}
		strcpy(netname, cl->pers.netname);
		Q_CleanStr(netname);
		trap_SendConsoleCommand(EXEC_INSERT, va("kick \"%s\" 0\n", netname));
		return qtrue;
	}
	return qfalse;
}
コード例 #8
0
ファイル: cl_console.c プロジェクト: Sixthly/Unvanquished
/*
================
Con_DrawInput

Draw the editline after a ] prompt
================
*/
void Con_DrawInput( void )
{
	int     y;
	char    prompt[ MAX_STRING_CHARS ];
	vec4_t  color;
	qtime_t realtime;

	if ( cls.state != CA_DISCONNECTED && !( cls.keyCatchers & KEYCATCH_CONSOLE ) )
	{
		return;
	}

	Com_RealTime( &realtime );

	y = con.vislines - ( SCR_ConsoleFontCharHeight() * 2 ) + 2;

	Com_sprintf( prompt,  sizeof( prompt ), "^0[^3%02d%c%02d^0]^7 %s", realtime.tm_hour, ( realtime.tm_sec & 1 ) ? ':' : ' ', realtime.tm_min, cl_consolePrompt->string );

	color[ 0 ] = 1.0f;
	color[ 1 ] = 1.0f;
	color[ 2 ] = 1.0f;
	color[ 3 ] = ( scr_conUseOld->integer ? 1.0f : con.displayFrac * 2.0f );

	SCR_DrawSmallStringExt( con.xadjust + cl_conXOffset->integer, y + 10, prompt, color, qfalse, qfalse );

	Q_CleanStr( prompt );
	Field_Draw( &g_consoleField, con.xadjust + cl_conXOffset->integer + SCR_ConsoleFontStringWidth( prompt, strlen( prompt ) ), y + 10, qtrue, qtrue, color[ 3 ] );
}
コード例 #9
0
ファイル: g_svcmds.c プロジェクト: chegestar/omni-bot
/*
==================
G_GetPlayerByName
==================
*/
gclient_t *G_GetPlayerByName( char *name ) {

	int			i;
	gclient_t	*cl;
	char		cleanName[64];

	// make sure server is running
	if ( !G_Is_SV_Running() ) {
		return NULL;
	}

	if ( trap_Argc() < 2 ) {
		G_Printf( "No player specified.\n" );
		return NULL;
	}

	for (i = 0; i < level.numConnectedClients; i++) {
		
		cl = &level.clients[i];
		
		if (!Q_stricmp(cl->pers.netname, name)) {
			return cl;
		}

		Q_strncpyz( cleanName, cl->pers.netname, sizeof(cleanName) );
		Q_CleanStr( cleanName );
		if ( !Q_stricmp( cleanName, name ) ) {
			return cl;
		}
	}

	G_Printf( "Player %s is not on the server\n", name );

	return NULL;
}
コード例 #10
0
ファイル: g_svcmds.c プロジェクト: zturtleman/mint-arena
/*
===================
G_Field_CompletePlayerName
===================
*/
void G_Field_CompletePlayerName( void ) {
	gplayer_t	*cl;
	int			idnum;
	char		cleanName[MAX_NETNAME];
	char		list[MAX_CLIENTS * MAX_NETNAME];
	int			listTotalLength;

	// ZTM: FIXME: have to clear whole list because BG_AddStringToList doesn't properly terminate list
	memset( list, 0, sizeof( list ) );
	listTotalLength = 0;

	for ( idnum=0,cl=level.players ; idnum < level.maxplayers ; idnum++,cl++ ) {
		if ( cl->pers.connected != CON_CONNECTED ) {
			continue;
		}
		Q_strncpyz(cleanName, cl->pers.netname, sizeof(cleanName));
		Q_CleanStr(cleanName);

		// Use quotes if there is a space in the name
		if ( strchr( cleanName, ' ' ) != NULL ) {
			BG_AddStringToList( list, sizeof( list ), &listTotalLength, va( "\"%s\"", cleanName ) );
		} else {
			BG_AddStringToList( list, sizeof( list ), &listTotalLength, cleanName );
		}
	}

	if ( listTotalLength > 0 ) {
		list[listTotalLength++] = 0;
		trap_Field_CompleteList( list );
	}
}
コード例 #11
0
ファイル: g_svcmds.c プロジェクト: zturtleman/mint-arena
int PlayerForString( const char *s ) {
	gplayer_t	*cl;
	int			idnum;
	char		cleanName[MAX_NETNAME];

	// numeric values could be slot numbers
	if ( StringIsInteger( s ) ) {
		idnum = atoi( s );
		if ( idnum >= 0 && idnum < level.maxplayers ) {
			cl = &level.players[idnum];
			if ( cl->pers.connected == CON_CONNECTED ) {
				return idnum;
			}
		}
	}

	// check for a name match
	for ( idnum=0,cl=level.players ; idnum < level.maxplayers ; idnum++,cl++ ) {
		if ( cl->pers.connected != CON_CONNECTED ) {
			continue;
		}
		Q_strncpyz(cleanName, cl->pers.netname, sizeof(cleanName));
		Q_CleanStr(cleanName);
		if ( !Q_stricmp( cleanName, s ) ) {
			return idnum;
		}
	}

	G_Printf( "User %s is not on the server\n", s );

	return -1;
}
コード例 #12
0
void BotMatch_WrongWall(bot_state_t* bs, bot_match_t *match){
	char netname[MAX_MESSAGE_SIZE];
	char buf[MAX_INFO_STRING];
	int client;

	if(gametype != GT_SPRAY)
		return;

	// talking about me ? (avoid clientfromname, its ambiguous)
	trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
	trap_GetConfigstring(CS_PLAYERS + bs->client, buf, sizeof(buf));
	Q_CleanStr( buf );
	if (!Q_stricmp(Info_ValueForKey(buf, "n"), netname)){
		// could be someone with same name, so make (more) sure
		if( ClientInSprayroom(bs->client) ){
			bs->which_wall = BotChooseCorrectWall(bs);
			bs->enemy = -1;
			// chat
			BotAI_BotInitialChat(bs, "wall_missed", NULL);
			trap_BotEnterChat(bs->cs, 0, CHAT_ALL);
			return;
		}
	}
	// check if opposite team
	client = ClientFromName(netname);
	if(!BotSameTeam(bs, client)){
		float rnd;
		// flame
		rnd = trap_Characteristic_BFloat(bs->character, CHARACTERISTIC_CHAT_INSULT, 0, 1);
		if(random() > rnd) return;	
		BotAI_BotInitialChat(bs, "wall_insult", netname, NULL);
		trap_BotEnterChat(bs->cs, 0, CHAT_ALL);
	}
}
コード例 #13
0
ファイル: g_client.c プロジェクト: baseas/aftershock
gclient_t *ClientFromString(const char *str)
{
	gclient_t	*cl;
	int			idnum;
	char		cleanName[MAX_STRING_CHARS];

	// numeric values could be slot numbers
	if (Q_isanumber(str) && Q_isintegral(atof(str))) {
		idnum = atoi(str);
		if (idnum >= 0 && idnum < level.maxclients) {
			cl = &level.clients[idnum];
			if (cl->pers.connected == CON_CONNECTED) {
				return cl;
			}
		}
	}

	// check for a name match
	for (idnum = 0, cl = level.clients; idnum < level.maxclients; idnum++, cl++) {
		if (cl->pers.connected != CON_CONNECTED) {
			continue;
		}
		Q_strncpyz(cleanName, cl->pers.netname, sizeof cleanName);
		Q_CleanStr(cleanName);
		if (!Q_stricmp(cleanName, str)) {
			return cl;
		}
	}

	return NULL;
}
コード例 #14
0
ファイル: cg_info.c プロジェクト: ElderPlayerX/Afterwards
/*
===================
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 = Q_strrchr( model, '/' );
		if ( skin ) {
			*skin++ = '\0';
		} else {
			skin = "default";
		}

		Com_sprintf( iconName, MAX_QPATH, "models/aw_players/%s/icon_%s.tga", model, skin );
		
		loadingPlayerIcons[loadingPlayerIconCount] = trap_R_RegisterShaderNoMip( iconName );
		if ( !loadingPlayerIcons[loadingPlayerIconCount] ) {
			Com_sprintf( iconName, MAX_QPATH, "models/aw_players/%s/icon_%s.tga", 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 );

	CG_LoadingString( personality );
}
コード例 #15
0
/*
==================
ClientNumberFromString

Returns a player number for either a number or name string
Returns -1 if invalid
==================
*/
int ClientNumberFromString( gentity_t *to, char *s ) {
	gclient_t	*cl;
	int			idnum;
	char		cleanName[MAX_STRING_CHARS];

	// numeric values could be slot numbers
	if ( StringIsInteger( s ) ) {
		idnum = atoi( s );
		if ( idnum >= 0 && idnum < level.maxclients ) {
			cl = &level.clients[idnum];
			if ( cl->pers.connected == CON_CONNECTED ) {
				return idnum;
			}
		}
	}

	// check for a name match
	for ( idnum=0,cl=level.clients ; idnum < level.maxclients ; idnum++,cl++ ) {
		if ( cl->pers.connected != CON_CONNECTED ) {
			continue;
		}
		Q_strncpyz(cleanName, cl->pers.netname, sizeof(cleanName));
		Q_CleanStr(cleanName);
		if ( !Q_stricmp( cleanName, s ) ) {
			return idnum;
		}
	}

	trap_SendServerCommand( to-g_entities, va("print \"User %s is not on the server\n\"", s));
	return -1;
}
コード例 #16
0
ファイル: g_referee.c プロジェクト: SHOVELL/Unvanquished
/////////////////
//   Utility
//
int G_refClientnumForName( gentity_t *ent, const char *name )
{
	char cleanName[ MAX_TOKEN_CHARS ];
	int  i;

	if ( !*name )
	{
		return ( MAX_CLIENTS );
	}

	for ( i = 0; i < level.numConnectedClients; i++ )
	{
		Q_strncpyz( cleanName, level.clients[ level.sortedClients[ i ] ].pers.netname, sizeof( cleanName ) );
		Q_CleanStr( cleanName );

		if ( !Q_stricmp( cleanName, name ) )
		{
			return ( level.sortedClients[ i ] );
		}
	}

	G_refPrintf( ent, "Client not on server." );

	return ( MAX_CLIENTS );
}
コード例 #17
0
ファイル: sv_ccmds.cpp プロジェクト: adnanfzafar/OpenJK
void SV_AutoRecordDemo( client_t *cl ) {
	char demoName[MAX_OSPATH];
	char demoFolderName[MAX_OSPATH];
	char demoFileName[MAX_OSPATH];
	char *demoNames[] = { demoFolderName, demoFileName };
	char date[MAX_OSPATH];
	char folderDate[MAX_OSPATH];
	char folderTreeDate[MAX_OSPATH];
	char demoPlayerName[MAX_NAME_LENGTH];
	time_t rawtime;
	struct tm * timeinfo;
	time( &rawtime );
	timeinfo = localtime( &rawtime );
	strftime( date, sizeof( date ), "%Y-%m-%d_%H-%M-%S", timeinfo );
	timeinfo = localtime( &sv.realMapTimeStarted );
	strftime( folderDate, sizeof( folderDate ), "%Y-%m-%d_%H-%M-%S", timeinfo );
	strftime( folderTreeDate, sizeof( folderTreeDate ), "%Y/%m/%d", timeinfo );
	Q_strncpyz( demoPlayerName, cl->name, sizeof( demoPlayerName ) );
	Q_CleanStr( demoPlayerName );
	Com_sprintf( demoFileName, sizeof( demoFileName ), "%d %s %s %s",
			cl - svs.clients, demoPlayerName, Cvar_VariableString( "mapname" ), date );
	Com_sprintf( demoFolderName, sizeof( demoFolderName ), "%s %s", Cvar_VariableString( "mapname" ), folderDate );
	// sanitize filename
	for ( char **start = demoNames; start - demoNames < (ptrdiff_t)ARRAY_LEN( demoNames ); start++ ) {
		Q_strstrip( *start, "\n\r;:.?*<>|\\/\"", NULL );
	}
	Com_sprintf( demoName, sizeof( demoName ), "autorecord/%s/%s/%s", folderTreeDate, demoFolderName, demoFileName );
	SV_RecordDemo( cl, demoName );
}
コード例 #18
0
ファイル: g_bot.c プロジェクト: GenaSG/ET
/*
==============
G_RemoveNamedBot - removes the bot named "name"
==============
*/
int G_RemoveNamedBot( char *name ) {
	int i;
	char netname[36];
	gclient_t	*cl;

	for ( i=0 ; i< g_maxclients.integer ; i++ ) {
		cl = level.clients + i;
		if ( cl->pers.connected != CON_CONNECTED ) {
			continue;
		}
		if ( !(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) ) {
			continue;
		}

		// use scriptname, not netname
		if (!Q_stricmp(name, cl->pers.botScriptName))
		{
			// found the bot. boot him
			strcpy(netname, cl->pers.netname);
			Q_CleanStr(netname);
			trap_SendConsoleCommand( EXEC_INSERT, va("kick \"%s\" 0\n", netname) );
			return qtrue;
		}
	}
	return qfalse;
}
コード例 #19
0
ファイル: cg_info.c プロジェクト: UberGames/RPG-X2-rpgxEF
/*
===================
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 );

	Q_strncpyz( model, Info_ValueForKey( info, "model" ), sizeof( model ) );
	skin = strchr( model, '/' );
	if ( skin ) {
		//*skin++ = '\0';
		//} else {
		//	skin = "default";
		model[strlen(model) - strlen(skin)] = '\0';
	}

	//RPG-X: MODEL SYSTEM CHANGE
	Com_sprintf( iconName, MAX_QPATH, "models/players_rpgx/%s/model_icon.jpg", model );

	//Com_sprintf( iconName, MAX_QPATH, "models/players/%s/icon_%s.jpg", model, skin );
	
	//CG_Printf( S_COLOR_RED "Loading %s\n", iconName );
	loadingPlayerIcon = trap_R_RegisterShaderNoMip( iconName ); //iconName;

	Q_strncpyz( personality, Info_ValueForKey( info, "n" ), sizeof(personality) );
	Q_CleanStr( personality );

	CG_LoadingString( personality ); 	
}
コード例 #20
0
ファイル: censor.c プロジェクト: dioda/apb
char* G_SayCensor(char *msg)
{
	char token2[1024];
	char token[1024];
	badwordsList_t *this;
	char* ret = msg;

	while(1){
		msg = Com_ParseGetToken(msg);
		if(msg==NULL)
			break;

		int size = Com_ParseTokenLength(msg);
		Q_strncpyz(token,msg,size+1);
		Q_CleanStr(token);
		CharConv(token2,token,sizeof(token2));//	'clear' token
		censor_ignoreMultiple(token,token2,sizeof(token));

		for(this = svse.badwords ; this ; this = this->next){
			if(this->exactmatch){
				if(!Q_stricmp(token2,this->word)){
					memset(msg,'*',size);
					break;
				}
			}else{
				if(strstr(token,this->word)!=NULL){
					memset(msg,'*',size);
					break;
				}
			}
		}
	}
	return ret;
}
コード例 #21
0
ファイル: sv_ccmds.cpp プロジェクト: vvvjk2/jk2mv
/*
==================
SV_GetPlayerByName

Returns the player with name from Cmd_Argv(1)
==================
*/
static client_t *SV_GetPlayerByFedName( const char *name )
{
	client_t	*cl;
	int			i;
	char		cleanName[64];

	// make sure server is running
	if ( !com_sv_running->integer )
	{
		return NULL;
	}

	// check for a name match
	for ( i=0, cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++ )
	{
		if ( !cl->state )
		{
			continue;
		}
		if ( !Q_stricmp( cl->name, name ) )
		{
			return cl;
		}

		Q_strncpyz( cleanName, cl->name, sizeof(cleanName) );
		Q_CleanStr( cleanName, (qboolean)MV_USE102COLOR );
		if ( !Q_stricmp( cleanName, name ) )
		{
			return cl;
		}
	}

	return NULL;
}
コード例 #22
0
ファイル: ui_rankings.c プロジェクト: zturtleman/recoil
/*
===============
Rankings_DrawName
===============
*/
void Rankings_DrawName( void* self )
{
    menufield_s*	f;
    int				length;

    f = (menufield_s*)self;

    // strip color codes
    Q_CleanStr( f->field.buffer );
    length = strlen( f->field.buffer );
    if( f->field.cursor > length )
    {
        f->field.cursor = length;
    }

    // show beginning of long names
    /*
    if( Menu_ItemAtCursor( f->generic.parent ) != f )
    {
    	if( f->field.scroll > 0 )
    	{
    		f->field.cursor = 0;
    		f->field.scroll = 0;
    	}
    }
    */

    MenuField_Draw( f );
}
コード例 #23
0
ファイル: ui_rankings.c プロジェクト: zturtleman/recoil
/*
===============
Rankings_DrawName
===============
*/
void Rankings_DrawName( void* self )
{
    menufield_s		*f;
    int				length;
    char*			p;

    f = (menufield_s*)self;

    // GRANK_FIXME - enforce valid characters
    for( p = f->field.buffer; *p != '\0'; p++ )
    {
        //if( ispunct(*p) || isspace(*p) )
        if( !( ( (*p) >= '0' && (*p) <= '9') || Q_isalpha(*p)) )
        {
            *p = '\0';
        }
    }

    // strip color codes
    Q_CleanStr( f->field.buffer );
    length = strlen( f->field.buffer );
    if( f->field.cursor > length )
    {
        f->field.cursor = length;
    }

    Rankings_DrawText( f );
}
コード例 #24
0
ファイル: main.cpp プロジェクト: D4edalus/CoD4x_Server
void AdminCmds::SM_Chat(const char* line, int clnum)
{
  char chattername[256];
  char cleanname[256];
  int i;

  if(line[0] == 0)
  {
    return;
  }

  if ( clnum >= 0 )
  {
    Q_strncpyz(cleanname, Plugin_GetPlayerName(clnum), sizeof(cleanname));
    Q_CleanStr(cleanname);
    if(Plugin_CanPlayerUseCommand(clnum, "sm_chat"))
    {
        Com_sprintf(chattername, sizeof(chattername), "^3%s", cleanname);
    }else{
        Com_sprintf(chattername, sizeof(chattername), "^2%s", cleanname);
    }
  }else{
    Q_strncpyz(chattername, "^1Console", sizeof(chattername));
  }

  for ( i = 0; i < Plugin_GetSlotCount(); ++i )
  {
    if ( Plugin_CanPlayerUseCommand(i, "sm_chat") || i == clnum)
    {
      Plugin_ChatPrintf(i, "^3[^0AdminChat^3]^7 (%s^7): %s", chattername, line);
    }
  }
}
コード例 #25
0
ファイル: cl_logs.c プロジェクト: AlienHoboken/Unvanquished
/*
==================
CL_WriteClientChatLog
==================
*/
void CL_WriteClientChatLog( char *text ) 
{
	if ( cl_logs && cl_logs->integer ) 
	{
		if ( LogFileOpened == qfalse || !LogFileHandle ) 
		{
			CL_OpenClientLog();
		}
		if ( FS_Initialized() && LogFileOpened == qtrue ) 
		{
			if( cl.serverTime > 0 )
			{
				// varibles
				char NoColorMsg[MAXPRINTMSG];
				char Timestamp[ 60 ];
				char LogText[ 60 + MAXPRINTMSG ];
				if( cl_logs->integer == 1 )
				{
					//just do 3 stars to seperate from normal logging stuff
					Q_strncpyz( Timestamp, "***", sizeof( Timestamp ) );
				} 
				else if ( cl_logs->integer == 2 ) 
				{
					//just game time
					//do timestamp prep
					sprintf( Timestamp, "[%d:%02d]", cl.serverTime / 60000, ( cl.serverTime / 1000 ) % 60 ); //server Time
					
				} 
				else if ( cl_logs->integer == 3 )
				{
					//just system time
					//do timestamp prep
					//get current time/date info
					qtime_t now;
					Com_RealTime( &now );
					sprintf( Timestamp, "[%d:%02d]", now.tm_hour, now.tm_min ); //server Time
				} 
				else if( cl_logs->integer == 4 )
				{
					//all the data
					//do timestamp prep
					//get current time/date info
					qtime_t now;
					Com_RealTime( &now );
					sprintf( Timestamp, "[%d:%02d][%d:%02d]", now.tm_hour, now.tm_min, cl.serverTime / 60000, ( cl.serverTime / 1000 ) % 60 ); //server Time
				}
				//decolor the string
				Q_strncpyz( NoColorMsg, text, sizeof(NoColorMsg) );
				Q_CleanStr( NoColorMsg );
				//prepare text for log
				sprintf( LogText, "%s%s\n", Timestamp, NoColorMsg ); //thing to write to log
				//write to the file
				FS_Write( LogText, strlen( LogText ), LogFileHandle );
				//flush the file so we can see the data
				FS_ForceFlush( LogFileHandle );
			}
		}
	}
}
コード例 #26
0
/*
=============
Com_Printf

Both client and server can use this, and it will output
to the apropriate place.

A raw string should NEVER be passed as fmt, because of "%f" type crashers.
=============
*/
void QDECL Com_Printf( const char *fmt, ... ) {
	va_list		argptr;
	char		msg[MAXPRINTMSG];

	va_start (argptr,fmt);
	vsprintf (msg,fmt,argptr);
	va_end (argptr);

	if ( rd_buffer ) {
		if ((strlen (msg) + strlen(rd_buffer)) > (rd_buffersize - 1)) {
			rd_flush(rd_buffer);
			*rd_buffer = 0;
		}
		Q_strcat(rd_buffer, rd_buffersize, msg);
		rd_flush(rd_buffer);			
		*rd_buffer = 0;
		return;
	}

	// echo to console if we're not a dedicated server
	if ( com_dedicated && !com_dedicated->integer ) {
		CL_ConsolePrint( msg );
	}

	// echo to dedicated console and early console
	Sys_Print( msg );

	// logfile
#ifndef _XBOX
	if ( com_logfile && com_logfile->integer ) {
		if ( !logfile && FS_Initialized() ) {
			struct tm *newtime;
			time_t aclock;

			time( &aclock );
			newtime = localtime( &aclock );

			logfile = FS_FOpenFileWrite( "qconsole.log" );
			Com_Printf( "logfile opened on %s\n", asctime( newtime ) );
			if ( com_logfile->integer > 1 ) {
				// force it to not buffer so we get valid
				// data even if we are crashing
				FS_ForceFlush(logfile);
			}
		}
		if ( logfile && FS_Initialized()) {
			FS_Write(msg, strlen(msg), logfile);
		}
	}
#endif

#if defined(_WIN32) && defined(_DEBUG) && !defined(_XBOX)
	if ( *msg )
	{
		OutputDebugString ( Q_CleanStr(msg) );
		OutputDebugString ("\n");
	}
#endif
}
コード例 #27
0
/*
=================
PlayerModel_SetMenuItems
=================
*/
static void PlayerModel_SetMenuItems( void )
{
	int				i;
	int				maxlen;
	char			modelskin[64];
	char*			buffptr;
	char*			pdest;

	// name
	trap_Cvar_VariableStringBuffer( Com_LocalPlayerCvarName(s_playermodel.localPlayerNum, "name"), s_playermodel.playername.string, 16 );
	Q_CleanStr( s_playermodel.playername.string );

	// model
	trap_Cvar_VariableStringBuffer( Com_LocalPlayerCvarName(s_playermodel.localPlayerNum, "model"), s_playermodel.modelskin, sizeof ( s_playermodel.modelskin ) );
	trap_Cvar_VariableStringBuffer( Com_LocalPlayerCvarName(s_playermodel.localPlayerNum, "headmodel"), s_playermodel.headmodelskin, sizeof ( s_playermodel.headmodelskin ) );
	
	// use default skin if none is set
	if (!strchr(s_playermodel.modelskin, '/')) {
		Q_strcat(s_playermodel.modelskin, 64, "/default");
	}
	
	// find model in our list
	for (i=0; i<s_playermodel.nummodels; i++)
	{
		// strip icon_
		buffptr  = s_playermodel.modelnames[i] + strlen("models/players/");
		pdest    = strstr(buffptr,"icon_");
		if (pdest)
		{
			Q_strncpyz( modelskin, buffptr, pdest - buffptr + 1 );
			Q_strcat( modelskin, sizeof (modelskin), pdest + 5);
		}
		else
			continue;

		if (!Q_stricmp( s_playermodel.modelskin, modelskin ))
		{
			// found pic, set selection here		
			s_playermodel.selectedmodel = i;
			s_playermodel.modelpage     = i/MAX_MODELSPERPAGE;

			// seperate the model name
			maxlen = pdest-buffptr;
			if (maxlen > 16)
				maxlen = 16;
			Q_strncpyz( s_playermodel.modelname.string, buffptr, maxlen );
			Q_strupr( s_playermodel.modelname.string );

			// seperate the skin name
			maxlen = strlen(pdest+5)+1;
			if (maxlen > 16)
				maxlen = 16;
			Q_strncpyz( s_playermodel.skinname.string, pdest+5, maxlen );
			Q_strupr( s_playermodel.skinname.string );
			break;
		}
	}
}
コード例 #28
0
ファイル: sv_ccmds.c プロジェクト: urthub/ioUrTded
/*
==================
SV_GetPlayerByHandle

Returns the player with player id or name from Cmd_Argv(1)
==================
*/
static client_t *SV_GetPlayerByHandle( void ) {
	client_t	*cl;
	int			i;
	char		*s;
	char		cleanName[64];

	// make sure server is running
	if ( !com_sv_running->integer ) {
		return NULL;
	}

	if ( Cmd_Argc() < 2 ) {
		Com_Printf( "No player specified.\n" );
		return NULL;
	}

	s = Cmd_Argv(1);

	// Check whether this is a numeric player handle
	for ( i = 0; s[i] >= '0' && s[i] <= '9'; i++ );
	
	if ( !s[i] )
	{
		int plid = atoi(s);

		// Check for numeric playerid match
		if ( plid >= 0 && plid < sv_maxclients->integer )
		{
			cl = &svs.clients[plid];
			
			if ( cl->state )
				return cl;
		}
	}

	// check for a name match
	for ( i=0, cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++ ) {
		if ( !cl->state ) {
			continue;
		}
		if ( !Q_stricmp( cl->name, s ) ) {
			return cl;
		}

		Q_strncpyz( cleanName, cl->name, sizeof(cleanName) );
		Q_CleanStr( cleanName );
		if ( !Q_stricmp( cleanName, s ) ) {
			return cl;
		}
	}

	if ( Q_stricmp( s, "all" ) ) {
		Com_Printf( "Player %s is not on the server\n", s );
	}

	return NULL;
}
コード例 #29
0
ファイル: ui_teamorders.c プロジェクト: ElderPlayerX/Invasion
/*
===============
UI_TeamOrdersMenu_BuildBotList
===============
*/
static void UI_TeamOrdersMenu_BuildBotList(void)
{
	uiClientState_t	cs;
	int		numPlayers;
	int		isBot;
	int		n;
	char	playerTeam;
	char	botTeam;
	char	info[MAX_INFO_STRING];

	for (n = 0; n < 9; n++)
	{
		teamOrdersMenuInfo.bots[n] = teamOrdersMenuInfo.botNames[n];
	}

	trap_GetClientState(&cs);

	Q_strncpyz(teamOrdersMenuInfo.botNames[0], "Everyone", 16);
	teamOrdersMenuInfo.numBots = 1;

	trap_GetConfigString(CS_SERVERINFO, info, sizeof(info));
	numPlayers = atoi(Info_ValueForKey(info, "sv_maxclients"));
	teamOrdersMenuInfo.gametype = atoi(Info_ValueForKey(info, "g_gametype"));

	//Too: get the player team before the loop, so If player enter after bots in game, the menu still works !
	trap_GetConfigString(CS_PLAYERS + cs.clientNum, info, MAX_INFO_STRING);
	playerTeam = *Info_ValueForKey(info, "t");

	for (n = 0; n < numPlayers && teamOrdersMenuInfo.numBots < 9; n++)
	{
		trap_GetConfigString(CS_PLAYERS + n, info, MAX_INFO_STRING);

		//playerTeam = TEAM_SPECTATOR; // bk001204 = possible uninit use

		/*if (n == cs.clientNum)
		{
			playerTeam = *Info_ValueForKey(info, "t");
			continue;
		}*/

		isBot = atoi(Info_ValueForKey(info, "skill"));
		if (!isBot)
		{
			continue;
		}

		botTeam = *Info_ValueForKey(info, "t");
		if (botTeam != playerTeam)
		{
			continue;
		}

		Q_strncpyz(teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.numBots], Info_ValueForKey(info, "n"), 16);
		Q_CleanStr(teamOrdersMenuInfo.botNames[teamOrdersMenuInfo.numBots]);
		teamOrdersMenuInfo.numBots++;
	}
}
コード例 #30
0
ファイル: g_bot.c プロジェクト: Mattman1153/jedi-academy
/*
===============
G_RemoveRandomBot
===============
*/
int G_RemoveRandomBot( int team ) {
	int i;
	char netname[36];
	gclient_t	*cl;

	for ( i=0 ; i< g_maxclients.integer ; i++ ) {
		cl = level.clients + i;
		if ( cl->pers.connected != CON_CONNECTED ) {
			continue;
		}
		/*if ( !(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) ) {
			continue;
		}*/
		// Fix: ensiform
		if ( !(g_entities[i].r.svFlags & SVF_BOT) ) {
			continue;
		}
		if ( g_entities[i].client->ps.powerups[PW_BLUEFLAG] ) {
			continue;
		}
		if ( g_entities[i].client->ps.powerups[PW_REDFLAG] ) {
			continue;
		}
		if ( g_entities[i].client->ps.powerups[PW_NEUTRALFLAG] ) {
			continue;
		}
		//[OJP - BugFix9]
		if ( cl->sess.sessionTeam == TEAM_SPECTATOR 
			&& cl->sess.spectatorState == SPECTATOR_FOLLOW )
		{//this entity is actually following another entity so the ps data is for a
			//different entity.  Bots never spectate like this so, skip this player.
			continue;
		}
		//[/OJP - BugFix9]

		if (g_gametype.integer == GT_SIEGE)
		{
			if ( team >= 0 && cl->sess.siegeDesiredTeam != team ) {
				continue;
			}
		}
		else
		{
			if ( team >= 0 && cl->sess.sessionTeam != team ) {
				continue;
			}
		}
		strcpy(netname, cl->pers.netname);
		Q_CleanStr(netname);
		// Fix: ensiform
		//trap_SendConsoleCommand( EXEC_INSERT, va("kick \"%s\"\n", netname) );
		trap_SendConsoleCommand( EXEC_INSERT, va("clientkick \"%d\"\n", cl->ps.clientNum));
		return qtrue;
	}
	return qfalse;
}