mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-29 02:51:41 +00:00
## About The Pull Request This is a follow up patch for #92508, otherwise than said in coderbus, calling the cleanup too early can lead to bad assets. We'll now keep track of the count of assets in generation and only clean up after they all have passed the generation. <img width="3067" height="455" alt="grafik" src="https://github.com/user-attachments/assets/0b65acf3-464f-436c-8a60-84c9472be6cd" /> ## Why It's Good For The Game ## Changelog There should be nothing player facing here as the asset job fails straight up if the cache was cleared too early.
38 lines
1.2 KiB
Plaintext
38 lines
1.2 KiB
Plaintext
/// Allows us to lazyload asset datums
|
|
/// Anything inserted here will fully load if directly gotten
|
|
/// So this just serves to remove the requirement to load assets fully during init
|
|
SUBSYSTEM_DEF(asset_loading)
|
|
name = "Asset Loading"
|
|
priority = FIRE_PRIORITY_ASSETS
|
|
flags = SS_NO_INIT
|
|
runlevels = RUNLEVEL_LOBBY|RUNLEVELS_DEFAULT
|
|
var/list/datum/asset/generate_queue = list()
|
|
var/assets_generating = 0
|
|
var/last_queue_len = 0
|
|
|
|
/datum/controller/subsystem/asset_loading/fire(resumed)
|
|
while(length(generate_queue))
|
|
var/datum/asset/to_load = generate_queue[generate_queue.len]
|
|
|
|
last_queue_len = length(generate_queue)
|
|
generate_queue.len--
|
|
|
|
to_load.queued_generation()
|
|
|
|
if(MC_TICK_CHECK)
|
|
return
|
|
|
|
// We just emptied the queue
|
|
if(last_queue_len && !length(generate_queue) && !assets_generating)
|
|
// Clean up cached icons, freeing memory.
|
|
rustg_iconforge_cleanup()
|
|
|
|
/datum/controller/subsystem/asset_loading/proc/queue_asset(datum/asset/queue)
|
|
#ifdef DO_NOT_DEFER_ASSETS
|
|
stack_trace("We queued an instance of [queue.type] for lateloading despite not allowing it")
|
|
#endif
|
|
generate_queue += queue
|
|
|
|
/datum/controller/subsystem/asset_loading/proc/dequeue_asset(datum/asset/queue)
|
|
generate_queue -= queue
|