diff options
-rw-r--r-- | npc/functions/bitwise.txt | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/npc/functions/bitwise.txt b/npc/functions/bitwise.txt index 023606629..eadfb30ce 100644 --- a/npc/functions/bitwise.txt +++ b/npc/functions/bitwise.txt @@ -56,6 +56,10 @@ function script bitmask_count { // Loop only as needed while (.@s < .@n) { + // Safeguard (2,147,483,647 is INT_MAX) + if (.@m >= 31) + break; + // Actual calculation .@s=2**.@m; if (.@n & .@s) .@p++; |