mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-27 15:01:04 +01:00
Adds NTNet, more programs, improvements
- Overall improvements of code, fixes, etc. - Adds NTNet and NTNet relays. They currently miss deconstruction/construction but that's planned for later. - Adds few more programs (still preinstalled in the laptop, for debugging) - Successfully gets rid of copypaste formerly needed in templates. Now the header is in default template itself. This seems to be least problematic solution without making change to nanoui's code itself.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
var/global/datum/ntnet/ntnet_global = new()
|
||||
|
||||
|
||||
// This is the NTNet datum. There can be only one NTNet datum in game at once. Modular computers read data from this.
|
||||
/datum/ntnet/
|
||||
var/list/relays = list()
|
||||
var/setting_softwaredownload = 1
|
||||
var/setting_peertopeer = 1
|
||||
var/setting_communication = 1
|
||||
var/setting_systemcontrol = 1
|
||||
|
||||
|
||||
// If new NTNet datum is spawned, it replaces the old one.
|
||||
/datum/ntnet/New()
|
||||
if(ntnet_global && (ntnet_global != src))
|
||||
ntnet_global = src // There can be only one.
|
||||
for(var/obj/machinery/ntnet_relay/R in machines)
|
||||
relays.Add(R)
|
||||
|
||||
/datum/ntnet/proc/check_function(var/specific_action = 0)
|
||||
if(!relays || !relays.len) // No relays found. NTNet is down
|
||||
return 0
|
||||
|
||||
var/operating = 0
|
||||
|
||||
// Check all relays. If we have at least one working relay, network is up.
|
||||
for(var/obj/machinery/ntnet_relay/R in relays)
|
||||
if(R.is_operational())
|
||||
operating = 1
|
||||
break
|
||||
|
||||
if(specific_action == NTNET_SOFTWAREDOWNLOAD)
|
||||
return (operating && setting_softwaredownload)
|
||||
if(specific_action == NTNET_PEERTOPEER)
|
||||
return (operating && setting_peertopeer)
|
||||
if(specific_action == NTNET_COMMUNICATION)
|
||||
return (operating && setting_communication)
|
||||
if(specific_action == NTNET_SYSTEMCONTROL)
|
||||
return (operating && setting_systemcontrol)
|
||||
return operating
|
||||
@@ -0,0 +1,21 @@
|
||||
// Relays don't handle any actual communication. Global NTNet datum does that, relays only tell the datum if it should or shouldn't work.
|
||||
/obj/machinery/ntnet_relay
|
||||
name = "NTNet Quantum Relay"
|
||||
desc = "A very complex router and transmitter capable of connecting electronic devices together. Looks fragile."
|
||||
use_power = 1
|
||||
idle_power_usage = 20000 //20kW, apropriate for machine that keeps massive cross-Zlevel wireless network operational.
|
||||
icon_state = "bus"
|
||||
|
||||
// TODO: Implement more logic here. For now it's only a placeholder.
|
||||
/obj/machinery/ntnet_relay/proc/is_operational()
|
||||
if(stat & (BROKEN | NOPOWER | EMPED))
|
||||
return 0
|
||||
return 1
|
||||
|
||||
/obj/machinery/ntnet_relay/New()
|
||||
if(ntnet_global)
|
||||
ntnet_global.relays.Add(src)
|
||||
|
||||
/obj/machinery/ntnet_relay/Destroy()
|
||||
if(ntnet_global)
|
||||
ntnet_global.relays.Remove(src)
|
||||
@@ -163,7 +163,11 @@
|
||||
battery.maxcharge = 500
|
||||
battery.charge = 500
|
||||
|
||||
hard_drive.stored_files.Add(new/datum/computer_file/program/alarm_monitor(src))
|
||||
hard_drive.stored_files.Add(new/datum/computer_file/program/power_monitor(src))
|
||||
hard_drive.stored_files.Add(new/datum/computer_file/program/atmos_control(src))
|
||||
hard_drive.stored_files.Add(new/datum/computer_file/program/rcon_console(src))
|
||||
hard_drive.stored_files.Add(new/datum/computer_file/program/suit_sensors(src))
|
||||
update_icon()
|
||||
..()
|
||||
|
||||
@@ -205,6 +209,7 @@
|
||||
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "laptop_mainscreen.tmpl", "NTOS Main Menu", 400, 500)
|
||||
ui.auto_update_layout = 1
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
@@ -224,7 +229,11 @@
|
||||
use_power = 0
|
||||
return 0
|
||||
|
||||
handle_power() // Handles all laptop power interaction
|
||||
if(active_program && active_program.requires_ntnet && !get_ntnet_status(active_program.requires_ntnet_feature)) // Active program requires NTNet to run but we've just lost connection. Crash.
|
||||
kill_program(1)
|
||||
visible_message("<span class='danger'>\The [src]'s screen briefly freezes and then shows \"NETWORK ERROR - NTNet connection lost. Please retry. If problem persists contact your system administrator.\" error.</span>")
|
||||
|
||||
handle_power() // Handles all computer power interaction
|
||||
|
||||
// Function used by NanoUI's to obtain data for header. All relevant entries begin with "PC_"
|
||||
/obj/machinery/modular_computer/proc/get_header_data()
|
||||
@@ -276,9 +285,9 @@
|
||||
update_icon()
|
||||
|
||||
// Returns 0 for No Signal, 1 for Low Signal and 2 for Good Signal. 3 is for wired connection (always-on)
|
||||
/obj/machinery/modular_computer/proc/get_ntnet_status()
|
||||
/obj/machinery/modular_computer/proc/get_ntnet_status(var/specific_action = 0)
|
||||
if(network_card)
|
||||
return network_card.get_signal()
|
||||
return network_card.get_signal(specific_action)
|
||||
else
|
||||
return 0
|
||||
|
||||
@@ -291,6 +300,7 @@
|
||||
kill_program(1)
|
||||
visible_message("\The [src] shuts down.")
|
||||
enabled = 0
|
||||
update_icon()
|
||||
return
|
||||
if( href_list["PC_runprogram"] )
|
||||
var/prog = href_list["PC_runprogram"]
|
||||
@@ -300,8 +310,12 @@
|
||||
P = hard_drive.find_file_by_name(prog)
|
||||
|
||||
if(!P || !istype(P)) // Program not found or it's not executable program.
|
||||
user << "<span class='danger'>\The [src]'s screen shows \"I/O ERROR - Unable to run program\" warning.</span>"
|
||||
return
|
||||
|
||||
if(P.requires_ntnet && !get_ntnet_status(P.requires_ntnet_feature)) // The program requires NTNet connection, but we are not connected to NTNet.
|
||||
user << "<span class='danger'>\The [src]'s screen shows \"NETWORK ERROR - Unable to connect to NTNet. Please retry. If problem persists contact your system administrator.\" warning.</span>"
|
||||
return
|
||||
if(P.run_program(user))
|
||||
active_program = P
|
||||
update_icon()
|
||||
@@ -310,7 +324,7 @@
|
||||
// Used in following function to reduce copypaste
|
||||
/obj/machinery/modular_computer/proc/power_failure()
|
||||
if(enabled) // Shut down the computer)
|
||||
visible_message("\The [src]'s screen flickers \"BATTERY CRITICAL\" warning as it shuts down unexpectedly.")
|
||||
visible_message("<span class='danger'>\The [src]'s screen flickers \"BATTERY CRITICAL\" warning as it shuts down unexpectedly.</span>")
|
||||
kill_program(1)
|
||||
enabled = 0
|
||||
update_icon()
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
var/filedesc = "Unknown Program" // User-friendly name of this program.
|
||||
var/fileicon = "unknwn" // Name of relevant icon that is displayed with the program
|
||||
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)
|
||||
|
||||
/datum/computer_file/program/New(var/atom/movable/comp = null)
|
||||
..()
|
||||
@@ -18,19 +20,29 @@
|
||||
|
||||
// Check if the user can run program. Only humans can operate computer. Automatically called in run_program()
|
||||
// User has to wear their ID or have it inhand for ID Scan to work.
|
||||
/datum/computer_file/program/proc/can_run(var/mob/living/user)
|
||||
/datum/computer_file/program/proc/can_run(var/mob/living/user, var/loud = 0)
|
||||
if(!required_access) // No required_access, allow it.
|
||||
return 1
|
||||
if(istype(user, /mob/living/carbon/human))
|
||||
var/mob/living/carbon/human/H = user
|
||||
var/obj/item/weapon/card/id/I = H.wear_id
|
||||
if(!H) // No equipped ID, let's try checking active hand too
|
||||
var/obj/item/device/pda/P = H.wear_id
|
||||
if(P && istype(P)) // PDA. Try to grab the ID from it then.
|
||||
I = P.id
|
||||
if(!I) // No equipped ID, let's try checking active hand too
|
||||
I = H.get_active_hand()
|
||||
if(!H || !istype(I)) // Still no ID.
|
||||
P = H.get_active_hand()
|
||||
if(P && istype(P))
|
||||
I = P.id
|
||||
if(!I || !istype(I)) // Still no ID.
|
||||
if(loud && computer)
|
||||
user << "<span class='danger'>\The [computer] flashes an \"RFID Error - Unable to scan ID\" warning.</span>"
|
||||
return 0
|
||||
|
||||
if(required_access in I.access)
|
||||
return 1
|
||||
if(loud && computer)
|
||||
user << "<span class='danger'>\The [computer] flashes an \"Access Denied\" warning.</span>"
|
||||
return 0
|
||||
|
||||
// This attempts to retrieve header data for NanoUIs. If implementing completely new device of different type than existing ones
|
||||
@@ -43,7 +55,7 @@
|
||||
// This is performed on program startup. May be overriden to add extra logic. Remember to include ..() call. Return 1 on success, 0 on failure.
|
||||
// When implementing new program based device, use this to run the program.
|
||||
/datum/computer_file/program/proc/run_program(var/mob/living/user)
|
||||
if(can_run(user))
|
||||
if(can_run(user, 1))
|
||||
if(nanomodule_path)
|
||||
NM = new nanomodule_path(computer) // Computer is passed here as it's (probably!) physical object. Some UI's perform get_turf() and passing program datum wouldn't go well with this.
|
||||
NM.program = src // Set the program reference to separate variable, instead.
|
||||
|
||||
@@ -2,4 +2,37 @@
|
||||
filename = "powermonitor"
|
||||
filedesc = "Power Monitoring"
|
||||
nanomodule_path = /datum/nano_module/power_monitor/
|
||||
laptop_icon_state = "power_monitor"
|
||||
laptop_icon_state = "power_monitor"
|
||||
requires_ntnet = 1
|
||||
|
||||
/datum/computer_file/program/alarm_monitor
|
||||
filename = "alarmmonitor"
|
||||
filedesc = "Alarm Monitoring"
|
||||
nanomodule_path = /datum/nano_module/alarm_monitor/engineering
|
||||
laptop_icon_state = "alarm_monitor"
|
||||
requires_ntnet = 1
|
||||
|
||||
/datum/computer_file/program/atmos_control
|
||||
filename = "atmoscontrol"
|
||||
filedesc = "Atmosphere Control"
|
||||
nanomodule_path = /datum/nano_module/atmos_control
|
||||
laptop_icon_state = "atmos_control"
|
||||
required_access = access_atmospherics
|
||||
requires_ntnet = 1
|
||||
requires_ntnet_feature = NTNET_SYSTEMCONTROL
|
||||
|
||||
/datum/computer_file/program/rcon_console
|
||||
filename = "rconconsole"
|
||||
filedesc = "RCON Remote Control"
|
||||
nanomodule_path = /datum/nano_module/rcon
|
||||
laptop_icon_state = "rcon_console"
|
||||
required_access = access_engine
|
||||
requires_ntnet = 1
|
||||
requires_ntnet_feature = NTNET_SYSTEMCONTROL
|
||||
|
||||
/datum/computer_file/program/suit_sensors
|
||||
filename = "sensormonitor"
|
||||
filedesc = "Suit Sensors Monitoring"
|
||||
nanomodule_path = /datum/nano_module/crew_monitor
|
||||
laptop_icon_state = "suit_sensors"
|
||||
requires_ntnet = 1
|
||||
@@ -23,7 +23,7 @@
|
||||
..()
|
||||
|
||||
// 0 - No signal, 1 - Low signal, 2 - High signal. 3 - Wired Connection
|
||||
/datum/computer_hardware/network_card/proc/get_signal()
|
||||
/datum/computer_hardware/network_card/proc/get_signal(var/specific_action = 0)
|
||||
if(!holder) // Hardware is not installed in anything. No signal. How did this even get called?
|
||||
return 0
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
if(ethernet) // Computer is connected via wired connection.
|
||||
return 3
|
||||
|
||||
// TODO: Add checks for NTNet Relays here!
|
||||
if(!ntnet_global || !ntnet_global.check_function(specific_action)) // NTNet is down and we are not connected via wired connection. No signal.
|
||||
return 0
|
||||
|
||||
if(holder.z in config.station_levels) // Computer is on station, High signal
|
||||
return 2
|
||||
|
||||
Reference in New Issue
Block a user