• Welcome to PiBoSo Official Forum. Please login or sign up.
 
November 21, 2019, 11:50:59 am

News:

GP Bikes beta16b available! :)


Another comment on output plugin data structures.

Started by HornetMaX, June 21, 2016, 07:46:58 am

Previous topic - Next topic

HornetMaX

[Mostly for PiBoSo]

Playing around with RaceData stuff, the more I think about it the more I'm convinced the current data organization is not so good.
We have 3 "high-frequency" callbacks with their respective data structures: RaceClassification, RaceTrackPosition and RaceVehicleData.

It would be much handier if these 3 were actually a single one. Example: when drawing the track map with a dot for each vehicle you may want to color-code the dots to indicate the race leader and/or vehicles already lapped (or being lapped). But to do so you need the classification data.

A simple, single callback could have a single vector of data structure containing everything: the vector would be sorted as the current standings and each element could contain all the data, i.e. standings data (gaps), position data and vehicle data (plus an index to indicate which is the current vehicle being driven or spectated).

I'm not 100% sure about the RaceVehicleData: does a client receive RaceVehicleData for all the other vehicles ? But even if it's not the case, you can have the single vehicle data in the overall data
structure. It would be at the same time simpler (1 callback instead of 3) and much more practical to use.



PiBoSo


Please note that RaceClassification is not called when watching a saved replay.
RaceVehicleData is separate because it's only called for the active vehicle.
"Obviously your ambition outweighs your talent".

HornetMaX

Quote from: PiBoSo on June 21, 2016, 06:03:00 pm
RaceVehicleData is separate because it's only called for the active vehicle.

Understood. But having a single callback instead of 3 coud still work: just add the active vehicle's data to the data structure passed to the single callback.


Quote from: PiBoSo on June 21, 2016, 06:03:00 pm
Please note that RaceClassification is not called when watching a saved replay.

Well, not a big deal, but it should be (even if I do see why it isn't). Still, you could have an empty standings in case of saved replay while preserving the single callback.

Something like:

typedef struct
{
int iNumEntries; // Size of aEntries and of aPositions arrays
SPluginsRaceAddEntry_t *aEntries; // Array of race entries
SPluginsRaceTrackPosition_t *aPositions; // Array of positions

int iNumClassEntries; // Size of aClassEntries: 0 when no standings available (e.g. saved replays).
SPluginsRaceClassificationEntry_t *aClassEntries; // Array of classification entries: instead of RaceNum there should be an index into aEntries.

int iActiveVehicleIdx; // Index of active vehicle into aEntries
SPluginsRaceVehicleData_t activeVehicleData; // Data of active vehicle (only one)

} SPluginsSuperSingleDataStructure_t;