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 );
}