InternalsPluginV05 - successful build anyone ?

Discussion in 'Plugins' started by celkaris, May 24, 2013.

  1. celkaris

    celkaris Registered

    Joined:
    May 19, 2013
    Messages:
    31
    Likes Received:
    0
    [SOLVED] InternalsPluginV05 - successful build anyone ?

    hi,

    Can anyone confirm a successful plugin build & usage with current build 218 (or 217 as reported by dev mode) ?

    I tried implementing a bare plugin, inspired by sample plugin from http://rfactor.net/web/rf2/devscorner/ ("v5 Download – May 20, 2013") but rf2 refuses to start when the plugin is there (starts, initializes gfx window then crashes).

    I tried implementing v1 and v5 plugins, same result.

    Here are some logs when started in dev mode with +trace=4 :

    trace.txt:
    Code:
    TRACE LEVEL = 3
    TRACE LEVEL = 4
    tracelog.cpp  139: Command line: "+path=".." +hash=####HIDDEN#### +trace=4"
    main.cpp      218: FPU=0x0009001f
    game.cpp     1692: Entered Game::Enter()
    osman.cpp     727: Entered OSMan::Enter()
    plrfile.cpp  2891: Entered PlayerFile::Enter()
    setup.cpp    2031: ATTENTION: Skipping vehicle because the filename rter_01.veh matches an existing vehicle
    setup.cpp    2031: ATTENTION: Skipping vehicle because the filename rter_02.veh matches an existing vehicle
    plrfile.cpp  2033: Attempting to save to E:\games\rfactor2\ModDev\UserData\player\player.TMP
    plrfile.cpp  2066: Retcode: 0 for renaming to E:\games\rfactor2\ModDev\UserData\player\player.PLR
    hwinput.cpp  7484: Entered HWInput::Enter()
    hwinput.cpp  7485: HKL=0x04090409
    

    my v5 plugin log (logs every function/method entry, only those are shown til crash) :
    Code:
    +++GetPluginName()
    +++GetPluginType()
    +++GetPluginVersion()
    +++CreatePluginObject()
    +++ExampleInternalsPlugin::PostReset()
    
    Win7 error window:
    Code:
     Problem Event Name:	APPCRASH
      Application Name:	rFactor2 Mod Mode.exe
      Application Version:	1.2.1.7
      Application Timestamp:	5192a561
      Fault Module Name:	rFactor2 Mod Mode.exe
      Fault Module Version:	1.2.1.7
      Fault Module Timestamp:	5192a561
      Exception Code:	c0000005
      Exception Offset:	003770b5
      OS Version:	6.1.7600.2.0.0.256.1
      Locale ID:	1036
      Additional Information 1:	0a9e
      Additional Information 2:	0a9e372d3b4ad19135b953a78882e789
      Additional Information 3:	0a9e
      Additional Information 4:	0a9e372d3b4ad19135b953a78882e789
    
    any idea anyone ? The call sequence would be great :)
    [for example, i would expect PreReset() to be called before PostReset() which is not the case atm if i'm right]

    I'm building the shared lib with eclipse under win7, using mingw.
     
    Last edited by a moderator: May 24, 2013
  2. B1K3R

    B1K3R Registered

    Joined:
    Apr 6, 2012
    Messages:
    1,605
    Likes Received:
    88
    I have not used V5 but my plugin worked fine with the last build. Try to insert some logging in your dll and see where its crashing.
     
  3. Lazza

    Lazza Registered

    Joined:
    Oct 5, 2010
    Messages:
    12,388
    Likes Received:
    6,602
    I think that's what he's done :)

    I haven't tried building anything recently, assuming you're running rF2 on the same machine/windows you're building on you shouldn't have any dependency issues but I don't know if there are any obscure (or obvious) build settings that won't work. I've only used VS C++ and the plugin template comes with an existing project including build options, so I can't say I've played with many different things to see what does or doesn't work.

    Hopefully someone who's successfully used a more generic compiler can shed some light.
     
  4. B1K3R

    B1K3R Registered

    Joined:
    Apr 6, 2012
    Messages:
    1,605
    Likes Received:
    88
    You're right...but I meant to add more logging, and error catching etc :)

    I've compiled it with VS C++ too and kept most default settings.
     
  5. celkaris

    celkaris Registered

    Joined:
    May 19, 2013
    Messages:
    31
    Likes Received:
    0
    I suspected the pragma pack causing problems with mingw/gcc, but it should be fully supported.

    Regarding the log addition, every single function / method is logged, i can't add log entries to rf2's dynamic loader unfortunately, so i'll have to make various assumptions on the next lib calls.

    for information, here are my current compilation/linking flags :
    Code:
    g++ -DEXAMPLEINTERNALSPLUGIN_EXPORTS -DNDEBUG -DExampleInternalsPlugin_EXPORTS -DWIN32 -D_WINDOWS -D_USRDLL -D_CRT_SECURE_NO_DEPRECATE -D_SECURE_SCL=0 "-ID:\\downloads\\games\\rfactor2\\mymodding\\examplePugin\\examplePlugin/Include" -O3 -Wall -c -fmessage-length=0 -o "Source\\Example.o" "..\\Source\\Example.cpp" 
    g++ -Wl,--subsystem,windows -mwindows -shared -Wl,-soname=ExampleInternalsPlugin -o libExampleInternalsPlugin.dll "Source\\Example.o"
    
    EDIT : i'll switch to VS using the same code, can't afford to mess around with the compiler dll non-interoperability (which would need the use of .def files by rf2?) ; will update this post with results later.
     
    Last edited by a moderator: May 24, 2013
  6. celkaris

    celkaris Registered

    Joined:
    May 19, 2013
    Messages:
    31
    Likes Received:
    0
    Problem solved : installing Visual Studio Express 2012, opening the solution hitting build and voila .. dll is fully working.
     
  7. B1K3R

    B1K3R Registered

    Joined:
    Apr 6, 2012
    Messages:
    1,605
    Likes Received:
    88
    Cool :)
     
  8. celkaris

    celkaris Registered

    Joined:
    May 19, 2013
    Messages:
    31
    Likes Received:
    0
    now i have to figure how to display a custom 'window' within the game with plugin-originated data :) i guess i'll have a look at an existing plugin because i can't find guidelines atm.

    I'll start with something really simple first, we'll see how it goes :)

    EDIT: i think i start to see how custom panels/dialogs are rendered ; looks like you retrieve d3d handlers from ScreenInfoV01 and use them from your plugin, as already created/initialized. Will look further into this
     
    Last edited by a moderator: May 24, 2013
  9. celkaris

    celkaris Registered

    Joined:
    May 19, 2013
    Messages:
    31
    Likes Received:
    0
    ok, i finally found a way to display my custom primitives (using triangle strips) while on track.

    Now i have to investigate why my plugin only renders those primitives while a given in-game status panel is visible (the one where you can change next pitstop fuel addition/tires/...).

    Oh.. for the curious readers, what i am trying to do with my first rF2 plugin is a simple custom display similar to iRacing's session best lap/personal best / sector /... graphic bar :
    * which goes red if your current lap time (realtime) goes worse when compared to selected set,
    * green when getting better,
    * white for nearly equal,
    * and with variable dimension according to current gap,
    * also displaying current gap
    (you know what i'm talking about :p )

    Now i can draw my own primitives on screen with no impact on framerate (i spent quite some time dealing with my dev->Present() call mistake), i'll have to :
    * compute realtime gap between personal session best lap (easiest first) and current lap
    * draw primitives according to that computed gap and trend
    * learn how to display text using that fck*** d3d thing :) and display current gap next to rectangle
    * optionally use a dedicated ini section within custom plugin config file (using path provided within EnvironmentInfoV01.mPath[1]
    * assign a custom control to enable/disable plugin
    * eventually position primitives according to .ini directives when set
     
    Last edited by a moderator: May 25, 2013
  10. celkaris

    celkaris Registered

    Joined:
    May 19, 2013
    Messages:
    31
    Likes Received:
    0
    I'll probably open a new topic when the remaining problem is fixed (bar / primitives not drawn when message panel is active or another status panel than fuel+tires is shown ; probably because they set some specific rendering parameters? alpha?) but this already looks quite interesting :)

    * Text & bar color changes (in realtime) according to current lap gap versus personal session best lap
    * Gap bar width is also adjusted according to gap 'amplitude' (i'll still have to adjust cap value, using last lap gap for example, instead of currently hardcoded 40s limit for max bar width)

    Progressively "fading" gap bar color with gap increasing/decreasing would also be great, will think about it.

    Here are a few screenshots of the current state of my first rfactor plugin :) (green text appears quite ugly on those shots, not sure what settings i had, it looks better ingame)


    1. typical display when no personal best lap is available in current session :

    http://tinypic.com/view.php?pic=2n9wdj5&s=5

    Shows:
    * current lap percentage done
    * current lap duration
    * estimated lap time


    2. display, when current laptime estimation is faster than current session's personal best:

    http://tinypic.com/view.php?pic=edd6u&s=5

    Shows:
    * current lap percentage done
    * current lap duration
    * estimated lap time
    * green gap bar (growing to the left of its origin according to estimated gap)
    * current gap estimation

    3. display, within a 'bad lap' (current lap estimation worse than session's personnal best)

    http://tinypic.com/view.php?pic=dbsgtf&s=5

    Shows:
    * current lap percentage done
    * current lap duration
    * estimated lap time
    * red gap bar (growing to the right of its origin according to estimated gap)
    * current gap estimation
     
  11. DuRiN

    DuRiN Registered

    Joined:
    Oct 12, 2010
    Messages:
    44
    Likes Received:
    14
    nice work for your first plugin mate...keep on the good work!!!!
     
  12. celkaris

    celkaris Registered

    Joined:
    May 19, 2013
    Messages:
    31
    Likes Received:
    0
    thanks, unfortunately i have a major issue with the rendering part (which i use to draw the 'gap bar') and the rendering device ; it looks like the game currently let the device in different states according to the active panels, messing with alpha blending and/or lighting (i guess).

    Not beeing familiar with dx programming i'm not really sure of all the required renderingState(s) my plugin could set to fix the blending/lighting issue.

    Currently, activating anotherpanel that the pit status will make my primitive plain black, the same problem appears when the message center is shown.

    I can probably use something else than DrawPrimitive() to render the bar, but again, not beeing familiar with dx/d3d programming i haven't find the '2d' way yet (like the DrawText() call i use to render text).

    I spent way too much time "fighting" with blending, trying to solve this issue, i'll try a few last things (first thing: move rendering part from RenderScreenAfterOverlays() to RenderScreenBeforeOverlays() and see if it changes anything), then i'm affraid i'll have to disable the bar, and throw this plugin away... :(

    It really looks weird to me that different existing "official" ingame overlays/panels let the engine in different states, i may be wrong though .. we'll see how it goes :)
     
    Last edited by a moderator: May 25, 2013
  13. celkaris

    celkaris Registered

    Joined:
    May 19, 2013
    Messages:
    31
    Likes Received:
    0
    yes! finally got rid of the disappearing bar problem according to the last activated panel :)

    Solved by first storing initial FVF, StreamSource & some textureStageState(s) (D3DTSS_COLOROP, D3DTSS_COLORARG1 and D3DTSS_ALPHAARG1), then restoring them before exiting from RenderScreenAfterOverlays().


    It looks like storing and restoring those parameters have a small impact on framerate (1 or 2 fps on my 7870), but i'll have to experiment to confirm this as i tried it with 10 AI and some varying weather conditions.

    I think i'll now add a second bar based on sector data, so both full lap & sector by sector data is immediately visible.
    Next i'll focus on making the thing look nicer, then will probably add some user-customisation by the use of an optional .ini file.
     
  14. cosimo

    cosimo Registered

    Joined:
    Apr 14, 2013
    Messages:
    827
    Likes Received:
    99
    Old thread, I know, but I'm trying to do something similar (BTW, is this plugin published anywhere?) but the game doesn't call my RenderScreenBeforeOverlays() or RenderScreenAfterOverlays()... What am I doing wrong?

    It is indeed calling InitScreen() and friends but not RenderScreen*() functions.

    Any idea?
     
  15. Gerald Jacobson

    Gerald Jacobson Registered

    Joined:
    Jan 26, 2013
    Messages:
    827
    Likes Received:
    18
    Verify the method signature. There are some error in the exampe.cpp/hpp. And don't forget to set boolean to true. Additionnaly be sure to not run in private session (to limit risk).
     
  16. cosimo

    cosimo Registered

    Joined:
    Apr 14, 2013
    Messages:
    827
    Likes Received:
    99
    Hi Gerald, thanks.

    The method signature for RenderScreen{Before,After}Overlays() is exactly the same.
    As for the boolean, which one you mean? WantsGraphicsUpdates() perhaps?
     
  17. cosimo

    cosimo Registered

    Joined:
    Apr 14, 2013
    Messages:
    827
    Likes Received:
    99
    Nevermind. The problem was some bits of logic in my code. The functions are actually called just fine :)
     

Share This Page