Kart Racing Pro Official Forum

Mods => Plugins => Topic started by: PiBoSo on June 19, 2010, 10:40:35 PM

Title: Output Plugins
Post by: PiBoSo on June 19, 2010, 10:40:35 PM
It is possible to write a DLL that receives data from the simulated kart in realtime.

Example source code can be downloaded at http://www.kartracing-pro.com/?page=downloads

Please note that all function calls are blocking, so control should be returned to simulation as soon as possible to avoid framerate issues.

The DLL must be compiled for 64 bit.

The plugin must have the file extension renamed to DLO and it must be copied to the "plugins" directory in Kart Racing Pro installation folder.

NOTE: a license is not needed to add plugins.
Title: Re: Plugins
Post by: PiBoSo on October 30, 2011, 01:23:57 AM
Example source code updated to the latest interface.
Title: Re: Output Plugins
Post by: PiBoSo on October 05, 2012, 02:41:44 PM
Example source code updated to the latest interface and first post updated.
Title: Re: Output Plugins
Post by: PiBoSo on March 21, 2013, 06:29:17 PM
Example source code updated to the latest interface ( backward compatible with the previous one ), that adds the possibility to draw on the screen.
Title: Re: Output Plugins
Post by: PiBoSo on June 08, 2013, 11:38:26 PM

Example source code updated to the latest interface ( backward compatible with the previous one ), that adds the possibility to get the track centerline.
Title: Re: Output Plugins
Post by: Russell Hodgson on February 24, 2014, 07:06:25 PM
Can you add the ability to get the percentage of the way round the track the kart is at any given time?
Title: Re: Output Plugins
Post by: PiBoSo on February 24, 2014, 08:11:22 PM
Quote from: Russell Hodgson on February 24, 2014, 07:06:25 PM
Can you add the ability to get the percentage of the way round the track the kart is at any given time?

Percentage = 100 * _fPos
_fPos is a parameter of RunTelemetry
Title: Re: Output Plugins
Post by: Russell Hodgson on February 24, 2014, 09:58:23 PM
Quote from: PiBoSo on February 24, 2014, 08:11:22 PM
Quote from: Russell Hodgson on February 24, 2014, 07:06:25 PM
Can you add the ability to get the percentage of the way round the track the kart is at any given time?

Percentage = 100 * _fPos
_fPos is a parameter of RunTelemetry

Brilliant.  Thanks!
Title: Re: Output Plugins
Post by: PiBoSo on April 06, 2014, 05:36:30 PM

Example source code updated to the latest interface.
Title: Re: Output Plugins
Post by: PiBoSo on January 02, 2015, 11:29:31 PM

Example source code updated to the latest interface.
Title: Re: Output Plugins
Post by: PiBoSo on July 20, 2015, 09:41:54 PM

Example source code updated to the latest interface.
Title: Re: Output Plugins
Post by: HornetMaX on July 22, 2015, 11:58:10 PM
Quote from: PiBoSo on July 20, 2015, 09:41:54 PM

Example source code updated to the latest interface.
Uh, is this (and the updates for proxy and input plugins) for the future beta14 ?

Some interesting stuff !!

MaX.
Title: Re: Output Plugins
Post by: Russell Hodgson on December 16, 2015, 11:07:21 PM
Would it be possible in future versions of the API to get information in the competitors?  I'd like to see for each competitor the following: the driver name; the type of kart being driven; where they are on track (ie percentage of the way round); whether they are in the pits or on track; their current fastest lap time; the current position in the session (ie 1st, 2nd, 3rd, etc).

Thanks!
Title: Re: Output Plugins
Post by: HornetMaX on December 17, 2015, 08:52:27 AM
Quote from: Russell Hodgson on December 16, 2015, 11:07:21 PM
Would it be possible in future versions of the API to get information in the competitors?  I'd like to see for each competitor the following: the driver name; the type of kart being driven; where they are on track (ie percentage of the way round); whether they are in the pits or on track; their current fastest lap time; the current position in the session (ie 1st, 2nd, 3rd, etc).
Most of this is already there in beta14, check all the SPluginsRace*_t data structures (http://www.kartracing-pro.com/downloads/krp_example.c (http://www.kartracing-pro.com/downloads/krp_example.c)).

The "where they are on track (ie percentage of the way round)" has been recently added to WRS beta8, so it should make its way in KRP too I guess.

One thing I think is still missing (even in WRS beta8) is this: http://forum.kartracing-pro.com/index.php?topic=5478.msg42582#msg42582 (http://forum.kartracing-pro.com/index.php?topic=5478.msg42582#msg42582)
Title: Re: Output Plugins
Post by: Russell Hodgson on December 17, 2015, 07:30:55 PM
As far as I can tell that information is only there for the kart I am driving.  I want to see if for every kart on track.  Am I missing something in the API?
Title: Re: Output Plugins
Post by: HornetMaX on December 18, 2015, 08:32:34 AM
Quote from: Russell Hodgson on December 17, 2015, 07:30:55 PM
As far as I can tell that information is only there for the kart I am driving.  I want to see if for every kart on track.  Am I missing something in the API?
I haven't tried it yet on an online event, but to me it looks like it's for all the kart in the event. For example, the below definitely looks like the client is gonna receive the whole classification, of all the karts:

typedef struct
{
int m_iSession;
int m_iSessionState;
int m_iSessionTime;
int m_iNumEntries;
} SPluginsRaceClassification_t;

typedef struct
{
int m_iRaceNum;
int m_iState;
float m_fBestLap;
float m_fBestSpeed;
int m_iBestLapNum;
int m_iNumLaps;
float m_fGap;
int m_iGapLaps;
float m_fPenalty;
int m_iPit;
} SPluginsRaceClassificationEntry_t;


/* This function is optional */
__declspec(dllexport) void RaceClassification(void *_pData,int _iDataSize,void *_pArray,int _iElemSize)
{

}


You also have the two call RaceAddEntry and RaceRemoveEntry that notify the client when a new player joins/quits the event. So it definitely looks like you'll get data for all the participants (which I guess was the whole point of the whole RaceData stuff).
Title: Re: Output Plugins
Post by: Russell Hodgson on December 18, 2015, 11:04:08 PM
Thanks!
Title: Re: Output Plugins
Post by: Dragoon on June 28, 2016, 01:15:10 PM
Is there a plan to output also wheel temperatures? It would be very cool to see how the temperatures develop :)
Title: Re: Output Plugins
Post by: PiBoSo on August 12, 2016, 04:51:19 PM

Example source code updated to the latest interface.
Hopefully this will be the final one.
Title: Re: Output Plugins
Post by: Russell Hodgson on November 21, 2016, 11:30:23 PM
Does a plugin still need to have a .dlo extension?  We are trying to use the latest interface (data version 5 and interface version 9)  But the sim doesn't seem to see our plugin.  Any ideas?
Title: Re: Output Plugins
Post by: PiBoSo on December 31, 2016, 05:43:44 PM
Quote from: Russell Hodgson on November 21, 2016, 11:30:23 PM
Does a plugin still need to have a .dlo extension?  We are trying to use the latest interface (data version 5 and interface version 9)  But the sim doesn't seem to see our plugin.  Any ideas?

Yes, output plugins must have the DLO extension.
Title: Re: Output Plugins
Post by: HornetMaX on December 31, 2016, 05:51:57 PM
Quote from: Russell Hodgson on November 21, 2016, 11:30:23 PM
Does a plugin still need to have a .dlo extension?  We are trying to use the latest interface (data version 5 and interface version 9)  But the sim doesn't seem to see our plugin.  Any ideas?
Be sure to check that you have in your plugin all the functions that are not marked as optional in the sample code.
Title: Re: Output Plugins
Post by: PiBoSo on March 11, 2017, 04:15:14 PM

Example source code updated to the latest interface.
Title: Re: Output Plugins
Post by: Russell Hodgson on March 21, 2017, 06:08:22 PM
Quote from: HornetMaX on December 31, 2016, 05:51:57 PM
Quote from: Russell Hodgson on November 21, 2016, 11:30:23 PM
Does a plugin still need to have a .dlo extension?  We are trying to use the latest interface (data version 6 and interface version 9)  But the sim doesn't seem to see our plugin.  Any ideas?
Be sure to check that you have in your plugin all the functions that are not marked as optional in the sample code.

They are and still it doesn't seem to be recognized.

Is there a way to check in KRP to see if it is registering the plugin?  Also is there a way to see which version of KRP is running?  I have updated to the latest beta, but the program seems the same as before.

Thanks.
Title: Re: Output Plugins
Post by: HornetMaX on March 21, 2017, 09:15:32 PM
CTRL-V in any KRP screen shows the version number on screen.

When a plugin is not seen by KRP, most likely you're using the wrong plugin interface version.
Title: Re: Output Plugins
Post by: Russell Hodgson on March 22, 2017, 08:17:19 PM
Quote from: HornetMaX on March 21, 2017, 09:15:32 PM
CTRL-V in any KRP screen shows the version number on screen.

When a plugin is not seen by KRP, most likely you're using the wrong plugin interface version.

Is there a screen that displays the plugins that are currently recognized by the sim?

As far as I can tell we are implementing everything correctly.  So I need to know if the issue is KRP isn't seeing the plugin, or if it is and for some reason the plugin isn't working as expected.

Thanks.
Title: Re: Output Plugins
Post by: HornetMaX on March 22, 2017, 08:29:48 PM
Quote from: Russell Hodgson on March 22, 2017, 08:17:19 PM
Is there a screen that displays the plugins that are currently recognized by the sim?
Not that I'm aware.

Quote from: Russell Hodgson on March 22, 2017, 08:17:19 PM
As far as I can tell we are implementing everything correctly.  So I need to know if the issue is KRP isn't seeing the plugin, or if it is and for some reason the plugin isn't working as expected.
My plugin works fine so I'm tempted to think there's something wrong on your side.
Title: Re: Output Plugins
Post by: ajunhyuk on July 16, 2017, 06:28:52 PM
Where can I download the final version sample project and code?


Title: Re: Output Plugins
Post by: PiBoSo on July 17, 2017, 01:04:52 AM
Quote from: ajunhyuk on July 16, 2017, 06:28:52 PM
Where can I download the final version sample project and code?

It can be downloaded from the download page of the official website.
Direct link: http://www.kartracing-pro.com/downloads/krp_example.c
Title: Re: Output Plugins
Post by: Racer_S on January 04, 2018, 04:14:59 PM
Trying to update some of my existing output plugins for V4. 

When using the new plugin example from the website the game is crashing when clicking ToTrack.  Even with no changes to example.

Anyone else?


EDIT:

I have found changing


__declspec(dllexport) int GetModDataVersion()
{
return 6;
}


to 5 it does not crash anymore, but ofcourse the telemetry output does not work either.
Title: Re: Output Plugins
Post by: HornetMaX on January 04, 2018, 05:50:19 PM
Quote from: Racer_S on January 04, 2018, 04:14:59 PM
Trying to update some of my existing output plugins for V4. 

When using the new plugin example from the website the game is crashing when clicking ToTrack.  Even with no changes to example.

Anyone else?
All my plugins work fine with v4 (no change from v3, v2, v1 and beta16, if I recall correctly).
I'm tempted to say you're doing something wrong.
Title: Re: Output Plugins
Post by: PiBoSo on January 04, 2018, 07:16:41 PM
Quote from: Racer_S on January 04, 2018, 04:14:59 PM
Trying to update some of my existing output plugins for V4. 

When using the new plugin example from the website the game is crashing when clicking ToTrack.  Even with no changes to example.

No changes have been made to the plugins interface, so all plugins for previous versions, down to Beta16, should still work.
Title: Re: Output Plugins
Post by: Racer_S on January 04, 2018, 07:50:22 PM
Thanks for the quick reply guys.

The old plugin used to work with older version of KRP but it does not work anymore, hence the reason I am trying to update.

The only difference from my old source I can see is GetModDataVersion was changed to 6, and RPM was changed from float to integer?

I am using Visual Studio 2013 to compile, the project was created using the empty DLL template.

I've tried adding extern "C" and compiling as C code,  It still crashes when I click ToTrack.

Does KRP not like VS2013 compiler?


EDIT: I tried compiling the example with MinGW and its crashing still.






Title: Re: Output Plugins
Post by: Racer_S on January 09, 2018, 04:08:44 PM
No solution?

The example does not work without crashing.

Steps to reproduce:

Compiling latest example as DLL with DLO extension and placing in plugin folder. 

Crashes when clicking ToTrack in KRP release 4.

Title: Re: Output Plugins
Post by: HornetMaX on January 09, 2018, 09:53:35 PM
Quote from: Racer_S on January 04, 2018, 07:50:22 PM
The only difference from my old source I can see is GetModDataVersion was changed to 6, and RPM was changed from float to integer?
No, I think there's also the extra field "int m_iInvalid;" in structures SPluginsKartLap_t and SPluginsRaceLap_t.
Title: Re: Output Plugins
Post by: PiBoSo on January 09, 2018, 10:24:46 PM
Quote from: Racer_S on January 09, 2018, 04:08:44 PM
No solution?

The example does not work without crashing.

Steps to reproduce:

Compiling latest example as DLL with DLO extension and placing in plugin folder. 

Crashes when clicking ToTrack in KRP release 4.

No crash here with the compiled example.
What compiler are you using? Are you compiling as C? Is the integer size 32 bits? Is the struct member alignment 8 bytes?
Title: Re: Output Plugins
Post by: Racer_S on January 14, 2018, 02:07:02 AM
I am indeed compiling as C.

If compiled as C++, the game does not recognize it and there is no crash.

I have tried with the new version of WRS and his example output plugin and same problem there.
Strange because I never had this problem with the older versions of KRP and WRS.

I have tried aligning the structs with #pragma pack ( 8 )
Tried turning off all optimizations, tried compiling with older visual studio toolset compilers, and intel compiler...

Always crashes when clicking ToTrack..  I am out of ideas.



Some other details:
I am testing with the DEMO

This is the order I am starting the race
Testing>Start >ToTrack *crash*


Here is a link to the visual studio project and compiled DLO plugin.

https://drive.google.com/file/d/1N5XgUaZ-iQeCGFYz0Nro2mZupXhfCXWc/view?usp=sharing


Thanks for any help, I think I will just recommend our clients use an older version of KRP for now.
Title: Re: Output Plugins
Post by: Racer_S on February 14, 2018, 06:46:31 PM
FWIW, I've solved the crashing problem by commenting out this function:


__declspec(dllexport) void Draw(int _iState, int *_piNumQuads, void **_ppQuad, int *_piNumString, void **_ppString)
{

}


I didnt need it in my case anyway. Thanks!
Title: Re: Output Plugins
Post by: PiBoSo on February 15, 2018, 12:17:31 PM
Quote from: Racer_S on February 14, 2018, 06:46:31 PM
FWIW, I've solved the crashing problem by commenting out this function:


__declspec(dllexport) void Draw(int _iState, int *_piNumQuads, void **_ppQuad, int *_piNumString, void **_ppString)
{

}


I didnt need it in my case anyway. Thanks!

Thank you for the report.
Title: Re: Output Plugins
Post by: PiBoSo on April 09, 2019, 12:16:48 PM

Please note that, starting with Release8, output plugins must be compiled for 64 bit.
Title: Re: Output Plugins
Post by: PiBoSo on December 22, 2023, 11:34:41 PM
Example source code updated to add a couple functions to control the replay / live riders and cameras selection.