From 6b9ffdbe2aff0761c5455b81202ef225c4094f7f Mon Sep 17 00:00:00 2001 From: CobaltXII Date: Sat, 29 Dec 2018 15:23:37 -0500 Subject: [PATCH] Implemented inline void set_artificial_safe --- src/inc/world.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/inc/world.hpp b/src/inc/world.hpp index 6af7068..94c8d7d 100644 --- a/src/inc/world.hpp +++ b/src/inc/world.hpp @@ -144,4 +144,16 @@ struct world voxel_set_artificial(voxels[x + x_res * (y + y_res * z)], artificial); } + // Set the artificial lighting information of the voxel at the specified + // coordinates, if the coordinates are within the bounds of the world. + + inline void set_artificial_safe(unsigned int x, unsigned int y, unsigned int z, unsigned char artificial) + { + if (x < 0 || y < 0 || z < 0 || x > x_res - 1 || y > y_res - 1 || z > z_res - 1) + { + return; + } + + voxel_set_artificial(voxels[x + x_res * (y + y_res * z)], artificial); + } }; \ No newline at end of file