TonyWhitley / pyRfactor2SharedMemory

Python library for accessing rFactor 2's shared memory
MIT License
5 stars 5 forks source link

Get data from dedicated server #5

Open frey123 opened 4 years ago

frey123 commented 4 years ago

Hi @TonyWhitley ,

is it possible to read data from the dedicated server?

I changed the process name to "rfactor2 dedicated.exe" in __find_rf2_pid() and isRF2running() but I get "rFactor 2 Shared Memory not present." and "Incorrect shared memory". Server only is running for sure.

Does the rF2SharedMemoryMapPlugin by TheIronWolfModding map data from the dedicated server at all? I set DedicatedServerMapGloballyto 1 in CustomPluginVariables.json

Can you help me please to figure out how I could use your python implementation to read telemetry from dedicated server?

Thank you and a merry x-mas! Frey

TonyWhitley commented 4 years ago

Hi Frey,

I don't think the dedicated server has a shared memory but The Iron Wolf can give you a better answer. It's not something I've ever thought about.

Cheers, Merry Xmas to you too, -- Tony

frey123 commented 4 years ago

Hi @TonyWhitley,

ok I found out the following:

 Shared resources use the following naming convention:

    - $rFactor2SMMP_<BUFFER_TYPE>$

      or

    - $rFactor2SMMP_<BUFFER_TYPE>$PID where PID is dedicated server process PID.

Source: /rFactor2SharedMemoryMap.cpp#L20

I was able to map the dedicated server with you code. If you like I can modify your code and make a pull request.

Greetings

TonyWhitley commented 4 years ago

Hi Frey,

Please go ahead and modify the code as I would have to set up a server to test it. Raise a PR and I'll merge it into my code, it will be a good addition. I'm interested to hear what you're going to use it for.

Cheers, -- Tony

1frey commented 4 years ago

Hi Tony,

alright, I will do when I have time.

I want to implement a plugin to improve the safety car experiences.

Let's say to make the call out of the SC more realistic.

I will set the safety car threshold to a high number, so game will never call out the safety car. I will override the call out logic in my plugin and sending /throwyellow commands.

On server-side, I will track some events to call the SC, like:

I also have a red flag plugin in mind. When a hard crash or car pile happened, I will stop the session, store the current ranking and session time and restart the race with flying start with the previous ranking that I want to reset with /editgrid command. And everything automated with python.

TonyWhitley commented 4 years ago

Ah, sounds like the sort of thing I do to improve rF2 but I never race with the safety car so I have never even thought about that. Only think I've written for the server is to reverse the grid: https://github.com/TonyWhitley/rF2DedicatedServer