diff --git a/code/__DEFINES/subsystems.dm b/code/__DEFINES/subsystems.dm index aa942b9d13e..df95c8d4eaa 100644 --- a/code/__DEFINES/subsystems.dm +++ b/code/__DEFINES/subsystems.dm @@ -260,6 +260,7 @@ * * callback the callback to call on timer finish * * wait deciseconds to run the timer for * * flags flags for this timer, see: code\__DEFINES\subsystems.dm + * * timer_subsystem the subsystem to insert this timer into */ #define addtimer(args...) _addtimer(args, file = __FILE__, line = __LINE__) diff --git a/code/_compile_options.dm b/code/_compile_options.dm index 94d17a40bcb..a4ccce442ca 100644 --- a/code/_compile_options.dm +++ b/code/_compile_options.dm @@ -35,6 +35,11 @@ */ //#define REAGENTS_TESTING +// Displays static object lighting updates +// Also enables some debug vars on sslighting that can be used to modify +// How extensively we prune lighting corners to update +#define VISUALIZE_LIGHT_UPDATES + #define VISUALIZE_ACTIVE_TURFS //Highlights atmos active turfs in green #define TRACK_MAX_SHARE //Allows max share tracking, for use in the atmos debugging ui #endif //ifdef TESTING diff --git a/code/controllers/subsystem/lighting.dm b/code/controllers/subsystem/lighting.dm index 29999a8ff46..378a849dfa1 100644 --- a/code/controllers/subsystem/lighting.dm +++ b/code/controllers/subsystem/lighting.dm @@ -6,6 +6,10 @@ SUBSYSTEM_DEF(lighting) var/static/list/sources_queue = list() // List of lighting sources queued for update. var/static/list/corners_queue = list() // List of lighting corners queued for update. var/static/list/objects_queue = list() // List of lighting objects queued for update. +#ifdef VISUALIZE_LIGHT_UPDATES + var/allow_duped_values = FALSE + var/allow_duped_corners = FALSE +#endif /datum/controller/subsystem/lighting/stat_entry(msg) msg = "L:[length(sources_queue)]|C:[length(corners_queue)]|O:[length(objects_queue)]" diff --git a/code/controllers/subsystem/timer.dm b/code/controllers/subsystem/timer.dm index 791677903ab..704e7fb19e0 100644 --- a/code/controllers/subsystem/timer.dm +++ b/code/controllers/subsystem/timer.dm @@ -565,6 +565,7 @@ SUBSYSTEM_DEF(timer) * * callback the callback to call on timer finish * * wait deciseconds to run the timer for * * flags flags for this timer, see: code\__DEFINES\subsystems.dm + * * timer_subsystem the subsystem to insert this timer into */ /proc/_addtimer(datum/callback/callback, wait = 0, flags = 0, datum/controller/subsystem/timer/timer_subsystem, file, line) if (!callback) diff --git a/code/modules/lighting/lighting_corner.dm b/code/modules/lighting/lighting_corner.dm index 19285ae9888..572cd8b50d7 100644 --- a/code/modules/lighting/lighting_corner.dm +++ b/code/modules/lighting/lighting_corner.dm @@ -88,8 +88,14 @@ // God that was a mess, now to do the rest of the corner code! Hooray! /datum/lighting_corner/proc/update_lumcount(delta_r, delta_g, delta_b) + +#ifdef VISUALIZE_LIGHT_UPDATES + if (!SSlighting.allow_duped_values && !(delta_r || delta_g || delta_b)) // 0 is falsey ok + return +#else if (!(delta_r || delta_g || delta_b)) // 0 is falsey ok return +#endif lum_r += delta_r lum_g += delta_g @@ -109,6 +115,10 @@ if (largest_color_luminosity > 1) . = 1 / largest_color_luminosity + var/old_r = cache_r + var/old_g = cache_g + var/old_b = cache_b + #if LIGHTING_SOFT_THRESHOLD != 0 else if (largest_color_luminosity < LIGHTING_SOFT_THRESHOLD) . = 0 // 0 means soft lighting. @@ -123,6 +133,13 @@ #endif src.largest_color_luminosity = round(largest_color_luminosity, LIGHTING_ROUND_VALUE) +#ifdef VISUALIZE_LIGHT_UPDATES + if(!SSlighting.allow_duped_corners && old_r == cache_r && old_g == cache_g && old_b == cache_b) + return +#else + if(old_r == cache_r && old_g == cache_g && old_b == cache_b) + return +#endif var/datum/lighting_object/lighting_object = master_NE?.lighting_object if (lighting_object && !lighting_object.needs_update) diff --git a/code/modules/lighting/lighting_object.dm b/code/modules/lighting/lighting_object.dm index 21cfb8003cf..9004e35b204 100644 --- a/code/modules/lighting/lighting_object.dm +++ b/code/modules/lighting/lighting_object.dm @@ -43,6 +43,11 @@ return ..() /datum/lighting_object/proc/update() +#ifdef VISUALIZE_LIGHT_UPDATES + affected_turf.add_atom_colour(COLOR_BLUE_LIGHT, ADMIN_COLOUR_PRIORITY) + animate(affected_turf, 10, color = null) + addtimer(CALLBACK(affected_turf, /atom/proc/remove_atom_colour, ADMIN_COLOUR_PRIORITY, COLOR_BLUE_LIGHT), 10, TIMER_UNIQUE|TIMER_OVERRIDE) +#endif // To the future coder who sees this and thinks // "Why didn't he just use a loop?"