From 0e0a86a6376f71a5cd069043d9251e4f0c8ec914 Mon Sep 17 00:00:00 2001 From: fira Date: Tue, 23 Jan 2024 04:52:35 +0000 Subject: [PATCH] Fixes playing cards (#5337) # About the pull request 3 layers of fixes for a pretty bad bug with playing cards you might have seen recently. # Changelog :cl: fix: Fixed an exploit involving playing cards. /:cl: --- code/game/objects/items/toys/cards.dm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/code/game/objects/items/toys/cards.dm b/code/game/objects/items/toys/cards.dm index 2debd83f9bab..697feaf857f5 100644 --- a/code/game/objects/items/toys/cards.dm +++ b/code/game/objects/items/toys/cards.dm @@ -30,6 +30,10 @@ . = ..() populate_deck() +/obj/item/toy/deck/Destroy(force) + . = ..() + QDEL_NULL_LIST(cards) + /obj/item/toy/deck/get_examine_text(mob/user) . = ..() . += SPAN_NOTICE("There are [length(cards)] cards remaining in the deck.") @@ -75,6 +79,7 @@ var/obj/item/toy/handcard/H = O for(var/datum/playing_card/P as anything in H.cards) cards += P + H.cards -= P update_icon() qdel(O) user.visible_message(SPAN_NOTICE("[user] places their cards on the bottom of \the [src]."), SPAN_NOTICE("You place your cards on the bottom of the deck.")) @@ -271,6 +276,10 @@ if(!concealed) . += " ([length(cards)] card\s)" +/obj/item/toy/handcard/Destroy(force) + . = ..() + QDEL_NULL_LIST(cards) + /obj/item/toy/handcard/aceofspades icon_state = "spades_ace" desc = "An Ace of Spades" @@ -315,6 +324,9 @@ //fuck any qsorts and merge sorts. This needs to be brutally easy var/cards_length = length(cards) + if(cards_length >= 200) + to_chat(usr, SPAN_WARNING("Your hand is too big to sort. Remove some cards.")) + return for(var/i = 1 to cards_length) for(var/k = 2 to cards_length) if(cards[i].sort_index > cards[k].sort_index) @@ -331,6 +343,7 @@ var/cards_length = length(H.cards) for(var/datum/playing_card/P in H.cards) cards += P + H.cards -= P qdel(O) if(pile_state) if(concealed) @@ -390,6 +403,8 @@ /obj/item/toy/handcard/MouseDrop(atom/over) if(usr != over || !Adjacent(usr)) return + if(ismob(loc)) + return usr.put_in_hands(src) /obj/item/toy/handcard/get_examine_text(mob/user) @@ -423,6 +438,12 @@ name = "a playing card" desc = "A playing card." + if(length(cards) >= 200) + // BYOND will flat out choke when using thousands of cards for some unknown reason, + // possibly due to the transformed overlay stacking below. Nobody's gonna see the + // difference past 40 or so anyway. + return + overlays.Cut() if(!cards_length)