From 118299b70b2cf4523b96cf9b07c6519aa86c871e Mon Sep 17 00:00:00 2001
From: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
Date: Mon, 21 Nov 2022 21:49:07 -0500
Subject: [PATCH] More expanded multi-web support (#71402)
## About The Pull Request
This is a continuation of my previous PR
https://github.com/tgstation/tgstation/pull/71070
That one tackled techwebs and syncing it to machines, this one primarily
focuses on Generic techwebs and Experiment handlers.
### What it does
* Experiment handlers now only broadcast completed experiments over the
node they're connected to
* RD consoles once again no longer bluescreen if not connected to a
techweb
* RD servers now delete their techweb on deconstruction if they're the
creator of it
* 'Generic' techwebs are now capitalized
* Experiment handlers now see all techwebs instead of all servers being
listed under the same web, allowing there to have more than 1 techweb on
the same Z level but not list it as the same. They don't show the
location of the server anymore, I don't know if that's something that's
wanted or not.
In-game screenshot:

## Why It's Good For The Game
Mostly the same reason as my previous PR, this opens up more ways to
modularize techwebs and give more possibilities for ghost roles and
downstreams.
## Changelog
:cl:
fix: Experisci handlers no longer show all servers as being on the same
techweb if they aren't.
fix: RnD consoles no longer bluescreen if they aren't connected to a
techweb, instead it will give an error message.
balance: Experisci handlers no longer show the location of RnD servers.
/:cl:
---
.../experiment/handlers/experiment_handler.dm | 26 +++++----
code/modules/research/rdconsole.dm | 6 +-
code/modules/research/server.dm | 5 ++
code/modules/research/techweb/_techweb.dm | 44 ++++++++------
.../tgui/interfaces/ExperimentConfigure.js | 40 ++++++-------
tgui/packages/tgui/interfaces/Techweb.js | 58 ++++++++-----------
6 files changed, 90 insertions(+), 89 deletions(-)
diff --git a/code/modules/experisci/experiment/handlers/experiment_handler.dm b/code/modules/experisci/experiment/handlers/experiment_handler.dm
index 38628678882..a8370b1ebdf 100644
--- a/code/modules/experisci/experiment/handlers/experiment_handler.dm
+++ b/code/modules/experisci/experiment/handlers/experiment_handler.dm
@@ -179,8 +179,9 @@
* * message - The message to announce
*/
/datum/component/experiment_handler/proc/announce_message_to_all(message)
- for(var/experiment in GLOB.experiment_handlers)
- var/datum/component/experiment_handler/experi_handler = experiment
+ for(var/datum/component/experiment_handler/experi_handler as anything in GLOB.experiment_handlers)
+ if(experi_handler.linked_web != linked_web)
+ continue
var/atom/movable/experi_parent = experi_handler.parent
experi_parent.say(message)
@@ -353,17 +354,22 @@
. = list(
"always_active" = config_flags & EXPERIMENT_CONFIG_ALWAYS_ACTIVE,
"has_start_callback" = !isnull(start_experiment_callback))
- .["servers"] = list()
- for (var/obj/machinery/rnd/server/server in get_available_servers())
+ .["techwebs"] = list()
+ for (var/datum/techweb/techwebs as anything in SSresearch.techwebs)
+ if(!length(techwebs.techweb_servers)) //no servers, we don't care
+ continue
+ var/obj/machinery/rnd/server = techwebs.techweb_servers[1] //get the first machine possible
+ if(!is_valid_z_level(get_turf(user), get_turf(server)))
+ continue
var/list/data = list(
name = server.name,
- web_id = server.stored_research?.id,
- web_org = server.stored_research?.organization,
- location = get_area(server),
- selected = !isnull(linked_web) && server.stored_research == linked_web,
- ref = REF(server)
+ web_id = techwebs.id,
+ web_org = techwebs.organization,
+ selected = (techwebs == linked_web),
+ ref = REF(server),
+ all_servers = techwebs.techweb_servers,
)
- .["servers"] += list(data)
+ .["techwebs"] += list(data)
.["experiments"] = list()
if (linked_web)
for (var/datum/experiment/experiment in linked_web.available_experiments)
diff --git a/code/modules/research/rdconsole.dm b/code/modules/research/rdconsole.dm
index 7fab447eabe..64187c547df 100644
--- a/code/modules/research/rdconsole.dm
+++ b/code/modules/research/rdconsole.dm
@@ -49,7 +49,7 @@ Nothing else in the console has ID requirements.
. = ..()
if(!CONFIG_GET(flag/no_default_techweb_link))
stored_research = SSresearch.science_tech
- stored_research.consoles_accessing[src] = TRUE
+ stored_research.consoles_accessing += src
/obj/machinery/computer/rdconsole/Destroy()
if(stored_research)
@@ -153,13 +153,14 @@ Nothing else in the console has ID requirements.
/obj/machinery/computer/rdconsole/ui_assets(mob/user)
return list(
- get_asset_datum(/datum/asset/spritesheet/research_designs)
+ get_asset_datum(/datum/asset/spritesheet/research_designs),
)
// heavy data from this proc should be moved to static data when possible
/obj/machinery/computer/rdconsole/ui_data(mob/user)
var/list/data = list()
data["stored_research"] = !!stored_research
+ data["locked"] = locked
if(!stored_research) //lack of a research node is all we care about.
return data
data += list(
@@ -172,7 +173,6 @@ Nothing else in the console has ID requirements.
"sec_protocols" = !(obj_flags & EMAGGED),
"t_disk" = null,
"d_disk" = null,
- "locked" = locked,
)
if (t_disk)
diff --git a/code/modules/research/server.dm b/code/modules/research/server.dm
index 54589658f3b..e9c9745aaf5 100644
--- a/code/modules/research/server.dm
+++ b/code/modules/research/server.dm
@@ -30,9 +30,14 @@
if(CONFIG_GET(flag/no_default_techweb_link))
stored_research = new /datum/techweb
SSresearch.servers |= src
+ stored_research.techweb_servers |= src
name += " [num2hex(rand(1,65535), -1)]" //gives us a random four-digit hex number as part of the name. Y'know, for fluff.
/obj/machinery/rnd/server/Destroy()
+ if(stored_research)
+ stored_research.techweb_servers -= src
+ if(CONFIG_GET(flag/no_default_techweb_link))
+ QDEL_NULL(stored_research)
SSresearch.servers -= src
return ..()
diff --git a/code/modules/research/techweb/_techweb.dm b/code/modules/research/techweb/_techweb.dm
index b4f0d233487..96efe865549 100644
--- a/code/modules/research/techweb/_techweb.dm
+++ b/code/modules/research/techweb/_techweb.dm
@@ -7,6 +7,11 @@
* on research consoles, servers, and disks. They are NOT global.
*/
/datum/techweb
+ ///The id/name of the whole Techweb viewable to players.
+ var/id = "Generic"
+ /// Organization name, used for display
+ var/organization = "Third-Party"
+
/// Already unlocked and all designs are now available. Assoc list, id = TRUE
var/list/researched_nodes = list()
/// Visible nodes, doesn't mean it can be researched. Assoc list, id = TRUE
@@ -25,12 +30,8 @@
var/list/deconstructed_items = list()
/// Available research points, type = number
var/list/research_points = list()
- var/list/obj/machinery/computer/rdconsole/consoles_accessing = list()
- var/id = "generic"
/// IC logs
var/list/research_logs = list()
- /// Organization name, used for display
- var/organization = "Third-Party"
/// Current per-second production, used for display only.
var/list/last_bitcoins = list()
/// Mutations discovered by genetics, this way they are shared and cant be destroyed by destroying a single console
@@ -42,6 +43,11 @@
/// Completed experiments
var/list/completed_experiments = list()
+ ///All RD consoles connected to this individual techweb.
+ var/list/obj/machinery/computer/rdconsole/consoles_accessing = list()
+ ///All research servers connected to this individual techweb.
+ var/list/obj/machinery/rnd/server/techweb_servers = list()
+
/**
* Assoc list of relationships with various partners
* scientific_cooperation[partner_typepath] = relationship
@@ -62,6 +68,7 @@
hidden_nodes = SSresearch.techweb_nodes_hidden.Copy()
initialize_published_papers()
return ..()
+
/datum/techweb/admin
id = "ADMIN"
organization = "CentCom"
@@ -75,14 +82,6 @@
research_points[i] = INFINITY
hidden_nodes = list()
-/datum/techweb/science //Global science techweb for RND consoles.
- id = "SCIENCE"
- organization = "Nanotrasen"
-
-/datum/techweb/bepis //Should contain only 1 BEPIS tech selected at random.
- id = "EXPERIMENTAL"
- organization = "Nanotrasen R&D"
-
/datum/techweb/bepis/New(remove_tech = TRUE)
. = ..()
var/bepis_id = pick(SSresearch.techweb_nodes_experimental) //To add a new tech to the BEPIS, add the ID to this pick list.
@@ -285,8 +284,7 @@
*/
/datum/techweb/proc/add_experiments(list/experiment_list)
. = TRUE
- for (var/experiment_type in experiment_list)
- var/datum/experiment/experiment = experiment_type
+ for (var/datum/experiment/experiment as anything in experiment_list)
. = . && add_experiment(experiment)
/**
@@ -332,11 +330,6 @@
science_department_bank_account?.adjust_money(SSeconomy.techweb_bounty)
return TRUE
-/datum/techweb/science/research_node(datum/techweb_node/node, force = FALSE, auto_adjust_cost = TRUE, get_that_dosh = TRUE) //When something is researched, triggers the proc for this techweb only
- . = ..()
- if(.)
- node.on_research()
-
/datum/techweb/proc/unresearch_node_id(id)
return unresearch_node(SSresearch.techweb_node_by_id(id))
@@ -523,3 +516,16 @@
handler.announce_message_to_all("The [experiment.name] has been completed!")
return TRUE
+
+/datum/techweb/science //Global science techweb for RND consoles.
+ id = "SCIENCE"
+ organization = "Nanotrasen"
+
+/datum/techweb/science/research_node(datum/techweb_node/node, force = FALSE, auto_adjust_cost = TRUE, get_that_dosh = TRUE) //When something is researched, triggers the proc for this techweb only
+ . = ..()
+ if(.)
+ node.on_research()
+
+/datum/techweb/bepis //Should contain only 1 BEPIS tech selected at random.
+ id = "EXPERIMENTAL"
+ organization = "Nanotrasen R&D"
diff --git a/tgui/packages/tgui/interfaces/ExperimentConfigure.js b/tgui/packages/tgui/interfaces/ExperimentConfigure.js
index fce89046f93..06371393df0 100644
--- a/tgui/packages/tgui/interfaces/ExperimentConfigure.js
+++ b/tgui/packages/tgui/interfaces/ExperimentConfigure.js
@@ -53,28 +53,26 @@ const ExperimentStageRow = (props) => {
export const TechwebServer = (props, context) => {
const { act, data } = useBackend(context);
- const { servers } = props;
+ const { techwebs } = props;
- return (
-
+ return techwebs.map((server, index) => (
+
- {servers[0].web_id} / {servers[0].web_org}
+ {server.web_id} / {server.web_org}
@@ -84,29 +82,25 @@ export const TechwebServer = (props, context) => {
Connectivity to this web is maintained by the following servers...
- {servers.map((server, index) => {
- return (
-
- Located in {server.location}
-
- );
- })}
+ {server.all_servers.map((individual_servers, new_index) => (
+ {individual_servers}
+ ))}
- );
+ ));
};
export const ExperimentConfigure = (props, context) => {
const { act, data } = useBackend(context);
const { always_active, has_start_callback } = data;
- let servers = data.servers ?? [];
+ let techwebs = data.techwebs ?? [];
const experiments = sortBy((exp) => exp.name)(data.experiments ?? []);
// Group servers together by web
let webs = new Map();
- servers.forEach((x) => {
+ techwebs.forEach((x) => {
if (x.web_id !== null) {
if (!webs.has(x.web_id)) {
webs.set(x.web_id, []);
@@ -127,13 +121,13 @@ export const ExperimentConfigure = (props, context) => {
: 'Found no available techwebs!'}
{webs.size > 0 &&
- Array.from(webs, ([techweb, servers]) => (
-
+ Array.from(webs, ([techweb, techwebs]) => (
+
))}
- {servers.some((e) => e.selected) && (
+ {techwebs.some((e) => e.selected) && (
diff --git a/tgui/packages/tgui/interfaces/Techweb.js b/tgui/packages/tgui/interfaces/Techweb.js
index c72a3851db1..f933b24c0d5 100644
--- a/tgui/packages/tgui/interfaces/Techweb.js
+++ b/tgui/packages/tgui/interfaces/Techweb.js
@@ -92,30 +92,30 @@ export const Techweb = (props, context) => {
};
const TechwebStart = (props, context) => {
- const { act, data } = useRemappedBackend(context);
+ const { act, data } = useBackend(context);
const { locked, stored_research } = data;
- return (
- <>
- {!!locked && (
-
-
- Console Locked
-
-
-
- )}
- {!stored_research && (
-
-
- No research techweb found, please synchronize the console.
-