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

Need a Multiplayer Mutex handover Protocol #1

Open
kuroneko opened this issue Apr 18, 2020 · 0 comments
Open

Need a Multiplayer Mutex handover Protocol #1

kuroneko opened this issue Apr 18, 2020 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@kuroneko
Copy link
Contributor

kuroneko commented Apr 18, 2020

Need to implement some logic to do gentle/soft handover of the Multiplayer Mutex.

Recommended strategy:

Register the shared dataref xplanemp/want_planes as an int.

Acquiring Planes:

  • write our PluginID to the shared dataref xplanemp/want_planes
  • Try to get the XPLMAcquirePlanes with a registered callback for late acquisition.
  • if the aquisition was successful:
    • complete the setup steps that require the plane mutex (tcas callbacks, etc)

Releasing Planes:

  • get the value of xplanemp/want_planes
  • disable our XPMP Planes dependent callbacks
  • XPLMReleasePlanes
  • if the value of the dataref is our plugin ID:
    • set the dataref to 0 (or -1 if 0 is a valid plugin ID)

deferred aquisition callback:

  • Get the value of xplanemp/want_planes
  • if the value of the dataref is our plugin_id:
    • make an XPLMAcquirePlanes call
    • complete the setup steps for the plane mutex

shared dataref update callback:

  • Get the value of xplanemp/want_planes
  • if the value of the dataref is NOT our plugin_id and not 0 (or -1 per above) and we have the mutex:
    • disable our XPMP Planes dependent callbacks
    • XPLMReleasePlanes

This approach should allow multiple xplanemp consumers to hand off the plane mutex to the most recently invoked tool, rather than holding onto it. For plugins that want to voluntarily take the lowest precedence and not have explicit enable steps, they can monitor for the 0/-1 value in xplanemp/want_planes and use that as a cue to take ownership.

@kuroneko kuroneko added the enhancement New feature or request label Apr 18, 2020
@kuroneko kuroneko self-assigned this Apr 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant