Files
WildkinsandGitHub 3d183d7262 Begin, the Lag Wars Have (#21839)
<img width="700" height="848" alt="image"
src="https://github.com/user-attachments/assets/e0db50af-35db-43c7-b78e-6c1ea5ac569c"
/>

you take a tiny little two year LOA and this happens
this PR hits some large lag culprits:
- UpdateOverlays() getting spammed by human/update_icon. This was 0.85%
of server CPU time during the event. Doesn't sound like a whole lot but
it's insane. 99% of it was caused by sloppy duplicate calls of
update_icon in set_dir (as well as update icon itself!). Refactored to
stop that
- Makes Follow menu update manually, which cuts down on the 2.8 million
REF() calls it made during the event. This was ~1% of CPU time including
ui_data as well.
- Gets rid of a bunch of random runtimes and some lighting-related
harddels.
- NanoUIs now clean themselves up when their owner qdels rather than
forcing the owner to do REF(src) and close all matching UIs. saves us
~0.1% server cpu time! wowza!
2026-02-09 23:20:48 +00:00

197 lines
5.6 KiB
Plaintext

//I would have rewritten this whole thing, but it requires to change half a million systems for it to be proper, therefore
//i declare this shit legacy code, to be slowly phased out as things get updated
/mob/living/carbon/human/movement_delay()
var/tally = 0
if(species.slowdown)
tally = species.slowdown
if(lying) //Crawling, it's slower
tally += (8 + ((weakened * 3) + (confused * 2)))
if (!(species.flags & NO_EQUIP_SPEEDMODS))
tally += get_pulling_movement_delay()
if (istype(loc, /turf/space) || isopenturf(loc))
if(!(locate(/obj/structure/lattice, loc) || locate(/obj/structure/stairs, loc) || locate(/obj/structure/ladder, loc)))
return 0
if(embedded_flag)
handle_embedded_objects() //Moving with objects stuck in you can cause bad times.
var/health_deficiency = maxHealth - health
if(health_deficiency >= 40)
tally += (health_deficiency / 25)
var/shock = get_shock()
if(shock >= 10)
tally += (shock / 30) //get_shock checks if we can feel pain
if(species)
tally += species.get_species_tally(src)
tally += species.handle_movement_tally(src)
if(is_asystole())
tally += 10 //heart attacks are kinda distracting
if(aiming?.aiming_at)
tally += 5 // Iron sights make you slower, it's a well-known fact.
if (is_drowsy())
tally += 6
if (!(species.flags & NO_COLD_SLOWDOWN)) // Bugs and machines don't move slower when cold.
if((mutations & FAT))
tally += 1.5
if (bodytemperature < 283.222)
tally += (283.222 - bodytemperature) / 10 * 1.75
tally += max(2 * stance_damage, 0) //damaged/missing feet or legs is slow
if((mutations & mRun))
tally = 0
if(isitem(pulling) && !(species.flags & NO_EQUIP_SPEEDMODS))
var/obj/item/P = pulling
tally += P.slowdown
var/obj/item/grab/grab = get_type_in_hands(/obj/item/grab)
if(istype(grab) && ishuman(grab.affecting))
if(grab.affecting.mob_weight > get_mob_strength())
tally += grab.affecting.mob_weight - get_mob_strength()
var/turf/T = get_turf(src)
if(T) // changelings don't get movement costs
var/datum/changeling/changeling
if(mind)
changeling = mind.antag_datums[MODE_CHANGELING]
if(!changeling)
tally += T.movement_cost
if(species && istype(T, /turf/simulated/floor/exoplanet/water))
if(species.can_breathe_water())
tally -= T.movement_cost
if(HAS_TRAIT(src, TRAIT_SHOE_GRIP))
tally += 1
tally += GLOB.config.human_delay
if(!isnull(facing_dir) && facing_dir != dir)
tally += 3
tally = round(tally, 0.1)
return tally
/mob/living/carbon/human/Allow_Spacemove(var/check_drift = 0)
//Can we act?
if(restrained()) return 0
//Do we have a working jetpack?
var/obj/item/tank/jetpack/thrust = GetJetpack(src)
if(thrust)
if(((!check_drift) || (check_drift && thrust.stabilization_on)) && (!lying) && (thrust.allow_thrust(0.01, src)))
inertia_dir = 0
return 1
//If no working jetpack then use the other checks
. = ..()
/mob/living/carbon/human/slip_chance(var/prob_slip = 5)
if(!..())
return 0
//Check hands and mod slip
if(!l_hand) prob_slip -= 2
else if(l_hand.w_class <= 2) prob_slip -= 1
if (!r_hand) prob_slip -= 2
else if(r_hand.w_class <= 2) prob_slip -= 1
return prob_slip
/mob/living/carbon/human/Check_Shoegrip(checkSpecies = TRUE)
if(shoes && (shoes.item_flags & ITEM_FLAG_NO_SLIP) && istype(shoes, /obj/item/clothing/shoes/magboots) && !lying && !buckled_to && !length(grabbed_by)) //magboots + dense_object = no floating. Doesn't work if lying. Grabbedby and buckled_to are for mob carrying, wheelchairs, roller beds, etc.
return TRUE
if(HAS_TRAIT(src, TRAIT_SHOE_GRIP))
return TRUE
return FALSE
/mob/living/carbon/human/set_dir(var/new_dir, ignore_facing_dir = FALSE)
. = ..()
if(. && tail_style)
update_tail_showing(!lying)
if(lying)
update_icon(TRUE)
/mob/living/carbon/human/Move()
. = ..()
if(.) //We moved
handle_leg_damage()
var/turf/T = get_turf(loc)
var/footsound
var/top_layer = 0
if(istype(T))
for(var/obj/structure/S in T)
if(S.layer > top_layer && S.footstep_sound)
top_layer = S.layer
footsound = S.footstep_sound
if(!footsound)
footsound = T.footstep_sound
if (client)
var/turf/T1 = GET_TURF_ABOVE(T)
if(up_hint)
up_hint.icon_state = "uphint[(T1 ? !!isopenturf(T1) : 0)]"
if (!stat && !lying)
if ((x == last_x && y == last_y) || !footsound)
return
last_x = x
last_y = y
if(shoes)
var/obj/item/clothing/shoes/S = shoes
if(S.do_special_footsteps(m_intent))
return
if (m_intent == M_RUN)
playsound(src, (is_noisy ? footsound : species.footsound), 70, TRUE, extrarange = MEDIUM_RANGE_SOUND_EXTRARANGE, required_asfx_toggles = ASFX_FOOTSTEPS)
else
footstep++
if (footstep % 2)
playsound(src, (is_noisy ? footsound : species.footsound), 40, TRUE, extrarange = SHORT_RANGE_SOUND_EXTRARANGE, required_asfx_toggles = ASFX_FOOTSTEPS)
/mob/living/carbon/human/proc/handle_leg_damage()
if(!can_feel_pain())
return
var/crutches = 0
for (var/obj/item/cane/C as anything in get_type_in_hands(/obj/item/cane))
if(istype(C) && (C?.can_support))
crutches++
for(var/organ_name in list(BP_L_LEG, BP_R_LEG, BP_L_FOOT, BP_R_FOOT))
var/obj/item/organ/external/E = get_organ(organ_name)
if(E && (ORGAN_IS_DISLOCATED(E)|| E.is_broken()))
if(crutches)
crutches--
else
E.add_pain(10)
/mob/living/carbon/human/mob_has_gravity()
. = ..()
if(!. && mob_negates_gravity())
. = 1
/mob/living/carbon/human/mob_negates_gravity()
return (shoes && shoes.negates_gravity())
/mob/living/carbon/human/get_pulling_movement_delay()
. = ..()
if(ishuman(pulling))
var/mob/living/carbon/human/H = pulling
if(H.species.slowdown > species.slowdown)
. += H.species.slowdown - species.slowdown