Files
Bubberstation/code/modules/mob/dead/dead.dm
SkyratBot 9c5408fe27 [MIRROR] Optimizes changing z level as a ghost by something like 85% [MDB IGNORE] (#19030)
Optimizes changing z level as a ghost by something like 85% (#73005)

<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request

<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

Optimizes hud image addition/removal on z change

We were doing a lot of repeated work here, not to mention all the proc
calls.
So I pushed the "operate on loops" behavior into its own proc, so I
could ensure we only do some of this stuff once

This plus some removal of safeties saves 75% of the cost of z level
transitions as a ghost

Prevents double on_changed_z_level calls from ghosts and shuttles

Reacting to z changes used to be done off doMove or one of those
children, timber moved it to Moved, but did not remove the calls that
assumed things like abstract_move wouldn't trigger it

This means that moving up/down as a ghost was causing a double call of
the whole z move stack. Suprised this never broke anything tbh

Makes csv stat tracking actually encode numbers properly, cleans up an
indev comment from plane group code

## Why It's Good For The Game

Speed, and fixes

Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
2023-01-29 23:50:33 +00:00

119 lines
2.9 KiB
Plaintext

//Dead mobs can exist whenever. This is needful
INITIALIZE_IMMEDIATE(/mob/dead)
/mob/dead
sight = SEE_TURFS | SEE_MOBS | SEE_OBJS | SEE_SELF
move_resist = INFINITY
throwforce = 0
/mob/dead/Initialize(mapload)
SHOULD_CALL_PARENT(FALSE)
if(flags_1 & INITIALIZED_1)
stack_trace("Warning: [src]([type]) initialized multiple times!")
flags_1 |= INITIALIZED_1
// Initial is non standard here, but ghosts move before they get here so it's needed. this is a cold path too so it's ok
SET_PLANE_IMPLICIT(src, initial(plane))
tag = "mob_[next_mob_id++]"
add_to_mob_list()
prepare_huds()
if(length(CONFIG_GET(keyed_list/cross_server)))
add_verb(src, /mob/dead/proc/server_hop)
set_focus(src)
become_hearing_sensitive()
log_mob_tag("CREATED: [key_name(src)] \[[src.type]\]")
return INITIALIZE_HINT_NORMAL
/mob/dead/canUseStorage()
return FALSE
/mob/dead/get_status_tab_items()
. = ..()
if(SSticker.HasRoundStarted())
return
var/time_remaining = SSticker.GetTimeLeft()
if(time_remaining > 0)
. += "Time To Start: [round(time_remaining/10)]s"
else if(time_remaining == -10)
. += "Time To Start: DELAYED"
else
. += "Time To Start: SOON"
. += "Players: [LAZYLEN(GLOB.clients)]"
if(client.holder)
. += "Players Ready: [SSticker.totalPlayersReady]"
. += "Admins Ready: [SSticker.total_admins_ready] / [length(GLOB.admins)]"
/mob/dead/proc/server_hop()
set category = "OOC"
set name = "Server Hop"
set desc= "Jump to the other server"
if(notransform)
return
var/list/our_id = CONFIG_GET(string/cross_comms_name)
var/list/csa = CONFIG_GET(keyed_list/cross_server) - our_id
var/pick
switch(length(csa))
if(0)
remove_verb(src, /mob/dead/proc/server_hop)
to_chat(src, span_notice("Server Hop has been disabled."))
if(1)
pick = csa[1]
else
pick = tgui_input_list(src, "Server to jump to", "Server Hop", csa)
if(isnull(pick))
return
var/addr = csa[pick]
if(tgui_alert(usr, "Jump to server [pick] ([addr])?", "Server Hop", list("Yes", "No")) != "Yes")
return
var/client/C = client
to_chat(C, span_notice("Sending you to [pick]."))
new /atom/movable/screen/splash(null, C)
notransform = TRUE
sleep(2.9 SECONDS) //let the animation play
notransform = FALSE
if(!C)
return
winset(src, null, "command=.options") //other wise the user never knows if byond is downloading resources
C << link("[addr]")
/mob/dead/proc/update_z(new_z) // 1+ to register, null to unregister
if (registered_z != new_z)
if (registered_z)
SSmobs.dead_players_by_zlevel[registered_z] -= src
if (client)
if (new_z)
SSmobs.dead_players_by_zlevel[new_z] += src
registered_z = new_z
else
registered_z = null
/mob/dead/Login()
. = ..()
if(!. || !client)
return FALSE
var/turf/T = get_turf(src)
if (isturf(T))
update_z(T.z)
/mob/dead/auto_deadmin_on_login()
return
/mob/dead/Logout()
update_z(null)
return ..()
/mob/dead/on_changed_z_level(turf/old_turf, turf/new_turf, same_z_layer, notify_contents)
..()
update_z(new_turf?.z)