[no gbp] Fixes runtimes in shuttle event and shuttle cling (#77343)

Fixes no-candidate runtime from pick() on an empty list
Fixes spawning null movables if run out of mobs to spawn
Fixes shuttle cling qdeling on Initialize due to lattices not counting
as hyperspace

🆑
runtime: Fixes runtimes in shuttle event and shuttle cling code
/🆑

---------

Co-authored-by: Jacquerel <hnevard@gmail.com>
This commit is contained in:
Time-Green
2023-08-07 12:50:04 +01:00
committed by GitHub
co-authored by Jacquerel
parent c7ef171ad7
commit 203aecbf63
8 changed files with 29 additions and 14 deletions
@@ -106,10 +106,12 @@
. = ..()
if(!.)
return FALSE
return
if(!LAZYLEN(spawning_list) && self_destruct_when_empty)
return SHUTTLE_EVENT_CLEAR
if(!LAZYLEN(spawning_list))
if(self_destruct_when_empty)
return SHUTTLE_EVENT_CLEAR
return
if(prob(spawn_probability_per_process))
for(var/i in 1 to spawns_per_spawn)
@@ -9,6 +9,7 @@
spawn_probability_per_process = 20
remove_from_list_when_spawned = TRUE
self_destruct_when_empty = TRUE
/datum/shuttle_event/simple_spawner/carp/post_spawn(mob/living/basic/carp/carpee)
. = ..()
@@ -26,6 +27,7 @@
spawn_probability_per_process = 20
remove_from_list_when_spawned = TRUE
self_destruct_when_empty = TRUE
///Spawn a bunch of friendly carp to view from inside the shuttle! May occassionally pass through and nibble some windows, but are otherwise pretty harmless
/datum/shuttle_event/simple_spawner/carp/friendly
@@ -20,6 +20,7 @@
spawn_probability_per_process = 5
remove_from_list_when_spawned = TRUE
self_destruct_when_empty = TRUE
///Just spawn random maint garbage
/datum/shuttle_event/simple_spawner/maintenance
@@ -15,13 +15,18 @@
else
..()
/// Attempt to grant control of a mob to ghosts before spawning it in. if spawn_anyway_if_no_player = TRUE, we spawn the mob even if there's no ghosts
/datum/shuttle_event/simple_spawner/player_controlled/proc/try_grant_ghost_control(spawn_type)
var/list/candidates = poll_ghost_candidates(ghost_alert_string + " (Warning: you will not be able to return to your body!)", role_type, FALSE, 10 SECONDS)
var/mob/dead/observer/candidate = pick(candidates)
if(candidate || spawn_anyway_if_no_player)
var/mob/living/new_mob = new spawn_type (get_turf(get_spawn_turf()))
if(candidate)
new_mob.ckey = candidate.ckey
if(!candidates.len && !spawn_anyway_if_no_player)
return
var/mob/living/new_mob = new spawn_type (get_turf(get_spawn_turf()))
if(candidates.len)
var/mob/dead/observer/candidate = pick(candidates)
new_mob.ckey = candidate.ckey
post_spawn(new_mob)
///BACK FOR REVENGE!!!
@@ -37,6 +42,7 @@
spawn_anyway_if_no_player = FALSE
ghost_alert_string = "Would you like to be an alien queen shot at the shuttle?"
remove_from_list_when_spawned = TRUE
self_destruct_when_empty = TRUE
role_type = ROLE_ALIEN
@@ -53,6 +59,7 @@
spawn_anyway_if_no_player = TRUE
ghost_alert_string = "Would you like to be a space carp to pester the emergency shuttle?"
remove_from_list_when_spawned = TRUE
self_destruct_when_empty = TRUE
role_type = ROLE_SENTIENCE