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

Allow client 0 in FormatUserLogText #856

Merged
merged 3 commits into from Aug 1, 2018
Merged

Conversation

@ddhoward
Copy link
Contributor

@ddhoward ddhoward commented Jul 22, 2018

Modifying FormatUserLogText to allow client 0 to be passed.

Modifying FormatUserLogText to allow client 0 to be passed.
{
strcopy(name, sizeof(name), "UNKNOWN");
strcopy(auth, sizeof(auth), "Console");
Copy link
Member

@KyleSanderson KyleSanderson Jul 22, 2018

Choose a reason for hiding this comment

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

We probably want CONSOLE here? I'm not sure, do most games have it as a name and not an entire capitalized string now?

Copy link
Contributor Author

@ddhoward ddhoward Jul 22, 2018

Choose a reason for hiding this comment

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

It's Console in TF2, as well as in the %L and %N explanations on the wiki:
https://wiki.alliedmods.net/Format_Class_Functions_(SourceMod_Scripting)#Format_Specifiers

I am not sure about other games.

Copy link
Contributor Author

@ddhoward ddhoward Jul 22, 2018

Choose a reason for hiding this comment

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

Honestly, maybe the whole function should just be marked as deprecated and the body replaced with a FormatEx(buffer, maxlength, "%L", client); Or just the second thing, idk.

@KyleSanderson
Copy link
Member

@KyleSanderson KyleSanderson commented Jul 22, 2018

Well you know what, we should just be using %N here regardless instead of filling a magical buffer.

@ddhoward
Copy link
Contributor Author

@ddhoward ddhoward commented Jul 23, 2018

For some reason I was under the impression that %N would have the same behavior as GetClientName() in regards to client 0. In reality, %N results in Console whereas GetClientName() gives the current value of the hostname cvar. So you're totally right.

Regardless, is there any reason why the whole thing can't just be replaced with:

stock void FormatUserLogText(int client, char[] buffer, int maxlength)
{
	FormatEx(buffer, maxlength, "%L", client);
}

This should guarantee consistency.

@KyleSanderson
Copy link
Member

@KyleSanderson KyleSanderson commented Jul 23, 2018

This may be \"%L\" but yeah this is an ancient func in comparison to what actually landed.

Updating my previous FormatUserLogText() change. This change guarantees consistency, is much simpler, and allows client 0 to be passed.
@asherkin
Copy link
Member

@asherkin asherkin commented Jul 31, 2018

We should mark it as deprecated alongside this change I think.

Copy link
Member

@Headline Headline left a comment

This looks good, congrats on your first contribution.

@Headline Headline merged commit beaf812 into alliedmodders:master Aug 1, 2018
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants