Skip to content

Conversation

@ddhoward
Copy link
Contributor

Modifying FormatUserLogText to allow client 0 to be passed.

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

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

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

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

@ddhoward
Copy link
Contributor Author

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 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

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

Copy link
Member

@Headline Headline left a comment

Choose a reason for hiding this comment

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

This looks good, congrats on your first contribution.

@Headline Headline merged commit beaf812 into alliedmodders:master Aug 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants