Cleanup of proc/helpers.dm

Split a bunch of procs in helpers.dm into new files:
-helper_list
-helper_text
-helper_type2type

These files are sorted into groups internally. Hopefully people will make it easier for people to find useful procs.

I've added comments to a good chunk of these procs as well explaining what they do.

I've removed a few unused or unnecessary procs and fixed up a couple that were not working as intended.

I've also moved a mob proc 'get_equipped_items()' into mob/inventory.

All of the non-helper.dm files (besides mob/inventory.dm) are the result of fixing duplicate procs. It seems that there used to be text searching procs where one was case sensitive and one was not, and at some point someone removed the case-sensitivity of the case sensitive procs. I've re-added the case-sensitivity and as a result, I've had to go through extra files and ensure that they were calling the proper proc.


git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4341 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
johnsonmt88@gmail.com
2012-08-08 19:32:08 +00:00
parent 5dac189480
commit 0225ed33b7
13 changed files with 896 additions and 878 deletions

View File

@@ -309,20 +309,4 @@ proc/isInSight(var/atom/A, var/atom/B)
return 1
else
return 0
/*proc/doafterattack(obj/target , obj/source)
if (istype(target, /obj/item/weapon/storage/ ))
return 0
else if (locate (/obj/structure/table, source.loc))
return 0
else if (!istype(target.loc, /turf/))
return 0
else
return 1
{R}*/
return 0

View File

@@ -0,0 +1,259 @@
/*
* Holds procs to help with list operations
* Contains groups:
* Misc
* Sorting
*/
/*
* Misc
*/
//Returns a list in plain english as a string
/proc/english_list(var/list/input, nothing_text = "nothing", and_text = " and ", comma_text = ", ", final_comma_text = "," )
var/total = input.len
if (!total)
return "[nothing_text]"
else if (total == 1)
return "[input[1]]"
else if (total == 2)
return "[input[1]][and_text][input[2]]"
else
var/output = ""
var/index = 1
while (index < total)
if (index == total - 1)
comma_text = final_comma_text
output += "[input[index]][comma_text]"
index++
return "[output][and_text][input[index]]"
//Returns list element or null. Should prevent "index out of bounds" error.
proc/listgetindex(var/list/list,index)
if(istype(list) && list.len)
if(isnum(index))
if(InRange(index,1,list.len))
return list[index]
else if(index in list)
return list[index]
return
proc/islist(list/list)
if(istype(list))
return 1
return 0
//Return either pick(list) or null if list is not of type /list or is empty
proc/safepick(list/list)
if(!islist(list) || !list.len)
return
return pick(list)
//Checks if the list is empty
proc/isemptylist(list/list)
if(!list.len)
return 1
return 0
//Empties the list by setting the length to 0. Hopefully the elements get garbage collected
proc/clearlist(list/list)
if(istype(list))
list.len = 0
return
//Removes any null entries from the list
proc/listclearnulls(list/list)
if(istype(list))
while(null in list)
list -= null
return
/*
* Returns list containing all the entries from first list that are not present in second.
* If skiprep = 1, repeated elements are treated as one.
* If either of arguments is not a list, returns null
*/
/proc/difflist(var/list/first, var/list/second, var/skiprep=0)
if(!islist(first) || !islist(second))
return
var/list/result = new
if(skiprep)
for(var/e in first)
if(!(e in result) && !(e in second))
result += e
else
result = first - second
return result
/*
* Returns list containing entries that are in either list but not both.
* If skipref = 1, repeated elements are treated as one.
* If either of arguments is not a list, returns null
*/
/proc/uniquemergelist(var/list/first, var/list/second, var/skiprep=0)
if(!islist(first) || !islist(second))
return
var/list/result = new
if(skiprep)
result = difflist(first, second, skiprep)+difflist(second, first, skiprep)
else
result = first ^ second
return result
//Pretends to pick an element based on its weight but really just seems to pick a random element.
/proc/pickweight(list/L)
var/total = 0
var/item
for (item in L)
if (!L[item])
L[item] = 1
total += L[item]
total = rand(1, total)
for (item in L)
total -=L [item]
if (total <= 0)
return item
return null
//Pick a random element from the list and remove it from the list.
/proc/pick_n_take(list/listfrom)
if (listfrom.len > 0)
var/picked = pick(listfrom)
listfrom -= picked
return picked
return null
//Returns the top(last) element from the list and removes it from the list (typical stack function)
/proc/pop(list/listfrom)
if (listfrom.len > 0)
var/picked = listfrom[listfrom.len]
listfrom.len--
return picked
return null
/*
* Sorting
*/
//Reverses the order of items in the list (Turning a stack into a queue)
/proc/reverselist(var/list/input)
var/list/output = new/list()
for(var/A in input)
output += A
return output
//Randomize: Return the list in a random order
/proc/shuffle(var/list/shufflelist)
if(!shufflelist)
return
var/list/new_list = list()
var/list/old_list = shufflelist.Copy()
while(old_list.len)
var/item = pick(old_list)
new_list += item
old_list -= item
return new_list
//Return a list with no duplicate entries
/proc/uniquelist(var/list/L)
var/list/K = list()
for(var/item in L)
if(!(item in K))
K += item
return K
//Mergesort: divides up the list into halves to begin the sort
/proc/sortAtom(var/list/atom/L, var/order = 1)
if(isnull(L) || L.len < 2)
return L
var/middle = L.len / 2 + 1
return mergeAtoms(sortAtom(L.Copy(0,middle)), sortAtom(L.Copy(middle)), order)
//Mergsort: does the actual sorting and returns the results back to sortAtom
/proc/mergeAtoms(var/list/atom/L, var/list/atom/R, var/order = 1)
var/Li=1
var/Ri=1
var/list/result = new()
while(Li <= L.len && Ri <= R.len)
var/atom/rL = L[Li]
var/atom/rR = R[Ri]
if(sorttext(rL.name, rR.name) == order)
result += L[Li++]
else
result += R[Ri++]
if(Li <= L.len)
return (result + L.Copy(Li, 0))
return (result + R.Copy(Ri, 0))
//Mergesort: Specifically for record datums in a list.
/proc/sortRecord(var/list/datum/data/record/L, var/field = "name", var/order = 1)
if(isnull(L))
return list()
if(L.len < 2)
return L
var/middle = L.len / 2 + 1
return mergeRecordLists(sortRecord(L.Copy(0, middle), field, order), sortRecord(L.Copy(middle), field, order), field, order)
//Mergsort: does the actual sorting and returns the results back to sortRecord
/proc/mergeRecordLists(var/list/datum/data/record/L, var/list/datum/data/record/R, var/field = "name", var/order = 1)
var/Li=1
var/Ri=1
var/list/result = new()
if(!isnull(L) && !isnull(R))
while(Li <= L.len && Ri <= R.len)
var/datum/data/record/rL = L[Li]
if(isnull(rL))
L -= rL
continue
var/datum/data/record/rR = R[Ri]
if(isnull(rR))
R -= rR
continue
if(sorttext(rL.fields[field], rR.fields[field]) == order)
result += L[Li++]
else
result += R[Ri++]
if(Li <= L.len)
return (result + L.Copy(Li, 0))
return (result + R.Copy(Ri, 0))
//Mergesort: any value in a list
/proc/sortList(var/list/L)
if(L.len < 2)
return L
var/middle = L.len / 2 + 1 // Copy is first,second-1
return mergeLists(sortList(L.Copy(0,middle)), sortList(L.Copy(middle))) //second parameter null = to end of list
//Mergsorge: uses sortList() but uses the var's name specifically. This should probably be using mergeAtom() instead
/proc/sortNames(var/list/L)
var/list/Q = new()
for(var/atom/x in L)
Q[x.name] = x
return sortList(Q)
/proc/mergeLists(var/list/L, var/list/R)
var/Li=1
var/Ri=1
var/list/result = new()
while(Li <= L.len && Ri <= R.len)
if(sorttext(L[Li], R[Ri]) < 1)
result += R[Ri++]
else
result += L[Li++]
if(Li <= L.len)
return (result + L.Copy(Li, 0))
return (result + R.Copy(Ri, 0))

View File

@@ -0,0 +1,288 @@
/*
* Holds procs designed to help with filtering text
* Contains groups:
* Text sanitization
* Text searches
* Text modification
* Misc
*/
/*
* Text sanitization
*/
//Simply removes < and > and limits the length of the message
/proc/strip_html_simple(var/t,var/limit=MAX_MESSAGE_LEN)
var/list/strip_chars = list("<",">")
t = copytext(t,1,limit)
for(var/char in strip_chars)
var/index = findtext(t, char)
while(index)
t = copytext(t, 1, index) + copytext(t, index+1)
index = findtext(t, char)
return t
//Removes a few problematic characters
/proc/sanitize_simple(var/t,var/list/repl_chars = list("\n"="#","\t"="#","<22>"="<22>"))
for(var/char in repl_chars)
var/index = findtext(t, char)
while(index)
t = copytext(t, 1, index) + repl_chars[char] + copytext(t, index+1)
index = findtext(t, char)
return t
//Runs byond's sanitization proc along-side sanitize_simple
/proc/sanitize(var/t,var/list/repl_chars = null)
return html_encode(sanitize_simple(t,repl_chars))
//Runs sanitize and strip_html_simple
//I believe strip_html_simple() is required to run first to prevent '<' from displaying as '&lt;' after sanitize() calls byond's html_encode()
/proc/strip_html(var/t,var/limit=MAX_MESSAGE_LEN)
return copytext((sanitize(strip_html_simple(t))),1,limit)
//Runs byond's sanitization proc along-side strip_html_simple
//I believe strip_html_simple() is required to run first to prevent '<' from displaying as '&lt;' that html_encode() would cause
/proc/adminscrub(var/t,var/limit=MAX_MESSAGE_LEN)
return copytext((html_encode(strip_html_simple(t))),1,limit)
//Returns null if there is any bad text in the string
/proc/reject_bad_text(var/text, var/max_length=512)
if(length(text) > max_length) return //message too long
var/non_whitespace = 0
for(var/i=1, i<=length(text), i++)
switch(text2ascii(text,i))
if(62,60,92,47) return //rejects the text if it contains these bad characters: <, >, \ or /
if(127 to 255) return //rejects weird letters like <20>
if(0 to 31) return //more weird stuff
if(32) continue //whitespace
else non_whitespace = 1
if(non_whitespace) return text //only accepts the text if it has some non-spaces
//Filters out undesirable characters from names
/proc/reject_bad_name(var/t_in, var/allow_numbers=0, var/max_length=MAX_NAME_LEN)
if(t_in == "" || length(t_in) > max_length)
return //Rejects the input if it is null or if it is longer then the max length allowed
var/number_of_alphanumeric = 0
var/last_char_group = 0
var/t_out = ""
for(var/i=1, i<=length(t_in), i++)
var/ascii_char = text2ascii(t_in,i)
switch(ascii_char)
// A .. Z
if(65 to 90) //Uppercase Letters
t_out += ascii2text(ascii_char)
number_of_alphanumeric++
last_char_group = 4
// a .. z
if(97 to 122) //Lowercase Letters
if(last_char_group<2) t_out += ascii2text(ascii_char-32) //Force uppercase first character
else t_out += ascii2text(ascii_char)
number_of_alphanumeric++
last_char_group = 4
// 0 .. 9
if(48 to 57) //Numbers
if(!last_char_group) continue //suppress at start of string
if(!allow_numbers) continue
t_out += ascii2text(ascii_char)
number_of_alphanumeric++
last_char_group = 3
// ' - .
if(39,45,46) //Common name punctuation
t_out += ascii2text(ascii_char)
last_char_group = 2
// ~ | @ : # $ % & * +
if(126,124,64,58,35,36,37,38,42,43) //Other symbols that we'll allow (mainly for AI)
if(!last_char_group) continue //suppress at start of string
if(!allow_numbers) continue
t_out += ascii2text(ascii_char)
last_char_group = 2
//Space
if(32)
if(last_char_group <= 1) continue //suppress double-spaces and spaces at start of string
t_out += ascii2text(ascii_char)
last_char_group = 1
else
return
if(number_of_alphanumeric < 2) return //protects against tiny names like "A" and also names like "' ' ' ' ' ' ' '"
trim_right(t_out)//Remove spaces from the end of the name.
return t_out
/*
* Text searches
*/
//Checks the beginning of a string for a specified sub-string
//Returns the position of the substring or 0 if it was not found
/proc/dd_hasprefix(text, prefix)
var/start = 1
var/end = length(prefix) + 1
return findtext(text, prefix, start, end)
//Checks the beginning of a string for a specified sub-string. This proc is case sensitive
//Returns the position of the substring or 0 if it was not found
/proc/dd_hasprefix_case(text, prefix)
var/start = 1
var/end = length(prefix) + 1
return findtextEx(text, prefix, start, end)
//Checks the end of a string for a specified substring.
//Returns the position of the substring or 0 if it was not found
/proc/dd_hassuffix(text, suffix)
var/start = length(text) - length(suffix)
if(start)
return findtext(text, suffix, start, null)
return
//Checks the end of a string for a specified substring. This proc is case sensitive
//Returns the position of the substring or 0 if it was not found
/proc/dd_hassuffix_case(text, suffix)
var/start = length(text) - length(suffix)
if(start)
return findtextEx(text, suffix, start, null)
/*
* Text modification
*/
//Search and replace a sub-string within a string
/proc/dd_replacetext(text, search_string, replacement_string)
if(!text || !istext(text) || !search_string || !istext(search_string) || !istext(replacement_string))
return null
var/textList = dd_text2list(text, search_string)
return dd_list2text(textList, replacement_string)
//Search and replace a case sensitive sub-string within a string
/proc/dd_replacetext_case(text, search_string, replacement_string)
var/textList = dd_text2list(text, search_string)
return dd_list2text(textList, replacement_string)
//Adds 'u' number of zeros ahead of the text 't'
/proc/add_zero(t, u)
while (length(t) < u)
t = "0[t]"
return t
//Adds 'u' number of spaces ahead of the text 't'
/proc/add_lspace(t, u)
while(length(t) < u)
t = " [t]"
return t
//Adds 'u' number of spaces behind the text 't'
/proc/add_tspace(t, u)
while(length(t) < u)
t = "[t] "
return t
//Returns a string with reserved characters and spaces before the first letter removed
/proc/trim_left(text)
for (var/i = 1 to length(text))
if (text2ascii(text, i) > 32)
return copytext(text, i)
return ""
//Returns a string with reserved characters and spaces after the last letter removed
/proc/trim_right(text)
for (var/i = length(text), i > 0, i--)
if (text2ascii(text, i) > 32)
return copytext(text, 1, i + 1)
return ""
//Returns a string with reserved characters and spaces before the first word and after the last word removed.
/proc/trim(text)
return trim_left(trim_right(text))
//Returns a string with the first element of the string capitalized.
/proc/capitalize(var/t as text)
return uppertext(copytext(t, 1, 2)) + copytext(t, 2)
//Centers text by adding spaces to either side of the string.
/proc/dd_centertext(message, length)
var/new_message = message
var/size = length(message)
var/delta = length - size
if(size == length)
return new_message
if(size > length)
return copytext(new_message, 1, length + 1)
if(delta == 1)
return new_message + " "
if(delta % 2)
new_message = " " + new_message
delta--
var/spaces = add_lspace("",delta/2-1)
return spaces + new_message + spaces
//Limits the length of the text. Note: MAX_MESSAGE_LEN and MAX_NAME_LEN are widely used for this purpose
/proc/dd_limittext(message, length)
var/size = length(message)
if(size <= length)
return message
return copytext(message, 1, length + 1)
/*
* Misc
*/
/proc/stringsplit(txt, character)
var/cur_text = txt
var/last_found = 1
var/found_char = findtext(cur_text,character)
var/list/list = list()
if(found_char)
var/fs = copytext(cur_text,last_found,found_char)
list += fs
last_found = found_char+length(character)
found_char = findtext(cur_text,character,last_found)
while(found_char)
var/found_string = copytext(cur_text,last_found,found_char)
last_found = found_char+length(character)
list += found_string
found_char = findtext(cur_text,character,last_found)
list += copytext(cur_text,last_found,length(cur_text)+1)
return list
/proc/stringmerge(var/text,var/compare,replace = "*")
//This proc fills in all spaces with the "replace" var (* by default) with whatever
//is in the other string at the same spot (assuming it is not a replace char).
//This is used for fingerprints
var/newtext = text
if(lentext(text) != lentext(compare))
return 0
for(var/i = 1, i < lentext(text), i++)
var/a = copytext(text,i,i+1)
var/b = copytext(compare,i,i+1)
//if it isn't both the same letter, or if they are both the replacement character
//(no way to know what it was supposed to be)
if(a != b)
if(a == replace) //if A is the replacement char
newtext = copytext(newtext,1,i) + b + copytext(newtext, i+1)
else if(b == replace) //if B is the replacement char
newtext = copytext(newtext,1,i) + a + copytext(newtext, i+1)
else //The lists disagree, Uh-oh!
return 0
return newtext
/proc/stringpercent(var/text,character = "*")
//This proc returns the number of chars of the string that is the character
//This is used for detective work to determine fingerprint completion.
if(!text || !character)
return 0
var/count = 0
for(var/i = 1, i <= lentext(text), i++)
var/a = copytext(text,i,i+1)
if(a == character)
count++
return count

View File

@@ -0,0 +1,220 @@
/*
* Holds procs designed to change one type of value, into another.
* Contains:
* hex2num & num2hex
* text2list & list2text
* file2list
* angle2dir
* angle2text
* worldtime2text
*/
//Returns an integer given a hex input
/proc/hex2num(hex)
if (!( istext(hex) ))
return
var/num = 0
var/power = 0
var/i = null
i = length(hex)
while(i > 0)
var/char = copytext(hex, i, i + 1)
switch(char)
if("0")
//Apparently, switch works with empty statements, yay! If that doesn't work, blame me, though. -- Urist
if("9", "8", "7", "6", "5", "4", "3", "2", "1")
num += text2num(char) * 16 ** power
if("a", "A")
num += 16 ** power * 10
if("b", "B")
num += 16 ** power * 11
if("c", "C")
num += 16 ** power * 12
if("d", "D")
num += 16 ** power * 13
if("e", "E")
num += 16 ** power * 14
if("f", "F")
num += 16 ** power * 15
else
return
power++
i--
return num
//Returns the hex value of a number given a value assumed to be a base-ten value
/proc/num2hex(num, placeholder)
if (placeholder == null)
placeholder = 2
if (!( isnum(num) ))
return
if (!( num ))
return "0"
var/hex = ""
var/i = 0
while(16 ** i < num)
i++
var/power = null
power = i - 1
while(power >= 0)
var/val = round(num / 16 ** power)
num -= val * 16 ** power
switch(val)
if(9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 0.0)
hex += text("[]", val)
if(10.0)
hex += "A"
if(11.0)
hex += "B"
if(12.0)
hex += "C"
if(13.0)
hex += "D"
if(14.0)
hex += "E"
if(15.0)
hex += "F"
else
power--
while(length(hex) < placeholder)
hex = text("0[]", hex)
return hex
//Text 'text' will be added as elements of a list when seperated by 'seperator'
/proc/dd_text2list(text, separator, var/list/withinList)
var/textlength = length(text)
var/separatorlength = length(separator)
if(withinList && !withinList.len) withinList = null
var/list/textList = new()
var/searchPosition = 1
var/findPosition = 1
var/loops = 999
while(loops) //Byond will think 1000+ iterations of a loop is an infinite loop
findPosition = findtext(text, separator, searchPosition, 0)
var/buggyText = copytext(text, searchPosition, findPosition)
if(!withinList || (buggyText in withinList)) textList += "[buggyText]"
if(!findPosition) return textList
searchPosition = findPosition + separatorlength
if(searchPosition > textlength)
textList += ""
return textList
loops--
return
//Text 'text' will be added as elements of a list when seperated by 'seperator'. The separator is case sensitive.
/proc/dd_text2list_case(text, separator, var/list/withinList)
var/textlength = length(text)
var/separatorlength = length(separator)
if(withinList && !withinList.len) withinList = null
var/list/textList = new()
var/searchPosition = 1
var/findPosition = 1
var/loops = 999
while(loops) //Byond will think 1000+ iterations of a loop is an infinite loop
findPosition = findtextEx(text, separator, searchPosition, 0)
var/buggyText = copytext(text, searchPosition, findPosition)
if(!withinList || (buggyText in withinList)) textList += "[buggyText]"
if(!findPosition) return textList
searchPosition = findPosition + separatorlength
if(searchPosition > textlength)
textList += ""
return textList
loops--
return
//Attaches each element of a list to a single string seperated by 'seperator'.
/proc/dd_list2text(var/list/the_list, separator)
var/total = the_list.len
if(!total)
return
var/count = 2
var/newText = "[the_list[1]]"
while(count <= total)
if(separator)
newText += separator
newText += "[the_list[count]]"
count++
return newText
//tg_text2list is faster then dd_text2list
//not case sensitive version
proc/tg_text2list(string, separator=",")
if(!string)
return
var/list/output = new
var/seplength = length(separator)
var/strlength = length(string)
var/prev = 1
var/index
do
index = findtext(string, separator, prev, 0)
output += copytext(string, prev, index)
if(!index)
break
prev = index+seplength
if(prev>strlength)
break
while(index)
return output
//case sensitive version
proc/tg_text2list_case(string, separator=",")
if(!string)
return
var/list/output = new
var/seplength = length(separator)
var/strlength = length(string)
var/prev = 1
var/index
do
index = findtextEx(string, separator, prev, 0)
output += copytext(string, prev, index)
if(!index)
break
prev = index+seplength
if(prev>strlength)
break
while(index)
return output
//slower then dd_list2text, but correctly processes associative lists.
proc/tg_list2text(list/list, glue=",")
if(!istype(list) || !list.len)
return
var/output
for(var/i=1 to list.len)
output += (i!=1? glue : null)+(!isnull(list["[list[i]]"])?"[list["[list[i]]"]]":"[list[i]]")
return output
//Gets a file and adds its contents to a list.
/proc/dd_file2list(file_path, separator)
var/file
if(separator == null)
separator = "\n"
if(isfile(file_path))
file = file_path
else
file = file(file_path)
return dd_text2list(file2text(file), separator)
//Converts an angle (degrees) into an ss13 direction
/proc/angle2dir(var/degree)
degree = ((degree+22.5)%365)
if(degree < 45) return NORTH
if(degree < 90) return NORTH|EAST
if(degree < 135) return EAST
if(degree < 180) return SOUTH|EAST
if(degree < 225) return SOUTH
if(degree < 270) return SOUTH|WEST
if(degree < 315) return WEST
return NORTH|WEST
//Returns the angle in english
/proc/angle2text(var/degree)
return dir2text(angle2dir(degree))
//Returns the world time in english
proc/worldtime2text()
return "[round(world.time / 36000)+12]:[(world.time / 600 % 60) < 10 ? add_zero(world.time / 600 % 60, 1) : world.time / 600 % 60]"

File diff suppressed because it is too large Load Diff

View File

@@ -39,7 +39,7 @@
codes = new()
var/list/entries = dd_text2List(codes_txt, ";") // entries are separated by semicolons
var/list/entries = dd_text2list(codes_txt, ";") // entries are separated by semicolons
for(var/e in entries)
var/index = findtext(e, "=") // format is "key=value"

View File

@@ -13,13 +13,13 @@
/obj/machinery/vending/New()
..()
spawn(4)
src.slogan_list = dd_text2List(src.product_slogans, ";")
var/list/temp_paths = dd_text2List(src.product_paths, ";")
var/list/temp_amounts = dd_text2List(src.product_amounts, ";")
var/list/temp_hidden = dd_text2List(src.product_hidden, ";")
var/list/temp_hideamt = dd_text2List(src.product_hideamt, ";")
var/list/temp_coin = dd_text2List(src.product_coin, ";")
var/list/temp_coin_amt = dd_text2List(src.product_coin_amt, ";")
src.slogan_list = dd_text2list(src.product_slogans, ";")
var/list/temp_paths = dd_text2list(src.product_paths, ";")
var/list/temp_amounts = dd_text2list(src.product_amounts, ";")
var/list/temp_hidden = dd_text2list(src.product_hidden, ";")
var/list/temp_hideamt = dd_text2list(src.product_hideamt, ";")
var/list/temp_coin = dd_text2list(src.product_coin, ";")
var/list/temp_coin_amt = dd_text2list(src.product_coin_amt, ";")
//Little sanity check here
if ((isnull(temp_paths)) || (isnull(temp_amounts)) || (temp_paths.len != temp_amounts.len) || (temp_hidden.len != temp_hideamt.len))
stat |= BROKEN

View File

@@ -10,9 +10,9 @@ var/global/BSACooldown = 0
if (C)
var/msg = rendered
if (admin_ref)
msg = dd_replaceText(msg, "%admin_ref%", "\ref[C]")
msg = dd_replacetext(msg, "%admin_ref%", "\ref[C]")
if (admin_holder_ref && C.holder)
msg = dd_replaceText(msg, "%holder_ref%", "\ref[C.holder]")
msg = dd_replacetext(msg, "%holder_ref%", "\ref[C.holder]")
C << msg

View File

@@ -25,9 +25,9 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an", "monkey", "ali
var/original_msg = msg
//The symbol <20> (fancy multiplication sign) will be used to mark where to put replacements, so the original message must not contain it.
msg = dd_replaceText(msg, "<22>", "")
msg = dd_replaceText(msg, "HOLDERREF", "HOLDER-REF") //HOLDERREF is a key word which gets replaced with the admin's holder ref later on, so it mustn't be in the original message
msg = dd_replaceText(msg, "ADMINREF", "ADMIN-REF") //ADMINREF is a key word which gets replaced with the admin's client's ref. So it mustn't be in the original message.
msg = dd_replacetext(msg, "<22>", "")
msg = dd_replacetext(msg, "HOLDERREF", "HOLDER-REF") //HOLDERREF is a key word which gets replaced with the admin's holder ref later on, so it mustn't be in the original message
msg = dd_replacetext(msg, "ADMINREF", "ADMIN-REF") //ADMINREF is a key word which gets replaced with the admin's client's ref. So it mustn't be in the original message.
var/list/msglist = dd_text2list(msg, " ")
@@ -50,14 +50,14 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an", "monkey", "ali
for(var/i = 1; i <= msglist.len; i++)
var/word = msglist[i]
var/original_word = word
word = dd_replaceText(word, ".", "")
word = dd_replaceText(word, ",", "")
word = dd_replaceText(word, "!", "")
word = dd_replaceText(word, "?", "") //Strips some common punctuation characters so the actual word can be better compared.
word = dd_replaceText(word, ";", "")
word = dd_replaceText(word, ":", "")
word = dd_replaceText(word, "(", "")
word = dd_replaceText(word, ")", "")
word = dd_replacetext(word, ".", "")
word = dd_replacetext(word, ",", "")
word = dd_replacetext(word, "!", "")
word = dd_replacetext(word, "?", "") //Strips some common punctuation characters so the actual word can be better compared.
word = dd_replacetext(word, ";", "")
word = dd_replacetext(word, ":", "")
word = dd_replacetext(word, "(", "")
word = dd_replacetext(word, ")", "")
if(lowertext(word) in adminhelp_ignored_words)
continue
if(lowertext(word) == "ai")
@@ -104,8 +104,8 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an", "monkey", "ali
check_laws_text = (" (<A HREF='?src=\ref[X.holder];adminchecklaws=[ref_mob]'>CL</A>)")
var/msg_to_send = "\blue <b><font color=red>HELP: </font>[key_name(src, X)] (<A HREF='?src=\ref[X.holder];adminmoreinfo=[ref_mob]'>?</A>) (<A HREF='?src=\ref[X.holder];adminplayeropts=[ref_mob]'>PP</A>) (<A HREF='?src=\ref[X.holder];adminplayervars=[ref_mob]'>VV</A>) (<A HREF='?src=\ref[X.holder];adminplayersubtlemessage=[ref_mob]'>SM</A>) (<A HREF='?src=\ref[X.holder];adminplayerobservejump=[ref_mob]'>JMP</A>) (<A HREF='?src=\ref[X.holder];secretsadmin=check_antagonist'>CA</A>) [check_laws_text]:</b> [msg]"
msg_to_send = dd_replaceText(msg_to_send, "HOLDERREF", "\ref[X.holder]")
msg_to_send = dd_replaceText(msg_to_send, "ADMINREF", "\ref[X]")
msg_to_send = dd_replacetext(msg_to_send, "HOLDERREF", "\ref[X.holder]")
msg_to_send = dd_replacetext(msg_to_send, "ADMINREF", "\ref[X]")
X << msg_to_send
else
var/ref_client = "\ref[src]"
@@ -117,8 +117,8 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an", "monkey", "ali
if(X.sound_adminhelp)
X << 'adminhelp.ogg'
var/msg_to_send = "\blue <b><font color=red>HELP: </font>[key_name(src, X)] (<A HREF='?src=\ref[X.holder];adminplayervars=[ref_client]'>VV</A>) (<A HREF='?src=\ref[X.holder];secretsadmin=check_antagonist'>CA</A>):</b> [msg]"
msg_to_send = dd_replaceText(msg_to_send, "HOLDERREF", "\ref[X.holder]")
msg_to_send = dd_replaceText(msg_to_send, "ADMINREF", "\ref[X]")
msg_to_send = dd_replacetext(msg_to_send, "HOLDERREF", "\ref[X.holder]")
msg_to_send = dd_replacetext(msg_to_send, "ADMINREF", "\ref[X]")
X << msg_to_send
src << "<font color='blue'>PM to-<b>Admins</b>: [original_msg]</font>"

View File

@@ -180,3 +180,26 @@
O.layer = initial(O.layer)
O.screen_loc = null
return 1
//Outdated but still in use apparently. This should at least be a human proc.
/mob/proc/get_equipped_items()
var/list/items = new/list()
if(hasvar(src,"back")) if(src:back) items += src:back
if(hasvar(src,"belt")) if(src:belt) items += src:belt
if(hasvar(src,"ears")) if(src:ears) items += src:ears
if(hasvar(src,"glasses")) if(src:glasses) items += src:glasses
if(hasvar(src,"gloves")) if(src:gloves) items += src:gloves
if(hasvar(src,"head")) if(src:head) items += src:head
if(hasvar(src,"shoes")) if(src:shoes) items += src:shoes
if(hasvar(src,"wear_id")) if(src:wear_id) items += src:wear_id
if(hasvar(src,"wear_mask")) if(src:wear_mask) items += src:wear_mask
if(hasvar(src,"wear_suit")) if(src:wear_suit) items += src:wear_suit
// if(hasvar(src,"w_radio")) if(src:w_radio) items += src:w_radio commenting this out since headsets go on your ears now PLEASE DON'T BE MAD KEELIN
if(hasvar(src,"w_uniform")) if(src:w_uniform) items += src:w_uniform
//if(hasvar(src,"l_hand")) if(src:l_hand) items += src:l_hand
//if(hasvar(src,"r_hand")) if(src:r_hand) items += src:r_hand
return items

View File

@@ -18,7 +18,7 @@
if(src.mutantrace == "lizard")
if(copytext(message, 1, 2) != "*")
message = dd_replaceText(message, "s", stutter("ss"))
message = dd_replacetext(message, "s", stutter("ss"))
if(src.mutantrace == "metroid" && prob(5))
if(copytext(message, 1, 2) != "*")
@@ -81,37 +81,37 @@
temp_message[H] = ninjaspeak(temp_message[H])
pick_list -= H
message = dd_list2text(temp_message, " ")
message = dd_replaceText(message, "o", "<22>")
message = dd_replaceText(message, "p", "<22>")
message = dd_replaceText(message, "l", "<22>")
message = dd_replaceText(message, "s", "<22>")
message = dd_replaceText(message, "u", "<22>")
message = dd_replaceText(message, "b", "<22>")
message = dd_replacetext(message, "o", "<22>")
message = dd_replacetext(message, "p", "<22>")
message = dd_replacetext(message, "l", "<22>")
message = dd_replacetext(message, "s", "<22>")
message = dd_replacetext(message, "u", "<22>")
message = dd_replacetext(message, "b", "<22>")
/*This text is hilarious but also absolutely retarded.
message = dd_replaceText(message, "l", "r")
message = dd_replaceText(message, "rr", "ru")
message = dd_replaceText(message, "v", "b")
message = dd_replaceText(message, "f", "hu")
message = dd_replaceText(message, "'t", "")
message = dd_replaceText(message, "t ", "to ")
message = dd_replaceText(message, " I ", " ai ")
message = dd_replaceText(message, "th", "z")
message = dd_replaceText(message, "ish", "isu")
message = dd_replaceText(message, "is", "izu")
message = dd_replaceText(message, "ziz", "zis")
message = dd_replaceText(message, "se", "su")
message = dd_replaceText(message, "br", "bur")
message = dd_replaceText(message, "ry", "ri")
message = dd_replaceText(message, "you", "yuu")
message = dd_replaceText(message, "ck", "cku")
message = dd_replaceText(message, "eu", "uu")
message = dd_replaceText(message, "ow", "au")
message = dd_replaceText(message, "are", "aa")
message = dd_replaceText(message, "ay", "ayu")
message = dd_replaceText(message, "ea", "ii")
message = dd_replaceText(message, "ch", "chi")
message = dd_replaceText(message, "than", "sen")
message = dd_replaceText(message, ".", "")
message = dd_replacetext(message, "l", "r")
message = dd_replacetext(message, "rr", "ru")
message = dd_replacetext(message, "v", "b")
message = dd_replacetext(message, "f", "hu")
message = dd_replacetext(message, "'t", "")
message = dd_replacetext(message, "t ", "to ")
message = dd_replacetext(message, " I ", " ai ")
message = dd_replacetext(message, "th", "z")
message = dd_replacetext(message, "ish", "isu")
message = dd_replacetext(message, "is", "izu")
message = dd_replacetext(message, "ziz", "zis")
message = dd_replacetext(message, "se", "su")
message = dd_replacetext(message, "br", "bur")
message = dd_replacetext(message, "ry", "ri")
message = dd_replacetext(message, "you", "yuu")
message = dd_replacetext(message, "ck", "cku")
message = dd_replacetext(message, "eu", "uu")
message = dd_replacetext(message, "ow", "au")
message = dd_replacetext(message, "are", "aa")
message = dd_replacetext(message, "ay", "ayu")
message = dd_replacetext(message, "ea", "ii")
message = dd_replacetext(message, "ch", "chi")
message = dd_replacetext(message, "than", "sen")
message = dd_replacetext(message, ".", "")
message = lowertext(message)
*/
..(message)

View File

@@ -48,12 +48,12 @@
temp_message[H] = ninjaspeak(temp_message[H])
pick_list -= H
message = dd_list2text(temp_message, " ")
message = dd_replaceText(message, "o", "<22>")
message = dd_replaceText(message, "p", "<22>")
message = dd_replaceText(message, "l", "<22>")
message = dd_replaceText(message, "s", "<22>")
message = dd_replaceText(message, "u", "<22>")
message = dd_replaceText(message, "b", "<22>")
message = dd_replacetext(message, "o", "<22>")
message = dd_replacetext(message, "p", "<22>")
message = dd_replacetext(message, "l", "<22>")
message = dd_replacetext(message, "s", "<22>")
message = dd_replacetext(message, "u", "<22>")
message = dd_replacetext(message, "b", "<22>")
if (src.stuttering)
message = stutter(message)

View File

@@ -83,7 +83,6 @@
#define FILE_DIR "code/game/vehicles/airtight"
#define FILE_DIR "code/game/verbs"
#define FILE_DIR "code/js"
#define FILE_DIR "code/liquid"
#define FILE_DIR "code/modules"
#define FILE_DIR "code/modules/admin"
#define FILE_DIR "code/modules/admin/DB ban"
@@ -190,7 +189,6 @@
#define FILE_DIR "icons/vending_icons"
#define FILE_DIR "interface"
#define FILE_DIR "maps"
#define FILE_DIR "maps/backup"
#define FILE_DIR "maps/RandomZLevels"
#define FILE_DIR "sound"
#define FILE_DIR "sound/AI"
@@ -337,6 +335,9 @@
#include "code\defines\procs\forum_activation.dm"
#include "code\defines\procs\gamehelpers.dm"
#include "code\defines\procs\global_lists.dm"
#include "code\defines\procs\helper_list.dm"
#include "code\defines\procs\helper_text.dm"
#include "code\defines\procs\helper_type2type.dm"
#include "code\defines\procs\helpers.dm"
#include "code\defines\procs\icon_procs.dm"
#include "code\defines\procs\icon_procs_readme.dm"