Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetPlay: Limit nickname length #7410

Merged
merged 2 commits into from Jul 16, 2020

Conversation

Techjar
Copy link
Contributor

@Techjar Techjar commented Sep 12, 2018

32767 character names is more than a bit silly, so I figured adding a (server enforced) length limit would be a good idea. 30 characters seems like a reasonable limit, as it's the same as the forums.

@JosJuice
Copy link
Member

Is the limit in this PR actually 30 characters, or is it 30 bytes (when encoded as UTF-8)? The latter might be a bit restrictive for e.g. Japanese, since it would mean you only can use 10 characters.

@Techjar
Copy link
Contributor Author

Techjar commented Sep 12, 2018

It's based on whatever std::string::length() returns.

@JosJuice
Copy link
Member

Then it's 30 bytes.

@@ -164,6 +165,7 @@ enum

constexpr u32 NETPLAY_LZO_IN_LEN = 1024 * 64;
constexpr u32 NETPLAY_LZO_OUT_LEN = NETPLAY_LZO_IN_LEN + (NETPLAY_LZO_IN_LEN / 16) + 64 + 3;
const unsigned int MAX_NAME_LENGTH = 30;

This comment was marked as off-topic.

delete (PlayerId*)netEvent.peer->data;
netEvent.peer->data = nullptr;
sf::Packet spac;
spac << (MessageId)error;

This comment was marked as off-topic.

Send(netEvent.peer, spac);
if (netEvent.peer->data)
{
delete (PlayerId*)netEvent.peer->data;

This comment was marked as off-topic.

}
else
{
auto it = m_players.find(*(PlayerId*)netEvent.peer->data);

This comment was marked as off-topic.

@Techjar Techjar changed the title NetPlay: Fix server peer initialization hang and limit nickname length [WIP] NetPlay: Fix server peer initialization hang and limit nickname length Sep 12, 2018
@Techjar Techjar changed the title [WIP] NetPlay: Fix server peer initialization hang and limit nickname length NetPlay: Fix server peer initialization hang and limit nickname length Sep 12, 2018
@@ -449,6 +449,12 @@ void StringPopBackIf(std::string* s, char c)
s->pop_back();
}

size_t StringUTF8Size(const std::string& str)

This comment was marked as off-topic.

@Techjar Techjar force-pushed the netplay-max-name-length branch 3 times, most recently from 857d52a to 9a42b03 Compare November 21, 2018 19:36
@Techjar Techjar changed the title NetPlay: Fix server peer initialization hang and limit nickname length NetPlay: Limit nickname length Nov 22, 2018
Source/Core/DolphinQt/NetPlay/NetPlaySetupDialog.cpp Outdated Show resolved Hide resolved
Source/Core/Core/NetPlayServer.cpp Outdated Show resolved Hide resolved
Source/Core/Core/NetPlayServer.cpp Outdated Show resolved Hide resolved
@Techjar Techjar changed the title NetPlay: Limit nickname length NetPlay: Fix server peer initialization hang and limit nickname length Nov 22, 2018
@Techjar Techjar changed the title NetPlay: Fix server peer initialization hang and limit nickname length NetPlay: Limit nickname length Jan 5, 2019
Ridiculously long nicknames cause UI silliness, so 30 characters seems
like a reasonable limit, as it's the same as the forum.
@jordan-woyak jordan-woyak merged commit 01178e4 into dolphin-emu:master Jul 16, 2020
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants