BeeStation-Hornet
BeeStation-Hornet copied to clipboard
Removes some major sleepers (100% lag free)
Thanks to TheFinalPotato from coderbus for helping diagnose this issue.
Downstream Notice: Breaking changes
This PR changes the way that /datum/map_template are loaded.
Previously, map_templates would have their completion awaited for, however now the loading operates on a subsystem, meaning .load() will no longer freeze the current proc until loading is completed. /datum/parsed_map (Used for loading the station at roundstart and loading z-levels) is not affected by this and will run using CHECK_TICK (This is fine for roundstart, but shouldn't be used during a round). All instances of /proc/load from /datum/map_template and subtypes need to be checked to ensure that any code after .load() doesn't depend on the results of .load. Any code that needs to be run after the completion of the map load need to use the completion callbacks.
Completion Callbacks:
If you are calling /datum/map_template.load() from somewhere else: Map template load returns the map generator being used to generate the map, you can use .on_completion to register a completion callback which will be called after the map successfully loads.
If you are calling /datum/map_generator.generate(), then you can register completion callbacks using the .on_completion() proc to register as many completion procs as you want.
Old code:
ship.load(T)
message_admins("Ship loaded")
New code:
/datum/whatever/proc/load_ship(turf/T)
var/datum/map_generator/ship_placer = ship.load(T)
ship_placer.on_completion(CALLBACK(src, .proc/on_ship_loaded))
/datum/whatever/proc/on_ship_loaded(datum/map_generator/map_gen, turf/T, init_atmos, datum/parsed_map/parsed, register = TRUE)
message_admins("Ship loaded")
If you want, you can probably make the code closer to /TG/ by just using UNTIL and waiting until the generation is completed, however its a somewhat janky solution and won't be able to utilize all of the subsystem for concurrent loading.
About The Pull Request
Removes some major sleepers that could result in the MC freezing up (Sleeping procs may wake up before the MC, leading to the MC's maptick being consumed before the MC has a chance to fire).
Why It's Good For The Game
Sleeping inside some extremely long function, or something that loops can cause the sleeps to wake up before the MC, meaning the MCs maptick is consumed before it even has a chance to fire, leading to the MC freezing up and everything going to shit.
Testing Photographs and Procedure
Round > Trigger Event > Catastrophic Meteors Watch as meteors approach the station and blow shit up. Some systems will queue up, however the MC will still run and that list will slowly get shorter and shorter. The MC no longer freezes during meteors as a result of airlocks losing power.
Ruin Generation: Harder to test this one since it never happened locally anyway. Just try it on the server and hope for the best. Of course I tested to make sure the ruins generate properly. I'm going to TM this anyway.
I've tested every form of map place that is affected, except for fugatives since it requires players to trigger the event.
Changelog
:cl: PowerfulBacon, TheFinalPotato fix: Removes a sleep loop from airlocks fix: Makes ruin generation a subsystem process rather than using CHECK_TICK, so that its execution flow can be managed by the MC rather than byond. /:cl:
next up: Ruin generation
You are the Syndicate Sleeper Agent
Your job is to lag the MC, as much as possible. Spend as much time sleeping as physically possible.
Your PDA has been embedded with a remote uplink to retrieve items useful to your objectives. Enter the code Charlie 204 as your ringtone to unlock it.
code/game/machinery/doors/airlock.dm, line 501, column 3:
error: undefined field: "proc" on /obj/machinery/door/airlock
code/game/machinery/doors/airlock.dm, line 501, column 3:
error: undefined var: "restorePower"
RIP
I'm not done yet, I still got generators to refactor
This is going to need a pretty major rework to map loading, since the map loader checks tick a bunch and will probably need its own subsystem for running while the game isn't loading. Will continue tomorrow
A side note is that this will increase the speed of ruin generation since all rooms can be generated at the same time rather than one after the other
This pull request has conflicts, please resolve those before we can evaluate the pull request.
Random ruins can spawn inside each other due to the async nature of loading only blocking off ruins at the end.
It seems like the asteroid station can run before map place completes, making the areas have invalid lighting
This breaks the fuck out of the holodeck
It doesn't use the callbacks
The issue with preview shuttles not working has been fixed. Passing async references around is honestly not the most ideal solution and SSshuttle is a little messy but it works.
It does use the callbacks in the holodeck, I think its runtiming. Let me have a look and get this fixed
Im so dumb, finish_spawning calls itself
I had a report that the backup shuttle was sent, however haven't been provided with the round ID. I assume its an issue with either admin shuttle spawning, or purchasing shuttles (or both).
epic
This pull request has conflicts, please resolve those before we can evaluate the pull request.
Fuck this imma just copy and paste the map