Merge lp:~widelands-dev/widelands/bug-1797702-spaces-in-names-clean-start into lp:widelands

Proposed by Toni Förster
Status: Merged
Merged at revision: 9120
Proposed branch: lp:~widelands-dev/widelands/bug-1797702-spaces-in-names-clean-start
Merge into: lp:widelands
Prerequisite: lp:~widelands-dev/widelands/bug-1827786-metaserver-login-box-clean-start
Diff against target: 86 lines (+26/-4)
3 files modified
src/network/gamehost.cc (+3/-3)
src/ui_basic/editbox.h (+4/-0)
src/ui_fsmenu/netsetup_lan.cc (+19/-1)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1797702-spaces-in-names-clean-start
Reviewer Review Type Date Requested Status
Toni Förster Approve
Review via email: mp+367314@code.launchpad.net

This proposal supersedes a proposal from 2019-05-11.

Commit message

rework netsetup

- allowed characters are limited
- login with empty username not allowed
- if username ist taken append number
- don't join game with empty username

editbox

- added has_warning()

To post a comment you must log in.
Revision history for this message
Toni Förster (stonerl) wrote :

This is the same as this one:

https://code.launchpad.net/~widelands-dev/widelands/bug-1797702-spaces-in-names/+merge/367123

The old one got approved but was merged too early. This is the third patch that needs to go in when the others have been merged

review: Approve
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4948. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/531272166.
Appveyor build 4729. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1797702_spaces_in_names_clean_start-4729.

Revision history for this message
GunChleoc (gunchleoc) wrote :

There is some code duplication that I'd like to see solved.

Revision history for this message
Toni Förster (stonerl) wrote :

Solved :)

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5034. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/536418869.
Appveyor build 4814. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1797702_spaces_in_names_clean_start-4814.

Revision history for this message
Toni Förster (stonerl) wrote :

Since the parent branch has been merged, this can go in as well.

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/network/gamehost.cc'
2--- src/network/gamehost.cc 2019-05-11 18:50:30 +0000
3+++ src/network/gamehost.cc 2019-05-23 17:14:57 +0000
4@@ -1621,13 +1621,13 @@
5
6 // Assign the player a name, preferably the name chosen by the client
7 if (playername.empty()) // Make sure there is at least a name base.
8- playername = _("Player");
9+ playername = "Player";
10 std::string effective_name = playername;
11
12 if (has_user_name(effective_name, client.usernum)) {
13- uint32_t i = 2;
14+ uint32_t i = 1;
15 do {
16- effective_name = (boost::format(_("Player %u")) % i++).str();
17+ effective_name = (boost::format("%s%u") % playername % i++).str();
18 } while (has_user_name(effective_name, client.usernum));
19 }
20
21
22=== modified file 'src/ui_basic/editbox.h'
23--- src/ui_basic/editbox.h 2019-05-23 17:14:56 +0000
24+++ src/ui_basic/editbox.h 2019-05-23 17:14:57 +0000
25@@ -80,6 +80,10 @@
26 warning_ = warn;
27 }
28
29+ bool has_warning() {
30+ return warning_;
31+ }
32+
33 bool is_password() {
34 return password_;
35 }
36
37=== modified file 'src/ui_fsmenu/netsetup_lan.cc'
38--- src/ui_fsmenu/netsetup_lan.cc 2019-05-11 18:50:30 +0000
39+++ src/ui_fsmenu/netsetup_lan.cc 2019-05-23 17:14:57 +0000
40@@ -24,6 +24,7 @@
41 #include "graphic/graphic.h"
42 #include "graphic/text_constants.h"
43 #include "network/constants.h"
44+#include "network/internet_gaming.h"
45 #include "network/network.h"
46 #include "profile/profile.h"
47
48@@ -136,6 +137,7 @@
49
50 void FullscreenMenuNetSetupLAN::think() {
51 FullscreenMenuBase::think();
52+ change_playername();
53
54 discovery.run();
55 }
56@@ -186,7 +188,7 @@
57 assert(opengames.has_selection());
58 const NetOpenGame* const game = opengames.get_selected();
59 // Only join games that are open
60- if (game->info.state == LAN_GAME_OPEN) {
61+ if (game->info.state == LAN_GAME_OPEN || !playername.has_warning()) {
62 clicked_joingame();
63 }
64 }
65@@ -247,6 +249,22 @@
66 }
67
68 void FullscreenMenuNetSetupLAN::change_playername() {
69+ playername.set_warning(false);
70+ playername.set_tooltip("");
71+ hostgame.set_enabled(true);
72+
73+ if (!InternetGaming::ref().valid_username(playername.text())) {
74+ playername.set_warning(true);
75+ playername.set_tooltip(_("Enter a valid nickname. This value may contain only "
76+ "English letters, numbers, and @ . + - _ characters."));
77+ joingame.set_enabled(false);
78+ hostgame.set_enabled(false);
79+ return;
80+ }
81+ if (!hostname.text().empty()) {
82+ joingame.set_enabled(true);
83+ }
84+
85 g_options.pull_section("global").set_string("nickname", playername.text());
86 }
87

Subscribers

People subscribed via source and target branches

to status/vote changes: