diff options
author | sfan5 <sfan5@live.de> | 2021-04-05 13:38:31 +0200 |
---|---|---|
committer | rubenwardy <rw@rubenwardy.com> | 2021-10-20 14:25:39 +0100 |
commit | 83e26f839d28c5d9aa75aeab7d924fcaad445007 (patch) | |
tree | ff2617af2c8d2ca1b8742c64a28bd659def66743 /src/client/clientmap.cpp | |
parent | c3f7905d82e5b1201d81378dedde746caf0e2451 (diff) | |
download | minetest-83e26f839d28c5d9aa75aeab7d924fcaad445007.tar.gz minetest-83e26f839d28c5d9aa75aeab7d924fcaad445007.tar.bz2 minetest-83e26f839d28c5d9aa75aeab7d924fcaad445007.zip |
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 b9e0cc2ce..8e02fea63 100644 --- a/src/client/clientmap.cpp +++ b/src/client/clientmap.cpp @@ -496,12 +496,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), @@ -517,7 +517,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); |