當前位置: 首頁>>代碼示例>>C++>>正文


C++ BigShort函數代碼示例

本文整理匯總了C++中BigShort函數的典型用法代碼示例。如果您正苦於以下問題:C++ BigShort函數的具體用法?C++ BigShort怎麽用?C++ BigShort使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了BigShort函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: SV_BanNum_f

/*
==================
SV_BanNum_f

Ban a user from being able to play on this server through the auth
server
==================
*/
static void SV_BanNum_f( void ) {
	client_t	*cl;

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

	if ( Cmd_Argc() != 2 ) {
		Com_Printf ("Usage: banClient <client number>\n");
		return;
	}

	cl = SV_GetPlayerByNum();
	if ( !cl ) {
		return;
	}
	if( cl->netchan.remoteAddress.type == NA_LOOPBACK ) {
		Com_Printf("Cannot kick host player\n");
		return;
	}

	// look up the authorize server's IP
	if ( !svs.authorizeAddress.ip[0] && svs.authorizeAddress.type != NA_BAD ) {
		Com_Printf( "Resolving %s\n", AUTHORIZE_SERVER_NAME );
		if ( !NET_StringToAdr( AUTHORIZE_SERVER_NAME, &svs.authorizeAddress, NA_IP ) ) {
			Com_Printf( "Couldn't resolve address\n" );
			return;
		}
		svs.authorizeAddress.port = BigShort( PORT_AUTHORIZE );
		Com_Printf( "%s resolved to %i.%i.%i.%i:%i\n", AUTHORIZE_SERVER_NAME,
			svs.authorizeAddress.ip[0], svs.authorizeAddress.ip[1],
			svs.authorizeAddress.ip[2], svs.authorizeAddress.ip[3],
			BigShort( svs.authorizeAddress.port ) );
	}

	// otherwise send their ip to the authorize server
	if ( svs.authorizeAddress.type != NA_BAD ) {
		NET_OutOfBandPrint( NS_SERVER, svs.authorizeAddress,
			"banUser %i.%i.%i.%i", cl->netchan.remoteAddress.ip[0], cl->netchan.remoteAddress.ip[1], 
								   cl->netchan.remoteAddress.ip[2], cl->netchan.remoteAddress.ip[3] );
		Com_Printf("%s was banned from coming back\n", cl->name);
	}
}
開發者ID:TwistTheNeil,項目名稱:ioq3-urt-4.2-jump-server,代碼行數:53,代碼來源:sv_ccmds.c

示例2: Com_sprintf

const char  *NET_AdrToString (netadr_t a) {
    static  char    s[64];

    if (a.type == NA_LOOPBACK) {
        Com_sprintf (s, sizeof(s), "loopback");
    } else if (a.type == NA_BOT) {
        Com_sprintf (s, sizeof(s), "bot");
    } else if (a.type == NA_IP) {
        Com_sprintf (s, sizeof(s), "%i.%i.%i.%i:%hu",
            a.ip[0], a.ip[1], a.ip[2], a.ip[3], BigShort(a.port));
    } else {
        Com_sprintf (s, sizeof(s), "%02x%02x%02x%02x.%02x%02x%02x%02x%02x%02x:%hu",
        a.ipx[0], a.ipx[1], a.ipx[2], a.ipx[3], a.ipx[4], a.ipx[5], a.ipx[6], a.ipx[7], a.ipx[8], a.ipx[9], 
        BigShort(a.port));
    }

    return s;
}
開發者ID:EndlessClan,項目名稱:CoDExtended,代碼行數:18,代碼來源:net_chan.c

示例3: NET_SendTCPPacket_SV

qbool NET_SendTCPPacket_SV (netsrc_t netsrc, int length, void *data, netadr_t to)
{
	svtcpstream_t *st;

	if (netsrc != NS_SERVER)
		return false;

	for (st = svs.tcpstreams; st; st = st->next)
	{
		if (st->socketnum == INVALID_SOCKET)
			continue;

		if (NET_CompareAdr(to, st->remoteaddr))
		{
			int sent;
			unsigned short slen = BigShort((unsigned short)length);

			if (st->outlen + length + sizeof(slen) >= sizeof(st->outbuffer))
			{
				// not enough space, we overflowed
				break; // well, quake should resist to some packet lost.. so we just drop that packet.
			}

			// put data in buffer
			memmove(st->outbuffer + st->outlen, (char*)&slen, sizeof(slen));
			st->outlen += sizeof(slen);
			memmove(st->outbuffer + st->outlen, data, length);
			st->outlen += length;

			sent = send(st->socketnum, st->outbuffer, st->outlen, 0);

			if (sent == 0)
			{
				// think it's OK
			}
			else if (sent > 0) //we put some data through
			{ //move up the buffer
				st->outlen -= sent;
				memmove(st->outbuffer, st->outbuffer + sent, st->outlen);
			}
			else
			{ //error of some kind. would block or something
				if (qerrno != EWOULDBLOCK && qerrno != EAGAIN)
				{
					st->drop = true; // something cricial, drop than
				}
			}

			break;
		}
	}

	// 'st' will be not zero, if we found 'to' in 'svs.tcpstreams'.
	// That does not mean we actualy send packet, since there case of overflow, but who cares,
	// all is matter that we found such 'to' and tried to send packet.
	return !!st;
}
開發者ID:DavidWiberg,項目名稱:ezquake-source,代碼行數:57,代碼來源:net.c

示例4: SV_MasterGameCompleteStatus

/*
=================
SV_MasterGameCompleteStatus

NERVE - SMF - Sends gameCompleteStatus messages to all master servers
=================
*/
void SV_MasterGameCompleteStatus() {
	static netadr_t adr[MAX_MASTER_SERVERS];
	int i;

	// "dedicated 1" is for lan play, "dedicated 2" is for inet public play
	if ( !com_dedicated || com_dedicated->integer != 2 ) {
		return;     // only dedicated servers send master game status
	}

	// send to group masters
	for ( i = 0 ; i < MAX_MASTER_SERVERS ; i++ ) {
		if ( !sv_master[i]->string[0] ) {
			continue;
		}

		// see if we haven't already resolved the name
		// resolving usually causes hitches on win95, so only
		// do it when needed
		if ( sv_master[i]->modified ) {
			sv_master[i]->modified = qfalse;

			Com_Printf( "Resolving %s\n", sv_master[i]->string );
			if ( !NET_StringToAdr( sv_master[i]->string, &adr[i] ) ) {
				// if the address failed to resolve, clear it
				// so we don't take repeated dns hits
				Com_Printf( "Couldn't resolve address: %s\n", sv_master[i]->string );
				Cvar_Set( sv_master[i]->name, "" );
				sv_master[i]->modified = qfalse;
				continue;
			}
			if ( !strstr( ":", sv_master[i]->string ) ) {
				adr[i].port = BigShort( PORT_MASTER );
			}
			Com_Printf( "%s resolved to %i.%i.%i.%i:%i\n", sv_master[i]->string,
						adr[i].ip[0], adr[i].ip[1], adr[i].ip[2], adr[i].ip[3],
						BigShort( adr[i].port ) );
		}

		Com_Printf( "Sending gameCompleteStatus to %s\n", sv_master[i]->string );
		// this command should be changed if the server info / status format
		// ever incompatably changes
		SVC_GameCompleteStatus( adr[i] );
	}
}
開發者ID:chegestar,項目名稱:omni-bot,代碼行數:51,代碼來源:sv_main.c

示例5: NET_CompareAddress

/*
* NET_CompareAddress
*
* Compares with the port
*/
qboolean NET_CompareAddress( const netadr_t *a, const netadr_t *b )
{
    if( a->type != b->type )
        return qfalse;

    switch( a->type )
    {
    case NA_LOOPBACK:
        return qtrue;

    case NA_IP:
    {
        const netadr_ipv4_t *addr1 = &a->address.ipv4;
        const netadr_ipv4_t *addr2 = &b->address.ipv4;

        if( addr1->ip[0] == addr2->ip[0] && addr1->ip[1] == addr2->ip[1] && addr1->ip[2] == addr2->ip[2] && addr1->ip[3] == addr2->ip[3] &&
                BigShort( addr1->port ) == BigShort( addr2->port ) )
        {
            return qtrue;
        }
        return qfalse;
    }

    case NA_IP6:
    {
        const netadr_ipv6_t *addr1 = &a->address.ipv6;
        const netadr_ipv6_t *addr2 = &b->address.ipv6;

        if( memcmp( addr1->ip, addr2->ip, sizeof( addr1->ip ) ) == 0 &&
                addr1->scope_id == addr2->scope_id &&
                BigShort( addr1->port ) == BigShort( addr2->port ) )
        {
            return qtrue;
        }

        return qfalse;
    }

    default:
        assert( qfalse );
        return qfalse;
    }
}
開發者ID:ewirch,項目名稱:qfusion,代碼行數:48,代碼來源:net.c

示例6: PSDGetInfo

//-----------------------------------------------------------------------------
// Returns information about the PSD file
//-----------------------------------------------------------------------------
bool PSDGetInfo( CUtlBuffer &buf, int *pWidth, int *pHeight, ImageFormat *pImageFormat, float *pSourceGamma )
{
	int nGet = buf.TellGet();
	PSDHeader_t header;
	buf.Get( &header, sizeof(header) );
	buf.SeekGet( CUtlBuffer::SEEK_HEAD, nGet );

	if ( BigLong( header.m_nSignature ) != PSD_SIGNATURE )
		return false;
	if ( BigShort( header.m_nVersion ) != 1 )
		return false;
	if ( BigShort( header.m_nDepth ) != 8 )
		return false;

	*pWidth = BigLong( header.m_nColumns );
	*pHeight = BigLong( header.m_nRows );
	*pImageFormat = BigShort( header.m_nChannels ) == 3 ? IMAGE_FORMAT_RGB888 : IMAGE_FORMAT_RGBA8888;
	*pSourceGamma = ARTWORK_GAMMA;

	return true;
}
開發者ID:Axitonium,項目名稱:SourceEngine2007,代碼行數:24,代碼來源:psd.cpp

示例7: BigShort

static char *FChecks_FServerResponse_Text(void)
{
	netadr_t adr;

	if (!NET_StringToAdr (cls.servername, &adr))
		return NULL;

	if (adr.port == 0)
		adr.port = BigShort (PORT_SERVER);

	return NET_AdrToString(adr);
}
開發者ID:qqshka,項目名稱:ezquake-source,代碼行數:12,代碼來源:fchecks.c

示例8: memset

PSDImageResources::ResElement PSDImageResources::FindElement( Resource eType ) const
{
	ResElement res;
	memset( &res, 0, sizeof( res ) );

	unsigned char const *pvBuffer = m_pvBuffer, * const pvBufferEnd = m_pvBuffer + m_numBytes;
	while ( pvBuffer < pvBufferEnd )
	{
		// 4 : signature
		// 2 : type
		// 4 : reserved
		// 2 : length
		// bytes[ length ]

		unsigned long uSignature = BigLong( *( unsigned long * )( pvBuffer ) );
		pvBuffer += 4;
		if ( uSignature != PSD_IMGRES_SIGNATURE )
			break;

		unsigned short uType = BigShort( *( unsigned short * )( pvBuffer ) );
		pvBuffer += 6;

		unsigned short uLength = BigShort( *( unsigned short * )( pvBuffer ) );
		pvBuffer += 2;

		if ( uType == eType )
		{
			res.m_eType = eType;
			res.m_numBytes = uLength;
			res.m_pvData = pvBuffer;
			break;
		}
		else
		{
			pvBuffer += ( ( uLength + 1 ) &~1 );
		}
	}

	return res;
}
開發者ID:Axitonium,項目名稱:SourceEngine2007,代碼行數:40,代碼來源:psd.cpp

示例9: NET_StringToAdr

/*
=============
NET_StringToAdr

Traps "localhost" for loopback, passes everything else to system
=============
*/
qboolean	NET_StringToAdr( const char *s, netadr_t *a ) {
	qboolean	r;
	char	base[MAX_STRING_CHARS];
	char	*port;

	if (!strcmp (s, "localhost")) {
		Com_Memset (a, 0, sizeof(*a));
		a->type = NA_LOOPBACK;
		return qtrue;
	}

	// look for a port number
	Q_strncpyz( base, s, sizeof( base ) );
	port = strstr( base, ":" );
	if ( port ) {
		*port = 0;
		port++;
	}

	r = Sys_StringToAdr( base, a );

	if ( !r ) {
		a->type = NA_BAD;
		return qfalse;
	}

	// inet_addr returns this if out of range
	if ( a->ip[0] == 255 && a->ip[1] == 255 && a->ip[2] == 255 && a->ip[3] == 255 ) {
		a->type = NA_BAD;
		return qfalse;
	}

	if ( port ) {
		a->port = BigShort( (short)atoi( port ) );
	} else {
		a->port = BigShort( PORT_SERVER );
	}

	return qtrue;
}
開發者ID:Avatarchik,項目名稱:Quake-III-Arena-D3D11,代碼行數:47,代碼來源:net_chan.c

示例10: CL_Rcon_f

/*
 * Send the rest of the command line over as
 * an unconnected command.
 */
void CL_Rcon_f(void)
{
  char message[1024];
  int i;
  netadr_t to;

  if (!rcon_client_password->string) {
    Com_Printf("You must set 'rcon_password' before\n"
               "issuing an rcon command.\n");
    return;
  }

  memset(&to, 0, sizeof(to));

  message[0] = (char) 255;
  message[1] = (char) 255;
  message[2] = (char) 255;
  message[3] = (char) 255;
  message[4] = 0;

  NET_Config(true); /* allow remote */

  strcat(message, "rcon ");

  strcat(message, rcon_client_password->string);
  strcat(message, " ");

  for (i = 1; i < Cmd_Argc(); i++) {
    strcat(message, Cmd_Argv(i));
    strcat(message, " ");
  }

  if (cls.state >= ca_connected) {
    to = cls.netchan.remote_address;
  } else {
    if (!strlen(rcon_address->string)) {
      Com_Printf("You must either be connected,\n"
                 "or set the 'rcon_address' cvar\n"
                 "to issue rcon commands\n");

      return;
    }

    NET_StringToAdr(rcon_address->string, &to);

    if (to.port == 0) {
      to.port = BigShort(PORT_SERVER);
    }
  }

  NET_SendPacket(NS_CLIENT, strlen(message) + 1, message, to);
}
開發者ID:greck2908,項目名稱:qengine,代碼行數:56,代碼來源:cl_network.c

示例11: SV_SetMaster_f

/*
 * Specify a list of master servers
 */
void
SV_SetMaster_f(void)
{
	int i, slot;

	/* only dedicated servers send heartbeats */
	if (!dedicated->value)
	{
		Com_Printf("Only dedicated servers use masters.\n");
		return;
	}

	/* make sure the server is listed public */
	Cvar_Set("public", "1");

	for (i = 1; i < MAX_MASTERS; i++)
	{
		memset(&master_adr[i], 0, sizeof(master_adr[i]));
	}

	slot = 1; /* slot 0 will always contain the id master */

	for (i = 1; i < Cmd_Argc(); i++)
	{
		if (slot == MAX_MASTERS)
		{
			break;
		}

		if (!NET_StringToAdr(Cmd_Argv(i), &master_adr[i]))
		{
			Com_Printf("Bad address: %s\n", Cmd_Argv(i));
			continue;
		}

		if (master_adr[slot].port == 0)
		{
			master_adr[slot].port = BigShort(PORT_MASTER);
		}

		Com_Printf("Master server at %s\n", NET_AdrToString(master_adr[slot]));

		Com_Printf("Sending a ping.\n");

		Netchan_OutOfBandPrint(NS_SERVER, master_adr[slot], "ping");

		slot++;
	}

	svs.last_heartbeat = -9999999;
}
開發者ID:Clever-Boy,項目名稱:yquake2,代碼行數:54,代碼來源:sv_cmd.c

示例12: CL_SendConnectPacket

/*
	CL_SendConnectPacket

	called by CL_Connect_f and CL_CheckResend
*/
void
CL_SendConnectPacket (void)
{
	netadr_t    adr;
	char        data[2048];
	double      t1, t2;

// JACK: Fixed bug where DNS lookups would cause two connects real fast
//       Now, adds lookup time to the connect time.
//       Should I add it to realtime instead?!?!

	if (cls.state != ca_disconnected)
		return;

	t1 = Sys_DoubleTime ();

	if (!NET_StringToAdr (cls.servername, &adr)) {
		Con_Printf ("Bad server address\n");
		connect_time = -1;
		return;
	}

	if (!NET_IsClientLegal (&adr)) {
		Con_Printf ("Illegal server address\n");
		connect_time = -1;
		return;
	}

	if (adr.port == 0)
		adr.port = BigShort (27500);
	t2 = Sys_DoubleTime ();

	connect_time = realtime + t2 - t1;	// for retransmit requests

	cls.qport = Cvar_VariableValue ("qport");

	// Arrgh, this was not in the old binary only release, and eats up
	// far too much of the 196 chars in the userinfo space, leaving nothing
	// for player use, thus, its commented out for the moment..
	// 
	// Info_SetValueForStarKey (cls.userinfo, "*ip", NET_AdrToString(adr),
	// MAX_INFO_STRING);

//  Con_Printf ("Connecting to %s...\n", cls.servername);
	snprintf (data, sizeof (data), "%c%c%c%cconnect %i %i %i \"%s\"\n",
			  255, 255, 255, 255, PROTOCOL_VERSION, cls.qport, cls.challenge,
			  cls.userinfo);
	NET_SendPacket (strlen (data), data, adr);
}
開發者ID:luaman,項目名稱:qforge-newtree,代碼行數:54,代碼來源:cl_main.c

示例13: ping_broadcast

static void ping_broadcast (void)
{
	netadr_t	adr;
	char		buff[256];
	cvar_t		*noudp;
	cvar_t		*noipx;

	NET_Config(true);		// allow remote
	Com_DPrintf("Pinging broadcast...\n");
	noudp = Cvar_Get("noudp", "0", CVAR_NOSET);
	noipx = Cvar_Get("noipx", "1", CVAR_NOSET);

	m_serverPingSartTime = Sys_Milliseconds();

	if (!noudp->value)
	{
		int i;

		// Scan the LAN for multiple IP's
		for (i = PORT_SERVER; i <= PORT_SERVER_MAX; i++) // jitLAN
		{
			adr.type = NA_BROADCAST;
			adr.port = BigShort(i);
			sprintf(buff, "info %i", PROTOCOL_VERSION);
			Netchan_OutOfBandPrint(NS_CLIENT, adr, buff);
		}
	}

	if (!noipx->value)
	{
		adr.type = NA_BROADCAST_IPX;
		adr.port = BigShort(PORT_SERVER);
		sprintf(buff, "info %i", PROTOCOL_VERSION);
		Netchan_OutOfBandPrint(NS_CLIENT, adr, buff);
	}
}
開發者ID:jitspoe,項目名稱:starviewer,代碼行數:36,代碼來源:cl_serverlist.c

示例14: UncompressBlock

	// Reads the next chunk in the block. Returns true if successful and
	// returns false if it ran out of input data.
	bool UncompressBlock()
	{
		if(Stream.CFlags & 1)
		{
			// Check to see if we have enough input
			if(Stream.AvailIn < 2)
				return false;
			Stream.AvailIn -= 2;

			WORD pos = BigShort(*(WORD*)Stream.In);
			BYTE len = (pos & 0xF)+1;
			pos >>= 4;
			Stream.In += 2;
			if(len == 1)
			{
				// We've reached the end of the stream.
				Stream.State = STREAM_FINAL;
				return true;
			}

			const BYTE* copyStart = Stream.InternalBuffer-pos-1;

			// Complete overlap: Single byte repeated
			if(pos == 0)
				memset(Stream.InternalBuffer, *copyStart, len);
			// No overlap: One copy
			else if(pos >= len)
				memcpy(Stream.InternalBuffer, copyStart, len);
			else
			{
				// Partial overlap: Copy in 2 or 3 chunks.
				do
				{
					unsigned int copy = MIN<unsigned int>(len, pos+1);
					memcpy(Stream.InternalBuffer, copyStart, copy);
					Stream.InternalBuffer += copy;
					Stream.InternalOut += copy;
					len -= copy;
					pos += copy; // Increase our position since we can copy twice as much the next round.
				}
				while(len);
			}

			Stream.InternalOut += len;
			Stream.InternalBuffer += len;
		}
		else
		{
開發者ID:Leonan8995,項目名稱:Xenomia,代碼行數:50,代碼來源:file_wad.cpp

示例15: Cl_Servers_f

/*
 * Cl_Servers_f
 */
void Cl_Servers_f(void) {
	net_addr_t addr;

	if (!Net_StringToNetaddr(IP_MASTER, &addr)) {
		Com_Print("Failed to resolve %s\n", IP_MASTER);
		return;
	}

	Com_Print("Refreshing servers.\n");

	addr.type = NA_IP;
	addr.port = (unsigned short) BigShort(PORT_MASTER);
	Netchan_OutOfBandPrint(NS_CLIENT, addr, "getservers");

	Cl_SendBroadcast();
}
開發者ID:darkshade9,項目名稱:aq2w,代碼行數:19,代碼來源:cl_server.c


注:本文中的BigShort函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。