From 6a17a044c4cea5b865eb3919a10ae4c532cd0a2a Mon Sep 17 00:00:00 2001 From: deathride58 Date: Fri, 27 May 2022 23:48:04 -0400 Subject: [PATCH 1/3] rate limits pizza to prevent an edge case exploit --- code/modules/food_and_drinks/pizzabox.dm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/code/modules/food_and_drinks/pizzabox.dm b/code/modules/food_and_drinks/pizzabox.dm index 3c0d60907f..33a1075202 100644 --- a/code/modules/food_and_drinks/pizzabox.dm +++ b/code/modules/food_and_drinks/pizzabox.dm @@ -311,6 +311,7 @@ /obj/item/reagent_containers/food/snacks/pizza/donkpocket = 0.3, /obj/item/reagent_containers/food/snacks/pizza/dank = 0.1) //pizzas here are weighted by chance to be someone's favorite var/static/list/pizza_preferences + var/next_pizza_attunement /obj/item/pizzabox/infinite/Initialize(mapload) . = ..() @@ -323,11 +324,18 @@ . += "This pizza box is anomalous, and will produce infinite pizza." /obj/item/pizzabox/infinite/attack_self(mob/living/user) - QDEL_NULL(pizza) - if(ishuman(user)) - attune_pizza(user) + if(world.time > next_pizza_attunement) + QDEL_NULL(pizza) + if(ishuman(user)) + attune_pizza(user) . = ..() +/obj/item/pizzabox/infinite/on_attack_hand(mob/user, act_intent, unarmed_attack_flags) + var/had_pizza = (pizza ? TRUE : FALSE) + . = ..() + if(had_pizza && !pizza) + next_pizza_attunement = world.time + (10 SECONDS) //This is balanced specifically so that it takes several hours to generate enough pizzas to use for lag methods that on item duping + /obj/item/pizzabox/infinite/proc/attune_pizza(mob/living/carbon/human/noms) //tonight on "proc names I never thought I'd type" if(!pizza_preferences[noms.ckey]) pizza_preferences[noms.ckey] = pickweight(pizza_types) From 9bd070b1a75569d330437963a0f02a7a0467d5fe Mon Sep 17 00:00:00 2001 From: deathride58 Date: Sat, 28 May 2022 00:01:37 -0400 Subject: [PATCH 2/3] cooldown defines! --- code/modules/food_and_drinks/pizzabox.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/modules/food_and_drinks/pizzabox.dm b/code/modules/food_and_drinks/pizzabox.dm index 33a1075202..d5b5a95891 100644 --- a/code/modules/food_and_drinks/pizzabox.dm +++ b/code/modules/food_and_drinks/pizzabox.dm @@ -311,7 +311,7 @@ /obj/item/reagent_containers/food/snacks/pizza/donkpocket = 0.3, /obj/item/reagent_containers/food/snacks/pizza/dank = 0.1) //pizzas here are weighted by chance to be someone's favorite var/static/list/pizza_preferences - var/next_pizza_attunement + COOLDOWN_DECLARE(next_pizza_attunement) /obj/item/pizzabox/infinite/Initialize(mapload) . = ..() @@ -324,7 +324,7 @@ . += "This pizza box is anomalous, and will produce infinite pizza." /obj/item/pizzabox/infinite/attack_self(mob/living/user) - if(world.time > next_pizza_attunement) + if(COOLDOWN_FINISHED(src, next_pizza_attunement)) QDEL_NULL(pizza) if(ishuman(user)) attune_pizza(user) @@ -334,7 +334,7 @@ var/had_pizza = (pizza ? TRUE : FALSE) . = ..() if(had_pizza && !pizza) - next_pizza_attunement = world.time + (10 SECONDS) //This is balanced specifically so that it takes several hours to generate enough pizzas to use for lag methods that on item duping + COOLDOWN_START(src, next_pizza_attunement, (10 SECONDS)) //This is balanced specifically so that it takes several hours to generate enough pizzas to use for lag methods that on item duping /obj/item/pizzabox/infinite/proc/attune_pizza(mob/living/carbon/human/noms) //tonight on "proc names I never thought I'd type" if(!pizza_preferences[noms.ckey]) From d2f8f34857f6065a68b8650af0956207320df912 Mon Sep 17 00:00:00 2001 From: deathride58 Date: Sat, 28 May 2022 11:21:14 -0400 Subject: [PATCH 3/3] nerfs cooldown down to 3 seconds for the sake of not feeling entirely awful to use --- code/modules/food_and_drinks/pizzabox.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/food_and_drinks/pizzabox.dm b/code/modules/food_and_drinks/pizzabox.dm index d5b5a95891..9d0e38cdec 100644 --- a/code/modules/food_and_drinks/pizzabox.dm +++ b/code/modules/food_and_drinks/pizzabox.dm @@ -334,7 +334,7 @@ var/had_pizza = (pizza ? TRUE : FALSE) . = ..() if(had_pizza && !pizza) - COOLDOWN_START(src, next_pizza_attunement, (10 SECONDS)) //This is balanced specifically so that it takes several hours to generate enough pizzas to use for lag methods that on item duping + COOLDOWN_START(src, next_pizza_attunement, (3 SECONDS)) /obj/item/pizzabox/infinite/proc/attune_pizza(mob/living/carbon/human/noms) //tonight on "proc names I never thought I'd type" if(!pizza_preferences[noms.ckey])