summaryrefslogtreecommitdiff
path: root/src/util/numeric.h
diff options
context:
space:
mode:
authorproller <proller@github.com>2013-07-27 22:34:30 +0400
committerproller <proller@github.com>2013-07-27 23:21:48 +0400
commit3aedfac9685c2d9ae8bac5a5b7e72e527f22c08d (patch)
treed1f9067040acb0b5dad42a2ae8935b91124a36d3 /src/util/numeric.h
parente65d8ad6553d7ae0acf63b43e9818059088a00b6 (diff)
downloadminetest-3aedfac9685c2d9ae8bac5a5b7e72e527f22c08d.tar.gz
minetest-3aedfac9685c2d9ae8bac5a5b7e72e527f22c08d.tar.bz2
minetest-3aedfac9685c2d9ae8bac5a5b7e72e527f22c08d.zip
Weather support
Diffstat (limited to 'src/util/numeric.h')
-rw-r--r--src/util/numeric.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/util/numeric.h b/src/util/numeric.h
index 3e82997bd..076a08efc 100644
--- a/src/util/numeric.h
+++ b/src/util/numeric.h
@@ -349,5 +349,12 @@ inline void paging(u32 length, u32 page, u32 pagecount, u32 &minindex, u32 &maxi
}
}
+inline float cycle_shift(float value, float by = 0, float max = 1)
+{
+ if (value + by < 0) return max + by + value;
+ if (value + by > max) return value + by - max;
+ return value + by;
+}
+
#endif