From say code import, we get to learn one proc.

This commit is contained in:
eswordthecat
2015-04-04 23:16:44 +08:00
parent 666b16b242
commit 39a3bca274
4 changed files with 56 additions and 30 deletions

View File

@@ -130,19 +130,39 @@
//This is the new version of recursive_mob_check, used for say().
//The other proc was left intact because morgue trays use it.
/proc/recursive_hear_check(var/atom/O)
/proc/recursive_hear_check(atom/O)
var/list/processing_list = list(O)
var/list/processed_list = list()
var/list/found_atoms = list()
while(processing_list.len)
while (processing_list.len)
var/atom/A = processing_list[1]
if(A.flags & HEAR)
if (A.flags & HEAR)
found_atoms |= A
for(var/atom/B in A)
if(!processed_list[B])
for (var/atom/B in A)
if (!processed_list[B])
processing_list |= B
processing_list.Cut(1, 2)
processed_list[A] = A
return found_atoms
/proc/recursive_type_check(atom/O, type = /atom)
var/list/processing_list = list(O)
var/list/processed_list = new/list()
var/list/found_atoms = new/list()
while (processing_list.len)
var/atom/A = processing_list[1]
if (istype(A, type))
found_atoms |= A
for (var/atom/B in A)
if (!processed_list[B])
processing_list |= B
processing_list.Cut(1, 2)

View File

@@ -328,9 +328,16 @@ var/bomb_set
return
return
/obj/item/weapon/disk/nuclear/Destroy()
/obj/item/weapon/disk/nuclear/Del()
if(blobstart.len > 0)
var/obj/D = new /obj/item/weapon/disk/nuclear(pick(blobstart))
message_admins("[src] has been destroyed. Spawning [D] at ([D.x], [D.y], [D.z]).")
log_game("[src] has been destroyed. Spawning [D] at ([D.x], [D.y], [D.z]).")
var/picked_location = pick(blobstart)
var/log_message = "[type] has been destroyed. Creating one at [formatJumpTo(picked_location)]"
message_admins(log_message)
log_game(log_message)
new /obj/item/weapon/disk/nuclear(picked_location)
..()

View File

@@ -310,9 +310,9 @@
return
else
var/inside = src.search_contents_for(/atom)
if(is_type_in_list(/obj/item/weapon/disk/nuclear, inside))
usr << "You get the feeling that you shouldn't cremate one of the items in the cremator."
var/inside = recursive_type_check(src, /atom/movable) - src
if (locate(/obj/item/weapon/disk/nuclear) in inside)
return
for (var/mob/M in viewers(src))
@@ -321,7 +321,7 @@
cremating = 1
locked = 1
for(var/mob/living/M in inside)
for (var/mob/living/M in inside)
if (M.stat!=2)
M.emote("scream",,, 1)
//Logging for this causes runtimes resulting in the cremator locking up. Commenting it out until that's figured out.
@@ -332,8 +332,10 @@
M.ghostize()
del(M)
for(var/obj/O in inside) //obj instead of obj/item so that bodybags and ashes get destroyed. We dont want tons and tons of ash piling up
del(O)
for (var/obj/O in inside) //obj instead of obj/item so that bodybags and ashes get destroyed. We dont want tons and tons of ash piling up
qdel(O)
inside = null
new /obj/effect/decal/cleanable/ash(src)
sleep(30)
@@ -393,12 +395,10 @@
return
/obj/machinery/crema_switch/attack_hand(mob/user as mob)
if(src.allowed(usr))
if (allowed(user))
for (var/obj/structure/crematorium/C in world)
if (C.id == id)
if (!C.cremating)
C.cremate(user)
C.cremate(user)
else
usr << "\red Access denied."
user << "<SPAN CLASS='alert'>Access denied.</SPAN>"
return

View File

@@ -52,16 +52,14 @@
qdel(A)
return
if(istype(A, /obj/item/weapon/disk/nuclear)) // Don't let nuke disks travel Z levels ... And moving this shit down here so it only fires when they're actually trying to change z-level.
del(A) //The disk's Destroy() proc ensures a new one is created
return
var/disks_list = recursive_type_check(A, /obj/item/weapon/disk/nuclear)
var/list/disk_search = A.search_contents_for(/obj/item/weapon/disk/nuclear)
if(istype(A, /obj/structure/stool/bed/chair/vehicle))
var/obj/structure/stool/bed/chair/vehicle/B = A
if(B.buckled_mob)
disk_search = B.buckled_mob.search_contents_for(/obj/item/weapon/disk/nuclear)
if(!isemptylist(disk_search))
disks_list = recursive_type_check(B.buckled_mob, /obj/item/weapon/disk/nuclear)
if (length(disks_list))
if(istype(A, /mob/living))
var/mob/living/MM = A
if(MM.client && !MM.stat)
@@ -75,11 +73,12 @@
else if(MM.y >= world.maxy -TRANSITIONEDGE)
MM.inertia_dir = 2
else
for(var/obj/item/weapon/disk/nuclear/N in disk_search)
del(N)//Make the disk respawn it is on a clientless mob or corpse
for (var/obj/item/weapon/disk/nuclear/N in disks_list)
qdel(N) // make the disk respawn if it is floating on its own.
else
for(var/obj/item/weapon/disk/nuclear/N in disk_search)
del(N)//Make the disk respawn if it is floating on its own
for (var/obj/item/weapon/disk/nuclear/N in disks_list)
qdel(N) // make the disk respawn if it is floating on its own.
return
//Check if it's a mob pulling an object