Vendor Exploit Fix (#1967)

Fixes a pretty severe exploit where spambuying from a vendor allows you to purchase a larger quantity than the vendor has. Coupled with the ability to add things, this is basically infinite item duplication. How did we not notice this before now?

I kept the spam buying, because it's pretty nifty, but added a safety check to ensure there's one remaining to buy

In addition, adds a little exception that allows bluespace technicians to take free stuff from vendors. Largely for debugging. I'm sick of having to spawn as a crewmember to do anything vendor related, this will save a bit of development time in the long run.
This commit is contained in:
NanakoAC
2017-03-23 00:58:34 +02:00
committed by skull132
parent 8d323f1b06
commit 7bc50597a7
2 changed files with 52 additions and 0 deletions
+16
View File
@@ -181,6 +181,13 @@
var/paid = 0
var/handled = 0
if (currently_vending.amount < 1)
visible_message(span("warning","\The [src] buzzes and flashes a message on its LCD: <b>\"Out of stock.\"</b>"))
src.status_error = 1
playsound(src.loc, 'sound/machines/buzz-two.ogg', 35, 1)
currently_vending = null
return
if (I) //for IDs and PDAs and wallets with IDs
paid = pay_with_card(I,W)
handled = 1
@@ -321,6 +328,10 @@
visible_message("<span class='info'>\The [usr] swipes \the [ID_container] through \the [src].</span>")
var/datum/money_account/customer_account = get_account(I.associated_account_number)
if (!customer_account)
//Allow BSTs to take stuff from vendors, for debugging and adminbus purposes
if (istype(I, /obj/item/weapon/card/id/bst))
return 1
src.status_message = "Error: Unable to access account. Please contact technical support if problem persists."
src.status_error = 1
return 0
@@ -507,6 +518,9 @@
nanomanager.update_uis(src)
/obj/machinery/vending/proc/vend(datum/data/vending_product/R, mob/user)
if (!R || R.amount < 1)
return
if((!allowed(usr)) && !emagged && scan_id) //For SECURE VENDING MACHINES YEAH
usr << "<span class='warning'>Access denied.</span>" //Unless emagged of course
flick(src.icon_deny,src)
@@ -516,6 +530,8 @@
src.status_error = 0
nanomanager.update_uis(src)
if (R.category & CAT_COIN)
if(!coin)
user << "<span class='notice'>You need to insert a coin to get this item.</span>"