mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Removes unnecessary, unused, and redundant helpers.
This commit is contained in:
@@ -2,11 +2,8 @@
|
||||
* 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 hexadecimal number string as input.
|
||||
@@ -133,10 +130,6 @@
|
||||
if (NORTHWEST) return 315
|
||||
if (SOUTHWEST) return 225
|
||||
|
||||
// Returns the angle in english
|
||||
/proc/angle2text(var/degree)
|
||||
return dir2text(angle2dir(degree))
|
||||
|
||||
// Converts a blend_mode constant to one acceptable to icon.Blend()
|
||||
/proc/blendMode2iconMode(blend_mode)
|
||||
switch (blend_mode)
|
||||
@@ -294,107 +287,6 @@
|
||||
return strtype
|
||||
return copytext(strtype, delim_pos)
|
||||
|
||||
// Concatenates a list of strings into a single string. A seperator may optionally be provided.
|
||||
/proc/list2text(list/ls, sep)
|
||||
if (ls.len <= 1) // Early-out code for empty or singleton lists.
|
||||
return ls.len ? ls[1] : ""
|
||||
|
||||
var/l = ls.len // Made local for sanic speed.
|
||||
var/i = 0 // Incremented every time a list index is accessed.
|
||||
|
||||
if (sep != null)
|
||||
// Macros expand to long argument lists like so: sep, ls[++i], sep, ls[++i], sep, ls[++i], etc...
|
||||
#define S1 sep, ls[++i]
|
||||
#define S4 S1, S1, S1, S1
|
||||
#define S16 S4, S4, S4, S4
|
||||
#define S64 S16, S16, S16, S16
|
||||
|
||||
. = "[ls[++i]]" // Make sure the initial element is converted to text.
|
||||
|
||||
// Having the small concatenations come before the large ones boosted speed by an average of at least 5%.
|
||||
if (l-1 & 0x01) // 'i' will always be 1 here.
|
||||
. = text("[][][]", ., S1) // Append 1 element if the remaining elements are not a multiple of 2.
|
||||
if (l-i & 0x02)
|
||||
. = text("[][][][][]", ., S1, S1) // Append 2 elements if the remaining elements are not a multiple of 4.
|
||||
if (l-i & 0x04)
|
||||
. = text("[][][][][][][][][]", ., S4) // And so on....
|
||||
if (l-i & 0x08)
|
||||
. = text("[][][][][][][][][][][][][][][][][]", ., S4, S4)
|
||||
if (l-i & 0x10)
|
||||
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S16)
|
||||
if (l-i & 0x20)
|
||||
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S16, S16)
|
||||
if (l-i & 0x40)
|
||||
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S64)
|
||||
while (l > i) // Chomp through the rest of the list, 128 elements at a time.
|
||||
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S64, S64)
|
||||
|
||||
#undef S64
|
||||
#undef S16
|
||||
#undef S4
|
||||
#undef S1
|
||||
else
|
||||
// Macros expand to long argument lists like so: ls[++i], ls[++i], ls[++i], etc...
|
||||
#define S1 ls[++i]
|
||||
#define S4 S1, S1, S1, S1
|
||||
#define S16 S4, S4, S4, S4
|
||||
#define S64 S16, S16, S16, S16
|
||||
|
||||
. = "[ls[++i]]" // Make sure the initial element is converted to text.
|
||||
|
||||
if (l-1 & 0x01) // 'i' will always be 1 here.
|
||||
. += S1 // Append 1 element if the remaining elements are not a multiple of 2.
|
||||
if (l-i & 0x02)
|
||||
. = text("[][][]", ., S1, S1) // Append 2 elements if the remaining elements are not a multiple of 4.
|
||||
if (l-i & 0x04)
|
||||
. = text("[][][][][]", ., S4) // And so on...
|
||||
if (l-i & 0x08)
|
||||
. = text("[][][][][][][][][]", ., S4, S4)
|
||||
if (l-i & 0x10)
|
||||
. = text("[][][][][][][][][][][][][][][][][]", ., S16)
|
||||
if (l-i & 0x20)
|
||||
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S16, S16)
|
||||
if (l-i & 0x40)
|
||||
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S64)
|
||||
while (l > i) // Chomp through the rest of the list, 128 elements at a time.
|
||||
. = text("[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]\
|
||||
[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]", ., S64, S64)
|
||||
|
||||
#undef S64
|
||||
#undef S16
|
||||
#undef S4
|
||||
#undef S1
|
||||
|
||||
// Converts a string into a list by splitting the string at each delimiter found. (discarding the seperator)
|
||||
/proc/text2list(text, delimiter="\n")
|
||||
var/delim_len = length(delimiter)
|
||||
if (delim_len < 1)
|
||||
return list(text)
|
||||
|
||||
. = list()
|
||||
var/last_found = 1
|
||||
var/found
|
||||
|
||||
do
|
||||
found = findtext(text, delimiter, last_found, 0)
|
||||
. += copytext(text, last_found, found)
|
||||
last_found = found + delim_len
|
||||
while (found)
|
||||
|
||||
/proc/type2parent(child)
|
||||
var/string_type = "[child]"
|
||||
var/last_slash = findlasttext(string_type, "/")
|
||||
|
||||
@@ -196,9 +196,6 @@ Turf and target are seperate in case you want to teleport some distance from a t
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/proc/sign(x)
|
||||
return x!=0?x/abs(x):0
|
||||
|
||||
/proc/getline(atom/M,atom/N)//Ultra-Fast Bresenham Line-Drawing Algorithm
|
||||
var/px=M.x //starting x
|
||||
var/py=M.y
|
||||
@@ -207,8 +204,8 @@ Turf and target are seperate in case you want to teleport some distance from a t
|
||||
var/dy=N.y-py
|
||||
var/dxabs=abs(dx)//Absolute value of x distance
|
||||
var/dyabs=abs(dy)
|
||||
var/sdx=sign(dx) //Sign of x distance (+ or -)
|
||||
var/sdy=sign(dy)
|
||||
var/sdx=SIGN(dx) //Sign of x distance (+ or -)
|
||||
var/sdy=SIGN(dy)
|
||||
var/x=dxabs>>1 //Counters for steps taken, setting to distance/2
|
||||
var/y=dyabs>>1 //Bit-shifting makes me l33t. It also makes getline() unnessecarrily fast.
|
||||
var/j //Generic integer for counting
|
||||
@@ -426,34 +423,6 @@ Turf and target are seperate in case you want to teleport some distance from a t
|
||||
else . = pick(ais)
|
||||
return .
|
||||
|
||||
/proc/get_sorted_mobs()
|
||||
var/list/old_list = getmobs()
|
||||
var/list/AI_list = list()
|
||||
var/list/Dead_list = list()
|
||||
var/list/keyclient_list = list()
|
||||
var/list/key_list = list()
|
||||
var/list/logged_list = list()
|
||||
for(var/named in old_list)
|
||||
var/mob/M = old_list[named]
|
||||
if(issilicon(M))
|
||||
AI_list |= M
|
||||
else if(isobserver(M) || M.stat == 2)
|
||||
Dead_list |= M
|
||||
else if(M.key && M.client)
|
||||
keyclient_list |= M
|
||||
else if(M.key)
|
||||
key_list |= M
|
||||
else
|
||||
logged_list |= M
|
||||
old_list.Remove(named)
|
||||
var/list/new_list = list()
|
||||
new_list += AI_list
|
||||
new_list += keyclient_list
|
||||
new_list += key_list
|
||||
new_list += logged_list
|
||||
new_list += Dead_list
|
||||
return new_list
|
||||
|
||||
//Returns a list of all mobs with their name
|
||||
/proc/getmobs()
|
||||
return observe_list_format(sortmobs())
|
||||
@@ -528,14 +497,6 @@ Turf and target are seperate in case you want to teleport some distance from a t
|
||||
return "[round((powerused * 0.000001),0.001)] MW"
|
||||
return "[round((powerused * 0.000000001),0.0001)] GW"
|
||||
|
||||
/proc/get_mob_by_ckey(key)
|
||||
if(!key)
|
||||
return
|
||||
var/list/mobs = sortmobs()
|
||||
for(var/mob/M in mobs)
|
||||
if(M.ckey == key)
|
||||
return M
|
||||
|
||||
//Forces a variable to be posative
|
||||
/proc/modulus(var/M)
|
||||
if(M >= 0)
|
||||
@@ -648,34 +609,6 @@ Turf and target are seperate in case you want to teleport some distance from a t
|
||||
cant_pass = 1
|
||||
return cant_pass
|
||||
|
||||
/proc/get_step_towards2(var/atom/ref , var/atom/trg)
|
||||
var/base_dir = get_dir(ref, get_step_towards(ref,trg))
|
||||
var/turf/temp = get_step_towards(ref,trg)
|
||||
|
||||
if(is_blocked_turf(temp))
|
||||
var/dir_alt1 = turn(base_dir, 90)
|
||||
var/dir_alt2 = turn(base_dir, -90)
|
||||
var/turf/turf_last1 = temp
|
||||
var/turf/turf_last2 = temp
|
||||
var/free_tile = null
|
||||
var/breakpoint = 0
|
||||
|
||||
while(!free_tile && breakpoint < 10)
|
||||
if(!is_blocked_turf(turf_last1))
|
||||
free_tile = turf_last1
|
||||
break
|
||||
if(!is_blocked_turf(turf_last2))
|
||||
free_tile = turf_last2
|
||||
break
|
||||
turf_last1 = get_step(turf_last1,dir_alt1)
|
||||
turf_last2 = get_step(turf_last2,dir_alt2)
|
||||
breakpoint++
|
||||
|
||||
if(!free_tile) return get_step(ref, base_dir)
|
||||
else return get_step_towards(ref,free_tile)
|
||||
|
||||
else return get_step(ref, base_dir)
|
||||
|
||||
//Takes: Anything that could possibly have variables and a varname to check.
|
||||
//Returns: 1 if found, 0 if not.
|
||||
/proc/hasvar(var/datum/A, var/varname)
|
||||
@@ -693,20 +626,6 @@ Turf and target are seperate in case you want to teleport some distance from a t
|
||||
/proc/return_sorted_areas()
|
||||
return sortTim(return_areas(), /proc/cmp_text_asc)
|
||||
|
||||
//Takes: Area type as text string or as typepath OR an instance of the area.
|
||||
//Returns: A list of all areas of that type in the world.
|
||||
/proc/get_areas(var/areatype)
|
||||
if(!areatype) return null
|
||||
if(istext(areatype)) areatype = text2path(areatype)
|
||||
if(isarea(areatype))
|
||||
var/area/areatemp = areatype
|
||||
areatype = areatemp.type
|
||||
|
||||
var/list/areas = new/list()
|
||||
for(var/area/N in world)
|
||||
if(istype(N, areatype)) areas += N
|
||||
return areas
|
||||
|
||||
//Takes: Area type as text string or as typepath OR an instance of the area.
|
||||
//Returns: A list of all turfs in areas of that type of that type in the world.
|
||||
/proc/get_area_turfs(var/areatype)
|
||||
@@ -1021,10 +940,6 @@ Turf and target are seperate in case you want to teleport some distance from a t
|
||||
var/dy = abs(B.y - A.y)
|
||||
return get_dir(A, B) & (rand() * (dx+dy) < dy ? 3 : 12)
|
||||
|
||||
//chances are 1:value. anyprob(1) will always return true
|
||||
/proc/anyprob(value)
|
||||
return (rand(1,value)==value)
|
||||
|
||||
/proc/view_or_range(distance = world.view , center = usr , type)
|
||||
switch(type)
|
||||
if("view")
|
||||
@@ -1033,14 +948,6 @@ Turf and target are seperate in case you want to teleport some distance from a t
|
||||
. = range(distance,center)
|
||||
return
|
||||
|
||||
/proc/oview_or_orange(distance = world.view , center = usr , type)
|
||||
switch(type)
|
||||
if("view")
|
||||
. = oview(distance,center)
|
||||
if("range")
|
||||
. = orange(distance,center)
|
||||
return
|
||||
|
||||
/proc/get_mob_with_client_list()
|
||||
var/list/mobs = list()
|
||||
for(var/mob/M in mob_list)
|
||||
@@ -1162,16 +1069,6 @@ var/global/list/common_tools = list(
|
||||
istype(W, /obj/item/weapon/shovel) \
|
||||
)
|
||||
|
||||
/proc/is_surgery_tool(obj/item/W as obj)
|
||||
return ( \
|
||||
istype(W, /obj/item/weapon/surgical/scalpel) || \
|
||||
istype(W, /obj/item/weapon/surgical/hemostat) || \
|
||||
istype(W, /obj/item/weapon/surgical/retractor) || \
|
||||
istype(W, /obj/item/weapon/surgical/cautery) || \
|
||||
istype(W, /obj/item/weapon/surgical/bonegel) || \
|
||||
istype(W, /obj/item/weapon/surgical/bonesetter)
|
||||
)
|
||||
|
||||
// check if mob is lying down on something we can operate him on.
|
||||
// The RNG with table/rollerbeds comes into play in do_surgery() so that fail_step() can be used instead.
|
||||
/proc/can_operate(mob/living/carbon/M)
|
||||
@@ -1184,29 +1081,13 @@ var/global/list/common_tools = list(
|
||||
var/obj/surface = null
|
||||
for(var/obj/O in loc) // Looks for the best surface.
|
||||
if(O.surgery_odds)
|
||||
if(!surface || surface.surgery_odds < O)
|
||||
if(!surface || surface.surgery_odds < O.surgery_odds)
|
||||
surface = O
|
||||
if(surface)
|
||||
return surface
|
||||
|
||||
/proc/reverse_direction(var/dir)
|
||||
switch(dir)
|
||||
if(NORTH)
|
||||
return SOUTH
|
||||
if(NORTHEAST)
|
||||
return SOUTHWEST
|
||||
if(EAST)
|
||||
return WEST
|
||||
if(SOUTHEAST)
|
||||
return NORTHWEST
|
||||
if(SOUTH)
|
||||
return NORTH
|
||||
if(SOUTHWEST)
|
||||
return NORTHEAST
|
||||
if(WEST)
|
||||
return EAST
|
||||
if(NORTHWEST)
|
||||
return SOUTHEAST
|
||||
return global.reverse_dir[dir]
|
||||
|
||||
/*
|
||||
Checks if that loc and dir has a item on the wall
|
||||
@@ -1323,16 +1204,12 @@ var/mob/dview/dview_mob = new
|
||||
living_mob_list -= src
|
||||
|
||||
/mob/dview/Destroy(var/force)
|
||||
crash_with("Attempt to delete the dview_mob: [log_info_line(src)]")
|
||||
stack_trace("Attempt to delete the dview_mob: [log_info_line(src)]")
|
||||
if (!force)
|
||||
return QDEL_HINT_LETMELIVE
|
||||
global.dview_mob = new
|
||||
return ..()
|
||||
|
||||
// call to generate a stack trace and print to runtime logs
|
||||
/proc/crash_with(msg)
|
||||
CRASH(msg)
|
||||
|
||||
/proc/screen_loc2turf(scr_loc, turf/origin)
|
||||
var/tX = splittext(scr_loc, ",")
|
||||
var/tY = splittext(tX[2], ":")
|
||||
@@ -1478,9 +1355,6 @@ var/mob/dview/dview_mob = new
|
||||
if(337.5)
|
||||
return "North-Northwest"
|
||||
|
||||
/proc/pass()
|
||||
return
|
||||
|
||||
/proc/pick_closest_path(value, list/matches = get_fancy_list_of_atom_types())
|
||||
if (value == FALSE) //nothing should be calling us with a number, so this is safe
|
||||
value = input(usr, "Enter type to find (blank for all, cancel to cancel)", "Search for type") as null|text
|
||||
|
||||
Reference in New Issue
Block a user