[REL] rF2 Shared Memory Tools for Developers

Discussion in 'Other' started by The Iron Wolf, Jan 19, 2017.

  1. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    730
    Likes Received:
    568
    Hi fellow rF2 Players,

    Please find rFactor 2 Shared Memory Tools for Developers.

    Download:
    http://www.mediafire.com/file/tpp755nmqbwj74c/rf2_sm_tools_3.1.0.0.zip/file

    Install:
    Drop rFactor2SharedMemoryMapPlugin64.dll into [rF2Root]\Bin64\Plugins

    Description
    This plugin writes out rF2 Internals structures into shared memory buffers. Reading shared memory allows creating external tools running outside of rFactor 2 and written in languages other than C++ (C# sample is included). This approach makes development easier and helps to keep rF2 FPS impact minimal.

    Also includes Monitor program that helps with understanding rF2 state without debugger.

    This work is based on:
    - rF2 Internals Plugin sample #7 by ISI/S397 found at: https://www.studio-397.com/modding-resources/
    - rF1 Shared Memory Map Plugin by Dan Allongo found at: https://github.com/dallongo/rFactorSharedMemoryMap

    Source: https://github.com/TheIronWolfModding/rF2SharedMemoryMapPlugin

    Features:
    Plugin offers optional weak synchronization by using version variables on each of the buffers. Plugin is also capable of hosting StockCarRules.dll plugin as a hack/workaround for accessing SCR set values.

    Refresh Rates:
    • Telemetry - 50FPS.
    • Scoring - 5FPS.
    • Extended - 5FPS and on tracked callback by the game.
    • FFB - 400FPS, yes, rF2 is that good.
    Uses:

    • Basic: Most clients (HUDs, Dashes, visualizers) won't need synchronization, see rF2SMMonitor.MainForm.MappedBuffer<>.GetMappedDataUnsynchronized for sample implementation.
    • Advanced: If you would like to make sure you're not reading a torn (partially overwritten) frame, see rF2SMMonitor.MainForm.MappedBuffer<>.GetMappedData for sample implementation.
    Distribution and reuse
    You are allowed to include this .dll with your distribution, as long as it is:

    • Free
    • Readme is included
    • You had my permission via email
    Please also be aware, that Crew Chief will always ship with the latest version of the .dll and will overwrite .dll to match its version. I do not expect compatibility to break without game changing its model, aside from rF2Extended buffer, which contains stuff not directly exposed by the game. Every time layout of memory changes, second digit in Plugin version is incremented.

    Current known clients
    Donations:
    If you would like to support Crew Chief Mega Corp Team, and all sorts of immoral lifestyle, send beer money here.

    Release history:
    09/04/2018 - v3.1.0.0

    Plugin:

    • Exposed FFB info. Add $rFactor2SMMP_ForceFeedback$ buffer to map rF2ForceFeedback structure. Note that since it is a single value buffer, and it is updated at 400FPS, no synchronization is applied nor needed while reading it.
    Monitor:

    • Updated to expose FFB info.

    03/29/2018 - v3.0.1.0

    Plugin:
    • Add DedicatedServerMapGlobally preference to allow mapping dedicated server shared memory buffers to global section, so that users running under other accounts can access them. Note that "Create Global Objects" permission is needed on user account running dedicated server.

    02/21/2018 - v3.0.0.1

    Hotfix for physics options not being captured.


    02/16/2018 - v3.0.0.0

    Rework Plugin to replace mutexes with buffer version tracking mechanism. Update Monitor to match new way of reading data.

    01/24/2018 - v2.4.0.0

    Plugin:

    • Expose Stock Car Rules plugin DoubleFileType setting.
    • Rearrange rF2Extended to better expose hosted plugin variables.
    Monitor:

    • Improve Rolling Start detection when no SC present.
    • Correctly calculate distance to the SC.
    • Add Frozen Order sub-phases for Rolling start without SC, while assigned pole/pole row.
    01/02/2018 - v2.3.1.2

    Plugin:

    • Allow hosting of StockCarRules.dll plugin. Capture mMessage members filled out by SCR plugin and pass them out via SM.
    • Remove .ini file config and move to standard rF2 plugin config via CustomPluginVariables.json.
    Monitor:

    • Minor fixes and changes to support SCR plugin hosting feature.

    10/04/2017 - v2.2.1.0
    Plugin:
    • Expose rF2MultiRules buffer
    • Add rF2SessionTransitionCapture to rF2Extended. This allows tracking some state on session transition.
    • Add mSessionStarted, mTicksSessionStarted and mTicksSessionStarted to rF2Extended to help tracking session transitions.
    • Buffers are no longer cleared out on EndSession. This is neccessary to capture data in StartSession.
    Monitor:
    • Add Frozen Order rules detection.

    9/01/2017 - v2.1.1.1

    Plugin:

    • Fix crash in physics update that happens when buffer can't be mapped.
    • Expose TrackRules01 as rF2Rules buffer.
    • Improve Win32 error tracing.
    • Minor reliability improvements.
    Monitor:

    • Add rF2Rules tracking.
    • Force invariant culture on the app.

    7/22/2017 - v2.0.0.0

    Complete redesign/rework to better reflect rFactor 2 internals read model. Interpolation is removed, plugin is now essentially double buffered memcpy of rF2 internals.

    3/22/2017 - v1.1.0.1
    Plugin:

    • Replaced rF2State::mInRealTime with mInRealTimeFC and mInRealTimeSU values, to distiguish between InRealtime state reported via ScoringUpdate, and via Enter/ExitRealtime calls.
    • rF2State::mCurrentET is no longer updated between Scoring Updates, and matches value last reported by the game.
    Monitor:

    • Extended monitor to dislay more information
    • Implemented correct "Best Split" time calculation logic.
    2/26/2017 - v1.0.0.1

    Fixed synchronization of:

    • rF2State::mElapsedTime
    • rF2State::mLapStartET
    • rF2State::mLapNumber

      This eliminates the gap those values had between telemetry and scoring update

    01/31/2017 - v1.0.0.0
    • Plugin: Added damage and invulnerability tracking
    • Monitor: Added phase and damage tracking and logging
    1/18/2017 v0.5.0.0 - Initial release
     
    Last edited: Sep 8, 2018
  2. ebeninca

    ebeninca Registered

    Joined:
    Sep 7, 2016
    Messages:
    447
    Likes Received:
    166
    I'm using the spotter that is actually available here in the forum. What is the difference for the crew chief?
     
  3. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    730
    Likes Received:
    568
    It is different spotter, try it out, it works on many games: R3E, pCars, rF1, AMS, AC and bunch of trucking sims :)
     
  4. DaVeX

    DaVeX Registered

    Joined:
    Feb 7, 2015
    Messages:
    486
    Likes Received:
    463
    Wasn't Gongo?Or Gonzo is someone else?
    Btw, I hope you are succesfull with your project, crew chief is fantastic!

    @Marcel Offermans
    Dan Allongo, aka Gongo, is the man behind the integrated spotter in AMS, maybe he can help for an integrated spotter plugin for rF2 too? ;)
    It works great and will be good to have the same on rF2...
     
  5. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    730
    Likes Received:
    568
    Thanks Davex, my mistake, fixed description.
     
  6. DaVeX

    DaVeX Registered

    Joined:
    Feb 7, 2015
    Messages:
    486
    Likes Received:
    463
    No prob mate, you are our hope for a rF2 crewchief port!!!
    Lol, jus to give you some pressure :p
     
  7. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    730
    Likes Received:
    568
    won't help :p
     
  8. Erick3331

    Erick3331 Registered

    Joined:
    Jan 25, 2017
    Messages:
    43
    Likes Received:
    9
    Thank you, this is awesome plugin , really very helps the memory , yeahhhhhh ;)
     
    The Iron Wolf likes this.
  9. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    730
    Likes Received:
    568
    Eric, glad you like it - just remember I'll break it at V1. I am adding extra fields to make sense of rF2 damage (since it seems fairly limited atm :(). But after V1 I'll use expansion bytes, so will be good.
     
    Erick3331 likes this.
  10. Erick3331

    Erick3331 Registered

    Joined:
    Jan 25, 2017
    Messages:
    43
    Likes Received:
    9
    Iron, Thank you for the very useful info :)
     
  11. Will Mazeo

    Will Mazeo Registered

    Joined:
    Sep 12, 2015
    Messages:
    1,581
    Likes Received:
    930
    wish I knew how to do this stuff, I tried to learn some C, Python and Java but I ended up wanting to punch my monitor instead of learning :D
     
  12. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    730
    Likes Received:
    568
    we actually live in amazing time. In past, I had to read 300 page book to learn some subset of technology. Now, it is google and stackoverflow and github, it is much easier.
     
    Erick3331 likes this.
  13. DaVeX

    DaVeX Registered

    Joined:
    Feb 7, 2015
    Messages:
    486
    Likes Received:
    463
    wait...there is already a working piece of code for this?
     
  14. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    730
    Likes Received:
    568
    v1 released:
    01/31/2017 - v1.0.0.0
    • Plugin: Added damage and invulnerability tracking
    • Monitor: Added phase and damage tracking and logging
     
    Erick3331 likes this.
  15. Erick3331

    Erick3331 Registered

    Joined:
    Jan 25, 2017
    Messages:
    43
    Likes Received:
    9
    Ok mate thank you the update ;)
     
  16. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    730
    Likes Received:
    568
    Erick, are you building/experimenting with something based on this? :)
     
    Erick3331 likes this.
  17. Erick3331

    Erick3331 Registered

    Joined:
    Jan 25, 2017
    Messages:
    43
    Likes Received:
    9
    Yes now I test the plugin , and as you can see works well , perfect ;) is once again thank you very much :cool:
     
    The Iron Wolf likes this.
  18. The Iron Wolf

    The Iron Wolf Registered

    Joined:
    Feb 20, 2016
    Messages:
    730
    Likes Received:
    568
    Keep me posted on what you're doing, you can PM me if that's more comfortable. This will help me to not break you and others. Also, I am not rF2 Internals expert, and any ideas/suggestions are welcome.
     
    Erick3331 likes this.
  19. bravotangosix

    bravotangosix Registered

    Joined:
    Nov 21, 2015
    Messages:
    253
    Likes Received:
    239
    Works brilliantly for me. Have just ordered a mic to use voice recog.
     
    The Iron Wolf likes this.
  20. Wiggin

    Wiggin Registered

    Joined:
    Mar 15, 2016
    Messages:
    132
    Likes Received:
    4
    Can I just suggest you please put at the very least the install location in the readme, please ? I'd hate for the thread/site change to happen again and loose valuable information.

    Thanks, testing with the crew chief app now.
     

Share This Page