Last Comment Wins!

Status
Not open for further replies.

Kessa

|KKK|'s Sheep Herder
Former Krew Member
I like turtles!!!

Turtles-return-to-the-mother-ship.jpg

That's an adorable picture! :D
 

Ethan

Captain
Former Krew Member
What can I say about the 571B Banana Slicer that hasn't already been said about the wheel, penicillin, or the iPhone.... this is one of the greatest inventions of all time. My husband and I would argue constantly over who had to cut the day's banana slices. It's one of those chores NO ONE wants to do! You know, the old "I spent the entire day rearing OUR children, maybe YOU can pitch in a little and cut these bananas?" and of course, "You think I have the energy to slave over your damn bananas? I worked a 12 hour shift just to come home to THIS?!" These are the things that can destroy an entire relationship. It got to the point where our children could sense the tension. The minute I heard our 6-year-old girl in her bedroom, re-enacting our daily banana fight with her Barbie dolls, I knew we had to make a change. That's when I found the 571B Banana Slicer. Our marriage has never been healthier, AND we've even incorporated it into our lovemaking. THANKS 571B BANANA SLICER!
 

Jack

|KKK|s Sexiest Voice
|K3| Member
Fuck you ethan! Fuck you and your fucking banana slicer in the butt.

 
Last edited by a moderator:

Kreubs

|K3|Minecraft Admin
|K3| Executive
I didn't know we had code tags :K

:pc:
Code:
void Host::processTheDatagram(QByteArray data) {
	QString maxNrPlayers, mapName, gameType;
	QList<QByteArray> splitArray = data.split('\\');

	qDebug() << "Message: " << splitArray.at(12);

	int index = splitArray.indexOf("g_gametype", 0);
	gameType = splitArray.at(index+1);
	if(index > 0) {
		if(gameType == "dm")
			serverData.gameType.append("Free-for-all");
		else if(gameType == "war")
			serverData.gameType.append("Team Deathmatch");
		else if(gameType == "dom")
			serverData.gameType.append("Domination");
		else if(gameType == "sd")
			serverData.gameType.append("Search & Destroy");
		else if(gameType == "cft")
			serverData.gameType.append("Capture the Flag");
		else if(gameType == "koth")
			serverData.gameType.append("Headquarters");
		else if(gameType == "sab")
			serverData.gameType.append("Sabotage");
	}
//	serverData.gameType.append(splitArray.at(index +1));

	index = splitArray.indexOf("mapname", 0);
	serverData.mapName.append(splitArray.at(index+1));

	index = splitArray.indexOf("sv_maxclients", 0);
	serverData.playerCount.second.append(splitArray.at(index+1));

	index = data.indexOf("mod\\1", 0);
	if(index < 0)
		index = data.indexOf("mod\\0", 0);

	qDebug() << data.data();

	data.remove(0, index+6); //chop the buffer down to just the player list
	data.chop(1); //remove the final newline character

	qDebug() << data.data();

	if(data.isEmpty()) {
		serverData.playerCount.first = "0";
		return;
	}

	QList<QByteArray> playerLines = data.split('\n');
	QList<QByteArray> playerLine;
	QString temp;

	serverData.playerCount.first = QString::number(playerLines.size()); //current number of players


	qDebug() << playerLines;

	for(int i = 0; i < playerLines.size(); i++) {
		temp.clear();
		playerLine = playerLines[i].split(' '); //split up data for a single player
		qDebug() << playerLine;
		if(!playerLine[0].isEmpty()) {
			serverData.playerScores.push_back(playerLine[0]); //add score
			serverData.playerPings.push_back(playerLine[1]); //add ping
		}
		else {
			return;
		}
		for(int j = 2; j < playerLine.size(); j++) {
			 temp.append(playerLine[j] + " "); //put the name back together
		}
		serverData.playerNames.push_back(temp); //add the name
	}

	for(int i = 0; i < playerLines.size(); i++) {
		serverData.playerNames[i].remove("\""); //remove all quotation marks from player names
		serverData.playerNames[i] = serverData.playerNames[i].trimmed();
	}

	//------------------------------sort by score------------------------------
	int pos = 1;
	while(pos < playerLines.size()){
		if (serverData.playerScores[pos].toInt() <= serverData.playerScores[pos-1].toInt()) {
			pos++;
		}
		else {
			qDebug() << serverData.playerScores;
			serverData.playerScores.swap(pos, pos-1);
			qDebug() << serverData.playerScores;

			serverData.playerPings.swap(pos, pos-1);
			serverData.playerNames.swap(pos, pos-1);
			if (pos > 1) {
				pos--;
			}
		}
	}
	//-------------------------------------------------------------------------
}
 
Status
Not open for further replies.
Top Bottom