Merge branch 'master' into TGUIs_Nexties
This commit is contained in:
@@ -165,6 +165,12 @@
|
||||
/proc/log_mapping(text)
|
||||
WRITE_LOG(GLOB.world_map_error_log, text)
|
||||
|
||||
/proc/log_reagent(text)
|
||||
WRITE_LOG(GLOB.reagent_log, text)
|
||||
|
||||
/proc/log_reagent_transfer(text)
|
||||
log_reagent("TRANSFER: [text]")
|
||||
|
||||
/* For logging round startup. */
|
||||
/proc/start_log(log)
|
||||
WRITE_LOG(log, "Starting up round ID [GLOB.round_id].\n-------------------------")
|
||||
|
||||
@@ -1,5 +1,81 @@
|
||||
#define BP_MAX_ROOM_SIZE 300
|
||||
|
||||
//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/V in GLOB.sortedAreas)
|
||||
var/area/A = V
|
||||
if(cache[A.type])
|
||||
areas += V
|
||||
else
|
||||
for(var/V in GLOB.sortedAreas)
|
||||
var/area/A = V
|
||||
if(A.type == areatype)
|
||||
areas += V
|
||||
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/V in GLOB.sortedAreas)
|
||||
var/area/A = V
|
||||
if(!cache[A.type])
|
||||
continue
|
||||
for(var/turf/T in A)
|
||||
if(target_z == 0 || target_z == T.z)
|
||||
turfs += T
|
||||
else
|
||||
for(var/V in GLOB.sortedAreas)
|
||||
var/area/A = V
|
||||
if(A.type != areatype)
|
||||
continue
|
||||
for(var/turf/T in A)
|
||||
if(target_z == 0 || target_z == T.z)
|
||||
turfs += T
|
||||
return turfs
|
||||
|
||||
// Gets an atmos isolated contained space
|
||||
// Returns an associative list of turf|dirs pairs
|
||||
// The dirs are connected turfs in the same space
|
||||
@@ -103,4 +179,62 @@
|
||||
to_chat(creator, "<span class='notice'>You have created a new area, named [newA.name]. It is now weather proof, and constructing an APC will allow it to be powered.</span>")
|
||||
return TRUE
|
||||
|
||||
|
||||
/**
|
||||
* Returns the base area the target is located in if there is one.
|
||||
* Alternatively, returns the area as is.
|
||||
*/
|
||||
/proc/get_base_area(atom/target)
|
||||
var/area/A = get_area(target)
|
||||
if(A?.base_area)
|
||||
return A.base_area
|
||||
return A
|
||||
|
||||
/**
|
||||
* Returns either null, or a list containing every sub area associated with our base area.
|
||||
* If include_base is TRUE, the base area will also be added to the return list.
|
||||
*/
|
||||
/proc/get_sub_areas(atom/target, include_base = TRUE)
|
||||
var/area/A = get_area(target)
|
||||
if(!A)
|
||||
return
|
||||
. = list()
|
||||
if(A.base_area)
|
||||
A = A.base_area
|
||||
if(include_base)
|
||||
. += A
|
||||
if(A.sub_areas)
|
||||
. += A.sub_areas
|
||||
|
||||
/**
|
||||
* Proc used for purposes similar to get_areas_turfs(), but aimed to include associated areas.
|
||||
* Only accepts area instances and paths for the first arg, no text strings.
|
||||
* Returns a list of all turfs found in the sub areas (including the base's if include_base is TRUE)
|
||||
* and located in a z level matching target_z, or anywhere if target_z is 0
|
||||
*/
|
||||
|
||||
/proc/get_sub_areas_turfs(area/A, target_z = 0, include_base = TRUE)
|
||||
var/list/contents = get_sub_areas_contents(A, include_base)
|
||||
. = list()
|
||||
for(var/turf/T in contents)
|
||||
if(target_z == 0 || target_z == T.z)
|
||||
. += T
|
||||
/**
|
||||
* Simple proc that returns a sum of all contents from every sub area,
|
||||
* Think of the above but for all contents, not just turfs, and without target z.
|
||||
*/
|
||||
|
||||
/proc/get_sub_areas_contents(area/A, include_base = TRUE)
|
||||
if(ispath(A))
|
||||
A = GLOB.areas_by_type[A]
|
||||
else
|
||||
A = get_area(A) //in case it's called on other atoms.
|
||||
if(!A)
|
||||
return
|
||||
if(A.base_area)
|
||||
A = A.base_area
|
||||
. = list(A.contents)
|
||||
for(var/i in A.sub_areas)
|
||||
. += A.sub_areas[i].contents
|
||||
|
||||
#undef BP_MAX_ROOM_SIZE
|
||||
|
||||
+17
-36
@@ -8,8 +8,8 @@
|
||||
#define Z_TURFS(ZLEVEL) block(locate(1,1,ZLEVEL), locate(world.maxx, world.maxy, ZLEVEL))
|
||||
#define CULT_POLL_WAIT 2400
|
||||
|
||||
/proc/get_area_name(atom/X, format_text = FALSE)
|
||||
var/area/A = isarea(X) ? X : get_area(X)
|
||||
/proc/get_area_name(atom/X, format_text = FALSE, get_base_area = FALSE)
|
||||
var/area/A = get_base_area ? get_base_area(X) : get_area(X)
|
||||
if(!A)
|
||||
return null
|
||||
return format_text ? format_text(A.name) : A.name
|
||||
@@ -145,20 +145,6 @@
|
||||
turfs += T
|
||||
return turfs
|
||||
|
||||
|
||||
//This is the new version of recursive_mob_check, used for say().
|
||||
//The other proc was left intact because morgue trays use it.
|
||||
//Sped this up again for real this time
|
||||
/proc/recursive_hear_check(O)
|
||||
var/list/processing_list = list(O)
|
||||
. = list()
|
||||
while(processing_list.len)
|
||||
var/atom/A = processing_list[1]
|
||||
if(A.flags_1 & HEAR_1)
|
||||
. += A
|
||||
processing_list.Cut(1, 2)
|
||||
processing_list += A.contents
|
||||
|
||||
/** recursive_organ_check
|
||||
* inputs: O (object to start with)
|
||||
* outputs:
|
||||
@@ -238,35 +224,30 @@
|
||||
|
||||
return found_mobs
|
||||
|
||||
|
||||
/proc/get_hearers_in_view(R, atom/source)
|
||||
// Returns a list of hearers in view(R) from source (ignoring luminosity). Used in saycode.
|
||||
var/turf/T = get_turf(source)
|
||||
. = list()
|
||||
|
||||
if(!T)
|
||||
return
|
||||
|
||||
var/list/processing_list = list()
|
||||
if (R == 0) // if the range is zero, we know exactly where to look for, we can skip view
|
||||
processing_list += T.contents // We can shave off one iteration by assuming turfs cannot hear
|
||||
else // A variation of get_hear inlined here to take advantage of the compiler's fastpath for obj/mob in view
|
||||
var/list/processing = list()
|
||||
if(R == 0)
|
||||
processing += T.contents
|
||||
else
|
||||
var/lum = T.luminosity
|
||||
T.luminosity = 6 // This is the maximum luminosity
|
||||
var/list/cachedview = view(R, T)
|
||||
for(var/mob/M in cachedview)
|
||||
processing_list += M
|
||||
for(var/obj/O in cachedview)
|
||||
processing_list += O
|
||||
T.luminosity = 6
|
||||
var/list/cached_view = view(R, T)
|
||||
for(var/mob/M in cached_view)
|
||||
processing += M
|
||||
for(var/obj/O in cached_view)
|
||||
processing += O
|
||||
T.luminosity = lum
|
||||
|
||||
while(processing_list.len) // recursive_hear_check inlined here
|
||||
var/atom/A = processing_list[1]
|
||||
var/i = 0
|
||||
while(i < length(processing))
|
||||
var/atom/A = processing[++i]
|
||||
if(A.flags_1 & HEAR_1)
|
||||
. += A
|
||||
SEND_SIGNAL(A, COMSIG_ATOM_HEARER_IN_VIEW, processing_list, .)
|
||||
processing_list.Cut(1, 2)
|
||||
processing_list += A.contents
|
||||
SEND_SIGNAL(A, COMSIG_ATOM_HEARER_IN_VIEW, processing, .)
|
||||
processing += A.contents
|
||||
|
||||
/proc/get_mobs_in_radio_ranges(list/obj/item/radio/radios)
|
||||
. = list()
|
||||
|
||||
+15
-92
@@ -457,36 +457,35 @@ Turf and target are separate in case you want to teleport some distance from a t
|
||||
|
||||
/atom/proc/GetAllContents(var/T)
|
||||
var/list/processing_list = list(src)
|
||||
var/list/assembled = list()
|
||||
if(T)
|
||||
while(processing_list.len)
|
||||
var/atom/A = processing_list[1]
|
||||
processing_list.Cut(1, 2)
|
||||
. = list()
|
||||
var/i = 0
|
||||
while(i < length(processing_list))
|
||||
var/atom/A = processing_list[++i]
|
||||
//Byond does not allow things to be in multiple contents, or double parent-child hierarchies, so only += is needed
|
||||
//This is also why we don't need to check against assembled as we go along
|
||||
processing_list += A.contents
|
||||
if(istype(A,T))
|
||||
assembled += A
|
||||
. += A
|
||||
else
|
||||
while(processing_list.len)
|
||||
var/atom/A = processing_list[1]
|
||||
processing_list.Cut(1, 2)
|
||||
var/i = 0
|
||||
while(i < length(processing_list))
|
||||
var/atom/A = processing_list[++i]
|
||||
processing_list += A.contents
|
||||
assembled += A
|
||||
return assembled
|
||||
return processing_list
|
||||
|
||||
/atom/proc/GetAllContentsIgnoring(list/ignore_typecache)
|
||||
if(!length(ignore_typecache))
|
||||
return GetAllContents()
|
||||
var/list/processing = list(src)
|
||||
var/list/assembled = list()
|
||||
while(processing.len)
|
||||
var/atom/A = processing[1]
|
||||
processing.Cut(1,2)
|
||||
. = list()
|
||||
var/i = 0
|
||||
while(i < length(processing))
|
||||
var/atom/A = processing[++i]
|
||||
if(!ignore_typecache[A.type])
|
||||
processing += A.contents
|
||||
assembled += A
|
||||
return assembled
|
||||
. += 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.
|
||||
@@ -566,82 +565,6 @@ Turf and target are separate in case you want to teleport some distance from a t
|
||||
else
|
||||
return 0
|
||||
|
||||
//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/V in GLOB.sortedAreas)
|
||||
var/area/A = V
|
||||
if(cache[A.type])
|
||||
areas += V
|
||||
else
|
||||
for(var/V in GLOB.sortedAreas)
|
||||
var/area/A = V
|
||||
if(A.type == areatype)
|
||||
areas += V
|
||||
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/V in GLOB.sortedAreas)
|
||||
var/area/A = V
|
||||
if(!cache[A.type])
|
||||
continue
|
||||
for(var/turf/T in A)
|
||||
if(target_z == 0 || target_z == T.z)
|
||||
turfs += T
|
||||
else
|
||||
for(var/V in GLOB.sortedAreas)
|
||||
var/area/A = V
|
||||
if(A.type != areatype)
|
||||
continue
|
||||
for(var/turf/T in A)
|
||||
if(target_z == 0 || target_z == T.z)
|
||||
turfs += T
|
||||
return turfs
|
||||
|
||||
/proc/get_cardinal_dir(atom/A, atom/B)
|
||||
var/dx = abs(B.x - A.x)
|
||||
var/dy = abs(B.y - A.y)
|
||||
|
||||
Reference in New Issue
Block a user