Skip to content

Fix animation query crash for streamed-out peds#5057

Open
HeresHavi wants to merge 1 commit into
multitheftauto:masterfrom
HeresHavi:fix-streamed-out-ped-animation-queries
Open

Fix animation query crash for streamed-out peds#5057
HeresHavi wants to merge 1 commit into
multitheftauto:masterfrom
HeresHavi:fix-streamed-out-ped-animation-queries

Conversation

@HeresHavi

@HeresHavi HeresHavi commented Jul 14, 2026

Copy link
Copy Markdown

Summary

Added missing task checks to getPedAnimationProgress, getPedAnimationSpeed, and getPedAnimationLength.
These functions now return -1 when the ped has no task manager or active task.

Motivation

A streamed-out ped can still be a valid Lua element, but it no longer has native task data. Querying its animation progress tried to access that missing data and caused an access violation. The speed and length functions had the same unchecked path.

For example, a server resource might track an NPC's animation to update a progress bar or other UI. If the player moves far enough away and the NPC streams out, the resource can still hold the ped element. The next animation query could crash the player's client.

Crash Stack
Exception: Access violation

CLuaPedDefs::GetPedAnimationProgress (CLuaPedDefs.cpp:2325)
CLuaFunctionParser<...>::Call
CLuaFunctionParser<...>::operator()
CLuaMain::PCall
image

Test plan

Runtime

  • Before Fix: Querying a valid streamed-out ped caused the Debug client to crash.
  • After Fix: Progress, speed, and length returned -1 for the same ped, and the client stayed open.
  • Valid Case: A streamed-in ped with an active animation still returned normal progress, speed, and length values.

Builds and Tests

  • Debug | Win32: Build passed, 304 client tests passed.
  • Release | Win32: Build passed, 304 client tests passed.
  • Debug | x64: Server build passed.
  • Ran clang-format.

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.

Prevent animation progress, speed, and length queries from accessing missing task data on streamed-out peds. These queries now return -1 when the task manager or active task is unavailable.
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

Successfully merging this pull request may close these issues.

1 participant