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

Alpha conversion for 0.3.7-R3 and newer clients #982

Open
edgyaf opened this issue Sep 16, 2024 · 0 comments
Open

Alpha conversion for 0.3.7-R3 and newer clients #982

edgyaf opened this issue Sep 16, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@edgyaf
Copy link
Contributor

edgyaf commented Sep 16, 2024

Is your feature request related to a problem? Please describe.
Client versions older than 0.3.7-R3 rendered the textdraws twice. Kalcor fixed it in 0.3.7-R3, but this causes textdraws to look different due to different alpha values.

SA-MP 0.3.7-R3
image

SA-MP 0.3.7-R2
image

Describe the solution you'd like
The issue can be fixed server-side by darkening the textdraw values for players on 0.3.7-R3 and newer clients (assuming that the textdraws are made on 0.3.7 or 0.3.7-R2 client). Some config switch would be useful if someone already made all textdraws on newer versions (maybe with possible textdraw brightening to make them look the same on older clients?).

@Y-Less posted ready-to-use snippet for darkening the colors:

uint32_t FixAlpha(uint32_t colour)
{
    // Extract the alpha channel.
    uint32_t alpha = colour & 0xFF;
    // Convert to a fraction.
    float n = (float)alpha / 255;
    // Darken the result.
    float m = n * (2 - n);
    // Convert back to a value.
    uint32_t final = (uint32_t)((m * 255.0f) + 0.5f);
    // Clamp.
    if (final > 255)
        final = 255;
    // Put back in the colour.
    return (colour & 0xFFFFFF00) | final;
}

Describe alternatives you've considered
I've already made my own solution in Pawn with Pawn.RakNet (hooking ShowTextDraw and SelectTextDraw RPCs), but after discussing it on Discord, we came to the conclusion that it would be nice to have a native patch as well.

Additional context
https://sampforum.blast.hk/showthread.php?tid=661491&pid=4070154#pid4070154

@edgyaf edgyaf added the enhancement New feature or request label Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant