Skip to content

Commit

Permalink
Startwork on fixing programatic issues with wallmount and directional…
Browse files Browse the repository at this point in the history
… mapping objects (#325)

This attempts to fix the various issues with sinks, APCs, and various other wallmounts in-game that are running into mapping issues.

I've got APCs working properly from their own subtype of the macro, but at the second I'm still breaking down where things are falling apart on the other subtypes to get those fixed.

Taking #285 up alongside #248 and #313 as part of a wallmount combined fix atm, there's a few causes for this but it seems to primarily be a combination of wall-mounted objects using the older system of offsets and directions, some things have additional offsets in initialize, and misuse of the existing wallmount macros combined with MAP_SWITCH() causing some things to appear the opposite of how they should in-game.

At this current point, this will not fix everything, but will be a substantial improvement to much of it
  • Loading branch information
ArcaneMusic authored Aug 12, 2024
1 parent 1cb44ac commit bc168e7
Show file tree
Hide file tree
Showing 13 changed files with 258 additions and 207 deletions.
268 changes: 183 additions & 85 deletions _maps/map_files/debug/runtimestation.dmm

Large diffs are not rendered by default.

77 changes: 63 additions & 14 deletions code/__DEFINES/directional.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,33 @@
/// Inverse direction, taking into account UP|DOWN if necessary.
#define REVERSE_DIR(dir) ( ((dir & 85) << 1) | ((dir & 170) >> 1) )

#define _WALL_MOUNT_OFFSET(path, north_offset, south_offset, physical_south_offset, east_offset, west_offset, horizontal_up_offset) \
##path/wall_mount_offset(direction) { \
pixel_x = 0; \
pixel_z = 0; \
pixel_y = 0; \
switch(direction) { \
if(NORTH) { \
pixel_z = north_offset; \
} \
if(SOUTH) { \
pixel_z = south_offset; \
pixel_y = physical_south_offset; \
} \
if(EAST) { \
pixel_x = east_offset; \
pixel_z = horizontal_up_offset; \
} \
if(WEST) { \
pixel_x = west_offset; \
pixel_z = horizontal_up_offset; \
} \
} \
}

#define _INVERTED_WALL_MOUNT_OFFSET(path, north_offset, physical_north_offset, south_offset, east_offset, west_offset, horizontal_up_offset) \
_WALL_MOUNT_OFFSET(path, south_offset, north_offset, physical_north_offset, west_offset, east_offset, horizontal_up_offset)

// Wallening todo: temporary helper, until we finish fleshing things out and can convert the main one
// Why are we not just changing the sprites agian?
#define INVERT_MAPPING_DIRECTIONAL_HELPERS(path, offset) \
Expand All @@ -46,24 +73,21 @@
##path/directional/west {\
dir = EAST; \
pixel_x = -offset; \
}
} \
_INVERTED_WALL_MOUNT_OFFSET(path, offset, 0, -offset, offset, -offset, 0)

/// Directional helpers for things that use the wall_mount element
#define WALL_MOUNT_DIRECTIONAL_HELPERS(path) _WALL_MOUNT_DIRECTIONAL_HELPERS(path, 35, -8, 11, -11, 16)
#define WALL_MOUNT_DIRECTIONAL_HELPERS(path) _WALL_MOUNT_DIRECTIONAL_HELPERS(path, 35, 0, -8, 11, -11, 16)

#define SHOWER_DIRECTIONAL_HELPERS(path) _WALL_MOUNT_DIRECTIONAL_HELPERS(path, 32, -4, 16, -16, 12)
#define SHOWER_DIRECTIONAL_HELPERS(path) _WALL_MOUNT_DIRECTIONAL_HELPERS(path, 32, 0, -4, 16, -16, 12)

// Sinks need to be shifted down so they layer correctly when north due to their unique status
#define SINK_DIRECTIONAL_HELPERS(path) \
_WALL_MOUNT_DIRECTIONAL_HELPERS(path, 16, 24, 16, -16, 12) \
##path/directional/north {\
pixel_y = -32; \
}
#define SINK_DIRECTIONAL_HELPERS(path) _WALL_MOUNT_DIRECTIONAL_HELPERS(path, 24, -32, 24, 16, -16, 12)

#define _WALL_MOUNT_DIRECTIONAL_HELPERS(path, north_offset, south_offset, east_offset, west_offset, horizontal_up_offset) \
#define _WALL_MOUNT_DIRECTIONAL_HELPERS(path, north_offset, physical_north_offset, south_offset, east_offset, west_offset, horizontal_up_offset) \
##path/directional/north {\
dir = SOUTH; \
MAP_SWITCH(pixel_z, pixel_y) = north_offset; \
MAP_SWITCH(pixel_z, pixel_y) = north_offset + physical_north_offset; \
} \
##path/directional/south {\
dir = NORTH; \
Expand All @@ -78,7 +102,8 @@ _WALL_MOUNT_DIRECTIONAL_HELPERS(path, 16, 24, 16, -16, 12) \
dir = EAST; \
pixel_x = west_offset; \
MAP_SWITCH(pixel_z, pixel_y) = horizontal_up_offset; \
}
} \
_INVERTED_WALL_MOUNT_OFFSET(path, north_offset, physical_north_offset, south_offset, east_offset, west_offset, horizontal_up_offset)

/// Directional helpers for cameras (cameras are really annoying)
/// They have diagonal dirs and also offset south differently
Expand Down Expand Up @@ -118,9 +143,31 @@ _WALL_MOUNT_DIRECTIONAL_HELPERS(path, 16, 24, 16, -16, 12) \
dir = SOUTHEAST; \
pixel_x = -11; \
MAP_SWITCH(pixel_z, pixel_y) = 16; \
} \
##path/wall_mount_offset(direction) { \
/* Exists because cameras have more then the normal dir count so we're doin this manually */ \
/* Fit the usual offsets except SOUTH is different, because cameras want to jut out from the wall */ \
/* Also cameras have weird offsets because lmao camera sprites dies */ \
pixel_x = 0; \
pixel_z = 0; \
switch(direction) { \
if(NORTH, NORTHWEST) { \
pixel_z = 16; \
} \
if(SOUTH, NORTHEAST) { \
pixel_z = 35; \
} \
if(EAST, SOUTHEAST) { \
pixel_x = -11; \
pixel_z = 16; \
} \
if(WEST, SOUTHWEST) { \
pixel_x = 11; \
pixel_z = 16; \
} \
} \
}


/// Create directional subtypes for a path to simplify mapping.

#define MAPPING_DIRECTIONAL_HELPERS(path, offset) \
Expand All @@ -139,7 +186,8 @@ _WALL_MOUNT_DIRECTIONAL_HELPERS(path, 16, 24, 16, -16, 12) \
##path/directional/west {\
dir = WEST; \
pixel_x = -offset; \
}
} \
_WALL_MOUNT_OFFSET(path, offset, 0, -offset, offset, -offset, 0)

#define MAPPING_DIRECTIONAL_HELPERS_EMPTY(path) \
##path/directional/north {\
Expand All @@ -153,7 +201,8 @@ _WALL_MOUNT_DIRECTIONAL_HELPERS(path, 16, 24, 16, -16, 12) \
} \
##path/directional/west {\
dir = WEST; \
}
} \
_WALL_MOUNT_OFFSET(path, 0, 0, 0, 0, 0, 0)

#define BUTTON_DIRECTIONAL_HELPERS(path) \
##path/table { \
Expand Down
17 changes: 2 additions & 15 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1733,22 +1733,9 @@
/// Offsets this movable based on dir (in context of wallmounts)
/// Yes yes mothblocks I know this is not modular but I don't want to make the element bespoke
/// Insert ranting about element key generation here
/// This proc is filled in by the directional macros, should not need to manually touch it unless something is wrong
/atom/movable/proc/wall_mount_offset(direction)
//These magic offsets are chosen for no particular reason
//The wall mount template is made to work with them
pixel_x = 0
pixel_z = 0
switch(direction)
if(NORTH)
pixel_z = -8
if(SOUTH)
pixel_z = 35
if(EAST)
pixel_x = -11
pixel_z = 16
if(WEST)
pixel_x = 11
pixel_z = 16
return

/// Returns true if we should layer in common with the general game
/// If false, render over the frill plane insted
Expand Down
9 changes: 0 additions & 9 deletions code/game/machinery/barsigns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,6 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/barsign, 32)
/obj/machinery/barsign/wall_mount_common_plane(direction)
return TRUE

/obj/machinery/barsign/wall_mount_offset(direction)
pixel_x = 0
pixel_z = 0
switch(direction)
if(NORTH)
pixel_z = 32
if(SOUTH)
pixel_z = -32

/obj/machinery/barsign/update_icon_state()
if(!(machine_stat & BROKEN) && (!(machine_stat & NOPOWER) || machine_stat & EMPED) && chosen_sign && chosen_sign.icon_state)
icon_state = chosen_sign.icon_state
Expand Down
17 changes: 0 additions & 17 deletions code/game/machinery/camera/camera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -338,23 +338,6 @@ CAMERA_DIRECTIONAL_HELPERS(/obj/machinery/camera/xray)
icon_state = "[xray_module][base_icon_state][in_use_lights ? "_in_use" : ""]"
return ..()

/obj/machinery/camera/wall_mount_offset(direction)
// Fit the usual offsets except SOUTH is different, because cameras want to jut out from the wall
// Also cameras have weird offsets because lmao camera sprites dies
pixel_x = 0
pixel_z = 0
switch(direction)
if(NORTH, NORTHWEST)
pixel_z = 16
if(SOUTH, NORTHEAST)
pixel_z = 35
if(EAST, SOUTHEAST)
pixel_x = -11
pixel_z = 16
if(WEST, SOUTHWEST)
pixel_x = 11
pixel_z = 16

/obj/machinery/camera/wall_mount_common_plane(direction)
if(direction == SOUTH || direction == NORTHEAST)
return TRUE
Expand Down
4 changes: 4 additions & 0 deletions code/game/machinery/status_display.dm
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,8 @@ WALL_MOUNT_DIRECTIONAL_HELPERS(/obj/machinery/status_display/evac)
text_color = COLOR_DISPLAY_ORANGE
header_text_color = COLOR_DISPLAY_YELLOW

WALL_MOUNT_DIRECTIONAL_HELPERS(/obj/machinery/status_display/supply)

/obj/machinery/status_display/supply/process()
if(machine_stat & NOPOWER)
// No power, no processing.
Expand Down Expand Up @@ -579,6 +581,8 @@ WALL_MOUNT_DIRECTIONAL_HELPERS(/obj/machinery/status_display/evac)
text_color = COLOR_DISPLAY_GREEN
header_text_color = COLOR_DISPLAY_CYAN

WALL_MOUNT_DIRECTIONAL_HELPERS(/obj/machinery/status_display/shuttle)

/obj/machinery/status_display/shuttle/process()
if(!shuttle_id || (machine_stat & NOPOWER))
// No power, no processing.
Expand Down
16 changes: 0 additions & 16 deletions code/game/objects/structures/shower.dm
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,6 @@ SHOWER_DIRECTIONAL_HELPERS(/obj/machinery/shower)
. += span_notice("The auto shut-off is programmed to [GLOB.shower_mode_descriptions["[mode]"]].")
. += span_notice("[reagents.total_volume]/[reagents.maximum_volume] liquids remaining.")

/obj/machinery/shower/wall_mount_offset(direction)
pixel_x = 0
pixel_z = 0
pixel_y = 0
switch(direction)
if(NORTH)
pixel_z = 32
if(SOUTH)
pixel_z = -4
if(EAST)
pixel_x = 16
pixel_z = 12
if(WEST)
pixel_x = -16
pixel_z = 12

/obj/machinery/shower/Destroy()
QDEL_NULL(soundloop)
QDEL_NULL(reagents)
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/structures/signs/signs_interactive.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
desc = "It's your run-of-the-mill wall clock showing both the local Coalition Standard Time and the galactic Treaty Coordinated Time. Perfect for staring at instead of working."
icon_state = "clock"

MAPPING_DIRECTIONAL_HELPERS(/obj/structure/sign/clock, 32)
_WALL_MOUNT_DIRECTIONAL_HELPERS(/obj/structure/sign/clock, 35, 0, -8, 24, -24, 16)

/obj/structure/sign/clock/examine(mob/user)
. = ..()
Expand All @@ -15,7 +15,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/sign/clock, 32)
desc = "It's an old-school wall calendar. Sure, it might be obsolete with modern technology, but it's still hard to imagine an office without one."
icon_state = "calendar"

MAPPING_DIRECTIONAL_HELPERS(/obj/structure/sign/calendar, 32)
_WALL_MOUNT_DIRECTIONAL_HELPERS(/obj/structure/sign/calendar, 35, 0, -8, 24, -24, 16)

/obj/structure/sign/calendar/examine(mob/user)
. = ..()
Expand Down
18 changes: 0 additions & 18 deletions code/game/objects/structures/water_structures/sink.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,6 @@ SINK_DIRECTIONAL_HELPERS(/obj/structure/sink)
/obj/structure/sink/wall_mount_common_plane(direction)
return TRUE

/obj/structure/sink/wall_mount_offset(direction)
pixel_x = 0
pixel_z = 0
pixel_y = 0
switch(direction)
if(NORTH)
pixel_z = 16
if(SOUTH)
pixel_z = 24
// shift down so we layer correctly
pixel_y = -32
if(EAST)
pixel_x = 16
pixel_z = 12
if(WEST)
pixel_x = -16
pixel_z = 12

/obj/structure/sink/attack_hand(mob/living/user, list/modifiers)
. = ..()
if(.)
Expand Down
16 changes: 2 additions & 14 deletions code/modules/power/apc/apc_main.dm
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,7 @@
SSmachines.processing_apcs += src

//Pixel offset its appearance based on its direction
dir = ndir
switch(dir)
if(NORTH)
offset_old = pixel_z
pixel_z = APC_PIXEL_OFFSET
if(SOUTH)
offset_old = pixel_z
pixel_z = -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
setDir(ndir)

hud_list = list(
MALF_APC_HUD = image(icon = 'icons/mob/huds/hud.dmi', icon_state = "apc_hacked", pixel_x = src.pixel_x, pixel_y = src.pixel_y)
Expand Down Expand Up @@ -272,6 +259,7 @@
if(auto_name)
name = "\improper [get_area_name(area, TRUE)] APC"


/obj/machinery/power/apc/proc/assign_to_area(area/target_area = get_area(src))
if(area == target_area)
return
Expand Down
2 changes: 1 addition & 1 deletion code/modules/power/apc/apc_mapping.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/obj/machinery/power/apc/auto_name
auto_name = TRUE

#define APC_DIRECTIONAL_HELPERS(path) _WALL_MOUNT_DIRECTIONAL_HELPERS(path, -APC_PIXEL_OFFSET, APC_PIXEL_OFFSET, -APC_PIXEL_OFFSET, APC_PIXEL_OFFSET, 16)
#define APC_DIRECTIONAL_HELPERS(path) _WALL_MOUNT_DIRECTIONAL_HELPERS(path, 35, 0, -8, 11, -11, 16)

APC_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/worn_out)
APC_DIRECTIONAL_HELPERS(/obj/machinery/power/apc/auto_name)
Expand Down
17 changes: 1 addition & 16 deletions code/modules/security_levels/keycard_authentication.dm
Original file line number Diff line number Diff line change
Expand Up @@ -159,27 +159,12 @@ GLOBAL_DATUM_INIT(keycard_events, /datum/events, new)
/obj/machinery/keycard_auth/wall_mounted
icon = 'icons/obj/machines/keycard.dmi'

_WALL_MOUNT_DIRECTIONAL_HELPERS(/obj/machinery/keycard_auth/wall_mounted, 34, 2, 12, -14, 16)
_WALL_MOUNT_DIRECTIONAL_HELPERS(/obj/machinery/keycard_auth/wall_mounted, 34, 0, 2, 12, -14, 16)

/obj/machinery/keycard_auth/wall_mounted/Initialize(mapload)
. = ..()
find_and_hang_on_wall()

/obj/machinery/keycard_auth/wall_mounted/wall_mount_offset(newdir)
pixel_x = 0
pixel_z = 0
switch(newdir)
if(NORTH)
pixel_z = 2
if(SOUTH)
pixel_z = 34
if(EAST)
pixel_x = -14
pixel_z = 16
if(WEST)
pixel_x = 12
pixel_z = 16

GLOBAL_VAR_INIT(emergency_access, FALSE)
/proc/make_maint_all_access()
for(var/area/station/maintenance/area in GLOB.areas)
Expand Down
Binary file modified icons/obj/watercloset.dmi
Binary file not shown.

0 comments on commit bc168e7

Please sign in to comment.