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

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

51自学网 2021-06-01 20:11:22
  C++
这篇教程C++ ClientConnect函数代码示例写得很实用,希望能帮到您。

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

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

示例1: switch

void GateModule::handle_message(const message& msg){	switch (msg.get_type())	{	case EMessageType::SocketConnect:	{		ClientConnect(msg);		break;	}	case EMessageType::SocketData:	{		ClientData(msg);		break;	}	case EMessageType::SocketClose:	{		ClientClose(msg);		break;	}	case EMessageType::ActorData:	{		ActorData(msg);		break;	}	case EMessageType::ToClient:	{		ToClientData(msg);		break;	}	}}
开发者ID:dr520,项目名称:moon_net,代码行数:31,


示例2: Client

void Client(char *filename){    int clientSocketDescriptor;    int connectResult;    FILE *rdfile;    rdfile = fopen(filename, "r");    if (rdfile == NULL)    {        puts ("Error while opening file.");        return;    }    clientSocketDescriptor = StartClient("tcp");    connectResult = ClientConnect(clientSocketDescriptor, "127.0.0.1", 6660);    if (connectResult == -1)    {        return;    }    if (SendFileName(clientSocketDescriptor, filename) == -1)    {        return;    }    if (SendFileSize(clientSocketDescriptor, rdfile) == -1)    {        return;    }    ClientProcess(clientSocketDescriptor, rdfile);    ShutdownSocket(clientSocketDescriptor);    CloseSocket(clientSocketDescriptor);    fclose(rdfile);    return;}
开发者ID:spolks-2013-2014-sem1,项目名称:050501_alexandrow,代码行数:33,


示例3: SSL_library_load

SslHandle *NetlibSslConnect(SOCKET s, const char* host, int verify){	/* negotiate SSL session, verify cert, return NULL if failed */	bool res = SSL_library_load();	if (!res)		return NULL;		SslHandle *ssl = (SslHandle*)mir_calloc(sizeof(SslHandle));	ssl->s = s;	res = ClientConnect(ssl, host);	if (res && verify) {		DWORD dwFlags = 0;		if (!host || inet_addr(host) != INADDR_NONE)			dwFlags |= 0x00001000;		res = VerifyCertificate(ssl, host, dwFlags);	}	if(res) {		return ssl;	}	else {		NetlibSslFree(ssl);		return NULL;	}}
开发者ID:kmdtukl,项目名称:miranda-ng,代码行数:26,


示例4: BOT_SpawnBot

///////////////////////////////////////////////////////////////////////// Spawn the bot///////////////////////////////////////////////////////////////////////void BOT_SpawnBot (char *team, char *name, char *skin, char *userinfo){	edict_t	*bot;	if( !nav.loaded ) {		Com_Printf("Can't spawn bots without a valid navigation file/n");		return;	}		bot = BOT_FindFreeClient ();		if (!bot)	{		safe_bprintf (PRINT_MEDIUM, "Server is full, increase Maxclients./n");		return;	}	//init the bot	bot->inuse = true;	bot->yaw_speed = 100;	// To allow bots to respawn	if(userinfo == NULL)		BOT_SetName(bot, name, skin, team);	else		ClientConnect (bot, userinfo);		G_InitEdict (bot);	G_SpawnAI(bot); //jabot092(2)	bot->ai->is_bot = true;	InitClientResp (bot->client);	PutClientInServer(bot);	BOT_StartAsSpectator (bot);	//skill	bot->ai->pers.skillLevel = (int)(random()*MAX_BOT_SKILL);	if (bot->ai->pers.skillLevel > MAX_BOT_SKILL)	//fix if off-limits		bot->ai->pers.skillLevel =  MAX_BOT_SKILL;	else if (bot->ai->pers.skillLevel < 0)		bot->ai->pers.skillLevel =  0;	BOT_DMclass_InitPersistant(bot);	AI_ResetWeights(bot);	AI_ResetNavigation(bot);	bot->think = BOT_JoinGame;	bot->nextthink = level.time + (int)(random()*6.0);	if( ctf->value && team != NULL )	{		if( !Q_stricmp( team, "blue" ) )			bot->think = BOT_JoinBlue;		else if( !Q_stricmp( team, "red" ) )			bot->think = BOT_JoinRed;	}		AI_EnemyAdded (bot); // let the ai know we added another}
开发者ID:ZwS,项目名称:qudos,代码行数:61,


示例5: My_ClientConnect

char* __cdecl My_ClientConnect(int clientNum, qboolean firstTime, qboolean isBot) {	if (firstTime) {		char* res = ClientConnectDispatcher(clientNum, isBot);		if (res && !isBot) {			return res;		}	}	return ClientConnect(clientNum, firstTime, isBot);}
开发者ID:PerpetualWar,项目名称:minqlx,代码行数:10,


示例6: baseq3_qagame_vmMain

int baseq3_qagame_vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11  ) {#elseint vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11  ) {#endif // IOS	switch ( command ) {	case GAME_INIT:		G_InitGame( arg0, arg1, arg2 );		return 0;	case GAME_SHUTDOWN:		G_ShutdownGame( arg0 );		return 0;	case GAME_CLIENT_CONNECT:		return (int)ClientConnect( arg0, arg1, arg2 );	case GAME_CLIENT_THINK:		ClientThink( arg0 );		return 0;	case GAME_CLIENT_USERINFO_CHANGED:		ClientUserinfoChanged( arg0 );		return 0;	case GAME_CLIENT_DISCONNECT:		ClientDisconnect( arg0 );		return 0;	case GAME_CLIENT_BEGIN:		ClientBegin( arg0 );		return 0;	case GAME_CLIENT_COMMAND:		ClientCommand( arg0 );		return 0;	case GAME_RUN_FRAME:		G_RunFrame( arg0 );		return 0;	case GAME_CONSOLE_COMMAND:		return ConsoleCommand();	case BOTAI_START_FRAME:		return BotAIStartFrame( arg0 );	}	return -1;}void QDECL G_Printf( const char *fmt, ... ) {	va_list		argptr;	char		text[1024];	va_start (argptr, fmt);	vsprintf (text, fmt, argptr);	va_end (argptr);	trap_Printf( text );}
开发者ID:he110world,项目名称:quake3-ios,代码行数:51,


示例7: Info_SetValueForKey

//----(SA) modified this for head separationgentity_t *AICast_AddCastToGame( gentity_t *ent, char *castname, char *model, char *head, char *sex, char *color, char *handicap ){	int clientNum;	gentity_t *bot;	char	userinfo[MAX_INFO_STRING];	usercmd_t		cmd;	// create the bot's userinfo	userinfo[0] = '/0';	Info_SetValueForKey( userinfo, "name", castname );	Info_SetValueForKey( userinfo, "rate", "25000" );	Info_SetValueForKey( userinfo, "snaps", "20" );	Info_SetValueForKey( userinfo, "handicap", handicap );	Info_SetValueForKey( userinfo, "model", model );	Info_SetValueForKey( userinfo, "head", head );	Info_SetValueForKey( userinfo, "color", color );	// have the server allocate a client slot	clientNum = trap_BotAllocateClient();	if ( clientNum == -1 ) {		G_Printf( S_COLOR_RED "BotAllocateClient failed/n" );		return NULL;	}	bot = &g_entities[ clientNum ];	bot->r.svFlags |= SVF_BOT;	bot->r.svFlags |= SVF_CASTAI;		// flag it for special Cast AI behaviour	// register the userinfo	trap_SetUserinfo( bot->s.number, userinfo );	// have it connect to the game as a normal client//----(SA) ClientConnect requires a third 'isbot' parameter.  setting to qfalse and noting	ClientConnect( bot->s.number, qtrue, qfalse );//----(SA) end	// copy the origin/angles across	VectorCopy( ent->s.origin, bot->s.origin );	VectorCopy( ent->s.angles, bot->s.angles );	memset( &cmd, 0, sizeof( cmd ) );	ClientBegin( bot->s.number );	// set up the ai	AICast_SetupClient( bot->s.number );	return bot;}
开发者ID:natelo,项目名称:rtcwPub,代码行数:49,


示例8: SocketConnect

void SocketConnect(char *argv[]){	nPort = atoi(argv[1]);	nSocketDesc = socket(AF_INET,SOCK_STREAM,0);	serv.sin_family = AF_INET;	serv.sin_addr.s_addr = INADDR_ANY;	serv.sin_port = htons(nPort);	bind(nSocketDesc,(struct sockaddr *)&serv,sizeof(serv));	listen(nSocketDesc,5);	printf("/n===========================/n");	printf("Waiting for connection/n");	printf("===========================/n/n");		ClientConnect();	close(nSocketDesc);}
开发者ID:prashantnair240255,项目名称:dms,代码行数:16,


示例9: while

void ServerNetwork::newConnection() {	while (server->hasPendingConnections()) {		QTcpSocket *socket = server->nextPendingConnection();		s32 clientId = clientManager->AddClient(socket);		emit ClientConnect(clientId);		connect(socket, SIGNAL(readyRead()), SLOT(readyRead()));		connect(socket, SIGNAL(disconnected()), SLOT(disconnected()));		QByteArray *buffer = new QByteArray();		buffers.insert(socket, buffer);		qDebug().nospace() << "Connected:    Instrument #" << clientId << " at " << qPrintable(socket->peerAddress().toString()) << ":" << socket->peerPort();	}}
开发者ID:manpat,项目名称:netsynth,代码行数:16,


示例10: ACESP_SpawnBot

///////////////////////////////////////////////////////////////////////// Spawn the bot///////////////////////////////////////////////////////////////////////void ACESP_SpawnBot (char *team, char *name, char *skin, char *userinfo){	edict_t	*bot;		bot = ACESP_FindFreeClient ();		if (!bot)	{		safe_bprintf (PRINT_MEDIUM, "Server is full, increase Maxclients./n");		return;	}	bot->yaw_speed = 100; // yaw speed	bot->inuse = true;	bot->is_bot = true;	// To allow bots to respawn	if(userinfo == NULL)		ACESP_SetName(bot, name, skin, team);	else		ClientConnect (bot, userinfo);		G_InitEdict (bot);	InitClientResp (bot->client);		// locate ent at a spawn point    /*if(ctf->value)	{		if (team != NULL && strcmp(team,"red")==0)			ACESP_PutClientInServer (bot,false, CTF_TEAM1);		else			ACESP_PutClientInServer (bot,false, CTF_TEAM2);	}	else*/ 		ACESP_PutClientInServer (bot,false,0);	// make sure all view stuff is valid	ClientEndServerFrame (bot);		ACEIT_PlayerAdded (bot); // let the world know we added another	ACEAI_PickLongRangeGoal(bot); // pick a new goal}
开发者ID:ZwS,项目名称:qudos,代码行数:48,


示例11: while

void ServerSystem::Update( double DeltaTime ){    PerfTimer.Log( "server update started" );    ENetEvent event;    while( enet_host_service ( mServer, & event, 0 ) > 0 )    {        //PerfTimer.Log("server enter");        switch ( event.type )        {        case ENET_EVENT_TYPE_CONNECT:            ClientConnect( event );            break;        case ENET_EVENT_TYPE_RECEIVE:            Receive( event );            break;        case ENET_EVENT_TYPE_DISCONNECT:            ClientDisconnect( event );            break;        }    }    PerfTimer.Log( "server receive ended" );    MessageList& messages = mMessageHolder.GetOutgoingMessages();    if ( messages.mMessages.size() > 0 )    {        std::ostringstream oss;        eos::portable_oarchive oa( oss );        oa& messages;        std::string astr( oss.str() );        // L1("server sends - %s:/n",astr.c_str());        ENetPacket* packet = enet_packet_create ( astr.c_str(),                             astr.size(),                             ENET_PACKET_FLAG_RELIABLE );        mSentMessagesSize += packet->dataLength * mClients.size();        enet_host_broadcast( mServer, 0, packet );        enet_host_flush( mServer );        mMessageHolder.ClearOutgoingMessages();    }    PerfTimer.Log( "server update ended" );}
开发者ID:HalalUr,项目名称:Reaping2,代码行数:43,


示例12: NetlibSslConnect

SslHandle* NetlibSslConnect(SOCKET s, const char* host, int verify){	SslHandle *ssl = (SslHandle*)mir_calloc(sizeof(SslHandle));	ssl->s = s;	SecInvalidateHandle(&ssl->hContext);	DWORD dwFlags = 0;	if (!host || inet_addr(host) != INADDR_NONE)		dwFlags |= 0x00001000;	bool res = SSL_library_init();	if (res) res = ClientConnect(ssl, host);	if (res && verify) res = VerifyCertificate(ssl, host, dwFlags);	if (!res) {		NetlibSslFree(ssl);		ssl = NULL;	}	return ssl;}
开发者ID:truefriend-cz,项目名称:miranda-ng,代码行数:23,


示例13: vmMain

/*================vmMainThis is the only way control passes into the module.This must be the very first function compiled into the .q3vm file================*/Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11  ) {	switch ( command ) {	case GAME_INIT:		G_InitGame( arg0, arg1, arg2 );		return 0;	case GAME_SHUTDOWN:		G_ShutdownGame( arg0 );		return 0;	case GAME_CLIENT_CONNECT:		return (intptr_t)ClientConnect( arg0, arg1, arg2 );	case GAME_CLIENT_THINK:		ClientThink( arg0 );		return 0;	case GAME_CLIENT_USERINFO_CHANGED:		ClientUserinfoChanged( arg0 );		return 0;	case GAME_CLIENT_DISCONNECT:		ClientDisconnect( arg0 );		return 0;	case GAME_CLIENT_BEGIN:		ClientBegin( arg0 );		return 0;	case GAME_CLIENT_COMMAND:		ClientCommand( arg0 );		return 0;	case GAME_RUN_FRAME:		G_RunFrame( arg0 );		return 0;	case GAME_CONSOLE_COMMAND:		return ConsoleCommand();	case BOTAI_START_FRAME:		return BotAIStartFrame( arg0 );	}	return -1;}
开发者ID:CarlGammaSagan,项目名称:Quake-3-Android-Port-QIII4A,代码行数:44,


示例14: G_AddBot

//.........这里部分代码省略.........		Info_SetValueForKey( userinfo, "pWeapon", va("%i", playerWeapon) );	}*/	// END Mad Doc - TDF	key = "wolfbot";	if (!Q_stricmp( (char *)name, key )) {		// read the botnames file, and pick a name that doesnt exist		fileHandle_t f;		int len, i, j, k;		qboolean setname = qfalse;		char botnames[8192], *pbotnames, *listbotnames[MAX_BOTNAMES], *token, *oldpbotnames;		int	lengthbotnames[MAX_BOTNAMES];		len = trap_FS_FOpenFile( "botfiles/botnames.txt", &f, FS_READ );		if (len >= 0) {			if (len > sizeof(botnames)) {				G_Error( "botfiles/botnames.txt is too big (max = %i)", (int)sizeof(botnames) );			}			memset( botnames, 0, sizeof(botnames) );			trap_FS_Read( botnames, len, f );			pbotnames = botnames;			// read them in			i = 0;			oldpbotnames = pbotnames;			while ((token = COM_Parse( &pbotnames ))) {				if (!token[0]) break;				listbotnames[i] = strstr( oldpbotnames, token );				lengthbotnames[i] = strlen(token);				listbotnames[i][lengthbotnames[i]] = 0;				oldpbotnames = pbotnames;				if (++i == MAX_BOTNAMES) break;			}			//			if (i > 2) {				j = rand() % (i-1);	// start at a random spot inthe list				for( k = j + 1; k != j; k++ ) {					if( k == i ) {						k = -1;	// gets increased on next loop						continue;					}					if (ClientFromName( listbotnames[k] ) == -1) {						// found an unused name						Info_SetValueForKey( userinfo, "name", listbotnames[k]  );						setname = qtrue;						break;					}				}			}			//			trap_FS_FCloseFile( f );		}		if (!setname) {			Info_SetValueForKey( userinfo, "name", va("wolfbot_%i", clientNum+1)  );		}	} else {		Info_SetValueForKey( userinfo, "name", name );	}	// if a character was specified, put the index of that character filename in the CS_CHARACTERS table in the userinfo	if( characerIndex != -1 ) {		Info_SetValueForKey( userinfo, "ch", va( "%i", characerIndex ) );	}	// if a rank was specified, use that/*	if (rank != -1) {		Info_SetValueForKey(userinfo, "rank", va("%i", rank));	}*/	// END Mad Doc - TDF		bot = &g_entities[ clientNum ];	bot->r.svFlags |= SVF_BOT;	if( pow ) {		bot->r.svFlags |= SVF_POW;	}	bot->inuse = qtrue;	bot->aiName = bot->client->pers.netname;	// register the userinfo	trap_SetUserinfo( clientNum, userinfo );	// have it connect to the game as a normal client	if ((s = ClientConnect( clientNum, qtrue, qtrue ))) {		G_Printf( S_COLOR_RED "Unable to add bot: %s/n", s );		return;	}	SetTeam( bot, (char *)team, qtrue, -1, -1, qfalse );/*	if( skills ) {		int i;				for( i = 0; i < SK_NUM_SKILLS; i++ ) {			bot->client->sess.skill[i] = skills[i];		}	}*/	return;}
开发者ID:GenaSG,项目名称:ET,代码行数:101,


示例15: G_AddBot

//.........这里部分代码省略.........	if ( skill >= 1 && skill < 2 ) {		Info_SetValueForKey( userinfo, "handicap", "50" );	}	else if ( skill >= 2 && skill < 3 ) {		Info_SetValueForKey( userinfo, "handicap", "70" );	}	else if ( skill >= 3 && skill < 4 ) {		Info_SetValueForKey( userinfo, "handicap", "90" );	}	key = "model";	model = Info_ValueForKey( botinfo, key );	if ( !*model ) {		model = "sarge/default";	}	Info_SetValueForKey( userinfo, key, model );	key = "team_model";	Info_SetValueForKey( userinfo, key, model );	key = "headmodel";	headmodel = Info_ValueForKey( botinfo, key );	if ( !*headmodel ) {		headmodel = model;	}	Info_SetValueForKey( userinfo, key, headmodel );	key = "team_headmodel";	Info_SetValueForKey( userinfo, key, headmodel );	key = "gender";	s = Info_ValueForKey( botinfo, key );	if ( !*s ) {		s = "male";	}	Info_SetValueForKey( userinfo, "sex", s );	key = "color1";	s = Info_ValueForKey( botinfo, key );	if ( !*s ) {		s = "4";	}	Info_SetValueForKey( userinfo, key, s );	key = "color2";	s = Info_ValueForKey( botinfo, key );	if ( !*s ) {		s = "5";	}	Info_SetValueForKey( userinfo, key, s );	s = Info_ValueForKey(botinfo, "aifile");	if (!*s ) {		trap_Printf( S_COLOR_RED "Error: bot has no aifile specified/n" );		return;	}	// 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 (or check setting of sv_maxclients cvar)./n" );                return;	}	// initialize the bot settings	if( !team || !*team ) {		if( g_gametype.integer >= GT_TEAM && g_ffa_gt!=1) {			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 );	// have it connect to the game as a normal client	if ( ClientConnect( clientNum, qtrue, qtrue ) ) {		return;	}	if( delay == 0 ) {		ClientBegin( clientNum );		return;	}	AddBotToSpawnQueue( clientNum, delay );}
开发者ID:OpenArena,项目名称:leixperimental,代码行数:101,


示例16: G_AddBot

//.........这里部分代码省略.........		// Elder: changed to our default		model = "reactionmale/default";	}	Info_SetValueForKey(userinfo, "model", model);	Info_SetValueForKey(userinfo, "team_model", model);	headmodel = Info_ValueForKey(botinfo, "headmodel");	if (!*headmodel) {		headmodel = model;	}	Info_SetValueForKey(userinfo, "headmodel", headmodel);	Info_SetValueForKey(userinfo, "team_headmodel", headmodel);	s = Info_ValueForKey(botinfo, "gender");	if (!*s) {		s = "male";	}	Info_SetValueForKey(userinfo, "sex", s);	s = Info_ValueForKey(botinfo, "color1");	if (!*s) {		s = "4";	}	Info_SetValueForKey(userinfo, "color1", s);	s = Info_ValueForKey(botinfo, "color2");	if (!*s) {		s = "5";	}	Info_SetValueForKey(userinfo, "color2", s);	s = Info_ValueForKey(botinfo, "aifile");	if (!*s) {		trap_Printf(S_COLOR_RED "Error: bot has no aifile specified/n");		return;	}	// 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 (or check setting of sv_maxclients cvar)./n");		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);	if (g_gametype.integer == GT_TEAMPLAY) {		//Makro - load custom weapon/item from bot file		tpWeapon = CharToWeapon(Info_ValueForKey(botinfo, "weapon"), WP_M4);		tpItem = CharToItem(Info_ValueForKey(botinfo, "item"), HI_LASER);	}	Info_SetValueForKey(userinfo, "tpw", va("%i", tpWeapon - WP_NONE));	Info_SetValueForKey(userinfo, "tpi", va("%i", tpItem - HI_NONE));	bot = &g_entities[clientNum];	bot->r.svFlags |= SVF_BOT;	bot->inuse = qtrue;	// register the userinfo	trap_SetUserinfo(clientNum, userinfo);	// have it connect to the game as a normal client	if (ClientConnect(clientNum, qtrue, qtrue)) {		return;	}	if (delay == 0) {		ClientBegin(clientNum);		//Makro - load custom weapon/item from bot file		if (g_gametype.integer == GT_TEAMPLAY) {			bot->client->teamplayWeapon = tpWeapon;			bot->client->teamplayItem = tpItem;		}		return;	}	AddBotToSpawnQueue(clientNum, delay);	//Makro - load custom weapon/item from bot file	if (g_gametype.integer == GT_TEAMPLAY) {		bot->client->teamplayWeapon = tpWeapon;		bot->client->teamplayItem = tpItem;	}}
开发者ID:titityy,项目名称:reaction,代码行数:101,


示例17: vmMain

int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5,            int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ){    ClearGlobals();    switch ( command )    {    case GAME_INIT:        api_ver = trap_GetApiVersion();        if ( api_ver < MIN_API_VERSION )        {            G_conprintf("Mod requried API_VERSION %d or higher, server have %d/n", MIN_API_VERSION, api_ver);            return 0;        }        if( api_ver >= MIN_API_VERSION && api_ver <= GAME_API_VERSION )        {            gamedata.APIversion = api_ver;        }        G_InitGame( arg0, arg1 );        return ( int ) ( &gamedata );    case GAME_LOADENTS:        G_SpawnEntitiesFromString();        return 1;    case GAME_START_FRAME:        StartFrame( arg0 );        return 1;    case GAME_CLIENT_CONNECT:        self = PROG_TO_EDICT( g_globalvars.self );        self->auth_time = g_globalvars.time + 10.0;        self->isSpectator = arg0?1:0;        if ( arg0 )            SpectatorConnect();        else            ClientConnect();        return 1;    case GAME_PUT_CLIENT_IN_SERVER:        self = PROG_TO_EDICT( g_globalvars.self );        if ( !arg0 )            PutClientInServer();        return 1;    case GAME_CLIENT_DISCONNECT:        self = PROG_TO_EDICT( g_globalvars.self );        if ( arg0 )            SpectatorDisconnect();        else            ClientDisconnect();        return 1;    case GAME_SETNEWPARMS:        SetNewParms();        return 1;    case GAME_CLIENT_PRETHINK:        self = PROG_TO_EDICT( g_globalvars.self );        if ( !arg0 )            PlayerPreThink();        return 1;    case GAME_CLIENT_POSTTHINK:        self = PROG_TO_EDICT( g_globalvars.self );        if ( !arg0 )            PlayerPostThink();        else            SpectatorThink();        return 1;    case GAME_EDICT_TOUCH:        G_EdictTouch();        return 1;    case GAME_EDICT_THINK:        G_EdictThink();        return 1;    case GAME_EDICT_BLOCKED:        G_EdictBlocked();        return 1;    case GAME_SETCHANGEPARMS: //called before spawn new server for save client params        self = PROG_TO_EDICT( g_globalvars.self );        SetChangeParms();        return 1;    case GAME_CLIENT_COMMAND:        self = PROG_TO_EDICT( g_globalvars.self );        return ClientCommand();    case GAME_CLIENT_USERINFO_CHANGED:        // called on user /cmd setinfo	if value changed        // return not zero dont allow change        // params like GAME_CLIENT_COMMAND, but argv(0) always "setinfo" and argc always 3        self = PROG_TO_EDICT( g_globalvars.self );        return ClientUserInfoChanged();    case GAME_SHUTDOWN://.........这里部分代码省略.........
开发者ID:angeld29,项目名称:TF2003-qvm,代码行数:101,


示例18: G_AddBot

//.........这里部分代码省略.........	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)		{			bot->client->sess.sessionTeam = TEAM_RED;		}		else if (team && Q_stricmp(team, "blue") == 0)		{			bot->client->sess.sessionTeam = TEAM_BLUE;		}		else		{			bot->client->sess.sessionTeam = PickTeam( -1 );		}	}	if (g_gametype.integer == GT_SIEGE)	{		bot->client->sess.siegeDesiredTeam = bot->client->sess.sessionTeam;		bot->client->sess.sessionTeam = TEAM_SPECTATOR;	}	preTeam = bot->client->sess.sessionTeam;	// have it connect to the game as a normal client	if ( ClientConnect( clientNum, qtrue, qtrue ) ) {		return;	}	if (bot->client->sess.sessionTeam != preTeam)	{		trap_GetUserinfo(clientNum, userinfo, MAX_INFO_STRING);		if (bot->client->sess.sessionTeam == TEAM_SPECTATOR)		{			bot->client->sess.sessionTeam = preTeam;		}		if (bot->client->sess.sessionTeam == TEAM_RED)		{			team = "Red";		}		else		{			if (g_gametype.integer == GT_SIEGE)			{				if (bot->client->sess.sessionTeam == TEAM_BLUE)				{					team = "Blue";				}				else				{					team = "s";				}			}			else			{				team = "Blue";
开发者ID:Mattman1153,项目名称:jedi-academy,代码行数:67,


示例19: G_AddBot

//.........这里部分代码省略.........	if ( !team || !*team ) {		if ( level.gametype >= GT_TEAM ) {			if ( PickTeam( clientNum ) == TEAM_RED)				team = "red";			else				team = "blue";		}		else			team = "red";	}	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 ( level.gametype >= GT_TEAM )	{		if ( team && !Q_stricmp( team, "red" ) )			bot->client->sess.sessionTeam = TEAM_RED;		else if ( team && !Q_stricmp( team, "blue" ) )			bot->client->sess.sessionTeam = TEAM_BLUE;		else			bot->client->sess.sessionTeam = PickTeam( -1 );	}	if ( level.gametype == GT_SIEGE )	{		bot->client->sess.siegeDesiredTeam = bot->client->sess.sessionTeam;		bot->client->sess.sessionTeam = TEAM_SPECTATOR;	}	preTeam = bot->client->sess.sessionTeam;	// have it connect to the game as a normal client	if ( ClientConnect( clientNum, qtrue, qtrue ) )		return;	if ( bot->client->sess.sessionTeam != preTeam )	{		trap->GetUserinfo( clientNum, userinfo, sizeof( userinfo ) );		if ( bot->client->sess.sessionTeam == TEAM_SPECTATOR )			bot->client->sess.sessionTeam = preTeam;		if ( bot->client->sess.sessionTeam == TEAM_RED )			team = "Red";		else		{			if ( level.gametype == GT_SIEGE )				team = (bot->client->sess.sessionTeam == TEAM_BLUE) ? "Blue" : "s";			else				team = "Blue";		}		Info_SetValueForKey( userinfo, "team", team );		trap->SetUserinfo( clientNum, userinfo );		bot->client->ps.persistant[ PERS_TEAM ] = bot->client->sess.sessionTeam;		G_ReadSessionData( bot->client );		if ( !ClientUserinfoChanged( clientNum ) )			return;	}	if (level.gametype == GT_DUEL ||		level.gametype == GT_POWERDUEL)	{		int loners = 0;		int doubles = 0;		bot->client->sess.duelTeam = 0;		G_PowerDuelCount(&loners, &doubles, qtrue);		if (!doubles || loners > (doubles/2))		{            bot->client->sess.duelTeam = DUELTEAM_DOUBLE;		}		else		{            bot->client->sess.duelTeam = DUELTEAM_LONE;		}		bot->client->sess.sessionTeam = TEAM_SPECTATOR;		SetTeam(bot, "s");	}	else	{		if( delay == 0 ) {			ClientBegin( clientNum, qfalse );			return;		}		AddBotToSpawnQueue( clientNum, delay );	}}
开发者ID:Rhamill7,项目名称:OpenJK,代码行数:101,


示例20: switch

void VM::VMHandleSyscall(uint32_t id, Util::Reader reader) {	int major = id >> 16;	int minor = id & 0xffff;	if (major == VM::QVM) {		switch (minor) {		case GAME_STATIC_INIT:			IPC::HandleMsg<GameStaticInitMsg>(VM::rootChannel, std::move(reader), [] (int milliseconds) {				VM::InitializeProxies(milliseconds);				FS::Initialize();				VM::VMInit();			});			break;		case GAME_INIT:			IPC::HandleMsg<GameInitMsg>(VM::rootChannel, std::move(reader), [](int levelTime, int randomSeed, bool cheats, bool inClient) {				g_cheats.integer = cheats;				G_InitGame(levelTime, randomSeed, inClient);			});			break;		case GAME_SHUTDOWN:			IPC::HandleMsg<GameShutdownMsg>(VM::rootChannel, std::move(reader), [](bool restart) {				G_ShutdownGame(restart);			});			break;		case GAME_CLIENT_CONNECT:			IPC::HandleMsg<GameClientConnectMsg>(VM::rootChannel, std::move(reader), [](int clientNum, bool firstTime, int isBot, bool& denied, std::string& reason) {				const char* deniedStr = isBot ? ClientBotConnect(clientNum, firstTime, TEAM_NONE) : ClientConnect(clientNum, firstTime);				denied = deniedStr != nullptr;				if (denied)					reason = deniedStr;			});			break;		case GAME_CLIENT_THINK:			IPC::HandleMsg<GameClientThinkMsg>(VM::rootChannel, std::move(reader), [](int clientNum) {				ClientThink(clientNum);			});			break;		case GAME_CLIENT_USERINFO_CHANGED:			IPC::HandleMsg<GameClientUserinfoChangedMsg>(VM::rootChannel, std::move(reader), [](int clientNum) {				ClientUserinfoChanged(clientNum, false);			});			break;		case GAME_CLIENT_DISCONNECT:			IPC::HandleMsg<GameClientDisconnectMsg>(VM::rootChannel, std::move(reader), [](int clientNum) {				ClientDisconnect(clientNum);			});			break;		case GAME_CLIENT_BEGIN:			IPC::HandleMsg<GameClientBeginMsg>(VM::rootChannel, std::move(reader), [](int clientNum) {				ClientBegin(clientNum);			});			break;		case GAME_CLIENT_COMMAND:			IPC::HandleMsg<GameClientCommandMsg>(VM::rootChannel, std::move(reader), [](int clientNum, std::string command) {				Cmd::PushArgs(command);				ClientCommand(clientNum);				Cmd::PopArgs();			});			break;		case GAME_RUN_FRAME:			IPC::HandleMsg<GameRunFrameMsg>(VM::rootChannel, std::move(reader), [](int levelTime) {				G_RunFrame(levelTime);			});			break;		case GAME_SNAPSHOT_CALLBACK:			G_Error("GAME_SNAPSHOT_CALLBACK not implemented");			break;		case BOTAI_START_FRAME:			G_Error("BOTAI_START_FRAME not implemented");			break;		case GAME_MESSAGERECEIVED:			G_Error("GAME_MESSAGERECEIVED not implemented");			break;		default:			G_Error("VMMain(): unknown game command %i", minor);		}	} else if (major < VM::LAST_COMMON_SYSCALL) {		VM::HandleCommonSyscall(major, minor, std::move(reader), VM::rootChannel);	} else {		G_Error("unhandled VM major syscall number %i", major);	}}
开发者ID:RamchandraApte,项目名称:Unvanquished,代码行数:95,


示例21: BOT_SetName

///////////////////////////////////////////////////////////////////////// Set the name of the bot and update the userinfo///////////////////////////////////////////////////////////////////////void BOT_SetName(edict_t *bot, char *name, char *skin, char *team){	char userinfo[MAX_INFO_STRING];	char bot_skin[MAX_INFO_STRING];	char bot_name[MAX_INFO_STRING];	// Set the name for the bot.	// name	if(strlen(name) == 0)		sprintf(bot_name,"Bot%d",bot->count);	else		strcpy(bot_name,name);	// skin	/*if(strlen(skin) == 0)	{		// randomly choose skin 		rnd = random();		if(rnd  < 0.05)			sprintf(bot_skin,"female/athena");		else if(rnd < 0.1)			sprintf(bot_skin,"female/brianna");		else if(rnd < 0.15)			sprintf(bot_skin,"female/cobalt");		else if(rnd < 0.2)			sprintf(bot_skin,"female/ensign");		else if(rnd < 0.25)			sprintf(bot_skin,"female/jezebel");		else if(rnd < 0.3)			sprintf(bot_skin,"female/jungle");		else if(rnd < 0.35)			sprintf(bot_skin,"female/lotus");		else if(rnd < 0.4)			sprintf(bot_skin,"female/stiletto");		else if(rnd < 0.45)			sprintf(bot_skin,"female/venus");		else if(rnd < 0.5)			sprintf(bot_skin,"female/voodoo");		else if(rnd < 0.55)			sprintf(bot_skin,"male/cipher");		else if(rnd < 0.6)			sprintf(bot_skin,"male/flak");		else if(rnd < 0.65)			sprintf(bot_skin,"male/grunt");		else if(rnd < 0.7)			sprintf(bot_skin,"male/howitzer");		else if(rnd < 0.75)			sprintf(bot_skin,"male/major");		else if(rnd < 0.8)			sprintf(bot_skin,"male/nightops");		else if(rnd < 0.85)			sprintf(bot_skin,"male/pointman");		else if(rnd < 0.9)			sprintf(bot_skin,"male/psycho");		else if(rnd < 0.95)			sprintf(bot_skin,"male/razor");		else 			sprintf(bot_skin,"male/sniper");	}	else		strcpy(bot_skin,skin);*/	// initialise userinfo	memset (userinfo, 0, sizeof(userinfo));	// add bot's name/skin/hand to userinfo	Info_SetValueForKey (userinfo, "name", bot_name);	Info_SetValueForKey (userinfo, "skin", bot_skin);	Info_SetValueForKey (userinfo, "hand", "2"); // bot is center handed for now!	ClientConnect (bot, userinfo);//	ACESP_SaveBots(); // make sure to save the bots}
开发者ID:zardoru,项目名称:vrxcl,代码行数:77,


示例22: switch

void IncomingDataParser::Parse(const pb::remote::Message& msg) {  close_connection_ = false;  RemoteClient* client = qobject_cast<RemoteClient*>(sender());  // Now check what's to do  switch (msg.type()) {    case pb::remote::CONNECT:      ClientConnect(msg);      break;    case pb::remote::DISCONNECT:      close_connection_ = true;      break;    case pb::remote::REQUEST_PLAYLISTS:      SendPlaylists(msg);      break;    case pb::remote::REQUEST_PLAYLIST_SONGS:      GetPlaylistSongs(msg);      break;    case pb::remote::SET_VOLUME:      emit SetVolume(msg.request_set_volume().volume());      break;    case pb::remote::PLAY:      emit Play();      break;    case pb::remote::PLAYPAUSE:      emit PlayPause();      break;    case pb::remote::PAUSE:      emit Pause();      break;    case pb::remote::STOP:      emit Stop();      break;    case pb::remote::STOP_AFTER:      emit StopAfterCurrent();      break;    case pb::remote::NEXT:      emit Next();      break;    case pb::remote::PREVIOUS:      emit Previous();      break;    case pb::remote::CHANGE_SONG:      ChangeSong(msg);      break;    case pb::remote::SHUFFLE_PLAYLIST:      emit ShuffleCurrent();      break;    case pb::remote::REPEAT:      SetRepeatMode(msg.repeat());      break;    case pb::remote::SHUFFLE:      SetShuffleMode(msg.shuffle());      break;    case pb::remote::SET_TRACK_POSITION:      emit SeekTo(msg.request_set_track_position().position());      break;    case pb::remote::INSERT_URLS:      InsertUrls(msg);      break;    case pb::remote::REMOVE_SONGS:      RemoveSongs(msg);      break;    case pb::remote::OPEN_PLAYLIST:      OpenPlaylist(msg);      break;    case pb::remote::CLOSE_PLAYLIST:      ClosePlaylist(msg);      break;    case pb::remote::LOVE:      emit Love();      break;    case pb::remote::BAN:      emit Ban();      break;    case pb::remote::GET_LYRICS:      emit GetLyrics();      break;    case pb::remote::DOWNLOAD_SONGS:      emit SendSongs(msg.request_download_songs(), client);      break;    case pb::remote::SONG_OFFER_RESPONSE:      emit ResponseSongOffer(client, msg.response_song_offer().accepted());      break;    case pb::remote::GET_LIBRARY:      emit SendLibrary(client);      break;    case pb::remote::RATE_SONG:      RateSong(msg);      break;    default:      break;  }}
开发者ID:Gu1,项目名称:Clementine,代码行数:95,


示例23: G_AddBot

//.........这里部分代码省略.........		if ( botinfoNum < 0 ) {			G_Printf( S_COLOR_RED "Error: Cannot add random bot, no bot info available./n" );			trap_BotFreeClient( clientNum );			return;		}		botinfo = G_GetBotInfoByNumber( botinfoNum );	}	else {		botinfo = G_GetBotInfoByName( name );	}	if ( !botinfo ) {		G_Printf( S_COLOR_RED "Error: Bot '%s' not defined/n", name );		trap_BotFreeClient( clientNum );		return;	}	// create the bot's userinfo	userinfo[0] = '/0';	botname = Info_ValueForKey( botinfo, "funname" );	if( !botname[0] ) {		botname = Info_ValueForKey( botinfo, "name" );	}	// check for an alternative name	if (altname && altname[0]) {		botname = altname;	}	Info_SetValueForKey( userinfo, "name", botname );	Info_SetValueForKey( userinfo, "rate", "25000" );	Info_SetValueForKey( userinfo, "snaps", "20" );	Info_SetValueForKey( userinfo, "skill", va("%.2f", skill) );	Info_SetValueForKey( userinfo, "teampref", team );	key = "model";	model = Info_ValueForKey( botinfo, key );	if ( !*model ) {		model = "visor/default";	}	Info_SetValueForKey( userinfo, key, model );	key = "team_model";	Info_SetValueForKey( userinfo, key, model );	key = "headmodel";	headmodel = Info_ValueForKey( botinfo, key );	if ( !*headmodel ) {		headmodel = model;	}	Info_SetValueForKey( userinfo, key, headmodel );	key = "team_headmodel";	Info_SetValueForKey( userinfo, key, headmodel );	key = "gender";	s = Info_ValueForKey( botinfo, key );	if ( !*s ) {		s = "male";	}	Info_SetValueForKey( userinfo, "sex", s );	key = "color1";	s = Info_ValueForKey( botinfo, key );	if ( !*s ) {		s = "4";	}	Info_SetValueForKey( userinfo, key, s );	key = "color2";	s = Info_ValueForKey( botinfo, key );	if ( !*s ) {		s = "5";	}	Info_SetValueForKey( userinfo, key, s );	s = Info_ValueForKey(botinfo, "aifile");	if (!*s ) {		trap_Print( S_COLOR_RED "Error: bot has no aifile specified/n" );		trap_BotFreeClient( clientNum );		return;	}	Info_SetValueForKey( userinfo, "characterfile", s );	// don't send tinfo to bots, they don't parse it	Info_SetValueForKey( userinfo, "teamoverlay", "0" );	// register the userinfo	trap_SetUserinfo( clientNum, userinfo );	// have it connect to the game as a normal client	if ( ClientConnect( clientNum, qtrue, qtrue ) ) {		return;	}	if( delay == 0 ) {		ClientBegin( clientNum );		return;	}	AddBotToSpawnQueue( clientNum, delay );}
开发者ID:eserozvataf,项目名称:q3now,代码行数:101,


示例24: ACESP_SetName

///////////////////////////////////////////////////////////////////////// Set the name of the bot and update the userinfo///////////////////////////////////////////////////////////////////////void ACESP_SetName(edict_t *bot, char *name, char *skin, char *team){	float rnd;	char userinfo[MAX_INFO_STRING] = "";	char bot_skin[MAX_INFO_STRING] = "";	char bot_name[MAX_INFO_STRING] = "";	int i, r;	if (NUM_BOT_SKINS == 0)		NUM_BOT_SKINS = listSize(skinnames);	// Set the name for the bot.	// name	if (strlen(name) == 0)	{		// Randomly select from the name/skin table		if (num_botinfo > 0)		{			//int numtries = 0;			rnd = random();			for (i = 0; i < num_botinfo; i++)				if (rnd < ((float)(i+1)/(float)num_botinfo) )				{	r=i; break; }			// Search for an unused name starting at selected pos			for (i = r; i < num_botinfo; i++)				if (!bot_info[i].ingame_count)				{					Com_sprintf(bot_name, sizeof(bot_name), bot_info[i].name);					bot_info[i].ingame_count++;					break;				}			// If none found, loop back			if (strlen(bot_name) == 0)				for (i = 0; i < r; i++)					if (!bot_info[i].ingame_count)					{						Com_sprintf(bot_name, sizeof(bot_name), bot_info[i].name);						bot_info[i].ingame_count++;						break;					}			// If no more free bots in table, use a numbered name			if (strlen(bot_name) == 0)				Com_sprintf(bot_name, sizeof(bot_name), "ACEBot_%d",bot->count);		}		else			Com_sprintf(bot_name, sizeof(bot_name), "ACEBot_%d",bot->count);	}	else	//	strncpy(bot_name, name);		Q_strncpyz(bot_name, name, sizeof(bot_name));	// skin	if (strlen(skin) == 0)	{	// check if this bot is in the table		for (i = 0; i < num_botinfo; i++)		{			if (!Q_stricmp(bot_name, bot_info[i].name))			{				Com_sprintf(bot_name, sizeof(bot_name), bot_info[i].name); // fix capitalization				Com_sprintf(bot_skin, sizeof(bot_skin), bot_info[i].skin);				bot_info[i].ingame_count++;				break;			}		}		if (strlen(bot_skin) == 0)		{	// randomly choose skin 			rnd = random();			for (i = 0; i < NUM_BOT_SKINS; i++)				if (rnd < ((float)(i + 1) / (float)NUM_BOT_SKINS))				{					r = i; break;				}			Com_sprintf(bot_skin, sizeof(bot_skin), skinnames[r]);		}	}	else	//	strncpy(bot_skin, skin);		Q_strncpyz(bot_skin, skin, sizeof(bot_skin));		// initialise userinfo	memset(userinfo, 0, sizeof(userinfo));	// add bot's name/skin/hand to userinfo	Info_SetValueForKey(userinfo, "name", bot_name);	Info_SetValueForKey(userinfo, "skin", bot_skin);	Info_SetValueForKey(userinfo, "hand", "2"); // bot is center handed for now!	ClientConnect (bot, userinfo);	// Knightmare- removed this	//ACESP_SaveBots(); // make sure to save the bots}
开发者ID:m-x-d,项目名称:Mission64-src,代码行数:95,


示例25: G_AddBot

//.........这里部分代码省略.........	trap_SetUserinfo( clientNum, userinfo );	//[NewGameTypes][EnhancedImpliment]	//if (g_gametype.integer >= GT_TEAM && g_gametype.integer != GT_RPG)	if (g_gametype.integer >= GT_TEAM)	//[/NewGameTypes][EnhancedImpliment]	{		if (team && Q_stricmp(team, "red") == 0)		{			bot->client->sess.sessionTeam = TEAM_RED;		}		else if (team && Q_stricmp(team, "blue") == 0)		{			bot->client->sess.sessionTeam = TEAM_BLUE;		}		else		{			//[AdminSys]			bot->client->sess.sessionTeam = PickTeam( -1, qtrue );			//bot->client->sess.sessionTeam = PickTeam( -1 );			//[/AdminSys]		}	}	if (g_gametype.integer == GT_SIEGE)	{		bot->client->sess.siegeDesiredTeam = bot->client->sess.sessionTeam;		bot->client->sess.sessionTeam = TEAM_SPECTATOR;	}	preTeam = bot->client->sess.sessionTeam;	// have it connect to the game as a normal client	if ( ClientConnect( clientNum, qtrue, qtrue ) ) {		return;	}	if (bot->client->sess.sessionTeam != preTeam)	{		trap_GetUserinfo(clientNum, userinfo, MAX_INFO_STRING);		if (bot->client->sess.sessionTeam == TEAM_SPECTATOR)		{			bot->client->sess.sessionTeam = preTeam;		}		if (bot->client->sess.sessionTeam == TEAM_RED)		{			team = "Red";		}		else		{			if (g_gametype.integer == GT_SIEGE)			{				if (bot->client->sess.sessionTeam == TEAM_BLUE)				{					team = "Blue";				}				else				{					team = "s";				}			}			else			{				team = "Blue";
开发者ID:ForcePush,项目名称:OJPRPFZ,代码行数:67,


示例26: ACESP_SpawnBot

///////////////////////////////////////////////////////////////////////// Spawn the bot///////////////////////////////////////////////////////////////////////void ACESP_SpawnBot(char *team, char *name, char *skin, char *userinfo){	edict_t *bot = ACESP_FindFreeClient();		if (!bot)	{		safe_bprintf(PRINT_MEDIUM, "Server is full, increase Maxclients./n");		return;	}	bot->yaw_speed = 100; // yaw speed	bot->inuse = true;	bot->is_bot = true;	// To allow bots to respawn	if (userinfo == NULL)		ACESP_SetName(bot, name, skin, team);	else		ClientConnect (bot, userinfo);		G_InitEdict (bot);	InitClientResp (bot->client);		// locate ent at a spawn point	if (ctf->value)	{		// Knightmare- rewrote this		int team1count = 0, team2count = 0, team3count = 0;		int jointeam;		const float r = random();		for (int i = 1; i <= maxclients->value; i++)		{			edict_t *player = &g_edicts[i];			if (!player->inuse || !player->client || player == bot)				continue;			switch (player->client->resp.ctf_team)			{			case CTF_TEAM1:				team1count++;				break;			case CTF_TEAM2:				team2count++;				break;			case CTF_TEAM3: 				team3count++;				break;			}		}		if (ttctf->value)		{			if (team != NULL && strcmp(team,"red")==0)				jointeam = CTF_TEAM1;			else if (team != NULL && strcmp(team,"blue")==0)				jointeam = CTF_TEAM2;			else if (team != NULL && strcmp(team,"green")==0)				jointeam = CTF_TEAM3;			// join either of the outnumbered teams			else if (team1count == team2count && team1count < team3count)				jointeam = (r < 0.5) ? CTF_TEAM1 : CTF_TEAM2;			else if (team1count == team3count && team1count < team2count)				jointeam = (r < 0.5) ? CTF_TEAM1 : CTF_TEAM3;			else if (team2count == team3count && team2count < team1count)				jointeam = (r < 0.5) ? CTF_TEAM2 : CTF_TEAM3;			// join outnumbered team			else if (team1count < team2count && team1count < team3count)				jointeam = CTF_TEAM1;			else if (team2count < team1count &&  team2count < team3count) 				jointeam = CTF_TEAM2;			else if (team3count < team1count &&  team3count < team2count) 				jointeam = CTF_TEAM3;			// pick random team			else if (r < 0.33)				jointeam = CTF_TEAM1;			else if (r < 0.66)				jointeam = CTF_TEAM2;			else				jointeam = CTF_TEAM3;		}		else		{			if (team != NULL && strcmp(team,"red")==0)				jointeam = CTF_TEAM1;			else if (team != NULL && strcmp(team,"blue")==0)				jointeam = CTF_TEAM2;			// join outnumbered team			else if (team1count < team2count)				jointeam = CTF_TEAM1;			else if (team2count < team1count)				jointeam = CTF_TEAM2;			// pick random team			else if (r < 0.5)				jointeam = CTF_TEAM1;			else//.........这里部分代码省略.........
开发者ID:m-x-d,项目名称:Mission64-src,代码行数:101,



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


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