Exemple #1
0
void CClient::DebugDrawNetStats()
{
	if (g_pNetMan->IsNetworkGame())
	{
		QueueStats stats;
		NString str;

		g_pDarkNet->GetSendQueueStats(stats);

		if (!g_pNetMan->AmDefaultHost())
		{
			DPN_CONNECTION_INFO ci;

			ci.dwSize = sizeof(DPN_CONNECTION_INFO);

			HRESULT hRes = g_pDarkNet->GetHostConnectionInfo(&ci);
			if (FAILED(hRes))
				return;

			if (!g_pDarkNet)
				return;

			int timeouts = ci.dwMessagesTimedOutHighPriority + ci.dwMessagesTimedOutLowPriority + ci.dwMessagesTimedOutNormalPriority;

			str.Format("Ping: %d\nPackets dropped: %d\nTimeouts: %d\nGuaranteed sends: %d\nNon-guaranteed sends: %d\nQueue: %d\nQueue peak: %d\n", ci.dwRoundTripLatencyMS, ci.dwPacketsDropped, 
				timeouts, ci.dwPacketsSentGuaranteed, ci.dwPacketsSentNonGuaranteed, stats.queued, stats.peak);
		}
		else
			str.Format("Queue %d\nQueue peak: %d", stats.queued, stats.peak);

		TextDrawCentered(g_TextFont, CLR_Red, str, 0.98f, 0.01f);
	}
}
Exemple #2
0
//-----------------------------------------------------------------
//!	\brief	Display animation properties (recurse)
//-----------------------------------------------------------------
void NPropertiesCtrl::_DisplayAnimationObjectProperties(NObject* _pobj, udword _dwDepth)
{
	//Get First Object var bloc
	NVarsBloc* pbloc = _pobj->GetFirstVarsBloc();

	while (pbloc)
	{
		//NVarsBlocDesc*	pblocdesc	= pbloc->GetBlocDesc();

		//Parse Vars for this bloc
		for (udword i=0; i<pbloc->Count(); i++)
		{
			//Animation for this variable?
			NObject* pctrlObj = pbloc->GetValueControler(i);
			if (pctrlObj!=null)
			{
				NString str;
				str.Format("Animation %s", pbloc->GetValueDesc(i)->pszName );
				pctrlObj->SetName(str.Buffer());	//##TOFIX### variable bloc name

				//Display properties for this controler
				_DisplayObjectProperties(pctrlObj, _dwDepth);
			}

		}

		//pblocdesc=pblocdesc->	//###TOFIX### Next Bloc
		pbloc=null;	//###TOFIX####
	}


}
Exemple #3
0
NString TimeString(int time)
{	
	NString timeStr;

	int hours = time / 3600;
	int minutes = (time % 3600) / 60;
	int seconds = (time % 3600) % 60;

	if (minutes < 0) minutes = 0;
	if (seconds < 0) seconds = 0;

	if (hours > 0)
		timeStr.Format("%u:%02u:%02u", hours, minutes, seconds);
	else
		timeStr.Format("%u:%02u", minutes, seconds);

	return timeStr;
}
Exemple #4
0
//============================================================================
//		NNumber::GetString : Get the number as a string.
//----------------------------------------------------------------------------
NString NNumber::GetString(void) const
{	NString		valueText;



	// Get the string
	switch (mPrecision) {
		case kNPrecisionInt8:
		case kNPrecisionInt16:
		case kNPrecisionInt32:
		case kNPrecisionInt64:
			valueText.Format("%lld", mValue.integer);
			break;
			
		case kNPrecisionFloat32:
		case kNPrecisionFloat64:
			if (NTargetPOSIX::is_nan(mValue.real))
				valueText = kNStringNaN;

			else if (NTargetPOSIX::is_inf(mValue.real))
				valueText = (mValue.real < 0.0) ? kNStringInfinityNeg : kNStringInfinityPos;

			else if (NMathUtilities::IsZero(mValue.real))
				valueText = kNStringZero;

			else
				{
				if (mPrecision == kNPrecisionFloat32)
					valueText.Format(kFormatFloat32, (Float32) mValue.real);
				else
					valueText.Format(kFormatFloat64,           mValue.real);
				}
			break;

		default:
			NN_LOG("Unknown precision: %d", mPrecision);
			valueText = kNStringZero;
			break;
		}

	return(valueText);
}
Exemple #5
0
void CClient::DebugDrawVisibility()
{
	sAIVisibility* vis;
	float alpha;

	if (g_pAIVisibilityProperty->Get(*_highlit_obj, (void**)&vis) && gAlphaRenderProp->Get(*_highlit_obj, &alpha))
	{
		NString str;
		str.Format("Level: %d Exposure: %d Rating %d Transparency %.2f", vis->level, vis->exposureRating, vis->lightRating, alpha);
		TextDrawCentered(g_TextFont, CLR_Red, str, 0.5f, 0.5f);
	}

	if (g_pTraitMan->ObjHasDonor(*_highlit_obj, Gamesys.Arch.MPAvatar))
		*_highlit_obj = 0;
}
Exemple #6
0
void CClient::DebugDrawMiscStats()
{
	mxs_vector vec;
	NString str;
	float totalSpeed;
	Position* pos;

	pos = _ObjPosGet(*_gPlayerObj);
	_PhysGetVelocity(*_gPlayerObj, & vec);
	totalSpeed = sqrt((vec.x * vec.x) + (vec.y * vec.y) + (vec.z * vec.z));
	sGhostLocal* pGhost = _GhostGetLocal(*_gPlayerObj);
	
	str.Format("ftime %d\nstime %d\nforward %0.4f\nside %0.4f\noverall %0.4f\n[%0.4f %0.4f %0.4f] \ndelta %f\nfps %0.2f\nanm %d aflags %x", _GetSimFrameTime(), _GetSimTime(), g_pPlayerMode->m_forwardSpeed, g_pPlayerMode->m_sidestepSpeed, 
		totalSpeed, pos->vec.x, pos->vec.y, pos->vec.z, g_DeltaFrame.Get(), 1.0f / g_DeltaFrame.Get(), pGhost ? pGhost->playing.schema_idx : 0, pGhost ? pGhost->playing.motion_num : 0);

	TextDrawCentered(g_TextFont, CLR_Red, str, 0.0f, 0.0f);
}
Exemple #7
0
bool NParserImpl::GetStyleParam(LPCTSTR packFilePath, NString& filePath, NString& styleName)
{
    // Normalize path
    LPCTSTR separator = _tcschr(packFilePath, _T(':'));
    if(separator == NULL)
        return false;

    styleName = separator + 1;

    if(packFilePath[0] == _T('@'))
    {
        NString tmpPath;
        tmpPath.Assign(packFilePath, separator - packFilePath);
        filePath.Format(_T("@style:%s.xml"), tmpPath.GetData() + 1);
    }
    else
    {
        filePath.Assign(packFilePath, separator - packFilePath);
    }

    return true;
}
Exemple #8
0
//============================================================================
//      NTargetNetwork::SocketOpen : Open a socket.
//----------------------------------------------------------------------------
NSocketRef NTargetNetwork::SocketOpen(NSocket *nanoSocket, const NString &theHost, uint16_t thePort)
{	struct addrinfo		*theAddress, *addrList;
	int					sysErr, tmpSocket;
	NSocketRef			theSocket;
	const char			*hostName;
	struct addrinfo		addrInfo;
	bool				isListen;
	NString				portNum;



	// Get the state we need
	isListen  = theHost.IsEmpty();
	theAddress = NULL;

	hostName = isListen ? NULL : theHost.GetUTF8();
	portNum.Format("%d",thePort);



	// Create the address
	memset(&addrInfo, 0, sizeof(struct addrinfo));

	addrInfo.ai_family   = AF_UNSPEC;						// Allow IPv4 or IPv6
	addrInfo.ai_socktype = SOCK_STREAM;						// Always TCP
	addrInfo.ai_flags    = isListen ? AI_PASSIVE : 0;

	sysErr = getaddrinfo(hostName, portNum.GetUTF8(), &addrInfo, &addrList);
	NN_ASSERT_NOERR(sysErr);

	if (sysErr != 0)
		return(NULL);



	// Create the socket
	//
	// As we may have multiple addresses, we loop until we find one that we can connect/bind.
	for (theAddress = addrList; theAddress != NULL; theAddress = theAddress->ai_next)
		{
		tmpSocket = socket(theAddress->ai_family, theAddress->ai_socktype, theAddress->ai_protocol);
		if (tmpSocket == kSocketHandleInvalid)
			continue;

		if (isListen)
			{
			if (bind(tmpSocket, theAddress->ai_addr, theAddress->ai_addrlen) == 0)
				break;
			}
		else
			{
			if (connect(tmpSocket, theAddress->ai_addr, theAddress->ai_addrlen) == 0)
				break;
			}

		close(tmpSocket);
		}

	freeaddrinfo(addrList);

	NN_ASSERT(theAddress != NULL);
	if (theAddress == NULL)
		return(NULL);



	// Setup signal handler for closed sockets
	//
	// TO DO
		/*
		sa.sa_handler = sigchld_handler;
		sigemptyset(&sa.sa_mask);

		sa.sa_flags = SA_RESTART;
		NN_ASSERT(sigaction(SIGCHLD, &sa, NULL) != -1);
	*/

	// TODO Create thread for listening/accepting connections



	// Create the socket info
	theSocket = new NSocketInfo;

	theSocket->nanoSocket   = nanoSocket;
	theSocket->nativeSocket = tmpSocket;

	return(theSocket);
}
Exemple #9
0
cAnsiStr GetMissionName(int missionID)
{
	NString str;
	str.Format("title_%d", missionID);
	return FetchUIString("titles", str, "strings");
}