Merge remote-tracking branch 'ParadiseSS13/master' into toml-config

This commit is contained in:
AffectedArc07
2021-06-03 18:10:19 +01:00
117 changed files with 12076 additions and 18356 deletions
+51 -41
View File
@@ -358,61 +358,69 @@ GLOBAL_DATUM_INIT(_preloader, /datum/dmm_suite/preloader, new())
/datum/dmm_suite/proc/readlist(text, delimiter = ",")
var/list/to_return = list()
var/position
var/delimiter_position
var/old_position = 1
do
// find next delimiter that is not within "..."
position = find_next_delimiter_position(text, old_position, delimiter)
delimiter_position = find_next_delimiter_position(text, old_position, delimiter)
// check if this is a simple variable (as in list(var1, var2)) or an associative one (as in list(var1="foo", var2=7))
var/equal_position = findtext(text, "=", old_position, position)
var/equal_position = findtext(text, "=", old_position, delimiter_position)
var/trim_left = trim_text(copytext(text, old_position, (equal_position ? equal_position : position)), 1) // the name of the variable, must trim quotes to build a BYOND compliant associatives list
old_position = position + 1
// Take the left value of the association or just the value if it isn't an association
var/left_value = copytext(text, old_position, (equal_position ? equal_position : delimiter_position))
old_position = delimiter_position + 1
if(equal_position) // associative var, so do the association
var/trim_right = trim_text(copytext(text, equal_position + 1, position)) // the content of the variable
left_value = trim_text(left_value, TRUE) // the name of the variable, must trim quotes to build a BYOND compliant associatives list
var/trim_right = trim_text(copytext(text, equal_position + 1, delimiter_position)) // the content of the variable
// Check for string
// Make it read to the next delimiter, instead of the quote
if(findtext(trim_right, quote, 1, 2))
var/endquote = findtext(trim_right, quote, -1)
if(!endquote)
log_runtime(EXCEPTION("Terminating quote not found!"), src)
// Our map writer escapes quotes and curly brackets to avoid
// letting our simple parser choke on meanly-crafted names/etc
// - so we decode it here so it's back to good ol' legibility
trim_right = dmm_decode(copytext(trim_right, 2, endquote))
// Check for number
else if(isnum(text2num(trim_right)))
trim_right = text2num(trim_right)
// Check for null
else if(trim_right == "null")
trim_right = null
// Check for list
else if(copytext(trim_right, 1, 5) == "list")
trim_right = readlist(copytext(trim_right, 6, length(trim_right)))
// Check for file
else if(copytext(trim_right, 1, 2) == "'")
trim_right = file(copytext(trim_right, 2, length(trim_right)))
// Check for path
else if(ispath(text2path(trim_right)))
trim_right = text2path(trim_right)
to_return[trim_left] = trim_right
to_return[left_value] = parse_value(trim_right)
else// simple var
to_return[trim_left] = null
to_return += parse_value(trim_text(left_value)) // Don't trim the quotes
while(position != 0)
while(delimiter_position != 0)
return to_return
/**
* Tries to parse the given value_text. Will fallback on the value_text as a string if it fails
*/
/datum/dmm_suite/proc/parse_value(value_text)
// Check for string
// Make it read to the next delimiter, instead of the quote
if(findtext(value_text, quote, 1, 2))
var/endquote = findtext(value_text, quote, -1)
if(!endquote)
stack_trace("Terminating quote not found!")
// Our map writer escapes quotes and curly brackets to avoid
// letting our simple parser choke on meanly-crafted names/etc
// - so we decode it here so it's back to good ol' legibility
. = dmm_decode(copytext(value_text, 2, endquote))
// Check for number
else if(isnum(text2num(value_text)))
. = text2num(value_text)
// Check for null
else if(value_text == "null")
. = null
// Check for list
else if(copytext(value_text, 1, 5) == "list")
. = readlist(copytext(value_text, 6, length(value_text)))
// Check for file
else if(copytext(value_text, 1, 2) == "'")
. = file(copytext(value_text, 2, length(value_text)))
// Check for path
else if(ispath(text2path(value_text)))
. = text2path(value_text)
else
. = value_text // Assume it is a string without quotes
/datum/dmm_suite/Destroy()
..()
@@ -475,7 +483,9 @@ GLOBAL_DATUM_INIT(_preloader, /datum/dmm_suite/preloader, new())
if(initial(A.there_can_be_many))
area_list[A] = new A
else
area_list[A] = locate(A)
if(!GLOB.all_unique_areas[A])
GLOB.all_unique_areas[A] = new A // No locate here else it will find a subtype of the one we're looking for
area_list[A] = GLOB.all_unique_areas[A]
return area_list[A]