Skip to content

Commit 9523801

Browse files
committed
made player name default to current username
as long as it's not a default username
1 parent 0f2b0fb commit 9523801

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

FezMultiplayerMod/MultiplayerMod/MultiplayerClientSettings.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.ComponentModel;
33
using System.Collections.Generic;
44
using static FezGame.MultiplayerMod.ServerListMenu;
5+
using System;
56

67
namespace FezGame.MultiplayerMod
78
{
@@ -22,7 +23,22 @@ public sealed class MultiplayerClientSettings
2223
/// A string representing the name to display for this client.
2324
/// </summary>
2425
[Description("A string representing the name to display for this client.")]
25-
public string MyPlayerName = "Player";
26+
public string MyPlayerName = ((Func<string>)(() =>
27+
{
28+
const string DefaultPlayerName = "Player";
29+
string username = Environment.UserName.Trim();
30+
HashSet<string> rootNames = new HashSet<string> {
31+
"root", "system", "sudo", "admin", "administrator", "test", "pi", "ubuntu", "default", "home", "public",
32+
"guest", "nobody", "user", "username", "macuser", "defaultuser"
33+
};
34+
if (string.IsNullOrEmpty(username) || rootNames.Contains(username.ToLower()))
35+
{
36+
return DefaultPlayerName;
37+
}
38+
rootNames.Clear();
39+
rootNames = null;
40+
return username;
41+
}))();
2642
/// <summary>
2743
/// Format currently TBD. The custom player skin/appearance to use
2844
/// </summary>

changelog.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ Various optimizations
7272
Made ServerDiscover non-blocking
7373
Added in-game option to change name
7474
various bug fixes and improvements
75-
75+
Made the player name default to the name of the current user (as long as it's not a default username)

0 commit comments

Comments
 (0)