diff options
author | sfan5 <sfan5@live.de> | 2021-04-05 13:38:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-05 13:38:31 +0200 |
commit | f0bad0e2badbb7d4777aac7de1b50239bca4010a (patch) | |
tree | 4c3115a42ac86e9a64d9e5f088fe187022885779 /src/client/clientmap.cpp | |
parent | 3e1904fa8c4aae3448d58b7e60545a4fdd8234f3 (diff) | |
download | dragonfireclient-f0bad0e2badbb7d4777aac7de1b50239bca4010a.tar.xz |
Reserve vectors before pushing and other code quality changes (#11161)
Diffstat (limited to 'src/client/clientmap.cpp')
-rw-r--r-- | src/client/clientmap.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/client/clientmap.cpp b/src/client/clientmap.cpp index be8343009..c5b47532c 100644 --- a/src/client/clientmap.cpp +++ b/src/client/clientmap.cpp @@ -499,12 +499,12 @@ int ClientMap::getBackgroundBrightness(float max_d, u32 daylight_factor, static v3f z_directions[50] = { v3f(-100, 0, 0) }; - static f32 z_offsets[sizeof(z_directions)/sizeof(*z_directions)] = { + static f32 z_offsets[50] = { -1000, }; - if(z_directions[0].X < -99){ - for(u32 i=0; i<sizeof(z_directions)/sizeof(*z_directions); i++){ + if (z_directions[0].X < -99) { + for (u32 i = 0; i < ARRLEN(z_directions); i++) { // Assumes FOV of 72 and 16/9 aspect ratio z_directions[i] = v3f( 0.02 * myrand_range(-100, 100), @@ -520,7 +520,8 @@ int ClientMap::getBackgroundBrightness(float max_d, u32 daylight_factor, if(sunlight_min_d > 35*BS) sunlight_min_d = 35*BS; std::vector<int> values; - for(u32 i=0; i<sizeof(z_directions)/sizeof(*z_directions); i++){ + values.reserve(ARRLEN(z_directions)); + for (u32 i = 0; i < ARRLEN(z_directions); i++) { v3f z_dir = z_directions[i]; core::CMatrix4<f32> a; a.buildRotateFromTo(v3f(0,1,0), z_dir); |