[MIRROR] Removing the last sleeps in Init (#10715)

Co-authored-by: Cameron Lennox <killer65311@gmail.com>
This commit is contained in:
CHOMPStation2StaffMirrorBot
2025-04-22 02:41:59 -07:00
committed by GitHub
parent 42c640d672
commit b34a389663
14 changed files with 246 additions and 228 deletions

View File

@@ -138,6 +138,7 @@ var/global/list/runlevel_flags = list(RUNLEVEL_LOBBY, RUNLEVEL_SETUP, RUNLEVEL_G
#define INIT_ORDER_ALARM 16 // Must initialize before atoms.
#define INIT_ORDER_TRANSCORE 15
#define INIT_ORDER_ATOMS 14
#define INIT_ORDER_POIS 13
#define INIT_ORDER_MACHINES 10
#define INIT_ORDER_SHUTTLES 3
#define INIT_ORDER_TIMER 1
@@ -181,6 +182,7 @@ var/global/list/runlevel_flags = list(RUNLEVEL_LOBBY, RUNLEVEL_SETUP, RUNLEVEL_G
#define FIRE_PRIORITY_AI 10
#define FIRE_PRIORITY_GARBAGE 15
#define FIRE_PRIORITY_ASSETS 20
#define FIRE_PRIORITY_POIS 20
#define FIRE_PRIORITY_ALARM 20
#define FIRE_PRIORITY_CHARSETUP 25
#define FIRE_PRIORITY_AIRFLOW 30

View File

@@ -0,0 +1,87 @@
GLOBAL_LIST_EMPTY(global_used_pois)
SUBSYSTEM_DEF(points_of_interest)
name = "Points of Interest"
wait = 1 SECONDS
priority = FIRE_PRIORITY_POIS
init_order = INIT_ORDER_POIS
runlevels = RUNLEVEL_LOBBY | RUNLEVELS_DEFAULT //POIs can be loaded mid-round.
var/list/obj/effect/landmark/poi_loader/poi_queue = list()
/datum/controller/subsystem/points_of_interest/Initialize()
while (poi_queue.len)
load_next_poi()
to_world_log("Initializing POIs")
admin_notice(span_danger("Initializing POIs"), R_DEBUG)
return SS_INIT_SUCCESS
/datum/controller/subsystem/points_of_interest/fire(resumed = FALSE)
while (poi_queue.len)
load_next_poi()
if (MC_TICK_CHECK)
return
/// We select and fire the next PoI in the list.
/datum/controller/subsystem/points_of_interest/proc/load_next_poi()
var/obj/effect/landmark/poi_loader/poi_to_load = poi_queue[1]
poi_queue -= poi_to_load
//We then fire it!
load_poi(poi_to_load)
/datum/controller/subsystem/points_of_interest/proc/get_turfs_to_clean(obj/effect/landmark/poi_loader/poi_to_load)
return block(locate(poi_to_load.x, poi_to_load.y, poi_to_load.z), locate((poi_to_load.x + poi_to_load.size_x - 1), (poi_to_load.y + poi_to_load.size_y - 1), poi_to_load.z))
/datum/controller/subsystem/points_of_interest/proc/annihilate_bounds(obj/effect/landmark/poi_loader/poi_to_load)
//var/deleted_atoms = 0
//admin_notice(span_danger("Annihilating objects in poi loading location."), R_DEBUG)
var/list/turfs_to_clean = get_turfs_to_clean(poi_to_load)
if(turfs_to_clean.len)
for(var/x in 1 to 2) // Requires two passes to get everything.
for(var/turf/T in turfs_to_clean)
for(var/atom/movable/AM in T)
//++deleted_atoms
qdel(AM)
//admin_notice(span_danger("Annihilated [deleted_atoms] objects."), R_DEBUG)
/datum/controller/subsystem/points_of_interest/proc/load_poi(obj/effect/landmark/poi_loader/poi_to_load)
if(!poi_to_load)
return
var/turf/T = get_turf(poi_to_load)
if(!isturf(T))
to_world_log("[log_info_line(poi_to_load)] not on a turf! Cannot place poi template.")
return
// Choose a poi
if(!poi_to_load.poi_type)
return
if(!(GLOB.global_used_pois.len) || !(GLOB.global_used_pois[poi_to_load.poi_type]))
GLOB.global_used_pois[poi_to_load.poi_type] = list()
var/list/poi_list = GLOB.global_used_pois[poi_to_load.poi_type]
for(var/map in SSmapping.map_templates)
var/template = SSmapping.map_templates[map]
if(istype(template, poi_to_load.poi_type))
poi_list += template
var/datum/map_template/template_to_use = null
var/list/our_poi_list = GLOB.global_used_pois[poi_to_load.poi_type]
if(!our_poi_list.len)
return
else
template_to_use = pick(our_poi_list)
if(!template_to_use)
return
//admin_notice(span_danger("Chosen Predefined PoI Map: [chosen_type.name]"), R_DEBUG)
if(poi_to_load.remove_from_pool)
GLOB.global_used_pois[poi_to_load.poi_type] -= template_to_use
// Annihilate movable atoms
annihilate_bounds(poi_to_load)
// Actually load it
template_to_use.load(T)
qdel(poi_to_load)

View File

@@ -92,6 +92,7 @@
// Other parameters are passed from New (excluding loc), this does not happen if mapload is TRUE
// Must return an Initialize hint. Defined in code/__defines/subsystems.dm
/atom/proc/Initialize(mapload, ...)
SHOULD_NOT_SLEEP(TRUE)
SHOULD_CALL_PARENT(TRUE)
if(QDELETED(src))
stack_trace("GC: -- [type] had initialize() called after qdel() --")

View File

@@ -186,10 +186,11 @@ GLOBAL_VAR_INIT(message_delay, 0) // To make sure restarting the recentmessages
signal.data["level"] = map_levels
if(signal.data["slow"] > 0)
sleep(signal.data["slow"]) // simulate the network lag if necessary
addtimer(CALLBACK(src, PROC_REF(broadcast_signal), signal), signal.data["slow"], TIMER_DELETE_ME)
/obj/machinery/telecomms/allinone/proc/broadcast_signal(datum/signal/signal)
/* ###### Broadcast a message using signal.data ###### */
var/datum/radio_frequency/connection = signal.data["connection"]
var/list/forced_radios
@@ -244,8 +245,9 @@ GLOBAL_VAR_INIT(message_delay, 0) // To make sure restarting the recentmessages
//signal.data["level"] = using_map.contact_levels.Copy()
if(signal.data["slow"] > 0)
sleep(signal.data["slow"]) // simulate the network lag if necessary
addtimer(CALLBACK(src, PROC_REF(broadcast_signal), signal), signal.data["slow"], TIMER_DELETE_ME)
/obj/machinery/telecomms/allinone/antag/broadcast_signal(datum/signal/signal)
/* ###### Broadcast a message using signal.data ###### */
var/datum/radio_frequency/connection = signal.data["connection"]
@@ -274,6 +276,7 @@ GLOBAL_VAR_INIT(message_delay, 0) // To make sure restarting the recentmessages
signal.data["compression"], list(0), connection.frequency,
signal.data["verb"], forced_radios)
/**
Here is the big, bad function that broadcasts a message given the appropriate

View File

@@ -39,34 +39,4 @@
signal.data["compression"] = 0 // decompress since we're a processor
if(signal.data["slow"] > 0)
sleep(signal.data["slow"]) // simulate the network lag if necessary
/* ###### Broadcast a message using signal.data ###### */
var/datum/radio_frequency/connection = signal.data["connection"]
var/list/forced_radios
for(var/datum/weakref/wr in linked_radios_weakrefs)
var/obj/item/radio/R = wr.resolve()
if(istype(R))
LAZYDISTINCTADD(forced_radios, R)
Broadcast_Message(
signal.data["connection"],
signal.data["mob"],
signal.data["vmask"],
signal.data["vmessage"],
signal.data["radio"],
signal.data["message"],
signal.data["name"],
signal.data["job"],
signal.data["realname"],
signal.data["vname"],
DATA_NORMAL,
signal.data["compression"],
signal.data["level"],
connection.frequency,
signal.data["verb"],
signal.data["language"],
forced_radios
)
addtimer(CALLBACK(src, PROC_REF(broadcast_signal), signal), signal.data["slow"], TIMER_DELETE_ME)

View File

@@ -1,7 +1,3 @@
var/global/list/global_used_pois = list()
/obj/effect/landmark/poi_loader
name = "PoI Loader"
var/size_x
@@ -12,61 +8,5 @@ var/global/list/global_used_pois = list()
INITIALIZE_IMMEDIATE(/obj/effect/landmark/poi_loader)
/obj/effect/landmark/poi_loader/Initialize(mapload)
src.load_poi()
SSpoints_of_interest.poi_queue += src
return ..()
/obj/effect/landmark/poi_loader/proc/get_turfs_to_clean()
return block(locate(src.x, src.y, src.z), locate((src.x + size_x - 1), (src.y + size_y - 1), src.z))
/obj/effect/landmark/poi_loader/proc/annihilate_bounds()
//var/deleted_atoms = 0
//admin_notice(span_danger("Annihilating objects in poi loading location."), R_DEBUG)
var/list/turfs_to_clean = get_turfs_to_clean()
if(turfs_to_clean.len)
for(var/x in 1 to 2) // Requires two passes to get everything.
for(var/turf/T in turfs_to_clean)
for(var/atom/movable/AM in T)
//++deleted_atoms
qdel(AM)
//admin_notice(span_danger("Annihilated [deleted_atoms] objects."), R_DEBUG)
/obj/effect/landmark/poi_loader/proc/load_poi()
var/turf/T = get_turf(src)
if(!isturf(T))
to_world_log("[log_info_line(src)] not on a turf! Cannot place poi template.")
return
// Choose a poi
if(!poi_type)
return
if(!(global_used_pois.len) || !(global_used_pois[poi_type]))
global_used_pois[poi_type] = list()
var/list/poi_list = global_used_pois[poi_type]
for(var/map in SSmapping.map_templates)
var/template = SSmapping.map_templates[map]
if(istype(template, poi_type))
poi_list += template
var/datum/map_template/template_to_use = null
var/list/our_poi_list = global_used_pois[poi_type]
if(!our_poi_list.len)
return
else
template_to_use = pick(our_poi_list)
if(!template_to_use)
return
//admin_notice(span_danger("Chosen Predefined PoI Map: [chosen_type.name]"), R_DEBUG)
if(remove_from_pool)
global_used_pois[poi_type] -= template_to_use
// Annihilate movable atoms
annihilate_bounds()
//CHECK_TICK //Don't let anything else happen for now
// Actually load it
template_to_use.load(T)

View File

@@ -90,11 +90,9 @@
var/turf/T = M.loc
if(istype(T, /turf))
if(!M.moved_recently && M.last_move)
M.moved_recently = 1
M.moved_recently = TRUE
step(M, M.last_move)
sleep(50)
if(M)
M.moved_recently = 0
addtimer(VARSET_CALLBACK(M, moved_recently, FALSE), 5 SECONDS, TIMER_DELETE_ME)
to_chat(M, span_danger("You feel a sharp shock!"))
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(3, 1, M)

View File

@@ -19,16 +19,16 @@
/obj/item/buttonofnormal/attack_self(mob/user)
if(colorindex)
nonrandom()
sleep(10)
capsuleowner.resize(sizetouse)
sizetouse = rand(25,200)/100 //randmization occurs after press
addtimer(CALLBACK(src, PROC_REF(do_size_effect), capsuleowner), 10, TIMER_DELETE_ME)
/obj/item/buttonofnormal/throw_impact(atom/A, speed, mob/user)
..()
if(isliving(A))
if(colorindex)
nonrandom()
sleep(5)
addtimer(CALLBACK(src, PROC_REF(do_size_effect), A), 5, TIMER_DELETE_ME)
/obj/item/buttonofnormal/proc/do_size_effect(atom/A)
var/mob/living/capsulehit = A
capsulehit.resize(sizetouse)
sizetouse = rand(25,200)/100 //randmization occurs after press

View File

@@ -11,7 +11,7 @@
input = sanitize(tgui_input_text(src,"Choose an emote to display."))
else
input = message
process_emote(m_type, message, input, range)
process_normal_emote(m_type, message, input, range)
/// This is the custom_emote that you'll want to use if you're forcing something to custom emote with no input from the mob.
/// By default, we have a visible message, our range is world.view, and we do NOT check the stat.
@@ -19,10 +19,10 @@
if(check_stat && (src && stat))
return
var/input = message
process_emote(m_type, message, input, range)
process_automatic_emote(m_type, message, input, range)
//The actual meat and potatoes of the emote processing.
/mob/proc/process_emote(var/m_type = VISIBLE_MESSAGE, var/message, var/input, var/range = world.view)
/mob/proc/process_normal_emote(var/m_type = VISIBLE_MESSAGE, var/message, var/input, var/range = world.view)
var/list/formatted
var/runemessage
if(input)
@@ -36,28 +36,44 @@
else
return
log_the_emote(m_type, message, input, range, runemessage)
/mob/proc/format_the_emote(var/m_type = VISIBLE_MESSAGE, var/message, var/input, var/range = world.view)
/mob/proc/process_automatic_emote(var/m_type = VISIBLE_MESSAGE, var/message, var/input, var/range = world.view)
var/list/formatted
var/runemessage
if(input)
formatted = format_emote(src, message)
if(!islist(formatted))
return
message = formatted["pretext"] + formatted["nametext"] + formatted["subtext"]
runemessage = formatted["subtext"]
// This is just personal preference (but I'm objectively right) that custom emotes shouldn't have periods at the end in runechat
runemessage = replacetext(runemessage,".","",length(runemessage),length(runemessage)+1)
else
return
build_the_emote(m_type, message, input, range, runemessage)
/mob/proc/log_the_emote(m_type, message, input, range, runemessage)
log_emote(message,src) //Log before we add junk
build_the_emote(m_type, message, input, range, runemessage)
/mob/proc/build_the_emote(m_type, message, input, range, runemessage)
if(client)
message = span_emote(span_bold("[src]") + " [input]")
else
message = span_npc_emote(span_bold("[src]") + " [input]")
else
return
if(message)
send_the_emote(m_type, message, input, range, runemessage)
/mob/proc/send_the_emote(m_type, message, input, range, runemessage)
message = encode_html_emphasis(message)
/* CHOMPRemove - Not needed if you set your defaults right
var/ourfreq = null
if(isliving(src))
var/mob/living/L = src
if(L.voice_freq > 0 )
ourfreq = L.voice_freq
*/
// Hearing gasp and such every five seconds is not good emotes were not global for a reason.
// Maybe some people are okay with that.
var/turf/T = get_turf(src)
if(!T) return

View File

@@ -108,12 +108,16 @@
return INITIALIZE_HINT_QDEL
humanform = H
updatehealth()
calculate_health()
/mob/living/simple_mob/slime/promethean/updatehealth()
if(!humanform)
return ..()
calculate_health()
if((stat < DEAD) && (health <= 0))
death()
/mob/living/simple_mob/slime/promethean/proc/calculate_health()
//Set the max
maxHealth = humanform.getMaxHealth()*2 //HUMANS, and their 'double health', bleh.
//Set us to their health, but, human health ignores robolimbs so we do it 'the hard way'
@@ -121,10 +125,6 @@
human_burn = humanform.getActualFireLoss()
health = maxHealth - humanform.getOxyLoss() - humanform.getToxLoss() - humanform.getCloneLoss() - human_brute - human_burn
//Alive, becoming dead
if((stat < DEAD) && (health <= 0))
death()
//Overhealth
if(health > getMaxHealth())
health = getMaxHealth()

View File

@@ -75,7 +75,7 @@
return INITIALIZE_HINT_QDEL
humanform = H
updatehealth()
calculate_health()
refactory = locate() in humanform.internal_organs
// add_verb(src,/mob/living/proc/ventcrawl) // CHOMPRemove
add_verb(src,/mob/living/proc/usehardsuit)
@@ -207,19 +207,21 @@
return
if(humanform.nano_dead_check(src))
return
calculate_health()
//Alive, becoming dead
if((stat < DEAD) && (health <= 0))
humanform.death()
/mob/living/simple_mob/protean_blob/proc/calculate_health()
//Set the max
maxHealth = humanform.getMaxHealth()*2 //HUMANS, and their 'double health', bleh.
human_brute = humanform.getActualBruteLoss()
human_burn = humanform.getActualFireLoss()
health = maxHealth - humanform.getOxyLoss() - humanform.getToxLoss() - humanform.getCloneLoss() - humanform.getBruteLoss() - humanform.getFireLoss()
//Alive, becoming dead
if((stat < DEAD) && (health <= 0))
humanform.death()
nutrition = humanform.nutrition
//Overhealth
if(health > getMaxHealth())
health = getMaxHealth()

View File

@@ -2,14 +2,14 @@
"am" = (
/obj/random/obstruction,
/obj/effect/decal/cleanable/dirt,
/turf/simulated/floor/wood/broken,
/turf/simulated/floor/wood/broken/turfpack/sif,
/area/submap/FrostOasis)
"bB" = (
/obj/structure/closet/cabinet,
/obj/item/stolenpackage,
/obj/item/stolenpackage,
/obj/item/storage/belt/holding,
/turf/simulated/floor/wood,
/turf/simulated/floor/wood/turfpack/sif,
/area/submap/FrostOasis)
"cm" = (
/obj/effect/decal/cleanable/dirt,
@@ -27,9 +27,7 @@
"fh" = (
/obj/effect/floor_decal/stairs/wood_stairs,
/obj/effect/decal/cleanable/dirt,
/turf/simulated/floor/outdoors/dirt{
outdoors = 0
},
/turf/simulated/floor/wood/turfpack/sif,
/area/submap/FrostOasis)
"fj" = (
/turf/simulated/floor/outdoors/ice,
@@ -51,7 +49,7 @@
/obj/item/flame/candle/candelabra/everburn{
pixel_y = 7
},
/turf/simulated/floor/wood/broken,
/turf/simulated/floor/wood/broken/turfpack/sif,
/area/submap/FrostOasis)
"jN" = (
/mob/living/simple_mob/animal/sif/glitterfly{
@@ -63,7 +61,7 @@
"kr" = (
/obj/item/a_gift,
/obj/effect/decal/cleanable/dirt,
/turf/simulated/floor/wood,
/turf/simulated/floor/wood/turfpack/sif,
/area/submap/FrostOasis)
"ll" = (
/obj/random/obstruction,
@@ -135,7 +133,7 @@
"tv" = (
/obj/item/a_gift,
/obj/effect/decal/cleanable/dirt,
/turf/simulated/floor/wood/broken,
/turf/simulated/floor/wood/broken/turfpack/sif,
/area/submap/FrostOasis)
"tT" = (
/obj/effect/landmark/loot_spawn,
@@ -156,7 +154,7 @@
"vK" = (
/obj/item/a_gift,
/obj/item/clothing/ears/earring/dangle/glass,
/turf/simulated/floor/wood,
/turf/simulated/floor/wood/turfpack/sif,
/area/submap/FrostOasis)
"xI" = (
/turf/simulated/floor/outdoors/dirt{
@@ -168,7 +166,7 @@
/turf/simulated/floor/outdoors/snow,
/area/submap/FrostOasis)
"zI" = (
/turf/simulated/wall/sifwood,
/turf/simulated/wall/sifwood/turfpack/sif,
/area/submap/FrostOasis)
"Aj" = (
/mob/living/simple_mob/animal/sif/savik{
@@ -191,7 +189,7 @@
"EW" = (
/obj/structure/table/standard,
/obj/item/gift,
/turf/simulated/floor/wood/broken,
/turf/simulated/floor/wood/broken/turfpack/sif,
/area/submap/FrostOasis)
"Fl" = (
/obj/structure/curtain/open/bed,
@@ -209,7 +207,7 @@
/obj/structure/window/reinforced/tinted/frosted{
dir = 4
},
/turf/simulated/floor/wood/broken,
/turf/simulated/floor/wood/broken/turfpack/sif,
/area/submap/FrostOasis)
"It" = (
/obj/effect/decal/cleanable/dirt,
@@ -222,7 +220,7 @@
/obj/item/a_gift,
/obj/random/junk,
/obj/effect/decal/cleanable/dirt,
/turf/simulated/floor/wood,
/turf/simulated/floor/wood/turfpack/sif,
/area/submap/FrostOasis)
"Ka" = (
/obj/random/obstruction,
@@ -283,7 +281,7 @@
/obj/structure/table/bench/padded,
/obj/random/junk,
/obj/effect/decal/cleanable/dirt,
/turf/simulated/floor/wood,
/turf/simulated/floor/wood/turfpack/sif,
/area/submap/FrostOasis)
"TD" = (
/obj/structure/flora/tree/winter,
@@ -297,13 +295,11 @@
/area/submap/FrostOasis)
"Vz" = (
/obj/random/obstruction,
/turf/simulated/floor/wood/broken,
/turf/simulated/floor/wood/broken/turfpack/sif,
/area/submap/FrostOasis)
"Wk" = (
/obj/effect/floor_decal/stairs/wood_stairs,
/turf/simulated/floor/outdoors/dirt{
outdoors = 0
},
/turf/simulated/floor/wood/turfpack/sif,
/area/submap/FrostOasis)
"Xf" = (
/obj/effect/decal/cleanable/dirt,
@@ -316,7 +312,7 @@
faction = "diyaab"
},
/obj/effect/decal/cleanable/dirt,
/turf/simulated/floor/wood/broken,
/turf/simulated/floor/wood/broken/turfpack/sif,
/area/submap/FrostOasis)
"ZD" = (
/obj/structure/flora/grass/brown,

View File

@@ -108,7 +108,9 @@
desc = "Dark rock that has been smoothened to be perfectly even. It's coated in a layer of slippey ice"
/turf/unsimulated/floor/outdoors/ice/Entered(var/mob/living/M)
sleep(1 * world.tick_lag)
addtimer(CALLBACK(src, PROC_REF(do_slip), M), (1 * world.tick_lag), TIMER_DELETE_ME)
/turf/unsimulated/floor/outdoors/ice/proc/do_slip(var/mob/living/M)
if(istype(M, /mob/living))
if(M.stunned == 0)
to_chat(M, span_warning("You slide across the ice!"))

View File

@@ -425,6 +425,7 @@
#include "code\controllers\subsystems\planets.dm"
#include "code\controllers\subsystems\plants.dm"
#include "code\controllers\subsystems\player_tips.dm"
#include "code\controllers\subsystems\pois.dm"
#include "code\controllers\subsystems\radiation.dm"
#include "code\controllers\subsystems\reflect_ch.dm"
#include "code\controllers\subsystems\robot_sprites.dm"