您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ trap_SendServerCommand函数代码示例

51自学网 2021-06-03 08:58:13
  C++
这篇教程C++ trap_SendServerCommand函数代码示例写得很实用,希望能帮到您。

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

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

示例1: ACEND_SetGoal

void ACEND_SetGoal(gentity_t * self, int goalNode){	int             node;	self->bs.goalNode = goalNode;	node = ACEND_FindClosestReachableNode(self, NODE_DENSITY * 3, NODE_ALL);	if(node == INVALID)		return;	if(ace_debug.integer)		trap_SendServerCommand(-1, va("print /"%s: new start node selected %d/n/"", self->client->pers.netname, node));	self->bs.currentNode = node;	self->bs.nextNode = self->bs.currentNode;	// make sure we get to the nearest node first	self->bs.node_timeout = 0;	if(ace_showPath.integer)	{		// draw path to LR goal		ACEND_DrawPath(self->bs.currentNode, self->bs.goalNode);	}}
开发者ID:otty,项目名称:cake3,代码行数:24,


示例2: CheckVote

/*==================CheckVote==================*/void CheckVote( void ) {	if ( level.voteExecuteTime && level.voteExecuteTime < level.time ) {		level.voteExecuteTime = 0;		trap_SendConsoleCommand( EXEC_APPEND, va("%s/n", level.voteString ) );	}	if ( !level.voteTime ) {		return;	}	if ( level.time - level.voteTime >= VOTE_TIME ) {		if(g_dmflags.integer & DF_LIGHT_VOTING) {			//Let pass if there was at least twice as many for as against			if ( level.voteYes > level.voteNo*2 ) {				trap_SendServerCommand( -1, "print /"Vote passed. At least 2 of 3 voted yes/n/"" );				level.voteExecuteTime = level.time + 3000;			} else {				//Let pass if there is more yes than no and at least 2 yes votes and at least 30% yes of all on the server				if ( level.voteYes > level.voteNo && level.voteYes >= 2 && (level.voteYes*10)>(level.numVotingClients*3) ) {					trap_SendServerCommand( -1, "print /"Vote passed. More yes than no./n/"" );					level.voteExecuteTime = level.time + 3000;				} else					trap_SendServerCommand( -1, "print /"Vote failed./n/"" );			}		} else {			trap_SendServerCommand( -1, "print /"Vote failed./n/"" );		}	} else {		// ATVI Q3 1.32 Patch #9, WNF		if ( level.voteYes > (level.numVotingClients)/2 ) {			// execute the command, then remove the vote			trap_SendServerCommand( -1, "print /"Vote passed./n/"" );			level.voteExecuteTime = level.time + 3000;		} else if ( level.voteNo >= (level.numVotingClients)/2 ) {			// same behavior as a timeout			trap_SendServerCommand( -1, "print /"Vote failed./n/"" );		} else {			// still waiting for a majority			return;		}	}	level.voteTime = 0;	trap_SetConfigstring( CS_VOTE_TIME, "" );}
开发者ID:Developer626,项目名称:gamecode,代码行数:48,


示例3: TeamplayInfoMessage

/*==================TeamplayLocationsMessageFormat:	clientNum location health armor weapon powerups==================*/void TeamplayInfoMessage( gentity_t *ent ) {	char		entry[1024];	char		string[8192];	int			stringlength;	int			i, j;	gentity_t	*player;	int			cnt;	int			h, a;	int			clients[TEAM_MAXOVERLAY];	int			team;	if ( ! ent->client->pers.teamInfo )		return;	// send team info to spectator for team of followed client	if (ent->client->sess.sessionTeam == TEAM_SPECTATOR) {		if ( ent->client->sess.spectatorState != SPECTATOR_FOLLOW			|| ent->client->sess.spectatorClient < 0 ) {				return;		}		team = g_entities[ ent->client->sess.spectatorClient ].client->sess.sessionTeam;	} else {		team = ent->client->sess.sessionTeam;	}	if (team != TEAM_RED && team != TEAM_BLUE) {		return;	}	// figure out what client should be on the display	// we are limited to 8, but we want to use the top eight players	// but in client order (so they don't keep changing position on the overlay)	for (i = 0, cnt = 0; i < sv_maxclients.integer && cnt < TEAM_MAXOVERLAY; i++) {		player = g_entities + level.sortedClients[i];		if (player->inuse && player->client->sess.sessionTeam == team ) {			clients[cnt++] = level.sortedClients[i];		}	}	// We have the top eight players, sort them by clientNum	qsort( clients, cnt, sizeof( clients[0] ), SortClients );	// send the latest information on all clients	string[0] = 0;	stringlength = 0;	for (i = 0, cnt = 0; i < sv_maxclients.integer && cnt < TEAM_MAXOVERLAY; i++) {		player = g_entities + i;		if (player->inuse && player->client->sess.sessionTeam == team ) {			h = player->client->ps.stats[STAT_HEALTH];			a = player->client->ps.stats[STAT_ARMOR];			if (h < 0) h = 0;			if (a < 0) a = 0;			Com_sprintf (entry, sizeof(entry),				" %i %i %i %i %i %i", 			//	level.sortedClients[i], player->client->pers.teamState.location, h, a, 				i, player->client->pers.teamState.location, h, a, 				player->client->ps.weapon, player->s.powerups);			j = strlen(entry);			if (stringlength + j >= sizeof(string))				break;			strcpy (string + stringlength, entry);			stringlength += j;			cnt++;		}	}	trap_SendServerCommand( ent-g_entities, va("tinfo %i %s", cnt, string) );}
开发者ID:L0rdWaffles,项目名称:OpenJK,代码行数:80,


示例4: player_die

/*==================player_die==================*/void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int meansOfDeath ){	gentity_t *ent;	int       anim;	int       killer;	int       i;	const char *killerName, *obit;	if ( self->client->ps.pm_type == PM_DEAD )	{		return;	}	if ( level.intermissiontime )	{		return;	}	self->client->ps.pm_type = PM_DEAD;	self->suicideTime = 0;	if ( attacker )	{		killer = attacker->s.number;		if ( attacker->client )		{			killerName = attacker->client->pers.netname;		}		else		{			killerName = "<world>";		}	}	else	{		killer = ENTITYNUM_WORLD;		killerName = "<world>";	}	if ( meansOfDeath < 0 || meansOfDeath >= ARRAY_LEN( modNames ) )	{		// fall back on the number		obit = va( "%d", meansOfDeath );	}	else	{		obit = modNames[ meansOfDeath ];	}	G_LogPrintf( "Die: %d %d %s: %s" S_COLOR_WHITE " killed %s/n",	             killer,	             ( int )( self - g_entities ),	             obit,	             killerName,	             self->client->pers.netname );	// deactivate all upgrades	for ( i = UP_NONE + 1; i < UP_NUM_UPGRADES; i++ )	{		BG_DeactivateUpgrade( i, self->client->ps.stats );	}	// broadcast the death event to everyone	ent = G_NewTempEntity( self->r.currentOrigin, EV_OBITUARY );	ent->s.eventParm = meansOfDeath;	ent->s.otherEntityNum = self->s.number;	ent->s.otherEntityNum2 = killer;	ent->r.svFlags = SVF_BROADCAST; // send to everyone	if ( attacker && attacker->client )	{		if ( ( attacker == self || OnSameTeam( self, attacker ) ) )		{			//punish team kills and suicides			if ( attacker->client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS )			{				G_AddCreditToClient( attacker->client, -ALIEN_TK_SUICIDE_PENALTY, qtrue );				G_AddCreditsToScore( attacker, -ALIEN_TK_SUICIDE_PENALTY );			}			else if ( attacker->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS )			{				G_AddCreditToClient( attacker->client, -HUMAN_TK_SUICIDE_PENALTY, qtrue );				G_AddCreditsToScore( attacker, -HUMAN_TK_SUICIDE_PENALTY );			}		}		else if ( g_showKillerHP.integer )		{			trap_SendServerCommand( self - g_entities, va( "print_tr %s %s %3i", QQ( N_("Your killer, $1$^7, had $2$ HP./n") ),			                        Quote( killerName ),			                        attacker->health ) );		}	}	else if ( attacker->s.eType != ET_BUILDABLE )	{//.........这里部分代码省略.........
开发者ID:luislezcair,项目名称:Unvanquished,代码行数:101,


示例5: Use_Target_Print

/*QUAKED target_print (1 0 0) (-8 -8 -8) (8 8 8) redteam blueteam private"message"	text to print"wait"		don't fire off again if triggered within this many milliseconds agoIf "private", only the activator gets the message.  If no checks, all clients get the message.*/void Use_Target_Print (gentity_t *ent, gentity_t *other, gentity_t *activator){	if (!ent || !ent->inuse)	{		Com_Printf("ERROR: Bad ent in Use_Target_Print");		return;	}	if (ent->wait)	{		if (ent->genericValue14 >= level.time)		{			return;		}		ent->genericValue14 = level.time + ent->wait;	}#ifndef FINAL_BUILD	if (!ent || !ent->inuse)	{		Com_Error(ERR_DROP, "Bad ent in Use_Target_Print");	}	else if (!activator || !activator->inuse)	{		Com_Error(ERR_DROP, "Bad activator in Use_Target_Print");	}	/*if (ent->genericValue15 > level.time) // lol wtf is this bullshit	{		Com_Printf("TARGET PRINT ERRORS:/n");		if (activator && activator->classname && activator->classname[0])		{			Com_Printf("activator classname: %s/n", activator->classname);		}		if (activator && activator->target && activator->target[0])		{			Com_Printf("activator target: %s/n", activator->target);		}		if (activator && activator->targetname && activator->targetname[0])		{			Com_Printf("activator targetname: %s/n", activator->targetname);		}		if (ent->targetname && ent->targetname[0])		{			Com_Printf("print targetname: %s/n", ent->targetname);		}		Com_Error(ERR_DROP, "target_print used in quick succession, fix it! See the console for details.");	}	ent->genericValue15 = level.time + 5000;*/#endif	G_ActivateBehavior(ent,BSET_USE);	if ( ( ent->spawnflags & 4 ) ) 	{//private, to one client only		if (!activator || !activator->inuse)		{			Com_Printf("ERROR: Bad activator in Use_Target_Print");		}		if ( activator && activator->client )		{//make sure there's a valid client ent to send it to			if (ent->message[0] == '@' && ent->message[1] != '@')			{				trap_SendServerCommand( activator-g_entities, va("cps /"%s/"", ent->message ));			}			else			{				trap_SendServerCommand( activator-g_entities, va("cp /"%s/"", ent->message ));			}		}		//NOTE: change in functionality - if there *is* no valid client ent, it won't send it to anyone at all		return;	}	if ( ent->spawnflags & 3 ) {		if ( ent->spawnflags & 1 ) {			if (ent->message[0] == '@' && ent->message[1] != '@')			{				G_TeamCommand( TEAM_RED, va("cps /"%s/"", ent->message) );			}			else			{				G_TeamCommand( TEAM_RED, va("cp /"%s/"", ent->message) );			}		}		if ( ent->spawnflags & 2 ) {			if (ent->message[0] == '@' && ent->message[1] != '@')			{				G_TeamCommand( TEAM_BLUE, va("cps /"%s/"", ent->message) );			}			else			{				G_TeamCommand( TEAM_BLUE, va("cp /"%s/"", ent->message) );			}		}		return;//.........这里部分代码省略.........
开发者ID:NikitaRus,项目名称:JediKnightGalaxies-1,代码行数:101,


示例6: Svcmd_CamCmd

void Svcmd_CamCmd( void ) {    char buf[MAX_TOKEN_CHARS];    char cmd[MAX_TOKEN_CHARS];    char name[MAX_TOKEN_CHARS];    int i;    gclient_t* cl;    if( !level.cammode ) {        return;    }    if( trap_Argc() < 2 ) {        return;    }    trap_Argv( 1, cmd, sizeof(cmd) );    if ( !Q_stricmp (cmd, "print")  )    {        trap_Argv( 2, buf, sizeof(buf) );        trap_SendServerCommand( -1, va("cp /"%s/n/"", buf ) );    }    else if( !Q_stricmp (cmd, "setclientpos") ) {        vec3_t	newOrigin;        if( trap_Argc() != 8 && trap_Argc() != 6 ) {            Com_Printf("usage: camcmd setclientpos name/id x y z (a b) /na = PITCH-angle, b = YAW-angle/n");            return;        }        trap_Argv( 2, name, sizeof( name ) );        cl = ClientForString( name ) ;        if(!cl)            return;        for( i=0; i<3; i++) {            trap_Argv( i+3, buf, sizeof( buf) );            newOrigin[i] = atof( buf );        }        G_SetOrigin( &g_entities[cl->ps.clientNum], newOrigin );        VectorCopy( newOrigin, cl->ps.origin );        if(trap_Argc() == 8) {            vec3_t	newAngles;            memset(newAngles,0,sizeof(newAngles));            trap_Argv( 6, buf, sizeof( buf ) );            newAngles[PITCH] = atoi(buf);            trap_Argv( 7, buf, sizeof( buf ) );            newAngles[YAW] = atoi(buf);            SetClientViewAngle( &g_entities[cl->ps.clientNum], newAngles );        }    }    else if( !Q_stricmp (cmd, "setspawn")  )    {        if( trap_Argc() != 8 ) {            Com_Printf("usage: camcmd setspawn x y z a b c /n");            return;        }        for( i=0; i<3; i++) {            trap_Argv( i+2, buf, sizeof(buf) );            level.cam_spawnpos[i] = atof(buf);        }        for( i=0; i<3; i++) {            trap_Argv( i+5, buf, sizeof(buf) );            level.cam_spawnangles[i] = atof(buf);        }    }    else if( !Q_stricmp (cmd, "botmove")  )    {        vec3_t pos;        if( trap_Argc() != 6 ) {            Com_Printf("usage: camcmd botmove name x y z /n");            return;        }        trap_Argv( 2, name, sizeof( name ) );        for( i=0; i<3; i++) {            trap_Argv( i+3, buf, sizeof( buf) );            pos[i] = atof( buf );        }        cl = ClientForString( name ) ;        if(!cl)            return;        BotCamMoveTo( cl->ps.clientNum, pos );    }    else if( !Q_stricmp (cmd, "botviewangles")  )    {        vec3_t angles;        if( trap_Argc() != 5 ) {            Com_Printf("usage: camcmd botviewangles name x y /n");            return;//.........这里部分代码省略.........
开发者ID:PadWorld-Entertainment,项目名称:wop-gamesource,代码行数:101,


示例7: ClientThink_real

//.........这里部分代码省略.........	// Ridah, made it a latched event (occurs on keydown only)	if (client->latched_buttons & BUTTON_ACTIVATE) {		Cmd_Activate_f(ent);	}	if (g_entities[ent->client->ps.identifyClient].team != ent->team ||	    !g_entities[ent->client->ps.identifyClient].client) {		ent->client->ps.identifyClient = -1;	}	// check for respawning	if (client->ps.stats[STAT_HEALTH] <= 0) {		// Nico, forcing respawn		limbo(ent);		return;	}	// perform once-a-second actions	ClientTimerActions(ent, msec);	// Nico, check ping	if (client->ps.ping > MAX_PLAYER_PING) {		if (!client->pers.loadKillNeeded) {			CP(va("cpm /"%s^w: ^1Too high ping detected, load or kill required./n/"", GAME_VERSION_COLORED));			// suburb, prevent trigger bug			client->pers.loadKillNeeded = qtrue;		}	}	// Nico, pmove_fixed	if (!client->pers.pmoveFixed) {		CP(va("cpm /"%s^w: ^1You were removed from teams because you can not use pmove_fixed 0./n/"", GAME_VERSION_COLORED));		trap_SendServerCommand(ent - g_entities, "pmoveon");		SetTeam(ent, "s", -1, -1, qfalse);	}	// Nico, check rate	if (client->pers.rate < MIN_PLAYER_RATE_VALUE || client->pers.rate > MAX_PLAYER_RATE_VALUE) {		CP(va("cpm /"%s^w: ^1You were removed from teams because you must use %d <= rate <= %d./n/"", GAME_VERSION_COLORED, MIN_PLAYER_RATE_VALUE, MAX_PLAYER_RATE_VALUE));		trap_SendServerCommand(ent - g_entities, "resetRate");		SetTeam(ent, "s", -1, -1, qfalse);	}	// Nico, check snaps (unsigned int)	if (client->pers.snaps > MAX_PLAYER_SNAPS_VALUE) {		CP(va("cpm /"%s^w: ^1You were removed from teams because you must use %d <= snaps <= %d./n/"", GAME_VERSION_COLORED, MIN_PLAYER_SNAPS_VALUE, MAX_PLAYER_SNAPS_VALUE));		trap_SendServerCommand(ent - g_entities, "resetSnaps");		SetTeam(ent, "s", -1, -1, qfalse);	}	// Nico, check timenudge	if (client->pers.clientTimeNudge != FORCED_PLAYER_TIMENUDGE_VALUE) {		CP(va("cpm /"%s^w: ^1You were removed from teams because you must use cl_timenudge %d./n/"", GAME_VERSION_COLORED, FORCED_PLAYER_TIMENUDGE_VALUE));		trap_SendServerCommand(ent - g_entities, "resetTimeNudge");		SetTeam(ent, "s", -1, -1, qfalse);	}	// Nico, check maxpackets	if (client->pers.clientMaxPackets < MIN_PLAYER_MAX_PACKETS_VALUE || client->pers.clientMaxPackets > MAX_PLAYER_MAX_PACKETS_VALUE) {		CP(va("cpm /"%s^w: ^1You were removed from teams because you must use %d <= cl_maxpackets <= %d./n/"", GAME_VERSION_COLORED, MIN_PLAYER_MAX_PACKETS_VALUE, MAX_PLAYER_MAX_PACKETS_VALUE));		trap_SendServerCommand(ent - g_entities, "resetMaxPackets");		SetTeam(ent, "s", -1, -1, qfalse);	}	// Nico, check max FPS
开发者ID:ETrun,项目名称:ETrun,代码行数:67,


示例8: trap_GetUserinfo

/*===========ClientUserInfoChangedCalled from ClientConnect when the player first connects anddirectly by the server system when the player updates a userinfo variable.The game can override any of the settings and call trap_SetUserinfoif desired.============*/char *ClientUserinfoChanged( int clientNum, qboolean forceName ){    gentity_t *ent;    char      *s;    char      model[ MAX_QPATH ];    char      buffer[ MAX_QPATH ];    char      filename[ MAX_QPATH ];    char      oldname[ MAX_NAME_LENGTH ];    char      newname[ MAX_NAME_LENGTH ];    char      err[ MAX_STRING_CHARS ];    qboolean  revertName = qfalse;    gclient_t *client;    char      userinfo[ MAX_INFO_STRING ];    ent = g_entities + clientNum;    client = ent->client;    trap_GetUserinfo( clientNum, userinfo, sizeof( userinfo ) );    // check for malformed or illegal info strings    if( !Info_Validate(userinfo) )    {        trap_SendServerCommand( ent - g_entities,                                "disconnect /"illegal or malformed userinfo/n/"" );        trap_DropClient( ent - g_entities,                         "dropped: illegal or malformed userinfo");        return "Illegal or malformed userinfo";    }    // If their userinfo overflowed, tremded is in the process of disconnecting them.    // If we send our own disconnect, it won't work, so just return to prevent crashes later    //  in this function. This check must come after the Info_Validate call.    else if( !userinfo[ 0 ] )        return "Empty (overflowed) userinfo";    // stickyspec toggle    s = Info_ValueForKey( userinfo, "cg_stickySpec" );    client->pers.stickySpec = atoi( s ) != 0;    // set name    Q_strncpyz( oldname, client->pers.netname, sizeof( oldname ) );    s = Info_ValueForKey( userinfo, "name" );    G_ClientCleanName( s, newname, sizeof( newname ) );    if( strcmp( oldname, newname ) )    {        if( !forceName && client->pers.namelog->nameChangeTime &&                level.time - client->pers.namelog->nameChangeTime <=                g_minNameChangePeriod.value * 1000 )        {            trap_SendServerCommand( ent - g_entities, va(                                        "print /"Name change spam protection (g_minNameChangePeriod = %d)/n/"",                                        g_minNameChangePeriod.integer ) );            revertName = qtrue;        }        else if( !forceName && g_maxNameChanges.integer > 0 &&                 client->pers.namelog->nameChanges >= g_maxNameChanges.integer  )        {            trap_SendServerCommand( ent - g_entities, va(                                        "print /"Maximum name changes reached (g_maxNameChanges = %d)/n/"",                                        g_maxNameChanges.integer ) );            revertName = qtrue;        }        else if( !forceName && client->pers.namelog->muted )        {            trap_SendServerCommand( ent - g_entities,                                    "print /"You cannot change your name while you are muted/n/"" );            revertName = qtrue;        }        else if( !G_admin_name_check( ent, newname, err, sizeof( err ) ) )        {            trap_SendServerCommand( ent - g_entities, va( "print /"%s/n/"", err ) );            revertName = qtrue;        }        if( revertName )        {            Q_strncpyz( client->pers.netname, *oldname ? oldname : "UnnamedPlayer",                        sizeof( client->pers.netname ) );            Info_SetValueForKey( userinfo, "name", oldname );            trap_SetUserinfo( clientNum, userinfo );        }        else        {            G_CensorString( client->pers.netname, newname,                            sizeof( client->pers.netname ), ent );            if( !forceName && client->pers.connected == CON_CONNECTED )            {                client->pers.namelog->nameChangeTime = level.time;                client->pers.namelog->nameChanges++;//.........这里部分代码省略.........
开发者ID:GrangerHub,项目名称:tremulous,代码行数:101,


示例9: CheckTeamStatus

void CheckTeamStatus( void ){	int       i;	gentity_t *loc, *ent;	if ( level.time - level.lastTeamLocationTime > TEAM_LOCATION_UPDATE_TIME )	{		level.lastTeamLocationTime = level.time;		for ( i = 0; i < g_maxclients.integer; i++ )		{			ent = g_entities + i;			if ( ent->client->pers.connected != CON_CONNECTED )			{				continue;			}			if ( ent->inuse && ( ent->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ||			                     ent->client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS ) )			{				loc = Team_GetLocation( ent );				if ( loc )				{					ent->client->pers.location = loc->s.generic1;				}				else				{					ent->client->pers.location = 0;				}			}		}		for ( i = 0; i < g_maxclients.integer; i++ )		{			ent = g_entities + i;			if ( ent->client->pers.connected != CON_CONNECTED )			{				continue;			}			if ( ent->inuse )			{				TeamplayInfoMessage( ent );			}		}	}	// Warn on imbalanced teams	if ( g_teamImbalanceWarnings.integer && !level.intermissiontime &&	     ( level.time - level.lastTeamImbalancedTime >	       ( g_teamImbalanceWarnings.integer * 1000 ) ) &&	     level.numTeamImbalanceWarnings < 3 && !level.restarted )	{		level.lastTeamImbalancedTime = level.time;		if ( level.numAlienSpawns > 0 &&		     level.numHumanClients - level.numAlienClients > 2 )		{			trap_SendServerCommand( -1, "print_tr /"" N_("Teams are imbalanced. "			                        "Humans have more players./n") "/"" );			level.numTeamImbalanceWarnings++;		}		else if ( level.numHumanSpawns > 0 &&		          level.numAlienClients - level.numHumanClients > 2 )		{			trap_SendServerCommand( -1, "print_tr /"" N_("Teams are imbalanced. "			                        "Aliens have more players./n") "/"" );			level.numTeamImbalanceWarnings++;		}		else		{			level.numTeamImbalanceWarnings = 0;		}	}}
开发者ID:Sixthly,项目名称:Unvanquished,代码行数:78,


示例10: TeamplayInfoMessage

//.........这里部分代码省略.........		}		team = g_entities[ ent->client->sess.spectatorClient ].client->		       pers.teamSelection;	}	else	{		team = ent->client->pers.teamSelection;	}	string[ 0 ] = '/0';	stringlength = 0;	for ( i = 0; i < MAX_CLIENTS; i++ )	{		player = g_entities + i;		cl = player->client;		if ( ent == player || !cl || team != cl->pers.teamSelection ||		     !player->inuse )		{			continue;		}		if ( cl->sess.spectatorState != SPECTATOR_NOT )		{			curWeaponClass = WP_NONE;			upgrade = UP_NONE;		}		else if ( cl->pers.teamSelection == TEAM_HUMANS )		{			curWeaponClass = cl->ps.weapon;			if ( BG_InventoryContainsUpgrade( UP_BATTLESUIT, cl->ps.stats ) )			{				upgrade = UP_BATTLESUIT;			}			else if ( BG_InventoryContainsUpgrade( UP_JETPACK, cl->ps.stats ) )			{				upgrade = UP_JETPACK;			}			else if ( BG_InventoryContainsUpgrade( UP_BATTPACK, cl->ps.stats ) )			{				upgrade = UP_BATTPACK;			}			else if ( BG_InventoryContainsUpgrade( UP_HELMET, cl->ps.stats ) )			{				upgrade = UP_HELMET;			}			else if ( BG_InventoryContainsUpgrade( UP_LIGHTARMOUR, cl->ps.stats ) )			{				upgrade = UP_LIGHTARMOUR;			}			else			{				upgrade = UP_NONE;			}		}		else if ( cl->pers.teamSelection == TEAM_ALIENS )		{			curWeaponClass = cl->ps.stats[ STAT_CLASS ];			upgrade = UP_NONE;		}		tmp = va( "%i %i %i %i",		          player->client->pers.location,		          player->client->ps.stats[ STAT_HEALTH ] < 1 ? 0 :		          player->client->ps.stats[ STAT_HEALTH ],		          curWeaponClass,		          upgrade );		if ( !strcmp( ent->client->pers.cinfo[ i ], tmp ) )		{			continue;		}		Q_strncpyz( ent->client->pers.cinfo[ i ], tmp,		            sizeof( ent->client->pers.cinfo[ i ] ) );		Com_sprintf( entry, sizeof( entry ), " %i %s", i, tmp );		j = strlen( entry );		if ( stringlength + j >= sizeof( string ) )		{			break;		}		strcpy( string + stringlength, entry );		stringlength += j;		sent++;	}	if ( !sent )	{		return;	}	trap_SendServerCommand( ent - g_entities, va( "tinfo%s", string ) );}
开发者ID:Sixthly,项目名称:Unvanquished,代码行数:101,


示例11: Team_TouchOurFlag

/*=======================================================================================================================================Team_TouchOurFlag=======================================================================================================================================*/int Team_TouchOurFlag(gentity_t *ent, gentity_t *other, int team) {	int i;	gentity_t *player;	gclient_t *cl = other->client;	int enemy_flag;	if (g_gametype.integer == GT_1FCTF) {		enemy_flag = PW_NEUTRALFLAG;	} else {		if (cl->sess.sessionTeam == TEAM_RED) {			enemy_flag = PW_BLUEFLAG;		} else {			enemy_flag = PW_REDFLAG;		}		if (ent->flags & FL_DROPPED_ITEM) {			// hey, it's not home. return it by teleporting it back			PrintMsg(NULL, "%s" S_COLOR_WHITE " returned the %s flag!/n", cl->pers.netname, TeamName(team));			AddScore(other, ent->r.currentOrigin, CTF_RECOVERY_BONUS);			other->client->pers.teamState.lastreturnedflag = level.time;			// 'ResetFlag' will remove this entity! We must return zero			Team_ReturnFlagSound(Team_ResetFlag(team), team);			return 0;		}	}	// the flag is at home base. if the player has the enemy flag, he's just won!	if (!cl->ps.powerups[enemy_flag]) {		return 0; // we don't have the flag	}	if (g_gametype.integer == GT_1FCTF) {		trap_SendServerCommand(-1, va("cp /"%s" S_COLOR_WHITE "/ncaptured the flag!/n/"", cl->pers.netname));	} else {		trap_SendServerCommand(-1, va("cp /"%s" S_COLOR_WHITE "/ncaptured the %s flag!/n/"", cl->pers.netname, TeamName(OtherTeam(team))));	}	cl->ps.powerups[enemy_flag] = 0;	other->client->rewardTime = level.time + REWARD_TIME;	other->client->ps.persistant[PERS_CAPTURES]++;	// other gets another 10 frag bonus	AddScore(other, ent->r.currentOrigin, CTF_CAPTURE_BONUS);	// ok, let's do the player loop, hand out the bonuses	for (i = 0; i < g_maxclients.integer; i++) {		player = &g_entities[i];		// also make sure we don't award assist bonuses to the flag carrier himself.		if (!player->inuse || player == other) {			continue;		}		if (player->client->sess.sessionTeam != cl->sess.sessionTeam) {			player->client->pers.teamState.lasthurtcarrier = -5;		} else if (player->client->sess.sessionTeam == cl->sess.sessionTeam) {			AddScore(player, ent->r.currentOrigin, CTF_TEAM_BONUS);			// award extra points for capture assists			if (player->client->pers.teamState.lastreturnedflag + CTF_RETURN_FLAG_ASSIST_TIMEOUT > level.time) {				AddScore(player, ent->r.currentOrigin, CTF_RETURN_FLAG_ASSIST_BONUS);				player->client->ps.persistant[PERS_ASSIST_COUNT]++;				player->client->rewardTime = level.time + REWARD_TIME;			}			if (player->client->pers.teamState.lastfraggedcarrier + CTF_FRAG_CARRIER_ASSIST_TIMEOUT > level.time) {				AddScore(player, ent->r.currentOrigin, CTF_FRAG_CARRIER_ASSIST_BONUS);				player->client->ps.persistant[PERS_ASSIST_COUNT]++;				player->client->rewardTime = level.time + REWARD_TIME;			}		}	}	teamgame.last_flag_capture = level.time;	teamgame.last_capture_team = team;	// increase the team's score	AddTeamScore(ent->s.pos.trBase, other->client->sess.sessionTeam, 1);	CalculateRanks();	Team_ResetFlags();	Team_CaptureFlagSound(ent, team);	Team_ForceGesture(other->client->sess.sessionTeam);	return 0; // do not respawn this automatically}
开发者ID:KuehnhammerTobias,项目名称:ioqw,代码行数:88,


示例12: ConsoleCommand

/*=================ConsoleCommand=================*/qboolean    ConsoleCommand( void ) {	char cmd[MAX_TOKEN_CHARS];	trap_Argv( 0, cmd, sizeof( cmd ) );	if ( Q_stricmp( cmd, "entitylist" ) == 0 ) {		Svcmd_EntityList_f();		return qtrue;	}	if ( Q_stricmp( cmd, "forceteam" ) == 0 ) {		Svcmd_ForceTeam_f();		return qtrue;	}	if ( Q_stricmp( cmd, "game_memory" ) == 0 ) {		Svcmd_GameMem_f();		return qtrue;	}	if ( Q_stricmp( cmd, "addbot" ) == 0 ) {		Svcmd_AddBot_f();		return qtrue;	}	if ( Q_stricmp( cmd, "addip" ) == 0 ) {		Svcmd_AddIP_f();		return qtrue;	}	if ( Q_stricmp( cmd, "removeip" ) == 0 ) {		Svcmd_RemoveIP_f();		return qtrue;	}	if ( Q_stricmp( cmd, "listip" ) == 0 ) {		trap_SendConsoleCommand( EXEC_INSERT, "g_banIPs/n" );		return qtrue;	}	if ( Q_stricmp( cmd, "listmaxlivesip" ) == 0 ) {		PrintMaxLivesGUID();		return qtrue;	}	// NERVE - SMF	if ( Q_stricmp( cmd, "start_match" ) == 0 ) {		Svcmd_StartMatch_f();		return qtrue;	}	if ( Q_stricmp( cmd, "reset_match" ) == 0 ) {		Svcmd_ResetMatch_f();		return qtrue;	}	if ( Q_stricmp( cmd, "swap_teams" ) == 0 ) {		Svcmd_SwapTeams_f();		return qtrue;	}	// -NERVE - SMF	if ( g_dedicated.integer ) {		if ( Q_stricmp( cmd, "say" ) == 0 ) {			trap_SendServerCommand( -1, va( "print /"server:[lof] %s/"", ConcatArgs( 1 ) ) );			return qtrue;		}		// everything else will also be printed as a say command		trap_SendServerCommand( -1, va( "print /"server:[lof] %s/"", ConcatArgs( 0 ) ) );		return qtrue;	}	return qfalse;}
开发者ID:Justasic,项目名称:RTCW-MP,代码行数:81,


示例13: G_TimeShiftClient

/*=================G_TimeShiftClientMove a client back to where he was at the specified "time"=================*/void G_TimeShiftClient( gentity_t *ent, int time, qboolean debug, gentity_t *debugger ) {	int		j, k;	char msg[2048];	// this will dump out the head index, and the time for all the stored positions/*	if ( debug ) {		char	str[MAX_STRING_CHARS];		Com_sprintf(str, sizeof(str), "print /"head: %d, %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d/n/"",			ent->client->historyHead,			ent->client->history[0].leveltime,			ent->client->history[1].leveltime,			ent->client->history[2].leveltime,			ent->client->history[3].leveltime,			ent->client->history[4].leveltime,			ent->client->history[5].leveltime,			ent->client->history[6].leveltime,			ent->client->history[7].leveltime,			ent->client->history[8].leveltime,			ent->client->history[9].leveltime,			ent->client->history[10].leveltime,			ent->client->history[11].leveltime,			ent->client->history[12].leveltime,			ent->client->history[13].leveltime,			ent->client->history[14].leveltime,			ent->client->history[15].leveltime,			ent->client->history[16].leveltime);		trap_SendServerCommand( debugger - g_entities, str );	}*/	// find two entries in the history whose times sandwich "time"	// assumes no two adjacent records have the same timestamp	j = k = ent->client->historyHead;	do {		if ( ent->client->history[j].leveltime <= time )			break;		k = j;		j--;		if ( j < 0 ) {			j = NUM_CLIENT_HISTORY - 1;		}	}	while ( j != ent->client->historyHead );	// if we got past the first iteration above, we've sandwiched (or wrapped)	if ( j != k ) {		// make sure it doesn't get re-saved		if ( ent->client->saved.leveltime != level.time ) {			// save the current origin and bounding box			VectorCopy( ent->r.mins, ent->client->saved.mins );			VectorCopy( ent->r.maxs, ent->client->saved.maxs );			VectorCopy( ent->r.currentOrigin, ent->client->saved.currentOrigin );			ent->client->saved.leveltime = level.time;		}		// if we haven't wrapped back to the head, we've sandwiched, so		// we shift the client's position back to where he was at "time"		if ( j != ent->client->historyHead ) {			float	frac = (float)(time - ent->client->history[j].leveltime) /				(float)(ent->client->history[k].leveltime - ent->client->history[j].leveltime);			// interpolate between the two origins to give position at time index "time"			TimeShiftLerp( frac,				ent->client->history[j].currentOrigin, ent->client->history[k].currentOrigin,				ent->r.currentOrigin );			// lerp these too, just for fun (and ducking)			TimeShiftLerp( frac,				ent->client->history[j].mins, ent->client->history[k].mins,				ent->r.mins );			TimeShiftLerp( frac,				ent->client->history[j].maxs, ent->client->history[k].maxs,				ent->r.maxs );			if ( debug && debugger != NULL ) {				// print some debugging stuff exactly like what the client does				// it starts with "Rec:" to let you know it backward-reconciled				Com_sprintf( msg, sizeof(msg),					"print /"^1Rec: time: %d, j: %d, k: %d, origin: %0.2f %0.2f %0.2f/n"					"^2frac: %0.4f, origin1: %0.2f %0.2f %0.2f, origin2: %0.2f %0.2f %0.2f/n"					"^7level.time: %d, est time: %d, level.time delta: %d, est real ping: %d/n/"",					time, ent->client->history[j].leveltime, ent->client->history[k].leveltime,					ent->r.currentOrigin[0], ent->r.currentOrigin[1], ent->r.currentOrigin[2],					frac,					ent->client->history[j].currentOrigin[0],					ent->client->history[j].currentOrigin[1],					ent->client->history[j].currentOrigin[2], //.........这里部分代码省略.........
开发者ID:themuffinator,项目名称:fnq3,代码行数:101,


示例14: ThinkBalloonzone

void ThinkBalloonzone( gentity_t *self ) {	//"(team == 0) ? TEAM_RED : TEAM_BLUE" => ! in this code red=0, blue=1 ! (unlike TEAM_RED(1), TEAM_BLUE(2) from team_t)	// FIXME: Remove that offset team uglyness or at least make it readable!!1!	int team, opponent;	int numPlayers;	team_t tteam;	char *msg;	if ( !self->message ) {		msg = "Balloon";	}	else {		msg = self->message;	}	if ( self->target_ent->s.frame ) {		// get teams		team = ( self->target_ent->s.generic1 - 1 );		opponent = ( team ^ 1 );		tteam = ( team + 1 );		// capturing		if ( ( self->target_ent->s.frame < 11 ) &&		     ( self->teamMask & ( 1 << team ) ) &&		     !( self->teamMask & (1 << opponent ) ) ) {			numPlayers = NumPlayersAtBalloon( self, tteam );			if ( numPlayers <= 0 ) {				numPlayers = 1; //... so, we must not check this later			}			self->teamTime[team] += ( BALLOON_THINKTIME * numPlayers );			self->target_ent->s.frame = ( 1 + self->teamTime[team] / ( 100 * self->speed ) );			if ( self->target_ent->s.frame >= 11 ) {				// captured				self->last_move_time = 0;				self->teamTime[team] = 0;				level.balloonState[self->count] = ( '1' + team );				trap_SetConfigstring( CS_BALLOONS, level.balloonState );				// TODO: Give more points for capturing than for owning?				//       Need to test balance!				AddTeamScore( self->s.pos.trBase, tteam, ( BalloonScore() * 2 ), SCORE_BONUS_CAPTURE_S );				AddBalloonScores( self, tteam, 1 );				trap_SendServerCommand( -1, va( "mp /"%s captured by %s Team/"", msg, TeamName( tteam ) ) );			}		}		// balloon is fully raised		if ( self->target_ent->s.frame >= 11 ) {			// animate			self->last_move_time += BALLOON_THINKTIME;			if ( self->last_move_time >= ( 700 * self->speed ) ) {				self->last_move_time -= ( 700 * self->speed );			}			self->target_ent->s.frame = ( 11 + self->last_move_time / ( 100 * self->speed ) );			// give points			if ( !level.intermissiontime ) {				self->teamTime[team] += BALLOON_THINKTIME;				while ( self->teamTime[team] >= BALLOON_POINTTIME ) {					self->teamTime[team] -= BALLOON_POINTTIME;					AddTeamScore( self->s.pos.trBase, tteam, ( BalloonScore() * 2 ), SCORE_BONUS_CAPTURE_TEAM_S );				}			}		}		// countering capture		if ( self->teamMask & (1 << opponent ) ) {			numPlayers = NumPlayersAtBalloon( self, tteam );			if ( numPlayers <= 0 ) {				numPlayers = 1; //... so, we must not check this later			}			if ( !self->teamTime[opponent] ) {				self->teamTime[opponent] = level.time;			}			// FIXME: If some players come "later", they will also be calculated for the full time.			else if ( level.time > ( self->teamTime[opponent] + ( self->wait * 1000 / numPlayers ) ) ) {				// countered				self->teamTime[0] = 0;				self->teamTime[1] = 0;				self->target_ent->s.frame = 0;				level.balloonState[self->count] = '0';				trap_SetConfigstring( CS_BALLOONS, level.balloonState );				// TODO: Also give players//&team points for destroying a balloon?				trap_SendServerCommand( -1, va( "mp /"%s destroyed by %s Team/"", msg, TeamName( OtherTeam( tteam ) ) ) );			}		}		else {			self->teamTime[opponent] = 0;		}	}	else {		if ( ( self->teamMask & BT_RED ) && ( self->teamMask & BT_BLUE ) ) {//.........这里部分代码省略.........
开发者ID:meveric,项目名称:WoP-Pandora,代码行数:101,


示例15: trigger_teleporter_touch

void trigger_teleporter_touch( gentity_t *self, gentity_t *other, trace_t *trace ) {	gentity_t	*dest;	if ( !other->client ) {		return;	}	if ( other->client->ps.pm_type == PM_DEAD ) {		return;	}	// Spectators only?	if ( ( self->spawnflags & 1 ) && 		( ( other->client->sess.sessionTeam != TEAM_SPECTATOR ) && !LPSDeadSpec( other->client ) ) ) {		return;	}	// FIXME: Use defines for spawnflags	if ( ( self->spawnflags & 0x2 ) && !IsSyc() ) {		// No need to check for sprayroom teleporter out		return;	}	if ( ( other->client->sess.sessionTeam != TEAM_SPECTATOR ) && !LPSDeadSpec( other->client ) ) {		// sprayroom teleporter in		if ( self->spawnflags & 0x2 ) {			if ( other->client->ps.ammo[WP_SPRAYPISTOL] <= 0 ) {				return;			}			other->client->logocounter = 0;			other->client->sprayroomleavetime = ( ( level.maxsprayroomtime * 1000 ) + level.time );			other->client->sprayroomsoundflags = 0;			other->client->ps.stats[STAT_SPRAYROOMSECS] = ( level.maxsprayroomtime + 1 );			if ( other->client->ps.weapon != WP_SPRAYPISTOL ) {				other->client->last_nonspray_weapon = other->client->ps.weapon;			}			if ( other->client->ps.weaponstate == WEAPON_CHARGING ) {				other->client->ps.weaponstate = WEAPON_READY;				other->client->ps.weaponTime = 0;			}			trap_SendServerCommand( other->client->ps.clientNum, va( "srwc %i", WP_SPRAYPISTOL ) );			other->client->pers.cmd.weapon = WP_SPRAYPISTOL;			other->client->ps.weapon = WP_SPRAYPISTOL;			G_BackupPowerups( other->client );		}		// sprayroom teleporter out		else if ( self->spawnflags & 0x4 ) {			other->client->ps.stats[STAT_SPRAYROOMSECS] = 0;			trap_SendServerCommand( other->client->ps.clientNum, va( "srwc %i", other->client->last_nonspray_weapon ) );			other->client->pers.cmd.weapon = other->client->last_nonspray_weapon;			other->client->ps.weapon = other->client->last_nonspray_weapon;			G_RestorePowerups( other->client );		}	}	dest = 	G_PickTarget( self->target );	if (!dest) {		G_Printf ("Couldn't find teleporter destination/n");		return;	}	TeleportPlayer( other, dest->s.origin, dest->s.angles );}
开发者ID:meveric,项目名称:WoP-Pandora,代码行数:67,


示例16: ConsoleCommand

/*=================ConsoleCommand=================*/qboolean	ConsoleCommand( void ) {	char	cmd[MAX_TOKEN_CHARS];	trap_Argv( 0, cmd, sizeof( cmd ) );	//	all commands prefixed with st_ are destined for the rules engine.	if (	cmd[ 0 ] == 's' &&			cmd[ 1 ] == 't' &&			cmd[ 2 ] == '_' )	{		if ( G_ST_exec( ST_CONSOLECOMMAND, cmd+3 ) )			return qtrue;	}	switch( SWITCHSTRING( cmd ) )	{#ifdef DEVELOPER	case CS('b','u','y',0):	case CS('s','e','l','l'):	case CS('v','i','s','i'):	case CS('b','e','g','i'):	case CS('a','s','s','e'):	case CS('i','n','t','e'):	case CS('e','n','d','i'):	case CS('l','o','o','k'):	case CS('p','l','a','n'):		G_ST_exec( ST_CLIENTCOMMAND, 0, cmd );		trap_SendConsoleCommand( EXEC_INSERT, "wait 50 ;" );		return qtrue;		//	cl0_	case CS('c','l','0','_'):		ClientCommand( 0, cmd + 4 );		return 0;#endif		//	entitylist	case CS('e','n','t','i'):		Svcmd_EntityList_f();		return qtrue;		//	forceteam	case CS('f','o','r','c'):		Svcmd_ForceTeam_f();		return qtrue;		//	game_memory	case CS('g','a','m','e'):		Svcmd_GameMem_f();		return qtrue;		//	addbot	case CS('a','d','d','b'):		Svcmd_AddBot_f();		return qtrue;		//	botlist	case CS('b','o','t','l'):		Svcmd_BotList_f();		return qtrue;		//	addip	case CS('a','d','d','i'):		Svcmd_AddIP_f();		return qtrue;		//	removeip	case CS('r','e','m','o'):		Svcmd_RemoveIP_f();		return qtrue;		//	listip	case CS('l','i','s','t'):		trap_SendConsoleCommand( EXEC_NOW, "g_banIPs/n" );		return qtrue;		//	abort	case CS('a','b','o','r'):		G_ST_exec( ST_CONSOLECOMMAND, cmd );		return qtrue;	}	if (g_dedicated.integer) {		if (Q_stricmp (cmd, "say") == 0) {			trap_SendServerCommand( -1, va("print /"server: %s/"", ConcatArgs(1) ) );			return qtrue;		}		// everything else will also be printed as a say command		trap_SendServerCommand( -1, va("print /"server: %s/"", ConcatArgs(0) ) );		return qtrue;	}	return qfalse;//.........这里部分代码省略.........
开发者ID:ballju,项目名称:SpaceTrader-GPL-1.1.14,代码行数:101,


示例17: memset

/*===========ClientConnectCalled when a player begins connecting to the server.Called again for every map change or tournement restart.The session information will be valid after exit.Return NULL if the client should be allowed, otherwise returna string with the reason for denial.Otherwise, the client will be sent the current gamestateand will eventually get to ClientBegin.firstTime will be qtrue the very first time a client connectsto the server machine, but qfalse on map changes and tournementrestarts.============*/char *ClientConnect( int clientNum, qboolean firstTime ){    char      *value;    char      *userInfoError;    gclient_t *client;    char      userinfo[ MAX_INFO_STRING ];    gentity_t *ent;    char      reason[ MAX_STRING_CHARS ] = {""};    int       i;    ent = &g_entities[ clientNum ];    client = &level.clients[ clientNum ];    // ignore if client already connected    if( client->pers.connected != CON_DISCONNECTED )        return NULL;    ent->client = client;    memset( client, 0, sizeof( *client ) );    trap_GetUserinfo( clientNum, userinfo, sizeof( userinfo ) );    value = Info_ValueForKey( userinfo, "cl_guid" );    Q_strncpyz( client->pers.guid, value, sizeof( client->pers.guid ) );    value = Info_ValueForKey( userinfo, "ip" );    // check for local client    if( !strcmp( value, "localhost" ) )        client->pers.localClient = qtrue;    G_AddressParse( value, &client->pers.ip );    client->pers.admin = G_admin_admin( client->pers.guid );    // check for admin ban    if( G_admin_ban_check( ent, reason, sizeof( reason ) ) )    {        return va( "%s", reason );    }    // check for a password    value = Info_ValueForKey( userinfo, "password" );    if( g_password.string[ 0 ] && Q_stricmp( g_password.string, "none" ) &&            strcmp( g_password.string, value ) != 0 )        return "Invalid password";    // add guid to session so we don't have to keep parsing userinfo everywhere    for( i = 0; i < sizeof( client->pers.guid ) - 1 &&            isxdigit( client->pers.guid[ i ] ); i++ );    if( i < sizeof( client->pers.guid ) - 1 )        return "Invalid GUID";    for( i = 0; i < level.maxclients; i++ )    {        if( level.clients[ i ].pers.connected == CON_DISCONNECTED )            continue;        if( !Q_stricmp( client->pers.guid, level.clients[ i ].pers.guid ) )        {            if( !G_ClientIsLagging( level.clients + i ) )            {                trap_SendServerCommand( i, "cp /"Your GUID is not secure/"" );                return "Duplicate GUID";            }            trap_DropClient( i, "Ghost" );        }    }    client->pers.connected = CON_CONNECTING;    // read or initialize the session data    if( firstTime || level.newSession )        G_InitSessionData( client, userinfo );    G_ReadSessionData( client );    // get and distribute relevent paramters    G_namelog_connect( client );    userInfoError = ClientUserinfoChanged( clientNum, qfalse );//.........这里部分代码省略.........
开发者ID:GrangerHub,项目名称:tremulous,代码行数:101,


示例18: player_die

void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath ) {	gentity_t   *ent;	// TTimo might be used uninitialized	int contents = 0;	int killer;	int i;	const char        *killerName, *obit;	qboolean nogib = qtrue;	gitem_t     *item = NULL; // JPW NERVE for flag drop	vec3_t launchvel,launchspot;      // JPW NERVE	gentity_t   *flag; // JPW NERVE	if ( self->client->ps.pm_type == PM_DEAD ) {		return;	}	if ( level.intermissiontime ) {		return;	}	self->client->ps.pm_type = PM_DEAD;	G_AddEvent( self, EV_STOPSTREAMINGSOUND, 0 );	if ( attacker ) {		killer = attacker->s.number;		if ( attacker->client ) {			killerName = attacker->client->pers.netname;		} else {			killerName = "<non-client>";		}	} else {		killer = ENTITYNUM_WORLD;		killerName = "<world>";	}	if ( killer < 0 || killer >= MAX_CLIENTS ) {		killer = ENTITYNUM_WORLD;		killerName = "<world>";	}	if ( meansOfDeath < 0 || meansOfDeath >= sizeof( modNames ) / sizeof( modNames[0] ) ) {		obit = "<bad obituary>";	} else {		obit = modNames[ meansOfDeath ];	}	G_LogPrintf( "Kill: %i %i %i: %s killed %s by %s/n",				 killer, self->s.number, meansOfDeath, killerName,				 self->client->pers.netname, obit );	// broadcast the death event to everyone	ent = G_TempEntity( self->r.currentOrigin, EV_OBITUARY );	ent->s.eventParm = meansOfDeath;	ent->s.otherEntityNum = self->s.number;	ent->s.otherEntityNum2 = killer;	ent->r.svFlags = SVF_BROADCAST; // send to everyone	self->enemy = attacker;	self->client->ps.persistant[PERS_KILLED]++;// JPW NERVE -- if player is holding ticking grenade, drop it	if ( g_gametype.integer != GT_SINGLE_PLAYER ) {		if ( ( self->client->ps.grenadeTimeLeft ) && ( self->s.weapon != WP_DYNAMITE ) ) {			launchvel[0] = crandom();			launchvel[1] = crandom();			launchvel[2] = random();			VectorScale( launchvel, 160, launchvel );			VectorCopy( self->r.currentOrigin, launchspot );			launchspot[2] += 40;			fire_grenade( self, launchspot, launchvel, self->s.weapon );		}	}// jpw	if ( attacker && attacker->client ) {		if ( attacker == self || OnSameTeam( self, attacker ) ) {			// DHM - Nerve :: Complaint lodging			if ( attacker != self && level.warmupTime <= 0 ) {				if ( attacker->client->pers.localClient ) {					trap_SendServerCommand( self - g_entities, "complaint -4" );				} else {					trap_SendServerCommand( self - g_entities, va( "complaint %i", attacker->s.number ) );					self->client->pers.complaintClient = attacker->s.clientNum;					self->client->pers.complaintEndTime = level.time + 20500;				}			}			// dhm			// JPW NERVE			if ( g_gametype.integer >= GT_WOLF ) { // high penalty to offset medic heal				AddScore( attacker, WOLF_FRIENDLY_PENALTY );			} else {				// jpw				AddScore( attacker, -1 );			}		} else {//.........这里部分代码省略.........
开发者ID:bibendovsky,项目名称:rtcw,代码行数:101,


示例19: G_RadarUpdateCS

void G_RadarUpdateCS(void) {	int i, valid_count;	gentity_t *ent;	playerState_t *ps;	char cmd[MAX_TOKEN_CHARS];	// make sure our command string is								// large enough for all the data	// do we need to update the positions yet?	if (level.time - level.lastRadarUpdateTime > RADAR_UPDATE_TIME) {		//store the current time so we know when to update next		level.lastRadarUpdateTime = level.time;		//for each possible client		valid_count = 0;				for (i = 0; i < g_maxclients.integer; i++) {			//get a pointer to the entity			ent = g_entities + i;						//see if we have a valid entry			if ( ent->client->pers.connected != CON_CONNECTED ) {				g_playerOrigins[i].valid = qfalse;			} else if ( !(ent->inuse) ) {				g_playerOrigins[i].valid = qfalse;			} else if( ent->client->ps.powerLevel[plCurrent] <= 0 ) {				g_playerOrigins[i].valid = qfalse;			} else {				// get the client's player info				ps = &ent->client->ps;				//get and store the client position and information				VectorCopy( ps->origin, g_playerOrigins[i].pos );				g_playerOrigins[i].pl = ps->powerLevel[plCurrent];				g_playerOrigins[i].plMax = ps->powerLevel[plMaximum];				g_playerOrigins[i].clientNum = ps->clientNum;				g_playerOrigins[i].properties = 0;				if ( ( ps->stats[stChargePercentPrimary] >= 50 ) || ( ps->stats[stChargePercentSecondary] >= 50 ) ) {					g_playerOrigins[i].properties |= RADAR_WARN;				}				if ( ( ps->eFlags & EF_AURA ) || ps->powerups[PW_BOOST] ) {					g_playerOrigins[i].properties |= RADAR_BURST;				}				g_playerOrigins[i].team = ps->persistant[ PERS_TEAM ];				if ( g_playerOrigins[i].team >= TEAM_SPECTATOR ) {					// mark as invalid entry for a spectator					g_playerOrigins[i].valid = qfalse;								} else {					//mark as valid entry					g_playerOrigins[i].valid = qtrue;					//increase the valid counter					valid_count++;				}			}		} 		//build the command string to send		Com_sprintf( cmd, sizeof(cmd), "radar %i", valid_count );		for( i = 0; i < g_maxclients.integer; i++ ) {			//if weve got a valid entry then add the position to the command string			if( g_playerOrigins[i].valid ) {				strcat(cmd, va(" %i,", g_playerOrigins[i].clientNum));				strcat(cmd, va("%i,",  g_playerOrigins[i].pl));				strcat(cmd, va("%i,",  g_playerOrigins[i].plMax));				strcat(cmd, va("%i,",  g_playerOrigins[i].team));				strcat(cmd, va("%i,",  g_playerOrigins[i].properties));				strcat(cmd, va("%i,",  (int)ceil(g_playerOrigins[i].pos[0])));				strcat(cmd, va("%i,",  (int)ceil(g_playerOrigins[i].pos[1])));				strcat(cmd, va("%i",   (int)ceil(g_playerOrigins[i].pos[2])));			}		}		// broadcast the command seperately to only connected clients.				// FIXME: Does this prevent overflows that otherwise have to		//        wait for a time-out message from unconnected clients?		// NOTE:  Yep, seems to fix it.		for ( i = 0; i < g_maxclients.integer; i++ ) {			ent = g_entities + i;			if ( ent->client->pers.connected != CON_CONNECTED ) {				continue;			}			if ( ent->inuse ) {				trap_SendServerCommand( ent-g_entities, cmd );			}		}    		/*		//finally broadcast the command		trap_SendServerCommand( -1, cmd );		*/	}}
开发者ID:burzumishi,项目名称:dragonballworld,代码行数:99,


示例20: TeamplayInfoMessage

/* * Format: *      clientNum location health armor weapon powerups */voidTeamplayInfoMessage(Gentity *ent){	char	entry[1024];	char	string[8192];	int	stringlength;	int	i, j;	Gentity *player;	int	cnt;	int	h, a;	int	clients[TEAM_MAXOVERLAY];	int team;	if(!ent->client->pers.teamInfo)		return;	/* send info about followed client's team to spectator */	if(ent->client->sess.team == TEAM_SPECTATOR){		if(ent->client->sess.specclient != SPECTATOR_FOLLOW		   || ent->client->sess.specclient < 0)			return;		team = g_entities[ent->client->sess.specclient].client->sess.team;	}else		team = ent->client->sess.team;	if(team != TEAM_RED && team != TEAM_BLUE)		return;	/* 	 * figure out what client should be on the display	 * we are limited to 8, but we want to use the top eight players	 * but in client order (so they don't keep changing position on the overlay) 	 */	for(i = 0, cnt = 0; i < g_maxclients.integer && cnt < TEAM_MAXOVERLAY; i++){		player = g_entities + level.sortedClients[i];		if(player->inuse && player->client->sess.team == team)			clients[cnt++] = level.sortedClients[i];	}	/* We have the top eight players, sort them by clientNum */	qsort(clients, cnt, sizeof(clients[0]), SortClients);	/* send the latest information on all clients */	string[0] = 0;	stringlength = 0;	for(i = 0, cnt = 0; i < g_maxclients.integer && cnt < TEAM_MAXOVERLAY;	    i++){		player = g_entities + i;		if(player->inuse && player->client->sess.team == team){			h = player->client->ps.stats[STAT_HEALTH];			a = player->client->ps.stats[STAT_SHIELD];			if(h < 0) h = 0;			if(a < 0) a = 0;			Q_sprintf (entry, sizeof(entry), " %i %i %i %i %i %i",/*				level.sortedClients[i], player->client->pers.teamState.location, h, a, */				i, player->client->pers.teamState.location, h, a,				player->client->ps.weap[WSpri], player->s.powerups);			j = strlen(entry);			if(stringlength + j >= sizeof(string))				break;			strcpy (string + stringlength, entry);			stringlength += j;			cnt++;		}	}	trap_SendServerCommand(ent-g_entities, va("tinfo %i %s", cnt, string));}
开发者ID:icanhas,项目名称:yantar,代码行数:72,


示例21: AICast_ScriptParse

//.........这里部分代码省略.........			{				if ( !token[0] ) {					G_Error( "AICast_ScriptParse(), Error (line %d): '}' expected, end of script found./n", COM_GetCurrentParseLine() );				}				action = AICast_ActionForString( cs, token );				if ( !action ) {					G_Error( "AICast_ScriptParse(), Error (line %d): unknown action: %s./n", COM_GetCurrentParseLine(), token );				}				curEvent->stack.items[curEvent->stack.numItems].action = action;				memset( params, 0, sizeof( params ) );				token = COM_ParseExt( &pScript, qfalse );				for ( i = 0; token[0]; i++ )				{					if ( strlen( params ) ) { // add a space between each param						Q_strcat( params, sizeof( params ), " " );					}					if ( i == 0 ) {						// Special case: playsound's need to be cached on startup to prevent in-game pauses						if ( !Q_stricmp( action->actionString, "playsound" ) ) {							G_SoundIndex( token );						}//----(SA)	added a bit more						if (    buildScript && (									!Q_stricmp( action->actionString, "mu_start" ) ||									!Q_stricmp( action->actionString, "mu_play" ) ||									!Q_stricmp( action->actionString, "mu_queue" ) ||									!Q_stricmp( action->actionString, "startcam" ) ||									!Q_stricmp( action->actionString, "startcamblack" ) )								) {							if ( strlen( token ) ) { // we know there's a [0], but don't know if it's '0'								trap_SendServerCommand( cs->entityNum, va( "addToBuild %s/n", token ) );							}						}						if ( !Q_stricmp( action->actionString, "giveweapon" ) ) { // register weapon for client pre-loading							gitem_t *weap = BG_FindItem2( token );    // (SA) FIXME: rats, need to fix this for weapon names with spaces: 'mauser rifle'//							if(weap)							RegisterItem( weap );   // don't be nice, just do it.  if it can't find it, you'll bomb out to the error menu						}//----(SA)	end					}					if ( strrchr( token,' ' ) ) { // need to wrap this param in quotes since it has more than one word						Q_strcat( params, sizeof( params ), "/"" );					}					Q_strcat( params, sizeof( params ), token );					if ( strrchr( token,' ' ) ) { // need to wrap this param in quotes since it has more than one word						Q_strcat( params, sizeof( params ), "/"" );					}					token = COM_ParseExt( &pScript, qfalse );				}				if ( strlen( params ) ) { // copy the params into the event					curEvent->stack.items[curEvent->stack.numItems].params = G_Alloc( strlen( params ) + 1 );					Q_strncpyz( curEvent->stack.items[curEvent->stack.numItems].params, params, strlen( params ) + 1 );				}				curEvent->stack.numItems++;				if ( curEvent->stack.numItems >= AICAST_MAX_SCRIPT_STACK_ITEMS ) {					G_Error( "AICast_ScriptParse(): script exceeded MAX_SCRIPT_ITEMS (%d), line %d/n", AICAST_MAX_SCRIPT_STACK_ITEMS, COM_GetCurrentParseLine() );				}			}			numEventItems++;		} else    // skip this character completely		{			// TTimo: gcc: suggest () around assignment used as truth value			while ( ( token = COM_Parse( &pScript ) ) )			{				if ( !token[0] ) {					G_Error( "AICast_ScriptParse(), Error (line %d): '}' expected, end of script found./n", COM_GetCurrentParseLine() );				} else if ( token[0] == '{' ) {					bracketLevel++;				} else if ( token[0] == '}' ) {					if ( !--bracketLevel ) {						break;					}				}			}		}	}	// alloc and copy the events into the cast_state_t for this cast	if ( numEventItems > 0 ) {		cs->castScriptEvents = G_Alloc( sizeof( cast_script_event_t ) * numEventItems );		memcpy( cs->castScriptEvents, events, sizeof( cast_script_event_t ) * numEventItems );		cs->numCastScriptEvents = numEventItems;		cs->castScriptStatus.castScriptEventIndex = -1;	}}
开发者ID:JackalFrost,项目名称:RTCW-WSGF,代码行数:101,


示例22: G_Damage

//.........这里部分代码省略.........			if( dist > 1500.f ) {				if( dist > 2500.f ) {					take *= 0.2f;				} else {					float scale = 1.f - 0.2f * (1000.f / (dist - 1000.f));					take *= scale;				}			}		}		if( !(targ->client->ps.eFlags & EF_HEADSHOT) ) {	// only toss hat on first headshot			G_AddEvent( targ, EV_LOSE_HAT, DirToByte(dir) );			if( mod != MOD_K43_SCOPE &&				mod != MOD_GARAND_SCOPE ) {				take *= .8f;	// helmet gives us some protection			}		}		targ->client->ps.eFlags |= EF_HEADSHOT;		// OSP - Record the headshot		if(client && attacker && attacker->client#ifndef DEBUG_STATS		  && attacker->client->sess.sessionTeam != targ->client->sess.sessionTeam#endif		  ) {			G_addStatsHeadShot(attacker, mod);		}		if( g_debugBullets.integer ) {			trap_SendServerCommand( attacker-g_entities, "print /"Head Shot/n/"/n");		}		G_LogRegionHit( attacker, HR_HEAD );		hr = HR_HEAD;	} else if ( IsLegShot(targ, dir, point, mod) ) {		G_LogRegionHit( attacker, HR_LEGS );		hr = HR_LEGS;		if( g_debugBullets.integer ) {			trap_SendServerCommand( attacker-g_entities, "print /"Leg Shot/n/"/n");		}	} else if ( IsArmShot(targ, attacker, point, mod) ) {		G_LogRegionHit( attacker, HR_ARMS );		hr = HR_ARMS;		if( g_debugBullets.integer ) {			trap_SendServerCommand( attacker-g_entities, "print /"Arm Shot/n/"/n");		}	} else if (targ->client && targ->health > 0 && IsHeadShotWeapon( mod ) ) {		G_LogRegionHit( attacker, HR_BODY );		hr = HR_BODY;		if( g_debugBullets.integer ) {			trap_SendServerCommand( attacker-g_entities, "print /"Body Shot/n/"/n");		}	}#ifndef DEBUG_STATS	if ( g_debugDamage.integer )#endif	{		G_Printf( "client:%i health:%i damage:%i mod:%s/n", targ->s.number, targ->health, take, modNames[mod] );	}	// add to the damage inflicted on a player this frame	// the total will be turned into screen blends and view angle kicks
开发者ID:BackupTheBerlios,项目名称:et-flf-svn,代码行数:67,


示例23: ConsoleCommand

//.........这里部分代码省略.........    if (Q_stricmp (cmd, "botlist") == 0) {        Svcmd_BotList_f();        return qtrue;    }    if (Q_stricmp (cmd, "abort_podium") == 0) {        Svcmd_AbortPodium_f();        return qtrue;    }    if (Q_stricmp (cmd, "addip") == 0) {        Svcmd_AddIP_f();        return qtrue;    }    if (Q_stricmp (cmd, "removeip") == 0) {        Svcmd_RemoveIP_f();        return qtrue;    }    if (Q_stricmp (cmd, "listip") == 0) {        trap_SendConsoleCommand( EXEC_NOW, "g_banIPs/n" );        return qtrue;    }    if(Q_stricmp (cmd, "setGametype") == 0)    {        Svcmd_SetGameType_f();        return qtrue;    }    if(Q_stricmp (cmd, "startcam") == 0) {        Svcmd_StartCam();        return qtrue;    }    if(Q_stricmp (cmd, "stopcam") == 0) {        Svcmd_StopCam();        return qtrue;    }    if(Q_stricmp (cmd, "camcmd") == 0) {        Svcmd_CamCmd();        return qtrue;    }    if( !Q_stricmp( cmd, "initwp") ) {        WaypointInit();        return qtrue;    }    if ( Q_stricmp( cmd, "blibset") == 0 ) {        char key[MAX_TOKEN_CHARS];        char value[MAX_TOKEN_CHARS];        trap_Argv(1, key, sizeof(key) );        trap_Argv(2, value, sizeof(value) );        if(!strlen(key))        {            G_Printf("missing key/n");            return qtrue;        }        if( !strlen(value) )	// use "1" as default            strcpy( value, "1" );        trap_BotLibVarSet( key, value );        return qtrue;    }    if(wopSP_cmdCheck(cmd))        return qtrue;    if (g_dedicated.integer) {        if ( Q_stricmp( cmd, "ssay" ) == 0 ) {            Svcmd_Say_f();            return qtrue;        }        if ( Q_stricmp( cmd, "stell" ) == 0 ) {            Svcmd_Tell_f();            return qtrue;        }        if ( Q_stricmp( cmd, "scp" ) == 0 ) {            Svcmd_ClientCommand_f( CCMD_CP );            return qtrue;        }        if ( Q_stricmp( cmd, "smp" ) == 0 ) {            Svcmd_ClientCommand_f( CCMD_MP );            return qtrue;        }        if ( Q_stricmp( cmd, "sprint" ) == 0 ) {            Svcmd_ClientCommand_f( CCMD_PRINT );            return qtrue;        }        // everything else will also be printed to clients        trap_SendServerCommand( -1, va("print /"server: %s/n/"", ConcatArgs(0) ) );        return qtrue;    }    return qfalse;}
开发者ID:PadWorld-Entertainment,项目名称:wop-gamesource,代码行数:101,


示例24: player_die

//.........这里部分代码省略.........	ent->s.eventParm = meansOfDeath;	ent->s.otherEntityNum = self->s.number;	ent->s.otherEntityNum2 = killer;	ent->r.svFlags = SVF_BROADCAST;	// send to everyone	self->enemy = attacker;	self->client->ps.persistant[PERS_KILLED]++;	// JPW NERVE -- if player is holding ticking grenade, drop it	if ((self->client->ps.grenadeTimeLeft) && (self->s.weapon != WP_DYNAMITE) && (self->s.weapon != WP_LANDMINE) && (self->s.weapon != WP_SATCHEL) && (self->s.weapon != WP_TRIPMINE)) {		vec3_t launchvel, launchspot;		launchvel[0] = crandom();		launchvel[1] = crandom();		launchvel[2] = random();		VectorScale( launchvel, 160, launchvel );		VectorCopy(self->r.currentOrigin, launchspot);		launchspot[2] += 40;				{			// Gordon: fixes premature grenade explosion, ta bani ;)			gentity_t *m = fire_grenade(self, launchspot, launchvel, self->s.weapon);			m->damage = 0;		}	}	if (attacker && attacker->client) {		if ( attacker == self || OnSameTeam (self, attacker ) ) {			// DHM - Nerve :: Complaint lodging			if( attacker != self && level.warmupTime <= 0 && g_gamestate.integer == GS_PLAYING) {				if( attacker->client->pers.localClient ) {					trap_SendServerCommand( self-g_entities, "complaint -4" );				} else {					if( meansOfDeath != MOD_CRUSH_CONSTRUCTION && meansOfDeath != MOD_CRUSH_CONSTRUCTIONDEATH && meansOfDeath != MOD_CRUSH_CONSTRUCTIONDEATH_NOATTACKER ) {						if( g_complaintlimit.integer ) {							if( !(meansOfDeath == MOD_LANDMINE && g_disableComplaints.integer & TKFL_MINES ) &&								!((meansOfDeath == MOD_ARTY || meansOfDeath == MOD_AIRSTRIKE) && g_disableComplaints.integer & TKFL_AIRSTRIKE ) &&								!(meansOfDeath == MOD_MORTAR && g_disableComplaints.integer & TKFL_MORTAR ) ) {								trap_SendServerCommand( self-g_entities, va( "complaint %i", attacker->s.number ) );								self->client->pers.complaintClient = attacker->s.clientNum;								self->client->pers.complaintEndTime = level.time + 20500;							}						}					}				}			}			// high penalty to offset medic heal/*			AddScore( attacker, WOLF_FRIENDLY_PENALTY ); */			if( g_gametype.integer == GT_WOLF_LMS ) {				AddKillScore( attacker, WOLF_FRIENDLY_PENALTY );			}		} else {			//G_AddExperience( attacker, 1 );			// JPW NERVE -- mostly added as conveneience so we can tweak from the #defines all in one place			AddScore(attacker, WOLF_FRAG_BONUS);			if( g_gametype.integer == GT_WOLF_LMS ) {				if( level.firstbloodTeam == -1 )					level.firstbloodTeam = attacker->client->sess.sessionTeam;
开发者ID:BackupTheBerlios,项目名称:et-flf-svn,代码行数:67,


示例25: CheckExitRules

/*=================CheckExitRulesThere will be a delay between the time the exit is qualified forand the time everyone is moved to the intermission spot, so youcan see the last frag.=================*/void CheckExitRules( void ) { 	int			i;	gclient_t	*cl;	// if at the intermission, wait for all non-bots to	// signal ready, then go to next level	if ( level.intermissiontime ) {		CheckIntermissionExit ();		return;	}	if ( level.intermissionQueued ) {#ifdef MISSIONPACK		int time = (g_singlePlayer.integer) ? SP_INTERMISSION_DELAY_TIME : INTERMISSION_DELAY_TIME;		if ( level.time - level.intermissionQueued >= time ) {			level.intermissionQueued = 0;			BeginIntermission();		}#else		if ( level.time - level.intermissionQueued >= INTERMISSION_DELAY_TIME ) {			level.intermissionQueued = 0;			BeginIntermission();		}#endif		return;	}	// check for sudden death	if ( ScoreIsTied() ) {		// always wait for sudden death		return;	}	if ( g_timelimit.integer && !level.warmupTime ) {		if ( level.time - level.startTime >= g_timelimit.integer*60000 ) {			trap_SendServerCommand( -1, "print /"Timelimit hit./n/"");			LogExit( "Timelimit hit." );			return;		}	}	if ( g_gametype.integer < GT_CTF && g_fraglimit.integer ) {		if ( level.teamScores[TEAM_RED] >= g_fraglimit.integer ) {			trap_SendServerCommand( -1, "print /"Red hit the fraglimit./n/"" );			LogExit( "Fraglimit hit." );			return;		}		if ( level.teamScores[TEAM_BLUE] >= g_fraglimit.integer ) {			trap_SendServerCommand( -1, "print /"Blue hit the fraglimit./n/"" );			LogExit( "Fraglimit hit." );			return;		}		for ( i=0 ; i< g_maxclients.integer ; i++ ) {			cl = level.clients + i;			if ( cl->pers.connected != CON_CONNECTED ) {				continue;			}			if ( cl->sess.sessionTeam != TEAM_FREE ) {				continue;			}			if ( cl->ps.persistant[PERS_SCORE] >= g_fraglimit.integer ) {				LogExit( "Fraglimit hit." );				trap_SendServerCommand( -1, va("print /"%s" S_COLOR_WHITE " hit the fraglimit./n/"",					cl->pers.netname ) );				return;			}		}	}	if ( g_gametype.integer >= GT_CTF && g_capturelimit.integer ) {		if ( level.teamScores[TEAM_RED] >= g_capturelimit.integer ) {			trap_SendServerCommand( -1, "print /"Red hit the capturelimit./n/"" );			LogExit( "Capturelimit hit." );			return;		}		if ( level.teamScores[TEAM_BLUE] >= g_capturelimit.integer ) {			trap_SendServerCommand( -1, "print /"Blue hit the capturelimit./n/"" );			LogExit( "Capturelimit hit." );			return;		}	}}
开发者ID:CarlGammaSagan,项目名称:Quake-3-Android-Port-QIII4A,代码行数:95,


示例26: ConsoleCommand

/*=================ConsoleCommand=================*/qboolean	ConsoleCommand( void ) {	char	cmd[MAX_TOKEN_CHARS];	trap_Argv( 0, cmd, sizeof( cmd ) );	if ( Q_stricmp (cmd, "entitylist") == 0 ) {		Svcmd_EntityList_f();		return qtrue;	}	if ( Q_stricmp (cmd, "forceteam") == 0 ) {		Svcmd_ForceTeam_f();		return qtrue;	}	if (Q_stricmp (cmd, "game_memory") == 0) {		Svcmd_GameMem_f();		return qtrue;	}	if (Q_stricmp (cmd, "addbot") == 0) {		Svcmd_AddBot_f();		return qtrue;	}	if (Q_stricmp (cmd, "botlist") == 0) {		Svcmd_BotList_f();		return qtrue;	}/*	if (Q_stricmp (cmd, "abort_podium") == 0) {		Svcmd_AbortPodium_f();		return qtrue;	}*/	if (Q_stricmp (cmd, "addip") == 0) {		Svcmd_AddIP_f();		return qtrue;	}	if (Q_stricmp (cmd, "removeip") == 0) {		Svcmd_RemoveIP_f();		return qtrue;	}	if (Q_stricmp (cmd, "listip") == 0) {		trap_SendConsoleCommand( EXEC_NOW, "g_banIPs/n" );		return qtrue;	}	if (g_dedicated.integer) {		if (Q_stricmp (cmd, "say") == 0) {			trap_SendServerCommand( -1, va("print /"server: %s/n/"", ConcatArgs(1) ) );			return qtrue;		}		// everything else will also be printed as a say command		trap_SendServerCommand( -1, va("print /"server: %s/n/"", ConcatArgs(0) ) );		return qtrue;	}	return qfalse;}
开发者ID:Drakesinger,项目名称:jediacademypc,代码行数:68,


示例27: G_RankRunFrame

/*================G_RankRunFrame================*/void G_RankRunFrame(){	gentity_t*		ent;	gentity_t*		ent2;	grank_status_t	old_status;	grank_status_t	status;	int				time;	int				i;	int				j;	if( !trap_RankCheckInit() ) 	{		trap_RankBegin( GR_GAMEKEY );	}	trap_RankPoll();		if( trap_RankActive() )	{		for( i = 0; i < level.maxclients; i++ )		{			ent = &(g_entities[i]);			if ( !ent->inuse )				continue;			if ( ent->client == NULL )				continue;			if ( ent->r.svFlags & SVF_BOT)			{				// no bots in ranked games				trap_SendConsoleCommand( EXEC_INSERT, va("kick %s/n", 					ent->client->pers.netname) );				continue;			}			old_status = ent->client->client_status;			status = trap_RankUserStatus( i );						if( ent->client->client_status != status )			{				// inform client of current status				// not needed for client side log in				trap_SendServerCommand( i, va("rank_status %i/n",status) );				if ( i == 0 )				{					int j = 0;				}				ent->client->client_status = status;			}						switch( status )			{			case QGR_STATUS_NEW:			case QGR_STATUS_SPECTATOR:				if( ent->client->sess.sessionTeam != TEAM_SPECTATOR )				{					ent->client->sess.sessionTeam = TEAM_SPECTATOR;					ent->client->sess.spectatorState = SPECTATOR_FREE;					ClientSpawn( ent );					// make sure by now CS_GRAND rankingsGameID is ready					trap_SendServerCommand( i, va("rank_status %i/n",status) );					trap_SendServerCommand( i, "rank_menu/n" );				}				break;			case QGR_STATUS_NO_USER:			case QGR_STATUS_BAD_PASSWORD:			case QGR_STATUS_TIMEOUT:			case QGR_STATUS_NO_MEMBERSHIP:			case QGR_STATUS_INVALIDUSER:			case QGR_STATUS_ERROR:				if( (ent->r.svFlags & SVF_BOT) == 0 )				{					trap_RankUserReset( ent->s.clientNum );				}				break;			case QGR_STATUS_ACTIVE:				if( (ent->client->sess.sessionTeam == TEAM_SPECTATOR) &&					(g_gametype.integer < GT_TEAM) )				{					SetTeam( ent, "free" );				}				if( old_status != QGR_STATUS_ACTIVE )				{					// player has just become active					for( j = 0; j < level.maxclients; j++ )					{						ent2 = &(g_entities[j]);						if ( !ent2->inuse )							continue;						if ( ent2->client == NULL )							continue;						if ( ent2->r.svFlags & SVF_BOT)							continue;						if( (i != j) && (trap_RankUserStatus( j ) == QGR_STATUS_ACTIVE) )//.........这里部分代码省略.........
开发者ID:0culus,项目名称:ioq3,代码行数:101,


示例28: G_AddBot

//.........这里部分代码省略.........		s = "4";	}	Info_SetValueForKey( userinfo, key, s );	key = "saber1";	s = Info_ValueForKey( botinfo, key );	if ( !*s ) {		s = "single_1";	}	Info_SetValueForKey( userinfo, key, s );	key = "saber2";	s = Info_ValueForKey( botinfo, key );	if ( !*s ) {		s = "none";	}	Info_SetValueForKey( userinfo, key, s );	s = Info_ValueForKey(botinfo, "personality");	if (!*s )	{		Info_SetValueForKey( userinfo, "personality", "botfiles/default.jkb" );	}	else	{		Info_SetValueForKey( userinfo, "personality", s );	}	// have the server allocate a client slot	clientNum = trap_BotAllocateClient();	if ( clientNum == -1 ) {//		G_Printf( S_COLOR_RED "Unable to add bot.  All player slots are in use./n" );//		G_Printf( S_COLOR_RED "Start server with more 'open' slots./n" );		trap_SendServerCommand( -1, va("print /"%s/n/"", G_GetStringEdString("MP_SVGAME", "UNABLE_TO_ADD_BOT")));		return;	}	// initialize the bot settings	if( !team || !*team ) {		if( g_gametype.integer >= GT_TEAM ) {			if( PickTeam(clientNum) == TEAM_RED) {				team = "red";			}			else {				team = "blue";			}		}		else {			team = "red";		}	}//	Info_SetValueForKey( userinfo, "characterfile", Info_ValueForKey( botinfo, "aifile" ) );	Info_SetValueForKey( userinfo, "skill", va( "%5.2f", skill ) );	Info_SetValueForKey( userinfo, "team", team );	bot = &g_entities[ clientNum ];	bot->r.svFlags |= SVF_BOT;	bot->inuse = qtrue;	// register the userinfo	trap_SetUserinfo( clientNum, userinfo );	if (g_gametype.integer >= GT_TEAM)	{		if (team && Q_stricmp(team, "red") == 0)		{
开发者ID:Mattman1153,项目名称:jedi-academy,代码行数:67,


示例29: G_Script_ScriptParse

//.........这里部分代码省略.........					token = COM_Parse(&pScript);					if (token[0] != '{') {						COM_ParseError("'{' expected, found: %s./n", token);					}					while ((token = COM_Parse(&pScript)) != NULL && (token[0] != '}')) {						if (strlen(params)) {     // add a space between each param							Q_strcat(params, sizeof (params), " ");						}						if (strrchr(token, ' ')) {    // need to wrap this param in quotes since it has more than one word							Q_strcat(params, sizeof (params), "/"");						}						Q_strcat(params, sizeof (params), token);						if (strrchr(token, ' ')) {    // need to wrap this param in quotes since it has mor							Q_strcat(params, sizeof (params), "/"");						}					}				} else				// hackly precaching of custom characters				if (!Q_stricmp(token, "spawnbot")) {					// this is fairly indepth, so I'll move it to a separate function for readability					G_Script_ParseSpawnbot(&pScript, params, MAX_INFO_STRING);				} else {					token = COM_ParseExt(&pScript, qfalse);					for (i = 0; token[0]; ++i) {						if (strlen(params)) {     // add a space between each param							Q_strcat(params, sizeof (params), " ");						}						if (i == 0) {							// Special case: playsound's need to be cached on startup to prevent in-game pauses							if (!Q_stricmp(action->actionString, "playsound")) {								G_SoundIndex(token);							} else if (!Q_stricmp(action->actionString, "changemodel")) {								G_ModelIndex(token);							} else if (buildScript &&							           (!Q_stricmp(action->actionString, "mu_start") ||							            !Q_stricmp(action->actionString, "mu_play") ||							            !Q_stricmp(action->actionString, "mu_queue") ||							            !Q_stricmp(action->actionString, "startcam")) &&							           strlen(token)) {								trap_SendServerCommand(-1, va("addToBuild %s/n", token));							}						}						if ((i == 0 || i == 1) && !Q_stricmp(action->actionString, "remapshader")) {							G_ShaderIndex(token);						}						if (strrchr(token, ' ')) {    // need to wrap this param in quotes since it has more than one word							Q_strcat(params, sizeof (params), "/"");						}						Q_strcat(params, sizeof (params), token);						if (strrchr(token, ' ')) {    // need to wrap this param in quotes since it has more than one word							Q_strcat(params, sizeof (params), "/"");						}						token = COM_ParseExt(&pScript, qfalse);					}				}				if (strlen(params)) {     // copy the params into the event					curEvent->stack.items[curEvent->stack.numItems].params = G_Alloc(strlen(params) + 1);					Q_strncpyz(curEvent->stack.items[curEvent->stack.numItems].params, params, strlen(params) + 1);				}				curEvent->stack.numItems++;				if (curEvent->stack.numItems >= G_MAX_SCRIPT_STACK_ITEMS) {					G_Error("G_Script_ScriptParse(): script exceeded G_MAX_SCRIPT_STACK_ITEMS (%d), line %d/n", G_MAX_SCRIPT_STACK_ITEMS, COM_GetCurrentParseLine());				}			}			numEventItems++;		} else {   // skip this character completely			// TTimo gcc: suggest parentheses around assignment used as truth value			while ((token = COM_Parse(&pScript)) != NULL) {				if (!token[0]) {					G_Error("G_Script_ScriptParse(), Error (line %d): '}' expected, end of script found./n", COM_GetCurrentParseLine());				} else if (token[0] == '{') {					bracketLevel++;				} else if (token[0] == '}' && !--bracketLevel) {					break;				}			}		}	}	// alloc and copy the events into the gentity_t for this cast	if (numEventItems > 0) {		ent->scriptEvents = G_Alloc(sizeof (g_script_event_t) * numEventItems);		memcpy(ent->scriptEvents, events, sizeof (g_script_event_t) * numEventItems);		ent->numScriptEvents = numEventItems;	}}
开发者ID:ETrun,项目名称:ETrun,代码行数:101,


示例30: UpdateTournamentInfo

//.........这里部分代码省略.........	}	if ( winningTeam )	{//one of the teams won		winningCaptures = level.teamScores[winningTeam];		if (winningTeam == TEAM_RED)			loseCaptures = level.teamScores[TEAM_BLUE];		else			loseCaptures = level.teamScores[TEAM_RED];		for (i = 0; i < level.maxclients; i++ )		{			if ( !&g_entities[i] ) continue;			if ( !(&g_entities[i])->client ) continue;			if ( g_entities[i].client->ps.persistant[PERS_TEAM] == winningTeam )				winningPoints += g_entities[i].client->ps.persistant[PERS_SCORE];			else				losePoints += g_entities[i].client->ps.persistant[PERS_SCORE];		}	}	for (i = 0; i < level.maxclients; i++ )	{		player = &g_entities[i];		if ( !player->inuse || (player->r.svFlags & SVF_BOT))		{			continue;		}		playerClientNum = i;		G_Client_CalculateRanks( qfalse );		// put info for the top three players into the msg		Com_sprintf(msg, AWARDS_MSG_LENGTH, "awards %d", level.numNonSpectatorClients);		for( j = 0; j < level.numNonSpectatorClients; j++ )		{			if (j > 2)			{				break;			}			n = level.sortedClients[j];			strcpy(msg2, msg);			Com_sprintf(msg, AWARDS_MSG_LENGTH, "%s %d", msg2, n);		}		// put this guy's awards into the msg		if ( level.clients[playerClientNum].sess.sessionTeam == TEAM_SPECTATOR )		{			strcpy(msg2, msg);			Com_sprintf( msg, sizeof(msg), "%s 0", msg2);		}		// now supply...		//		// 1) winning team's MVP's name		// 2) winning team's MVP's score		// 3) winning team's total captures		// 4) winning team's total points		// 5) this player's rank		// 6) the highest rank for which this player tied		// 7) losing team's total captures		// 8) losing team's total points		// 9) if second place was tied		// 10) intermission point		// 11) intermission angles		//		for (k = 0; k < level.numNonSpectatorClients; k++)		{			if (level.sortedClients[k] == playerClientNum)			{				playerRank = k;				break;			}		}		highestTiedRank = 0;		for (k = playerRank-1; k >= 0; k--)		{			cl = &level.clients[level.sortedClients[k]];			if (cl->ps.persistant[PERS_SCORE] > level.clients[level.sortedClients[playerRank]].ps.persistant[PERS_SCORE])			{				break;			}			highestTiedRank = k+1;		}		strcpy(msg2, msg);		Com_sprintf(msg, AWARDS_MSG_LENGTH, "%s /"%s/" %d %d %d %d %d %d %d %d %f %f %f %f %f %f",			msg2, mvpName, mvpPoints, winningCaptures, winningPoints, playerRank, highestTiedRank,			loseCaptures, losePoints, secondPlaceTied, level.intermission_origin[0], level.intermission_origin[1],			level.intermission_origin[2], level.intermission_angle[0], level.intermission_angle[1],			level.intermission_angle[2]);		trap_SendServerCommand(player-g_entities, msg);	}	if (g_gametype.integer == GT_SINGLE_PLAYER)	{		Com_sprintf( msg, sizeof(msg), "postgame %i", playerRank);		trap_SendConsoleCommand( EXEC_APPEND, msg); 	}}
开发者ID:UberGames,项目名称:RPG-X2-rpgxEF,代码行数:101,



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


C++ trap_SetBrushModel函数代码示例
C++ trap_S_StartSound函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。