Handles for C structs

Posted By: TehV

Handles for C structs - 11/30/13 13:19

Hi,
I have a program that makes use of custom C structs. It requires that every entity has two instances of these structs assigned to it at any given time. I create instances of these structs at runtime using malloc() (it is required I do this). Ideally, I would like to store handles to these instances in the entitys skills.

I've read in the documentation that handle() and ptr_for_handle() only works for engine objects, and that I should use pVars for everything else.

On the page for pVars it says that pVars has no meaning for objects created through malloc().

My question is, how can I store instances of my custom structs in entity skills? Is it possible at all?
Posted By: Arrovs

Re: Handles for C structs - 11/30/13 13:53

just say ent.skill[0] = (var)mystruct;
and it vill store pointer in it;

Mystruct* mystruct = (Mystruct*)ent.skill[0];

Posted By: TehV

Re: Handles for C structs - 12/02/13 17:03

Oh, great! Thanks!
© 2024 lite-C Forums