Esempio n. 1
0
void GPC_Engine::UpdateLoadingAnimation(void)
{
	//int delta;

	float progress = DetermineProgress();

	if(progress > m_previousProgress)
	{
//		delta = progress - m_previousProgress;
		m_previousProgress = progress;
		if(m_previousProgress > 1.0)
			m_previousProgress = 1.0;  // limit to 1.0 (has to change !)
//			m_engine->m_previousProgress = 0.0;
	}

	STR_String to = "";
	STR_String from = "";
	STR_String subject = "progress";
	STR_String body;
	body.Format("%f", progress);  // a number between 0.0 and 1.0

	if(m_networkdev)
	{
		// Store a progress message in the network device.
		NG_NetworkMessage* msg = new NG_NetworkMessage(to, from, subject, body);
		m_networkdev->SendNetworkMessage(msg);
		msg->Release();
	}
}
Esempio n. 2
0
/**
 * progress one frame, handle all network traffic
 */
void NG_NetworkScene::proceed(double curtime)
{
	if (!m_networkdevice) return;
	if (!m_networkdevice->IsOnline()) return;

	ClearAllMessageMaps();

	// read all NetworkMessages from the device
	vector<NG_NetworkMessage*> messages =
		m_networkdevice->RetrieveNetworkMessages();

	vector<NG_NetworkMessage*>::iterator mesit = messages.begin();
	for (; !(mesit == messages.end()); mesit++) {
		NG_NetworkMessage* message = (*mesit);
		vector<NG_NetworkMessage*>* tmplist=NULL;

		vector<NG_NetworkMessage*>** tmplistptr =
			m_messagesByDestinationName[message->GetDestinationName()];
		// if there is already a vector of messages, append, else create
		// a new vector and insert into map
		if (!tmplistptr) {
			tmplist = new vector<NG_NetworkMessage*>;
			m_messagesByDestinationName.insert(message->GetDestinationName(),
											   tmplist);
		} else {
			tmplist = *tmplistptr;
		}
		message->AddRef();
		tmplist->push_back(message);
		tmplist = NULL;

		tmplistptr = m_messagesBySenderName[message->GetSenderName()];
		// if there is already a vector of messages, append, else create
		// a new vector and insert into map
		if (!tmplistptr) {
			tmplist = new vector<NG_NetworkMessage*>;
			m_messagesBySenderName.insert(message->GetSenderName(), tmplist);
		}  else {
			tmplist = *tmplistptr;
		}
		message->AddRef();
		tmplist->push_back(message);
		tmplist = NULL;
		
		tmplistptr = m_messagesBySubject[message->GetSubject()];
		// if there is already a vector of messages, append, else create
		// a new vector and insert into map
		if (!tmplistptr) {
			tmplist = new vector<NG_NetworkMessage*>;
			m_messagesBySubject.insert(message->GetSubject(), tmplist);
		}  else {
			tmplist = *tmplistptr;
		}
		message->AddRef();
		tmplist->push_back(message);
		tmplist = NULL;
	}
}
Esempio n. 3
0
void NG_NetworkScene::SendMessage(
	const STR_String& to,
	const STR_String& from,
	const STR_String& subject,
	const STR_String& message)
{
	NG_NetworkMessage* msg = new NG_NetworkMessage(to, from, subject, message);
	m_networkdevice->SendNetworkMessage(msg);
	msg->Release();
}
Esempio n. 4
0
vector<NG_NetworkMessage*> NG_NetworkScene::FindMessages(
	const STR_String& to,
	const STR_String& from,
	const STR_String& subject,
	bool spamallowed)
{
	vector<NG_NetworkMessage*> foundmessages;
	bool notfound = false;

	// broad phase
	notfound = ((to.IsEmpty() || spamallowed) ? notfound : m_messagesByDestinationName[to] == NULL);
	if (!notfound)
		notfound = (from.IsEmpty() ? notfound : m_messagesBySenderName[from] == NULL);
	if (!notfound)
		notfound = (subject.IsEmpty() ? notfound : m_messagesBySubject[subject] == NULL);
	if (notfound) {
		// it's definitely NOT in the scene, so stop looking
	} else { // narrow phase
		// possibly it's there, but maybe not (false hit)
		if (to.IsEmpty()) {
			// take all messages, and check other fields
			MT_assert(!"objectnames that are empty are not valid, so make it a hobby project :)\n");
		} else {
			//todo: find intersection of messages (that are in other 2 maps)
			vector<NG_NetworkMessage*>** tolistptr = m_messagesByDestinationName[to];
			if (tolistptr) {
				vector<NG_NetworkMessage*>* tolist = *tolistptr;
				vector<NG_NetworkMessage*>::iterator listit;
				for (listit=tolist->begin();!(listit==tolist->end());listit++) {
					NG_NetworkMessage* message = *listit;
					if (ConstraintsAreValid(from, subject, message)) {
						message->AddRef();
						foundmessages.push_back(message);
					}
				} 
			}
			// TODO find intersection of messages (that are in other 2 maps)
			if (spamallowed) {
				tolistptr = m_messagesByDestinationName[""];
				if (tolistptr) {
					vector<NG_NetworkMessage*>* tolist = *tolistptr;
					vector<NG_NetworkMessage*>::iterator listit;
					for (listit=tolist->begin();!(listit==tolist->end());listit++) {
						NG_NetworkMessage* message = *listit;
						if (ConstraintsAreValid(from, subject, message)) {
							message->AddRef();
							foundmessages.push_back(message);
						}
					} 
				}
			}
		}
	} 
	return foundmessages;
}