diff --git a/code/__DEFINES/say.dm b/code/__DEFINES/say.dm index 53776c278b5..cbecdce670a 100644 --- a/code/__DEFINES/say.dm +++ b/code/__DEFINES/say.dm @@ -7,7 +7,7 @@ #define LANGUAGE_EXTENSION "language specific" //Message modes. Each one defines a radio channel, more or less. -//if you use ! as a mode key for some ungodly reason, change the first character for ionnum() so get_message_mode() doesn't freak out with state law prompts - shiz. +//if you use ! as a mode key for some ungodly reason, change the first character for ion_num() so get_message_mode() doesn't freak out with state law prompts - shiz. #define MODE_HEADSET "headset" #define MODE_ROBOT "robot" diff --git a/code/__DEFINES/turfs.dm b/code/__DEFINES/turfs.dm index 048c81f12c1..73a36c5b2aa 100644 --- a/code/__DEFINES/turfs.dm +++ b/code/__DEFINES/turfs.dm @@ -6,3 +6,16 @@ #define CHANGETURF_RECALC_ADJACENT 32 //Immediately recalc adjacent atmos turfs instead of queuing. #define IS_OPAQUE_TURF(turf) (turf.directional_opacity == ALL_CARDINALS) + +//supposedly the fastest way to do this according to https://gist.github.com/Giacom/be635398926bb463b42a +///Returns a list of turf in a square +#define RANGE_TURFS(RADIUS, CENTER) \ + block( \ + locate(max(CENTER.x-(RADIUS),1), max(CENTER.y-(RADIUS),1), CENTER.z), \ + locate(min(CENTER.x+(RADIUS),world.maxx), min(CENTER.y+(RADIUS),world.maxy), CENTER.z) \ + ) + +///Returns all turfs in a zlevel +#define Z_TURFS(ZLEVEL) block(locate(1,1,ZLEVEL), locate(world.maxx, world.maxy, ZLEVEL)) + +#define TURF_FROM_COORDS_LIST(List) (locate(List[1], List[2], List[3])) diff --git a/code/__HELPERS/_lists.dm b/code/__HELPERS/_lists.dm index 175157130e2..faebf2299c0 100644 --- a/code/__HELPERS/_lists.dm +++ b/code/__HELPERS/_lists.dm @@ -618,3 +618,13 @@ ? right_list.Copy()\ : null\ ) + +///Returns a list with items filtered from a list that can call callback +/proc/special_list_filter(list/list_to_filter, datum/callback/condition) + if(!islist(list_to_filter) || !length(list_to_filter) || !istype(condition)) + return list() + . = list() + for(var/i in list_to_filter) + if(condition.Invoke(i)) + . |= i + diff --git a/code/__HELPERS/areas.dm b/code/__HELPERS/areas.dm index 5bdbbd60186..6323f238844 100644 --- a/code/__HELPERS/areas.dm +++ b/code/__HELPERS/areas.dm @@ -103,3 +103,75 @@ GLOBAL_LIST_INIT(typecache_powerfailure_safe_areas, typecacheof(/area/engineerin return TRUE #undef BP_MAX_ROOM_SIZE + +//Repopulates sortedAreas list +/proc/repopulate_sorted_areas() + GLOB.sortedAreas = list() + + for(var/area/A in world) + GLOB.sortedAreas.Add(A) + + sortTim(GLOB.sortedAreas, /proc/cmp_name_asc) + +/area/proc/addSorted() + GLOB.sortedAreas.Add(src) + sortTim(GLOB.sortedAreas, /proc/cmp_name_asc) + +//Takes: Area type as a text string from a variable. +//Returns: Instance for the area in the world. +/proc/get_area_instance_from_text(areatext) + if(istext(areatext)) + areatext = text2path(areatext) + return GLOB.areas_by_type[areatext] + +//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(areatype, subtypes=TRUE) + if(istext(areatype)) + areatype = text2path(areatype) + else if(isarea(areatype)) + var/area/areatemp = areatype + areatype = areatemp.type + else if(!ispath(areatype)) + return null + + var/list/areas = list() + if(subtypes) + var/list/cache = typecacheof(areatype) + for(var/area/area_to_check as anything in GLOB.sortedAreas) + if(cache[area_to_check.type]) + areas += area_to_check + else + for(var/area/area_to_check as anything in GLOB.sortedAreas) + if(area_to_check.type == areatype) + areas += area_to_check + 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(areatype, target_z = 0, subtypes=FALSE) + if(istext(areatype)) + areatype = text2path(areatype) + else if(isarea(areatype)) + var/area/areatemp = areatype + areatype = areatemp.type + else if(!ispath(areatype)) + return null + + var/list/turfs = list() + if(subtypes) + var/list/cache = typecacheof(areatype) + for(var/area/area_to_check as anything in GLOB.sortedAreas) + if(!cache[area_to_check.type]) + continue + for(var/turf/turf_in_area in area_to_check) + if(target_z == 0 || target_z == turf_in_area.z) + turfs += turf_in_area + else + for(var/area/area_to_check as anything in GLOB.sortedAreas) + if(area_to_check.type != areatype) + continue + for(var/turf/turf_in_area in area_to_check) + if(target_z == 0 || target_z == turf_in_area.z) + turfs += turf_in_area + return turfs diff --git a/code/__HELPERS/atoms.dm b/code/__HELPERS/atoms.dm new file mode 100644 index 00000000000..3e81cd53190 --- /dev/null +++ b/code/__HELPERS/atoms.dm @@ -0,0 +1,301 @@ +///Returns the src and all recursive contents as a list. +/atom/proc/get_all_contents(ignore_flag_1) + . = list(src) + var/i = 0 + while(i < length(.)) + var/atom/checked_atom = .[++i] + if(checked_atom.flags_1 & ignore_flag_1) + continue + . += checked_atom.contents + +///identical to get_all_contents but returns a list of atoms of the type passed in the argument. +/atom/proc/get_all_contents_type(type) + var/list/processing_list = list(src) + . = list() + while(length(processing_list)) + var/atom/checked_atom = processing_list[1] + processing_list.Cut(1, 2) + processing_list += checked_atom.contents + if(istype(checked_atom, type)) + . += checked_atom + +///Like get_all_contents_type, but uses a typecache list as argument +/atom/proc/get_all_contents_ignoring(list/ignore_typecache) + if(!length(ignore_typecache)) + return get_all_contents() + var/list/processing = list(src) + . = list() + var/i = 0 + while(i < length(processing)) + var/atom/checked_atom = processing[++i] + if(ignore_typecache[checked_atom.type]) + continue + processing += checked_atom.contents + . += checked_atom + +///Step-towards method of determining whether one atom can see another. Similar to viewers() +/proc/can_see(atom/source, atom/target, length=5) // I couldnt be arsed to do actual raycasting :I This is horribly inaccurate. + var/turf/current = get_turf(source) + var/turf/target_turf = get_turf(target) + if(get_dist(source, target) > length) + return FALSE + var/steps = 1 + if(current == target_turf)//they are on the same turf, source can see the target + return TRUE + current = get_step_towards(current, target_turf) + while(current != target_turf) + if(steps > length) + return FALSE + if(IS_OPAQUE_TURF(current)) + return FALSE + current = get_step_towards(current, target_turf) + steps++ + return TRUE + +///Get the cardinal direction between two atoms +/proc/get_cardinal_dir(atom/start, atom/end) + var/dx = abs(end.x - start.x) + var/dy = abs(end.y - start.y) + return get_dir(start, end) & (rand() * (dx+dy) < dy ? 3 : 12) + +/** + * Finds the distance between two atoms, in pixels + * centered = FALSE counts from turf edge to edge + * centered = TRUE counts from turf center to turf center + * of course mathematically this is just adding world.icon_size on again +**/ +/proc/get_pixel_distance(atom/start, atom/end, centered = TRUE) + if(!istype(start) || !istype(end)) + return 0 + . = bounds_dist(start, end) + sqrt((((start.pixel_x + end.pixel_x) ** 2) + ((start.pixel_y + end.pixel_y) ** 2))) + if(centered) + . += world.icon_size + +///Check if there is already a wall item on the turf loc +/proc/got_wall_item(loc, dir, check_external = 0) + var/locdir = get_step(loc, dir) + for(var/obj/checked_object in loc) + if(is_type_in_typecache(checked_object, GLOB.WALLITEMS) && check_external != 2) + //Direction works sometimes + if(is_type_in_typecache(checked_object, GLOB.WALLITEMS_INVERSE)) + if(checked_object.dir == turn(dir, 180)) + return TRUE + else if(checked_object.dir == dir) + return TRUE + + //Some stuff doesn't use dir properly, so we need to check pixel instead + //That's exactly what get_turf_pixel() does + if(get_turf_pixel(checked_object) == locdir) + return TRUE + + if(is_type_in_typecache(checked_object, GLOB.WALLITEMS_EXTERNAL) && check_external) + if(is_type_in_typecache(checked_object, GLOB.WALLITEMS_INVERSE)) + if(checked_object.dir == turn(dir, 180)) + return TRUE + else if(checked_object.dir == dir) + return TRUE + + //Some stuff is placed directly on the wallturf (signs) + for(var/obj/checked_object in locdir) + if(is_type_in_typecache(checked_object, GLOB.WALLITEMS) && check_external != 2) + if(checked_object.pixel_x == 0 && checked_object.pixel_y == 0) + return TRUE + return FALSE + +///Forces the atom to take a step in a random direction +/proc/random_step(atom/movable/moving_atom, steps, chance) + var/initial_chance = chance + while(steps > 0) + if(prob(chance)) + step(moving_atom, pick(GLOB.alldirs)) + chance = max(chance - (initial_chance / steps), 0) + steps-- + +/** + * Compare source's dir, the clockwise dir of source and the anticlockwise dir of source + * To the opposite dir of the dir returned by get_dir(target,source) + * If one of them is a match, then source is facing target +**/ +/proc/is_source_facing_target(atom/source,atom/target) + if(!istype(source) || !istype(target)) + return FALSE + if(isliving(source)) + var/mob/living/source_mob = source + if(source_mob.body_position == LYING_DOWN) + return FALSE + var/goal_dir = get_dir(source, target) + var/clockwise_source_dir = turn(source.dir, -45) + var/anticlockwise_source_dir = turn(source.dir, 45) + + if(source.dir == goal_dir || clockwise_source_dir == goal_dir || anticlockwise_source_dir == goal_dir) + return TRUE + return FALSE + +/* +rough example of the "cone" made by the 3 dirs checked + +* \ +* \ +* > +* < +* \ +* \ +*B --><-- A +* / +* / +* < +* > +* / +* / + + +*/ + +///ultra range (no limitations on distance, faster than range for distances > 8); including areas drastically decreases performance +/proc/urange(dist = 0, atom/center = usr, orange = FALSE, areas = FALSE) + if(!dist) + if(!orange) + return list(center) + else + return list() + + var/list/turfs = RANGE_TURFS(dist, center) + if(orange) + turfs -= get_turf(center) + . = list() + for(var/turf/checked_turf as anything in turfs) + . += checked_turf + . += checked_turf.contents + if(areas) + . |= checked_turf.loc + +///similar function to range(), but with no limitations on the distance; will search spiralling outwards from the center +/proc/spiral_range(dist = 0, center = usr, orange = FALSE) + var/list/atom_list = list() + var/turf/t_center = get_turf(center) + if(!t_center) + return list() + + if(!orange) + atom_list += t_center + atom_list += t_center.contents + + if(!dist) + return atom_list + + + var/turf/checked_turf + var/y + var/x + var/c_dist = 1 + + + while( c_dist <= dist ) + y = t_center.y + c_dist + x = t_center.x - c_dist + 1 + for(x in x to t_center.x + c_dist) + checked_turf = locate(x, y, t_center.z) + if(checked_turf) + atom_list += checked_turf + atom_list += checked_turf.contents + + y = t_center.y + c_dist - 1 + x = t_center.x + c_dist + for(y in t_center.y - c_dist to y) + checked_turf = locate(x, y, t_center.z) + if(checked_turf) + atom_list += checked_turf + atom_list += checked_turf.contents + + y = t_center.y - c_dist + x = t_center.x + c_dist - 1 + for(x in t_center.x - c_dist to x) + checked_turf = locate(x, y, t_center.z) + if(checked_turf) + atom_list += checked_turf + atom_list += checked_turf.contents + + y = t_center.y - c_dist + 1 + x = t_center.x - c_dist + for(y in y to t_center.y + c_dist) + checked_turf = locate(x, y, t_center.z) + if(checked_turf) + atom_list += checked_turf + atom_list += checked_turf.contents + c_dist++ + + return atom_list + +///Returns the closest atom of a specific type in a list from a source +/proc/get_closest_atom(type, list/atom_list, source) + var/closest_atom + var/closest_distance + for(var/atom in atom_list) + if(!istype(atom, type)) + continue + var/distance = get_dist(source, atom) + if(!closest_atom) + closest_distance = distance + closest_atom = atom + else + if(closest_distance > distance) + closest_distance = distance + closest_atom = atom + return closest_atom + +///Returns a chosen path that is the closest to a list of matches +/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("Enter type to find (blank for all, cancel to cancel)", "Search for type") as null|text + if (isnull(value)) + return + value = trim(value) + + var/random = FALSE + if(findtext(value, "?")) + value = replacetext(value, "?", "") + random = TRUE + + if(!isnull(value) && value != "") + matches = filter_fancy_list(matches, value) + + if(matches.len==0) + return + + var/chosen + if(matches.len==1) + chosen = matches[1] + else if(random) + chosen = pick(matches) || null + else + chosen = input("Select a type", "Pick Type", matches[1]) as null|anything in sortList(matches) + if(!chosen) + return + chosen = matches[chosen] + return chosen + +///Creates new items inside an atom based on a list +/proc/generate_items_inside(list/items_list, where_to) + for(var/each_item in items_list) + for(var/i in 1 to items_list[each_item]) + new each_item(where_to) + +///Returns the atom type in the specified loc +/proc/get(atom/loc, type) + while(loc) + if(istype(loc, type)) + return loc + loc = loc.loc + return null + +///Returns true if the src countain the atom target +/atom/proc/contains(atom/target) + if(!target) + return FALSE + for(var/atom/location = target.loc, location, location = location.loc) + if(location == src) + return TRUE + +///A do nothing proc +/proc/pass(...) + return diff --git a/code/__HELPERS/clients.dm b/code/__HELPERS/clients.dm new file mode 100644 index 00000000000..3b61cf1e1c4 --- /dev/null +++ b/code/__HELPERS/clients.dm @@ -0,0 +1,12 @@ +///Returns whether or not a player is a guest using their ckey as an input +/proc/is_guest_key(key) + if(findtext(key, "Guest-", 1, 7) != 1) //was findtextEx + return FALSE + + var/i, ch, len = length(key) + + for(i = 7, i <= len, ++i) //we know the first 6 chars are Guest- + ch = text2ascii(key, i) + if (ch < 48 || ch > 57) //0-9 + return FALSE + return TRUE diff --git a/code/__HELPERS/colors.dm b/code/__HELPERS/colors.dm index 5847c30aff5..2fed8109779 100644 --- a/code/__HELPERS/colors.dm +++ b/code/__HELPERS/colors.dm @@ -17,3 +17,49 @@ final_color += copytext(color, digit, digit + 1) return final_color + +///Returns a random color picked from a list, has 2 modes (0 and 1), mode 1 doesn't pick white, black or gray +/proc/random_colour(mode = 0) + switch(mode) + if(0) + return pick("white","black","gray","red","green","blue","brown","yellow","orange","darkred", + "crimson","lime","darkgreen","cyan","navy","teal","purple","indigo") + if(1) + return pick("red","green","blue","brown","yellow","orange","darkred","crimson", + "lime","darkgreen","cyan","navy","teal","purple","indigo") + else + return "white" + +///Inverts the colour of an HTML string +/proc/invert_HTML_colour(HTMLstring) + if(!istext(HTMLstring)) + CRASH("Given non-text argument!") + else if(length(HTMLstring) != 7) + CRASH("Given non-HTML argument!") + else if(length_char(HTMLstring) != 7) + CRASH("Given non-hex symbols in argument!") + var/textr = copytext(HTMLstring, 2, 4) + var/textg = copytext(HTMLstring, 4, 6) + var/textb = copytext(HTMLstring, 6, 8) + return rgb(255 - hex2num(textr), 255 - hex2num(textg), 255 - hex2num(textb)) + +///Flash a color on the client +/proc/flash_color(mob_or_client, flash_color="#960000", flash_time=20) + var/client/flashed_client + if(ismob(mob_or_client)) + var/mob/client_mob = mob_or_client + if(client_mob.client) + flashed_client = client_mob.client + else + return + else if(istype(mob_or_client, /client)) + flashed_client = mob_or_client + + if(!istype(flashed_client)) + return + + var/animate_color = flashed_client.color + flashed_client.color = flash_color + animate(flashed_client, color = animate_color, time = flash_time) + +#define RANDOM_COLOUR (rgb(rand(0,255),rand(0,255),rand(0,255))) diff --git a/code/__HELPERS/datums.dm b/code/__HELPERS/datums.dm new file mode 100644 index 00000000000..7cf87c203b7 --- /dev/null +++ b/code/__HELPERS/datums.dm @@ -0,0 +1,9 @@ +///Check if a datum has not been deleted and is a valid source +/proc/is_valid_src(datum/source_datum) + if(istype(source_datum)) + return !QDELETED(source_datum) + return FALSE + +/proc/call_async(datum/source, proc_type, list/arguments) + set waitfor = FALSE + return call(source, proc_type)(arglist(arguments)) diff --git a/code/__HELPERS/game.dm b/code/__HELPERS/game.dm index 80c0fc93e19..fcb40a99341 100644 --- a/code/__HELPERS/game.dm +++ b/code/__HELPERS/game.dm @@ -1,13 +1,3 @@ -//supposedly the fastest way to do this according to https://gist.github.com/Giacom/be635398926bb463b42a -///Returns a list of turf in a square -#define RANGE_TURFS(RADIUS, CENTER) \ - block( \ - locate(max(CENTER.x-(RADIUS),1), max(CENTER.y-(RADIUS),1), CENTER.z), \ - locate(min(CENTER.x+(RADIUS),world.maxx), min(CENTER.y+(RADIUS),world.maxy), CENTER.z) \ - ) - -///Returns all turfs in a zlevel -#define Z_TURFS(ZLEVEL) block(locate(1,1,ZLEVEL), locate(world.maxx, world.maxy, ZLEVEL)) ///Time before being allowed to select a new cult leader again #define CULT_POLL_WAIT 240 SECONDS diff --git a/code/__HELPERS/global_lists.dm b/code/__HELPERS/global_lists.dm index d99e7003d85..3d3db534947 100644 --- a/code/__HELPERS/global_lists.dm +++ b/code/__HELPERS/global_lists.dm @@ -92,3 +92,45 @@ for(var/path as anything in subtypesof(prototype)) L[path] = new path() return L + +/** + * Checks if that loc and dir has an item on the wall +**/ +GLOBAL_LIST_INIT(WALLITEMS, typecacheof(list( + /obj/item/radio/intercom, + /obj/item/storage/secure/safe, + /obj/machinery/airalarm, + /obj/machinery/bounty_board, + /obj/machinery/button, + /obj/machinery/computer/security/telescreen, + /obj/machinery/computer/security/telescreen/entertainment, + /obj/machinery/door_timer, + /obj/machinery/embedded_controller/radio/simple_vent_controller, + /obj/machinery/firealarm, + /obj/machinery/flasher, + /obj/machinery/keycard_auth, + /obj/machinery/light_switch, + /obj/machinery/newscaster, + /obj/machinery/power/apc, + /obj/machinery/requests_console, + /obj/machinery/status_display, + /obj/structure/extinguisher_cabinet, + /obj/structure/fireaxecabinet, + /obj/structure/mirror, + /obj/structure/noticeboard, + /obj/structure/reagent_dispensers/peppertank, + /obj/structure/sign, + /obj/structure/sign/picture_frame + ))) + +GLOBAL_LIST_INIT(WALLITEMS_EXTERNAL, typecacheof(list( + /obj/machinery/camera, + /obj/machinery/light, + /obj/structure/camera_assembly, + /obj/structure/light_construct + ))) + +GLOBAL_LIST_INIT(WALLITEMS_INVERSE, typecacheof(list( + /obj/machinery/light, + /obj/structure/light_construct + ))) diff --git a/code/__HELPERS/guid.dm b/code/__HELPERS/guid.dm new file mode 100644 index 00000000000..49903cceb3c --- /dev/null +++ b/code/__HELPERS/guid.dm @@ -0,0 +1,19 @@ +/** + * returns a GUID like identifier (using a mostly made up record format) + * guids are not on their own suitable for access or security tokens, as most of their bits are predictable. + * (But may make a nice salt to one) +**/ +/proc/GUID() + var/const/GUID_VERSION = "b" + var/const/GUID_VARIANT = "d" + var/node_id = copytext_char(md5("[rand()*rand(1,9999999)][world.name][world.hub][world.hub_password][world.internet_address][world.address][world.contents.len][world.status][world.port][rand()*rand(1,9999999)]"), 1, 13) + + var/time_high = "[num2hex(text2num(time2text(world.realtime,"YYYY")), 2)][num2hex(world.realtime, 6)]" + + var/time_mid = num2hex(world.timeofday, 4) + + var/time_low = num2hex(world.time, 3) + + var/time_clock = num2hex(TICK_DELTA_TO_MS(world.tick_usage), 3) + + return "{[time_high]-[time_mid]-[GUID_VERSION][time_low]-[GUID_VARIANT][time_clock]-[node_id]}" diff --git a/code/__HELPERS/icons.dm b/code/__HELPERS/icons.dm index 09569413f2c..2a8cab89a70 100644 --- a/code/__HELPERS/icons.dm +++ b/code/__HELPERS/icons.dm @@ -1266,3 +1266,58 @@ GLOBAL_LIST_EMPTY(transformation_animation_objects) GLOB.transformation_animation_objects -= src if(filters && length(filters) >= filter_index) filters -= filters[filter_index] + +/** + * Center's an image. + * Requires: + * The Image + * The x dimension of the icon file used in the image + * The y dimension of the icon file used in the image + * eg: center_image(image_to_center, 32,32) + * eg2: center_image(image_to_center, 96,96) +**/ +/proc/center_image(image/image_to_center, x_dimension = 0, y_dimension = 0) + if(!image_to_center) + return + + if(!x_dimension || !y_dimension) + return + + if((x_dimension == world.icon_size) && (y_dimension == world.icon_size)) + return image_to_center + + //Offset the image so that it's bottom left corner is shifted this many pixels + //This makes it infinitely easier to draw larger inhands/images larger than world.iconsize + //but still use them in game + var/x_offset = -((x_dimension / world.icon_size) - 1) * (world.icon_size * 0.5) + var/y_offset = -((y_dimension / world.icon_size) - 1) * (world.icon_size * 0.5) + + //Correct values under world.icon_size + if(x_dimension < world.icon_size) + x_offset *= -1 + if(y_dimension < world.icon_size) + y_offset *= -1 + + image_to_center.pixel_x = x_offset + image_to_center.pixel_y = y_offset + + return image_to_center + +///Flickers an overlay on an atom +/proc/flick_overlay_static(overlay_image, atom/source, duration) + set waitfor = FALSE + if(!source || !overlay_image) + return + source.add_overlay(overlay_image) + sleep(duration) + source.cut_overlay(overlay_image) + +///Perform a shake on an atom, resets its position afterwards +/atom/proc/Shake(pixelshiftx = 15, pixelshifty = 15, duration = 250) + var/initialpixelx = pixel_x + var/initialpixely = pixel_y + var/shiftx = rand(-pixelshiftx,pixelshiftx) + var/shifty = rand(-pixelshifty,pixelshifty) + animate(src, pixel_x = pixel_x + shiftx, pixel_y = pixel_y + shifty, time = 0.2, loop = duration) + pixel_x = initialpixelx + pixel_y = initialpixely diff --git a/code/__HELPERS/maths.dm b/code/__HELPERS/maths.dm new file mode 100644 index 00000000000..5e1e3e76f67 --- /dev/null +++ b/code/__HELPERS/maths.dm @@ -0,0 +1,119 @@ +///Calculate the angle between two points and the west|east coordinate +/proc/get_angle(atom/movable/start, atom/movable/end)//For beams. + if(!start || !end) + return 0 + var/dy + var/dx + dy=(32 * end.y + end.pixel_y) - (32 * start.y + start.pixel_y) + dx=(32 * end.x + end.pixel_x) - (32 * start.x + start.pixel_x) + if(!dy) + return (dx >= 0) ? 90 : 270 + . = arctan(dx/dy) + if(dy < 0) + . += 180 + else if(dx < 0) + . += 360 + +///for getting the angle when animating something's pixel_x and pixel_y +/proc/get_pixel_angle(y, x) + if(!y) + return (x >= 0) ? 90 : 270 + . = arctan(x/y) + if(y < 0) + . += 180 + else if(x < 0) + . += 360 + +/** + * Get a list of turfs in a line from `starting_atom` to `ending_atom`. + * + * Uses the ultra-fast [Bresenham Line-Drawing Algorithm](https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm). + */ +/proc/get_line(atom/starting_atom, atom/ending_atom) + var/px = starting_atom.x //starting x + var/py = starting_atom.y + var/line[] = list(locate(px, py, starting_atom.z)) + var/dx = ending_atom.x - px //x distance + var/dy = ending_atom.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/x = dxabs >> 1 //Counters for steps taken, setting to distance/2 + var/y = dyabs >> 1 //Bit-shifting makes me l33t. It also makes get_line() unnessecarrily fast. + var/j //Generic integer for counting + if(dxabs >= dyabs) //x distance is greater than y + for(j = 0; j < dxabs; j++)//It'll take dxabs steps to get there + y += dyabs + if(y >= dxabs) //Every dyabs steps, step once in y direction + y -= dxabs + py += sdy + px += sdx //Step on in x direction + line += locate(px, py, starting_atom.z)//Add the turf to the list + else + for(j=0 ;j < dyabs; j++) + x += dxabs + if(x >= dyabs) + x -= dyabs + px += sdx + py += sdy + line += locate(px, py, starting_atom.z) + return line + +///Format a power value in W, kW, MW, or GW. +/proc/display_power(powerused) + if(powerused < 1000) //Less than a kW + return "[powerused] W" + else if(powerused < 1000000) //Less than a MW + return "[round((powerused * 0.001),0.01)] kW" + else if(powerused < 1000000000) //Less than a GW + return "[round((powerused * 0.000001),0.001)] MW" + return "[round((powerused * 0.000000001),0.0001)] GW" + +///Format an energy value in J, kJ, MJ, or GJ. 1W = 1J/s. +/proc/display_joules(units) + if (units < 1000) // Less than a kJ + return "[round(units, 0.1)] J" + else if (units < 1000000) // Less than a MJ + return "[round(units * 0.001, 0.01)] kJ" + else if (units < 1000000000) // Less than a GJ + return "[round(units * 0.000001, 0.001)] MJ" + return "[round(units * 0.000000001, 0.0001)] GJ" + +///Format an energy value measured in Power Cell units. +/proc/display_energy(units) + // APCs process every (SSmachines.wait * 0.1) seconds, and turn 1 W of + // excess power into watts when charging cells. + // With the current configuration of wait=20 and CELLRATE=0.002, this + // means that one unit is 1 kJ. + return display_joules(units * SSmachines.wait * 0.1 WATTS) + +///chances are 1:value. anyprob(1) will always return true +/proc/anyprob(value) + return (rand(1,value)==value) + +///counts the number of bits in Byond's 16-bit width field, in constant time and memory! +/proc/bit_count(bit_field) + var/temp = bit_field - ((bit_field >> 1) & 46811) - ((bit_field >> 2) & 37449) //0133333 and 0111111 respectively + temp = ((temp + (temp >> 3)) & 29127) % 63 //070707 + return temp + +/// Returns the name of the mathematical tuple of same length as the number arg (rounded down). +/proc/make_tuple(number) + var/static/list/units_prefix = list("", "un", "duo", "tre", "quattuor", "quin", "sex", "septen", "octo", "novem") + var/static/list/tens_prefix = list("", "decem", "vigin", "trigin", "quadragin", "quinquagin", "sexagin", "septuagin", "octogin", "nongen") + var/static/list/one_to_nine = list("monuple", "double", "triple", "quadruple", "quintuple", "sextuple", "septuple", "octuple", "nonuple") + number = round(number) + switch(number) + if(0) + return "empty tuple" + if(1 to 9) + return one_to_nine[number] + if(10 to 19) + return "[units_prefix[(number%10)+1]]decuple" + if(20 to 99) + return "[units_prefix[(number%10)+1]][tens_prefix[round((number % 100)/10)+1]]tuple" + if(100) + return "centuple" + else //It gets too tedious to use latin prefixes from here. + return "[number]-tuple" diff --git a/code/__HELPERS/mobs.dm b/code/__HELPERS/mobs.dm index 33ab6972cce..51d3d8a93d6 100644 --- a/code/__HELPERS/mobs.dm +++ b/code/__HELPERS/mobs.dm @@ -679,3 +679,198 @@ GLOBAL_LIST_EMPTY(species_list) /// Gets the client of the mob, allowing for mocking of the client. /// You only need to use this if you know you're going to be mocking clients somewhere else. #define GET_CLIENT(mob) (##mob.client || ##mob.mock_client) + +///Orders mobs by type then by name. Accepts optional arg to sort a custom list, otherwise copies GLOB.mob_list. +/proc/sort_mobs() + var/list/moblist = list() + var/list/sortmob = sortNames(GLOB.mob_list) + for(var/mob/living/silicon/ai/mob_to_sort in sortmob) + moblist += mob_to_sort + for(var/mob/camera/mob_to_sort in sortmob) + moblist += mob_to_sort + for(var/mob/living/silicon/pai/mob_to_sort in sortmob) + moblist += mob_to_sort + for(var/mob/living/silicon/robot/mob_to_sort in sortmob) + moblist += mob_to_sort + for(var/mob/living/carbon/human/mob_to_sort in sortmob) + moblist += mob_to_sort + for(var/mob/living/brain/mob_to_sort in sortmob) + moblist += mob_to_sort + for(var/mob/living/carbon/alien/mob_to_sort in sortmob) + moblist += mob_to_sort + for(var/mob/dead/observer/mob_to_sort in sortmob) + moblist += mob_to_sort + for(var/mob/dead/new_player/mob_to_sort in sortmob) + moblist += mob_to_sort + for(var/mob/living/simple_animal/slime/mob_to_sort in sortmob) + moblist += mob_to_sort + for(var/mob/living/simple_animal/mob_to_sort in sortmob) + // We've already added slimes. + if(isslime(mob_to_sort)) + continue + moblist += mob_to_sort + for(var/mob/living/basic/mob_to_sort in sortmob) + moblist += mob_to_sort + return moblist + +///returns a mob type controlled by a specified ckey +/proc/get_mob_by_ckey(key) + if(!key) + return + var/list/mobs = sort_mobs() + for(var/mob/mob in mobs) + if(mob.ckey == key) + return mob + +///Return a string for the specified body zone +/proc/parse_zone(zone) + if(zone == BODY_ZONE_PRECISE_R_HAND) + return "right hand" + else if (zone == BODY_ZONE_PRECISE_L_HAND) + return "left hand" + else if (zone == BODY_ZONE_L_ARM) + return "left arm" + else if (zone == BODY_ZONE_R_ARM) + return "right arm" + else if (zone == BODY_ZONE_L_LEG) + return "left leg" + else if (zone == BODY_ZONE_R_LEG) + return "right leg" + else if (zone == BODY_ZONE_PRECISE_L_FOOT) + return "left foot" + else if (zone == BODY_ZONE_PRECISE_R_FOOT) + return "right foot" + else + return zone + +///Returns the direction that the initiator and the target are facing +/proc/check_target_facings(mob/living/initiator, mob/living/target) + /*This can be used to add additional effects on interactions between mobs depending on how the mobs are facing each other, such as adding a crit damage to blows to the back of a guy's head. + Given how click code currently works (Nov '13), the initiating mob will be facing the target mob most of the time + That said, this proc should not be used if the change facing proc of the click code is overridden at the same time*/ + if(!isliving(target) || target.body_position == LYING_DOWN) + //Make sure we are not doing this for things that can't have a logical direction to the players given that the target would be on their side + return FALSE + if(initiator.dir == target.dir) //mobs are facing the same direction + return FACING_SAME_DIR + if(is_source_facing_target(initiator,target) && is_source_facing_target(target,initiator)) //mobs are facing each other + return FACING_EACHOTHER + if(initiator.dir + 2 == target.dir || initiator.dir - 2 == target.dir || initiator.dir + 6 == target.dir || initiator.dir - 6 == target.dir) //Initating mob is looking at the target, while the target mob is looking in a direction perpendicular to the 1st + return FACING_INIT_FACING_TARGET_TARGET_FACING_PERPENDICULAR + +///Returns the occupant mob or brain from a specified input +/proc/get_mob_or_brainmob(occupant) + var/mob/living/mob_occupant + + if(isliving(occupant)) + mob_occupant = occupant + + else if(isbodypart(occupant)) + var/obj/item/bodypart/head/head = occupant + + mob_occupant = head.brainmob + + else if(isorgan(occupant)) + var/obj/item/organ/brain/brain = occupant + mob_occupant = brain.brainmob + + return mob_occupant + +///Generalised helper proc for letting mobs rename themselves. Used to be clname() and ainame() +/mob/proc/apply_pref_name(preference_type, client/requesting_client) + if(!requesting_client) + requesting_client = client + var/oldname = real_name + var/newname + var/loop = 1 + var/safety = 0 + + var/random = CONFIG_GET(flag/force_random_names) || (requesting_client ? is_banned_from(requesting_client.ckey, "Appearance") : FALSE) + + while(loop && safety < 5) + if(!safety && !random) + newname = requesting_client?.prefs?.read_preference(preference_type) + else + var/datum/preference/preference = GLOB.preference_entries[preference_type] + newname = preference.create_informed_default_value(requesting_client.prefs) + + for(var/mob/living/checked_mob in GLOB.player_list) + if(checked_mob == src) + continue + if(!newname || checked_mob.real_name == newname) + newname = null + loop++ // name is already taken so we roll again + break + loop-- + safety++ + + if(newname) + fully_replace_character_name(oldname, newname) + return TRUE + return FALSE + +///Returns the amount of currently living players +/proc/living_player_count() + var/living_player_count = 0 + for(var/mob in GLOB.player_list) + if(mob in GLOB.alive_mob_list) + living_player_count += 1 + return living_player_count + +GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new) + +///Version of view() which ignores darkness, because BYOND doesn't have it (I actually suggested it but it was tagged redundant, BUT HEARERS IS A T- /rant). +/proc/dview(range = world.view, center, invis_flags = 0) + if(!center) + return + + GLOB.dview_mob.loc = center + + GLOB.dview_mob.see_invisible = invis_flags + + . = view(range, GLOB.dview_mob) + GLOB.dview_mob.loc = null + +/mob/dview + name = "INTERNAL DVIEW MOB" + invisibility = 101 + density = FALSE + see_in_dark = 1e6 + move_resist = INFINITY + var/ready_to_die = FALSE + +/mob/dview/Initialize(mapload) //Properly prevents this mob from gaining huds or joining any global lists + SHOULD_CALL_PARENT(FALSE) + if(flags_1 & INITIALIZED_1) + stack_trace("Warning: [src]([type]) initialized multiple times!") + flags_1 |= INITIALIZED_1 + return INITIALIZE_HINT_NORMAL + +/mob/dview/Destroy(force = FALSE) + if(!ready_to_die) + stack_trace("ALRIGHT WHICH FUCKER TRIED TO DELETE *MY* DVIEW?") + + if (!force) + return QDEL_HINT_LETMELIVE + + log_world("EVACUATE THE SHITCODE IS TRYING TO STEAL MUH JOBS") + GLOB.dview_mob = new + return ..() + + +#define FOR_DVIEW(type, range, center, invis_flags) \ + GLOB.dview_mob.loc = center; \ + GLOB.dview_mob.see_invisible = invis_flags; \ + for(type in view(range, GLOB.dview_mob)) + +#define FOR_DVIEW_END GLOB.dview_mob.loc = null + +///Makes a call in the context of a different usr. Use sparingly +/world/proc/push_usr(mob/user_mob, datum/callback/invoked_callback, ...) + var/temp = usr + usr = user_mob + if (length(args) > 2) + . = invoked_callback.Invoke(arglist(args.Copy(3))) + else + . = invoked_callback.Invoke() + usr = temp diff --git a/code/__HELPERS/randoms.dm b/code/__HELPERS/randoms.dm new file mode 100644 index 00000000000..7d425c70c88 --- /dev/null +++ b/code/__HELPERS/randoms.dm @@ -0,0 +1,46 @@ +///Get a random food item exluding the blocked ones +/proc/get_random_food() + var/list/blocked = list(/obj/item/food/bread, + /obj/item/food/breadslice, + /obj/item/food/cake, + /obj/item/food/cakeslice, + /obj/item/food/pie, + /obj/item/food/pieslice, + /obj/item/food/kebab, + /obj/item/food/pizza, + /obj/item/food/pizzaslice, + /obj/item/food/salad, + /obj/item/food/meat, + /obj/item/food/meat/slab, + /obj/item/food/soup, + /obj/item/food/grown, + /obj/item/food/grown/mushroom, + /obj/item/food/deepfryholder, + /obj/item/food/clothing, + /obj/item/food/meat/slab/human/mutant, + /obj/item/food/grown/ash_flora, + /obj/item/food/grown/nettle, + /obj/item/food/grown/shell + ) + + return pick(subtypesof(/obj/item/food) - blocked) + +///Gets a random drink excluding the blocked type +/proc/get_random_drink() + var/list/blocked = list( + /obj/item/reagent_containers/food/drinks/soda_cans, + /obj/item/reagent_containers/food/drinks/bottle + ) + return pick(subtypesof(/obj/item/reagent_containers/food/drinks) - blocked) + +///Picks a string of symbols to display as the law number for hacked or ion laws +/proc/ion_num() //! is at the start to prevent us from changing say modes via get_message_mode() + return "![pick("!","@","#","$","%","^","&")][pick("!","@","#","$","%","^","&","*")][pick("!","@","#","$","%","^","&","*")][pick("!","@","#","$","%","^","&","*")]" + +///Returns a string for a random nuke code +/proc/random_nukecode() + var/val = rand(0, 99999) + var/str = "[val]" + while(length(str) < 5) + str = "0" + str + . = str diff --git a/code/__HELPERS/ref.dm b/code/__HELPERS/ref.dm new file mode 100644 index 00000000000..4e787c88e1d --- /dev/null +++ b/code/__HELPERS/ref.dm @@ -0,0 +1,15 @@ +/** + * \ref behaviour got changed in 512 so this is necesary to replicate old behaviour. + * If it ever becomes necesary to get a more performant REF(), this lies here in wait + * #define REF(thing) (thing && istype(thing, /datum) && (thing:datum_flags & DF_USE_TAG) && thing:tag ? "[thing:tag]" : "\ref[thing]") +**/ +/proc/REF(input) + if(istype(input, /datum)) + var/datum/thing = input + if(thing.datum_flags & DF_USE_TAG) + if(!thing.tag) + stack_trace("A ref was requested of an object with DF_USE_TAG set but no tag: [thing]") + thing.datum_flags &= ~DF_USE_TAG + else + return "\[[url_encode(thing.tag)]\]" + return "\ref[input]" diff --git a/code/__HELPERS/spawns.dm b/code/__HELPERS/spawns.dm new file mode 100644 index 00000000000..da3d7c82642 --- /dev/null +++ b/code/__HELPERS/spawns.dm @@ -0,0 +1,43 @@ +/** + * One proc for easy spawning of pods in the code to drop off items before whizzling (please don't proc call this in game, it will destroy you) + * + * Arguments: + * * specifications: special mods to the pod, see non var edit specifications for details on what you should fill this with + * Non var edit specifications: + * * target = where you want the pod to drop + * * path = a special specific pod path if you want, this can save you a lot of var edits + * * style = style of the pod, defaults to the normal pod + * * spawn = spawned path or a list of the paths spawned, what you're sending basically + * Returns the pod spawned, in case you want to spawn items yourself and modify them before putting them in. + */ +/proc/podspawn(specifications) + //get non var edit specifications + var/turf/landing_location = specifications["target"] + var/spawn_type = specifications["path"] + var/style = specifications["style"] + var/list/paths_to_spawn = specifications["spawn"] + + //setup pod, add contents + if(!isturf(landing_location)) + landing_location = get_turf(landing_location) + if(!spawn_type) + spawn_type = /obj/structure/closet/supplypod/podspawn + var/obj/structure/closet/supplypod/podspawn/pod = new spawn_type(null, style) + if(paths_to_spawn && !islist(paths_to_spawn)) + paths_to_spawn = list(paths_to_spawn) + for(var/atom/path as anything in paths_to_spawn) + path = new path(pod) + + //remove non var edits from specifications + specifications -= "target" + specifications -= "style" + specifications -= "path" + specifications -= "spawn" //list, we remove the key + + //rest of specificiations are edits on the pod + for(var/variable_name in specifications) + var/variable_value = specifications[variable_name] + if(!pod.vv_edit_var(variable_name, variable_value)) + stack_trace("WARNING! podspawn vareditting \"[variable_name]\" to \"[variable_value]\" was rejected by the pod!") + new /obj/effect/pod_landingzone(landing_location, pod) + return pod diff --git a/code/__HELPERS/stack_trace.dm b/code/__HELPERS/stack_trace.dm new file mode 100644 index 00000000000..24851507a9b --- /dev/null +++ b/code/__HELPERS/stack_trace.dm @@ -0,0 +1,11 @@ +///gives us the stack trace from CRASH() without ending the current proc. +/proc/stack_trace(msg) + CRASH(msg) + +GLOBAL_REAL_VAR(list/stack_trace_storage) +/proc/gib_stack_trace() + stack_trace_storage = list() + stack_trace() + stack_trace_storage.Cut(1, min(3,stack_trace_storage.len)) + . = stack_trace_storage + stack_trace_storage = null diff --git a/code/__HELPERS/stoplag.dm b/code/__HELPERS/stoplag.dm new file mode 100644 index 00000000000..25fad12c71b --- /dev/null +++ b/code/__HELPERS/stoplag.dm @@ -0,0 +1,23 @@ +//Key thing that stops lag. Cornerstone of performance in ss13, Just sitting here, in unsorted.dm. Now with dedicated file! + +///Increases delay as the server gets more overloaded, as sleeps aren't cheap and sleeping only to wake up and sleep again is wasteful +#define DELTA_CALC max(((max(TICK_USAGE, world.cpu) / 100) * max(Master.sleep_delta-1,1)), 1) + +///returns the number of ticks slept +/proc/stoplag(initial_delay) + if (!Master || !(Master.current_runlevel & RUNLEVELS_DEFAULT)) + sleep(world.tick_lag) + return 1 + if (!initial_delay) + initial_delay = world.tick_lag + . = 0 + var/i = DS2TICKS(initial_delay) + do + . += CEILING(i * DELTA_CALC, 1) + sleep(i * world.tick_lag * DELTA_CALC) + i *= 2 + while (TICK_USAGE > min(TICK_LIMIT_TO_RUN, Master.current_ticklimit)) + +#undef DELTA_CALC + +#define UNTIL(X) while(!(X)) stoplag() diff --git a/code/__HELPERS/text.dm b/code/__HELPERS/text.dm index 9c5eb58ebb0..b4e69e9f48f 100644 --- a/code/__HELPERS/text.dm +++ b/code/__HELPERS/text.dm @@ -989,12 +989,12 @@ GLOBAL_LIST_INIT(binary, list("0","1")) return word + "ay" //otherwise unmutated return word - + /** * The procedure to check the text of the entered text on ntnrc_client.dm * - * This procedure is designed to check the text you type into the chat client. - * It checks for invalid characters and the size of the entered text. + * This procedure is designed to check the text you type into the chat client. + * It checks for invalid characters and the size of the entered text. */ /proc/reject_bad_chattext(text, max_length = 256) var/non_whitespace = FALSE @@ -1013,3 +1013,25 @@ GLOBAL_LIST_INIT(binary, list("0","1")) non_whitespace = TRUE if (non_whitespace) return text + +///Properly format a string of text by using replacetext() +/proc/format_text(text) + return replacetext(replacetext(text,"\proper ",""),"\improper ","") + +///Returns a string based on the weight class define used as argument +/proc/weight_class_to_text(w_class) + switch(w_class) + if(WEIGHT_CLASS_TINY) + . = "tiny" + if(WEIGHT_CLASS_SMALL) + . = "small" + if(WEIGHT_CLASS_NORMAL) + . = "normal-sized" + if(WEIGHT_CLASS_BULKY) + . = "bulky" + if(WEIGHT_CLASS_HUGE) + . = "huge" + if(WEIGHT_CLASS_GIGANTIC) + . = "gigantic" + else + . = "" diff --git a/code/__HELPERS/traits.dm b/code/__HELPERS/traits.dm new file mode 100644 index 00000000000..068b147b3d5 --- /dev/null +++ b/code/__HELPERS/traits.dm @@ -0,0 +1,30 @@ +#define TRAIT_CALLBACK_ADD(target, trait, source) CALLBACK(GLOBAL_PROC, /proc/___TraitAdd, ##target, ##trait, ##source) +#define TRAIT_CALLBACK_REMOVE(target, trait, source) CALLBACK(GLOBAL_PROC, /proc/___TraitRemove, ##target, ##trait, ##source) + +///DO NOT USE ___TraitAdd OR ___TraitRemove as a replacement for ADD_TRAIT / REMOVE_TRAIT defines. To be used explicitly for callback. +/proc/___TraitAdd(target,trait,source) + if(!target || !trait || !source) + return + if(islist(target)) + for(var/i in target) + if(!isatom(i)) + continue + var/atom/the_atom = i + ADD_TRAIT(the_atom,trait,source) + else if(isatom(target)) + var/atom/the_atom2 = target + ADD_TRAIT(the_atom2,trait,source) + +///DO NOT USE ___TraitAdd OR ___TraitRemove as a replacement for ADD_TRAIT / REMOVE_TRAIT defines. To be used explicitly for callback. +/proc/___TraitRemove(target,trait,source) + if(!target || !trait || !source) + return + if(islist(target)) + for(var/i in target) + if(!isatom(i)) + continue + var/atom/the_atom = i + REMOVE_TRAIT(the_atom,trait,source) + else if(isatom(target)) + var/atom/the_atom2 = target + REMOVE_TRAIT(the_atom2,trait,source) diff --git a/code/__HELPERS/turfs.dm b/code/__HELPERS/turfs.dm new file mode 100644 index 00000000000..5c81b6ddcd0 --- /dev/null +++ b/code/__HELPERS/turfs.dm @@ -0,0 +1,384 @@ +///Returns location. Returns null if no location was found. +/proc/get_teleport_loc(turf/location,mob/target,distance = 1, density = FALSE, errorx = 0, errory = 0, eoffsetx = 0, eoffsety = 0) +/* +Location where the teleport begins, target that will teleport, distance to go, density checking 0/1(yes/no). +Random error in tile placement x, error in tile placement y, and block offset. +Block offset tells the proc how to place the box. Behind teleport location, relative to starting location, forward, etc. +Negative values for offset are accepted, think of it in relation to North, -x is west, -y is south. Error defaults to positive. +Turf and target are separate in case you want to teleport some distance from a turf the target is not standing on or something. +*/ + + var/dirx = 0//Generic location finding variable. + var/diry = 0 + + var/xoffset = 0//Generic counter for offset location. + var/yoffset = 0 + + var/b1xerror = 0//Generic placing for point A in box. The lower left. + var/b1yerror = 0 + var/b2xerror = 0//Generic placing for point B in box. The upper right. + var/b2yerror = 0 + + errorx = abs(errorx)//Error should never be negative. + errory = abs(errory) + + switch(target.dir)//This can be done through equations but switch is the simpler method. And works fast to boot. + //Directs on what values need modifying. + if(1)//North + diry += distance + yoffset += eoffsety + xoffset += eoffsetx + b1xerror -= errorx + b1yerror -= errory + b2xerror += errorx + b2yerror += errory + if(2)//South + diry -= distance + yoffset -= eoffsety + xoffset += eoffsetx + b1xerror -= errorx + b1yerror -= errory + b2xerror += errorx + b2yerror += errory + if(4)//East + dirx += distance + yoffset += eoffsetx//Flipped. + xoffset += eoffsety + b1xerror -= errory//Flipped. + b1yerror -= errorx + b2xerror += errory + b2yerror += errorx + if(8)//West + dirx -= distance + yoffset -= eoffsetx//Flipped. + xoffset += eoffsety + b1xerror -= errory//Flipped. + b1yerror -= errorx + b2xerror += errory + b2yerror += errorx + + var/turf/destination = locate(location.x+dirx,location.y+diry,location.z) + + if(!destination)//If there isn't a destination. + return + + if(!errorx && !errory)//If errorx or y were not specified. + if(density&&destination.density) + return + if(destination.x>world.maxx || destination.x<1) + return + if(destination.y>world.maxy || destination.y<1) + return + + var/destination_list[] = list()//To add turfs to list. + //destination_list = new() + /*This will draw a block around the target turf, given what the error is. + Specifying the values above will basically draw a different sort of block. + If the values are the same, it will be a square. If they are different, it will be a rectengle. + In either case, it will center based on offset. Offset is position from center. + Offset always calculates in relation to direction faced. In other words, depending on the direction of the teleport, + the offset should remain positioned in relation to destination.*/ + + var/turf/center = locate((destination.x + xoffset), (destination.y + yoffset), location.z)//So now, find the new center. + + //Now to find a box from center location and make that our destination. + for(var/turf/current_turf in block(locate(center.x + b1xerror, center.y + b1yerror, location.z), locate(center.x + b2xerror, center.y + b2yerror, location.z))) + if(density && current_turf.density) + continue//If density was specified. + if(current_turf.x > world.maxx || current_turf.x < 1) + continue//Don't want them to teleport off the map. + if(current_turf.y > world.maxy || current_turf.y < 1) + continue + destination_list += current_turf + + if(!destination_list.len) + return + + destination = pick(destination_list) + return destination + +/** + * Returns the atom sitting on the turf. + * For example, using this on a disk, which is in a bag, on a mob, will return the mob because it's on the turf. + * Optional arg 'type' to stop once it reaches a specific type instead of a turf. +**/ +/proc/get_atom_on_turf(atom/movable/atom_on_turf, stop_type) + var/atom/turf_to_check = atom_on_turf + while(turf_to_check?.loc && !isturf(turf_to_check.loc)) + turf_to_check = turf_to_check.loc + if(stop_type && istype(turf_to_check, stop_type)) + break + return turf_to_check + +///Returns a list of all locations (except the area) the movable is within. +/proc/get_nested_locs(atom/movable/atom_on_location, include_turf = FALSE) + . = list() + var/atom/location = atom_on_location.loc + var/turf/turf = get_turf(atom_on_location) + while(location && location != turf) + . += location + location = location.loc + if(location && include_turf) //At this point, only the turf is left, provided it exists. + . += location + + +///Returns the turf located at the map edge in the specified direction relative to target_atom used for mass driver +/proc/get_edge_target_turf(atom/target_atom, direction) + var/turf/target = locate(target_atom.x, target_atom.y, target_atom.z) + if(!target_atom || !target) + return 0 + //since NORTHEAST == NORTH|EAST, etc, doing it this way allows for diagonal mass drivers in the future + //and isn't really any more complicated + + var/x = target_atom.x + var/y = target_atom.y + if(direction & NORTH) + y = world.maxy + else if(direction & SOUTH) //you should not have both NORTH and SOUTH in the provided direction + y = 1 + if(direction & EAST) + x = world.maxx + else if(direction & WEST) + x = 1 + if(ISDIAGONALDIR(direction)) //let's make sure it's accurately-placed for diagonals + var/lowest_distance_to_map_edge = min(abs(x - target_atom.x), abs(y - target_atom.y)) + return get_ranged_target_turf(target_atom, direction, lowest_distance_to_map_edge) + return locate(x,y,target_atom.z) + +// returns turf relative to target_atom in given direction at set range +// result is bounded to map size +// note range is non-pythagorean +// used for disposal system +/proc/get_ranged_target_turf(atom/target_atom, direction, range) + + var/x = target_atom.x + var/y = target_atom.y + if(direction & NORTH) + y = min(world.maxy, y + range) + else if(direction & SOUTH) + y = max(1, y - range) + if(direction & EAST) + x = min(world.maxx, x + range) + else if(direction & WEST) //if you have both EAST and WEST in the provided direction, then you're gonna have issues + x = max(1, x - range) + + return locate(x,y,target_atom.z) + +/** + * Get ranged target turf, but with direct targets as opposed to directions + * + * Starts at atom starting_atom and gets the exact angle between starting_atom and target + * Moves from starting_atom with that angle, Range amount of times, until it stops, bound to map size + * Arguments: + * * starting_atom - Initial Firer / Position + * * target - Target to aim towards + * * range - Distance of returned target turf from starting_atom + * * offset - Angle offset, 180 input would make the returned target turf be in the opposite direction + */ +/proc/get_ranged_target_turf_direct(atom/starting_atom, atom/target, range, offset) + var/angle = ATAN2(target.x - starting_atom.x, target.y - starting_atom.y) + if(offset) + angle += offset + var/turf/starting_turf = get_turf(starting_atom) + for(var/i in 1 to range) + var/turf/check = locate(starting_atom.x + cos(angle) * i, starting_atom.y + sin(angle) * i, starting_atom.z) + if(!check) + break + starting_turf = check + + return starting_turf + + +/// returns turf relative to target_atom offset in dx and dy tiles, bound to map limits +/proc/get_offset_target_turf(atom/target_atom, dx, dy) + var/x = min(world.maxx, max(1, target_atom.x + dx)) + var/y = min(world.maxy, max(1, target_atom.y + dy)) + return locate(x, y, target_atom.z) + +/** + * Lets the turf this atom's *ICON* appears to inhabit + * it takes into account: + * Pixel_x/y + * Matrix x/y + * NOTE: if your atom has non-standard bounds then this proc + * will handle it, but: + * if the bounds are even, then there are an even amount of "middle" turfs, the one to the EAST, NORTH, or BOTH is picked + * this may seem bad, but you're atleast as close to the center of the atom as possible, better than byond's default loc being all the way off) + * if the bounds are odd, the true middle turf of the atom is returned +**/ +/proc/get_turf_pixel(atom/checked_atom) + if(!istype(checked_atom)) + return + + //Find checked_atom's matrix so we can use it's X/Y pixel shifts + var/matrix/atom_matrix = matrix(checked_atom.transform) + + var/pixel_x_offset = checked_atom.pixel_x + atom_matrix.get_x_shift() + var/pixel_y_offset = checked_atom.pixel_y + atom_matrix.get_y_shift() + + //Irregular objects + var/icon/checked_atom_icon = icon(checked_atom.icon, checked_atom.icon_state) + var/checked_atom_icon_height = checked_atom_icon.Height() + var/checked_atom_icon_width = checked_atom_icon.Width() + if(checked_atom_icon_height != world.icon_size || checked_atom_icon_width != world.icon_size) + pixel_x_offset += ((checked_atom_icon_width / world.icon_size) - 1) * (world.icon_size * 0.5) + pixel_y_offset += ((checked_atom_icon_height / world.icon_size) - 1) * (world.icon_size * 0.5) + + //DY and DX + var/rough_x = round(round(pixel_x_offset, world.icon_size) / world.icon_size) + var/rough_y = round(round(pixel_y_offset, world.icon_size) / world.icon_size) + + //Find coordinates + var/turf/atom_turf = get_turf(checked_atom) //use checked_atom's turfs, as it's coords are the same as checked_atom's AND checked_atom's coords are lost if it is inside another atom + if(!atom_turf) + return null + var/final_x = atom_turf.x + rough_x + var/final_y = atom_turf.y + rough_y + + if(final_x || final_y) + return locate(final_x, final_y, atom_turf.z) + +///Returns a turf based on text inputs, original turf and viewing client +/proc/params_to_turf(scr_loc, turf/origin, client/viewing_client) + if(!scr_loc) + return null + var/tX = splittext(scr_loc, ",") + var/tY = splittext(tX[2], ":") + var/tZ = origin.z + tY = tY[1] + tX = splittext(tX[1], ":") + tX = tX[1] + var/list/actual_view = getviewsize(viewing_client ? viewing_client.view : world.view) + tX = clamp(origin.x + text2num(tX) - round(actual_view[1] / 2) - 1, 1, world.maxx) + tY = clamp(origin.y + text2num(tY) - round(actual_view[2] / 2) - 1, 1, world.maxy) + return locate(tX, tY, tZ) + +///Almost identical to the params_to_turf(), but unused (remove?) +/proc/screen_loc_to_turf(text, turf/origin, client/C) + if(!text) + return null + var/tZ = splittext(text, ",") + var/tX = splittext(tZ[1], "-") + var/tY = text2num(tX[2]) + tX = splittext(tZ[2], "-") + tX = text2num(tX[2]) + tZ = origin.z + var/list/actual_view = getviewsize(C ? C.view : world.view) + tX = clamp(origin.x + round(actual_view[1] / 2) - tX, 1, world.maxx) + tY = clamp(origin.y + round(actual_view[2] / 2) - tY, 1, world.maxy) + return locate(tX, tY, tZ) + +///similar function to RANGE_TURFS(), but will search spiralling outwards from the center (like the above, but only turfs) +/proc/spiral_range_turfs(dist = 0, center = usr, orange = FALSE, list/outlist = list(), tick_checked) + outlist.Cut() + if(!dist) + outlist += center + return outlist + + var/turf/t_center = get_turf(center) + if(!t_center) + return outlist + + var/list/turf_list = outlist + var/turf/checked_turf + var/y + var/x + var/c_dist = 1 + + if(!orange) + turf_list += t_center + + while( c_dist <= dist ) + y = t_center.y + c_dist + x = t_center.x - c_dist + 1 + for(x in x to t_center.x + c_dist) + checked_turf = locate(x, y, t_center.z) + if(checked_turf) + turf_list += checked_turf + + y = t_center.y + c_dist - 1 + x = t_center.x + c_dist + for(y in t_center.y - c_dist to y) + checked_turf = locate(x, y, t_center.z) + if(checked_turf) + turf_list += checked_turf + + y = t_center.y - c_dist + x = t_center.x + c_dist - 1 + for(x in t_center.x - c_dist to x) + checked_turf = locate(x, y, t_center.z) + if(checked_turf) + turf_list += checked_turf + + y = t_center.y - c_dist + 1 + x = t_center.x - c_dist + for(y in y to t_center.y + c_dist) + checked_turf = locate(x, y, t_center.z) + if(checked_turf) + turf_list += checked_turf + c_dist++ + if(tick_checked) + CHECK_TICK + + return turf_list + +///Returns a random turf on the station +/proc/get_random_station_turf() + var/list/turfs = get_area_turfs(pick(GLOB.the_station_areas)) + if (length(turfs)) + return pick(turfs) + +///Returns a random turf on the station, excludes dense turfs (like walls) and areas that have valid_territory set to FALSE +/proc/get_safe_random_station_turf(list/areas_to_pick_from = GLOB.the_station_areas) + for (var/i in 1 to 5) + var/list/turf_list = get_area_turfs(pick(areas_to_pick_from)) + var/turf/target + while (turf_list.len && !target) + var/I = rand(1, turf_list.len) + var/turf/checked_turf = turf_list[I] + var/area/turf_area = get_area(checked_turf) + if(!checked_turf.density && (turf_area.area_flags & VALID_TERRITORY)) + var/clear = TRUE + for(var/obj/checked_object in checked_turf) + if(checked_object.density) + clear = FALSE + break + if(clear) + target = checked_turf + if (!target) + turf_list.Cut(I, I + 1) + if (target) + return target + +/** + * Checks whether the target turf is in a valid state to accept a directional window + * or other directional pseudo-dense object such as railings. + * + * Returns FALSE if the target turf cannot accept a directional window or railing. + * Returns TRUE otherwise. + * + * Arguments: + * * dest_turf - The destination turf to check for existing windows and railings + * * test_dir - The prospective dir of some atom you'd like to put on this turf. + * * is_fulltile - Whether the thing you're attempting to move to this turf takes up the entire tile or whether it supports multiple movable atoms on its tile. + */ +/proc/valid_window_location(turf/dest_turf, test_dir, is_fulltile = FALSE) + if(!dest_turf) + return FALSE + for(var/obj/turf_content in dest_turf) + if(istype(turf_content, /obj/machinery/door/window)) + if((turf_content.dir == test_dir) || is_fulltile) + return FALSE + if(istype(turf_content, /obj/structure/windoor_assembly)) + var/obj/structure/windoor_assembly/windoor_assembly = turf_content + if(windoor_assembly.dir == test_dir || is_fulltile) + return FALSE + if(istype(turf_content, /obj/structure/window)) + var/obj/structure/window/window_structure = turf_content + if(window_structure.dir == test_dir || window_structure.fulltile || is_fulltile) + return FALSE + if(istype(turf_content, /obj/structure/railing)) + var/obj/structure/railing/rail = turf_content + if(rail.dir == test_dir || is_fulltile) + return FALSE + return TRUE diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm deleted file mode 100644 index 0b07a3cca87..00000000000 --- a/code/__HELPERS/unsorted.dm +++ /dev/null @@ -1,1487 +0,0 @@ - - -/* - * A large number of misc global procs. - */ - -//Inverts the colour of an HTML string -/proc/invertHTML(HTMLstring) - if(!istext(HTMLstring)) - CRASH("Given non-text argument!") - else if(length(HTMLstring) != 7) - CRASH("Given non-HTML argument!") - else if(length_char(HTMLstring) != 7) - CRASH("Given non-hex symbols in argument!") - var/textr = copytext(HTMLstring, 2, 4) - var/textg = copytext(HTMLstring, 4, 6) - var/textb = copytext(HTMLstring, 6, 8) - return rgb(255 - hex2num(textr), 255 - hex2num(textg), 255 - hex2num(textb)) - -/proc/Get_Angle(atom/movable/start,atom/movable/end)//For beams. - if(!start || !end) - return 0 - var/dy - var/dx - dy=(32*end.y+end.pixel_y)-(32*start.y+start.pixel_y) - dx=(32*end.x+end.pixel_x)-(32*start.x+start.pixel_x) - if(!dy) - return (dx>=0)?90:270 - .=arctan(dx/dy) - if(dy<0) - .+=180 - else if(dx<0) - .+=360 - -/proc/Get_Pixel_Angle(y, x)//for getting the angle when animating something's pixel_x and pixel_y - if(!y) - return (x>=0)?90:270 - .=arctan(x/y) - if(y<0) - .+=180 - else if(x<0) - .+=360 - -//Returns location. Returns null if no location was found. -/proc/get_teleport_loc(turf/location,mob/target,distance = 1, density = FALSE, errorx = 0, errory = 0, eoffsetx = 0, eoffsety = 0) -/* -Location where the teleport begins, target that will teleport, distance to go, density checking 0/1(yes/no). -Random error in tile placement x, error in tile placement y, and block offset. -Block offset tells the proc how to place the box. Behind teleport location, relative to starting location, forward, etc. -Negative values for offset are accepted, think of it in relation to North, -x is west, -y is south. Error defaults to positive. -Turf and target are separate in case you want to teleport some distance from a turf the target is not standing on or something. -*/ - - var/dirx = 0//Generic location finding variable. - var/diry = 0 - - var/xoffset = 0//Generic counter for offset location. - var/yoffset = 0 - - var/b1xerror = 0//Generic placing for point A in box. The lower left. - var/b1yerror = 0 - var/b2xerror = 0//Generic placing for point B in box. The upper right. - var/b2yerror = 0 - - errorx = abs(errorx)//Error should never be negative. - errory = abs(errory) - - switch(target.dir)//This can be done through equations but switch is the simpler method. And works fast to boot. - //Directs on what values need modifying. - if(1)//North - diry+=distance - yoffset+=eoffsety - xoffset+=eoffsetx - b1xerror-=errorx - b1yerror-=errory - b2xerror+=errorx - b2yerror+=errory - if(2)//South - diry-=distance - yoffset-=eoffsety - xoffset+=eoffsetx - b1xerror-=errorx - b1yerror-=errory - b2xerror+=errorx - b2yerror+=errory - if(4)//East - dirx+=distance - yoffset+=eoffsetx//Flipped. - xoffset+=eoffsety - b1xerror-=errory//Flipped. - b1yerror-=errorx - b2xerror+=errory - b2yerror+=errorx - if(8)//West - dirx-=distance - yoffset-=eoffsetx//Flipped. - xoffset+=eoffsety - b1xerror-=errory//Flipped. - b1yerror-=errorx - b2xerror+=errory - b2yerror+=errorx - - var/turf/destination=locate(location.x+dirx,location.y+diry,location.z) - - if(destination)//If there is a destination. - if(errorx||errory)//If errorx or y were specified. - var/destination_list[] = list()//To add turfs to list. - //destination_list = new() - /*This will draw a block around the target turf, given what the error is. - Specifying the values above will basically draw a different sort of block. - If the values are the same, it will be a square. If they are different, it will be a rectengle. - In either case, it will center based on offset. Offset is position from center. - Offset always calculates in relation to direction faced. In other words, depending on the direction of the teleport, - the offset should remain positioned in relation to destination.*/ - - var/turf/center = locate((destination.x+xoffset),(destination.y+yoffset),location.z)//So now, find the new center. - - //Now to find a box from center location and make that our destination. - for(var/turf/T in block(locate(center.x+b1xerror,center.y+b1yerror,location.z), locate(center.x+b2xerror,center.y+b2yerror,location.z) )) - if(density&&T.density) - continue//If density was specified. - if(T.x>world.maxx || T.x<1) - continue//Don't want them to teleport off the map. - if(T.y>world.maxy || T.y<1) - continue - destination_list += T - if(destination_list.len) - destination = pick(destination_list) - else - return - - else//Same deal here. - if(density&&destination.density) - return - if(destination.x>world.maxx || destination.x<1) - return - if(destination.y>world.maxy || destination.y<1) - return - else - return - - return destination - -/** - * Get a list of turfs in a line from `M` to `N`. - * - * Uses the ultra-fast [Bresenham Line-Drawing Algorithm](https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm). - */ -/proc/getline(atom/M,atom/N) - var/px=M.x //starting x - var/py=M.y - var/line[] = list(locate(px,py,M.z)) - var/dx=N.x-px //x distance - 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/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 - if(dxabs>=dyabs) //x distance is greater than y - for(j=0;j=dxabs) //Every dyabs steps, step once in y direction - y-=dxabs - py+=sdy - px+=sdx //Step on in x direction - line+=locate(px,py,M.z)//Add the turf to the list - else - for(j=0;j=dyabs) - x-=dyabs - px+=sdx - py+=sdy - line+=locate(px,py,M.z) - return line - -//Returns whether or not a player is a guest using their ckey as an input -/proc/IsGuestKey(key) - if (findtext(key, "Guest-", 1, 7) != 1) //was findtextEx - return FALSE - - var/i, ch, len = length(key) - - for (i = 7, i <= len, ++i) //we know the first 6 chars are Guest- - ch = text2ascii(key, i) - if (ch < 48 || ch > 57) //0-9 - return FALSE - return TRUE - -//Generalised helper proc for letting mobs rename themselves. Used to be clname() and ainame() -/mob/proc/apply_pref_name(preference_type, client/C) - if(!C) - C = client - var/oldname = real_name - var/newname - var/loop = 1 - var/safety = 0 - - var/random = CONFIG_GET(flag/force_random_names) || (C ? is_banned_from(C.ckey, "Appearance") : FALSE) - - while(loop && safety < 5) - if(!safety && !random) - newname = C?.prefs?.read_preference(preference_type) - else - var/datum/preference/preference = GLOB.preference_entries[preference_type] - newname = preference.create_informed_default_value(C.prefs) - - for(var/mob/living/M in GLOB.player_list) - if(M == src) - continue - if(!newname || M.real_name == newname) - newname = null - loop++ // name is already taken so we roll again - break - loop-- - safety++ - - if(newname) - fully_replace_character_name(oldname,newname) - return TRUE - return FALSE - - -//Picks a string of symbols to display as the law number for hacked or ion laws -/proc/ionnum() //! is at the start to prevent us from changing say modes via get_message_mode() - return "![pick("!","@","#","$","%","^","&")][pick("!","@","#","$","%","^","&","*")][pick("!","@","#","$","%","^","&","*")][pick("!","@","#","$","%","^","&","*")]" - -/// Orders mobs by type then by name. Accepts optional arg to sort a custom list, otherwise copies GLOB.mob_list. -/proc/sortmobs() - var/list/moblist = list() - var/list/sortmob = sortNames(GLOB.mob_list) - for(var/mob/living/silicon/ai/mob_to_sort in sortmob) - moblist += mob_to_sort - for(var/mob/camera/mob_to_sort in sortmob) - moblist += mob_to_sort - for(var/mob/living/silicon/pai/mob_to_sort in sortmob) - moblist += mob_to_sort - for(var/mob/living/silicon/robot/mob_to_sort in sortmob) - moblist += mob_to_sort - for(var/mob/living/carbon/human/mob_to_sort in sortmob) - moblist += mob_to_sort - for(var/mob/living/brain/mob_to_sort in sortmob) - moblist += mob_to_sort - for(var/mob/living/carbon/alien/mob_to_sort in sortmob) - moblist += mob_to_sort - for(var/mob/dead/observer/mob_to_sort in sortmob) - moblist += mob_to_sort - for(var/mob/dead/new_player/mob_to_sort in sortmob) - moblist += mob_to_sort - for(var/mob/living/simple_animal/slime/mob_to_sort in sortmob) - moblist += mob_to_sort - for(var/mob/living/simple_animal/mob_to_sort in sortmob) - // We've already added slimes. - if(isslime(mob_to_sort)) - continue - moblist += mob_to_sort - for(var/mob/living/basic/mob_to_sort in sortmob) - moblist += mob_to_sort - return moblist - -// Format a power value in W, kW, MW, or GW. -/proc/DisplayPower(powerused) - if(powerused < 1000) //Less than a kW - return "[powerused] W" - else if(powerused < 1000000) //Less than a MW - return "[round((powerused * 0.001),0.01)] kW" - else if(powerused < 1000000000) //Less than a GW - return "[round((powerused * 0.000001),0.001)] MW" - return "[round((powerused * 0.000000001),0.0001)] GW" - -// Format an energy value in J, kJ, MJ, or GJ. 1W = 1J/s. -/proc/DisplayJoules(units) - if (units < 1000) // Less than a kJ - return "[round(units, 0.1)] J" - else if (units < 1000000) // Less than a MJ - return "[round(units * 0.001, 0.01)] kJ" - else if (units < 1000000000) // Less than a GJ - return "[round(units * 0.000001, 0.001)] MJ" - return "[round(units * 0.000000001, 0.0001)] GJ" - -// Format an energy value measured in Power Cell units. -/proc/DisplayEnergy(units) - // APCs process every (SSmachines.wait * 0.1) seconds, and turn 1 W of - // excess power into watts when charging cells. - // With the current configuration of wait=20 and CELLRATE=0.002, this - // means that one unit is 1 kJ. - return DisplayJoules(units * SSmachines.wait * 0.1 WATTS) - -/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 - -//Returns the atom sitting on the turf. -//For example, using this on a disk, which is in a bag, on a mob, will return the mob because it's on the turf. -//Optional arg 'type' to stop once it reaches a specific type instead of a turf. -/proc/get_atom_on_turf(atom/movable/M, stop_type) - var/atom/turf_to_check = M - while(turf_to_check?.loc && !isturf(turf_to_check.loc)) - turf_to_check = turf_to_check.loc - if(stop_type && istype(turf_to_check, stop_type)) - break - return turf_to_check - -//Returns a list of all locations (except the area) the movable is within. -/proc/get_nested_locs(atom/movable/AM, include_turf = FALSE) - . = list() - var/atom/location = AM.loc - var/turf/turf = get_turf(AM) - while(location && location != turf) - . += location - location = location.loc - if(location && include_turf) //At this point, only the turf is left, provided it exists. - . += location - -// returns the turf located at the map edge in the specified direction relative to A -// used for mass driver -/proc/get_edge_target_turf(atom/A, direction) - var/turf/target = locate(A.x, A.y, A.z) - if(!A || !target) - return 0 - //since NORTHEAST == NORTH|EAST, etc, doing it this way allows for diagonal mass drivers in the future - //and isn't really any more complicated - - var/x = A.x - var/y = A.y - if(direction & NORTH) - y = world.maxy - else if(direction & SOUTH) //you should not have both NORTH and SOUTH in the provided direction - y = 1 - if(direction & EAST) - x = world.maxx - else if(direction & WEST) - x = 1 - if(ISDIAGONALDIR(direction)) //let's make sure it's accurately-placed for diagonals - var/lowest_distance_to_map_edge = min(abs(x - A.x), abs(y - A.y)) - return get_ranged_target_turf(A, direction, lowest_distance_to_map_edge) - return locate(x,y,A.z) - -// returns turf relative to A in given direction at set range -// result is bounded to map size -// note range is non-pythagorean -// used for disposal system -/proc/get_ranged_target_turf(atom/A, direction, range) - - var/x = A.x - var/y = A.y - if(direction & NORTH) - y = min(world.maxy, y + range) - else if(direction & SOUTH) - y = max(1, y - range) - if(direction & EAST) - x = min(world.maxx, x + range) - else if(direction & WEST) //if you have both EAST and WEST in the provided direction, then you're gonna have issues - x = max(1, x - range) - - return locate(x,y,A.z) - -/** - * Get ranged target turf, but with direct targets as opposed to directions - * - * Starts at atom A and gets the exact angle between A and target - * Moves from A with that angle, Range amount of times, until it stops, bound to map size - * Arguments: - * * A - Initial Firer / Position - * * target - Target to aim towards - * * range - Distance of returned target turf from A - * * offset - Angle offset, 180 input would make the returned target turf be in the opposite direction - */ -/proc/get_ranged_target_turf_direct(atom/A, atom/target, range, offset) - var/angle = ATAN2(target.x - A.x, target.y - A.y) - if(offset) - angle += offset - var/turf/T = get_turf(A) - for(var/i in 1 to range) - var/turf/check = locate(A.x + cos(angle) * i, A.y + sin(angle) * i, A.z) - if(!check) - break - T = check - - return T - - -// returns turf relative to A offset in dx and dy tiles -// bound to map limits -/proc/get_offset_target_turf(atom/A, dx, dy) - var/x = min(world.maxx, max(1, A.x + dx)) - var/y = min(world.maxy, max(1, A.y + dy)) - return locate(x,y,A.z) - - -///Returns the src and all recursive contents as a list. -/atom/proc/GetAllContents(ignore_flag_1) - . = list(src) - var/i = 0 - while(i < length(.)) - var/atom/A = .[++i] - if (!(A.flags_1 & ignore_flag_1)) - . += A.contents - -///identical to getallcontents but returns a list of atoms of the type passed in the argument. -/atom/proc/get_all_contents_type(type) - var/list/processing_list = list(src) - . = list() - while(length(processing_list)) - var/atom/A = processing_list[1] - processing_list.Cut(1, 2) - processing_list += A.contents - if(istype(A, type)) - . += A - -/atom/proc/GetAllContentsIgnoring(list/ignore_typecache) - if(!length(ignore_typecache)) - return GetAllContents() - var/list/processing = list(src) - . = list() - var/i = 0 - while(i < length(processing)) - var/atom/A = processing[++i] - if(!ignore_typecache[A.type]) - processing += A.contents - . += A - -//Step-towards method of determining whether one atom can see another. Similar to viewers() -/proc/can_see(atom/source, atom/target, length=5) // I couldnt be arsed to do actual raycasting :I This is horribly inaccurate. - var/turf/current = get_turf(source) - var/turf/target_turf = get_turf(target) - if(get_dist(source, target) > length) - return FALSE - var/steps = 1 - if(current != target_turf) - current = get_step_towards(current, target_turf) - while(current != target_turf) - if(steps > length) - return FALSE - if(IS_OPAQUE_TURF(current)) - return FALSE - current = get_step_towards(current, target_turf) - steps++ - return TRUE - - -//Repopulates sortedAreas list -/proc/repopulate_sorted_areas() - GLOB.sortedAreas = list() - - for(var/area/A in world) - GLOB.sortedAreas.Add(A) - - sortTim(GLOB.sortedAreas, /proc/cmp_name_asc) - -/area/proc/addSorted() - GLOB.sortedAreas.Add(src) - sortTim(GLOB.sortedAreas, /proc/cmp_name_asc) - -//Takes: Area type as a text string from a variable. -//Returns: Instance for the area in the world. -/proc/get_area_instance_from_text(areatext) - if(istext(areatext)) - areatext = text2path(areatext) - return GLOB.areas_by_type[areatext] - -//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(areatype, subtypes=TRUE) - if(istext(areatype)) - areatype = text2path(areatype) - else if(isarea(areatype)) - var/area/areatemp = areatype - areatype = areatemp.type - else if(!ispath(areatype)) - return null - - var/list/areas = list() - if(subtypes) - var/list/cache = typecacheof(areatype) - for(var/area/area_to_check as anything in GLOB.sortedAreas) - if(cache[area_to_check.type]) - areas += area_to_check - else - for(var/area/area_to_check as anything in GLOB.sortedAreas) - if(area_to_check.type == areatype) - areas += area_to_check - 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(areatype, target_z = 0, subtypes=FALSE) - if(istext(areatype)) - areatype = text2path(areatype) - else if(isarea(areatype)) - var/area/areatemp = areatype - areatype = areatemp.type - else if(!ispath(areatype)) - return null - - var/list/turfs = list() - if(subtypes) - var/list/cache = typecacheof(areatype) - for(var/area/area_to_check as anything in GLOB.sortedAreas) - if(!cache[area_to_check.type]) - continue - for(var/turf/turf_in_area in area_to_check) - if(target_z == 0 || target_z == turf_in_area.z) - turfs += turf_in_area - else - for(var/area/area_to_check as anything in GLOB.sortedAreas) - if(area_to_check.type != areatype) - continue - for(var/turf/turf_in_area in area_to_check) - if(target_z == 0 || target_z == turf_in_area.z) - turfs += turf_in_area - return turfs - -/proc/get_cardinal_dir(atom/A, atom/B) - var/dx = abs(B.x - A.x) - 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/parse_zone(zone) - if(zone == BODY_ZONE_PRECISE_R_HAND) - return "right hand" - else if (zone == BODY_ZONE_PRECISE_L_HAND) - return "left hand" - else if (zone == BODY_ZONE_L_ARM) - return "left arm" - else if (zone == BODY_ZONE_R_ARM) - return "right arm" - else if (zone == BODY_ZONE_L_LEG) - return "left leg" - else if (zone == BODY_ZONE_R_LEG) - return "right leg" - else if (zone == BODY_ZONE_PRECISE_L_FOOT) - return "left foot" - else if (zone == BODY_ZONE_PRECISE_R_FOOT) - return "right foot" - else - return zone - -/* - -Lets the turf this atom's *ICON* appears to inhabit -it takes into account: -* Pixel_x/y -* Matrix x/y - -NOTE: if your atom has non-standard bounds then this proc -will handle it, but: -* if the bounds are even, then there are an even amount of "middle" turfs, the one to the EAST, NORTH, or BOTH is picked -this may seem bad, but you're atleast as close to the center of the atom as possible, better than byond's default loc being all the way off) -* if the bounds are odd, the true middle turf of the atom is returned - -*/ - -/proc/get_turf_pixel(atom/AM) - if(!istype(AM)) - return - - //Find AM's matrix so we can use it's X/Y pixel shifts - var/matrix/M = matrix(AM.transform) - - var/pixel_x_offset = AM.pixel_x + M.get_x_shift() - var/pixel_y_offset = AM.pixel_y + M.get_y_shift() - - //Irregular objects - var/icon/AMicon = icon(AM.icon, AM.icon_state) - var/AMiconheight = AMicon.Height() - var/AMiconwidth = AMicon.Width() - if(AMiconheight != world.icon_size || AMiconwidth != world.icon_size) - pixel_x_offset += ((AMiconwidth/world.icon_size)-1)*(world.icon_size*0.5) - pixel_y_offset += ((AMiconheight/world.icon_size)-1)*(world.icon_size*0.5) - - //DY and DX - var/rough_x = round(round(pixel_x_offset,world.icon_size)/world.icon_size) - var/rough_y = round(round(pixel_y_offset,world.icon_size)/world.icon_size) - - //Find coordinates - var/turf/T = get_turf(AM) //use AM's turfs, as it's coords are the same as AM's AND AM's coords are lost if it is inside another atom - if(!T) - return null - var/final_x = T.x + rough_x - var/final_y = T.y + rough_y - - if(final_x || final_y) - return locate(final_x, final_y, T.z) - -//Finds the distance between two atoms, in pixels -//centered = FALSE counts from turf edge to edge -//centered = TRUE counts from turf center to turf center -//of course mathematically this is just adding world.icon_size on again -/proc/getPixelDistance(atom/A, atom/B, centered = TRUE) - if(!istype(A)||!istype(B)) - return 0 - . = bounds_dist(A, B) + sqrt((((A.pixel_x+B.pixel_x)**2) + ((A.pixel_y+B.pixel_y)**2))) - if(centered) - . += world.icon_size - -/proc/get(atom/loc, type) - while(loc) - if(istype(loc, type)) - return loc - loc = loc.loc - return null - - -/* -Checks if that loc and dir has an item on the wall -*/ -GLOBAL_LIST_INIT(WALLITEMS, typecacheof(list( - /obj/machinery/power/apc, /obj/machinery/airalarm, /obj/item/radio/intercom, - /obj/structure/extinguisher_cabinet, /obj/structure/reagent_dispensers/peppertank, - /obj/machinery/status_display, /obj/machinery/requests_console, /obj/machinery/light_switch, /obj/structure/sign, - /obj/machinery/newscaster, /obj/machinery/firealarm, /obj/structure/noticeboard, /obj/machinery/button, - /obj/machinery/computer/security/telescreen, /obj/machinery/embedded_controller/radio/simple_vent_controller, - /obj/item/storage/secure/safe, /obj/machinery/door_timer, /obj/machinery/flasher, /obj/machinery/keycard_auth, - /obj/structure/mirror, /obj/structure/fireaxecabinet, /obj/machinery/computer/security/telescreen/entertainment, - /obj/structure/sign/picture_frame, /obj/machinery/bounty_board - ))) - -GLOBAL_LIST_INIT(WALLITEMS_EXTERNAL, typecacheof(list( - /obj/machinery/camera, /obj/structure/camera_assembly, - /obj/structure/light_construct, /obj/machinery/light))) - -GLOBAL_LIST_INIT(WALLITEMS_INVERSE, typecacheof(list( - /obj/structure/light_construct, /obj/machinery/light))) - - -/proc/gotwallitem(loc, dir, check_external = 0) - var/locdir = get_step(loc, dir) - for(var/obj/O in loc) - if(is_type_in_typecache(O, GLOB.WALLITEMS) && check_external != 2) - //Direction works sometimes - if(is_type_in_typecache(O, GLOB.WALLITEMS_INVERSE)) - if(O.dir == turn(dir, 180)) - return TRUE - else if(O.dir == dir) - return TRUE - - //Some stuff doesn't use dir properly, so we need to check pixel instead - //That's exactly what get_turf_pixel() does - if(get_turf_pixel(O) == locdir) - return TRUE - - if(is_type_in_typecache(O, GLOB.WALLITEMS_EXTERNAL) && check_external) - if(is_type_in_typecache(O, GLOB.WALLITEMS_INVERSE)) - if(O.dir == turn(dir, 180)) - return TRUE - else if(O.dir == dir) - return TRUE - - //Some stuff is placed directly on the wallturf (signs) - for(var/obj/O in locdir) - if(is_type_in_typecache(O, GLOB.WALLITEMS) && check_external != 2) - if(O.pixel_x == 0 && O.pixel_y == 0) - return TRUE - return FALSE - -/proc/format_text(text) - return replacetext(replacetext(text,"\proper ",""),"\improper ","") - -/proc/check_target_facings(mob/living/initator, mob/living/target) - /*This can be used to add additional effects on interactions between mobs depending on how the mobs are facing each other, such as adding a crit damage to blows to the back of a guy's head. - Given how click code currently works (Nov '13), the initiating mob will be facing the target mob most of the time - That said, this proc should not be used if the change facing proc of the click code is overridden at the same time*/ - if(!isliving(target) || target.body_position == LYING_DOWN) - //Make sure we are not doing this for things that can't have a logical direction to the players given that the target would be on their side - return FALSE - if(initator.dir == target.dir) //mobs are facing the same direction - return FACING_SAME_DIR - if(is_A_facing_B(initator,target) && is_A_facing_B(target,initator)) //mobs are facing each other - return FACING_EACHOTHER - if(initator.dir + 2 == target.dir || initator.dir - 2 == target.dir || initator.dir + 6 == target.dir || initator.dir - 6 == target.dir) //Initating mob is looking at the target, while the target mob is looking in a direction perpendicular to the 1st - return FACING_INIT_FACING_TARGET_TARGET_FACING_PERPENDICULAR - -/proc/random_step(atom/movable/AM, steps, chance) - var/initial_chance = chance - while(steps > 0) - if(prob(chance)) - step(AM, pick(GLOB.alldirs)) - chance = max(chance - (initial_chance / steps), 0) - steps-- - -/proc/living_player_count() - var/living_player_count = 0 - for(var/mob in GLOB.player_list) - if(mob in GLOB.alive_mob_list) - living_player_count += 1 - return living_player_count - -/proc/randomColor(mode = 0) //if 1 it doesn't pick white, black or gray - switch(mode) - if(0) - return pick("white","black","gray","red","green","blue","brown","yellow","orange","darkred", - "crimson","lime","darkgreen","cyan","navy","teal","purple","indigo") - if(1) - return pick("red","green","blue","brown","yellow","orange","darkred","crimson", - "lime","darkgreen","cyan","navy","teal","purple","indigo") - else - return "white" - -/proc/params2turf(scr_loc, turf/origin, client/C) - if(!scr_loc) - return null - var/tX = splittext(scr_loc, ",") - var/tY = splittext(tX[2], ":") - var/tZ = origin.z - tY = tY[1] - tX = splittext(tX[1], ":") - tX = tX[1] - var/list/actual_view = getviewsize(C ? C.view : world.view) - tX = clamp(origin.x + text2num(tX) - round(actual_view[1] / 2) - 1, 1, world.maxx) - tY = clamp(origin.y + text2num(tY) - round(actual_view[2] / 2) - 1, 1, world.maxy) - return locate(tX, tY, tZ) - -/proc/screen_loc2turf(text, turf/origin, client/C) - if(!text) - return null - var/tZ = splittext(text, ",") - var/tX = splittext(tZ[1], "-") - var/tY = text2num(tX[2]) - tX = splittext(tZ[2], "-") - tX = text2num(tX[2]) - tZ = origin.z - var/list/actual_view = getviewsize(C ? C.view : world.view) - tX = clamp(origin.x + round(actual_view[1] / 2) - tX, 1, world.maxx) - tY = clamp(origin.y + round(actual_view[2] / 2) - tY, 1, world.maxy) - return locate(tX, tY, tZ) - -/proc/IsValidSrc(datum/D) - if(istype(D)) - return !QDELETED(D) - return 0 - -//Compare A's dir, the clockwise dir of A and the anticlockwise dir of A -//To the opposite dir of the dir returned by get_dir(B,A) -//If one of them is a match, then A is facing B -/proc/is_A_facing_B(atom/A,atom/B) - if(!istype(A) || !istype(B)) - return FALSE - if(isliving(A)) - var/mob/living/LA = A - if(LA.body_position == LYING_DOWN) - return FALSE - var/goal_dir = get_dir(A,B) - var/clockwise_A_dir = turn(A.dir, -45) - var/anticlockwise_A_dir = turn(A.dir, 45) - - if(A.dir == goal_dir || clockwise_A_dir == goal_dir || anticlockwise_A_dir == goal_dir) - return TRUE - return FALSE - - -/* -rough example of the "cone" made by the 3 dirs checked - - -* \ -* \ -* > -* < -* \ -* \ -*B --><-- A -* / -* / -* < -* > -* / -* / - - -*/ - - -//Center's an image. -//Requires: -//The Image -//The x dimension of the icon file used in the image -//The y dimension of the icon file used in the image -// eg: center_image(I, 32,32) -// eg2: center_image(I, 96,96) - -/proc/center_image(image/I, x_dimension = 0, y_dimension = 0) - if(!I) - return - - if(!x_dimension || !y_dimension) - return - - if((x_dimension == world.icon_size) && (y_dimension == world.icon_size)) - return I - - //Offset the image so that it's bottom left corner is shifted this many pixels - //This makes it infinitely easier to draw larger inhands/images larger than world.iconsize - //but still use them in game - var/x_offset = -((x_dimension/world.icon_size)-1)*(world.icon_size*0.5) - var/y_offset = -((y_dimension/world.icon_size)-1)*(world.icon_size*0.5) - - //Correct values under world.icon_size - if(x_dimension < world.icon_size) - x_offset *= -1 - if(y_dimension < world.icon_size) - y_offset *= -1 - - I.pixel_x = x_offset - I.pixel_y = y_offset - - return I - -//ultra range (no limitations on distance, faster than range for distances > 8); including areas drastically decreases performance -/proc/urange(dist=0, atom/center=usr, orange=0, areas=0) - if(!dist) - if(!orange) - return list(center) - else - return list() - - var/list/turfs = RANGE_TURFS(dist, center) - if(orange) - turfs -= get_turf(center) - . = list() - for(var/V in turfs) - var/turf/T = V - . += T - . += T.contents - if(areas) - . |= T.loc - -//similar function to range(), but with no limitations on the distance; will search spiralling outwards from the center -/proc/spiral_range(dist=0, center=usr, orange=0) - var/list/L = list() - var/turf/t_center = get_turf(center) - if(!t_center) - return list() - - if(!orange) - L += t_center - L += t_center.contents - - if(!dist) - return L - - - var/turf/T - var/y - var/x - var/c_dist = 1 - - - while( c_dist <= dist ) - y = t_center.y + c_dist - x = t_center.x - c_dist + 1 - for(x in x to t_center.x+c_dist) - T = locate(x,y,t_center.z) - if(T) - L += T - L += T.contents - - y = t_center.y + c_dist - 1 - x = t_center.x + c_dist - for(y in t_center.y-c_dist to y) - T = locate(x,y,t_center.z) - if(T) - L += T - L += T.contents - - y = t_center.y - c_dist - x = t_center.x + c_dist - 1 - for(x in t_center.x-c_dist to x) - T = locate(x,y,t_center.z) - if(T) - L += T - L += T.contents - - y = t_center.y - c_dist + 1 - x = t_center.x - c_dist - for(y in y to t_center.y+c_dist) - T = locate(x,y,t_center.z) - if(T) - L += T - L += T.contents - c_dist++ - - return L - -//similar function to RANGE_TURFS(), but will search spiralling outwards from the center (like the above, but only turfs) -/proc/spiral_range_turfs(dist=0, center=usr, orange=0, list/outlist = list(), tick_checked) - outlist.Cut() - if(!dist) - outlist += center - return outlist - - var/turf/t_center = get_turf(center) - if(!t_center) - return outlist - - var/list/L = outlist - var/turf/T - var/y - var/x - var/c_dist = 1 - - if(!orange) - L += t_center - - while( c_dist <= dist ) - y = t_center.y + c_dist - x = t_center.x - c_dist + 1 - for(x in x to t_center.x+c_dist) - T = locate(x,y,t_center.z) - if(T) - L += T - - y = t_center.y + c_dist - 1 - x = t_center.x + c_dist - for(y in t_center.y-c_dist to y) - T = locate(x,y,t_center.z) - if(T) - L += T - - y = t_center.y - c_dist - x = t_center.x + c_dist - 1 - for(x in t_center.x-c_dist to x) - T = locate(x,y,t_center.z) - if(T) - L += T - - y = t_center.y - c_dist + 1 - x = t_center.x - c_dist - for(y in y to t_center.y+c_dist) - T = locate(x,y,t_center.z) - if(T) - L += T - c_dist++ - if(tick_checked) - CHECK_TICK - - return L - -/atom/proc/contains(atom/A) - if(!A) - return FALSE - for(var/atom/location = A.loc, location, location = location.loc) - if(location == src) - return TRUE - -/proc/flick_overlay_static(O, atom/A, duration) - set waitfor = FALSE - if(!A || !O) - return - A.add_overlay(O) - sleep(duration) - A.cut_overlay(O) - -/proc/get_random_station_turf() - var/list/turfs = get_area_turfs(pick(GLOB.the_station_areas)) - if (length(turfs)) - return pick(turfs) - -/proc/get_safe_random_station_turf(list/areas_to_pick_from = GLOB.the_station_areas) //excludes dense turfs (like walls) and areas that have valid_territory set to FALSE - for (var/i in 1 to 5) - var/list/L = get_area_turfs(pick(areas_to_pick_from)) - var/turf/target - while (L.len && !target) - var/I = rand(1, L.len) - var/turf/T = L[I] - var/area/X = get_area(T) - if(!T.density && (X.area_flags & VALID_TERRITORY)) - var/clear = TRUE - for(var/obj/O in T) - if(O.density) - clear = FALSE - break - if(clear) - target = T - if (!target) - L.Cut(I,I+1) - if (target) - return target - - -/proc/get_closest_atom(type, list, source) - var/closest_atom - var/closest_distance - for(var/A in list) - if(!istype(A, type)) - continue - var/distance = get_dist(source, A) - if(!closest_atom) - closest_distance = distance - closest_atom = A - else - if(closest_distance > distance) - closest_distance = distance - closest_atom = A - return closest_atom - - -/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("Enter type to find (blank for all, cancel to cancel)", "Search for type") as null|text - if (isnull(value)) - return - value = trim(value) - - var/random = FALSE - if(findtext(value, "?")) - value = replacetext(value, "?", "") - random = TRUE - - if(!isnull(value) && value != "") - matches = filter_fancy_list(matches, value) - - if(matches.len==0) - return - - var/chosen - if(matches.len==1) - chosen = matches[1] - else if(random) - chosen = pick(matches) || null - else - chosen = input("Select a type", "Pick Type", matches[1]) as null|anything in sortList(matches) - if(!chosen) - return - chosen = matches[chosen] - return chosen - -//gives us the stack trace from CRASH() without ending the current proc. -/proc/stack_trace(msg) - CRASH(msg) - -/datum/proc/stack_trace(msg) - CRASH(msg) - -GLOBAL_REAL_VAR(list/stack_trace_storage) -/proc/gib_stack_trace() - stack_trace_storage = list() - stack_trace() - stack_trace_storage.Cut(1, min(3,stack_trace_storage.len)) - . = stack_trace_storage - stack_trace_storage = null - -//Key thing that stops lag. Cornerstone of performance in ss13, Just sitting here, in unsorted.dm. - -//Increases delay as the server gets more overloaded, -//as sleeps aren't cheap and sleeping only to wake up and sleep again is wasteful -#define DELTA_CALC max(((max(TICK_USAGE, world.cpu) / 100) * max(Master.sleep_delta-1,1)), 1) - -//returns the number of ticks slept -/proc/stoplag(initial_delay) - if (!Master || !(Master.current_runlevel & RUNLEVELS_DEFAULT)) - sleep(world.tick_lag) - return 1 - if (!initial_delay) - initial_delay = world.tick_lag - . = 0 - var/i = DS2TICKS(initial_delay) - do - . += CEILING(i*DELTA_CALC, 1) - sleep(i*world.tick_lag*DELTA_CALC) - i *= 2 - while (TICK_USAGE > min(TICK_LIMIT_TO_RUN, Master.current_ticklimit)) - -#undef DELTA_CALC - -/proc/flash_color(mob_or_client, flash_color="#960000", flash_time=20) - var/client/C - if(ismob(mob_or_client)) - var/mob/M = mob_or_client - if(M.client) - C = M.client - else - return - else if(istype(mob_or_client, /client)) - C = mob_or_client - - if(!istype(C)) - return - - var/animate_color = C.color - C.color = flash_color - animate(C, color = animate_color, time = flash_time) - -#define RANDOM_COLOUR (rgb(rand(0,255),rand(0,255),rand(0,255))) - -/proc/random_nukecode() - var/val = rand(0, 99999) - var/str = "[val]" - while(length(str) < 5) - str = "0" + str - . = str - -/atom/proc/Shake(pixelshiftx = 15, pixelshifty = 15, duration = 250) - var/initialpixelx = pixel_x - var/initialpixely = pixel_y - var/shiftx = rand(-pixelshiftx,pixelshiftx) - var/shifty = rand(-pixelshifty,pixelshifty) - animate(src, pixel_x = pixel_x + shiftx, pixel_y = pixel_y + shifty, time = 0.2, loop = duration) - pixel_x = initialpixelx - pixel_y = initialpixely - -/proc/weightclass2text(w_class) - switch(w_class) - if(WEIGHT_CLASS_TINY) - . = "tiny" - if(WEIGHT_CLASS_SMALL) - . = "small" - if(WEIGHT_CLASS_NORMAL) - . = "normal-sized" - if(WEIGHT_CLASS_BULKY) - . = "bulky" - if(WEIGHT_CLASS_HUGE) - . = "huge" - if(WEIGHT_CLASS_GIGANTIC) - . = "gigantic" - else - . = "" - -GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new) - -//Version of view() which ignores darkness, because BYOND doesn't have it (I actually suggested it but it was tagged redundant, BUT HEARERS IS A T- /rant). -/proc/dview(range = world.view, center, invis_flags = 0) - if(!center) - return - - GLOB.dview_mob.loc = center - - GLOB.dview_mob.see_invisible = invis_flags - - . = view(range, GLOB.dview_mob) - GLOB.dview_mob.loc = null - -/mob/dview - name = "INTERNAL DVIEW MOB" - invisibility = 101 - density = FALSE - see_in_dark = 1e6 - move_resist = INFINITY - var/ready_to_die = FALSE - -/mob/dview/Initialize(mapload) //Properly prevents this mob from gaining huds or joining any global lists - SHOULD_CALL_PARENT(FALSE) - if(flags_1 & INITIALIZED_1) - stack_trace("Warning: [src]([type]) initialized multiple times!") - flags_1 |= INITIALIZED_1 - return INITIALIZE_HINT_NORMAL - -/mob/dview/Destroy(force = FALSE) - if(!ready_to_die) - stack_trace("ALRIGHT WHICH FUCKER TRIED TO DELETE *MY* DVIEW?") - - if (!force) - return QDEL_HINT_LETMELIVE - - log_world("EVACUATE THE SHITCODE IS TRYING TO STEAL MUH JOBS") - GLOB.dview_mob = new - return ..() - - -#define FOR_DVIEW(type, range, center, invis_flags) \ - GLOB.dview_mob.loc = center; \ - GLOB.dview_mob.see_invisible = invis_flags; \ - for(type in view(range, GLOB.dview_mob)) - -#define FOR_DVIEW_END GLOB.dview_mob.loc = null - -/** - * Checks whether the target turf is in a valid state to accept a directional window - * or other directional pseudo-dense object such as railings. - * - * Returns FALSE if the target turf cannot accept a directional window or railing. - * Returns TRUE otherwise. - * - * Arguments: - * * dest_turf - The destination turf to check for existing windows and railings - * * test_dir - The prospective dir of some atom you'd like to put on this turf. - * * is_fulltile - Whether the thing you're attempting to move to this turf takes up the entire tile or whether it supports multiple movable atoms on its tile. - */ -/proc/valid_window_location(turf/dest_turf, test_dir, is_fulltile = FALSE) - if(!dest_turf) - return FALSE - for(var/obj/turf_content in dest_turf) - if(istype(turf_content, /obj/machinery/door/window)) - if((turf_content.dir == test_dir) || is_fulltile) - return FALSE - if(istype(turf_content, /obj/structure/windoor_assembly)) - var/obj/structure/windoor_assembly/windoor_assembly = turf_content - if(windoor_assembly.dir == test_dir || is_fulltile) - return FALSE - if(istype(turf_content, /obj/structure/window)) - var/obj/structure/window/window_structure = turf_content - if(window_structure.dir == test_dir || window_structure.fulltile || is_fulltile) - return FALSE - if(istype(turf_content, /obj/structure/railing)) - var/obj/structure/railing/rail = turf_content - if(rail.dir == test_dir || is_fulltile) - return FALSE - return TRUE - -#define UNTIL(X) while(!(X)) stoplag() - -/proc/pass(...) - return - -/proc/get_mob_or_brainmob(occupant) - var/mob/living/mob_occupant - - if(isliving(occupant)) - mob_occupant = occupant - - else if(isbodypart(occupant)) - var/obj/item/bodypart/head/head = occupant - - mob_occupant = head.brainmob - - else if(isorgan(occupant)) - var/obj/item/organ/brain/brain = occupant - mob_occupant = brain.brainmob - - return mob_occupant - -//counts the number of bits in Byond's 16-bit width field -//in constant time and memory! -/proc/BitCount(bitfield) - var/temp = bitfield - ((bitfield>>1)&46811) - ((bitfield>>2)&37449) //0133333 and 0111111 respectively - temp = ((temp + (temp>>3))&29127) % 63 //070707 - return temp - -//returns a GUID like identifier (using a mostly made up record format) -//guids are not on their own suitable for access or security tokens, as most of their bits are predictable. -// (But may make a nice salt to one) -/proc/GUID() - var/const/GUID_VERSION = "b" - var/const/GUID_VARIANT = "d" - var/node_id = copytext_char(md5("[rand()*rand(1,9999999)][world.name][world.hub][world.hub_password][world.internet_address][world.address][world.contents.len][world.status][world.port][rand()*rand(1,9999999)]"), 1, 13) - - var/time_high = "[num2hex(text2num(time2text(world.realtime,"YYYY")), 2)][num2hex(world.realtime, 6)]" - - var/time_mid = num2hex(world.timeofday, 4) - - var/time_low = num2hex(world.time, 3) - - var/time_clock = num2hex(TICK_DELTA_TO_MS(world.tick_usage), 3) - - return "{[time_high]-[time_mid]-[GUID_VERSION][time_low]-[GUID_VARIANT][time_clock]-[node_id]}" - -// \ref behaviour got changed in 512 so this is necesary to replicate old behaviour. -// If it ever becomes necesary to get a more performant REF(), this lies here in wait -// #define REF(thing) (thing && istype(thing, /datum) && (thing:datum_flags & DF_USE_TAG) && thing:tag ? "[thing:tag]" : "\ref[thing]") -/proc/REF(input) - if(istype(input, /datum)) - var/datum/thing = input - if(thing.datum_flags & DF_USE_TAG) - if(!thing.tag) - stack_trace("A ref was requested of an object with DF_USE_TAG set but no tag: [thing]") - thing.datum_flags &= ~DF_USE_TAG - else - return "\[[url_encode(thing.tag)]\]" - return "\ref[input]" - -// Makes a call in the context of a different usr -// Use sparingly -/world/proc/PushUsr(mob/M, datum/callback/CB, ...) - var/temp = usr - usr = M - if (length(args) > 2) - . = CB.Invoke(arglist(args.Copy(3))) - else - . = CB.Invoke() - usr = temp - -//datum may be null, but it does need to be a typed var -#define NAMEOF(datum, X) (#X || ##datum.##X) - -#define VARSET_LIST_CALLBACK(target, var_name, var_value) CALLBACK(GLOBAL_PROC, /proc/___callbackvarset, ##target, ##var_name, ##var_value) -//dupe code because dm can't handle 3 level deep macros -#define VARSET_CALLBACK(datum, var, var_value) CALLBACK(GLOBAL_PROC, /proc/___callbackvarset, ##datum, NAMEOF(##datum, ##var), ##var_value) - -/proc/___callbackvarset(list_or_datum, var_name, var_value) - if(length(list_or_datum)) - list_or_datum[var_name] = var_value - return - var/datum/D = list_or_datum - if(IsAdminAdvancedProcCall()) - D.vv_edit_var(var_name, var_value) //same result generally, unless badmemes - else - D.vars[var_name] = var_value - -#define TRAIT_CALLBACK_ADD(target, trait, source) CALLBACK(GLOBAL_PROC, /proc/___TraitAdd, ##target, ##trait, ##source) -#define TRAIT_CALLBACK_REMOVE(target, trait, source) CALLBACK(GLOBAL_PROC, /proc/___TraitRemove, ##target, ##trait, ##source) - -///DO NOT USE ___TraitAdd OR ___TraitRemove as a replacement for ADD_TRAIT / REMOVE_TRAIT defines. To be used explicitly for callback. -/proc/___TraitAdd(target,trait,source) - if(!target || !trait || !source) - return - if(islist(target)) - for(var/i in target) - if(!isatom(i)) - continue - var/atom/the_atom = i - ADD_TRAIT(the_atom,trait,source) - else if(isatom(target)) - var/atom/the_atom2 = target - ADD_TRAIT(the_atom2,trait,source) - -///DO NOT USE ___TraitAdd OR ___TraitRemove as a replacement for ADD_TRAIT / REMOVE_TRAIT defines. To be used explicitly for callback. -/proc/___TraitRemove(target,trait,source) - if(!target || !trait || !source) - return - if(islist(target)) - for(var/i in target) - if(!isatom(i)) - continue - var/atom/the_atom = i - REMOVE_TRAIT(the_atom,trait,source) - else if(isatom(target)) - var/atom/the_atom2 = target - REMOVE_TRAIT(the_atom2,trait,source) - -/proc/get_random_food() - var/list/blocked = list(/obj/item/food/bread, - /obj/item/food/breadslice, - /obj/item/food/cake, - /obj/item/food/cakeslice, - /obj/item/food/pie, - /obj/item/food/pieslice, - /obj/item/food/kebab, - /obj/item/food/pizza, - /obj/item/food/pizzaslice, - /obj/item/food/salad, - /obj/item/food/meat, - /obj/item/food/meat/slab, - /obj/item/food/soup, - /obj/item/food/grown, - /obj/item/food/grown/mushroom, - /obj/item/food/deepfryholder, - /obj/item/food/clothing, - /obj/item/food/meat/slab/human/mutant, - /obj/item/food/grown/ash_flora, - /obj/item/food/grown/nettle, - /obj/item/food/grown/shell - ) - - return pick(subtypesof(/obj/item/food) - blocked) - -/proc/get_random_drink() - var/list/blocked = list(/obj/item/reagent_containers/food/drinks/soda_cans, - /obj/item/reagent_containers/food/drinks/bottle - ) - return pick(subtypesof(/obj/item/reagent_containers/food/drinks) - blocked) - -//For these two procs refs MUST be ref = TRUE format like typecaches! -/proc/weakref_filter_list(list/things, list/refs) - if(!islist(things) || !islist(refs)) - return - if(!refs.len) - return things - if(things.len > refs.len) - var/list/f = list() - for(var/i in refs) - var/datum/weakref/r = i - var/datum/d = r.resolve() - if(d) - f |= d - return things & f - - else - . = list() - for(var/i in things) - if(!refs[WEAKREF(i)]) - continue - . |= i - -/proc/weakref_filter_list_reverse(list/things, list/refs) - if(!islist(things) || !islist(refs)) - return - if(!refs.len) - return things - if(things.len > refs.len) - var/list/f = list() - for(var/i in refs) - var/datum/weakref/r = i - var/datum/d = r.resolve() - if(d) - f |= d - - return things - f - else - . = list() - for(var/i in things) - if(refs[WEAKREF(i)]) - continue - . |= i - -/proc/special_list_filter(list/L, datum/callback/condition) - if(!islist(L) || !length(L) || !istype(condition)) - return list() - . = list() - for(var/i in L) - if(condition.Invoke(i)) - . |= i -/proc/generate_items_inside(list/items_list,where_to) - for(var/each_item in items_list) - for(var/i in 1 to items_list[each_item]) - new each_item(where_to) - -/proc/CallAsync(datum/source, proctype, list/arguments) - set waitfor = FALSE - return call(source, proctype)(arglist(arguments)) - -/// Returns the name of the mathematical tuple of same length as the number arg (rounded down). -/proc/make_tuple(number) - var/static/list/units_prefix = list("", "un", "duo", "tre", "quattuor", "quin", "sex", "septen", "octo", "novem") - var/static/list/tens_prefix = list("", "decem", "vigin", "trigin", "quadragin", "quinquagin", "sexagin", "septuagin", "octogin", "nongen") - var/static/list/one_to_nine = list("monuple", "double", "triple", "quadruple", "quintuple", "sextuple", "septuple", "octuple", "nonuple") - number = round(number) - switch(number) - if(0) - return "empty tuple" - if(1 to 9) - return one_to_nine[number] - if(10 to 19) - return "[units_prefix[(number%10)+1]]decuple" - if(20 to 99) - return "[units_prefix[(number%10)+1]][tens_prefix[round((number % 100)/10)+1]]tuple" - if(100) - return "centuple" - else //It gets too tedious to use latin prefixes from here. - return "[number]-tuple" - -#define TURF_FROM_COORDS_LIST(List) (locate(List[1], List[2], List[3])) - - -/** - * One proc for easy spawning of pods in the code to drop off items before whizzling (please don't proc call this in game, it will destroy you) - * - * Arguments: - * * specifications: special mods to the pod, see non var edit specifications for details on what you should fill this with - * Non var edit specifications: - * * target = where you want the pod to drop - * * path = a special specific pod path if you want, this can save you a lot of var edits - * * style = style of the pod, defaults to the normal pod - * * spawn = spawned path or a list of the paths spawned, what you're sending basically - * Returns the pod spawned, in case you want to spawn items yourself and modify them before putting them in. - */ -/proc/podspawn(specifications) - //get non var edit specifications - var/turf/landing_location = specifications["target"] - var/spawn_type = specifications["path"] - var/style = specifications["style"] - var/list/paths_to_spawn = specifications["spawn"] - - //setup pod, add contents - if(!isturf(landing_location)) - landing_location = get_turf(landing_location) - if(!spawn_type) - spawn_type = /obj/structure/closet/supplypod/podspawn - var/obj/structure/closet/supplypod/podspawn/pod = new spawn_type(null, style) - if(paths_to_spawn && !islist(paths_to_spawn)) - paths_to_spawn = list(paths_to_spawn) - for(var/atom/path as anything in paths_to_spawn) - path = new path(pod) - - //remove non var edits from specifications - specifications -= "target" - specifications -= "style" - specifications -= "path" - specifications -= "spawn" //list, we remove the key - - //rest of specificiations are edits on the pod - for(var/variable_name in specifications) - var/variable_value = specifications[variable_name] - if(!pod.vv_edit_var(variable_name, variable_value)) - stack_trace("WARNING! podspawn vareditting \"[variable_name]\" to \"[variable_value]\" was rejected by the pod!") - new /obj/effect/pod_landingzone(landing_location, pod) - return pod diff --git a/code/__HELPERS/varset_callback.dm b/code/__HELPERS/varset_callback.dm new file mode 100644 index 00000000000..8748af5ebe8 --- /dev/null +++ b/code/__HELPERS/varset_callback.dm @@ -0,0 +1,16 @@ +///datum may be null, but it does need to be a typed var +#define NAMEOF(datum, X) (#X || ##datum.##X) + +#define VARSET_LIST_CALLBACK(target, var_name, var_value) CALLBACK(GLOBAL_PROC, /proc/___callbackvarset, ##target, ##var_name, ##var_value) +//dupe code because dm can't handle 3 level deep macros +#define VARSET_CALLBACK(datum, var, var_value) CALLBACK(GLOBAL_PROC, /proc/___callbackvarset, ##datum, NAMEOF(##datum, ##var), ##var_value) + +/proc/___callbackvarset(list_or_datum, var_name, var_value) + if(length(list_or_datum)) + list_or_datum[var_name] = var_value + return + var/datum/datum = list_or_datum + if(IsAdminAdvancedProcCall()) + datum.vv_edit_var(var_name, var_value) //same result generally, unless badmemes + else + datum.vars[var_name] = var_value diff --git a/code/__HELPERS/weakref.dm b/code/__HELPERS/weakref.dm index 0b007332ef1..56b3782c5b9 100644 --- a/code/__HELPERS/weakref.dm +++ b/code/__HELPERS/weakref.dm @@ -1,2 +1,45 @@ /// Checks if potential_weakref is a weakref of thing. #define IS_WEAKREF_OF(thing, potential_weakref) (istype(thing, /datum) && !isnull(potential_weakref) && thing.weak_reference == potential_weakref) + +//For these two procs refs MUST be ref = TRUE format like typecaches! +/proc/weakref_filter_list(list/things, list/refs) + if(!islist(things) || !islist(refs)) + return + if(!refs.len) + return things + if(things.len > refs.len) + var/list/f = list() + for(var/i in refs) + var/datum/weakref/r = i + var/datum/d = r.resolve() + if(d) + f |= d + return things & f + + else + . = list() + for(var/i in things) + if(!refs[WEAKREF(i)]) + continue + . |= i + +/proc/weakref_filter_list_reverse(list/things, list/refs) + if(!islist(things) || !islist(refs)) + return + if(!refs.len) + return things + if(things.len > refs.len) + var/list/f = list() + for(var/i in refs) + var/datum/weakref/r = i + var/datum/d = r.resolve() + if(d) + f |= d + + return things - f + else + . = list() + for(var/i in things) + if(refs[WEAKREF(i)]) + continue + . |= i diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index 3ac035ae531..a3608069792 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -231,7 +231,7 @@ return ..() + contents /mob/living/DirectAccess(atom/target) - return ..() + GetAllContents() + return ..() + get_all_contents() /atom/proc/AllowClick() return FALSE @@ -513,7 +513,7 @@ var/mob/living/carbon/C = usr C.swap_hand() else - var/turf/T = params2turf(LAZYACCESS(modifiers, SCREEN_LOC), get_turf(usr.client ? usr.client.eye : usr), usr.client) + var/turf/T = params_to_turf(LAZYACCESS(modifiers, SCREEN_LOC), get_turf(usr.client ? usr.client.eye : usr), usr.client) params += "&catcher=1" if(T) T.Click(location, control, params) diff --git a/code/_onclick/hud/alert.dm b/code/_onclick/hud/alert.dm index 588304a105f..80858133967 100644 --- a/code/_onclick/hud/alert.dm +++ b/code/_onclick/hud/alert.dm @@ -536,7 +536,7 @@ or shoot a gun to move around via Newton's 3rd Law of Motion." desc = "You are currently tracking [real_target.real_name] in [get_area_name(blood_target)]." else desc = "You are currently tracking [blood_target] in [get_area_name(blood_target)]." - var/target_angle = Get_Angle(Q, P) + var/target_angle = get_angle(Q, P) var/target_dist = get_dist(P, Q) cut_overlays() switch(target_dist) diff --git a/code/_onclick/hud/new_player.dm b/code/_onclick/hud/new_player.dm index 975487f3164..334c0b9b39f 100644 --- a/code/_onclick/hud/new_player.dm +++ b/code/_onclick/hud/new_player.dm @@ -266,7 +266,7 @@ if(!usr) return var/mob/dead/new_player/new_player = usr - if(IsGuestKey(new_player.key)) + if(is_guest_key(new_player.key)) set_button_status(FALSE) return if(!SSdbcore.Connect()) diff --git a/code/controllers/subsystem/atoms.dm b/code/controllers/subsystem/atoms.dm index 68f905e6c9f..e453360df06 100644 --- a/code/controllers/subsystem/atoms.dm +++ b/code/controllers/subsystem/atoms.dm @@ -123,7 +123,7 @@ SUBSYSTEM_DEF(atoms) else SEND_SIGNAL(A,COMSIG_ATOM_AFTER_SUCCESSFUL_INITIALIZE) if(created_atoms && from_template && ispath(the_type, /atom/movable))//we only want to populate the list with movables - created_atoms += A.GetAllContents() + created_atoms += A.get_all_contents() return qdeleted || QDELING(A) diff --git a/code/controllers/subsystem/explosions.dm b/code/controllers/subsystem/explosions.dm index df9923a678e..0b92804cbcf 100644 --- a/code/controllers/subsystem/explosions.dm +++ b/code/controllers/subsystem/explosions.dm @@ -416,7 +416,7 @@ SUBSYSTEM_DEF(explosions) for(var/I in T) var/atom/A = I if (length(A.contents) && !(A.flags_1 & PREVENT_CONTENTS_EXPLOSION_1)) //The atom/contents_explosion() proc returns null if the contents ex_acting has been handled by the atom, and TRUE if it hasn't. - items += A.GetAllContents(ignore_flag_1 = PREVENT_CONTENTS_EXPLOSION_1) + items += A.get_all_contents(ignore_flag_1 = PREVENT_CONTENTS_EXPLOSION_1) for(var/thing in items) var/atom/movable/movable_thing = thing if(QDELETED(movable_thing)) diff --git a/code/datums/ai_laws.dm b/code/datums/ai_laws.dm index 3d58bd2e48b..4f5db69e110 100644 --- a/code/datums/ai_laws.dm +++ b/code/datums/ai_laws.dm @@ -447,11 +447,11 @@ for(var/law in hacked) if (length(law) > 0) - data += "[show_numbers ? "[ionnum()]:" : ""] [render_html ? "[law]" : law]" + data += "[show_numbers ? "[ion_num()]:" : ""] [render_html ? "[law]" : law]" for(var/law in ion) if (length(law) > 0) - data += "[show_numbers ? "[ionnum()]:" : ""] [render_html ? "[law]" : law]" + data += "[show_numbers ? "[ion_num()]:" : ""] [render_html ? "[law]" : law]" var/number = 1 for(var/law in inherent) diff --git a/code/datums/beam.dm b/code/datums/beam.dm index 1522ba0ae71..f0149edf7ad 100644 --- a/code/datums/beam.dm +++ b/code/datums/beam.dm @@ -79,7 +79,7 @@ * Creates the beam effects and places them in a line from the origin to the target. Sets their rotation to make the beams face the target, too. */ /datum/beam/proc/Draw() - var/Angle = round(Get_Angle(origin,target)) + var/Angle = round(get_angle(origin,target)) var/matrix/rot_matrix = matrix() var/turf/origin_turf = get_turf(origin) rot_matrix.Turn(Angle) diff --git a/code/datums/callback.dm b/code/datums/callback.dm index b5baea28f1f..76de87bef7a 100644 --- a/code/datums/callback.dm +++ b/code/datums/callback.dm @@ -111,8 +111,8 @@ var/mob/M = W.resolve() if(M) if (length(args)) - return world.PushUsr(arglist(list(M, src) + args)) - return world.PushUsr(M, src) + return world.push_usr(arglist(list(M, src) + args)) + return world.push_usr(M, src) if (!object) return @@ -146,8 +146,8 @@ var/mob/M = W.resolve() if(M) if (length(args)) - return world.PushUsr(arglist(list(M, src) + args)) - return world.PushUsr(M, src) + return world.push_usr(arglist(list(M, src) + args)) + return world.push_usr(M, src) if (!object) return diff --git a/code/datums/components/fullauto.dm b/code/datums/components/fullauto.dm index 8790ab9ed09..bcf898e6043 100644 --- a/code/datums/components/fullauto.dm +++ b/code/datums/components/fullauto.dm @@ -120,7 +120,7 @@ if(isnull(location)) //Clicking on a screen object. if(_target.plane != CLICKCATCHER_PLANE) //The clickcatcher is a special case. We want the click to trigger then, under it. return //If we click and drag on our worn backpack, for example, we want it to open instead. - _target = params2turf(modifiers["screen-loc"], get_turf(source.eye), source) + _target = params_to_turf(modifiers["screen-loc"], get_turf(source.eye), source) if(!_target) CRASH("Failed to get the turf under clickcatcher") @@ -199,7 +199,7 @@ SIGNAL_HANDLER if(isnull(over_location)) //This happens when the mouse is over an inventory or screen object, or on entering deep darkness, for example. var/list/modifiers = params2list(params) - var/new_target = params2turf(modifiers["screen-loc"], get_turf(source.eye), source) + var/new_target = params_to_turf(modifiers["screen-loc"], get_turf(source.eye), source) mouse_parameters = params if(!new_target) if(QDELETED(target)) //No new target acquired, and old one was deleted, get us out of here. diff --git a/code/datums/components/gps.dm b/code/datums/components/gps.dm index fbb3239b88e..eeca6811d1d 100644 --- a/code/datums/components/gps.dm +++ b/code/datums/components/gps.dm @@ -136,7 +136,7 @@ GLOBAL_LIST_EMPTY(GPS_list) signal["coords"] = "[pos.x], [pos.y], [pos.z]" if(pos.z == curr.z) //Distance/Direction calculations for same z-level only signal["dist"] = max(get_dist(curr, pos), 0) //Distance between the src and remote GPS turfs - signal["degrees"] = round(Get_Angle(curr, pos)) //0-360 degree directional bearing, for more precision. + signal["degrees"] = round(get_angle(curr, pos)) //0-360 degree directional bearing, for more precision. signals += list(signal) //Add this signal to the list of signals data["signals"] = signals return data diff --git a/code/datums/components/storage/concrete/bag_of_holding.dm b/code/datums/components/storage/concrete/bag_of_holding.dm index 4af217891c4..0b63707d3ad 100644 --- a/code/datums/components/storage/concrete/bag_of_holding.dm +++ b/code/datums/components/storage/concrete/bag_of_holding.dm @@ -2,7 +2,7 @@ var/atom/A = parent if(A == W) //don't put yourself into yourself. return - var/list/obj/item/storage/backpack/holding/matching = typecache_filter_list(W.GetAllContents(), typecacheof(/obj/item/storage/backpack/holding)) + var/list/obj/item/storage/backpack/holding/matching = typecache_filter_list(W.get_all_contents(), typecacheof(/obj/item/storage/backpack/holding)) matching -= A if(istype(W, /obj/item/storage/backpack/holding) || matching.len) INVOKE_ASYNC(src, .proc/recursive_insertion, W, user) diff --git a/code/datums/components/tether.dm b/code/datums/components/tether.dm index ec8da0f7b0d..c17293708e5 100644 --- a/code/datums/components/tether.dm +++ b/code/datums/components/tether.dm @@ -25,7 +25,7 @@ var/atom/blocker out: - for(var/turf/T in getline(tether_target,newloc)) + for(var/turf/T in get_line(tether_target,newloc)) if (T.density) blocker = T break out diff --git a/code/datums/diseases/advance/symptoms/sneeze.dm b/code/datums/diseases/advance/symptoms/sneeze.dm index cb8e49f3b25..93885a7c1b4 100644 --- a/code/datums/diseases/advance/symptoms/sneeze.dm +++ b/code/datums/diseases/advance/symptoms/sneeze.dm @@ -59,7 +59,7 @@ Bonus M.emote("sneeze") if(M.CanSpreadAirborneDisease()) //don't spread germs if they covered their mouth for(var/mob/living/L in oview(spread_range, M)) - if(is_A_facing_B(M, L) && disease_air_spread_walk(get_turf(M), get_turf(L))) + if(is_source_facing_target(M, L) && disease_air_spread_walk(get_turf(M), get_turf(L))) L.AirborneContractDisease(A, TRUE) if(cartoon_sneezing) //Yeah, this can fling you around even if you have a space suit helmet on. It's, uh, bluespace snot, yeah. var/sneeze_distance = rand(2,4) //twice as far as a normal baseball bat strike will fling you diff --git a/code/datums/elements/backblast.dm b/code/datums/elements/backblast.dm index 903704c159c..14b8cf3a312 100644 --- a/code/datums/elements/backblast.dm +++ b/code/datums/elements/backblast.dm @@ -41,7 +41,7 @@ if(!weapon.chambered || HAS_TRAIT(user, TRAIT_PACIFISM)) return - var/backwards_angle = Get_Angle(target, user) + var/backwards_angle = get_angle(target, user) var/starting_angle = SIMPLIFY_DEGREES(backwards_angle-(angle_spread * 0.5)) var/iter_offset = angle_spread / plumes // how much we increment the angle for each plume @@ -57,7 +57,7 @@ if(!weapon.chambered || HAS_TRAIT(user, TRAIT_PACIFISM)) return - var/backwards_angle = Get_Angle(target, user) + var/backwards_angle = get_angle(target, user) var/turf/target_turf = get_turf_in_angle(backwards_angle, get_turf(user), 10) INVOKE_ASYNC(src, .proc/pew, target_turf, weapon, user) diff --git a/code/datums/elements/selfknockback.dm b/code/datums/elements/selfknockback.dm index e5287ca0482..bd59b9d17fe 100644 --- a/code/datums/elements/selfknockback.dm +++ b/code/datums/elements/selfknockback.dm @@ -45,7 +45,7 @@ clamping the Knockback_Force value below. */ var/knockback_force = Get_Knockback_Force(clamp(CEILING((I.force / 10), 1), 1, 5)) var/knockback_speed = Get_Knockback_Speed(clamp(knockback_force, 1, 5)) - var/target_angle = Get_Angle(attacktarget, usertarget) + var/target_angle = get_angle(attacktarget, usertarget) var/move_target = get_ranged_target_turf(usertarget, angle2dir(target_angle), knockback_force) usertarget.throw_at(move_target, knockback_force, knockback_speed) usertarget.visible_message(span_warning("[usertarget] gets thrown back by the force of \the [I] impacting \the [attacktarget]!"), span_warning("The force of \the [I] impacting \the [attacktarget] sends you flying!")) diff --git a/code/datums/helper_datums/teleport.dm b/code/datums/helper_datums/teleport.dm index b07a28a07e8..3d0afa13b54 100644 --- a/code/datums/helper_datums/teleport.dm +++ b/code/datums/helper_datums/teleport.dm @@ -34,7 +34,7 @@ precision = rand(1,100) var/static/list/bag_cache = typecacheof(/obj/item/storage/backpack/holding) - var/list/bagholding = typecache_filter_list(teleatom.GetAllContents(), bag_cache) + var/list/bagholding = typecache_filter_list(teleatom.get_all_contents(), bag_cache) if(bagholding.len) precision = max(rand(1,100)*bagholding.len,100) if(isliving(teleatom)) diff --git a/code/datums/mind.dm b/code/datums/mind.dm index afe12a551d2..ef90eb30d5a 100644 --- a/code/datums/mind.dm +++ b/code/datums/mind.dm @@ -381,7 +381,7 @@ if (!istype(traitor_mob)) return - var/list/all_contents = traitor_mob.GetAllContents() + var/list/all_contents = traitor_mob.get_all_contents() var/obj/item/pda/PDA = locate() in all_contents var/obj/item/radio/R = locate() in all_contents var/obj/item/pen/P @@ -657,7 +657,7 @@ obj_count++ /datum/mind/proc/find_syndicate_uplink(check_unlocked) - var/list/L = current.GetAllContents() + var/list/L = current.get_all_contents() for (var/i in L) var/atom/movable/I = i var/datum/component/uplink/found_uplink = I.GetComponent(/datum/component/uplink) diff --git a/code/datums/quirks/negative.dm b/code/datums/quirks/negative.dm index e51e62bc0b0..77b02c670eb 100644 --- a/code/datums/quirks/negative.dm +++ b/code/datums/quirks/negative.dm @@ -214,7 +214,7 @@ var/obj/family_heirloom = heirloom?.resolve() - if(family_heirloom && (family_heirloom in quirk_holder.GetAllContents())) + if(family_heirloom && (family_heirloom in quirk_holder.get_all_contents())) SEND_SIGNAL(quirk_holder, COMSIG_CLEAR_MOOD_EVENT, "family_heirloom_missing") SEND_SIGNAL(quirk_holder, COMSIG_ADD_MOOD_EVENT, "family_heirloom", /datum/mood_event/family_heirloom) else diff --git a/code/game/gamemodes/objective.dm b/code/game/gamemodes/objective.dm index 4efabbafe75..77484dc88b2 100644 --- a/code/game/gamemodes/objective.dm +++ b/code/game/gamemodes/objective.dm @@ -622,7 +622,7 @@ GLOBAL_LIST_EMPTY(possible_items) if(!isliving(M.current)) continue - var/list/all_items = M.current.GetAllContents() //this should get things in cheesewheels, books, etc. + var/list/all_items = M.current.get_all_contents() //this should get things in cheesewheels, books, etc. for(var/obj/I in all_items) //Check for items if(istype(I, steal_target)) @@ -853,7 +853,7 @@ GLOBAL_LIST_EMPTY(possible_items_special) for(var/datum/mind/M in owners) if(!isliving(M.current)) continue - var/list/all_items = M.current.GetAllContents() //this should get things in cheesewheels, books, etc. + var/list/all_items = M.current.get_all_contents() //this should get things in cheesewheels, books, etc. for(var/obj/I in all_items) //Check for wanted items if(is_type_in_typecache(I, wanted_items)) stolen_count++ @@ -879,7 +879,7 @@ GLOBAL_LIST_EMPTY(possible_items_special) for(var/datum/mind/M in owners) if(!isliving(M.current)) continue - var/list/all_items = M.current.GetAllContents() //this should get things in cheesewheels, books, etc. + var/list/all_items = M.current.get_all_contents() //this should get things in cheesewheels, books, etc. for(var/obj/I in all_items) //Check for wanted items if(istype(I, /obj/item/book/granter/spell)) var/obj/item/book/granter/spell/spellbook = I diff --git a/code/game/machinery/computer/apc_control.dm b/code/game/machinery/computer/apc_control.dm index 950aa892d28..16ad9d068f6 100644 --- a/code/game/machinery/computer/apc_control.dm +++ b/code/game/machinery/computer/apc_control.dm @@ -67,7 +67,7 @@ "name" = A.area.name, "operating" = A.operating, "charge" = (has_cell) ? A.cell.percent() : "NOCELL", - "load" = DisplayPower(A.lastused_total), + "load" = display_power(A.lastused_total), "charging" = A.charging, "chargeMode" = A.chargemode, "eqp" = A.equipment, diff --git a/code/game/machinery/recycler.dm b/code/game/machinery/recycler.dm index 196464bccdf..c2e66792bc7 100644 --- a/code/game/machinery/recycler.dm +++ b/code/game/machinery/recycler.dm @@ -120,7 +120,7 @@ if(!isturf(AM0.loc)) return //I don't know how you called Crossed() but stop it. - var/list/to_eat = AM0.GetAllContents() + var/list/to_eat = AM0.get_all_contents() var/living_detected = FALSE //technically includes silicons as well but eh var/list/nom = list() diff --git a/code/game/machinery/suit_storage_unit.dm b/code/game/machinery/suit_storage_unit.dm index 5247cfcb53d..7387f4ba238 100644 --- a/code/game/machinery/suit_storage_unit.dm +++ b/code/game/machinery/suit_storage_unit.dm @@ -403,19 +403,19 @@ var/list/things_to_clear = list() //Done this way since using GetAllContents on the SSU itself would include circuitry and such. if(suit) things_to_clear += suit - things_to_clear += suit.GetAllContents() + things_to_clear += suit.get_all_contents() if(helmet) things_to_clear += helmet - things_to_clear += helmet.GetAllContents() + things_to_clear += helmet.get_all_contents() if(mask) things_to_clear += mask - things_to_clear += mask.GetAllContents() + things_to_clear += mask.get_all_contents() if(storage) things_to_clear += storage - things_to_clear += storage.GetAllContents() + things_to_clear += storage.get_all_contents() if(mob_occupant) things_to_clear += mob_occupant - things_to_clear += mob_occupant.GetAllContents() + things_to_clear += mob_occupant.get_all_contents() for(var/am in things_to_clear) //Scorches away blood and forensic evidence, although the SSU itself is unaffected var/atom/movable/dirty_movable = am dirty_movable.wash(CLEAN_ALL) diff --git a/code/game/objects/effects/powerup.dm b/code/game/objects/effects/powerup.dm index 32079b9729d..234989205c0 100644 --- a/code/game/objects/effects/powerup.dm +++ b/code/game/objects/effects/powerup.dm @@ -95,7 +95,7 @@ . = ..() if(!.) return - for(var/obj/item/gun in target.GetAllContents()) + for(var/obj/item/gun in target.get_all_contents()) if(!isgun(gun) && !istype(gun, /obj/item/flamethrower)) continue SEND_SIGNAL(gun, COMSIG_ITEM_RECHARGED) diff --git a/code/game/objects/effects/temporary_visuals/projectiles/tracer.dm b/code/game/objects/effects/temporary_visuals/projectiles/tracer.dm index c0fa093a2fe..cb1334aadca 100644 --- a/code/game/objects/effects/temporary_visuals/projectiles/tracer.dm +++ b/code/game/objects/effects/temporary_visuals/projectiles/tracer.dm @@ -8,7 +8,7 @@ PB.apply_vars(angle_between_points(starting, ending), midpoint.return_px(), midpoint.return_py(), color, pixel_length_between_points(starting, ending) / world.icon_size, midpoint.return_turf(), 0) . = PB if(light_range > 0 && light_intensity > 0) - var/list/turf/line = getline(starting.return_turf(), ending.return_turf()) + var/list/turf/line = get_line(starting.return_turf(), ending.return_turf()) tracing_line: for(var/i in line) var/turf/T = i diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index cc8f36944f1..b639a522e33 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -309,7 +309,7 @@ GLOBAL_DATUM_INIT(fire_overlay, /mutable_appearance, mutable_appearance('icons/e /obj/item/examine(mob/user) //This might be spammy. Remove? . = ..() - . += "[gender == PLURAL ? "They are" : "It is"] a [weightclass2text(w_class)] item." + . += "[gender == PLURAL ? "They are" : "It is"] a [weight_class_to_text(w_class)] item." if(resistance_flags & INDESTRUCTIBLE) . += "[src] seems extremely robust! It'll probably withstand anything that could happen to it!" @@ -531,7 +531,7 @@ GLOBAL_DATUM_INIT(fire_overlay, /mutable_appearance, mutable_appearance('icons/e R.hud_used.update_robot_modules_display() /obj/item/proc/GetDeconstructableContents() - return GetAllContents() - src + return get_all_contents() - src // afterattack() and attack() prototypes moved to _onclick/item_attack.dm for consistency diff --git a/code/game/objects/items/apc_frame.dm b/code/game/objects/items/apc_frame.dm index 4dcc0096442..cea787d6f40 100644 --- a/code/game/objects/items/apc_frame.dm +++ b/code/game/objects/items/apc_frame.dm @@ -24,7 +24,7 @@ if(A.always_unpowered) to_chat(user, span_warning("You cannot place [src] in this area!")) return - if(gotwallitem(T, ndir, inverse*2)) + if(got_wall_item(T, ndir, inverse*2)) to_chat(user, span_warning("There's already an item on this wall!")) return diff --git a/code/game/objects/items/devices/PDA/cart.dm b/code/game/objects/items/devices/PDA/cart.dm index 6d6e0013a35..132389f9c96 100644 --- a/code/game/objects/items/devices/PDA/cart.dm +++ b/code/game/objects/items/devices/PDA/cart.dm @@ -274,7 +274,7 @@ Code: var/obj/machinery/power/apc/A = term.master L += A - menu += "
Location: [get_area_name(powmonitor, TRUE)]
Total power: [DisplayPower(connected_powernet.viewavail)]
Total load: [DisplayPower(connected_powernet.viewload)]
" + menu += "
Location: [get_area_name(powmonitor, TRUE)]
Total power: [display_power(connected_powernet.viewavail)]
Total load: [display_power(connected_powernet.viewload)]
" menu += "" @@ -290,7 +290,7 @@ Code: //would be to use [A.area.name] for(var/obj/machinery/power/apc/A in L) menu += copytext_char(add_trailing(A.area.name, 30, " "), 1, 30) - menu += " [S[A.equipment+1]] [S[A.lighting+1]] [S[A.environ+1]] [add_leading(DisplayPower(A.lastused_total), 6, " ")] [A.cell ? "[add_leading(round(A.cell.percent()), 3, " ")]% [chg[A.charging+1]]" : " N/C"]
" + menu += " [S[A.equipment+1]] [S[A.lighting+1]] [S[A.environ+1]] [add_leading(display_power(A.lastused_total), 6, " ")] [A.cell ? "[add_leading(round(A.cell.percent()), 3, " ")]% [chg[A.charging+1]]" : " N/C"]
" menu += "
" diff --git a/code/game/objects/items/devices/PDA/virus_cart.dm b/code/game/objects/items/devices/PDA/virus_cart.dm index 6ab9b731f3b..c601267e1ba 100644 --- a/code/game/objects/items/devices/PDA/virus_cart.dm +++ b/code/game/objects/items/devices/PDA/virus_cart.dm @@ -66,7 +66,7 @@ charges-- var/difficulty = 0 if(target.cartridge) - difficulty += BitCount(target.cartridge.access&(CART_MEDICAL | CART_SECURITY | CART_ENGINE | CART_CLOWN | CART_JANITOR | CART_MANIFEST)) + difficulty += bit_count(target.cartridge.access&(CART_MEDICAL | CART_SECURITY | CART_ENGINE | CART_CLOWN | CART_JANITOR | CART_MANIFEST)) if(target.cartridge.access & CART_MANIFEST) difficulty++ //if cartridge has manifest access it has extra snowflake difficulty if(SEND_SIGNAL(target, COMSIG_PDA_CHECK_DETONATE) & COMPONENT_PDA_NO_DETONATE || prob(difficulty * 15)) diff --git a/code/game/objects/items/devices/electroadaptive_pseudocircuit.dm b/code/game/objects/items/devices/electroadaptive_pseudocircuit.dm index 80f496b4026..daec0343d44 100644 --- a/code/game/objects/items/devices/electroadaptive_pseudocircuit.dm +++ b/code/game/objects/items/devices/electroadaptive_pseudocircuit.dm @@ -29,7 +29,7 @@ to_chat(R, span_warning("You need a power cell installed for that.")) return if(!R.cell.use(circuit_cost)) - to_chat(R, span_warning("You don't have the energy for that (you need [DisplayEnergy(circuit_cost)].)")) + to_chat(R, span_warning("You don't have the energy for that (you need [display_energy(circuit_cost)].)")) return if(recharging) to_chat(R, span_warning("[src] needs some time to recharge first.")) diff --git a/code/game/objects/items/flamethrower.dm b/code/game/objects/items/flamethrower.dm index 3a75d3ebcf2..a7bdf4b3fdf 100644 --- a/code/game/objects/items/flamethrower.dm +++ b/code/game/objects/items/flamethrower.dm @@ -83,7 +83,7 @@ if(user && user.get_active_held_item() == src) // Make sure our user is still holding us var/turf/target_turf = get_turf(target) if(target_turf) - var/turflist = getline(user, target_turf) + var/turflist = get_line(user, target_turf) log_combat(user, target, "flamethrowered", src) flame_turf(turflist) diff --git a/code/game/objects/items/inducer.dm b/code/game/objects/items/inducer.dm index 21322cdba2b..db12f6f7263 100644 --- a/code/game/objects/items/inducer.dm +++ b/code/game/objects/items/inducer.dm @@ -159,7 +159,7 @@ /obj/item/inducer/examine(mob/living/M) . = ..() if(cell) - . += span_notice("Its display shows: [DisplayEnergy(cell.charge)].") + . += span_notice("Its display shows: [display_energy(cell.charge)].") else . += span_notice("Its display is dark.") if(opened) diff --git a/code/game/objects/items/stacks/wrap.dm b/code/game/objects/items/stacks/wrap.dm index 33218c6ae40..b1737e1caa5 100644 --- a/code/game/objects/items/stacks/wrap.dm +++ b/code/game/objects/items/stacks/wrap.dm @@ -124,7 +124,7 @@ user.put_in_hands(P) I.forceMove(P) var/size = round(I.w_class) - P.name = "[weightclass2text(size)] parcel" + P.name = "[weight_class_to_text(size)] parcel" P.w_class = size size = min(size, 5) P.icon_state = "deliverypackage[size]" diff --git a/code/game/objects/items/storage/toolbox.dm b/code/game/objects/items/storage/toolbox.dm index b27da30a689..fa211d885ae 100644 --- a/code/game/objects/items/storage/toolbox.dm +++ b/code/game/objects/items/storage/toolbox.dm @@ -108,7 +108,7 @@ /obj/item/storage/toolbox/mechanical/old/clean/proc/calc_damage() var/power = 0 - for (var/obj/item/stack/telecrystal/TC in GetAllContents()) + for (var/obj/item/stack/telecrystal/TC in get_all_contents()) power += TC.amount force = 19 + power throwforce = 22 + power diff --git a/code/game/objects/items/wayfinding.dm b/code/game/objects/items/wayfinding.dm index cc7d203c9f4..e0255a3e741 100644 --- a/code/game/objects/items/wayfinding.dm +++ b/code/game/objects/items/wayfinding.dm @@ -113,7 +113,7 @@ user_interact_cooldowns[user.real_name] = world.time + COOLDOWN_INTERACT - for(var/obj/item/pinpointer/wayfinding/held_pinpointer in user.GetAllContents()) + for(var/obj/item/pinpointer/wayfinding/held_pinpointer in user.get_all_contents()) set_expression("veryhappy", 2 SECONDS) say("You already have a pinpointer!") return diff --git a/code/game/objects/structures/crates_lockers/closets.dm b/code/game/objects/structures/crates_lockers/closets.dm index 79328a94c78..e7a2df063f1 100644 --- a/code/game/objects/structures/crates_lockers/closets.dm +++ b/code/game/objects/structures/crates_lockers/closets.dm @@ -234,7 +234,7 @@ for(var/atom/movable/AM in L) if(AM != src && insert(AM) == LOCKER_FULL) // limit reached break - for(var/i in reverseRange(L.GetAllContents())) + for(var/i in reverseRange(L.get_all_contents())) var/atom/movable/thing = i SEND_SIGNAL(thing, COMSIG_TRY_STORAGE_HIDE_ALL) diff --git a/code/game/objects/structures/displaycase.dm b/code/game/objects/structures/displaycase.dm index e3db4947935..c9868452a5b 100644 --- a/code/game/objects/structures/displaycase.dm +++ b/code/game/objects/structures/displaycase.dm @@ -333,7 +333,7 @@ to_chat(user, span_warning("The case rejects the [W]!")) return - for(var/a in W.GetAllContents()) + for(var/a in W.get_all_contents()) if(is_type_in_typecache(a, GLOB.blacklisted_cargo_types)) to_chat(user, span_warning("The case rejects the [W]!")) return diff --git a/code/game/objects/structures/morgue.dm b/code/game/objects/structures/morgue.dm index 25b8c0af9ff..38ca7875a2c 100644 --- a/code/game/objects/structures/morgue.dm +++ b/code/game/objects/structures/morgue.dm @@ -248,7 +248,7 @@ GLOBAL_LIST_EMPTY(crematoriums) if(locked) return //don't let you cremate something twice or w/e // Make sure we don't delete the actual morgue and its tray - var/list/conts = GetAllContents() - src - connected + var/list/conts = get_all_contents() - src - connected if(!conts.len) audible_message(span_hear("You hear a hollow crackle.")) diff --git a/code/game/turfs/change_turf.dm b/code/game/turfs/change_turf.dm index c4f286fd174..b950a803229 100644 --- a/code/game/turfs/change_turf.dm +++ b/code/game/turfs/change_turf.dm @@ -7,7 +7,7 @@ GLOBAL_LIST_INIT(blacklisted_automated_baseturfs, typecacheof(list( /turf/proc/empty(turf_type=/turf/open/space, baseturf_type, list/ignore_typecache, flags) // Remove all atoms except observers, landmarks, docking ports var/static/list/ignored_atoms = typecacheof(list(/mob/dead, /obj/effect/landmark, /obj/docking_port)) - var/list/allowed_contents = typecache_filter_list_reverse(GetAllContentsIgnoring(ignore_typecache), ignored_atoms) + var/list/allowed_contents = typecache_filter_list_reverse(get_all_contents_ignoring(ignore_typecache), ignored_atoms) allowed_contents -= src for(var/i in 1 to allowed_contents.len) var/thing = allowed_contents[i] diff --git a/code/modules/admin/IsBanned.dm b/code/modules/admin/IsBanned.dm index 351cdff676e..938c47e27f6 100644 --- a/code/modules/admin/IsBanned.dm +++ b/code/modules/admin/IsBanned.dm @@ -46,7 +46,7 @@ return list("reason"="whitelist", "desc" = "\nReason: You are not on the white list for this server") //Guest Checking - if(!real_bans_only && !C && IsGuestKey(key)) + if(!real_bans_only && !C && is_guest_key(key)) if (CONFIG_GET(flag/guest_ban)) log_access("Failed Login: [key] - Guests not allowed") return list("reason"="guest", "desc"="\nReason: Guests not allowed. Please sign in with a byond account.") diff --git a/code/modules/admin/callproc/callproc.dm b/code/modules/admin/callproc/callproc.dm index 158a9b2d6ee..be7b0a770d9 100644 --- a/code/modules/admin/callproc/callproc.dm +++ b/code/modules/admin/callproc/callproc.dm @@ -247,7 +247,7 @@ GLOBAL_PROTECT(LastAdminCalledProc) if(!lst) return - if(!A || !IsValidSrc(A)) + if(!A || !is_valid_src(A)) to_chat(usr, span_warning("Error: callproc_datum(): owner of proc no longer exists."), confidential = TRUE) return log_admin("[key_name(src)] called [A]'s [procname]() with [lst.len ? "the arguments [list2params(lst)]":"no arguments"].") diff --git a/code/modules/admin/player_panel.dm b/code/modules/admin/player_panel.dm index 21baaaee96f..f7aad8f38a3 100644 --- a/code/modules/admin/player_panel.dm +++ b/code/modules/admin/player_panel.dm @@ -216,7 +216,7 @@ "} - var/list/mobs = sortmobs() + var/list/mobs = sort_mobs() var/i = 1 for(var/mob/M in mobs) if(M.ckey) diff --git a/code/modules/admin/verbs/adminjump.dm b/code/modules/admin/verbs/adminjump.dm index 9237e7d07ff..cb843524246 100644 --- a/code/modules/admin/verbs/adminjump.dm +++ b/code/modules/admin/verbs/adminjump.dm @@ -153,7 +153,7 @@ usr.forceMove(M.loc) SSblackbox.record_feedback("tally", "admin_verb", 1, "Get Key") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! -/client/proc/sendmob(mob/M in sortmobs()) +/client/proc/sendmob(mob/M in sort_mobs()) set category = "Admin.Game" set name = "Send Mob" if(!src.holder) diff --git a/code/modules/antagonists/abductor/equipment/abduction_gear.dm b/code/modules/antagonists/abductor/equipment/abduction_gear.dm index 451e83d124a..de3505a4214 100644 --- a/code/modules/antagonists/abductor/equipment/abduction_gear.dm +++ b/code/modules/antagonists/abductor/equipment/abduction_gear.dm @@ -278,7 +278,7 @@ radio_off_mob(M) /obj/item/abductor/silencer/proc/radio_off_mob(mob/living/carbon/human/M) - var/list/all_items = M.GetAllContents() + var/list/all_items = M.get_all_contents() for(var/obj/I in all_items) if(istype(I, /obj/item/radio/)) diff --git a/code/modules/antagonists/creep/creep.dm b/code/modules/antagonists/creep/creep.dm index 672724e31a3..6c65d5e170d 100644 --- a/code/modules/antagonists/creep/creep.dm +++ b/code/modules/antagonists/creep/creep.dm @@ -268,7 +268,7 @@ for(var/datum/mind/M in owners) if(!isliving(M.current)) continue - var/list/all_items = M.current.GetAllContents() //this should get things in cheesewheels, books, etc. + var/list/all_items = M.current.get_all_contents() //this should get things in cheesewheels, books, etc. for(var/obj/I in all_items) //Check for wanted items if(istype(I, /obj/item/photo)) var/obj/item/photo/P = I diff --git a/code/modules/antagonists/cult/cult.dm b/code/modules/antagonists/cult/cult.dm index 0b57b25e3f1..7e10352f678 100644 --- a/code/modules/antagonists/cult/cult.dm +++ b/code/modules/antagonists/cult/cult.dm @@ -198,7 +198,7 @@ /datum/antagonist/cult/proc/admin_take_all(mob/admin) var/mob/living/current = owner.current - for(var/o in current.GetAllContents()) + for(var/o in current.get_all_contents()) if(istype(o, /obj/item/melee/cultblade/dagger) || istype(o, /obj/item/stack/sheet/runed_metal)) qdel(o) diff --git a/code/modules/antagonists/cult/cult_items.dm b/code/modules/antagonists/cult/cult_items.dm index c166d406ff7..5897c80e0df 100644 --- a/code/modules/antagonists/cult/cult_items.dm +++ b/code/modules/antagonists/cult/cult_items.dm @@ -674,7 +674,7 @@ to_chat(user, "[cultist_to_receive] is not a follower of the Geometer!") log_game("Void torch failed - target was deconverted") return - if(A in user.GetAllContents()) + if(A in user.get_all_contents()) to_chat(user, "[A] must be on a surface in order to teleport it!") return to_chat(user, "You ignite [A] with \the [src], turning it to ash, but through the torch's flames you see that [A] has reached [cultist_to_receive]!") @@ -898,7 +898,7 @@ if(firing || charging) return if(ishuman(user)) - angle = Get_Angle(user, A) + angle = get_angle(user, A) else qdel(src) return @@ -953,7 +953,7 @@ playsound(src, 'sound/magic/exit_blood.ogg', 75, TRUE) new /obj/effect/temp_visual/dir_setting/cult/phase(user.loc, user.dir) var/turf/temp_target = get_turf_in_angle(set_angle, targets_from, 40) - for(var/turf/T in getline(targets_from,temp_target)) + for(var/turf/T in get_line(targets_from,temp_target)) if (locate(/obj/effect/blessing, T)) temp_target = T playsound(T, 'sound/machines/clockcult/ark_damage.ogg', 50, TRUE) diff --git a/code/modules/antagonists/disease/disease_abilities.dm b/code/modules/antagonists/disease/disease_abilities.dm index 21459ce28ce..4608616a484 100644 --- a/code/modules/antagonists/disease/disease_abilities.dm +++ b/code/modules/antagonists/disease/disease_abilities.dm @@ -220,7 +220,7 @@ new /datum/disease_ability/symptom/powerful/youth var/datum/disease/advance/sentient_disease/SD = D.hosts[L] for(var/mob/living/M in oview(4, SD.affected_mob)) - if(is_A_facing_B(SD.affected_mob, M) && disease_air_spread_walk(get_turf(SD.affected_mob), get_turf(M))) + if(is_source_facing_target(SD.affected_mob, M) && disease_air_spread_walk(get_turf(SD.affected_mob), get_turf(M))) M.AirborneContractDisease(SD, TRUE) StartCooldown() diff --git a/code/modules/antagonists/eldritch_cult/eldritch_magic.dm b/code/modules/antagonists/eldritch_cult/eldritch_magic.dm index 5c1c858ac7c..dc7de5deb5d 100644 --- a/code/modules/antagonists/eldritch_cult/eldritch_magic.dm +++ b/code/modules/antagonists/eldritch_cult/eldritch_magic.dm @@ -341,7 +341,7 @@ if(!check) break T = check - return (getline(user, T) - get_turf(user)) + return (get_line(user, T) - get_turf(user)) /obj/effect/proc_holder/spell/pointed/ash_final/proc/fire_line(atom/source, list/turfs) var/list/hit_list = list() diff --git a/code/modules/antagonists/eldritch_cult/knowledge/rust_lore.dm b/code/modules/antagonists/eldritch_cult/knowledge/rust_lore.dm index a2bab11f37b..10129d0eb5a 100644 --- a/code/modules/antagonists/eldritch_cult/knowledge/rust_lore.dm +++ b/code/modules/antagonists/eldritch_cult/knowledge/rust_lore.dm @@ -274,7 +274,7 @@ if(turfie in turfs || is_type_in_typecache(turfie,blacklisted_turfs)) continue - for(var/line_turfie_owo in getline(turfie,centre)) + for(var/line_turfie_owo in get_line(turfie,centre)) if(get_dist(turfie,line_turfie_owo) <= 1) edge_turfs += turfie CHECK_TICK diff --git a/code/modules/assembly/flash.dm b/code/modules/assembly/flash.dm index 528c166f9d1..120b065ebb8 100644 --- a/code/modules/assembly/flash.dm +++ b/code/modules/assembly/flash.dm @@ -115,7 +115,7 @@ if(isturf(target_loc) || (ismob(target_loc) && isturf(target_loc.loc))) return viewers(range, get_turf(target_loc)) else - return typecache_filter_list(target_loc.GetAllContents(), GLOB.typecache_living) + return typecache_filter_list(target_loc.get_all_contents(), GLOB.typecache_living) /obj/item/assembly/flash/proc/try_use_flash(mob/user = null) if(burnt_out || (world.time < last_trigger + cooldown)) diff --git a/code/modules/awaymissions/away_props.dm b/code/modules/awaymissions/away_props.dm index 02b6bc6a4ad..daf00cae2f9 100644 --- a/code/modules/awaymissions/away_props.dm +++ b/code/modules/awaymissions/away_props.dm @@ -46,7 +46,7 @@ /obj/effect/path_blocker/CanAllowThrough(atom/movable/mover, border_dir) . = ..() if(blocked_types.len) - var/list/mover_contents = mover.GetAllContents() + var/list/mover_contents = mover.get_all_contents() for(var/atom/movable/thing in mover_contents) if(blocked_types[thing.type]) return reverse diff --git a/code/modules/cargo/centcom_podlauncher.dm b/code/modules/cargo/centcom_podlauncher.dm index bf09c7ca5c2..df07b6c1828 100644 --- a/code/modules/cargo/centcom_podlauncher.dm +++ b/code/modules/cargo/centcom_podlauncher.dm @@ -781,9 +781,9 @@ selector.moveToNullspace() //Otherwise, we move the selector to nullspace until it is needed again /datum/centcom_podlauncher/proc/clearBay() //Clear all objs and mobs from the selected bay - for (var/obj/O in bay.GetAllContents()) + for (var/obj/O in bay.get_all_contents()) qdel(O) - for (var/mob/M in bay.GetAllContents()) + for (var/mob/M in bay.get_all_contents()) qdel(M) for (var/bayturf in bay) var/turf/turf_to_clear = bayturf diff --git a/code/modules/cargo/exports.dm b/code/modules/cargo/exports.dm index bf3e647dcee..b6900c38fca 100644 --- a/code/modules/cargo/exports.dm +++ b/code/modules/cargo/exports.dm @@ -33,7 +33,7 @@ Then the player gets the profit from selling his own wasted time. var/profit_ratio = 1 //Percentage that gets sent to the seller, rest goes to cargo. - var/list/contents = AM.GetAllContents() + var/list/contents = AM.get_all_contents() var/datum/export_report/report = external_report diff --git a/code/modules/cargo/supplypod.dm b/code/modules/cargo/supplypod.dm index 0cce41d4a88..b06ea002650 100644 --- a/code/modules/cargo/supplypod.dm +++ b/code/modules/cargo/supplypod.dm @@ -618,7 +618,7 @@ var/angle = effectCircle ? rand(0,360) : rand(70,110) //The angle that we can come in from pod.pixel_x = cos(angle)*32*length(smoke_effects) //Use some ADVANCED MATHEMATICS to set the animated pod's position to somewhere on the edge of a circle with the center being the pod_landingzone pod.pixel_z = sin(angle)*32*length(smoke_effects) - var/rotation = Get_Pixel_Angle(pod.pixel_z, pod.pixel_x) //CUSTOM HOMEBREWED proc that is just arctan with extra steps + var/rotation = get_pixel_angle(pod.pixel_z, pod.pixel_x) //CUSTOM HOMEBREWED proc that is just arctan with extra steps setupSmoke(rotation) pod.transform = matrix().Turn(rotation) pod.layer = FLY_LAYER diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index d15fecf34fd..e390061f2a2 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -529,7 +529,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list( return QDEL_HINT_HARDDEL_NOW /client/proc/set_client_age_from_db(connectiontopic) - if (IsGuestKey(src.key)) + if (is_guest_key(src.key)) return if(!SSdbcore.Connect()) return diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 6e72b0bf009..efe7eadf25e 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -97,7 +97,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) middleware += new middleware_type(src) if(istype(C)) - if(!IsGuestKey(C.key)) + if(!is_guest_key(C.key)) load_path(C.ckey) unlock_content = !!C.IsByondMember() if(unlock_content) diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm index 6f2f2a08dd1..9526864de93 100644 --- a/code/modules/clothing/clothing.dm +++ b/code/modules/clothing/clothing.dm @@ -308,7 +308,7 @@ if (pockets.can_hold?.len) // If pocket type can hold anything, vs only specific items how_cool_are_your_threads += "[src] can store [pockets.max_items] item\s.\n" else - how_cool_are_your_threads += "[src] can store [pockets.max_items] item\s that are [weightclass2text(pockets.max_w_class)] or smaller.\n" + how_cool_are_your_threads += "[src] can store [pockets.max_items] item\s that are [weight_class_to_text(pockets.max_w_class)] or smaller.\n" if(pockets.quickdraw) how_cool_are_your_threads += "You can quickly remove an item from [src] using Right-Click.\n" if(pockets.silent) diff --git a/code/modules/detectivework/evidence.dm b/code/modules/detectivework/evidence.dm index e6dc5148972..714d62d7aa7 100644 --- a/code/modules/detectivework/evidence.dm +++ b/code/modules/detectivework/evidence.dm @@ -36,7 +36,7 @@ to_chat(user, span_warning("You find putting an evidence bag in another evidence bag to be slightly absurd.")) return TRUE //now this is podracing - if(loc in I.GetAllContents()) // fixes tg #39452, evidence bags could store their own location, causing I to be stored in the bag while being present inworld still, and able to be teleported when removed. + if(loc in I.get_all_contents()) // fixes tg #39452, evidence bags could store their own location, causing I to be stored in the bag while being present inworld still, and able to be teleported when removed. to_chat(user, span_warning("You find putting [I] in [src] while it's still inside it quite difficult!")) return diff --git a/code/modules/explorer_drone/loot.dm b/code/modules/explorer_drone/loot.dm index b9d0ae4135d..4048a5034b1 100644 --- a/code/modules/explorer_drone/loot.dm +++ b/code/modules/explorer_drone/loot.dm @@ -176,7 +176,7 @@ GLOBAL_LIST_INIT(adventure_loot_generator_index,generate_generator_index()) var/turf/start_turf = get_turf(user) var/turf/last_turf = get_ranged_target_turf(start_turf,user.dir,melt_range) start_turf.Beam(last_turf,icon_state="solar_beam",time=1 SECONDS) - for(var/turf/turf_to_melt in getline(start_turf,last_turf)) + for(var/turf/turf_to_melt in get_line(start_turf,last_turf)) if(turf_to_melt.density) turf_to_melt.Melt() inhand_icon_state = initial(inhand_icon_state) diff --git a/code/modules/holodeck/area_copy.dm b/code/modules/holodeck/area_copy.dm index d6a656fcc36..5eb040b760c 100644 --- a/code/modules/holodeck/area_copy.dm +++ b/code/modules/holodeck/area_copy.dm @@ -123,13 +123,13 @@ GLOBAL_LIST_INIT(duplicate_forbidden_vars,list( var/obj/O2 = DuplicateObject(O , perfectcopy=TRUE, newloc = B, nerf=nerf_weapons, holoitem=TRUE) if(!O2) continue - copiedobjs += O2.GetAllContents() + copiedobjs += O2.get_all_contents() for(var/mob/M in T) if(iscameramob(M)) continue // If we need to check for more mobs, I'll add a variable var/mob/SM = DuplicateObject(M , perfectcopy=TRUE, newloc = B, holoitem=TRUE) - copiedobjs += SM.GetAllContents() + copiedobjs += SM.get_all_contents() for(var/V in T.vars - GLOB.duplicate_forbidden_vars) if(V == "air") diff --git a/code/modules/hydroponics/plant_genes.dm b/code/modules/hydroponics/plant_genes.dm index b1764a072b1..ab4e2c255a8 100644 --- a/code/modules/hydroponics/plant_genes.dm +++ b/code/modules/hydroponics/plant_genes.dm @@ -335,7 +335,7 @@ to_chat(eater, span_notice("You feel energized as you bite into [our_plant].")) var/batteries_recharged = FALSE var/obj/item/seeds/our_seed = our_plant.get_plant_seed() - for(var/obj/item/stock_parts/cell/found_cell in eater.GetAllContents()) + for(var/obj/item/stock_parts/cell/found_cell in eater.get_all_contents()) var/newcharge = min(our_seed.potency * 0.01 * found_cell.maxcharge, found_cell.maxcharge) if(found_cell.charge < newcharge) found_cell.charge = newcharge @@ -563,7 +563,7 @@ pocell.maxcharge *= (electrical_gene.rate * 100) pocell.charge = pocell.maxcharge pocell.name = "[our_plant.name] battery" - pocell.desc = "A rechargeable plant-based power cell. This one has a rating of [DisplayEnergy(pocell.maxcharge)], and you should not swallow it." + pocell.desc = "A rechargeable plant-based power cell. This one has a rating of [display_energy(pocell.maxcharge)], and you should not swallow it." if(our_plant.reagents.has_reagent(/datum/reagent/toxin/plasma, 2)) pocell.rigged = TRUE diff --git a/code/modules/mapping/mapping_helpers.dm b/code/modules/mapping/mapping_helpers.dm index d413b14f11a..d6192673915 100644 --- a/code/modules/mapping/mapping_helpers.dm +++ b/code/modules/mapping/mapping_helpers.dm @@ -201,7 +201,7 @@ INITIALIZE_IMMEDIATE(/obj/effect/mapping_helpers/no_lava) if(!ispath(component_type,/datum/component)) CRASH("Wrong component type in [type] - [component_type] is not a component") var/turf/T = get_turf(src) - for(var/atom/A in T.GetAllContents()) + for(var/atom/A in T.get_all_contents()) if(A == src) continue if(target_name && A.name != target_name) @@ -426,7 +426,7 @@ INITIALIZE_IMMEDIATE(/obj/effect/mapping_helpers/no_lava) CRASH("Wrong trait in [type] - [trait_name] is not a trait") var/turf/target_turf = get_turf(src) var/matches_found = 0 - for(var/a in target_turf.GetAllContents()) + for(var/a in target_turf.get_all_contents()) var/atom/atom_on_turf = a if(atom_on_turf == src) continue @@ -464,7 +464,7 @@ INITIALIZE_IMMEDIATE(/obj/effect/mapping_helpers/no_lava) var/I = fetch_icon(icon_url) var/turf/target_turf = get_turf(src) var/matches_found = 0 - for(var/a in target_turf.GetAllContents()) + for(var/a in target_turf.get_all_contents()) var/atom/atom_on_turf = a if(atom_on_turf == src) continue diff --git a/code/modules/mining/fulton.dm b/code/modules/mining/fulton.dm index 627d23d8eaa..4dec6836e60 100644 --- a/code/modules/mining/fulton.dm +++ b/code/modules/mining/fulton.dm @@ -182,7 +182,7 @@ GLOBAL_LIST_EMPTY(total_extraction_beacons) var/mob/living/L = A if(L.stat != DEAD) return TRUE - for(var/thing in A.GetAllContents()) + for(var/thing in A.get_all_contents()) if(isliving(A)) var/mob/living/L = A if(L.stat != DEAD) diff --git a/code/modules/mining/lavaland/megafauna_loot.dm b/code/modules/mining/lavaland/megafauna_loot.dm index dd5395495c4..4093f9b6ea6 100644 --- a/code/modules/mining/lavaland/megafauna_loot.dm +++ b/code/modules/mining/lavaland/megafauna_loot.dm @@ -664,7 +664,7 @@ /obj/item/melee/ghost_sword/proc/ghost_check() var/ghost_counter = 0 var/turf/T = get_turf(src) - var/list/contents = T.GetAllContents() + var/list/contents = T.get_all_contents() var/mob/dead/observer/current_spirits = list() for(var/thing in contents) var/atom/A = thing diff --git a/code/modules/mob/living/carbon/human/species_types/dullahan.dm b/code/modules/mob/living/carbon/human/species_types/dullahan.dm index c8f4b4260d7..52db68a3da9 100644 --- a/code/modules/mob/living/carbon/human/species_types/dullahan.dm +++ b/code/modules/mob/living/carbon/human/species_types/dullahan.dm @@ -161,7 +161,7 @@ if(admin_revive) var/obj/item/bodypart/head/H = loc var/turf/T = get_turf(owner) - if(H && istype(H) && T && !(H in owner.GetAllContents())) + if(H && istype(H) && T && !(H in owner.get_all_contents())) H.forceMove(T) /obj/item/dullahan_relay/Destroy() diff --git a/code/modules/mob/living/silicon/pai/personality.dm b/code/modules/mob/living/silicon/pai/personality.dm index d33891fd253..9b866d1560e 100644 --- a/code/modules/mob/living/silicon/pai/personality.dm +++ b/code/modules/mob/living/silicon/pai/personality.dm @@ -11,7 +11,7 @@ return "data/player_saves/[user.ckey[1]]/[user.ckey]/pai.sav" /datum/pai_candidate/proc/savefile_save(mob/user) - if(IsGuestKey(user.key)) + if(is_guest_key(user.key)) return FALSE var/savefile/F = new /savefile(src.savefile_path(user)) @@ -32,7 +32,7 @@ // returns 0 if savefile did not exist /datum/pai_candidate/proc/savefile_load(mob/user, silent = TRUE) - if (IsGuestKey(user.key)) + if (is_guest_key(user.key)) return 0 var/path = savefile_path(user) diff --git a/code/modules/mob/living/silicon/silicon.dm b/code/modules/mob/living/silicon/silicon.dm index d2bf8f02555..aab86589794 100644 --- a/code/modules/mob/living/silicon/silicon.dm +++ b/code/modules/mob/living/silicon/silicon.dm @@ -210,7 +210,7 @@ for (var/index in 1 to length(lawcache_hacked)) var/law = lawcache_hacked[index] - var/num = ionnum() + var/num = ion_num() if (length(law) > 0) if (force || lawcache_hackedcheck[index] == "Yes") say("[radiomod] [num]. [law]") @@ -218,7 +218,7 @@ for (var/index in 1 to length(lawcache_ion)) var/law = lawcache_ion[index] - var/num = ionnum() + var/num = ion_num() if (length(law) > 0) if (force || lawcache_ioncheck[index] == "Yes") say("[radiomod] [num]. [law]") @@ -258,7 +258,7 @@ if (length(law) > 0) if (!hackedcheck[index]) hackedcheck[index] = "No" - list += {"[hackedcheck[index]] [ionnum()]:[law]
"} + list += {"[hackedcheck[index]] [ion_num()]:[law]
"} hackedcheck.len += 1 for (var/index = 1, index <= laws.ion.len, index++) @@ -267,7 +267,7 @@ if (length(law) > 0) if (!ioncheck[index]) ioncheck[index] = "Yes" - list += {"[ioncheck[index]] [ionnum()]:[law]
"} + list += {"[ioncheck[index]] [ion_num()]:[law]
"} ioncheck.len += 1 var/number = 1 diff --git a/code/modules/mob/living/simple_animal/hostile/hostile.dm b/code/modules/mob/living/simple_animal/hostile/hostile.dm index 35ba82d91b8..885036406ec 100644 --- a/code/modules/mob/living/simple_animal/hostile/hostile.dm +++ b/code/modules/mob/living/simple_animal/hostile/hostile.dm @@ -397,7 +397,7 @@ /mob/living/simple_animal/hostile/proc/CheckFriendlyFire(atom/A) if(check_friendly_fire) - for(var/turf/T in getline(src,A)) // Not 100% reliable but this is faster than simulating actual trajectory + for(var/turf/T in get_line(src,A)) // Not 100% reliable but this is faster than simulating actual trajectory for(var/mob/living/L in T) if(L == src || L == A) continue diff --git a/code/modules/mob/living/simple_animal/hostile/jungle/seedling.dm b/code/modules/mob/living/simple_animal/hostile/jungle/seedling.dm index 82c0e0d1f91..0c8e2b15ef4 100644 --- a/code/modules/mob/living/simple_animal/hostile/jungle/seedling.dm +++ b/code/modules/mob/living/simple_animal/hostile/jungle/seedling.dm @@ -95,7 +95,7 @@ return ..() /datum/status_effect/seedling_beam_indicator/tick() - var/target_angle = Get_Angle(owner, target) + var/target_angle = get_angle(owner, target) var/matrix/final = matrix() final.Turn(target_angle) seedling_screen_object.transform = final diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/blood_drunk_miner.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/blood_drunk_miner.dm index e482b49d548..5d7db2d53db 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/blood_drunk_miner.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/blood_drunk_miner.dm @@ -221,7 +221,7 @@ Difficulty: Medium turf_dist_to_target += get_dist(dash_target, O) if(get_dist(src, O) >= MINER_DASH_RANGE && turf_dist_to_target <= self_dist_to_target && !islava(O) && !ischasm(O)) var/valid = TRUE - for(var/turf/T in getline(own_turf, O)) + for(var/turf/T in get_line(own_turf, O)) if(T.is_blocked_turf(TRUE)) valid = FALSE continue diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/colossus.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/colossus.dm index acff8017102..09d4fc0472c 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/colossus.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/colossus.dm @@ -201,7 +201,7 @@ var/turf/target_turf = get_turf(target) playsound(src, 'sound/magic/clockwork/invoke_general.ogg', 200, TRUE, 2) newtonian_move(get_dir(target_turf, src)) - var/angle_to_target = Get_Angle(src, target_turf) + var/angle_to_target = get_angle(src, target_turf) if(isnum(set_angle)) angle_to_target = set_angle var/static/list/colossus_shotgun_shot_angles = list(12.5, 7.5, 2.5, -2.5, -7.5, -12.5) diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/drake.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/drake.dm index 1d35c00ed67..cf34f0f4520 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/drake.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/drake.dm @@ -271,7 +271,7 @@ if(!at) return var/turf/T = get_ranged_target_turf_direct(src, at, range, offset) - return (getline(src, T) - get_turf(src)) + return (get_line(src, T) - get_turf(src)) /mob/living/simple_animal/hostile/megafauna/dragon/proc/fire_line(list/turfs) SLEEP_CHECK_DEATH(0) diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/legion.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/legion.dm index 58cf9033be4..2af2448d829 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/legion.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/legion.dm @@ -296,7 +296,7 @@ if(!T || !T1) return //Now we generate the tracer. - var/angle = Get_Angle(T1, T) + var/angle = get_angle(T1, T) var/datum/point/vector/V = new(T1.x, T1.y, T1.z, 0, 0, angle) generate_tracer_between_points(V, V.return_vector_after_increments(6), /obj/effect/projectile/tracer/legion/tracer, 0, shot_delay, 0, 0, 0, null) playsound(src, 'sound/machines/airlockopen.ogg', 100, TRUE) diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/wendigo.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/wendigo.dm index 43e0b00d00f..d927d69c66f 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/wendigo.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/wendigo.dm @@ -235,7 +235,7 @@ Difficulty: Hard SLEEP_CHECK_DEATH(6 - WENDIGO_ENRAGED * 2) if("Spiral") var/shots_spiral = WENDIGO_SPIRAL_SHOTCOUNT - var/angle_to_target = Get_Angle(src, target) + var/angle_to_target = get_angle(src, target) var/spiral_direction = pick(-1, 1) for(var/shot in 1 to shots_spiral) var/shots_per_tick = 5 - WENDIGO_ENRAGED * 3 diff --git a/code/modules/mob/living/simple_animal/hostile/mining_mobs/elites/herald.dm b/code/modules/mob/living/simple_animal/hostile/mining_mobs/elites/herald.dm index 6f3cc1e2991..86246326b7a 100644 --- a/code/modules/mob/living/simple_animal/hostile/mining_mobs/elites/herald.dm +++ b/code/modules/mob/living/simple_animal/hostile/mining_mobs/elites/herald.dm @@ -143,7 +143,7 @@ ranged_cooldown = world.time + 30 playsound(get_turf(src), 'sound/magic/clockwork/invoke_general.ogg', 20, TRUE) var/target_turf = get_turf(target) - var/angle_to_target = Get_Angle(src, target_turf) + var/angle_to_target = get_angle(src, target_turf) shoot_projectile(target_turf, angle_to_target, FALSE, TRUE) addtimer(CALLBACK(src, .proc/shoot_projectile, target_turf, angle_to_target, FALSE, TRUE), 2) addtimer(CALLBACK(src, .proc/shoot_projectile, target_turf, angle_to_target, FALSE, TRUE), 4) @@ -178,7 +178,7 @@ ranged_cooldown = world.time + 30 playsound(get_turf(src), 'sound/magic/clockwork/invoke_general.ogg', 20, TRUE) var/target_turf = get_turf(target) - var/angle_to_target = Get_Angle(src, target_turf) + var/angle_to_target = get_angle(src, target_turf) shoot_projectile(target_turf, angle_to_target, TRUE, FALSE) /mob/living/simple_animal/hostile/asteroid/elite/herald/proc/herald_mirror() diff --git a/code/modules/mob/living/simple_animal/hostile/mining_mobs/ice whelp.dm b/code/modules/mob/living/simple_animal/hostile/mining_mobs/ice whelp.dm index 42b0d75dea4..6ab0f8ada88 100644 --- a/code/modules/mob/living/simple_animal/hostile/mining_mobs/ice whelp.dm +++ b/code/modules/mob/living/simple_animal/hostile/mining_mobs/ice whelp.dm @@ -43,7 +43,7 @@ /mob/living/simple_animal/hostile/asteroid/ice_whelp/Shoot() var/turf/target_fire_turf = get_ranged_target_turf_direct(src, target, fire_range) - var/list/burn_turfs = getline(src, target_fire_turf) - get_turf(src) + var/list/burn_turfs = get_line(src, target_fire_turf) - get_turf(src) dragon_fire_line(src, burn_turfs, frozen = TRUE) /mob/living/simple_animal/hostile/asteroid/ice_whelp/Life(delta_time = SSMOBS_DT, times_fired) diff --git a/code/modules/mob/living/simple_animal/hostile/space_dragon.dm b/code/modules/mob/living/simple_animal/hostile/space_dragon.dm index 37d451cf136..ea0c486adc3 100644 --- a/code/modules/mob/living/simple_animal/hostile/space_dragon.dm +++ b/code/modules/mob/living/simple_animal/hostile/space_dragon.dm @@ -283,7 +283,7 @@ if(!check) break T = check - return (getline(src, T) - get_turf(src)) + return (get_line(src, T) - get_turf(src)) /** * Spawns fire at each position in a line from the source to the target. diff --git a/code/modules/mob/living/simple_animal/hostile/venus_human_trap.dm b/code/modules/mob/living/simple_animal/hostile/venus_human_trap.dm index db9db1a4547..0da10a35c4e 100644 --- a/code/modules/mob/living/simple_animal/hostile/venus_human_trap.dm +++ b/code/modules/mob/living/simple_animal/hostile/venus_human_trap.dm @@ -161,7 +161,7 @@ return if(get_dist(src,the_target) > vine_grab_distance || vines.len >= max_vines) return - for(var/turf/T in getline(src,target)) + for(var/turf/T in get_line(src,target)) if (T.density) return for(var/obj/O in T) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 2fa09a584a4..10d7e1b0235 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -1082,7 +1082,7 @@ ///update the ID name of this mob /mob/proc/replace_identification_name(oldname,newname) - var/list/searching = GetAllContents() + var/list/searching = get_all_contents() var/search_id = 1 var/search_pda = 1 diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index 65b9c06fb1d..6e357a317eb 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -234,7 +234,7 @@ if(target) L.forceMove(target) var/limit = 2//For only two trailing shadows. - for(var/turf/T in getline(mobloc, L.loc)) + for(var/turf/T in get_line(mobloc, L.loc)) new /obj/effect/temp_visual/dir_setting/ninja/shadow(T, L.dir) limit-- if(limit<=0) diff --git a/code/modules/modular_computers/file_system/programs/powermonitor.dm b/code/modules/modular_computers/file_system/programs/powermonitor.dm index d2bd38d9116..e5f350f8609 100644 --- a/code/modules/modular_computers/file_system/programs/powermonitor.dm +++ b/code/modules/modular_computers/file_system/programs/powermonitor.dm @@ -80,8 +80,8 @@ data["interval"] = record_interval / 10 data["attached"] = connected_powernet ? TRUE : FALSE if(connected_powernet) - data["supply"] = DisplayPower(connected_powernet.viewavail) - data["demand"] = DisplayPower(connected_powernet.viewload) + data["supply"] = display_power(connected_powernet.viewavail) + data["demand"] = display_power(connected_powernet.viewload) data["history"] = history data["areas"] = list() @@ -92,7 +92,7 @@ data["areas"] += list(list( "name" = A.area.name, "charge" = A.cell ? A.cell.percent() : 0, - "load" = DisplayPower(A.lastused_total), + "load" = display_power(A.lastused_total), "charging" = A.charging, "eqp" = A.equipment, "lgt" = A.lighting, diff --git a/code/modules/modular_computers/file_system/programs/radar.dm b/code/modules/modular_computers/file_system/programs/radar.dm index 6de48b76b7f..4764e114c95 100644 --- a/code/modules/modular_computers/file_system/programs/radar.dm +++ b/code/modules/modular_computers/file_system/programs/radar.dm @@ -98,7 +98,7 @@ if(get_dist_euclidian(here_turf, target_turf) > 24) userot = TRUE - rot = round(Get_Angle(here_turf, target_turf)) + rot = round(get_angle(here_turf, target_turf)) else if(target_turf.z > here_turf.z) pointer="caret-up" diff --git a/code/modules/ninja/suit/gloves.dm b/code/modules/ninja/suit/gloves.dm index 5e66356db7c..f551cf3d99c 100644 --- a/code/modules/ninja/suit/gloves.dm +++ b/code/modules/ninja/suit/gloves.dm @@ -57,7 +57,7 @@ if(isnum(.)) //Numerical values of drained handle their feedback here, Alpha values handle it themselves (Research hacking) if(.) - to_chat(wearer, span_notice("Gained [DisplayEnergy(.)] of energy from [A].")) + to_chat(wearer, span_notice("Gained [display_energy(.)] of energy from [A].")) else to_chat(wearer, span_danger("\The [A] has run dry of energy, you must find another source!")) else diff --git a/code/modules/ninja/suit/ninja_equipment_actions/ninja_net.dm b/code/modules/ninja/suit/ninja_equipment_actions/ninja_net.dm index 0b58a65b210..fbfc53f2d93 100644 --- a/code/modules/ninja/suit/ninja_equipment_actions/ninja_net.dm +++ b/code/modules/ninja/suit/ninja_equipment_actions/ninja_net.dm @@ -20,7 +20,7 @@ if(locate(/obj/structure/energy_net) in get_turf(net_target))//Check if they are already being affected by an energy net. to_chat(ninja, span_warning("[net_target.p_they(TRUE)] are already trapped inside an energy net!")) return - for(var/turf/between_turf in getline(get_turf(ninja), get_turf(net_target))) + for(var/turf/between_turf in get_line(get_turf(ninja), get_turf(net_target))) if(between_turf.density)//Don't want them shooting nets through walls. It's kind of cheesy. to_chat(ninja, span_warning("You may not use an energy net through solid obstacles!")) return diff --git a/code/modules/ninja/suit/ninja_equipment_actions/ninja_suit_initialisation.dm b/code/modules/ninja/suit/ninja_equipment_actions/ninja_suit_initialisation.dm index 945b8fb249d..4220cca57df 100644 --- a/code/modules/ninja/suit/ninja_equipment_actions/ninja_suit_initialisation.dm +++ b/code/modules/ninja/suit/ninja_equipment_actions/ninja_suit_initialisation.dm @@ -72,7 +72,7 @@ GLOBAL_LIST_INIT(ninja_deinitialize_messages, list( lockIcons(ninja)//Check for icons. ninja.regenerate_icons() if (NINJA_COMPLETE_PHASE - 1) - message += "[DisplayEnergy(cell.charge)]." + message += "[display_energy(cell.charge)]." if (NINJA_COMPLETE_PHASE) message += "[ninja.real_name]." s_initialized = TRUE diff --git a/code/modules/ninja/suit/suit.dm b/code/modules/ninja/suit/suit.dm index 74690539e25..886fc88449e 100644 --- a/code/modules/ninja/suit/suit.dm +++ b/code/modules/ninja/suit/suit.dm @@ -63,7 +63,7 @@ return if(!user == affecting) return - . += "All systems operational. Current energy capacity: [DisplayEnergy(cell.charge)].\n"+\ + . += "All systems operational. Current energy capacity: [display_energy(cell.charge)].\n"+\ "The CLOAK-tech device is [stealth?"active":"inactive"].\n"+\ "[a_boost?"An adrenaline boost is available to use.":"There is no adrenaline boost available. Try refilling the suit with 20 units of radium."]" diff --git a/code/modules/paperwork/handlabeler.dm b/code/modules/paperwork/handlabeler.dm index 687f4fe4f6b..243006f9c8c 100644 --- a/code/modules/paperwork/handlabeler.dm +++ b/code/modules/paperwork/handlabeler.dm @@ -15,7 +15,7 @@ var/old_real_name = user.real_name user.real_name += " (suicide)" // no conflicts with their identification card - for(var/atom/A in user.GetAllContents()) + for(var/atom/A in user.get_all_contents()) if(istype(A, /obj/item/card/id)) var/obj/item/card/id/their_card = A diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index c5ab67315c8..754b66f82e5 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -939,7 +939,7 @@ "powerCellStatus" = cell ? cell.percent() : null, "chargeMode" = chargemode, "chargingStatus" = charging, - "totalLoad" = DisplayPower(lastused_total), + "totalLoad" = display_power(lastused_total), "coverLocked" = coverlocked, "siliconUser" = user.has_unlimited_silicon_privilege || user.using_power_flow_console(), "malfStatus" = get_malf_status(user), @@ -949,7 +949,7 @@ "powerChannels" = list( list( "title" = "Equipment", - "powerLoad" = DisplayPower(lastused_equip), + "powerLoad" = display_power(lastused_equip), "status" = equipment, "topicParams" = list( "auto" = list("eqp" = 3), @@ -959,7 +959,7 @@ ), list( "title" = "Lighting", - "powerLoad" = DisplayPower(lastused_light), + "powerLoad" = display_power(lastused_light), "status" = lighting, "topicParams" = list( "auto" = list("lgt" = 3), @@ -969,7 +969,7 @@ ), list( "title" = "Environment", - "powerLoad" = DisplayPower(lastused_environ), + "powerLoad" = display_power(lastused_environ), "status" = environ, "topicParams" = list( "auto" = list("env" = 3), diff --git a/code/modules/power/cable.dm b/code/modules/power/cable.dm index a8c8d4da047..42d21c56ee6 100644 --- a/code/modules/power/cable.dm +++ b/code/modules/power/cable.dm @@ -180,7 +180,7 @@ GLOBAL_LIST_INIT(wire_node_generating_types, typecacheof(list(/obj/structure/gri /obj/structure/cable/proc/get_power_info() if(powernet?.avail > 0) - return span_danger("Total power: [DisplayPower(powernet.avail)]\nLoad: [DisplayPower(powernet.load)]\nExcess power: [DisplayPower(surplus())]") + return span_danger("Total power: [display_power(powernet.avail)]\nLoad: [display_power(powernet.load)]\nExcess power: [display_power(surplus())]") else return span_danger("The cable is not powered.") diff --git a/code/modules/power/cell.dm b/code/modules/power/cell.dm index 1409b7e6988..f0073561d49 100644 --- a/code/modules/power/cell.dm +++ b/code/modules/power/cell.dm @@ -47,7 +47,7 @@ maxcharge = override_maxcharge charge = maxcharge if(ratingdesc) - desc += " This one has a rating of [DisplayEnergy(maxcharge)], and you should not swallow it." + desc += " This one has a rating of [display_energy(maxcharge)], and you should not swallow it." update_appearance() /obj/item/stock_parts/cell/create_reagents(max_vol, flags) diff --git a/code/modules/power/generator.dm b/code/modules/power/generator.dm index d6a411431ca..c82d8f38fbc 100644 --- a/code/modules/power/generator.dm +++ b/code/modules/power/generator.dm @@ -113,7 +113,7 @@ t += "
" - t += "Output: [DisplayPower(lastgenlev)]" + t += "Output: [display_power(lastgenlev)]" t += "
" diff --git a/code/modules/power/monitor.dm b/code/modules/power/monitor.dm index e5e6099a25f..5802c49a167 100644 --- a/code/modules/power/monitor.dm +++ b/code/modules/power/monitor.dm @@ -98,8 +98,8 @@ data["areas"] = list() if(connected_powernet) - data["supply"] = DisplayPower(connected_powernet.viewavail) - data["demand"] = DisplayPower(connected_powernet.viewload) + data["supply"] = display_power(connected_powernet.viewavail) + data["demand"] = display_power(connected_powernet.viewload) for(var/obj/machinery/power/terminal/term in connected_powernet.nodes) var/obj/machinery/power/apc/A = term.master if(istype(A)) @@ -111,7 +111,7 @@ data["areas"] += list(list( "name" = A.area.name, "charge" = cell_charge, - "load" = DisplayPower(A.lastused_total), + "load" = display_power(A.lastused_total), "charging" = A.charging, "eqp" = A.equipment, "lgt" = A.lighting, diff --git a/code/modules/power/port_gen.dm b/code/modules/power/port_gen.dm index 0dbab13c099..440bcdce570 100644 --- a/code/modules/power/port_gen.dm +++ b/code/modules/power/port_gen.dm @@ -119,7 +119,7 @@ /obj/machinery/power/port_gen/pacman/examine(mob/user) . = ..() - . += span_notice("The generator has [sheets] units of [sheet_name] fuel left, producing [DisplayPower(power_gen)] per cycle.") + . += span_notice("The generator has [sheets] units of [sheet_name] fuel left, producing [display_power(power_gen)] per cycle.") if(anchored) . += span_notice("It is anchored to the ground.") if(in_range(user, src) || isobserver(user)) @@ -245,9 +245,9 @@ data["anchored"] = anchored data["connected"] = (powernet == null ? 0 : 1) data["ready_to_boot"] = anchored && HasFuel() - data["power_generated"] = DisplayPower(power_gen) - data["power_output"] = DisplayPower(power_gen * power_output) - data["power_available"] = (powernet == null ? 0 : DisplayPower(avail())) + data["power_generated"] = display_power(power_gen) + data["power_output"] = display_power(power_gen * power_output) + data["power_available"] = (powernet == null ? 0 : display_power(avail())) data["current_heat"] = current_heat . = data diff --git a/code/modules/power/singularity/collector.dm b/code/modules/power/singularity/collector.dm index f8ae9c1b943..827eceac4eb 100644 --- a/code/modules/power/singularity/collector.dm +++ b/code/modules/power/singularity/collector.dm @@ -160,7 +160,7 @@ // Therefore, its units are joules per SSmachines.wait * 0.1 seconds. // So joules = stored_energy * SSmachines.wait * 0.1 var/joules = stored_energy * SSmachines.wait * 0.1 - . += span_notice("[src]'s display states that it has stored [DisplayJoules(joules)], and is processing [DisplayPower(RAD_COLLECTOR_OUTPUT)].") + . += span_notice("[src]'s display states that it has stored [display_joules(joules)], and is processing [display_power(RAD_COLLECTOR_OUTPUT)].") /obj/machinery/power/rad_collector/atom_break(damage_flag) . = ..() diff --git a/code/modules/power/singularity/emitter.dm b/code/modules/power/singularity/emitter.dm index 19298843cdd..d9105c4d386 100644 --- a/code/modules/power/singularity/emitter.dm +++ b/code/modules/power/singularity/emitter.dm @@ -130,7 +130,7 @@ . += span_notice("Its status display is glowing faintly.") else . += span_notice("Its status display reads: Emitting one beam every [DisplayTimeText(fire_delay)].") - . += span_notice("Power consumption at [DisplayPower(active_power_usage)].") + . += span_notice("Power consumption at [display_power(active_power_usage)].") /obj/machinery/power/emitter/ComponentInitialize() . = ..() diff --git a/code/modules/power/smes.dm b/code/modules/power/smes.dm index 504bb6282f8..781b2aeaee7 100644 --- a/code/modules/power/smes.dm +++ b/code/modules/power/smes.dm @@ -323,13 +323,13 @@ "inputAttempt" = input_attempt, "inputting" = inputting, "inputLevel" = input_level, - "inputLevel_text" = DisplayPower(input_level), + "inputLevel_text" = display_power(input_level), "inputLevelMax" = input_level_max, "inputAvailable" = input_available, "outputAttempt" = output_attempt, "outputting" = outputting, "outputLevel" = output_level, - "outputLevel_text" = DisplayPower(output_level), + "outputLevel_text" = display_power(output_level), "outputLevelMax" = output_level_max, "outputUsed" = output_used, ) diff --git a/code/modules/power/turbine.dm b/code/modules/power/turbine.dm index 4e756f9a154..0b6e5aab432 100644 --- a/code/modules/power/turbine.dm +++ b/code/modules/power/turbine.dm @@ -263,7 +263,7 @@ data["turbine"] = compressor?.turbine ? TRUE : FALSE data["turbine_broke"] = (!compressor || !compressor.turbine || (compressor.turbine.machine_stat & BROKEN)) ? TRUE : FALSE data["online"] = compressor?.starter - data["power"] = DisplayPower(compressor?.turbine?.lastgen) + data["power"] = display_power(compressor?.turbine?.lastgen) data["rpm"] = compressor?.rpm data["temp"] = compressor?.gas_contained.temperature return data @@ -325,7 +325,7 @@ data["turbine"] = compressor?.turbine ? TRUE : FALSE data["turbine_broke"] = (!compressor || !compressor.turbine || (compressor.turbine.machine_stat & BROKEN)) ? TRUE : FALSE data["online"] = compressor?.starter - data["power"] = DisplayPower(compressor?.turbine?.lastgen) + data["power"] = display_power(compressor?.turbine?.lastgen) data["rpm"] = compressor?.rpm data["temp"] = compressor?.gas_contained.temperature return data diff --git a/code/modules/projectiles/guns/energy/dueling.dm b/code/modules/projectiles/guns/energy/dueling.dm index 511c7e0ba3a..2dcd6a9b252 100644 --- a/code/modules/projectiles/guns/energy/dueling.dm +++ b/code/modules/projectiles/guns/energy/dueling.dm @@ -123,7 +123,7 @@ return FALSE if(get_dist(A,B) != required_distance) return FALSE - for(var/turf/T in getline(get_turf(A),get_turf(B))) + for(var/turf/T in get_line(get_turf(A),get_turf(B))) if(T.is_blocked_turf(TRUE)) return FALSE return TRUE diff --git a/code/modules/projectiles/guns/energy/kinetic_accelerator.dm b/code/modules/projectiles/guns/energy/kinetic_accelerator.dm index aa134817764..d1ea5c6f6d7 100644 --- a/code/modules/projectiles/guns/energy/kinetic_accelerator.dm +++ b/code/modules/projectiles/guns/energy/kinetic_accelerator.dm @@ -127,7 +127,7 @@ var/carried = 0 if(!unique_frequency) - for(var/obj/item/gun/energy/kinetic_accelerator/K in loc.GetAllContents()) + for(var/obj/item/gun/energy/kinetic_accelerator/K in loc.get_all_contents()) if(!K.unique_frequency) carried++ diff --git a/code/modules/projectiles/guns/special/medbeam.dm b/code/modules/projectiles/guns/special/medbeam.dm index d54cfb3750e..f7773b25e42 100644 --- a/code/modules/projectiles/guns/special/medbeam.dm +++ b/code/modules/projectiles/guns/special/medbeam.dm @@ -103,7 +103,7 @@ dummy.pass_flags |= PASSTABLE|PASSGLASS|PASSGRILLE //Grille/Glass so it can be used through common windows var/turf/previous_step = user_turf var/first_step = TRUE - for(var/turf/next_step as anything in (getline(user_turf, target) - user_turf)) + for(var/turf/next_step as anything in (get_line(user_turf, target) - user_turf)) if(first_step) for(var/obj/blocker in user_turf) if(!blocker.density || !(blocker.flags_1 & ON_BORDER_1)) diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index 18d68621fc1..12e0e0eecd3 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -316,13 +316,13 @@ for(var/mob/living/L in range(ricochet_auto_aim_range, src.loc)) if(L.stat == DEAD || !is_in_sight(src, L)) continue - var/our_angle = abs(closer_angle_difference(Angle, Get_Angle(src.loc, L.loc))) + var/our_angle = abs(closer_angle_difference(Angle, get_angle(src.loc, L.loc))) if(our_angle < best_angle) best_angle = our_angle unlucky_sob = L if(unlucky_sob) - set_angle(Get_Angle(src, unlucky_sob.loc)) + set_angle(get_angle(src, unlucky_sob.loc)) /obj/projectile/proc/store_hitscan_collision(datum/point/point_cache) beam_segments[beam_index] = point_cache @@ -626,7 +626,7 @@ /obj/projectile/proc/return_pathing_turfs_in_moves(moves, forced_angle) var/turf/current = get_turf(src) var/turf/ending = return_predicted_turf_after_moves(moves, forced_angle) - return getline(current, ending) + return get_line(current, ending) /obj/projectile/Process_Spacemove(movement_dir = 0) return TRUE //Bullets don't drift in space @@ -678,7 +678,7 @@ qdel(src) return var/turf/target = locate(clamp(starting + xo, 1, world.maxx), clamp(starting + yo, 1, world.maxy), starting.z) - set_angle(Get_Angle(src, target)) + set_angle(get_angle(src, target)) original_angle = Angle if(!nondirectional_sprite) var/matrix/matrix = new @@ -870,7 +870,7 @@ if(targloc || !length(modifiers)) yo = targloc.y - curloc.y xo = targloc.x - curloc.x - set_angle(Get_Angle(src, targloc) + spread) + set_angle(get_angle(src, targloc) + spread) if(isliving(source) && length(modifiers)) var/list/calculated = calculate_projectile_angle_and_pixel_offsets(source, modifiers) @@ -881,7 +881,7 @@ else if(targloc) yo = targloc.y - curloc.y xo = targloc.x - curloc.x - set_angle(Get_Angle(src, targloc) + spread) + set_angle(get_angle(src, targloc) + spread) else stack_trace("WARNING: Projectile [type] fired without either mouse parameters, or a target atom to aim at!") qdel(src) diff --git a/code/modules/reagents/chem_splash.dm b/code/modules/reagents/chem_splash.dm index f655f8321bb..5f1c8975457 100644 --- a/code/modules/reagents/chem_splash.dm +++ b/code/modules/reagents/chem_splash.dm @@ -58,7 +58,7 @@ break var/list/reactable = accessible for(var/turf/T in accessible) - for(var/atom/A in T.GetAllContents()) + for(var/atom/A in T.get_all_contents()) if(!(A in viewable)) continue reactable |= A diff --git a/code/modules/recycling/sortingmachinery.dm b/code/modules/recycling/sortingmachinery.dm index fb3d5ab9983..add1e8fbeca 100644 --- a/code/modules/recycling/sortingmachinery.dm +++ b/code/modules/recycling/sortingmachinery.dm @@ -114,7 +114,7 @@ sticker.payments_acc = tagger.payments_acc //new tag gets the tagger's current account. sticker.cut_multiplier = tagger.cut_multiplier //same, but for the percentage taken. - var/list/wrap_contents = src.GetAllContents() + var/list/wrap_contents = src.get_all_contents() for(var/obj/I in wrap_contents) I.AddComponent(/datum/component/pricetag, sticker.payments_acc, tagger.cut_multiplier) var/overlaystring = "[icon_state]_tag" @@ -133,7 +133,7 @@ to_chat(user, span_warning("For some reason, you can't attach [W]!")) return sticker = stickerA - var/list/wrap_contents = src.GetAllContents() + var/list/wrap_contents = src.get_all_contents() for(var/obj/I in wrap_contents) I.AddComponent(/datum/component/pricetag, sticker.payments_acc, sticker.cut_multiplier) var/overlaystring = "[icon_state]_tag" @@ -167,7 +167,7 @@ /obj/structure/big_delivery/proc/unwrap_contents() if(!sticker) return - for(var/obj/I in src.GetAllContents()) + for(var/obj/I in src.get_all_contents()) SEND_SIGNAL(I, COMSIG_STRUCTURE_UNWRAPPED) /obj/structure/big_delivery/proc/disposal_handling(disposal_source, obj/structure/disposalholder/disposal_holder, obj/machinery/disposal/disposal_machine, hasmob) @@ -307,7 +307,7 @@ sticker.payments_acc = tagger.payments_acc //new tag gets the tagger's current account. sticker.cut_multiplier = tagger.cut_multiplier //as above, as before. - var/list/wrap_contents = src.GetAllContents() + var/list/wrap_contents = src.get_all_contents() for(var/obj/I in wrap_contents) I.AddComponent(/datum/component/pricetag, sticker.payments_acc, tagger.cut_multiplier) var/overlaystring = "[icon_state]_tag" @@ -327,7 +327,7 @@ to_chat(user, span_warning("For some reason, you can't attach [W]!")) return sticker = stickerA - var/list/wrap_contents = src.GetAllContents() + var/list/wrap_contents = src.get_all_contents() for(var/obj/I in wrap_contents) I.AddComponent(/datum/component/pricetag, sticker.payments_acc, sticker.cut_multiplier) var/overlaystring = "[icon_state]_tag" @@ -338,7 +338,7 @@ /obj/item/small_delivery/proc/unwrap_contents() if(!sticker) return - for(var/obj/I in src.GetAllContents()) + for(var/obj/I in src.get_all_contents()) SEND_SIGNAL(I, COMSIG_ITEM_UNWRAPPED) /obj/item/small_delivery/proc/disposal_handling(disposal_source, obj/structure/disposalholder/disposal_holder, obj/machinery/disposal/disposal_machine, hasmob) diff --git a/code/modules/research/xenobiology/crossbreeding/_status_effects.dm b/code/modules/research/xenobiology/crossbreeding/_status_effects.dm index 5c8c7671f4c..a2ed1aa1640 100644 --- a/code/modules/research/xenobiology/crossbreeding/_status_effects.dm +++ b/code/modules/research/xenobiology/crossbreeding/_status_effects.dm @@ -527,7 +527,7 @@ else cooldown = max_cooldown var/list/sheets = list() - for(var/obj/item/stack/sheet/S in owner.GetAllContents()) + for(var/obj/item/stack/sheet/S in owner.get_all_contents()) if(S.amount < S.max_amount) sheets += S @@ -552,7 +552,7 @@ return ..() cooldown = max_cooldown var/list/batteries = list() - for(var/obj/item/stock_parts/cell/C in owner.GetAllContents()) + for(var/obj/item/stock_parts/cell/C in owner.get_all_contents()) if(C.charge < C.maxcharge) batteries += C if(batteries.len) diff --git a/code/modules/research/xenobiology/crossbreeding/regenerative.dm b/code/modules/research/xenobiology/crossbreeding/regenerative.dm index b8bc272120b..efe03c7ef51 100644 --- a/code/modules/research/xenobiology/crossbreeding/regenerative.dm +++ b/code/modules/research/xenobiology/crossbreeding/regenerative.dm @@ -81,7 +81,7 @@ Regenerative extracts: /obj/item/slimecross/regenerative/yellow/core_effect(mob/living/target, mob/user) var/list/batteries = list() - for(var/obj/item/stock_parts/cell/C in target.GetAllContents()) + for(var/obj/item/stock_parts/cell/C in target.get_all_contents()) if(C.charge < C.maxcharge) batteries += C if(batteries.len) diff --git a/code/modules/shuttle/shuttle.dm b/code/modules/shuttle/shuttle.dm index c09c1ef4f35..1707fb606b9 100644 --- a/code/modules/shuttle/shuttle.dm +++ b/code/modules/shuttle/shuttle.dm @@ -593,7 +593,7 @@ // Loop over mobs for(var/t in return_turfs()) var/turf/T = t - for(var/mob/living/M in T.GetAllContents()) + for(var/mob/living/M in T.get_all_contents()) // If they have a mind and they're not in the brig, they escaped if(M.mind && !istype(t, /turf/open/floor/mineral/plastitanium/red/brig)) M.mind.force_escaped = TRUE diff --git a/code/modules/shuttle/special.dm b/code/modules/shuttle/special.dm index 847bff5ca5f..f3ac6ae3004 100644 --- a/code/modules/shuttle/special.dm +++ b/code/modules/shuttle/special.dm @@ -314,17 +314,17 @@ //Here is all the possible paygate payment methods. var/list/counted_money = list() - for(var/obj/item/coin/C in AM.GetAllContents()) //Coins. + for(var/obj/item/coin/C in AM.get_all_contents()) //Coins. if(payees[AM] >= threshold) break payees[AM] += C.value counted_money += C - for(var/obj/item/stack/spacecash/S in AM.GetAllContents()) //Paper Cash + for(var/obj/item/stack/spacecash/S in AM.get_all_contents()) //Paper Cash if(payees[AM] >= threshold) break payees[AM] += S.value * S.amount counted_money += S - for(var/obj/item/holochip/H in AM.GetAllContents()) //Holocredits + for(var/obj/item/holochip/H in AM.get_all_contents()) //Holocredits if(payees[AM] >= threshold) break payees[AM] += H.credits diff --git a/code/modules/shuttle/supply.dm b/code/modules/shuttle/supply.dm index 65a4125dfa2..e445a1b090f 100644 --- a/code/modules/shuttle/supply.dm +++ b/code/modules/shuttle/supply.dm @@ -69,7 +69,7 @@ GLOBAL_LIST_INIT(blacklisted_cargo_types, typecacheof(list( for(var/place in areaInstances) var/area/shuttle/shuttle_area = place for(var/turf/shuttle_turf in shuttle_area) - for(var/atom/passenger in shuttle_turf.GetAllContents()) + for(var/atom/passenger in shuttle_turf.get_all_contents()) if((is_type_in_typecache(passenger, GLOB.blacklisted_cargo_types) || HAS_TRAIT(passenger, TRAIT_BANNED_FROM_CARGO_SHUTTLE)) && !istype(passenger, /obj/docking_port)) return FALSE return TRUE diff --git a/code/modules/spells/spell.dm b/code/modules/spells/spell.dm index df2f2b191c8..9150944521a 100644 --- a/code/modules/spells/spell.dm +++ b/code/modules/spells/spell.dm @@ -523,7 +523,7 @@ GLOBAL_LIST_INIT(spells, typesof(/obj/effect/proc_holder/spell)) //needed for th dummy.pass_flags |= PASSTABLE var/turf/previous_step = get_turf(A) var/first_step = TRUE - for(var/turf/next_step as anything in (getline(A, B) - previous_step)) + for(var/turf/next_step as anything in (get_line(A, B) - previous_step)) if(first_step) for(var/obj/blocker in previous_step) if(!blocker.density || !(blocker.flags_1 & ON_BORDER_1)) diff --git a/code/modules/station_goals/bsa.dm b/code/modules/station_goals/bsa.dm index da3d93c45a1..a51ac8d90bd 100644 --- a/code/modules/station_goals/bsa.dm +++ b/code/modules/station_goals/bsa.dm @@ -194,7 +194,7 @@ GLOBAL_VAR_INIT(bsa_unlock, FALSE) var/turf/point = get_front_turf() var/turf/target = get_target_turf() var/atom/movable/blocker - for(var/T in getline(get_step(point, dir), target)) + for(var/T in get_line(get_step(point, dir), target)) var/turf/tile = T if(SEND_SIGNAL(tile, COMSIG_ATOM_BSA_BEAM) & COMSIG_ATOM_BLOCKS_BSA_BEAM) blocker = tile diff --git a/code/modules/station_goals/shield.dm b/code/modules/station_goals/shield.dm index cbe974b3f2d..8e12556225a 100644 --- a/code/modules/station_goals/shield.dm +++ b/code/modules/station_goals/shield.dm @@ -146,7 +146,7 @@ var/kill_range = 14 /obj/machinery/satellite/meteor_shield/proc/space_los(meteor) - for(var/turf/T in getline(src,meteor)) + for(var/turf/T in get_line(src,meteor)) if(!isspaceturf(T)) return FALSE return TRUE diff --git a/code/modules/unit_tests/resist.dm b/code/modules/unit_tests/resist.dm index 9fe5cd11149..208c9d0cad3 100644 --- a/code/modules/unit_tests/resist.dm +++ b/code/modules/unit_tests/resist.dm @@ -10,7 +10,7 @@ TEST_ASSERT_EQUAL(human.fire_stacks, 5, "Human does not have 5 fire stacks pre-resist") // Stop, drop, and roll has a sleep call. This would delay the test, and is not necessary. - CallAsync(human, /mob/living/verb/resist) + call_async(human, /mob/living/verb/resist) TEST_ASSERT(human.fire_stacks < 5, "Human did not lower fire stacks after resisting") diff --git a/tgstation.dme b/tgstation.dme index da8ec9f0380..98b90fe08b5 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -180,19 +180,23 @@ #include "code\__HELPERS\admin.dm" #include "code\__HELPERS\areas.dm" #include "code\__HELPERS\atmospherics.dm" +#include "code\__HELPERS\atoms.dm" #include "code\__HELPERS\bitflag_lists.dm" #include "code\__HELPERS\chat.dm" #include "code\__HELPERS\chat_filter.dm" +#include "code\__HELPERS\clients.dm" #include "code\__HELPERS\cmp.dm" #include "code\__HELPERS\colors.dm" #include "code\__HELPERS\config.dm" #include "code\__HELPERS\construction.dm" #include "code\__HELPERS\dates.dm" +#include "code\__HELPERS\datums.dm" #include "code\__HELPERS\dna.dm" #include "code\__HELPERS\files.dm" #include "code\__HELPERS\filters.dm" #include "code\__HELPERS\game.dm" #include "code\__HELPERS\global_lists.dm" +#include "code\__HELPERS\guid.dm" #include "code\__HELPERS\heap.dm" #include "code\__HELPERS\hearted.dm" #include "code\__HELPERS\icon_smoothing.dm" @@ -200,6 +204,7 @@ #include "code\__HELPERS\jatum.dm" #include "code\__HELPERS\level_traits.dm" #include "code\__HELPERS\lighting.dm" +#include "code\__HELPERS\maths.dm" #include "code\__HELPERS\matrices.dm" #include "code\__HELPERS\memory_helpers.dm" #include "code\__HELPERS\mobs.dm" @@ -212,20 +217,27 @@ #include "code\__HELPERS\qdel.dm" #include "code\__HELPERS\radiation.dm" #include "code\__HELPERS\radio.dm" +#include "code\__HELPERS\randoms.dm" #include "code\__HELPERS\reagents.dm" #include "code\__HELPERS\records.dm" +#include "code\__HELPERS\ref.dm" #include "code\__HELPERS\roundend.dm" #include "code\__HELPERS\sanitize_values.dm" #include "code\__HELPERS\shell.dm" +#include "code\__HELPERS\spawns.dm" +#include "code\__HELPERS\stack_trace.dm" #include "code\__HELPERS\stat_tracking.dm" +#include "code\__HELPERS\stoplag.dm" #include "code\__HELPERS\string_assoc_lists.dm" #include "code\__HELPERS\string_lists.dm" #include "code\__HELPERS\text.dm" #include "code\__HELPERS\time.dm" +#include "code\__HELPERS\traits.dm" +#include "code\__HELPERS\turfs.dm" #include "code\__HELPERS\type2type.dm" #include "code\__HELPERS\type_processing.dm" #include "code\__HELPERS\typelists.dm" -#include "code\__HELPERS\unsorted.dm" +#include "code\__HELPERS\varset_callback.dm" #include "code\__HELPERS\verbs.dm" #include "code\__HELPERS\view.dm" #include "code\__HELPERS\weakref.dm" diff --git a/tools/Runtime Condenser/Main.cpp b/tools/Runtime Condenser/Main.cpp index 01518277788..ddc38db58fb 100644 --- a/tools/Runtime Condenser/Main.cpp +++ b/tools/Runtime Condenser/Main.cpp @@ -74,7 +74,7 @@ inline string safe_substr(string * S, size_t start = 0, size_t end = string::npo start = S->length(); return S->substr(start, end); } -//getline() is slow as fucking balls. this is quicker because we prefill a buffer rather then read 1 byte at a time searching for newlines, lowering on i/o calls and overhead. (110MB/s vs 40MB/s on a 1.8GB file pre-filled into the disk cache) +//get_line() is slow as fucking balls. this is quicker because we prefill a buffer rather then read 1 byte at a time searching for newlines, lowering on i/o calls and overhead. (110MB/s vs 40MB/s on a 1.8GB file pre-filled into the disk cache) //if i wanted to make it even faster, I'd use a reading thread, a new line searching thread, another thread or four for searching for runtimes in the list to see if they are unique, and finally the main thread for displaying the progress bar. but fuck that noise. inline string * readline(FILE * f) { static char buf[LINEBUFFER]; @@ -117,13 +117,13 @@ inline void forward_progress(FILE * inputFile) { delete(lastLine); lastLine = currentLine; currentLine = nextLine; - do { + do { nextLine = readline(inputFile); //strip out rustg continuing line markers if (safe_substr(nextLine, 0, 3) == " - ") { nextLine->erase(0, 3); } - + //strip out any timestamps. if (nextLine->length() >= 10) { if ((*nextLine)[0] == '[' && (*nextLine)[3] == ':' && (*nextLine)[6] == ':' && (*nextLine)[9] == ']') @@ -132,7 +132,7 @@ inline void forward_progress(FILE * inputFile) { nextLine->erase(0, 26); } } while (!endofbuffer && nextLine->length() < 1); - + } //deallocates to, copys from to to. inline void string_send(string * &from, string * &to) {