diff --git a/coresdk/src/coresdk/random.cpp b/coresdk/src/coresdk/random.cpp index 8ae17dcf..3334b42d 100644 --- a/coresdk/src/coresdk/random.cpp +++ b/coresdk/src/coresdk/random.cpp @@ -24,7 +24,7 @@ namespace splashkit_lib int rnd(int ubound) { - if (ubound == 0) return 0; + if (ubound <= 0) return 0; if (_do_seed) { @@ -51,6 +51,7 @@ namespace splashkit_lib srand((unsigned)time(0)); } - return min + rand() % (max - min); + int range = abs(max - min) + 1; + return min + (rand() % range); } }