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

Implementing online sync #105

Closed
vgarcia007 opened this issue Sep 29, 2023 · 4 comments
Closed

Implementing online sync #105

vgarcia007 opened this issue Sep 29, 2023 · 4 comments
Labels

Comments

@vgarcia007
Copy link

Hi,

I am a hardcore NFS2SE fan. I wanted a way to sync my times to a server to compete with other players.

Here's what I've accomplished so far:

Wrapped my head around the format of the stats files to decode them. That worked very well.

Implemented an API endpoint to post the stats. Basically, a bash script using curl takes the files from ~/.nfs2se/stats/ and the config.dat file and posts them to an endpoint. The API decodes the config.dat to extract the player's name. Then, the "record files" are decoded. When an entry matches the previously extracted player's name, the record is saved to a database.

This also works in reverse. There are endpoints for every track to download the records in the correct format and place them in the stats directory. This way, the in-game records are updated.

For now, this process works, but it needs to be triggered manually.

Do you see a way to implement this in the build itself, or do you have any tips on how I can simplify this process?

You can view the results at: https://garcias-garage.de/nfs2se-ranking/oval.stf/

Currently, I have this setup running with one other player. And I must say, it is so much more fun racing against times another human produced than against AI times. We list challenges on the website so we can compete in them.

Enpoint to post times:
(Example for "Last Resort" Do this for every track)

curl --location 'https://garcias-garage.de/nfs2se-ranking/post_v2' \  
--form 'stf=@"~/.nfs2se/stats/last.stf"' \  
--form 'config=@"~/.nfs2se/config/config.dat"

Endpoint to download records for tracks:
(Example for "Last Resort" Do this for every track)
curl --location 'https://garcias-garage.de/nfs2se-ranking/download/last.stf'

Possible track record file names (for upload and download):

  • oval.stf (Proving Grounds)
  • oz.stf (Outback)
  • last.stf (Last Resort)
  • nort.stf (North Country)
  • pac.stf (Pacific Spirit)
  • med.stf (Mediterraneo)
  • myst.stf (Mystic Peaks)
  • mono.stf (Monolithic Studios)

Here is the Bash script: https://gist.github.com/vgarcia007/977d992d22a974e00557d6eccb6c78c0

I am mainly a web developer, with a few Linux and Docker skills. But that's it. I must admit I don't understand the code in this repository enough to comprehend if it is possible to implement this in the binary itself or create an in-game menu entry to trigger the sync. If I could, I would try to implement this myself.

For now, my workaround is to trigger the bash script via a Bashy Steam Deck plugin. However, some automation or an in-game possibility would be much nicer. Does anyone have an idea?

Sorry for posting this as an issue, but I thought this way I have the highest chance to reach out to someone with enough interest in this old game :)

@zaps166
Copy link
Owner

zaps166 commented Oct 1, 2023

Hi, you can create a shell script which will sync records, launch a game and sync records when game closes. Modify your game launcher (.desktop or whatever) to launch your script instead of a game 🙂

@vgarcia007
Copy link
Author

This is what I've done so far. Ideally, it would be great if this happened automatically when the files change. I know how I would do that – a small service or something. However, especially on the Steam Deck, this is problematic. So, I thought it would be cool if somehow the game could trigger the sync.

@Krutonium
Copy link

For the steamdeck, have Steam run your script that does the syncing, and have it do the sync before and after closing the game.

@zaps166 zaps166 added the wontfix label Mar 4, 2024
@zaps166 zaps166 pinned this issue Mar 4, 2024
@zaps166 zaps166 closed this as completed Mar 4, 2024
@zaps166
Copy link
Owner

zaps166 commented Mar 4, 2024

Pinned this issue. Closing, because it's task for external tools.

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

No branches or pull requests

3 participants