[MIRROR] [MDB IGNORE] dir sanity, primarily on WALLITEMs [MDB IGNORE] (#9315)

* [MDB IGNORE] dir sanity, primarily on WALLITEMs (#62601)

About The Pull Request

Wall items mostly use the direction from the floor to the wall in the named mapping helper. Wall items mostly use the direction from the wall to the floor for the internal dir variable.

This leads to a headache when it comes to working out what conflicts with what, and what needs placing where.

Wall frames provided a member, inverse, which specified whether or not to invert the direction of the item when looking for conflicts. It was also used to specify whether to look for conflicts outside of the wall (cameras and lights appear external to the wall) or inside the wall (most wall items). This flag was set for Intercoms, APCs, and Lights. Since APCs and Lights expect a floor-to-wall direction, and Intercoms expect a wall-to-floor direction, this means that APCs and Lights were getting the correct direction, and Intercoms were getting the wrong direction.

Some implications of this setup were:

    You could build an APC on top of another wall item, provided there was nothing external attached to the wall and the area didn't have an APC.
    You could stack Intercoms indefinitely on top of the same wall, provided you weren't in a one-tile wide corridor with something on the opposite wall.

Or both! Here's twenty Intercoms placed on the wall, and a freshly placed APC frame after placing all Intercoms and deconstructing the old APC:

endless-stack-of-intercoms

Not everything used this inverse variable to adjust to the correct direction. For example, /obj/machinery/defibrillator_mount just used a negative pixel_offset to be visually placed in the correct direction, even though the internal direction was wrong, and never set! This also let you stack an indefinite number of defib mounts on the same wall, provided it wasn't a northern wall... except you could do this to northern walls too, since defibs weren't considered a wall item for the purposes of checking collisions at all!

Ultimately, every constructable interior wall item either used this inverse variable to adjust to the correct placement, set a negative pixel_offset variable to have its offset adjusted to the correct placement, or overrode New or Initialize to run its own checks and assignment to pixel_x and pixel_y!
Inventory: Table of various paths, related paths, and the adjustments they used

Unfortunately, untangling /obj/structure/sign is going to be another major headache, and this has already exploded in scope enough already, so we can't get rid of the get_turf_pixel call just yet. This also doesn't fix problems with the special 2x1 /obj/structure/sign/barsign.

Some non-wall items have been made to use the new MAPPING_DIRECTIONAL_HELPERS as part of the directional cleanup.

tl;dr: All wall mounted items and some directional objects now use the same direction that they were labelled as. More consistent directional types everywhere.
Why It's Good For The Game

fml
Changelog

cl
refactor: Wall mounted and directional objects have undergone major internal simplification. Please report anything unusual!
fix: You can no longer stack an indefinite amount of Intercoms on the same wall.
fix: Defibrillator Mounts, Bluespace Gas Vendors, Turret Controlers, and Ticket Machines are now considered wall items.
fix: Wall mounted items on top of the wall now consistently check against other items on top of the wall, and items coming out of the wall now consistently check against other items coming out of the wall.
fix: The various directional pixel offsets within an APC, Fire Extinguisher Cabinet, Intercom, or Newscaster have been made consistent with each other.
fix: The pixel offsets of Intercoms, Fire Alarms, Fire Extinguisher Cabinets, Flashers, and Newscasters have been made consistent between roundstart and constructed instances.
fix: Constructed Turret Controls will no longer oddly overhang the wall they were placed on.
qol: Defibrillator mounts now better indicate which side of the wall they are on.
fix: Some instances where there were multiple identical lights on the same tile have been fixed to only have one.
/cl

* [MDB IGNORE] dir sanity, primarily on WALLITEMs

* apc directionals

* bluespace vendor fix

* defib fix

Co-authored-by: esainane <esainane+github@gmail.com>
Co-authored-by: jjpark-kb <55967837+jjpark-kb@users.noreply.github.com>
This commit is contained in:
SkyratBot
2021-11-10 22:17:26 +00:00
committed by GitHub
parent 42dd617408
commit 71b5f92eda
145 changed files with 3328 additions and 4029 deletions
+1 -3
View File
@@ -242,6 +242,7 @@
flags_1 = NONE
icon_state = "frame-empty"
result_path = /obj/structure/sign/painting
pixel_shift = 30
/obj/structure/sign/painting
name = "Painting"
@@ -262,9 +263,6 @@
SSpersistent_paintings.painting_frames += src
if(dir)
setDir(dir)
if(building)
pixel_x = (dir & 3)? 0 : (dir == 4 ? -30 : 30)
pixel_y = (dir & 3)? (dir ==1 ? -30 : 30) : 0
/obj/structure/sign/painting/Destroy()
. = ..()
@@ -49,6 +49,7 @@
icon = 'icons/obj/monitors.dmi' //OVERRIDEN IN SKYRAT AESTHETICS - SEE MODULE
icon_state = "alarm_bitem"
result_path = /obj/machinery/airalarm
pixel_shift = 24
#define AALARM_MODE_SCRUBBING 1
#define AALARM_MODE_VENTING 2 //makes draught
@@ -128,8 +129,6 @@
if(nbuild)
buildstage = AIRALARM_BUILD_NO_CIRCUIT
panel_open = TRUE
pixel_x = (dir & 3)? 0 : (dir == 4 ? -24 : 24)
pixel_y = (dir & 3)? (dir == 1 ? -24 : 24) : 0
if(name == initial(name))
name = "[get_area_name(src)] Air Alarm"
@@ -886,21 +885,7 @@
/obj/machinery/airalarm/away //general away mission access
req_access = list(ACCESS_AWAY_GENERAL)
/obj/machinery/airalarm/directional/north //Pixel offsets get overwritten on New()
dir = SOUTH
pixel_y = 24
/obj/machinery/airalarm/directional/south
dir = NORTH
pixel_y = -24
/obj/machinery/airalarm/directional/east
dir = WEST
pixel_x = 24
/obj/machinery/airalarm/directional/west
dir = EAST
pixel_x = -24
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/airalarm, 24)
/obj/item/circuit_component/air_alarm
display_name = "Air Alarm"
@@ -4,6 +4,7 @@
icon = 'icons/obj/atmospherics/components/bluespace_gas_selling.dmi'
icon_state = "bluespace_vendor_open"
result_path = /obj/machinery/bluespace_vendor/built
pixel_shift = 30
///Defines for the mode of the vendor
#define BS_MODE_OFF 1
@@ -51,31 +52,13 @@
map_spawned = FALSE
mode = BS_MODE_OPEN
/obj/machinery/bluespace_vendor/north //Pixel offsets get overwritten on New()
dir = SOUTH
pixel_y = 30
/obj/machinery/bluespace_vendor/south
dir = NORTH
pixel_y = -30
/obj/machinery/bluespace_vendor/east
dir = WEST
pixel_x = 30
/obj/machinery/bluespace_vendor/west
dir = EAST
pixel_x = -30
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/bluespace_vendor, 30)
/obj/machinery/bluespace_vendor/New(loc, ndir, nbuild)
. = ..()
if(ndir)
setDir(ndir)
if(nbuild)
panel_open = TRUE
pixel_x = (dir & 3)? 0 : (dir == 4 ? -30 : 30)
pixel_y = (dir & 3)? (dir == 1 ? -30 : 30) : 0
update_appearance()
+1 -15
View File
@@ -34,21 +34,7 @@
density = FALSE //this is a wallmount
/obj/machinery/computer/auxiliary_base/directional/north
dir = SOUTH
pixel_y = 32
/obj/machinery/computer/auxiliary_base/directional/south
dir = NORTH
pixel_y = -32
/obj/machinery/computer/auxiliary_base/directional/east
dir = WEST
pixel_x = 32
/obj/machinery/computer/auxiliary_base/directional/west
dir = EAST
pixel_x = -32
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/computer/auxiliary_base, 32)
/obj/machinery/computer/auxiliary_base/Initialize(mapload)
. = ..()
+1 -15
View File
@@ -22,21 +22,7 @@
var/list/ticket_holders = list()
var/list/obj/item/ticket_machine_ticket/tickets = list()
/obj/machinery/ticket_machine/directional/north
dir = SOUTH
pixel_y = 32
/obj/machinery/ticket_machine/directional/south
dir = NORTH
pixel_y = -32
/obj/machinery/ticket_machine/directional/east
dir = WEST
pixel_x = 32
/obj/machinery/ticket_machine/directional/west
dir = EAST
pixel_x = -32
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/ticket_machine, 32)
/obj/machinery/ticket_machine/multitool_act(mob/living/user, obj/item/I)
if(!multitool_check_buffer(user, I)) //make sure it has a data buffer
+1 -3
View File
@@ -9,6 +9,7 @@
icon_state = "frame-overlay"
result_path = /obj/structure/sign/picture_frame
var/obj/item/photo/displayed
pixel_shift = 30
/obj/item/wallframe/picture/attackby(obj/item/I, mob/user)
if(istype(I, /obj/item/photo))
@@ -83,9 +84,6 @@
LAZYADD(SSpersistence.photo_frames, src)
if(dir)
setDir(dir)
if(building)
pixel_x = (dir & 3)? 0 : (dir == 4 ? -30 : 30)
pixel_y = (dir & 3)? (dir ==1 ? -30 : 30) : 0
/obj/structure/sign/picture_frame/Destroy()
LAZYREMOVE(SSpersistence.photo_frames, src)
+28 -40
View File
@@ -14,6 +14,10 @@
/// The APCs cover is missing.
#define APC_COVER_REMOVED 2
// APC visuals
/// Pixel offset of the APC from the floor turf
#define APC_PIXEL_OFFSET 25
// APC charging status:
/// The APC is not charging.
#define APC_NOT_CHARGING 0
@@ -145,7 +149,6 @@
var/locked = TRUE
var/coverlocked = TRUE
var/aidisabled = FALSE
var/tdir = null
var/obj/machinery/power/terminal/terminal = null
var/lastused_light = 0
var/lastused_equip = 0
@@ -198,21 +201,7 @@
/obj/machinery/power/apc/auto_name
auto_name = TRUE
/obj/machinery/power/apc/auto_name/north //Pixel offsets get overwritten on New()
dir = NORTH
pixel_y = 23
/obj/machinery/power/apc/auto_name/south
dir = SOUTH
pixel_y = -23
/obj/machinery/power/apc/auto_name/east
dir = EAST
pixel_x = 24
/obj/machinery/power/apc/auto_name/west
dir = WEST
pixel_x = -25
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name, APC_PIXEL_OFFSET)
/obj/machinery/power/apc/get_cell()
return cell
@@ -232,30 +221,7 @@
GLOB.apcs_list += src
wires = new /datum/wires/apc(src)
// offset 24 pixels in direction of dir
// this allows the APC to be embedded in a wall, yet still inside an area
if (building)
setDir(ndir)
tdir = dir // to fix Vars bug
setDir(SOUTH)
switch(tdir)
if(NORTH)
if((pixel_y != initial(pixel_y)) && (pixel_y != 23))
log_mapping("APC: ([src]) at [AREACOORD(src)] with dir ([tdir] | [uppertext(dir2text(tdir))]) has pixel_y value ([pixel_y] - should be 23.)")
pixel_y = 23
if(SOUTH)
if((pixel_y != initial(pixel_y)) && (pixel_y != -23))
log_mapping("APC: ([src]) at [AREACOORD(src)] with dir ([tdir] | [uppertext(dir2text(tdir))]) has pixel_y value ([pixel_y] - should be -23.)")
pixel_y = -23
if(EAST)
if((pixel_y != initial(pixel_x)) && (pixel_x != 24))
log_mapping("APC: ([src]) at [AREACOORD(src)] with dir ([tdir] | [uppertext(dir2text(tdir))]) has pixel_x value ([pixel_x] - should be 24.)")
pixel_x = 24
if(WEST)
if((pixel_y != initial(pixel_x)) && (pixel_x != -25))
log_mapping("APC: ([src]) at [AREACOORD(src)] with dir ([tdir] | [uppertext(dir2text(tdir))]) has pixel_x value ([pixel_x] - should be -25.)")
pixel_x = -25
if (building)
area = get_area(src)
opened = APC_COVER_OPENED
@@ -264,6 +230,26 @@
set_machine_stat(machine_stat | MAINT)
update_appearance()
addtimer(CALLBACK(src, .proc/update), 5)
dir = ndir
// offset APC_PIXEL_OFFSET pixels in direction of dir
// this allows the APC to be embedded in a wall, yet still inside an area
var/offset_old
switch(dir)
if(NORTH)
offset_old = pixel_y
pixel_y = APC_PIXEL_OFFSET
if(SOUTH)
offset_old = pixel_y
pixel_y = -APC_PIXEL_OFFSET
if(EAST)
offset_old = pixel_x
pixel_x = APC_PIXEL_OFFSET
if(WEST)
offset_old = pixel_x
pixel_x = -APC_PIXEL_OFFSET
if(offset_old != APC_PIXEL_OFFSET && !building)
log_mapping("APC: ([src]) at [AREACOORD(src)] with dir ([dir] | [uppertext(dir2text(dir))]) has pixel_[dir & (WEST|EAST) ? "x" : "y"] value [offset_old] - should be [dir & (SOUTH|EAST) ? "-" : ""][APC_PIXEL_OFFSET]. Use the directional/ helpers!")
/obj/machinery/power/apc/Destroy()
GLOB.apcs_list -= src
@@ -297,7 +283,7 @@
// create a terminal object at the same position as original turf loc
// wires will attach to this
terminal = new/obj/machinery/power/terminal(loc)
terminal.setDir(tdir)
terminal.setDir(dir)
terminal.master = src
/obj/machinery/power/apc/Initialize(mapload)
@@ -1599,6 +1585,8 @@
#undef AUTOSET_OFF
#undef AUTOSET_ON
#undef APC_PIXEL_OFFSET
#undef APC_NO_POWER
#undef APC_LOW_POWER
#undef APC_HAS_POWER
@@ -85,236 +85,56 @@
// -------- Directional presets
// The directions are backwards on the lights we have now
/obj/machinery/light/directional/north
dir = NORTH
/obj/machinery/light/directional/south
dir = SOUTH
/obj/machinery/light/directional/east
dir = EAST
/obj/machinery/light/directional/west
dir = WEST
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/light, 0)
// ---- Broken tube
/obj/machinery/light/broken/directional/north
dir = NORTH
/obj/machinery/light/broken/directional/south
dir = SOUTH
/obj/machinery/light/broken/directional/east
dir = EAST
/obj/machinery/light/broken/directional/west
dir = WEST
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/light/broken, 0)
// ---- Tube construct
/obj/structure/light_construct/directional/north
dir = NORTH
/obj/structure/light_construct/directional/south
dir = SOUTH
/obj/structure/light_construct/directional/east
dir = EAST
/obj/structure/light_construct/directional/west
dir = WEST
MAPPING_DIRECTIONAL_HELPERS(/obj/structure/light_construct, 0)
// ---- Tube frames
/obj/machinery/light/built/directional/north
dir = NORTH
/obj/machinery/light/built/directional/south
dir = SOUTH
/obj/machinery/light/built/directional/east
dir = EAST
/obj/machinery/light/built/directional/west
dir = WEST
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/light/built, 0)
// ---- No nightlight tubes
/obj/machinery/light/no_nightlight/directional/north
dir = NORTH
/obj/machinery/light/no_nightlight/directional/south
dir = SOUTH
/obj/machinery/light/no_nightlight/directional/east
dir = EAST
/obj/machinery/light/no_nightlight/directional/west
dir = WEST
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/light/no_nightlight, 0)
// ---- Warm light tubes
/obj/machinery/light/warm/directional/north
dir = NORTH
/obj/machinery/light/warm/directional/south
dir = SOUTH
/obj/machinery/light/warm/directional/east
dir = EAST
/obj/machinery/light/warm/directional/west
dir = WEST
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/light/warm, 0)
// ---- No nightlight warm light tubes
/obj/machinery/light/warm/no_nightlight/directional/north
dir = NORTH
/obj/machinery/light/warm/no_nightlight/directional/south
dir = SOUTH
/obj/machinery/light/warm/no_nightlight/directional/east
dir = EAST
/obj/machinery/light/warm/no_nightlight/directional/west
dir = WEST
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/light/warm/no_nightlight, 0)
// ---- Cold light tubes
/obj/machinery/light/cold/directional/north
dir = NORTH
/obj/machinery/light/cold/directional/south
dir = SOUTH
/obj/machinery/light/cold/directional/east
dir = EAST
/obj/machinery/light/cold/directional/west
dir = WEST
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/light/cold, 0)
// ---- No nightlight cold light tubes
/obj/machinery/light/cold/no_nightlight/directional/north
dir = NORTH
/obj/machinery/light/cold/no_nightlight/directional/south
dir = SOUTH
/obj/machinery/light/cold/no_nightlight/directional/east
dir = EAST
/obj/machinery/light/cold/no_nightlight/directional/west
dir = WEST
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/light/cold/no_nightlight, 0)
// ---- Red tubes
/obj/machinery/light/red/directional/north
dir = NORTH
/obj/machinery/light/red/directional/south
dir = SOUTH
/obj/machinery/light/red/directional/east
dir = EAST
/obj/machinery/light/red/directional/west
dir = WEST
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/light/red, 0)
// ---- Blacklight tubes
/obj/machinery/light/blacklight/directional/north
dir = NORTH
/obj/machinery/light/blacklight/directional/south
dir = SOUTH
/obj/machinery/light/blacklight/directional/east
dir = EAST
/obj/machinery/light/blacklight/directional/west
dir = WEST
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/light/blacklight, 0)
// ---- Dim tubes
/obj/machinery/light/dim/directional/north
dir = NORTH
/obj/machinery/light/dim/directional/south
dir = SOUTH
/obj/machinery/light/dim/directional/east
dir = EAST
/obj/machinery/light/dim/directional/west
dir = WEST
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/light/dim, 0)
// -------- Bulb lights
/obj/machinery/light/small/directional/north
dir = NORTH
/obj/machinery/light/small/directional/south
dir = SOUTH
/obj/machinery/light/small/directional/east
dir = EAST
/obj/machinery/light/small/directional/west
dir = WEST
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/light/small, 0)
// ---- Bulb construct
/obj/structure/light_construct/small/directional/north
dir = NORTH
/obj/structure/light_construct/small/directional/south
dir = SOUTH
/obj/structure/light_construct/small/directional/east
dir = EAST
/obj/structure/light_construct/small/directional/west
dir = WEST
MAPPING_DIRECTIONAL_HELPERS(/obj/structure/light_construct/small, 0)
// ---- Bulb frames
/obj/machinery/light/small/built/directional/north
dir = NORTH
/obj/machinery/light/small/built/directional/south
dir = SOUTH
/obj/machinery/light/small/built/directional/east
dir = EAST
/obj/machinery/light/small/built/directional/west
dir = WEST
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/light/small/built, 0)
// ---- Broken bulbs
/obj/machinery/light/small/broken/directional/north
dir = NORTH
/obj/machinery/light/small/broken/directional/south
dir = SOUTH
/obj/machinery/light/small/broken/directional/east
dir = EAST
/obj/machinery/light/small/broken/directional/west
dir = WEST
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/light/small/broken, 0)
// ---- Red bulbs
/obj/machinery/light/small/red/directional/north
dir = NORTH
/obj/machinery/light/small/red/directional/south
dir = SOUTH
/obj/machinery/light/small/red/directional/east
dir = EAST
/obj/machinery/light/small/red/directional/west
dir = WEST
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/light/small/red, 0)
// ---- Blacklight bulbs
/obj/machinery/light/small/blacklight/directional/north
dir = NORTH
/obj/machinery/light/small/blacklight/directional/south
dir = SOUTH
/obj/machinery/light/small/blacklight/directional/east
dir = EAST
/obj/machinery/light/small/blacklight/directional/west
dir = WEST
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/light/small/blacklight, 0)
@@ -4,7 +4,7 @@
icon = 'icons/obj/lighting.dmi'
icon_state = "tube-construct-item"
result_path = /obj/structure/light_construct
inverse = TRUE
wall_external = TRUE
/obj/item/wallframe/light_fixture/small
name = "small light fixture frame"
+2 -30
View File
@@ -161,21 +161,7 @@
density = FALSE
reagent_id = /datum/reagent/consumable/condensedcapsaicin
/obj/structure/reagent_dispensers/peppertank/directional/north
dir = SOUTH
pixel_y = 30
/obj/structure/reagent_dispensers/peppertank/directional/south
dir = NORTH
pixel_y = -30
/obj/structure/reagent_dispensers/peppertank/directional/east
dir = WEST
pixel_x = 30
/obj/structure/reagent_dispensers/peppertank/directional/west
dir = EAST
pixel_x = -30
MAPPING_DIRECTIONAL_HELPERS(/obj/structure/reagent_dispensers/peppertank, 30)
/obj/structure/reagent_dispensers/peppertank/Initialize(mapload)
. = ..()
@@ -232,21 +218,7 @@
density = FALSE
reagent_id = /datum/reagent/consumable/virus_food
/obj/structure/reagent_dispensers/virusfood/directional/north
dir = SOUTH
pixel_y = 30
/obj/structure/reagent_dispensers/virusfood/directional/south
dir = NORTH
pixel_y = -30
/obj/structure/reagent_dispensers/virusfood/directional/east
dir = WEST
pixel_x = 30
/obj/structure/reagent_dispensers/virusfood/directional/west
dir = EAST
pixel_x = -30
MAPPING_DIRECTIONAL_HELPERS(/obj/structure/reagent_dispensers/virusfood, 30)
/obj/structure/reagent_dispensers/cooking_oil
name = "vat of cooking oil"
@@ -22,21 +22,7 @@ GLOBAL_DATUM_INIT(keycard_events, /datum/events, new)
var/mob/triggerer = null
var/waiting = FALSE
/obj/machinery/keycard_auth/directional/north
dir = SOUTH
pixel_y = 26
/obj/machinery/keycard_auth/directional/south
dir = NORTH
pixel_y = -26
/obj/machinery/keycard_auth/directional/east
dir = WEST
pixel_x = 26
/obj/machinery/keycard_auth/directional/west
dir = EAST
pixel_x = -26
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/keycard_auth, 26)
/obj/machinery/keycard_auth/Initialize(mapload)
. = ..()
+1 -15
View File
@@ -28,21 +28,7 @@
tiltable = FALSE
light_mask = "wallmed-light-mask"
/obj/machinery/vending/wallmed/directional/north
dir = SOUTH
pixel_y = 32
/obj/machinery/vending/wallmed/directional/south
dir = NORTH
pixel_y = -32
/obj/machinery/vending/wallmed/directional/east
dir = WEST
pixel_x = 32
/obj/machinery/vending/wallmed/directional/west
dir = EAST
pixel_x = -32
MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/vending/wallmed, 32)
/obj/item/vending_refill/wallmed
machine_name = "NanoMed"