Skip to content

Commit

Permalink
[MIRROR] Removes unused vars from cargo & economy. [MDB IGNORE] (#524)
Browse files Browse the repository at this point in the history
* Removes unused vars from cargo & economy.

* Update supply.dm

* Update supply.dm

---------

Co-authored-by: SkyratBot <[email protected]>
Co-authored-by: SyncIt21 <[email protected]>
Co-authored-by: Bloop <[email protected]>
  • Loading branch information
4 people authored Nov 9, 2023
1 parent c098684 commit 82fa27e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 27 deletions.
4 changes: 0 additions & 4 deletions code/controllers/subsystem/economy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 0 additions & 5 deletions code/controllers/subsystem/shuttle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion code/modules/cargo/materials_market.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 14 additions & 3 deletions code/modules/cargo/order.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
25 changes: 12 additions & 13 deletions code/modules/shuttle/supply.dm
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ 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)
if(!empty_turfs.len)
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
Expand All @@ -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()
Expand All @@ -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))
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 82fa27e

Please sign in to comment.