Jibble

Author Topic: Dynamic array within (unmanaged) struct  (Read 105 times)

Dynamic array within (unmanaged) struct
« on: 21 Jan 2019, 01:27 »
Hi -

Can regular structs contain dynamic arrays?

I'm trying to make an array of integers inside of each room, with the size of the array proportional to the size of the room. I've tried declaring a struct containing a dynamic array int rsize[], but when I try to initialize the struct the game crashes.

In the manual it states explicitly that managed structs can't contain dynamic arrays, but the documentation on regular structs is a little more vague. I see older technical threads saying that dynamic arrays don't work in regular structs, but I just want to be sure that I'm not missing anything in the newer versions of AGS.

Thanks as always.

Re: Dynamic array within (unmanaged) struct
« Reply #1 on: 21 Jan 2019, 07:02 »
Yes, regular structs can contain dynamic arrays, since AGS 3.4.0.

Quote
the size of the array proportional to the size of the room. I've tried declaring a struct containing a dynamic array int rsize[], but when I try to initialize the struct the game crashes.

Please, when it comes to crashes, always give actual error message and post your script if possible.