Request for adding buffer pointer getter to script array

Started by
2 comments, last by WitchLord 9 years, 1 month ago

I'd like to request the addition of a getter on the standard CScriptArray that returns a pointer to the buffer.

In our code we sometimes have to return data in script arrays, but the function that fills it uses a plain C array.

Allocating a temporary array is a waste of memory, so being able to directly fill the script array would be a big plus.

The array always has handles in it, so it will only fill it with pointers; no actual data would be copied into it.

This is a method that requires the use of such a getter. Our copy of the add on already has this change, but it would be easier if it were present by default:


int	CASEntityFuncs::MonstersInSphere( CScriptArray* pArray, const Vector& vecCenter, float flRadius )
{
	asIScriptEngine* pEngine = gASManager()->GetScriptEngine();

	if( gASManager()->GetObjectTypeByName( "Entity" ) != pEngine->GetObjectTypeById( pArray->GetElementTypeId() ) )
	{
		ANGELSCRIPT_ALERT( at_error, "CEntityFuncs::MonstersInSphere: array element type must be \"Entity\"!\n" );
		return 0;
	}

	return UTIL_MonstersInSphere( reinterpret_cast<CBaseEntity**>( pArray->GetBuffer() ), static_cast<int>( pArray->GetSize() ), vecCenter, flRadius );
}
Advertisement

I think that can be managed :)

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

hi,

i also would love to see a getter for the scripthandle addon, so that i can access the internal pointer and can do stuff with it.

thanks in advance

I've added these in revision 2144.

Regards,

Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement