Skip to content

Commit

Permalink
SSair performance improvements (#28271)
Browse files Browse the repository at this point in the history
  • Loading branch information
FunnyMan3595 authored Feb 12, 2025
1 parent 2e2a778 commit 194e851
Show file tree
Hide file tree
Showing 32 changed files with 150 additions and 70 deletions.
51 changes: 33 additions & 18 deletions code/controllers/subsystem/SSair.dm
Original file line number Diff line number Diff line change
Expand Up @@ -417,40 +417,54 @@ SUBSYSTEM_DEF(air)
continue

var/reasons = currentrun[offset + MILLA_INDEX_INTERESTING_REASONS]
var/x_flow = currentrun[offset + MILLA_INDEX_AIRFLOW_X]
var/y_flow = currentrun[offset + MILLA_INDEX_AIRFLOW_Y]
var/milla_tile = currentrun.Copy(offset + 1, offset + 1 + MILLA_TILE_SIZE + 1)
currentrun.len -= MILLA_INTERESTING_TILE_SIZE

// Bind the MILLA tile we got, if needed.
if(isnull(T.bound_air))
bind_turf(T, milla_tile)
else if(T.bound_air.lastread < milla_tick)
T.bound_air.copy_from_milla(milla_tile)
T.bound_air.lastread = milla_tick
T.bound_air.readonly = null
T.bound_air.dirty = FALSE
T.bound_air.synchronized = FALSE

if(reasons & MILLA_INTERESTING_REASON_DISPLAY)
var/milla_tile = currentrun.Copy(offset + 1, offset + 1 + MILLA_TILE_SIZE + 1)
if(isnull(T.bound_air))
bind_turf(T, milla_tile)
else if(T.bound_air.lastread < milla_tick)
T.bound_air.copy_from_milla(milla_tile)
T.bound_air.lastread = milla_tick
T.bound_air.readonly = null
T.bound_air.dirty = FALSE
T.bound_air.synchronized = FALSE

var/turf/simulated/S = T
if(istype(S))
S.update_visuals()

if(reasons & MILLA_INTERESTING_REASON_HOT)
var/temperature = currentrun[offset + MILLA_INDEX_TEMPERATURE]
var/fuel_burnt = currentrun[offset + MILLA_INDEX_FUEL_BURNT]
var/hotspot_temperature = currentrun[offset + MILLA_INDEX_HOTSPOT_TEMPERATURE]
var/hotspot_volume = currentrun[offset + MILLA_INDEX_HOTSPOT_VOLUME]

var/turf/simulated/S = T
if(istype(S))
if(isnull(S.active_hotspot))
// Wasn't an active hotspot before, add it.
hotspots += S

var/datum/gas_mixture/air = T.get_readonly_air()
T.temperature_expose(air.temperature())
else
S.active_hotspot.temperature = temperature
S.active_hotspot.fuel_burnt = fuel_burnt
S.active_hotspot.data_tick = milla_tick
if(hotspot_volume > 0)
S.active_hotspot.temperature = hotspot_temperature
S.active_hotspot.volume = hotspot_volume * CELL_VOLUME
else
S.active_hotspot.temperature = temperature
S.active_hotspot.volume = CELL_VOLUME

T.temperature_expose(temperature)
for(var/atom/movable/item in T)
item.temperature_expose(air, air.temperature(), CELL_VOLUME)
T.temperature_expose(air, air.temperature(), CELL_VOLUME)
if(item.cares_about_temperature || !isnull(item.reagents))
item.temperature_expose(temperature, CELL_VOLUME)

if(reasons & MILLA_INTERESTING_REASON_WIND)
var/x_flow = currentrun[offset + MILLA_INDEX_AIRFLOW_X]
var/y_flow = currentrun[offset + MILLA_INDEX_AIRFLOW_Y]

var/turf/simulated/S = T
if(istype(S))
if(isnull(S.wind_tick))
Expand All @@ -461,6 +475,7 @@ SUBSYSTEM_DEF(air)
S.wind_y = y_flow
T.high_pressure_movements(x_flow, y_flow)

currentrun.len -= MILLA_INTERESTING_TILE_SIZE
if(MC_TICK_CHECK)
return

Expand Down
3 changes: 3 additions & 0 deletions code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@
/// Whether this atom is using the new attack chain.
var/new_attack_chain = FALSE

/// Do we care about temperature at all? Saves us a ton of proc calls during big fires.
var/cares_about_temperature = FALSE

/atom/New(loc, ...)
SHOULD_CALL_PARENT(TRUE)
if(GLOB.use_preloader && (src.type == GLOB._preloader.target_path))//in case the instanciated atom is creating other atoms in New()
Expand Down
3 changes: 2 additions & 1 deletion code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ GLOBAL_LIST_EMPTY(airlock_emissive_underlays)
flags_2 = RAD_PROTECT_CONTENTS_2 | RAD_NO_CONTAMINATE_2
rad_insulation = RAD_MEDIUM_INSULATION
smoothing_groups = list(SMOOTH_GROUP_AIRLOCK)
cares_about_temperature = TRUE
var/security_level = 0 //How much are wires secured
var/aiControlDisabled = AICONTROLDISABLED_OFF
var/hackProof = FALSE // if TRUE, this door can't be hacked by the AI
Expand Down Expand Up @@ -1680,7 +1681,7 @@ GLOBAL_LIST_EMPTY(airlock_emissive_underlays)
else
return PROCESS_KILL

/obj/machinery/door/airlock/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
/obj/machinery/door/airlock/temperature_expose(exposed_temperature, exposed_volume)
..()
if(heat_proof)
return
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/doors/airlock_types.dm
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
assemblytype = /obj/structure/door_assembly/door_assembly_plasma
paintable = FALSE

/obj/machinery/door/airlock/plasma/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
/obj/machinery/door/airlock/plasma/temperature_expose(exposed_temperature, exposed_volume)
..()
if(exposed_temperature > 300)
PlasmaBurn(exposed_temperature)
Expand Down
6 changes: 4 additions & 2 deletions code/game/machinery/doors/firedoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
blocks_emissive = EMISSIVE_BLOCK_GENERIC
armor = list(MELEE = 30, BULLET = 30, LASER = 20, ENERGY = 20, BOMB = 10, RAD = 100, FIRE = 95, ACID = 70)
superconductivity = ZERO_HEAT_TRANSFER_COEFFICIENT
cares_about_temperature = TRUE
/// How long does opening by hand take, in deciseconds.
var/manual_open_time = 5 SECONDS
var/can_crush = TRUE
Expand Down Expand Up @@ -350,7 +351,7 @@
return FALSE
return ..()

/obj/machinery/door/firedoor/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
/obj/machinery/door/firedoor/temperature_expose(exposed_temperature, exposed_volume)
..()
if(exposed_temperature > (T0C + heat_resistance))
take_damage(round(exposed_volume / 100), BURN, 0, 0)
Expand Down Expand Up @@ -382,6 +383,7 @@
icon_state = "frame1"
anchored = FALSE
density = TRUE
cares_about_temperature = TRUE
var/constructionStep = CONSTRUCTION_NOCIRCUIT
var/reinforced = 0
var/heat_resistance = 1000
Expand Down Expand Up @@ -546,7 +548,7 @@
new /obj/machinery/door/firedoor(get_turf(src))
qdel(src)

/obj/structure/firelock_frame/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
/obj/structure/firelock_frame/temperature_expose(exposed_temperature, exposed_volume)
..()
if(exposed_temperature > (T0C + heat_resistance))
take_damage(round(exposed_volume / 100), BURN, 0, 0)
Expand Down
3 changes: 2 additions & 1 deletion code/game/machinery/doors/windowdoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
armor = list(MELEE = 20, BULLET = 50, LASER = 50, ENERGY = 50, BOMB = 10, RAD = 100, FIRE = 70, ACID = 100)
glass = TRUE // Used by polarized helpers. Windoors are always glass.
superconductivity = WINDOW_HEAT_TRANSFER_COEFFICIENT
cares_about_temperature = TRUE
var/obj/item/airlock_electronics/electronics
var/base_state = "left"
var/reinf = FALSE
Expand Down Expand Up @@ -268,7 +269,7 @@
/obj/machinery/door/window/narsie_act()
color = NARSIE_WINDOW_COLOUR

/obj/machinery/door/window/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
/obj/machinery/door/window/temperature_expose(exposed_temperature, exposed_volume)
..()
if(exposed_temperature > T0C + (reinf ? 1600 : 800))
take_damage(round(exposed_volume / 200), BURN, 0, 0)
Expand Down
3 changes: 2 additions & 1 deletion code/game/machinery/firealarm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ FIRE ALARM
active_power_consumption = 6
power_channel = PW_CHANNEL_ENVIRONMENT
resistance_flags = FIRE_PROOF
cares_about_temperature = TRUE

light_power = LIGHTING_MINIMUM_POWER
light_range = 7
Expand Down Expand Up @@ -107,7 +108,7 @@ FIRE ALARM
playsound(loc, 'sound/effects/sparks4.ogg', 50, TRUE)
return TRUE

/obj/machinery/firealarm/temperature_expose(datum/gas_mixture/air, temperature, volume)
/obj/machinery/firealarm/temperature_expose(temperature, volume)
..()
if(!emagged && detecting && temperature > T0C + 200)
alarm() // added check of detector status here
Expand Down
3 changes: 2 additions & 1 deletion code/game/mecha/mecha.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
max_integrity = 300 //max_integrity is base health
armor = list(melee = 20, bullet = 10, laser = 0, energy = 0, bomb = 0, rad = 0, fire = 100, acid = 75)
bubble_icon = "machine"
cares_about_temperature = TRUE
var/list/facing_modifiers = list(MECHA_FRONT_ARMOUR = 1.5, MECHA_SIDE_ARMOUR = 1, MECHA_BACK_ARMOUR = 0.5)
var/initial_icon = null //Mech type for resetting icon. Only used for reskinning kits (see custom items)
var/can_move = 0 // time of next allowed movement
Expand Down Expand Up @@ -699,7 +700,7 @@
log_message("EMP detected", 1)
check_for_internal_damage(list(MECHA_INT_FIRE, MECHA_INT_TEMP_CONTROL, MECHA_INT_CONTROL_LOST, MECHA_INT_SHORT_CIRCUIT), 1)

/obj/mecha/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
/obj/mecha/temperature_expose(exposed_temperature, exposed_volume)
..()
if(exposed_temperature > max_temperature)
log_message("Exposed to dangerous temperature.", 1)
Expand Down
5 changes: 3 additions & 2 deletions code/game/objects/effects/effect_system/effects_foam.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
gender = PLURAL
layer = OBJ_LAYER + 0.9
animate_movement = NO_STEPS
cares_about_temperature = TRUE
/// How many times this one bit of foam can spread around itself
var/spread_amount = 3
/// How long it takes this to initially start spreading after being dispersed
Expand Down Expand Up @@ -121,7 +122,7 @@
/obj/effect/particle_effect/foam/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume, global_overlay = TRUE) //Don't heat the reagents inside
return

/obj/effect/particle_effect/foam/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume) // overriden to prevent weird behaviors with heating reagents inside
/obj/effect/particle_effect/foam/temperature_expose(exposed_temperature, exposed_volume) // overriden to prevent weird behaviors with heating reagents inside
if(prob(max(0, exposed_temperature - 475)))
flick("[icon_state]-disolve", src)
QDEL_IN(src, 0.5 SECONDS)
Expand Down Expand Up @@ -155,7 +156,7 @@
M.metal = metal_kind
M.update_state()

/obj/effect/particle_effect/foam/metal/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
/obj/effect/particle_effect/foam/metal/temperature_expose(exposed_temperature, exposed_volume)
return

/obj/effect/particle_effect/foam/metal/on_atom_entered(datum/source, atom/movable/entered)
Expand Down
3 changes: 2 additions & 1 deletion code/game/objects/effects/glowshroom.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
base_icon_state = "glowshroom" //replaced in New
layer = ABOVE_NORMAL_TURF_LAYER
max_integrity = 30
cares_about_temperature = TRUE
var/floor = 0
var/obj/item/seeds/myseed = /obj/item/seeds/glowshroom

Expand Down Expand Up @@ -107,7 +108,7 @@
if(damage_type == BURN && damage_amount)
playsound(src.loc, 'sound/items/welder.ogg', 100, TRUE)

/obj/structure/glowshroom/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
/obj/structure/glowshroom/temperature_expose(exposed_temperature, exposed_volume)
..()
if(exposed_temperature > 300)
take_damage(5, BURN, 0, 0)
Expand Down
3 changes: 2 additions & 1 deletion code/game/objects/effects/spiders.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
anchored = TRUE
density = FALSE
max_integrity = 15
cares_about_temperature = TRUE
var/mob/living/carbon/human/master_commander = null

/obj/structure/spider/play_attack_sound(damage_amount, damage_type = BRUTE, damage_flag = 0)
Expand All @@ -26,7 +27,7 @@
master_commander = null
return ..()

/obj/structure/spider/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
/obj/structure/spider/temperature_expose(exposed_temperature, exposed_volume)
..()
if(exposed_temperature > 300)
take_damage(5, BURN, 0, 0)
Expand Down
3 changes: 2 additions & 1 deletion code/game/objects/items/latexballoon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
w_class = WEIGHT_CLASS_TINY
throw_speed = 1
throw_range = 7
cares_about_temperature = TRUE
var/state
var/datum/gas_mixture/air_contents = null

Expand Down Expand Up @@ -52,7 +53,7 @@
burst()
return ..()

/obj/item/latexballon/temperature_expose(datum/gas_mixture/air, temperature, volume)
/obj/item/latexballon/temperature_expose(temperature, volume)
..()
if(temperature > T0C+100)
burst()
Expand Down
3 changes: 2 additions & 1 deletion code/game/objects/items/stacks/sheets/leather.dm
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ GLOBAL_LIST_INIT(xeno_recipes, list (
icon_state = "sheet-wetleather"
item_state = "sheet-leather"
origin_tech = ""
cares_about_temperature = TRUE
var/wetness = 30 //Reduced when exposed to high temperautres
var/drying_threshold_temperature = 500 //Kelvin to start drying

Expand Down Expand Up @@ -327,7 +328,7 @@ GLOBAL_LIST_INIT(sinew_recipes, list (
qdel(src)

//Step three - drying
/obj/item/stack/sheet/wetleather/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
/obj/item/stack/sheet/wetleather/temperature_expose(exposed_temperature, exposed_volume)
..()
if(exposed_temperature >= drying_threshold_temperature)
wetness--
Expand Down
5 changes: 3 additions & 2 deletions code/game/objects/structures/aliens.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/obj/structure/alien
icon = 'icons/mob/alien.dmi'
max_integrity = 100
cares_about_temperature = TRUE

/obj/structure/alien/run_obj_armor(damage_amount, damage_type, damage_flag = 0, attack_dir)
if(damage_flag == MELEE)
Expand Down Expand Up @@ -355,7 +356,7 @@
new /obj/structure/alien/weeds(T, linked_node)
check_surroundings()

/obj/structure/alien/weeds/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
/obj/structure/alien/weeds/temperature_expose(exposed_temperature, exposed_volume)
..()
if(exposed_temperature > 300)
take_damage(5, BURN, 0, 0)
Expand Down Expand Up @@ -545,7 +546,7 @@
if(status != BURST)
burst(kill = TRUE)

/obj/structure/alien/egg/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
/obj/structure/alien/egg/temperature_expose(exposed_temperature, exposed_volume)
..()
if(exposed_temperature > 500)
take_damage(5, BURN, 0, 0)
Expand Down
3 changes: 2 additions & 1 deletion code/game/objects/structures/door_assembly.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
anchored = FALSE
density = TRUE
max_integrity = 200
cares_about_temperature = TRUE
var/overlays_file = 'icons/obj/doors/airlocks/station/overlays.dmi'
var/state = AIRLOCK_ASSEMBLY_NEEDS_WIRES
/// String value. Used in user chat messages
Expand Down Expand Up @@ -309,7 +310,7 @@
new /obj/item/shard(T)
qdel(src)

/obj/structure/door_assembly/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
/obj/structure/door_assembly/temperature_expose(exposed_temperature, exposed_volume)
..()
if(exposed_temperature > (T0C + heat_resistance))
take_damage(round(exposed_volume / 100), BURN, 0, 0)
1 change: 1 addition & 0 deletions code/game/objects/structures/false_walls.dm
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@
smoothing_flags = SMOOTH_BITMASK
smoothing_groups = list(SMOOTH_GROUP_WALLS, SMOOTH_GROUP_PLASMA_WALLS)
canSmoothWith = list(SMOOTH_GROUP_PLASMA_WALLS)
cares_about_temperature = TRUE

/obj/structure/falsewall/plasma/attackby__legacy__attackchain(obj/item/W, mob/user, params)
if(W.get_heat() > 300)
Expand Down
3 changes: 2 additions & 1 deletion code/game/objects/structures/girders.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
layer = BELOW_OBJ_LAYER
flags_2 = RAD_PROTECT_CONTENTS_2 | RAD_NO_CONTAMINATE_2
rad_insulation = RAD_VERY_LIGHT_INSULATION
cares_about_temperature = TRUE
var/state = GIRDER_NORMAL
var/girderpasschance = 20 // percentage chance that a projectile passes through the girder.
max_integrity = 200
Expand Down Expand Up @@ -40,7 +41,7 @@
for(var/i=0;i < metalAmount;i++)
new metal_type(get_turf(src))

/obj/structure/girder/temperature_expose(datum/gas_mixture/air, exposed_temperature)
/obj/structure/girder/temperature_expose(exposed_temperature)
..()
var/temp_check = exposed_temperature
if(temp_check >= GIRDER_MELTING_TEMP)
Expand Down
3 changes: 2 additions & 1 deletion code/game/objects/structures/grille.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
armor = list(MELEE = 50, BULLET = 70, LASER = 70, ENERGY = 100, BOMB = 10, RAD = 100, FIRE = 0, ACID = 0)
max_integrity = 50
integrity_failure = 20
cares_about_temperature = TRUE
var/rods_type = /obj/item/stack/rods
var/rods_amount = 2
var/rods_broken = 1
Expand Down Expand Up @@ -228,7 +229,7 @@
return FALSE
return FALSE

/obj/structure/grille/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
/obj/structure/grille/temperature_expose(exposed_temperature, exposed_volume)
..()
if(!broken)
if(exposed_temperature > T0C + 1500)
Expand Down
3 changes: 2 additions & 1 deletion code/game/objects/structures/mineral_doors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
name = "plasma door"
icon_state = "plasma"
sheetType = /obj/item/stack/sheet/mineral/plasma
cares_about_temperature = TRUE

/obj/structure/mineral_door/transparent/plasma/attackby__legacy__attackchain(obj/item/W, mob/user)
if(W.get_heat())
Expand All @@ -190,7 +191,7 @@
else
return ..()

/obj/structure/mineral_door/transparent/plasma/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
/obj/structure/mineral_door/transparent/plasma/temperature_expose(exposed_temperature, exposed_volume)
..()
if(exposed_temperature > 300)
TemperatureAct(exposed_temperature)
Expand Down
Loading

0 comments on commit 194e851

Please sign in to comment.