Skip to content

Fix animations progress & sync - #4821

Draft
FileEX wants to merge 27 commits into
multitheftauto:masterfrom
FileEX:bugfix/animations_progress
Draft

Fix animations progress & sync#4821
FileEX wants to merge 27 commits into
multitheftauto:masterfrom
FileEX:bugfix/animations_progress

Conversation

@FileEX

@FileEX FileEX commented Apr 18, 2026

Copy link
Copy Markdown
Member

Summary

  • Time synchronization refactor for animations (server-authoritative clock)
  • Replaced unreliable GetTimestamp() / GetTickCount64_ usage with a monotonic steady_clock-based tick system.
  • Fixed a bug where the server was sending elapsedTime while the client treated it as startTime.
  • setPedAnimationProgress now runs in the "same" frame as setPedAnimation (setPedAnimationProgress() does not work when called in the same frame as setPedAnimation() #1172).
  • When setPedAnimationProgress is set to 0 on the server, it refreshes the animation startTime.
  • On the server side, setPedAnimationProgress updates the animation startTime, ensuring all clients play the animation from the same progress point.

Motivation

Fixes #1172

Test plan

crun ped = createPed(50, getElementPosition(me))
crun setPedAnimation(ped, "ped", "ko_shot_face", -1, false, false, false, true) setPedAnimationProgress(ped, "ko_shot_face", 0.5)

Checklist

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

@FileEX FileEX added sync bugfix Solution to a bug of any kind labels Apr 18, 2026
@FileEX FileEX mentioned this pull request Apr 20, 2026
1 task
@FileEX FileEX modified the milestone: 1.7 (Current) May 7, 2026
@FileEX FileEX added the backwards-incompatible Should be merged after the release of 1.7.1 label Aug 10, 2026
@FileEX FileEX added this to the 1.7 (Current) milestone Aug 10, 2026
@FileEX

FileEX commented Aug 21, 2026

Copy link
Copy Markdown
Member Author

I'm not sure about the changes to bitstream.h. There could potentially be an issue on Linux. If anyone has an idea how to solve this differently, that would be great.

@Flashmyname

Copy link
Copy Markdown
Contributor

On 64-bit Linux int64_t and long are the same type, so with the guard the call doesn't fail, it just falls through to Write(long) { Write((int)e); } and truncates to 4 bytes. No warning either, I checked on gcc 15. Windows then reads 8, and speed is right after startTime in both packets.

Maybe something like this instead?

void WriteInt64(std::int64_t v)
{
    Write(static_cast<uint>(static_cast<std::uint64_t>(v) >> 32));
    Write(static_cast<uint>(static_cast<std::uint64_t>(v)));
}

bool ReadInt64(std::int64_t& v)
{
    uint hi, lo;
    if (!Read(hi) || !Read(lo))
        return false;
    v = static_cast<std::int64_t>((static_cast<std::uint64_t>(hi) << 32) | lo);
    return true;
}

Then the guard can go, but the call sites need switching over as well or Linux keeps picking Write(long).

Copilot AI review requested due to automatic review settings September 12, 2026 23:46

This comment was marked as outdated.

Copilot AI review requested due to automatic review settings September 13, 2026 00:32

This comment was marked as outdated.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 13, 2026 00:44
@FileEX
FileEX removed the request for review from Copilot September 13, 2026 00:45
Copilot AI review requested due to automatic review settings September 13, 2026 01:38

This comment was marked as outdated.

Copilot AI review requested due to automatic review settings September 13, 2026 03:59

This comment was marked as spam.

Copilot AI review requested due to automatic review settings September 13, 2026 04:46

This comment was marked as spam.

Copilot AI review requested due to automatic review settings September 13, 2026 05:00

This comment was marked as spam.

@FileEX

FileEX commented Sep 13, 2026

Copy link
Copy Markdown
Member Author

That's enough. I'll wait for a human review, because this will take forever with Copilot - just going around in circles constantly. Using AI was a mistake after all.

@FileEX
FileEX marked this pull request as draft September 13, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backwards-incompatible Should be merged after the release of 1.7.1 bugfix Solution to a bug of any kind sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

setPedAnimationProgress() does not work when called in the same frame as setPedAnimation()

3 participants