diff --git a/code/__HELPERS/game.dm b/code/__HELPERS/game.dm index f7c5404bd8f..b945b4a4c47 100644 --- a/code/__HELPERS/game.dm +++ b/code/__HELPERS/game.dm @@ -431,3 +431,10 @@ new_character.key = G_found.key return new_character + +//supposedly the fastest way to do this according to https://gist.github.com/Giacom/be635398926bb463b42a +#define RANGE_TURFS(RADIUS, CENTER) \ + block( \ + locate(max(CENTER.x-(RADIUS),1), max(CENTER.y-(RADIUS),1), CENTER.z), \ + locate(min(CENTER.x+(RADIUS),world.maxx), min(CENTER.y+(RADIUS),world.maxy), CENTER.z) \ + ) diff --git a/code/game/turfs/space/space.dm b/code/game/turfs/space/space.dm index da5456a028a..cc02c1959aa 100644 --- a/code/game/turfs/space/space.dm +++ b/code/game/turfs/space/space.dm @@ -15,19 +15,16 @@ /turf/space/New() if(!istype(src, /turf/space/transit)) icon_state = "[((x + y) ^ ~(x * y) + z) % 25]" - if(config) - if(config.starlight) - update_starlight() + /turf/space/Destroy() return QDEL_HINT_LETMELIVE /turf/space/proc/update_starlight() if(config) if(config.starlight) - for(var/turf/T in orange(src,1)) - if(istype(T,/turf/simulated)) - SetLuminosity(3) - return + for(var/turf/simulated/T in RANGE_TURFS(1,src)) //RANGE_TURFS is in code\__HELPERS\game.dm + SetLuminosity(3) + return SetLuminosity(0) /turf/space/attack_paw(mob/user) diff --git a/code/modules/lighting/lighting_system.dm b/code/modules/lighting/lighting_system.dm index d393adb3728..e332250336c 100644 --- a/code/modules/lighting/lighting_system.dm +++ b/code/modules/lighting/lighting_system.dm @@ -267,10 +267,9 @@ lighting_object = locate() in src init_lighting() - for(var/turf/space/S in orange(1,src)) + for(var/turf/space/S in RANGE_TURFS(1,src)) //RANGE_TURFS is in code\__HELPERS\game.dm S.update_starlight() - /turf/proc/update_lumcount(amount) lighting_lumcount += amount if(!lighting_changed)