Skip to content

Commit

Permalink
Merge branch 'master' into new_maps_galore
Browse files Browse the repository at this point in the history
  • Loading branch information
dwasint authored Jul 5, 2024
2 parents 8e42404 + aa5c846 commit 52ce27e
Show file tree
Hide file tree
Showing 65 changed files with 925 additions and 94 deletions.
10 changes: 10 additions & 0 deletions code/__DEFINES/shuttles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,13 @@
#define SHUTTLE_UNLOCK_BUBBLEGUM "bubblegum"
#define SHUTTLE_UNLOCK_MEDISIM "holodeck"
#define SHUTTLE_UNLOCK_NARNAR "narnar"

//Shuttle Events

///Self destruct if this is returned in process
#define SHUTTLE_EVENT_CLEAR 2

///spawned stuff should float by the window and not hit the shuttle
#define SHUTTLE_EVENT_MISS_SHUTTLE 1 << 0
///spawned stuff should hit the shuttle
#define SHUTTLE_EVENT_HIT_SHUTTLE 1 << 1
9 changes: 9 additions & 0 deletions code/__DEFINES/spatial_gridmap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define SPATIAL_GRID_CELLSIZE 17
///Takes a coordinate, and spits out the spatial grid index (x or y) it's inside
#define GET_SPATIAL_INDEX(coord) ROUND_UP((coord) / SPATIAL_GRID_CELLSIZE)
#define GRID_INDEX_TO_COORDS(index) (index * SPATIAL_GRID_CELLSIZE)
#define SPATIAL_GRID_CELLS_PER_SIDE(world_bounds) GET_SPATIAL_INDEX(world_bounds)

#define SPATIAL_GRID_CHANNELS 2
Expand All @@ -15,6 +16,8 @@
///all atmos machines are stored in this channel (I'm sorry kyler)
#define SPATIAL_GRID_CONTENTS_TYPE_ATMOS "spatial_grid_contents_type_atmos"

#define ALL_CONTENTS_OF_CELL(cell) (cell.hearing_contents | cell.client_contents | cell.atmos_contents)

///whether movable is itself or containing something which should be in one of the spatial grid channels.
#define HAS_SPATIAL_GRID_CONTENTS(movable) (movable.spatial_grid_key)

Expand Down Expand Up @@ -43,3 +46,9 @@
if(!length(cell_contents_list)) {\
cell_contents_list = dummy_list; \
};

///remove from every list
#define GRID_CELL_REMOVE_ALL(cell, movable) \
GRID_CELL_REMOVE(cell.hearing_contents, movable) \
GRID_CELL_REMOVE(cell.client_contents, movable) \
GRID_CELL_REMOVE(cell.atmos_contents, movable)
2 changes: 2 additions & 0 deletions code/__DEFINES/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define TRAIT_LAVA_STOPPED "lava_stopped"
///Chasms will be safe to cross while they've this trait.
#define TRAIT_CHASM_STOPPED "chasm_stopped"
/// The effects of hyperspace drift are blocked when the tile has this trait
#define TRAIT_HYPERSPACE_STOPPED "hyperspace_stopped"
///Turf slowdown will be ignored when this trait is added to a turf.
#define TRAIT_TURF_IGNORE_SLOWDOWN "turf_ignore_slowdown"
///Mobs won't slip on a wet turf while it has this trait
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ GLOBAL_LIST_INIT(typecache_powerfailure_safe_areas, typecacheof(list(
//inform atoms on the turf that their area has changed
for(var/atom/stuff as anything in the_turf)
//unregister the stuff from its old area
SEND_SIGNAL(stuff, COMSIG_EXIT_AREA, oldA)
SEND_SIGNAL(stuff, COMSIG_EXIT_AREA, old_area)

//register the stuff to its new area. special exception for apc as its not registered to this signal
if(istype(stuff, /obj/machinery/power/apc))
Expand Down
6 changes: 3 additions & 3 deletions code/__HELPERS/lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@

// First, we cut away a constant amount
var/cut_away = (alpha_to_leave - 1) / 255
var/atom/movable/render_step/color/alpha_threshold_down = new(make_blocker, make_blocker.render_target, list(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0,-cut_away))
var/atom/movable/render_step/color/alpha_threshold_down = new(null, make_blocker, list(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0,-cut_away))
alpha_threshold_down.render_target = "*emissive_block_alpha_down_[uid]"
// Then we multiply what remains by the amount we took away
var/atom/movable/render_step/color/alpha_threshold_up = new(make_blocker, alpha_threshold_down.render_target, list(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,alpha_to_leave, 0,0,0,0))
var/atom/movable/render_step/color/alpha_threshold_up = new(null, alpha_threshold_down, list(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,alpha_to_leave, 0,0,0,0))
alpha_threshold_up.render_target = "*emissive_block_alpha_up_[uid]"
// Now we just feed that into an emissive blocker
var/atom/movable/render_step/emissive_blocker/em_block = new(make_blocker, alpha_threshold_up.render_target)
var/atom/movable/render_step/emissive_blocker/em_block = new(null, alpha_threshold_up)
var/list/hand_back = list()
hand_back += alpha_threshold_down
hand_back += alpha_threshold_up
Expand Down
2 changes: 1 addition & 1 deletion code/_compile_options.dm
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
#endif

#ifndef PRELOAD_RSC //set to:
#define PRELOAD_RSC 2 // 0 to allow using external resources or on-demand behaviour;
#define PRELOAD_RSC 1 // 0 to allow using external resources or on-demand behaviour;
#endif // 1 to use the default behaviour;
// 2 for preloading absolutely everything;

Expand Down
6 changes: 3 additions & 3 deletions code/_onclick/hud/action_button.dm
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
old_object.MouseExited(over_location, over_control, params)

last_hovored_ref = WEAKREF(over_object)
over_object.MouseEntered(over_location, over_control, params)
over_object?.MouseEntered(over_location, over_control, params)

/atom/movable/screen/movable/action_button/MouseEntered(location, control, params)
. = ..()
Expand Down Expand Up @@ -230,7 +230,7 @@
return

for(var/datum/action/action as anything in take_from.actions)
if(!action.show_to_observers)
if(!action.show_to_observers || !action.owner_has_control)
continue
action.GiveAction(src)
RegisterSignal(take_from, COMSIG_MOB_GRANTED_ACTION, PROC_REF(on_observing_action_granted), TRUE)
Expand All @@ -251,7 +251,7 @@
/mob/proc/on_observing_action_granted(mob/living/source, datum/action/action)
SIGNAL_HANDLER

if(!action.show_to_observers)
if(!action.show_to_observers || !action.owner_has_control)
return
action.GiveAction(src)

Expand Down
4 changes: 2 additions & 2 deletions code/controllers/subsystem/shuttle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ SUBSYSTEM_DEF(shuttle)
if(!thing)
mobile_docking_ports.Remove(thing)
continue
var/obj/docking_port/mobile/P = thing
P.check()
var/obj/docking_port/mobile/port = thing
port.check()
for(var/thing in transit_docking_ports)
var/obj/docking_port/stationary/transit/T = thing
if(!T.owner)
Expand Down
109 changes: 96 additions & 13 deletions code/controllers/subsystem/spatial_gridmap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -482,21 +482,106 @@ SUBSYSTEM_DEF(spatial_grid)

return TRUE

///find the cell this movable is associated with and removes it from all lists
/datum/controller/subsystem/spatial_grid/proc/force_remove_from_cell(atom/movable/to_remove, datum/spatial_grid_cell/input_cell)
/// if for whatever reason this movable is "untracked" e.g. it breaks the assumption that a movable is only inside the contents of any grid cell associated with its loc,
/// this will error. this checks every grid cell in the world so dont call this on live unless you have to.
/// returns TRUE if this movable is untracked, FALSE otherwise
/datum/controller/subsystem/spatial_grid/proc/untracked_movable_error(atom/movable/movable_to_check)
if(!movable_to_check?.spatial_grid_key)
return FALSE

if(!initialized)
return FALSE

var/datum/spatial_grid_cell/loc_cell = get_cell_of(movable_to_check)
var/list/containing_cells = find_hanging_cell_refs_for_movable(movable_to_check, remove_from_cells=FALSE)
//if we're in multiple cells, throw an error.
//if we're in 1 cell but it cant be deduced by our location, throw an error.
if(length(containing_cells) > 1 || (length(containing_cells) == 1 && loc_cell && containing_cells[1] != loc_cell && containing_cells[1] != null))
var/error_data = ""

var/location_string = "which is in nullspace, and thus not be within the contents of any spatial grid cell"
if(loc_cell)
location_string = "which is supposed to only be in the contents of a spatial grid cell at coords: ([GRID_INDEX_TO_COORDS(loc_cell.cell_x)], [GRID_INDEX_TO_COORDS(loc_cell.cell_y)], [loc_cell.cell_z])"

var/error_explanation = "was in the contents of [length(containing_cells)] spatial grid cells when it was only supposed to be in one!"
if(length(containing_cells) == 1)
error_explanation = "was in the contents of 1 spatial grid cell but it was inside the area handled by another grid cell!"
var/datum/spatial_grid_cell/bad_cell = containing_cells[1]

error_data = "within the contents of a cell at coords: ([GRID_INDEX_TO_COORDS(bad_cell.cell_x)], [GRID_INDEX_TO_COORDS(bad_cell.cell_y)], [bad_cell.cell_z])"

if(!error_data)
for(var/datum/spatial_grid_cell/cell in containing_cells)
var/coords = "([GRID_INDEX_TO_COORDS(cell.cell_x)], [GRID_INDEX_TO_COORDS(cell.cell_y)], [cell.cell_z])"
var/contents = ""

if(movable_to_check in cell.hearing_contents)
contents = "hearing"

if(movable_to_check in cell.client_contents)
if(length(contents) > 0)
contents = "[contents], client"
else
contents = "client"

if(movable_to_check in cell.atmos_contents)
if(length(contents) > 0)
contents = "[contents], atmos"
else
contents = "atmos"

if(length(error_data) > 0)
error_data = "[error_data], {coords: [coords], within channels: [contents]}"
else
error_data = "within the contents of the following cells: {coords: [coords], within channels: [contents]}"

/**
* example:
*
* /mob/living/trolls_the_maintainer instance, which is supposed to only be in the contents of a spatial grid cell at coords: (136, 136, 14),
* was in the contents of 3 spatial grid cells when it was only supposed to be in one! within the contents of the following cells:
* {(68, 153, 2), within channels: hearing},
* {coords: (221, 170, 3), within channels: hearing},
* {coords: (255, 153, 11), within channels: hearing},
* {coords: (136, 136, 14), within channels: hearing}.
*/
stack_trace("[movable_to_check.type] instance, [location_string], [error_explanation] [error_data].")

return TRUE

return FALSE

/**
* remove this movable from the grid by finding the grid cell its in and removing it from that.
* if it cant infer a grid cell its located in (e.g. if its in nullspace but it can happen if the grid isnt expanded to a z level), search every grid cell.
*/
/datum/controller/subsystem/spatial_grid/proc/force_remove_from_grid(atom/movable/to_remove)
if(!to_remove?.spatial_grid_key)
return

if(!initialized)
remove_from_pre_init_queue(to_remove)//the spatial grid doesnt exist yet, so just take it out of the queue
return

#ifdef UNIT_TESTS
if(untracked_movable_error(to_remove))
find_hanging_cell_refs_for_movable(to_remove, remove_from_cells=TRUE)
return
#endif

var/datum/spatial_grid_cell/loc_cell = get_cell_of(to_remove)

if(loc_cell)
GRID_CELL_REMOVE_ALL(loc_cell, to_remove)
else
find_hanging_cell_refs_for_movable(to_remove, remove_from_cells=TRUE)

///remove this movable from the given spatial_grid_cell
/datum/controller/subsystem/spatial_grid/proc/force_remove_from_cell(atom/movable/to_remove, datum/spatial_grid_cell/input_cell)
if(!input_cell)
input_cell = get_cell_of(to_remove)
if(!input_cell)
find_hanging_cell_refs_for_movable(to_remove, TRUE)
return
return

GRID_CELL_REMOVE(input_cell.client_contents, to_remove)
GRID_CELL_REMOVE(input_cell.hearing_contents, to_remove)
GRID_CELL_REMOVE(input_cell.atmos_contents, to_remove)
GRID_CELL_REMOVE_ALL(input_cell, to_remove)

///if shit goes south, this will find hanging references for qdeleting movables inside the spatial grid
/datum/controller/subsystem/spatial_grid/proc/find_hanging_cell_refs_for_movable(atom/movable/to_remove, remove_from_cells = TRUE)
Expand Down Expand Up @@ -526,7 +611,7 @@ SUBSYSTEM_DEF(spatial_grid)
///debug proc for checking if a movable is in multiple cells when it shouldnt be (ie always unless multitile entering is implemented)
/atom/proc/find_all_cells_containing(remove_from_cells = FALSE)
var/datum/spatial_grid_cell/real_cell = SSspatial_grid.get_cell_of(src)
var/list/containing_cells = SSspatial_grid.find_hanging_cell_refs_for_movable(src, FALSE, remove_from_cells)
var/list/containing_cells = SSspatial_grid.find_hanging_cell_refs_for_movable(src, remove_from_cells)

message_admins("[src] is located in the contents of [length(containing_cells)] spatial grid cells")

Expand Down Expand Up @@ -758,7 +843,5 @@ SUBSYSTEM_DEF(spatial_grid)

#undef BOUNDING_BOX_MAX
#undef BOUNDING_BOX_MIN
#undef GRID_CELL_ADD
#undef GRID_CELL_REMOVE
#undef GRID_CELL_SET

#undef NUMBER_OF_PREGENERATED_ORANGES_EARS
6 changes: 4 additions & 2 deletions code/datums/brain_damage/severe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
..()

/datum/brain_trauma/severe/aphasia/on_lose()
owner.remove_blocked_language(subtypesof(/datum/language/), LANGUAGE_APHASIA)
owner.remove_language(/datum/language/aphasia, TRUE, TRUE, LANGUAGE_APHASIA)
if(!QDELING(owner))
owner.remove_blocked_language(subtypesof(/datum/language/), LANGUAGE_APHASIA)
owner.remove_language(/datum/language/aphasia, TRUE, TRUE, LANGUAGE_APHASIA)

..()

/datum/brain_trauma/severe/blindness
Expand Down
8 changes: 4 additions & 4 deletions code/datums/components/mind_linker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,10 @@
return ..() && (owner.stat != DEAD)

/datum/action/innate/linked_speech/Activate()

var/datum/component/mind_linker/linker = target
var/mob/living/linker_parent = linker.parent

var/message = sanitize(tgui_input_text(owner, "Enter a message to transmit.", "[linker.network_name] Telepathy"))
var/message = tgui_input_text(owner, "Enter a message to transmit.", "[linker.network_name] Telepathy")
if(!message || QDELETED(src) || QDELETED(owner) || owner.stat == DEAD)
return

Expand All @@ -208,7 +207,8 @@
var/list/all_who_can_hear = assoc_to_keys(linker.linked_mobs) + linker_parent

for(var/mob/living/recipient as anything in all_who_can_hear)
to_chat(recipient, formatted_message)
var/avoid_highlighting = (recipient == owner) || (recipient == linker_parent)
to_chat(recipient, formatted_message, type = MESSAGE_TYPE_RADIO, avoid_highlighting = avoid_highlighting)

for(var/mob/recipient as anything in GLOB.dead_mob_list)
to_chat(recipient, "[FOLLOW_LINK(recipient, owner)] [formatted_message]")
to_chat(recipient, "[FOLLOW_LINK(recipient, owner)] [formatted_message]", type = MESSAGE_TYPE_RADIO)
27 changes: 24 additions & 3 deletions code/datums/components/shuttle_cling.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,25 @@
ADD_TRAIT(parent, TRAIT_HYPERSPACED, src)

RegisterSignals(parent, list(COMSIG_MOVABLE_MOVED, COMSIG_MOVABLE_UNBUCKLE, COMSIG_ATOM_NO_LONGER_PULLED), PROC_REF(update_state))
RegisterSignal(parent, SIGNAL_REMOVETRAIT(TRAIT_FREE_HYPERSPACE_MOVEMENT), PROC_REF(initialize_loop))
RegisterSignal(parent, SIGNAL_ADDTRAIT(TRAIT_FREE_HYPERSPACE_MOVEMENT), PROC_REF(clear_loop))

//Items have this cool thing where they're first put on the floor if you grab them from storage, and then into your hand, which isn't caught by movement signals that well
if(isitem(parent))
RegisterSignal(parent, COMSIG_ITEM_PICKUP, PROC_REF(do_remove))

hyperloop = SSmove_manager.move(moving = parent, direction = direction, delay = not_clinging_move_delay, subsystem = SShyperspace_drift, priority = MOVEMENT_ABOVE_SPACE_PRIORITY, flags = MOVEMENT_LOOP_NO_DIR_UPDATE|MOVEMENT_LOOP_DRAGGING)
if(!HAS_TRAIT(parent, TRAIT_FREE_HYPERSPACE_MOVEMENT))
initialize_loop()

update_state(parent) //otherwise we'll get moved 1 tile before we can correct ourselves, which isnt super bad but just looks jank

/datum/component/shuttle_cling/proc/initialize_loop()
hyperloop = SSmove_manager.move(moving = parent, direction = direction, delay = not_clinging_move_delay, subsystem = SShyperspace_drift, priority = MOVEMENT_ABOVE_SPACE_PRIORITY, flags = MOVEMENT_LOOP_NO_DIR_UPDATE|MOVEMENT_LOOP_OUTSIDE_CONTROL)
update_state()

/datum/component/shuttle_cling/proc/clear_loop()
QDEL_NULL(hyperloop)

///Check if we're in hyperspace and our state in hyperspace
/datum/component/shuttle_cling/proc/update_state()
SIGNAL_HANDLER
Expand All @@ -55,6 +65,9 @@
qdel(src)
return

if(!hyperloop)
return

var/should_loop = FALSE

switch(is_holding_on(parent))
Expand All @@ -72,6 +85,10 @@
if(ALL_GOOD)
should_loop = FALSE

// the hyperloop can get reset to null from the above procs
if(!hyperloop)
return

//Do pause/unpause/nothing for the hyperloop
if(should_loop && hyperloop.paused)
hyperloop.resume_loop()
Expand All @@ -80,12 +97,16 @@

///Check if we're "holding on" to the shuttle
/datum/component/shuttle_cling/proc/is_holding_on(atom/movable/movee)
if(movee.pulledby || !isturf(movee.loc))
if(movee.pulledby || !isturf(movee.loc) || HAS_TRAIT(movee, TRAIT_FREE_HYPERSPACE_MOVEMENT))
return ALL_GOOD

if(!isliving(movee))
if(HAS_TRAIT(movee, TRAIT_FORCED_GRAVITY)) // nothing can block the singularity
return SUPER_NOT_HOLDING_ON

if(is_tile_solid(get_step(movee, direction))) //something is blocking us so do the cool drift
return CLINGING

return SUPER_NOT_HOLDING_ON

var/mob/living/living = movee
Expand All @@ -108,7 +129,7 @@

///Are we on a hyperspace tile? There's some special bullshit with lattices so we just wrap this check
/datum/component/shuttle_cling/proc/is_on_hyperspace(atom/movable/clinger)
if(istype(clinger.loc, hyperspace_type) && !(locate(/obj/structure/lattice) in clinger.loc))
if(istype(clinger.loc, hyperspace_type) && !HAS_TRAIT(clinger.loc, TRAIT_HYPERSPACE_STOPPED))
return TRUE
return FALSE

Expand Down
6 changes: 3 additions & 3 deletions code/datums/elements/forced_gravity.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
///whether we will override the turf if it forces no gravity
var/ignore_turf_gravity

/datum/element/forced_gravity/Attach(datum/target, gravity = 1, ignore_turf_gravity = FALSE)
/datum/element/forced_gravity/Attach(datum/target, gravity = 1, ignore_turf_gravity = FALSE, can_override = FALSE)
. = ..()
if(!isatom(target))
return ELEMENT_INCOMPATIBLE

src.gravity = gravity
src.ignore_turf_gravity = ignore_turf_gravity

RegisterSignal(target, COMSIG_ATOM_HAS_GRAVITY, PROC_REF(gravity_check))
RegisterSignal(target, COMSIG_ATOM_HAS_GRAVITY, PROC_REF(gravity_check), override = can_override)
if(isturf(target))
RegisterSignal(target, COMSIG_TURF_HAS_GRAVITY, PROC_REF(turf_gravity_check))
RegisterSignal(target, COMSIG_TURF_HAS_GRAVITY, PROC_REF(turf_gravity_check), override = can_override)

ADD_TRAIT(target, TRAIT_FORCED_GRAVITY, REF(src))

Expand Down
Loading

0 comments on commit 52ce27e

Please sign in to comment.