mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-11 10:11:09 +00:00
[MIRROR] Ensures early assets init when expected during unit tests, [MDB IGNORE] (#17259)
* Ensures early assets init when expected during unit tests, (#70753) Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com> * Ensures early assets init when expected during unit tests, Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: Mothblocks <35135081+Mothblocks@ users.noreply.github.com>
This commit is contained in:
@@ -49,6 +49,8 @@
|
||||
#define GC_FAILURE_HARD_LOOKUP
|
||||
#endif // REFERENCE_DOING_IT_LIVE
|
||||
|
||||
// If defined, we will NOT defer asset generation till later in the game, and will instead do it all at once, during initiialize
|
||||
//#define DO_NOT_DEFER_ASSETS
|
||||
//#define UNIT_TESTS //If this is uncommented, we do a single run though of the game setup and tear down process with unit tests in between
|
||||
|
||||
/// If this is uncommented, Autowiki will generate edits and shut down the server.
|
||||
@@ -116,6 +118,8 @@
|
||||
#define REFERENCE_TRACKING_DEBUG
|
||||
#define FIND_REF_NO_CHECK_TICK
|
||||
#define GC_FAILURE_HARD_LOOKUP
|
||||
//Ensures all early assets can actually load early
|
||||
#define DO_NOT_DEFER_ASSETS
|
||||
#endif
|
||||
|
||||
#ifdef TGS
|
||||
|
||||
@@ -17,3 +17,12 @@ SUBSYSTEM_DEF(asset_loading)
|
||||
if(MC_TICK_CHECK)
|
||||
return
|
||||
generate_queue.len--
|
||||
|
||||
/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
|
||||
|
||||
@@ -139,6 +139,14 @@ GLOBAL_LIST_EMPTY(asset_datums)
|
||||
/// Defaults to false so we can process this stuff nicely
|
||||
var/load_immediately = FALSE
|
||||
|
||||
/datum/asset/spritesheet/proc/should_load_immediately()
|
||||
#ifdef DO_NOT_DEFER_ASSETS
|
||||
return TRUE
|
||||
#else
|
||||
return load_immediately
|
||||
#endif
|
||||
|
||||
|
||||
/datum/asset/spritesheet/should_refresh()
|
||||
if (..())
|
||||
return TRUE
|
||||
@@ -167,10 +175,10 @@ GLOBAL_LIST_EMPTY(asset_datums)
|
||||
load_immediately = TRUE
|
||||
|
||||
create_spritesheets()
|
||||
if(load_immediately)
|
||||
if(should_load_immediately())
|
||||
realize_spritesheets(yield = FALSE)
|
||||
else
|
||||
SSasset_loading.generate_queue += src
|
||||
SSasset_loading.queue_asset(src)
|
||||
|
||||
/datum/asset/spritesheet/proc/realize_spritesheets(yield)
|
||||
if(fully_generated)
|
||||
@@ -197,7 +205,7 @@ GLOBAL_LIST_EMPTY(asset_datums)
|
||||
write_to_cache()
|
||||
fully_generated = TRUE
|
||||
// If we were ever in there, remove ourselves
|
||||
SSasset_loading.generate_queue -= src
|
||||
SSasset_loading.dequeue_asset(src)
|
||||
|
||||
/datum/asset/spritesheet/queued_generation()
|
||||
realize_spritesheets(yield = TRUE)
|
||||
@@ -328,7 +336,7 @@ GLOBAL_LIST_EMPTY(asset_datums)
|
||||
CRASH("create_spritesheets() not implemented for [type]!")
|
||||
|
||||
/datum/asset/spritesheet/proc/Insert(sprite_name, icon/I, icon_state="", dir=SOUTH, frame=1, moving=FALSE)
|
||||
if(load_immediately)
|
||||
if(should_load_immediately())
|
||||
queuedInsert(sprite_name, I, icon_state, dir, frame, moving)
|
||||
else
|
||||
to_generate += list(args.Copy())
|
||||
|
||||
Reference in New Issue
Block a user