Assorted performance improvements (#25649)

* Improved efficiency of playsound.

* Improve performance of turf/Enter

* Improve performace of thrown objects.

* Improved performance of /atom/movable/CanPass.

* Improved pipeline destruction performance.

* Apply suggestions from code review

Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Co-authored-by: 1080pCat <96908085+1080pCat@users.noreply.github.com>
Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>

---------

Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>
Co-authored-by: FunnyMan3595 (Charlie Nolan) <funnyman@google.com>
Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Co-authored-by: 1080pCat <96908085+1080pCat@users.noreply.github.com>
This commit is contained in:
Charlie Nolan
2024-07-16 10:12:13 +00:00
committed by GitHub
co-authored by Luc 1080pCat FunnyMan3595
parent a5dd1a1bd3
commit fb93e5a74a
6 changed files with 75 additions and 60 deletions
+3 -2
View File
@@ -529,9 +529,10 @@
return FALSE
/atom/movable/CanPass(atom/movable/mover, turf/target, height=1.5)
if(mover in buckled_mobs)
// This condition is copied from atom to avoid an extra parent call, because this is a very hot proc.
if(!density || !height)
return TRUE
return ..()
return LAZYIN(buckled_mobs, mover)
/atom/movable/proc/get_spacemove_backup()
var/atom/movable/dense_object_backup
+22 -15
View File
@@ -61,25 +61,32 @@ falloff_distance - Distance at which falloff begins. Sound is at peak volume (in
var/sound/S = sound(get_sfx(soundin))
var/maxdistance = SOUND_RANGE + extrarange
var/list/listeners = GLOB.player_list
if(!ignore_walls) //these sounds don't carry through walls
listeners = listeners & hearers(maxdistance, turf_source)
for(var/P in listeners)
var/mob/M = P
if(!M || !M.client)
var/list/possible_listeners = list()
var/list/desired_turfs = list()
for(var/mob/P as anything in GLOB.player_list)
if(isnull(P) || !P.client)
continue
var/turf/T = get_turf(P)
if(!T || T.z != turf_source.z || get_dist(T, turf_source) > maxdistance)
continue
var/turf/T = get_turf(M) // These checks need to be changed if z-levels are ever further refactored
if(!T)
continue
if(T.z != turf_source.z)
continue
possible_listeners += P
desired_turfs |= T
var/distance = get_dist(M, turf_source)
var/list/listeners = list()
if(ignore_walls)
listeners = possible_listeners
else if(length(possible_listeners))
var/list/turf_vis = list()
for(var/turf/T as anything in desired_turfs)
turf_vis[T] = inLineOfSight(T.x, T.y, turf_source.x, turf_source.y, T.z)
if(distance <= maxdistance)
M.playsound_local(turf_source, soundin, vol, vary, frequency, falloff_exponent, channel, pressure_affected, S, maxdistance, falloff_distance, 1, use_reverb)
for(var/mob/P in possible_listeners)
if(turf_vis[get_turf(P)])
listeners += P
for(var/mob/M as anything in listeners)
M.playsound_local(turf_source, soundin, vol, vary, frequency, falloff_exponent, channel, pressure_affected, S, maxdistance, falloff_distance, 1, use_reverb)
/mob/proc/playsound_local(turf/turf_source, soundin, vol as num, vary, frequency, falloff_exponent = SOUND_FALLOFF_EXPONENT, channel = 0, pressure_affected = TRUE, sound/S, max_distance, falloff_distance = SOUND_DEFAULT_FALLOFF_DISTANCE, distance_multiplier = 1, use_reverb = TRUE)
if(!client || !can_hear())
+18 -11
View File
@@ -195,16 +195,22 @@
// First, make sure it can leave its square
if(isturf(mover.loc))
// Nothing but border objects stop you from leaving a tile, only one loop is needed
for(var/obj/obstacle in mover.loc)
if(!obstacle.CheckExit(mover, src) && obstacle != mover && obstacle != forget)
// This as anything looks odd, since we check istype shortly after, but it's so we can save an istype check for items, which are far more common than other objects.
for(var/obj/obstacle as anything in mover.loc)
if(isitem(obstacle) || !istype(obstacle) || obstacle == mover || obstacle == forget)
continue
if(!obstacle.CheckExit(mover, src))
mover.Bump(obstacle, TRUE)
return FALSE
var/list/large_dense = list()
//Next, check objects to block entry that are on the border
for(var/atom/movable/border_obstacle in src)
// Next, check for border obstacles on this turf
// Everyting inside a turf is an atom/movable.
for(var/atom/movable/border_obstacle as anything in src)
if(isitem(border_obstacle) || border_obstacle == forget || isnull(border_obstacle))
continue
if(border_obstacle.flags & ON_BORDER)
if(!border_obstacle.CanPass(mover, mover.loc, 1) && (forget != border_obstacle))
if(!border_obstacle.CanPass(mover, mover.loc, 1))
mover.Bump(border_obstacle, TRUE)
return FALSE
else
@@ -215,14 +221,15 @@
mover.Bump(src, TRUE)
return FALSE
//Finally, check objects/mobs to block entry that are not on the border
// Finally, check objects/mobs that block entry and are not on the border
var/atom/movable/tompost_bump
var/top_layer = FALSE
for(var/atom/movable/obstacle in large_dense)
if(!obstacle.CanPass(mover, mover.loc, 1) && (forget != obstacle))
if(obstacle.layer > top_layer)
tompost_bump = obstacle
top_layer = obstacle.layer
for(var/atom/movable/obstacle as anything in large_dense)
if(obstacle.layer <= top_layer)
continue
if(!obstacle.CanPass(mover, mover.loc, 1))
tompost_bump = obstacle
top_layer = obstacle.layer
if(tompost_bump)
mover.Bump(tompost_bump, TRUE)
return FALSE