mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
Generalizes the telecommunication reception check.
Also happens to fix a bug where a Detomax could blow up PDAs without reception. Changes a couple of type checks to access checks.
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
#define TELECOMMS_RECEPTION_NONE 0
|
||||||
|
#define TELECOMMS_RECEPTION_SENDER 1
|
||||||
|
#define TELECOMMS_RECEPTION_RECEIVER 2
|
||||||
|
#define TELECOMMS_RECEPTION_BOTH 3
|
||||||
|
|
||||||
/proc/get_frequency_name(var/display_freq)
|
/proc/get_frequency_name(var/display_freq)
|
||||||
var/freq_text
|
var/freq_text
|
||||||
|
|
||||||
@@ -16,3 +21,59 @@
|
|||||||
|
|
||||||
return freq_text
|
return freq_text
|
||||||
|
|
||||||
|
/datum/reception
|
||||||
|
var/obj/machinery/message_server/message_server = null
|
||||||
|
var/telecomms_reception = TELECOMMS_RECEPTION_NONE
|
||||||
|
var/message = ""
|
||||||
|
|
||||||
|
/datum/receptions
|
||||||
|
var/obj/machinery/message_server/message_server = null
|
||||||
|
var/sender_reception = TELECOMMS_RECEPTION_NONE
|
||||||
|
var/list/receiver_reception = new
|
||||||
|
|
||||||
|
/proc/get_message_server()
|
||||||
|
if(message_servers)
|
||||||
|
for (var/obj/machinery/message_server/MS in message_servers)
|
||||||
|
if(MS.active)
|
||||||
|
return MS
|
||||||
|
return null
|
||||||
|
|
||||||
|
/proc/check_signal(var/datum/signal/signal)
|
||||||
|
return signal && signal.data["done"]
|
||||||
|
|
||||||
|
/proc/get_sender_reception(var/atom/sender, var/datum/signal/signal)
|
||||||
|
return check_signal(signal) ? TELECOMMS_RECEPTION_SENDER : TELECOMMS_RECEPTION_NONE
|
||||||
|
|
||||||
|
/proc/get_receiver_reception(var/receiver, var/datum/signal/signal)
|
||||||
|
if(receiver && check_signal(signal))
|
||||||
|
var/turf/pos = get_turf(receiver)
|
||||||
|
if(pos.z in signal.data["level"])
|
||||||
|
return TELECOMMS_RECEPTION_RECEIVER
|
||||||
|
return TELECOMMS_RECEPTION_NONE
|
||||||
|
|
||||||
|
/proc/get_reception(var/atom/sender, var/receiver, var/message = "")
|
||||||
|
var/datum/reception/reception = new
|
||||||
|
|
||||||
|
// check if telecomms I/O route 1459 is stable
|
||||||
|
//var/telecomms_intact = telecomms_process(P.owner, owner, t)
|
||||||
|
reception.message_server = get_message_server()
|
||||||
|
|
||||||
|
var/datum/signal/signal = sender.telecomms_process()
|
||||||
|
reception.telecomms_reception |= get_sender_reception(sender, signal)
|
||||||
|
reception.telecomms_reception |= get_receiver_reception(receiver, signal)
|
||||||
|
reception.message = signal && signal.data["compression"] > 0 ? Gibberish(message, signal.data["compression"] + 50) : message
|
||||||
|
|
||||||
|
return reception
|
||||||
|
|
||||||
|
/proc/get_receptions(var/atom/sender, var/list/receivers)
|
||||||
|
var/datum/receptions/receptions = new
|
||||||
|
receptions.message_server = get_message_server()
|
||||||
|
|
||||||
|
var/datum/signal/signal = sender.telecomms_process()
|
||||||
|
receptions.sender_reception = get_sender_reception(sender, signal)
|
||||||
|
|
||||||
|
if(receptions.sender_reception)
|
||||||
|
for(var/receiver in receivers)
|
||||||
|
receptions.receiver_reception[receiver] = get_receiver_reception(receiver, signal)
|
||||||
|
|
||||||
|
return receptions
|
||||||
|
|||||||
@@ -347,7 +347,6 @@ var/global/list/obj/item/device/pda/PDAs = list()
|
|||||||
|
|
||||||
var/data[0] // This is the data that will be sent to the PDA
|
var/data[0] // This is the data that will be sent to the PDA
|
||||||
|
|
||||||
|
|
||||||
data["owner"] = owner // Who is your daddy...
|
data["owner"] = owner // Who is your daddy...
|
||||||
data["ownjob"] = ownjob // ...and what does he do?
|
data["ownjob"] = ownjob // ...and what does he do?
|
||||||
|
|
||||||
@@ -669,7 +668,7 @@ var/global/list/obj/item/device/pda/PDAs = list()
|
|||||||
active_conversation=P
|
active_conversation=P
|
||||||
mode=21
|
mode=21
|
||||||
if("Send Honk")//Honk virus
|
if("Send Honk")//Honk virus
|
||||||
if(istype(cartridge, /obj/item/weapon/cartridge/clown))//Cartridge checks are kind of unnecessary since everything is done through switch.
|
if(cartridge && cartridge.access_clown)//Cartridge checks are kind of unnecessary since everything is done through switch.
|
||||||
var/obj/item/device/pda/P = locate(href_list["target"])//Leaving it alone in case it may do something useful, I guess.
|
var/obj/item/device/pda/P = locate(href_list["target"])//Leaving it alone in case it may do something useful, I guess.
|
||||||
if(!isnull(P))
|
if(!isnull(P))
|
||||||
if (!P.toff && cartridge.charges > 0)
|
if (!P.toff && cartridge.charges > 0)
|
||||||
@@ -682,7 +681,7 @@ var/global/list/obj/item/device/pda/PDAs = list()
|
|||||||
ui.close()
|
ui.close()
|
||||||
return 0
|
return 0
|
||||||
if("Send Silence")//Silent virus
|
if("Send Silence")//Silent virus
|
||||||
if(istype(cartridge, /obj/item/weapon/cartridge/mime))
|
if(cartridge && cartridge.access_mime)
|
||||||
var/obj/item/device/pda/P = locate(href_list["target"])
|
var/obj/item/device/pda/P = locate(href_list["target"])
|
||||||
if(!isnull(P))
|
if(!isnull(P))
|
||||||
if (!P.toff && cartridge.charges > 0)
|
if (!P.toff && cartridge.charges > 0)
|
||||||
@@ -709,34 +708,15 @@ var/global/list/obj/item/device/pda/PDAs = list()
|
|||||||
M.close()
|
M.close()
|
||||||
|
|
||||||
if("Detonate")//Detonate PDA... maybe
|
if("Detonate")//Detonate PDA... maybe
|
||||||
// check if telecomms I/O route 1459 is stable
|
if(cartridge && cartridge.access_detonate_pda)
|
||||||
//var/telecomms_intact = telecomms_process(P.owner, owner, t)
|
var/obj/item/device/pda/P = locate(href_list["target"])
|
||||||
var/obj/machinery/message_server/useMS = null
|
var/datum/reception/reception = get_reception(src, P, "")
|
||||||
if(message_servers)
|
if(!(reception.message_server && reception.telecomms_reception & TELECOMMS_RECEPTION_SENDER))
|
||||||
for (var/obj/machinery/message_server/MS in message_servers)
|
|
||||||
//PDAs are now dependant on the Message Server.
|
|
||||||
if(MS.active)
|
|
||||||
useMS = MS
|
|
||||||
break
|
|
||||||
|
|
||||||
var/datum/signal/signal = src.telecomms_process()
|
|
||||||
|
|
||||||
var/useTC = 0
|
|
||||||
if(signal)
|
|
||||||
if(signal.data["done"])
|
|
||||||
useTC = 1
|
|
||||||
var/turf/pos = get_turf(src)
|
|
||||||
if(pos.z in signal.data["level"])
|
|
||||||
useTC = 2
|
|
||||||
|
|
||||||
if(istype(cartridge, /obj/item/weapon/cartridge/syndicate))
|
|
||||||
if(!(useMS && useTC))
|
|
||||||
U.show_message("\red An error flashes on your [src]: Connection unavailable", 1)
|
U.show_message("\red An error flashes on your [src]: Connection unavailable", 1)
|
||||||
return
|
return
|
||||||
if(useTC != 2) // Does our recepient have a broadcaster on their level?
|
if(reception.telecomms_reception & TELECOMMS_RECEPTION_RECEIVER == 0) // Does our recepient have a broadcaster on their level?
|
||||||
U.show_message("\red An error flashes on your [src]: Recipient unavailable", 1)
|
U.show_message("\red An error flashes on your [src]: Recipient unavailable", 1)
|
||||||
return
|
return
|
||||||
var/obj/item/device/pda/P = locate(href_list["target"])
|
|
||||||
if(!isnull(P))
|
if(!isnull(P))
|
||||||
if (!P.toff && cartridge.charges > 0)
|
if (!P.toff && cartridge.charges > 0)
|
||||||
cartridge.charges--
|
cartridge.charges--
|
||||||
@@ -900,34 +880,14 @@ var/global/list/obj/item/device/pda/PDAs = list()
|
|||||||
return
|
return
|
||||||
|
|
||||||
last_text = world.time
|
last_text = world.time
|
||||||
// check if telecomms I/O route 1459 is stable
|
var/datum/reception/reception = get_reception(src, P, t)
|
||||||
//var/telecomms_intact = telecomms_process(P.owner, owner, t)
|
t = reception.message
|
||||||
var/obj/machinery/message_server/useMS = null
|
|
||||||
if(message_servers)
|
|
||||||
for (var/obj/machinery/message_server/MS in message_servers)
|
|
||||||
//PDAs are now dependent on the Message Server.
|
|
||||||
if(MS.active)
|
|
||||||
useMS = MS
|
|
||||||
break
|
|
||||||
|
|
||||||
var/datum/signal/signal = src.telecomms_process()
|
if(reception.message_server && reception.telecomms_reception & TELECOMMS_RECEPTION_SENDER) // only send the message if it's stable
|
||||||
|
if(reception.telecomms_reception & TELECOMMS_RECEPTION_RECEIVER == 0) // Does our recipient have a broadcaster on their level?
|
||||||
var/useTC = 0
|
|
||||||
if(signal)
|
|
||||||
if(signal.data["done"])
|
|
||||||
useTC = 1
|
|
||||||
var/turf/pos = get_turf(P)
|
|
||||||
if(pos.z in signal.data["level"])
|
|
||||||
useTC = 2
|
|
||||||
//Let's make this barely readable
|
|
||||||
if(signal.data["compression"] > 0)
|
|
||||||
t = Gibberish(t, signal.data["compression"] + 50)
|
|
||||||
|
|
||||||
if(useMS && useTC) // only send the message if it's stable
|
|
||||||
if(useTC != 2) // Does our recipient have a broadcaster on their level?
|
|
||||||
U << "ERROR: Cannot reach recipient."
|
U << "ERROR: Cannot reach recipient."
|
||||||
return
|
return
|
||||||
var/send_result = useMS.send_pda_message("[P.owner]","[owner]","[t]")
|
var/send_result = reception.message_server.send_pda_message("[P.owner]","[owner]","[t]")
|
||||||
if (send_result)
|
if (send_result)
|
||||||
U << "ERROR: Messaging server rejected your message. Reason: contains '[send_result]'."
|
U << "ERROR: Messaging server rejected your message. Reason: contains '[send_result]'."
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user