mauserrifle / simresults

Sim racing result reader for PHP
http://simresults.net
ISC License
60 stars 21 forks source link

Assetto Corsa missing lap 1 position data #42

Closed mhightree closed 6 years ago

mhightree commented 7 years ago

I have an instance where lap 1 is missing for all participants. All other laps are processed ok. This is an Assetto Corsa json file. I can see lap 1 in the file for all participants. Any workaround for this problem? Thanks.

mauserrifle commented 7 years ago

Could you share the log files? Then I can just fix it. Thanks!

mhightree commented 7 years ago

I have attached two race result files. Both exhibit the issue. Thanks for looking at the issue! AssettoCorsaRaceResultFiles.zip

mauserrifle commented 7 years ago

Thnx. I can see the first lap in the json on the web result. I don't see any issue?

http://simresults.net/170416-0vh http://simresults.net/170416-jX2

mhightree commented 7 years ago

That is interesting. When I process those files I don't get lap one. Here are my results. I don't have this problem processing rF1, rF2 or Automobilista files. Ok, well thank you for checking. I will recheck my code.

http://www.simracingonline.co.uk/racing/event.44/racereport/2 http://www.simracingonline.co.uk/racing/event.45/racereport/83

mauserrifle commented 7 years ago

Ok. Keep me posted if its an issue in the library.

mhightree commented 7 years ago

Hello, I think I figured out what is happening. The Lap 1 data does exist in AC. There are two problems. First my code was not defensive enough against NULL values. Second issue is that $lap->getPosition() returns NULL for lap 1 in AC files. Some evidence of that is from your simresults web site. I compared an AC result file with an rF2 file. See attached image. You will notice that the AC file shows lap 2 as the first lap position while the rF2 shows the Grid position and Lap 1 position. I was trying to store the lap 1 position, which doesn't exist, and getting runtime in my code.

Let me know if you have any questions.

ac_result_file

mauserrifle commented 7 years ago

Could you send me that specific log?

mauserrifle commented 7 years ago

Never mind. I got it with my logs too

mauserrifle commented 7 years ago

Found the issue: https://github.com/mauserrifle/simresults/blob/develop/lib/Simresults/Data/Reader.php#L340

Positions are only fixed from lap 2 and on because some sims did have grid position. But in AC case that info is not in the server json files. So need to make it variable per reader. Will fix it soon.

Thnx for the detailed info!

mauserrifle commented 7 years ago

Actually this aint a bug. In AC there is no position data at all. The parser fixes this by reading out the laps of all participants. But the position is for the beginning of the lap. We can't decide the de position for lap 1. Because there are no times to compare yet before that.