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

Fix silent fail on player name change #388

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/SampSharp.GameMode/World/BasePlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ public virtual string Name
PlayerInternal.Instance.GetPlayerName(Id, out var name, MaxNameLength);
return name;
}
set => PlayerInternal.Instance.SetPlayerName(Id, value);
set
{
if(PlayerInternal.Instance.SetPlayerName(Id, value) == -1)
{
throw new Exception("The name is already in use, too long or has invalid characters.");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change it to InvalidOperationException?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. But wait, I'm adding similar return codes handling on the other setters, seems that all lacks these checks.

}
}
}

/// <summary>
Expand Down