Skip to content

Commit

Permalink
Previous suggestions to prevent T and cross shape flips
Browse files Browse the repository at this point in the history
  • Loading branch information
Drulikar committed Jul 13, 2023
1 parent 39a95b3 commit e68cea2
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions code/game/objects/structures/tables_racks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -326,16 +326,14 @@
/// Checks whether a table is a straight line along a given axis
/obj/structure/surface/table/proc/straight_table_check(direction)
var/obj/structure/surface/table/table = src

// Check whether there are connected tables perpendicular to the axis
for(var/angle in list(-90, 90))
table = locate() in get_step(loc, turn(direction, angle))
if(table && !table.flipped)
return FALSE

table = src
var/tables_count = 8 // Lazy extra safety against infinite loops. If table big, can't flip, i guess.
while(table && tables_count--)
var/obj/structure/surface/table/side_table
var/tables_count = 7 // Lazy extra safety against infinite loops. If table big, can't flip, i guess.
while(--tables_count)
// Check whether there are connected tables perpendicular to the axis
for(var/angle in list(-90, 90))
side_table = locate() in get_step(table, turn(direction, angle))
if(side_table && !side_table.flipped)
return FALSE
table = locate() in get_step(table, direction)
if(!table || table.flipped)
return TRUE
Expand Down Expand Up @@ -427,7 +425,7 @@
to_chat(usr, SPAN_WARNING("You have moved a table too recently."))
return FALSE

if(!skip_straight_check && (!straight_table_check(turn(direction, 90)) || !straight_table_check(turn(direction, -90))))
if(!skip_straight_check && !(straight_table_check(turn(direction, 90)) && straight_table_check(turn(direction, -90))))
to_chat(usr, SPAN_WARNING("[src] is too wide to be flipped."))
return FALSE

Expand Down

0 comments on commit e68cea2

Please sign in to comment.