Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitize empty values in file2list() #1201

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions code/__HELPERS/type2type.dm
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,16 @@
return num_list

//Splits the text of a file at seperator and returns them in a list.
/proc/file2list(filename, seperator="\n")
return splittext(return_file_text(filename),seperator)

/proc/file2list(filename, seperator = "\n", no_empty = TRUE)
var/list/result = list()
for(var/line in splittext(return_file_text(filename), seperator))
var/text = trim(line)
if(no_empty && !text)
continue
result += text
return result

//Turns a direction into text

/proc/num2dir(direction)
switch(direction)
if(1.0) return NORTH
Expand Down
Loading