open.mp
open.mp copied to clipboard
Alpha conversion for 0.3.7-R3 and newer clients
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
SA-MP 0.3.7-R2
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