Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server framework v2 #10983

Merged
merged 38 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
50dcd1b
i don't remember what is happening
Dejaku51 Apr 30, 2024
8a847ec
much better
Dejaku51 May 2, 2024
3d82262
just debug stuff
Dejaku51 May 2, 2024
f96c923
the ideas are coming
Dejaku51 May 20, 2024
0ebd144
Merge branch 'master' of https://github.com/BeeStation/BeeStation-Hor…
Dejaku51 May 20, 2024
bc3c9c6
that shouldn't be here
Dejaku51 May 20, 2024
07ce01a
it works now!
Dejaku51 May 22, 2024
f86cafa
RnD servers integrated
Dejaku51 May 28, 2024
a580bf6
sparks!
Dejaku51 May 29, 2024
b19db60
Merge branch 'master' of https://github.com/BeeStation/BeeStation-Hor…
Dejaku51 Jun 6, 2024
d3843ec
no more "if true return true"
Dejaku51 Jun 25, 2024
92d448c
reverse logic
Dejaku51 Jun 25, 2024
94d843e
adds ! to comments in stat.dm
Dejaku51 Jun 25, 2024
ed1690c
clean up after yourself on Destroy()
Dejaku51 Jun 25, 2024
5b45681
splits early return
Dejaku51 Jun 25, 2024
d40f91f
clean up after yourself tcomm monitoring
Dejaku51 Jun 25, 2024
96ba686
you too all tcomms machines
Dejaku51 Jun 25, 2024
3a77785
adds type holder instead of GetComponents
Dejaku51 Jun 25, 2024
c2d29a6
fix indentation
Dejaku51 Jun 25, 2024
619c35b
cmon indentation
Dejaku51 Jun 25, 2024
6dd585a
HOW?!
Dejaku51 Jun 25, 2024
582d2d7
oopsie woopsie
Dejaku51 Jun 25, 2024
b64db82
removes TODO and adds a comment
Dejaku51 Jun 26, 2024
1d92dbd
packet types and null on destroy
Dejaku51 Jun 26, 2024
7fa4517
update comment
Dejaku51 Jun 26, 2024
6552001
fixed radstation tcomms area + switches hub with blackbox
Dejaku51 Jul 25, 2024
167bee8
rebalances tcomms heat generation
Dejaku51 Jul 25, 2024
c06d004
Merge branch 'master' of https://github.com/BeeStation/BeeStation-Hor…
Dejaku51 Jul 25, 2024
e1bea62
Merge branch 'master' of https://github.com/BeeStation/BeeStation-Hor…
Dejaku51 Aug 1, 2024
5cd185c
fix echo tcomms cooling
Dejaku51 Aug 16, 2024
9945f83
Merge branch 'master' of https://github.com/BeeStation/BeeStation-Hor…
Dejaku51 Aug 16, 2024
44df99f
that should stop funny exploit discovered by aramix
Dejaku51 Aug 21, 2024
f0d2e04
cooldown define
Dejaku51 Aug 29, 2024
149a9be
remove useless signal
Dejaku51 Aug 29, 2024
89decd8
opened machine is under maintenance
Dejaku51 Aug 29, 2024
5bf1778
return null instead of 0 points
Dejaku51 Aug 29, 2024
bde3fab
return false
Dejaku51 Aug 29, 2024
bf62ea1
I HATE TESTS
Dejaku51 Aug 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions beestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@
#include "code\controllers\subsystem\processing\processing.dm"
#include "code\controllers\subsystem\processing\projectiles.dm"
#include "code\controllers\subsystem\processing\quirks.dm"
#include "code\controllers\subsystem\processing\servers.dm"
#include "code\controllers\subsystem\processing\singulo.dm"
#include "code\controllers\subsystem\processing\station.dm"
#include "code\controllers\subsystem\processing\wet_floors.dm"
Expand Down Expand Up @@ -672,6 +673,7 @@
#include "code\datums\components\remote_materials.dm"
#include "code\datums\components\riding.dm"
#include "code\datums\components\rotation.dm"
#include "code\datums\components\server.dm"
#include "code\datums\components\seclight_attachable.dm"
#include "code\datums\components\shell.dm"
#include "code\datums\components\shielded.dm"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@
#define COMSIG_MACHINERY_POWER_RESTORED "machinery_power_restored"
///from /obj/machinery/set_occupant(atom/movable/O): (new_occupant)
#define COMSIG_MACHINERY_SET_OCCUPANT "machinery_set_occupant"
///from /obj/machinery/proc/use_power(): (power_used)
#define COMSIG_MACHINERY_POWER_USED "machinery_power_used"

// /obj/machinery/atmospherics/components/unary/cryo_cell signals

/// from /obj/machinery/atmospherics/components/unary/cryo_cell/set_on(bool): (on)
#define COMSIG_CRYO_SET_ON "cryo_set_on"

// /datum/component/server signals

// from //datum/component/server/proc/overheated(is_overheated): (is_overheated)
#define COMSIG_MACHINERY_OVERHEAT_CHANGE "machinery_overheated"
1 change: 1 addition & 0 deletions code/__DEFINES/networks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#define __NETWORK_CARGO "CARGO"
#define __NETWORK_BOTS "BOTS"
#define __NETWORK_COMPUTER "COMPUTER"
#define __NETWORK_SERVER "SERVER"
#define __NETWORK_CARDS "CARDS"
#define __NETWORK_CIRCUITS "CIRCUITS"

Expand Down
10 changes: 6 additions & 4 deletions code/__DEFINES/stat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
#define MAX_SATIETY 600

// bitflags for machine stat variable
#define BROKEN (1<<0)
#define NOPOWER (1<<1)
#define MAINT (1<<2) // under maintaince
#define EMPED (1<<3) // temporary broken by EMP pulse
#define BROKEN (1<<0)
#define NOPOWER (1<<1)
#define MAINT (1<<2) // under maintenance
#define EMPED (1<<3) // temporary broken by EMP pulse
#define OVERHEATED (1<<4) // overheated
#define TURNED_OFF (1<<5) // turned off
Dejaku51 marked this conversation as resolved.
Show resolved Hide resolved

//ai power requirement defines
#define POWER_REQ_ALL 1
4 changes: 4 additions & 0 deletions code/controllers/subsystem/processing/servers.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PROCESSING_SUBSYSTEM_DEF(servers)
name = "Servers"
wait = 0.2 SECONDS
stat_tag = "SP"
4 changes: 2 additions & 2 deletions code/controllers/subsystem/research.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ SUBSYSTEM_DEF(research)
bitcoins[i] = bitcoins[i]? bitcoins[i] + result[i] : result[i]
else
for(var/obj/machinery/rnd/server/miner in servers)
if(miner.working)
if(!miner.machine_stat)
bitcoins = single_server_income.Copy()
break //Just need one to work.
Dejaku51 marked this conversation as resolved.
Show resolved Hide resolved
if (!isnull(last_income))
Expand All @@ -78,7 +78,7 @@ SUBSYSTEM_DEF(research)
/datum/controller/subsystem/research/proc/calculate_server_coefficient() //Diminishing returns.
var/list/obj/machinery/rnd/server/active = new()
for(var/obj/machinery/rnd/server/miner in servers)
if(miner.working)
if(!miner.machine_stat)
Dejaku51 marked this conversation as resolved.
Show resolved Hide resolved
active.Add(miner)
var/amt = active.len
if(!amt)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/components/ntnet_interface.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Arguments:
* * packet_data - Either a list() or a /datum/netdata. If its netdata, the other args are ignored
* * target_id - Target hardware id or network_id for this packet. If we are a network id, then its
broadcasted to that network.
* * broadcasted to that network.
* * passkey - Authentication for the packet. If the target doesn't authenticate the packet is dropped
*/
/datum/proc/ntnet_send(packet_data, target_id = null, passkey = null)
Expand Down
64 changes: 64 additions & 0 deletions code/datums/components/server.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Server component
// will generate a heat based on the power usage of the machine
// use only with /obj/machinery



/datum/component/server

var/efficiency = 1 // 0 to 1 range

var/temperature = T20C // current temperature
var/warning_temp = T0C + 50 // 50C
var/overheated_temp = T0C + 100 // 100C - temperature at which the server stops working
var/heat_capacity = 2500 // Used for auxmos heat transfer

var/heat_generation = 0 // heat generated by the machine

// if it sparks when overheated
var/sparks = TRUE
COOLDOWN_DECLARE(spark_cooldown)
var/sparks_cooldown_time = 10 SECONDS
Dejaku51 marked this conversation as resolved.
Show resolved Hide resolved

/datum/component/server/Initialize()
if(!ismachinery(parent)) // currently only compatible with machinery
return COMPONENT_INCOMPATIBLE
RegisterSignal(parent, COMSIG_MACHINERY_POWER_USED, PROC_REF(ParentPowerUsed))
START_PROCESSING(SSservers, src)
Dejaku51 marked this conversation as resolved.
Show resolved Hide resolved

/datum/component/server/proc/ParentPowerUsed(source, amount, chan)
heat_generation += amount * 1000

// server is overheated and doesn't work
/datum/component/server/proc/overheated(is_overheated)
if(is_overheated && sparks && COOLDOWN_FINISHED(src, spark_cooldown))
do_sparks(5, FALSE, parent)
COOLDOWN_START(src, spark_cooldown, sparks_cooldown_time)

SEND_SIGNAL(parent, COMSIG_MACHINERY_OVERHEAT_CHANGE, is_overheated)
Dejaku51 marked this conversation as resolved.
Show resolved Hide resolved

/datum/component/server/process(delta_time)
var/obj/machinery/parent_machine = parent
calculate_temperature()
Dejaku51 marked this conversation as resolved.
Show resolved Hide resolved
if(temperature > overheated_temp)
if(!(parent_machine.machine_stat & OVERHEATED))
overheated(TRUE)
parent_machine.set_machine_stat(parent_machine.machine_stat | OVERHEATED)
return
efficiency = 0
else
if(parent_machine.machine_stat & OVERHEATED)
overheated(FALSE)
parent_machine.set_machine_stat(parent_machine.machine_stat & ~OVERHEATED)
var/efficiency_change = ((temperature - T20C) / (overheated_temp - T20C))
efficiency = clamp(1 - efficiency_change, 0, 1)
temperature += heat_generation / heat_capacity
heat_generation = 0

/datum/component/server/proc/calculate_temperature()
var/turf/turf = get_turf(parent)
if(!turf)
return FALSE
var/datum/gas_mixture/environment = turf.return_air()

temperature = environment.temperature_share(null, OPEN_HEAT_TRANSFER_COEFFICIENT, temperature, heat_capacity)
196 changes: 76 additions & 120 deletions code/game/machinery/telecomms/computers/telemonitor.dm
Original file line number Diff line number Diff line change
@@ -1,126 +1,82 @@

/*
Telecomms monitor tracks the overall trafficing of a telecommunications network
and displays a heirarchy of linked machines.
Telecommunications Monitoring Console displays the status of the telecommunications network it's connected to.
*/


/obj/machinery/computer/telecomms/monitor
name = "telecommunications monitoring console"
icon_screen = "comm_monitor"
desc = "Monitors the details of the telecommunications network it's synced with."

var/screen = 0 // the screen number:
var/list/machinelist = list() // the machines located by the computer
var/obj/machinery/telecomms/SelectedMachine

var/network = "NULL" // the network to probe

var/temp = "" // temporary feedback messages
circuit = /obj/item/circuitboard/computer/comm_monitor

/obj/machinery/computer/telecomms/monitor/ui_interact(mob/user)
. = ..()
var/dat = "<TITLE>Telecommunications Monitor</TITLE><center><b>Telecommunications Monitor</b></center>"

switch(screen)


// --- Main Menu ---

if(0)
dat += "<br>[temp]<br><br>"
dat += "<br>Current Network: <a href='?src=[REF(src)];network=1'>[network]</a><br>"
if(machinelist.len)
dat += "<br>Detected Network Entities:<ul>"
for(var/obj/machinery/telecomms/T in machinelist)
dat += "<li><a href='?src=[REF(src)];viewmachine=[T.id]'>[REF(T)] [T.name]</a> ([T.id])</li>"
dat += "</ul>"
dat += "<br><a href='?src=[REF(src)];operation=release'>\[Flush Buffer\]</a>"
else
dat += "<a href='?src=[REF(src)];operation=probe'>\[Probe Network\]</a>"


// --- Viewing Machine ---

if(1)
dat += "<br>[temp]<br>"
dat += "<center><a href='?src=[REF(src)];operation=mainmenu'>\[Main Menu\]</a></center>"
dat += "<br>Current Network: [network]<br>"
dat += "Selected Network Entity: [SelectedMachine.name] ([SelectedMachine.id])<br>"
dat += "Linked Entities: <ol>"
for(var/obj/machinery/telecomms/T in SelectedMachine.links)
if(!T.hide)
dat += "<li><a href='?src=[REF(src)];viewmachine=[T.id]'>[REF(T.id)] [T.name]</a> ([T.id])</li>"
dat += "</ol>"



user << browse(dat, "window=comm_monitor;size=575x400")
onclose(user, "server_control")

temp = ""
return


/obj/machinery/computer/telecomms/monitor/Topic(href, href_list)
if(..())
return


add_fingerprint(usr)
usr.set_machine(src)

if(href_list["viewmachine"])
screen = 1
for(var/obj/machinery/telecomms/T in machinelist)
if(T.id == href_list["viewmachine"])
SelectedMachine = T
break

if(href_list["operation"])
switch(href_list["operation"])

if("release")
machinelist = list()
screen = 0

if("mainmenu")
screen = 0

if("probe")
if(machinelist.len > 0)
temp = "<font color = #D70B00>- FAILED: CANNOT PROBE WHEN BUFFER FULL -</font color>"

else
for(var/obj/machinery/telecomms/T in urange(25, src))
if(T.network == network)
machinelist.Add(T)

if(!machinelist.len)
temp = "<font color = #D70B00>- FAILED: UNABLE TO LOCATE NETWORK ENTITIES IN \[[network]\] -</font color>"
else
temp = "<font color = #336699>- [machinelist.len] ENTITIES LOCATED & BUFFERED -</font color>"

screen = 0


if(href_list["network"])

var/newnet = stripped_input(usr, "Which network do you want to view?", "Comm Monitor", network)
if(newnet && (get_dist(usr, src) <= 1 || issilicon(usr)))
if(length(newnet) > 15)
temp = "<font color = #D70B00>- FAILED: NETWORK TAG STRING TOO LENGHTLY -</font color>"

else
network = newnet
screen = 0
machinelist = list()
temp = "<font color = #336699>- NEW NETWORK TAG SET IN ADDRESS \[[network]\] -</font color>"

updateUsrDialog()
return

/obj/machinery/computer/telecomms/monitor/attackby()
. = ..()
updateUsrDialog()
name = "telecommunications monitoring console"
icon_screen = "comm_monitor"
desc = "Monitors the details of the telecommunications network it's synced with."
circuit = /obj/item/circuitboard/computer/comm_monitor
network_id = __NETWORK_SERVER // if its connected to the default one we will ignore it
var/network = "NULL" // the network to probe
var/list/servers = list() // the servers in the network


/obj/machinery/computer/telecomms/monitor/Initialize(mapload)
. = ..()
update_network()
RegisterSignal(src, COMSIG_COMPONENT_NTNET_RECEIVE, PROC_REF(ntnet_receive))
Dejaku51 marked this conversation as resolved.
Show resolved Hide resolved


/obj/machinery/computer/telecomms/monitor/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "Telemonitor")
ui.set_autoupdate(TRUE)
ui.open()

/obj/machinery/computer/telecomms/monitor/ui_act(action, params)
if(..())
return
Dejaku51 marked this conversation as resolved.
Show resolved Hide resolved
if(action == "change_network")
network = params["network_name"]
update_network()
return TRUE
if(action == "delete_server")
servers -= params["server_id"]

/obj/machinery/computer/telecomms/monitor/ui_data(mob/user)
var/list/data = list()
data["network_id"] = network
data["current_time"] = world.time
data["servers"] = servers

return data

Dejaku51 marked this conversation as resolved.
Show resolved Hide resolved
/obj/machinery/computer/telecomms/monitor/process()
get_server_status()

/obj/machinery/computer/telecomms/monitor/proc/get_server_status()
if(network_id == __NETWORK_SERVER)
return
var/data = list()
data["type"] = "ping"
Dejaku51 marked this conversation as resolved.
Show resolved Hide resolved
ntnet_send(data, network_id)

/obj/machinery/computer/telecomms/monitor/proc/ntnet_receive(datum/source, datum/netdata/data)
if(islist(data.receiver_id))
return // if its broadcasting we don't want that packet, its probably our ping
servers[data.sender_id] = data.data
servers[data.sender_id]["last_update"] = world.time
servers[data.sender_id]["sender_id"] = data.sender_id

/obj/machinery/computer/telecomms/monitor/proc/update_network()
servers = list()
if(!network || network == "NULL")
return
var/new_network_id = NETWORK_NAME_COMBINE(__NETWORK_SERVER, network) // should result in something like SERVER.TCOMMSAT
var/area/A = get_area(src)
if(A)
if(!A.network_root_id)
log_telecomms("Area '[A.name]([REF(A)])' has no network network_root_id, force assigning in object [src]([REF(src)])")
SSnetworks.lookup_area_root_id(A)
new_network_id = NETWORK_NAME_COMBINE(A.network_root_id, new_network_id) // should result in something like SS13.SERVER.TCOMMSAT
else
log_telecomms("Created [src]([REF(src)] in nullspace, assuming network to be in station")
new_network_id = NETWORK_NAME_COMBINE(STATION_NETWORK_ROOT, new_network_id) // should result in something like SS13.SERVER.TCOMMSAT
new_network_id = simple_network_name_fix(new_network_id) // make sure the network name is valid
var/datum/ntnet/new_network = SSnetworks.create_network_simple(new_network_id)
new_network.move_interface(GetComponent(/datum/component/ntnet_interface), new_network_id, network_id)
network_id = new_network_id
1 change: 1 addition & 0 deletions code/game/machinery/telecomms/machine_interactions.dm
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
network = params["value"]
links = list()
log_game("[key_name(usr)] has changed the network for [src] at [AREACOORD(src)] to [network].")
update_network()
. = TRUE
if("tempfreq")
if(params["value"])
Expand Down
Loading
Loading