Fox, on 06 February 2014 - 11:22 AM, said:
For the sake of saving some memory, shouldn't the game not compile gamevars (not pre-defined) if they aren't used in the CON? Of course all unused gamevars should be removed from CONs as of now, but this optimization wouldn't hurt.
Good idea with finding these. Starting with
r4299, LunaCON adds two new
warnings, -Wnever-used-gamevar and -Wnever-read-gamevar. They are
not enabled by default: many CON mods in the wild contain a spamgenic amount of these gamevars. Also, they are not automatically removed from the code: memory-wise, what matters most are per-actor gamevars in C-CON. In LunaCON, they're implemented in a
sparse fashion, meaning that they only use an amount of memory roughy proportional to the number of non-default values stored in it.
Fox, on 06 February 2014 - 12:35 PM, said:
I had like to have a new command to define gamevars that can specify the size. It's common to use a gamevar for a simply yes or no check, and 32-bits is a waste...
For the occasional global gamevar, you shouldn't feel bad using a 32-bit int even if it's only used in a boolean sense; the memory "waste" is negligibe. Again, if you want an
array of booleans, using a CON gamearray (or per-something gamevar) is suboptimal. However, there's a simple trick: just consolidate up to 32 variables into one by using bit-wise operations. Like this:
gamevar tmp 0 0
gamevar actorprop 0 2 // various per-actor boolean properties
define APROP_ISAPIG 1
define APROP_CANFLY 2
define APROP_VERYDANGEROUS 4
useractor PIGCOP // ...
getactorvar[THISACTOR].actorprop tmp
orvar tmp APROP_ISAPIG
ifvare sprite[THISACTOR].pal 21
orvar tmp APROP_CANFLY
setactorvar[THISACTOR].actorprop tmp
enda
(Untested, but you get the idea...)