当前位置: 首页>>代码示例>>C++>>正文


C++ Cmd_Argv函数代码示例

本文整理汇总了C++中Cmd_Argv函数的典型用法代码示例。如果您正苦于以下问题:C++ Cmd_Argv函数的具体用法?C++ Cmd_Argv怎么用?C++ Cmd_Argv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Cmd_Argv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CD_f

static void
CD_f ()
{
	char *command;
	int cdstate;

	if ( Cmd_Argc() < 2 )
	{
		return;
	}

	command = Cmd_Argv( 1 );

	if ( !Q_strcasecmp( command, "on" ) )
	{
		enabled = true;
	}

	if ( !Q_strcasecmp( command, "off" ) )
	{
		if ( !cd_id )
		{
			return;
		}

		cdstate = SDL_CDStatus( cd_id );

		if ( ( cdstate == CD_PLAYING ) || ( cdstate == CD_PAUSED ) )
		{
			CDAudio_Stop();
		}

		enabled = false;
		return;
	}

	if ( !Q_strcasecmp( command, "play" ) )
	{
		CDAudio_Play( (byte) atoi( Cmd_Argv( 2 ) ), false );
		return;
	}

	if ( !Q_strcasecmp( command, "loop" ) )
	{
		CDAudio_Play( (byte) atoi( Cmd_Argv( 2 ) ), true );
		return;
	}

	if ( !Q_strcasecmp( command, "stop" ) )
	{
		CDAudio_Stop();
		return;
	}

	if ( !Q_strcasecmp( command, "pause" ) )
	{
		CDAudio_Pause();
		return;
	}

	if ( !Q_strcasecmp( command, "resume" ) )
	{
		CDAudio_Resume();
		return;
	}

	if ( !Q_strcasecmp( command, "eject" ) )
	{
		CDAudio_Eject();
		return;
	}

	if ( !Q_strcasecmp( command, "info" ) )
	{
		if ( !cd_id )
		{
			return;
		}

		cdstate = SDL_CDStatus( cd_id );
		Com_Printf( "%d tracks\n", cd_id->numtracks );

		if ( cdstate == CD_PLAYING )
		{
			Com_Printf( "Currently %s track %d\n",
					playLooping ? "looping" : "playing",
					cd_id->cur_track + 1 );
		}
		else
		if ( cdstate == CD_PAUSED )
		{
			Com_Printf( "Paused %s track %d\n",
					playLooping ? "looping" : "playing",
					cd_id->cur_track + 1 );
		}

		return;
	}
}
开发者ID:Nekrofage,项目名称:Quake2RPi,代码行数:99,代码来源:cd.c

示例2: CL_GetServerCommand

/*
===================
CL_GetServerCommand

Set up argc/argv for the given command
===================
*/
qboolean CL_GetServerCommand( int serverCommandNumber ) {
	char	*s;
	char	*cmd;
	static char bigConfigString[BIG_INFO_STRING];
	int argc;

	// if we have irretrievably lost a reliable command, drop the connection
	if ( serverCommandNumber <= clc.serverCommandSequence - MAX_RELIABLE_COMMANDS ) {
		// when a demo record was started after the client got a whole bunch of
		// reliable commands then the client never got those first reliable commands
		if ( clc.demoplaying )
			return qfalse;
		Com_Error( ERR_DROP, "CL_GetServerCommand: a reliable command was cycled out" );
		return qfalse;
	}

	if ( serverCommandNumber > clc.serverCommandSequence ) {
		Com_Error( ERR_DROP, "CL_GetServerCommand: requested a command not received" );
		return qfalse;
	}

	s = clc.serverCommands[ serverCommandNumber & ( MAX_RELIABLE_COMMANDS - 1 ) ];
	clc.lastExecutedServerCommand = serverCommandNumber;

	Com_DPrintf( "serverCommand: %i : %s\n", serverCommandNumber, s );

rescan:
	Cmd_TokenizeString( s );
	cmd = Cmd_Argv(0);
	argc = Cmd_Argc();

	if ( !strcmp( cmd, "disconnect" ) ) {
		// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=552
		// allow server to indicate why they were disconnected
		if ( argc >= 2 )
			Com_Error( ERR_SERVERDISCONNECT, "Server disconnected - %s", Cmd_Argv( 1 ) );
		else
			Com_Error( ERR_SERVERDISCONNECT, "Server disconnected" );
	}

	if ( !strcmp( cmd, "bcs0" ) ) {
		Com_sprintf( bigConfigString, BIG_INFO_STRING, "cs %s \"%s", Cmd_Argv(1), Cmd_Argv(2) );
		return qfalse;
	}

	if ( !strcmp( cmd, "bcs1" ) ) {
		s = Cmd_Argv(2);
		if( strlen(bigConfigString) + strlen(s) >= BIG_INFO_STRING ) {
			Com_Error( ERR_DROP, "bcs exceeded BIG_INFO_STRING" );
		}
		strcat( bigConfigString, s );
		return qfalse;
	}

	if ( !strcmp( cmd, "bcs2" ) ) {
		s = Cmd_Argv(2);
		if( strlen(bigConfigString) + strlen(s) + 1 >= BIG_INFO_STRING ) {
			Com_Error( ERR_DROP, "bcs exceeded BIG_INFO_STRING" );
		}
		strcat( bigConfigString, s );
		strcat( bigConfigString, "\"" );
		s = bigConfigString;
		goto rescan;
	}

	if ( !strcmp( cmd, "cs" ) ) {
		CL_ConfigstringModified();
		// reparse the string, because CL_ConfigstringModified may have done another Cmd_TokenizeString()
		Cmd_TokenizeString( s );
		return qtrue;
	}

	if ( !strcmp( cmd, "map_restart" ) ) {
		// clear notify lines and outgoing commands before passing
		// the restart to the cgame
		Con_ClearNotify();
		// reparse the string, because Con_ClearNotify() may have done another Cmd_TokenizeString()
		Cmd_TokenizeString( s );
		Com_Memset( cl.cmds, 0, sizeof( cl.cmds ) );
		return qtrue;
	}

	// the clientLevelShot command is used during development
	// to generate 128*128 screenshots from the intermission
	// point of levels for the menu system to use
	// we pass it along to the cgame to make apropriate adjustments,
	// but we also clear the console and notify lines here
	if ( !strcmp( cmd, "clientLevelShot" ) ) {
		// don't do it if we aren't running the server locally,
		// otherwise malicious remote servers could overwrite
		// the existing thumbnails
		if ( !com_sv_running->integer ) {
			return qfalse;
//.........这里部分代码省略.........
开发者ID:d00man,项目名称:openarena-engine,代码行数:101,代码来源:cl_cgame.c

示例3: Cmd_ArgvBuffer

/*
============
Cmd_ArgvBuffer

The interpreted versions use this because
they can't have pointers returned to them
============
*/
void Cmd_ArgvBuffer( int arg, char *buffer, int bufferLength )
{
	Q_strncpyz( buffer, Cmd_Argv( arg ), bufferLength );
}
开发者ID:JacksonTech,项目名称:Unvanquished,代码行数:12,代码来源:cmd.cpp

示例4: SV_MapRestart_f

/*
================
SV_MapRestart_f

Completely restarts a level, but doesn't send a new gamestate to the clients.
This allows fair starts with variable load times.
================
*/
static void SV_MapRestart_f(void)
{
	int         i;
	client_t    *client;
	char        *denied;
	qboolean    isBot;
	int         delay = 0;
	gamestate_t new_gs, old_gs;     // NERVE - SMF

	// make sure we aren't restarting twice in the same frame
	if (com_frameTime == sv.serverId)
	{
		return;
	}

	// make sure server is running
	if (!com_sv_running->integer)
	{
		Com_Printf("Server is not running.\n");
		return;
	}

	// ydnar: allow multiple delayed server restarts [atvi bug 3813]
	//%	if ( sv.restartTime ) {
	//%		return;
	//%	}

	if (Cmd_Argc() > 1)
	{
		delay = atoi(Cmd_Argv(1));
	}

	if (delay)
	{
		sv.restartTime = svs.time + delay * 1000;
		SV_SetConfigstring(CS_WARMUP, va("%i", sv.restartTime));
		return;
	}

	// NERVE - SMF - read in gamestate or just default to GS_PLAYING
	old_gs = atoi(Cvar_VariableString("gamestate"));

	if (SV_GameIsSinglePlayer() || SV_GameIsCoop())
	{
		new_gs = GS_PLAYING;
	}
	else
	{
		if (Cmd_Argc() > 2)
		{
			new_gs = atoi(Cmd_Argv(2));
		}
		else
		{
			new_gs = GS_PLAYING;
		}
	}

	if (!SV_TransitionGameState(new_gs, old_gs, delay))
	{
		return;
	}

	// check for changes in variables that can't just be restarted
	// check for maxclients change
	if (sv_maxclients->modified)
	{
		char mapname[MAX_QPATH];

		Com_Printf("sv_maxclients variable change -- restarting.\n");
		// restart the map the slow way
		Q_strncpyz(mapname, Cvar_VariableString("mapname"), sizeof(mapname));

		SV_SpawnServer(mapname, qfalse);
		return;
	}

	// Check for loading a saved game
	if (Cvar_VariableIntegerValue("savegame_loading"))
	{
		// open the current savegame, and find out what the time is, everything else we can ignore
		char savemap[MAX_QPATH];
		byte *buffer;
		int  size, savegameTime;
		char *cl_profileStr = Cvar_VariableString("cl_profile");

		if (com_gameInfo.usesProfiles)
		{
			Com_sprintf(savemap, sizeof(savemap), "profiles/%s/save/current.sav", cl_profileStr);
		}
		else
		{
//.........这里部分代码省略.........
开发者ID:morsik,项目名称:war-territory,代码行数:101,代码来源:sv_ccmds.c

示例5: ParseMasterArgs

static void ParseMasterArgs(netadr_t *broadcast)
{
    void *data;
    ssize_t len;
    void (*parse)(void *, size_t, size_t);
    size_t chunk;
    char *s, *p;
    int i, argc;

    Cmd_TokenizeString(m_servers.args, qfalse);

    argc = Cmd_Argc();
    if (!argc) {
        // default action to take when no URLs are given
        ParseAddressBook();
        broadcast->type = NA_BROADCAST;
        broadcast->port = BigShort(PORT_SERVER);
        return;
    }

    for (i = 0; i < argc; i++) {
        s = Cmd_Argv(i);
        if (!*s)
            continue;

        // parse binary format specifier
        parse = ParsePlain;
        chunk = 0;
        if (*s == '+' || *s == '-') {
            parse = ParseBinary;
            chunk = strtoul(s, &p, 10);
            if (s == p) {
                chunk = 6;
                s = p + 1;
            } else {
                if (chunk < 6)
                    goto ignore;
                s = p;
            }
        }

        if (!strncmp(s, "file://", 7)) {
            len = FS_LoadFile(s + 7, &data);
            if (len < 0)
                continue;
            (*parse)(data, len, chunk);
            FS_FreeFile(data);
            continue;
        }

        if (!strncmp(s, "http://", 7)) {
#if USE_CURL
            len = HTTP_FetchFile(s + 7, &data);
            if (len < 0)
                continue;
            (*parse)(data, len, chunk);
            Z_Free(data);
#else
            Com_Printf("Can't fetch '%s', no HTTP support compiled in.\n", s);
#endif
            continue;
        }

        if (!strncmp(s, "favorites://", 12)) {
            ParseAddressBook();
            continue;
        }

        if (!strncmp(s, "broadcast://", 12)) {
            broadcast->type = NA_BROADCAST;
            broadcast->port = BigShort(PORT_SERVER);
            continue;
        }

        if (!strncmp(s, "quake2://", 9)) {
            AddServer(NULL, s + 9);
            continue;
        }

ignore:
        Com_Printf("Ignoring invalid master URL: %s\n", s);
    }
}
开发者ID:m4son,项目名称:q2pro,代码行数:83,代码来源:servers.c

示例6: SV_DelBanFromList

static void SV_DelBanFromList(qboolean isexception)
{
	int index, count = 0, todel, mask;
	netadr_t ip;
	char *banstring;
	
	if(Cmd_Argc() != 2)
	{
		Com_Printf ("Usage: %s (ip[/subnet] | num)\n", Cmd_Argv(0));
		return;
	}

	banstring = Cmd_Argv(1);
	
	if(strchr(banstring, '.') || strchr(banstring, ':'))
	{
		serverBan_t *curban;
		
		if(SV_ParseCIDRNotation(&ip, &mask, banstring))
		{
			Com_Printf("Error: Invalid address %s\n", banstring);
			return;
		}
		
		index = 0;
		
		while(index < serverBansCount)
		{
			curban = &serverBans[index];
			
			if(curban->isexception == isexception		&&
			   curban->subnet >= mask 			&&
			   NET_CompareBaseAdrMask(curban->ip, ip, mask))
			{
				Com_Printf("Deleting %s %s/%d\n",
					   isexception ? "exception" : "ban",
					   NET_AdrToString(curban->ip), curban->subnet);
					   
				SV_DelBanEntryFromList(index);
			}
			else
				index++;
		}
	}
	else
	{
		todel = atoi(Cmd_Argv(1));

		if(todel < 1 || todel > serverBansCount)
		{
			Com_Printf("Error: Invalid ban number given\n");
			return;
		}
	
		for(index = 0; index < serverBansCount; index++)
		{
			if(serverBans[index].isexception == isexception)
			{
				count++;
			
				if(count == todel)
				{
					Com_Printf("Deleting %s %s/%d\n",
					   isexception ? "exception" : "ban",
					   NET_AdrToString(serverBans[index].ip), serverBans[index].subnet);

					SV_DelBanEntryFromList(index);

					break;
				}
			}
		}
	}
	
	SV_WriteBans();
}
开发者ID:TwistTheNeil,项目名称:ioq3-urt-4.2-jump-server,代码行数:76,代码来源:sv_ccmds.c

示例7: string

/*
-----------------------------------------------------------------------------
 Function: Cmd_Alias_f -Creates a new command that executes a command 
						string (possibly ; seperated).
 
 Parameters: Nothing.
 
 Returns: Nothing. 
 
 Notes: 

-----------------------------------------------------------------------------
*/
PRIVATE void Cmd_Alias_f( void )
{
	cmdalias_t	*a;
	char		cmd[ 1024 ];
	int			i, c;
	char		*s;
	W32	hashid;

	if( Cmd_Argc() == 1 )
	{
		Com_Printf( "Current alias commands:\n" );
		for( a = cmd_alias ; a ; a = a->next )
		{
			Com_Printf( "%s : %s\n", a->name, a->value );
		}
		return;
	}

	s = Cmd_Argv( 1 );
	if( strlen( s ) >= MAX_ALIAS_NAME )
	{
		Com_Printf( "Alias name is too long\n" );
		return;
	}

	hashid = my_strhash( s );

	// if the alias already exists, reuse it
	for( a = cmd_alias ; a ; a = a->next )
	{
		if( hashid == a->id )
		{
			Z_Free( a->value );
			break;
		}
	}

	if( ! a )
	{
		a = Z_Malloc( sizeof( cmdalias_t ) );
		a->next = cmd_alias;
		cmd_alias = a;
	}	
	my_strlcpy( a->name, s, sizeof( a->name ) );
	a->id = hashid;

// copy the rest of the command line
	cmd[ 0 ] = '\0';	// start out with a NUL-terminated string
	c = Cmd_Argc();
	for( i = 2; i < c; ++i )
	{
		my_strlcat( cmd, Cmd_Argv( i ), sizeof( cmd ) );
		if( i != (c - 1) )
		{
			my_strlcat( cmd, " ", sizeof( cmd ) );
		}
	}
	my_strlcat( cmd, "\n", sizeof( cmd ) );
	
	a->value = my_CopyString( cmd );
}
开发者ID:feraligatr,项目名称:wolf2d,代码行数:74,代码来源:cmd.c

示例8: KeyUp

void
KeyUp(kbutton_t *b)
{
	int k;
	char *c;
	unsigned uptime;

	c = Cmd_Argv(1);

	if (c[0])
	{
		k = (int)strtol(c, (char **)NULL, 10);
	}

	else
	{
		/* typed manually at the console, assume for unsticking, so clear all */
		b->down[0] = b->down[1] = 0;
		b->state = 4; /* impulse up */
		return;
	}

	if (b->down[0] == k)
	{
		b->down[0] = 0;
	}

	else if (b->down[1] == k)
	{
		b->down[1] = 0;
	}

	else
	{
		return; /* key up without coresponding down (menu pass through) */
	}

	if (b->down[0] || b->down[1])
	{
		return; /* some other key is still holding it down */
	}

	if (!(b->state & 1))
	{
		return; /* still up (this should not happen) */
	}

	/* save timestamp */
	c = Cmd_Argv(2);
	uptime = (int)strtol(c, (char **)NULL, 10);

	if (uptime)
	{
		b->msec += uptime - b->downtime;
	}

	else
	{
		b->msec += 10;
	}

	b->state &= ~1; /* now up */
	b->state |= 4; /* impulse up */
}
开发者ID:Samurai336,项目名称:yquake2,代码行数:64,代码来源:cl_input.c

示例9: IN_Impulse

void
IN_Impulse(void)
{
	in_impulse = (int)strtol(Cmd_Argv(1), (char **)NULL, 10);
}
开发者ID:Samurai336,项目名称:yquake2,代码行数:5,代码来源:cl_input.c

示例10: CL_PlayDemo_f

/*
====================
CL_PlayDemo_f

playdemo <demoname>
====================
*/
void CL_PlayDemo_f( void )
{
	string	filename;
	string	demoname;
	int	i;

	if( Cmd_Argc() != 2 )
	{
		Msg( "Usage: playdemo <demoname>\n" );
		return;
	}

	if( cls.demoplayback )
	{
		CL_StopPlayback();
	}

	if( cls.demorecording )
	{
		Msg( "Can't playback during demo record.\n");
		return;
	}

	Q_strncpy( demoname, Cmd_Argv( 1 ), sizeof( demoname ) - 1 );
	Q_snprintf( filename, sizeof( filename ), "demos/%s.dem", demoname );

	if( !FS_FileExists( filename, true ))
	{
		MsgDev( D_ERROR, "couldn't open %s\n", filename );
		cls.demonum = -1; // stop demo loop
		return;
	}

	cls.demofile = FS_Open( filename, "rb", true );
	Q_strncpy( cls.demoname, demoname, sizeof( cls.demoname ));
	Q_strncpy( menu.globals->demoname, demoname, sizeof( menu.globals->demoname ));

	// read in the m_DemoHeader
	FS_Read( cls.demofile, &demo.header, sizeof( demoheader_t ));

	if( demo.header.id != IDEMOHEADER )
	{
		MsgDev( D_ERROR, "%s is not a demo file\n", filename );
		FS_Close( cls.demofile );
		cls.demofile = NULL;
		cls.demonum = -1; // stop demo loop
		return;
	}

	if( demo.header.net_protocol != PROTOCOL_VERSION || demo.header.dem_protocol != DEMO_PROTOCOL )
	{
		MsgDev( D_ERROR, "demo protocol outdated\n"
			"Demo file protocols Network(%i), Demo(%i)\n"
			"Server protocol is at Network(%i), Demo(%i)\n",
			demo.header.net_protocol, 
			demo.header.dem_protocol,
			PROTOCOL_VERSION,
			DEMO_PROTOCOL
		);

		FS_Close( cls.demofile );
		cls.demofile = NULL;
		cls.demonum = -1; // stop demo loop
		return;
	}

	// now read in the directory structure.
	FS_Seek( cls.demofile, demo.header.directory_offset, SEEK_SET );
	FS_Read( cls.demofile, &demo.directory.numentries, sizeof( int ));

	if( demo.directory.numentries < 1 || demo.directory.numentries > 1024 )
	{
		MsgDev( D_ERROR, "demo had bogus # of directory entries: %i\n", demo.directory.numentries );
		FS_Close( cls.demofile );
		cls.demofile = NULL;
		cls.demonum = -1; // stop demo loop
		cls.changedemo = false;
		return;
	}

	if( cls.changedemo )
	{
		S_StopAllSounds();
		SCR_BeginLoadingPlaque( false );

		CL_ClearState ();
		CL_InitEdicts (); // re-arrange edicts
	}
	else
	{
		// NOTE: at this point demo is still valid
		CL_Disconnect();
		Host_ShutdownServer();
//.........这里部分代码省略.........
开发者ID:Reedych,项目名称:xash3d,代码行数:101,代码来源:cl_demo.c

示例11: CL_Record_f

/*
====================
CL_Record_f

record <demoname>
Begins recording a demo from the current position
====================
*/
void CL_Record_f( void )
{
	const char	*name;
	string		demoname, demopath, demoshot;
	int		n;

	if( Cmd_Argc() == 1 )
	{
		name = "new";
	}
	else if( Cmd_Argc() == 2 )
	{
		name = Cmd_Argv( 1 );
	}
	else
	{
		Msg( "Usage: record <demoname>\n" );
		return;
	}

	if( cls.demorecording )
	{
		Msg( "Already recording.\n");
		return;
	}

	if( cls.demoplayback )
	{
		Msg( "Can't record during demo playback.\n");
		return;
	}

	if( !cls.demoheader || cls.state != ca_active )
	{
		Msg( "You must be in a level to record.\n");
		return;
	}

	if( !Q_stricmp( name, "new" ))
	{
		// scan for a free filename
		for( n = 0; n < 10000; n++ )
		{
			CL_DemoGetName( n, demoname );
			if( !FS_FileExists( va( "demos/%s.dem", demoname ), true ))
				break;
		}

		if( n == 10000 )
		{
			Msg( "^3ERROR: no free slots for demo recording\n" );
			return;
		}
	}
	else Q_strncpy( demoname, name, sizeof( demoname ));

	// open the demo file
	Q_sprintf( demopath, "demos/%s.dem", demoname );
	Q_sprintf( demoshot, "demos/%s.bmp", demoname );

	// make sure what old demo is removed
	if( FS_FileExists( demopath, false )) FS_Delete( demopath );
	if( FS_FileExists( demoshot, false )) FS_Delete( demoshot );

	// write demoshot for preview
	Cbuf_AddText( va( "demoshot \"%s\"\n", demoname ));
	Q_strncpy( cls.demoname, demoname, sizeof( cls.demoname ));
	Q_strncpy( menu.globals->demoname, demoname, sizeof( menu.globals->demoname ));
	
	CL_WriteDemoHeader( demopath );
}
开发者ID:Reedych,项目名称:xash3d,代码行数:79,代码来源:cl_demo.c

示例12: SVC_DirectConnect

/*
==================
SVC_DirectConnect

A connection request that did not come from the master
==================
*/
void SVC_DirectConnect (void)
{
    char		userinfo[MAX_INFO_STRING];
    netadr_t	adr;
    int32_t			i;
    client_t	*cl, *newcl;
    client_t	temp;
    edict_t		*ent;
    int32_t			edictnum;
    int32_t			version;
    int32_t			qport;
    int32_t			challenge;
    int32_t			previousclients;	// rich: connection limit per IP

    adr = net_from;

    Com_DPrintf ("SVC_DirectConnect ()\n");

    version = atoi(Cmd_Argv(1));
    if (version != PROTOCOL_VERSION)
    {
        Netchan_OutOfBandPrint (NS_SERVER, adr, "print\nServer is version %4.2f.\n", VERSION);
        Com_DPrintf ("    rejected connect from version %i\n", version);
        return;
    }

    qport = atoi(Cmd_Argv(2));

    challenge = atoi(Cmd_Argv(3));

    // r1ch: limit connections from a single IP
    previousclients = 0;
    for (i=0,cl=svs.clients; i<(int32_t)maxclients->value; i++,cl++)
    {
        if (cl->state == cs_free)
            continue;
        if (NET_CompareBaseAdr (adr, cl->netchan.remote_address))
        {
            // r1ch: zombies are less dangerous
            if (cl->state == cs_zombie)
                previousclients++;
            else
                previousclients += 2;
        }
    }
    if (previousclients >= (int32_t)sv_iplimit->value * 2)
    {
        Netchan_OutOfBandPrint (NS_SERVER, adr, "print\nToo many connections from your host.\n");
        Com_DPrintf ("    too many connections\n");
        return;
    }
    // end r1ch fix

    strncpy (userinfo, Cmd_Argv(4), sizeof(userinfo)-1);
    userinfo[sizeof(userinfo) - 1] = 0;

    // force the IP key/value pair so the game can filter based on ip
    Info_SetValueForKey (userinfo, "ip", NET_AdrToString(net_from));

    // attractloop servers are ONLY for local clients
    if (sv.attractloop)
    {
        if (!NET_IsLocalAddress (adr))
        {
            Com_Printf ("Remote connect in attract loop.  Ignored.\n");
            Netchan_OutOfBandPrint (NS_SERVER, adr, "print\nConnection refused.\n");
            return;
        }
    }

    // see if the challenge is valid
    if (!NET_IsLocalAddress (adr))
    {
        for (i=0 ; i<MAX_CHALLENGES ; i++)
        {
            if (NET_CompareBaseAdr (net_from, svs.challenges[i].adr))
            {
                if (challenge == svs.challenges[i].challenge)
                    break;		// good
                Netchan_OutOfBandPrint (NS_SERVER, adr, "print\nBad challenge.\n");
                return;
            }
        }
        if (i == MAX_CHALLENGES)
        {
            Netchan_OutOfBandPrint (NS_SERVER, adr, "print\nNo challenge for address.\n");
            return;
        }
    }

    newcl = &temp;
    memset (newcl, 0, sizeof(client_t));

//.........这里部分代码省略.........
开发者ID:postfix,项目名称:quake2vr,代码行数:101,代码来源:sv_main.c

示例13: CL_Say_f

void CL_Say_f (void)
{
	char output[8192];
	char string[256];
	char *msg;
	int c;
	output[0] = '\0';
	if (cls.state == ca_disconnected || cls.demoplayback)
	{
#ifndef CLIENT_ONLY
		if (sv.state)
			SV_ConSay_f();
		else
#endif
			Con_TPrintf ("Can't \"%s\", not connected\n", Cmd_Argv(0));
		return;
	}

	if (!strcmp("sayone", Cmd_Argv(0)))
	{
		if (strcmp(Info_ValueForKey(cl.serverinfo, "*distrib"), DISTRIBUTION) || atoi(Info_ValueForKey(cl.serverinfo, "*ver")) < PRE_SAYONE)
		{
			Con_Printf ("%s is only available with server support\n", Cmd_Argv(0));
			return;
		}
	}

	Q_strncpyz(output, Cmd_Argv(0), sizeof(string));
	for (msg = output; *msg; msg++)
		if (*msg >= 'A' && *msg <= 'Z')
			*msg = *msg - 'A' + 'a';

	msg = Cmd_Args();

	if (Cmd_Argc() > 1)
	{
		Q_strncatz(output, " \"", sizeof(output));

		while(*msg)
		{
			c = *msg;

			if (c == '%')
			{
				char *message = NULL;
				msg++;

				if (message == NULL)
				switch(*msg)
				{
				case 'n':
					Q_strncatz(output, name.string, sizeof(output));
					msg++;
					continue;
				case 'h':
					Q_strncatz(output, va("%i", cl.stats[0][STAT_HEALTH]), sizeof(output));
					msg++;
					continue;
				case 'a':
					Q_strncatz(output, va("%i", cl.stats[0][STAT_ARMOR]), sizeof(output));
					msg++;
					continue;
				case 'A':
					Q_strncatz(output, TP_ArmourType(), sizeof(output));
					msg++;
					continue;
				case 'l':
					Q_strncatz(output, CL_LocationName(cl.simorg[0]), sizeof(output));
					msg++;
					continue;
				case 'S':
					Q_strncatz(output, TP_ClassForTFSkin(), sizeof(output));
					msg++;
					continue;
				case '%':
					c  = '%';
					break;
				default:
					c  = '%';
					msg--;
					break;
				}
			}
			else if (c == '$')
			{
				msg++;
				switch(*msg)
				{
				case '\\': c = 0x0D; break;
				case ':': c = 0x0A; break;
				case '[': c = 0x10; break;
				case ']': c = 0x11; break;
				case 'G': c = 0x86; break;
				case 'R': c = 0x87; break;
				case 'Y': c = 0x88; break;
				case 'B': c = 0x89; break;
				case '(': c = 0x80; break;
				case '=': c = 0x81; break;
				case ')': c = 0x82; break;
				case 'a': c = 0x83; break;
//.........这里部分代码省略.........
开发者ID:ProfessorKaos64,项目名称:ftequake,代码行数:101,代码来源:teamplay.c

示例14: Cmd_CvarList_f

/* <18d23> ../engine/cvar.c:671 */
void Cmd_CvarList_f(void)
{
	cvar_t *var;
	int iCvars;
	int iArgs;
	const char *partial, *arg1;
	int ipLen;
	qboolean bAOnly;
	qboolean bSOnly;
	char szTemp[MAX_PATH];
	FileHandle_t f;
	FileHandle_t fp;
	qboolean bLogging;

	iCvars = 0;
	partial = NULL;
	bAOnly = FALSE;
	bSOnly = FALSE;
	f = NULL;
	fp = NULL;
	bLogging = FALSE;

	iArgs = Cmd_Argc();
	if (iArgs > 1)
	{
		arg1 = Cmd_Argv(1);

		if (!Q_stricmp(arg1, "?"))
		{
			Con_Printf("CvarList           : List all cvars\nCvarList [Partial] : List cvars starting with 'Partial'\nCvarList log [Partial] : Logs cvars to file \"cvarlist.txt\" in the gamedir.\n");
			return;
		}

		if (!Q_stricmp(arg1, "log"))
		{
			// Open log
			int i;
			for (i = 0; i < 100; i++)
			{
				Q_snprintf(szTemp, ARRAYSIZE(szTemp) - 1, "cvarlist%02d.txt", i);
				szTemp[ARRAYSIZE(szTemp) - 1] = 0;

				fp = FS_Open(szTemp, "r");
				if (!fp)
				{
					break;
				}
				FS_Close(fp);
			}

			if (i >= 100)
			{
				Con_Printf("Can't cvarlist! Too many existing cvarlist output files in the gamedir!\n");
				return;
			}

			f = FS_Open(szTemp, "wt");
			if (!f)
			{
				Con_Printf("Couldn't open \"%s\" for writing!\n", szTemp);
				return;
			}
			bLogging = TRUE;

			// Get next argument into partial, if present
			if (iArgs > 2)
			{
				partial = Cmd_Argv(2);
				ipLen = Q_strlen(partial);
			}
		}
		else if (!Q_stricmp(arg1, "-a"))
		{
			bAOnly = TRUE;
		}
		else if (!Q_stricmp(arg1, "-s"))
		{
			bSOnly = TRUE;
		}
		else
		{
			partial = arg1;
			ipLen = Q_strlen(partial);
		}
	}

	// Print cvars
	Con_Printf("CVar List\n--------------\n");

	for (var = cvar_vars; var; var = var->next)
	{
		if (bAOnly && !(var->flags & FCVAR_ARCHIVE))
		{
			continue;
		}
		if (bSOnly && !(var->flags & FCVAR_SERVER))
		{
			continue;
		}
//.........这里部分代码省略.........
开发者ID:Adidasman1,项目名称:rehlds,代码行数:101,代码来源:cvar.cpp

示例15: SV_MapRestart_f

/*
================
SV_MapRestart_f

Completely restarts a level, but doesn't send a new gamestate to the clients.
This allows fair starts with variable load times.
================
*/
static void SV_MapRestart_f( void ) {
	int			i;
	client_t	*client;
	char		*denied;
	qboolean	isBot;
	int			delay;

	// make sure we aren't restarting twice in the same frame
	if ( com_frameTime == sv.serverId ) {
		return;
	}

	// make sure server is running
	if ( !com_sv_running->integer ) {
		Com_Printf( "Server is not running.\n" );
		return;
	}

	if ( sv.restartTime ) {
		return;
	}

	if (Cmd_Argc() > 1 ) {
		delay = atoi( Cmd_Argv(1) );
	}
	else {
		delay = 5;
	}
	if( delay && !Cvar_VariableValue("g_doWarmup") ) {
		sv.restartTime = sv.time + delay * 1000;
		SV_SetConfigstring( CS_WARMUP, va("%i", sv.restartTime) );
		return;
	}

	// check for changes in variables that can't just be restarted
	// check for maxclients change
	if ( sv_maxclients->modified || sv_gametype->modified ) {
		char	mapname[MAX_QPATH];

		Com_Printf( "variable change -- restarting.\n" );
		// restart the map the slow way
		Q_strncpyz( mapname, Cvar_VariableString( "mapname" ), sizeof( mapname ) );

		SV_SpawnServer( mapname, qfalse );
		return;
	}

	// toggle the server bit so clients can detect that a
	// map_restart has happened
	svs.snapFlagServerBit ^= SNAPFLAG_SERVERCOUNT;

	// generate a new serverid	
	// TTimo - don't update restartedserverId there, otherwise we won't deal correctly with multiple map_restart
	sv.serverId = com_frameTime;
	Cvar_Set( "sv_serverid", va("%i", sv.serverId ) );

	// if a map_restart occurs while a client is changing maps, we need
	// to give them the correct time so that when they finish loading
	// they don't violate the backwards time check in cl_cgame.c
	for (i=0 ; i<sv_maxclients->integer ; i++) {
		if (svs.clients[i].state == CS_PRIMED) {
			svs.clients[i].oldServerTime = sv.restartTime;
		}
	}

	// reset all the vm data in place without changing memory allocation
	// note that we do NOT set sv.state = SS_LOADING, so configstrings that
	// had been changed from their default values will generate broadcast updates
	sv.state = SS_LOADING;
	sv.restarting = qtrue;

	SV_RestartGameProgs();

	// run a few frames to allow everything to settle
	for (i = 0; i < 3; i++)
	{
		VM_Call (gvm, GAME_RUN_FRAME, sv.time);
		sv.time += 100;
		svs.time += 100;
	}

	sv.state = SS_GAME;
	sv.restarting = qfalse;

	// connect and begin all the clients
	for (i=0 ; i<sv_maxclients->integer ; i++) {
		client = &svs.clients[i];

		// send the new gamestate to all connected clients
		if ( client->state < CS_CONNECTED) {
			continue;
		}
//.........这里部分代码省略.........
开发者ID:TwistTheNeil,项目名称:ioq3-urt-4.2-jump-server,代码行数:101,代码来源:sv_ccmds.c


注:本文中的Cmd_Argv函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。