fix user data resetting on adduser
This commit is contained in:
parent
b02e967761
commit
59fa954e11
1 changed files with 20 additions and 8 deletions
|
@ -371,20 +371,32 @@ public class CollabVMClient {
|
|||
case "adduser": {
|
||||
for (int i = 2; i < msgArr.Length; i += 2) {
|
||||
// This can happen when a user logs in
|
||||
_users.RemoveAll(u => u.Username == msgArr[i]);
|
||||
var user = new User {
|
||||
Username = msgArr[i],
|
||||
Rank = msgArr[i + 1] switch {
|
||||
var user = _users.Find(u => u.Username == msgArr[i]);
|
||||
if (user == null) {
|
||||
user = new User {
|
||||
Username = msgArr[i],
|
||||
Rank = msgArr[i + 1] switch {
|
||||
"0" => Rank.Unregistered,
|
||||
"1" => Rank.Registered,
|
||||
"2" => Rank.Admin,
|
||||
"3" => Rank.Moderator,
|
||||
_ => Rank.Unregistered
|
||||
},
|
||||
Turn = TurnStatus.None
|
||||
};
|
||||
this._users.Add(user);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.Rank = msgArr[i + 1] switch {
|
||||
"0" => Rank.Unregistered,
|
||||
"1" => Rank.Registered,
|
||||
"2" => Rank.Admin,
|
||||
"3" => Rank.Moderator,
|
||||
_ => Rank.Unregistered
|
||||
},
|
||||
Turn = TurnStatus.None
|
||||
};
|
||||
};
|
||||
}
|
||||
this.UserJoined.Invoke(this, user);
|
||||
this._users.Add(user);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue