Skip to content

Commit

Permalink
Revert "various minor /tg/ bugfixes (#2505)"
Browse files Browse the repository at this point in the history
This reverts commit caeca3c.
  • Loading branch information
dwasint authored Aug 21, 2024
1 parent ebd5d96 commit 748ed55
Show file tree
Hide file tree
Showing 25 changed files with 61 additions and 185 deletions.
9 changes: 0 additions & 9 deletions code/__DEFINES/spatial_gridmap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#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 @@ -16,8 +15,6 @@
///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 @@ -46,9 +43,3 @@
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: 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, old_area)
SEND_SIGNAL(stuff, COMSIG_EXIT_AREA, oldA)

//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(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))
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))
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(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))
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))
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(null, alpha_threshold_up)
var/atom/movable/render_step/emissive_blocker/em_block = new(make_blocker, alpha_threshold_up.render_target)
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 1 // 0 to allow using external resources or on-demand behaviour;
#define PRELOAD_RSC 2 // 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 || !action.owner_has_control)
if(!action.show_to_observers)
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 || !action.owner_has_control)
if(!action.show_to_observers)
return
action.GiveAction(src)

Expand Down
109 changes: 13 additions & 96 deletions code/controllers/subsystem/spatial_gridmap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -482,106 +482,21 @@ SUBSYSTEM_DEF(spatial_grid)

return TRUE

/// 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

///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(!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)
return
input_cell = get_cell_of(to_remove)
if(!input_cell)
find_hanging_cell_refs_for_movable(to_remove, TRUE)
return

GRID_CELL_REMOVE_ALL(input_cell, to_remove)
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)

///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 @@ -611,7 +526,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, remove_from_cells)
var/list/containing_cells = SSspatial_grid.find_hanging_cell_refs_for_movable(src, FALSE, remove_from_cells)

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

Expand Down Expand Up @@ -843,5 +758,7 @@ 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: 2 additions & 4 deletions code/datums/brain_damage/severe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@
..()

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

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
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, can_override = FALSE)
/datum/element/forced_gravity/Attach(datum/target, gravity = 1, ignore_turf_gravity = 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), override = can_override)
RegisterSignal(target, COMSIG_ATOM_HAS_GRAVITY, PROC_REF(gravity_check))
if(isturf(target))
RegisterSignal(target, COMSIG_TURF_HAS_GRAVITY, PROC_REF(turf_gravity_check), override = can_override)
RegisterSignal(target, COMSIG_TURF_HAS_GRAVITY, PROC_REF(turf_gravity_check))

ADD_TRAIT(target, TRAIT_FORCED_GRAVITY, REF(src))

Expand Down
4 changes: 1 addition & 3 deletions code/datums/progressbar.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
/datum/progressbar/New(mob/User, goal_number, atom/target, border_look = "border", border_look_accessory, bar_look = "prog_bar", old_format = FALSE, active_color = "#6699FF", finish_color = "#FFEE8C", fail_color = "#FF0033" , mutable_appearance/additional_image)
. = ..()
if (!istype(target))
stack_trace("Invalid target [target] passed in")
qdel(src)
return
EXCEPTION("Invalid target given")
if(QDELETED(User) || !istype(User))
stack_trace("/datum/progressbar created with [isnull(User) ? "null" : "invalid"] user")
qdel(src)
Expand Down
3 changes: 2 additions & 1 deletion code/datums/proximity_monitor/fields/gravity.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
. = ..()
if (isnull(modified_turfs[target]))
return
target.AddElement(/datum/element/forced_gravity, gravity_value, can_override = TRUE)

target.AddElement(/datum/element/forced_gravity, gravity_value)
modified_turfs[target] = gravity_value

/datum/proximity_monitor/advanced/gravity/cleanup_field_turf(turf/target)
Expand Down
16 changes: 5 additions & 11 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
if (blocks_emissive)
if (blocks_emissive == EMISSIVE_BLOCK_UNIQUE)
render_target = ref(src)
em_block = new(null, src)
em_block = new(src, render_target)
overlays += em_block
if(managed_overlays)
if(islist(managed_overlays))
Expand Down Expand Up @@ -211,7 +211,7 @@
move_packet = null

if(spatial_grid_key)
SSspatial_grid.force_remove_from_grid(src)
SSspatial_grid.force_remove_from_cell(src)

LAZYCLEARLIST(client_mobs_in_contents)

Expand Down Expand Up @@ -243,11 +243,9 @@
// This saves several hundred milliseconds of init time.
if (blocks_emissive)
if (blocks_emissive == EMISSIVE_BLOCK_UNIQUE)
if(em_block)
SET_PLANE(em_block, EMISSIVE_PLANE, src)
else if(!QDELETED(src))
if(!em_block && !QDELETED(src))
render_target = ref(src)
em_block = new(null, src)
em_block = new(src, render_target)
return em_block
// Implied else if (blocks_emissive == EMISSIVE_BLOCK_NONE) -> return
// EMISSIVE_BLOCK_GENERIC == 0
Expand All @@ -263,7 +261,7 @@
SET_PLANE(underlay_appearance, PLANE_SPACE, generate_for)
if(!generate_for.render_target)
generate_for.render_target = ref(generate_for)
var/atom/movable/render_step/emissive_blocker/em_block = new(null, generate_for)
var/atom/movable/render_step/emissive_blocker/em_block = new(null, generate_for.render_target)
underlay_appearance.overlays += em_block
// We used it because it's convienient and easy, but it's gotta go now or it'll hang refs
QDEL_NULL(em_block)
Expand Down Expand Up @@ -1473,10 +1471,6 @@

/// Gets or creates the relevant language holder. For mindless atoms, gets the local one. For atom with mind, gets the mind one.
/atom/movable/proc/get_language_holder(get_minds = TRUE)
if(QDELING(src))
CRASH("get_language_holder() called on a QDELing atom, \
this will try to re-instantiate the language holder that's about to be deleted, which is bad.")

if(!language_holder)
language_holder = new initial_language_holder(src)
return language_holder
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/hologram.dm
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ For the other part of the code, check silicon say.dm. Particularly robot talk.*/
render_target = "holoray#[uid]"
uid++
// Let's GLOW BROTHER! (Doing it like this is the most robust option compared to duped overlays)
glow = new(null, src)
glow = new(src, render_target)
// We need to counteract the pixel offset to ensure we don't double offset (I hate byond)
glow.pixel_x = 32
glow.pixel_y = 32
Expand Down
10 changes: 5 additions & 5 deletions code/game/objects/effects/spiderwebs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
return
if(!HAS_TRAIT(user,TRAIT_WEB_WEAVER))
return
loc.balloon_alert_to_viewers("weaving...")
user.balloon_alert_to_viewers("weaving...")
if(!do_after(user, 2 SECONDS))
loc.balloon_alert(user, "interrupted!")
user.balloon_alert(user, "interrupted!")
return
qdel(src)
var/obj/item/stack/sheet/cloth/woven_cloth = new /obj/item/stack/sheet/cloth
Expand All @@ -68,7 +68,7 @@
if(mover.pulledby && HAS_TRAIT(mover.pulledby, TRAIT_WEB_SURFER))
return TRUE
if(prob(50))
loc.balloon_alert(mover, "stuck in web!")
balloon_alert(mover, "stuck in web!")
return FALSE
else if(isprojectile(mover))
return prob(30)
Expand Down Expand Up @@ -100,7 +100,7 @@
if(mover.pulledby == allowed_mob)
return TRUE
if(prob(50))
loc.balloon_alert(mover, "stuck in web!")
balloon_alert(mover, "stuck in web!")
return FALSE
else if(isprojectile(mover))
return prob(30)
Expand Down Expand Up @@ -180,7 +180,7 @@
return
if(!isnull(mover.pulledby) && isspider(mover.pulledby))
return TRUE
loc.balloon_alert(mover, "stuck in web!")
balloon_alert(mover, "stuck in web!")
return FALSE

/obj/structure/spider/spikes
Expand Down
13 changes: 6 additions & 7 deletions code/game/objects/items/melee/baton.dm
Original file line number Diff line number Diff line change
Expand Up @@ -787,10 +787,9 @@
if(!.)
return
var/obj/item/stuff_in_hand = target.get_active_held_item()
if(!user || !stuff_in_hand || !target.temporarilyRemoveItemFromInventory(stuff_in_hand))
return
if(user.put_in_inactive_hand(stuff_in_hand))
stuff_in_hand.loc.visible_message(span_warning("[stuff_in_hand] suddenly appears in [user]'s hand!"))
else
stuff_in_hand.forceMove(user.drop_location())
stuff_in_hand.loc.visible_message(span_warning("[stuff_in_hand] suddenly appears!"))
if(stuff_in_hand && target.temporarilyRemoveItemFromInventory(stuff_in_hand))
if(user.put_in_inactive_hand(stuff_in_hand))
stuff_in_hand.loc.visible_message(span_warning("[stuff_in_hand] suddenly appears in [user]'s hand!"))
else
stuff_in_hand.forceMove(user.drop_location())
stuff_in_hand.loc.visible_message(span_warning("[stuff_in_hand] suddenly appears!"))
Loading

0 comments on commit 748ed55

Please sign in to comment.