openmultiplayer / openmultiplayer/open.mp

Alpha conversion for 0.3.7-R3 and newer clients

Open
#982 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C++
Stars
641
Forks
208
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the server-side ShowTextDraw and SelectTextDraw RPC handling and how client versions are identified. Review the proposed FixAlpha behavior and the requested configuration options for 0.3.7-R3 and newer clients. Done means the native patch produces consistent textdraw appearance across the stated client versions without requiring Pawn.RakNet hooks.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
game-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.