eckhchri / pcars-ds-liveview

Provides a html page for project cars dedicated server and display a map of the current race.
14 stars 1 forks source link

marker duplicates generated if same drivername occurs several times #131

Open viper4gh opened 6 years ago

viper4gh commented 6 years ago

If the same drivername occurs 2 or more times at the same time the associated markers are duplicated on every worker run and remain as "dead" markers.

Explanation: The markers are not simply generated every worker run, they perform a smooth transition from source to destination coordinates. The source coordinate information comes from the previous worker run. That means that you firstly have to map the driver array in the current worker run to the markers from the previous worker run and the only constant identifier is the driver name. But if the name occurs 2 or more times you cannot create a unique assignment between the drivers and the markers, which results in "dead" marker duplicates.

The same happens in DS mode during the SessionState Loading, because the driver array is already completely filled, but all drivernames are empty. That means all driver have the same name "".

The problem ca be replicated by: Load the Demo File "PCARS2_rec_DS_MugelloShort_20LapRace.zip" for example. The SessionState changes from "Lobby" to "Loading" after record position 10. If you then move the map a marker duplicate is generated with every move. The markers are also duplicated with every worker run, but they are all at coordinates [0,0] and you cannot see it, because they are on top of each other.

viper4gh commented 4 years ago

Check if the driver array index from SharedMemory stays connected to the driver names. If yes it maybe could be used as additional identifier. Only problem could be if in multiplayer someone left or joins the session or if someone is disqualified.

Further we rearrange the driver array and use the race position as index for easier calculation of the gaps between the drivers. If the SharedMemory index will stay connected to the drivers then we have to add it as additional value to the PCARSDriver object.

viper4gh commented 4 years ago

ToDo:

viper4gh commented 4 years ago

Tested CREST2 in pcars2 and AMS2, tested DS2 mode with pcars2. Complete Race weekend with Practice, Qualifying and Race. Also Disqualification. In all cases the participant array index remains constant. Only JIP is not tested, because I need other real players for it. But in worst case such markers are deleted and generated new.

In result we can use it next to the driver name as additional identifier and key value for the aSensorData array: https://github.com/eckhchri/pcars-ds-liveview/blob/master/index.html#L1514

viper4gh commented 4 years ago

The recent commit solved the issue. But now the drivetable filter chnages the maker opacity wrong. On any filter the opacity of all markers goes down. That means the mapping between the filtered driver table data and the markers is not working anymore.

Relevant code

index.html: var DrivernamesAfterSearch = jQuery("#DriverDataTable").jqGrid('getCol','drivername'); CSSClsChg.HideSpecificDrivers( DrivernamesAfterSearch );

css_classchanger.js: function HideSpecificDrivers( ObjectsRemainDisplayed ){ var assarray = []; for (var i = 0; i < ObjectsRemainDisplayed.length; i++){
assarray[""+ ObjectsRemainDisplayed[i]] = i; } if ( assarray[""+ d.Key] != undefined ){

viper4gh commented 4 years ago

First step: add oIdx as column to the driver table