#171397 - headspin - Wed Nov 18, 2009 11:14 am
In my game I have a basic event system that turns bits on to trigger certain events. I use an enum to specify which event is which bit.
And I have a global 32 bit uint to store all these flags
And to check if a certain event has occured I do
Which just checks if the bits that are set match those needed to trigger the event.
Now I've realised I need to expand this beyond the 32 bits and it's too late for me to come up with a different method of doing things. What is the easiest way to expand this to be 64 bits? I tried using a uint64 instead and get an error in the enum
Then I tried changing the enum to uint64
Then I get the error
So then I added -std=c++0x to the compiler options and then get
And still get the "left shift count >= width of type" error. Will I need to split the flags into two 32-bit integers or perhaps a union? Any ideas on how to expand this without re-writing large chunks of the event system?
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game
Code: |
enum EventFlag
{ EVENTFLAG_NONE = 0, EVENTFLAG_EVENT1 = BIT(0), EVENTFLAG_EVENT2 = BIT(1), ... EVENTFLAG_EVENT30 = BIT(29), EVENTFLAG_EVENT31 = BIT(30), EVENTFLAG_EVENT32 = BIT(31) }; |
And I have a global 32 bit uint to store all these flags
Code: |
uint m_eventFlags; |
And to check if a certain event has occured I do
Code: |
if ((eventFlags & m_eventFlags) == eventFlags) |
Which just checks if the bits that are set match those needed to trigger the event.
Now I've realised I need to expand this beyond the 32 bits and it's too late for me to come up with a different method of doing things. What is the easiest way to expand this to be 64 bits? I tried using a uint64 instead and get an error in the enum
Code: |
warning: left shift count >= width of type |
Then I tried changing the enum to uint64
Code: |
enum EventFlag : uint64 |
Then I get the error
Code: |
warning: scoped enums only available with -std=c++0x or -std=gnu++0x |
So then I added -std=c++0x to the compiler options and then get
Code: |
error: enumerator value -0x00000000080000000 is too large for underlying type 'uint64' |
And still get the "left shift count >= width of type" error. Will I need to split the flags into two 32-bit integers or perhaps a union? Any ideas on how to expand this without re-writing large chunks of the event system?
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game