Discuss and collaborate on GML scripts

You are not logged in.

#1 2011-03-25 03:14:01

Registered: 2007-08-18
Posts: 1,239

Further horrors of "Treat uninitialized variables as value 0"

Lucb1e pointed out a bug in my md5 script related to this blight of a feature. For speed, the script uses some precomputed tables. The first time it is called it checks for the existence of the tables and creates them as global arrays if they do not yet exist. The problem is when "Treat uninitialized variables as value 0" is set, the variable_global_exists() function always returns true. Because of this, the first time the script is called it thinks the tables have been created and proceeds to use tables filled with zeros to arrive at the wrong result. The workaround is to first check for the existence of an initialization flag, and then confirm that it is set to a non-zero or string value.

There are a few scripts posted here that will fail similarly.

Abusing forum power since 1986.


Board footer

Powered by FluxBB