mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2026-01-03 22:13:24 +00:00
Tweak to Radiation Optimization
* Optimized garbage collection of radiation sources until we get qdel() hints. * Made the RADIATION_LOWER_LIMIT configurable (option for people to save some cpu time) * Added some comments and broke the proccessor into separate procs for profiling purposes * Added a changelog.
This commit is contained in:
@@ -19,14 +19,23 @@ var/global/repository/radiation/radiation_repository = new()
|
||||
radiation_repository.sources -= src
|
||||
if(radiation_repository.sources_assoc[src.source_turf] == src)
|
||||
radiation_repository.sources -= src.source_turf
|
||||
src.source_turf = null
|
||||
. = ..()
|
||||
|
||||
// TEMPORARY HACK - hard del()'ing sources is too expensive! Until we implement qdel() hints we need to override behavior here
|
||||
/datum/radiation_source/finalize_qdel()
|
||||
if(garbage_collector)
|
||||
garbage_collector.AddTrash(src)
|
||||
else
|
||||
delayed_garbage |= src
|
||||
// TEMPORARY HACK END
|
||||
|
||||
/datum/radiation_source/proc/update_rad_power(var/new_power = null)
|
||||
if(new_power != null && new_power != rad_power)
|
||||
rad_power = new_power
|
||||
. = 1
|
||||
if(. && !flat)
|
||||
range = min(round(sqrt(rad_power / config.radiation_lower_limit)), 31)
|
||||
range = min(round(sqrt(rad_power / config.radiation_lower_limit)), 31) // R = rad_power / dist**2 - Solve for dist
|
||||
|
||||
// Ray trace from all active radiation sources to T and return the strongest effect.
|
||||
/repository/radiation/proc/get_rads_at_turf(var/turf/T)
|
||||
@@ -76,7 +85,6 @@ var/global/repository/radiation/radiation_repository = new()
|
||||
S.source_turf = get_turf(source)
|
||||
S.update_rad_power(power)
|
||||
add_source(S)
|
||||
return S
|
||||
|
||||
// Sets the radiation in a range to a constant value.
|
||||
/repository/radiation/proc/flat_radiate(source, power, range, var/respect_maint = FALSE)
|
||||
@@ -89,7 +97,6 @@ var/global/repository/radiation/radiation_repository = new()
|
||||
S.source_turf = get_turf(source)
|
||||
S.update_rad_power(power)
|
||||
add_source(S)
|
||||
return S
|
||||
|
||||
// Irradiates a full Z-level. Hacky way of doing it, but not too expensive.
|
||||
/repository/radiation/proc/z_radiate(var/atom/source, power, var/respect_maint = FALSE)
|
||||
|
||||
Reference in New Issue
Block a user