Skip to content

Commit

Permalink
Ports qols & fixes: 14677, 14822, 15793, 15814, 15855, 16153 (#209)
Browse files Browse the repository at this point in the history
* AI QOL stuffs (bounty) (#14677)

* Bunch of weird runtimes that broke one round then never happened again (#14822)

* Update attack.dm

* Runtime fixes (#15793)

* Minimap code fix (#15814)

* Observers can jump to locations using their minimap (#15795)

* Runtime fixes (#15855)

* Lighting error fix (#16153)

---------

Co-authored-by: ivanmixo <[email protected]>
Co-authored-by: Lumipharon <[email protected]>
Co-authored-by: SandPoot <[email protected]>
  • Loading branch information
4 people authored Sep 6, 2024
1 parent 09c9f38 commit 382315c
Show file tree
Hide file tree
Showing 30 changed files with 118 additions and 99 deletions.
5 changes: 2 additions & 3 deletions code/__HELPERS/logging/attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@
var/postfix = "[sobject][saddition][hp]"

var/message = "[what_done] [starget][postfix]"
user.log_message(message, LOG_ATTACK, color="red")
user?.log_message(message, LOG_ATTACK, color="red")

//if(user != target) // ORIGINAL
if(target && user != target) // RUTMGC EDITION
if(target && user != target)
var/reverse_message = "was [what_done] by [ssource][postfix]"
target.log_message(reverse_message, LOG_VICTIM, color="orange", log_globally=FALSE)

Expand Down
4 changes: 3 additions & 1 deletion code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,11 @@
/proc/deadchat_broadcast(message, source = null, mob/follow_target = null, turf/turf_target = null, speaker_key = null, message_type = DEADCHAT_REGULAR)
message = span_deadsay("[source][span_linkify("[message]")]")
for(var/mob/M in GLOB.player_list)
if(!M.client)
continue
var/chat_toggles = TOGGLES_CHAT_DEFAULT
var/deadchat_toggles = TOGGLES_DEADCHAT_DEFAULT
if(M.client.prefs)
if(M?.client?.prefs)
var/datum/preferences/prefs = M.client.prefs
chat_toggles = prefs.toggles_chat
deadchat_toggles = prefs.toggles_deadchat
Expand Down
13 changes: 0 additions & 13 deletions code/controllers/subsystem/lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,3 @@ SUBSYSTEM_DEF(lighting)
/datum/controller/subsystem/lighting/Recover()
initialized = SSlighting.initialized
return ..()

///sets up light objects for a particular z level. Used for late loading
/datum/controller/subsystem/lighting/proc/create_lighting_objects_for_z(z_level)
for(var/area/new_area in world)
if(new_area.z != z_level)
continue
if(!new_area.static_lighting)
continue

for(var/turf/T in new_area)
new/datum/static_lighting_object(T)
CHECK_TICK
CHECK_TICK
73 changes: 55 additions & 18 deletions code/controllers/subsystem/minimaps.dm
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ SUBSYSTEM_DEF(minimaps)
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
///assoc list of mob choices by clicking on coords. only exists fleetingly for the wait loop in [/proc/get_coords_from_click]
var/list/mob/choices_by_mob
///should get_coords_from_click stop waiting for an input?
var/stop_polling = FALSE

/atom/movable/screen/minimap/Initialize(mapload, datum/hud/hud_owner, target, flags)
. = ..()
Expand All @@ -391,21 +393,25 @@ SUBSYSTEM_DEF(minimaps)

/atom/movable/screen/minimap/Destroy()
SSminimaps.hashed_minimaps -= src
stop_polling = TRUE
return ..()

/**
* lets the user get coordinates by clicking the actual map
* Returns a list(x_coord, y_coord)
* note: sleeps until the user makes a choice or they disconnect
* note: sleeps until the user makes a choice, stop_polling is set to TRUE or they disconnect
*/
/atom/movable/screen/minimap/proc/get_coords_from_click(mob/user)
//lord forgive my shitcode
RegisterSignal(user, COMSIG_MOB_CLICKON, PROC_REF(on_click))
while(!choices_by_mob[user] && user.client)
var/signal_by_type = isobserver(user) ? COMSIG_OBSERVER_CLICKON : COMSIG_MOB_CLICKON
RegisterSignal(user, signal_by_type, PROC_REF(on_click))
while(!(choices_by_mob[user] || stop_polling) && user.client)
stoplag(1)
UnregisterSignal(user, COMSIG_MOB_CLICKON)
UnregisterSignal(user, signal_by_type)
. = choices_by_mob[user]
choices_by_mob -= user
// I have an extra layer of shitcode for you
stop_polling = FALSE

/**
* Handles fetching the targetted coordinates when the mob tries to click on this map
Expand Down Expand Up @@ -492,24 +498,34 @@ SUBSYSTEM_DEF(minimaps)
/datum/action/minimap/action_activate()
. = ..()
if(!map)
to_chat(owner, span_warning("This region doesn't seem to have a minimap!"))// RUTGMC ADDITION
return
to_chat(owner, span_warning("This region doesn't seem to have a minimap!"))
return FALSE
return toggle_minimap()

/// Toggles the minimap, has a variable to force on or off (most likely only going to be used to close it)
/datum/action/minimap/proc/toggle_minimap(force_state)
// No force state? Invert the current state
if(isnull(force_state))
force_state = !minimap_displayed
if(force_state == minimap_displayed)
return FALSE
if(!locator_override && ismovableatom(owner.loc))
override_locator(owner.loc)
var/atom/movable/tracking = locator_override ? locator_override : owner
if(minimap_displayed)
owner.client.screen -= map
owner.client.screen -= locator
locator.UnregisterSignal(tracking, COMSIG_MOVABLE_MOVED)
else
if(locate(/atom/movable/screen/minimap) in owner?.client.screen) //This seems like the most effective way to do this without some wacky code // RUTGMC ADDITION, added "?"
if(force_state)
if(locate(/atom/movable/screen/minimap) in owner?.client.screen) //This seems like the most effective way to do this without some wacky code
to_chat(owner, span_warning("You already have a minimap open!"))
return
return FALSE
owner.client.screen += map
owner.client.screen += locator
locator.update(tracking)
locator.RegisterSignal(tracking, COMSIG_MOVABLE_MOVED, TYPE_PROC_REF(/atom/movable/screen/minimap_locator, update))
minimap_displayed = !minimap_displayed
else
owner.client.screen -= map
owner.client.screen -= locator
locator.UnregisterSignal(tracking, COMSIG_MOVABLE_MOVED)
minimap_displayed = force_state
return TRUE

///Overrides the minimap locator to a given atom
/datum/action/minimap/proc/override_locator(atom/movable/to_track)
Expand All @@ -523,13 +539,13 @@ SUBSYSTEM_DEF(minimaps)
locator_override = to_track
if(to_track)
RegisterSignal(to_track, COMSIG_QDELETING, TYPE_PROC_REF(/datum/action/minimap, clear_locator_override))
if(owner?.loc == to_track) // RUTGMC ADDITION, added "?"
if(owner && owner.loc == to_track)
RegisterSignal(to_track, COMSIG_ATOM_EXITED, TYPE_PROC_REF(/datum/action/minimap, on_exit_check))
if(owner)
RegisterSignal(new_track, COMSIG_MOVABLE_Z_CHANGED, PROC_REF(on_owner_z_change))
var/turf/old_turf = get_turf(tracking)
if(!old_turf.z || old_turf.z != new_track.z)
on_owner_z_change(new_track, old_turf.z, new_track.z)
if(!old_turf || !old_turf.z || old_turf.z != new_track.z)
on_owner_z_change(new_track, old_turf?.z, new_track?.z)
return
locator.UnregisterSignal(tracking, COMSIG_MOVABLE_MOVED)
locator_override = to_track
Expand All @@ -554,10 +570,12 @@ SUBSYSTEM_DEF(minimaps)
///CLears the locator override in case the override target is deleted
/datum/action/minimap/proc/clear_locator_override()
SIGNAL_HANDLER
if(!locator_override)
return
UnregisterSignal(locator_override, list(COMSIG_QDELETING, COMSIG_ATOM_EXITED))
if(owner)
UnregisterSignal(locator_override, COMSIG_MOVABLE_Z_CHANGED)
RegisterSignal(owner, COMSIG_MOVABLE_Z_CHANGED)
RegisterSignal(owner, COMSIG_MOVABLE_Z_CHANGED, PROC_REF(on_owner_z_change))
var/turf/owner_turf = get_turf(owner)
if(owner_turf.z != locator_override.z)
on_owner_z_change(owner, locator_override.z, owner_turf.z)
Expand Down Expand Up @@ -717,3 +735,22 @@ SUBSYSTEM_DEF(minimaps)
/datum/action/minimap/observer
minimap_flags = MINIMAP_FLAG_XENO|MINIMAP_FLAG_MARINE|MINIMAP_FLAG_MARINE_SOM|MINIMAP_FLAG_EXCAVATION_ZONE
marker_flags = NONE

/datum/action/minimap/observer/action_activate()
. = ..()
if(!.)
return
if(!minimap_displayed)
map.stop_polling = TRUE
return
var/list/clicked_coords = map.get_coords_from_click(owner)
if(!clicked_coords)
return
var/turf/clicked_turf = locate(clicked_coords[1], clicked_coords[2], owner.z)
if(!clicked_turf)
return
// Taken directly from observer/DblClickOn
owner.abstract_move(clicked_turf)
owner.update_parallax_contents()
// Close minimap
toggle_minimap(FALSE)
3 changes: 1 addition & 2 deletions code/datums/jobs/squads.dm
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,7 @@
CRASH("attempted to remove squad leader from squad [name] while not having one set")

SSdirection.clear_leader(tracking_id)
SSdirection.stop_tracking(TRACKING_ID_MARINE_COMMANDER, squad_leader)
SSdirection.stop_tracking(TRACKING_ID_SOM_COMMANDER, squad_leader)
SSdirection.stop_tracking(faction == FACTION_SOM ? TRACKING_ID_SOM_COMMANDER : TRACKING_ID_MARINE_COMMANDER, squad_leader)

//Handle aSL skill level and radio
if(!ismarineleaderjob(squad_leader.job) && !issommarineleaderjob(squad_leader.job))
Expand Down
4 changes: 4 additions & 0 deletions code/game/atoms/atom_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,8 @@ RU TGMC EDIT */
return
var/hit_successful
var/old_throw_source = throw_source
if(QDELETED(hit_atom))
return FALSE
hit_successful = hit_atom.hitby(src, speed)
if(hit_successful)
SEND_SIGNAL(src, COMSIG_MOVABLE_IMPACT, hit_atom, speed)
Expand All @@ -498,6 +500,8 @@ RU TGMC EDIT */
/atom/movable/proc/throw_bounce(atom/hit_atom, turf/old_throw_source)
if(QDELETED(src))
return
if(QDELETED(hit_atom))
return
if(!isturf(loc))
return
var/dir_to_proj = get_dir(hit_atom, old_throw_source)
Expand Down
6 changes: 3 additions & 3 deletions code/game/objects/items/motion_detector.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
setDir(direction)
update_icon()

/// Remove the blip from the operator screen
///Remove the blip from the operator screen
/obj/effect/blip/edge_blip/remove_blip(mob/operator)
operator.client.screen -= src
operator?.client?.screen -= src
qdel(src)

/obj/effect/blip/edge_blip/update_icon_state()
Expand All @@ -41,7 +41,7 @@

/// Remove the blip from the operator images
/obj/effect/blip/close_blip/remove_blip(mob/operator)
operator.client?.images -= blip_image
operator?.client?.images -= blip_image
qdel(src)

/obj/effect/blip/close_blip/Destroy()
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/weapons/blades.dm
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,9 @@
///Throws a knife from the stack, or, if the stack is one, throws the stack.
/obj/item/stack/throwing_knife/proc/throw_knife()
SIGNAL_HANDLER
if(living_user?.get_active_held_item() != src) // RUTGMC ADDITION, added "?"
if(living_user?.get_active_held_item() != src)
return
if(living_user?.Adjacent(current_target)) // RUTGMC ADDITION, added "?"
if(living_user?.Adjacent(current_target))
return AUTOFIRE_CONTINUE
var/thrown_thing = src
if(amount == 1)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/weapon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
hitsound = "swing_hit"
var/caliber = "missing from codex" //codex
var/load_method = null //codex, defines are below.
var/max_shells = 0 //codex, bullets, shotgun shells
var/max_shells = 0 //codex, bullets, shotgun shells TODO: KILL THESE TWO VARS
var/max_shots = 0 //codex, energy weapons
var/scope_zoom = FALSE//codex
var/self_recharge = FALSE //codex
Expand Down
1 change: 0 additions & 1 deletion code/game/objects/machinery/computer/camera_advanced.dm
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@
var/visible_icon = 0
var/image/user_image = null


/mob/camera/aiEye/remote/update_remote_sight(mob/living/user)
user.see_invisible = SEE_INVISIBLE_LIVING
user.sight = SEE_SELF|SEE_MOBS|SEE_OBJS|SEE_TURFS|SEE_BLACKNESS
Expand Down
5 changes: 0 additions & 5 deletions code/game/objects/machinery/hologram.dm
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,6 @@
For the other part of the code, check silicon say.dm. Particularly robot talk.*/
/obj/machinery/holopad/Hear(message, atom/movable/speaker, datum/language/message_language, raw_message, radio_freq, list/spans, message_mode)
. = ..()
if(speaker && LAZYLEN(masters) && !radio_freq)//Master is mostly a safety in case lag hits or something. Radio_freq so AIs dont hear holopad stuff through radios.
for(var/mob/living/silicon/ai/master in masters)
if(masters[master] && speaker != master)
master.relay_speech(message, speaker, message_language, raw_message, radio_freq, spans, message_mode)

for(var/datum/holocall/holocall_to_update AS in holo_calls)
if(holocall_to_update.connected_holopad == src && speaker != holocall_to_update.hologram)
holocall_to_update.user.Hear(message, speaker, message_language, raw_message, radio_freq, spans, message_mode)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/machinery/telecomms/broadcasting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@

// Add observers who have ghost radio enabled.
for(var/mob/dead/observer/ghost in GLOB.player_list)
if(ghost.client.prefs.toggles_chat & CHAT_GHOSTRADIO)
if(ghost?.client?.prefs?.toggles_chat & CHAT_GHOSTRADIO)
receive |= ghost

// Render the message and have everybody hear it.
Expand Down
8 changes: 3 additions & 5 deletions code/game/objects/structures/droppod.dm
Original file line number Diff line number Diff line change
Expand Up @@ -550,19 +550,17 @@ GLOBAL_LIST_INIT(blocked_droppod_tiles, typecacheof(list(/turf/open/space/transi
owner.client.screen += map
choosing = TRUE
var/list/polled_coords = map.get_coords_from_click(owner)
owner?.client?.screen -= map
choosing = FALSE
if(!polled_coords)
owner.client?.screen -= map
choosing = FALSE
return
owner.client?.screen -= map
choosing = FALSE
pod.set_target(polled_coords[1], polled_coords[2])

/datum/action/innate/set_drop_target/remove_action(mob/M)
if(choosing)
var/obj/structure/droppod/pod = target
var/atom/movable/screen/minimap/map = SSminimaps.fetch_minimap_object(pod.target_z, MINIMAP_FLAG_MARINE)
owner.client?.screen -= map
owner?.client?.screen -= map
map.UnregisterSignal(owner, COMSIG_MOB_CLICKON)
choosing = FALSE
return ..()
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/structures/teleporter_array.dm
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
choosing = TRUE
var/list/polled_coords = map.get_coords_from_click(owner)
if(!polled_coords)
owner.client?.screen -= map
owner?.client?.screen -= map
choosing = FALSE
return
var/turf/chosen_turf = locate(polled_coords[1], polled_coords[2], teleporter.targetted_zlevel)
Expand All @@ -194,7 +194,7 @@
if(choosing)
var/obj/structure/teleporter_array/teleporter = target
var/atom/movable/screen/minimap/map = SSminimaps.fetch_minimap_object(teleporter.targetted_zlevel, GLOB.faction_to_minimap_flag[owner.faction])
owner.client?.screen -= map
owner?.client?.screen -= map
map.UnregisterSignal(owner, COMSIG_MOB_CLICKON)
choosing = FALSE
return ..()
2 changes: 1 addition & 1 deletion code/game/sound.dm
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ A good representation is: 'byond applies a volume reduction to the sound every X
var/turf/T = get_turf(M)
if(!T || T.z != turf_source.z || get_dist(M, turf_source) > sound_range)
continue
M.playsound_local(turf_source, soundin, vol, vary, frequency, falloff, is_global, channel, S)
M.playsound_local(turf_source, soundin, vol, vary, frequency, falloff, is_global, channel, S, sound_reciever = M)

for(var/obj/vehicle/sealed/armored/armor AS in GLOB.tank_list)
if(!armor.interior || armor.z != turf_source.z || get_dist(armor, turf_source) > sound_range)
Expand Down
4 changes: 3 additions & 1 deletion code/modules/condor/cas_shuttle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@
var/atom/movable/screen/minimap/map = SSminimaps.fetch_minimap_object(2, MINIMAP_FLAG_MARINE)
user.client.screen += map
var/list/polled_coords = map.get_coords_from_click(user)
user.client.screen -= map
user?.client?.screen -= map
if(!polled_coords)
return
starting_point = locate(polled_coords[1], polled_coords[2], 2)

if(GLOB.minidropship_start_loc && !starting_point) //and if this somehow fails (it shouldn't) we just go to the default point
Expand Down
8 changes: 4 additions & 4 deletions code/modules/keybindings/bindings_atom.dm
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// You might be wondering why this isn't client level. If focus is null, we don't want you to move.
// Only way to do that is to tie the behavior into the focus's keyLoop().
/atom/movable/keyLoop(client/user)
if(user.keys_held["Ctrl"])
if(user?.keys_held["Ctrl"])
return
var/movement_dir = NONE
for(var/_key in user.keys_held)
movement_dir = movement_dir | user.movement_keys[_key]
if(user.next_move_dir_add)
if(user?.next_move_dir_add)
movement_dir |= user.next_move_dir_add
if(user.next_move_dir_sub)
if(user?.next_move_dir_sub)
movement_dir &= ~user.next_move_dir_sub
// Sanity checks in case you hold left and right and up to make sure you only go up
if((movement_dir & NORTH) && (movement_dir & SOUTH))
movement_dir &= ~(NORTH|SOUTH)
if((movement_dir & EAST) && (movement_dir & WEST))
movement_dir &= ~(EAST|WEST)
user.Move(get_step(src, movement_dir), movement_dir)
user?.Move(get_step(src, movement_dir), movement_dir)
1 change: 0 additions & 1 deletion code/modules/mapping/map_template.dm
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
SSweather.load_late_z(level.z_value)
SSair.setup_atmos_machinery()
SSair.setup_pipenets()
SSlighting.create_lighting_objects_for_z(level.z_value)
smooth_zlevel(level.z_value)
if(minimap)
SSminimaps.load_new_z(null, level)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,12 @@ GLOBAL_LIST_INIT(hivemind_resin_images_list, list(
owner.client?.screen += shown_map
showing_map = TRUE
var/list/polled_coords = shown_map.get_coords_from_click(owner)

owner.client?.screen -= shown_map
showing_map = FALSE
if(!polled_coords)
owner.client?.screen -= shown_map
shown_map.UnregisterSignal(owner, COMSIG_MOB_CLICKON)
showing_map = FALSE
return

owner.client?.screen -= shown_map
showing_map = FALSE
var/turf/turf_to_teleport_to = locate(polled_coords[1], polled_coords[2], owner.z)

if(!turf_to_teleport_to)
return

Expand Down
Loading

0 comments on commit 382315c

Please sign in to comment.