Merge lp:~widelands-dev/widelands/net-user-type into lp:widelands
- net-user-type
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 8674 |
Proposed branch: | lp:~widelands-dev/widelands/net-user-type |
Merge into: | lp:widelands |
Diff against target: |
244 lines (+41/-56) 6 files modified
src/network/internet_gaming.cc (+3/-12) src/network/internet_gaming.h (+0/-1) src/network/internet_gaming_protocol.h (+4/-7) src/ui_fsmenu/internet_lobby.cc (+21/-19) src/wui/gamechatpanel.cc (+12/-16) src/wui/gamechatpanel.h (+1/-1) |
To merge this branch: | bzr merge lp:~widelands-dev/widelands/net-user-type |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Klaus Halfmann | review, compile | Approve | |
GunChleoc | Approve | ||
Review via email: mp+343754@code.launchpad.net |
Commit message
Cleaner transmission of client status
Description of the change
Some small changes regarding transmitted client status and IRC clients.
- That a metaserver client is an IRC user is now transmitted as permission instead of as build-id. Avoids the theoretical problem that a Widelands client could have a build-id of "IRC".
- No longer block private messages to IRC users client side. This is now blocked on the metaserver.
- No longer sending (not existing) "points" of a user when transmitting the client list. If someone has an objection against removing these "points" (e.g., there are plans to use them), please say so.
- cleaning up code for "messages beeps" when receiving a non-system message.
Note: Don't merge/deploy this, I should do that myself since the protocol version has not been changed yet.
Notabilis (notabilis27) wrote : | # |
GunChleoc (gunchleoc) wrote : | # |
I don't know anything about bots, sorry.
I think the points can go - they were never displayed anyway, and the screen space is now used for displaying the client version.
Code LGTM :)
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 3393. State: passed. Details: https:/
Appveyor build 3199. State: success. Details: https:/
Klaus Halfmann (klaus-halfmann) wrote : | # |
* I assume that "BOT" was intended for chat or game Bots (we have/had some on irc, do we?)
* A first review of the diffs shows me no obvious Issues, some nits in the comments.
* I will now compile the code an do some review on the complete internet_gaming* files.
(More for me to get familiar with that code)
* Notabalis: I will try to be online with that version starting at perhaps 16:00 CEST,
so we can try you changes "live" in chat and on IRC.
Maybe we can hunt down these IRC Bots, too?
* GunCheloc: FYI with latest XCode updates Apple has pushed clang to a newer version,
so a lot of newer options finally work here and some warnigns are finally gone:
Apple LLVM version 9.1.0 (clang-902.0.39.1)
Target: x86_64-
Thread model: posix
InstalledDir: /Applications/
Klaus Halfmann (klaus-halfmann) wrote : | # |
I checekd the Multiplayer lobby and it looks garbled now,
will you need a screenshot?
I did a small improvemenet in gamechatpanel.cc, not sure if I should commit it?
GunChleoc (gunchleoc) wrote : | # |
@Klaus: Glad it's working better now. I have opened a bug to update Travis with the new version too: https:/
Notabilis (notabilis27) wrote : | # |
Sorry, should have mentioned it: This branch is not compatible with the currently running metaserver. So its "fine" that it looks strange.
Feel free to commit your change. I will look at your suggestions later on.
Notabilis (notabilis27) wrote : | # |
It looks indeed as it might have been a game or chat bot. But I don't know whether there have been any at some time. I am not aware of any that are currently active.
Thanks for the review and for fixing the one nit. I replaced the numeric constants with const variables, an enum wasn't possible since we have to compare the values. But it looks much better now.
Regarding testing this branch: If you want to test a branch which changes something on the online gaming protocol (or the relay protocol), you have to run your own metaserver based on the matching branch of it (https:/
To make widelands use your local metaserver, start it with "--metaserver=
GunChleoc (gunchleoc) wrote : | # |
Can you please document the metaserver option in a separate branch? This is where it should go:
https:/
Notabilis (notabilis27) wrote : | # |
Oh! I wasn't aware that this isn't documented. Thanks for the pointer, I will do so.
kaputtnik (franku) wrote : | # |
The bot is maybe a holdover from the time ggz was used?
Klaus Halfmann (klaus-halfmann) wrote : | # |
Sorry I was unable to the get wlms server going:
klaus$ ./go/bin/wlms
2018/05/01 10:07:50 No configuration found, using in-memory database
2018/05/01 10:07:50 Using 127.0.0.1 and fe80::1 as IP addresses of the relay
2018/05/01 10:07:50 Unable to connect to relay server at localhost: dial tcp [::1]:7398: connect: connection refused
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x13152c1]
goroutine 53 [running]:
main.(*
/Users/
created by main.CreateServ
/Users/
And I was unbale to git checkout that pullrequerst, either. No time to really deep dive into that code yet.
Still the code change is ok for me. So how to we get this into the offical server now?
GunChleoc (gunchleoc) wrote : | # |
> So how to we get this into the offical server now?
We leave that up to Notabilis. He knows how to do it :)
Do not merge this branch, let him handle it, because it needs to be coordinated.
Notabilis (notabilis27) wrote : | # |
Hm, well... Unfortunately its not easy to get it running, actually I am surprised you got that far. I had quite some trouble getting it compiled when I first tried to.
What is missing in your case is a running relay server. Seems that the "documentation" is incomplete, sorry for that. You have to compile and run the wlnr executable, afterwards the wlms can connect to it and it should start correctly.
Currently I am working on some semi-automated test scripts for the metaserver but they are far from useful yet.
I will do some local testing with my three branches now and if they work together, I will merge and deploy them.
Notabilis (notabilis27) wrote : | # |
@bunnybot merge
Notabilis (notabilis27) wrote : | # |
Thanks for the reviews! The new version is online and seems to be working. If someone notices a bug, please say so.
GunChleoc (gunchleoc) wrote : | # |
Will do. Thanks!
Preview Diff
1 | === modified file 'src/network/internet_gaming.cc' |
2 | --- src/network/internet_gaming.cc 2018-04-07 16:59:00 +0000 |
3 | +++ src/network/internet_gaming.cc 2018-04-22 16:47:03 +0000 |
4 | @@ -606,8 +606,7 @@ |
5 | inc.build_id = packet.string(); |
6 | inc.game = packet.string(); |
7 | inc.type = packet.string(); |
8 | - inc.points = packet.string(); |
9 | - if (inc.build_id == "IRC") { |
10 | + if (inc.type == INTERNET_CLIENT_IRC) { |
11 | irc.push_back(inc); |
12 | // No "join" or "left" messages for IRC users |
13 | continue; |
14 | @@ -631,7 +630,7 @@ |
15 | clientlist_.insert(clientlist_.end(), irc.begin(), irc.end()); |
16 | |
17 | for (InternetClient& client : old) { |
18 | - if (client.name.size() && client.build_id != "IRC") { |
19 | + if (client.name.size() && client.type != INTERNET_CLIENT_IRC) { |
20 | format_and_add_chat( |
21 | "", "", true, (boost::format(_("%s left the lobby")) % client.name).str()); |
22 | } |
23 | @@ -867,17 +866,9 @@ |
24 | _("Message could not be sent: Was this supposed to be a private message?")); |
25 | return; |
26 | } |
27 | - std::string recipient = msg.substr(1, space - 1); |
28 | - for (const InternetClient& client : clientlist_) { |
29 | - if (recipient == client.name && client.build_id == "IRC") { |
30 | - format_and_add_chat( |
31 | - "", "", true, _("Private messages to IRC users are not supported.")); |
32 | - return; |
33 | - } |
34 | - } |
35 | |
36 | s.string(trimmed); // message |
37 | - s.string(recipient); // recipient |
38 | + s.string(msg.substr(1, space - 1)); // recipient |
39 | |
40 | format_and_add_chat(clientname_, msg.substr(1, space - 1), false, msg.substr(space + 1)); |
41 | |
42 | |
43 | === modified file 'src/network/internet_gaming.h' |
44 | --- src/network/internet_gaming.h 2018-04-07 16:59:00 +0000 |
45 | +++ src/network/internet_gaming.h 2018-04-22 16:47:03 +0000 |
46 | @@ -37,7 +37,6 @@ |
47 | std::string build_id; |
48 | std::string game; |
49 | std::string type; |
50 | - std::string points; // Currently unused |
51 | }; |
52 | |
53 | /// A simple network game struct |
54 | |
55 | === modified file 'src/network/internet_gaming_protocol.h' |
56 | --- src/network/internet_gaming_protocol.h 2018-04-07 16:59:00 +0000 |
57 | +++ src/network/internet_gaming_protocol.h 2018-04-22 16:47:03 +0000 |
58 | @@ -71,7 +71,7 @@ |
59 | static const std::string INTERNET_CLIENT_UNREGISTERED = "UNREGISTERED"; |
60 | static const std::string INTERNET_CLIENT_REGISTERED = "REGISTERED"; |
61 | static const std::string INTERNET_CLIENT_SUPERUSER = "SUPERUSER"; |
62 | -static const std::string INTERNET_CLIENT_BOT = "BOT"; |
63 | +static const std::string INTERNET_CLIENT_IRC = "IRC"; |
64 | |
65 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
66 | * COMMUNICATION PROTOCOL BETWEEN CLIENT AND METASERVER * |
67 | @@ -322,10 +322,8 @@ |
68 | |
69 | /** |
70 | * Sent by the metaserver to inform the client, that the list of clients was changed. No payload is |
71 | - * sent, |
72 | - * as e.g. clients in a game are not really interested about other clients and we want to keep |
73 | - * traffic |
74 | - * as low as possible. |
75 | + * sent, as e.g. clients in a game are not really interested about other clients and we want to |
76 | + * keep traffic as low as possible. |
77 | * |
78 | * To get the new list of clients, the client must send \ref IGPCMD_CLIENT |
79 | */ |
80 | @@ -338,9 +336,8 @@ |
81 | * \li string: Number of client packages and for uint8_t i = 0; i < num; ++i {: |
82 | * \li string: Name of the client |
83 | * \li string: Widelands version |
84 | - * \li string: Game the player is connected to, else empty. |
85 | + * \li string: Game the player is connected to, else empty |
86 | * \li string: Clients rights (see client rights section above) |
87 | - * \li string: Points of the client |
88 | * } |
89 | */ |
90 | static const std::string IGPCMD_CLIENTS = "CLIENTS"; |
91 | |
92 | === modified file 'src/ui_fsmenu/internet_lobby.cc' |
93 | --- src/ui_fsmenu/internet_lobby.cc 2018-04-07 16:59:00 +0000 |
94 | +++ src/ui_fsmenu/internet_lobby.cc 2018-04-22 16:47:03 +0000 |
95 | @@ -35,6 +35,16 @@ |
96 | #include "random/random.h" |
97 | #include "ui_basic/messagebox.h" |
98 | |
99 | +namespace { |
100 | + |
101 | + // Constants for convert_clienttype() / compare_clienttype() |
102 | + const uint8_t kClientUnregistered = 0; |
103 | + const uint8_t kClientRegistered = 1; |
104 | + const uint8_t kClientSuperuser = 2; |
105 | + // 3 was INTERNET_CLIENT_BOT which is not used |
106 | + const uint8_t kClientIRC = 4; |
107 | +} |
108 | + |
109 | FullscreenMenuInternetLobby::FullscreenMenuInternetLobby(char const* const nick, |
110 | char const* const pwd, |
111 | bool registered) |
112 | @@ -232,13 +242,13 @@ |
113 | |
114 | uint8_t FullscreenMenuInternetLobby::convert_clienttype(const std::string& type) { |
115 | if (type == INTERNET_CLIENT_REGISTERED) |
116 | - return 1; |
117 | + return kClientRegistered; |
118 | if (type == INTERNET_CLIENT_SUPERUSER) |
119 | - return 2; |
120 | - if (type == INTERNET_CLIENT_BOT) |
121 | - return 3; |
122 | + return kClientSuperuser; |
123 | + if (type == INTERNET_CLIENT_IRC) |
124 | + return kClientIRC; |
125 | // if (type == INTERNET_CLIENT_UNREGISTERED) |
126 | - return 0; |
127 | + return kClientUnregistered; |
128 | } |
129 | |
130 | /** |
131 | @@ -262,27 +272,24 @@ |
132 | er.set_string(2, client.build_id); |
133 | er.set_string(3, client.game); |
134 | |
135 | - if (client.build_id == "IRC") { |
136 | - // No icon for IRC users |
137 | - continue; |
138 | - } |
139 | - |
140 | const Image* pic; |
141 | switch (convert_clienttype(client.type)) { |
142 | - case 0: // UNREGISTERED |
143 | + case kClientUnregistered: |
144 | pic = g_gr->images().get("images/wui/overlays/roadb_red.png"); |
145 | er.set_picture(0, pic); |
146 | break; |
147 | - case 1: // REGISTERED |
148 | + case kClientRegistered: |
149 | pic = g_gr->images().get("images/wui/overlays/roadb_yellow.png"); |
150 | er.set_picture(0, pic); |
151 | break; |
152 | - case 2: // SUPERUSER |
153 | - case 3: // BOT |
154 | + case kClientSuperuser: |
155 | pic = g_gr->images().get("images/wui/overlays/roadb_green.png"); |
156 | er.set_color(RGBColor(0, 255, 0)); |
157 | er.set_picture(0, pic); |
158 | break; |
159 | + case kClientIRC: |
160 | + // No icon for IRC users |
161 | + continue; |
162 | default: |
163 | continue; |
164 | } |
165 | @@ -301,11 +308,6 @@ |
166 | if (clientsonline_list_.has_selection()) { |
167 | UI::Table<const InternetClient* const>::EntryRecord& er = clientsonline_list_.get_record(i); |
168 | |
169 | - if (er.get_string(2) == "IRC") { |
170 | - // No PM to IRC users |
171 | - return; |
172 | - } |
173 | - |
174 | std::string temp("@"); |
175 | temp += er.get_string(1); |
176 | std::string text(chat.get_edit_text()); |
177 | |
178 | === modified file 'src/wui/gamechatpanel.cc' |
179 | --- src/wui/gamechatpanel.cc 2018-04-07 16:59:00 +0000 |
180 | +++ src/wui/gamechatpanel.cc 2018-04-22 16:47:03 +0000 |
181 | @@ -45,7 +45,7 @@ |
182 | g_gr->images().get("images/ui_basic/but1.png"), |
183 | UI::MultilineTextarea::ScrollMode::kScrollLogForced), |
184 | editbox(this, 0, h - 20, w, 20, 2), |
185 | - chat_message_counter(std::numeric_limits<uint32_t>::max()) { |
186 | + chat_message_counter(0) { |
187 | editbox.ok.connect(boost::bind(&GameChatPanel::key_enter, this)); |
188 | editbox.cancel.connect(boost::bind(&GameChatPanel::key_escape, this)); |
189 | editbox.activate_history(true); |
190 | @@ -65,31 +65,27 @@ |
191 | void GameChatPanel::recalculate() { |
192 | const std::vector<ChatMessage> msgs = chat_.get_messages(); |
193 | |
194 | + size_t msgs_size = msgs.size(); |
195 | std::string str = "<rt>"; |
196 | - for (uint32_t i = 0; i < msgs.size(); ++i) { |
197 | + for (uint32_t i = 0; i < msgs_size; ++i) { |
198 | str += format_as_richtext(msgs[i]); |
199 | } |
200 | str += "</rt>"; |
201 | |
202 | chatbox.set_text(str); |
203 | |
204 | - // If there are new messages, play a sound |
205 | - if (0 < msgs.size() && msgs.size() != chat_message_counter) { |
206 | - // computer generated ones are ignored |
207 | - // Note: if many messages arrive simultaneously, |
208 | - // the latest is a system message and some others |
209 | - // are not, then this act wrong! |
210 | - if (!msgs.back().sender.empty() && !chat_.sound_off()) { |
211 | - // The latest message is not a system message |
212 | - if (std::string::npos == msgs.back().sender.find("(IRC)") && |
213 | - chat_message_counter < msgs.size()) { |
214 | - // The latest message was not relayed from IRC. |
215 | - // The above built-in string constant should match |
216 | - // that of the IRC bridge. |
217 | + if (chat_message_counter < msgs_size) { // are there new messages? |
218 | + if (!chat_.sound_off()) { // play a sound, if needed |
219 | + for (size_t i = chat_message_counter; i < msgs_size; ++i) { |
220 | + if (msgs[i].sender.empty()) { |
221 | + continue; // System message. Don't play a sound |
222 | + } |
223 | + // Got a message that is no system message. Beep |
224 | play_new_chat_message(); |
225 | + break; |
226 | } |
227 | } |
228 | - chat_message_counter = msgs.size(); |
229 | + chat_message_counter = msgs_size; |
230 | } |
231 | } |
232 | |
233 | |
234 | === modified file 'src/wui/gamechatpanel.h' |
235 | --- src/wui/gamechatpanel.h 2018-04-07 16:59:00 +0000 |
236 | +++ src/wui/gamechatpanel.h 2018-04-22 16:47:03 +0000 |
237 | @@ -58,7 +58,7 @@ |
238 | ChatProvider& chat_; |
239 | UI::MultilineTextarea chatbox; |
240 | UI::EditBox editbox; |
241 | - uint32_t chat_message_counter; |
242 | + size_t chat_message_counter; |
243 | std::unique_ptr<Notifications::Subscriber<ChatMessage>> chat_message_subscriber_; |
244 | }; |
245 |
Oh, and does someone know something about the "bots"?
static const std::string INTERNET_CLIENT_BOT = "BOT";
I removed it now since it does not seem to be used, neither in Widelands nor on the metaserver.