From 23e7de72af90b1ee50b75a0f8a634c58af83f067 Mon Sep 17 00:00:00 2001 From: EgorDinamit Date: Tue, 13 Feb 2024 15:46:46 +0300 Subject: [PATCH] More supply updates --- code/controllers/subsystems/supply.dm | 31 ++++++------ code/game/machinery/trade_beacon.dm | 2 +- .../file_system/programs/generic/supply.dm | 49 ++++++++++++++++--- 3 files changed, 59 insertions(+), 23 deletions(-) diff --git a/code/controllers/subsystems/supply.dm b/code/controllers/subsystems/supply.dm index b1e19dddd2..a5c6d4c194 100644 --- a/code/controllers/subsystems/supply.dm +++ b/code/controllers/subsystems/supply.dm @@ -10,8 +10,6 @@ SUBSYSTEM_DEF(supply) var/list/all_trading_stations = list() /// All visible and available stations var/list/visible_trading_stations = list() - /// All hidden/unavailable stations - var/list/hidden_trading_stations = list() /// All factions in the world; Assoc list Name = Datum. /// Trading stations get the datums from here var/list/factions = list() @@ -96,7 +94,6 @@ SUBSYSTEM_DEF(supply) for(var/datum/trading_station/TS in all_trading_stations) TS.RegainTradeStationsBudget() qdel(TS) - hidden_trading_stations -= TS visible_trading_stations -= TS all_trading_stations -= TS @@ -275,7 +272,7 @@ SUBSYSTEM_DEF(supply) return order_queue_slot -/datum/controller/subsystem/supply/proc/PurchaseOrder(obj/machinery/trade_beacon/receiving/beacon, order_id) +/datum/controller/subsystem/supply/proc/PurchaseOrder(obj/machinery/trade_beacon/receiving/beacon, order_id, used_faction = FACTION_INDEPENDENT) if(QDELETED(beacon) || !beacon || !order_id) return @@ -289,12 +286,12 @@ SUBSYSTEM_DEF(supply) var/total_cost = order["cost"] + order["fee"] var/is_requestor_master = (requesting_account == master_account) ? TRUE : FALSE - Buy(beacon, master_account, shopping_list, !is_requestor_master, requesting_account.owner_name) + Buy(beacon, master_account, shopping_list, !is_requestor_master, requesting_account.owner_name, used_faction) if(!is_requestor_master) requesting_account.transfer(master_account, total_cost, "Order Request") - CreateLogEntry("Order", requesting_account.owner_name, viewable_contents, total_cost) + CreateLogEntry("Order", requesting_account.owner_name, used_faction, viewable_contents, total_cost) -/datum/controller/subsystem/supply/proc/Buy(obj/machinery/trade_beacon/receiving/senderBeacon, datum/money_account/account, list/shopList, is_order = FALSE, buyer_name = null) +/datum/controller/subsystem/supply/proc/Buy(obj/machinery/trade_beacon/receiving/senderBeacon, datum/money_account/account, list/shopList, is_order = FALSE, buyer_name = null, used_faction = FACTION_INDEPENDENT) if(QDELETED(senderBeacon) || !istype(senderBeacon) || !account || !RecursiveLen(shopList)) return FALSE @@ -348,14 +345,17 @@ SUBSYSTEM_DEF(supply) if(count_of_all > 1) invoice_location = C - CreateLogEntry("Shipping", account.owner_name, order_contents_info, price_for_all, FALSE, invoice_location) + CreateLogEntry("Shipping", account.owner_name, used_faction, order_contents_info, price_for_all, FALSE, invoice_location) account.withdraw(price_for_all, "Purchase", "Trade Network") return TRUE -/datum/controller/subsystem/supply/proc/Export(obj/machinery/trade_beacon/sending/senderBeacon, datum/money_account/moneyAccount) +/datum/controller/subsystem/supply/proc/Export(obj/machinery/trade_beacon/sending/senderBeacon, datum/money_account/moneyAccount, used_faction = FACTION_INDEPENDENT) if(QDELETED(senderBeacon)) return + if(!senderBeacon.StartExport()) + return + var/invoice_contents_info var/export_count = 0 var/cost = 0 @@ -392,31 +392,30 @@ SUBSYSTEM_DEF(supply) if(export_count > 100) break - senderBeacon.StartExport() moneyAccount.deposit(cost, "Export", "Trade Network") if(invoice_contents_info) // If no info, then nothing was exported - CreateLogEntry("Export", moneyAccount.owner_name, invoice_contents_info, cost, FALSE, get_turf(senderBeacon)) + CreateLogEntry("Export", moneyAccount.owner_name, used_faction, invoice_contents_info, cost, FALSE, get_turf(senderBeacon)) return TRUE // Logging -/datum/controller/subsystem/supply/proc/CreateLogEntry(type, ordering_account, contents, total_paid, create_invoice = FALSE, invoice_location = null) +/datum/controller/subsystem/supply/proc/CreateLogEntry(type, ordering_account, assoc_faction = FACTION_INDEPENDENT, contents, total_paid, create_invoice = FALSE, invoice_location = null) var/log_id switch(type) if("Shipping") log_id = "[++shipping_invoice_number]-S" - shipping_log.Add(list(list("id" = log_id, "ordering_acct" = ordering_account, "contents" = contents, "total_paid" = total_paid, "time" = time2text(world.time, "hh:mm")))) + shipping_log.Add(list(list("id" = log_id, "ordering_acct" = ordering_account, "assoc_faction" = assoc_faction, "contents" = contents, "total_paid" = total_paid, "time" = time2text(world.time, "hh:mm")))) if("Export") log_id = "[++export_invoice_number]-E" - export_log.Add(list(list("id" = log_id, "ordering_acct" = ordering_account, "contents" = contents, "total_paid" = total_paid, "time" = time2text(world.time, "hh:mm")))) + export_log.Add(list(list("id" = log_id, "ordering_acct" = ordering_account, "assoc_faction" = assoc_faction, "contents" = contents, "total_paid" = total_paid, "time" = time2text(world.time, "hh:mm")))) if("Special Offer") log_id = "[++offer_invoice_number]-SO" - offer_log.Add(list(list("id" = log_id, "ordering_acct" = ordering_account, "contents" = contents, "total_paid" = total_paid, "time" = time2text(world.time, "hh:mm")))) + offer_log.Add(list(list("id" = log_id, "ordering_acct" = ordering_account, "assoc_faction" = assoc_faction, "contents" = contents, "total_paid" = total_paid, "time" = time2text(world.time, "hh:mm")))) if("Order") log_id = "[++order_number]-O" - order_log.Add(list(list("id" = log_id, "ordering_acct" = ordering_account, "contents" = contents, "total_paid" = total_paid, "time" = time2text(world.time, "hh:mm")))) + order_log.Add(list(list("id" = log_id, "ordering_acct" = ordering_account, "assoc_faction" = assoc_faction, "contents" = contents, "total_paid" = total_paid, "time" = time2text(world.time, "hh:mm")))) else return diff --git a/code/game/machinery/trade_beacon.dm b/code/game/machinery/trade_beacon.dm index 3f75313109..b67dbc2549 100644 --- a/code/game/machinery/trade_beacon.dm +++ b/code/game/machinery/trade_beacon.dm @@ -33,7 +33,7 @@ name = "sending trade beacon" icon_state = "beacon_sending" var/export_cooldown - var/export_cooldown_time = 120 SECONDS + var/export_cooldown_time = 90 SECONDS /obj/machinery/trade_beacon/sending/Initialize() . = ..() diff --git a/code/modules/modular_computers/file_system/programs/generic/supply.dm b/code/modules/modular_computers/file_system/programs/generic/supply.dm index 34d8840924..6b62c4f81c 100644 --- a/code/modules/modular_computers/file_system/programs/generic/supply.dm +++ b/code/modules/modular_computers/file_system/programs/generic/supply.dm @@ -215,7 +215,10 @@ return TRUE if(href_list["PRG_log_screen"]) - log_screen = input("Select log type", "Log Type", null) as null|anything in LOG_SCREEN_LIST + if(!(href_list["PRG_log_screen"] in LOG_SCREEN_LIST)) + return FALSE + + log_screen = href_list["PRG_log_screen"] current_log_page = 1 return TRUE @@ -595,7 +598,7 @@ if(get_area(receiving) != get_area(computer) && program_type != "master") to_chat(usr, SPAN_WARNING("ERROR: Receiving beacon is too far from \the [computer].")) return - if(!SSsupply.Buy(receiving, account, shopping_list)) + if(!SSsupply.Buy(receiving, account, shopping_list, FALSE, null, faction)) to_chat(usr, SPAN_WARNING("ERROR: Purchase failed.")) return FALSE ResetShopList() @@ -606,7 +609,7 @@ if(get_area(sending) != get_area(computer) && program_type != "master") to_chat(usr, SPAN_WARNING("ERROR: Sending beacon is too far from \the [computer].")) return - SSsupply.Export(sending, account) + SSsupply.Export(sending, account, faction) return TRUE if(href_list["PRG_approve_order"]) @@ -625,7 +628,7 @@ to_chat(usr, SPAN_WARNING("ERROR: Not enough funds in requesting account ([requesting_account.owner_name] #[requesting_account.account_number]).")) return - SSsupply.PurchaseOrder(receiving, order) + SSsupply.PurchaseOrder(receiving, order, faction) SSsupply.order_queue.Remove(order) if(current_order == order) current_order = null @@ -652,6 +655,7 @@ dat += " | " dat += trade_screen == CART_SCREEN ? "Cart" :"Cart" dat += " | " + dat += trade_screen == LOG_SCREEN ? "Logs" :"Logs" dat += "Exit" dat += "
" @@ -754,9 +758,12 @@ if(!sending) dat += "Sending beacon is missing!" else - dat += "Update" + dat += "Update " dat += "Export" dat += "
" + if(sending.export_cooldown > world.time) + dat += "Export cooldown: [round(sending.export_cooldown - world.time) / 1 SECONDS] seconds" + dat += "
" var/total_cost = 0 for(var/atom/movable/AM in sending.GetObjects()) if(ishuman(AM)) @@ -767,12 +774,14 @@ var/cost = 0 for(var/atom/movable/item in reverselist(contents_incl_self)) cost += get_value(item) + if(!cost) + continue dat += "- [AM.name] ([cost] [GLOB.using_map.local_currency_name_short])
" total_cost += cost if(total_cost) dat += "Total export cost: [total_cost] [GLOB.using_map.local_currency_name_short]" else - dat += "There is no items within sending beacon's range!" + dat += "There is no items for export within sending beacon's range!" if(trade_screen == CART_SCREEN) dat += "Purchase | " @@ -794,6 +803,34 @@ dat += "
" dat += "
" + if(trade_screen == LOG_SCREEN) + dat += trade_screen == LOG_SHIPPING ? "Shipping" :"Shipping" + dat += " | " + dat += trade_screen == LOG_EXPORT ? "Export" :"Export" + + dat += "
" + + switch(log_screen) + if(LOG_SHIPPING) + for(var/list/log in reverseRange(SSsupply.shipping_log)) + for(var/log in reverseRange(SSsupply.export_log)) + dat += "Time: [log["time"]]
" + dat += "Account: [log["ordering_acct"]]
" + dat += "Link: [log["assoc_faction"]]
" + dat += "Total invoice: [log["total_paid"]] [GLOB.using_map.local_currency_name_short]
" + dat += "Articles bought: [log["contents"]]
" + dat += "Print" + dat += "
" + if(LOG_EXPORT) + for(var/log in reverseRange(SSsupply.export_log)) + dat += "Time: [log["time"]]
" + dat += "Account: [log["ordering_acct"]]
" + dat += "Link: [log["assoc_faction"]]
" + dat += "Total invoice: [log["total_paid"]] [GLOB.using_map.local_currency_name_short]
" + dat += "Articles sold: [log["contents"]]
" + dat += "Print" + dat += "
" + var/datum/browser/popup = new(user, "supply_prg", "Trade Network", 600, 680) popup.set_content(dat) popup.open()