Git Product home page Git Product logo

klplugins.dynleaderboards's Introduction

SimHub ACC Dynamic Leaderboards Plugin

This is an ACC specific (at least at the moment) leaderboard plugin providing simple switching between overall/class/relative leaderboards.

The reason for this plugin is that I found myself creating effectively the same dash leaderboard layout several times for overall leaderboard and then again for class leaderboard and so on. And then again when I decided to change something. With this plugin you need to create only one SimHub dash and assign buttons to swap between different leaderboard types. Also there seem to be some issues with SimHub's ACC leaderboard data, which I set on to fix with this plugin. I provide example dash (named AccDynLeaderboard) which I created for my own use. It's relatively simple one and designed to be used on smartphone.

Features

  • Connect directly to ACC broadcasting server to have most control and try to provide reliable results.
  • Provide a way to switch between leaderboard types on a single dash screen with a single click.
    • Also provide gaps and lap deltas that change based on currently selected leaderboard.
  • Provide more leaderboard types (see here).
  • Calculate bunch of new properties (see here or download the plugin as they are also mostly listen under the settings tab).
  • More stable calculation of gaps between the cars (no more gap changing by 1s depending if you are in the corner or straights).

Getting started

  • Download the latest release from OverTake or here

  • To install provided dashboard run "AccDynLeaderboard_v8.simhubdash".

  • Copy all the files from folder "SimHub" to the SimHub root

  • Open SimHub and enable the plugin

  • Check plugin settings for correct "ACC configuration location" under "General settings". If it's background is green, then we found needed files, if it's red there's something wrong with the location. We need to find the file "...\Documents\Assetto Corsa Competizione\Config\broadcasting.json". It is used to read information needed to connct to ACC broadcasting client.

  • If you needed to change the location, restart SimHub.

  • Go to "Controls and events" from SimHub sidebar and add mappings for DynLeaderboardsPlugin.Dynamic.NextLeaderboard and DynLeaderboardsPlugin.Dynamic.PreviousLeaderboard actions.

    For mapping to controller inputs you need to enable "Controllers input" plugin and to keyboard inputs "Keyboard Input" plugin.

  • Now the AccDynLeaderboard dash should work.

  • For best experience start SimHub before joining the session, but it should work other way too.

More information

Head over to the docs. It describes all available options, properties, how to use, configure and troubleshoot known issues.

SimHub and ACC version

Last tested on ACC v1.9.6 and SimHub v9.1.22. Since v1.3.0 this plugin needs at least SimHub v8.3.0 to work.

klplugins.dynleaderboards's People

Contributors

kaiusl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

lukaslichten

klplugins.dynleaderboards's Issues

Gaps on track

Hi again,

Using the Gap.ToFocused.OnTrack property to calculate the gap ahead/behind myself, I notice the result will include cars in the pitlane. Would it be possible to exclude cars in the pitlane with this property or am I overlooking another property that will achieve this?

Simhub has a built in quick component (Opponent gap) that will allow to select a gap "Leaderboard Position Relative to Player on Track" that can solve this but the internal gap calculation is not stable like you have corrected nicely in your plugin.

I have tried setting Simhub's gap computation mode to "game" or "Simhub" but the results are the same.

(BTW thanks for the additional valid.lap properties, they work great!)

after an acc 1.9.0 update position for each car is -1

this error is spamming logs

[2023-04-19 21:29:10,555] INFO - DynLeaderboards (ACCUdpRemoteClient.cs: ConnectAndRun,86)
	Couldn't connect to broadcast client. Err System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at KLPlugins.DynLeaderboards.Values.<>c__DisplayClass72_0.<OnBroadcastRealtimeUpdate>g__SetStartionOrder|5()
   at KLPlugins.DynLeaderboards.Values.OnBroadcastRealtimeUpdate(String sender, RealtimeUpdate update)
   at KLPlugins.DynLeaderboards.ksBroadcastingNetwork.BroadcastingNetworkProtocol.ProcessMessage(BinaryReader br)
   at KLPlugins.DynLeaderboards.ksBroadcastingNetwork.ACCUdpRemoteClient.<ConnectAndRun>d__29.MoveNext()

no errors in single player mode

Save leaderboard configs separately

This would allow to pack configs with dashboards/overlays and wouldn't require separate setup by the end user's who just downloaded the dashboard/overlay.

Suggestions for enhancement

Hi,
I was thinking about additional properties that might be accessible from the plugin, not sure if the below data would be accessible from ACC and can be implemented?

  1. Distance in meters to the yellow flag incident ahead, or white flag (slow car) ahead? (Have seen this used in other programs so it appears that ACC outputs this data)

  2. Drive-through or stop-and-go penalties (with associated time penalty in seconds) per driver

  3. Mandatory pit requirement & completion per driver (i.e. DataCorePlugin.GameRawData.Graphics.missingMandatoryPits & DataCorePlugin.GameRawData.Graphics.MandatoryPitDone)

Best Lap Sectors = Last Lap Sectors, and Position Overall Start = -1 for all cars on race restart

Describe the bug

Hi,

The best lap sectors are equal to the last lap sectors, even when the lap is not your best lap, i.e. .Laps.Best.S1 = .Laps.Last.S1 (and the same for S2 and S3).

Also if you restart a race, then the Position.Overall.Start = -1 for all cars.

Otherwise a great plugin.

Reproduction steps

I am running the latest version of ACC (v 1.9.5) and the latest version of Simhub (v 9.15), do your fastest lap and then do a slow lap. At which point .Laps.Best.S1 = .Laps.Last.S1 instead of .Laps.Best.S1 still relating to your best lap.

After doing them lap, restart the race and then Position.Overall.Start = -1 for all cars instead of their correct starting position.

Plugin version

1.3.2

SimHub version

9.15

Relevant log output

No response

Extra information

No response

Add mandatory pit info

Split from #14.

Add mandatory pit requirement & completion per driver (i.e. DataCorePlugin.GameRawData.Graphics.missingMandatoryPits & DataCorePlugin.GameRawData.Graphics.MandatoryPitDone).

Generate lap data for Red Bull Ring

I won't be getting the new ACC DLC right now and thus I cannot generate the lap data for Red Bull Ring and need some help updating the plugin to include proper gaps calculation.

How to

  • Download and install utility plugin for SimHub from https://github.com/kaiusl/KLPlugins.DataExport/releases/tag/v0.0.2

  • Run three 10min AI qualy sessions (see below for the images with session settings):

    • one with GT3, CUP21,
    • one with GT2, ST21, CHL
    • another for GT4, TCX
      (so they don't trip each other up that much, also don't max out the opponents for the same reason, I used 5 cars in each class)

    This will track the AI cars and save their best lap data.

  • Either:

    • a) upload the generated files from ..\SimHub\PluginsData\KLPlugins\DataExport\laps_data\raw (as zip or make a PR with them added to PluginsData\KLPlugins\DataExport\laps_data\raw), so I can post process them or

    • b) fork this repo, copy the generated files to the forks PluginsData\KLPlugins\DataExport\laps_data\raw and run the python post processing script PostProcessLapData.py and submit a PR with newly generated lap data files. (Both raw and post processed files should be included).

      Note that occasionally the raw generated files can end with weird position values (jumps from 1 to 0.x). If it is the case for all classes then the track has some offset between the point where position and time reset. However if happens only for some of the class then so far rerunning the qualy session and regenerating the raw files has fixed that issue.

1
4

PartialRelativeClass shows N-1 position ahead instead of N

If the number of relative positions for partial relative class leaderboard is set to N, then it only shows N-1 positions ahead but N+1 positions behind. Simplest to see it is to compare to the partial overall leaderboard in single class race.

The positions need to be shifted by one. Should be a simple fix, I think...

Other Game Support

I have been maintaining a personal fork to allow me to use this leaderboard plugin for all my streams, even if the game is not ACC (and also address some short comings). https://github.com/LukasLichten/KLPlugins.DynLeaderboards/tree/generalized

However it is currently not in a state of being turned into a PR:

  • Still uses depracted SimHub Opponent data
  • Unrelated features such as a work around flag for ACC driverswap (so the plugin stays connected if simhub sets the game to stopped), and other things I probably forgot about
  • All drivers are treated as pro and as unknown class (which inherits the GT3 styling)
  • Branch is 37 commits behind
  • Some of my commits undo and redo changes due to refactoring work done by you over time (the commits might say 3 weeks ago, this is because of a rebase, we are talking about years here in actuality)
  • Adheres to code conventions as well as a teenager to curfew

Before I rebase and or rebuild (potentially into multiple PRs) this I wanted to ask.
Firstly if I should do this at all.
But then in terms of design especially how and if other game multiclass should be handled, as it would require in the UI the ability to add more classes, perhaps require defining car names that would be put into the class (for AC for example), but especially the car classes could no longer be handled by an Enum.

Currently the other game support is run by in large parts emulating the way the websocket messages would be reencoded into classes like RealtimeUpdate (but instead using another constructor that takes the simhub data to construct it) using the ProcessViaSimHub function in Values.

For the other things that can be turned into other PRs:

  • ACC driver swap work around:
    • SimHub thinks the game is no longer "running" if you are not actively driving. While you can swap SimHub to spectator mode, to remember to swap this back prior to the driver swap is difficult and cumbersome (also causes all plugins to reload)
    • So, if the game is ACC, and our websocket is not already connected, and SimHub doesn't think ACC is running, then check the Windows API to see if we can find the process running, if it is try connect (if it fails we retry after a bit)
    • That win api poll is slow (5ms), but because it only triggers when the game truely isn't running we don't need to worry about causing SimHub to drop updates
    • Obviously data like session time or session time are not updated, we do have these values from the websocket, so could add them as propertys (I did a hack workaround for Session Time Remaining)
  • Apparently I added at some point actions that swap the leaderboard into specfic modes (instead of having only cycle actions)
  • Some fixes for Values going out of bounds (like my most recent commit to make a workaround for GT2)

Add backup gap calculation if proper lap data is not available

Should fix improper gap calculations if a new track is released but we haven't managed to push an update yet. At the moment the gaps are null if the lap data is not available.

We can use a distance based calculation as a backup, so then the gaps do fluctuate a bit more but at least we get realtime gaps.

full name not working

Trying to use full name on leaderboard, i replaced the line
return DynLeaderboardsPluginProp(leaderBoardName, position, "Driver.1.InitialPlusLastName").replace(teamName, "");
with
return DynLeaderboardsPluginProp(leaderBoardName, position, "Driver.1.Fullname").replace(teamName, "");

Now the name is blank in leaderboard

If i change the settings in simhub additional plugins/DynLeaderboardsPlugin the same thing happens. I have restarted Simhub.

Request: Valid lap status

Hi,
Great plugin and additional properties, thanks for all the hard work.

Wondering if it is possible to add a property that determines if a given car is currently on a valid lap? I.E. if Car X is on an outlap or has invalidated the current lap, return 0, else return 1 , for example.

It seems this info is available within ACC on the track map but the current Simhub property (isValidLap) is available only for yourself and not other drivers.

Thank you

First time init doesn't create config if game is not ACC, but does throw an error on Simhub start

The default leaderboard config is generated at the first start of the plugin. At the moment this only seems happens if the selected game is ACC. However starting the plugin (with any game selected) needs to load that config file. So starting the plugin first time when the selected game is not ACC results in an error.

Steps to reproduce

  • Open Simhub and select some other game than ACC
  • Close Simhub
  • Delete PluginsData\KLPlugins\DynLeaderboards\leaderboardConfigs
  • On the next reload of Simhub an error occurs
[2023-04-18 11:52:08,255] ERROR - An error occured while loading plugin settings control for DynLeaderboardsPlugin: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at KLPlugins.DynLeaderboards.Settings.SettingsControl..ctor(DynLeaderboardsPlugin plugin)
   at KLPlugins.DynLeaderboards.DynLeaderboardsPlugin.GetWPFSettingsControl(PluginManager pluginManager)
   at SimHubWPF.MainWindow.<>c__DisplayClass52_0.<LoadPluginsControls>b__0()

Temporary fix

On my machine Simhub itself launches fine even with this error. Solution is to just select ACC, which will reload the plugin and generate the needed config file. Any following launches (with any game selected) work fine.

Add penalties info

Split from #14.

Add drive-through or stop-and-go penalties (with associated time penalty in seconds) per driver

Generate lap data for Valencia

As I won't be getting the new ACC DLC on the 19th and thus cannot generate the lap data for Valencia, I need some help updating the plugin.
@Mtrade You still up for helping?

How to

  • Download and install utility plugin for SimHub from https://github.com/kaiusl/KLPlugins.DataExport/releases/tag/0.0.1
  • Run two 10min AI qualy sessions (see below for the images with session settings):
    • one with GT3, CUP21, ST21, CHL
    • another for GT4, TCX
      (so they don't trip each other up that much, also don't max out the opponents for the same reason)
      This will track the AI cars and save their best lap data.
  • Upload the generated files from \SimHub\PluginsData\KLPlugins\DataExport\laps_data\raw.

1
4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.