本文整理汇总了C++中Cmd_Argc函数的典型用法代码示例。如果您正苦于以下问题:C++ Cmd_Argc函数的具体用法?C++ Cmd_Argc怎么用?C++ Cmd_Argc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Cmd_Argc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PR_Profile_f
void PR_Profile_f (void)
{
int i, j;
int max;
dfunction_t *f, *bestFunc;
int total;
int funcCount;
qboolean byHC;
char saveName[MAX_OSPATH];
FILE *saveFile = NULL;
int currentFile;
int bestFile;
int tally;
const char *s;
byHC = false;
funcCount = 10;
*saveName = 0;
for (i = 1; i < Cmd_Argc(); i++)
{
s = Cmd_Argv(i);
if (tolower(*s) == 'h')
{ // Sort by HC source file
byHC = true;
}
else if (tolower(*s) == 's')
{ // Save to file
if (i + 1 < Cmd_Argc() && !isdigit(*Cmd_Argv(i + 1)))
{
i++;
sprintf(saveName, "%s/%s", fs_userdir, Cmd_Argv(i));
}
else
{
sprintf(saveName, "%s/profile.txt", fs_userdir);
}
}
else if (isdigit(*s))
{ // Specify function count
funcCount = atoi(Cmd_Argv(i));
if (funcCount < 1)
{
funcCount = 1;
}
}
}
total = 0;
for (i = 0; i < progs->numfunctions; i++)
{
total += pr_functions[i].profile;
}
if (*saveName)
{ // Create the output file
saveFile = fopen(saveName, "w");
if (saveFile == NULL)
Con_Printf("Could not open %s\n", saveName);
}
#ifdef TIMESNAP_ACTIVE
if (saveFile)
{
fprintf(saveFile, "(Timesnap Profile)\n");
}
else
{
Con_Printf("(Timesnap Profile)\n");
}
#endif
if (byHC == false)
{
j = 0;
do
{
max = 0;
bestFunc = NULL;
for (i = 0; i < progs->numfunctions; i++)
{
f = &pr_functions[i];
if (f->profile > max)
{
max = f->profile;
bestFunc = f;
}
}
if (bestFunc)
{
if (j < funcCount)
{
if (saveFile)
{
fprintf(saveFile, "%05.2f %s\n",
((float)bestFunc->profile / (float)total) * 100.0,
PR_GetString(bestFunc->s_name));
}
else
{
Con_Printf("%05.2f %s\n",
//.........这里部分代码省略.........
示例2: 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 ) {
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, eForceReload_NOTHING );
return;
}
SV_StopAutoRecordDemos();
// 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 ) );
time( &sv.realMapTimeStarted );
sv.demosPruned = qfalse;
// 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_RestartGame();
// run a few frames to allow everything to settle
for ( i = 0 ;i < 3 ; i++ ) {
GVM_RunFrame( 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];
//.........这里部分代码省略.........
示例3: SV_DelBanFromList
static void SV_DelBanFromList( qboolean isexception )
{
int index, count = 0, todel, mask;
netadr_t ip;
char *banstring;
// make sure server is running
if ( !com_sv_running->integer ) {
Com_Printf( "Server is not running.\n" );
return;
}
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();
}
示例4: Cvar_List_f
/*
=======================================================================================================================================
Cvar_List_f
=======================================================================================================================================
*/
void Cvar_List_f(void) {
cvar_t *var;
int i;
char *match;
if (Cmd_Argc() > 1) {
match = Cmd_Argv(1);
} else {
match = NULL;
}
i = 0;
for (var = cvar_vars; var; var = var->next, i++) {
if (!var->name || (match && !Com_Filter(match, var->name, qfalse))) {
continue;
}
if (var->flags & CVAR_SERVERINFO) {
Com_Printf("S");
} else {
Com_Printf(" ");
}
if (var->flags & CVAR_SYSTEMINFO) {
Com_Printf("s");
} else {
Com_Printf(" ");
}
if (var->flags & CVAR_USERINFO) {
Com_Printf("U");
} else {
Com_Printf(" ");
}
if (var->flags & CVAR_ROM) {
Com_Printf("R");
} else {
Com_Printf(" ");
}
if (var->flags & CVAR_INIT) {
Com_Printf("I");
} else {
Com_Printf(" ");
}
if (var->flags & CVAR_ARCHIVE) {
Com_Printf("A");
} else {
Com_Printf(" ");
}
if (var->flags & CVAR_LATCH) {
Com_Printf("L");
} else {
Com_Printf(" ");
}
if (var->flags & CVAR_CHEAT) {
Com_Printf("C");
} else {
Com_Printf(" ");
}
if (var->flags & CVAR_USER_CREATED) {
Com_Printf("?");
} else {
Com_Printf(" ");
}
Com_Printf(" %s \"%s\"\n", var->name, var->string);
}
Com_Printf("\n%i total cvars\n", i);
Com_Printf("%i cvar indexes\n", cvar_numIndexes);
}
示例5: SV_Status_f
/*
================
SV_Status_f
================
*/
static void SV_Status_f( void )
{
int i, humans, bots;
client_t *cl;
playerState_t *ps;
const char *s;
int ping;
char state[32];
qboolean avoidTruncation = qfalse;
// make sure server is running
if ( !com_sv_running->integer )
{
Com_Printf( "Server is not running.\n" );
return;
}
if ( Cmd_Argc() > 1 )
{
if (!Q_stricmp("notrunc", Cmd_Argv(1)))
{
avoidTruncation = qtrue;
}
}
humans = bots = 0;
for ( i = 0 ; i < sv_maxclients->integer ; i++ ) {
if ( svs.clients[i].state >= CS_CONNECTED ) {
if ( svs.clients[i].netchan.remoteAddress.type != NA_BOT ) {
humans++;
}
else {
bots++;
}
}
}
#if defined(_WIN32)
#define STATUS_OS "Windows"
#elif defined(__linux__)
#define STATUS_OS "Linux"
#elif defined(MACOS_X)
#define STATUS_OS "OSX"
#else
#define STATUS_OS "Unknown"
#endif
const char *ded_table[] =
{
"listen",
"lan dedicated",
"public dedicated",
};
char hostname[MAX_HOSTNAMELENGTH] = { 0 };
Q_strncpyz( hostname, sv_hostname->string, sizeof(hostname) );
Q_StripColor( hostname );
Com_Printf( "hostname: %s^7\n", hostname );
Com_Printf( "version : %s %i\n", VERSION_STRING_DOTTED, PROTOCOL_VERSION );
Com_Printf( "game : %s\n", FS_GetCurrentGameDir() );
Com_Printf( "udp/ip : %s:%i os(%s) type(%s)\n", Cvar_VariableString( "net_ip" ), Cvar_VariableIntegerValue( "net_port" ), STATUS_OS, ded_table[com_dedicated->integer] );
Com_Printf( "map : %s gametype(%i)\n", sv_mapname->string, sv_gametype->integer );
Com_Printf( "players : %i humans, %i bots (%i max)\n", humans, bots, sv_maxclients->integer - sv_privateClients->integer );
Com_Printf( "uptime : %s\n", SV_CalcUptime() );
Com_Printf ("cl score ping name address rate \n");
Com_Printf ("-- ----- ---- --------------- --------------------------------------- -----\n");
for (i=0,cl=svs.clients ; i < sv_maxclients->integer ; i++,cl++)
{
if ( !cl->state )
continue;
if ( cl->state == CS_CONNECTED )
Q_strncpyz( state, "CON ", sizeof( state ) );
else if ( cl->state == CS_ZOMBIE )
Q_strncpyz( state, "ZMB ", sizeof( state ) );
else {
ping = cl->ping < 9999 ? cl->ping : 9999;
Com_sprintf( state, sizeof(state), "%4i", ping );
}
ps = SV_GameClientNum( i );
s = NET_AdrToString( cl->netchan.remoteAddress );
if (!avoidTruncation)
{
Com_Printf ("%2i %5i %s %-15.15s ^7%39s %5i\n",
i,
ps->persistant[PERS_SCORE],
state,
cl->name,
s,
cl->rate
//.........这里部分代码省略.........
示例6: SV_WriteDownloadToClient
/*
==================
SV_WriteDownloadToClient
Check to see if the client wants a file, open it if needed and start pumping the client
Fill up msg with data, return number of download blocks added
==================
*/
int SV_WriteDownloadToClient(client_t *cl, msg_t *msg)
{
int curindex;
int unreferenced = 1;
char errorMessage[1024];
char pakbuf[MAX_QPATH], *pakptr;
int numRefPaks;
if (!*cl->downloadName)
return 0; // Nothing being downloaded
if(!cl->download)
{
// Chop off filename extension.
Com_sprintf(pakbuf, sizeof(pakbuf), "%s", cl->downloadName);
pakptr = strrchr(pakbuf, '.');
if(pakptr)
{
*pakptr = '\0';
// Check for pk3 filename extension
if(!Q_stricmp(pakptr + 1, "pk3"))
{
const char *referencedPaks = FS_ReferencedPakNames();
// Check whether the file appears in the list of referenced
// paks to prevent downloading of arbitrary files.
Cmd_TokenizeStringIgnoreQuotes(referencedPaks);
numRefPaks = Cmd_Argc();
for(curindex = 0; curindex < numRefPaks; curindex++)
{
if(!FS_FilenameCompare(Cmd_Argv(curindex), pakbuf))
{
unreferenced = 0;
break;
}
}
}
}
cl->download = 0;
// We open the file here
if ( !(sv_allowDownload->integer & DLF_ENABLE) ||
(sv_allowDownload->integer & DLF_NO_UDP) ||
unreferenced ||
( cl->downloadSize = FS_SV_FOpenFileRead( cl->downloadName, &cl->download ) ) < 0 ) {
// cannot auto-download file
if(unreferenced)
{
Com_Printf("clientDownload: %d : \"%s\" is not referenced and cannot be downloaded.\n", (int) (cl - svs.clients), cl->downloadName);
Com_sprintf(errorMessage, sizeof(errorMessage), "File \"%s\" is not referenced and cannot be downloaded.", cl->downloadName);
}
else if ( !(sv_allowDownload->integer & DLF_ENABLE) ||
(sv_allowDownload->integer & DLF_NO_UDP) ) {
Com_Printf("clientDownload: %d : \"%s\" download disabled\n", (int) (cl - svs.clients), cl->downloadName);
if (sv_pure->integer) {
Com_sprintf(errorMessage, sizeof(errorMessage), "Could not download \"%s\" because autodownloading is disabled on the server.\n\n"
"You will need to get this file elsewhere before you "
"can connect to this pure server.\n", cl->downloadName);
} else {
Com_sprintf(errorMessage, sizeof(errorMessage), "Could not download \"%s\" because autodownloading is disabled on the server.\n\n"
"The server you are connecting to is not a pure server, "
"set autodownload to No in your settings and you might be "
"able to join the game anyway.\n", cl->downloadName);
}
} else {
// NOTE TTimo this is NOT supposed to happen unless bug in our filesystem scheme?
// if the pk3 is referenced, it must have been found somewhere in the filesystem
Com_Printf("clientDownload: %d : \"%s\" file not found on server\n", (int) (cl - svs.clients), cl->downloadName);
Com_sprintf(errorMessage, sizeof(errorMessage), "File \"%s\" not found on server for autodownloading.\n", cl->downloadName);
}
MSG_WriteByte( msg, svc_download );
MSG_WriteShort( msg, 0 ); // client is expecting block zero
MSG_WriteLong( msg, -1 ); // illegal file size
MSG_WriteString( msg, errorMessage );
*cl->downloadName = 0;
if(cl->download)
FS_FCloseFile(cl->download);
return 1;
}
Com_Printf( "clientDownload: %d : beginning \"%s\"\n", (int) (cl - svs.clients), cl->downloadName );
// Init
cl->downloadCurrentBlock = cl->downloadClientBlock = cl->downloadXmitBlock = 0;
//.........这里部分代码省略.........
示例7: CL_Record_f
/*
* record <demoname>
* Begins recording a demo from the current position
*/
void
CL_Record_f(void)
{
char name[MAX_OSPATH];
byte buf_data[MAX_MSGLEN];
sizebuf_t buf;
int i;
int len;
entity_state_t *ent;
entity_state_t nullstate;
if (Cmd_Argc() != 2)
{
Com_Printf("record <demoname>\n");
return;
}
if (cls.demorecording)
{
Com_Printf("Already recording.\n");
return;
}
if (cls.state != ca_active)
{
Com_Printf("You must be in a level to record.\n");
return;
}
Com_sprintf(name, sizeof(name), "%s/demos/%s.dm2", FS_Gamedir(), Cmd_Argv(1));
Com_Printf("recording to %s.\n", name);
FS_CreatePath(name);
cls.demofile = fopen(name, "wb");
if (!cls.demofile)
{
Com_Printf("ERROR: couldn't open.\n");
return;
}
cls.demorecording = true;
/* don't start saving messages until a non-delta compressed message is received */
cls.demowaiting = true;
/* write out messages to hold the startup information */
SZ_Init(&buf, buf_data, sizeof(buf_data));
/* send the serverdata */
MSG_WriteByte(&buf, svc_serverdata);
MSG_WriteLong(&buf, PROTOCOL_VERSION);
MSG_WriteLong(&buf, 0x10000 + cl.servercount);
MSG_WriteByte(&buf, 1); /* demos are always attract loops */
MSG_WriteString(&buf, cl.gamedir);
MSG_WriteShort(&buf, cl.playernum);
MSG_WriteString(&buf, cl.configstrings[CS_NAME]);
/* configstrings */
for (i = 0; i < MAX_CONFIGSTRINGS; i++)
{
if (cl.configstrings[i][0])
{
if (buf.cursize + strlen(cl.configstrings[i]) + 32 > buf.maxsize)
{
len = LittleLong(buf.cursize);
fwrite(&len, 4, 1, cls.demofile);
fwrite(buf.data, buf.cursize, 1, cls.demofile);
buf.cursize = 0;
}
MSG_WriteByte(&buf, svc_configstring);
MSG_WriteShort(&buf, i);
MSG_WriteString(&buf, cl.configstrings[i]);
}
}
/* baselines */
memset(&nullstate, 0, sizeof(nullstate));
for (i = 0; i < MAX_EDICTS; i++)
{
ent = &cl_entities[i].baseline;
if (!ent->modelindex)
{
continue;
}
if (buf.cursize + 64 > buf.maxsize)
{
len = LittleLong(buf.cursize);
fwrite(&len, 4, 1, cls.demofile);
fwrite(buf.data, buf.cursize, 1, cls.demofile);
//.........这里部分代码省略.........
示例8: CL_CgameSystemCalls
/*
====================
CL_CgameSystemCalls
The cgame module is making a system call
====================
*/
intptr_t CL_CgameSystemCalls( intptr_t *args ) {
switch ( args[0] ) {
case CG_PRINT:
Com_Printf( "%s", VMA( 1 ) );
return 0;
case CG_ERROR:
Com_Error( ERR_DROP, "%s", VMA( 1 ) );
return 0;
case CG_MILLISECONDS:
return Sys_Milliseconds();
case CG_CVAR_REGISTER:
Cvar_Register( VMA( 1 ), VMA( 2 ), VMA( 3 ), args[4] );
return 0;
case CG_CVAR_UPDATE:
Cvar_Update( VMA( 1 ) );
return 0;
case CG_CVAR_SET:
Cvar_Set( VMA( 1 ), VMA( 2 ) );
return 0;
case CG_CVAR_VARIABLESTRINGBUFFER:
Cvar_VariableStringBuffer( VMA( 1 ), VMA( 2 ), args[3] );
return 0;
case CG_ARGC:
return Cmd_Argc();
case CG_ARGV:
Cmd_ArgvBuffer( args[1], VMA( 2 ), args[3] );
return 0;
case CG_ARGS:
Cmd_ArgsBuffer( VMA( 1 ), args[2] );
return 0;
case CG_FS_FOPENFILE:
return FS_FOpenFileByMode( VMA( 1 ), VMA( 2 ), args[3] );
case CG_FS_READ:
FS_Read( VMA( 1 ), args[2], args[3] );
return 0;
case CG_FS_WRITE:
return FS_Write( VMA( 1 ), args[2], args[3] );
case CG_FS_FCLOSEFILE:
FS_FCloseFile( args[1] );
return 0;
case CG_SENDCONSOLECOMMAND:
Cbuf_AddText( VMA( 1 ) );
return 0;
case CG_ADDCOMMAND:
CL_AddCgameCommand( VMA( 1 ) );
return 0;
case CG_REMOVECOMMAND:
Cmd_RemoveCommand( VMA( 1 ) );
return 0;
case CG_SENDCLIENTCOMMAND:
CL_AddReliableCommand( VMA( 1 ) );
return 0;
case CG_UPDATESCREEN:
// this is used during lengthy level loading, so pump message loop
// Com_EventLoop(); // FIXME: if a server restarts here, BAD THINGS HAPPEN!
// We can't call Com_EventLoop here, a restart will crash and this _does_ happen
// if there is a map change while we are downloading at pk3.
// ZOID
SCR_UpdateScreen();
return 0;
case CG_CM_LOADMAP:
CL_CM_LoadMap( VMA( 1 ) );
return 0;
case CG_CM_NUMINLINEMODELS:
return CM_NumInlineModels();
case CG_CM_INLINEMODEL:
return CM_InlineModel( args[1] );
case CG_CM_TEMPBOXMODEL:
return CM_TempBoxModel( VMA( 1 ), VMA( 2 ), qfalse );
case CG_CM_TEMPCAPSULEMODEL:
return CM_TempBoxModel( VMA( 1 ), VMA( 2 ), qtrue );
case CG_CM_POINTCONTENTS:
return CM_PointContents( VMA( 1 ), args[2] );
case CG_CM_TRANSFORMEDPOINTCONTENTS:
return CM_TransformedPointContents( VMA( 1 ), args[2], VMA( 3 ), VMA( 4 ) );
case CG_CM_BOXTRACE:
CM_BoxTrace( VMA( 1 ), VMA( 2 ), VMA( 3 ), VMA( 4 ), VMA( 5 ), args[6], args[7], /*int capsule*/ qfalse );
return 0;
case CG_CM_TRANSFORMEDBOXTRACE:
CM_TransformedBoxTrace( VMA( 1 ), VMA( 2 ), VMA( 3 ), VMA( 4 ), VMA( 5 ), args[6], args[7], VMA( 8 ), VMA( 9 ), /*int capsule*/ qfalse );
return 0;
case CG_CM_CAPSULETRACE:
CM_BoxTrace( VMA( 1 ), VMA( 2 ), VMA( 3 ), VMA( 4 ), VMA( 5 ), args[6], args[7], /*int capsule*/ qtrue );
return 0;
case CG_CM_TRANSFORMEDCAPSULETRACE:
CM_TransformedBoxTrace( VMA( 1 ), VMA( 2 ), VMA( 3 ), VMA( 4 ), VMA( 5 ), args[6], args[7], VMA( 8 ), VMA( 9 ), /*int capsule*/ qtrue );
return 0;
case CG_CM_MARKFRAGMENTS:
return re.MarkFragments( args[1], VMA( 2 ), VMA( 3 ), args[4], VMA( 5 ), args[6], VMA( 7 ) );
case CG_S_STARTSOUND:
S_StartSound( VMA( 1 ), args[2], args[3], args[4] );
return 0;
//----(SA) added
//.........这里部分代码省略.........
示例9: UI_GetParamNumber
/**
* Get the number of param from an execution context
* @param[in] context The execution context
* @return The requested param
*/
int UI_GetParamNumber (const uiCallContext_t* context)
{
if (context->useCmdParam)
return Cmd_Argc() - 1;
return context->paramNumber;
}
示例10: CL_CgameSystemCalls
/*
====================
CL_CgameSystemCalls
The cgame module is making a system call
====================
*/
intptr_t CL_CgameSystemCalls( intptr_t *args )
{
switch ( args[ 0 ] )
{
case CG_PRINT:
Com_Printf( "%s", ( char * ) VMA( 1 ) );
return 0;
case CG_ERROR:
Com_Error( ERR_DROP, "%s", ( char * ) VMA( 1 ) );
case CG_MILLISECONDS:
return Sys_Milliseconds();
case CG_CVAR_REGISTER:
Cvar_Register( VMA( 1 ), VMA( 2 ), VMA( 3 ), args[ 4 ] );
return 0;
case CG_CVAR_UPDATE:
Cvar_Update( VMA( 1 ) );
return 0;
case CG_CVAR_SET:
Cvar_Set( VMA( 1 ), VMA( 2 ) );
return 0;
case CG_CVAR_VARIABLESTRINGBUFFER:
VM_CheckBlock( args[2], args[3], "CVARVSB" );
Cvar_VariableStringBuffer( VMA( 1 ), VMA( 2 ), args[ 3 ] );
return 0;
case CG_CVAR_LATCHEDVARIABLESTRINGBUFFER:
VM_CheckBlock( args[2], args[3], "CVARLVSB" );
Cvar_LatchedVariableStringBuffer( VMA( 1 ), VMA( 2 ), args[ 3 ] );
return 0;
case CG_CVAR_VARIABLEINTEGERVALUE:
return Cvar_VariableIntegerValue( VMA( 1 ) );
case CG_ARGC:
return Cmd_Argc();
case CG_ARGV:
VM_CheckBlock( args[2], args[3], "ARGV" );
Cmd_ArgvBuffer( args[ 1 ], VMA( 2 ), args[ 3 ] );
return 0;
case CG_ARGS:
VM_CheckBlock( args[1], args[2], "ARGS" );
Cmd_ArgsBuffer( VMA( 1 ), args[ 2 ] );
return 0;
case CG_LITERAL_ARGS:
// FIXME
VM_CheckBlock( args[1], args[2], "LARGS" );
Cmd_LiteralArgsBuffer( VMA( 1 ), args[ 2 ] );
// Cmd_ArgsBuffer(VMA(1), args[2]);
return 0;
case CG_GETDEMOSTATE:
return CL_DemoState();
case CG_GETDEMOPOS:
return CL_DemoPos();
case CG_FS_FOPENFILE:
return FS_FOpenFileByMode( VMA( 1 ), VMA( 2 ), args[ 3 ] );
case CG_FS_READ:
VM_CheckBlock( args[1], args[2], "FSREAD" );
FS_Read2( VMA( 1 ), args[ 2 ], args[ 3 ] );
return 0;
case CG_FS_WRITE:
VM_CheckBlock( args[1], args[2], "FSWRITE" );
return FS_Write( VMA( 1 ), args[ 2 ], args[ 3 ] );
case CG_FS_FCLOSEFILE:
FS_FCloseFile( args[ 1 ] );
return 0;
case CG_FS_GETFILELIST:
VM_CheckBlock( args[3], args[4], "FSGFL" );
return FS_GetFileList( VMA( 1 ), VMA( 2 ), VMA( 3 ), args[ 4 ] );
case CG_FS_DELETEFILE:
return FS_Delete( VMA( 1 ) );
case CG_SENDCONSOLECOMMAND:
Cbuf_AddText( VMA( 1 ) );
return 0;
case CG_ADDCOMMAND:
//.........这里部分代码省略.........
示例11: CL_GetServerCommand
/*
===================
CL_GetServerCommand
Set up argc/argv for the given command
===================
*/
qboolean CL_GetServerCommand( int serverCommandNumber )
{
const 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" );
}
if ( serverCommandNumber > clc.serverCommandSequence )
{
Com_Error( ERR_DROP, "CL_GetServerCommand: requested a command not received" );
}
s = clc.serverCommands[ serverCommandNumber & ( MAX_RELIABLE_COMMANDS - 1 ) ];
clc.lastExecutedServerCommand = serverCommandNumber;
if ( cl_showServerCommands->integer )
{
// NERVE - SMF
Com_Printf( "serverCommand: %i : %s\n", serverCommandNumber, s );
}
rescan:
Cmd_TokenizeString( s );
cmd = Cmd_Argv( 0 );
argc = Cmd_Argc();
if ( !strcmp( cmd, "disconnect" ) )
{
// NERVE - SMF - 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_QuoteString( Cmd_Argv( 2 ) ) );
return qfalse;
}
if ( !strcmp( cmd, "bcs1" ) )
{
s = Cmd_QuoteString( 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_QuoteString( 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;
}
//.........这里部分代码省略.........
示例12: SV_VerifyPaks_f
/*
=================
SV_VerifyPaks_f
If we are pure, disconnect the client if they do no meet the following conditions:
1. the first two checksums match our view of cgame and ui
2. there are no any additional checksums that we do not have
This routine would be a bit simpler with a goto but i abstained
=================
*/
static void SV_VerifyPaks_f( client_t *cl ) {
int nChkSum1, nChkSum2, nClientPaks, nServerPaks, i, j, nCurArg;
int nClientChkSum[1024];
int nServerChkSum[1024];
const char *pPaks, *pArg;
qboolean bGood = qtrue;
// if we are pure, we "expect" the client to load certain things from
// certain pk3 files, namely we want the client to have loaded the
// ui and cgame that we think should be loaded based on the pure setting
//
if ( sv_pure->integer != 0 ) {
bGood = qtrue;
nChkSum1 = nChkSum2 = 0;
// we run the game, so determine which cgame and ui the client "should" be running
//dlls are valid too now -rww
bGood = (qboolean)(FS_FileIsInPAK("cgamex86.dll", &nChkSum1) == 1);
if (bGood)
bGood = (qboolean)(FS_FileIsInPAK("uix86.dll", &nChkSum2) == 1);
nClientPaks = Cmd_Argc();
// start at arg 1 ( skip cl_paks )
nCurArg = 1;
// we basically use this while loop to avoid using 'goto' :)
while (bGood) {
// must be at least 6: "cl_paks cgame ui @ firstref ... numChecksums"
// numChecksums is encoded
if (nClientPaks < 6) {
bGood = qfalse;
break;
}
// verify first to be the cgame checksum
pArg = Cmd_Argv(nCurArg++);
if (!pArg || *pArg == '@' || atoi(pArg) != nChkSum1 ) {
bGood = qfalse;
break;
}
// verify the second to be the ui checksum
pArg = Cmd_Argv(nCurArg++);
if (!pArg || *pArg == '@' || atoi(pArg) != nChkSum2 ) {
bGood = qfalse;
break;
}
// should be sitting at the delimeter now
pArg = Cmd_Argv(nCurArg++);
if (*pArg != '@') {
bGood = qfalse;
break;
}
// store checksums since tokenization is not re-entrant
for (i = 0; nCurArg < nClientPaks; i++) {
nClientChkSum[i] = atoi(Cmd_Argv(nCurArg++));
}
// store number to compare against (minus one cause the last is the number of checksums)
nClientPaks = i - 1;
// make sure none of the client check sums are the same
// so the client can't send 5 the same checksums
for (i = 0; i < nClientPaks; i++) {
for (j = 0; j < nClientPaks; j++) {
if (i == j)
continue;
if (nClientChkSum[i] == nClientChkSum[j]) {
bGood = qfalse;
break;
}
}
if (bGood == qfalse)
break;
}
if (bGood == qfalse)
break;
// get the pure checksums of the pk3 files loaded by the server
pPaks = FS_LoadedPakPureChecksums();
Cmd_TokenizeString( pPaks );
nServerPaks = Cmd_Argc();
if (nServerPaks > 1024)
nServerPaks = 1024;
for (i = 0; i < nServerPaks; i++) {
//.........这里部分代码省略.........
示例13: 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;
//.........这里部分代码省略.........
示例14: dissect_quakeworld_ConnectionlessPacket
//.........这里部分代码省略.........
tvb,
offset + Cmd_Argv_start(4),
Cmd_Argv_length(4), infostring);
info_tree = proto_item_add_subtree(
info_item, ett_quakeworld_connectionless_connect_infostring);
dissect_id_infostring(tvb, info_tree, offset + Cmd_Argv_start(4),
wmem_strdup(wmem_packet_scope(), infostring),
ett_quakeworld_connectionless_connect_infostring_key_value,
hf_quakeworld_connectionless_connect_infostring_key_value,
hf_quakeworld_connectionless_connect_infostring_key,
hf_quakeworld_connectionless_connect_infostring_value);
}
} else if (strcmp(c,"getchallenge") == 0) {
command = "Get Challenge";
command_len = Cmd_Argv_length(0);
} else if (strcmp(c,"rcon") == 0) {
const char* password;
int i;
char remaining[MAX_TEXT_SIZE+1];
proto_tree *argument_tree = NULL;
command = "Remote Command";
command_len = Cmd_Argv_length(0);
if (text_tree) {
proto_item *argument_item;
proto_tree_add_string(text_tree, hf_quakeworld_connectionless_command,
tvb, offset, command_len, command);
argument_item = proto_tree_add_string(text_tree,
hf_quakeworld_connectionless_arguments,
tvb, offset + Cmd_Argv_start(1), len - Cmd_Argv_start(1),
text + Cmd_Argv_start(1));
argument_tree = proto_item_add_subtree(argument_item,
ett_quakeworld_connectionless_arguments);
command_finished=TRUE;
}
password = Cmd_Argv(1);
if (argument_tree) {
proto_tree_add_string(argument_tree,
hf_quakeworld_connectionless_rcon_password,
tvb,
offset + Cmd_Argv_start(1),
Cmd_Argv_length(1), password);
}
remaining[0] = '\0';
for (i=2; i<Cmd_Argc() ; i++) {
g_strlcat (remaining, Cmd_Argv(i), MAX_TEXT_SIZE+1);
g_strlcat (remaining, " ", MAX_TEXT_SIZE+1);
}
if (text_tree) {
proto_tree_add_string(argument_tree,
hf_quakeworld_connectionless_rcon_command,
tvb, offset + Cmd_Argv_start(2),
Cmd_Argv_start(Cmd_Argc()-1) + Cmd_Argv_length(Cmd_Argc()-1) -
Cmd_Argv_start(2),
remaining);
}
} else if (c[0]==A2A_PING && ( c[1]=='\0' || c[1]=='\n')) {
command = "Ping";
command_len = 1;
} else if (c[0]==A2A_ACK && ( c[1]=='\0' || c[1]=='\n')) {
command = "Ack";
command_len = 1;
} else {
command = "Unknown";
command_len = len - 1;
}
}
else {
/* server to client commands */
if (text[0] == S2C_CONNECTION) {
command = "Connected";
command_len = 1;
} else if (text[0] == A2C_CLIENT_COMMAND) {
command = "Client Command";
command_len = 1;
/* stringz (command), stringz (localid) */
} else if (text[0] == A2C_PRINT) {
command = "Print";
command_len = 1;
/* string */
} else if (text[0] == A2A_PING) {
command = "Ping";
command_len = 1;
} else if (text[0] == S2C_CHALLENGE) {
command = "Challenge";
command_len = 1;
/* string, conversion */
} else {
command = "Unknown";
command_len = len - 1;
}
}
col_append_fstr(pinfo->cinfo, COL_INFO, " %s", command);
if (!command_finished) {
proto_tree_add_string(text_tree, hf_quakeworld_connectionless_command,
tvb, offset, command_len, command);
}
/*offset += len;*/
}
示例15: CL_CgameSystemCalls
/*
====================
CL_CgameSystemCalls
The cgame module is making a system call
====================
*/
intptr_t CL_CgameSystemCalls( intptr_t *args ) {
switch( args[0] ) {
case CG_PRINT:
Com_Printf( "%s", (const char*)VMA(1) );
return 0;
case CG_ERROR:
Com_Error( ERR_DROP, "%s", (const char*)VMA(1) );
return 0;
case CG_MILLISECONDS:
return Sys_Milliseconds();
case CG_CVAR_REGISTER:
Cvar_Register( VMA(1), VMA(2), VMA(3), args[4] );
return 0;
case CG_CVAR_UPDATE:
Cvar_Update( VMA(1) );
return 0;
case CG_CVAR_SET:
Cvar_SetSafe( VMA(1), VMA(2) );
return 0;
case CG_CVAR_VARIABLESTRINGBUFFER:
Cvar_VariableStringBuffer( VMA(1), VMA(2), args[3] );
return 0;
case CG_ARGC:
return Cmd_Argc();
case CG_ARGV:
Cmd_ArgvBuffer( args[1], VMA(2), args[3] );
return 0;
case CG_ARGS:
Cmd_ArgsBuffer( VMA(1), args[2] );
return 0;
case CG_FS_FOPENFILE:
return FS_FOpenFileByMode( VMA(1), VMA(2), args[3] );
case CG_FS_READ:
FS_Read2( VMA(1), args[2], args[3] );
return 0;
case CG_FS_WRITE:
FS_Write( VMA(1), args[2], args[3] );
return 0;
case CG_FS_FCLOSEFILE:
FS_FCloseFile( args[1] );
return 0;
case CG_FS_SEEK:
return FS_Seek( args[1], args[2], args[3] );
case CG_SENDCONSOLECOMMAND:
Cbuf_AddText( VMA(1) );
return 0;
case CG_ADDCOMMAND:
CL_AddCgameCommand( VMA(1) );
return 0;
case CG_REMOVECOMMAND:
Cmd_RemoveCommandSafe( VMA(1) );
return 0;
case CG_SENDCLIENTCOMMAND:
CL_AddReliableCommand(VMA(1), qfalse);
return 0;
case CG_UPDATESCREEN:
// this is used during lengthy level loading, so pump message loop
// Com_EventLoop(); // FIXME: if a server restarts here, BAD THINGS HAPPEN!
// We can't call Com_EventLoop here, a restart will crash and this _does_ happen
// if there is a map change while we are downloading at pk3.
// ZOID
SCR_UpdateScreen();
return 0;
case CG_CM_LOADMAP:
CL_CM_LoadMap( VMA(1) );
return 0;
case CG_CM_NUMINLINEMODELS:
return CM_NumInlineModels();
case CG_CM_INLINEMODEL:
return CM_InlineModel( args[1] );
case CG_CM_TEMPBOXMODEL:
return CM_TempBoxModel( VMA(1), VMA(2), /*int capsule*/ qfalse );
case CG_CM_TEMPCAPSULEMODEL:
return CM_TempBoxModel( VMA(1), VMA(2), /*int capsule*/ qtrue );
case CG_CM_POINTCONTENTS:
return CM_PointContents( VMA(1), args[2] );
case CG_CM_TRANSFORMEDPOINTCONTENTS:
return CM_TransformedPointContents( VMA(1), args[2], VMA(3), VMA(4) );
case CG_CM_BOXTRACE:
CM_BoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule*/ qfalse );
return 0;
case CG_CM_CAPSULETRACE:
CM_BoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], /*int capsule*/ qtrue );
return 0;
case CG_CM_TRANSFORMEDBOXTRACE:
CM_TransformedBoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), /*int capsule*/ qfalse );
return 0;
case CG_CM_TRANSFORMEDCAPSULETRACE:
CM_TransformedBoxTrace( VMA(1), VMA(2), VMA(3), VMA(4), VMA(5), args[6], args[7], VMA(8), VMA(9), /*int capsule*/ qtrue );
return 0;
case CG_CM_MARKFRAGMENTS:
return re.MarkFragments( args[1], VMA(2), VMA(3), args[4], VMA(5), args[6], VMA(7) );
case CG_S_STARTSOUND:
//.........这里部分代码省略.........