Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions code/__DEFINES/layers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@
/// Layer for light overlays
#define LIGHT_DEBUG_LAYER 6

/// Layer for pathfinding arrows
#define PATH_ARROW_DEBUG_LAYER 7
/// Layer for pathfinding overlays
#define PATH_DEBUG_LAYER 8

///Layer for lobby menu collapse button
#define LOBBY_BELOW_MENU_LAYER 2
///Layer for lobby menu background image and main buttons (Join/Ready, Observe, Charater Prefs)
Expand Down
3 changes: 2 additions & 1 deletion code/__DEFINES/path.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
* If you really want to optimize things, optimize this, cuz this gets called a lot.
* We do early next.density check despite it being already checked in LinkBlockedWithAccess for short-circuit performance
*/
#define CAN_STEP(cur_turf, next, simulated_only, pass_info, avoid) (next && !next.density && !(simulated_only && SSpathfinder.space_type_cache[next.type]) && !cur_turf.LinkBlockedWithAccess(next, pass_info) && (next != avoid))
#define CAN_STEP(cur_turf, next, simulated_only, pass_info, avoid) \
(next && !next.density && !(simulated_only && SSpathfinder.space_type_cache[next.type]) && (next != avoid) && !cur_turf.LinkBlockedWithAccess(next, pass_info))

#define DIAGONAL_DO_NOTHING NONE
#define DIAGONAL_REMOVE_ALL 1
Expand Down
8 changes: 8 additions & 0 deletions code/__DEFINES/tgui.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,11 @@
#define TGUI_CREATE_MESSAGE(type, payload) ( \
"%7b%22type%22%3a%22[type]%22%2c%22payload%22%3a[url_encode(json_encode(payload))]%7d" \
)

/**
* Gets a ui_state that checks to see if the user has specific admin permissions.
*
* Arguments:
* * required_perms: Which admin permission flags to check the user for, such as [R_ADMIN]
*/
#define ADMIN_STATE(required_perms) (GLOB.admin_states["[required_perms]"] ||= new /datum/ui_state/admin_state(required_perms))
14 changes: 14 additions & 0 deletions code/__HELPERS/abstract_types.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/// Returns a list of all abstract typepaths for all datums
/proc/get_abstract_types()
var/static/list/abstracts
if(abstracts)
return abstracts
abstracts = list()
for(var/datum/sometype as anything in subtypesof(/datum))
if(sometype == sometype::abstract_type)
abstracts |= sometype::abstract_type
return abstracts

/// Like subtypesof, but automatically excludes abstract typepaths
/proc/valid_subtypesof(datum/sometype)
return subtypesof(sometype) - get_abstract_types()
28 changes: 20 additions & 8 deletions code/__HELPERS/paths/jps.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

/// A helper macro for JPS, for telling when a node has forced neighbors that need expanding
/// Only usable in the context of the jps datum because of the datum vars it relies on
/// Checks if we are deviating from our "running" directions
#define STEP_NOT_HERE_BUT_THERE(cur_turf, dirA, dirB) ((!CAN_STEP(cur_turf, get_step(cur_turf, dirA), simulated_only, pass_info, avoid) && CAN_STEP(cur_turf, get_step(cur_turf, dirB), simulated_only, pass_info, avoid)))
/// Checks if a border object stops our parent from reaching a turf we CAN reach
#define TURF_CANT_WE_CAN(parent_turf, dir_parent, cur_turf, dur_cur) ((!CAN_STEP(parent_turf, get_step(parent_turf, dir_parent), simulated_only, pass_info, avoid) && CAN_STEP(cur_turf, get_step(cur_turf, dur_cur), simulated_only, pass_info, avoid)))


/// The JPS Node datum represents a turf that we find interesting enough to add to the open list and possibly search for new tiles from
/datum/jps_node
Expand Down Expand Up @@ -212,16 +216,20 @@

switch(heading)
if(NORTH)
if(STEP_NOT_HERE_BUT_THERE(current_turf, WEST, NORTHWEST) || STEP_NOT_HERE_BUT_THERE(current_turf, EAST, NORTHEAST))
if(STEP_NOT_HERE_BUT_THERE(current_turf, WEST, NORTHWEST) || STEP_NOT_HERE_BUT_THERE(current_turf, EAST, NORTHEAST) \
|| TURF_CANT_WE_CAN(get_step(current_turf, EAST), NORTH, current_turf, NORTHEAST) || TURF_CANT_WE_CAN(get_step(current_turf, WEST), NORTH, current_turf, NORTHWEST))
interesting = TRUE
if(SOUTH)
if(STEP_NOT_HERE_BUT_THERE(current_turf, WEST, SOUTHWEST) || STEP_NOT_HERE_BUT_THERE(current_turf, EAST, SOUTHEAST))
if(STEP_NOT_HERE_BUT_THERE(current_turf, WEST, SOUTHWEST) || STEP_NOT_HERE_BUT_THERE(current_turf, EAST, SOUTHEAST) \
|| TURF_CANT_WE_CAN(get_step(current_turf, EAST), SOUTH, current_turf, SOUTHEAST) || TURF_CANT_WE_CAN(get_step(current_turf, WEST), SOUTH, current_turf, SOUTHWEST))
interesting = TRUE
if(EAST)
if(STEP_NOT_HERE_BUT_THERE(current_turf, NORTH, NORTHEAST) || STEP_NOT_HERE_BUT_THERE(current_turf, SOUTH, SOUTHEAST))
if(STEP_NOT_HERE_BUT_THERE(current_turf, NORTH, NORTHEAST) || STEP_NOT_HERE_BUT_THERE(current_turf, SOUTH, SOUTHEAST) \
|| TURF_CANT_WE_CAN(get_step(current_turf, SOUTH), EAST, current_turf, SOUTHEAST) || TURF_CANT_WE_CAN(get_step(current_turf, NORTH), EAST, current_turf, NORTHEAST))
interesting = TRUE
if(WEST)
if(STEP_NOT_HERE_BUT_THERE(current_turf, NORTH, NORTHWEST) || STEP_NOT_HERE_BUT_THERE(current_turf, SOUTH, SOUTHWEST))
if(STEP_NOT_HERE_BUT_THERE(current_turf, NORTH, NORTHWEST) || STEP_NOT_HERE_BUT_THERE(current_turf, SOUTH, SOUTHWEST) \
|| TURF_CANT_WE_CAN(get_step(current_turf, SOUTH), WEST, current_turf, SOUTHWEST) || TURF_CANT_WE_CAN(get_step(current_turf, NORTH), WEST, current_turf, NORTHWEST))
interesting = TRUE

if(interesting)
Expand Down Expand Up @@ -274,22 +282,26 @@

switch(heading)
if(NORTHWEST)
if(STEP_NOT_HERE_BUT_THERE(current_turf, EAST, NORTHEAST) || STEP_NOT_HERE_BUT_THERE(current_turf, SOUTH, SOUTHWEST))
if(STEP_NOT_HERE_BUT_THERE(current_turf, EAST, NORTHEAST) || STEP_NOT_HERE_BUT_THERE(current_turf, SOUTH, SOUTHWEST) \
|| TURF_CANT_WE_CAN(lag_turf, NORTH, current_turf, EAST) || TURF_CANT_WE_CAN(lag_turf, WEST, current_turf, SOUTH))
interesting = TRUE
else
possible_child_node = (lateral_scan_spec(current_turf, WEST) || lateral_scan_spec(current_turf, NORTH))
if(NORTHEAST)
if(STEP_NOT_HERE_BUT_THERE(current_turf, WEST, NORTHWEST) || STEP_NOT_HERE_BUT_THERE(current_turf, SOUTH, SOUTHEAST))
if(STEP_NOT_HERE_BUT_THERE(current_turf, WEST, NORTHWEST) || STEP_NOT_HERE_BUT_THERE(current_turf, SOUTH, SOUTHEAST) \
|| TURF_CANT_WE_CAN(lag_turf, NORTH, current_turf, WEST) || TURF_CANT_WE_CAN(lag_turf, EAST, current_turf, SOUTH))
interesting = TRUE
else
possible_child_node = (lateral_scan_spec(current_turf, EAST) || lateral_scan_spec(current_turf, NORTH))
if(SOUTHWEST)
if(STEP_NOT_HERE_BUT_THERE(current_turf, EAST, SOUTHEAST) || STEP_NOT_HERE_BUT_THERE(current_turf, NORTH, NORTHWEST))
if(STEP_NOT_HERE_BUT_THERE(current_turf, EAST, SOUTHEAST) || STEP_NOT_HERE_BUT_THERE(current_turf, NORTH, NORTHWEST) \
|| TURF_CANT_WE_CAN(lag_turf, SOUTH, current_turf, EAST) || TURF_CANT_WE_CAN(lag_turf, WEST, current_turf, NORTH))
interesting = TRUE
else
possible_child_node = (lateral_scan_spec(current_turf, SOUTH) || lateral_scan_spec(current_turf, WEST))
if(SOUTHEAST)
if(STEP_NOT_HERE_BUT_THERE(current_turf, WEST, SOUTHWEST) || STEP_NOT_HERE_BUT_THERE(current_turf, NORTH, NORTHEAST))
if(STEP_NOT_HERE_BUT_THERE(current_turf, WEST, SOUTHWEST) || STEP_NOT_HERE_BUT_THERE(current_turf, NORTH, NORTHEAST) \
|| TURF_CANT_WE_CAN(lag_turf, SOUTH, current_turf, WEST) || TURF_CANT_WE_CAN(lag_turf, EAST, current_turf, NORTH))
interesting = TRUE
else
possible_child_node = (lateral_scan_spec(current_turf, SOUTH) || lateral_scan_spec(current_turf, EAST))
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/paths/sssp.dm
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
var/turf/next_turf = other_end
// Cache for sonic speed
var/next_closest = src.next_closest
while(next_turf != FLOW_PATH_END || next_turf == null)
while(next_turf != FLOW_PATH_END && next_turf != null)
path += next_turf
next_turf = next_closest[next_turf] // We take the first entry cause that's the turf

Expand Down
17 changes: 17 additions & 0 deletions code/__HELPERS/random_items.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Its not full proof but it standerizes behavoir between gifts and lootboxes
/// Used for random item gen to try and generate a list of types that arent weird parent types and similar
/proc/get_sane_item_types(requested_type)
if(!ispath(requested_type, /obj/item))
return list()
var/list/all_valid_types = list()
for(var/obj/item/iter_type as anything in typesof(requested_type))
if((iter_type.abstract_type == iter_type) || (iter_type.item_flags & ABSTRACT))
continue
if(iter_type.spawn_blacklisted)
continue
// The original behavior also included inhand icon states but that seems dumb
// if(!iter_type.icon_state || !iter_type.inhand_icon_state)
if(!iter_type.icon_state)
continue // With the existance of abstract_type we could prob depricate this handling at some point
all_valid_types += iter_type
return all_valid_types
44 changes: 11 additions & 33 deletions code/__HELPERS/randoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,24 @@
var/static/list/allowed_food = list()

if(!LAZYLEN(allowed_food)) //it's static so we only ever do this once
var/list/blocked = list(
/obj/item/food/bowled,
/obj/item/food/bread,
/obj/item/food/breadslice,
/obj/item/food/cake,
/obj/item/food/cakeslice,
/obj/item/food/clothing,
/obj/item/food/drug,
/obj/item/food/grown,
/obj/item/food/grown/ash_flora,
/obj/item/food/grown/mushroom,
/obj/item/food/grown/nettle,
/obj/item/food/grown/shell,
/obj/item/food/kebab,
/obj/item/food/meat,
/obj/item/food/meat/slab,
/obj/item/food/meat/slab/human/mutant,
/obj/item/food/pie,
/obj/item/food/pieslice,
/obj/item/food/pizza,
/obj/item/food/pizzaslice,
/obj/item/food/salad,
/obj/item/food/spaghetti,
)
var/list/blocked = list() // This used to be populated

var/list/unfiltered_allowed_food = subtypesof(/obj/item/food) - blocked
for(var/obj/item/food/food as anything in unfiltered_allowed_food)
if(!initial(food.icon_state)) //food with no icon_state should probably not be spawned
continue
allowed_food.Add(food)
allowed_food = get_sane_item_types(/obj/item/food) - blocked

return pick(allowed_food)

///Gets a random drink excluding the blocked type
/proc/get_random_drink()
var/list/blocked = list(
/obj/item/reagent_containers/cup/soda_cans,
/obj/item/reagent_containers/cup/glass/bottle
var/static/list/allowed_drinks = list()

if(!LAZYLEN(allowed_drinks))
var/list/blocked = list(
/obj/item/reagent_containers/cup/glass/bottle
)
return pick(subtypesof(/obj/item/reagent_containers/cup/glass) - blocked)

allowed_drinks = get_sane_item_types(/obj/item/reagent_containers/cup/glass) + get_sane_item_types(/obj/item/reagent_containers/cup/soda_cans) - blocked

return pick(allowed_drinks)

///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()
Expand Down
Loading
Loading