PiBoSo Official Forum

GP Bikes => Mods => Plugins => Topic started by: Gibbon on November 19, 2016, 05:49:55 PM

Title: Debug plugins
Post by: Gibbon on November 19, 2016, 05:49:55 PM
Hi,

I'm trying to write a plugin (based on this one: http://www.gp-bikes.com/downloads/gpb_example.c (http://www.gp-bikes.com/downloads/gpb_example.c)).
At first I would like to create a .txt file and write something in it.
I don't know why but it's not working...I mean it works sometimes and I still don't know why.

Here what I did:

-Create new DLL project in Code Blocks (C++)
-Copy gpb_example.c in the main.cpp file I have
-insert extern "C" for every function
- add this code (nothing fancy)

/* called when bike goes to track. This function is optional */
extern "C" __declspec(dllexport) void RunInit(void *_pData,int _iDataSize)
{
    FILE * fp;

    fp = fopen ("test.txt", "wt");
    fprintf(fp, "test");
    fclose(fp);
SPluginsBikeSession_t *psSessionData;

psSessionData = (SPluginsBikeSession_t*)_pData;
}


- Then I built the project and copy the DLL from bin/Debug into GP Bikes plugins folder and modified the extension in .dlo

But after running the game and going to the track, nothing happened...

I tried to install GP Bikes in C: instead of Program Files (I thought writing in Program Files was not allowed) but I still have the problem.

So, I'd like to know if using debug mode in Code Blocks (with host application "core.exe") is possible.

(Also I use Windows 10).

Thanks  ;)
Title: Re: Debug plugins
Post by: HornetMaX on November 19, 2016, 07:40:53 PM
I don't know code blocks (I use visual studio), but I'm not sure you can actually run a debugger on your .dll running inside GPB.

If you don't use debug mode, can you compile and run PiBoSo example plugin ?
Title: Re: Debug plugins
Post by: Gibbon on November 19, 2016, 07:54:37 PM
Yes, the game is running and works well, but I'm not sure the DLL is "viewed" because my function seems to not work.
Title: Re: Debug plugins
Post by: HornetMaX on November 19, 2016, 08:30:52 PM
Sounds like a config problem of your project in Code Blocks.
Title: Re: Debug plugins
Post by: Gibbon on November 19, 2016, 09:58:03 PM
I will have a try on Visual Studio then.
Thank you
Title: Re: Debug plugins
Post by: Gibbon on November 19, 2016, 11:39:50 PM
The plugin is working with Visual Studio.
Thanks  ;)
Title: Re: Debug plugins
Post by: ironbond on September 29, 2020, 06:10:44 AM
Can you help me ? i want to make new project from example source code but i don't know what project is right
Title: Re: Debug plugins
Post by: PiBoSo on September 29, 2020, 08:27:42 AM
Quote from: ironbond on September 29, 2020, 06:10:44 AMCan you help me ? i want to make new project from example source code but i don't know what project is right


It should be a Win32 project.
Title: Re: Debug plugins
Post by: ironbond on September 29, 2020, 10:35:47 AM
Quote from: PiBoSo on September 29, 2020, 08:27:42 AM
Quote from: ironbond on September 29, 2020, 06:10:44 AMCan you help me ? i want to make new project from example source code but i don't know what project is right


It should be a Win32 project.

I tried it, but the problem is my plugins not "viewed" by game,
I did the same thing that Gibbon did, but nothing happened
Can you help me, what's wrong / lacking?

You cannot see attachments on this board.