Files
Paradise/code/modules/research/server.dm
Charlie Nolan d3584b1d1c LINDA -> MILLA (#25328)
* LINDA -> MILLA

* Tiles now change their atmos mode properly.

* Fixed a bug that made walls generate supercold air when deconstructed/destroyed.

* Apply suggestions from code review

Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
Co-authored-by: GDN <96800819+GDNgit@users.noreply.github.com>
Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>

* Begone, var!

* MILLA -> milla

* Lint.

* More lint.

* Prevent negative/NaN atmos from spreading.

* Made fires start more reliably.

* Undef what the rest should not see.

* Enums are nice.

* Match LINDA better.

* Debugging verbs.

* Debug verb fixes.

* Labelled more lavaland stuff with ATMOS_MODE_LAVALAND

* Block superconductivity on a couple more things for Lavaland.

* Updated milla.dll

* Lavaland map fixes.

* Missed a spot.

* Begone, var! (again)

* Add libmilla_ci.so for continuous integration tests.

* Install/contributing instructions for MILLA.

* Directional plasmaglass windows on shuttles shouldn't stop protecting from heat after moving.

* Banish bad naming.

* Better naming and debug stats for SSair.

* Apply suggestions from code review

Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>

* Magic numbers and formatting.

* Don't screw up the temperature during reactions.

* Efficiency and readability.

* Fix hotspots.

* Removed redundant safety (MILLA will already output an error)

* Optimizations.

* oops

* TGS build script update.

* Change API of gas_mixture and how you get one from a turf.

* Get in there.

* so many vars

* MILLA binary updates.

* Lint

* Made MT cost more honest.

* Gave MILLA a read-only mode.

* More read-only vs synchronized mode work.

* Even more.

* Synchronize disposals.

* Updated a bunch of stuff to use SSair.synchronize or GM.synchronize.

* MILLA <3 Tracy

* lint

* cargo fmt

* more lint

* Test needed MILLA sync.

* Silence atmos machinery that's behaving as intended, but continue objecting to other potential failures to synchronize.

* Push new MILLA DLL

* Build MILLA

* Update PR instructions for MILLA.

* Add some fancy plasmaglass windows to the Lifebringers' ship.

* The golems remembered that they should insulate *all* their engines.

* First round of TM bugfixes.

* Build MILLA

* fix two lavaland ruin turf types

* bunch more maps

* fixes milla ci and makes the interesting turf verb better

* Solid turfs can no longer conduct heat (for now...)

* Made indoor tiles in beach and winter biodomes not lavaland air.

* Re-added random IT teleport, adjusted warning message

* Fixed a tinted window on Lavaland to be a plasglass window instead.

* Made firelocks and holofans heatproof

* Made RPD auto-wrench pipes if you have a wrench in your offhand.

* Runtime fixes.

* Made visuals update more reliably.

* Lint

* Update .github/CONTRIBUTING.md

Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>

* Build MILLA

* The Syndicate have installed tiny fans on their research base.

* The syndicate have figured out how to make plastitanium windows heatproof.

* This is getting out of hand. Now there are two of them.

* Un-break the auto-wrenching that I broke before committing.

* Build MILLA

* Build MILLA

* Massive MILLA refactor, assorted bugfixes.

* Build MILLA

* Explicit typing.

* Less sleeping/blocking.

* Build MILLA

* Yes, yes, this part can sleep.

* Build MILLA

* SSair reporting improvements.

* Build MILLA

* Please do not dock twice and splat yourself.

* Build MILLA

* Pls to not make SM go nuts.

* Build MILLA

* Build MILLA

* Added stricter lower bounds on plasmafire, fixing perpetually-burning SM.

* Build MILLA

* Lint

* Temporary logging, begone.

* Build MILLA

* Prevent hotspot strobing.

* Add in radiate_to_spess behavior.

* Build MILLA

* progress

* Compiling is good.

* bugfixes

* Progress.

* Ruins update.

* This one exists.

* Fixup temporary hotspots to last longer than one tick.

* Add/fix comments.

* Cut the slash.

* Fix test.

* No sleep for you.

* Build MILLA

* Prevent nested MILLA safety from runtiming.

* Build MILLA

* Runtime fix.

* Build MILLA

* Fix canisters not updating icon when gas contents change.

* Build MILLA

* Build MILLA

* Fixed an issue that made mechs very cold on environment air.

* Build MILLA

* oops

* Build MILLA

* Walls can make loud noises again.

* Build MILLA

* Fixes a rare runtime.

* Build MILLA

* Update .github/DOWNLOADING.md

Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>

* Review suggestions

* Lint

* Build MILLA

* bound_mixtures now only contains mixtures that can be written

* Build MILLA

* Apply suggestions from code review

Co-authored-by: Matt <116982774+Burzah@users.noreply.github.com>
Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>

* Build MILLA

* Restore the original async behavior of pyro anomalies.

* Build MILLA

* Build MILLA

* Make the safety assertion in /datum/milla_safe safer.

* Build MILLA

---------

Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>
Co-authored-by: FunnyMan3595 (Charlie Nolan) <funnyman@google.com>
Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
Co-authored-by: GDN <96800819+GDNgit@users.noreply.github.com>
Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Co-authored-by: paradisess13[bot] <165046124+paradisess13[bot]@users.noreply.github.com>
Co-authored-by: warriorstar-orion <orion@snowfrost.garden>
Co-authored-by: GDN <Roanrichards1@Gmail.com>
2024-06-09 07:18:11 +00:00

396 lines
13 KiB
Plaintext

/obj/machinery/r_n_d/server
name = "R&D Server"
icon = 'icons/obj/machines/research.dmi'
icon_state = "RD-server-off"
var/datum/research/files
var/health = 100
var/list/id_with_upload = list() //List of R&D consoles with upload to server access.
var/list/id_with_download = list() //List of R&D consoles with download from server access.
var/id_with_upload_string = "" //String versions for easy editing in map editor.
var/id_with_download_string = ""
var/server_id = 0
var/heat_gen = 100
var/heating_power = 40000
var/delay = 10
req_access = list(ACCESS_RD) //Only the R&D can change server settings.
var/plays_sound = 0
/obj/machinery/r_n_d/server/Initialize(mapload)
. = ..()
component_parts = list()
component_parts += new /obj/item/circuitboard/rdserver(null)
component_parts += new /obj/item/stock_parts/scanning_module(null)
component_parts += new /obj/item/stack/cable_coil(null,1)
component_parts += new /obj/item/stack/cable_coil(null,1)
RefreshParts()
initialize_serv(); //Agouri // fuck you agouri
/obj/machinery/r_n_d/server/upgraded/Initialize(mapload)
. = ..()
component_parts = list()
component_parts += new /obj/item/circuitboard/rdserver(null)
component_parts += new /obj/item/stock_parts/scanning_module/phasic(null)
component_parts += new /obj/item/stack/cable_coil(null,1)
component_parts += new /obj/item/stack/cable_coil(null,1)
RefreshParts()
/obj/machinery/r_n_d/server/Destroy()
griefProtection()
return ..()
/obj/machinery/r_n_d/server/RefreshParts()
var/tot_rating = 0
for(var/obj/item/stock_parts/SP in src)
tot_rating += SP.rating
heat_gen /= max(1, tot_rating)
/obj/machinery/r_n_d/server/update_icon_state()
if(stat & NOPOWER)
icon_state = "RD-server-off"
else
icon_state = "RD-server-on"
/obj/machinery/r_n_d/server/power_change()
if(!..())
return
update_icon(UPDATE_ICON_STATE)
/obj/machinery/r_n_d/server/proc/initialize_serv()
if(!files)
files = new /datum/research(src)
var/list/temp_list
if(!length(id_with_upload))
temp_list = list()
temp_list = splittext(id_with_upload_string, ";")
for(var/N in temp_list)
id_with_upload += text2num(N)
if(!length(id_with_download))
temp_list = list()
temp_list = splittext(id_with_download_string, ";")
for(var/N in temp_list)
id_with_download += text2num(N)
/obj/machinery/r_n_d/server/process()
if(prob(3) && plays_sound)
playsound(loc, "computer_ambience", 10, TRUE, ignore_walls = FALSE)
var/turf/T = get_turf(src)
var/datum/gas_mixture/environment = T.get_readonly_air()
switch(environment.temperature())
if(0 to T0C)
health = min(100, health + 1)
if(T0C to (T20C + 20))
health = clamp(health, 0, 100)
if((T20C + 20) to INFINITY)
health = max(0, health - 1)
if(health <= 0)
/*griefProtection() This seems to get called twice before running any code that deletes/damages the server or it's files anwyay.
refreshParts and the hasReq procs that get called by this are laggy and do not need to be called by every server on the map every tick */
var/updateRD = 0
files.known_designs = list()
for(var/v in files.known_tech)
var/datum/tech/tech = files.known_tech[v]
// Slowly decrease research if health drops below 0
if(prob(1))
updateRD++
tech.level--
if(updateRD)
files.RefreshResearch()
if(delay)
delay--
else
produce_heat(heat_gen)
delay = initial(delay)
/obj/machinery/r_n_d/server/emp_act(severity)
griefProtection()
..()
/obj/machinery/r_n_d/server/ex_act(severity)
griefProtection()
return ..()
/obj/machinery/r_n_d/server/blob_act(obj/structure/blob/B)
griefProtection()
return ..()
// Backup files to CentComm to help admins recover data after griefer attacks
/obj/machinery/r_n_d/server/proc/griefProtection()
for(var/obj/machinery/r_n_d/server/centcom/C in GLOB.machines)
files.push_data(C.files)
/obj/machinery/r_n_d/server/proc/produce_heat(heat_amt)
var/datum/milla_safe/rnd_server_heat/milla = new()
milla.invoke_async(src, heat_amt)
/datum/milla_safe/rnd_server_heat
/datum/milla_safe/rnd_server_heat/on_run(obj/machinery/r_n_d/server/server, heat)
var/turf/T = get_turf(server)
var/datum/gas_mixture/env = get_turf_air(T)
if(server.stat & (NOPOWER|BROKEN))
return
if(env.temperature() >= (heat + T0C))
return
var/transfer_moles = 0.25 * env.total_moles()
var/datum/gas_mixture/removed = env.remove(transfer_moles)
if(!removed)
return
var/heat_capacity = removed.heat_capacity()
if(heat_capacity == 0 || heat_capacity == null)
heat_capacity = 1
removed.set_temperature(min((removed.temperature() * heat_capacity + server.heating_power) / heat_capacity, 1000))
env.merge(removed)
/obj/machinery/r_n_d/server/attackby(obj/item/O as obj, mob/user as mob, params)
if(exchange_parts(user, O))
return TRUE
return ..()
/obj/machinery/r_n_d/server/crowbar_act(mob/living/user, obj/item/I)
if(!panel_open)
return
. = TRUE
griefProtection()
default_deconstruction_crowbar(user, I)
/obj/machinery/r_n_d/server/screwdriver_act(mob/living/user, obj/item/I)
default_deconstruction_screwdriver(user, "RD-server-on_t", "RD-server-on", I)
return TRUE
/obj/machinery/r_n_d/server/centcom
name = "CentComm. Central R&D Database"
server_id = -1
/obj/machinery/r_n_d/server/centcom/Initialize()
. = ..()
var/list/no_id_servers = list()
var/list/server_ids = list()
for(var/obj/machinery/r_n_d/server/S in GLOB.machines)
switch(S.server_id)
if(-1)
continue
if(0)
no_id_servers += S
else
server_ids += S.server_id
for(var/obj/machinery/r_n_d/server/S in no_id_servers)
var/num = 1
while(!S.server_id)
if(num in server_ids)
num++
else
S.server_id = num
server_ids += num
no_id_servers -= S
/obj/machinery/r_n_d/server/centcom/process()
return PROCESS_KILL //don't need process()
/obj/machinery/computer/rdservercontrol
name = "\improper R&D server controller"
icon_screen = "rdcomp"
icon_keyboard = "rd_key"
light_color = LIGHT_COLOR_FADEDPURPLE
circuit = /obj/item/circuitboard/rdservercontrol
var/screen = 0
var/obj/machinery/r_n_d/server/temp_server
var/list/servers = list()
var/list/consoles = list()
var/badmin = 0
/obj/machinery/computer/rdservercontrol/Topic(href, href_list)
if(..())
return
add_fingerprint(usr)
usr.set_machine(src)
if(!src.allowed(usr) && !emagged)
to_chat(usr, "<span class='warning'>You do not have the required access level</span>")
return
if(href_list["main"])
screen = 0
else if(href_list["access"] || href_list["data"] || href_list["transfer"])
temp_server = null
consoles = list()
servers = list()
for(var/obj/machinery/r_n_d/server/S in GLOB.machines)
if(istype(S, /obj/machinery/r_n_d/server/centcom) && !badmin)
continue
if(!atoms_share_level(get_turf(src), get_turf(S)) && !badmin)
continue
if(S.server_id == text2num(href_list["access"]) || S.server_id == text2num(href_list["data"]) || S.server_id == text2num(href_list["transfer"]))
temp_server = S
break
if(href_list["access"])
screen = 1
for(var/obj/machinery/computer/rdconsole/C in GLOB.machines)
if(C.sync)
consoles += C
else if(href_list["data"])
screen = 2
else if(href_list["transfer"])
screen = 3
for(var/obj/machinery/r_n_d/server/S in GLOB.machines)
if(S == src)
continue
servers += S
else if(href_list["upload_toggle"])
var/num = text2num(href_list["upload_toggle"])
for(var/obj/machinery/computer/rdconsole/C in consoles)
if(C.id != num)
continue
if(!atoms_share_level(get_turf(src), get_turf(C)) && !badmin)
to_chat(usr, "<span class='warning'>Unable to modify upload protocols of this console; is it in the same sector?</span>")
return
if(num in temp_server.id_with_upload)
temp_server.id_with_upload -= num
else
temp_server.id_with_upload += num
else if(href_list["download_toggle"])
var/num = text2num(href_list["download_toggle"])
if(num in temp_server.id_with_download)
temp_server.id_with_download -= num
else
temp_server.id_with_download += num
else if(href_list["reset_tech"])
var/choice = tgui_alert(usr, "Technology Data Reset", "Are you sure you want to reset this technology to its default data? Data lost cannot be recovered.", list("Continue", "Cancel"))
if(choice == "Continue")
for(var/I in temp_server.files.known_tech)
var/datum/tech/T = temp_server.files.known_tech[I]
if(T.id == href_list["reset_tech"])
T.level = 1
break
temp_server.files.RefreshResearch()
else if(href_list["reset_design"])
var/choice = tgui_alert(usr, "Design Data Deletion", "Are you sure you want to blacklist this design? Ensure you sync servers after this decision.", list("Continue", "Cancel"))
if(choice == "Continue")
for(var/I in temp_server.files.known_designs)
var/datum/design/D = temp_server.files.known_designs[I]
if(D.id == href_list["reset_design"])
temp_server.files.known_designs -= D.id
temp_server.files.blacklisted_designs += D.id
message_admins("[key_name_admin(usr)] blacklisted [D.name] from the rnd server controler.")
log_game("[key_name(usr)] blacklisted [D.name] from the rnd server controler.")
break
temp_server.files.RefreshResearch()
else if(href_list["restore_design"])
var/choice = tgui_alert(usr, "Design Data Restoration", "Are you sure you want to restore this design? Ensure you sync servers after this decision.", list("Continue", "Cancel"))
if(choice == "Continue")
temp_server.files.blacklisted_designs -= href_list["restore_design"]
temp_server.files.unblacklisted_designs += href_list["restore_design"]
message_admins("[key_name_admin(usr)] unblacklisted [href_list["restore_design"]] from the rnd server controler.")
log_game("[key_name(usr)] unblacklisted [href_list["restore_design"]] from the rnd server controler.")
temp_server.files.RefreshResearch()
updateUsrDialog()
return
/obj/machinery/computer/rdservercontrol/attack_hand(mob/user as mob)
if(stat & (BROKEN|NOPOWER))
return
user.set_machine(src)
var/dat = ""
switch(screen)
if(0) //Main Menu
dat += "Connected Servers:<BR><BR>"
for(var/obj/machinery/r_n_d/server/S in GLOB.machines)
if(istype(S, /obj/machinery/r_n_d/server/centcom) && !badmin)
continue
if(!atoms_share_level(get_turf(src), get_turf(S)) && !badmin)
continue
dat += "[S.name] || "
dat += "<A href='byond://?src=[UID()];access=[S.server_id]'>Access Rights</A> | "
dat += "<A href='byond://?src=[UID()];data=[S.server_id]'>Data Management</A>"
if(badmin) dat += " | <A href='byond://?src=[UID()];transfer=[S.server_id]'>Server-to-Server Transfer</A>"
dat += "<BR>"
if(1) //Access rights menu
dat += "[temp_server.name] Access Rights<BR><BR>"
dat += "Consoles with Upload Access<BR>"
for(var/obj/machinery/computer/rdconsole/C in consoles)
var/turf/console_turf = get_turf(C)
dat += "* <A href='byond://?src=[UID()];upload_toggle=[C.id]'>[console_turf.loc]" //FYI, these are all numeric ids, eventually.
if(C.id in temp_server.id_with_upload)
dat += " (Remove)</A><BR>"
else
dat += " (Add)</A><BR>"
dat += "Consoles with Download Access<BR>"
for(var/obj/machinery/computer/rdconsole/C in consoles)
var/turf/console_turf = get_turf(C)
dat += "* <A href='byond://?src=[UID()];download_toggle=[C.id]'>[console_turf.loc]"
if(C.id in temp_server.id_with_download)
dat += " (Remove)</A><BR>"
else
dat += " (Add)</A><BR>"
dat += "<HR><A href='byond://?src=[UID()];main=1'>Main Menu</A>"
if(2) //Data Management menu
dat += "[temp_server.name] Data Management<BR><BR>"
dat += "Known Technologies<BR>"
for(var/I in temp_server.files.known_tech)
var/datum/tech/T = temp_server.files.known_tech[I]
if(T.level <= 0)
continue
dat += "* [T.name] "
dat += "<A href='byond://?src=[UID()];reset_tech=[T.id]'>(Reset)</A><BR>" //FYI, these are all strings.
dat += "Known Designs<BR>"
for(var/I in temp_server.files.known_designs)
var/datum/design/D = temp_server.files.known_designs[I]
dat += "* [D.name] "
dat += "<A href='byond://?src=[UID()];reset_design=[D.id]'>(Blacklist)</A><BR>"
if(length(temp_server.files.blacklisted_designs))
dat += "Blacklisted Designs<br>"
for(var/I in temp_server.files.blacklisted_designs)
dat += "* [I] "
dat += "<a href='byond://?src=[UID()];restore_design=[I]'>(Restore design)</a><br>"
dat += "<HR><A href='byond://?src=[UID()];main=1'>Main Menu</A>"
if(3) //Server Data Transfer
dat += "[temp_server.name] Server to Server Transfer<BR><BR>"
dat += "Send Data to what server?<BR>"
for(var/obj/machinery/r_n_d/server/S in servers)
dat += "[S.name] <a href='byond://?src=[UID()];send_to=[S.server_id]'> (Transfer)</a><br>"
dat += "<hr><a href='byond://?src=[UID()];main=1'>Main Menu</a>"
user << browse("<title>R&D Server Control</title><hr><meta charset='UTF-8'>[dat]", "window=server_control;size=575x400")
onclose(user, "server_control")
return
/obj/machinery/computer/rdservercontrol/emag_act(user as mob)
if(!emagged)
playsound(loc, 'sound/effects/sparks4.ogg', 75, TRUE)
emagged = TRUE
to_chat(user, "<span class='notice'>You you disable the security protocols</span>")
return TRUE
src.updateUsrDialog()
/obj/machinery/r_n_d/server/core
name = "Core R&D Server"
id_with_upload_string = "1;3"
id_with_download_string = "1;3"
server_id = 1
plays_sound = 1
/obj/machinery/r_n_d/server/robotics
name = "Robotics R&D Server"
id_with_upload_string = "1;2;4"
id_with_download_string = "1;2;4"
server_id = 2