mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +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:
@@ -7,7 +7,12 @@
|
|||||||
linked = radiation_repository
|
linked = radiation_repository
|
||||||
|
|
||||||
/datum/controller/process/radiation/doWork()
|
/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
|
var/list/sources = linked.sources
|
||||||
for(var/thing in sources)
|
for(var/thing in sources)
|
||||||
if(deleted(thing))
|
if(deleted(thing))
|
||||||
@@ -20,7 +25,8 @@
|
|||||||
sources.Remove(S)
|
sources.Remove(S)
|
||||||
SCHECK // This scheck probably just wastes resources, but better safe than sorry in this case.
|
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
|
var/list/resistance_cache = linked.resistance_cache
|
||||||
for(var/thing in resistance_cache)
|
for(var/thing in resistance_cache)
|
||||||
if(deleted(thing))
|
if(deleted(thing))
|
||||||
@@ -32,6 +38,7 @@
|
|||||||
SCHECK
|
SCHECK
|
||||||
|
|
||||||
// Step 3 - Registered irradiatable things are checked for radiation
|
// 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.
|
var/list/registered_listeners = living_mob_list // For now just use this. Nothing else is interested anyway.
|
||||||
if(length(linked.sources) > 0)
|
if(length(linked.sources) > 0)
|
||||||
for(var/thing in registered_listeners)
|
for(var/thing in registered_listeners)
|
||||||
|
|||||||
@@ -720,6 +720,9 @@ var/list/gamemode_cache = list()
|
|||||||
if(values.len > 0)
|
if(values.len > 0)
|
||||||
language_prefixes = values
|
language_prefixes = values
|
||||||
|
|
||||||
|
if("radiation_lower_limit")
|
||||||
|
radiation_lower_limit = text2num(value)
|
||||||
|
|
||||||
else
|
else
|
||||||
log_misc("Unknown setting in configuration: '[name]'")
|
log_misc("Unknown setting in configuration: '[name]'")
|
||||||
|
|
||||||
|
|||||||
@@ -19,14 +19,23 @@ var/global/repository/radiation/radiation_repository = new()
|
|||||||
radiation_repository.sources -= src
|
radiation_repository.sources -= src
|
||||||
if(radiation_repository.sources_assoc[src.source_turf] == src)
|
if(radiation_repository.sources_assoc[src.source_turf] == src)
|
||||||
radiation_repository.sources -= src.source_turf
|
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)
|
/datum/radiation_source/proc/update_rad_power(var/new_power = null)
|
||||||
if(new_power != null && new_power != rad_power)
|
if(new_power != null && new_power != rad_power)
|
||||||
rad_power = new_power
|
rad_power = new_power
|
||||||
. = 1
|
. = 1
|
||||||
if(. && !flat)
|
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.
|
// Ray trace from all active radiation sources to T and return the strongest effect.
|
||||||
/repository/radiation/proc/get_rads_at_turf(var/turf/T)
|
/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.source_turf = get_turf(source)
|
||||||
S.update_rad_power(power)
|
S.update_rad_power(power)
|
||||||
add_source(S)
|
add_source(S)
|
||||||
return S
|
|
||||||
|
|
||||||
// Sets the radiation in a range to a constant value.
|
// Sets the radiation in a range to a constant value.
|
||||||
/repository/radiation/proc/flat_radiate(source, power, range, var/respect_maint = FALSE)
|
/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.source_turf = get_turf(source)
|
||||||
S.update_rad_power(power)
|
S.update_rad_power(power)
|
||||||
add_source(S)
|
add_source(S)
|
||||||
return S
|
|
||||||
|
|
||||||
// Irradiates a full Z-level. Hacky way of doing it, but not too expensive.
|
// 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)
|
/repository/radiation/proc/z_radiate(var/atom/source, power, var/respect_maint = FALSE)
|
||||||
|
|||||||
@@ -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.
|
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
|
#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 channel
|
||||||
LOG_OOC
|
LOG_OOC
|
||||||
|
|
||||||
|
|||||||
5
html/changelogs/Leshana-Radiation.yml
Normal file
5
html/changelogs/Leshana-Radiation.yml
Normal file
@@ -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."
|
||||||
Reference in New Issue
Block a user