diff options
author | SmallJoker <mk939@ymail.com> | 2015-04-29 19:28:25 +0200 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2015-05-01 07:34:51 +0200 |
commit | 6626a3f72f66703a161abccab90cffcec31c3932 (patch) | |
tree | 80838a69a411c1bff1462b7ed07be007236a4e5b /src | |
parent | 37ca3212eee6d70a54493168014f9254cc6e8f37 (diff) | |
download | minetest-6626a3f72f66703a161abccab90cffcec31c3932.tar.gz minetest-6626a3f72f66703a161abccab90cffcec31c3932.tar.bz2 minetest-6626a3f72f66703a161abccab90cffcec31c3932.zip |
Fix several MSVC issues numeric.h
-> Round negative numbers correctly CMakeLists.txt
-> Link Json with the static run-time library
Diffstat (limited to 'src')
-rw-r--r-- | src/json/CMakeLists.txt | 5 | ||||
-rw-r--r-- | src/unittest/test_utilities.cpp | 11 | ||||
-rw-r--r-- | src/util/numeric.h | 2 |
3 files changed, 16 insertions, 2 deletions
diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt index 206c6ea9c..de99c7f0c 100644 --- a/src/json/CMakeLists.txt +++ b/src/json/CMakeLists.txt @@ -1,4 +1,7 @@ -add_library(jsoncpp jsoncpp.cpp) +if(MSVC) + set(CMAKE_CXX_FLAGS_RELEASE "/MT") +endif() +add_library(jsoncpp jsoncpp.cpp) target_link_libraries(jsoncpp) diff --git a/src/unittest/test_utilities.cpp b/src/unittest/test_utilities.cpp index caf4515c8..07108706a 100644 --- a/src/unittest/test_utilities.cpp +++ b/src/unittest/test_utilities.cpp @@ -45,6 +45,7 @@ public: void testWrapRows(); void testIsNumber(); void testIsPowerOfTwo(); + void testMyround(); }; static TestUtilities g_test_instance; @@ -67,6 +68,7 @@ void TestUtilities::runTests(IGameDef *gamedef) TEST(testWrapRows); TEST(testIsNumber); TEST(testIsPowerOfTwo); + TEST(testMyround); } //////////////////////////////////////////////////////////////////////////////// @@ -239,3 +241,12 @@ void TestUtilities::testIsPowerOfTwo() } UASSERT(is_power_of_two((u32)-1) == false); } + +void TestUtilities::testMyround() +{ + UASSERT(myround(4.6f) == 5); + UASSERT(myround(1.2f) == 1); + UASSERT(myround(-3.1f) == -3); + UASSERT(myround(-6.5f) == -7); +} + diff --git a/src/util/numeric.h b/src/util/numeric.h index b4b841918..0eba01359 100644 --- a/src/util/numeric.h +++ b/src/util/numeric.h @@ -288,7 +288,7 @@ bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir, */ inline s32 myround(f32 f) { - return floor(f + 0.5); + return (s32)(f < 0.f ? (f - 0.5f) : (f + 0.5f)); } /* |