You're right. I looked a bit harder in the code and saw that it stores and handles STATES as an integer data type, i.e. int.
Everywhere we see a "long" this is just short for "long int" which is the same as "int".
An "int" is only 32 bits long, and this is sufficient for our 32 states. Because individual states are defined like (1 << 3) which in binary is 1000, or the integer 8, once you define the 32nd state (1 << 31), you get the biggest size flag that you can represent with 32 bit integers. There is no (1 << 32), because that overflows to the (1 << 0)th state, or polymorphed, as you rightly observe.
What we need is for STATES to be represented at "long long", which is 64 bits long, giving us twice the number of available states. N.B. long long is the same as 'long long int".
EDIT:
In ivandef.h we might elect to define STATES as a long long thus:
#define STATES 32LL
a la the examples stated in
https://stackoverflow.com/questions/208433/how-do-i-write-a-...
That won't do it either... STATES is just the number of states. Maybe each state needs to be declared
#define POLYMORPHED (1 << 0)LL
???
BUT, I don't know how far that will solve the problem, because I am not sure whether the rest of the code assumes STATES is long and therefore go bung, OR whether this simple change will be respected by the rest of the code, and it plays nice with STATES as long long.