Sign in to follow this  

Question: Debugging script array

Recommended Posts

virious    182
I'm trying to inspect items which are stored in a script array. For example, I have "[b]array<Location@> locations[/b]". I know it's type and subtype by using [b]GetObjectTypeById()[/b] and next [b]GetSubType()[/b]. How can I get pointer to the original native CScriptArray object, so I can iterate through the items it contains?

The problem is that [b]m_context->GetAddressOfVar()[/b] returns null in this case, so that's why I'm trying to figure out some other way of obtaining that pointer.

Thanks in advance!

Share this post

Link to post
Share on other sites
WitchLord    4677
GetAddressOfVar() should work on script arrays the same way it does for other types.

If the variable has been declared with 'array<Location@> locations', then m_context->GetAddressOfVar() should return a pointer to the actual CScriptArray object, you just need to cast it. If on the other hand the variable is declared as a handle, then GetAddressOfVar() will return a pointer to the handle to the CScriptArray, and you'll need to dereference the pointer before accessing the CScriptArray object.

That GetAddressOfVar() is returning a null pointer is probably because the variable index, or the stack level argument is wrong. Another possibility is that you're trying to inspect the array before it has actually been instanciating, in which case the function also returns null. You can call IsVarInScope() to determine if the array has already been instanciated or not.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this