Modern Modular Computers

This commit is contained in:
Unknown
2019-04-13 14:58:08 -04:00
parent a0904cb9fd
commit dfd9415458
164 changed files with 3597 additions and 2080 deletions

View File

@@ -27,10 +27,7 @@ var/global/ntnrc_uid = 0
/datum/ntnet_conversation/proc/trim_message_list()
if(messages.len <= 50)
return
for(var/message in messages)
messages -= message
if(messages <= 50)
return
messages.Cut(1, (messages.len-49))
/datum/ntnet_conversation/proc/add_client(var/datum/computer_file/program/chatclient/C)
if(!istype(C))

View File

@@ -10,6 +10,7 @@ var/global/datum/ntnet/ntnet_global = new()
var/list/available_news = list()
var/list/chat_channels = list()
var/list/fileservers = list()
var/list/email_accounts = list() // I guess we won't have more than 999 email accounts active at once in single round, so this will do until Servers are implemented someday.
// Amount of logs the system tries to keep in memory. Keep below 999 to prevent byond from acting weirdly.
// High values make displaying logs much laggier.
var/setting_maxlogcount = 100
@@ -34,8 +35,13 @@ var/global/datum/ntnet/ntnet_global = new()
R.NTNet = src
build_software_lists()
build_news_list()
build_emails_list()
add_log("NTNet logging system activated.")
/datum/ntnet/proc/add_log_with_ids_check(var/log_string, var/obj/item/weapon/computer_hardware/network_card/source = null)
if(intrusion_detection_enabled)
add_log(log_string, source)
// Simplified logging: Adds a log. log_string is mandatory parameter, source is optional.
/datum/ntnet/proc/add_log(var/log_string, var/obj/item/weapon/computer_hardware/network_card/source = null)
var/log_text = "[stationtime2text()] - "
@@ -103,6 +109,10 @@ var/global/datum/ntnet/ntnet_global = new()
if(news.stored_data)
available_news.Add(news)
// Generates service email list. Currently only used by broadcaster service
/datum/ntnet/proc/build_emails_list()
for(var/F in subtypesof(/datum/computer_file/data/email_account/service))
new F()
// Attempts to find a downloadable file according to filename var
/datum/ntnet/proc/find_ntnet_file_by_name(var/filename)
@@ -153,7 +163,11 @@ var/global/datum/ntnet/ntnet_global = new()
setting_systemcontrol = !setting_systemcontrol
add_log("Configuration Updated. Wireless network firewall now [setting_systemcontrol ? "allows" : "disallows"] remote control of station's systems.")
/datum/ntnet/proc/does_email_exist(var/login)
for(var/datum/computer_file/data/email_account/A in ntnet_global.email_accounts)
if(A.login == login)
return 1
return 0

View File

@@ -0,0 +1,82 @@
/datum/computer_file/data/email_account/
var/list/inbox = list()
var/list/spam = list()
var/list/deleted = list()
var/login = ""
var/password = ""
var/can_login = TRUE // Whether you can log in with this account. Set to false for system accounts
var/suspended = FALSE // Whether the account is banned by the SA.
/datum/computer_file/data/email_account/calculate_size()
size = 1
for(var/datum/computer_file/data/email_message/stored_message in all_emails())
stored_message.calculate_size()
size += stored_message.size
/datum/computer_file/data/email_account/New()
ntnet_global.email_accounts.Add(src)
..()
/datum/computer_file/data/email_account/Destroy()
ntnet_global.email_accounts.Remove(src)
. = ..()
/datum/computer_file/data/email_account/proc/all_emails()
return (inbox | spam | deleted)
/datum/computer_file/data/email_account/proc/send_mail(var/recipient_address, var/datum/computer_file/data/email_message/message, var/relayed = 0)
var/datum/computer_file/data/email_account/recipient
for(var/datum/computer_file/data/email_account/account in ntnet_global.email_accounts)
if(account.login == recipient_address)
recipient = account
break
if(!istype(recipient))
return 0
if(!recipient.receive_mail(message, relayed))
return
ntnet_global.add_log_with_ids_check("EMAIL LOG: [login] -> [recipient.login] title: [message.title].")
return 1
/datum/computer_file/data/email_account/proc/receive_mail(var/datum/computer_file/data/email_message/received_message, var/relayed)
received_message.set_timestamp()
if(!ntnet_global.intrusion_detection_enabled)
inbox.Add(received_message)
return 1
// Spam filters may occassionally let something through, or mark something as spam that isn't spam.
if(received_message.spam)
if(prob(98))
spam.Add(received_message)
else
inbox.Add(received_message)
else
if(prob(1))
spam.Add(received_message)
else
inbox.Add(received_message)
return 1
// Address namespace (@internal-services.nt) for email addresses with special purpose only!.
/datum/computer_file/data/email_account/service/
can_login = FALSE
/datum/computer_file/data/email_account/service/broadcaster/
login = "broadcast@internal-services.nt"
/datum/computer_file/data/email_account/service/broadcaster/receive_mail(var/datum/computer_file/data/email_message/received_message, var/relayed)
if(!istype(received_message) || relayed)
return 0
// Possibly exploitable for user spamming so keep admins informed.
if(!received_message.spam)
log_and_message_admins("Broadcast email address used by [usr]. Message title: [received_message.title].")
spawn(0)
for(var/datum/computer_file/data/email_account/email_account in ntnet_global.email_accounts)
var/datum/computer_file/data/email_message/new_message = received_message.clone()
send_mail(email_account.login, new_message, 1)
sleep(2)
return 1

View File

@@ -0,0 +1,32 @@
// Currently not actually represented in file systems, though the support for it is in place already.
/datum/computer_file/data/email_message/
stored_data = ""
var/title = ""
var/source = ""
var/spam = FALSE
var/timestamp = ""
var/datum/computer_file/attachment = null
/datum/computer_file/data/email_message/clone()
var/datum/computer_file/data/email_message/temp = ..()
temp.title = title
temp.source = source
temp.spam = spam
temp.timestamp = timestamp
if(attachment)
temp.attachment = attachment.clone()
return temp
// Turns /email_message/ file into regular /data/ file.
/datum/computer_file/data/email_message/proc/export()
var/datum/computer_file/data/dat = new/datum/computer_file/data()
dat.stored_data = "Received from [source] at [timestamp]."
dat.stored_data += "\[b\][title]\[/b\]"
dat.stored_data += stored_data
dat.calculate_size()
return dat
/datum/computer_file/data/email_message/proc/set_timestamp()
timestamp = stationtime2text()