Skip to content

Fix setPedControlState is aborted when ped created #3916

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

Merged
merged 4 commits into from
Jan 1, 2025

Conversation

FileEX
Copy link
Contributor

@FileEX FileEX commented Jan 1, 2025

Fix #1201 and probably #3867

The bug is caused by m_sScriptedStates being static, which led to the variable being reset by the CClientPad constructor after creating a ped

// Initialise our analog control states
for (unsigned int i = 0; i < MAX_GTA_ANALOG_CONTROLS; i++)
{
m_sScriptedStates[i] = CS_NAN;
m_bScriptedStatesNextFrameOverride[i] = false;
}

@botder
Copy link
Member

botder commented Jan 1, 2025

And why did you de-static these values intead of moving the reset out of that constructor or doing that once?

@FileEX
Copy link
Contributor Author

FileEX commented Jan 1, 2025

And why did you de-static these values intead of moving the reset out of that constructor or doing that once?

Don't other peds need their own 'scriptedStates'? Does this only apply to the local player?

@botder
Copy link
Member

botder commented Jan 1, 2025

We have two functions setPedAnalogControlState and setAnalogControlState. I don't know how these functions differ right now.

Every CClientPed has an instance of CClientPad m_Pad. And the default constructor of CClientPad initializes the static variables everytime. The simplest solution would be to move the initialization out of the default constructor and offer a static function that gets called whenever we create the local player's ped.

@FileEX
Copy link
Contributor Author

FileEX commented Jan 1, 2025

We have two functions setPedAnalogControlState and setAnalogControlState. I don't know how these functions differ right now.

Every CClientPed has an instance of CClientPad m_Pad. And the default constructor of CClientPad initializes the static variables everytime. The simplest solution would be to move the initialization out of the default constructor and offer a static function that gets called whenever we create the local player's ped.

Done

@botder botder merged commit 8117ebc into multitheftauto:master Jan 1, 2025
6 checks passed
@botder botder added this to the 1.6.1 milestone Jan 1, 2025
@botder botder added the bugfix Solution to a bug of any kind label Jan 1, 2025
MTABot pushed a commit that referenced this pull request Jan 1, 2025
8117ebc Fix setPedControlState reset from ped constructor (PR #3916, Fixes #1201)
3f957b8 Update client en_US pot
@FileEX FileEX deleted the bugfix/controlstate_static branch January 1, 2025 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Solution to a bug of any kind
Projects
None yet
2 participants