mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-13 19:22:20 +00:00
* Add the system for managed global variables * Travis ban old globals * So you CAN inline proccall, that's neat * Fix that * master.dm * Remove the hack procs * Move InitGlobals to the proper spot * configuration.dm * Fix the missing pre-slash * clockcult.dm * This is probably for the best * Doy * Fix shit * Rest of the DEFINES tree * Fix * Use global. for access * Update find_references_in_globals Always hated that proc Whoever made it must've bee a r e a l idiot... * __HELPERS tree * Move global initialization to master. Fix the declaration * database.dm * Dat newline * I said DECLARATIVE order! * Here's something you can chew on @Iamgoofball * game_modes.dm * Fix this * genetics.dm * flavor_misc.dm * More stuff * Do it mso's way. Keep the controllers as global * Make master actually see it * Fix * Finish _globalvars/lists * Finish the rest of the _globalvars tree * This is weird * Migrate the controllers * SLOTH -> GLOB * Lighting globals * round_start_time -> ticker * PAI card list -> pai SS * record_id_num -> static * Diseases list -> SSdisease * More disease globals to the SS * More disease stuff * Emote list * Better and better * Bluh * So much stuff * Ahh * Wires * dview * station_areas * Teleportlocs * blood_splatter_icons * Stuff and such * More stuff * RAD IO * More stuff and such * Blob shit * Changeling stuff * Add "Balance" to changelogs * Balance for changelog compiler + Auto Tagging * Update the PR template * hivemind_bank * Bip * sacrificed * Good shit * Better define * More cult shit * Devil shit * Gang shit * > borers Fix shit * Rename the define * Nuke * Objectives * Sandbox * Multiverse sword * Announce systems * Stuff and such * TC con * Airlock * doppllllerrrrrr * holopads * Shut up byond you inconsistent fuck * Sneaky fuck * Burp * Bip * Fixnshit * Port without regard * askdlfjs; * asdfjasoidojfi * Protected globals and more * SO MANY * ajsimkvahsaoisd * akfdsiaopwimfeoiwafaw * gsdfigjosidjfgiosdg * AHHHHHHHHHHHHHHHHHHHHHHH!!!!! * facerolll * ASDFASDFASDF * Removes the unused parts of dmm_suite * WIP * Fix quote * asdfjauwfnkjs * afwlunhskjfda * asfjlaiwuefhaf * SO CLOSE * wwwweeeeeewwwww * agdgmoewranwg * HOLY MOTHER OF FUCK AND THATS JUST HALF THE JOB?!? * Fix syntax errors * 100 errors * Another 100 * So many... * Ugh * More shit * kilme * Stuuuuuufffff * ajrgmrlshio;djfa;sdkl * jkbhkhjbmjvjmh * soi soi soi * butt * TODAY WE LEARNED THAT GLOBAL AND STATIC ARE THE EXACT SAME FUCKING THING * lllllllllllllllllllllllllllllllllllllllllll * afsdijfiawhnflnjhnwsdfs * yugykihlugk,kj * time to go * STUFFF!!! * AAAAAAAAAAAAAAAAAHHHHHHHHHHHHHHHHHHHHHHHHHHH!!!!!!!!!!!!!!!!!!!!!!! * ngoaijdjlfkamsdlkf * Break time * aufjsdklfalsjfi * CONTROL KAY AND PRAY * IT COMPILEELEELELAKLJFKLDAFJLKFDJLADKJHFLJKAJGAHIEJALDFJ!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * Goteem * Fix testing mode * This does not belong in this PR * Convert it to a controller * Eh, fuck this option * Revert controllerization Ill do it some other time * Fix * Working controllerization * FOR THE LOVE OF CHRIST PROTECT THE LOGS * Protect admins and deadmins * Use the inbuilt proc
130 lines
4.3 KiB
Plaintext
130 lines
4.3 KiB
Plaintext
// Relays don't handle any actual communication. Global NTNet datum does that, relays only tell the datum if it should or shouldn't work.
|
|
/obj/machinery/ntnet_relay
|
|
name = "NTNet Quantum Relay"
|
|
desc = "A very complex router and transmitter capable of connecting electronic devices together. Looks fragile."
|
|
use_power = 2
|
|
active_power_usage = 10000 //10kW, apropriate for machine that keeps massive cross-Zlevel wireless network operational. Used to be 20 but that actually drained the smes one round
|
|
idle_power_usage = 100
|
|
icon = 'icons/obj/machines/telecomms.dmi'
|
|
icon_state = "bus"
|
|
anchored = 1
|
|
density = 1
|
|
var/datum/ntnet/NTNet = null // This is mostly for backwards reference and to allow varedit modifications from ingame.
|
|
var/enabled = 1 // Set to 0 if the relay was turned off
|
|
var/dos_failure = 0 // Set to 1 if the relay failed due to (D)DoS attack
|
|
var/list/dos_sources = list() // Backwards reference for qdel() stuff
|
|
|
|
// Denial of Service attack variables
|
|
var/dos_overload = 0 // Amount of DoS "packets" in this relay's buffer
|
|
var/dos_capacity = 500 // Amount of DoS "packets" in buffer required to crash the relay
|
|
var/dos_dissipate = 1 // Amount of DoS "packets" dissipated over time.
|
|
|
|
|
|
// TODO: Implement more logic here. For now it's only a placeholder.
|
|
/obj/machinery/ntnet_relay/is_operational()
|
|
if(stat & (BROKEN | NOPOWER | EMPED))
|
|
return 0
|
|
if(dos_failure)
|
|
return 0
|
|
if(!enabled)
|
|
return 0
|
|
return 1
|
|
|
|
/obj/machinery/ntnet_relay/update_icon()
|
|
if(is_operational())
|
|
icon_state = "bus"
|
|
else
|
|
icon_state = "bus_off"
|
|
|
|
/obj/machinery/ntnet_relay/process()
|
|
if(is_operational())
|
|
use_power = 2
|
|
else
|
|
use_power = 1
|
|
|
|
update_icon()
|
|
|
|
if(dos_overload)
|
|
dos_overload = max(0, dos_overload - dos_dissipate)
|
|
|
|
// If DoS traffic exceeded capacity, crash.
|
|
if((dos_overload > dos_capacity) && !dos_failure)
|
|
dos_failure = 1
|
|
update_icon()
|
|
GLOB.ntnet_global.add_log("Quantum relay switched from normal operation mode to overload recovery mode.")
|
|
// If the DoS buffer reaches 0 again, restart.
|
|
if((dos_overload == 0) && dos_failure)
|
|
dos_failure = 0
|
|
update_icon()
|
|
GLOB.ntnet_global.add_log("Quantum relay switched from overload recovery mode to normal operation mode.")
|
|
..()
|
|
|
|
/obj/machinery/ntnet_relay/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
|
|
|
|
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
|
|
|
if(!ui)
|
|
ui = new(user, src, ui_key, "ntnet_relay", "NTNet Quantum Relay", 500, 300, master_ui, state)
|
|
ui.open()
|
|
|
|
|
|
/obj/machinery/ntnet_relay/ui_data(mob/user)
|
|
var/list/data = list()
|
|
data["enabled"] = enabled
|
|
data["dos_capacity"] = dos_capacity
|
|
data["dos_overload"] = dos_overload
|
|
data["dos_crashed"] = dos_failure
|
|
return data
|
|
|
|
|
|
/obj/machinery/ntnet_relay/ui_act(action, params)
|
|
if(..())
|
|
return
|
|
switch(action)
|
|
if("restart")
|
|
dos_overload = 0
|
|
dos_failure = 0
|
|
update_icon()
|
|
GLOB.ntnet_global.add_log("Quantum relay manually restarted from overload recovery mode to normal operation mode.")
|
|
if("toggle")
|
|
enabled = !enabled
|
|
GLOB.ntnet_global.add_log("Quantum relay manually [enabled ? "enabled" : "disabled"].")
|
|
update_icon()
|
|
|
|
|
|
/obj/machinery/ntnet_relay/attack_hand(mob/living/user)
|
|
ui_interact(user)
|
|
|
|
/obj/machinery/ntnet_relay/New()
|
|
uid = gl_uid
|
|
gl_uid++
|
|
component_parts = list()
|
|
var/obj/item/weapon/circuitboard/machine/B = new /obj/item/weapon/circuitboard/machine/ntnet_relay(null)
|
|
B.apply_default_parts(src)
|
|
|
|
if(GLOB.ntnet_global)
|
|
GLOB.ntnet_global.relays.Add(src)
|
|
NTNet = GLOB.ntnet_global
|
|
GLOB.ntnet_global.add_log("New quantum relay activated. Current amount of linked relays: [NTNet.relays.len]")
|
|
..()
|
|
|
|
/obj/machinery/ntnet_relay/Destroy()
|
|
if(GLOB.ntnet_global)
|
|
GLOB.ntnet_global.relays.Remove(src)
|
|
GLOB.ntnet_global.add_log("Quantum relay connection severed. Current amount of linked relays: [NTNet.relays.len]")
|
|
NTNet = null
|
|
|
|
for(var/datum/computer_file/program/ntnet_dos/D in dos_sources)
|
|
D.target = null
|
|
D.error = "Connection to quantum relay severed"
|
|
|
|
return ..()
|
|
|
|
/obj/item/weapon/circuitboard/machine/ntnet_relay
|
|
name = "NTNet Relay (Machine Board)"
|
|
build_path = /obj/machinery/ntnet_relay
|
|
origin_tech = "programming=3;bluespace=3;magnets=2"
|
|
req_components = list(
|
|
/obj/item/stack/cable_coil = 2,
|
|
/obj/item/weapon/stock_parts/subspace/filter = 1)
|