r/Scrolls • u/TheSunbroo TheSunbro • Jan 15 '15
TIL If you increase countdown by more than 2147483647 it gets 0
So i played a little bit around by increasing countdown. After 1349336032 i played another thought trap and it went to 0. So it is because the countdown seems to be of the type int.
18
Upvotes
14
u/squiddybiscuit @Squiddylicious Jan 15 '15
Aging Knight just got a buff.
6
u/Raytional Jan 15 '15
2,147,483,647 is the max size of an int variable in java (and possibly other languages?). So that's why that is the max size of countdown.
2
u/fdagpigj Jan 16 '15
I thought this was common knowledge :P
1
u/TehLittleOne darksteel Jan 16 '15
It always bugs me that games don't gracefully handle overflow of stats. It's not a particularly difficult thing for games to deal with nor do I think it's unreasonable for developers to expect people to try this. Maybe it's somewhat unreasonable to expect in a real game but I know Hearthstone ended up making some cards that makes it quite reasonable to happen.
We all know the cause is simple integer overflow. ~2.1 billion or 232 is the biggest possible number that can be stored, and when it gets passed the programming language causes it to go to 0 as a result. This is expected behaviour for the language but unexpected behaviour for the game.
It's fairly easy for them to fix, or at least I hope it would be. I suppose it depends on how they've defined their engine to work. If stat increases are always handled explicitly, it becomes easy to do a quick check whether it overflows and simply prevent it. If stat increases occur silently however, it becomes very difficult to fix because they have to run this check any time a stat change happens, and it could happen hundreds of time in the code. I'm a fan of the former, that is, to handle each stat increase as a separate event, which would make fixing this bug trivial.