Skip to content

refactor is_blocked_turf #29324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

warriorstar-orion
Copy link
Contributor

What Does This PR Do

This PR pulls our implementation of /proc/is_blocked_turf more in line with /tg/'s /turf/proc/is_blocked_turf.

Why It's Good For The Game

The argument names and behavior of these two different procs is just different enough to be confusing when porting things like AI behavior subtrees, so better to avoid any confusion on how to properly handle the discrepancies.

Testing

Compiles, will request TM as well.

Declaration

  • I confirm that I either do not require pre-approval for this PR, or I have obtained such approval and have included a screenshot to demonstrate this below.

Changelog

NPFC

@ParadiseSS13-Bot ParadiseSS13-Bot added Testmerge Requested This PR has a pending testmerge request -Status: Awaiting review This PR is awaiting review from the review team labels May 14, 2025
@kyunkyunkyun
Copy link
Contributor

kyunkyunkyun commented May 14, 2025

wonder if it can be now renamed into just is_blocked() since it's now declared for turf only, not globally
mb even isblocked()

Copy link
Contributor

@kyunkyunkyun kyunkyunkyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can shorten it i believe

@@ -246,7 +246,7 @@ Difficulty: Medium
if(get_dist(src, O) >= MINER_DASH_RANGE && turf_dist_to_target <= self_dist_to_target && !islava(O) && !ischasm(O))
var/valid = TRUE
for(var/turf/T in get_line(own_turf, O))
if(is_blocked_turf(T, TRUE))
if(T.is_blocked_turf(exclude_mobs = TRUE))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(T.is_blocked_turf(exclude_mobs = TRUE))
if(T.is_blocked_turf(TRUE))

@@ -680,7 +680,7 @@
for(var/distance in 0 to 8)
var/turf/current_dash_target = dash_target
current_dash_target = get_step(current_dash_target, user.dir)
if(!is_blocked_turf(current_dash_target, TRUE))
if(!current_dash_target.is_blocked_turf(exclude_mobs = TRUE))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(!current_dash_target.is_blocked_turf(exclude_mobs = TRUE))
if(!current_dash_target.is_blocked_turf(TRUE))

@@ -240,7 +241,7 @@

/obj/item/hierophant_club/proc/teleport_mob(turf/source, mob/M, turf/target, mob/user)
var/turf/turf_to_teleport_to = get_step(target, get_dir(source, M)) //get position relative to caster
if(!turf_to_teleport_to || is_blocked_turf(turf_to_teleport_to, TRUE))
if(!turf_to_teleport_to || turf_to_teleport_to.is_blocked_turf(exclude_mobs = TRUE))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(!turf_to_teleport_to || turf_to_teleport_to.is_blocked_turf(exclude_mobs = TRUE))
if(!turf_to_teleport_to || turf_to_teleport_to.is_blocked_turf(TRUE))

@@ -205,7 +206,7 @@
if(beacon)
beacon.icon_state = "hierophant_tele_off"
return
if(is_blocked_turf(T, TRUE))
if(T.is_blocked_turf(exclude_mobs = TRUE))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(T.is_blocked_turf(exclude_mobs = TRUE))
if(T.is_blocked_turf(TRUE))

@@ -184,7 +185,7 @@
if(do_after(user, 40, target = user) && user && beacon)
var/turf/T = get_turf(beacon)
var/turf/source = get_turf(user)
if(is_blocked_turf(T, TRUE))
if(T.is_blocked_turf(exclude_mobs = TRUE))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(T.is_blocked_turf(exclude_mobs = TRUE))
if(T.is_blocked_turf(TRUE))

@@ -82,7 +82,7 @@
return
var/turf/T = get_turf(target)

if(is_blocked_turf(T, TRUE)) //can't put mines on a tile that has dense stuff
if(T.is_blocked_turf(exclude_mobs = TRUE)) //can't put mines on a tile that has dense stuff
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(T.is_blocked_turf(exclude_mobs = TRUE)) //can't put mines on a tile that has dense stuff
if(T.is_blocked_turf(TRUE)) //can't put mines on a tile that has dense stuff

@@ -180,7 +180,7 @@

/obj/effect/spawner/random/proc/has_unblocked_line(destination)
for(var/turf/potential_blockage as anything in get_line(get_turf(src), destination))
if(!is_blocked_turf(potential_blockage, exclude_mobs = TRUE))
if(!potential_blockage.is_blocked_turf(exclude_mobs = TRUE))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(!potential_blockage.is_blocked_turf(exclude_mobs = TRUE))
if(!potential_blockage.is_blocked_turf(TRUE))

@@ -1053,7 +1053,7 @@

var/has_tried_to_move = FALSE

if(is_blocked_turf(target_turf, TRUE, excluded_objs = list(src)))
if(target_turf.is_blocked_turf(exclude_mobs = TRUE, ignore_atoms = list(src)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(target_turf.is_blocked_turf(exclude_mobs = TRUE, ignore_atoms = list(src)))
if(target_turf.is_blocked_turf(TRUE, ignore_atoms = list(src)))

@@ -61,7 +61,7 @@
sleep(jaunt_in_time)
qdel(holder)
if(!QDELETED(target))
if(is_blocked_turf(mobloc, TRUE))
if(mobloc.is_blocked_turf(exclude_mobs = TRUE))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(mobloc.is_blocked_turf(exclude_mobs = TRUE))
if(mobloc.is_blocked_turf(TRUE))

for(var/turf/potential_blockage as anything in get_line(get_turf(structure_parent), turf_in_view))
if(!is_blocked_turf(potential_blockage, exclude_mobs = TRUE, excluded_objs = list(parent)))
nearby_empty_tiles += turf_in_view
if(potential_blockage.is_blocked_turf(exclude_mobs = TRUE, source_atom = parent))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(potential_blockage.is_blocked_turf(exclude_mobs = TRUE, source_atom = parent))
if(potential_blockage.is_blocked_turf(TRUE, parent))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd personally lean towards leaving these args in place, it never hurts to be a little more verbose about what the arguments to a proc are

Copy link
Contributor

@lewcc lewcc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me. I'd argue that keeping the arguments for the proc is probably a net positive

@ParadiseSS13-Bot ParadiseSS13-Bot added -Status: Awaiting merge This PR is ready for merge and removed -Status: Awaiting review This PR is awaiting review from the review team labels May 15, 2025
@warriorstar-orion
Copy link
Contributor Author

wonder if it can be now renamed into just is_blocked() since it's now declared for turf only, not globally mb even isblocked()

is_blocked() is the better name but I'm keeping it as is_blocked_turf() in order to avoid people porting AI behaviors and the like from /tg/ to have to change it.

Regarding the use of the argument name in the proc call, as @lewcc said, keeping the argument name makes it clearer what the purpose of the boolean value is for. is_blocked_turf(exclude_mobs = TRUE) is more readable than is_blocked_turf(TRUE) if you're reading through the code.

@ParadiseSS13-Bot ParadiseSS13-Bot added the Testmerge Active This PR is currently testmerged on production label May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Status: Awaiting merge This PR is ready for merge Testmerge Active This PR is currently testmerged on production Testmerge Requested This PR has a pending testmerge request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants