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


C++ NET_CompareAdr函数代码示例

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


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

示例1: CL_SetServerInfoByAddress

static void CL_SetServerInfoByAddress(netadr_t from, const char *info, int ping) {
	int i;

	for (i = 0; i < MAX_OTHER_SERVERS; i++) {
		if (NET_CompareAdr(from, cls.localServers[i].adr)) {
			CL_SetServerInfo(&cls.localServers[i], info, ping);
		}
	}

	for (i = 0; i < MAX_OTHER_SERVERS; i++) {
		if (NET_CompareAdr(from, cls.mplayerServers[i].adr)) {
			CL_SetServerInfo(&cls.mplayerServers[i], info, ping);
		}
	}

	for (i = 0; i < MAX_GLOBAL_SERVERS; i++) {
		if (NET_CompareAdr(from, cls.globalServers[i].adr)) {
			CL_SetServerInfo(&cls.globalServers[i], info, ping);
		}
	}

	for (i = 0; i < MAX_OTHER_SERVERS; i++) {
		if (NET_CompareAdr(from, cls.favoriteServers[i].adr)) {
			CL_SetServerInfo(&cls.favoriteServers[i], info, ping);
		}
	}

}
开发者ID:ShaneIsley,项目名称:challengeq3,代码行数:28,代码来源:cl_browser.cpp

示例2: LAN_AddFavAddr

int LAN_AddFavAddr( const char *address ) {
	if ( cls.numfavoriteservers < MAX_OTHER_SERVERS ) {
		netadr_t adr;
		if ( !NET_StringToAdr( address, &adr ) ) {
			return 2;
		}
		if ( adr.type == NA_BAD ) {
			return 3;
		}

		for ( int i = 0; i < cls.numfavoriteservers; i++ ) {
			if ( NET_CompareAdr( cls.favoriteServers[i].adr, adr ) ) {
				return 0;
			}
		}
		cls.favoriteServers[cls.numfavoriteservers].adr = adr;
		Q_strncpyz( cls.favoriteServers[cls.numfavoriteservers].hostName, address,
			sizeof(cls.favoriteServers[cls.numfavoriteservers].hostName) );
		cls.favoriteServers[cls.numfavoriteservers].visible = qtrue;
		cls.numfavoriteservers++;
		return 1;
	}

	return -1;
}
开发者ID:AlexXT,项目名称:OpenJK,代码行数:25,代码来源:cl_lan.cpp

示例3: Master_AddServer

void Master_AddServer(netadr_t *adr) {

   master_server_t *ptr;


   Master_Init();
   ptr = masterlist;

   //Is it already listed?
   while(ptr != NULL) {
      if(NET_CompareAdr(ptr->address, *adr) != 0) {
         return;
      }
      ptr = ptr->next;
   }

   //Not found, make a new entry.
   ptr = (master_server_t *)Q_Malloc(sizeof(master_server_t));
   if(ptr == NULL) { //malloc failure.  Just back away and let some other function handle it...
      return;
   }

   ptr->address = *adr;
   ptr->last_heartbeat = -15;
   ptr->next = masterlist;
   masterlist = ptr;
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:27,代码来源:master.c

示例4: LAN_ServerIsInFavoriteList

/*
=======================
LAN_ServerIsInFavoriteList
=======================
*/
qboolean LAN_ServerIsInFavoriteList( int source, int n ) {
	int i;
	serverInfo_t *server = NULL;

	switch ( source ) {
	case AS_LOCAL:
		if ( n >= 0 && n < MAX_OTHER_SERVERS ) {
			server = &cls.localServers[n];
		}
		break;
	case AS_GLOBAL:
		if ( n >= 0 && n < MAX_GLOBAL_SERVERS ) {
			server = &cls.globalServers[n];
		}
		break;
	case AS_FAVORITES:
		if ( n >= 0 && n < MAX_OTHER_SERVERS ) {
			return qtrue;
		}
		break;
	}

	if ( !server ) {
		return qfalse;
	}

	for ( i = 0; i < cls.numfavoriteservers; i++ ) {
		if ( NET_CompareAdr( cls.favoriteServers[i].adr, server->adr ) ) {
			return qtrue;
		}
	}

	return qfalse;
}
开发者ID:bibendovsky,项目名称:rtcw,代码行数:39,代码来源:cl_ui.cpp

示例5: NET_CompareAdr

bool operator==(const netadr_t &a, const netadr_t &b) {
	if (a.type != b.type) {
		return false;
	}

	return NET_CompareAdr(&a, &b);
}
开发者ID:turol,项目名称:webquake2,代码行数:7,代码来源:net_websockets.cpp

示例6: LAN_RemoveServer

/*
====================
LAN_RemoveServer
====================
*/
static void LAN_RemoveServer(int source, const char *addr) {
	int *count, i;
	serverInfo_t *servers = NULL;
	count = NULL;
	switch (source) {
		case AS_LOCAL :
			count = &cls.numlocalservers;
			servers = &cls.localServers[0];
			break;
		case AS_MPLAYER:
		case AS_GLOBAL :
			count = &cls.numglobalservers;
			servers = &cls.globalServers[0];
			break;
		case AS_FAVORITES :
			count = &cls.numfavoriteservers;
			servers = &cls.favoriteServers[0];
			break;
	}
	if (servers) {
		netadr_t comp;
		NET_StringToAdr( addr, &comp );
		for (i = 0; i < *count; i++) {
			if (NET_CompareAdr( comp, servers[i].adr)) {
				int j = i;
				while (j < *count - 1) {
					Com_Memcpy(&servers[j], &servers[j+1], sizeof(servers[j]));
					j++;
				}
				(*count)--;
				break;
			}
		}
	}
}
开发者ID:entdark,项目名称:jaMME,代码行数:40,代码来源:cl_ui.cpp

示例7: CL_UpdateInfoPacket

/*
===================
CL_UpdateInfoPacket
===================
*/
void CL_UpdateInfoPacket(netadr_t from)
{
	if (autoupdate.autoupdateServer.type == NA_BAD)
	{
		Com_DPrintf("CL_UpdateInfoPacket: Update server has bad address\n");
		return;
	}

	Com_DPrintf("Update server resolved to %s\n",
	            NET_AdrToString(autoupdate.autoupdateServer));

	if (!NET_CompareAdr(from, autoupdate.autoupdateServer))
	{
		// TODO: when the updater is server-side as well, write this message to the Attack log
		Com_DPrintf("CL_UpdateInfoPacket: Ignoring packet from %s, because the update server is located at %s\n",
		            NET_AdrToString(from), NET_AdrToString(autoupdate.autoupdateServer));
		return;
	}

	Cvar_Set("com_updateavailable", Cmd_Argv(1));

	if (!Q_stricmp(com_updateavailable->string, "1"))
	{
		Cvar_Set("com_updatefiles", Cmd_Argv(2));
#ifdef FEATURE_AUTOUPDATE
		VM_Call(uivm, UI_SET_ACTIVE_MENU, UIMENU_WM_AUTOUPDATE);
#endif /* FEATURE_AUTOUPDATE */
	}
}
开发者ID:Ponce,项目名称:etlegacy,代码行数:34,代码来源:cl_update.c

示例8: CL_SetServerInfoByAddress

static void CL_SetServerInfoByAddress(netadr_t from, const char *info, int ping) {
	int i;

	int count;
	serverInfo_t *server = NULL;

	switch (cls.pingUpdateSource)
	{
	case 0:
		server = &cls.historyServers[0];
		count = cls.numhistoryservers;
		break;
	case 1:
		server = &cls.globalServers[0];
		count = cls.numglobalservers;
		break;
	case 2:
		server = &cls.favoriteServers[0];
		count = cls.numfavoriteservers;
		break;
	}

	for (i = 0; i < count; i++) {
		if (NET_CompareAdr(from, server[i].adr)) {
			CL_SetServerInfo(&server[i], info, ping);
		}
	}
}
开发者ID:Call-of-Duty-Scripts,项目名称:fourdeltaone,代码行数:28,代码来源:PatchMW2ServerList.cpp

示例9: PR2_GameConsoleCommand

//===========================================================================
// GameConsoleCommand
//===========================================================================
void PR2_GameConsoleCommand(void)
{
	int     old_other, old_self;
	client_t	*cl;
	int			i;

	if( sv_vm )
	{
		old_self = pr_global_struct->self;
		old_other = pr_global_struct->other;
		pr_global_struct->other = 0; //sv_cmd = SV_CMD_CONSOLE;
		pr_global_struct->self = 0;

		for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++)
		{
			if (!cl->state)
				continue;
			if ( cl->isBot )
				continue;

			if (NET_CompareAdr(cl->netchan.remote_address, net_from))
			{
				pr_global_struct->self = EDICT_TO_PROG(cl->edict);
				break;
			}
		}
		VM_Call(sv_vm, GAME_CONSOLE_COMMAND, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
		pr_global_struct->self = old_self;
		pr_global_struct->other = old_other;
	}
}
开发者ID:Classic-Fortress,项目名称:server,代码行数:34,代码来源:pr2_exec.c

示例10:

/*
===================
CL_GetServerStatus
===================
*/
serverStatus_t *CL_GetServerStatus( netadr_t from ) {
	serverStatus_t *serverStatus;
	int i, oldest, oldestTime;

	serverStatus = NULL;
	for (i = 0; i < MAX_SERVERSTATUSREQUESTS; i++) {
		if ( NET_CompareAdr( from, cl_serverStatusList[i].address ) ) {
			return &cl_serverStatusList[i];
		}
	}
	for (i = 0; i < MAX_SERVERSTATUSREQUESTS; i++) {
		if ( cl_serverStatusList[i].retrieved ) {
			return &cl_serverStatusList[i];
		}
	}
	oldest = -1;
	oldestTime = 0;
	for (i = 0; i < MAX_SERVERSTATUSREQUESTS; i++) {
		if (oldest == -1 || cl_serverStatusList[i].startTime < oldestTime) {
			oldest = i;
			oldestTime = cl_serverStatusList[i].startTime;
		}
	}
	if (oldest != -1) {
		return &cl_serverStatusList[oldest];
	}
	serverStatusCount++;
	return &cl_serverStatusList[serverStatusCount & (MAX_SERVERSTATUSREQUESTS-1)];
}
开发者ID:ShaneIsley,项目名称:challengeq3,代码行数:34,代码来源:cl_browser.cpp

示例11: CL_PacketEvent

/*
=================
CL_PacketEvent

A packet has arrived from the main event loop
=================
*/
void CL_PacketEvent( netadr_t from, msg_t *msg ) {
	clc.lastPacketTime = cls.realtime;

	if ( msg->cursize >= 4 && *(int *)msg->data == -1 ) {
		CL_ConnectionlessPacket( from, msg );
		return;
	}

	if ( cls.state < CA_CONNECTED ) {
		return;		// can't be a valid sequenced packet
	}

	if ( msg->cursize < 8 ) {
		Com_Printf ("%s: Runt packet\n",NET_AdrToString( from ));
		return;
	}

	//
	// packet from server
	//
	if ( !NET_CompareAdr( from, clc.netchan.remoteAddress ) ) {
		Com_DPrintf ("%s:sequenced packet without connection\n"
			,NET_AdrToString( from ) );
		// FIXME: send a client disconnect?
		return;
	}

	if (!Netchan_Process( &clc.netchan, msg) ) {
		return;		// out of order, duplicated, etc
	}

	clc.lastPacketTime = cls.realtime;
	CL_ParseServerMessage( msg );
}
开发者ID:Delfin1,项目名称:OpenJK,代码行数:41,代码来源:cl_main.cpp

示例12: OnPacketTV

void OnPacketTV()
{
	if(NET_CompareAdr(net_from, net_server))
	{
		buf_t out = net_message;
		// if this is a server connect message, keep a copy for other clients
		int t = net_message.ReadLong();
		if(t == CHALLENGE)
		{
			std::cout << "first client connected" << std::endl;
			challenge_message = net_message;
		}
		else if(t == 0)
		{
			first_message = net_message;
			buf_t tmp;
			tr.Go(net_message, tmp);
		}
		else
		{
			out.clear();
			out.WriteLong(t);
			tr.Go(net_message, out);
		}
		// replicate server packet to all connected clients
		for(int i = 0; i < spectators.size(); i++)
		{
			NET_SendPacket(out.cursize, out.data, spectators[i]);
		}
	}
	else
	{
		// is this an existing client?
		for(int i = 0; i < spectators.size(); i++)
		{
			if(NET_CompareAdr(net_from, spectators[i]))
			{
				OnClientTV(i);
				return;
			}
		}

		// must be a new client
		OnNewClientTV();
	}
}
开发者ID:JohnnyonFlame,项目名称:odamex,代码行数:46,代码来源:protocol.cpp

示例13: CL_ReadNetMessage

/*
=================
CL_ReadNetMessage
=================
*/
void CL_ReadNetMessage( void )
{
	size_t	curSize;

	while( CL_GetMessage( net_message_buffer, &curSize ))
	{
		BF_Init( &net_message, "ServerData", net_message_buffer, curSize );

		// check for connectionless packet (0xffffffff) first
		if( BF_GetMaxBytes( &net_message ) >= 4 && *(int *)net_message.pData == -1 )
		{
			CL_ConnectionlessPacket( net_from, &net_message );
			continue;
		}

		// can't be a valid sequenced packet	
		if( cls.state < ca_connected ) continue;

		if( BF_GetMaxBytes( &net_message ) < 8 )
		{
			MsgDev( D_WARN, "%s: runt packet\n", NET_AdrToString( net_from ));
			continue;
		}

		// packet from server
		if( !cls.demoplayback && !NET_CompareAdr( net_from, cls.netchan.remote_address ))
		{
			MsgDev( D_ERROR, "CL_ReadPackets: %s:sequenced packet without connection\n", NET_AdrToString( net_from ));
			continue;
		}

		if( !cls.demoplayback && !Netchan_Process( &cls.netchan, &net_message ))
			continue;	// wasn't accepted for some reason

		CL_ParseServerMessage( &net_message );
	}

	// check for fragmentation/reassembly related packets.
	if( cls.state != ca_disconnected && Netchan_IncomingReady( &cls.netchan ))
	{
		// the header is different lengths for reliable and unreliable messages
		int headerBytes = BF_GetNumBytesRead( &net_message );

		// process the incoming buffer(s)
		if( Netchan_CopyNormalFragments( &cls.netchan, &net_message ))
		{
			CL_ParseServerMessage( &net_message );
		}
		
		if( Netchan_CopyFileFragments( &cls.netchan, &net_message ))
		{
			// remove from resource request stuff.
			CL_ProcessFile( true, cls.netchan.incomingfilename );
		}
	}

	Netchan_UpdateProgress( &cls.netchan );
}
开发者ID:Reedych,项目名称:xash3d,代码行数:63,代码来源:cl_main.c

示例14: CL_ServerInfoPacket

void CL_ServerInfoPacket( netadr_t from, msg_t *msg )
{
	int		i, type;
	//->char	info[1024];
	char*	str;
	char	*infoString;
	//->int		prot;

	infoString = MSG_ReadString( msg );
	//infoString = msg->data;

	// if this isn't the correct protocol version, ignore it
	/*prot = atoi( Info_ValueForKey( infoString, "protocol" ) );
	if ( prot != 144 ) {
		Com_DPrintf( "Different protocol info packet: %s\n", infoString );
		return;
	}*/

	const char* challenge = Info_ValueForKey(infoString, "challenge");
	if (challenge && !_strnicmp("_join", challenge, 5))
	{
		CL_JoinResponse(from, infoString);
	}

	// iterate servers waiting for ping response
	for (i=0; i<MAX_PINGREQUESTS; i++)
	{
		if ( cl_pinglist[i].adr.port && !cl_pinglist[i].time && NET_CompareAdr( from, cl_pinglist[i].adr ) )
		{
			// calc ping time
			cl_pinglist[i].time = timeGetTime() - cl_pinglist[i].start + 1;
			//Com_Printf( 0, "ping time %dms from %s\n", cl_pinglist[i].time, NET_AdrToString( from ) );

			// save of info
			strncpy( cl_pinglist[i].info, infoString, sizeof( cl_pinglist[i].info ) );

			// tack on the net type
			// NOTE: make sure these types are in sync with the netnames strings in the UI
			switch (from.type)
			{
			case NA_BROADCAST:
			case NA_IP:
				str = "udp";
				type = 1;
				break;

			default:
				str = "???";
				type = 0;
				break;
			}
			Info_SetValueForKey( cl_pinglist[i].info, "nettype", va("%d", type) );
			CL_SetServerInfoByAddress(from, infoString, cl_pinglist[i].time);

			return;
		}
	}
}
开发者ID:Call-of-Duty-Scripts,项目名称:fourdeltaone,代码行数:58,代码来源:PatchMW2ServerList.cpp

示例15: CL_ServerStatus

/*
===================
CL_ServerStatus
===================
*/
int CL_ServerStatus( char *serverAddress, char *serverStatusString, int maxLen ) {
	int i;
	netadr_t	to;
	serverStatus_t *serverStatus;

	// if no server address then reset all server status requests
	if ( !serverAddress ) {
		for (i = 0; i < MAX_SERVERSTATUSREQUESTS; i++) {
			cl_serverStatusList[i].address.port = 0;
			cl_serverStatusList[i].retrieved = qtrue;
		}
		return qfalse;
	}
	// get the address
	if ( !NET_StringToAdr( serverAddress, &to ) ) {
		return qfalse;
	}
	serverStatus = CL_GetServerStatus( to );
	// if no server status string then reset the server status request for this address
	if ( !serverStatusString ) {
		serverStatus->retrieved = qtrue;
		return qfalse;
	}

	// if this server status request has the same address
	if ( NET_CompareAdr( to, serverStatus->address) ) {
		// if we recieved an response for this server status request
		if (!serverStatus->pending) {
			Q_strncpyz(serverStatusString, serverStatus->string, maxLen);
			serverStatus->retrieved = qtrue;
			serverStatus->startTime = 0;
			return qtrue;
		}
		// resend the request regularly
		else if ( serverStatus->startTime < Com_Milliseconds() - cl_serverStatusResendTime->integer ) {
			serverStatus->print = qfalse;
			serverStatus->pending = qtrue;
			serverStatus->retrieved = qfalse;
			serverStatus->time = 0;
			serverStatus->startTime = Com_Milliseconds();
			NET_OutOfBandPrint( NS_CLIENT, to, "getstatus" );
			return qfalse;
		}
	}
	// if retrieved
	else if ( serverStatus->retrieved ) {
		serverStatus->address = to;
		serverStatus->print = qfalse;
		serverStatus->pending = qtrue;
		serverStatus->retrieved = qfalse;
		serverStatus->startTime = Com_Milliseconds();
		serverStatus->time = 0;
		NET_OutOfBandPrint( NS_CLIENT, to, "getstatus" );
		return qfalse;
	}
	return qfalse;
}
开发者ID:ShaneIsley,项目名称:challengeq3,代码行数:62,代码来源:cl_browser.cpp


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