From 60aec770ffd8a2290941dd9675b84c92bb7d8637 Mon Sep 17 00:00:00 2001 From: Atermonera Date: Thu, 27 Aug 2020 18:31:22 -0700 Subject: [PATCH] Station overmap sensors should connect automatically now (#7547) --- code/modules/overmap/sectors.dm | 2 ++ .../overmap/ships/computers/sensors.dm | 10 ++++---- code/modules/overmap/ships/computers/ship.dm | 23 +++++++++++++------ code/modules/overmap/ships/ship.dm | 2 -- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/code/modules/overmap/sectors.dm b/code/modules/overmap/sectors.dm index 1c93a66f6a..90beb4831c 100644 --- a/code/modules/overmap/sectors.dm +++ b/code/modules/overmap/sectors.dm @@ -51,6 +51,8 @@ //This is called later in the init order by SSshuttles to populate sector objects. Importantly for subtypes, shuttles will be created by then. /obj/effect/overmap/visitable/proc/populate_sector_objects() + for(var/obj/machinery/computer/ship/S in global.machines) + S.attempt_hook_up(src) /obj/effect/overmap/visitable/proc/get_areas() . = list() diff --git a/code/modules/overmap/ships/computers/sensors.dm b/code/modules/overmap/ships/computers/sensors.dm index 41d174b51c..f750481ddc 100644 --- a/code/modules/overmap/ships/computers/sensors.dm +++ b/code/modules/overmap/ships/computers/sensors.dm @@ -29,7 +29,7 @@ var/data[0] data["viewing"] = viewing_overmap(user) - if(sensors) + if(sensors || find_sensors()) data["on"] = sensors.use_power data["range"] = sensors.range data["health"] = sensors.health @@ -69,11 +69,13 @@ ui.set_auto_update(1) /obj/machinery/computer/ship/sensors/OnTopic(var/mob/user, var/list/href_list, state) - if(..()) - return TOPIC_HANDLED + if((. = ..())) + return if (!linked) - return TOPIC_NOACTION + var/obj/effect/overmap/visitable/sector = get_overmap_sector(src.z) + if(!istype(sector) || !attempt_hook_up_recursive(sector)) + return TOPIC_NOACTION if (href_list["viewing"]) if(user && !isAI(user)) diff --git a/code/modules/overmap/ships/computers/ship.dm b/code/modules/overmap/ships/computers/ship.dm index b088798513..f350aa11f6 100644 --- a/code/modules/overmap/ships/computers/ship.dm +++ b/code/modules/overmap/ships/computers/ship.dm @@ -10,16 +10,25 @@ somewhere on that shuttle. Subtypes of these can be then used to perform ship ov var/list/whitelisted_types = list(/obj/effect/overmap/visitable/ship) var/list/blacklisted_types = list() +/obj/machinery/computer/ship/New() + . = ..() + var/list/L = list() + for(var/type in whitelisted_types) + L |= typesof(type) + for(var/type in blacklisted_types) + L -= typesof(type) + whitelisted_types = L + // A late init operation called in SSshuttles, used to attach the thing to the right ship. -/obj/machinery/computer/ship/proc/attempt_hook_up(obj/effect/overmap/visitable/ship/sector) - if(!sector || (sector.type in blacklisted_types) || !(sector.type in whitelisted_types)) - return +/obj/machinery/computer/ship/proc/attempt_hook_up(obj/effect/overmap/visitable/sector) + if(!sector || !(sector.type in whitelisted_types)) + return FALSE if(sector.check_ownership(src)) linked = sector - return 1 + return TRUE /obj/machinery/computer/ship/proc/sync_linked(var/user = null) - var/obj/effect/overmap/visitable/ship/sector = get_overmap_sector(z) + var/obj/effect/overmap/visitable/sector = get_overmap_sector(z) if(!sector) return . = attempt_hook_up_recursive(sector) @@ -27,10 +36,10 @@ somewhere on that shuttle. Subtypes of these can be then used to perform ship ov to_chat(user, "[src] reconnected to [linked]") user << browse(null, "window=[src]") // close reconnect dialog -/obj/machinery/computer/ship/proc/attempt_hook_up_recursive(obj/effect/overmap/visitable/ship/sector) +/obj/machinery/computer/ship/proc/attempt_hook_up_recursive(obj/effect/overmap/visitable/sector) if(attempt_hook_up(sector)) return sector - for(var/obj/effect/overmap/visitable/ship/candidate in sector) + for(var/obj/effect/overmap/visitable/candidate in sector) if((. = .(candidate))) return diff --git a/code/modules/overmap/ships/ship.dm b/code/modules/overmap/ships/ship.dm index 925d5ca136..fadf601c1e 100644 --- a/code/modules/overmap/ships/ship.dm +++ b/code/modules/overmap/ships/ship.dm @@ -239,8 +239,6 @@ /obj/effect/overmap/visitable/ship/populate_sector_objects() ..() - for(var/obj/machinery/computer/ship/S in global.machines) - S.attempt_hook_up(src) for(var/datum/ship_engine/E in ship_engines) if(check_ownership(E.holder)) engines |= E