diff options
Diffstat (limited to 'src/mapnode.cpp')
-rw-r--r-- | src/mapnode.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/mapnode.cpp b/src/mapnode.cpp index 786224240..fbf0ac8c9 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "serialization.h" // For ser_ver_supported #include "util/serialize.h" #include "log.h" +#include "util/numeric.h" #include <string> #include <sstream> @@ -77,19 +78,14 @@ u8 MapNode::getLight(enum LightBank bank, INodeDefManager *nodemgr) const { // Select the brightest of [light source, propagated light] const ContentFeatures &f = nodemgr->get(*this); - u8 light = 0; + + u8 light; if(f.param_type == CPT_LIGHT) - { - if(bank == LIGHTBANK_DAY) - light = param1 & 0x0f; - else if(bank == LIGHTBANK_NIGHT) - light = (param1>>4)&0x0f; - else - assert(0); - } - if(f.light_source > light) - light = f.light_source; - return light; + light = bank == LIGHTBANK_DAY ? param1 & 0x0f : (param1 >> 4) & 0x0f; + else + light = 0; + + return MYMAX(f.light_source, light); } bool MapNode::getLightBanks(u8 &lightday, u8 &lightnight, INodeDefManager *nodemgr) const |