Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion code/controllers/subsystems/ticker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ Helpers
if(dronecount)
to_world("<b>There [dronecount>1 ? "were" : "was"] [dronecount] industrious maintenance drone\s at the end of this round.</b>")

if(SSmoney_accounts.all_glob_accounts.len)
if(length(SSmoney_accounts.all_glob_accounts))
var/datum/money_account/max_profit = SSmoney_accounts.all_glob_accounts[1]
var/datum/money_account/max_loss = SSmoney_accounts.all_glob_accounts[1]
for(var/datum/money_account/D in SSmoney_accounts.all_glob_accounts)
Expand Down
11 changes: 6 additions & 5 deletions code/modules/economy/cael/related_accounts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
var/list/datum/money_account/child/children = list()

/datum/money_account/parent/Destroy(force)
QDEL_NULL(children)
QDEL_NULL_LIST(children)
. = ..()

/datum/money_account/parent/can_afford(amount, datum/money_account/receiver)
Expand Down Expand Up @@ -55,9 +55,10 @@

var/datum/money_account/parent/parent_account

/datum/money_account/child/New(account_type, p_account, n_interest, n_withdrawal_limit, n_transaction_fee)
parent_account = p_account
parent_account.children |= src
/datum/money_account/child/New(account_type, datum/money_account/parent/p_account, n_interest, n_withdrawal_limit, n_transaction_fee)
if(istype(p_account))
parent_account = p_account
parent_account.children |= src
interest_rate = n_interest
withdrawal_limit = n_withdrawal_limit
transaction_fee = n_transaction_fee
Expand Down Expand Up @@ -150,7 +151,7 @@
if(!parent_account || !money) // Nothing to escrow!
return

var/solvency = max(1, parent_account.money / parent_account.child_totals)
var/solvency = min(1, parent_account.money / parent_account.child_totals)

var/escrowed_money = FLOOR(min(solvency*money, parent_account.money))
var/datum/money_account/escrow/child_escrow = SSmoney_accounts.get_or_add_escrow(account_id, remote_access_pin, parent_account.owner_name)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/events/money_lotto.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/datum/event/money_lotto/start()
winner_sum = pick(5000, 10000, 50000, 100000, 500000, 1000000, 1500000)
if(prob(50))
if(SSmoney_accounts.all_glob_accounts.len)
if(length(SSmoney_accounts.all_glob_accounts))
winner_account = pick(SSmoney_accounts.all_glob_accounts)
winner_name = winner_account.owner_name
deposit_success = winner_account.deposit(winner_sum, "Nyx Daily Loan Lottery winner!", "Biesel TCD Terminal #[rand(111,333)]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@
/datum/computer_file/program/docking
)

/obj/machinery/computer/modular/preset/finance
default_software = list(
/datum/computer_file/program/finances,
/datum/computer_file/program/atm,
/datum/computer_file/program/accounts
)
uncreated_component_parts = list(
/obj/item/stock_parts/power/apc,
/obj/item/stock_parts/computer/card_slot,
/obj/item/stock_parts/computer/money_printer
)

/obj/machinery/computer/modular/preset/supply_public
default_software = list(
/datum/computer_file/program/supply
Expand Down
4 changes: 4 additions & 0 deletions code/modules/modular_computers/networking/_network.dm
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@
SSnetworking.networks -= network_id
add_log("Network ID was changed from '[network_id]' to '[new_id]'")
network_id = new_id

if(parent_account)
parent_account.owner_name = network_id

SSnetworking.networks[network_id] = src

/datum/computer_network/proc/enable_network_feature(feature)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
var/datum/computer_file/data/email_message/bankrupt_email
var/datum/computer_file/data/email_message/escrow_email

var/get_network_error = FALSE // Network accounts need at least one money storage device and a banking mainframe to function.

/datum/money_account/parent/network/New(account_type, network_id)
owner_name = network_id
if(owner_name)
Expand All @@ -29,6 +27,7 @@
return err
. = ..()

// Network accounts need at least one money storage device and a banking mainframe to function.
/datum/money_account/parent/network/proc/get_network_error()
var/datum/computer_network/net = SSnetworking.networks[owner_name]
if(!net || !net.banking_mainframe)
Expand All @@ -51,10 +50,11 @@
An escrow account has been opened for you containing some or all of your outstanding balance of your account. \
Escrow accounts are accessible from any financial terminal using your prior account information, \
and the financial provider ID '[owner_name]'. Please contact your financial provider for further information."

/datum/money_account/child/network
var/weakref/network_account

/datum/money_account/child/network/New(account_type, p_account, n_interest, n_withdrawal_limit, n_transaction_fee, datum/computer_file/data/account/attached_account)
/datum/money_account/child/network/New(account_type, datum/money_account/parent/p_account, n_interest, n_withdrawal_limit, n_transaction_fee, datum/computer_file/data/account/attached_account)
if(attached_account)
account_name = "[attached_account.fullname]'s account"
account_id = attached_account.login
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@
var/stored_money // Money temporarily stored in the case that the parent account on the network vanishes.
internet_allowed = TRUE

/datum/extension/network_device/money_cube/connect()
. = ..()
if(.)
var/obj/H = holder
H.queue_icon_update()

/datum/extension/network_device/money_cube/disconnect(net_down)
var/obj/H = holder
H.queue_icon_update()
Expand Down
13 changes: 9 additions & 4 deletions mods/persistence/_persistence.dme
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@
#include "datums\mind\mind.dm"
#include "datums\music_tracks\blood_loss.dm"
#include "datums\music_tracks\juno.dm"
#include "datums\music_tracks\neon_koto.dm"
#include "datums\music_tracks\neogrotesque.dm"
#include "datums\music_tracks\neon_koto.dm"
#include "datums\observation\saving.dm"
#include "datums\vending\stored_item.dm"
#include "datums\wires\wires.dm"
#include "game\antagonist\antagonist_helpers.dm"
#include "game\area\areas.dm"
#include "game\area\area_space.dm"
#include "game\area\areas.dm"
#include "game\gamemodes\persistence.dm"
#include "game\machinery\cryopod.dm"
#include "game\machinery\machinery.dm"
Expand Down Expand Up @@ -124,6 +124,7 @@
#include "modules\detectivework\evidence\_evidence_holder.dm"
#include "modules\detectivework\evidence\_evidence_type.dm"
#include "modules\detectivework\microscope\_forensic_machine.dm"
#include "modules\economy\account.dm"
#include "modules\economy\economy.dm"
#include "modules\emotes\audible.dm"
#include "modules\emotes\human.dm"
Expand All @@ -140,10 +141,10 @@
#include "modules\hydroponics\spreading\spreading.dm"
#include "modules\integrated_electronics\printer.dm"
#include "modules\lighting\lighting_overlay.dm"
#include "modules\materials\recipes_persistence.dm"
#include "modules\materials\definitions\materials_solid_metal.dm"
#include "modules\materials\definitions\materials_stone.dm"
#include "modules\materials\geology\_strata.dm"
#include "modules\materials\recipes_persistence.dm"
#include "modules\mining\machinery\_material_processing.dm"
#include "modules\mining\machinery\material_compressor.dm"
#include "modules\mining\machinery\material_smelter.dm"
Expand Down Expand Up @@ -175,12 +176,15 @@
#include "modules\modular_computers\file_system\reports\crew_record.dm"
#include "modules\modular_computers\file_system\reports\report.dm"
#include "modules\modular_computers\hardware\battery_module.dm"
#include "modules\modular_computers\networking\_network.dm"
#include "modules\modular_computers\networking\network_cable.dm"
#include "modules\modular_computers\networking\accounts\account.dm"
#include "modules\modular_computers\networking\accounts\email_message.dm"
#include "modules\modular_computers\networking\device_types\_network_device.dm"
#include "modules\modular_computers\networking\device_types\acl.dm"
#include "modules\modular_computers\networking\device_types\mainframe.dm"
#include "modules\modular_computers\networking\finance\bank.dm"
#include "modules\modular_computers\networking\finance\money_cube.dm"
#include "modules\modular_computers\networking\machines\_network_machine.dm"
#include "modules\modular_computers\networking\machines\area_controller.dm"
#include "modules\modular_computers\networking\machines\router.dm"
Expand Down Expand Up @@ -232,8 +236,8 @@
#include "modules\reagents\chems\chems.dm"
#include "modules\reagents\chems\recipes.dm"
#include "modules\reagents\heat_sources\heat_source.dm"
#include "modules\reagents\reagent_containers\glass\bottle.dm"
#include "modules\reagents\reagent_containers\food\food.dm"
#include "modules\reagents\reagent_containers\glass\bottle.dm"
#include "modules\science\_defines.dm"
#include "modules\science\recipe.dm"
#include "modules\science\research_overrides.dm"
Expand Down Expand Up @@ -269,6 +273,7 @@
#include "modules\world_save\wrappers\_wrapper_holder.dm"
#include "modules\world_save\wrappers\area_wrapper.dm"
#include "modules\world_save\wrappers\decl_wrapper.dm"
#include "modules\world_save\wrappers\escrow_holder.dm"
#include "modules\world_save\wrappers\image_wrapper.dm"
#include "modules\world_save\wrappers\map_data_wrapper.dm"
#include "modules\world_save\wrappers\weakref_wrapper.dm"
Expand Down
17 changes: 13 additions & 4 deletions mods/persistence/controllers/subsystems/persistence.dm
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,8 @@
if(QDELETED(current_mob))
continue
// Check to see if the mobs are already being saved.
var/area/MA = get_area(current_mob)
if(istype(MA) && !(MA.area_flags & AREA_FLAG_IS_NOT_PERSISTENT))
if(((MA in SSpersistence.saved_areas) || (current_mob.z in SSpersistence.saved_levels)))
continue
if(current_mob.in_saved_location())
continue
one_off.AddToLimbo(list(current_mob, char_mind), char_mind.unique_id, LIMBO_MIND, char_mind.key, current_mob.real_name, TRUE)
report_progress_serializer("Done adding player minds to limbo in [(REALTIMEOFDAY - time_start_limbo_minds) / (1 SECOND)]s.")
sleep(5)
Expand Down Expand Up @@ -318,6 +316,17 @@
report_progress_serializer("Extensions saved in [(REALTIMEOFDAY - time_start_extensions) / (1 SECOND)]s.")
sleep(5)

// Save escrow accounts which are normally held on the SSmoney_accounts subsystem
if(length(SSmoney_accounts.all_escrow_accounts))
report_progress_serializer("Saving escrow accounts...")
var/datum/wrapper_holder/escrow_holder/e_holder = new(SSmoney_accounts.all_escrow_accounts.Copy())
var/time_start_escrow = REALTIMEOFDAY

serializer.Serialize(e_holder)
serializer.Commit()

report_progress_serializer("Escrow accounts saved in [(REALTIMEOFDAY - time_start_escrow) / (1 SECOND)]s.")

//
// CLEANUP SECTION
//
Expand Down
11 changes: 9 additions & 2 deletions mods/persistence/datums/extensions/extensions.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@
/datum/extension/proc/on_save()
SSpersistence.saved_extensions += src

/datum/extension/should_save(object_parent)
/datum/extension/should_save(object_parent, one_off = FALSE)
if(object_parent) // Extensions are saved manually, either by self-reporting or by the one off serializer checking. Don't permit saving from object vars.
return FALSE
return should_save

// If the holder is a movable and wouldn't be saved, don't save this either.
if(!one_off && istype(holder, /atom/movable))
var/atom/movable/H = holder
if(!H.in_saved_location())
return FALSE

return ..()
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/datum/extension/forensic_evidence
should_save = TRUE

var/last_updated
var/last_updated

/datum/extension/forensic_evidence/add_data(evidence_type, data)
. = ..()
Expand All @@ -13,7 +13,7 @@
. = ..()
last_updated = world.realtime

/datum/extension/forensic_evidence/should_save(object_parent)
/datum/extension/forensic_evidence/should_save(object_parent, one_off = FALSE)
if(world.realtime > (last_updated + EVIDENCE_SPOIL_TIME))
return FALSE
. = ..()
Expand Down
63 changes: 63 additions & 0 deletions mods/persistence/modules/economy/account.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Money accounts should not be flattened. Child accounts do some work with references post save,
// and because both network accounts and transactions are flattened, could lead to absurdly large rows in the database.
SAVED_VAR(/datum/money_account, account_name)
SAVED_VAR(/datum/money_account, owner_name)
SAVED_VAR(/datum/money_account, account_id)
SAVED_VAR(/datum/money_account, remote_access_pin)
SAVED_VAR(/datum/money_account, money)
SAVED_VAR(/datum/money_account, transaction_log)
SAVED_VAR(/datum/money_account, suspended)
SAVED_VAR(/datum/money_account, security_level)
SAVED_VAR(/datum/money_account, account_type)
SAVED_VAR(/datum/money_account, currency)

// Related accounts
SAVED_VAR(/datum/money_account/parent, fractional_reserve)
SAVED_VAR(/datum/money_account/parent, open_escrow_on_destroy)
SAVED_VAR(/datum/money_account/parent, children)

SAVED_VAR(/datum/money_account/child, withdrawal_limit)
SAVED_VAR(/datum/money_account/child, current_withdrawal)
SAVED_VAR(/datum/money_account/child, last_withdraw_period)
SAVED_VAR(/datum/money_account/child, transaction_fee)
SAVED_VAR(/datum/money_account/child, interest_rate)
SAVED_VAR(/datum/money_account/child, last_interest_period)
SAVED_VAR(/datum/money_account/child, parent_account)

// Account modifications
SAVED_FLATTEN(/datum/account_modification)
SAVED_VAR(/datum/account_modification, name)
SAVED_VAR(/datum/account_modification, start_time)
SAVED_VAR(/datum/account_modification, mod_delay)
SAVED_VAR(/datum/account_modification, affecting)
SAVED_VAR(/datum/account_modification, suspends_withdrawal_limit)
SAVED_VAR(/datum/account_modification, allow_early)
SAVED_VAR(/datum/account_modification, allow_cancel)

// Network accounts
/datum/money_account/parent/network/after_deserialize()
. = ..()
// Don't bother saving these since we can easily regenerate them.
if(owner_name)
generate_emails()

for(var/datum/money_account/child/network/net_child in children)
var/datum/computer_file/data/account/attached_account = net_child.network_account?.resolve()

// The network account has gone missing - escrow the account and destroy it.
if(!istype(attached_account))
net_child.on_escrow(ignore_email = TRUE)
qdel(net_child)

SAVED_VAR(/datum/money_account/child/network, network_account)
// Transactions
// TODO: These should disappear after some time to save space, even if they're flattened.
SAVED_FLATTEN(/datum/transaction)
SAVED_VAR(/datum/transaction, purpose)
SAVED_VAR(/datum/transaction, amount)
SAVED_VAR(/datum/transaction, date)
SAVED_VAR(/datum/transaction, time)
SAVED_VAR(/datum/transaction, target)
SAVED_VAR(/datum/transaction, source)
SAVED_VAR(/datum/transaction, target_name)
SAVED_VAR(/datum/transaction, source_name)
23 changes: 21 additions & 2 deletions mods/persistence/modules/economy/economy.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

//EFPOS
//#TODO: will need additional handling once we can rewrite how this thing inits
//EFTPOS
SAVED_VAR(/obj/item/eftpos, machine_id)
SAVED_VAR(/obj/item/eftpos, eftpos_name)
SAVED_VAR(/obj/item/eftpos, transaction_locked)
Expand All @@ -11,12 +10,29 @@ SAVED_VAR(/obj/item/eftpos, access_code)
SAVED_VAR(/obj/item/eftpos, currency)
SAVED_VAR(/obj/item/eftpos, linked_account) //Can probably just save the account id

// Network EFTPOS. For Persistence purposes, these deprecate the normal EFTPOS devices.
SAVED_VAR(/obj/item/network_pos, account_id)
SAVED_VAR(/obj/item/network_pos, account_provider)

//ATM
SAVED_VAR(/obj/machinery/atm, held_card)
SAVED_VAR(/obj/machinery/atm, machine_id)
SAVED_VAR(/obj/machinery/atm, view_screen)
SAVED_VAR(/obj/machinery/atm, authenticated_account) //Can probably just save the account id

// These don't currently serve a purpose for us, so remove them from availability.
/datum/fabricator_recipe/engineering/atm_board
fabricator_types = list()
path = /obj/item/stock_parts/circuitboard/requests_console/atm

/datum/fabricator_recipe/engineering/atm_frame
fabricator_types = list()
path = /obj/item/frame/stock_offset/atm

/datum/fabricator_recipe/engineering/atm_kit
fabricator_types = list()
path = /obj/item/frame/stock_offset/atm/kit

//Cash
SAVED_VAR(/obj/item/cash, absolute_worth)
SAVED_VAR(/obj/item/cash, currency)
Expand All @@ -27,3 +43,6 @@ SAVED_VAR(/obj/item/charge_stick, creator)
SAVED_VAR(/obj/item/charge_stick, id)
SAVED_VAR(/obj/item/charge_stick, currency)
SAVED_VAR(/obj/item/charge_stick, grade)

// Money printer
SAVED_VAR(/obj/item/stock_parts/computer/money_printer, stored_plastic)
18 changes: 18 additions & 0 deletions mods/persistence/modules/modular_computers/networking/_network.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Some additional safety for parent accounts, recover the parent account if the banking mainframe wasn't saved
// as long as a reference to the account was held elsewhere (normally, on a child account).
/datum/computer_network/New(new_id)
. = ..()
recover_parent_account()

/datum/computer_network/change_id(new_id)
. = ..()
recover_parent_account()

/datum/computer_network/proc/recover_parent_account()
if(parent_account)
return

for(var/datum/money_account/parent/network/net_account in SSmoney_accounts.all_accounts)
if(net_account.owner_name == network_id)
parent_account = net_account
return
Loading