Skip to content
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

FEAT/REFAC(positional-audio): Rewrite GTAV plugin, define "procid_t" to "uint64_t" #5704

Merged

Conversation

davidebeatrici
Copy link
Member

It should now work flawlessly with all variants (Rockstar, Steam, Epic Games).

plugins/gtav/Game.cpp Outdated Show resolved Hide resolved
plugins/gtav/Game.h Outdated Show resolved Hide resolved
plugins/gtav/Game.h Outdated Show resolved Hide resolved
plugins/gtav/Game.h Show resolved Hide resolved
plugins/gtav/gtav.cpp Outdated Show resolved Hide resolved
plugins/gtav/structs.h Show resolved Hide resolved
plugins/gtav/structs.h Outdated Show resolved Hide resolved
plugins/gtav/structs.h Show resolved Hide resolved
plugins/gtav/structs.h Show resolved Hide resolved
plugins/gtav/structs.h Show resolved Hide resolved
@davidebeatrici
Copy link
Member Author

@vimpostor Could you test the plugin, please?

@vimpostor
Copy link
Contributor

This awesome, thank you for doing this! I will definitely test this, but don't have time to do that before Monday unfortunately.

@davidebeatrici
Copy link
Member Author

No problem, thanks!

@vimpostor
Copy link
Contributor

vimpostor commented May 30, 2022

Confirmed working on Linux + Wine + GTA V Steam edition.
This is really awesome, finally no more looking through hardcoded memory addresses.

I only noticed two minor problems:

  • Player top vector seems to be locked to one value forever
  • When I first start Mumble, then start GTA, Mumble receives a MUMBLE_PDEC_ERROR_PERM once Rockstar launcher is about to close and start the real game (If I start Mumble after GTA is running already, then everything is fine)

@davidebeatrici
Copy link
Member Author

Player top vector seems to be locked to one value forever

The player character is almost always perpendicular to the floor.

Enter a vehicle and you will see it changes, unless you're on a level terrain.

When I first start Mumble, then start GTA, Mumble receives a MUMBLE_PDEC_ERROR_PERM once Rockstar launcher is about to close and start the real game (If I start Mumble after GTA is running already, then everything is fine)

Confirmed, I'm pretty sure it happens because at that point the executable is not "unpacked" yet.
In fact, in order to be able to reverse engineer it you have to take a dump of the process memory as the game is running.

As a workaround we could return MUMBLE_PDEC_ERROR_TEMP if a signature is not found, until we find a proper solution.

@vimpostor
Copy link
Contributor

vimpostor commented May 30, 2022 via email

@davidebeatrici
Copy link
Member Author

A few seconds if I recall correctly.

@Krzmbrzl

@Krzmbrzl
Copy link
Member

Every second - provided that there is currently no plugin that has established a link

static constexpr int POSITIONAL_DATA_CHECK_INTERVAL = 1000;

@davidebeatrici
Copy link
Member Author

What do you think? Should we return MUMBLE_PDEC_ERROR_TEMP?

Copy link
Member

@Krzmbrzl Krzmbrzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just marking all my previous review comments as "resolved" without actually addressing them does not seem like a productive strategy.
Should this become the norm, I will no longer provide code reviews in the first place. But for now I'll assume that it was merely some sort of oversight...

plugins/ProcessBase.h Outdated Show resolved Hide resolved
plugins/ProcessBase.h Show resolved Hide resolved
plugins/gtav/Game.cpp Outdated Show resolved Hide resolved
plugins/gtav/Game.cpp Show resolved Hide resolved
plugins/gtav/Game.cpp Outdated Show resolved Hide resolved
plugins/gtav/Game.h Outdated Show resolved Hide resolved
plugins/gtav/gtav.cpp Outdated Show resolved Hide resolved
plugins/gtav/structs.h Show resolved Hide resolved
plugins/gtav/structs.h Show resolved Hide resolved
plugins/gtav/structs.h Outdated Show resolved Hide resolved
@Krzmbrzl
Copy link
Member

What do you think? Should we return MUMBLE_PDEC_ERROR_TEMP?

Maybe add a counter. The first x times you fail to resolve the structs, you return a temp error but if you aren't able to resolve them after a bunch of attempts (that should cover the usual loading times of the game), then assume something is wrong and return a permanent error.
As soon as you are able to properly resolve the structs, reset the counter.

@davidebeatrici
Copy link
Member Author

Just marking all my previous review comments as "resolved" without actually addressing them does not seem like a productive strategy.
Should this become the norm, I will no longer provide code reviews in the first place. But for now I'll assume that it was merely some sort of oversight...

I resolved them locally, I wanted to know whether I should return MUMBLE_PDEC_ERROR_TEMP before pushing.

Maybe add a counter. The first x times you fail to resolve the structs, you return a temp error but if you aren't able to resolve them after a bunch of attempts (that should cover the usual loading times of the game), then assume something is wrong and return a permanent error.
As soon as you are able to properly resolve the structs, reset the counter.

Not a good idea, the time it takes the launcher to load the game is not constant.

A proper solution would probably consist in getting a snapshot of the process memory at the time the plugin returns MUMBLE_PDEC_ERROR_PERM and check what kind of pattern we can use to detect such a situation.

But, for the time being returning MUMBLE_PDEC_ERROR_TEMP is a viable workaround.

@davidebeatrici davidebeatrici force-pushed the positional-audio-gtav-revamp branch 2 times, most recently from 93028d3 to 8c83d7f Compare May 31, 2022 07:21
@vimpostor
Copy link
Contributor

But, for the time being returning MUMBLE_PDEC_ERROR_TEMP is a viable workaround.

I think it is a great workaround even. If the process called "GTA5.exe" is not running at all, we take the early exit with MUMBLE_PDEC_ERROR_TEMP in mumble_initPositionalData() anyway, so we only take the expensive search through the memory page every second, while the Rockstar launcher is running, which I guess is fine.

One unrelated optimization would be possible where each plugin tells Mumble what process name it is looking for, so that only Mumble itself iterates over all program names instead of n positional audio plugins iterating themself, but right now that does hardly matter because n is low (and this has nothing to do with this PR).

@davidebeatrici
Copy link
Member Author

That's an excellent idea!

Could you open an issue for it, please?

@davidebeatrici davidebeatrici changed the title FEAT(positional-audio): Rewrite GTAV plugin to use signatures and game structs FEAT(positional-audio): Rewrite GTAV plugin, define "procid_t" to "uint64_t" Jun 4, 2022
@davidebeatrici davidebeatrici changed the title FEAT(positional-audio): Rewrite GTAV plugin, define "procid_t" to "uint64_t" FEAT/REFAC(positional-audio): Rewrite GTAV plugin, define "procid_t" to "uint64_t" Jun 4, 2022
@davidebeatrici davidebeatrici force-pushed the positional-audio-gtav-revamp branch from 55a6c11 to 54825a2 Compare June 4, 2022 00:37
@davidebeatrici davidebeatrici force-pushed the positional-audio-gtav-revamp branch from 54825a2 to 6d1518e Compare June 4, 2022 20:56
…e structs

It should now work flawlessly with all variants (Rockstar, Steam, Epic Games).
…uint32_t"

This allows us to take advantage of the full range provided by the plugin API.
@davidebeatrici davidebeatrici force-pushed the positional-audio-gtav-revamp branch from 6d1518e to 5b7f95b Compare June 5, 2022 00:49
@vimpostor
Copy link
Contributor

Looks good to me now, thanks! :)
(I don't have an "Approve" button anywhere)

@davidebeatrici davidebeatrici merged commit 1fab81a into mumble-voip:master Jun 5, 2022
@davidebeatrici davidebeatrici deleted the positional-audio-gtav-revamp branch June 5, 2022 17:04
@davidebeatrici
Copy link
Member Author

Thank you very much for testing!

@Krzmbrzl
Copy link
Member

Krzmbrzl commented Jun 5, 2022

💚 All backports created successfully

Status Branch Result
1.4.x

Questions ?

Please refer to the Backport tool documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants