mirror of
https://github.com/Citadel-Station-13/Citadel-Station-13-RP.git
synced 2025-12-10 13:21:09 +00:00
* Tetherport * sigh * more fixes * shields * more * woo * compile * e * a * Tether, compilable and running not playable tho * Tether, compilable and running not playable tho * Automatic changelog generation for PR #3200 [ci skip] * why * EOL * nukes edited areas. if you had something important in here, you didn't deserve to. * another folder down * one more folder * the refacotring continues * change those * okay * dynamic zlevels * move stufF * reorganize that too * get rid of unneded archives * move talon too and rename that * meh * woop * fixes * move those * fixes * fix * Submap Repathing/Reconciliation * Attempts to fix Gecko invalid variable bug. * Alright. Let's actually fix every bugged instance. * Another round of updates. That same turf issue exists. * Should fix the last of those weird varedits. * One snuck by? * Another round of fixes. * I want to know who put all these var edits in. * Another batch down. * Yet another batch. * A map at a time, at this rate. * I hope these are the last four, but probably not. * Hopefully the last, but probably not. * ANOTHER stealth var_edit that snuck through. * Manually checked the rest of the map files I found. These were updated. * Did the same for bad var_edits. Caught these. * Updates the 140x140. * Sorts Talon and partially adds Point Defense. Too complex for me. * tether_turfs * I think this is it. The last variable bug. * Telenetwork Delenda Est * linterS * fix * extraneous files * woo * mmm * add that in until reagents hardsync * woo * sync * updates * t * weather * i want to rewrite telecomms * test * shift those * woo * move that * FUCK * Fix * fix * or null * shuffle * Fixes * Fixes * Fix * fixes * woo * that * facility safety * that too * move that out * fixes * woops / * rename those * those * woo * test * fixes * woo * exploration map edits changes oxygen tanks to o2 jetpacks, co2 jetpack to an o2, adds pathfinder voidsuit, suit cycler for medical, and fixes access restrictions on the PF's office and locker * mh * Update fueldepot.dmm * woo * woo * woo * fix * utterly fuck you * Automatic changelog generation for PR #3225 [ci skip] * test code * w * that * fieldgens * better * singulo * fixes * fix * fix * adds mirrortools, removes backup implants * why * Prevents falling through catwalks and lattice, stolen from Silicons * Lots of stuff! * Update talon2.dmm * Automatic changelog generation for PR #3226 [ci skip] * Removes Mining Stacker * Slight remap changes to Deck 3, pending more. * Automatic changelog generation for PR #3228 [ci skip] * fix that * that * R&D remap. * Lighting fix and correcting a talon vault issue? * Conflict clean-up. * Multi-floor modifications. Chem change. R&D revert. Etc. * Adds a few extra timeclocks. * Missed the bioregens. Hooray. * Re re readjusts R&D to a lobby design. Adds Space Spice. Maybe fixes Captain spawner. * woo * fix * not that * Xenobotany and Trash Pit adjustments. * proper * De-militarizes Talon. Will Trader-ify them when I wake up. * fix * fix * ashet pls * ashet pls v2 * cleaner * cleaner Co-authored-by: nevimer <77420409+nevimer@users.noreply.github.com> Co-authored-by: CitadelStationBot <citadelstationcommunity@gmail.com> Co-authored-by: Captain277 <agentraven16@gmail.com> Co-authored-by: Mag <86886852+MonaraMir@users.noreply.github.com> Co-authored-by: nik707 <38332985+nik707@users.noreply.github.com> Co-authored-by: TheLordME <58342752+TheLordME@users.noreply.github.com>
355 lines
12 KiB
Plaintext
355 lines
12 KiB
Plaintext
/*
|
|
HOW IT WORKS
|
|
|
|
The radio_controller is a global object maintaining all radio transmissions, think about it as about "ether".
|
|
Note that walkie-talkie, intercoms and headsets handle transmission using nonstandard way.
|
|
procs:
|
|
|
|
add_object(obj/device as obj, var/new_frequency as num, var/radio_filter as text|null = null)
|
|
Adds listening object.
|
|
parameters:
|
|
device - device receiving signals, must have proc receive_signal (see description below).
|
|
one device may listen several frequencies, but not same frequency twice.
|
|
new_frequency - see possibly frequencies below;
|
|
radio_filter - thing for optimization. Optional, but recommended.
|
|
All filters should be consolidated in this file, see defines later.
|
|
Device without listening filter will receive all signals (on specified frequency).
|
|
Device with filter will receive any signals sent without filter.
|
|
Device with filter will not receive any signals sent with different filter.
|
|
returns:
|
|
Reference to frequency object.
|
|
|
|
remove_object (obj/device, old_frequency)
|
|
Obliviously, after calling this proc, device will not receive any signals on old_frequency.
|
|
Other frequencies will left unaffected.
|
|
|
|
return_frequency(var/frequency as num)
|
|
returns:
|
|
Reference to frequency object. Use it if you need to send and do not need to listen.
|
|
|
|
radio_frequency is a global object maintaining list of devices that listening specific frequency.
|
|
procs:
|
|
|
|
post_signal(obj/source as obj|null, datum/signal/signal, var/radio_filter as text|null = null, var/range as num|null = null)
|
|
Sends signal to all devices that wants such signal.
|
|
parameters:
|
|
source - object, emitted signal. Usually, devices will not receive their own signals.
|
|
signal - see description below.
|
|
radio_filter - described above.
|
|
range - radius of regular byond's square circle on that z-level. null means everywhere, on all z-levels.
|
|
|
|
obj/proc/receive_signal(datum/signal/signal, var/receive_method as num, var/receive_param)
|
|
Handler from received signals. By default does nothing. Define your own for your object.
|
|
Avoid of sending signals directly from this proc, use spawn(-1). DO NOT use sleep() here or call procs that sleep please. If you must, use spawn()
|
|
parameters:
|
|
signal - see description below. Extract all needed data from the signal before doing sleep(), spawn() or return!
|
|
receive_method - may be TRANSMISSION_WIRE or TRANSMISSION_RADIO.
|
|
TRANSMISSION_WIRE is currently unused.
|
|
receive_param - for TRANSMISSION_RADIO here comes frequency.
|
|
|
|
datum/signal
|
|
vars:
|
|
source
|
|
an object that emitted signal. Used for debug and bearing.
|
|
data
|
|
list with transmitting data. Usual use pattern:
|
|
data["msg"] = "hello world"
|
|
encryption
|
|
Some number symbolizing "encryption key".
|
|
Note that game actually do not use any cryptography here.
|
|
If receiving object don't know right key, it must ignore encrypted signal in its receive_signal.
|
|
|
|
*/
|
|
|
|
/*
|
|
Frequency range: 1200 to 1600
|
|
Radiochat range: 1441 to 1489 (most devices refuse to be tune to other frequency, even during mapmaking)
|
|
|
|
Radio:
|
|
1459 - standard radio chat
|
|
1351 - Science
|
|
1353 - Command
|
|
1355 - Medical
|
|
1357 - Engineering
|
|
1359 - Security
|
|
1341 - deathsquad
|
|
1443 - Confession Intercom
|
|
1347 - Cargo techs
|
|
1349 - Service people
|
|
|
|
Devices:
|
|
1451 - tracking implant
|
|
1457 - RSD default
|
|
|
|
On the map:
|
|
1311 for prison shuttle console (in fact, it is not used)
|
|
1435 for status displays
|
|
1437 for atmospherics/fire alerts
|
|
1438 for engine components
|
|
1439 for air pumps, air scrubbers, atmo control
|
|
1441 for atmospherics - supply tanks
|
|
1443 for atmospherics - distribution loop/mixed air tank
|
|
1445 for bot nav beacons
|
|
1447 for mulebot, secbot and ed209 control
|
|
1449 for airlock controls, electropack, magnets
|
|
1451 for toxin lab access
|
|
1453 for engineering access
|
|
1455 for AI access
|
|
*/
|
|
|
|
var/const/RADIO_LOW_FREQ = 1200
|
|
var/const/PUBLIC_LOW_FREQ = 1441
|
|
var/const/PUBLIC_HIGH_FREQ = 1489
|
|
var/const/RADIO_HIGH_FREQ = 1600
|
|
|
|
var/const/BOT_FREQ = 1447
|
|
var/const/COMM_FREQ = 1353
|
|
var/const/ERT_FREQ = 1345
|
|
var/const/AI_FREQ = 1343
|
|
var/const/DTH_FREQ = 1341
|
|
var/const/SYND_FREQ = 1213
|
|
var/const/RAID_FREQ = 1277
|
|
var/const/TRADE_FREQ = 1279
|
|
var/const/ENT_FREQ = 1461 //entertainment frequency. This is not a diona exclusive frequency.
|
|
|
|
// department channels
|
|
var/const/PUB_FREQ = 1459
|
|
var/const/SEC_FREQ = 1359
|
|
var/const/ENG_FREQ = 1357
|
|
var/const/MED_FREQ = 1355
|
|
var/const/SCI_FREQ = 1351
|
|
var/const/SRV_FREQ = 1349
|
|
var/const/SUP_FREQ = 1347
|
|
var/const/EXP_FREQ = 1361
|
|
var/const/TALON_FREQ = 1363
|
|
|
|
// internal department channels
|
|
var/const/MED_I_FREQ = 1485
|
|
var/const/SEC_I_FREQ = 1475
|
|
|
|
var/list/radiochannels = list(
|
|
"Common" = PUB_FREQ,
|
|
"Science" = SCI_FREQ,
|
|
"Command" = COMM_FREQ,
|
|
"Medical" = MED_FREQ,
|
|
"Engineering" = ENG_FREQ,
|
|
"Security" = SEC_FREQ,
|
|
"Response Team" = ERT_FREQ,
|
|
"Special Ops" = DTH_FREQ,
|
|
"Mercenary" = SYND_FREQ,
|
|
"Raider" = RAID_FREQ,
|
|
"Trader" = TRADE_FREQ,
|
|
"Supply" = SUP_FREQ,
|
|
"Service" = SRV_FREQ,
|
|
"Explorer" = EXP_FREQ,
|
|
"AI Private" = AI_FREQ,
|
|
"Entertainment" = ENT_FREQ,
|
|
"Medical(I)" = MED_I_FREQ,
|
|
"Security(I)" = SEC_I_FREQ
|
|
)
|
|
|
|
// central command channels, i.e deathsquid & response teams
|
|
var/list/CENT_FREQS = list(ERT_FREQ, DTH_FREQ)
|
|
|
|
// Antag channels, i.e. Syndicate
|
|
var/list/ANTAG_FREQS = list(SYND_FREQ, RAID_FREQ)
|
|
|
|
//Department channels, arranged lexically
|
|
var/list/DEPT_FREQS = list(AI_FREQ, COMM_FREQ, ENG_FREQ, ENT_FREQ, MED_FREQ, SEC_FREQ, SCI_FREQ, SRV_FREQ, SUP_FREQ, TRADE_FREQ)
|
|
|
|
/proc/frequency_span_class(var/frequency)
|
|
// Antags!
|
|
if (frequency in ANTAG_FREQS)
|
|
return "syndradio"
|
|
// CentCom channels (deathsquid and ert)
|
|
if(frequency in CENT_FREQS)
|
|
return "centradio"
|
|
// command channel
|
|
if(frequency == COMM_FREQ)
|
|
return "comradio"
|
|
// AI private channel
|
|
if(frequency == AI_FREQ)
|
|
return "airadio"
|
|
// department radio formatting (poorly optimized, ugh)
|
|
if(frequency == SEC_FREQ)
|
|
return "secradio"
|
|
if (frequency == ENG_FREQ)
|
|
return "engradio"
|
|
if(frequency == SCI_FREQ)
|
|
return "sciradio"
|
|
if(frequency == MED_FREQ)
|
|
return "medradio"
|
|
if(frequency == SUP_FREQ) // cargo
|
|
return "supradio"
|
|
if(frequency == SRV_FREQ) // service
|
|
return "srvradio"
|
|
if(frequency == EXP_FREQ) // explorer
|
|
return "expradio"
|
|
if(frequency == ENT_FREQ) // entertainment
|
|
return "entradio"
|
|
if(frequency == TRADE_FREQ)
|
|
return "syndradio"
|
|
if(frequency in DEPT_FREQS)
|
|
return "deptradio"
|
|
|
|
return "radio"
|
|
|
|
/* filters */
|
|
//When devices register with the radio controller, they might register under a certain filter.
|
|
//Other devices can then choose to send signals to only those devices that belong to a particular filter.
|
|
//This is done for performance, so we don't send signals to lots of machines unnecessarily.
|
|
|
|
//This filter is special because devices belonging to default also recieve signals sent to any other filter.
|
|
var/const/RADIO_DEFAULT = "radio_default"
|
|
|
|
var/const/RADIO_TO_AIRALARM = "radio_airalarm" //air alarms
|
|
var/const/RADIO_FROM_AIRALARM = "radio_airalarm_rcvr" //devices interested in recieving signals from air alarms
|
|
var/const/RADIO_CHAT = "radio_telecoms"
|
|
var/const/RADIO_ATMOSIA = "radio_atmos"
|
|
var/const/RADIO_NAVBEACONS = "radio_navbeacon"
|
|
var/const/RADIO_AIRLOCK = "radio_airlock"
|
|
var/const/RADIO_SECBOT = "radio_secbot"
|
|
var/const/RADIO_MULEBOT = "radio_mulebot"
|
|
var/const/RADIO_MAGNETS = "radio_magnet"
|
|
|
|
var/global/datum/controller/radio/radio_controller
|
|
|
|
/hook/startup/proc/createRadioController()
|
|
radio_controller = new /datum/controller/radio()
|
|
return 1
|
|
|
|
//callback used by objects to react to incoming radio signals
|
|
/obj/proc/receive_signal(datum/signal/signal, receive_method, receive_param)
|
|
return null
|
|
|
|
//The global radio controller
|
|
/datum/controller/radio
|
|
var/list/datum/radio_frequency/frequencies = list()
|
|
|
|
/datum/controller/radio/proc/add_object(obj/device as obj, var/new_frequency as num, var/radio_filter = null as text|null)
|
|
var/f_text = num2text(new_frequency)
|
|
var/datum/radio_frequency/frequency = frequencies[f_text]
|
|
|
|
if(!frequency)
|
|
frequency = new
|
|
frequency.frequency = new_frequency
|
|
frequencies[f_text] = frequency
|
|
|
|
frequency.add_listener(device, radio_filter)
|
|
return frequency
|
|
|
|
/datum/controller/radio/proc/remove_object(obj/device, old_frequency)
|
|
var/f_text = num2text(old_frequency)
|
|
var/datum/radio_frequency/frequency = frequencies[f_text]
|
|
|
|
if(frequency)
|
|
frequency.remove_listener(device)
|
|
|
|
if(frequency.devices.len == 0)
|
|
qdel(frequency)
|
|
frequencies -= f_text
|
|
|
|
return 1
|
|
|
|
/datum/controller/radio/proc/return_frequency(var/new_frequency as num)
|
|
var/f_text = num2text(new_frequency)
|
|
var/datum/radio_frequency/frequency = frequencies[f_text]
|
|
|
|
if(!frequency)
|
|
frequency = new
|
|
frequency.frequency = new_frequency
|
|
frequencies[f_text] = frequency
|
|
|
|
return frequency
|
|
|
|
/datum/radio_frequency
|
|
var/frequency as num
|
|
var/list/list/obj/devices = list()
|
|
|
|
/datum/radio_frequency/proc/post_signal(obj/source as obj|null, datum/signal/signal, var/radio_filter = null as text|null, var/range = null as num|null)
|
|
var/turf/start_point
|
|
if(range)
|
|
start_point = get_turf(source)
|
|
if(!start_point)
|
|
qdel(signal)
|
|
return 0
|
|
if (radio_filter)
|
|
send_to_filter(source, signal, radio_filter, start_point, range)
|
|
send_to_filter(source, signal, RADIO_DEFAULT, start_point, range)
|
|
else
|
|
//Broadcast the signal to everyone!
|
|
for (var/next_filter in devices)
|
|
send_to_filter(source, signal, next_filter, start_point, range)
|
|
|
|
//Sends a signal to all machines belonging to a given filter. Should be called by post_signal()
|
|
/datum/radio_frequency/proc/send_to_filter(obj/source, datum/signal/signal, var/radio_filter, var/turf/start_point = null, var/range = null)
|
|
if (range && !start_point)
|
|
return
|
|
|
|
for(var/obj/device in devices[radio_filter])
|
|
if(device == source)
|
|
continue
|
|
if(range)
|
|
var/turf/end_point = get_turf(device)
|
|
if(!end_point)
|
|
continue
|
|
if(start_point.z!=end_point.z || get_dist(start_point, end_point) > range)
|
|
continue
|
|
|
|
device.receive_signal(signal, TRANSMISSION_RADIO, frequency)
|
|
|
|
/datum/radio_frequency/proc/add_listener(obj/device as obj, var/radio_filter as text|null)
|
|
if (!radio_filter)
|
|
radio_filter = RADIO_DEFAULT
|
|
//log_admin("add_listener(device=[device],radio_filter=[radio_filter]) frequency=[frequency]")
|
|
var/list/obj/devices_line = devices[radio_filter]
|
|
if (!devices_line)
|
|
devices_line = new
|
|
devices[radio_filter] = devices_line
|
|
devices_line+=device
|
|
// var/list/obj/devices_line___ = devices[filter_str]
|
|
// var/l = devices_line___.len
|
|
//log_admin("DEBUG: devices_line.len=[devices_line.len]")
|
|
//log_admin("DEBUG: devices(filter_str).len=[l]")
|
|
|
|
/datum/radio_frequency/proc/remove_listener(obj/device)
|
|
for (var/devices_filter in devices)
|
|
var/list/devices_line = devices[devices_filter]
|
|
devices_line-=device
|
|
while (null in devices_line)
|
|
devices_line -= null
|
|
if (devices_line.len==0)
|
|
devices -= devices_filter
|
|
|
|
/datum/signal
|
|
var/obj/source
|
|
|
|
var/transmission_method = 0 //unused at the moment
|
|
//0 = wire
|
|
//1 = radio transmission
|
|
//2 = subspace transmission
|
|
|
|
var/list/data = list()
|
|
var/encryption
|
|
|
|
var/frequency = 0
|
|
|
|
/datum/signal/proc/copy_from(datum/signal/model)
|
|
source = model.source
|
|
transmission_method = model.transmission_method
|
|
data = model.data
|
|
encryption = model.encryption
|
|
frequency = model.frequency
|
|
|
|
/datum/signal/proc/debug_print()
|
|
if (source)
|
|
. = "signal = {source = '[source]' ([source:x],[source:y],[source:z])\n"
|
|
else
|
|
. = "signal = {source = '[source]' ()\n"
|
|
for (var/i in data)
|
|
. += "data\[\"[i]\"\] = \"[data[i]]\"\n"
|
|
if(islist(data[i]))
|
|
var/list/L = data[i]
|
|
for(var/t in L)
|
|
. += "data\[\"[i]\"\] list has: [t]"
|