mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 20:48:56 +01:00
Merge pull request #20702 from TheCarlSaganExpress/sagan_branch
Fixed a runtime error when eating a crayon.
This commit is contained in:
@@ -129,15 +129,15 @@
|
||||
/obj/item/toy/crayon/proc/check_empty(mob/user)
|
||||
// When eating a crayon, check_empty() can be called twice producing
|
||||
// two messages unless we check for being deleted first
|
||||
if(!qdeleted(src))
|
||||
. = TRUE
|
||||
if(qdeleted(src))
|
||||
return TRUE
|
||||
|
||||
. = FALSE
|
||||
// -1 is unlimited charges
|
||||
if(charges == -1)
|
||||
. = FALSE
|
||||
else if(!charges_left)
|
||||
user << "<span class='warning'>There is no more of [src.name] \
|
||||
user << "<span class='warning'>There is no more of \the [src.name] \
|
||||
left!</span>"
|
||||
if(self_contained)
|
||||
qdel(src)
|
||||
@@ -380,6 +380,8 @@
|
||||
if(edible && (M == user))
|
||||
user << "You take a bite of the [src.name]. Delicious!"
|
||||
var/eaten = use_charges(5)
|
||||
if(check_empty(user)) //Prevents divsion by zero
|
||||
return
|
||||
var/fraction = min(eaten / reagents.total_volume, 1)
|
||||
reagents.reaction(M, INGEST, fraction * volume_multiplier)
|
||||
reagents.trans_to(M, eaten, volume_multiplier)
|
||||
|
||||
Reference in New Issue
Block a user