Skip to content

Commit

Permalink
Revert "Revert "various minor /tg/ bugfixes"" (#3107)
Browse files Browse the repository at this point in the history
* Revert "Revert "various minor /tg/ bugfixes (#2505)" (#3038)"

This reverts commit 56fac5f.

* Revert aeeeb78
  • Loading branch information
Absolucy authored Aug 25, 2024
1 parent ebd362d commit ac29f4e
Show file tree
Hide file tree
Showing 21 changed files with 154 additions and 47 deletions.
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: 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
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
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
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
4 changes: 3 additions & 1 deletion code/datums/progressbar.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
/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))
EXCEPTION("Invalid target given")
stack_trace("Invalid target [target] passed in")
qdel(src)
return
if(QDELETED(User) || !istype(User))
stack_trace("/datum/progressbar created with [isnull(User) ? "null" : "invalid"] user")
qdel(src)
Expand Down
3 changes: 1 addition & 2 deletions code/datums/proximity_monitor/fields/gravity.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
. = ..()
if (isnull(modified_turfs[target]))
return

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

/datum/proximity_monitor/advanced/gravity/cleanup_field_turf(turf/target)
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
user.balloon_alert_to_viewers("weaving...")
loc.balloon_alert_to_viewers("weaving...")
if(!do_after(user, 2 SECONDS))
user.balloon_alert(user, "interrupted!")
loc.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))
balloon_alert(mover, "stuck in web!")
loc.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))
balloon_alert(mover, "stuck in web!")
loc.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
balloon_alert(mover, "stuck in web!")
loc.balloon_alert(mover, "stuck in web!")
return FALSE

/obj/structure/spider/spikes
Expand Down
13 changes: 7 additions & 6 deletions code/game/objects/items/melee/baton.dm
Original file line number Diff line number Diff line change
Expand Up @@ -787,9 +787,10 @@
if(!.)
return
var/obj/item/stuff_in_hand = target.get_active_held_item()
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!"))
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!"))
1 change: 1 addition & 0 deletions code/game/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ GLOBAL_VAR(restart_counter)
shutdown_logging() // See comment below.
auxcleanup()
TgsEndProcess()
return ..()

log_world("World rebooted at [time_stamp()]")

Expand Down
4 changes: 3 additions & 1 deletion code/modules/admin/IsBanned.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@

var/client_is_in_db = query_client_in_db.NextRow()
if(!client_is_in_db)

var/reject_message = "Failed Login: [ckey] [address]-[computer_id] - New Account attempting to connect during panic bunker, but was rejected due to no prior connections to game servers (no database entry)"
log_access(reject_message)
if (message)
message_admins(span_adminnotice("[reject_message]"))
qdel(query_client_in_db)
return list("reason"="panicbunker", "desc" = "Sorry but the server is currently not accepting connections from never before seen players")

qdel(query_client_in_db)

//Whitelist
if(!real_bans_only && !C && CONFIG_GET(flag/usewhitelist))
if(!check_whitelist(ckey))
Expand Down
4 changes: 2 additions & 2 deletions code/modules/atmospherics/machinery/other/meter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
return target?.return_air() || ..()

/obj/machinery/meter/process_atmos()
var/datum/gas_mixture/pipe_air = target.return_air()
if(!pipe_air)
var/datum/gas_mixture/pipe_air = target?.return_air()
if(isnull(pipe_air))
icon_state = "meter0"
return FALSE

Expand Down
8 changes: 7 additions & 1 deletion code/modules/logging/log_holder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,13 @@ GENERAL_PROTECT_DATUM(/datum/log_holder)
/datum/log_holder/proc/human_readable_timestamp(precision = 3)
var/start = time2text(world.timeofday, "YYYY-MM-DD hh:mm:ss")
// now we grab the millis from the rustg timestamp
var/list/timestamp = splittext(unix_timestamp_string(), ".")
var/rustg_stamp = unix_timestamp_string()
var/list/timestamp = splittext(rustg_stamp, ".")
#ifdef UNIT_TESTS
if(length(timestamp) != 2)
stack_trace("rustg returned illegally formatted string '[rustg_stamp]'")
return start
#endif
var/millis = timestamp[2]
if(length(millis) > precision)
millis = copytext(millis, 1, precision + 1)
Expand Down
1 change: 1 addition & 0 deletions code/modules/mapping/reader.dm
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@
// And we are done lads, call it off
loading = FALSE
SSatoms.map_loader_stop(REF(src))
loading = FALSE

if(new_z)
for(var/z_index in bounds[MAP_MINZ] to bounds[MAP_MAXZ])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
/mob/living/basic/guardian/protector/Initialize(mapload, datum/guardian_fluff/theme)
. = ..()
shield = new(src)
shield.owner_has_control = FALSE // Hide it from the user, it's integrated with guardian UI
shield.Grant(src)

/mob/living/basic/guardian/protector/Destroy()
Expand Down Expand Up @@ -49,6 +48,7 @@
background_icon_state = "base"
cooldown_time = 1 SECONDS
click_to_activate = FALSE
owner_has_control = FALSE // Hide it from the user, it's integrated with guardian UI

/datum/action/cooldown/mob_cooldown/protector_shield/Activate(mob/living/target)
if (!isliving(target))
Expand Down
Loading

0 comments on commit ac29f4e

Please sign in to comment.