예제 #1
0
void PublicHubsFrame::updateList()
{
	//CLockRedraw<> l_lock_draw(m_ctrlHubs);
	m_ctrlHubs.DeleteAllItems();
	users = 0;
	visibleHubs = 0;
	
	double size = -1;
	FilterModes mode = NONE;
	
	int sel = ctrlFilterSel.GetCurSel();
	
	bool doSizeCompare = parseFilter(mode, size);
	
	auto cnt = m_ctrlHubs.GetItemCount();
	for (auto i = m_hubs.cbegin(); i != m_hubs.cend(); ++i)
	{
		if (matchFilter(*i, sel, doSizeCompare, mode, size))
		{
			TStringList l;
			l.resize(COLUMN_LAST);
			l[COLUMN_NAME] = Text::toT(i->getName());
			string l_description = i->getDescription();
			boost::replace_all(l_description, ".px.", "");
			l[COLUMN_DESCRIPTION] = Text::toT(l_description);
			l[COLUMN_USERS] = Util::toStringW(i->getUsers());
			l[COLUMN_SERVER] = Text::toT(i->getServer());
			l[COLUMN_COUNTRY] = Text::toT(i->getCountry()); // !SMT!-IP
			l[COLUMN_SHARED] = Util::formatBytesW(i->getShared());
			l[COLUMN_MINSHARE] = Util::formatBytesW(i->getMinShare());
			l[COLUMN_MINSLOTS] = Util::toStringW(i->getMinSlots());
			l[COLUMN_MAXHUBS] = Util::toStringW(i->getMaxHubs());
			l[COLUMN_MAXUSERS] = Util::toStringW(i->getMaxUsers());
			l[COLUMN_RELIABILITY] = Util::toStringW(i->getReliability());
			l[COLUMN_RATING] = Text::toT(i->getRating());
			const auto l_country = i->getCountry();
			dcassert(!l_country.empty());
			const auto l_index_country = WinUtil::getFlagIndexByName(l_country.c_str());
			//const auto l_index =
			m_ctrlHubs.insert(cnt++, l, l_index_country); // !SMT!-IP
			
			/*
			LVITEM lvItem = { 0 };
			        lvItem.mask = LVIF_IMAGE;
			        lvItem.iItem = l_index;
			        lvItem.iImage = isOnline(i->getServer()) ? 0 : 1;
			        m_ctrlHubs.SetItem(&lvItem);
			*/
			visibleHubs++;
			users += i->getUsers();
		}
	}
	
	m_ctrlHubs.resort();
	
	updateStatus();
}
예제 #2
0
/*
*******************************************************************
* Function: 
*
* Description: 
*    
* Parameters: 
*
* Returns: 
*
*******************************************************************
*/
bool
xDistributedSession::isFull()
{
	return getNumUsers() >= getMaxUsers();


	int maxplayers   = -1;
	if (getProperty(E_DC_S_NP_MAX_USERS))
	{
		xDistributedInteger* maxPlayersP = (xDistributedInteger*)getProperty(E_DC_S_NP_MAX_USERS);
		if (maxPlayersP)
		{
			maxplayers  = maxPlayersP->mLastServerValue;
			return getNumUsers() < getMaxUsers();
		}
	}
	return true;
}
예제 #3
0
/*
*******************************************************************
* Function: 
*
* Description: 
*    
* Parameters: 
*
* Returns: 
*
*******************************************************************
*/
TNL::U32 xDistributedSession::packUpdate(TNL::GhostConnection *connection, TNL::U32 updateMask, TNL::BitStream *stream)
{
	xNetInterface *netInterface  = (xNetInterface*) connection->getInterface();
	if (netInterface)
	{
		//the first time  ? : we write out all necessary attributes for the client : 
		if(stream->writeFlag(updateMask & InitialMask))
		{

			if(stream->writeFlag(true))
			{
				//write out name :
				stream->writeString(GetName().getString(),strlen(GetName().getString()));

				//retrieve its class : 
				xDistributedClass *distClass = getDistributedClass();
				if (distClass)
				{
					//write out the class name : 
					stream->writeString(distClass->getClassName().getString(),strlen(distClass->getClassName().getString()));

					//write out the class base type : 
					stream->writeInt(distClass->getEnitityType(),32);

					//write out users id :
					vtConnection *con  = (vtConnection*)connection;
					int uid = getUserID();
					stream->writeInt(getUserID(),32);

					//write out server side id  : 
					int serverID = connection->getGhostIndex(this);
					stream->writeInt(connection->getGhostIndex(this),32);
					setServerID(connection->getGhostIndex(this));

					float time = getCreationTime();
					//write out creation time
					stream->write(getCreationTime());
				//	xLogger::xLog(ELOGINFO,XL_START,"server:init pack update of %s: %f , %d , ",GetName().getString(),time,uid);
					stream->writeInt(getSessionID(),32);
					stream->writeInt(getMaxUsers(),32);
					stream->writeString(getPassword().getString(),strlen(getPassword().getString()));

					//netInterface->deploySessionClasses(connection);

				}
				setNetInterface(netInterface);
			}
		}
		/************************************************************************/
		/*																			                                                                   */
		/************************************************************************/
		stream->writeSignedInt(getUpdateBits().getMask(),32);
		//xLogger::xLog(ELOGINFO,XL_START,"server is updating ghosts %d", getUpdateBits().getMask() );
		xDistributedPropertyArrayType &props = *getDistributedPorperties();
		for (unsigned int i = 0  ;  i < props.size() ; i++ )
		{
			xDistributedProperty *prop  = props[i];
			xDistributedPropertyInfo*propInfo  = prop->getPropertyInfo();
			int blockIndex = prop->getBlockIndex();
			if (propInfo)
			{
				if (getUpdateBits().testStrict(1<<blockIndex))
				{
					prop->updateGhostValue(stream);
					//xLogger::xLog(ELOGINFO,XL_START,"server is updating ghosts %d",blockIndex);
				}
			}
		}
		//getUpdateBits().clear();
	}
	return 0;
}