OpenB3D - GetChild

BlitzMax Forums/MiniB3D Module/OpenB3D - GetChild

bruZard(Posted 2016) [#1]
Hi Guys. GetChild and FindChild doesn't work for me. These functions always returns Null, although CountChildren gives me the right count of childrens. In Blitz3D all working fine, but in OpenB3D it will not. Is there a special trick?

p.s.: excuse my poor english ;)


RustyKristi(Posted 2016) [#2]
This can be expected on both OpenB3D and MiniB3D as they are not perfect implementation of B3D. BTW, have you tried with mini?

Luckily I have not used these buggy functions on my experiments.


BlitzSupport(Posted 2016) [#3]
Can you guys confirm if this fails only on 32-bit, but works on 64-bit? That's what happens for me, using the code below.

Spent hours today trying to figure this out, and when I finally checked, I was using a 32-bit build. The name gets set correctly, as tested by simple cout debugging of the relevant C++ side, but the result once returned and interpreted with String.FromCString is corrupted; however, I finally tried on a 64-bit build and it works! Not sure if that is down to the OpenB3D implementation or something to do with bmx-ng...



I'm thinking it's something to do with 32- versus 64-bit pointers, but I would assume the const char* result returned behind the scenes should work on both...

Same thing happens with EntityClass.


BlitzSupport(Posted 2016) [#4]
Think I have a fix for this... in mod\openb3d.mod\openb3dex.mod\inc\TEntity.bmx, replace the commented-out lines as below:

	Method EntityClass:String()
	
		'Return String.FromCString( EntityClass_( GetInstance(Self) ) )
		Return String.FromCString (EntityString_ (GetInstance(Self),ENTITY_class_name))
		
	End Method
	
	Method EntityName:String()

		'Return String.FromCString( EntityName_( GetInstance(Self) ) )
		Return String.FromCString (EntityString_ (GetInstance(Self),ENTITY_name))
		
	End Method


Before this change, EntityName/Class on x86, using the sample in the previous post, gave corrupt string results (FindChild depends on EntityName), while x64 was fine. With this change, the sample works on both for me.