summaryrefslogtreecommitdiffstats
path: root/src/Globals.h
diff options
context:
space:
mode:
authorarchshift <admin@archshift.com>2014-09-04 01:12:43 +0200
committerarchshift <admin@archshift.com>2014-09-04 01:12:43 +0200
commit472efa8174626a00ffdf5b39e1a44ac419cd3698 (patch)
treebd4a6bf77cf92aaa2529ead260cda91455e9ad09 /src/Globals.h
parentChunkGenerator: Log world seed when creating a new one. (diff)
downloadcuberite-472efa8174626a00ffdf5b39e1a44ac419cd3698.tar
cuberite-472efa8174626a00ffdf5b39e1a44ac419cd3698.tar.gz
cuberite-472efa8174626a00ffdf5b39e1a44ac419cd3698.tar.bz2
cuberite-472efa8174626a00ffdf5b39e1a44ac419cd3698.tar.lz
cuberite-472efa8174626a00ffdf5b39e1a44ac419cd3698.tar.xz
cuberite-472efa8174626a00ffdf5b39e1a44ac419cd3698.tar.zst
cuberite-472efa8174626a00ffdf5b39e1a44ac419cd3698.zip
Diffstat (limited to 'src/Globals.h')
-rw-r--r--src/Globals.h40
1 files changed, 36 insertions, 4 deletions
diff --git a/src/Globals.h b/src/Globals.h
index de1024010..a782de325 100644
--- a/src/Globals.h
+++ b/src/Globals.h
@@ -217,10 +217,10 @@ template class SizeChecker<UInt16, 2>;
// CRT stuff:
#include <sys/stat.h>
-#include <assert.h>
-#include <stdio.h>
-#include <math.h>
-#include <stdarg.h>
+#include <cassert>
+#include <cstdio>
+#include <cmath>
+#include <cstdarg>
@@ -370,6 +370,38 @@ T Clamp(T a_Value, T a_Min, T a_Max)
+/** Floors a_Value, then casts it to C (an int by default) */
+template <typename C = int>
+C FloorD(double a_Value)
+{
+ return static_cast<C>(std::floor(a_Value));
+}
+
+/** Floors a_Value, then casts it to C (an int by default) */
+template <typename C = int>
+C FloorF(double a_Value)
+{
+ return static_cast<C>(std::floorf(a_Value));
+}
+
+/** Ciels a_Value, then casts it to C (an int by default) */
+template <typename C = int>
+C CeilD(double a_Value)
+{
+ return static_cast<C>(std::ceil(a_Value));
+}
+
+/** Ciels a_Value, then casts it to C (an int by default) */
+template <typename C = int>
+C CeilF(double a_Value)
+{
+ return static_cast<C>(std::ceilf(a_Value));
+}
+
+
+
+
+
#ifndef TOLUA_TEMPLATE_BIND
#define TOLUA_TEMPLATE_BIND(x)
#endif