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,8 +371,9 @@ 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 {
|
||||
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,
|
||||
|
@ -383,9 +384,20 @@ public class CollabVMClient {
|
|||
},
|
||||
Turn = TurnStatus.None
|
||||
};
|
||||
this.UserJoined.Invoke(this, user);
|
||||
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
|
||||
};
|
||||
}
|
||||
this.UserJoined.Invoke(this, user);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "remuser": {
|
||||
|
|
Loading…
Reference in a new issue