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

Wrong Encode at AddServerRule #147

Closed
AthallahDzaki opened this issue Mar 12, 2023 · 4 comments
Closed

Wrong Encode at AddServerRule #147

AthallahDzaki opened this issue Mar 12, 2023 · 4 comments

Comments

@AthallahDzaki
Copy link

image
On Windows, The C and D is work very well.

@IS4Code
Copy link
Owner

IS4Code commented Mar 12, 2023

I have no idea what you are asking about. Show code.

@AthallahDzaki
Copy link
Author

AddServerRule("Community", "Sampindo");
AddServerRule("Discord", https://discord.com/....");
AddServerRule ("Developer", "Angga");

C will become # and D will become $

@AthallahDzaki
Copy link
Author

AthallahDzaki commented Mar 12, 2023

Only happend at Linux, not for windows

@IS4Code
Copy link
Owner

IS4Code commented Jun 14, 2023

Closing as not an YSF-related issue, as this is a SA-MP bug. Internally AddStringVariable calls strlwr on Windows, but on Linux that function has a custom implementation:

char *__cdecl sub_80A9190(char *s)
{
  size_t v1; // eax@1
  size_t v2; // ecx@1

  v1 = strlen(s);
  v2 = 0;
  if ( v1 )
  {
    do
    {
      if ( (unsigned __int8)(s[v2] - 65) <= 25u )
        s[v2] -= 32;
      ++v2;
    }
    while ( v1 > v2 );
  }
  return s;
}

As can also be seen in the source code, it attempts to lowercase letters A - Z, but instead of adding 32, it subtracts it.

The solution ‒ use lowercase, since console variables are supposed to be lowercase:

AddServerRule("community", "Sampindo");
AddServerRule("discord", "https://discord.com/....");
AddServerRule("developer", "Angga");

@IS4Code IS4Code closed this as completed Jun 14, 2023
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

No branches or pull requests

2 participants