Skip to content

Commit

Permalink
Sentry exploit fix (#16695)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lumipharon authored Oct 26, 2024
1 parent aa08a7c commit ace25b1
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions code/modules/projectiles/sentries.dm
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,7 @@ GLOBAL_LIST_INIT(sentry_ignore_List, set_sentry_ignore_List())
/obj/machinery/deployable/mounted/sentry/proc/knock_down()
if(CHECK_BITFIELD(machine_stat, KNOCKED_DOWN))
return
var/obj/item/weapon/gun/internal_gun = get_internal_item()
internal_gun.stop_fire() //Comrade sentry has been sent to the gulags. He served the revolution well.
firing = FALSE
update_minimap_icon()
sentry_stop_fire()
visible_message(span_highdanger("The [name] is knocked over!"))
sentry_alert(SENTRY_ALERT_FALLEN)
ENABLE_BITFIELD(machine_stat, KNOCKED_DOWN)
Expand Down Expand Up @@ -375,10 +372,7 @@ GLOBAL_LIST_INIT(sentry_ignore_List, set_sentry_ignore_List())
/obj/machinery/deployable/mounted/sentry/process()
update_icon()
if((machine_stat & EMPED) || !scan())
var/obj/item/weapon/gun/gun = get_internal_item()
gun?.stop_fire()
firing = FALSE
update_minimap_icon()
sentry_stop_fire()
return
playsound(loc, 'sound/items/detector.ogg', 25, FALSE)

Expand Down Expand Up @@ -425,29 +419,26 @@ GLOBAL_LIST_INIT(sentry_ignore_List, set_sentry_ignore_List())
if(CHECK_BITFIELD(internal_gun.reciever_flags, AMMO_RECIEVER_REQUIRES_UNIQUE_ACTION) && length(internal_gun.chamber_items))
INVOKE_ASYNC(internal_gun, TYPE_PROC_REF(/obj/item/weapon/gun, do_unique_action))
if(!CHECK_BITFIELD(internal_gun.item_flags, IS_DEPLOYED) || get_dist(src, gun_target) > range || (!CHECK_BITFIELD(get_dir(src, gun_target), dir) && !CHECK_BITFIELD(internal_gun.turret_flags, TURRET_RADIAL)) || !check_target_path(gun_target))
internal_gun.stop_fire()
firing = FALSE
update_minimap_icon()
sentry_stop_fire()
return
if(internal_gun.gun_firemode != GUN_FIREMODE_SEMIAUTO)
return
addtimer(CALLBACK(src, PROC_REF(sentry_start_fire)), internal_gun.fire_delay) //This schedules the next shot if the gun is on semi-automatic. This is so that semi-automatic guns don't fire once every two seconds.

///Sees if theres a target to shoot, then handles firing.
/obj/machinery/deployable/mounted/sentry/proc/sentry_start_fire()
if(isclosedturf(loc))
sentry_stop_fire()
return
var/obj/item/weapon/gun/gun = get_internal_item()
var/atom/target = get_target()
if(!target)
gun.stop_fire()
firing = FALSE
update_minimap_icon()
sentry_stop_fire()
return
sentry_alert(SENTRY_ALERT_HOSTILE, target)
update_icon()
if(target != gun.target)
gun.stop_fire()
firing = FALSE
update_minimap_icon()
sentry_stop_fire()
if(gun.rounds <= 0) //fucking lasers
sentry_alert(SENTRY_ALERT_AMMO)
return
Expand All @@ -460,6 +451,13 @@ GLOBAL_LIST_INIT(sentry_ignore_List, set_sentry_ignore_List())
firing = TRUE
update_minimap_icon()

///Ends firing
/obj/machinery/deployable/mounted/sentry/proc/sentry_stop_fire()
var/obj/item/weapon/gun/gun = get_internal_item()
gun?.stop_fire()
firing = FALSE
update_minimap_icon()

///Checks the path to the target for obstructions. Returns TRUE if the path is clear, FALSE if not.
/obj/machinery/deployable/mounted/sentry/proc/check_target_path(atom/target)
if(target.loc == loc)
Expand All @@ -481,15 +479,11 @@ GLOBAL_LIST_INIT(sentry_ignore_List, set_sentry_ignore_List())
return FALSE

var/obj/item/weapon/gun/gun = get_internal_item()
for(var/turf/T AS in path)
var/obj/effect/particle_effect/smoke/smoke = locate() in T
if(smoke?.opacity)
return FALSE

if(IS_OPAQUE_TURF(T) || T.density && !(T.allow_pass_flags & PASS_PROJECTILE) && !(T.type in GLOB.sentry_ignore_List))
for(var/turf/path_turf AS in path)
if(IS_OPAQUE_TURF(path_turf) || path_turf.density && !(path_turf.allow_pass_flags & PASS_PROJECTILE) && !(path_turf.type in GLOB.sentry_ignore_List))
return FALSE

for(var/atom/movable/AM AS in T)
for(var/atom/movable/AM AS in path_turf)
if(AM == target)
continue
if(AM.opacity)
Expand Down

0 comments on commit ace25b1

Please sign in to comment.