diff --git a/code/controllers/Processes/radiation.dm b/code/controllers/Processes/radiation.dm index e64f71ebb7..192acf5d5c 100644 --- a/code/controllers/Processes/radiation.dm +++ b/code/controllers/Processes/radiation.dm @@ -7,7 +7,12 @@ linked = radiation_repository /datum/controller/process/radiation/doWork() - // Step 1 - Sources Decay + sources_decay() + cache_expires() + irradiate_targets() + +// Step 1 - Sources Decay +/datum/controller/process/radiation/proc/sources_decay() var/list/sources = linked.sources for(var/thing in sources) if(deleted(thing)) @@ -20,7 +25,8 @@ sources.Remove(S) SCHECK // This scheck probably just wastes resources, but better safe than sorry in this case. - // Step 2 - Cache Expires +// Step 2 - Cache Expires +/datum/controller/process/radiation/proc/cache_expires() var/list/resistance_cache = linked.resistance_cache for(var/thing in resistance_cache) if(deleted(thing)) @@ -32,6 +38,7 @@ SCHECK // Step 3 - Registered irradiatable things are checked for radiation +/datum/controller/process/radiation/proc/irradiate_targets() var/list/registered_listeners = living_mob_list // For now just use this. Nothing else is interested anyway. if(length(linked.sources) > 0) for(var/thing in registered_listeners) diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index c22ac1bc81..51fc286928 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -720,6 +720,9 @@ var/list/gamemode_cache = list() if(values.len > 0) language_prefixes = values + if("radiation_lower_limit") + radiation_lower_limit = text2num(value) + else log_misc("Unknown setting in configuration: '[name]'") diff --git a/code/datums/repositories/radiation.dm b/code/datums/repositories/radiation.dm index 457e423b4e..5471282026 100644 --- a/code/datums/repositories/radiation.dm +++ b/code/datums/repositories/radiation.dm @@ -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) diff --git a/config/example/config.txt b/config/example/config.txt index 232d3c66ad..52892bc14a 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -36,6 +36,9 @@ JOBS_HAVE_MINIMAL_ACCESS Configure how fast explosion strength diminishes when travelling up/down z levels. All explosion distances are multiplied by this each time they go up/down z-levels. #MULTI_Z_EXPLOSION_SCALAR 0.5 +# Radiation weakens with distance from the source; stop calculating when the strength falls below this value. Lower values mean radiation reaches smaller (with increasingly trivial damage) at the cost of more CPU usage. Max range = DISTANCE^2 * POWER / RADIATION_LOWER_LIMIT +# RADIATION_LOWER_LIMIT 0.35 + ## log OOC channel LOG_OOC diff --git a/html/changelogs/Leshana-Radiation.yml b/html/changelogs/Leshana-Radiation.yml new file mode 100644 index 0000000000..d4d9c3589d --- /dev/null +++ b/html/changelogs/Leshana-Radiation.yml @@ -0,0 +1,5 @@ +author: Leshana +delete-after: True +changes: + - tweak: "Optimized the unified radiation system. Made the radiation cutoff level configurable." + - bugfix: "Standing still won't save you from radiation storms."