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
1=== modified file 'src/network/internet_gaming.cc'
2--- src/network/internet_gaming.cc 2017-11-30 20:45:41 +0000
3+++ src/network/internet_gaming.cc 2018-01-28 19:08:17 +0000
4@@ -170,8 +170,7 @@
5 if (state_ == LOBBY) {
6 if (!should_relogin) {
7 format_and_add_chat(
8- "", "", true, _("For hosting a game, please take a look at the notes at:"));
9- format_and_add_chat("", "", true, "http://wl.widelands.org/wiki/InternetGaming");
10+ "", "", true, _("Users marked with IRC will possibly not react to messages."));
11 }
12
13 // Try to establish a second connection to tell the metaserver about our IPv4 address
14@@ -537,21 +536,29 @@
15 // Client received the new list of clients
16 uint8_t number = boost::lexical_cast<int>(packet.string()) & 0xff;
17 std::vector<InternetClient> old = clientlist_;
18+ // Push IRC users to a second list and add them to the back
19+ std::vector<InternetClient> irc;
20 clientlist_.clear();
21 log("InternetGaming: Received a client list update with %u items.\n", number);
22+ InternetClient inc;
23 for (uint8_t i = 0; i < number; ++i) {
24- InternetClient* inc = new InternetClient();
25- inc->name = packet.string();
26- inc->build_id = packet.string();
27- inc->game = packet.string();
28- inc->type = packet.string();
29- inc->points = packet.string();
30- clientlist_.push_back(*inc);
31+ inc.name = packet.string();
32+ inc.build_id = packet.string();
33+ inc.game = packet.string();
34+ inc.type = packet.string();
35+ inc.points = packet.string();
36+ if (inc.build_id == "IRC") {
37+ irc.push_back(inc);
38+ // No "join" or "left" messages for IRC users
39+ continue;
40+ }
41+ // No IRC client
42+ clientlist_.push_back(inc);
43
44 bool found =
45 old.empty(); // do not show all clients, if this instance is the actual change
46 for (InternetClient& client : old) {
47- if (client.name == inc->name) {
48+ if (client.name == inc.name) {
49 found = true;
50 client.name = "";
51 break;
52@@ -559,14 +566,12 @@
53 }
54 if (!found)
55 format_and_add_chat(
56- "", "", true, (boost::format(_("%s joined the lobby")) % inc->name).str());
57-
58- delete inc;
59- inc = nullptr;
60+ "", "", true, (boost::format(_("%s joined the lobby")) % inc.name).str());
61 }
62+ clientlist_.insert(clientlist_.end(), irc.begin(), irc.end());
63
64 for (InternetClient& client : old) {
65- if (client.name.size()) {
66+ if (client.name.size() && client.build_id != "IRC") {
67 format_and_add_chat(
68 "", "", true, (boost::format(_("%s left the lobby")) % client.name).str());
69 }
70@@ -800,8 +805,18 @@
71 _("Message could not be sent: Was this supposed to be a private message?"));
72 return;
73 }
74+ std::string recipient = msg.substr(1, space - 1);
75+ for (const InternetClient& client : clientlist_) {
76+ if (recipient == client.name && client.build_id == "IRC") {
77+ format_and_add_chat(
78+ "", "", true,
79+ _("Private messages to IRC users are not supported."));
80+ return;
81+ }
82+ }
83+
84 s.string(trimmed); // message
85- s.string(msg.substr(1, space - 1)); // recipient
86+ s.string(recipient); // recipient
87
88 format_and_add_chat(clientname_, msg.substr(1, space - 1), false, msg.substr(space + 1));
89
90
91=== modified file 'src/ui_fsmenu/internet_lobby.cc'
92--- src/ui_fsmenu/internet_lobby.cc 2017-12-19 07:17:15 +0000
93+++ src/ui_fsmenu/internet_lobby.cc 2018-01-28 19:08:17 +0000
94@@ -262,6 +262,11 @@
95 er.set_string(2, client.build_id);
96 er.set_string(3, client.game);
97
98+ if (client.build_id == "IRC") {
99+ // No icon for IRC users
100+ continue;
101+ }
102+
103 const Image* pic;
104 switch (convert_clienttype(client.type)) {
105 case 0: // UNREGISTERED
106@@ -296,6 +301,11 @@
107 if (clientsonline_list_.has_selection()) {
108 UI::Table<const InternetClient* const>::EntryRecord& er = clientsonline_list_.get_record(i);
109
110+ if (er.get_string(2) == "IRC") {
111+ // No PM to IRC users
112+ return;
113+ }
114+
115 std::string temp("@");
116 temp += er.get_string(1);
117 std::string text(chat.get_edit_text());

Subscribers

People subscribed via source and target branches

to status/vote changes: