FX and NULL hRecipient in the EventHandler

edited August 2012 in General discussions
Hi Guys,

I'm having a first look at physics and in doing so, I'm mashing the 08_physics.c project into the standalone project.

Took a bit to get everything compiling as it's been a while since I needed to start anything from scratch. But I finally got it running and physics working.

Now the problem; whenever the physics EventHandler runs, the routine tries to add some FX to the sender and recipient objects, the code crashes because both are null:
orxSTATUS orxFASTCALL EventHandler(const orxEVENT *_pstEvent)
  /* Is a new contact? */
  if(_pstEvent->eID == orxPHYSICS_EVENT_CONTACT_ADD)
    orxOBJECT *pstObject1, *pstObject2;

    /* Gets colliding objects */
    pstObject1 = orxOBJECT(_pstEvent->hRecipient);
    pstObject2 = orxOBJECT(_pstEvent->hSender);

    /* Adds bump FX on both objects */
    orxObject_AddFX(pstObject1, "Bump"); //crash
    orxObject_AddFX(pstObject2, "Bump");

  /* Done! */
  return orxSTATUS_SUCCESS;

The physics are working, the boxes are bouncing off each other. Can't understand why the recipient and sender objects are always null.

I realise something I have defined is causing the issue. Rather than flood this post with realms of code and ini, is there a specific section I should provide first?

Of course afterwards, I found Grey's tutorial on mashing these projects and I have been through it but I'd rather know what causes this than start again with the tutorial.


  • edited August 2012

    There are two reasons I can think of that would produce this kind of issue:
    - EventHandler is register to handle other types of events in addition to physics and as the type of event isn't checked, the ID might match another ID for another type of event that doesn't have any payload
    - the include files are not in sync with the libraries you're using, which mean that the type of event might not be the same value inside orx and for you, resulting in the same kind of mismatch mentioned above

    If you have the whole source file it' ll be easier to diagnose if one of these two options is actually what's happening.
  • edited August 2012
    I added type checking a little later and was still getting null objects even though the event type was orxEVENT_TYPE_PHYSICS and the eventype enum orxPHYSICS_EVENT_CONTACT_ADD.

    However, it is very likely the second point where I would say my mashing of files has caused it, and my libs and includes are likely to be mismatched. Think I am best to start over with a clean solution.

    Thank you as usual!
  • edited August 2012
    Thought I'd try one last thing.. and discovered that my orx dlls were the culprit. They were out of sync with the libs and includes. I think I pulled these from a tutorials folder and the libs and includes from the 1.3rc0 zip.

    Pretty dumb I know :cheer: :huh:
  • edited August 2012
    Glad you found the problem! :)

    Also, any reason why you don't use the latest/svn version of orx instead? Things have changed so much the 1.3rc0!
  • edited August 2012
    I know... I'll be going svn from here on.

    It was mainly because I had a spare lunchtime at work and I downloaded the svn version from there. However I have VS2010 Ultimate and there was no pre-built orx.dll or orxd.dll.

    The solutions loaded ok in vs2010 but they're still not configured 100% to compile all the necessary things out of the box.

    So I didn't want to spend my entire lunch just getting the setup working.

    But maybe that's something I can get working and commit back to svn. I feel more comfortable with it these days.
  • edited August 2012
    For the benefit of others wanting to get VS2010 and SVN working in a real hurry, I've fixed Grey's Quick & Dirty SVN tutorial:


    The pictures are since missing (404s) but I re-wrote the missing bits so they don't rely on the images.

    At the end of the tutorial, I've provided an entry point to Grey's Tutorial 1 where Quick and Dirty SVN + VS2010 users should go.
  • edited August 2012
    Ah I see! Thanks for the wiki update, I'm sure it'll help a bunch of people that are not sticking with VS2008 like myself. ;)
Sign In or Register to comment.