Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: wynni2 on Mon 21/01/2019 01:27:01

Title: Dynamic array within (unmanaged) struct
Post by: wynni2 on Mon 21/01/2019 01:27:01
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.
Title: Re: Dynamic array within (unmanaged) struct
Post by: Crimson Wizard on Mon 21/01/2019 07:02:05
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.