PDA

View Full Version : Memory Mapped File gives incorrect Lap Number for Online events?



RacingSaul
14-05-2018, 19:03
Hi folks,

I've noticed when trying to read the PC2 format Memory Mapped File (MMF) that when running online events the lap number does not always change on crossing the line.

I would post an example, but apparently I'm not allowed links. So check the "Vintage Spring" event on the "UnstopaPaul" youtube channel at 3m28s to see this occurring.

you can see that lap 3 only registers in the last corner before lap 4 - almost a full lap later. On other tracks (e.g. Sakitto) it generally seems to register about 2 corners in.


This problem does not occur with offline events.
All other telemetry data lines up with what was happening at the time (e.g. current lap time)
I'm taking Lap Number straight from telemetry like every other piece of data.


I'm trying to work around this by using the resetting of lap time to indicate the change of lap. This works ok, but means I lose the ability for the app to be launched mid session and understand which lap it is truly on.

Any of the devs want to help a guy out here? Is this a confirmed issue?

cpcdem
15-05-2018, 02:13
Are you absolutely sure you are reading the lap number for the correct car and not from another one? It could explain the problem if you are accidentally reading the current lap for another car and the info updates at the time that car passes the finish line.

I will also have an eye open in my next online races to see if this value updates correctly.

Edit: thinking more about it, this must be it. You are always reading the current lap from mParticipantInfo[0], right? This works fine in offline, because there the user's car is always the first in the list, but online it can be anywhere, so you need to locate the correct entry first.

Shepard2603
15-05-2018, 06:39
Got your 6 Paul! Here is the link:

https://www.youtube.com/watch?v=FImQJ9ouppQ

RacingSaul
15-05-2018, 07:35
Are you absolutely sure you are reading the lap number for the correct car and not from another one? It could explain the problem if you are accidentally reading the current lap for another car and the info updates at the time that car passes the finish line.

I will also have an eye open in my next online races to see if this value updates correctly.

Edit: thinking more about it, this must be it. You are always reading the current lap from mParticipantInfo[0], right? This works fine in offline, because there the user's car is always the first in the list, but online it can be anywhere, so you need to locate the correct entry first.

OMG. THis is what happens when you write and wrap some code up then leave your project for 2 weeks :). That is an amazing shout. I can confirm I'm doing that (there's even a comment beside that code to come back and verify it is always participant 0). I will try that change, but it already sounds like the winner. Hopefully I can confirm this evening

Thank you so much!

(PS. I'm guessing [0] is the first person into lobby then?)

MaXyM
15-05-2018, 11:01
Please also note the array might be reordered in case participants are joining/leaving the session. It's at least what I've heard from another developer.
Use unique identifier to match particular driver.

cpcdem
15-05-2018, 13:23
OMG. THis is what happens when you write and wrap some code up then leave your project for 2 weeks :). That is an amazing shout. I can confirm I'm doing that (there's even a comment beside that code to come back and verify it is always participant 0). I will try that change, but it already sounds like the winner. Hopefully I can confirm this evening

Thank you so much!

(PS. I'm guessing [0] is the first person into lobby then?)

Glad I could help! I'm pretty sure I was caught by the same thing, too, before I realized it's not always my car first in the array.
About [0] being the first person in the lobby, that's my guess, too, but I have not checked it, I am always reordering based on current race position anyway, so it did not make a difference to me.

RacingSaul
15-05-2018, 17:38
Please also note the array might be reordered in case participants are joining/leaving the session. It's at least what I've heard from another developer.
Use unique identifier to match particular driver.

So for safety always look up the array based on player name? Thanks for the tip

RacingSaul
15-05-2018, 17:57
SOLVED

Superstars all of you. Thanks so much!

I'm now using data.mParticipantData[data.mViewedParticipantIndex].mCurrentLap to find player, and this seems to work on some recorded data. (I'm feeling smug for having a debug logger that just dumps every raw PC2 MMF frame sample to disk so I can replay it in tests through my parser :D )

I haven't checked, but as mViewedParticipantIndex comes through with every frame, I'd expect it to update with leavers/joiners.

cpcdem
15-05-2018, 17:57
So for safety always look up the array based on player name? Thanks for the tip

That's what I always do. For me it's simple, because I am the only one who uses my apps, so I have hard coded the name :)