From 13e995b811e80dc48c0769274d3dca3a2221b843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Thu, 17 Aug 2017 23:02:50 +0200 Subject: Modernize src/c* src/d* and src/e* files (#6263) * Modernize src/c* src/d* and src/e* files * default operator * redundant init * delete default constructors on CraftDefinition childs (never used) * fix some missing init values * const ref fix reported by clang-tidy * ranged-based for loops * simple conditions & returns * empty stl function instead of size * emplace_back stl function instead of push_back + construct temp obj * auto for some iterators * code style fixes * c++ stl headers instead of C stl headers (stdio.h -> cstdio) --- src/dungeongen.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/dungeongen.cpp') diff --git a/src/dungeongen.cpp b/src/dungeongen.cpp index f8859dcd0..851b1e25f 100644 --- a/src/dungeongen.cpp +++ b/src/dungeongen.cpp @@ -201,7 +201,7 @@ void DungeonGen::makeDungeon(v3s16 start_padding) } } // No place found - if (fits == false) + if (!fits) return; /* @@ -564,7 +564,7 @@ bool DungeonGen::findPlaceForRoomDoor(v3s16 roomsize, v3s16 &result_doorplace, v3s16 doorplace; v3s16 doordir; bool r = findPlaceForDoor(doorplace, doordir); - if (r == false) + if (!r) continue; v3s16 roomplace; // X east, Z north, Y up @@ -596,7 +596,7 @@ bool DungeonGen::findPlaceForRoomDoor(v3s16 roomsize, v3s16 &result_doorplace, break; } } - if (fits == false) { + if (!fits) { // Find new place continue; } @@ -625,12 +625,12 @@ v3s16 rand_ortho_dir(PseudoRandom &random, bool diagonal_dirs) } while ((dir.X == 0 || dir.Z == 0) && trycount < 10); return dir; - } else { - if (random.next() % 2 == 0) - return random.next() % 2 ? v3s16(-1, 0, 0) : v3s16(1, 0, 0); - else - return random.next() % 2 ? v3s16(0, 0, -1) : v3s16(0, 0, 1); } + + if (random.next() % 2 == 0) + return random.next() % 2 ? v3s16(-1, 0, 0) : v3s16(1, 0, 0); + + return random.next() % 2 ? v3s16(0, 0, -1) : v3s16(0, 0, 1); } @@ -673,6 +673,6 @@ int dir_to_facedir(v3s16 d) { if (abs(d.X) > abs(d.Z)) return d.X < 0 ? 3 : 1; - else - return d.Z < 0 ? 2 : 0; + + return d.Z < 0 ? 2 : 0; } -- cgit v1.2.3