Skip to content

Commit

Permalink
Fixes for Computer Smoothing (#10015)
Browse files Browse the repository at this point in the history
* Now adds SMOOTH_BITMASK_SKIP_CORNERS

* Do NOT smooth, Do NOT pass go...

* Revert Modular Console Smoothing

* That is slightly annoying

* Modular Console Icon Reverted

* No smoothing for these (again, this time clearing base_icon_state)

* Ratvar and Narsie handling + less flakey conditionals

* Icon: Broken Computer Smoothing

* Better smoothing logic

* Ratvar act still didn't work right... gaaaah...

* Normalize this so it's not out of place

* Return of Modular Console Smoothing

* Tidying up the logic...

* "BSA has been unlo- where's the BSA console?"
  • Loading branch information
HowToLoLu authored Oct 16, 2023
1 parent b062d29 commit ddf29d0
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 32 deletions.
6 changes: 4 additions & 2 deletions code/__DEFINES/icon_smoothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#define SMOOTH_OBJ (1<<5)
/// Smooths with atoms facing the same direction only
#define SMOOTH_DIRECTIONAL (1<<6)
/// Skips the corner step of bitmask smoothing (does nothing without SMOOTH_BITMASK)
#define SMOOTH_BITMASK_SKIP_CORNERS (1<<7)

DEFINE_BITFIELD(smoothing_flags, list(
"SMOOTH_CORNERS" = SMOOTH_CORNERS,
Expand All @@ -22,6 +24,7 @@ DEFINE_BITFIELD(smoothing_flags, list(
"SMOOTH_QUEUED" = SMOOTH_QUEUED,
"SMOOTH_OBJ" = SMOOTH_OBJ,
"SMOOTH_DIRECTIONAL" = SMOOTH_DIRECTIONAL,
"SMOOTH_BITMASK_SKIP_CORNERS" = SMOOTH_BITMASK_SKIP_CORNERS,
))


Expand Down Expand Up @@ -116,8 +119,7 @@ DEFINE_BITFIELD(smoothing_flags, list(
#define SMOOTH_GROUP_HEDGE_FLUFF S_OBJ(65) ///obj/structure/fluff/hedge
#define SMOOTH_GROUP_SHUTTLE_PARTS S_OBJ(66) ///obj/structure/window/shuttle, /obj/structure/window/plasma/reinforced/plastitanium, /turf/closed/indestructible/opsglass, /obj/structure/shuttle
#define SMOOTH_GROUP_CLEANABLE_DIRT S_OBJ(67) ///obj/effect/decal/cleanable/dirt
///obj/machinery/computer/_computer
#define SMOOTH_GROUP_COMPUTERS S_OBJ (68)
#define SMOOTH_GROUP_COMPUTERS S_OBJ(68) ///obj/machinery/computer/_computer

//LIQUIDS

Expand Down
3 changes: 2 additions & 1 deletion code/__HELPERS/icon_smoothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ DEFINE_BITFIELD(smoothing_junction, list(
var/smooth_border = (smoothing_flags & SMOOTH_BORDER)
var/smooth_obj = (smoothing_flags & SMOOTH_OBJ)
var/smooth_directional = (smoothing_flags & SMOOTH_DIRECTIONAL)
var/skip_corners = (smoothing_flags & SMOOTH_BITMASK_SKIP_CORNERS)

#define EXTRA_CHECKS(atom) \
if(smooth_directional) { \
Expand Down Expand Up @@ -334,7 +335,7 @@ DEFINE_BITFIELD(smoothing_junction, list(
for(var/direction in GLOB.cardinals) //Cardinal case first.
SET_ADJ_IN_DIR(direction, direction)

if(!(new_junction & (NORTH|SOUTH)) || !(new_junction & (EAST|WEST)))
if(skip_corners || !(new_junction & (NORTH|SOUTH)) || !(new_junction & (EAST|WEST)))
set_smoothed_icon_state(new_junction)
return

Expand Down
4 changes: 4 additions & 0 deletions code/game/machinery/bank_machine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
desc = "A machine used to deposit and withdraw station funds."
icon = 'goon/icons/obj/goon_terminals.dmi'
idle_power_usage = 100
base_icon_state = null // remove these 4 when we start using our own icon.
smoothing_flags = NONE
smoothing_groups = null
canSmoothWith = null
var/siphoning = FALSE
var/next_warning = 0
var/obj/item/radio/radio
Expand Down
20 changes: 15 additions & 5 deletions code/game/machinery/computer/_computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
icon = 'icons/obj/computer.dmi'
icon_state = "computer-0"
base_icon_state = "computer"
smoothing_flags = SMOOTH_BITMASK | SMOOTH_DIRECTIONAL
smoothing_flags = SMOOTH_BITMASK | SMOOTH_DIRECTIONAL | SMOOTH_BITMASK_SKIP_CORNERS | SMOOTH_OBJ //SMOOTH_OBJ is needed because of narsie_act using initial() to restore
smoothing_groups = list(SMOOTH_GROUP_COMPUTERS)
canSmoothWith = list(SMOOTH_GROUP_COMPUTERS)
density = TRUE
Expand All @@ -30,9 +30,8 @@

/obj/machinery/computer/Initialize(mapload, obj/item/circuitboard/C)
. = ..()
if(smoothing_flags & SMOOTH_BITMASK)
QUEUE_SMOOTH(src)
QUEUE_SMOOTH_NEIGHBORS(src)
QUEUE_SMOOTH(src)
QUEUE_SMOOTH_NEIGHBORS(src)
power_change()
if(!QDELETED(C))
qdel(circuit)
Expand All @@ -41,6 +40,7 @@

/obj/machinery/computer/Destroy()
QDEL_NULL(circuit)
QUEUE_SMOOTH_NEIGHBORS(src)
return ..()

/obj/machinery/computer/process()
Expand All @@ -55,15 +55,25 @@
icon_keyboard = "ratvar_key[rand(1, 2)]"
icon_state = "ratvarcomputer"
broken_overlay_emissive = TRUE
smoothing_groups = null
QUEUE_SMOOTH_NEIGHBORS(src)
smoothing_flags = NONE
update_appearance()

/obj/machinery/computer/narsie_act()
if(clockwork && clockwork != initial(clockwork)) //if it's clockwork but isn't normally clockwork
clockwork = FALSE
icon_screen = initial(icon_screen)
icon_keyboard = initial(icon_keyboard)
icon_state = initial(icon_state)
broken_overlay_emissive = initial(broken_overlay_emissive)
smoothing_flags = initial(smoothing_flags)
smoothing_groups = list(SMOOTH_GROUP_COMPUTERS)
canSmoothWith = list(SMOOTH_GROUP_COMPUTERS)
SET_BITFLAG_LIST(smoothing_groups)
SET_BITFLAG_LIST(canSmoothWith)
QUEUE_SMOOTH(src)
if(smoothing_flags)
QUEUE_SMOOTH_NEIGHBORS(src)
update_appearance()

/obj/machinery/computer/update_overlays()
Expand Down
4 changes: 4 additions & 0 deletions code/modules/antagonists/abductor/machinery/camera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

icon = 'icons/obj/abductor.dmi'
icon_state = "camera"
base_icon_state = null
smoothing_flags = NONE
smoothing_groups = null
canSmoothWith = null
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | ACID_PROOF

reveal_camera_mob = TRUE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
icon_screen = "ratvar1"
icon_keyboard = "ratvar_key1"
icon_state = "ratvarcomputer"
base_icon_state = null
smoothing_flags = NONE
smoothing_groups = null
canSmoothWith = null
clockwork = TRUE
lock_override = CAMERA_LOCK_STATION
broken_overlay_emissive = TRUE
Expand Down
4 changes: 4 additions & 0 deletions code/modules/mining/aux_base.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
name = "auxillary base management console"
icon = 'icons/obj/terminals.dmi'
icon_state = "dorm_available"
base_icon_state = null
smoothing_flags = NONE
smoothing_groups = null
canSmoothWith = null
var/shuttleId = "colony_drop"
desc = "Allows a deployable expedition base to be dropped from the station to a designated mining location. It can also \
interface with the mining shuttle at the landing site if a mobile beacon is also deployed."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
/obj/machinery/modular_computer/console
name = "console"
desc = "A stationary computer."

icon = 'icons/obj/modular_console.dmi'
icon_state = "console-0"
screen_icon_state_menu = "menu"
base_icon_state = "console"
smoothing_flags = SMOOTH_BITMASK | SMOOTH_DIRECTIONAL
smoothing_flags = SMOOTH_BITMASK | SMOOTH_DIRECTIONAL | SMOOTH_BITMASK_SKIP_CORNERS
smoothing_groups = list(SMOOTH_GROUP_COMPUTERS)
canSmoothWith = list(SMOOTH_GROUP_COMPUTERS)
icon_state_powered = "console"
icon_state_unpowered = "console" //These are the same because the base modifies the icon, which messes with smoothing
screen_icon_state_menu = "menu"
hardware_flag = PROGRAM_CONSOLE
density = TRUE
base_idle_power_usage = 100
Expand All @@ -31,10 +34,8 @@

/obj/machinery/modular_computer/console/Initialize(mapload)
. = ..()
if(smoothing_flags & SMOOTH_BITMASK)
QUEUE_SMOOTH(src)
QUEUE_SMOOTH_NEIGHBORS(src)

QUEUE_SMOOTH(src)
QUEUE_SMOOTH_NEIGHBORS(src)
var/obj/item/computer_hardware/battery/battery_module = cpu.all_components[MC_CELL]
if(battery_module)
qdel(battery_module)
Expand All @@ -59,20 +60,19 @@
cpu.screen_on = 1
update_icon()

// Same as parent code, but without the smoothing handling
/obj/machinery/modular_computer/update_icon()
cut_overlays()
/obj/machinery/modular_computer/console/Destroy()
QUEUE_SMOOTH_NEIGHBORS(src)
. = ..()

if(!cpu || !cpu.enabled)
if (!(machine_stat & NOPOWER) && (cpu && cpu.use_power()))
add_overlay(screen_icon_screensaver)
else
if(cpu.active_program)
add_overlay(cpu.active_program.program_icon_state ? cpu.active_program.program_icon_state : screen_icon_state_menu)
else
add_overlay(screen_icon_state_menu)
/obj/machinery/modular_computer/console/update_icon()
. = ..()

var/keyboard = "keyboard"
if ((machine_stat & NOPOWER) || !(cpu?.use_power()))
keyboard = "keyboard_off"
add_overlay(keyboard)

if(cpu && cpu.obj_integrity <= cpu.integrity_failure)
add_overlay("bsod")
add_overlay("broken")
icon_state = "[icon_state]-[smoothing_junction]"

if(machine_stat & BROKEN)
add_overlay("broken-[smoothing_junction]")
8 changes: 4 additions & 4 deletions code/modules/power/solar.dm
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
icon = 'icons/obj/computer.dmi'
icon_state = "computer-0"
base_icon_state = "computer"
smoothing_flags = SMOOTH_BITMASK | SMOOTH_DIRECTIONAL
smoothing_flags = SMOOTH_BITMASK | SMOOTH_DIRECTIONAL | SMOOTH_BITMASK_SKIP_CORNERS
smoothing_groups = list(SMOOTH_GROUP_COMPUTERS)
canSmoothWith = list(SMOOTH_GROUP_COMPUTERS)
density = TRUE
Expand All @@ -282,9 +282,8 @@

/obj/machinery/power/solar_control/Initialize(mapload)
. = ..()
if(smoothing_flags & SMOOTH_BITMASK)
QUEUE_SMOOTH(src)
QUEUE_SMOOTH_NEIGHBORS(src)
QUEUE_SMOOTH(src)
QUEUE_SMOOTH_NEIGHBORS(src)
if(powernet)
set_panels(currentdir)
connect_to_network()
Expand All @@ -294,6 +293,7 @@
M.unset_control()
if(connected_tracker)
connected_tracker.unset_control()
QUEUE_SMOOTH_NEIGHBORS(src)
return ..()

/obj/machinery/power/solar_control/disconnect_from_network()
Expand Down
4 changes: 4 additions & 0 deletions code/modules/station_goals/bsa.dm
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ DEFINE_BUFFER_HANDLER(/obj/machinery/bsa/middle)
circuit = /obj/item/circuitboard/computer/bsa_control
icon = 'icons/obj/machines/particle_accelerator.dmi'
icon_state = "control_boxp"
base_icon_state = null
smoothing_flags = NONE
smoothing_groups = null
canSmoothWith = null



Expand Down
Binary file modified icons/obj/computer.dmi
Binary file not shown.
Binary file modified icons/obj/modular_console.dmi
Binary file not shown.

0 comments on commit ddf29d0

Please sign in to comment.