Geekid812 / TrackmaniaBingo

An Openplanet plugin to race against your friends to be the first team to complete a Bingo board!
https://openplanet.dev/plugin/trackmaniabingo
16 stars 5 forks source link

Some runs are not counted if there exists a better PB #6

Closed Geekid812 closed 1 year ago

Geekid812 commented 1 year ago

For some reason. let's try and find out why

Geekid812 commented 1 year ago

Update: looking for people who can reproduce this issue, or any issue regarding a time that is not submitted as a claim when it should! please let me know the circumstances under which this bug happens in this issue :eyes:

XertroV commented 1 year ago

WRT the circumstances under which it happens, I suspect it's because of how you access the ghost, here: https://github.com/Geekid812/TrackmaniaBingo/blob/3a5de0ccd1e8d4f4c1745c89cc83b70be7db847d/src/play.as#L70

An alternate way (how TTG does it) is to track the number of ghosts, and then when a finish is detected, wait for the number of ghosts to increase and then get the most recent ghost's time.

Additional info and explanation:

In both cases, record ghosts get loaded into app.Network.ClientManiaAppPlayground.DataFileMgr.Ghosts. So you need to either check the nickname on the ghost, or just tolerate that there's a tiny race condition where someone could load a record ghost at the exact moment they finish or something like that.

My suspicion is that PlaygroundScript.Ghost_RetrieveFromPlayer is acting like a server would, which will return the best ghost for that player. You could test this by getting e.g., a 20s run, checking the time returned, then getting a 30s run, and checking the time returned (my prediction is that it'll be 20s not 30s).

This sort of bug would only matter if ppl already had a PB on the map -- and if the PB ghost loaded, which doesn't seem to always happen. Once they get a time, the best ghost isn't their new ghost, it's their PB.

Also, I am not exactly sure what Ghost_RetrieveFromPlayer actually does. It sounds like something a server could do to ask the client to send their ghost. That could mb load the PB ghost if it isn't already. Additionally, ghosts sometimes aren't populated immediately (this is particularly noticeable on a server), so it's possible that you would have pulled the right ghost if you requested it a frame or two later. I haven't noticed this in local play, but I have run into a handful of weird bugs that occur only with high FPS. So it might be possible that the combination of all these things together are responsible for the bug.