Replaces a bunch of mob loops with hopefully better ones

This commit is contained in:
vuonojenmustaturska
2017-11-17 00:08:40 +02:00
committed by CitadelStationBot
parent 0e0eb351b3
commit 6ce69fb2c8
84 changed files with 405 additions and 154 deletions
+1 -1
View File
@@ -566,7 +566,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
set desc= "Take over the body of a mindless creature!"
var/list/possessible = list()
for(var/mob/living/L in GLOB.living_mob_list)
for(var/mob/living/L in GLOB.alive_mob_list)
if(!(L in GLOB.player_list) && !L.mind)
possessible += L
+2 -2
View File
@@ -63,7 +63,7 @@
if(!newbrain.damaged_brain) // the brain organ hasn't been beaten to death.
brainmob.stat = CONSCIOUS //we manually revive the brain mob
GLOB.dead_mob_list -= brainmob
GLOB.living_mob_list += brainmob
GLOB.alive_mob_list += brainmob
brainmob.reset_perspective()
brain = newbrain
@@ -95,7 +95,7 @@
brainmob.stat = DEAD
brainmob.emp_damage = 0
brainmob.reset_perspective() //so the brainmob follows the brain organ instead of the mmi. And to update our vision
GLOB.living_mob_list -= brainmob //Get outta here
GLOB.alive_mob_list -= brainmob //Get outta here
GLOB.dead_mob_list += brainmob
brain.brainmob = brainmob //Set the brain to use the brainmob
brainmob = null //Set mmi brainmob var to null
+1 -1
View File
@@ -126,7 +126,7 @@ GLOBAL_VAR(posibrain_notify_cooldown)
brainmob.mind.assigned_role = new_role
brainmob.stat = CONSCIOUS
GLOB.dead_mob_list -= brainmob
GLOB.living_mob_list += brainmob
GLOB.alive_mob_list += brainmob
visible_message(new_mob_message)
check_success()
@@ -110,11 +110,12 @@ Des: Gives the client of the alien an image on each infected mob.
----------------------------------------*/
/mob/living/carbon/alien/proc/AddInfectionImages()
if (client)
for (var/mob/living/C in GLOB.mob_list)
if(C.status_flags & XENO_HOST)
var/obj/item/organ/body_egg/alien_embryo/A = C.getorgan(/obj/item/organ/body_egg/alien_embryo)
for (var/i in GLOB.mob_living_list)
var/mob/living/L = i
if(L.status_flags & XENO_HOST)
var/obj/item/organ/body_egg/alien_embryo/A = L.getorgan(/obj/item/organ/body_egg/alien_embryo)
if(A)
var/I = image('icons/mob/alien.dmi', loc = C, icon_state = "infected[A.stage]")
var/I = image('icons/mob/alien.dmi', loc = L, icon_state = "infected[A.stage]")
client.images += I
return
@@ -1,3 +1,4 @@
<<<<<<< HEAD
/mob/living/carbon/alien/humanoid/death(gibbed)
if(stat == DEAD)
return
@@ -20,4 +21,28 @@
if(istype(node)) // just in case someone would ever add a diffirent node to hivenode slot
node.queen_death()
=======
/mob/living/carbon/alien/humanoid/death(gibbed)
if(stat == DEAD)
return
. = ..()
update_canmove()
update_icons()
status_flags |= CANPUSH
//When the alien queen dies, all others must pay the price for letting her die.
/mob/living/carbon/alien/humanoid/royal/queen/death(gibbed)
if(stat == DEAD)
return
for(var/mob/living/carbon/C in GLOB.alive_mob_list)
if(C == src) //Make sure not to proc it on ourselves.
continue
var/obj/item/organ/alien/hivenode/node = C.getorgan(/obj/item/organ/alien/hivenode)
if(istype(node)) // just in case someone would ever add a diffirent node to hivenode slot
node.queen_death()
>>>>>>> 39375d5... Replaces a bunch of mob loops with hopefully better ones (#32786)
return ..()
@@ -111,7 +111,7 @@
//For alien evolution/promotion/queen finder procs. Checks for an active alien of that type
/proc/get_alien_type(var/alienpath)
for(var/mob/living/carbon/alien/humanoid/A in GLOB.living_mob_list)
for(var/mob/living/carbon/alien/humanoid/A in GLOB.alive_mob_list)
if(!istype(A, alienpath))
continue
if(!A.key || A.stat == DEAD) //Only living aliens with a ckey are valid.
@@ -46,7 +46,7 @@
/mob/living/carbon/alien/humanoid/royal/queen/Initialize()
//there should only be one queen
for(var/mob/living/carbon/alien/humanoid/royal/queen/Q in GLOB.living_mob_list)
for(var/mob/living/carbon/alien/humanoid/royal/queen/Q in GLOB.carbon_list)
if(Q == src)
continue
if(Q.stat == DEAD)
+5
View File
@@ -4,7 +4,11 @@
/mob/living/carbon/Initialize()
create_reagents(1000)
update_body_parts() //to update the carbon's new bodyparts appearance
<<<<<<< HEAD
..()
=======
GLOB.carbon_list += src
>>>>>>> 39375d5... Replaces a bunch of mob loops with hopefully better ones (#32786)
/mob/living/carbon/Destroy()
//This must be done first, so the mob ghosts correctly before DNA etc is nulled
@@ -16,6 +20,7 @@
QDEL_LIST(implants)
remove_from_all_data_huds()
QDEL_NULL(dna)
GLOB.carbon_list -= src
/mob/living/carbon/relaymove(mob/user, direction)
if(user in src.stomach_contents)
+1 -1
View File
@@ -57,7 +57,7 @@
deadchat_broadcast(rendered, follow_target = src, turf_target = T, message_type=DEADCHAT_DEATHRATTLE)
if(mind)
mind.store_memory("Time of death: [tod]", 0)
GLOB.living_mob_list -= src
GLOB.alive_mob_list -= src
if(!gibbed)
GLOB.dead_mob_list += src
set_drugginess(0)
+3 -1
View File
@@ -16,6 +16,7 @@
var/datum/atom_hud/data/human/medical/advanced/medhud = GLOB.huds[DATA_HUD_MEDICAL_ADVANCED]
medhud.add_to_hud(src)
faction += "[REF(src)]"
GLOB.mob_living_list += src
/mob/living/prepare_huds()
@@ -47,6 +48,7 @@
qdel(I)
staticOverlays.len = 0
remove_from_all_data_huds()
GLOB.mob_living_list -= src
return ..()
@@ -368,7 +370,7 @@
fully_heal(admin_revive)
if(stat == DEAD && can_be_revived()) //in some cases you can't revive (e.g. no brain)
GLOB.dead_mob_list -= src
GLOB.living_mob_list += src
GLOB.alive_mob_list += src
suiciding = 0
stat = UNCONSCIOUS //the mob starts unconscious,
blind_eyes(1)
+3 -3
View File
@@ -404,14 +404,14 @@
if(call_bot_cooldown > world.time)
to_chat(src, "<span class='danger'>Error: Your last call bot command is still processing, please wait for the bot to finish calculating a route.</span>")
return
Bot = locate(href_list["callbot"]) in GLOB.living_mob_list
Bot = locate(href_list["callbot"]) in GLOB.alive_mob_list
if(!Bot || Bot.remote_disabled || src.control_disabled)
return //True if there is no bot found, the bot is manually emagged, or the AI is carded with wireless off.
waypoint_mode = 1
to_chat(src, "<span class='notice'>Set your waypoint by clicking on a valid location free of obstructions.</span>")
return
if(href_list["interface"]) //Remotely connect to a bot!
Bot = locate(href_list["interface"]) in GLOB.living_mob_list
Bot = locate(href_list["interface"]) in GLOB.alive_mob_list
if(!Bot || Bot.remote_disabled || src.control_disabled)
return
Bot.attack_ai(src)
@@ -468,7 +468,7 @@
d += "<A HREF=?src=[REF(src)];botrefresh=1>Query network status</A><br>"
d += "<table width='100%'><tr><td width='40%'><h3>Name</h3></td><td width='30%'><h3>Status</h3></td><td width='30%'><h3>Location</h3></td><td width='10%'><h3>Control</h3></td></tr>"
for (Bot in GLOB.living_mob_list)
for (Bot in GLOB.alive_mob_list)
if(Bot.z == ai_Zlevel && !Bot.remote_disabled) //Only non-emagged bots on the same Z-level are detected!
bot_area = get_area(Bot)
var/bot_mode = Bot.get_mode()
+1 -1
View File
@@ -9,6 +9,6 @@
clear_fullscreens()
//New pAI's get a brand new mind to prevent meta stuff from their previous life. This new mind causes problems down the line if it's not deleted here.
GLOB.living_mob_list -= src
GLOB.alive_mob_list -= src
ghostize()
qdel(src)
@@ -172,7 +172,7 @@
if(mmi.brainmob.stat == DEAD)
mmi.brainmob.stat = CONSCIOUS
GLOB.dead_mob_list -= mmi.brainmob
GLOB.living_mob_list += mmi.brainmob
GLOB.alive_mob_list += mmi.brainmob
mind.transfer_to(mmi.brainmob)
mmi.update_icon()
else
@@ -18,17 +18,19 @@
//Base proc for anything to call
/proc/_alert_drones(msg, dead_can_hear = 0, atom/source, mob/living/faction_checked_mob, exact_faction_match)
for(var/W in GLOB.mob_list)
var/mob/living/simple_animal/drone/M = W
if(istype(M) && M.stat != DEAD)
if(faction_checked_mob)
if(M.faction_check_mob(faction_checked_mob, exact_faction_match))
to_chat(M, msg)
else
to_chat(M, msg)
if(dead_can_hear && source && (M in GLOB.dead_mob_list))
if (dead_can_hear && source)
for (var/mob/M in GLOB.dead_mob_list)
var/link = FOLLOW_LINK(M, source)
to_chat(M, "[link] [msg]")
for(var/i in GLOB.drones_list)
var/mob/living/simple_animal/drone/D = i
if(istype(D) && D.stat != DEAD)
if(faction_checked_mob)
if(D.faction_check_mob(faction_checked_mob, exact_faction_match))
to_chat(D, msg)
else
to_chat(D, msg)
//Wrapper for drones to handle factions
@@ -150,7 +150,8 @@
staticOverlays.len = 0
if(seeStatic)
for(var/mob/living/L in GLOB.mob_list)
for(var/i in GLOB.mob_living_list)
var/mob/living/L = i
if(isdrone(L))
continue
var/image/chosen
@@ -106,7 +106,7 @@ Difficulty: Hard
/mob/living/simple_animal/hostile/megafauna/bubblegum/Initialize()
. = ..()
for(var/mob/living/simple_animal/hostile/megafauna/bubblegum/B in GLOB.mob_list)
for(var/mob/living/simple_animal/hostile/megafauna/bubblegum/B in GLOB.mob_living_list)
if(B != src)
return INITIALIZE_HINT_QDEL //There can be only one
var/obj/effect/proc_holder/spell/bloodcrawl/bloodspell = new
@@ -129,7 +129,7 @@ Difficulty: Medium
visible_message("<span class='boldannounce'>[src] splits in twain!</span>")
else
var/last_legion = TRUE
for(var/mob/living/simple_animal/hostile/megafauna/legion/other in GLOB.mob_list)
for(var/mob/living/simple_animal/hostile/megafauna/legion/other in GLOB.mob_living_list)
if(other != src)
last_legion = FALSE
break
@@ -50,7 +50,7 @@
#define MEDAL_PREFIX "Tendril"
/mob/living/simple_animal/hostile/spawner/lavaland/death()
var/last_tendril = TRUE
for(var/mob/living/simple_animal/hostile/spawner/lavaland/other in GLOB.mob_list)
for(var/mob/living/simple_animal/hostile/spawner/lavaland/other in GLOB.mob_living_list)
if(other != src)
last_tendril = FALSE
break
@@ -185,7 +185,7 @@
range = 10
/obj/effect/proc_holder/spell/aoe_turf/blindness/cast(list/targets,mob/user = usr)
for(var/mob/living/L in GLOB.living_mob_list)
for(var/mob/living/L in GLOB.alive_mob_list)
var/turf/T = get_turf(L.loc)
if(T && T in targets)
L.blind_eyes(4)
+4 -4
View File
@@ -4,7 +4,7 @@
/mob/Destroy()//This makes sure that mobs with clients/keys are not just deleted from the game.
GLOB.mob_list -= src
GLOB.dead_mob_list -= src
GLOB.living_mob_list -= src
GLOB.alive_mob_list -= src
GLOB.all_clockwork_mobs -= src
GLOB.mob_directory -= tag
for (var/alert in alerts)
@@ -29,7 +29,7 @@
if(stat == DEAD)
GLOB.dead_mob_list += src
else
GLOB.living_mob_list += src
GLOB.alive_mob_list += src
prepare_huds()
for(var/v in GLOB.active_alternate_appearances)
if(!v)
@@ -926,9 +926,9 @@
if("stat")
if((stat == DEAD) && (var_value < DEAD))//Bringing the dead back to life
GLOB.dead_mob_list -= src
GLOB.living_mob_list += src
GLOB.alive_mob_list += src
if((stat < DEAD) && (var_value == DEAD))//Kill he
GLOB.living_mob_list -= src
GLOB.alive_mob_list -= src
GLOB.dead_mob_list += src
. = ..()
switch(var_name)
+2 -1
View File
@@ -274,7 +274,8 @@ It's fairly easy to fix if dealing with single letters but not so much with comp
/proc/findname(msg)
if(!istext(msg))
msg = "[msg]"
for(var/mob/M in GLOB.mob_list)
for(var/i in GLOB.mob_list)
var/mob/M = i
if(M.real_name == msg)
return M
return 0