diff --git a/code/controllers/subsystem/mapping.dm b/code/controllers/subsystem/mapping.dm index 6d65eb8dbea..3158fae7dbd 100644 --- a/code/controllers/subsystem/mapping.dm +++ b/code/controllers/subsystem/mapping.dm @@ -290,8 +290,8 @@ SUBSYSTEM_DEF(mapping) var/obj/structure/overmap/OM = instance_overmap(config.ship_type) pass(OM) // Free boarding overmap/mining level - add_new_zlevel("Overmap treadmill [++world.maxz]", ZTRAITS_OVERMAP) - OM.free_treadmills += world.maxz + var/datum/space_level/overmap_z1 = add_new_zlevel("Overmap treadmill [length(z_list)+1]", ZTRAITS_OVERMAP) + OM.free_treadmills += overmap_z1.z_value LoadStationRoomTemplates() LoadStationRooms() diff --git a/nsv13/code/__DEFINES/overmap.dm b/nsv13/code/__DEFINES/overmap.dm index 8bb8ce50961..b76e8577e0f 100644 --- a/nsv13/code/__DEFINES/overmap.dm +++ b/nsv13/code/__DEFINES/overmap.dm @@ -119,3 +119,6 @@ GLOBAL_LIST_INIT(overmap_impact_sounds, list('nsv13/sound/effects/ship/freespace #define SHIELD_ABSORB 1 //!Shield absorbed hit. #define SHIELD_FORCE_DEFLECT 2 //!Shield absorbed hit and is redirecting projectile with slightly turned vector. #define SHIELD_FORCE_REFLECT 3 //!Shield absorbed hit and is redirecting projectile in reverse direction. + +//Interior instancing comsig, aka cursed things. +#define COMSIG_INTERIOR_DONE_LOADING "interior_done_loading" diff --git a/nsv13/code/__HELPERS/overmap.dm b/nsv13/code/__HELPERS/overmap.dm index 39399783bc3..7d260c5f532 100644 --- a/nsv13/code/__HELPERS/overmap.dm +++ b/nsv13/code/__HELPERS/overmap.dm @@ -118,7 +118,17 @@ Another get_angle that works better with the looping edges of the overmap else if(CX<0) .+=360 +/** + * I am genuinely unsure what this is actually meant to do that normal z add does not do. +* If ANYONE actually knows if there is some important reason the procs I changed used this please tell me ~Delta +**/ /datum/controller/subsystem/mapping/proc/add_new_initialized_zlevel(name, traits = list(), z_type = /datum/space_level, orbital_body_type) add_new_zlevel(name, traits) SSatoms.InitializeAtoms(block(locate(1,1,world.maxz),locate(world.maxx,world.maxy,world.maxz))) setup_map_transitions(z_list[world.maxz]) +/** + * Generates a new z level with behavior specific to overmaps and returns its space level datum. + */ +/datum/controller/subsystem/mapping/proc/add_new_overmap_zlevel() + . = add_new_zlevel("Overmap treadmill [length(z_list)+1]", ZTRAITS_OVERMAP) + setup_map_transitions(.) diff --git a/nsv13/code/controllers/subsystem/starsystem.dm b/nsv13/code/controllers/subsystem/starsystem.dm index 51445fd48e5..624fd95c753 100644 --- a/nsv13/code/controllers/subsystem/starsystem.dm +++ b/nsv13/code/controllers/subsystem/starsystem.dm @@ -26,7 +26,13 @@ SUBSYSTEM_DEF(star_system) var/obj/structure/overmap/mining_ship = null //The mining ship var/saving = FALSE + ///Kind of cursed list that tracks which of our overmap interiors have been initialized yet. + var/list/overmap_interior_queue = list() //Ratvar save me from this. + ///Are we already busy? + var/initing_interior = FALSE + /datum/controller/subsystem/star_system/fire() //Overmap combat events control system, adds weight to combat events over time spent out of combat + handle_interior_inits() //Cursed. I don't like this. if(time_limit && world.time >= time_limit) var/datum/faction/winner = get_winner() if(istype(SSticker.mode, /datum/game_mode/pvp)) @@ -71,6 +77,25 @@ SUBSYSTEM_DEF(star_system) saving = FALSE . = ..() +///Absolutely cursed proc handling ship interior init queues. +/datum/controller/subsystem/star_system/proc/handle_interior_inits() + set waitfor = FALSE + if(initing_interior) + return + if(SSatoms.initialized_changed) + return + if(!length(overmap_interior_queue)) + return + initing_interior = TRUE + var/obj/structure/overmap/shipinterior_candidate = overmap_interior_queue[1] + shipinterior_candidate.instance_interior() + SEND_SIGNAL(shipinterior_candidate, COMSIG_INTERIOR_DONE_LOADING) + overmap_interior_queue -= shipinterior_candidate + initing_interior = FALSE + +/datum/controller/subsystem/star_system/proc/queue_for_interior_load(obj/structure/overmap/to_interior_load) + overmap_interior_queue += to_interior_load + /** Returns a faction datum by its name (case insensitive!) */ diff --git a/nsv13/code/modules/overmap/fighters/fighters_launcher.dm b/nsv13/code/modules/overmap/fighters/fighters_launcher.dm index 2417666ffec..47dffe75ee1 100644 --- a/nsv13/code/modules/overmap/fighters/fighters_launcher.dm +++ b/nsv13/code/modules/overmap/fighters/fighters_launcher.dm @@ -346,14 +346,27 @@ d) the ships[] list of ssstarsystem is acting up again. return FALSE if(istype(OM, /obj/structure/overmap/asteroid)) var/obj/structure/overmap/asteroid/AS = OM + if(AS.interior_status == INTERIOR_READY) + return transfer_from_overmap(AS) AS.interior_mode = INTERIOR_DYNAMIC // We don't actually want it to create one until we're ready but we do need entry points - AS.instance_interior() - AS.docking_points = AS.interior_entry_points - return transfer_from_overmap(OM) + DC.docking_cooldown = TRUE + RegisterSignal(AS, COMSIG_INTERIOR_DONE_LOADING, PROC_REF(on_dock_interior_load_finish)) + SSstar_system.queue_for_interior_load(AS) + return TRUE //We have to assume this will end up being a correct docking. if(mass < OM.mass) //If theyre bigger than us and have docking points, and we want to dock. return transfer_from_overmap(OM) return FALSE +///Listens for the interior loading to finish and finishes docking once it does. +/obj/structure/overmap/small_craft/proc/on_dock_interior_load_finish(obj/structure/overmap/docking_target) + SIGNAL_HANDLER + UnregisterSignal(docking_target, COMSIG_INTERIOR_DONE_LOADING) + docking_target.docking_points = docking_target.interior_entry_points + var/obj/item/fighter_component/docking_computer/DC = loadout.get_slot(HARDPOINT_SLOT_DOCKING) + if(DC) + DC.docking_cooldown = FALSE + INVOKE_ASYNC(src, PROC_REF(transfer_from_overmap), docking_target) + /obj/structure/overmap/small_craft/proc/transfer_from_overmap(obj/structure/overmap/OM) if(!length(OM.docking_points)) return FALSE diff --git a/nsv13/code/modules/overmap/overmap.dm b/nsv13/code/modules/overmap/overmap.dm index 6184028ce4e..2c5eba460a9 100644 --- a/nsv13/code/modules/overmap/overmap.dm +++ b/nsv13/code/modules/overmap/overmap.dm @@ -234,13 +234,15 @@ Proc to spool up a new Z-level for a player ship and assign it a treadmill. if(!_path) _path = /obj/structure/overmap/nanotrasen/heavy_cruiser/starter RETURN_TYPE(/obj/structure/overmap) - SSmapping.add_new_initialized_zlevel("Overmap ship level [++world.maxz]", ZTRAITS_OVERMAP) + var/datum/space_level/new_ship_z = SSmapping.add_new_zlevel("Overmap ship level [length(SSmapping.z_list)+1]", ZTRAITS_OVERMAP) + if(!folder || !interior_map_files) + SSmapping.setup_map_transitions(new_ship_z) //We usually recalculate transitions later, but not if there's no interior. repopulate_sorted_areas() - smooth_zlevel(world.maxz) - log_game("Z-level [world.maxz] loaded for overmap treadmills.") - var/turf/exit = get_turf(locate(round(world.maxx * 0.5, 1), round(world.maxy * 0.5, 1), world.maxz)) //Plop them bang in the center of the system. + smooth_zlevel(new_ship_z.z_value) + log_game("Z-level [new_ship_z.z_value] loaded for overmap treadmills.") + var/turf/exit = get_turf(locate(round(world.maxx * 0.5, 1), round(world.maxy * 0.5, 1), new_ship_z.z_value)) //Plop them bang in the center of the system. var/obj/structure/overmap/OM = new _path(exit) //Ship'll pick up the info it needs, so just domp eet at the exit turf. - OM.reserved_z = world.maxz + OM.reserved_z = new_ship_z.z_value OM.overmap_flags |= OVERMAP_FLAG_ZLEVEL_CARRIER OM.current_system = SSstar_system.find_system(OM) if(OM.role == MAIN_OVERMAP) //If we're the main overmap, we'll cheat a lil' and apply our status to all of the Zs under "station" @@ -444,12 +446,23 @@ Proc to spool up a new Z-level for a player ship and assign it a treadmill. interior_mode = (possible_interior_maps?.len) ? INTERIOR_EXCLUSIVE : NO_INTERIOR //Allows small ships to have a small interior. if(INTERIOR_DYNAMIC) - instance_interior() - post_load_interior() + RegisterSignal(src, COMSIG_INTERIOR_DONE_LOADING, PROC_REF(after_init_load_interior)) + SSstar_system.queue_for_interior_load(src) - apply_weapons() RegisterSignal(src, list(COMSIG_FTL_STATE_CHANGE, COMSIG_SHIP_KILLED), PROC_REF(dump_locks)) // Setup lockon handling //We have a lot of types but not that many weapons per ship, so let's just worry about the ones we do have + if(interior_mode != INTERIOR_DYNAMIC) + apply_weapons() + for(var/firemode = 1; firemode <= MAX_POSSIBLE_FIREMODE; firemode++) + var/datum/ship_weapon/SW = weapon_types[firemode] + if(istype(SW) && (SW.allowed_roles & OVERMAP_USER_ROLE_GUNNER)) + weapon_numkeys_map += firemode + +///Listens for when the interior is done initing and finishes up some variables when it is. +/obj/structure/overmap/proc/after_init_load_interior() + SIGNAL_HANDLER + UnregisterSignal(src, COMSIG_INTERIOR_DONE_LOADING) + apply_weapons() for(var/firemode = 1; firemode <= MAX_POSSIBLE_FIREMODE; firemode++) var/datum/ship_weapon/SW = weapon_types[firemode] if(istype(SW) && (SW.allowed_roles & OVERMAP_USER_ROLE_GUNNER)) @@ -972,8 +985,8 @@ Proc to spool up a new Z-level for a player ship and assign it a treadmill. return reserved_z if(ftl_drive) if(!free_treadmills?.len) - SSmapping.add_new_initialized_zlevel("Overmap treadmill [++world.maxz]", ZTRAITS_OVERMAP) - reserved_z = world.maxz + var/datum/space_level/new_level = SSmapping.add_new_overmap_zlevel() + reserved_z = new_level.z_value else var/_z = pick_n_take(free_treadmills) reserved_z = _z