Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: GarageGothic on Tue 19/07/2005 12:21:30

Title: Is there a quick way to zero a struct/array
Post by: GarageGothic on Tue 19/07/2005 12:21:30
Is there any quick way to clear out all values in a struct? Or do I have to do a

while (num <= maxnum) {
mystruct[num].array = 0;
num++:
}


on all values?

I'm not even sure, does it save memory if you reset the values to zero? I use a large amount of structs and arrays, and frankly I'm a bit worried about all the trash being stored in memory and in savegames.
Title: Re: Is there a quick way to zero a struct/array
Post by: Gilbert on Tue 19/07/2005 12:53:27
Right, just use loops, there's no quick way as far as I know.
Quote from: GarageGothic on Tue 19/07/2005 12:21:30
I'm not even sure, does it save memory if you reset the values to zero?
No it doesn't matter, so organize your game's variables wisely. Unless it's something like Dynamic sprites or variables local to functions that can be destroyed.
Title: Re: Is there a quick way to zero a struct/array
Post by: GarageGothic on Tue 19/07/2005 13:07:08
Ok thanks. Could the solution may be to use a room above 300 then so it wouldn't be state saved? And then use a global ints/struct for the few settings that are used later.
Title: Re: Is there a quick way to zero a struct/array
Post by: Pod on Tue 19/07/2005 21:36:02
can you "release" variables?
Title: Re: Is there a quick way to zero a struct/array
Post by: Gilbert on Wed 20/07/2005 02:00:13
Quote from: GarageGothic on Tue 19/07/2005 13:07:08
Ok thanks. Could the solution may be to use a room above 300 then so it wouldn't be state saved? And then use a global ints/struct for the few settings that are used later.
Yes, this can be an idea.
Quote from: Pod on Tue 19/07/2005 21:36:02
can you "release" variables?
No, unless the vraiables are defined within functions, variables defined outside of functions cannot be "removed" ingame.