From 82fa27e9a466a906fecf23abddbb032193e318ba Mon Sep 17 00:00:00 2001 From: Iajret Creature <122297233+AnArgonianLizardThatStealsPRs@users.noreply.github.com> Date: Thu, 9 Nov 2023 20:40:44 +0300 Subject: [PATCH] [MIRROR] Removes unused vars from cargo & economy. [MDB IGNORE] (#524) * Removes unused vars from cargo & economy. * Update supply.dm * Update supply.dm --------- Co-authored-by: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> --- code/controllers/subsystem/economy.dm | 4 --- code/controllers/subsystem/shuttle.dm | 5 ---- .../orders/order_computer/mining_order.dm | 2 +- code/modules/cargo/materials_market.dm | 2 +- code/modules/cargo/order.dm | 17 ++++++++++--- code/modules/shuttle/supply.dm | 25 +++++++++---------- 6 files changed, 28 insertions(+), 27 deletions(-) diff --git a/code/controllers/subsystem/economy.dm b/code/controllers/subsystem/economy.dm index 511a438bf9a..f047d17d944 100644 --- a/code/controllers/subsystem/economy.dm +++ b/code/controllers/subsystem/economy.dm @@ -53,10 +53,6 @@ SUBSYSTEM_DEF(economy) */ var/list/audit_log = list() - /// Total value of exported materials. - var/export_total = 0 - /// Total value of imported goods. - var/import_total = 0 /// Number of mail items generated. var/mail_waiting = 0 /// Mail Holiday: AKA does mail arrive today? Always blocked on Sundays. diff --git a/code/controllers/subsystem/shuttle.dm b/code/controllers/subsystem/shuttle.dm index a3ec32c0c3a..b1ebf3d586c 100644 --- a/code/controllers/subsystem/shuttle.dm +++ b/code/controllers/subsystem/shuttle.dm @@ -100,9 +100,6 @@ SUBSYSTEM_DEF(shuttle) /// Wishlist items made by crew for cargo to purchase at their leisure. var/list/request_list = list() - /// A listing of previously delivered supply packs. - var/list/order_history = list() - /// A list of job accesses that are able to purchase any shuttles. var/list/has_purchase_shuttle_access @@ -745,8 +742,6 @@ SUBSYSTEM_DEF(shuttle) shopping_list = SSshuttle.shopping_list if (istype(SSshuttle.request_list)) request_list = SSshuttle.request_list - if (istype(SSshuttle.order_history)) - order_history = SSshuttle.order_history if (istype(SSshuttle.shuttle_loan)) shuttle_loan = SSshuttle.shuttle_loan diff --git a/code/game/machinery/computer/orders/order_computer/mining_order.dm b/code/game/machinery/computer/orders/order_computer/mining_order.dm index c680974e4c1..2ba9e00d9f5 100644 --- a/code/game/machinery/computer/orders/order_computer/mining_order.dm +++ b/code/game/machinery/computer/orders/order_computer/mining_order.dm @@ -41,7 +41,7 @@ cost = get_total_cost(), \ contains = things_to_order, ) - var/datum/supply_order/new_order = new( + var/datum/supply_order/disposable/new_order = new( pack = mining_pack, orderer = purchaser, orderer_rank = "Mining Vendor", diff --git a/code/modules/cargo/materials_market.dm b/code/modules/cargo/materials_market.dm index 32befd95653..1a617e9e2dc 100644 --- a/code/modules/cargo/materials_market.dm +++ b/code/modules/cargo/materials_market.dm @@ -293,7 +293,7 @@ cost = cost, \ contains = things_to_order, \ ) - var/datum/supply_order/materials/new_order = new( + var/datum/supply_order/disposable/materials/new_order = new( pack = mineral_pack, orderer = living_user, orderer_rank = GALATIC_MATERIAL_ORDER, diff --git a/code/modules/cargo/order.dm b/code/modules/cargo/order.dm index 58c13afbe59..309567d51e9 100644 --- a/code/modules/cargo/order.dm +++ b/code/modules/cargo/order.dm @@ -85,6 +85,10 @@ src.manifest_can_fail = manifest_can_fail src.can_be_cancelled = can_be_cancelled +/datum/supply_order/Destroy(force, ...) + QDEL_NULL(applied_coupon) + return ..() + //returns the total cost of this order. Its not the total price paid by cargo but the total value of this order /datum/supply_order/proc/get_final_cost() var/cost = pack.get_cost() @@ -201,10 +205,17 @@ pack.contains[i] = new_contents[i] pack.cost += cost_increase -//To append cargo crate value to final order cost -/datum/supply_order/materials +/// Custom type of order who's supply pack can be safely deleted +/datum/supply_order/disposable + +/datum/supply_order/disposable/Destroy(force, ...) + QDEL_NULL(pack) + return ..() + +/// Custom material order to append cargo crate value to the final order cost +/datum/supply_order/disposable/materials -/datum/supply_order/materials/get_final_cost() +/datum/supply_order/disposable/materials/get_final_cost() return (..() + CARGO_CRATE_VALUE) #undef MANIFEST_ERROR_CHANCE diff --git a/code/modules/shuttle/supply.dm b/code/modules/shuttle/supply.dm index 351d419c03e..ffeefaad688 100644 --- a/code/modules/shuttle/supply.dm +++ b/code/modules/shuttle/supply.dm @@ -160,7 +160,7 @@ GLOBAL_LIST_INIT(blacklisted_cargo_types, typecacheof(list( var/price var/pack_cost var/list/goodies_by_buyer = list() // if someone orders more than GOODY_FREE_SHIPPING_MAX goodies, we upcharge to a normal crate so they can't carry around 20 combat shotties - var/list/rejected_orders = list() //list of all orders that exceeded the available budget and are uncancelable + var/list/clean_up_orders = list() // orders to remove since we are done with them var/list/forced_briefcases = list() // SKYRAT EDIT ADDITION for(var/datum/supply_order/spawning_order in SSshuttle.shopping_list) @@ -168,7 +168,7 @@ GLOBAL_LIST_INIT(blacklisted_cargo_types, typecacheof(list( break price = spawning_order.get_final_cost() - //department orders EARN money for cargo, not the other way around + // department orders EARN money for cargo, not the other way around var/datum/bank_account/paying_for_this if(!spawning_order.department_destination && spawning_order.charge_on_purchase) if(spawning_order.paying_account) //Someone paid out of pocket @@ -186,8 +186,9 @@ GLOBAL_LIST_INIT(blacklisted_cargo_types, typecacheof(list( if(!paying_for_this.adjust_money(-price, "Cargo: [spawning_order.pack.name]")) if(spawning_order.paying_account) paying_for_this.bank_card_talk("Cargo order #[spawning_order.id] rejected due to lack of funds. Credits required: [price]") - if(!spawning_order.can_be_cancelled) //only if it absolutely cannot be canceled by the player do we cancel it for them - rejected_orders += spawning_order + if(!spawning_order.can_be_cancelled) //only if it absolutly cannot be canceled by the player do we cancel it for them + SSshuttle.shopping_list -= spawning_order + clean_up_orders += spawning_order continue pack_cost = spawning_order.pack.get_cost() @@ -203,9 +204,6 @@ GLOBAL_LIST_INIT(blacklisted_cargo_types, typecacheof(list( var/datum/bank_account/department/cargo = SSeconomy.get_dep_account(ACCOUNT_CAR) cargo.adjust_money(price - pack_cost) //Cargo gets the handling fee value += pack_cost - SSshuttle.shopping_list -= spawning_order - SSshuttle.order_history += spawning_order - QDEL_NULL(spawning_order.applied_coupon) if(!spawning_order.pack.goody && !(spawning_order?.paying_account in forced_briefcases)) // SKYRAT EDIT CHANGE - ORIGINAL : if(!spawning_order.pack.goody) var/obj/structure/closet/crate = spawning_order.generate(pick_n_take(empty_turfs)) @@ -220,10 +218,9 @@ GLOBAL_LIST_INIT(blacklisted_cargo_types, typecacheof(list( message_admins("\A [spawning_order.pack.name] ordered by [ADMIN_LOOKUPFLW(spawning_order.orderer_ckey)], paid by [from_whom] has shipped.") purchases++ - //clear out all rejected uncancellable orders - for(var/datum/supply_order/rejected_order in rejected_orders) - SSshuttle.shopping_list -= rejected_order - qdel(rejected_order) + // done dealing with order. Time to remove & delete it + SSshuttle.shopping_list -= spawning_order + clean_up_orders += spawning_order // we handle packing all the goodies last, since the type of crate we use depends on how many goodies they ordered. If it's more than GOODY_FREE_SHIPPING_MAX // then we send it in a crate (including the CRATE_TAX cost), otherwise send it in a free shipping case @@ -266,7 +263,10 @@ GLOBAL_LIST_INIT(blacklisted_cargo_types, typecacheof(list( order.generateCombo(miscboxes[miscbox], miscbox, misc_contents[miscbox], misc_costs[miscbox]) qdel(order) - SSeconomy.import_total += value + //clean up all dealt with orders + for(var/datum/supply_order/completed_order in clean_up_orders) + qdel(completed_order) + var/datum/bank_account/cargo_budget = SSeconomy.get_dep_account(ACCOUNT_CAR) investigate_log("[purchases] orders in this shipment, worth [value] credits. [cargo_budget.account_balance] credits left.", INVESTIGATE_CARGO) @@ -301,7 +301,6 @@ GLOBAL_LIST_INIT(blacklisted_cargo_types, typecacheof(list( msg += export_text + "\n" cargo_budget.adjust_money(report.total_value[exported_datum]) - SSeconomy.export_total += (cargo_budget.account_balance - presale_points) SSshuttle.centcom_message = msg investigate_log("contents sold for [cargo_budget.account_balance - presale_points] credits. Contents: [report.exported_atoms ? report.exported_atoms.Join(",") + "." : "none."] Message: [SSshuttle.centcom_message || "none."]", INVESTIGATE_CARGO)