mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 05:00:55 +01:00
Fixed some possible runtimes with pollCandidates() (#19919)
* Fixed some possible runtimes with pollCandidates() * Fixed bug in pollCandidatesForMobs()
This commit is contained in:
@@ -442,6 +442,22 @@
|
||||
|
||||
return candidates
|
||||
|
||||
/proc/pollCandidatesForMob(Question, jobbanType, datum/game_mode/gametypeCheck, be_special_flag = 0, poll_time = 300, mob/M)
|
||||
var/list/L = pollCandidates(Question, jobbanType, gametypeCheck, be_special_flag, poll_time)
|
||||
if(!M || qdeleted(M))
|
||||
return list()
|
||||
return L
|
||||
|
||||
/proc/pollCandidatesForMobs(Question, jobbanType, datum/game_mode/gametypeCheck, be_special_flag = 0, poll_time = 300, list/mobs)
|
||||
var/list/L = pollCandidates(Question, jobbanType, gametypeCheck, be_special_flag, poll_time)
|
||||
var/i=1
|
||||
for(var/v in mobs)
|
||||
if(!v || qdeleted(v))
|
||||
mobs.Cut(i,i+1)
|
||||
else
|
||||
++i
|
||||
return L
|
||||
|
||||
/proc/makeBody(mob/dead/observer/G_found) // Uses stripped down and bastardized code from respawn character
|
||||
if(!G_found || !G_found.key)
|
||||
return
|
||||
|
||||
@@ -166,7 +166,7 @@
|
||||
blobber.notransform = 1 //stop the naut from moving around
|
||||
blobber.adjustHealth(blobber.maxHealth * 0.5)
|
||||
blob_mobs += blobber
|
||||
var/list/mob/dead/observer/candidates = pollCandidates("Do you want to play as a [blob_reagent_datum.name] blobbernaut?", ROLE_BLOB, null, ROLE_BLOB, 50) //players must answer rapidly
|
||||
var/list/mob/dead/observer/candidates = pollCandidatesForMob("Do you want to play as a [blob_reagent_datum.name] blobbernaut?", ROLE_BLOB, null, ROLE_BLOB, 50, blobber) //players must answer rapidly
|
||||
if(candidates.len) //if we got at least one candidate, they're a blobbernaut now.
|
||||
var/client/C = pick(candidates)
|
||||
blobber.notransform = 0
|
||||
|
||||
@@ -517,7 +517,7 @@
|
||||
return max(0, enemy_minimum_age - C.player_age)
|
||||
|
||||
/datum/game_mode/proc/replace_jobbaned_player(mob/living/M, role_type, pref)
|
||||
var/list/mob/dead/observer/candidates = pollCandidates("Do you want to play as a [role_type]?", "[role_type]", null, pref, 100)
|
||||
var/list/mob/dead/observer/candidates = pollCandidatesForMob("Do you want to play as a [role_type]?", "[role_type]", null, pref, 100, M)
|
||||
var/mob/dead/observer/theghost = null
|
||||
if(candidates.len)
|
||||
theghost = pick(candidates)
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
bodies += M
|
||||
|
||||
var/question = "Would you like to be [group_name]?"
|
||||
var/list/candidates = pollCandidates(question, "pAI", null, FALSE, 100)
|
||||
var/list/candidates = pollCandidatesForMobs(question, "pAI", null, FALSE, 100, bodies)
|
||||
while(candidates.len && bodies.len)
|
||||
var/mob/dead/observer/ghost = pick_n_take(candidates)
|
||||
var/mob/living/body = pick_n_take(bodies)
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
if(!current_wizard)
|
||||
return
|
||||
spawn(0)
|
||||
var/list/mob/dead/observer/candidates = pollCandidates("Do you want to play as Wizard Academy Defender?", "wizard", null, ROLE_WIZARD)
|
||||
var/list/mob/dead/observer/candidates = pollCandidatesForMob("Do you want to play as Wizard Academy Defender?", "wizard", null, ROLE_WIZARD, current_wizard)
|
||||
var/mob/dead/observer/chosen = null
|
||||
|
||||
if(candidates.len)
|
||||
@@ -266,7 +266,7 @@
|
||||
servant_mind.objectives += O
|
||||
servant_mind.transfer_to(H)
|
||||
|
||||
var/list/mob/dead/observer/candidates = pollCandidates("Do you want to play as [user.real_name] Servant?", "wizard")
|
||||
var/list/mob/dead/observer/candidates = pollCandidatesForMob("Do you want to play as [user.real_name] Servant?", "wizard", mob = H)
|
||||
var/mob/dead/observer/chosen = null
|
||||
|
||||
if(candidates.len)
|
||||
|
||||
@@ -453,7 +453,7 @@ It's fairly easy to fix if dealing with single letters but not so much with comp
|
||||
poll_message = "[poll_message] Job:[M.mind.assigned_role]."
|
||||
if(M.mind && M.mind.special_role)
|
||||
poll_message = "[poll_message] Status:[M.mind.special_role]."
|
||||
var/list/mob/dead/observer/candidates = pollCandidates(poll_message, "pAI", null, FALSE, 100)
|
||||
var/list/mob/dead/observer/candidates = pollCandidatesForMob(poll_message, "pAI", null, FALSE, 100, M)
|
||||
var/mob/dead/observer/theghost = null
|
||||
|
||||
if(candidates.len)
|
||||
|
||||
@@ -184,7 +184,7 @@
|
||||
user << "<span class='notice'>You offer the sentience potion to [SM]...</span>"
|
||||
being_used = 1
|
||||
|
||||
var/list/mob/dead/observer/candidates = pollCandidates("Do you want to play as [SM.name]?", ROLE_ALIEN, null, ROLE_ALIEN, 50, POLL_IGNORE_SENTIENCE_POTION) // see poll_ignore.dm
|
||||
var/list/mob/dead/observer/candidates = pollCandidatesForMob("Do you want to play as [SM.name]?", ROLE_ALIEN, null, ROLE_ALIEN, 50, POLL_IGNORE_SENTIENCE_POTION, SM) // see poll_ignore.dm
|
||||
var/mob/dead/observer/theghost = null
|
||||
if(candidates.len)
|
||||
theghost = pick(candidates)
|
||||
|
||||
Reference in New Issue
Block a user