From faefea70e0ebd88dc75e39abf2e152b728e77cef Mon Sep 17 00:00:00 2001 From: Birdtalon Date: Mon, 4 Dec 2023 22:44:49 +0000 Subject: [PATCH] Runtime fix and code maintenance for vendors (#5115) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # About the pull request #5066 introduced a runtime in certain vendors when attacking them with anything. Also removes duplicate `attackby()` definition. ``` [2023-12-03 16:04:24.708] runtime error: undefined variable /obj/item/storage/belt/marine/var/token_type - proc name: redeem token (/obj/structure/machinery/cm_vending/proc/redeem_token) - source file: code/game/machinery/vending/cm_vending.dm,453 - usr: William Henderson (/mob/living/carbon/human) - src: the ColMarTech Surplus Uniform... (/obj/structure/machinery/cm_vending/sorted/uniform_supply/squad_prep) - usr.loc: the floor (186,73,3) (/turf/open/floor/almayer) - src.loc: the floor (185,73,3) (/turf/open/floor/almayer) - call stack: - the ColMarTech Surplus Uniform... (/obj/structure/machinery/cm_vending/sorted/uniform_supply/squad_prep): redeem token(the M276 pattern ammo load rig (/obj/item/storage/belt/marine), William Henderson (/mob/living/carbon/human)) - the ColMarTech Surplus Uniform... (/obj/structure/machinery/cm_vending/sorted/uniform_supply/squad_prep): attackby(the M276 pattern ammo load rig (/obj/item/storage/belt/marine), William Henderson (/mob/living/carbon/human), /list (/list)) - the ColMarTech Surplus Uniform... (/obj/structure/machinery/cm_vending/sorted/uniform_supply/squad_prep): attackby(the M276 pattern ammo load rig (/obj/item/storage/belt/marine), William Henderson (/mob/living/carbon/human), /list (/list)) - William Henderson (/mob/living/carbon/human): click adjacent(the ColMarTech Surplus Uniform... (/obj/structure/machinery/cm_vending/sorted/uniform_supply/squad_prep), the M276 pattern ammo load rig (/obj/item/storage/belt/marine), /list (/list)) - William Henderson (/mob/living/carbon/human): do click(the ColMarTech Surplus Uniform... (/obj/structure/machinery/cm_vending/sorted/uniform_supply/squad_prep), the floor (185,73,3) (/turf/open/floor/almayer), "icon-x=1;icon-y=22;left=1;butt...") - ***** (/client): Click(the ColMarTech Surplus Uniform... (/obj/structure/machinery/cm_vending/sorted/uniform_supply/squad_prep), the floor (185,73,3) (/turf/open/floor/almayer), "mapwindow.map", "icon-x=1;icon-y=22;left=1;butt...") ``` # Explain why it's good for the game # Testing Photographs and Procedure
Screenshots & Videos Put screenshots and videos here with an empty line between the screenshots and the `
` tags.
# Changelog :cl: fix: Fixes a runtime in vendors /🆑 --- code/game/machinery/vending/cm_vending.dm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/code/game/machinery/vending/cm_vending.dm b/code/game/machinery/vending/cm_vending.dm index b0a09dcd1767..0745f05ab2d1 100644 --- a/code/game/machinery/vending/cm_vending.dm +++ b/code/game/machinery/vending/cm_vending.dm @@ -441,13 +441,6 @@ GLOBAL_LIST_EMPTY(vending_products) tgui_interact(user) /// Handles redeeming coin tokens. -/obj/structure/machinery/cm_vending/attackby(obj/item/attacking_item, mob/user) - if(!istype(attacking_item, /obj/item/coin/marine)) - ..() - if(!can_access_to_vend(user, ignore_hack = TRUE)) - return FALSE - redeem_token(attacking_item, user) - /obj/structure/machinery/cm_vending/proc/redeem_token(obj/item/coin/marine/token, mob/user) var/reward_typepath switch(token.token_type) @@ -766,6 +759,13 @@ GLOBAL_LIST_EMPTY(vending_products) hack_access(user) return TRUE + ///If we want to redeem a token + else if(istype(W, /obj/item/coin/marine)) + if(!can_access_to_vend(user, ignore_hack = TRUE)) + return FALSE + . = redeem_token(W, user) + return + ..() /obj/structure/machinery/cm_vending/proc/get_listed_products(mob/user)