From 885e4f411b0909beddff5687ac85b828c4f45468 Mon Sep 17 00:00:00 2001 From: Sulca2099 Date: Wed, 4 Mar 2026 12:47:00 -0800 Subject: [PATCH] Refactor darken function to use pointer parameter Fix darken() dependencies. --- engine/render_lighting.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/engine/render_lighting.cpp b/engine/render_lighting.cpp index 2dfe876..487f9bc 100644 --- a/engine/render_lighting.cpp +++ b/engine/render_lighting.cpp @@ -47,33 +47,33 @@ int32_t process_lighting(const struct light &light, vertex_32 &vertex, color_t & } -color_t darken(color_t &color) { +color_t darken(color_t* color) { - uint8_t r = color & 0x000F; - uint8_t b = (color >> 8) & 0x000F; - uint8_t g = (color >> 12) & 0x000F; + uint8_t r = *color & 0x000F; + uint8_t b = (*color >> 8) & 0x000F; + uint8_t g = (*color >> 12) & 0x000F; //reduce colors r -= light_falloff; b -= light_falloff; g -= light_falloff; - if (r > 15) + if (r > 15){ r = 0; - - if (b > 15) + }; + if (b > 15){ b = 0; - - if (g > 15) + }; + if (g > 15){ g = 0; + }; + *color = g; + *color <<= 4; + *color |= b; + *color <<= 8; + *color |= r; - color = g; - color <<= 4; - color |= b; - color <<= 8; - color |= r; - - return color; + } void vertex_lighting(struct vertex_32 &in, color_t &color, int16_t chunk_x, int16_t chunk_y) { @@ -115,7 +115,7 @@ void vertex_lighting(struct vertex_32 &in, color_t &color, int16_t chunk_x, int1 } //we have to assume the vertex has not found a close enough light source by now, so darken it - color = darken(color); + darken(&color); return; @@ -166,4 +166,4 @@ void render_lighting(struct triangle_32 &in) { in.shader_id = 2; } -} \ No newline at end of file +}