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

Proposed by Notabilis
Status: Merged
Merged at revision: 8570
Proposed branch: lp:~widelands-dev/widelands/irc_users
Merge into: lp:widelands
Diff against target: 117 lines (+41/-16)
2 files modified
src/network/internet_gaming.cc (+31/-16)
src/ui_fsmenu/internet_lobby.cc (+10/-0)
To merge this branch: bzr merge lp:~widelands-dev/widelands/irc_users
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+335898@code.launchpad.net

Commit message

Sorting IRC users behind the players in the lobby.

Description of the change

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

To post a comment you must log in.
Revision history for this message
Notabilis (notabilis27) wrote :

Additionally, I wanted to color the lines of the IRC users in gray. However, this did not work.
- A <rt><font ...> directive was printed as text.
- The existing Table::EntryRecord::set_color() method seems to be broken. At least, it does nothing and I can't find code that reads the set color.
I wouldn't mind leaving it as it is, though. Without the status symbols the lines stand out enough in my opinion.

When logging in to the metaserver, the user is greeted by the (obsolete) message "For hosting a game, ...". Maybe add a similar message "Users on IRC are unlikely to react to chat messages"? I think in the past we had some users on the forum which complained about not getting any answers.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 3041. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/326955621.
Appveyor build 2849. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_irc_users-2849.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I think a note is a good idea.

Don't worry about the colors - I already have a WIP branch where I have implemented fullscreen switching, so it would make more sense to implement it there to avoid merge conflicts, or wait until that branch has been merged. We could also open a bug for it.

Code LGTM, not tested.

review: Approve
Revision history for this message
Notabilis (notabilis27) wrote :

When joining the lobby a note is printed now. Additionally, trying to send a private message to IRC users is aborted with a messages, since it does not work and there would never be a response.

Thanks for the explanation regarding the colors. When no-one complains we can leave it as it is right now, otherwise we can still change it later.

The related metaserver branch has been deployed so this can be tested now. As far as I am concerned, this branch can go in.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 3044. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/328332356.
Appveyor build 2852. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_irc_users-2852.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Code still LGTM, 1 nit.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I have now done some testing, looks good.

Merge any time you're ready after fixing the nit :)

Revision history for this message
Notabilis (notabilis27) wrote :

Was already done. ;)
Thanks!

@bunnybot merge

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 3065. State: canceled. Details: https://travis-ci.org/widelands/widelands/builds/329644718.
Appveyor build 2872. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_irc_users-2872.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Refusing to merge, since Travis is not green. Use @bunnybot merge force for merging anyways.

Travis build 3065. State: canceled. Details: https://travis-ci.org/widelands/widelands/builds/329644718.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Can you please merge trunk again to make Travis go green?

Revision history for this message
SirVer (sirver) wrote :

I did the merge of master.

@bunnybot merge

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 3107. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/334452896.
Appveyor build 2914. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_irc_users-2914.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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-28 19:08:17 +0000
@@ -170,8 +170,7 @@
170 if (state_ == LOBBY) {170 if (state_ == LOBBY) {
171 if (!should_relogin) {171 if (!should_relogin) {
172 format_and_add_chat(172 format_and_add_chat(
173 "", "", true, _("For hosting a game, please take a look at the notes at:"));173 "", "", true, _("Users marked with IRC will possibly not react to messages."));
174 format_and_add_chat("", "", true, "http://wl.widelands.org/wiki/InternetGaming");
175 }174 }
176175
177 // Try to establish a second connection to tell the metaserver about our IPv4 address176 // Try to establish a second connection to tell the metaserver about our IPv4 address
@@ -537,21 +536,29 @@
537 // Client received the new list of clients536 // Client received the new list of clients
538 uint8_t number = boost::lexical_cast<int>(packet.string()) & 0xff;537 uint8_t number = boost::lexical_cast<int>(packet.string()) & 0xff;
539 std::vector<InternetClient> old = clientlist_;538 std::vector<InternetClient> old = clientlist_;
539 // Push IRC users to a second list and add them to the back
540 std::vector<InternetClient> irc;
540 clientlist_.clear();541 clientlist_.clear();
541 log("InternetGaming: Received a client list update with %u items.\n", number);542 log("InternetGaming: Received a client list update with %u items.\n", number);
543 InternetClient inc;
542 for (uint8_t i = 0; i < number; ++i) {544 for (uint8_t i = 0; i < number; ++i) {
543 InternetClient* inc = new InternetClient();545 inc.name = packet.string();
544 inc->name = packet.string();546 inc.build_id = packet.string();
545 inc->build_id = packet.string();547 inc.game = packet.string();
546 inc->game = packet.string();548 inc.type = packet.string();
547 inc->type = packet.string();549 inc.points = packet.string();
548 inc->points = packet.string();550 if (inc.build_id == "IRC") {
549 clientlist_.push_back(*inc);551 irc.push_back(inc);
552 // No "join" or "left" messages for IRC users
553 continue;
554 }
555 // No IRC client
556 clientlist_.push_back(inc);
550557
551 bool found =558 bool found =
552 old.empty(); // do not show all clients, if this instance is the actual change559 old.empty(); // do not show all clients, if this instance is the actual change
553 for (InternetClient& client : old) {560 for (InternetClient& client : old) {
554 if (client.name == inc->name) {561 if (client.name == inc.name) {
555 found = true;562 found = true;
556 client.name = "";563 client.name = "";
557 break;564 break;
@@ -559,14 +566,12 @@
559 }566 }
560 if (!found)567 if (!found)
561 format_and_add_chat(568 format_and_add_chat(
562 "", "", true, (boost::format(_("%s joined the lobby")) % inc->name).str());569 "", "", true, (boost::format(_("%s joined the lobby")) % inc.name).str());
563
564 delete inc;
565 inc = nullptr;
566 }570 }
571 clientlist_.insert(clientlist_.end(), irc.begin(), irc.end());
567572
568 for (InternetClient& client : old) {573 for (InternetClient& client : old) {
569 if (client.name.size()) {574 if (client.name.size() && client.build_id != "IRC") {
570 format_and_add_chat(575 format_and_add_chat(
571 "", "", true, (boost::format(_("%s left the lobby")) % client.name).str());576 "", "", true, (boost::format(_("%s left the lobby")) % client.name).str());
572 }577 }
@@ -800,8 +805,18 @@
800 _("Message could not be sent: Was this supposed to be a private message?"));805 _("Message could not be sent: Was this supposed to be a private message?"));
801 return;806 return;
802 }807 }
808 std::string recipient = msg.substr(1, space - 1);
809 for (const InternetClient& client : clientlist_) {
810 if (recipient == client.name && client.build_id == "IRC") {
811 format_and_add_chat(
812 "", "", true,
813 _("Private messages to IRC users are not supported."));
814 return;
815 }
816 }
817
803 s.string(trimmed); // message818 s.string(trimmed); // message
804 s.string(msg.substr(1, space - 1)); // recipient819 s.string(recipient); // recipient
805820
806 format_and_add_chat(clientname_, msg.substr(1, space - 1), false, msg.substr(space + 1));821 format_and_add_chat(clientname_, msg.substr(1, space - 1), false, msg.substr(space + 1));
807822
808823
=== 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-28 19:08:17 +0000
@@ -262,6 +262,11 @@
262 er.set_string(2, client.build_id);262 er.set_string(2, client.build_id);
263 er.set_string(3, client.game);263 er.set_string(3, client.game);
264264
265 if (client.build_id == "IRC") {
266 // No icon for IRC users
267 continue;
268 }
269
265 const Image* pic;270 const Image* pic;
266 switch (convert_clienttype(client.type)) {271 switch (convert_clienttype(client.type)) {
267 case 0: // UNREGISTERED272 case 0: // UNREGISTERED
@@ -296,6 +301,11 @@
296 if (clientsonline_list_.has_selection()) {301 if (clientsonline_list_.has_selection()) {
297 UI::Table<const InternetClient* const>::EntryRecord& er = clientsonline_list_.get_record(i);302 UI::Table<const InternetClient* const>::EntryRecord& er = clientsonline_list_.get_record(i);
298303
304 if (er.get_string(2) == "IRC") {
305 // No PM to IRC users
306 return;
307 }
308
299 std::string temp("@");309 std::string temp("@");
300 temp += er.get_string(1);310 temp += er.get_string(1);
301 std::string text(chat.get_edit_text());311 std::string text(chat.get_edit_text());

Subscribers

People subscribed via source and target branches

to status/vote changes: