I'm trying to play with orx and to do so I started with Gray's tutorial.
In tut number 3 a new function is introduced: GetObjectByName.
It searches for an orxOBJECT with the given name into the current structure.
It does not work.
I've done some debugging to better understand and here's what I've found.
I'm using svn version recompiled with VS2010 Embedded dynamic debug and release.
We're talking about the debug version.
The GetObjectByName function uses orxStructure_GetFirst accessor function to get the element in the structure.
Elements should have orxSTRUCTURE_ID_OBJECT type.
I debugged the orxStructure_GetFirst function and I saw that at the end, when we do pstStructure = pstNode->pstStructure, the value of pstStructure->eID is 0xdefacede.
After that, the _orxStructure_GetPointer is called and it checks if the structure eID matches the wanted one that, in this case, is orxSTRUCTURE_ID_OBJECT (it shoudl be 14 in dec.)
Obviously it does not match.
So I searched where the 0xdefacede value is assigned. That's the value of orxSTRUCTURE_MAGIC_TAG_ACTIVE when we use the DEBUG version of the orx library.
After re-running the debugger I saw that the value is used when creating the strucutre of an object...so we're talking of function orxStructure_Create().
I see it's called from orxObject_Create() function with param orxSTRUCTURE_ID_OBJECT.
In line 435 of orxStructure.c we have:
/* Stores ID with magic number */
pstStructure->eID = (orxSTRUCTURE_ID)(_eStructureID ^ orxSTRUCTURE_MAGIC_TAG_ACTIVE);
_eStructureID equals to orxSTRUCTURE_ID_OBJECT.
orxSTRUCTURE_MAGIC_TAG_ACTIVE should equal to 0xdefacede but the resulting pstStructure->eID is 0xdefacede.
It seems that sometimes orxSTRUCTURE_MAGIC_TAG_ACTIVE is 0x0 and sometimes is 0xdefacede.
It's seems that there's some module compiled in RELEASE and some module compiled in DEBUG mode.
That's weird but explains why orxStructure_GetFirst can't find valid objects.