From b3ebfcad270d9c186016b39480a75287cc9a344e Mon Sep 17 00:00:00 2001
From: Francinum <5572280+francinum@users.noreply.github.com>
Date: Tue, 5 Aug 2025 21:46:37 -0400
Subject: [PATCH 01/14] AGONY
---
code/__DEFINES/computer4_defines.dm | 5 +
code/__DEFINES/packetnet.dm | 23 ++
code/modules/computer4/data/socket.dm | 81 ++++++
.../data/terminal/medtrak/medtrak.dm | 5 +-
.../data/terminal/operating_system.dm | 237 ------------------
.../operating_system/_operating_system.dm | 80 ++++++
.../terminal/operating_system/filesystem.dm | 73 ++++++
.../terminal/operating_system/networking.dm | 29 +++
.../operating_system/program_management.dm | 90 +++++++
.../{ => operating_system}/rtos/_rtos.dm | 0
.../rtos/access_door.dm | 0
.../rtos/pincode_door.dm | 0
.../rtos/simple_door_control.dm | 0
.../{ => operating_system}/rtos/slave.dm | 0
.../thinkdos/thinkdos.dm | 2 +-
.../thinkdos/thinkdos_commands.dm | 0
.../thinkdos/thinkdos_signals.dm | 0
daedalus.dme | 22 +-
18 files changed, 399 insertions(+), 248 deletions(-)
create mode 100644 code/modules/computer4/data/socket.dm
delete mode 100644 code/modules/computer4/data/terminal/operating_system.dm
create mode 100644 code/modules/computer4/data/terminal/operating_system/_operating_system.dm
create mode 100644 code/modules/computer4/data/terminal/operating_system/filesystem.dm
create mode 100644 code/modules/computer4/data/terminal/operating_system/networking.dm
create mode 100644 code/modules/computer4/data/terminal/operating_system/program_management.dm
rename code/modules/computer4/data/terminal/{ => operating_system}/rtos/_rtos.dm (100%)
rename code/modules/computer4/data/terminal/{ => operating_system}/rtos/access_door.dm (100%)
rename code/modules/computer4/data/terminal/{ => operating_system}/rtos/pincode_door.dm (100%)
rename code/modules/computer4/data/terminal/{ => operating_system}/rtos/simple_door_control.dm (100%)
rename code/modules/computer4/data/terminal/{ => operating_system}/rtos/slave.dm (100%)
rename code/modules/computer4/data/terminal/{ => operating_system}/thinkdos/thinkdos.dm (98%)
rename code/modules/computer4/data/terminal/{ => operating_system}/thinkdos/thinkdos_commands.dm (100%)
rename code/modules/computer4/data/terminal/{ => operating_system}/thinkdos/thinkdos_signals.dm (100%)
diff --git a/code/__DEFINES/computer4_defines.dm b/code/__DEFINES/computer4_defines.dm
index 39b2ffeaff0c..870c5c90a30c 100644
--- a/code/__DEFINES/computer4_defines.dm
+++ b/code/__DEFINES/computer4_defines.dm
@@ -26,3 +26,8 @@
#define WIRELESS_FILTER_ID_TAGS 2 //! id_tag based filtering, for non-GPRS Control.
#define WIRELESS_FILTER_MODEMAX 2 //! Max of WIRELESS_FILTER_* Defines.
+
+// PDP BindPort return values
+
+#define PDP_BIND_FAILED_CATASTROPHIC 1 //! What the fuck did you do???
+#define PDP_BIND_FAILED_CONFLICT 2 //! Port already bound?
diff --git a/code/__DEFINES/packetnet.dm b/code/__DEFINES/packetnet.dm
index c0c4c12c8c46..19f95ab4b289 100644
--- a/code/__DEFINES/packetnet.dm
+++ b/code/__DEFINES/packetnet.dm
@@ -40,6 +40,9 @@
/// Network Class of a device, used as part of ping replies.
#define PACKET_NETCLASS "netclass"
+#define PACKET_ARG_PROTOCOL "proto"
+ #define PACKET_ARG_PROTOCOL_PDP "pdp"
+
// Pagers
/// Packet arg for pager types
#define PACKET_ARG_PAGER_CLASS "pager_class"
@@ -103,3 +106,23 @@
#define MAGIC_DATA_INVIOLABLE ALL
#define PACKET_STRING_FILE "packetnet.json"
+
+// -----
+// PDP Protocol Fields
+// These are partially duplicates of above but Deal With It.
+
+#define PDP_SOURCE_ADDRESS PACKET_SOURCE_ADDRESS
+#define PDP_DESTINATION_ADDRESS PACKET_DESTINATION_ADDRESS
+
+#define PDP_SOURCE_PORT "s_port"
+#define PDP_DESTINATION_PORT "d_port"
+
+/// PDP Payload Data. Is a list.
+#define PDP_PAYLOAD_DATA "payload"
+
+
+// -----
+// PDP Port Allocations
+
+#define PDP_MAX_PORT 65535 //! Maximum PDP Port number
+#define PDP_EPHEMERAL_START 64000 //! Start of PDP Ephemeral Range, used for outgoing client connections.
diff --git a/code/modules/computer4/data/socket.dm b/code/modules/computer4/data/socket.dm
new file mode 100644
index 000000000000..57bc42f79ef6
--- /dev/null
+++ b/code/modules/computer4/data/socket.dm
@@ -0,0 +1,81 @@
+/*
+ * Ported Datagram Protocol Socket
+ */
+
+#define PDP_SOCKET_QUEUE_DEPTH 50
+/// 'Real' insert position, subject to BYOND Listism.
+#define PDP_S_HEAD_REAL (head_pointer+1)
+/// 'Real' read position, subject to BYOND Listism.
+#define PDP_S_TAIL_REAL (tail_pointer+1)
+
+#if PDP_SOCKET_QUEUE_DEPTH < 3
+#error PDP_SOCKET_QUEUE_DEPTH is too short. If you trigger this, good fucking job:tm:
+#endif
+
+/datum/pdp_socket
+ /// Next Hop datum we send our packets to, Usually an operating system, but may be a physical network device.
+ var/datum/outgoing_datum
+ /// 'Owner' that registered for this socket. Used to assure ownership.
+ var/datum/owner
+ /// PDP Port the socket is bound to, Packets being sent out of this socket will have their source port set to this.
+ var/bound_port
+
+
+ /// Packet ring buffer
+ VAR_PRIVATE/list/packet_buffer
+ /// Insertion point, Incremented on packet receive. Will drop instead if =tail_pointer-1
+ /// Do not use directly, Must add 1 to account for list jank
+ VAR_PRIVATE/head_pointer
+ /// Read pointer, Incremented on packet read, Will not increment if there is no packet to read.
+ VAR_PRIVATE/tail_pointer
+
+/datum/pdp_socket/New(bound_port, outgoing_datum, owner)
+ if(!bound_port)
+ stack_trace("Created a PDP socket without a port number?")
+
+ src.bound_port = bound_port
+ src.outgoing_datum = outgoing_datum
+ src.owner = owner
+ packet_buffer = new /list(PDP_SOCKET_QUEUE_DEPTH)
+ head_pointer = 0
+ tail_pointer = 0
+
+/// Place received packet into ringqueue. Returns TRUE if inserted, FALSE if dropped due to full queue.
+// No lohi I am not implimenting DSCP. Right now, at least. Maybe later.
+/datum/pdp_socket/proc/enqueue(datum/signal/packet)
+ if(((head_pointer + 1) % PDP_SOCKET_QUEUE_DEPTH) == tail_pointer)
+ return FALSE //Ring full, Drop the packet.
+ packet_buffer[PDP_S_HEAD_REAL] = packet
+ head_pointer = (head_pointer+1) % PDP_SOCKET_QUEUE_DEPTH
+ return TRUE
+
+/// Get next signal in queue, or null if queue is dry.
+/datum/pdp_socket/proc/pop()
+ . = packet_buffer[PDP_S_TAIL_REAL]
+ if(!.)
+ return null
+ tail_pointer = (tail_pointer+1) % PDP_SOCKET_QUEUE_DEPTH
+ //return .
+
+#undef PDP_SOCKET_QUEUE_DEPTH
+#undef PDP_S_HEAD_REAL
+#undef PDP_S_TAIL_REAL
+
+/// Send a PDP payload packet to the destionation port and address.
+/datum/pdp_socket/proc/send_data(d_address, d_port, list/payload)
+ // Packets come out of this preeetty skeletonized, Higher layers above this are expected to fill out some remaining details
+ // Such as source address.
+
+ var/list/packet_data = list(
+ PACKET_ARG_PROTOCOL = PACKET_ARG_PROTOCOL_PDP,
+
+ PDP_DESTINATION_ADDRESS = d_address,
+ PDP_DESTINATION_PORT = d_port,
+
+ //Source address set at NIC
+ PDP_SOURCE_PORT = bound_port,
+
+ PDP_PAYLOAD_DATA = payload
+ )
+
+ var/datum/signal/packet = new(null, packet_data)
diff --git a/code/modules/computer4/data/terminal/medtrak/medtrak.dm b/code/modules/computer4/data/terminal/medtrak/medtrak.dm
index fd8688a948f0..b3512a9ea11b 100644
--- a/code/modules/computer4/data/terminal/medtrak/medtrak.dm
+++ b/code/modules/computer4/data/terminal/medtrak/medtrak.dm
@@ -68,7 +68,10 @@
/// Getter for the log file. This isn't kept as a ref because I don't want to manage the ref. :)
/datum/c4_file/terminal_program/medtrak/proc/get_log_file()
RETURN_TYPE(/datum/c4_file/text)
- var/datum/c4_file/folder/log_dir = get_os().get_log_folder()
+
+ // Sue me. Come up with a better way to do this that doesn't demand dead procs on the OS basetype.
+ // (Suggestion: Move medtrak and such to a thinkdos-specific subtype of terminal_program) (t_prog/dos/medtrak)
+ var/datum/c4_file/folder/log_dir = get_os():get_log_folder()
if(!log_dir)
return null
diff --git a/code/modules/computer4/data/terminal/operating_system.dm b/code/modules/computer4/data/terminal/operating_system.dm
deleted file mode 100644
index 7437791d825a..000000000000
--- a/code/modules/computer4/data/terminal/operating_system.dm
+++ /dev/null
@@ -1,237 +0,0 @@
-/datum/c4_file/terminal_program/operating_system
- name = "operating system"
- extension = "TSYS"
- size = 0
-
- is_executable = FALSE
-
- /// Gotta be logged in to access anything.
- var/logged_in = FALSE
-
- /// Current directory being operated on.
- var/datum/c4_file/folder/current_directory
-
- /// The current focused program.
- var/tmp/datum/c4_file/terminal_program/active_program
- /// All programs currently running on the machine.
- var/tmp/list/datum/c4_file/terminal_program/processing_programs = list()
-
- /// Halt And Catch Fire (Prevents STDIN, closest we can get to a HALT state.)
- var/deadlocked = FALSE
-
-/datum/c4_file/terminal_program/operating_system/Destroy()
- if(length(processing_programs))
- clean_up()
- return ..()
-
-/// Should run this before executing any commands.
-/datum/c4_file/terminal_program/operating_system/proc/is_operational()
- return (!!get_computer()?.is_operational) && (!deadlocked)
-
-/// Change active directory.
-/datum/c4_file/terminal_program/operating_system/proc/change_dir(datum/c4_file/folder/directory)
- current_directory = directory
- return TRUE
-
-/// Move a file to another location.
-/datum/c4_file/terminal_program/operating_system/proc/move_file(datum/c4_file/file, datum/c4_file/folder/destination, error_pointer, overwrite = FALSE, new_name = "")
- if(file.containing_folder == destination)
- *error_pointer = "Cannot move folder into itself."
- return FALSE
-
- if(!destination.can_add_file(file))
- *error_pointer = "Unable to move file to target."
- return FALSE
-
- var/datum/c4_file/file_at_dest = destination.get_file(new_name || file.name, TRUE)
- if(file_at_dest)
- if(!overwrite)
- *error_pointer = "Target in use."
- return FALSE
-
- if(!destination.can_remove_file(file_at_dest))
- *error_pointer = "Unable to delete target."
- return FALSE
-
- if(!file.containing_folder.can_remove_file(file))
- *error_pointer = "Unable to delete source."
- return FALSE
-
- if(file_at_dest)
- destination.try_delete_file(file_at_dest)
-
- file.containing_folder.try_remove_file(file)
- destination.try_add_file(file)
-
- file.set_name(new_name)
- return TRUE
-
-/// Find a file by it's name in the given directory. Defaults to the current directory.
-/datum/c4_file/terminal_program/operating_system/proc/get_file(file_name, datum/c4_file/folder/working_directory, include_folders = FALSE)
- if(!file_name)
- return
-
- if(!working_directory)
- working_directory = current_directory
-
- return working_directory.get_file(file_name, include_folders)
-
-/// Returns a file or folder with the given name inside of the given filepath relative to the working directory.
-/datum/c4_file/terminal_program/operating_system/proc/resolve_filepath(file_path, datum/c4_file/folder/working_directory)
- if(!file_path)
- return
-
- if(!working_directory)
- working_directory = current_directory
-
- var/list/split_path = splittext(file_path, "/")
-
- if(length(split_path) == 1)
- if(split_path[1] == ".")
- return working_directory
- return get_file(split_path[1], working_directory, include_folders = TRUE)
-
- var/datum/file_path/path_info = text_to_filepath(file_path)
-
- var/datum/c4_file/folder/found_folder = parse_directory(path_info.directory, working_directory)
- if(!found_folder)
- return null
-
- if(!path_info.file_name)
- return found_folder
-
- return get_file(path_info.file_name, found_folder, include_folders = TRUE)
-
-/// Write to the terminal.
-/datum/c4_file/terminal_program/operating_system/proc/println(text, update_ui = TRUE)
- if(isnull(text) || !is_operational())
- return FALSE
-
-
- var/obj/machinery/computer4/computer = get_computer()
- computer.text_buffer += "[text]
"
- if(update_ui)
- SStgui.update_uis(computer)
- return TRUE
-
-/// Clear the screen completely.
-/datum/c4_file/terminal_program/operating_system/proc/clear_screen(fully = FALSE)
- if(!is_operational())
- return FALSE
-
- get_computer().text_buffer = ""
- if(!fully)
- println("Screen cleared.")
- return TRUE
-
-/datum/c4_file/terminal_program/operating_system/proc/get_log_folder()
- return
-
-/// Wrapper around handling text input to make sure we can actually handle it.
-/datum/c4_file/terminal_program/operating_system/proc/try_std_in(text)
- if(!text || !is_operational())
- return FALSE
-
- return active_program?.std_in(text)
-
-/// Unload everything including myself
-/datum/c4_file/terminal_program/operating_system/proc/clean_up()
- for(var/datum/c4_file/terminal_program/program as anything in processing_programs - src)
- unload_program(program)
-
- if(src in processing_programs)
- unload_program(src)
-
- get_computer()?.text_buffer = ""
- get_computer()?.operating_system = null
-
-/// Run a program.
-/datum/c4_file/terminal_program/operating_system/proc/execute_program(datum/c4_file/terminal_program/program)
- if(!program)
- return FALSE
-
- if(!program.can_execute(src))
- return FALSE
-
- if(!(program in processing_programs))
- add_processing_program(program)
-
- set_active_program(program)
- program.execute(src)
- return TRUE
-
-/// Close a program.
-/datum/c4_file/terminal_program/operating_system/proc/unload_program(datum/c4_file/terminal_program/program)
- if(!program)
- return FALSE
-
- // Un-deadlock ourselves.
- deadlocked = FALSE
-
- if(!(program in processing_programs))
- CRASH("Tried tried to remove a program we aren't even running.")
-
- remove_processing_program(program)
-
- if(active_program == program)
- if(active_program == src)
- set_active_program(null)
- clean_up()
- else
- set_active_program(src)
-
- return TRUE
-
-/// Move a program to background
-/datum/c4_file/terminal_program/operating_system/proc/try_background_program(datum/c4_file/terminal_program/program)
- if(length(processing_programs) > 6) // Sane limit IMO
- return FALSE
-
- if(active_program == program)
- set_active_program(src)
-
- return TRUE
-
-/// Setter for the processing programs list. Use execute_program() instead!
-/datum/c4_file/terminal_program/operating_system/proc/add_processing_program(datum/c4_file/terminal_program/program)
- PRIVATE_PROC(TRUE)
-
- processing_programs += program
- RegisterSignal(program, list(COMSIG_PARENT_QDELETING, COMSIG_COMPUTER4_FILE_ADDED), PROC_REF(processing_program_moved))
-
-
-/// Setter for the processing programs list. Use unload_program() instead!
-/datum/c4_file/terminal_program/operating_system/proc/remove_processing_program(datum/c4_file/terminal_program/program)
- processing_programs -= program
- program.on_close(src)
- UnregisterSignal(program, list(COMSIG_PARENT_QDELETING, COMSIG_COMPUTER4_FILE_ADDED))
-
-/// Setter for active program. Use execute_program() or unload_program() instead!
-/datum/c4_file/terminal_program/operating_system/proc/set_active_program(datum/c4_file/terminal_program/program)
- PRIVATE_PROC(TRUE)
-
- active_program = program
-
-/// Handles any running programs being moved in the filesystem.
-/datum/c4_file/terminal_program/operating_system/proc/processing_program_moved(datum/source)
- SIGNAL_HANDLER
-
- if(source == src)
- var/obj/machinery/computer4/computer = get_computer()
- if(QDELING(src))
- clean_up()
- return
-
- // Check if it's still in the root of either disk, this is fine :)
- if(src in computer.internal_disk?.root.contents)
- return
-
- if(src in computer.inserted_disk?.root.contents)
- return
-
- // OS is not in a root folder, KILL!!!
- clean_up()
- return
-
-
- unload_program(active_program)
diff --git a/code/modules/computer4/data/terminal/operating_system/_operating_system.dm b/code/modules/computer4/data/terminal/operating_system/_operating_system.dm
new file mode 100644
index 000000000000..e41b3f4bfa88
--- /dev/null
+++ b/code/modules/computer4/data/terminal/operating_system/_operating_system.dm
@@ -0,0 +1,80 @@
+/datum/c4_file/terminal_program/operating_system
+ name = "operating system"
+ extension = "TSYS"
+ size = 0
+
+ is_executable = FALSE
+
+ /// Gotta be logged in to access anything.
+ var/logged_in = FALSE
+
+ /// Current directory being operated on.
+ var/datum/c4_file/folder/current_directory
+
+ /// The current focused program.
+ var/tmp/datum/c4_file/terminal_program/active_program
+ /// All programs currently running on the machine.
+ var/tmp/list/datum/c4_file/terminal_program/processing_programs = list()
+
+ /// Halt And Catch Fire (Prevents STDIN, closest we can get to a HALT state.)
+ var/deadlocked = FALSE
+
+ var/list/datum/pdp_socket/pdp_port_map
+
+/datum/c4_file/terminal_program/operating_system/Destroy()
+ if(length(processing_programs))
+ clean_up()
+ return ..()
+
+/// Should run this before executing any commands.
+/datum/c4_file/terminal_program/operating_system/proc/is_operational()
+ return (!!get_computer()?.is_operational) && (!deadlocked)
+
+/// Write to the terminal.
+/datum/c4_file/terminal_program/operating_system/proc/println(text, update_ui = TRUE)
+ if(isnull(text) || !is_operational())
+ return FALSE
+
+
+ var/obj/machinery/computer4/computer = get_computer()
+ computer.text_buffer += "[text]
"
+ if(update_ui)
+ SStgui.update_uis(computer)
+ return TRUE
+
+/// Clear the screen completely.
+/datum/c4_file/terminal_program/operating_system/proc/clear_screen(fully = FALSE)
+ if(!is_operational())
+ return FALSE
+
+ get_computer().text_buffer = ""
+ if(!fully)
+ println("Screen cleared.")
+ return TRUE
+
+/// Wrapper around handling text input to make sure we can actually handle it.
+/datum/c4_file/terminal_program/operating_system/proc/try_std_in(text)
+ if(!text || !is_operational())
+ return FALSE
+
+ return active_program?.std_in(text)
+
+/// Unload everything including myself
+/datum/c4_file/terminal_program/operating_system/proc/clean_up()
+ for(var/datum/c4_file/terminal_program/program as anything in processing_programs - src)
+ unload_program(program)
+
+ if(src in processing_programs)
+ unload_program(src)
+
+ get_computer()?.text_buffer = ""
+ get_computer()?.operating_system = null
+
+ pdp_port_map = null //Programs should clean these up, but just in case.
+
+/datum/c4_file/terminal_program/operating_system/proc/execute(datum/c4_file/terminal_program/operating_system/system)
+ if(system != src)
+ //If we aren't executing ourselves, something is nasty and wrong.
+ CRASH("System [system.type] tried to execute OS that isn't itself??")
+
+ prepare_networking()
diff --git a/code/modules/computer4/data/terminal/operating_system/filesystem.dm b/code/modules/computer4/data/terminal/operating_system/filesystem.dm
new file mode 100644
index 000000000000..aafbe274ccff
--- /dev/null
+++ b/code/modules/computer4/data/terminal/operating_system/filesystem.dm
@@ -0,0 +1,73 @@
+/// Change active directory.
+/datum/c4_file/terminal_program/operating_system/proc/change_dir(datum/c4_file/folder/directory)
+ current_directory = directory
+ return TRUE
+
+/// Move a file to another location.
+/datum/c4_file/terminal_program/operating_system/proc/move_file(datum/c4_file/file, datum/c4_file/folder/destination, error_pointer, overwrite = FALSE, new_name = "")
+ if(file.containing_folder == destination)
+ *error_pointer = "Cannot move folder into itself."
+ return FALSE
+
+ if(!destination.can_add_file(file))
+ *error_pointer = "Unable to move file to target."
+ return FALSE
+
+ var/datum/c4_file/file_at_dest = destination.get_file(new_name || file.name, TRUE)
+ if(file_at_dest)
+ if(!overwrite)
+ *error_pointer = "Target in use."
+ return FALSE
+
+ if(!destination.can_remove_file(file_at_dest))
+ *error_pointer = "Unable to delete target."
+ return FALSE
+
+ if(!file.containing_folder.can_remove_file(file))
+ *error_pointer = "Unable to delete source."
+ return FALSE
+
+ if(file_at_dest)
+ destination.try_delete_file(file_at_dest)
+
+ file.containing_folder.try_remove_file(file)
+ destination.try_add_file(file)
+
+ file.set_name(new_name)
+ return TRUE
+
+/// Find a file by it's name in the given directory. Defaults to the current directory.
+/datum/c4_file/terminal_program/operating_system/proc/get_file(file_name, datum/c4_file/folder/working_directory, include_folders = FALSE)
+ if(!file_name)
+ return
+
+ if(!working_directory)
+ working_directory = current_directory
+
+ return working_directory.get_file(file_name, include_folders)
+
+/// Returns a file or folder with the given name inside of the given filepath relative to the working directory.
+/datum/c4_file/terminal_program/operating_system/proc/resolve_filepath(file_path, datum/c4_file/folder/working_directory)
+ if(!file_path)
+ return
+
+ if(!working_directory)
+ working_directory = current_directory
+
+ var/list/split_path = splittext(file_path, "/")
+
+ if(length(split_path) == 1)
+ if(split_path[1] == ".")
+ return working_directory
+ return get_file(split_path[1], working_directory, include_folders = TRUE)
+
+ var/datum/file_path/path_info = text_to_filepath(file_path)
+
+ var/datum/c4_file/folder/found_folder = parse_directory(path_info.directory, working_directory)
+ if(!found_folder)
+ return null
+
+ if(!path_info.file_name)
+ return found_folder
+
+ return get_file(path_info.file_name, found_folder, include_folders = TRUE)
diff --git a/code/modules/computer4/data/terminal/operating_system/networking.dm b/code/modules/computer4/data/terminal/operating_system/networking.dm
new file mode 100644
index 000000000000..a9ccdc49a2f8
--- /dev/null
+++ b/code/modules/computer4/data/terminal/operating_system/networking.dm
@@ -0,0 +1,29 @@
+/datum/c4_file/terminal_program/operating_system/proc/prepare_networking()
+ //Create the array of all ports. Do I really need this many? No. I'll probably reduce this later to like, 1024.
+ pdp_port_map = new /list(PDP_MAX_PORT)
+
+/// Request a socket from the OS.
+/// A `port_number` of 0 will result in being allocated an ephemeral port.
+/datum/c4_file/terminal_program/operating_system/proc/bind_port(port_number, reliable = FALSE, datum/c4_file/binder)
+ RETURN_TYPE(/datum/pdp_socket)
+ if(!binder)
+ CRASH("Tried to bind a port: [isnull(port_number) ? "!NULL!" : port_number] without a binding program.")
+ if(!isnull(port_number))
+ CRASH("Program [binder] tried to bind a null port.")
+ if(port_number > PDP_MAX_PORT)
+ CRASH("Program [binder] tried to bind port above max, [port_number] > [PDP_MAX_PORT]")
+
+ // Assign ephemeral port.
+ while ((port_number = rand(PDP_EPHEMERAL_START, PDP_MAX_PORT)) && !pdp_port_map[port_number])
+
+ if(pdp_port_map[port_number])
+ return FALSE //Port already bound.
+
+ var/datum/pdp_socket = new(port_number, src)
+
+ pdp_port_map[port_number] = pdp_socket
+
+ return pdp_socket
+
+
+/datum/c4_file/terminal_program/operating_system/proc/free_port(port_number, datum/c4_file/binder)
diff --git a/code/modules/computer4/data/terminal/operating_system/program_management.dm b/code/modules/computer4/data/terminal/operating_system/program_management.dm
new file mode 100644
index 000000000000..0e640ba1623d
--- /dev/null
+++ b/code/modules/computer4/data/terminal/operating_system/program_management.dm
@@ -0,0 +1,90 @@
+/// Run a program.
+/datum/c4_file/terminal_program/operating_system/proc/execute_program(datum/c4_file/terminal_program/program)
+ if(!program)
+ return FALSE
+
+ if(!program.can_execute(src))
+ return FALSE
+
+ if(!(program in processing_programs))
+ add_processing_program(program)
+
+ set_active_program(program)
+ program.execute(src)
+ return TRUE
+
+/// Close a program.
+/datum/c4_file/terminal_program/operating_system/proc/unload_program(datum/c4_file/terminal_program/program)
+ if(!program)
+ return FALSE
+
+ // Un-deadlock ourselves.
+ deadlocked = FALSE
+
+ if(!(program in processing_programs))
+ CRASH("Tried tried to remove a program we aren't even running.")
+
+ remove_processing_program(program)
+
+ if(active_program == program)
+ if(active_program == src)
+ set_active_program(null)
+ clean_up()
+ else
+ set_active_program(src)
+
+ return TRUE
+
+/// Move a program to background
+/datum/c4_file/terminal_program/operating_system/proc/try_background_program(datum/c4_file/terminal_program/program)
+ if(length(processing_programs) > 6) // Sane limit IMO
+ return FALSE
+
+ if(active_program == program)
+ set_active_program(src)
+
+ return TRUE
+
+/// Setter for the processing programs list. Use execute_program() instead!
+/datum/c4_file/terminal_program/operating_system/proc/add_processing_program(datum/c4_file/terminal_program/program)
+ PRIVATE_PROC(TRUE)
+
+ processing_programs += program
+ RegisterSignal(program, list(COMSIG_PARENT_QDELETING, COMSIG_COMPUTER4_FILE_ADDED), PROC_REF(processing_program_moved))
+
+
+/// Setter for the processing programs list. Use unload_program() instead!
+/datum/c4_file/terminal_program/operating_system/proc/remove_processing_program(datum/c4_file/terminal_program/program)
+ processing_programs -= program
+ program.on_close(src)
+ UnregisterSignal(program, list(COMSIG_PARENT_QDELETING, COMSIG_COMPUTER4_FILE_ADDED))
+
+/// Setter for active program. Use execute_program() or unload_program() instead!
+/datum/c4_file/terminal_program/operating_system/proc/set_active_program(datum/c4_file/terminal_program/program)
+ PRIVATE_PROC(TRUE)
+
+ active_program = program
+
+/// Handles any running programs being moved in the filesystem.
+/datum/c4_file/terminal_program/operating_system/proc/processing_program_moved(datum/source)
+ SIGNAL_HANDLER
+
+ if(source == src)
+ var/obj/machinery/computer4/computer = get_computer()
+ if(QDELING(src))
+ clean_up()
+ return
+
+ // Check if it's still in the root of either disk, this is fine :)
+ if(src in computer.internal_disk?.root.contents)
+ return
+
+ if(src in computer.inserted_disk?.root.contents)
+ return
+
+ // OS is not in a root folder, KILL!!!
+ clean_up()
+ return
+
+
+ unload_program(active_program)
diff --git a/code/modules/computer4/data/terminal/rtos/_rtos.dm b/code/modules/computer4/data/terminal/operating_system/rtos/_rtos.dm
similarity index 100%
rename from code/modules/computer4/data/terminal/rtos/_rtos.dm
rename to code/modules/computer4/data/terminal/operating_system/rtos/_rtos.dm
diff --git a/code/modules/computer4/data/terminal/rtos/access_door.dm b/code/modules/computer4/data/terminal/operating_system/rtos/access_door.dm
similarity index 100%
rename from code/modules/computer4/data/terminal/rtos/access_door.dm
rename to code/modules/computer4/data/terminal/operating_system/rtos/access_door.dm
diff --git a/code/modules/computer4/data/terminal/rtos/pincode_door.dm b/code/modules/computer4/data/terminal/operating_system/rtos/pincode_door.dm
similarity index 100%
rename from code/modules/computer4/data/terminal/rtos/pincode_door.dm
rename to code/modules/computer4/data/terminal/operating_system/rtos/pincode_door.dm
diff --git a/code/modules/computer4/data/terminal/rtos/simple_door_control.dm b/code/modules/computer4/data/terminal/operating_system/rtos/simple_door_control.dm
similarity index 100%
rename from code/modules/computer4/data/terminal/rtos/simple_door_control.dm
rename to code/modules/computer4/data/terminal/operating_system/rtos/simple_door_control.dm
diff --git a/code/modules/computer4/data/terminal/rtos/slave.dm b/code/modules/computer4/data/terminal/operating_system/rtos/slave.dm
similarity index 100%
rename from code/modules/computer4/data/terminal/rtos/slave.dm
rename to code/modules/computer4/data/terminal/operating_system/rtos/slave.dm
diff --git a/code/modules/computer4/data/terminal/thinkdos/thinkdos.dm b/code/modules/computer4/data/terminal/operating_system/thinkdos/thinkdos.dm
similarity index 98%
rename from code/modules/computer4/data/terminal/thinkdos/thinkdos.dm
rename to code/modules/computer4/data/terminal/operating_system/thinkdos/thinkdos.dm
index 6bb8844ce53e..ec947524b1d7 100644
--- a/code/modules/computer4/data/terminal/thinkdos/thinkdos.dm
+++ b/code/modules/computer4/data/terminal/operating_system/thinkdos/thinkdos.dm
@@ -131,7 +131,7 @@
return TRUE
/// Returns the logging folder, attempting to create it if it doesn't already exist.
-/datum/c4_file/terminal_program/operating_system/thinkdos/get_log_folder()
+/datum/c4_file/terminal_program/operating_system/thinkdos/proc/get_log_folder()
var/datum/c4_file/folder/log_dir = parse_directory("logs", drive.root)
if(!log_dir)
log_dir = new /datum/c4_file/folder
diff --git a/code/modules/computer4/data/terminal/thinkdos/thinkdos_commands.dm b/code/modules/computer4/data/terminal/operating_system/thinkdos/thinkdos_commands.dm
similarity index 100%
rename from code/modules/computer4/data/terminal/thinkdos/thinkdos_commands.dm
rename to code/modules/computer4/data/terminal/operating_system/thinkdos/thinkdos_commands.dm
diff --git a/code/modules/computer4/data/terminal/thinkdos/thinkdos_signals.dm b/code/modules/computer4/data/terminal/operating_system/thinkdos/thinkdos_signals.dm
similarity index 100%
rename from code/modules/computer4/data/terminal/thinkdos/thinkdos_signals.dm
rename to code/modules/computer4/data/terminal/operating_system/thinkdos/thinkdos_signals.dm
diff --git a/daedalus.dme b/daedalus.dme
index 79b1813f4289..1267ac240f2c 100644
--- a/daedalus.dme
+++ b/daedalus.dme
@@ -2964,6 +2964,7 @@
#include "code\modules\computer4\computer4_types.dm"
#include "code\modules\computer4\data\metadata.dm"
#include "code\modules\computer4\data\shell_stdin.dm"
+#include "code\modules\computer4\data\socket.dm"
#include "code\modules\computer4\data\c4_file\_c4_file.dm"
#include "code\modules\computer4\data\c4_file\fab_design_bundle.dm"
#include "code\modules\computer4\data\c4_file\folder.dm"
@@ -2971,7 +2972,6 @@
#include "code\modules\computer4\data\c4_file\record.dm"
#include "code\modules\computer4\data\c4_file\text.dm"
#include "code\modules\computer4\data\c4_file\user_data.dm"
-#include "code\modules\computer4\data\terminal\operating_system.dm"
#include "code\modules\computer4\data\terminal\directive\directman.dm"
#include "code\modules\computer4\data\terminal\directive\directman_commands.dm"
#include "code\modules\computer4\data\terminal\medtrak\medtrak.dm"
@@ -2982,20 +2982,24 @@
#include "code\modules\computer4\data\terminal\medtrak\medtrak_record_commands.dm"
#include "code\modules\computer4\data\terminal\netpage\netpage.dm"
#include "code\modules\computer4\data\terminal\netpage\netpage_commands.dm"
+#include "code\modules\computer4\data\terminal\operating_system\_operating_system.dm"
+#include "code\modules\computer4\data\terminal\operating_system\filesystem.dm"
+#include "code\modules\computer4\data\terminal\operating_system\networking.dm"
+#include "code\modules\computer4\data\terminal\operating_system\program_management.dm"
+#include "code\modules\computer4\data\terminal\operating_system\rtos\_rtos.dm"
+#include "code\modules\computer4\data\terminal\operating_system\rtos\access_door.dm"
+#include "code\modules\computer4\data\terminal\operating_system\rtos\pincode_door.dm"
+#include "code\modules\computer4\data\terminal\operating_system\rtos\simple_door_control.dm"
+#include "code\modules\computer4\data\terminal\operating_system\rtos\slave.dm"
+#include "code\modules\computer4\data\terminal\operating_system\thinkdos\thinkdos.dm"
+#include "code\modules\computer4\data\terminal\operating_system\thinkdos\thinkdos_commands.dm"
+#include "code\modules\computer4\data\terminal\operating_system\thinkdos\thinkdos_signals.dm"
#include "code\modules\computer4\data\terminal\probe\probe.dm"
#include "code\modules\computer4\data\terminal\probe\probe_commands.dm"
#include "code\modules\computer4\data\terminal\_terminal_program.dm"
#include "code\modules\computer4\data\terminal\notepad\notepad.dm"
#include "code\modules\computer4\data\terminal\notepad\notepad_commands.dm"
#include "code\modules\computer4\data\terminal\packet_hound\packet_hound.dm"
-#include "code\modules\computer4\data\terminal\rtos\_rtos.dm"
-#include "code\modules\computer4\data\terminal\rtos\access_door.dm"
-#include "code\modules\computer4\data\terminal\rtos\pincode_door.dm"
-#include "code\modules\computer4\data\terminal\rtos\simple_door_control.dm"
-#include "code\modules\computer4\data\terminal\rtos\slave.dm"
-#include "code\modules\computer4\data\terminal\thinkdos\thinkdos.dm"
-#include "code\modules\computer4\data\terminal\thinkdos\thinkdos_commands.dm"
-#include "code\modules\computer4\data\terminal\thinkdos\thinkdos_signals.dm"
#include "code\modules\computer4\embedded_controller\access_door.dm"
#include "code\modules\computer4\embedded_controller\embedded_controller.dm"
#include "code\modules\computer4\embedded_controller\pincode_door.dm"
From fd91f7b280f763aee997dc04194eca06dc7e561a Mon Sep 17 00:00:00 2001
From: Francinum <5572280+francinum@users.noreply.github.com>
Date: Tue, 5 Aug 2025 22:46:33 -0400
Subject: [PATCH 02/14] I think this is mostly done????
---
code/__DEFINES/computer4_defines.dm | 1 +
code/game/communications.dm | 7 +++-
code/game/machinery/datanet/_networked.dm | 2 +-
.../embedded_controller_base.dm | 2 +-
code/modules/computer4/computer4.dm | 3 +-
code/modules/computer4/data/socket.dm | 4 ++-
.../data/terminal/medtrak/medtrak.dm | 2 +-
.../operating_system/_operating_system.dm | 13 +++++++-
.../terminal/operating_system/networking.dm | 33 +++++++++++++++----
.../terminal/operating_system/rtos/_rtos.dm | 2 +-
.../computer4/peripherals/network_card.dm | 9 ++---
.../file_system/programs/budgetordering.dm | 2 +-
.../modular_computers/hardware/gprs_card.dm | 2 +-
13 files changed, 60 insertions(+), 22 deletions(-)
diff --git a/code/__DEFINES/computer4_defines.dm b/code/__DEFINES/computer4_defines.dm
index 870c5c90a30c..5a53261fe831 100644
--- a/code/__DEFINES/computer4_defines.dm
+++ b/code/__DEFINES/computer4_defines.dm
@@ -4,6 +4,7 @@
// See proc/peripheral_input
#define PERIPHERAL_CMD_RECEIVE_PACKET "receive_packet"
+#define PERIPHERAL_CMD_RECEIVE_PDP_PACKET "receive_pdp_packet"
#define PERIPHERAL_CMD_SCAN_CARD "scan_card"
// MedTrak menus
diff --git a/code/game/communications.dm b/code/game/communications.dm
index 534ebddf9171..1046241bbadd 100644
--- a/code/game/communications.dm
+++ b/code/game/communications.dm
@@ -149,7 +149,7 @@ GLOBAL_LIST_INIT(freq2icon, list(
//If range is null, or 0, signal is TRULY global (skips z_level checks) (Be careful with this.)
//If range > 0, only post to devices on the same z_level and within range
//Use range = -1, to restrain to the same z_level without limiting range
-/datum/radio_frequency/proc/post_signal(datum/signal/signal, filter = null as text|null, range = null as num|null)
+/datum/radio_frequency/post_signal(datum/signal/signal, filter = null as text|null, range = null as num|null)
if(!istype(signal))
CRASH("LEGACY POST SIGNAL SHIT")
@@ -194,6 +194,11 @@ GLOBAL_LIST_INIT(freq2icon, list(
//SHOULD_CALL_PARENT(TRUE)
. = TRUE
+
+/datum/proc/post_signal(datum/signal/signal)
+ CRASH("Invoked base datum post_signal handler. Did something call parent?")
+
+
/datum/signal
/// The author/sender of this packet.
/// This atom will be skipped during packet send.
diff --git a/code/game/machinery/datanet/_networked.dm b/code/game/machinery/datanet/_networked.dm
index ab6f15b22c8b..f10b4c7d7c18 100644
--- a/code/game/machinery/datanet/_networked.dm
+++ b/code/game/machinery/datanet/_networked.dm
@@ -16,7 +16,7 @@
/// If you're sending a forged source address (You should have a good reason for this...) set `preserve_s_addr = TRUE
///
/// NONE OF THE ABOVE IS TRUE IF YOU ARE `machinery/power`, AS THEY DEAL DIRECTLY WITH SSPACKETS INSTEAD OF ABSTRACTED TERMINALS
-/obj/machinery/proc/post_signal(datum/signal/sending_signal, preserve_s_addr = FALSE)
+/obj/machinery/post_signal(datum/signal/sending_signal, preserve_s_addr = FALSE)
if(isnull(netjack) || isnull(sending_signal)) //nullcheck for sanic speed
return //You need a pipe and something to send down it, though.
if(!preserve_s_addr)
diff --git a/code/game/machinery/embedded_controller/embedded_controller_base.dm b/code/game/machinery/embedded_controller/embedded_controller_base.dm
index 6cf78c3ba8fe..7c0aef2fa87c 100644
--- a/code/game/machinery/embedded_controller/embedded_controller_base.dm
+++ b/code/game/machinery/embedded_controller/embedded_controller_base.dm
@@ -7,7 +7,7 @@
master = null
. = ..()
-/datum/computer/file/embedded_program/proc/post_signal(datum/signal/signal, comm_line)
+/datum/computer/file/embedded_program/post_signal(datum/signal/signal, comm_line)
SHOULD_CALL_PARENT(FALSE) // This is more of a relay than anything else.
if(master)
master.post_signal(signal, comm_line)
diff --git a/code/modules/computer4/computer4.dm b/code/modules/computer4/computer4.dm
index f7289b12f7a6..5894db1bdd69 100644
--- a/code/modules/computer4/computer4.dm
+++ b/code/modules/computer4/computer4.dm
@@ -252,8 +252,7 @@ TYPEINFO_DEF(/obj/machinery/computer4)
if(!is_operational)
return
- for(var/datum/c4_file/terminal_program/program as anything in operating_system?.processing_programs)
- program.peripheral_input(invoker, command, packet)
+ operating_system.peripheral_input(invoker, command, packet)
/obj/machinery/computer4/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src)
diff --git a/code/modules/computer4/data/socket.dm b/code/modules/computer4/data/socket.dm
index 57bc42f79ef6..4853390a39d0 100644
--- a/code/modules/computer4/data/socket.dm
+++ b/code/modules/computer4/data/socket.dm
@@ -13,7 +13,7 @@
#endif
/datum/pdp_socket
- /// Next Hop datum we send our packets to, Usually an operating system, but may be a physical network device.
+ /// Next Hop datum we send our packets to. Usually a network card.
var/datum/outgoing_datum
/// 'Owner' that registered for this socket. Used to assure ownership.
var/datum/owner
@@ -79,3 +79,5 @@
)
var/datum/signal/packet = new(null, packet_data)
+
+ outgoing_datum.receive_signal()
diff --git a/code/modules/computer4/data/terminal/medtrak/medtrak.dm b/code/modules/computer4/data/terminal/medtrak/medtrak.dm
index b3512a9ea11b..a1ce3f4502df 100644
--- a/code/modules/computer4/data/terminal/medtrak/medtrak.dm
+++ b/code/modules/computer4/data/terminal/medtrak/medtrak.dm
@@ -71,7 +71,7 @@
// Sue me. Come up with a better way to do this that doesn't demand dead procs on the OS basetype.
// (Suggestion: Move medtrak and such to a thinkdos-specific subtype of terminal_program) (t_prog/dos/medtrak)
- var/datum/c4_file/folder/log_dir = get_os():get_log_folder()
+ var/datum/c4_file/folder/log_dir = astype(get_os(), /datum/c4_file/terminal_program/operating_system/thinkdos):get_log_folder()
if(!log_dir)
return null
diff --git a/code/modules/computer4/data/terminal/operating_system/_operating_system.dm b/code/modules/computer4/data/terminal/operating_system/_operating_system.dm
index e41b3f4bfa88..37f53d8b526b 100644
--- a/code/modules/computer4/data/terminal/operating_system/_operating_system.dm
+++ b/code/modules/computer4/data/terminal/operating_system/_operating_system.dm
@@ -72,9 +72,20 @@
pdp_port_map = null //Programs should clean these up, but just in case.
-/datum/c4_file/terminal_program/operating_system/proc/execute(datum/c4_file/terminal_program/operating_system/system)
+/datum/c4_file/terminal_program/operating_system/execute(datum/c4_file/terminal_program/operating_system/system)
if(system != src)
//If we aren't executing ourselves, something is nasty and wrong.
CRASH("System [system.type] tried to execute OS that isn't itself??")
prepare_networking()
+
+/datum/c4_file/terminal_program/operating_system/peripheral_input(obj/item/peripheral/invoker, command, datum/signal/packet)
+
+ if(command == PERIPHERAL_CMD_RECEIVE_PDP_PACKET)
+ pdp_incoming(packet)
+ return
+
+ for(var/datum/c4_file/terminal_program/program as anything in processing_programs)
+ if(program == src)
+ continue
+ program.peripheral_input(invoker, command, packet)
diff --git a/code/modules/computer4/data/terminal/operating_system/networking.dm b/code/modules/computer4/data/terminal/operating_system/networking.dm
index a9ccdc49a2f8..cdd12706bec7 100644
--- a/code/modules/computer4/data/terminal/operating_system/networking.dm
+++ b/code/modules/computer4/data/terminal/operating_system/networking.dm
@@ -1,6 +1,6 @@
/datum/c4_file/terminal_program/operating_system/proc/prepare_networking()
//Create the array of all ports. Do I really need this many? No. I'll probably reduce this later to like, 1024.
- pdp_port_map = new /list(PDP_MAX_PORT)
+ pdp_port_map = list()
/// Request a socket from the OS.
/// A `port_number` of 0 will result in being allocated an ephemeral port.
@@ -14,16 +14,35 @@
CRASH("Program [binder] tried to bind port above max, [port_number] > [PDP_MAX_PORT]")
// Assign ephemeral port.
- while ((port_number = rand(PDP_EPHEMERAL_START, PDP_MAX_PORT)) && !pdp_port_map[port_number])
-
- if(pdp_port_map[port_number])
- return FALSE //Port already bound.
+ if(!port_number)
+ do
+ port_number = rand(PDP_EPHEMERAL_START, PDP_MAX_PORT)
+ while(pdp_port_map["[port_number]"])
+ else
+ if(pdp_port_map["[port_number]"])
+ return FALSE //Port already bound.
var/datum/pdp_socket = new(port_number, src)
- pdp_port_map[port_number] = pdp_socket
+ pdp_port_map["[port_number]"] = pdp_socket
return pdp_socket
-
/datum/c4_file/terminal_program/operating_system/proc/free_port(port_number, datum/c4_file/binder)
+
+/// Finish up outgoing program signals.
+/// Eventually: Routing table?
+/datum/c4_file/terminal_program/operating_system/post_signal(datum/signal/signal)
+ if(!signal)
+ CRASH("post signal wi no signal")
+
+ var/obj/item/peripheral/network_card/wireless/wcard = get_computer().get_peripheral(PERIPHERAL_TYPE_WIRELESS_CARD)
+ if(!wcard)
+ return //cry
+ wcard.post_signal(signal)
+
+/datum/c4_file/terminal_program/operating_system/proc/pdp_incoming(datum/signal/packet)
+ var/list/fields = packet.data
+ var/datum/pdp_socket/socket = pdp_port_map["[fields[PDP_DESTINATION_PORT]]"]
+ socket?.enqueue(packet)
+
diff --git a/code/modules/computer4/data/terminal/operating_system/rtos/_rtos.dm b/code/modules/computer4/data/terminal/operating_system/rtos/_rtos.dm
index c47d3924453a..651fbe2aba9f 100644
--- a/code/modules/computer4/data/terminal/operating_system/rtos/_rtos.dm
+++ b/code/modules/computer4/data/terminal/operating_system/rtos/_rtos.dm
@@ -103,7 +103,7 @@
/** RTOS.h - Post Signal
* Follows standard post_signal calling conventions.
*/
-/datum/c4_file/terminal_program/operating_system/rtos/proc/post_signal(datum/signal/sending_signal, filter)
+/datum/c4_file/terminal_program/operating_system/rtos/post_signal(datum/signal/sending_signal, filter)
if(!is_operational())
return
diff --git a/code/modules/computer4/peripherals/network_card.dm b/code/modules/computer4/peripherals/network_card.dm
index 49b65fd8a687..0dbc712d260b 100644
--- a/code/modules/computer4/peripherals/network_card.dm
+++ b/code/modules/computer4/peripherals/network_card.dm
@@ -52,7 +52,7 @@
radio_connection = SSpackets.add_object(src, new_frequency)
/// Post a signal. Has safety checks, so calling this with a timer is OK.
-/obj/item/peripheral/network_card/wireless/proc/post_signal(datum/signal/packet, filter)
+/obj/item/peripheral/network_card/wireless/post_signal(datum/signal/packet, filter)
if(!master_pc?.is_operational || !radio_connection)
return
@@ -97,10 +97,11 @@
//allow all
*/
-
-
var/datum/signal/clone = signal.Copy()
- master_pc.peripheral_input(src, PERIPHERAL_CMD_RECEIVE_PACKET, clone)
+ if(signal.data[PACKET_ARG_PROTOCOL] == PACKET_ARG_PROTOCOL_PDP)
+ master_pc.peripheral_input(src, PERIPHERAL_CMD_RECEIVE_PDP_PACKET, clone)
+ else
+ master_pc.peripheral_input(src, PERIPHERAL_CMD_RECEIVE_PACKET, clone)
/obj/item/peripheral/network_card/wireless/proc/ping()
if(!COOLDOWN_FINISHED(src, ping_cooldown))
diff --git a/code/modules/modular_computers/file_system/programs/budgetordering.dm b/code/modules/modular_computers/file_system/programs/budgetordering.dm
index 15def002b3a5..204851b3c0e5 100644
--- a/code/modules/modular_computers/file_system/programs/budgetordering.dm
+++ b/code/modules/modular_computers/file_system/programs/budgetordering.dm
@@ -298,7 +298,7 @@
if(.)
post_signal(cargo_shuttle)
-/datum/computer_file/program/budgetorders/proc/post_signal(command)
+/datum/computer_file/program/budgetorders/post_signal(command)
SHOULD_CALL_PARENT(FALSE) //TODO: Tie to cablenet
var/datum/radio_frequency/frequency = SSpackets.return_frequency(FREQ_STATUS_DISPLAYS)
diff --git a/code/modules/modular_computers/hardware/gprs_card.dm b/code/modules/modular_computers/hardware/gprs_card.dm
index 4b5ad47f60b7..4caa2cc89ff6 100644
--- a/code/modules/modular_computers/hardware/gprs_card.dm
+++ b/code/modules/modular_computers/hardware/gprs_card.dm
@@ -98,7 +98,7 @@
append_signal(signal)
-/obj/item/computer_hardware/network_card/packetnet/proc/post_signal(datum/signal/signal)
+/obj/item/computer_hardware/network_card/packetnet/post_signal(datum/signal/signal)
if(!radio_connection || !signal)
return FALSE // Something went wrong.
signal.data[PACKET_SOURCE_ADDRESS] = hardware_id //Readdress outgoing packets.
From 4f8f54ec78d48ac64d3e374a576675c32ab6dee3 Mon Sep 17 00:00:00 2001
From: Francinum <5572280+francinum@users.noreply.github.com>
Date: Tue, 5 Aug 2025 22:57:43 -0400
Subject: [PATCH 03/14] PASS CHECKS YOU CHEAP KAZAKH WHORE
---
code/modules/computer4/data/socket.dm | 2 +-
code/modules/computer4/peripherals/network_card.dm | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/code/modules/computer4/data/socket.dm b/code/modules/computer4/data/socket.dm
index 4853390a39d0..15563d938184 100644
--- a/code/modules/computer4/data/socket.dm
+++ b/code/modules/computer4/data/socket.dm
@@ -80,4 +80,4 @@
var/datum/signal/packet = new(null, packet_data)
- outgoing_datum.receive_signal()
+ outgoing_datum.post_signal(packet)
diff --git a/code/modules/computer4/peripherals/network_card.dm b/code/modules/computer4/peripherals/network_card.dm
index 0dbc712d260b..e397a0a9df2d 100644
--- a/code/modules/computer4/peripherals/network_card.dm
+++ b/code/modules/computer4/peripherals/network_card.dm
@@ -62,7 +62,7 @@
radio_connection.post_signal(packet, filter)
/obj/item/peripheral/network_card/wireless/proc/deferred_post_signal(datum/signal/packet, filter, time)
- addtimer(CALLBACK(src, PROC_REF(post_signal), packet, filter), time)
+ addtimer(CALLBACK(src, TYPE_PROC_REF(/datum, post_signal), packet, filter), time)
/obj/item/peripheral/network_card/wireless/receive_signal(datum/signal/signal)
if(!master_pc)
@@ -86,7 +86,7 @@
)
var/datum/signal/packet = new(src, data, TRANSMISSION_RADIO)
- addtimer(CALLBACK(src, PROC_REF(post_signal), packet), 1 SECOND)
+ addtimer(CALLBACK(src, TYPE_PROC_REF(/datum, post_signal), packet), 1 SECOND)
return
if(WIRELESS_FILTER_ID_TAGS)
//Drop packets not in our ID tags list.
From 08bb62324a6f080c00c7b049eb24410997bd07d0 Mon Sep 17 00:00:00 2001
From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com>
Date: Thu, 7 Aug 2025 15:12:20 -0400
Subject: [PATCH 04/14] update documentation, add a v2 helper.
---
.../centralized_phones/callstation.dm | 2 +-
code/__DEFINES/packetnet.dm | 37 +++++++++----------
code/__HELPERS/packetnet.dm | 12 ++++++
code/game/machinery/announcement_system.dm | 8 ++--
code/game/machinery/buttons_radio.dm | 4 +-
code/game/machinery/datanet/_networked.dm | 12 +++---
.../datanet/p2p_phones/_p2p_phones.dm | 20 +++++-----
.../datanet/{README.md => packetv1.md} | 11 +++---
code/game/machinery/datanet/packetv2.md | 17 +++++++++
.../telecomms/machines/message_server.dm | 6 +--
code/modules/computer4/data/socket.dm | 17 +++------
.../operating_system/_operating_system.dm | 5 ++-
.../terminal/operating_system/networking.dm | 2 +-
.../operating_system/rtos/access_door.dm | 14 +++----
.../operating_system/rtos/pincode_door.dm | 14 +++----
.../rtos/simple_door_control.dm | 6 +--
.../terminal/operating_system/rtos/slave.dm | 8 ++--
.../computer4/data/terminal/probe/probe.dm | 6 +--
.../computer4/peripherals/network_card.dm | 20 +++++-----
.../file_system/programs/ntmessenger.dm | 18 ++++-----
.../modular_computers/hardware/gprs_card.dm | 16 ++++----
.../modular_computers/hardware/virus_disk.dm | 4 +-
daedalus.dme | 1 +
23 files changed, 143 insertions(+), 117 deletions(-)
create mode 100644 code/__HELPERS/packetnet.dm
rename code/game/machinery/datanet/{README.md => packetv1.md} (67%)
create mode 100644 code/game/machinery/datanet/packetv2.md
diff --git a/WorkInProgress/francinum/centralized_phones/callstation.dm b/WorkInProgress/francinum/centralized_phones/callstation.dm
index 986a768a652f..4fd4ad13f2bd 100644
--- a/WorkInProgress/francinum/centralized_phones/callstation.dm
+++ b/WorkInProgress/francinum/centralized_phones/callstation.dm
@@ -44,7 +44,7 @@ Phone registration flow (Post-Roundstart):
return
switch(lowertext(signal.data["command"]))
if("ping_reply")// A reply to our ping!
- if(signal.data[PACKET_NETCLASS] != "PNET_SIPSERVER") //Not who we care about!
+ if(signal.data[PKT_HEAD_NETCLASS] != "PNET_SIPSERVER") //Not who we care about!
return
register_with_server(signal.data["s_addr"])// It's a server, link!
if("sip_adopt")
diff --git a/code/__DEFINES/packetnet.dm b/code/__DEFINES/packetnet.dm
index 19f95ab4b289..6f869d4fcc04 100644
--- a/code/__DEFINES/packetnet.dm
+++ b/code/__DEFINES/packetnet.dm
@@ -31,17 +31,27 @@
// not honestly thrilled with having these be defines but kapu wants it that way
// I believe every coder is empowered with a right to footgun by our lord Dennis Ritchie
+//* HEADER FIELDS *//
+/// The version of the packet.
+#define PKT_HEAD_VERSION "version"
/// Source (sender) address of a packet
-#define PACKET_SOURCE_ADDRESS "s_addr"
+#define PKT_HEAD_SOURCE_ADDRESS "s_addr"
/// Destination (receiver) address of a packet
-#define PACKET_DESTINATION_ADDRESS "d_addr"
-/// Command (type) of a packet
-#define PACKET_CMD "command"
+#define PKT_HEAD_DEST_ADDRESS "d_addr"
/// Network Class of a device, used as part of ping replies.
-#define PACKET_NETCLASS "netclass"
+#define PKT_HEAD_NETCLASS "netclass"
+
+#define PKT_HEAD_SOURCE_PORT "sourceport"
+#define PKT_HEAD_DEST_PORT "destport"
+
+#define PKT_HEAD_PROTOCOL "proto"
+ #define PKT_PROTOCOL_PDP "pdp"
-#define PACKET_ARG_PROTOCOL "proto"
- #define PACKET_ARG_PROTOCOL_PDP "pdp"
+#define PKT_PAYLOAD "payload"
+
+//* PAYLOAD FIELDS*//
+/// Command (type) of a packet
+#define PKT_ARG_CMD "command"
// Pagers
/// Packet arg for pager types
@@ -107,19 +117,6 @@
#define PACKET_STRING_FILE "packetnet.json"
-// -----
-// PDP Protocol Fields
-// These are partially duplicates of above but Deal With It.
-
-#define PDP_SOURCE_ADDRESS PACKET_SOURCE_ADDRESS
-#define PDP_DESTINATION_ADDRESS PACKET_DESTINATION_ADDRESS
-
-#define PDP_SOURCE_PORT "s_port"
-#define PDP_DESTINATION_PORT "d_port"
-
-/// PDP Payload Data. Is a list.
-#define PDP_PAYLOAD_DATA "payload"
-
// -----
// PDP Port Allocations
diff --git a/code/__HELPERS/packetnet.dm b/code/__HELPERS/packetnet.dm
new file mode 100644
index 000000000000..de64ba58951e
--- /dev/null
+++ b/code/__HELPERS/packetnet.dm
@@ -0,0 +1,12 @@
+/// Returns the data field for a packet.
+/proc/packetv2(source_addr, dest_addr, source_port, dest_port, netclass, protocol, list/payload) as /list
+ . = list(
+ PKT_HEAD_VERSION = 2,
+ PKT_HEAD_SOURCE_ADDRESS = source_addr,
+ PKT_HEAD_DEST_ADDRESS = dest_addr,
+ PKT_HEAD_SOURCE_PORT = source_port,
+ PKT_HEAD_DEST_PORT = dest_port,
+ PKT_HEAD_NETCLASS = netclass,
+ PKT_HEAD_PROTOCOL = protocol,
+ PKT_PAYLOAD = payload,
+ )
diff --git a/code/game/machinery/announcement_system.dm b/code/game/machinery/announcement_system.dm
index b3ce1a8b03fd..17a0ba4b6bd2 100644
--- a/code/game/machinery/announcement_system.dm
+++ b/code/game/machinery/announcement_system.dm
@@ -224,7 +224,7 @@ GLOBAL_LIST_EMPTY(announcement_systems)
for(var/next_addr in targets)
var/datum/signal/outgoing = create_signal(next_addr, list(
- PACKET_CMD = NETCMD_PDAMESSAGE,
+ PKT_ARG_CMD = NETCMD_PDAMESSAGE,
"name" = "Automated Announcement System",
"job" = "Security Department Update",
"message" = "Officer [officer.real_name] has been assigned to your department, [department].",
@@ -244,7 +244,7 @@ GLOBAL_LIST_EMPTY(announcement_systems)
break //No RF card to send to.
var/message = "You have been fined [fine_amount] marks for '[cite_message]'. Fines may be paid at security."
var/datum/signal/outgoing = create_signal(rfcard.hardware_id, list(
- PACKET_CMD = NETCMD_PDAMESSAGE,
+ PKT_ARG_CMD = NETCMD_PDAMESSAGE,
"name" = "Automated Announcement System",
"job" = "Security Citation",
"message" = message,
@@ -257,7 +257,7 @@ GLOBAL_LIST_EMPTY(announcement_systems)
/obj/machinery/announcement_system/proc/mass_pda_message(list/recipients, message, reason)
for(var/next_addr in recipients)
var/datum/signal/outgoing = create_signal(next_addr, list(
- PACKET_CMD = NETCMD_PDAMESSAGE,
+ PKT_ARG_CMD = NETCMD_PDAMESSAGE,
"name" = "Automated Announcement System",
"job" = reason,
"message" = message,
@@ -270,7 +270,7 @@ GLOBAL_LIST_EMPTY(announcement_systems)
/// A helper proc for sending an announcement to a single PDA.
/obj/machinery/announcement_system/proc/pda_message(recipient, message, reason)
var/datum/signal/outgoing = create_signal(recipient, list(
- PACKET_CMD = NETCMD_PDAMESSAGE,
+ PKT_ARG_CMD = NETCMD_PDAMESSAGE,
"name" = "Automated Announcement System",
"job" = reason,
"message" = message,
diff --git a/code/game/machinery/buttons_radio.dm b/code/game/machinery/buttons_radio.dm
index 4332005a3566..856881f9051b 100644
--- a/code/game/machinery/buttons_radio.dm
+++ b/code/game/machinery/buttons_radio.dm
@@ -13,8 +13,8 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/button/radio, 24)
var/datum/radio_frequency/radio_connection = SSpackets.return_frequency(frequency)
var/datum/signal/signal = new(src, list(
- PACKET_SOURCE_ADDRESS = net_id,
- PACKET_NETCLASS = NETCLASS_BUTTON,
+ PKT_HEAD_SOURCE_ADDRESS = net_id,
+ PKT_HEAD_NETCLASS = NETCLASS_BUTTON,
"tag" = id_tag,
))
radio_connection.post_signal(signal)
diff --git a/code/game/machinery/datanet/_networked.dm b/code/game/machinery/datanet/_networked.dm
index f10b4c7d7c18..bd05dc4d1cb4 100644
--- a/code/game/machinery/datanet/_networked.dm
+++ b/code/game/machinery/datanet/_networked.dm
@@ -7,8 +7,8 @@
if(!datagram || !destination_id)
return //Unfortunately /dev/null isn't network-scale.
var/list/sig_data = datagram.Copy()
- sig_data[PACKET_SOURCE_ADDRESS] = src.net_id
- sig_data[PACKET_DESTINATION_ADDRESS] = destination_id
+ sig_data[PKT_HEAD_SOURCE_ADDRESS] = src.net_id
+ sig_data[PKT_HEAD_DEST_ADDRESS] = destination_id
return new /datum/signal(src, sig_data, TRANSMISSION_WIRE)
@@ -20,7 +20,7 @@
if(isnull(netjack) || isnull(sending_signal)) //nullcheck for sanic speed
return //You need a pipe and something to send down it, though.
if(!preserve_s_addr)
- sending_signal.data[PACKET_SOURCE_ADDRESS] = src.net_id
+ sending_signal.data[PKT_HEAD_SOURCE_ADDRESS] = src.net_id
sending_signal.transmission_method = TRANSMISSION_WIRE
sending_signal.author = WEAKREF(src) // Override the sending signal author.
src.netjack.post_signal(sending_signal)
@@ -31,13 +31,13 @@
if(isnull(signal))
return
var/sigdat = signal.data //cache for sanic speed this joke is getting old.
- if(sigdat[PACKET_DESTINATION_ADDRESS] != src.net_id)//This packet doesn't belong to us directly
- if(sigdat[PACKET_DESTINATION_ADDRESS] == NET_ADDRESS_PING)// But it could be a ping, if so, reply
+ if(sigdat[PKT_HEAD_DEST_ADDRESS] != src.net_id)//This packet doesn't belong to us directly
+ if(sigdat[PKT_HEAD_DEST_ADDRESS] == NET_ADDRESS_PING)// But it could be a ping, if so, reply
var/tmp_filter = sigdat["filter"]
if(!isnull(tmp_filter) && tmp_filter != net_class)
return RECEIVE_SIGNAL_FINISHED
//Blame kapu for how stupid this looks :3
- post_signal(create_signal(sigdat[PACKET_SOURCE_ADDRESS], list("command"=NET_COMMAND_PING_REPLY,PACKET_NETCLASS=src.net_class,"netaddr"=src.net_id)+src.ping_addition))
+ post_signal(create_signal(sigdat[PKT_HEAD_SOURCE_ADDRESS], list("command"=NET_COMMAND_PING_REPLY,PKT_HEAD_NETCLASS=src.net_class,"netaddr"=src.net_id)+src.ping_addition))
return RECEIVE_SIGNAL_FINISHED//regardless, return 1 so that machines don't process packets not intended for them.
return RECEIVE_SIGNAL_CONTINUE // We are the designated recipient of this packet, we need to handle it.
diff --git a/code/game/machinery/datanet/p2p_phones/_p2p_phones.dm b/code/game/machinery/datanet/p2p_phones/_p2p_phones.dm
index 8d017a440f60..48b15a3ffeff 100644
--- a/code/game/machinery/datanet/p2p_phones/_p2p_phones.dm
+++ b/code/game/machinery/datanet/p2p_phones/_p2p_phones.dm
@@ -231,27 +231,27 @@
if(. == RECEIVE_SIGNAL_FINISHED)//Handled by default.
return
//Ping response handled in parent.
- switch(signal.data[PACKET_CMD])
+ switch(signal.data[PKT_ARG_CMD])
if(NET_COMMAND_PING_REPLY)//Add new phone to database
- if(signal.data[PACKET_NETCLASS] == NETCLASS_P2P_PHONE) //Another phone!
- discovered_phones[signal.data[PACKET_SOURCE_ADDRESS]]=signal.data["user_id"]
+ if(signal.data[PKT_HEAD_NETCLASS] == NETCLASS_P2P_PHONE) //Another phone!
+ discovered_phones[signal.data[PKT_HEAD_SOURCE_ADDRESS]]=signal.data["user_id"]
return RECEIVE_SIGNAL_FINISHED
if("tel_ring")//Incoming ring
if(active_caller || handset_state == HANDSET_OFFHOOK)//We're either calling, or about to call, Just tell them to fuck off.
- post_signal(create_signal(signal.data[PACKET_SOURCE_ADDRESS],list(PACKET_CMD="tel_busy"))) //Busy signal, Reject call.
+ post_signal(create_signal(signal.data[PKT_HEAD_SOURCE_ADDRESS],list(PKT_ARG_CMD="tel_busy"))) //Busy signal, Reject call.
return RECEIVE_SIGNAL_FINISHED
- receive_call(list(signal.data[PACKET_SOURCE_ADDRESS],signal.data["caller_id"]))
+ receive_call(list(signal.data[PKT_HEAD_SOURCE_ADDRESS],signal.data["caller_id"]))
return RECEIVE_SIGNAL_FINISHED
if("tel_ready")//Remote side pickup
- if(active_caller && signal.data[PACKET_SOURCE_ADDRESS] == active_caller[CALLER_NETID])// Ensure the packet is sensible
+ if(active_caller && signal.data[PKT_HEAD_SOURCE_ADDRESS] == active_caller[CALLER_NETID])// Ensure the packet is sensible
call_connected()
return RECEIVE_SIGNAL_FINISHED
if("tel_busy")//Answering station busy
- if(active_caller && signal.data[PACKET_SOURCE_ADDRESS] == active_caller[CALLER_NETID])// Ensure the packet is sensible
+ if(active_caller && signal.data[PKT_HEAD_SOURCE_ADDRESS] == active_caller[CALLER_NETID])// Ensure the packet is sensible
fuck_off_im_busy()
return RECEIVE_SIGNAL_FINISHED
if("tel_hup")//Remote side hangup
- if(active_caller && signal.data[PACKET_SOURCE_ADDRESS] == active_caller[CALLER_NETID])// Ensure the packet is sensible
+ if(active_caller && signal.data[PKT_HEAD_SOURCE_ADDRESS] == active_caller[CALLER_NETID])// Ensure the packet is sensible
switch(state)
if(STATE_ANSWER)
drop_call()// Call never connected, just reset.
@@ -588,8 +588,8 @@
//Bundle up what we care about.
var/datum/signal/v_signal = new(src, null, TRANSMISSION_WIRE)
v_signal.has_magic_data = MAGIC_DATA_INVIOLABLE //We're sending a virtual speaker. This packet MUST be discarded.
- v_signal.data[PACKET_SOURCE_ADDRESS] = null //(Set by post_signal), Just setting it to null means it's always first in the list.
- v_signal.data[PACKET_DESTINATION_ADDRESS] = callstation.active_caller[CALLER_NETID]
+ v_signal.data[PKT_HEAD_SOURCE_ADDRESS] = null //(Set by post_signal), Just setting it to null means it's always first in the list.
+ v_signal.data[PKT_HEAD_DEST_ADDRESS] = callstation.active_caller[CALLER_NETID]
v_signal.data["command"] = "tel_voicedata"
v_signal.data["virtualspeaker"] = v_speaker //This is a REAL REFERENCE. Packet MUST be discarded.
v_signal.data["message"] = message
diff --git a/code/game/machinery/datanet/README.md b/code/game/machinery/datanet/packetv1.md
similarity index 67%
rename from code/game/machinery/datanet/README.md
rename to code/game/machinery/datanet/packetv1.md
index e8e8dde7eb63..131076271d60 100644
--- a/code/game/machinery/datanet/README.md
+++ b/code/game/machinery/datanet/packetv1.md
@@ -1,9 +1,9 @@
# Data Networks, or: Why the OSI Model is for Pussies
-
## Important Variables
### Data
+
These are the basic entries in a signal's data list, which are required for standard network transport.
`s_addr` - Source Address, the ID of the machine that transmitted the packet.
@@ -14,8 +14,9 @@ Example:
```json
{
- "s_addr":00000001, // We are being sent by device 1
- "d_addr":00000002, // intended for device 2
- "command":"do_thing", // and we want them to "do_thing"
- "other_fields":"Are implimentation specific."
+ "PKT_HEAD_SOURCE_ADDR": 00000001, // We are being sent by device 1
+ "PKT_HEAD_DEST_ADDR": 00000002, // intended for device 2
+ "command": "do_thing", // and we want them to "do_thing"
+ "other_fields": "Are implimentation specific."
}
+```
diff --git a/code/game/machinery/datanet/packetv2.md b/code/game/machinery/datanet/packetv2.md
new file mode 100644
index 000000000000..aaaa0b946e2b
--- /dev/null
+++ b/code/game/machinery/datanet/packetv2.md
@@ -0,0 +1,17 @@
+```json
+{
+ "PKT_VERSION": 2,
+ "PKT_HEAD_SOURCE_ADDR": 00000001, // We are being sent by device 1
+ "PKT_HEAD_DEST_ADDR": 00000002, // intended for device 2.
+ "PKT_HEAD_SOURCE_PORT": 1, // The port the packet was broadcast from.
+ "PKT_HEAD_DEST_PORT": 320, // The port the packet is destined for. This is often a fixed number based on the usage.
+ "PKT_HEAD_NETCLASS": "NETCLASS_ADAPTER", // The type of device describing the source.
+ "PKT_HEAD_PROTOCOL": "PKT_PROTOCOL_PDP", // The protocol describing the exchange format.
+ "PKT_PAYLOAD": {
+ "PKT_ARG_CMD": "keepalive", // A command to give to the recieving machine, using payload as parameters.
+ // Any misc. data not specified by the format.
+ "impl. specific value": "true",
+ "impl. specific value 2": 27
+ }
+}
+```
diff --git a/code/game/machinery/telecomms/machines/message_server.dm b/code/game/machinery/telecomms/machines/message_server.dm
index d2d74f4d3ff0..9dd3da361aa7 100644
--- a/code/game/machinery/telecomms/machines/message_server.dm
+++ b/code/game/machinery/telecomms/machines/message_server.dm
@@ -158,9 +158,9 @@ TYPEINFO_DEF(/obj/machinery/blackbox_recorder)
if(calibrating) // If we're calibrating, just return, the fancy part of us isn't ready yet.
return
var/list/sig_data = signal.data //cachemere sweater
- switch(signal.data[PACKET_CMD])
+ switch(signal.data[PKT_ARG_CMD])
if(NETCMD_PDAMESSAGE)
- var/datum/data_pda_message/log_unit = new(sig_data[PACKET_DESTINATION_ADDRESS], sig_data[PACKET_SOURCE_ADDRESS], sig_data["message"])
+ var/datum/data_pda_message/log_unit = new(sig_data[PKT_HEAD_DEST_ADDRESS], sig_data[PKT_HEAD_SOURCE_ADDRESS], sig_data["message"])
pda_msgs += log_unit
return RECEIVE_SIGNAL_FINISHED
else
@@ -171,7 +171,7 @@ TYPEINFO_DEF(/obj/machinery/blackbox_recorder)
if(isnull(sending_signal)) //nullcheck for sanic speed
return //You need a pipe and something to send down it, though.
if(!preserve_s_addr)
- sending_signal.data[PACKET_SOURCE_ADDRESS] = src.net_id
+ sending_signal.data[PKT_HEAD_SOURCE_ADDRESS] = src.net_id
sending_signal.transmission_method = TRANSMISSION_RADIO
sending_signal.author = WEAKREF(src) // Override the sending signal author.
diff --git a/code/modules/computer4/data/socket.dm b/code/modules/computer4/data/socket.dm
index 15563d938184..21c5164dd091 100644
--- a/code/modules/computer4/data/socket.dm
+++ b/code/modules/computer4/data/socket.dm
@@ -40,6 +40,11 @@
head_pointer = 0
tail_pointer = 0
+/datum/pdp_socket/Destroy(force, ...)
+ outgoing_datum = null
+ owner = null
+ return ..()
+
/// Place received packet into ringqueue. Returns TRUE if inserted, FALSE if dropped due to full queue.
// No lohi I am not implimenting DSCP. Right now, at least. Maybe later.
/datum/pdp_socket/proc/enqueue(datum/signal/packet)
@@ -66,17 +71,7 @@
// Packets come out of this preeetty skeletonized, Higher layers above this are expected to fill out some remaining details
// Such as source address.
- var/list/packet_data = list(
- PACKET_ARG_PROTOCOL = PACKET_ARG_PROTOCOL_PDP,
-
- PDP_DESTINATION_ADDRESS = d_address,
- PDP_DESTINATION_PORT = d_port,
-
- //Source address set at NIC
- PDP_SOURCE_PORT = bound_port,
-
- PDP_PAYLOAD_DATA = payload
- )
+ var/list/packet_data = packetv2(null, d_address, bound_port, d_port, protocol = PKT_PROTOCOL_PDP, payload = payload)
var/datum/signal/packet = new(null, packet_data)
diff --git a/code/modules/computer4/data/terminal/operating_system/_operating_system.dm b/code/modules/computer4/data/terminal/operating_system/_operating_system.dm
index 37f53d8b526b..7b83bd9de483 100644
--- a/code/modules/computer4/data/terminal/operating_system/_operating_system.dm
+++ b/code/modules/computer4/data/terminal/operating_system/_operating_system.dm
@@ -19,6 +19,7 @@
/// Halt And Catch Fire (Prevents STDIN, closest we can get to a HALT state.)
var/deadlocked = FALSE
+ /// Associative list of "port_num" : socket_instance
var/list/datum/pdp_socket/pdp_port_map
/datum/c4_file/terminal_program/operating_system/Destroy()
@@ -70,7 +71,9 @@
get_computer()?.text_buffer = ""
get_computer()?.operating_system = null
- pdp_port_map = null //Programs should clean these up, but just in case.
+ //Programs should clean these up, but just in case.
+ QDEL_LIST_ASSOC_VAL(pdp_port_map)
+ pdp_port_map = null
/datum/c4_file/terminal_program/operating_system/execute(datum/c4_file/terminal_program/operating_system/system)
if(system != src)
diff --git a/code/modules/computer4/data/terminal/operating_system/networking.dm b/code/modules/computer4/data/terminal/operating_system/networking.dm
index cdd12706bec7..75e3446b3bec 100644
--- a/code/modules/computer4/data/terminal/operating_system/networking.dm
+++ b/code/modules/computer4/data/terminal/operating_system/networking.dm
@@ -43,6 +43,6 @@
/datum/c4_file/terminal_program/operating_system/proc/pdp_incoming(datum/signal/packet)
var/list/fields = packet.data
- var/datum/pdp_socket/socket = pdp_port_map["[fields[PDP_DESTINATION_PORT]]"]
+ var/datum/pdp_socket/socket = pdp_port_map["[fields[PKT_HEAD_DEST_PORT]]"]
socket?.enqueue(packet)
diff --git a/code/modules/computer4/data/terminal/operating_system/rtos/access_door.dm b/code/modules/computer4/data/terminal/operating_system/rtos/access_door.dm
index 2423be6ba5a1..8a8ea5a654ee 100644
--- a/code/modules/computer4/data/terminal/operating_system/rtos/access_door.dm
+++ b/code/modules/computer4/data/terminal/operating_system/rtos/access_door.dm
@@ -226,7 +226,7 @@
src,
list(
"tag" = tag_target,
- PACKET_CMD = "secure_open"
+ PKT_ARG_CMD = "secure_open"
)
)
expected_airlock_state = "open"
@@ -235,7 +235,7 @@
src,
list(
"tag" = tag_target,
- PACKET_CMD = "secure_close"
+ PKT_ARG_CMD = "secure_close"
)
)
expected_airlock_state = "closed"
@@ -244,7 +244,7 @@
src,
list(
"tag" = tag_target,
- PACKET_CMD = "status"
+ PKT_ARG_CMD = "status"
)
)
if(AC_COMMAND_BOLT)
@@ -252,7 +252,7 @@
src,
list(
"tag" = tag_target,
- PACKET_CMD = "lock"
+ PKT_ARG_CMD = "lock"
)
)
expected_bolt_state = "locked"
@@ -261,7 +261,7 @@
src,
list(
"tag" = tag_target,
- PACKET_CMD = "unlock"
+ PKT_ARG_CMD = "unlock"
)
)
expected_bolt_state = "unlocked"
@@ -348,7 +348,7 @@
src,
list(
"tag" = tag_slave,
- PACKET_CMD = NETCMD_UPDATE_DATA,
+ PKT_ARG_CMD = NETCMD_UPDATE_DATA,
PACKET_ARG_TEXTBUFFER = list2params(print_history),
PACKET_ARG_DISPLAY = display_icon,
PACKET_ARG_LEDS = display_indicators
@@ -362,7 +362,7 @@
return //what
if(tag_slave && (data["tag"] == tag_slave))
- switch(data[PACKET_CMD])
+ switch(data[PKT_ARG_CMD])
if("key")
std_in(copytext(data["key"],1,2)) //Only one char, sorry.
if(NETCMD_ECSLAVE_ACCESS)
diff --git a/code/modules/computer4/data/terminal/operating_system/rtos/pincode_door.dm b/code/modules/computer4/data/terminal/operating_system/rtos/pincode_door.dm
index 9caadc16310f..5bb6122101ab 100644
--- a/code/modules/computer4/data/terminal/operating_system/rtos/pincode_door.dm
+++ b/code/modules/computer4/data/terminal/operating_system/rtos/pincode_door.dm
@@ -385,7 +385,7 @@
src,
list(
"tag" = tag_slave,
- PACKET_CMD = NETCMD_UPDATE_DATA,
+ PKT_ARG_CMD = NETCMD_UPDATE_DATA,
PACKET_ARG_TEXTBUFFER = list2params(print_history),
PACKET_ARG_DISPLAY = display_icon,
PACKET_ARG_LEDS = display_indicators
@@ -398,7 +398,7 @@
if(!data["tag"])
return //what
if(tag_slave && (data["tag"] == tag_slave))
- switch(data[PACKET_CMD])
+ switch(data[PKT_ARG_CMD])
if("key")
std_in(copytext(data["key"],1,2)) //Only one char, sorry.
if(NETCMD_UPDATE_REQUEST)
@@ -434,7 +434,7 @@
src,
list(
"tag" = tag_target,
- PACKET_CMD = "secure_open"
+ PKT_ARG_CMD = "secure_open"
)
)
expected_airlock_state = "open"
@@ -443,7 +443,7 @@
src,
list(
"tag" = tag_target,
- PACKET_CMD = "secure_close"
+ PKT_ARG_CMD = "secure_close"
)
)
expected_airlock_state = "closed"
@@ -452,7 +452,7 @@
src,
list(
"tag" = tag_target,
- PACKET_CMD = "status"
+ PKT_ARG_CMD = "status"
)
)
if(AC_COMMAND_BOLT)
@@ -460,7 +460,7 @@
src,
list(
"tag" = tag_target,
- PACKET_CMD = "lock"
+ PKT_ARG_CMD = "lock"
)
)
expected_bolt_state = "locked"
@@ -469,7 +469,7 @@
src,
list(
"tag" = tag_target,
- PACKET_CMD = "unlock"
+ PKT_ARG_CMD = "unlock"
)
)
expected_bolt_state = "unlocked"
diff --git a/code/modules/computer4/data/terminal/operating_system/rtos/simple_door_control.dm b/code/modules/computer4/data/terminal/operating_system/rtos/simple_door_control.dm
index 016508082ebb..708fe3645987 100644
--- a/code/modules/computer4/data/terminal/operating_system/rtos/simple_door_control.dm
+++ b/code/modules/computer4/data/terminal/operating_system/rtos/simple_door_control.dm
@@ -88,7 +88,7 @@
src,
list(
"tag" = id_tag,
- PACKET_CMD = "update" //Doesn't matter.
+ PKT_ARG_CMD = "update" //Doesn't matter.
)
)
post_signal(signal, RADIO_AIRLOCK)
@@ -102,7 +102,7 @@
src,
list(
"tag" = id_tag,
- PACKET_CMD = (doorbolt_state == "locked") ? "unlock" : "lock"
+ PKT_ARG_CMD = (doorbolt_state == "locked") ? "unlock" : "lock"
)
)
if("#") //Toggle Open
@@ -110,7 +110,7 @@
src,
list(
"tag" = id_tag,
- PACKET_CMD = (dooropen_state == "closed") ? "open" : "close"
+ PKT_ARG_CMD = (dooropen_state == "closed") ? "open" : "close"
)
)
else //Just probe the airlock to update state.
diff --git a/code/modules/computer4/data/terminal/operating_system/rtos/slave.dm b/code/modules/computer4/data/terminal/operating_system/rtos/slave.dm
index 6194f2fde70f..5c59bb76bcf6 100644
--- a/code/modules/computer4/data/terminal/operating_system/rtos/slave.dm
+++ b/code/modules/computer4/data/terminal/operating_system/rtos/slave.dm
@@ -25,7 +25,7 @@
src,
list(
"tag" = id_tag,
- PACKET_CMD = NETCMD_UPDATE_REQUEST,
+ PKT_ARG_CMD = NETCMD_UPDATE_REQUEST,
)
)
post_signal(signal)
@@ -40,7 +40,7 @@
/datum/c4_file/terminal_program/operating_system/rtos/slave/proc/handle_packet(datum/signal/packet)
var/list/fields = packet.data
- if(fields[PACKET_CMD] != NETCMD_UPDATE_DATA)
+ if(fields[PKT_ARG_CMD] != NETCMD_UPDATE_DATA)
return
var/redraw_screen = FALSE
@@ -76,7 +76,7 @@
src,
list(
"tag" = id_tag,
- PACKET_CMD = NETCMD_ECSLAVE_ACCESS,
+ PKT_ARG_CMD = NETCMD_ECSLAVE_ACCESS,
"packet" = list2params(packet.data)
)
)
@@ -87,7 +87,7 @@
src,
list(
"tag" = id_tag,
- PACKET_CMD = "key",
+ PKT_ARG_CMD = "key",
"key" = text
)
)
diff --git a/code/modules/computer4/data/terminal/probe/probe.dm b/code/modules/computer4/data/terminal/probe/probe.dm
index 22048c7966c1..ed36035fdda0 100644
--- a/code/modules/computer4/data/terminal/probe/probe.dm
+++ b/code/modules/computer4/data/terminal/probe/probe.dm
@@ -48,11 +48,11 @@
if(!packet)
return
- if(!packet.data[PACKET_NETCLASS] || !packet.data[PACKET_SOURCE_ADDRESS] || (packet.data[PACKET_CMD] != NET_COMMAND_PING_REPLY))
+ if(!packet.data[PKT_HEAD_NETCLASS] || !packet.data[PKT_HEAD_SOURCE_ADDRESS] || (packet.data[PKT_ARG_CMD] != NET_COMMAND_PING_REPLY))
return
- var/reply_netclass = packet.data[PACKET_NETCLASS]
- var/reply_id = packet.data[PACKET_SOURCE_ADDRESS]
+ var/reply_netclass = packet.data[PKT_HEAD_NETCLASS]
+ var/reply_id = packet.data[PKT_HEAD_SOURCE_ADDRESS]
ping_replies[reply_id] = reply_netclass
get_os().println("\[[reply_netclass]\]-TYPE: [reply_id]")
diff --git a/code/modules/computer4/peripherals/network_card.dm b/code/modules/computer4/peripherals/network_card.dm
index e397a0a9df2d..44d354a85def 100644
--- a/code/modules/computer4/peripherals/network_card.dm
+++ b/code/modules/computer4/peripherals/network_card.dm
@@ -56,7 +56,7 @@
if(!master_pc?.is_operational || !radio_connection)
return
- packet.data[PACKET_SOURCE_ADDRESS] = network_id
+ packet.data[PKT_HEAD_SOURCE_ADDRESS] = network_id
// Rewrite the author so we don't get the packet we just sent back.
packet.author = WEAKREF(src)
radio_connection.post_signal(packet, filter)
@@ -74,15 +74,15 @@
switch(listen_mode)
if(WIRELESS_FILTER_NETADDR)
// Isn't meant for us, but could be a ping
- if(signal.data[PACKET_DESTINATION_ADDRESS] != network_id)
- if(!signal.data[PACKET_SOURCE_ADDRESS] || (signal.data[PACKET_DESTINATION_ADDRESS] != NET_ADDRESS_PING))
+ if(signal.data[PKT_HEAD_DEST_ADDRESS] != network_id)
+ if(!signal.data[PKT_HEAD_SOURCE_ADDRESS] || (signal.data[PKT_HEAD_DEST_ADDRESS] != NET_ADDRESS_PING))
return // Is not a ping, bye bye!
var/list/data = list(
- PACKET_SOURCE_ADDRESS = network_id,
- PACKET_DESTINATION_ADDRESS = signal.data[PACKET_SOURCE_ADDRESS],
- PACKET_CMD = NET_COMMAND_PING_REPLY,
- PACKET_NETCLASS = NETCLASS_ADAPTER,
+ PKT_HEAD_SOURCE_ADDRESS = network_id,
+ PKT_HEAD_DEST_ADDRESS = signal.data[PKT_HEAD_SOURCE_ADDRESS],
+ PKT_ARG_CMD = NET_COMMAND_PING_REPLY,
+ PKT_HEAD_NETCLASS = NETCLASS_ADAPTER,
)
var/datum/signal/packet = new(src, data, TRANSMISSION_RADIO)
@@ -98,7 +98,7 @@
*/
var/datum/signal/clone = signal.Copy()
- if(signal.data[PACKET_ARG_PROTOCOL] == PACKET_ARG_PROTOCOL_PDP)
+ if(signal.data[PKT_HEAD_PROTOCOL] == PKT_PROTOCOL_PDP)
master_pc.peripheral_input(src, PERIPHERAL_CMD_RECEIVE_PDP_PACKET, clone)
else
master_pc.peripheral_input(src, PERIPHERAL_CMD_RECEIVE_PACKET, clone)
@@ -109,8 +109,8 @@
COOLDOWN_START(src, ping_cooldown, 2 SECONDS)
var/list/data = list(
- PACKET_SOURCE_ADDRESS = network_id,
- PACKET_DESTINATION_ADDRESS = NET_ADDRESS_PING,
+ PKT_HEAD_SOURCE_ADDRESS = network_id,
+ PKT_HEAD_DEST_ADDRESS = NET_ADDRESS_PING,
)
var/datum/signal/packet = new(src, data)
diff --git a/code/modules/modular_computers/file_system/programs/ntmessenger.dm b/code/modules/modular_computers/file_system/programs/ntmessenger.dm
index e95b26bebebd..6b9f5e23dcc5 100644
--- a/code/modules/modular_computers/file_system/programs/ntmessenger.dm
+++ b/code/modules/modular_computers/file_system/programs/ntmessenger.dm
@@ -93,7 +93,7 @@
var/list/signal_data = signal.data
if(!signal_data)
return
- var/signal_command = signal_data[PACKET_CMD]
+ var/signal_command = signal_data[PKT_ARG_CMD]
//Network ID verification is "hardware accelerated" (AKA: Done for us by the card)
var/rigged = FALSE//are we going to explode?
@@ -104,7 +104,7 @@
// ESPECIALLY THIS FUCKER RIGHT HERE vvvv
if(signal_data[SSpackets.pda_exploitable_register] == SSpackets.detomatix_magic_packet)
//This one falls through to standard PDA behaviour, so we need to be checked first.
- if(signal_data[PACKET_DESTINATION_ADDRESS] == netcard_cache.hardware_id)//No broadcast bombings, fuck off.
+ if(signal_data[PKT_HEAD_DEST_ADDRESS] == netcard_cache.hardware_id)//No broadcast bombings, fuck off.
//Calculate our "difficulty"
var/difficulty
var/obj/item/computer_hardware/hard_drive/role/our_jobdisk = computer.all_components[MC_HDD_JOB]
@@ -114,7 +114,7 @@
difficulty++ //if cartridge has manifest access it has extra snowflake difficulty
if(!((SEND_SIGNAL(computer, COMSIG_TABLET_CHECK_DETONATE) & COMPONENT_TABLET_NO_DETONATE) || prob(difficulty * 15)))
rigged = TRUE //Cool, we're allowed to blow up. Really glad this whole check wasn't for nothing.
- var/trait_timer_key = signal_data[PACKET_SOURCE_ADDRESS]
+ var/trait_timer_key = signal_data[PKT_HEAD_SOURCE_ADDRESS]
ADD_TRAIT(computer, TRAIT_PDA_CAN_EXPLODE, trait_timer_key)
ADD_TRAIT(computer, TRAIT_PDA_MESSAGE_MENU_RIGGED, trait_timer_key)
addtimer(TRAIT_CALLBACK_REMOVE(computer, TRAIT_PDA_MESSAGE_MENU_RIGGED, trait_timer_key), 10 SECONDS)
@@ -127,7 +127,7 @@
html_decode("\"[signal_data["message"]]\"") || "#ERROR_MISSING_FIELD",
FALSE,
signal_data["automated"] || FALSE,
- signal_data[PACKET_SOURCE_ADDRESS] || null
+ signal_data[PKT_HEAD_SOURCE_ADDRESS] || null
)
if(ringer_status)
@@ -189,7 +189,7 @@
L = get(holder.holder, /mob/living/silicon)
if(L && L.stat == CONSCIOUS)
- var/reply = "(Reply)"
+ var/reply = "(Reply)"
var/hrefstart
var/hrefend
var/job_string = signal_data["job"] ? " ([signal_data["job"]])" : ""
@@ -197,7 +197,7 @@
hrefstart = ""
hrefend = ""
- if(signal_data[PACKET_SOURCE_ADDRESS] == null)
+ if(signal_data[PKT_HEAD_SOURCE_ADDRESS] == null)
reply = "\[#ERRNOADDR\]"
if(signal_data["automated"])
@@ -269,11 +269,11 @@
var/datum/signal/pda_message = new(
src,
list(
- PACKET_CMD = NETCMD_PDAMESSAGE,
+ PKT_ARG_CMD = NETCMD_PDAMESSAGE,
"name" = fake_name || computer.saved_identification,
"job" = fake_job || computer.saved_job,
"message" = html_decode(message),
- PACKET_DESTINATION_ADDRESS = target_address
+ PKT_HEAD_DEST_ADDRESS = target_address
),
logging_data = user
)
@@ -354,7 +354,7 @@
if(!istype(pnetcard)) //This catches nulls too, so...
to_chat(usr, span_warning("Radio missing or bad driver!"))
var/datum/signal/ping_sig = new(src, list(
- PACKET_DESTINATION_ADDRESS = NET_ADDRESS_PING,
+ PKT_HEAD_DEST_ADDRESS = NET_ADDRESS_PING,
"pda_scan" = "true"
))
pnetcard.post_signal(ping_sig)
diff --git a/code/modules/modular_computers/hardware/gprs_card.dm b/code/modules/modular_computers/hardware/gprs_card.dm
index 4caa2cc89ff6..ed44e4edba59 100644
--- a/code/modules/modular_computers/hardware/gprs_card.dm
+++ b/code/modules/modular_computers/hardware/gprs_card.dm
@@ -62,14 +62,14 @@
if(signal.transmission_method != TRANSMISSION_RADIO)
CRASH("[src] received non-radio packet, transmission method ID [signal.transmission_method], Expected [TRANSMISSION_RADIO]")
var/list/signal_data = signal.data //medium velocity silver hedgehog
- var/signal_d_addr = signal_data[PACKET_DESTINATION_ADDRESS]
+ var/signal_d_addr = signal_data[PKT_HEAD_DEST_ADDRESS]
if(signal_d_addr == NET_ADDRESS_PING) //Ping.
var/datum/signal/outgoing = new(
src,
list(
- PACKET_DESTINATION_ADDRESS = signal_data[PACKET_SOURCE_ADDRESS],
- PACKET_CMD = NET_COMMAND_PING_REPLY,
- PACKET_NETCLASS = NETCLASS_GRPS_CARD,
+ PKT_HEAD_DEST_ADDRESS = signal_data[PKT_HEAD_SOURCE_ADDRESS],
+ PKT_ARG_CMD = NET_COMMAND_PING_REPLY,
+ PKT_HEAD_NETCLASS = NETCLASS_GRPS_CARD,
"netaddr" = hardware_id
)
)
@@ -83,11 +83,11 @@
//Either it's broadcast or directed to us.
if(isnull(signal_d_addr) || signal_d_addr == hardware_id)
// If it's a ping reply, check for a PDA.
- if(signal.data[PACKET_CMD] == NET_COMMAND_PING_REPLY)
+ if(signal.data[PKT_ARG_CMD] == NET_COMMAND_PING_REPLY)
//If it's from a GPRS card, respond, otherwise, who cares.
- if(signal.data[PACKET_NETCLASS] == NETCLASS_GRPS_CARD)
+ if(signal.data[PKT_HEAD_NETCLASS] == NETCLASS_GRPS_CARD)
var/list/new_pda_info = list(
- "target_addr" = signal.data[PACKET_SOURCE_ADDRESS],
+ "target_addr" = signal.data[PKT_HEAD_SOURCE_ADDRESS],
"name" = signal.data["reg_name"] || "#UNK",
"job" = signal.data["reg_job"] || "#UNK"
)
@@ -101,7 +101,7 @@
/obj/item/computer_hardware/network_card/packetnet/post_signal(datum/signal/signal)
if(!radio_connection || !signal)
return FALSE // Something went wrong.
- signal.data[PACKET_SOURCE_ADDRESS] = hardware_id //Readdress outgoing packets.
+ signal.data[PKT_HEAD_SOURCE_ADDRESS] = hardware_id //Readdress outgoing packets.
signal.author = WEAKREF(src)
radio_connection.post_signal(signal, RADIO_PDAMESSAGE)
return TRUE //We at least tried.
diff --git a/code/modules/modular_computers/hardware/virus_disk.dm b/code/modules/modular_computers/hardware/virus_disk.dm
index 2bbda2e7c554..b8e10b32aaab 100644
--- a/code/modules/modular_computers/hardware/virus_disk.dm
+++ b/code/modules/modular_computers/hardware/virus_disk.dm
@@ -30,7 +30,7 @@
var/list/user_input_tuple = user_input(target_addr, user)
var/datum/signal/outgoing = new(src, list(
SSpackets.pda_exploitable_register = magic_packet,
- PACKET_DESTINATION_ADDRESS = target_addr
+ PKT_HEAD_DEST_ADDRESS = target_addr
))
var/signal_data = outgoing.data
switch(user_input_tuple[1])
@@ -121,7 +121,7 @@
var/list/pda_data_staple = list(
// We already have the target address
// GPRS Card handles the source address
- PACKET_CMD = NETCMD_PDAMESSAGE,
+ PKT_ARG_CMD = NETCMD_PDAMESSAGE,
"name" = sender_name,
"job" = sender_job,
"message" = text_message
diff --git a/daedalus.dme b/daedalus.dme
index 1267ac240f2c..a736a501a528 100644
--- a/daedalus.dme
+++ b/daedalus.dme
@@ -403,6 +403,7 @@
#include "code\__HELPERS\mouse_control.dm"
#include "code\__HELPERS\nameof.dm"
#include "code\__HELPERS\names.dm"
+#include "code\__HELPERS\packetnet.dm"
#include "code\__HELPERS\piping_colors_lists.dm"
#include "code\__HELPERS\priority_announce.dm"
#include "code\__HELPERS\pronouns.dm"
From 65ee145af4d88e17d1cc4230fb880f3575775deb Mon Sep 17 00:00:00 2001
From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com>
Date: Thu, 7 Aug 2025 15:14:35 -0400
Subject: [PATCH 05/14] This can just be there
---
.../data/terminal/operating_system/_operating_system.dm | 4 ++--
.../computer4/data/terminal/operating_system/networking.dm | 2 --
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/code/modules/computer4/data/terminal/operating_system/_operating_system.dm b/code/modules/computer4/data/terminal/operating_system/_operating_system.dm
index 7b83bd9de483..c32b890deda5 100644
--- a/code/modules/computer4/data/terminal/operating_system/_operating_system.dm
+++ b/code/modules/computer4/data/terminal/operating_system/_operating_system.dm
@@ -20,7 +20,7 @@
var/deadlocked = FALSE
/// Associative list of "port_num" : socket_instance
- var/list/datum/pdp_socket/pdp_port_map
+ var/list/datum/pdp_socket/pdp_port_map = list()
/datum/c4_file/terminal_program/operating_system/Destroy()
if(length(processing_programs))
@@ -73,7 +73,7 @@
//Programs should clean these up, but just in case.
QDEL_LIST_ASSOC_VAL(pdp_port_map)
- pdp_port_map = null
+ pdp_port_map.Cut()
/datum/c4_file/terminal_program/operating_system/execute(datum/c4_file/terminal_program/operating_system/system)
if(system != src)
diff --git a/code/modules/computer4/data/terminal/operating_system/networking.dm b/code/modules/computer4/data/terminal/operating_system/networking.dm
index 75e3446b3bec..2e559bddf170 100644
--- a/code/modules/computer4/data/terminal/operating_system/networking.dm
+++ b/code/modules/computer4/data/terminal/operating_system/networking.dm
@@ -1,6 +1,4 @@
/datum/c4_file/terminal_program/operating_system/proc/prepare_networking()
- //Create the array of all ports. Do I really need this many? No. I'll probably reduce this later to like, 1024.
- pdp_port_map = list()
/// Request a socket from the OS.
/// A `port_number` of 0 will result in being allocated an ephemeral port.
From 3e51d133cf8f1937055a1d54a6a873a63fbdd6fd Mon Sep 17 00:00:00 2001
From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com>
Date: Thu, 7 Aug 2025 23:15:01 -0400
Subject: [PATCH 06/14] add legacy aliases for old code
---
.../centralized_phones/callstation.dm | 2 +-
code/__DEFINES/packetnet.dm | 6 ++++++
code/game/machinery/announcement_system.dm | 8 ++++----
code/game/machinery/buttons_radio.dm | 4 ++--
code/game/machinery/datanet/_networked.dm | 12 +++++------
.../datanet/p2p_phones/_p2p_phones.dm | 20 +++++++++----------
.../telecomms/machines/message_server.dm | 6 +++---
.../operating_system/rtos/access_door.dm | 14 ++++++-------
.../operating_system/rtos/pincode_door.dm | 14 ++++++-------
.../rtos/simple_door_control.dm | 6 +++---
.../terminal/operating_system/rtos/slave.dm | 8 ++++----
.../computer4/data/terminal/probe/probe.dm | 6 +++---
.../computer4/peripherals/network_card.dm | 18 ++++++++---------
.../file_system/programs/ntmessenger.dm | 18 ++++++++---------
.../modular_computers/hardware/gprs_card.dm | 16 +++++++--------
.../modular_computers/hardware/virus_disk.dm | 4 ++--
16 files changed, 84 insertions(+), 78 deletions(-)
diff --git a/WorkInProgress/francinum/centralized_phones/callstation.dm b/WorkInProgress/francinum/centralized_phones/callstation.dm
index 4fd4ad13f2bd..ed5508693a75 100644
--- a/WorkInProgress/francinum/centralized_phones/callstation.dm
+++ b/WorkInProgress/francinum/centralized_phones/callstation.dm
@@ -44,7 +44,7 @@ Phone registration flow (Post-Roundstart):
return
switch(lowertext(signal.data["command"]))
if("ping_reply")// A reply to our ping!
- if(signal.data[PKT_HEAD_NETCLASS] != "PNET_SIPSERVER") //Not who we care about!
+ if(signal.data[LEGACY_PACKET_NETCLASS] != "PNET_SIPSERVER") //Not who we care about!
return
register_with_server(signal.data["s_addr"])// It's a server, link!
if("sip_adopt")
diff --git a/code/__DEFINES/packetnet.dm b/code/__DEFINES/packetnet.dm
index 6f869d4fcc04..5f35d5716d2d 100644
--- a/code/__DEFINES/packetnet.dm
+++ b/code/__DEFINES/packetnet.dm
@@ -53,6 +53,12 @@
/// Command (type) of a packet
#define PKT_ARG_CMD "command"
+// Legacy fields. Do not use.
+#define LEGACY_PACKET_SOURCE_ADDRESS PKT_HEAD_SOURCE_ADDRESS
+#define LEGACY_PACKET_DESTINATION_ADDRESS PKT_HEAD_DEST_ADDRESS
+#define LEGACY_PACKET_NETCLASS PKT_HEAD_NETCLASS
+#define LEGACY_PACKET_COMMAND PKT_ARG_CMD
+
// Pagers
/// Packet arg for pager types
#define PACKET_ARG_PAGER_CLASS "pager_class"
diff --git a/code/game/machinery/announcement_system.dm b/code/game/machinery/announcement_system.dm
index 17a0ba4b6bd2..24bf637914b8 100644
--- a/code/game/machinery/announcement_system.dm
+++ b/code/game/machinery/announcement_system.dm
@@ -224,7 +224,7 @@ GLOBAL_LIST_EMPTY(announcement_systems)
for(var/next_addr in targets)
var/datum/signal/outgoing = create_signal(next_addr, list(
- PKT_ARG_CMD = NETCMD_PDAMESSAGE,
+ LEGACY_PACKET_COMMAND = NETCMD_PDAMESSAGE,
"name" = "Automated Announcement System",
"job" = "Security Department Update",
"message" = "Officer [officer.real_name] has been assigned to your department, [department].",
@@ -244,7 +244,7 @@ GLOBAL_LIST_EMPTY(announcement_systems)
break //No RF card to send to.
var/message = "You have been fined [fine_amount] marks for '[cite_message]'. Fines may be paid at security."
var/datum/signal/outgoing = create_signal(rfcard.hardware_id, list(
- PKT_ARG_CMD = NETCMD_PDAMESSAGE,
+ LEGACY_PACKET_COMMAND = NETCMD_PDAMESSAGE,
"name" = "Automated Announcement System",
"job" = "Security Citation",
"message" = message,
@@ -257,7 +257,7 @@ GLOBAL_LIST_EMPTY(announcement_systems)
/obj/machinery/announcement_system/proc/mass_pda_message(list/recipients, message, reason)
for(var/next_addr in recipients)
var/datum/signal/outgoing = create_signal(next_addr, list(
- PKT_ARG_CMD = NETCMD_PDAMESSAGE,
+ LEGACY_PACKET_COMMAND = NETCMD_PDAMESSAGE,
"name" = "Automated Announcement System",
"job" = reason,
"message" = message,
@@ -270,7 +270,7 @@ GLOBAL_LIST_EMPTY(announcement_systems)
/// A helper proc for sending an announcement to a single PDA.
/obj/machinery/announcement_system/proc/pda_message(recipient, message, reason)
var/datum/signal/outgoing = create_signal(recipient, list(
- PKT_ARG_CMD = NETCMD_PDAMESSAGE,
+ LEGACY_PACKET_COMMAND = NETCMD_PDAMESSAGE,
"name" = "Automated Announcement System",
"job" = reason,
"message" = message,
diff --git a/code/game/machinery/buttons_radio.dm b/code/game/machinery/buttons_radio.dm
index 856881f9051b..62ca4df29dbd 100644
--- a/code/game/machinery/buttons_radio.dm
+++ b/code/game/machinery/buttons_radio.dm
@@ -13,8 +13,8 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/button/radio, 24)
var/datum/radio_frequency/radio_connection = SSpackets.return_frequency(frequency)
var/datum/signal/signal = new(src, list(
- PKT_HEAD_SOURCE_ADDRESS = net_id,
- PKT_HEAD_NETCLASS = NETCLASS_BUTTON,
+ LEGACY_PACKET_SOURCE_ADDRESS = net_id,
+ LEGACY_PACKET_NETCLASS = NETCLASS_BUTTON,
"tag" = id_tag,
))
radio_connection.post_signal(signal)
diff --git a/code/game/machinery/datanet/_networked.dm b/code/game/machinery/datanet/_networked.dm
index bd05dc4d1cb4..663773bd4cf4 100644
--- a/code/game/machinery/datanet/_networked.dm
+++ b/code/game/machinery/datanet/_networked.dm
@@ -7,8 +7,8 @@
if(!datagram || !destination_id)
return //Unfortunately /dev/null isn't network-scale.
var/list/sig_data = datagram.Copy()
- sig_data[PKT_HEAD_SOURCE_ADDRESS] = src.net_id
- sig_data[PKT_HEAD_DEST_ADDRESS] = destination_id
+ sig_data[LEGACY_PACKET_SOURCE_ADDRESS] = src.net_id
+ sig_data[LEGACY_PACKET_DESTINATION_ADDRESS] = destination_id
return new /datum/signal(src, sig_data, TRANSMISSION_WIRE)
@@ -20,7 +20,7 @@
if(isnull(netjack) || isnull(sending_signal)) //nullcheck for sanic speed
return //You need a pipe and something to send down it, though.
if(!preserve_s_addr)
- sending_signal.data[PKT_HEAD_SOURCE_ADDRESS] = src.net_id
+ sending_signal.data[LEGACY_PACKET_SOURCE_ADDRESS] = src.net_id
sending_signal.transmission_method = TRANSMISSION_WIRE
sending_signal.author = WEAKREF(src) // Override the sending signal author.
src.netjack.post_signal(sending_signal)
@@ -31,13 +31,13 @@
if(isnull(signal))
return
var/sigdat = signal.data //cache for sanic speed this joke is getting old.
- if(sigdat[PKT_HEAD_DEST_ADDRESS] != src.net_id)//This packet doesn't belong to us directly
- if(sigdat[PKT_HEAD_DEST_ADDRESS] == NET_ADDRESS_PING)// But it could be a ping, if so, reply
+ if(sigdat[LEGACY_PACKET_DESTINATION_ADDRESS] != src.net_id)//This packet doesn't belong to us directly
+ if(sigdat[LEGACY_PACKET_DESTINATION_ADDRESS] == NET_ADDRESS_PING)// But it could be a ping, if so, reply
var/tmp_filter = sigdat["filter"]
if(!isnull(tmp_filter) && tmp_filter != net_class)
return RECEIVE_SIGNAL_FINISHED
//Blame kapu for how stupid this looks :3
- post_signal(create_signal(sigdat[PKT_HEAD_SOURCE_ADDRESS], list("command"=NET_COMMAND_PING_REPLY,PKT_HEAD_NETCLASS=src.net_class,"netaddr"=src.net_id)+src.ping_addition))
+ post_signal(create_signal(sigdat[LEGACY_PACKET_SOURCE_ADDRESS], list("command"=NET_COMMAND_PING_REPLY,LEGACY_PACKET_NETCLASS=src.net_class,"netaddr"=src.net_id)+src.ping_addition))
return RECEIVE_SIGNAL_FINISHED//regardless, return 1 so that machines don't process packets not intended for them.
return RECEIVE_SIGNAL_CONTINUE // We are the designated recipient of this packet, we need to handle it.
diff --git a/code/game/machinery/datanet/p2p_phones/_p2p_phones.dm b/code/game/machinery/datanet/p2p_phones/_p2p_phones.dm
index 48b15a3ffeff..14286bd19b39 100644
--- a/code/game/machinery/datanet/p2p_phones/_p2p_phones.dm
+++ b/code/game/machinery/datanet/p2p_phones/_p2p_phones.dm
@@ -231,27 +231,27 @@
if(. == RECEIVE_SIGNAL_FINISHED)//Handled by default.
return
//Ping response handled in parent.
- switch(signal.data[PKT_ARG_CMD])
+ switch(signal.data[LEGACY_PACKET_COMMAND])
if(NET_COMMAND_PING_REPLY)//Add new phone to database
- if(signal.data[PKT_HEAD_NETCLASS] == NETCLASS_P2P_PHONE) //Another phone!
- discovered_phones[signal.data[PKT_HEAD_SOURCE_ADDRESS]]=signal.data["user_id"]
+ if(signal.data[LEGACY_PACKET_NETCLASS] == NETCLASS_P2P_PHONE) //Another phone!
+ discovered_phones[signal.data[LEGACY_PACKET_SOURCE_ADDRESS]]=signal.data["user_id"]
return RECEIVE_SIGNAL_FINISHED
if("tel_ring")//Incoming ring
if(active_caller || handset_state == HANDSET_OFFHOOK)//We're either calling, or about to call, Just tell them to fuck off.
- post_signal(create_signal(signal.data[PKT_HEAD_SOURCE_ADDRESS],list(PKT_ARG_CMD="tel_busy"))) //Busy signal, Reject call.
+ post_signal(create_signal(signal.data[LEGACY_PACKET_SOURCE_ADDRESS],list(LEGACY_PACKET_COMMAND="tel_busy"))) //Busy signal, Reject call.
return RECEIVE_SIGNAL_FINISHED
- receive_call(list(signal.data[PKT_HEAD_SOURCE_ADDRESS],signal.data["caller_id"]))
+ receive_call(list(signal.data[LEGACY_PACKET_SOURCE_ADDRESS],signal.data["caller_id"]))
return RECEIVE_SIGNAL_FINISHED
if("tel_ready")//Remote side pickup
- if(active_caller && signal.data[PKT_HEAD_SOURCE_ADDRESS] == active_caller[CALLER_NETID])// Ensure the packet is sensible
+ if(active_caller && signal.data[LEGACY_PACKET_SOURCE_ADDRESS] == active_caller[CALLER_NETID])// Ensure the packet is sensible
call_connected()
return RECEIVE_SIGNAL_FINISHED
if("tel_busy")//Answering station busy
- if(active_caller && signal.data[PKT_HEAD_SOURCE_ADDRESS] == active_caller[CALLER_NETID])// Ensure the packet is sensible
+ if(active_caller && signal.data[LEGACY_PACKET_SOURCE_ADDRESS] == active_caller[CALLER_NETID])// Ensure the packet is sensible
fuck_off_im_busy()
return RECEIVE_SIGNAL_FINISHED
if("tel_hup")//Remote side hangup
- if(active_caller && signal.data[PKT_HEAD_SOURCE_ADDRESS] == active_caller[CALLER_NETID])// Ensure the packet is sensible
+ if(active_caller && signal.data[LEGACY_PACKET_SOURCE_ADDRESS] == active_caller[CALLER_NETID])// Ensure the packet is sensible
switch(state)
if(STATE_ANSWER)
drop_call()// Call never connected, just reset.
@@ -588,8 +588,8 @@
//Bundle up what we care about.
var/datum/signal/v_signal = new(src, null, TRANSMISSION_WIRE)
v_signal.has_magic_data = MAGIC_DATA_INVIOLABLE //We're sending a virtual speaker. This packet MUST be discarded.
- v_signal.data[PKT_HEAD_SOURCE_ADDRESS] = null //(Set by post_signal), Just setting it to null means it's always first in the list.
- v_signal.data[PKT_HEAD_DEST_ADDRESS] = callstation.active_caller[CALLER_NETID]
+ v_signal.data[LEGACY_PACKET_SOURCE_ADDRESS] = null //(Set by post_signal), Just setting it to null means it's always first in the list.
+ v_signal.data[LEGACY_PACKET_DESTINATION_ADDRESS] = callstation.active_caller[CALLER_NETID]
v_signal.data["command"] = "tel_voicedata"
v_signal.data["virtualspeaker"] = v_speaker //This is a REAL REFERENCE. Packet MUST be discarded.
v_signal.data["message"] = message
diff --git a/code/game/machinery/telecomms/machines/message_server.dm b/code/game/machinery/telecomms/machines/message_server.dm
index 9dd3da361aa7..74481e9a2f15 100644
--- a/code/game/machinery/telecomms/machines/message_server.dm
+++ b/code/game/machinery/telecomms/machines/message_server.dm
@@ -158,9 +158,9 @@ TYPEINFO_DEF(/obj/machinery/blackbox_recorder)
if(calibrating) // If we're calibrating, just return, the fancy part of us isn't ready yet.
return
var/list/sig_data = signal.data //cachemere sweater
- switch(signal.data[PKT_ARG_CMD])
+ switch(signal.data[LEGACY_PACKET_COMMAND])
if(NETCMD_PDAMESSAGE)
- var/datum/data_pda_message/log_unit = new(sig_data[PKT_HEAD_DEST_ADDRESS], sig_data[PKT_HEAD_SOURCE_ADDRESS], sig_data["message"])
+ var/datum/data_pda_message/log_unit = new(sig_data[LEGACY_PACKET_DESTINATION_ADDRESS], sig_data[LEGACY_PACKET_SOURCE_ADDRESS], sig_data["message"])
pda_msgs += log_unit
return RECEIVE_SIGNAL_FINISHED
else
@@ -171,7 +171,7 @@ TYPEINFO_DEF(/obj/machinery/blackbox_recorder)
if(isnull(sending_signal)) //nullcheck for sanic speed
return //You need a pipe and something to send down it, though.
if(!preserve_s_addr)
- sending_signal.data[PKT_HEAD_SOURCE_ADDRESS] = src.net_id
+ sending_signal.data[LEGACY_PACKET_SOURCE_ADDRESS] = src.net_id
sending_signal.transmission_method = TRANSMISSION_RADIO
sending_signal.author = WEAKREF(src) // Override the sending signal author.
diff --git a/code/modules/computer4/data/terminal/operating_system/rtos/access_door.dm b/code/modules/computer4/data/terminal/operating_system/rtos/access_door.dm
index 8a8ea5a654ee..c8980e5dc002 100644
--- a/code/modules/computer4/data/terminal/operating_system/rtos/access_door.dm
+++ b/code/modules/computer4/data/terminal/operating_system/rtos/access_door.dm
@@ -226,7 +226,7 @@
src,
list(
"tag" = tag_target,
- PKT_ARG_CMD = "secure_open"
+ LEGACY_PACKET_COMMAND = "secure_open"
)
)
expected_airlock_state = "open"
@@ -235,7 +235,7 @@
src,
list(
"tag" = tag_target,
- PKT_ARG_CMD = "secure_close"
+ LEGACY_PACKET_COMMAND = "secure_close"
)
)
expected_airlock_state = "closed"
@@ -244,7 +244,7 @@
src,
list(
"tag" = tag_target,
- PKT_ARG_CMD = "status"
+ LEGACY_PACKET_COMMAND = "status"
)
)
if(AC_COMMAND_BOLT)
@@ -252,7 +252,7 @@
src,
list(
"tag" = tag_target,
- PKT_ARG_CMD = "lock"
+ LEGACY_PACKET_COMMAND = "lock"
)
)
expected_bolt_state = "locked"
@@ -261,7 +261,7 @@
src,
list(
"tag" = tag_target,
- PKT_ARG_CMD = "unlock"
+ LEGACY_PACKET_COMMAND = "unlock"
)
)
expected_bolt_state = "unlocked"
@@ -348,7 +348,7 @@
src,
list(
"tag" = tag_slave,
- PKT_ARG_CMD = NETCMD_UPDATE_DATA,
+ LEGACY_PACKET_COMMAND = NETCMD_UPDATE_DATA,
PACKET_ARG_TEXTBUFFER = list2params(print_history),
PACKET_ARG_DISPLAY = display_icon,
PACKET_ARG_LEDS = display_indicators
@@ -362,7 +362,7 @@
return //what
if(tag_slave && (data["tag"] == tag_slave))
- switch(data[PKT_ARG_CMD])
+ switch(data[LEGACY_PACKET_COMMAND])
if("key")
std_in(copytext(data["key"],1,2)) //Only one char, sorry.
if(NETCMD_ECSLAVE_ACCESS)
diff --git a/code/modules/computer4/data/terminal/operating_system/rtos/pincode_door.dm b/code/modules/computer4/data/terminal/operating_system/rtos/pincode_door.dm
index 5bb6122101ab..4efed399d4ac 100644
--- a/code/modules/computer4/data/terminal/operating_system/rtos/pincode_door.dm
+++ b/code/modules/computer4/data/terminal/operating_system/rtos/pincode_door.dm
@@ -385,7 +385,7 @@
src,
list(
"tag" = tag_slave,
- PKT_ARG_CMD = NETCMD_UPDATE_DATA,
+ LEGACY_PACKET_COMMAND = NETCMD_UPDATE_DATA,
PACKET_ARG_TEXTBUFFER = list2params(print_history),
PACKET_ARG_DISPLAY = display_icon,
PACKET_ARG_LEDS = display_indicators
@@ -398,7 +398,7 @@
if(!data["tag"])
return //what
if(tag_slave && (data["tag"] == tag_slave))
- switch(data[PKT_ARG_CMD])
+ switch(data[LEGACY_PACKET_COMMAND])
if("key")
std_in(copytext(data["key"],1,2)) //Only one char, sorry.
if(NETCMD_UPDATE_REQUEST)
@@ -434,7 +434,7 @@
src,
list(
"tag" = tag_target,
- PKT_ARG_CMD = "secure_open"
+ LEGACY_PACKET_COMMAND = "secure_open"
)
)
expected_airlock_state = "open"
@@ -443,7 +443,7 @@
src,
list(
"tag" = tag_target,
- PKT_ARG_CMD = "secure_close"
+ LEGACY_PACKET_COMMAND = "secure_close"
)
)
expected_airlock_state = "closed"
@@ -452,7 +452,7 @@
src,
list(
"tag" = tag_target,
- PKT_ARG_CMD = "status"
+ LEGACY_PACKET_COMMAND = "status"
)
)
if(AC_COMMAND_BOLT)
@@ -460,7 +460,7 @@
src,
list(
"tag" = tag_target,
- PKT_ARG_CMD = "lock"
+ LEGACY_PACKET_COMMAND = "lock"
)
)
expected_bolt_state = "locked"
@@ -469,7 +469,7 @@
src,
list(
"tag" = tag_target,
- PKT_ARG_CMD = "unlock"
+ LEGACY_PACKET_COMMAND = "unlock"
)
)
expected_bolt_state = "unlocked"
diff --git a/code/modules/computer4/data/terminal/operating_system/rtos/simple_door_control.dm b/code/modules/computer4/data/terminal/operating_system/rtos/simple_door_control.dm
index 708fe3645987..766a2edcbbb4 100644
--- a/code/modules/computer4/data/terminal/operating_system/rtos/simple_door_control.dm
+++ b/code/modules/computer4/data/terminal/operating_system/rtos/simple_door_control.dm
@@ -88,7 +88,7 @@
src,
list(
"tag" = id_tag,
- PKT_ARG_CMD = "update" //Doesn't matter.
+ LEGACY_PACKET_COMMAND = "update" //Doesn't matter.
)
)
post_signal(signal, RADIO_AIRLOCK)
@@ -102,7 +102,7 @@
src,
list(
"tag" = id_tag,
- PKT_ARG_CMD = (doorbolt_state == "locked") ? "unlock" : "lock"
+ LEGACY_PACKET_COMMAND = (doorbolt_state == "locked") ? "unlock" : "lock"
)
)
if("#") //Toggle Open
@@ -110,7 +110,7 @@
src,
list(
"tag" = id_tag,
- PKT_ARG_CMD = (dooropen_state == "closed") ? "open" : "close"
+ LEGACY_PACKET_COMMAND = (dooropen_state == "closed") ? "open" : "close"
)
)
else //Just probe the airlock to update state.
diff --git a/code/modules/computer4/data/terminal/operating_system/rtos/slave.dm b/code/modules/computer4/data/terminal/operating_system/rtos/slave.dm
index 5c59bb76bcf6..91a77529414c 100644
--- a/code/modules/computer4/data/terminal/operating_system/rtos/slave.dm
+++ b/code/modules/computer4/data/terminal/operating_system/rtos/slave.dm
@@ -25,7 +25,7 @@
src,
list(
"tag" = id_tag,
- PKT_ARG_CMD = NETCMD_UPDATE_REQUEST,
+ LEGACY_PACKET_COMMAND = NETCMD_UPDATE_REQUEST,
)
)
post_signal(signal)
@@ -40,7 +40,7 @@
/datum/c4_file/terminal_program/operating_system/rtos/slave/proc/handle_packet(datum/signal/packet)
var/list/fields = packet.data
- if(fields[PKT_ARG_CMD] != NETCMD_UPDATE_DATA)
+ if(fields[LEGACY_PACKET_COMMAND] != NETCMD_UPDATE_DATA)
return
var/redraw_screen = FALSE
@@ -76,7 +76,7 @@
src,
list(
"tag" = id_tag,
- PKT_ARG_CMD = NETCMD_ECSLAVE_ACCESS,
+ LEGACY_PACKET_COMMAND = NETCMD_ECSLAVE_ACCESS,
"packet" = list2params(packet.data)
)
)
@@ -87,7 +87,7 @@
src,
list(
"tag" = id_tag,
- PKT_ARG_CMD = "key",
+ LEGACY_PACKET_COMMAND = "key",
"key" = text
)
)
diff --git a/code/modules/computer4/data/terminal/probe/probe.dm b/code/modules/computer4/data/terminal/probe/probe.dm
index ed36035fdda0..a388da6e784f 100644
--- a/code/modules/computer4/data/terminal/probe/probe.dm
+++ b/code/modules/computer4/data/terminal/probe/probe.dm
@@ -48,11 +48,11 @@
if(!packet)
return
- if(!packet.data[PKT_HEAD_NETCLASS] || !packet.data[PKT_HEAD_SOURCE_ADDRESS] || (packet.data[PKT_ARG_CMD] != NET_COMMAND_PING_REPLY))
+ if(!packet.data[LEGACY_PACKET_NETCLASS] || !packet.data[LEGACY_PACKET_SOURCE_ADDRESS] || (packet.data[LEGACY_PACKET_COMMAND] != NET_COMMAND_PING_REPLY))
return
- var/reply_netclass = packet.data[PKT_HEAD_NETCLASS]
- var/reply_id = packet.data[PKT_HEAD_SOURCE_ADDRESS]
+ var/reply_netclass = packet.data[LEGACY_PACKET_NETCLASS]
+ var/reply_id = packet.data[LEGACY_PACKET_SOURCE_ADDRESS]
ping_replies[reply_id] = reply_netclass
get_os().println("\[[reply_netclass]\]-TYPE: [reply_id]")
diff --git a/code/modules/computer4/peripherals/network_card.dm b/code/modules/computer4/peripherals/network_card.dm
index 44d354a85def..9ad424bc6617 100644
--- a/code/modules/computer4/peripherals/network_card.dm
+++ b/code/modules/computer4/peripherals/network_card.dm
@@ -56,7 +56,7 @@
if(!master_pc?.is_operational || !radio_connection)
return
- packet.data[PKT_HEAD_SOURCE_ADDRESS] = network_id
+ packet.data[LEGACY_PACKET_SOURCE_ADDRESS] = network_id
// Rewrite the author so we don't get the packet we just sent back.
packet.author = WEAKREF(src)
radio_connection.post_signal(packet, filter)
@@ -74,15 +74,15 @@
switch(listen_mode)
if(WIRELESS_FILTER_NETADDR)
// Isn't meant for us, but could be a ping
- if(signal.data[PKT_HEAD_DEST_ADDRESS] != network_id)
- if(!signal.data[PKT_HEAD_SOURCE_ADDRESS] || (signal.data[PKT_HEAD_DEST_ADDRESS] != NET_ADDRESS_PING))
+ if(signal.data[LEGACY_PACKET_DESTINATION_ADDRESS] != network_id)
+ if(!signal.data[LEGACY_PACKET_SOURCE_ADDRESS] || (signal.data[LEGACY_PACKET_DESTINATION_ADDRESS] != NET_ADDRESS_PING))
return // Is not a ping, bye bye!
var/list/data = list(
- PKT_HEAD_SOURCE_ADDRESS = network_id,
- PKT_HEAD_DEST_ADDRESS = signal.data[PKT_HEAD_SOURCE_ADDRESS],
- PKT_ARG_CMD = NET_COMMAND_PING_REPLY,
- PKT_HEAD_NETCLASS = NETCLASS_ADAPTER,
+ LEGACY_PACKET_SOURCE_ADDRESS = network_id,
+ LEGACY_PACKET_DESTINATION_ADDRESS = signal.data[LEGACY_PACKET_SOURCE_ADDRESS],
+ LEGACY_PACKET_COMMAND = NET_COMMAND_PING_REPLY,
+ LEGACY_PACKET_NETCLASS = NETCLASS_ADAPTER,
)
var/datum/signal/packet = new(src, data, TRANSMISSION_RADIO)
@@ -109,8 +109,8 @@
COOLDOWN_START(src, ping_cooldown, 2 SECONDS)
var/list/data = list(
- PKT_HEAD_SOURCE_ADDRESS = network_id,
- PKT_HEAD_DEST_ADDRESS = NET_ADDRESS_PING,
+ LEGACY_PACKET_SOURCE_ADDRESS = network_id,
+ LEGACY_PACKET_DESTINATION_ADDRESS = NET_ADDRESS_PING,
)
var/datum/signal/packet = new(src, data)
diff --git a/code/modules/modular_computers/file_system/programs/ntmessenger.dm b/code/modules/modular_computers/file_system/programs/ntmessenger.dm
index 6b9f5e23dcc5..29c3d273963b 100644
--- a/code/modules/modular_computers/file_system/programs/ntmessenger.dm
+++ b/code/modules/modular_computers/file_system/programs/ntmessenger.dm
@@ -93,7 +93,7 @@
var/list/signal_data = signal.data
if(!signal_data)
return
- var/signal_command = signal_data[PKT_ARG_CMD]
+ var/signal_command = signal_data[LEGACY_PACKET_COMMAND]
//Network ID verification is "hardware accelerated" (AKA: Done for us by the card)
var/rigged = FALSE//are we going to explode?
@@ -104,7 +104,7 @@
// ESPECIALLY THIS FUCKER RIGHT HERE vvvv
if(signal_data[SSpackets.pda_exploitable_register] == SSpackets.detomatix_magic_packet)
//This one falls through to standard PDA behaviour, so we need to be checked first.
- if(signal_data[PKT_HEAD_DEST_ADDRESS] == netcard_cache.hardware_id)//No broadcast bombings, fuck off.
+ if(signal_data[LEGACY_PACKET_DESTINATION_ADDRESS] == netcard_cache.hardware_id)//No broadcast bombings, fuck off.
//Calculate our "difficulty"
var/difficulty
var/obj/item/computer_hardware/hard_drive/role/our_jobdisk = computer.all_components[MC_HDD_JOB]
@@ -114,7 +114,7 @@
difficulty++ //if cartridge has manifest access it has extra snowflake difficulty
if(!((SEND_SIGNAL(computer, COMSIG_TABLET_CHECK_DETONATE) & COMPONENT_TABLET_NO_DETONATE) || prob(difficulty * 15)))
rigged = TRUE //Cool, we're allowed to blow up. Really glad this whole check wasn't for nothing.
- var/trait_timer_key = signal_data[PKT_HEAD_SOURCE_ADDRESS]
+ var/trait_timer_key = signal_data[LEGACY_PACKET_SOURCE_ADDRESS]
ADD_TRAIT(computer, TRAIT_PDA_CAN_EXPLODE, trait_timer_key)
ADD_TRAIT(computer, TRAIT_PDA_MESSAGE_MENU_RIGGED, trait_timer_key)
addtimer(TRAIT_CALLBACK_REMOVE(computer, TRAIT_PDA_MESSAGE_MENU_RIGGED, trait_timer_key), 10 SECONDS)
@@ -127,7 +127,7 @@
html_decode("\"[signal_data["message"]]\"") || "#ERROR_MISSING_FIELD",
FALSE,
signal_data["automated"] || FALSE,
- signal_data[PKT_HEAD_SOURCE_ADDRESS] || null
+ signal_data[LEGACY_PACKET_SOURCE_ADDRESS] || null
)
if(ringer_status)
@@ -189,7 +189,7 @@
L = get(holder.holder, /mob/living/silicon)
if(L && L.stat == CONSCIOUS)
- var/reply = "(Reply)"
+ var/reply = "(Reply)"
var/hrefstart
var/hrefend
var/job_string = signal_data["job"] ? " ([signal_data["job"]])" : ""
@@ -197,7 +197,7 @@
hrefstart = ""
hrefend = ""
- if(signal_data[PKT_HEAD_SOURCE_ADDRESS] == null)
+ if(signal_data[LEGACY_PACKET_SOURCE_ADDRESS] == null)
reply = "\[#ERRNOADDR\]"
if(signal_data["automated"])
@@ -269,11 +269,11 @@
var/datum/signal/pda_message = new(
src,
list(
- PKT_ARG_CMD = NETCMD_PDAMESSAGE,
+ LEGACY_PACKET_COMMAND = NETCMD_PDAMESSAGE,
"name" = fake_name || computer.saved_identification,
"job" = fake_job || computer.saved_job,
"message" = html_decode(message),
- PKT_HEAD_DEST_ADDRESS = target_address
+ LEGACY_PACKET_DESTINATION_ADDRESS = target_address
),
logging_data = user
)
@@ -354,7 +354,7 @@
if(!istype(pnetcard)) //This catches nulls too, so...
to_chat(usr, span_warning("Radio missing or bad driver!"))
var/datum/signal/ping_sig = new(src, list(
- PKT_HEAD_DEST_ADDRESS = NET_ADDRESS_PING,
+ LEGACY_PACKET_DESTINATION_ADDRESS = NET_ADDRESS_PING,
"pda_scan" = "true"
))
pnetcard.post_signal(ping_sig)
diff --git a/code/modules/modular_computers/hardware/gprs_card.dm b/code/modules/modular_computers/hardware/gprs_card.dm
index ed44e4edba59..123f8573d933 100644
--- a/code/modules/modular_computers/hardware/gprs_card.dm
+++ b/code/modules/modular_computers/hardware/gprs_card.dm
@@ -62,14 +62,14 @@
if(signal.transmission_method != TRANSMISSION_RADIO)
CRASH("[src] received non-radio packet, transmission method ID [signal.transmission_method], Expected [TRANSMISSION_RADIO]")
var/list/signal_data = signal.data //medium velocity silver hedgehog
- var/signal_d_addr = signal_data[PKT_HEAD_DEST_ADDRESS]
+ var/signal_d_addr = signal_data[LEGACY_PACKET_DESTINATION_ADDRESS]
if(signal_d_addr == NET_ADDRESS_PING) //Ping.
var/datum/signal/outgoing = new(
src,
list(
- PKT_HEAD_DEST_ADDRESS = signal_data[PKT_HEAD_SOURCE_ADDRESS],
- PKT_ARG_CMD = NET_COMMAND_PING_REPLY,
- PKT_HEAD_NETCLASS = NETCLASS_GRPS_CARD,
+ LEGACY_PACKET_DESTINATION_ADDRESS = signal_data[LEGACY_PACKET_SOURCE_ADDRESS],
+ LEGACY_PACKET_COMMAND = NET_COMMAND_PING_REPLY,
+ LEGACY_PACKET_NETCLASS = NETCLASS_GRPS_CARD,
"netaddr" = hardware_id
)
)
@@ -83,11 +83,11 @@
//Either it's broadcast or directed to us.
if(isnull(signal_d_addr) || signal_d_addr == hardware_id)
// If it's a ping reply, check for a PDA.
- if(signal.data[PKT_ARG_CMD] == NET_COMMAND_PING_REPLY)
+ if(signal.data[LEGACY_PACKET_COMMAND] == NET_COMMAND_PING_REPLY)
//If it's from a GPRS card, respond, otherwise, who cares.
- if(signal.data[PKT_HEAD_NETCLASS] == NETCLASS_GRPS_CARD)
+ if(signal.data[LEGACY_PACKET_NETCLASS] == NETCLASS_GRPS_CARD)
var/list/new_pda_info = list(
- "target_addr" = signal.data[PKT_HEAD_SOURCE_ADDRESS],
+ "target_addr" = signal.data[LEGACY_PACKET_SOURCE_ADDRESS],
"name" = signal.data["reg_name"] || "#UNK",
"job" = signal.data["reg_job"] || "#UNK"
)
@@ -101,7 +101,7 @@
/obj/item/computer_hardware/network_card/packetnet/post_signal(datum/signal/signal)
if(!radio_connection || !signal)
return FALSE // Something went wrong.
- signal.data[PKT_HEAD_SOURCE_ADDRESS] = hardware_id //Readdress outgoing packets.
+ signal.data[LEGACY_PACKET_SOURCE_ADDRESS] = hardware_id //Readdress outgoing packets.
signal.author = WEAKREF(src)
radio_connection.post_signal(signal, RADIO_PDAMESSAGE)
return TRUE //We at least tried.
diff --git a/code/modules/modular_computers/hardware/virus_disk.dm b/code/modules/modular_computers/hardware/virus_disk.dm
index b8e10b32aaab..4d65293906da 100644
--- a/code/modules/modular_computers/hardware/virus_disk.dm
+++ b/code/modules/modular_computers/hardware/virus_disk.dm
@@ -30,7 +30,7 @@
var/list/user_input_tuple = user_input(target_addr, user)
var/datum/signal/outgoing = new(src, list(
SSpackets.pda_exploitable_register = magic_packet,
- PKT_HEAD_DEST_ADDRESS = target_addr
+ LEGACY_PACKET_DESTINATION_ADDRESS = target_addr
))
var/signal_data = outgoing.data
switch(user_input_tuple[1])
@@ -121,7 +121,7 @@
var/list/pda_data_staple = list(
// We already have the target address
// GPRS Card handles the source address
- PKT_ARG_CMD = NETCMD_PDAMESSAGE,
+ LEGACY_PACKET_COMMAND = NETCMD_PDAMESSAGE,
"name" = sender_name,
"job" = sender_job,
"message" = text_message
From 7c56ff9ab89766ba1b101e373fbb35ef912d3dd0 Mon Sep 17 00:00:00 2001
From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com>
Date: Fri, 8 Aug 2025 02:58:19 -0400
Subject: [PATCH 07/14] fix runtime
---
code/modules/computer4/computer4.dm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/code/modules/computer4/computer4.dm b/code/modules/computer4/computer4.dm
index 5894db1bdd69..cecb03fbaeb6 100644
--- a/code/modules/computer4/computer4.dm
+++ b/code/modules/computer4/computer4.dm
@@ -252,7 +252,8 @@ TYPEINFO_DEF(/obj/machinery/computer4)
if(!is_operational)
return
- operating_system.peripheral_input(invoker, command, packet)
+ // Operating system can be null here if the computer is mid-reboot.
+ operating_system?.peripheral_input(invoker, command, packet)
/obj/machinery/computer4/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src)
From 238db43c148feecd7ab5472b0c0804d8d953bd3c Mon Sep 17 00:00:00 2001
From: Francinum <5572280+francinum@users.noreply.github.com>
Date: Tue, 19 Aug 2025 20:03:40 -0400
Subject: [PATCH 08/14] Defines and cleanups/Port freeing support
---
code/__DEFINES/packetnet.dm | 9 ++++-
.../terminal/operating_system/networking.dm | 37 +++++++++++++++----
2 files changed, 38 insertions(+), 8 deletions(-)
diff --git a/code/__DEFINES/packetnet.dm b/code/__DEFINES/packetnet.dm
index 5f35d5716d2d..cfd5b68cba98 100644
--- a/code/__DEFINES/packetnet.dm
+++ b/code/__DEFINES/packetnet.dm
@@ -127,5 +127,12 @@
// -----
// PDP Port Allocations
+// Kapu insisted these be defines "to not be confusing"
+#define PDP_BIND_EPHEMERAL_PORT -1
+#define PDP_FREE_ALL_PORTS -1
+
#define PDP_MAX_PORT 65535 //! Maximum PDP Port number
-#define PDP_EPHEMERAL_START 64000 //! Start of PDP Ephemeral Range, used for outgoing client connections.
+
+#define PDP_EPHEMERAL_START 49152 //! Start of PDP Ephemeral Range, used for outgoing client connections.
+
+#define PDP_PORT_NETTEST 28910
diff --git a/code/modules/computer4/data/terminal/operating_system/networking.dm b/code/modules/computer4/data/terminal/operating_system/networking.dm
index 2e559bddf170..c819cf74d625 100644
--- a/code/modules/computer4/data/terminal/operating_system/networking.dm
+++ b/code/modules/computer4/data/terminal/operating_system/networking.dm
@@ -1,18 +1,18 @@
/datum/c4_file/terminal_program/operating_system/proc/prepare_networking()
/// Request a socket from the OS.
-/// A `port_number` of 0 will result in being allocated an ephemeral port.
+/// A `port_number` of `PDP_BIND_EPHEMERAL_PORT` will result in being allocated an ephemeral port.
/datum/c4_file/terminal_program/operating_system/proc/bind_port(port_number, reliable = FALSE, datum/c4_file/binder)
RETURN_TYPE(/datum/pdp_socket)
if(!binder)
CRASH("Tried to bind a port: [isnull(port_number) ? "!NULL!" : port_number] without a binding program.")
- if(!isnull(port_number))
+ if(isnull(port_number))
CRASH("Program [binder] tried to bind a null port.")
if(port_number > PDP_MAX_PORT)
CRASH("Program [binder] tried to bind port above max, [port_number] > [PDP_MAX_PORT]")
// Assign ephemeral port.
- if(!port_number)
+ if(port_number == PDP_BIND_EPHEMERAL_PORT)
do
port_number = rand(PDP_EPHEMERAL_START, PDP_MAX_PORT)
while(pdp_port_map["[port_number]"])
@@ -20,13 +20,36 @@
if(pdp_port_map["[port_number]"])
return FALSE //Port already bound.
- var/datum/pdp_socket = new(port_number, src)
+ var/datum/pdp_socket/socket = new(port_number, binder)
- pdp_port_map["[port_number]"] = pdp_socket
+ pdp_port_map["[port_number]"] = socket
+
+ return socket
+
+/// Requests the OS to free a socket.
+/// A `port_number` of `PDP_FREE_ALL_PORTS` will result in all ports bound by the binder being freed. It is also the default behaviour.
+/datum/c4_file/terminal_program/operating_system/proc/free_port(port_number = PDP_FREE_ALL_PORTS, datum/c4_file/binder)
+ if(isnull(port_number))
+ CRASH("Program [binder] tried to free a null or 0 port.")
+ if(port_number > PDP_MAX_PORT)
+ CRASH("Program [binder] tried to free port above max, [port_number] > [PDP_MAX_PORT]")
+ if(port_number != PDP_FREE_ALL_PORTS)
+ // Free by specific port number
+ if(pdp_port_map["[port_number]"].owner == binder) //If the binder matches
+ pdp_port_map["[port_number]"] = null
+ return TRUE
+ else
+ //This should throw an OS error but we have no concept of stderr.
+ return FALSE
+ //else: free all ports therein bound.
+ var/freed_at_least_one = FALSE
+ for(var/port_num, port_socket in pdp_port_map)
+ if(astype(port_socket.owner, /datum/pdp_socket) == binder)
+ pdp_port_map[port_num] = null
+ freed_at_least_one = TRUE
+ return freed_at_least_one
- return pdp_socket
-/datum/c4_file/terminal_program/operating_system/proc/free_port(port_number, datum/c4_file/binder)
/// Finish up outgoing program signals.
/// Eventually: Routing table?
From f78ec676008f58082cc7eb9aa387782dd3df1f19 Mon Sep 17 00:00:00 2001
From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com>
Date: Tue, 19 Aug 2025 21:04:49 -0400
Subject: [PATCH 09/14] fixes + basic netpage
---
code/__DEFINES/computer4_defines.dm | 5 ++
.../data/terminal/netpage/netpage.dm | 2 -
.../data/terminal/notepad/notepad.dm | 2 -
.../terminal/operating_system/networking.dm | 5 +-
.../operating_system/thinkdos/thinkdos.dm | 6 ++
.../data/terminal/packMAN/packman.dm | 63 +++++++++++++++++++
.../data/terminal/packMAN/packman_commands.dm | 53 ++++++++++++++++
.../computer4/data/terminal/probe/probe.dm | 2 -
.../data/terminal/probe/probe_commands.dm | 4 +-
daedalus.dme | 2 +
.../Terminal/TerminalOutputSection.tsx | 3 +
11 files changed, 137 insertions(+), 10 deletions(-)
create mode 100644 code/modules/computer4/data/terminal/packMAN/packman.dm
create mode 100644 code/modules/computer4/data/terminal/packMAN/packman_commands.dm
diff --git a/code/__DEFINES/computer4_defines.dm b/code/__DEFINES/computer4_defines.dm
index ab90fdb0303a..8915a613cdc8 100644
--- a/code/__DEFINES/computer4_defines.dm
+++ b/code/__DEFINES/computer4_defines.dm
@@ -21,6 +21,11 @@
// ITS THREE IN THE MOOOOORNIN' AND YOOUUU'RE EATING ALONE
#define DIRECTMAN_MENU_NEW_DIRECTIVE 5
+// packMAN shit
+#define PACKMAN_MODE_UNDEFINED 0
+#define PACKMAN_MODE_CLIENT 1
+#define PACKMAN_MODE_SERVER 2
+
// Wireless card incoming filter modes
#define WIRELESS_FILTER_PROMISC 0 //! Forward all packets
#define WIRELESS_FILTER_NETADDR 1 //! Forward only bcast/unicast matched GPRS packets
diff --git a/code/modules/computer4/data/terminal/netpage/netpage.dm b/code/modules/computer4/data/terminal/netpage/netpage.dm
index 67b7e0fade6c..9a0c4d5e3081 100644
--- a/code/modules/computer4/data/terminal/netpage/netpage.dm
+++ b/code/modules/computer4/data/terminal/netpage/netpage.dm
@@ -19,8 +19,6 @@
/datum/c4_file/terminal_program/netpage/execute(datum/c4_file/terminal_program/operating_system/thinkdos/system)
. = ..()
- if(.)
- return
var/title_text = list(
@"
___ ___ __ __ ___", diff --git a/code/modules/computer4/data/terminal/notepad/notepad.dm b/code/modules/computer4/data/terminal/notepad/notepad.dm index 916fe496e289..bb672b1ea206 100644 --- a/code/modules/computer4/data/terminal/notepad/notepad.dm +++ b/code/modules/computer4/data/terminal/notepad/notepad.dm @@ -16,8 +16,6 @@ /datum/c4_file/terminal_program/notepad/execute(datum/c4_file/terminal_program/operating_system/thinkdos/system) . = ..() - if(.) - return // Hope you saved your work motherfucker. working_line = 0 diff --git a/code/modules/computer4/data/terminal/operating_system/networking.dm b/code/modules/computer4/data/terminal/operating_system/networking.dm index c819cf74d625..d42ca7ffb1f3 100644 --- a/code/modules/computer4/data/terminal/operating_system/networking.dm +++ b/code/modules/computer4/data/terminal/operating_system/networking.dm @@ -20,7 +20,7 @@ if(pdp_port_map["[port_number]"]) return FALSE //Port already bound. - var/datum/pdp_socket/socket = new(port_number, binder) + var/datum/pdp_socket/socket = new(port_number, src, binder) pdp_port_map["[port_number]"] = socket @@ -44,7 +44,7 @@ //else: free all ports therein bound. var/freed_at_least_one = FALSE for(var/port_num, port_socket in pdp_port_map) - if(astype(port_socket.owner, /datum/pdp_socket) == binder) + if(astype(port_socket, /datum/pdp_socket).owner == binder) pdp_port_map[port_num] = null freed_at_least_one = TRUE return freed_at_least_one @@ -60,6 +60,7 @@ var/obj/item/peripheral/network_card/wireless/wcard = get_computer().get_peripheral(PERIPHERAL_TYPE_WIRELESS_CARD) if(!wcard) return //cry + wcard.post_signal(signal) /datum/c4_file/terminal_program/operating_system/proc/pdp_incoming(datum/signal/packet) diff --git a/code/modules/computer4/data/terminal/operating_system/thinkdos/thinkdos.dm b/code/modules/computer4/data/terminal/operating_system/thinkdos/thinkdos.dm index d72c3e75a6db..0436a0ffba21 100644 --- a/code/modules/computer4/data/terminal/operating_system/thinkdos/thinkdos.dm +++ b/code/modules/computer4/data/terminal/operating_system/thinkdos/thinkdos.dm @@ -101,6 +101,12 @@ if(.) handle_command_queue() +/datum/c4_file/terminal_program/operating_system/thinkdos/tick(delta_time) + for(var/datum/c4_file/terminal_program/program as anything in processing_programs) + if(program == src) + continue + + program.tick(delta_time) /datum/c4_file/terminal_program/operating_system/thinkdos/proc/handle_command_queue() while(LAZYLEN(queued_commands)) //hmm... diff --git a/code/modules/computer4/data/terminal/packMAN/packman.dm b/code/modules/computer4/data/terminal/packMAN/packman.dm new file mode 100644 index 000000000000..011674cf7a7e --- /dev/null +++ b/code/modules/computer4/data/terminal/packMAN/packman.dm @@ -0,0 +1,63 @@ +/datum/c4_file/terminal_program/packman + name = "packMAN" + + var/mode = PACKMAN_MODE_UNDEFINED + var/datum/pdp_socket/socket + + var/static/list/commands + +/datum/c4_file/terminal_program/packman/New() + if(!commands) + commands = list() + for(var/path as anything in subtypesof(/datum/shell_command/packman_cmd)) + commands += new path + +/datum/c4_file/terminal_program/packman/execute(datum/c4_file/terminal_program/operating_system/thinkdos/system) + . = ..() + if(!.) + return + + system.println("packMAN V1.01", FALSE) + system.println("Welcome to packMAN, type 'help' to get started.") + + if(!get_adapter()) + system.println("Error: No network adapter found.") + +/datum/c4_file/terminal_program/packman/on_close(datum/c4_file/terminal_program/operating_system/thinkdos/system) + . = ..() + mode = PACKMAN_MODE_UNDEFINED + socket = null + +/// Getter for a network adapter. +/datum/c4_file/terminal_program/packman/proc/get_adapter() + RETURN_TYPE(/obj/item/peripheral/network_card) + return get_computer().get_peripheral(PERIPHERAL_TYPE_WIRELESS_CARD) + +/datum/c4_file/terminal_program/packman/std_in(text) + . = ..() + if(.) + return + + get_os().println(text) + + var/datum/shell_stdin/parsed_input = parse_std_in(text) + + var/datum/c4_file/terminal_program/operating_system/os = get_os() + + for(var/datum/shell_command/potential_command as anything in commands) + if(potential_command.try_exec(parsed_input.command, os, src, parsed_input.arguments, parsed_input.options)) + return TRUE + + get_os().println("'[html_encode(parsed_input.raw)]' is not recognized as an internal or external command.") + +/datum/c4_file/terminal_program/packman/tick(delta_time) + . = ..() + if(!socket) + return + + var/datum/c4_file/terminal_program/operating_system/system = get_os() + var/datum/signal/packet + while((packet = socket.pop())) + system.println( + html_encode(json_encode(packet.data)) + ) diff --git a/code/modules/computer4/data/terminal/packMAN/packman_commands.dm b/code/modules/computer4/data/terminal/packMAN/packman_commands.dm new file mode 100644 index 000000000000..e8efbf06e6f0 --- /dev/null +++ b/code/modules/computer4/data/terminal/packMAN/packman_commands.dm @@ -0,0 +1,53 @@ +/datum/shell_command/packman_cmd/chat + aliases = list("c", "chat") + +/datum/shell_command/packman_cmd/chat/exec(datum/c4_file/terminal_program/operating_system/thinkdos/system, datum/c4_file/terminal_program/program, list/arguments, list/options) + if(length(arguments) < 2) + system.println("Error: Invalid argument count.") + return + + var/datum/c4_file/terminal_program/packman/packman = program + + var/address = arguments[1] + var/payload = jointext(arguments.Copy(2), " ") + + packman.socket.send_data(address, PDP_PORT_NETTEST, list(payload)) + system.println(html_encode(payload)) + +/datum/shell_command/packman_cmd/init + aliases = list("init") + +/datum/shell_command/packman_cmd/init/exec(datum/c4_file/terminal_program/operating_system/thinkdos/system, datum/c4_file/terminal_program/program, list/arguments, list/options) + if(!length(arguments)) + system.println("Error: Invalid argument count.") + return + + if(!(lowertext(arguments[1]) in list("c", "s"))) + system.println("Error: Invalid argument.") + return + + var/datum/c4_file/terminal_program/packman/packman = program + + if(packman.mode != PACKMAN_MODE_UNDEFINED) + return + + packman.mode = (lowertext(arguments[1]) == "s") ? PACKMAN_MODE_SERVER : PACKMAN_MODE_CLIENT + + if(packman.mode == PACKMAN_MODE_SERVER) + packman.socket = system.bind_port(PDP_PORT_NETTEST, FALSE, packman) + if(!packman.socket) + system.println("Error: Socket binding failed.") + return + + else + packman.socket = system.bind_port(PDP_BIND_EPHEMERAL_PORT, FALSE, packman) + if(!packman.socket) + system.println("Error: Socket binding failed.") + return + + system.println("Bound port to [packman.socket.bound_port] as [packman.mode == PACKMAN_MODE_SERVER ? "SERVER" : "CLIENT"]") + +/datum/shell_command/packman_cmd/quit/exec(datum/c4_file/terminal_program/operating_system/thinkdos/system, datum/c4_file/terminal_program/program, list/arguments, list/options) + system.println("Quitting...") + system.unload_program(program) + return diff --git a/code/modules/computer4/data/terminal/probe/probe.dm b/code/modules/computer4/data/terminal/probe/probe.dm index a388da6e784f..d9b6c1add768 100644 --- a/code/modules/computer4/data/terminal/probe/probe.dm +++ b/code/modules/computer4/data/terminal/probe/probe.dm @@ -13,8 +13,6 @@ /datum/c4_file/terminal_program/probe/execute(datum/c4_file/terminal_program/operating_system/thinkdos/system) . = ..() - if(!.) - return system.println("NetProbe V2.4", FALSE) system.println("Welcome to NetProbe, type 'help' to get started.") diff --git a/code/modules/computer4/data/terminal/probe/probe_commands.dm b/code/modules/computer4/data/terminal/probe/probe_commands.dm index 09b2a4f834f7..aa0cc1d4df0c 100644 --- a/code/modules/computer4/data/terminal/probe/probe_commands.dm +++ b/code/modules/computer4/data/terminal/probe/probe_commands.dm @@ -1,5 +1,5 @@ /datum/shell_command/probe_cmd/ping - aliases = list("ping, p") + aliases = list("ping", "p") /datum/shell_command/probe_cmd/ping/exec(datum/c4_file/terminal_program/operating_system/thinkdos/system, datum/c4_file/terminal_program/program, list/arguments, list/options) var/datum/c4_file/terminal_program/probe/probe = program @@ -13,7 +13,7 @@ system.println("Pinging '[format_frequency(adapter.frequency)]'...") /datum/shell_command/probe_cmd/view - aliases = list("view, v") + aliases = list("view", "v") /datum/shell_command/probe_cmd/view/exec(datum/c4_file/terminal_program/operating_system/thinkdos/system, datum/c4_file/terminal_program/program, list/arguments, list/options) var/datum/c4_file/terminal_program/probe/probe = program diff --git a/daedalus.dme b/daedalus.dme index 76d1249bf009..80a46d698e95 100644 --- a/daedalus.dme +++ b/daedalus.dme @@ -3005,6 +3005,8 @@ #include "code\modules\computer4\data\terminal\operating_system\thinkdos\thinkdos.dm" #include "code\modules\computer4\data\terminal\operating_system\thinkdos\thinkdos_commands.dm" #include "code\modules\computer4\data\terminal\operating_system\thinkdos\thinkdos_signals.dm" +#include "code\modules\computer4\data\terminal\packMAN\packman.dm" +#include "code\modules\computer4\data\terminal\packMAN\packman_commands.dm" #include "code\modules\computer4\data\terminal\probe\probe.dm" #include "code\modules\computer4\data\terminal\probe\probe_commands.dm" #include "code\modules\computer4\data\terminal\notepad\notepad.dm" diff --git a/tgui/packages/tgui/interfaces/Terminal/TerminalOutputSection.tsx b/tgui/packages/tgui/interfaces/Terminal/TerminalOutputSection.tsx index 551ad1712e92..e7111e97ad8b 100644 --- a/tgui/packages/tgui/interfaces/Terminal/TerminalOutputSection.tsx +++ b/tgui/packages/tgui/interfaces/Terminal/TerminalOutputSection.tsx @@ -42,6 +42,9 @@ export const TerminalOutputSection = (props: TerminalOutputSectionProps) => { height="100%" color={fontColor} fontSize="1.2em" + style={{ + wordBreak: 'break-all', + }} preserveWhitespace dangerouslySetInnerHTML={{ __html: displayHTML }} /> From 90abd5e80d3ccbd4da6690223606286c7865ddd6 Mon Sep 17 00:00:00 2001 From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com> Date: Tue, 19 Aug 2025 21:29:06 -0400 Subject: [PATCH 10/14] reduce help command boilerplate by 98% --- code/__DEFINES/computer4_defines.dm | 6 ++ .../data/terminal/notepad/notepad_commands.dm | 55 ++++--------------- .../thinkdos/thinkdos_commands.dm | 53 +++++++++--------- 3 files changed, 44 insertions(+), 70 deletions(-) diff --git a/code/__DEFINES/computer4_defines.dm b/code/__DEFINES/computer4_defines.dm index 8915a613cdc8..c348e2fd9574 100644 --- a/code/__DEFINES/computer4_defines.dm +++ b/code/__DEFINES/computer4_defines.dm @@ -7,6 +7,12 @@ #define PERIPHERAL_CMD_RECEIVE_PDP_PACKET "receive_pdp_packet" #define PERIPHERAL_CMD_SCAN_CARD "scan_card" +// Shell command macros +#define SHELL_CMD_HELP_ERROR 1 //! Could not find a command to display information about +#define SHELL_CMD_HELP_GENERIC 2 //! Generated generic help information +#define SHELL_CMD_HELP_COMMAND 3 //! Generated information about a command + + // MedTrak menus #define MEDTRAK_MENU_HOME 1 #define MEDTRAK_MENU_INDEX 2 diff --git a/code/modules/computer4/data/terminal/notepad/notepad_commands.dm b/code/modules/computer4/data/terminal/notepad/notepad_commands.dm index e0520a1f45c4..c50d7560b503 100644 --- a/code/modules/computer4/data/terminal/notepad/notepad_commands.dm +++ b/code/modules/computer4/data/terminal/notepad/notepad_commands.dm @@ -3,50 +3,19 @@ help_text = "Lists all available commands. Use help \[command\] to view information about a specific command." /datum/shell_command/notepad/edit_cmd/help/exec(datum/c4_file/terminal_program/operating_system/thinkdos/system, datum/c4_file/terminal_program/program, list/arguments, list/options) - // Stupid fucking byond compiler bug -#if !defined(SPACEMAN_DMM) && !defined(OPENDREAM) -#pragma push -#pragma ignore unused_var -#endif - var/datum/c4_file/terminal_program/notepad/notepad = program -#if !defined(SPACEMAN_DMM) && !defined(OPENDREAM) -#pragma pop -#endif - var/list/output = list() - - if(length(arguments)) - var/found = FALSE - var/searching_for = jointext(arguments, "") - for(var/datum/shell_command/command_iter as anything in notepad.edit_commands) - if(searching_for in command_iter.aliases) - found = TRUE - output += "Displaying information for '[command_iter.aliases[1]]':" - output += command_iter.help_text - break - - if(!found) - system.println("This command is not supported by the help utility. To see a list of commands, type !help.") - return - - else - for(var/datum/shell_command/command_iter as anything in notepad.edit_commands) - if(length(command_iter.aliases) == 1) - output += command_iter.aliases[1] - continue - - output += "[command_iter.aliases[1]] ([jointext(command_iter.aliases.Copy(2), ", ")])" - - sortTim(output, GLOBAL_PROC_REF(cmp_text_asc)) - output.Insert(1, - "Typing text without a '!' prefix will write to the current line.", - "You can change lines by typing '!\[number\]'. Zero will change to highest line number.