We have literally thousands of variables in DB. They are in all different formats too, a whole lot of them are integers which is where we get most of our overflows.
While it is pretty satraight forward to check that numbers aren't too big for th evariable type, the problem lies in the shear number of if-then statements needed to achieve this. Every time a variable is modified (possibly 100s of times per cycle), a check must be done and checks take a finite amount of time.
In order to speed up the program we try to centralize these checks to one or two places but sometimes this doesn't cut it, particularly when a bit of code gets modified in such a way that it effects a variable that on the face of it shouldn't be effected, and pushes it over the limit in another place entirely.
For example, changing the range of a shot in one routine can make a poison shot in another part of the program come back with a value of 33000 or something equally bizarre.
The whole thing is just hyper complicated.
I still thinnk the best thing to do would be to make every variable either a double or a long.
DB was originally written with the mindset that shorter 16 bit variable would be faster but on modern 32 bit windows environments, I am pretty sure that 32 bit variables are actually just as fast if not a little faster.
Besides this we could then remove all those checks and that would speed up the program too.