Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ports SSnetworks killings #22104

Merged
merged 3 commits into from
May 31, 2024
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
13 changes: 0 additions & 13 deletions code/__DEFINES/dcs/signals/signals_ntnet.dm

This file was deleted.

58 changes: 0 additions & 58 deletions code/__DEFINES/machines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,64 +42,6 @@
#define RACK_CREATOR (1<<9) //For AI non-physical AI hardware. (RAM expansions)
//Note: More than one of these can be added to a design but imprinter and lathe designs are incompatable.

//Modular computer/NTNet defines

//Modular computer part defines
#define MC_CPU "CPU"
#define MC_HDD "HDD"
#define MC_SDD "SDD"
#define MC_CARD "CARD"
#define MC_CARD2 "CARD2"
#define MC_NET "NET"
#define MC_PRINT "PRINT"
#define MC_CELL "CELL"
#define MC_CHARGE "CHARGE"
#define MC_AI "AI"
#define MC_SENSORS "SENSORS"
#define MC_AI_NETWORK "AINETWORK"

//NTNet stuff, for modular computers
// NTNet module-configuration values. Do not change these. If you need to add another use larger number (5..6..7 etc)
#define NTNET_SOFTWAREDOWNLOAD 1 // Downloads of software from NTNet
#define NTNET_PEERTOPEER 2 // P2P transfers of files between devices
#define NTNET_COMMUNICATION 3 // Communication (messaging)
#define NTNET_SYSTEMCONTROL 4 // Control of various systems, RCon, air alarm control, etc.

//NTNet transfer speeds, used when downloading/uploading a file/program.
#define NTNETSPEED_LOWSIGNAL 0.5 // GQ/s transfer speed when the device is wirelessly connected and on Low signal
#define NTNETSPEED_HIGHSIGNAL 1 // GQ/s transfer speed when the device is wirelessly connected and on High signal
#define NTNETSPEED_ETHERNET 3 // GQ/s transfer speed when the device is using wired connection

//Caps for NTNet logging. Less than 10 would make logging useless anyway, more than 500 may make the log browser too laggy. Defaults to 100 unless user changes it.
#define MAX_NTNET_LOGS 300
#define MIN_NTNET_LOGS 10

//Program bitflags
#define PROGRAM_ALL (~0)
#define PROGRAM_CONSOLE (1<<0)
#define PROGRAM_LAPTOP (1<<1)
#define PROGRAM_TABLET (1<<2)
#define PROGRAM_PHONE (1<<3)
#define PROGRAM_PDA (1<<4)
#define PROGRAM_TELESCREEN (1<<5)
#define PROGRAM_INTEGRATED (1<<6)

#define PROGRAM_PORTABLE PROGRAM_LAPTOP | PROGRAM_TABLET | PROGRAM_PHONE | PROGRAM_PDA
#define PROGRAM_STATIONARY PROGRAM_CONSOLE | PROGRAM_TELESCREEN

//Program states
#define PROGRAM_STATE_KILLED 0
#define PROGRAM_STATE_BACKGROUND 1
#define PROGRAM_STATE_ACTIVE 2
//Program categories
#define PROGRAM_CATEGORY_CMD "Command"
#define PROGRAM_CATEGORY_SEC "Security"
#define PROGRAM_CATEGORY_ENGI "Engineering"
#define PROGRAM_CATEGORY_SCI "Science"
#define PROGRAM_CATEGORY_MED "Medical"
#define PROGRAM_CATEGORY_SUPL "Supply"
#define PROGRAM_CATEGORY_MISC "Other"

#define FIREDOOR_OPEN 1
#define FIREDOOR_CLOSED 2

Expand Down
116 changes: 116 additions & 0 deletions code/__DEFINES/modular_computer.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// Used to stringify message targets before sending the signal datum.
#define STRINGIFY_PDA_TARGET(name, job) "[name] ([job])"
/**
* program_flags
* Used by programs to tell the ModPC any special functions it has.
*/
/* //TODO: Add these back in when TG ModPCs are ported.
///If the program requires NTNet to be online for it to work.
#define PROGRAM_REQUIRES_NTNET (1<<0)
///The program can be downloaded from the default NTNet downloader store.
#define PROGRAM_ON_NTNET_STORE (1<<1)
///The program can only be downloaded from the Syndinet store, usually nukie/emagged pda.
#define PROGRAM_ON_SYNDINET_STORE (1<<2)
///The program is unique and will delete itself upon being transferred to ensure only one copy exists.
#define PROGRAM_UNIQUE_COPY (1<<3)
///The program is a header and will show up at the top of the ModPC's UI.
#define PROGRAM_HEADER (1<<4)
///The program will run despite the ModPC not having any power in it.
#define PROGRAM_RUNS_WITHOUT_POWER (1<<5)
///The circuit ports of this program can be triggered even if the program is not open
#define PROGRAM_CIRCUITS_RUN_WHEN_CLOSED (1<<6)
*/

//Program categories
#define PROGRAM_CATEGORY_DEVICE "Device Tools"
#define PROGRAM_CATEGORY_EQUIPMENT "Equipment"
#define PROGRAM_CATEGORY_GAMES "Games"
#define PROGRAM_CATEGORY_SECURITY "Security & Records"
#define PROGRAM_CATEGORY_ENGINEERING "Engineering"
#define PROGRAM_CATEGORY_SUPPLY "Supply"
#define PROGRAM_CATEGORY_SCIENCE "Science"

///The default amount a program should take in cell use.
#define PROGRAM_BASIC_CELL_USE 15

///This app grants a minor protection against being PDA bombed if installed.
///(can sometimes prevent it from being sent, while wasting a PDA bomb from the sender).
#define DETOMATIX_RESIST_MINOR 1
///This app grants a larger protection against being PDA bombed if installed.
///(can sometimes prevent it from being sent, while wasting a PDA bomb from the sender).
#define DETOMATIX_RESIST_MAJOR 2
///This app gives a diminished protection against being PDA bombed if installed.
#define DETOMATIX_RESIST_MALUS -4

/**
* NTNet transfer speeds, used when downloading/uploading a file/program.
* The define is how fast it will download an app every program's process_tick.
*/
///Used for wireless devices with low signal.
#define NTNETSPEED_LOWSIGNAL 0.5
///Used for wireless devices with high signal.
#define NTNETSPEED_HIGHSIGNAL 1
///Used for laptops with a high signal, or computers, which is connected regardless of z level.
#define NTNETSPEED_ETHERNET 2

/**
* NTNet connection signals
* Used to calculate the defines above from NTNet Downloader, this is how
* good a ModPC's signal is.
*/
///When you're away from the station/mining base and not on a console, you can't access the internet.
#define NTNET_NO_SIGNAL 0
///Low signal, so away from the station, but still connected
#define NTNET_LOW_SIGNAL 1
///On station with good signal.
#define NTNET_GOOD_SIGNAL 2
///Using a Computer or Laptop with good signal, ethernet-connected.
#define NTNET_ETHERNET_SIGNAL 3

/// The default ringtone of the Messenger app.
#define MESSENGER_RINGTONE_DEFAULT "beep"

/// The maximum length of the ringtone of the Messenger app.
#define MESSENGER_RINGTONE_MAX_LENGTH 20

//Modular computer part defines
#define MC_CPU "CPU"
#define MC_HDD "HDD"
#define MC_SDD "SDD"
#define MC_CARD "CARD"
#define MC_CARD2 "CARD2"
#define MC_NET "NET"
#define MC_PRINT "PRINT"
#define MC_CELL "CELL"
#define MC_CHARGE "CHARGE"
#define MC_AI "AI"
#define MC_SENSORS "SENSORS"
#define MC_AI_NETWORK "AINETWORK"

//NTNet stuff, for modular computers
// NTNet module-configuration values. Do not change these. If you need to add another use larger number (5..6..7 etc)
#define NTNET_SOFTWAREDOWNLOAD 1 // Downloads of software from NTNet
#define NTNET_COMMUNICATION 2 // Communication (messaging)


//Caps for NTNet logging. Less than 10 would make logging useless anyway, more than 500 may make the log browser too laggy. Defaults to 100 unless user changes it.
#define MAX_NTNET_LOGS 300
#define MIN_NTNET_LOGS 10

//Program bitflags
#define PROGRAM_ALL (~0)
#define PROGRAM_CONSOLE (1<<0)
#define PROGRAM_LAPTOP (1<<1)
#define PROGRAM_TABLET (1<<2)
#define PROGRAM_PHONE (1<<3)
#define PROGRAM_PDA (1<<4)
#define PROGRAM_TELESCREEN (1<<5)
#define PROGRAM_INTEGRATED (1<<6)

#define PROGRAM_PORTABLE PROGRAM_LAPTOP | PROGRAM_TABLET | PROGRAM_PHONE | PROGRAM_PDA
#define PROGRAM_STATIONARY PROGRAM_CONSOLE | PROGRAM_TELESCREEN

//Program states
#define PROGRAM_STATE_KILLED 0
#define PROGRAM_STATE_BACKGROUND 1
#define PROGRAM_STATE_ACTIVE 2
3 changes: 0 additions & 3 deletions code/__DEFINES/networks.dm

This file was deleted.

2 changes: 0 additions & 2 deletions code/__DEFINES/subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@
#define INIT_ORDER_TICKER 55
#define INIT_ORDER_MAPPING 50
#define INIT_ORDER_EARLY_ASSETS 48
#define INIT_ORDER_NETWORKS 45
#define INIT_ORDER_ECONOMY 40
#define INIT_ORDER_OUTPUTS 35
#define INIT_ORDER_ATOMS 30
Expand Down Expand Up @@ -199,7 +198,6 @@
#define FIRE_PRIORITY_SPACEDRIFT 30
#define FIRE_PRIORITY_FIELDS 30
#define FIRE_PRIORITY_SMOOTHING 35
#define FIRE_PRIORITY_NETWORKS 40
#define FIRE_PRIORITY_OBJ 40
#define FIRE_PRIORITY_ACID 40
#define FIRE_PRIORITY_BURNING 40
Expand Down
33 changes: 33 additions & 0 deletions code/__HELPERS/names.dm
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,36 @@ GLOBAL_DATUM(syndicate_code_response_regex, /regex)
. += "."
else
. += ", "

/**
* Generate a name devices
*
* Creates a randomly generated tag or name for devices or anything really
* it keeps track of a special list that makes sure no name is used more than
* once
*
* args:
* * len (int)(Optional) Default=5 The length of the name
* * prefix (string)(Optional) static text in front of the random name
* * postfix (string)(Optional) static text in back of the random name
* Returns (string) The generated name
*/
/proc/assign_random_name(len=5, prefix="", postfix="")
//DO NOT REMOVE NAMES HERE UNLESS YOU KNOW WHAT YOU'RE DOING
//All names already used
var/static/list/used_names = list()

var/static/valid_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
var/list/new_name = list()
var/text
// machine id's should be fun random chars hinting at a larger world
do
new_name.Cut()
new_name += prefix
for(var/i = 1 to len)
new_name += valid_chars[rand(1,length(valid_chars))]
new_name += postfix
text = new_name.Join()
while(used_names[text])
used_names[text] = TRUE
return text
124 changes: 124 additions & 0 deletions code/controllers/subsystem/modular_computers.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
///The maximum amount of logs that can be generated before they start overwriting eachother.
#define MAX_LOG_COUNT 300

SUBSYSTEM_DEF(modular_computers)
name = "Modular Computers"
flags = SS_KEEP_TIMING | SS_NO_FIRE
wait = 1 MINUTES
runlevels = RUNLEVEL_GAME
loading_points = 1 SECONDS // Yogs -- loading times

///List of all logs generated by ModPCs through the round.
///Stops at MAX_LOG_COUNT and must be purged to keep logging.
var/list/modpc_logs = list()

///Boolean on whether downloading software works.
var/setting_softwaredownload = TRUE
///Boolean on whether downloading communication apps like the Chat client works.
var/setting_communication = TRUE

///List of all programs available to download from the NTNet store.
var/list/available_station_software = list()
///List of all programs that can be downloaded from an emagged NTNet store.
var/list/available_antag_software = list()
///List of all chat channels created by Chat Client.
var/list/chat_channels = list()

///Boolean on whether the IDS warning system is enabled
var/intrusion_detection_enabled = TRUE
///Boolean to show a message warning if there's an active intrusion for Wirecarp users.
var/intrusion_detection_alarm = FALSE
var/next_picture_id = 0

/datum/controller/subsystem/modular_computers/Initialize()
build_software_lists()
initialized = TRUE
return SS_INIT_SUCCESS

///Finds all downloadable programs and adds them to their respective downloadable list.
/datum/controller/subsystem/modular_computers/proc/build_software_lists()
for(var/datum/computer_file/program/prog as anything in subtypesof(/datum/computer_file/program))
// Has no TGUI file so is not meant to be a downloadable thing.
if(!initial(prog.tgui_id) || !initial(prog.filename))
continue
prog = new prog

if(prog.available_on_ntnet)
available_station_software.Add(prog)
if(prog.available_on_syndinet)
available_antag_software.Add(prog)

///Attempts to find a new file through searching the available stores with its name.
/datum/controller/subsystem/modular_computers/proc/find_ntnet_file_by_name(filename)
for(var/datum/computer_file/program/programs as anything in available_station_software + available_antag_software)
if(filename == programs.filename)
return programs
return null

///Attempts to find a chatorom using the ID of the channel.
/datum/controller/subsystem/modular_computers/proc/get_chat_channel_by_id(id)
for(var/datum/ntnet_conversation/chan as anything in chat_channels)
if(chan.id == id)
return chan
return null

/**
* Records a message into the station logging system for the network
* Arguments:
* * log_string - The message being logged
*/
/datum/controller/subsystem/modular_computers/proc/add_log(log_string)
var/list/log_text = list()
log_text += "\[[station_time_timestamp()]\]"
log_text += "*SYSTEM* - "
log_text += log_string
log_string = log_text.Join()

modpc_logs.Add(log_string)

// We have too many logs, remove the oldest entries until we get into the limit
if(modpc_logs.len > MAX_LOG_COUNT)
modpc_logs = modpc_logs.Copy(modpc_logs.len - MAX_LOG_COUNT, 0)

/datum/controller/subsystem/modular_computers/proc/toggle_function(function)
if(!function)
return
function = text2num(function)
switch(function)
if(NTNET_SOFTWAREDOWNLOAD)
setting_softwaredownload = !setting_softwaredownload
SSmodular_computers.add_log("Configuration Updated. Wireless network firewall now [setting_softwaredownload ? "allows" : "disallows"] connection to software repositories.")
if(NTNET_COMMUNICATION)
setting_communication = !setting_communication
SSmodular_computers.add_log("Configuration Updated. Wireless network firewall now [setting_communication ? "allows" : "disallows"] instant messaging and similar communication services.")

///Checks whether NTNet is available for a specific function, checking NTNet relays and shutdowns. If none is passed, none is needed.
/datum/controller/subsystem/modular_computers/proc/check_function(specific_action = NONE)
//NTNet is down.
if(!find_functional_ntnet_relay())
return FALSE

switch(specific_action)
if(NTNET_SOFTWAREDOWNLOAD)
return setting_softwaredownload
if(NTNET_COMMUNICATION)
return setting_communication
return TRUE

/**
* Removes all station logs and leaves it with an alert that it's been wiped.
*/
/datum/controller/subsystem/modular_computers/proc/purge_logs()
modpc_logs = list()
add_log("-!- LOGS DELETED BY SYSTEM OPERATOR -!-")

/**
* Returns a name which a /datum/picture can be assigned to.
* Use this function to get asset names and to avoid cache duplicates/overwriting.
*/
/datum/controller/subsystem/modular_computers/proc/get_next_picture_name()
var/next_uid = next_picture_id
next_picture_id++
return "ntos_picture_[next_uid].png"

#undef MAX_LOG_COUNT
Loading
Loading