From 0ba0d4803fbab92867f475677c914485a24afdb9 Mon Sep 17 00:00:00 2001 From: Fira Date: Tue, 27 Jun 2023 14:07:34 +0100 Subject: [PATCH 1/4] fix table stuff --- code/game/objects/structures/tables_racks.dm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/code/game/objects/structures/tables_racks.dm b/code/game/objects/structures/tables_racks.dm index 730263ad7a3e..8383ccafc6bf 100644 --- a/code/game/objects/structures/tables_racks.dm +++ b/code/game/objects/structures/tables_racks.dm @@ -326,12 +326,16 @@ /// 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 - while(table) - // 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 + + // 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/max_tables = 8 // Lazy extra safety against infinite loops. If table big, can't flip, i guess. + while(table && max_tables--) table = locate() in get_step(table, direction) if(!table || table.flipped) return TRUE From 89ce28cc2b6f9efca7c0847be033326120604fff Mon Sep 17 00:00:00 2001 From: Fira Date: Tue, 27 Jun 2023 14:14:36 +0100 Subject: [PATCH 2/4] woops --- code/game/objects/structures/tables_racks.dm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/game/objects/structures/tables_racks.dm b/code/game/objects/structures/tables_racks.dm index 8383ccafc6bf..c0db9f312519 100644 --- a/code/game/objects/structures/tables_racks.dm +++ b/code/game/objects/structures/tables_racks.dm @@ -343,6 +343,8 @@ var/obj/structure/surface/table/reinforced/reinforced_table = table if(reinforced_table.status == RTABLE_NORMAL) return FALSE + if(!max_tables) + return FALSE return TRUE /obj/structure/surface/table/verb/do_flip() From 94ceb4be4a31536c0966677318040c9c6ee90a27 Mon Sep 17 00:00:00 2001 From: Fira Date: Tue, 27 Jun 2023 14:45:53 +0100 Subject: [PATCH 3/4] oops --- code/game/objects/structures/tables_racks.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/game/objects/structures/tables_racks.dm b/code/game/objects/structures/tables_racks.dm index c0db9f312519..33cb0bcd7b46 100644 --- a/code/game/objects/structures/tables_racks.dm +++ b/code/game/objects/structures/tables_racks.dm @@ -334,8 +334,8 @@ return FALSE table = src - var/max_tables = 8 // Lazy extra safety against infinite loops. If table big, can't flip, i guess. - while(table && max_tables--) + var/tables_count = 8 // Lazy extra safety against infinite loops. If table big, can't flip, i guess. + while(table && tables_count--) table = locate() in get_step(table, direction) if(!table || table.flipped) return TRUE @@ -343,7 +343,7 @@ var/obj/structure/surface/table/reinforced/reinforced_table = table if(reinforced_table.status == RTABLE_NORMAL) return FALSE - if(!max_tables) + if(!tables_count) return FALSE return TRUE From e68cea2977a5a18aca65b58558a2a9047648ef5d Mon Sep 17 00:00:00 2001 From: Drulikar Date: Thu, 13 Jul 2023 15:55:59 -0700 Subject: [PATCH 4/4] Previous suggestions to prevent T and cross shape flips --- code/game/objects/structures/tables_racks.dm | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/code/game/objects/structures/tables_racks.dm b/code/game/objects/structures/tables_racks.dm index 33cb0bcd7b46..db3ce98339a3 100644 --- a/code/game/objects/structures/tables_racks.dm +++ b/code/game/objects/structures/tables_racks.dm @@ -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 @@ -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