From 1987b9f0f16245a7ecb00e95485333067e7b0641 Mon Sep 17 00:00:00 2001 From: Atlantis Date: Fri, 3 Jul 2015 06:10:47 +0200 Subject: [PATCH] Improvements to NTNet and file mechanics - Small adjustments to NTNet behaviour. - Adds "undeletable" and "unmovable" flags for computer files. Intended to use for ROM-style programs that are necessary for PC to work. - Programs now know NTNet status and can act differently depending on this. --- code/__defines/misc.dm | 2 +- code/modules/modular_computers/NTNet/NTNet.dm | 1 + code/modules/modular_computers/NTNet/NTNet_relay.dm | 9 ++++++++- .../modular_computers/computers/modular_computer.dm | 1 + .../modular_computers/file_system/computer_file.dm | 5 +++-- code/modules/modular_computers/file_system/program.dm | 6 ++++-- code/modules/modular_computers/hardware/network_card.dm | 1 + nano/templates/layout_default.tmpl | 4 +++- 8 files changed, 22 insertions(+), 7 deletions(-) diff --git a/code/__defines/misc.dm b/code/__defines/misc.dm index 575caa17f44..ac32880dd12 100644 --- a/code/__defines/misc.dm +++ b/code/__defines/misc.dm @@ -155,7 +155,7 @@ #define BOMBCAP_LIGHT_RADIUS max_explosion_range #define BOMBCAP_FLASH_RADIUS (max_explosion_range*1.5) - // NTNet configuration options + // 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) diff --git a/code/modules/modular_computers/NTNet/NTNet.dm b/code/modules/modular_computers/NTNet/NTNet.dm index f076cdf8a55..abcf5756d60 100644 --- a/code/modules/modular_computers/NTNet/NTNet.dm +++ b/code/modules/modular_computers/NTNet/NTNet.dm @@ -16,6 +16,7 @@ var/global/datum/ntnet/ntnet_global = new() ntnet_global = src // There can be only one. for(var/obj/machinery/ntnet_relay/R in machines) relays.Add(R) + R.NTNet = src /datum/ntnet/proc/check_function(var/specific_action = 0) if(!relays || !relays.len) // No relays found. NTNet is down diff --git a/code/modules/modular_computers/NTNet/NTNet_relay.dm b/code/modules/modular_computers/NTNet/NTNet_relay.dm index 528a7e00136..77258dc7ed7 100644 --- a/code/modules/modular_computers/NTNet/NTNet_relay.dm +++ b/code/modules/modular_computers/NTNet/NTNet_relay.dm @@ -5,6 +5,9 @@ use_power = 1 idle_power_usage = 20000 //20kW, apropriate for machine that keeps massive cross-Zlevel wireless network operational. icon_state = "bus" + anchored = 1 + density = 1 + var/NTNet = null // This is mostly for backwards reference and to allow varedit modifications from ingame. // TODO: Implement more logic here. For now it's only a placeholder. /obj/machinery/ntnet_relay/proc/is_operational() @@ -15,7 +18,11 @@ /obj/machinery/ntnet_relay/New() if(ntnet_global) ntnet_global.relays.Add(src) + NTNet = ntnet_global + ..() /obj/machinery/ntnet_relay/Destroy() if(ntnet_global) - ntnet_global.relays.Remove(src) \ No newline at end of file + ntnet_global.relays.Remove(src) + NTNet = null + ..() \ No newline at end of file diff --git a/code/modules/modular_computers/computers/modular_computer.dm b/code/modules/modular_computers/computers/modular_computer.dm index e040d1716e1..a74e8a75b2a 100644 --- a/code/modules/modular_computers/computers/modular_computer.dm +++ b/code/modules/modular_computers/computers/modular_computer.dm @@ -271,6 +271,7 @@ data["PC_stationtime"] = worldtime2text() data["PC_hasheader"] = 1 + data["PC_showexitprogram"] = active_program ? 1 : 0 // Hides "Exit Program" button on mainscreen return data diff --git a/code/modules/modular_computers/file_system/computer_file.dm b/code/modules/modular_computers/file_system/computer_file.dm index b62c01cff0d..729c9379e9b 100644 --- a/code/modules/modular_computers/file_system/computer_file.dm +++ b/code/modules/modular_computers/file_system/computer_file.dm @@ -4,7 +4,8 @@ var/size = 1 // File size in GQ (default 1, do not change unless you really have to). Non-1 values are currently unused but they should be supported. var/datum/computer_hardware/hard_drive/holder // Holder that contains this file. var/icon_path = null // !!32x32!! icon of this program - + var/unsendable = 0 // Whether the file may be sent to someone via NTNet transfer or other means. + var/undeletable = 0 // Whether the file may be deleted. Setting to 1 prevents deletion/renaming/etc. /datum/computer_file/Destroy() if(!holder) @@ -15,4 +16,4 @@ if(holder.holder && holder.holder.active_program == src) holder.holder.kill_program(1) holder = null - ..() + ..() \ No newline at end of file diff --git a/code/modules/modular_computers/file_system/program.dm b/code/modules/modular_computers/file_system/program.dm index b16cd8918c3..deb7ef03127 100644 --- a/code/modules/modular_computers/file_system/program.dm +++ b/code/modules/modular_computers/file_system/program.dm @@ -8,10 +8,11 @@ var/running = 1 // Set to 1 when the program is run and back to 0 when it's stopped. var/atom/movable/computer = null // Device that runs this program. var/filedesc = "Unknown Program" // User-friendly name of this program. - var/fileicon = "unknwn" // Name of relevant icon that is displayed with the program + var/fileicon = "unknwn" // Name of relevant icon that is displayed with the program. Currently unused. var/laptop_icon_state = null // Program-specific icon state (stored in /icons/obj/computer3.dmi) var/requires_ntnet = 0 // Set to 1 for program to require nonstop NTNet connection to run. If NTNet connection is lost program crashes. var/requires_ntnet_feature = 0 // Optional, if above is set to 1 checks for specific function of NTNet (currently NTNET_SOFTWAREDOWNLOAD, NTNET_PEERTOPEER, NTNET_SYSTEMCONTROL and NTNET_COMMUNICATION) + var/ntnet_status = 1 // NTNet status, updated every tick by computer running this program. Don't use this for checks if NTNet works, computers do that. Use this for calculations, etc. /datum/computer_file/program/New(var/atom/movable/comp = null) ..() @@ -92,4 +93,5 @@ if(computer) computer.Topic(href, href_list) - ..() \ No newline at end of file + ..() + diff --git a/code/modules/modular_computers/hardware/network_card.dm b/code/modules/modular_computers/hardware/network_card.dm index ff2fb20eb64..6263af7b2a5 100644 --- a/code/modules/modular_computers/hardware/network_card.dm +++ b/code/modules/modular_computers/hardware/network_card.dm @@ -3,6 +3,7 @@ desc = "A basic network card for usage with standard NTNet frequencies." power_usage = 50 critical = 0 + var/identification_string = "" // Identification string, technically nickname seen in the network. Can be set by user. var/long_range = 0 var/ethernet = 0 // Hard-wired, therefore always on, ignores NTNet wireless checks. diff --git a/nano/templates/layout_default.tmpl b/nano/templates/layout_default.tmpl index 7d30d5a4219..97550c0ba00 100644 --- a/nano/templates/layout_default.tmpl +++ b/nano/templates/layout_default.tmpl @@ -23,7 +23,9 @@
{{:helper.link('Shutdown', 'icon-power', {'PC_shutdown' : 1})}} - {{:helper.link('Exit Program', 'icon-close', {'PC_exit' : 1})}} + {{if data.PC_showexitprogram}} + {{:helper.link('Exit Program', 'icon-close', {'PC_exit' : 1})}} + {{/if}}