From d80c2e01b97e5dcc4cef5f91252e953473f38e22 Mon Sep 17 00:00:00 2001 From: CobaltXII Date: Sat, 29 Dec 2018 15:17:42 -0500 Subject: [PATCH] Implemented inline unsigned char get_artificial_safe --- src/inc/world.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/inc/world.hpp b/src/inc/world.hpp index 0b319b7..847eefd 100644 --- a/src/inc/world.hpp +++ b/src/inc/world.hpp @@ -81,4 +81,17 @@ struct world return voxel_get_artificial(voxels[x + x_res * (y + y_res * z)]); } + // Get the artificial lighting information of the voxel at the specified + // coordinates, if the coordinates are within the bounds of the world. If + // not, return 0. + + inline unsigned char get_artificial_safe(unsigned int x, unsigned int y, unsigned int z) + { + if (x < 0 || y < 0 || z < 0 || x > x_res - 1 || y > y_res - 1 || z > z_res - 1) + { + return 0; + } + + return voxel_get_artificial(voxels[x + x_res * (y + y_res * z)]); + } }; \ No newline at end of file