-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathmodular_computers.dm
124 lines (105 loc) · 4.7 KB
/
modular_computers.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
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