Example Plugin Version 2 & Verison 3

bab67

Hi all

When I compile the example plugin version 2 or version 3 and then use it, the output does not consist of data and instead lines such as -STARTUP- and -SHUTDOWN- which are in the same methods as the data that should be written.

Version 1 works fine.

Once I manage to get them working, I would like to cut them down to only the required output. So if it will be easier to work with just what I need then these are the values as they appear in version 3 (ExampleInternalsPlugin::UpdateScoring) which I wish to write to a file:
vinfo.mTotalLaps
vinfo.mFinishStatus
vinfo.mTimeBehindNext

Thanks :cool:
 
I don't have access to the files right now (at work lol), but the info you're referencing is passed into the UpdateTelemetry (?) function - whereas the startup, shutdown, realtime entered/exited, etc etc, are in the functions triggered by those events (which are empty except for the printing you've referred to, I think)

Pretty sure V3 was available when I first grabbed the example plugin (so it was what I used), and had no issues with it. If no one else can shed any light I'll take a look later.
 
Have you changed this line in Example.hpp?

bool WantsTelemetryUpdates() { return( false ); }

*Edit: And this one :)

bool WantsScoringUpdates() { return( false ); }
 
Last edited:
As TimeBehindNext only works for cars that are ahead of the user on the standings, am I heading in the right direction by doing a calculation with the position (mPos.x) of the user and all other vehicles so that the distance between the user and the nearest car in front can be known?
 
The positions are world - plotting X&Z would give you a 'top view', so you can't use them directly for lap distance. There is actually lap distance data, but I haven't found it to be totally reliable. The time values given are also approximate - it's not actually measuring the time gap directly, but using the cars' current 'lap distance' figure and their speed to work out an approximate effective time gap. In practice it varies quite a lot as the cars move around the track.

In setting up a simple 'live timing' page for a server I just relied on it anyway, but if I wanted something more accurate I'd be plotting out the track layout (from the .AIW), setting up my own virtual timing beams, and on each scoring update using each car's current and previous position to detect if and when they crossed each beam and thus work out my own correct gaps. But I haven't bothered yet, and that might be a bit more work than you're looking for (depending what you're looking to achieve).

In short it's not as easy to do what you're trying as you might think :)

Edit: Might also mention .mTimeBehindNext should pretty much work across the whole field - the issue is when there's a lap between successive cars. But generating a timing list using that, rather than time/laps behind leader, can give more useful info for groups of cars that are lap(s) down.
 
Last edited:
Thank you for your detailed reply. Looks like I might have to give it some more thought.

I have done the following function (array):
absolute value(users x axis position - each opponents X axis position)

With the smallest sum being the closest car right?

I just realised this will include cars behind the user, which should be the most furtherest away, so back to the drawing board.

Edit: used for oval racing only
 
Last edited:
Ignoring the Y axis for the moment, if you picture the top view of an oval with the straights along the top and bottom that's what you'd get by plotting X and Z (X and Y in the 'usual' cartesian coordinate system, if that's easier to visualise).

Cars and A and B on the 'bottom' straight would be separated by abs(X[SUB]A[/SUB] - X[SUB]B[/SUB]) - but a car C on the 'top' straight might be calculated to be closer based on abs(X[SUB]A[/SUB] - X[SUB]C[/SUB]). You could do some special-case branching to take out that specific example, but then a track with a different orientation or basic shape (tri-oval, road course :eek:) will need its own. Cue lots of mad tweaking from track to track, sleepless nights, loss of hair, higher blood pressure...

If you're looking to run this on a server (or for offline use) you can probably get pretty good results with the lapdistance figures for each car (need to check lap numbers etc, so cars that just crossed the line and have low lapdistance figures can be kept in the right 'position'; the scoringinfo struct has a track length figure which is useful), otherwise you can either make do with those figures and see how they go for remote cars (I haven't done any specific testing, but I'd be concerned distant cars might warp around a fair bit - still worth trying), or look into the .AIW file and do some of your own path-tracking using the car positions to work out where everyone is.

Anyway, give it some thought, you'll sort something out.
 
I hate the way mTimeBehindNext switches to laps behind next once you are a lap down. I wrote a timing page for an endurance league I race with and it sucks to not really know if one person is gaining on another when looking at the timing. I also display the lap count in decimal form so you can at least get some idea how close one car is to another because you would see one guy on lap 203.5 and the other guy on 202.4. So you know he is just about to unlap the guy ahead of him. I am curious if there is a memory address that could be sniffed to get the exact gaps, even for people that are a lap down.
 
I'm guessing that since it displays such things nowhere (just the number of laps when the gap gets that big), rFactor doesn't actually go to the trouble of calculating it. It already guesstimates the 'current gap' if you don't have it set to just show the sector splits, so having it store potentially x number of laps worth of lap-start ETs so it can calculate the actual gap would seem unlikely - just 2 sector times if needed.

Of course... a server-side program can monitor lap ETs and sector times (when they don't stuff up, as they occasionally seem to) and go about calculating gaps itself. As long as it's monitoring from the start of the race, or longer than any current time-gap, it can work out the sector/lap timing gaps between any two cars. Now I think about it I'm not sure why I didn't do this myself... might need to take a look when I go bugfixing :)
 
Hahaha.. yeah, why didn't I think of doing it this way. I think I will be revisiting my plugin too. :)

I hope we have some big improvements in the API for rF2. The current one is really buggy. I have had to add lots off error traps to work around the random stuff the API does. I wrote a lap logger which we use to track PreQ times (we let people PreQ for a week but only the first 30 laps are counted) and randomly the lapcount will change but the laptime for the new lap is identical to the last. I had to put logic in that holds off on logging the lap if it matches the previous lap and then on the next update if it still matches it will go ahead and log it. I guess it is possible to run the same laptime two laps in a row but really rare.
 
Or sometimes a new lap is started and there's no last lap time - even though they definitely did one, a hotlap sometimes in fact. Without accidentally counting outlaps sometimes only choice is to ignore the lap and just check their fastest time in case it 'mysteriously' changed without them having a last time... lol

I suspect we won't see all that much change initially, but hopefully as they move to JSON and overhaul the system they get some more useful (and consistent) stuff in there :)
 

Back
Top