mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-31 12:01:47 +00:00
* [s] Security vulnerability patch (#62568) About The Pull Request In my personal, subjective opinion; trialmins should not, in fact, be able to read and delete server/box configuration files on a whim. cl server: Patches multiple(?) arbitrary file related vulnerabilities /cl * [s] Security vulnerability patch Co-authored-by: TheFakeElon <59686430+TheFakeElon@users.noreply.github.com>
83 lines
2.4 KiB
Plaintext
83 lines
2.4 KiB
Plaintext
// How much "space" we give the edge of the map
|
|
GLOBAL_LIST_INIT(potentialRandomZlevels, generateMapList(filename = "[global.config.directory]/awaymissionconfig.txt"))
|
|
GLOBAL_LIST_INIT(potentialConfigRandomZlevels, generateConfigMapList(directory = "[global.config.directory]/away_missions/"))
|
|
|
|
/proc/createRandomZlevel(config_gateway = FALSE)
|
|
var/map
|
|
if(config_gateway && GLOB.potentialConfigRandomZlevels?.len)
|
|
map = pick_n_take(GLOB.potentialConfigRandomZlevels)
|
|
else if(GLOB.potentialRandomZlevels?.len)
|
|
map = pick_n_take(GLOB.potentialRandomZlevels)
|
|
else
|
|
return to_chat(world, span_boldannounce("No valid away mission files, loading aborted."))
|
|
to_chat(world, span_boldannounce("Loading away mission..."))
|
|
var/loaded = load_new_z_level(map, "Away Mission", config_gateway)
|
|
to_chat(world, span_boldannounce("Away mission [loaded ? "loaded" : "aborted due to errors"]."))
|
|
if(!loaded)
|
|
message_admins("Away mission [map] loading failed due to errors.")
|
|
log_admin("Away mission [map] loading failed due to errors.")
|
|
createRandomZlevel(config_gateway)
|
|
|
|
/obj/effect/landmark/awaystart
|
|
name = "away mission spawn"
|
|
desc = "Randomly picked away mission spawn points."
|
|
var/id
|
|
var/delay = TRUE // If the generated destination should be delayed by configured gateway delay
|
|
|
|
/obj/effect/landmark/awaystart/Initialize(mapload)
|
|
. = ..()
|
|
var/datum/gateway_destination/point/current
|
|
for(var/datum/gateway_destination/point/D in GLOB.gateway_destinations)
|
|
if(D.id == id)
|
|
current = D
|
|
if(!current)
|
|
current = new
|
|
current.id = id
|
|
if(delay)
|
|
current.wait = CONFIG_GET(number/gateway_delay)
|
|
GLOB.gateway_destinations += current
|
|
current.target_turfs += get_turf(src)
|
|
|
|
/obj/effect/landmark/awaystart/nodelay
|
|
delay = FALSE
|
|
|
|
/proc/generateMapList(filename)
|
|
. = list()
|
|
filename = "[global.config.directory]/[SANITIZE_FILENAME(filename)]"
|
|
var/list/Lines = world.file2list(filename)
|
|
|
|
if(!Lines.len)
|
|
return
|
|
for (var/t in Lines)
|
|
if (!t)
|
|
continue
|
|
|
|
t = trim(t)
|
|
if (length(t) == 0)
|
|
continue
|
|
else if (t[1] == "#")
|
|
continue
|
|
|
|
var/pos = findtext(t, " ")
|
|
var/name = null
|
|
|
|
if (pos)
|
|
name = lowertext(copytext(t, 1, pos))
|
|
|
|
else
|
|
name = lowertext(t)
|
|
|
|
if (!name)
|
|
continue
|
|
|
|
. += t
|
|
|
|
/proc/generateConfigMapList(directory)
|
|
var/list/config_maps = list()
|
|
var/list/maps = flist(directory)
|
|
for(var/map_file in maps)
|
|
if(!findtext(map_file, ".dmm"))
|
|
continue
|
|
config_maps += (directory + map_file)
|
|
return config_maps
|