Files
Bubberstation/code/modules/capture_the_flag/ctf_map_loading.dm
NamelessFairy f7ce249cb0 CTF qol update for admins, map selection and admins can't render CTF unplayable by accident anymore. (#69710)
About The Pull Request

When CTF map unloading was originally created in had an unforeseen consequence of not entirely removing parts of the ongoing CTF round, namely the flags, as a result of this, this system that was originally made as a precursor to map rotation was not really usable. Since this was added various PRs have made this more and less buggy but the recent CTF voting PR has caused unloading CTF rounds to be a one way process without far more involved admin intervention to reverse. As such, I've made the disable CTF buttons admins have access to only disable CTF and not unload the map entirely. I've left the function to unload the map in incase a situation arises where an admin or maintainer really needs to get rid of the CTF map.

Removing this functionality also removes a really clunky but theoretical function of it, being that you could repeatedly unload and reload the CTF map to get one of your choice, since this is not an option anymore this PR also allows admins to pick a CTF map when they start CTF themself.

EDIT: I fixed the bug introduced by the CTF voting PR, CTF maps can now be reloaded after being unloaded, the flag issue is still around so it shouldn't be used without admin supervision however. Also unloading is a debug verb now.
Why It's Good For The Game

Map unloading was super buggy so it shouldn't be easily accessible.
Since admins cannot repeatedly unload and reload CTF maps anymore to get the one they want they can now just pick the one they want from a list which is significantly less dumb.
Changelog

cl
admin: When admins start CTF they can now choose which map is played or choose random as its always been
admin: Admins can no-longer permanently break CTF by unloading the map accidentally
spellcheck: Fixed a typo in the Map Description for CTF Cruiser
fix: CTF can now be reloaded after being unloaded
/cl
2022-09-07 08:49:52 +12:00

92 lines
2.4 KiB
Plaintext

GLOBAL_DATUM(ctf_spawner, /obj/effect/landmark/ctf)
/obj/effect/landmark/ctf
name = "CTF Map Spawner"
var/list/map_bounds
/obj/effect/landmark/ctf/Initialize(mapload)
. = ..()
if(GLOB.ctf_spawner)
qdel(GLOB.ctf_spawner)
GLOB.ctf_spawner = src
/obj/effect/landmark/ctf/Destroy()
if(map_bounds)
for(var/turf/ctf_turf in block(
locate(
map_bounds[MAP_MINX],
map_bounds[MAP_MINY],
map_bounds[MAP_MINZ],
),
locate(
map_bounds[MAP_MAXX],
map_bounds[MAP_MAXY],
map_bounds[MAP_MAXZ],
)
))
ctf_turf.empty()
GLOB.ctf_spawner = null
return ..()
/obj/effect/landmark/ctf/proc/load_map(user)
if (map_bounds)
return
var/list/map_options = subtypesof(/datum/map_template/ctf)
var/turf/spawn_area = get_turf(src)
var/datum/map_template/ctf/current_map
var/chosen_map
if(user)
var/list/map_choices = list()
for(var/datum/map_template/ctf/map as anything in map_options)
var/mapname = initial(map.name)
map_choices[mapname] = map
chosen_map = tgui_input_list(user, "Select a map", "Choose CTF Map",list("Random")|sort_list(map_choices))
if (isnull(chosen_map))
return FALSE;
else
current_map = map_choices[chosen_map]
if(!user || chosen_map=="Random")
current_map = pick(map_options)
current_map = new current_map()
if(!spawn_area)
CRASH("No spawn area detected for CTF!")
else if(!current_map)
CRASH("No map prepared")
map_bounds = current_map.load(spawn_area, TRUE)
if(!map_bounds)
CRASH("Loading CTF map failed!")
return TRUE
/datum/map_template/ctf
var/description = ""
/datum/map_template/ctf/classic
name = "Classic"
description = "The original CTF map."
mappath = "_maps/map_files/CTF/classic.dmm"
/datum/map_template/ctf/four_side
name = "Four Side"
description = "A CTF map created to demonstrate 4 team CTF, features a single centred flag rather than one per team."
mappath = "_maps/map_files/CTF/fourSide.dmm"
/datum/map_template/ctf/downtown
name = "Downtown"
description = "A CTF map that takes place in a terrestrial city."
mappath = "_maps/map_files/CTF/downtown.dmm"
/datum/map_template/ctf/limbo
name = "Limbo"
description = "A KOTH map that takes place in a wizard den with looping hallways"
mappath = "_maps/map_files/CTF/limbo.dmm"
/datum/map_template/ctf/cruiser
name = "Crusier"
description = "A CTF map that takes place across multiple space ships, one carrying a powerful device that can accelerate those who obtain it"
mappath = "_maps/map_files/CTF/cruiser.dmm"