Files
Bubberstation/code/modules/paperwork/handlabeler.dm
MrPerson 9eee3e5067 First pass at a qdel() garbage collection system for tgstation
Works pretty well. If it can't GC something, it'll just del() it and be done.
Speed is amazing, holy shit.

New procs you should be aware of:
qdel(atom/movable) - sets up an object for garbage collection. Call this rather than del(atom/movable).
atom/movable/Destroy() - called right before the object is GC'd, so it still has a loc. Also called if the object is del()'d.
new controller - garbage.dm has all the details on this. Basically it nulls all references on GC'd objects and force del() them if necessary.
Generally speaking, objects should use Destroy() for behavior prior to deletion rather than Del(). You should also always call the parent so the object gets the right gc_destroyed var set.

ISSUES:
Tries to GC mobs atm. This actually works for new players, not so much for humans/monkies/simple_animals/anything. I'm guessing it needs to clear out their mind and HUD and maybe other things.
Gibbing is really bugged. It works, but the overlays just sit there for awhile and ugh. I'm very tempted just to del() mob/living and mob/camera and call it a day.
qdel() equipment doesn't unequip the item.
Pipes don't generally GC correctly. Debugging suggests they get referenced in many pipenets and that isn't cleared properly. However some do work fine. Need assistance here.
Bots don't GC, probably in the radio controller.
Lots of other shit doesn't GC but it's hard to find them because of the pipe spam.
I think I'm calling Destroy() twice by accident.
2014-02-23 14:55:12 -08:00

70 lines
2.2 KiB
Plaintext

/obj/item/weapon/hand_labeler
name = "hand labeler"
icon = 'icons/obj/bureaucracy.dmi'
icon_state = "labeler0"
item_state = "flight"
var/label = null
var/labels_left = 30
var/mode = 0
/obj/item/weapon/hand_labeler/afterattack(atom/A, mob/user,proximity)
if(!proximity) return
if(!mode) //if it's off, give up.
return
if(A == loc) // if placing the labeller into something (e.g. backpack)
return // don't set a label
if(!labels_left)
user << "<span class='notice'>No labels left.</span>"
return
if(!label || !length(label))
user << "<span class='notice'>No text set.</span>"
return
if(length(A.name) + length(label) > 64)
user << "<span class='notice'>Label too big.</span>"
return
if(ishuman(A))
user << "<span class='notice'>You can't label humans.</span>"
return
if(issilicon(A))
user << "<span class='notice'>You can't label cyborgs.</span>"
return
user.visible_message("<span class='notice'>[user] labels [A] as [label].</span>", \
"<span class='notice'>You label [A] as [label].</span>")
A.name = "[A.name] ([label])"
labels_left--
/obj/item/weapon/hand_labeler/attack_self(mob/user)
mode = !mode
icon_state = "labeler[mode]"
if(mode)
user << "<span class='notice'>You turn on [src].</span>"
//Now let them chose the text.
var/str = copytext(reject_bad_text(input(user,"Label text?","Set label","")),1,MAX_NAME_LEN)
if(!str || !length(str))
user << "<span class='notice'>Invalid text.</span>"
return
label = str
user << "<span class='notice'>You set the text to '[str]'.</span>"
else
user << "<span class='notice'>You turn off [src].</span>"
/obj/item/weapon/hand_labeler/attackby(obj/item/I as obj, mob/user as mob)
..()
if(istype(I, /obj/item/hand_labeler_refill))
user << "<span class='notice'>You insert [I] into [src].</span>"
user.drop_item()
qdel(I)
labels_left = initial(labels_left)
return
/obj/item/hand_labeler_refill
name = "hand labeler paper roll"
icon = 'icons/obj/bureaucracy.dmi'
desc = "A roll of paper. Use it on a hand labeler to refill it."
icon_state = "labeler_refill"
item_state = "electropack"
w_class = 1.0