← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/irc_users into lp:widelands

 

Notabilis has proposed merging lp:~widelands-dev/widelands/irc_users into lp:widelands.

Commit message:
Sorting IRC users behind the players in the lobby.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/irc_users/+merge/335898

When the next version of the metaserver is deployed [1], IRC users will also be listed in the lobby as players with a build-id of "IRC". Currently, this leads to a long list of IRC users followed by a few entries of players.

With this branch, IRC users are listed after the online players. Additionally, no "user status" (unregistered, ...) is displayed for them.

[1] https://github.com/widelands/widelands_metaserver/pull/19
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/irc_users into lp:widelands.
=== modified file 'src/network/internet_gaming.cc'
--- src/network/internet_gaming.cc	2017-11-30 20:45:41 +0000
+++ src/network/internet_gaming.cc	2018-01-09 19:14:51 +0000
@@ -537,21 +537,29 @@
 			// Client received the new list of clients
 			uint8_t number = boost::lexical_cast<int>(packet.string()) & 0xff;
 			std::vector<InternetClient> old = clientlist_;
+			// Push IRC users to a second list and add them to the back
+			std::vector<InternetClient> irc;
 			clientlist_.clear();
 			log("InternetGaming: Received a client list update with %u items.\n", number);
+			InternetClient inc;
 			for (uint8_t i = 0; i < number; ++i) {
-				InternetClient* inc = new InternetClient();
-				inc->name = packet.string();
-				inc->build_id = packet.string();
-				inc->game = packet.string();
-				inc->type = packet.string();
-				inc->points = packet.string();
-				clientlist_.push_back(*inc);
+				inc.name = packet.string();
+				inc.build_id = packet.string();
+				inc.game = packet.string();
+				inc.type = packet.string();
+				inc.points = packet.string();
+				if (inc.build_id == "IRC") {
+					irc.push_back(inc);
+					// No "join" or "left" messages for IRC users
+					continue;
+				}
+				// No IRC client
+				clientlist_.push_back(inc);
 
 				bool found =
 				   old.empty();  // do not show all clients, if this instance is the actual change
 				for (InternetClient& client : old) {
-					if (client.name == inc->name) {
+					if (client.name == inc.name) {
 						found = true;
 						client.name = "";
 						break;
@@ -559,14 +567,12 @@
 				}
 				if (!found)
 					format_and_add_chat(
-					   "", "", true, (boost::format(_("%s joined the lobby")) % inc->name).str());
-
-				delete inc;
-				inc = nullptr;
+					   "", "", true, (boost::format(_("%s joined the lobby")) % inc.name).str());
 			}
+			clientlist_.insert(clientlist_.end(), irc.begin(), irc.end());
 
 			for (InternetClient& client : old) {
-				if (client.name.size()) {
+				if (client.name.size() && client.build_id != "IRC") {
 					format_and_add_chat(
 					   "", "", true, (boost::format(_("%s left the lobby")) % client.name).str());
 				}

=== modified file 'src/ui_fsmenu/internet_lobby.cc'
--- src/ui_fsmenu/internet_lobby.cc	2017-12-19 07:17:15 +0000
+++ src/ui_fsmenu/internet_lobby.cc	2018-01-09 19:14:51 +0000
@@ -262,6 +262,11 @@
 			er.set_string(2, client.build_id);
 			er.set_string(3, client.game);
 
+			if (client.build_id == "IRC") {
+				// No icon for IRC users
+				continue;
+			}
+
 			const Image* pic;
 			switch (convert_clienttype(client.type)) {
 			case 0:  // UNREGISTERED
@@ -296,6 +301,11 @@
 	if (clientsonline_list_.has_selection()) {
 		UI::Table<const InternetClient* const>::EntryRecord& er = clientsonline_list_.get_record(i);
 
+		if (er.get_string(2) == "IRC") {
+			// No PM to IRC users
+			return;
+		}
+
 		std::string temp("@");
 		temp += er.get_string(1);
 		std::string text(chat.get_edit_text());


Follow ups