From 317958fb5ccf9503d8f8fb7db71ff04652b0eabb Mon Sep 17 00:00:00 2001 From: AnturK Date: Sun, 10 Sep 2017 02:40:23 +0200 Subject: [PATCH] Fixes more CanPass misuse (#30493) * Fixes more CanPass misuse * Let's not give wrong impression * spans --- code/game/atoms_movable.dm | 2 +- code/modules/holodeck/items.dm | 16 ++++++------ code/modules/recycling/disposal-unit.dm | 30 +++++++++++----------- code/modules/shuttle/special.dm | 33 ++++++++++++++++++------- 4 files changed, 46 insertions(+), 35 deletions(-) diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index f4cbcda098..38c815ee43 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -215,7 +215,7 @@ //to differentiate it, naturally everyone forgot about this immediately and so some things //would bump twice, so now it's called Collide /atom/movable/proc/Collide(atom/A) - if((A)) + if(A) if(throwing) throwing.hit_atom(A) . = 1 diff --git a/code/modules/holodeck/items.dm b/code/modules/holodeck/items.dm index 8dfbfa7c63..86481b4c14 100644 --- a/code/modules/holodeck/items.dm +++ b/code/modules/holodeck/items.dm @@ -120,17 +120,15 @@ else ..() -/obj/structure/holohoop/CanPass(atom/movable/mover, turf/target) - if (isitem(mover) && mover.throwing) - var/obj/item/I = mover - if(istype(I, /obj/item/projectile)) - return +/obj/structure/holohoop/hitby(atom/movable/AM) + if (isitem(AM) && !istype(AM,/obj/item/projectile)) if(prob(50)) - I.forceMove(get_turf(src)) - visible_message("Swish! [I] lands in [src].") + AM.forceMove(get_turf(src)) + visible_message("Swish! [AM] lands in [src].") + return else - visible_message("[I] bounces off of [src]'s rim!") - return 0 + visible_message("[AM] bounces off of [src]'s rim!") + return ..() else return ..() diff --git a/code/modules/recycling/disposal-unit.dm b/code/modules/recycling/disposal-unit.dm index 14ebec8128..04207a8e09 100644 --- a/code/modules/recycling/disposal-unit.dm +++ b/code/modules/recycling/disposal-unit.dm @@ -335,20 +335,18 @@ eject() . = TRUE -/obj/machinery/disposal/bin/CanPass(atom/movable/mover, turf/target) - if (isitem(mover) && mover.throwing) - var/obj/item/I = mover - if(istype(I, /obj/item/projectile)) - return + +/obj/machinery/disposal/bin/hitby(atom/movable/AM) + if(isitem(AM) && AM.CanEnterDisposals()) if(prob(75)) - I.forceMove(src) - visible_message("[I] lands in [src].") + AM.forceMove(src) + visible_message("[AM] lands in [src].") update_icon() else - visible_message("[I] bounces off of [src]'s rim!") - return 0 + visible_message("[AM] bounces off of [src]'s rim!") + return ..() else - return ..(mover, target) + return ..() /obj/machinery/disposal/bin/flush() ..() @@ -457,12 +455,12 @@ trunk.linked = src // link the pipe trunk to self /obj/machinery/disposal/deliveryChute/place_item_in_disposal(obj/item/I, mob/user) - if(I.disposalEnterTry()) + if(I.CanEnterDisposals()) ..() flush() /obj/machinery/disposal/deliveryChute/CollidedWith(atom/movable/AM) //Go straight into the chute - if(!AM.disposalEnterTry()) + if(!AM.CanEnterDisposals()) return switch(dir) if(NORTH) @@ -485,16 +483,16 @@ M.forceMove(src) flush() -/atom/movable/proc/disposalEnterTry() +/atom/movable/proc/CanEnterDisposals() return 1 -/obj/item/projectile/disposalEnterTry() +/obj/item/projectile/CanEnterDisposals() return -/obj/effect/disposalEnterTry() +/obj/effect/CanEnterDisposals() return -/obj/mecha/disposalEnterTry() +/obj/mecha/CanEnterDisposals() return /obj/machinery/disposal/deliveryChute/newHolderDestination(obj/structure/disposalholder/H) diff --git a/code/modules/shuttle/special.dm b/code/modules/shuttle/special.dm index 6a972bff9b..0373ea5b53 100644 --- a/code/modules/shuttle/special.dm +++ b/code/modules/shuttle/special.dm @@ -215,23 +215,37 @@ /obj/effect/forcefield/luxury_shuttle var/threshold = 500 var/static/list/approved_passengers = list() + var/static/list/check_times = list() /obj/effect/forcefield/luxury_shuttle/CanPass(atom/movable/mover, turf/target) if(mover in approved_passengers) - return 1 + return TRUE if(!isliving(mover)) //No stowaways - return 0 + return FALSE + + return FALSE + + +#define LUXURY_MESSAGE_COOLDOWN 100 +/obj/effect/forcefield/luxury_shuttle/CollidedWith(atom/movable/AM) + if(!isliving(AM)) + return ..() + + if(check_times[AM] && check_times[AM] > world.time) //Let's not spam the message + return ..() + + check_times[AM] = world.time + LUXURY_MESSAGE_COOLDOWN var/total_cash = 0 var/list/counted_money = list() - for(var/obj/item/coin/C in mover.GetAllContents()) + for(var/obj/item/coin/C in AM.GetAllContents()) total_cash += C.value counted_money += C if(total_cash >= threshold) break - for(var/obj/item/stack/spacecash/S in mover.GetAllContents()) + for(var/obj/item/stack/spacecash/S in AM.GetAllContents()) total_cash += S.value * S.amount counted_money += S if(total_cash >= threshold) @@ -241,12 +255,13 @@ for(var/obj/I in counted_money) qdel(I) - to_chat(mover, "Thank you for your payment! Please enjoy your flight.") - approved_passengers += mover - return 1 + to_chat(AM, "Thank you for your payment! Please enjoy your flight.") + approved_passengers += AM + check_times -= AM + return else - to_chat(mover, "You don't have enough money to enter the main shuttle. You'll have to fly coach.") - return 0 + to_chat(AM, "You don't have enough money to enter the main shuttle. You'll have to fly coach.") + return ..() /mob/living/simple_animal/hostile/bear/fightpit name = "fight pit bear"