Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] Fix a few vendor restocking bugs #2910

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 36 additions & 20 deletions code/modules/vending/_vending.dm
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,28 @@ GLOBAL_LIST_EMPTY(vending_machines_to_restock)

return .

/**
* After-effects of refilling a vending machine from a refill canister
*
* This takes the amount of products restocked and gives the user our contained credits if needed,
* sending the user a fitting message.
*
* Arguments:
* * user - the user restocking us
* * restocked - the amount of items we've been refilled with
*/
/obj/machinery/vending/proc/post_restock(mob/living/user, restocked)
if(!restocked)
to_chat(user, span_warning("There's nothing to restock!"))
return

to_chat(user, span_notice("You loaded [restocked] items in [src][credits_contained > 0 ? ", and are rewarded [credits_contained] credits." : "."]"))
var/datum/bank_account/cargo_account = SSeconomy.get_dep_account(ACCOUNT_CAR)
cargo_account.adjust_money(round(credits_contained * 0.5), "Vending: Restock")
var/obj/item/holochip/payday = new(src, credits_contained)
try_put_in_hand(payday, user)
credits_contained = 0

/**
* Refill our inventory from the passed in product list into the record list
*
Expand Down Expand Up @@ -704,15 +726,8 @@ GLOBAL_LIST_EMPTY(vending_machines_to_restock)
to_chat(user, span_warning("[canister] is empty!"))
else
// instantiate canister if needed
var/transferred = restock(canister)
if(transferred)
to_chat(user, span_notice("You loaded [transferred] items in [src][credits_contained > 0 ? ", and are rewarded [credits_contained] credits." : "."]"))
var/datum/bank_account/cargo_account = SSeconomy.get_dep_account(ACCOUNT_CAR)
cargo_account.adjust_money(round(credits_contained * 0.5), "Vending: Restock")
var/obj/item/holochip/payday = new(src, credits_contained)
try_put_in_hand(payday, user)
else
to_chat(user, span_warning("There's nothing to restock!"))
var/restocked = restock(canister)
post_restock(user, restocked)
return

if(compartmentLoadAccessCheck(user) && !user.combat_mode)
Expand Down Expand Up @@ -1145,17 +1160,18 @@ GLOBAL_LIST_EMPTY(vending_machines_to_restock)
if(!component_parts || !refill_canister)
return FALSE

var/moved = 0
if(panel_open || replacer.works_from_distance)
if(replacer.works_from_distance)
display_parts(user)
for(var/replacer_item in replacer)
if(istype(replacer, refill_canister))
moved += restock(replacer_item)
else
display_parts(user)
if(moved)
to_chat(user, span_notice("[moved] items restocked."))
if(!panel_open || replacer.works_from_distance)
to_chat(user, display_parts(user))

if(!panel_open && !replacer.works_from_distance)
return FALSE

var/restocked = 0
for(var/replacer_item in replacer)
if(istype(replacer_item, refill_canister))
restocked += restock(replacer_item)
post_restock(user, restocked)
if(restocked > 0)
replacer.play_rped_sound()
return TRUE

Expand Down
Loading